@veritree/ui 0.85.0 → 0.87.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.
@@ -5,6 +5,10 @@ export const formControlMixin = {
5
5
  },
6
6
 
7
7
  props: {
8
+ id: {
9
+ type: String,
10
+ default: null,
11
+ },
8
12
  disabled: {
9
13
  type: Boolean,
10
14
  default: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.85.0",
3
+ "version": "0.87.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -19,6 +19,13 @@ export default {
19
19
 
20
20
  mixins: [formControlMixin, formControlStyleMixin],
21
21
 
22
+ props: {
23
+ dataTestId: {
24
+ type: String,
25
+ default: null,
26
+ },
27
+ },
28
+
22
29
  data() {
23
30
  return {
24
31
  name: 'input',
@@ -1,7 +1,13 @@
1
1
  <template>
2
2
  <VTPopover>
3
3
  <VTPopoverTrigger ref="trigger">
4
- <button :class="classComputed" :disabled="disabled" @click.prevent>
4
+ <button
5
+ :id="id"
6
+ :class="classComputed"
7
+ :data-testid="dataTestid"
8
+ :disabled="disabled"
9
+ @click.prevent
10
+ >
5
11
  <span v-if="valueModel">{{ valueModelFormatted }}</span>
6
12
  <span class="text-gray-500" v-else>{{ format }}</span>
7
13
  <span
@@ -66,6 +72,10 @@ export default {
66
72
  },
67
73
 
68
74
  props: {
75
+ dataTestid: {
76
+ type: String,
77
+ default: null,
78
+ },
69
79
  disabledDates: {
70
80
  type: [Function, Object],
71
81
  default: null,
@@ -4,7 +4,9 @@
4
4
  currencySymbol
5
5
  }}</span>
6
6
  <input
7
+ :id="id"
7
8
  v-model="valueFormatted"
9
+ :data-testid="dataTestid"
8
10
  :disabled="disabled"
9
11
  :inputmode="inputmode"
10
12
  :placeholder="placeholder"
@@ -35,6 +37,10 @@ export default {
35
37
  },
36
38
 
37
39
  props: {
40
+ dataTestid: {
41
+ type: String,
42
+ default: null,
43
+ },
38
44
  currency: {
39
45
  type: String,
40
46
  default: 'USD',
@@ -0,0 +1,97 @@
1
+ <template>
2
+ <div class="range-slider" :style="style">
3
+ <input
4
+ :id="id"
5
+ v-model.number="computedValue"
6
+ :data-testid="dataTestid"
7
+ :min="min"
8
+ :max="max"
9
+ :step="step"
10
+ type="range"
11
+ @input="onInput"
12
+ @change="onChange"
13
+ />
14
+ <div class="range-slider-track" aria-hidden />
15
+ <div ref="thumb" class="range-slider-thumb" aria-hidden />
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ export default {
21
+ name: 'VTInputRanger',
22
+
23
+ model: {
24
+ prop: 'value',
25
+ event: 'input',
26
+ },
27
+
28
+ props: {
29
+ id: {
30
+ type: String,
31
+ default: null,
32
+ },
33
+ dataTestid: {
34
+ type: String,
35
+ default: null,
36
+ },
37
+ value: {
38
+ type: [Number, String],
39
+ default: 0,
40
+ },
41
+ min: {
42
+ type: Number,
43
+ default: 0,
44
+ },
45
+ max: {
46
+ type: Number,
47
+ default: 100,
48
+ },
49
+ step: {
50
+ type: Number,
51
+ default: 1,
52
+ },
53
+ },
54
+
55
+ data() {
56
+ return {
57
+ thumbSize: null,
58
+ };
59
+ },
60
+
61
+ computed: {
62
+ computedValue: {
63
+ get() {
64
+ return Number(this.value);
65
+ },
66
+ set(value) {
67
+ this.$emit('input', value);
68
+ },
69
+ },
70
+
71
+ percentage() {
72
+ return ((this.computedValue - this.min) / (this.max - this.min)) * 100;
73
+ },
74
+
75
+ style() {
76
+ return {
77
+ '--value': `${this.percentage}%`,
78
+ '--thumb-left-position': `calc(${this.percentage}% - ${this.thumbSize * (this.percentage / 100)}px)`,
79
+ };
80
+ },
81
+ },
82
+
83
+ mounted() {
84
+ this.thumbSize = 20;
85
+ },
86
+
87
+ methods: {
88
+ onInput(e) {
89
+ this.computedValue = e.target.value;
90
+ },
91
+
92
+ onChange(e) {
93
+ console.log(e.target);
94
+ },
95
+ },
96
+ };
97
+ </script>
@@ -1,6 +1,7 @@
1
1
  <template>
2
2
  <button
3
3
  :id="id"
4
+ :data-testid="dataTestid"
4
5
  :class="triggerClassComputed"
5
6
  :disabled="isDisabled"
6
7
  :aria-expanded="expanded"
@@ -47,6 +48,10 @@ export default {
47
48
  inject: ['apiListbox'],
48
49
 
49
50
  props: {
51
+ dataTestid: {
52
+ type: String,
53
+ default: null,
54
+ },
50
55
  role: {
51
56
  type: String,
52
57
  default: 'combobox',
@@ -69,8 +74,8 @@ export default {
69
74
  },
70
75
 
71
76
  computed: {
72
- id() {
73
- return `listbox-trigger-${this.apiListbox().id}`;
77
+ idComputed() {
78
+ return this.id || `listbox-trigger-${this.apiListbox().id}`;
74
79
  },
75
80
 
76
81
  componentContent() {
@@ -1,69 +0,0 @@
1
- <template>
2
- <transition
3
- enter-active-class="duration-300 ease-out"
4
- enter-class="transform opacity-0"
5
- enter-to-class="opacity-100"
6
- leave-active-class="duration-300 ease-in"
7
- leave-class="opacity-100"
8
- leave-to-class="transform opacity-0"
9
- @after-enter="afterEnter"
10
- @after-leave="afterLeave"
11
- >
12
- <div
13
- v-if="visible"
14
- class="bg-fd-700/75 fixed inset-0 z-50 flex flex-col justify-center"
15
- tabindex="-1"
16
- @keyup.esc="close"
17
- @click="close"
18
- >
19
- <div
20
- class="relative mx-auto flex max-w-lg flex-col justify-center rounded bg-white"
21
- @click.stop
22
- >
23
- <div class="absolute right-4 top-4">
24
- <VTButton variant="icon" @click.prevent="close"
25
- ><IconClose class="h-4 w-4"
26
- /></VTButton>
27
- </div>
28
- <slot></slot>
29
- </div>
30
- </div>
31
- </transition>
32
- </template>
33
-
34
- <script>
35
- import { IconClose } from '@veritree/icons';
36
- import VTButton from '../Button/VTButton.vue';
37
-
38
- export default {
39
- name: 'VTModal',
40
-
41
- components: { IconClose, VTButton },
42
-
43
- model: {
44
- prop: 'visible',
45
- },
46
-
47
- props: {
48
- visible: {
49
- type: Boolean,
50
- default: false,
51
- },
52
- },
53
-
54
- methods: {
55
- close() {
56
- this.$emit('input', false);
57
- },
58
-
59
- afterEnter() {
60
- this.$emit('shown');
61
- this.$nextTick(() => this.$el.focus());
62
- },
63
-
64
- afterLeave() {
65
- this.$emit('hidden');
66
- },
67
- },
68
- };
69
- </script>