@webitel/ui-sdk 0.9.31 → 0.9.35

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": "0.9.31",
3
+ "version": "0.9.35",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve-lib": "vue-cli-service serve",
@@ -8,10 +8,11 @@
8
8
  v-for="(option, index) in options"
9
9
  :key="index"
10
10
  >
11
+ <!-- <a> click.prevent prevents redirect to # -->
11
12
  <a
12
13
  class="wt-context-menu__option"
13
14
  href="#"
14
- @click="$emit('click', { option, index })"
15
+ @click.prevent="$emit('click', { option, index })"
15
16
  >
16
17
  {{ option.text || option }}
17
18
  </a>
@@ -40,6 +41,7 @@ export default {
40
41
  .wt-context-menu {
41
42
  @extend %typo-body-sm;
42
43
  min-width: var(--context-menu-min-width);
44
+ max-width: var(--context-menu-max-width);
43
45
  background-color: var(--context-menu-background-color);
44
46
  border-radius: var(--border-radius);
45
47
  box-shadow: var(--box-shadow);
@@ -22,7 +22,6 @@
22
22
  :class="{'wt-button-select__select-arrow--active': isOpened}"
23
23
  v-bind="$attrs"
24
24
  icon="arrow-down"
25
- size="sm"
26
25
  ></wt-icon>
27
26
  </wt-button>
28
27
 
@@ -42,7 +41,7 @@ export default {
42
41
  }),
43
42
  methods: {
44
43
  selectOption({ option, index }) {
45
- this.$emit('click:option', { option, index });
44
+ this.$emit('click:option', option, index);
46
45
  this.isOpened = false;
47
46
  },
48
47
  away() {
@@ -60,7 +59,7 @@ export default {
60
59
 
61
60
  .wt-context-menu {
62
61
  position: absolute;
63
- top: 100%;
62
+ top: calc(100% + 1px);
64
63
  left: 0;
65
64
  }
66
65
  }
@@ -1,8 +1,10 @@
1
1
  .wt-context-menu {
2
+ --context-menu-min-width : 160px;
3
+ --context-menu-max-width : 300px;
4
+
2
5
  --context-menu-option-color--hover: var(--secondary-color);
3
6
 
4
7
  --context-menu-background-color: var(--main-color);
5
8
 
6
9
  --context-menu-option-padding: var(--spacing--sm);
7
- --context-menu-min-width : 150px;
8
10
  }
@@ -4,7 +4,7 @@
4
4
  Reduce 1px from "spacing--md" for align a difference between arrow size in "wt-button-select__select"
5
5
  and line-height of text in "wt-button-select__button"
6
6
  */
7
- --button-select-icon-button-padding: calc(var(--spacing--md) - 1px);
7
+ --button-select-icon-button-padding: calc(var(--spacing--sm) - 1px);
8
8
 
9
9
  --button-select-buttons-gap: 1px;
10
10
 
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <wt-select
3
3
  :value="filterSchema.value"
4
- :options="filterSchema.options"
4
+ :options="localizedOptions"
5
5
  :label="$t(filterSchema.locale.label)"
6
6
  :track-by="filterSchema.storedProp"
7
7
  :multiple="filterSchema.multiple"
@@ -45,10 +45,26 @@ describe('Enum filter mixin', () => {
45
45
  });
46
46
 
47
47
  it('Sets empty array value if $route query is empty', async () => {
48
- const wrapper = shallowMount(Component, {
48
+ shallowMount(Component, {
49
49
  localVue,
50
50
  router,
51
51
  });
52
52
  expect(setValue).not.toHaveBeenCalled();
53
53
  });
54
+
55
+ it('Attaches locales to options, if they have "locale" key', async () => {
56
+ const options = [{
57
+ locale: 'jest.locale',
58
+ }];
59
+ const expectedOptions = [{
60
+ locale: options[0].locale,
61
+ name: options[0].locale,
62
+ }];
63
+ const wrapper = shallowMount(Component, {
64
+ localVue,
65
+ router,
66
+ data: () => ({ options }),
67
+ });
68
+ expect(wrapper.vm.localizedOptions).toEqual(expectedOptions);
69
+ });
54
70
  });
@@ -4,7 +4,7 @@ export default {
4
4
  mixins: [baseFilterMixin],
5
5
  computed: {
6
6
  options() {
7
- return this.filterSchema.options;
7
+ return this.filterSchema?.options;
8
8
  },
9
9
  locale() {
10
10
  return this.filterSchema?.locale;
@@ -18,6 +18,13 @@ export default {
18
18
  closeOnSelect() {
19
19
  return this.filterSchema?.storedProp;
20
20
  },
21
+ localizedOptions() {
22
+ const optsHaveLocale = this.options.length && this.options[0].locale; // just check 1st el
23
+ if (optsHaveLocale) {
24
+ return this.options.map((opt) => ({ ...opt, name: this.$t(opt.locale) }));
25
+ }
26
+ return this.options;
27
+ },
21
28
  },
22
29
  methods: {
23
30
  restoreValue(value) {