@weni/unnnic-system 3.31.1 → 3.32.0

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 (34) hide show
  1. package/dist/index.d.ts +1518 -4106
  2. package/dist/style.css +1 -1
  3. package/dist/unnnic.mjs +12879 -13865
  4. package/dist/unnnic.umd.js +36 -36
  5. package/package.json +1 -1
  6. package/src/components/index.ts +1 -41
  7. package/src/stories/PageHeader.stories.js +11 -5
  8. package/src/types/index.d.ts +0 -1
  9. package/src/components/Button/ButtonIcon.vue +0 -106
  10. package/src/components/Button/__tests__/ButtonIcon.spec.js +0 -56
  11. package/src/components/Carousel/Carousel.vue +0 -59
  12. package/src/components/Carousel/TagCarousel.vue +0 -209
  13. package/src/components/Carousel/__tests__/TagCarousel.spec.js +0 -258
  14. package/src/components/ChatText/ChatText.vue +0 -179
  15. package/src/components/CircleProgressBar/CircleProgressBar.vue +0 -150
  16. package/src/components/Indicator/Indicator.vue +0 -110
  17. package/src/components/InputNext/InputNext.vue +0 -282
  18. package/src/components/ModalUpload/ModalUpload.vue +0 -181
  19. package/src/components/MoodRating/MoodRating.vue +0 -130
  20. package/src/components/Slider/Slider.vue +0 -438
  21. package/src/components/Slider/__tests__/Slider.spec.js +0 -321
  22. package/src/components/StarRating/StarRating.vue +0 -76
  23. package/src/components/TransitionRipple/TransitionRipple.vue +0 -126
  24. package/src/stories/ButtonIcon.stories.js +0 -31
  25. package/src/stories/Carousel.stories.js +0 -45
  26. package/src/stories/ChatText.stories.js +0 -57
  27. package/src/stories/CircleProgressBar.stories.js +0 -15
  28. package/src/stories/Indicator.stories.js +0 -18
  29. package/src/stories/InputNext.stories.js +0 -92
  30. package/src/stories/ModalUpload.stories.js +0 -25
  31. package/src/stories/MoodRating.stories.js +0 -33
  32. package/src/stories/Slider.stories.js +0 -23
  33. package/src/stories/StarRating.stories.js +0 -38
  34. package/src/stories/TransitionRipple.stories.js +0 -35
@@ -1,438 +0,0 @@
1
- <template>
2
- <article>
3
- <section class="unnnic-label">
4
- <p
5
- v-if="label"
6
- class="unnnic-slider__label"
7
- >
8
- {{ label }}
9
- </p>
10
- <UnnnicTooltip
11
- v-if="labelInfo"
12
- class="unnnic-label__tooltip"
13
- :text="labelInfo"
14
- enabled
15
- side="top"
16
- >
17
- <UnnnicIcon
18
- class="unnnic-label__tooltip__icon"
19
- icon="info"
20
- size="sm"
21
- scheme="fg-base"
22
- :filled="true"
23
- />
24
- </UnnnicTooltip>
25
- </section>
26
-
27
- <section
28
- class="unnnic-slider"
29
- :style="cssVars"
30
- >
31
- <section class="unnnic-slider__content">
32
- <section class="unnnic-slider__content__labels">
33
- <span class="unnnic-slider__content__labels__min">{{
34
- minLabel
35
- }}</span>
36
- <UnnnicTooltip
37
- ref="tooltip"
38
- class="unnnic-slider__content__tooltip"
39
- :text="sliderVal.toString()"
40
- :forceOpen="true"
41
- :enabled="showTooltip"
42
- side="top"
43
- >
44
- <input
45
- ref="input"
46
- v-model="sliderVal"
47
- class="unnnic-slider__content__range-input"
48
- type="range"
49
- :min="minValue"
50
- :max="maxValue"
51
- :step="step"
52
- @change="handleValueChange"
53
- @mouseover="showTooltip = true"
54
- @mouseleave="showTooltip = false"
55
- />
56
- </UnnnicTooltip>
57
- <span class="unnnic-slider__content__labels__max">{{
58
- maxLabel
59
- }}</span>
60
- </section>
61
- </section>
62
- <template v-if="showInputValue">
63
- <input
64
- ref="value-input"
65
- class="value-input"
66
- :value="sliderVal"
67
- @input="handleInput"
68
- />
69
- </template>
70
- </section>
71
- </article>
72
- </template>
73
-
74
- <script>
75
- import UnnnicTooltip from '../ToolTip/ToolTip.vue';
76
- import UnnnicIcon from '../Icon.vue';
77
-
78
- export default {
79
- name: 'UnnnicSlider',
80
- components: {
81
- UnnnicTooltip,
82
- UnnnicIcon,
83
- },
84
- props: {
85
- initialValue: {
86
- type: Number,
87
- default: 0,
88
- },
89
- showInputValue: {
90
- type: Boolean,
91
- default: true,
92
- },
93
- label: {
94
- type: String,
95
- default: '',
96
- },
97
- labelInfo: {
98
- type: String,
99
- default: '',
100
- },
101
- minValue: {
102
- type: Number,
103
- default: 0,
104
- },
105
- maxValue: {
106
- type: Number,
107
- default: 5,
108
- },
109
- step: {
110
- type: Number,
111
- default: 1,
112
- },
113
- minLabel: {
114
- type: String,
115
- default: '',
116
- },
117
- maxLabel: {
118
- type: String,
119
- default: '',
120
- },
121
- },
122
- data() {
123
- return {
124
- showTooltip: false,
125
- sliderVal: this.initialValue,
126
- tooltipOffset: 0,
127
- sliderWidth: 0,
128
- labelWidth: 0,
129
- };
130
- },
131
- computed: {
132
- cssVars() {
133
- return {
134
- '--val': this.sliderVal,
135
- '--tooltip-offset': this.tooltipOffset,
136
- '--min': this.minValue,
137
- '--max': this.maxValue,
138
- };
139
- },
140
- },
141
- watch: {
142
- sliderVal: {
143
- handler() {
144
- this.$nextTick(() => {
145
- this.configureTooltip();
146
- const ValueInput = this.$refs['value-input'];
147
-
148
- if (ValueInput && ValueInput.textContent !== this.sliderVal) {
149
- this.$refs['value-input'].textContent = this.sliderVal;
150
- }
151
- });
152
- },
153
- immediate: true,
154
- deep: true,
155
- },
156
- },
157
- created() {
158
- window.addEventListener('resize', this.handleResize);
159
- },
160
- unmounted() {
161
- window.removeEventListener('resize', this.handleResize);
162
- },
163
- mounted() {
164
- this.checkInputWidth();
165
- this.checkTooltipLabelWidth();
166
- },
167
- methods: {
168
- configureTooltip() {
169
- this.sliderWidth = this.$refs.input.clientWidth;
170
- this.labelWidth = this.$refs.tooltip.$refs.label.clientWidth;
171
- this.tooltipOffset = this.getNewTooltipPosition();
172
- },
173
- handleResize() {
174
- this.configureTooltip();
175
- },
176
- handleValueChange() {
177
- this.configureTooltip();
178
- this.$emit('valueChange', this.sliderVal);
179
- },
180
- handleInput(event) {
181
- this.sliderVal = event.target.value;
182
-
183
- this.handleValueChange();
184
- },
185
- checkInputWidth() {
186
- const intervalId = setInterval(() => {
187
- const inputElement = this.$refs.input;
188
- if (inputElement) {
189
- const { offsetWidth } = inputElement;
190
- if (offsetWidth > 0) {
191
- this.sliderWidth = offsetWidth;
192
- this.configureTooltip();
193
- clearInterval(intervalId);
194
- }
195
- }
196
- }, 100);
197
- },
198
- checkTooltipLabelWidth() {
199
- const intervalId = setInterval(() => {
200
- const tooltipLabel = this.$refs.tooltip?.$refs.label;
201
- if (!tooltipLabel) {
202
- return;
203
- }
204
-
205
- const { clientWidth } = tooltipLabel;
206
- if (clientWidth > 0) {
207
- this.labelWidth = clientWidth;
208
- this.configureTooltip();
209
- clearInterval(intervalId);
210
- }
211
- }, 100);
212
- },
213
- getNewTooltipPosition() {
214
- if (this.sliderWidth === 0 || this.labelWidth === 0) {
215
- return 0;
216
- }
217
- const halfThumbWidth = 12 / 2;
218
- const halfLabelWidth = this.labelWidth / 2 || 16;
219
- const centerPosition = this.sliderWidth / 2;
220
-
221
- let percentOfRange =
222
- (this.sliderVal - this.minValue) / (this.maxValue - this.minValue);
223
- if (Number.isNaN(percentOfRange)) {
224
- percentOfRange = 0;
225
- }
226
-
227
- const valuePXPosition = percentOfRange * this.sliderWidth;
228
- const distFromCenter = valuePXPosition - centerPosition;
229
- const percentDistFromCenter = distFromCenter / centerPosition;
230
- const offset = percentDistFromCenter * halfThumbWidth;
231
-
232
- const finalLabelPosition = valuePXPosition - halfLabelWidth - offset;
233
- return finalLabelPosition;
234
- },
235
- },
236
- };
237
- </script>
238
-
239
- <style lang="scss" scoped>
240
- @use '@/assets/scss/unnnic' as *;
241
-
242
- .value-input {
243
- display: flex;
244
- margin-left: $unnnic-spacing-inline-sm;
245
- background: $unnnic-color-bg-base;
246
- border-radius: $unnnic-border-radius-sm;
247
- color: $unnnic-color-fg-base;
248
- font-weight: $unnnic-font-weight-regular;
249
- font-family: $unnnic-font-family-secondary;
250
- box-sizing: border-box;
251
- font-size: $unnnic-font-size-body-md;
252
- line-height: $unnnic-font-size-body-md + $unnnic-line-height-medium;
253
- min-width: 70px;
254
- max-width: 70px;
255
- padding: $unnnic-spacing-xs $unnnic-spacing-sm $unnnic-spacing-xs
256
- $unnnic-spacing-sm;
257
- gap: $unnnic-spacing-xs;
258
- height: $unnnic-font-size-body-md + $unnnic-line-height-medium + 0.5 *
259
- $unnnic-font-size * 2;
260
- position: relative;
261
- border: 1px solid $unnnic-color-border-emphasized;
262
- overflow: hidden;
263
- white-space: nowrap;
264
- text-overflow: ellipsis;
265
-
266
- &:before {
267
- content: ' ';
268
- position: absolute;
269
- left: 0;
270
- right: 0;
271
- top: 0;
272
- bottom: 0;
273
- border-radius: inherit;
274
- pointer-events: none;
275
- }
276
-
277
- &:focus:before {
278
- border-color: $unnnic-color-fg-base;
279
- }
280
-
281
- &:focus {
282
- outline: none;
283
- }
284
- }
285
- </style>
286
-
287
- <style lang="scss">
288
- @use '@/assets/scss/unnnic' as *;
289
-
290
- .unnnic-label {
291
- display: flex;
292
- gap: $unnnic-spacing-xs;
293
-
294
- &__tooltip {
295
- display: flex;
296
- align-self: center;
297
-
298
- &__icon {
299
- cursor: default;
300
- }
301
- }
302
- }
303
-
304
- .unnnic-slider {
305
- display: flex;
306
- width: 100%;
307
-
308
- &__label {
309
- font-family: $unnnic-font-family-secondary;
310
- font-weight: $unnnic-font-weight-regular;
311
- line-height: $unnnic-font-size-body-gt + $unnnic-line-height-medium;
312
- font-size: $unnnic-font-size-body-gt;
313
- color: $unnnic-color-fg-base;
314
- margin: $unnnic-spacing-stack-xs 0;
315
- }
316
- &__content {
317
- display: flex;
318
- flex-direction: column;
319
- width: 100%;
320
- margin-top: $unnnic-spacing-stack-xs;
321
-
322
- &__tooltip {
323
- display: flex;
324
- width: 100%;
325
- align-self: center;
326
- }
327
-
328
- &__labels {
329
- display: flex;
330
- gap: $unnnic-spacing-ant;
331
-
332
- &__min {
333
- font-family: $unnnic-font-family-secondary;
334
- font-weight: $unnnic-font-weight-regular;
335
- font-size: $unnnic-font-size-body-md;
336
- line-height: $unnnic-font-size-body-md + $unnnic-line-height-md;
337
- color: $unnnic-color-fg-base;
338
- }
339
-
340
- &__max {
341
- margin-left: auto;
342
- font-family: $unnnic-font-family-secondary;
343
- font-weight: $unnnic-font-weight-regular;
344
- font-size: $unnnic-font-size-body-md;
345
- line-height: $unnnic-font-size-body-md + $unnnic-line-height-md;
346
- color: $unnnic-color-fg-base;
347
- }
348
- }
349
-
350
- &__range-input {
351
- appearance: none;
352
- -webkit-appearance: none;
353
- width: 100%;
354
- margin: 0;
355
- @mixin thumb() {
356
- box-sizing: border-box;
357
- width: $unnnic-icon-size-xs;
358
- height: $unnnic-icon-size-xs;
359
- background: $unnnic-color-weni-600;
360
- border: $unnnic-border-width-thin solid $unnnic-color-weni-600;
361
- border-radius: 50%;
362
-
363
- &:active {
364
- box-shadow: $unnnic-shadow-1;
365
- }
366
- }
367
-
368
- /* Chrome */
369
- &::-webkit-slider-thumb {
370
- -webkit-appearance: none;
371
- @include thumb;
372
- margin-top: -$unnnic-spacing-stack-nano;
373
- }
374
- /* Firefox */
375
- &::-moz-range-thumb {
376
- @include thumb;
377
- }
378
- /* IE */
379
- &::-ms-thumb {
380
- @include thumb;
381
- }
382
-
383
- @mixin track($fill: 0) {
384
- width: 100%;
385
- height: 4px;
386
- box-sizing: border-box;
387
- border: none;
388
- background: $unnnic-color-bg-muted;
389
- border-radius: $unnnic-border-radius-pill;
390
- }
391
-
392
- /* Chrome */
393
- &::-webkit-slider-runnable-track {
394
- @include track(1);
395
- margin: $unnnic-spacing-inline-xs 0;
396
- --progress: calc(
397
- (var(--val) - var(--min)) / ((var(--max) - var(--min))) * 100%
398
- );
399
- background: linear-gradient(
400
- to right,
401
- $unnnic-color-weni-600 0%,
402
- $unnnic-color-weni-600 calc(var(--progress)),
403
- $unnnic-color-bg-muted calc(var(--progress)),
404
- $unnnic-color-bg-muted 100%
405
- );
406
- }
407
- /* Firefox */
408
- &::-moz-range-track {
409
- @include track;
410
- }
411
- /* IE */
412
- &::-ms-track {
413
- @include track;
414
- }
415
-
416
- @mixin fill() {
417
- height: 4px;
418
- background: $unnnic-color-weni-600;
419
- }
420
-
421
- /* Firefox */
422
- &::-moz-range-progress {
423
- @include fill;
424
- }
425
- /* IE */
426
- &::-ms-fill-lower {
427
- @include fill;
428
- }
429
- }
430
- }
431
-
432
- .unnnic-tooltip-label {
433
- position: absolute;
434
- left: calc(var(--tooltip-offset) * 1px) !important;
435
- top: -45px !important;
436
- }
437
- }
438
- </style>