@veritree/ui 0.19.2-10 → 0.19.2-11
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/mixins/form-control-icon.js +53 -0
- package/mixins/form-control.js +67 -0
- package/package.json +1 -1
- package/src/components/Form/VTFormGroup.vue +5 -7
- package/src/components/Form/VTFormLabel.vue +20 -0
- package/src/components/Form/VTInput.vue +40 -0
- package/src/components/Form/VTInputIcon.vue +35 -0
- package/src/components/Form/VTInputPassword.vue +49 -0
- package/src/components/Form/VTTextarea.vue +22 -0
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export const formControlMixin = {
|
|
2
|
+
props: {
|
|
3
|
+
disabled: {
|
|
4
|
+
type: Boolean,
|
|
5
|
+
default: false,
|
|
6
|
+
},
|
|
7
|
+
headless: {
|
|
8
|
+
type: Boolean,
|
|
9
|
+
default: false,
|
|
10
|
+
},
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: [String, Number, Object, Array],
|
|
13
|
+
default: null,
|
|
14
|
+
},
|
|
15
|
+
variant: {
|
|
16
|
+
type: [String, Object, Function],
|
|
17
|
+
default: '',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
computed: {
|
|
22
|
+
attrsComputed() {
|
|
23
|
+
// `Object.assign` merges objects together to form a new object
|
|
24
|
+
return Object.assign(
|
|
25
|
+
{},
|
|
26
|
+
// We add all the listeners from the parent
|
|
27
|
+
this.$attrs,
|
|
28
|
+
// Then we can add custom listeners or override the
|
|
29
|
+
// behavior of some listeners.
|
|
30
|
+
{
|
|
31
|
+
// This ensures that the component works with v-model
|
|
32
|
+
onInput: (event) => {
|
|
33
|
+
// if (this.lazy) return;
|
|
34
|
+
this.$emit('update:modelValue', event.target.value);
|
|
35
|
+
},
|
|
36
|
+
onBlur: (event) => {
|
|
37
|
+
this.$emit('blur', event);
|
|
38
|
+
},
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
classComputed() {
|
|
44
|
+
return [
|
|
45
|
+
this.headless
|
|
46
|
+
? `${this.name}`
|
|
47
|
+
: 'leading-0 flex w-full max-w-full appearance-none items-center justify-between gap-3 rounded border border-solid px-3 py-2 font-inherit text-base text-inherit file:hidden focus:border-secondary-200',
|
|
48
|
+
// variant styles
|
|
49
|
+
this.headless
|
|
50
|
+
? `${this.name}--${this.variant}`
|
|
51
|
+
: this.isError
|
|
52
|
+
? 'border-error-300'
|
|
53
|
+
: 'border-gray-300',
|
|
54
|
+
// height styles
|
|
55
|
+
this.headless
|
|
56
|
+
? null
|
|
57
|
+
: this.name === 'textarea'
|
|
58
|
+
? 'min-h-10' // limit it because input type number height can be different from other input types
|
|
59
|
+
: 'h-10',
|
|
60
|
+
];
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
isError() {
|
|
64
|
+
return this.variant === 'error';
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
};
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="as" :class="
|
|
2
|
+
<component :is="as" :class="[headless ? 'form-control' : 'mt-3']">
|
|
3
3
|
<slot></slot>
|
|
4
4
|
</component>
|
|
5
5
|
</template>
|
|
@@ -11,12 +11,10 @@ export default {
|
|
|
11
11
|
type: String,
|
|
12
12
|
default: 'div',
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
classes: {},
|
|
19
|
-
};
|
|
14
|
+
headless: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
20
18
|
},
|
|
21
19
|
};
|
|
22
20
|
</script>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label
|
|
3
|
+
:class="[
|
|
4
|
+
headless ? 'form-label' : 'font-semibold mb-1 flex justify-between gap-3',
|
|
5
|
+
]"
|
|
6
|
+
>
|
|
7
|
+
<slot />
|
|
8
|
+
</label>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script>
|
|
12
|
+
export default {
|
|
13
|
+
props: {
|
|
14
|
+
headless: {
|
|
15
|
+
type: Boolean,
|
|
16
|
+
default: false,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input
|
|
3
|
+
:class="classComputed"
|
|
4
|
+
:value="modelValue"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
v-bind="attrsComputed"
|
|
7
|
+
/>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { formControlMixin } from '../../../mixins/form-control';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
mixins: [formControlMixin],
|
|
15
|
+
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
name: 'input',
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style scoped>
|
|
25
|
+
/* input[type='date']::-webkit-inner-spin-button,
|
|
26
|
+
input[type='date']::-webkit-calendar-picker-indicator {
|
|
27
|
+
position: absolute;
|
|
28
|
+
opacity: 0;
|
|
29
|
+
} */
|
|
30
|
+
|
|
31
|
+
input[type='number'] {
|
|
32
|
+
appearance: textfield;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
input[type='number']::-webkit-inner-spin-button,
|
|
36
|
+
input[type='number']::-webkit-outer-spin-button {
|
|
37
|
+
appearance: none;
|
|
38
|
+
-webkit-appearance: none;
|
|
39
|
+
}
|
|
40
|
+
</style>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classComputedWrapper">
|
|
3
|
+
<input
|
|
4
|
+
:class="classComputed"
|
|
5
|
+
:value="value"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
v-bind="attrsComputed"
|
|
8
|
+
/>
|
|
9
|
+
<div :class="classComputedWrapperIcon">
|
|
10
|
+
<component :is="icon" class="h-5 w-5" />
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script>
|
|
16
|
+
import { formControlIconMixin } from '../../../mixins/form-control-icon';
|
|
17
|
+
|
|
18
|
+
export default {
|
|
19
|
+
name: 'VTInputIcon',
|
|
20
|
+
|
|
21
|
+
mixins: [formControlIconMixin],
|
|
22
|
+
|
|
23
|
+
props: {
|
|
24
|
+
icon: {
|
|
25
|
+
type: String,
|
|
26
|
+
default: null,
|
|
27
|
+
required: true,
|
|
28
|
+
},
|
|
29
|
+
iconPlacement: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: 'left',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classComputedWrapper">
|
|
3
|
+
<input
|
|
4
|
+
:class="classComputed"
|
|
5
|
+
:value="modelValue"
|
|
6
|
+
:disabled="disabled"
|
|
7
|
+
:type="reveal ? 'text' : 'password'"
|
|
8
|
+
v-bind="attrsComputed"
|
|
9
|
+
/>
|
|
10
|
+
<div :class="classComputedWrapperIcon">
|
|
11
|
+
<VTButton
|
|
12
|
+
v-show="modelValue.length"
|
|
13
|
+
variant="icon"
|
|
14
|
+
@click="reveal = !reveal"
|
|
15
|
+
>
|
|
16
|
+
<component :is="iconVisibility" class="h-5 w-5" />
|
|
17
|
+
</VTButton>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script>
|
|
23
|
+
import { formControlIconMixin } from '../../../mixins/form-control-icon';
|
|
24
|
+
|
|
25
|
+
export default {
|
|
26
|
+
name: 'VTInputPassword',
|
|
27
|
+
|
|
28
|
+
mixins: [formControlIconMixin],
|
|
29
|
+
|
|
30
|
+
props: {
|
|
31
|
+
iconPlacement: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: 'right',
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
data() {
|
|
38
|
+
return {
|
|
39
|
+
reveal: false,
|
|
40
|
+
};
|
|
41
|
+
},
|
|
42
|
+
|
|
43
|
+
computed: {
|
|
44
|
+
iconVisibility() {
|
|
45
|
+
return this.reveal ? 'IconVisibilityOn' : 'IconVisibilityOff';
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<textarea
|
|
3
|
+
:class="classComputed"
|
|
4
|
+
:value="value"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
v-bind="attrsComputed"
|
|
7
|
+
/>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
import { formControlMixin } from '../../../mixins/form-control';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
mixins: [formControlMixin],
|
|
15
|
+
|
|
16
|
+
data() {
|
|
17
|
+
return {
|
|
18
|
+
name: 'textarea',
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
</script>
|