@webitel/ui-sdk 2.1.14 → 2.1.16

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": "2.1.14",
3
+ "version": "2.1.16",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -26,6 +26,7 @@
26
26
  "CHANGELOG.md"
27
27
  ],
28
28
  "dependencies": {
29
+ "clipboard-copy": "^4.0.1",
29
30
  "core-js": "^3.6.5",
30
31
  "csv-stringify": "^5.5.3",
31
32
  "deep-copy": "^1.4.2",
@@ -33,6 +33,7 @@ import WtTimepicker from './molecules/wt-timepicker/wt-timepicker.vue';
33
33
  import WtLabel from './molecules/wt-label/wt-label.vue';
34
34
  import WtButtonSelect from './molecules/wt-button-select/wt-button-select.vue';
35
35
  import WtHint from './molecules/wt-hint/wt-hint.vue';
36
+ import WtCopyAction from './molecules/wt-copy-action/wt-copy-action.vue';
36
37
 
37
38
  import WtAppHeader from './organisms/wt-app-header/wt-app-header.vue';
38
39
  import WtAppNavigator from './organisms/wt-app-header/wt-app-navigator.vue';
@@ -101,6 +102,7 @@ const Components = {
101
102
  WtTableColumnSelect,
102
103
  WtButtonSelect,
103
104
  WtContextMenu,
105
+ WtCopyAction,
104
106
  };
105
107
 
106
108
  Object.keys(Components).forEach((name) => {
@@ -0,0 +1,14 @@
1
+ import { shallowMount } from '@vue/test-utils';
2
+ import WtIconBtn from '../../wt-icon-btn/wt-icon-btn.vue';
3
+ import WtCopyAction from '../wt-copy-action.vue';
4
+
5
+ describe('WtCopyAction', () => {
6
+ it('renders a component', () => {
7
+ const wrapper = shallowMount(WtCopyAction, {
8
+ stubs: {
9
+ WtIconBtn,
10
+ },
11
+ });
12
+ expect(wrapper.classes('wt-copy-action')).toBe(true);
13
+ });
14
+ });
@@ -0,0 +1,63 @@
1
+ <template>
2
+ <wt-tooltip class="wt-copy-action">
3
+ <template v-slot:activator>
4
+ <wt-icon-btn
5
+ v-bind="$attrs"
6
+ :icon="copied ? 'done' : 'copy'"
7
+ class="copy-action"
8
+ @click="copy"
9
+ ></wt-icon-btn>
10
+ </template>
11
+ {{ copied ? copiedTooltip : copyTooltip }}
12
+ </wt-tooltip>
13
+ </template>
14
+
15
+ <script>
16
+ import copy from 'clipboard-copy';
17
+
18
+ let copiedIdTimeout = null;
19
+
20
+ export default {
21
+ name: 'wt-copy-action',
22
+ data: () => ({
23
+ copied: false,
24
+ }),
25
+ props: {
26
+ value: {
27
+ type: String,
28
+ },
29
+ tooltips: {
30
+ type: Object,
31
+ default: () => ({
32
+ copy: '',
33
+ copied: '',
34
+ }),
35
+ },
36
+ },
37
+ computed: {
38
+ copyTooltip() {
39
+ return this.tooltips.copy || this.$t('webitelUI.copyAction.copy');
40
+ },
41
+ copiedTooltip() {
42
+ return this.tooltips.copied || this.$t('webitelUI.copyAction.copied');
43
+ },
44
+ },
45
+ methods: {
46
+ async copy() {
47
+ try {
48
+ await copy(this.value);
49
+ this.copied = this.value;
50
+ if (copiedIdTimeout) window.clearTimeout(copiedIdTimeout);
51
+ copiedIdTimeout = setTimeout(() => {
52
+ this.copied = null;
53
+ }, 1500);
54
+ } catch (err) {
55
+ throw err;
56
+ }
57
+ },
58
+ },
59
+ };
60
+ </script>
61
+
62
+ <style lang="scss" scoped>
63
+ </style>
@@ -23,7 +23,7 @@
23
23
  :close-on-select="false"
24
24
  :disabled="disabled"
25
25
  :internal-search="!searchMethod"
26
- :label="trackBy ? optionLabel : null"
26
+ :label="trackBy ? (optionLabel || trackBy) : null"
27
27
  :loading="false"
28
28
  :options="selectOptions"
29
29
  :placeholder="placeholder || label"
@@ -264,5 +264,9 @@ export default {
264
264
  text: 'Sorry, we can\'t find the page you want.',
265
265
  },
266
266
  },
267
+ copyAction: {
268
+ copy: 'Copy',
269
+ copied: 'Copied to clipboard!',
270
+ },
267
271
  },
268
272
  };
@@ -260,5 +260,9 @@ export default {
260
260
  text: 'Извините, мы не можем найти то, что вы ищете',
261
261
  },
262
262
  },
263
+ copyAction: {
264
+ copy: 'Копировать',
265
+ copied: 'Скопировано!',
266
+ },
263
267
  },
264
268
  };
@@ -260,5 +260,9 @@ export default {
260
260
  text: 'Вибачте, ми не можемо знайти те, що Ви шукаєте',
261
261
  },
262
262
  },
263
+ copyAction: {
264
+ copy: 'Копіювати',
265
+ copied: 'Скопійовано!',
266
+ },
263
267
  },
264
268
  };