@webitel/ui-sdk 24.10.39 → 24.10.41

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.10.39",
3
+ "version": "24.10.41",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -124,10 +124,18 @@ const badgeColorVar = computed(() => {
124
124
 
125
125
  <style lang="scss" scoped>
126
126
 
127
+ %wt-avatar-typo-xs {
128
+ font-size: 10px;
129
+ }
130
+
127
131
  %wt-avatar-typo-sm {
128
132
  font-size: 12px;
129
133
  }
130
134
 
135
+ %wt-avatar-typo-md {
136
+ font-size: 14px;
137
+ }
138
+
131
139
  %wt-avatar-typo-lg {
132
140
  font-size: 20px;
133
141
  }
@@ -163,6 +171,7 @@ const badgeColorVar = computed(() => {
163
171
  }
164
172
 
165
173
  &--size-xs {
174
+ @extend %wt-avatar-typo-xs;
166
175
  width: var(--wt-avatar-size--size-xs);
167
176
  height: var(--wt-avatar-size--size-xs);
168
177
  }
@@ -174,6 +183,7 @@ const badgeColorVar = computed(() => {
174
183
  }
175
184
 
176
185
  &--size-md {
186
+ @extend %wt-avatar-typo-md;
177
187
  width: var(--wt-avatar-size--size-md);
178
188
  height: var(--wt-avatar-size--size-md);
179
189
  }
@@ -23,18 +23,18 @@ describe('WtTextarea', () => {
23
23
  expect(wrapper.find('.wt-label').text()).toBe(label);
24
24
  });
25
25
 
26
- it('emits "Enter" event if expanded prop is passed', () => {
26
+ it('emits "Enter" event if autoresize prop is passed', () => {
27
27
  const wrapper = shallowMount(WtTextarea, {
28
28
  stubs: {
29
29
  WtLabel,
30
30
  },
31
- props: { expanded: true },
31
+ props: { autoresize: true },
32
32
  });
33
33
  wrapper.find('.wt-textarea__textarea').trigger('keypress', { key: 'Enter' });
34
34
  expect(wrapper.emitted().enter).toBeTruthy();
35
35
  });
36
36
 
37
- it('do not emit "Enter" event if expanded prop is not passed', () => {
37
+ it('do not emit "Enter" event if autoresize prop is not passed', () => {
38
38
  const wrapper = shallowMount(WtTextarea, {
39
39
  stubs: {
40
40
  WtLabel,
@@ -31,6 +31,7 @@
31
31
  rows="1"
32
32
  class="wt-textarea__textarea"
33
33
  v-on="listeners"
34
+ @input="autoGrow"
34
35
  />
35
36
  <div
36
37
  ref="after-wrapper"
@@ -43,7 +44,7 @@
43
44
  class="wt-textarea__reset-icon-btn"
44
45
  icon="close--filled"
45
46
  size="sm"
46
- @click="cleanInput"
47
+ @click="$emit('input', '')"
47
48
  />
48
49
  </div>
49
50
  </div>
@@ -57,7 +58,6 @@
57
58
  </template>
58
59
 
59
60
  <script>
60
- import autosize from 'autosize';
61
61
  import validationMixin from '../../mixins/validationMixin/validationMixin.js';
62
62
 
63
63
  export default {
@@ -125,27 +125,35 @@ export default {
125
125
  },
126
126
  mounted() {
127
127
  this.updateInputPaddings();
128
- if (this.autoresize) this.setupAutosize();
129
128
  },
130
- beforeUpdate() {
131
- if(!this.value) this.$nextTick(() => autosize.update(this.$refs['wt-textarea']));
129
+ updated() {
130
+ if(this.autoresize && !this.value) this.resetGrow();
132
131
  },
133
132
 
134
133
  methods: {
135
- cleanInput() {
136
- this.$emit('input', '');
137
- this.$nextTick(() => autosize.update(this.$refs['wt-textarea']));
138
- },
139
-
140
134
  handleKeypress(event) {
141
135
  if (!this.autoresize) return;
142
136
 
143
137
  if (event.key === 'Enter' && !event.shiftKey) {
144
138
  this.$emit('enter');
145
139
  event.preventDefault();
146
- this.$nextTick(() => autosize.update(this.$refs['wt-textarea']));
147
140
  }
148
141
  },
142
+
143
+ autoGrow() {
144
+ if (!this.autoresize) return;
145
+ const inputEl = this.$refs['wt-textarea'];
146
+ const bordersSize = 2; // + 2px for height because of --rounded-action-border-size
147
+
148
+ inputEl.style.height = 'auto';
149
+ inputEl.style.height = (inputEl.scrollHeight + bordersSize) + "px";
150
+ },
151
+
152
+ resetGrow() {
153
+ const inputEl = this.$refs['wt-textarea'];
154
+ inputEl.style.height = 'auto'; // reset text-area height
155
+ },
156
+
149
157
  updateInputPaddings() {
150
158
  // cant test this thing cause vue test utils doesnt render elements width :/
151
159
  const afterWrapperWidth = this.$refs['after-wrapper'].offsetWidth;
@@ -155,9 +163,6 @@ export default {
155
163
  );
156
164
  inputEl.style.paddingRight = `calc(${defaultInputPadding} * 2 + ${afterWrapperWidth}px)`;
157
165
  },
158
- setupAutosize() {
159
- autosize(this.$refs['wt-textarea']);
160
- },
161
166
  },
162
167
  };
163
168
  </script>