@veritree/ui 0.21.1-9 → 0.22.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.
package/.prettierrc CHANGED
@@ -1,4 +1,5 @@
1
1
  {
2
2
  "semi": true,
3
- "singleQuote": true
3
+ "singleQuote": true,
4
+ "quoteProps": "preserve"
4
5
  }
package/index.js CHANGED
@@ -21,6 +21,9 @@ import VTPopoverItem from "./src/components/Popover/VTPopoverItem.vue";
21
21
  import VTPopoverTrigger from "./src/components/Popover/VTPopoverTrigger.vue";
22
22
  import VTFormFeedback from "./src/components/Form/VTFormFeedback.vue";
23
23
  import VTFormGroup from "./src/components/Form/VTFormGroup.vue";
24
+ import VTInput from "./src/components/Form/VTInput.vue";
25
+ import VTInputIcon from "./src/components/Form/VTInputIcon.vue";
26
+ import VTInputPassword from "./src/components/Form/VTInputPassword.vue";
24
27
  import VTListbox from "./src/components/Listbox/VTListbox.vue";
25
28
  import VTListboxContent from "./src/components/Listbox/VTListboxContent.vue";
26
29
  import VTListboxItem from "./src/components/Listbox/VTListboxItem.vue";
@@ -29,7 +32,6 @@ import VTListboxList from "./src/components/Listbox/VTListboxList.vue";
29
32
  import VTListboxSearch from "./src/components/Listbox/VTListboxSearch.vue";
30
33
  import VTListboxTrigger from "./src/components/Listbox/VTListboxTrigger.vue";
31
34
  import VTSpinner from "./src/components/Spinner/VTSpinner.vue";
32
- import VTInput from "./src/components/Input/VTInput.vue";
33
35
  import VTInputDate from "./src/components/Input/VTInputDate.vue";
34
36
  import VTInputFile from "./src/components/Input/VTInputFile.vue";
35
37
  import VTInputUpload from "./src/components/Input/VTInputUpload.vue";
@@ -96,6 +98,8 @@ export {
96
98
  VTListboxTrigger,
97
99
  VTButton,
98
100
  VTInput,
101
+ VTInputIcon,
102
+ VTInputPassword,
99
103
  VTInputDate,
100
104
  VTInputFile,
101
105
  VTInputUpload,
@@ -1,10 +1,4 @@
1
- import FloatingUiItem from '../src/components/Utils/FloatingUiItem.vue';
2
-
3
1
  export const floatingUiItemMixin = {
4
- components: {
5
- FloatingUiItem,
6
- },
7
-
8
2
  props: {
9
3
  headless: {
10
4
  type: Boolean,
@@ -0,0 +1,53 @@
1
+ import { formControlMixin } from '../mixins/form-control';
2
+
3
+ export const formControlIconMixin = {
4
+ inheritAttrs: false,
5
+
6
+ mixins: [formControlMixin],
7
+
8
+ data() {
9
+ return {
10
+ name: 'input',
11
+ };
12
+ },
13
+
14
+ computed: {
15
+ isLeft() {
16
+ return this.iconPlacement === 'left';
17
+ },
18
+
19
+ isRight() {
20
+ return this.iconPlacement === 'right';
21
+ },
22
+
23
+ classComputedWrapper() {
24
+ return [
25
+ this.headless ? 'form-control-wrapper' : 'relative',
26
+ // placement styles
27
+ this.headless
28
+ ? `form-control-icon--${this.placement}`
29
+ : this.isLeft
30
+ ? '[&_input]:pl-9'
31
+ : this.isRight
32
+ ? '[&_input]:pr-9'
33
+ : null,
34
+ ];
35
+ },
36
+
37
+ classComputedWrapperIcon() {
38
+ return [
39
+ this.headless
40
+ ? 'form-control-wrapper__icon'
41
+ : `absolute top-0 bottom-0 flex w-9 justify-center items-center text-gray-400`,
42
+ // placement styles
43
+ this.headless
44
+ ? null
45
+ : this.isLeft
46
+ ? 'left-0'
47
+ : this.isRight
48
+ ? 'right-0'
49
+ : null,
50
+ ];
51
+ },
52
+ },
53
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veritree/ui",
3
- "version": "0.21.1-9",
3
+ "version": "0.22.0",
4
4
  "description": "veritree ui library",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -15,5 +15,9 @@
15
15
  "@linusborg/vue-simple-portal": "^0.1.5",
16
16
  "@veritree/icons": "^0.39.0"
17
17
  },
18
- "devDependencies": {}
18
+ "devDependencies": {
19
+ "prettier": "^2.7.1",
20
+ "prettier-plugin-tailwindcss": "^0.1.13",
21
+ "tailwindcss": "^3.2.4"
22
+ }
19
23
  }
@@ -22,11 +22,11 @@ export default {
22
22
  </script>
23
23
 
24
24
  <style scoped>
25
- input[type='date']::-webkit-inner-spin-button,
25
+ /* input[type='date']::-webkit-inner-spin-button,
26
26
  input[type='date']::-webkit-calendar-picker-indicator {
27
27
  position: absolute;
28
28
  opacity: 0;
29
- }
29
+ } */
30
30
 
31
31
  input[type='number'] {
32
32
  appearance: textfield;
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div :class="classComputedWrapper">
3
+ <input
4
+ :class="classComputed"
5
+ :value="value"
6
+ :disabled="disabled"
7
+ v-bind="$attrs"
8
+ v-on="listeners"
9
+ />
10
+ <div :class="classComputedWrapperIcon">
11
+ <component :is="icon" class="h-5 w-5" />
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script>
17
+ import { formControlIconMixin } from '../../../mixins/form-control-icon';
18
+
19
+ export default {
20
+ name: 'VTInputIcon',
21
+
22
+ mixins: [formControlIconMixin],
23
+
24
+ props: {
25
+ icon: {
26
+ type: String,
27
+ default: null,
28
+ required: true,
29
+ },
30
+ iconPlacement: {
31
+ type: String,
32
+ default: 'left',
33
+ },
34
+ },
35
+ };
36
+ </script>
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <div :class="classComputedWrapper">
3
+ <input
4
+ :class="classComputed"
5
+ :value="value"
6
+ :disabled="disabled"
7
+ :type="reveal ? 'text' : 'password'"
8
+ v-bind="$attrs"
9
+ v-on="listeners"
10
+ />
11
+ <div :class="classComputedWrapperIcon">
12
+ <VTButton v-show="value.length" variant="icon" @click="reveal = !reveal">
13
+ <component :is="iconVisibility" class="h-5 w-5" />
14
+ </VTButton>
15
+ </div>
16
+ </div>
17
+ </template>
18
+
19
+ <script>
20
+ import { formControlIconMixin } from '../../../mixins/form-control-icon';
21
+
22
+ export default {
23
+ name: 'VTInputPassword',
24
+
25
+ mixins: [formControlIconMixin],
26
+
27
+ props: {
28
+ iconPlacement: {
29
+ type: String,
30
+ default: 'right',
31
+ },
32
+ },
33
+
34
+ data() {
35
+ return {
36
+ reveal: false,
37
+ };
38
+ },
39
+
40
+ computed: {
41
+ iconVisibility() {
42
+ return this.reveal ? 'IconVisibilityOn' : 'IconVisibilityOff';
43
+ },
44
+ },
45
+ };
46
+ </script>
@@ -1,165 +0,0 @@
1
- <template>
2
- <div>
3
- <input
4
- ref="input"
5
- v-bind="$attrs"
6
- type="number"
7
- :class="classComputed"
8
- :value="value"
9
- :disabled="disabled"
10
- @blur="onBlur"
11
- @change="onChange"
12
- @keypress="isNumber"
13
- />
14
- <div v-if="!hideArrows">
15
- <VTButton
16
- variant="secondary"
17
- :disabled="qty >= max"
18
- tabindex="-1"
19
- @click="increase"
20
- >
21
- <IconChevronUp text="Increase" />
22
- </VTButton>
23
- <VTButton
24
- variant="secondary"
25
- :disabled="qty <= min"
26
- tabindex="-1"
27
- @click="decrease"
28
- >
29
- <IconChevronDown text="Increase" />
30
- </VTButton>
31
- </div>
32
- </div>
33
- </template>
34
-
35
- <script>
36
- import { formControlMixin } from '../../../mixins/form-control';
37
-
38
- export default {
39
- mixins: [formControlMixin],
40
-
41
- inheritAttrs: false,
42
-
43
- model: {
44
- prop: 'value',
45
- event: 'input',
46
- },
47
-
48
- props: {
49
- hideArrows: {
50
- type: Boolean,
51
- default: false,
52
- },
53
- value: {
54
- type: [String, Number],
55
- default: 0,
56
- },
57
- step: {
58
- type: [Number],
59
- default: 1,
60
- },
61
- allowDecimal: {
62
- type: Boolean,
63
- default: true,
64
- },
65
- },
66
-
67
- data() {
68
- return {
69
- decimalPlaces: this.setDecimalPlaces(this.value),
70
- // id: 'qty-' + this._uid,
71
- };
72
- },
73
-
74
- computed: {
75
- numberAllowedKeys() {
76
- const allowed = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
77
- if (this.allowDecimal) allowed.push('.');
78
- return allowed;
79
- },
80
-
81
- qty: {
82
- get() {
83
- return this.value;
84
- },
85
- set(newVal) {
86
- this.$emit('input', Number(newVal));
87
- this.$emit('change');
88
- },
89
- },
90
-
91
- min() {
92
- return this.$attrs.min ? this.$attrs.min : 0;
93
- },
94
-
95
- max() {
96
- return this.$attrs.max ? this.$attrs.max : Number.MAX_VALUE;
97
- },
98
-
99
- internalStep() {
100
- if (this.step && this.step > 0) return this.step;
101
- if (!this.decimalPlaces) return 1;
102
-
103
- const decimalStep = '1'.padStart(this.decimalPlaces, '0');
104
- return parseFloat('0.' + decimalStep);
105
- },
106
- },
107
-
108
- methods: {
109
- increase() {
110
- this.qty = (
111
- isNaN(parseFloat(this.qty))
112
- ? 0
113
- : parseFloat(this.qty) + this.internalStep
114
- ).toFixed(this.decimalPlaces);
115
- },
116
-
117
- decrease() {
118
- this.qty = (
119
- isNaN(parseFloat(this.qty))
120
- ? 0
121
- : parseFloat(this.qty) - this.internalStep
122
- ).toFixed(this.decimalPlaces);
123
- },
124
-
125
- /**
126
- * Checks if key pressed is a number (0-9)
127
- * TODO: combine validation with input price
128
- *
129
- * @param {object} - event
130
- */
131
- isNumber(ev) {
132
- const key = ev.key;
133
-
134
- if (!this.numberAllowedKeys.includes(key)) ev.preventDefault();
135
- },
136
-
137
- canUpdateQty(value) {
138
- return value >= this.min && value <= this.max;
139
- },
140
-
141
- setDecimalPlaces(typedValue) {
142
- this.decimalPlaces = typedValue.toString().includes('.')
143
- ? typedValue.toString().split('.')[1].length
144
- : 0;
145
- },
146
-
147
- onChange(event) {
148
- // const input = event.target;
149
- //
150
- // if (this.canUpdateQty(input.value)) {
151
- // this.setDecimalPlaces(input.value);
152
- // this.qty = input.value;
153
- // return;
154
- // }
155
- //
156
- // if (input.value < this.min) input.value = this.min;
157
- // if (input.value > this.max) input.value = this.max;
158
- },
159
-
160
- onBlur(event) {
161
- this.$emit('blur', event);
162
- },
163
- },
164
- };
165
- </script>