@indielayer/ui 0.2.0 → 0.2.1
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/lib/cjs/components/colors.vue.js +11 -0
- package/lib/cjs/components/{Colors.vue_vue_type_template_id_039e5c98_lang.js → colors.vue_vue_type_template_id_227ea690_lang.js} +0 -0
- package/lib/cjs/components/form/Form.vue.js +2 -1
- package/lib/cjs/components/form/Form.vue_vue_type_script_lang.js +48 -62
- package/lib/cjs/components/form/Form.vue_vue_type_template_id_bf90a49e_lang.js +20 -0
- package/lib/cjs/components/index.js +2 -2
- package/lib/cjs/composables/inputtable.js +22 -3
- package/lib/cjs/composables/interactive.js +3 -5
- package/lib/cjs/index.js +3 -2
- package/lib/esm/components/{Colors.vue.js → colors.vue.js} +1 -1
- package/lib/esm/components/{Colors.vue_vue_type_template_id_039e5c98_lang.js → colors.vue_vue_type_template_id_227ea690_lang.js} +0 -0
- package/lib/esm/components/form/Form.vue.js +3 -0
- package/lib/esm/components/form/Form.vue_vue_type_script_lang.js +49 -63
- package/lib/esm/components/form/Form.vue_vue_type_template_id_bf90a49e_lang.js +16 -0
- package/lib/esm/components/index.js +1 -1
- package/lib/esm/composables/inputtable.js +23 -4
- package/lib/esm/composables/interactive.js +3 -5
- package/lib/esm/index.js +2 -1
- package/lib/umd/index.js +1 -1
- package/package.json +2 -2
- package/src/components/form/Form.vue +57 -63
- package/src/components/index.js +1 -1
- package/src/composables/inputtable.js +23 -4
- package/src/composables/interactive.js +3 -5
- package/lib/cjs/components/Colors.vue.js +0 -11
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, computed, watch } from 'vue'
|
|
1
|
+
import { ref, computed, inject, watch, onMounted, onUnmounted } from 'vue'
|
|
2
2
|
import {
|
|
3
3
|
withValidator as withInteractiveValidator,
|
|
4
4
|
withProps as withInteractiveProps,
|
|
@@ -52,10 +52,21 @@ export const withEmits = (useListeners = true) => {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
export const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
55
|
+
const interactive = useInteractive()
|
|
56
|
+
|
|
55
57
|
const isFirstValidation = ref(true)
|
|
56
58
|
const errorInternal = ref(props.error)
|
|
57
59
|
|
|
60
|
+
const name = props.name ? props.name : (Math.random() + 1).toString(36).substring(7)
|
|
61
|
+
const nameInternal = ref(name)
|
|
62
|
+
|
|
58
63
|
watch(() => props.error, (val) => { errorInternal.value = val })
|
|
64
|
+
watch(() => props.name, (val) => { if (val) nameInternal.value = val })
|
|
65
|
+
|
|
66
|
+
const form = inject('form', {
|
|
67
|
+
registerInput: () => {},
|
|
68
|
+
unregisterInput: () => {},
|
|
69
|
+
})
|
|
59
70
|
|
|
60
71
|
const reset = () => {
|
|
61
72
|
errorInternal.value = ''
|
|
@@ -63,7 +74,7 @@ export const useInputtable = (props, { attrs, emit, useListeners = true } = {})
|
|
|
63
74
|
emit('update:modelValue', '')
|
|
64
75
|
}
|
|
65
76
|
|
|
66
|
-
const
|
|
77
|
+
const setError = (val) => {
|
|
67
78
|
errorInternal.value = val
|
|
68
79
|
}
|
|
69
80
|
|
|
@@ -120,8 +131,16 @@ export const useInputtable = (props, { attrs, emit, useListeners = true } = {})
|
|
|
120
131
|
}
|
|
121
132
|
}) : ref({})
|
|
122
133
|
|
|
134
|
+
onMounted(() => {
|
|
135
|
+
form.registerInput(nameInternal.value, { focus: interactive.focus, validate, setError })
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
onUnmounted(() => {
|
|
139
|
+
form.unregisterInput(nameInternal.value)
|
|
140
|
+
})
|
|
141
|
+
|
|
123
142
|
return {
|
|
124
|
-
...
|
|
143
|
+
...interactive,
|
|
125
144
|
|
|
126
145
|
// data
|
|
127
146
|
isFirstValidation,
|
|
@@ -133,6 +152,6 @@ export const useInputtable = (props, { attrs, emit, useListeners = true } = {})
|
|
|
133
152
|
// methods
|
|
134
153
|
reset,
|
|
135
154
|
validate,
|
|
136
|
-
|
|
155
|
+
setError,
|
|
137
156
|
}
|
|
138
157
|
}
|
|
@@ -25,14 +25,12 @@ export const withValidator = () => validator
|
|
|
25
25
|
export const useInteractive = () => {
|
|
26
26
|
const focusRef = ref(null)
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
if (focusRef.value) focusRef.value.focus()
|
|
31
|
-
},
|
|
28
|
+
const focus = () => {
|
|
29
|
+
if (focusRef.value) focusRef.value.focus()
|
|
32
30
|
}
|
|
33
31
|
|
|
34
32
|
return {
|
|
35
33
|
focusRef,
|
|
36
|
-
|
|
34
|
+
focus,
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Colors_vue_vue_type_template_id_039e5c98_lang = require('./Colors.vue_vue_type_template_id_039e5c98_lang.js');
|
|
4
|
-
|
|
5
|
-
const script = {};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
script.render = Colors_vue_vue_type_template_id_039e5c98_lang.render;
|
|
9
|
-
var script$1 = script;
|
|
10
|
-
|
|
11
|
-
module.exports = script$1;
|