@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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var colors_vue_vue_type_template_id_227ea690_lang = require('./colors.vue_vue_type_template_id_227ea690_lang.js');
|
|
4
|
+
|
|
5
|
+
const script = {};
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
script.render = colors_vue_vue_type_template_id_227ea690_lang.render;
|
|
9
|
+
var script$1 = script;
|
|
10
|
+
|
|
11
|
+
module.exports = script$1;
|
|
File without changes
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var Form_vue_vue_type_script_lang = require('./Form.vue_vue_type_script_lang.js');
|
|
4
|
+
var Form_vue_vue_type_template_id_bf90a49e_lang = require('./Form.vue_vue_type_template_id_bf90a49e_lang.js');
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
Form_vue_vue_type_script_lang.render = Form_vue_vue_type_template_id_bf90a49e_lang.render;
|
|
6
7
|
|
|
7
8
|
module.exports = Form_vue_vue_type_script_lang;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var vue = require('vue');
|
|
4
4
|
|
|
5
|
-
var script =
|
|
5
|
+
var script = {
|
|
6
6
|
name: 'XForm',
|
|
7
7
|
inheritAttrs: false,
|
|
8
8
|
props: {
|
|
@@ -23,42 +23,46 @@ var script = vue.defineComponent({
|
|
|
23
23
|
default: () => [],
|
|
24
24
|
},
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
|
|
27
|
+
setup(props, { emit }) {
|
|
28
|
+
const inputs = [];
|
|
29
|
+
|
|
30
|
+
vue.provide('form', {
|
|
31
|
+
registerInput: (name, { focus, validate, setError }) => {
|
|
32
|
+
const exists = inputs.find((i) => i.name === name);
|
|
33
|
+
|
|
34
|
+
if (exists) {
|
|
35
|
+
exists.focus = focus;
|
|
36
|
+
exists.validate = validate;
|
|
37
|
+
exists.setError = setError;
|
|
38
|
+
}
|
|
39
|
+
else inputs.push({ name, focus, validate, setError });
|
|
40
|
+
},
|
|
41
|
+
unregisterInput: (name) => {
|
|
42
|
+
const index = inputs.findIndex((i) => i.name === name);
|
|
43
|
+
|
|
44
|
+
inputs.splice(index, 1);
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
vue.onMounted(() => {
|
|
49
|
+
if (props.autoFocus && inputs && inputs.length > 0) inputs[0].focus();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
vue.watch(() => props.errors, (errors) => {
|
|
53
|
+
vue.nextTick(() => {
|
|
34
54
|
errors.forEach((error) => {
|
|
35
|
-
const input =
|
|
55
|
+
const input = inputs.find((i) => i.name === error.field);
|
|
36
56
|
|
|
37
|
-
if (input) input.
|
|
57
|
+
if (input) input.setError(error.msg);
|
|
38
58
|
});
|
|
39
59
|
});
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
mounted() {
|
|
43
|
-
this.getInputs(this.vnodesInDefaultSlot);
|
|
44
|
-
|
|
45
|
-
if (this.autoFocus) {
|
|
46
|
-
if (this.inputs && this.inputs.length > 0) this.inputs[0].focus();
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
methods: {
|
|
50
|
-
submit(e) {
|
|
51
|
-
e.preventDefault();
|
|
52
|
-
e.stopPropagation();
|
|
53
|
-
|
|
54
|
-
const isFormValid = this.autoValidate ? this.validate() : true;
|
|
60
|
+
});
|
|
55
61
|
|
|
56
|
-
|
|
57
|
-
},
|
|
58
|
-
validate() {
|
|
62
|
+
const validate = () => {
|
|
59
63
|
let isFormValid = true;
|
|
60
64
|
|
|
61
|
-
|
|
65
|
+
inputs.forEach((input) => {
|
|
62
66
|
const isInputValid = input.validate();
|
|
63
67
|
|
|
64
68
|
if (!isInputValid && isFormValid) {
|
|
@@ -70,40 +74,22 @@ var script = vue.defineComponent({
|
|
|
70
74
|
});
|
|
71
75
|
|
|
72
76
|
return isFormValid
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const submit = (e) => {
|
|
80
|
+
e.preventDefault();
|
|
81
|
+
e.stopPropagation();
|
|
76
82
|
|
|
77
|
-
|
|
78
|
-
const vInstance = vNode.component?.ctx;
|
|
83
|
+
const isFormValid = props.autoValidate ? validate() : true;
|
|
79
84
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
this.vnodesInDefaultSlot = vnodesInDefaultSlot;
|
|
89
|
-
|
|
90
|
-
return vue.h(
|
|
91
|
-
'form',
|
|
92
|
-
{
|
|
93
|
-
onKeyUp: (event) => {
|
|
94
|
-
if (event.target !== event.currentTarget) return
|
|
95
|
-
if (event.key === 'Enter') this.submit(event);
|
|
96
|
-
},
|
|
97
|
-
onSubmit: this.submit,
|
|
98
|
-
},
|
|
99
|
-
[
|
|
100
|
-
vue.h('fieldset', {
|
|
101
|
-
disabled: this.disabled,
|
|
102
|
-
},
|
|
103
|
-
vnodesInDefaultSlot),
|
|
104
|
-
],
|
|
105
|
-
)
|
|
85
|
+
emit('submit', isFormValid);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
validate,
|
|
90
|
+
submit,
|
|
91
|
+
}
|
|
106
92
|
},
|
|
107
|
-
}
|
|
93
|
+
};
|
|
108
94
|
|
|
109
95
|
module.exports = script;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var vue = require('vue');
|
|
6
|
+
|
|
7
|
+
const _hoisted_1 = ["disabled"];
|
|
8
|
+
|
|
9
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
10
|
+
return (vue.openBlock(), vue.createElementBlock("form", {
|
|
11
|
+
onSubmit: _cache[0] || (_cache[0] = (...args) => ($setup.submit && $setup.submit(...args))),
|
|
12
|
+
onKeypress: _cache[1] || (_cache[1] = vue.withKeys((...args) => ($setup.submit && $setup.submit(...args)), ["enter"]))
|
|
13
|
+
}, [
|
|
14
|
+
vue.createElementVNode("fieldset", { disabled: $props.disabled }, [
|
|
15
|
+
vue.renderSlot(_ctx.$slots, "default")
|
|
16
|
+
], 8, _hoisted_1)
|
|
17
|
+
], 32))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
exports.render = render;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var Spacer = require('./spacer/Spacer.vue.js');
|
|
6
|
-
var
|
|
6
|
+
var colors = require('./colors.vue.js');
|
|
7
7
|
var Avatar_vue_vue_type_script_lang = require('./avatar/Avatar.vue_vue_type_script_lang.js');
|
|
8
8
|
var Button_vue_vue_type_script_lang = require('./button/Button.vue_vue_type_script_lang.js');
|
|
9
9
|
var Card_vue_vue_type_script_lang = require('./card/Card.vue_vue_type_script_lang.js');
|
|
@@ -46,7 +46,7 @@ var Tooltip_vue_vue_type_script_lang = require('./tooltip/Tooltip.vue_vue_type_s
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
exports.Spacer = Spacer;
|
|
49
|
-
exports.Colors =
|
|
49
|
+
exports.Colors = colors;
|
|
50
50
|
exports.Avatar = Avatar_vue_vue_type_script_lang;
|
|
51
51
|
exports.Button = Button_vue_vue_type_script_lang;
|
|
52
52
|
exports.Card = Card_vue_vue_type_script_lang;
|
|
@@ -52,10 +52,21 @@ const withEmits = (useListeners = true) => {
|
|
|
52
52
|
};
|
|
53
53
|
|
|
54
54
|
const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
55
|
+
const interactive$1 = interactive.useInteractive();
|
|
56
|
+
|
|
55
57
|
const isFirstValidation = vue.ref(true);
|
|
56
58
|
const errorInternal = vue.ref(props.error);
|
|
57
59
|
|
|
60
|
+
const name = props.name ? props.name : (Math.random() + 1).toString(36).substring(7);
|
|
61
|
+
const nameInternal = vue.ref(name);
|
|
62
|
+
|
|
58
63
|
vue.watch(() => props.error, (val) => { errorInternal.value = val; });
|
|
64
|
+
vue.watch(() => props.name, (val) => { if (val) nameInternal.value = val; });
|
|
65
|
+
|
|
66
|
+
const form = vue.inject('form', {
|
|
67
|
+
registerInput: () => {},
|
|
68
|
+
unregisterInput: () => {},
|
|
69
|
+
});
|
|
59
70
|
|
|
60
71
|
const reset = () => {
|
|
61
72
|
errorInternal.value = '';
|
|
@@ -63,7 +74,7 @@ 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 @@ const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
|
120
131
|
}
|
|
121
132
|
}) : vue.ref({});
|
|
122
133
|
|
|
134
|
+
vue.onMounted(() => {
|
|
135
|
+
form.registerInput(nameInternal.value, { focus: interactive$1.focus, validate, setError });
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
vue.onUnmounted(() => {
|
|
139
|
+
form.unregisterInput(nameInternal.value);
|
|
140
|
+
});
|
|
141
|
+
|
|
123
142
|
return {
|
|
124
|
-
...interactive
|
|
143
|
+
...interactive$1,
|
|
125
144
|
|
|
126
145
|
// data
|
|
127
146
|
isFirstValidation,
|
|
@@ -133,7 +152,7 @@ const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
|
133
152
|
// methods
|
|
134
153
|
reset,
|
|
135
154
|
validate,
|
|
136
|
-
|
|
155
|
+
setError,
|
|
137
156
|
}
|
|
138
157
|
};
|
|
139
158
|
|
|
@@ -26,15 +26,13 @@ const withValidator = () => validator;
|
|
|
26
26
|
const useInteractive = () => {
|
|
27
27
|
const focusRef = vue.ref(null);
|
|
28
28
|
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
if (focusRef.value) focusRef.value.focus();
|
|
32
|
-
},
|
|
29
|
+
const focus = () => {
|
|
30
|
+
if (focusRef.value) focusRef.value.focus();
|
|
33
31
|
};
|
|
34
32
|
|
|
35
33
|
return {
|
|
36
34
|
focusRef,
|
|
37
|
-
|
|
35
|
+
focus,
|
|
38
36
|
}
|
|
39
37
|
};
|
|
40
38
|
|
package/lib/cjs/index.js
CHANGED
|
@@ -17,6 +17,7 @@ require('./components/container/Container.vue.js');
|
|
|
17
17
|
var Container_vue_vue_type_script_lang = require('./components/container/Container.vue_vue_type_script_lang.js');
|
|
18
18
|
require('./components/divider/Divider.vue.js');
|
|
19
19
|
var Divider_vue_vue_type_script_lang = require('./components/divider/Divider.vue_vue_type_script_lang.js');
|
|
20
|
+
require('./components/form/Form.vue.js');
|
|
20
21
|
var Form_vue_vue_type_script_lang = require('./components/form/Form.vue_vue_type_script_lang.js');
|
|
21
22
|
require('./components/image/Image.vue.js');
|
|
22
23
|
var Image_vue_vue_type_script_lang = require('./components/image/Image.vue_vue_type_script_lang.js');
|
|
@@ -71,7 +72,7 @@ var TableCell_vue_vue_type_script_lang = require('./components/table/TableCell.v
|
|
|
71
72
|
var TableHead_vue_vue_type_script_lang = require('./components/table/TableHead.vue_vue_type_script_lang.js');
|
|
72
73
|
var TableHeader_vue_vue_type_script_lang = require('./components/table/TableHeader.vue_vue_type_script_lang.js');
|
|
73
74
|
var TableRow_vue_vue_type_script_lang = require('./components/table/TableRow.vue_vue_type_script_lang.js');
|
|
74
|
-
var
|
|
75
|
+
var colors = require('./components/colors.vue.js');
|
|
75
76
|
|
|
76
77
|
const install = (Vue, config = {}) => {
|
|
77
78
|
Object.entries(index).forEach(([name, component]) => {
|
|
@@ -124,5 +125,5 @@ exports.TableCell = TableCell_vue_vue_type_script_lang;
|
|
|
124
125
|
exports.TableHead = TableHead_vue_vue_type_script_lang;
|
|
125
126
|
exports.TableHeader = TableHeader_vue_vue_type_script_lang;
|
|
126
127
|
exports.TableRow = TableRow_vue_vue_type_script_lang;
|
|
127
|
-
exports.Colors =
|
|
128
|
+
exports.Colors = colors;
|
|
128
129
|
exports["default"] = install;
|
|
File without changes
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { provide, onMounted, watch, nextTick } from 'vue';
|
|
2
2
|
|
|
3
|
-
var script =
|
|
3
|
+
var script = {
|
|
4
4
|
name: 'XForm',
|
|
5
5
|
inheritAttrs: false,
|
|
6
6
|
props: {
|
|
@@ -21,42 +21,46 @@ var script = defineComponent({
|
|
|
21
21
|
default: () => [],
|
|
22
22
|
},
|
|
23
23
|
},
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
24
|
+
|
|
25
|
+
setup(props, { emit }) {
|
|
26
|
+
const inputs = [];
|
|
27
|
+
|
|
28
|
+
provide('form', {
|
|
29
|
+
registerInput: (name, { focus, validate, setError }) => {
|
|
30
|
+
const exists = inputs.find((i) => i.name === name);
|
|
31
|
+
|
|
32
|
+
if (exists) {
|
|
33
|
+
exists.focus = focus;
|
|
34
|
+
exists.validate = validate;
|
|
35
|
+
exists.setError = setError;
|
|
36
|
+
}
|
|
37
|
+
else inputs.push({ name, focus, validate, setError });
|
|
38
|
+
},
|
|
39
|
+
unregisterInput: (name) => {
|
|
40
|
+
const index = inputs.findIndex((i) => i.name === name);
|
|
41
|
+
|
|
42
|
+
inputs.splice(index, 1);
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
onMounted(() => {
|
|
47
|
+
if (props.autoFocus && inputs && inputs.length > 0) inputs[0].focus();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
watch(() => props.errors, (errors) => {
|
|
51
|
+
nextTick(() => {
|
|
32
52
|
errors.forEach((error) => {
|
|
33
|
-
const input =
|
|
53
|
+
const input = inputs.find((i) => i.name === error.field);
|
|
34
54
|
|
|
35
|
-
if (input) input.
|
|
55
|
+
if (input) input.setError(error.msg);
|
|
36
56
|
});
|
|
37
57
|
});
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
mounted() {
|
|
41
|
-
this.getInputs(this.vnodesInDefaultSlot);
|
|
42
|
-
|
|
43
|
-
if (this.autoFocus) {
|
|
44
|
-
if (this.inputs && this.inputs.length > 0) this.inputs[0].focus();
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
methods: {
|
|
48
|
-
submit(e) {
|
|
49
|
-
e.preventDefault();
|
|
50
|
-
e.stopPropagation();
|
|
51
|
-
|
|
52
|
-
const isFormValid = this.autoValidate ? this.validate() : true;
|
|
58
|
+
});
|
|
53
59
|
|
|
54
|
-
|
|
55
|
-
},
|
|
56
|
-
validate() {
|
|
60
|
+
const validate = () => {
|
|
57
61
|
let isFormValid = true;
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
inputs.forEach((input) => {
|
|
60
64
|
const isInputValid = input.validate();
|
|
61
65
|
|
|
62
66
|
if (!isInputValid && isFormValid) {
|
|
@@ -68,40 +72,22 @@ var script = defineComponent({
|
|
|
68
72
|
});
|
|
69
73
|
|
|
70
74
|
return isFormValid
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const submit = (e) => {
|
|
78
|
+
e.preventDefault();
|
|
79
|
+
e.stopPropagation();
|
|
74
80
|
|
|
75
|
-
|
|
76
|
-
const vInstance = vNode.component?.ctx;
|
|
81
|
+
const isFormValid = props.autoValidate ? validate() : true;
|
|
77
82
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.vnodesInDefaultSlot = vnodesInDefaultSlot;
|
|
87
|
-
|
|
88
|
-
return h(
|
|
89
|
-
'form',
|
|
90
|
-
{
|
|
91
|
-
onKeyUp: (event) => {
|
|
92
|
-
if (event.target !== event.currentTarget) return
|
|
93
|
-
if (event.key === 'Enter') this.submit(event);
|
|
94
|
-
},
|
|
95
|
-
onSubmit: this.submit,
|
|
96
|
-
},
|
|
97
|
-
[
|
|
98
|
-
h('fieldset', {
|
|
99
|
-
disabled: this.disabled,
|
|
100
|
-
},
|
|
101
|
-
vnodesInDefaultSlot),
|
|
102
|
-
],
|
|
103
|
-
)
|
|
83
|
+
emit('submit', isFormValid);
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
return {
|
|
87
|
+
validate,
|
|
88
|
+
submit,
|
|
89
|
+
}
|
|
104
90
|
},
|
|
105
|
-
}
|
|
91
|
+
};
|
|
106
92
|
|
|
107
93
|
export { script as default };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { openBlock, createElementBlock, withKeys, createElementVNode, renderSlot } from 'vue';
|
|
2
|
+
|
|
3
|
+
const _hoisted_1 = ["disabled"];
|
|
4
|
+
|
|
5
|
+
function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
6
|
+
return (openBlock(), createElementBlock("form", {
|
|
7
|
+
onSubmit: _cache[0] || (_cache[0] = (...args) => ($setup.submit && $setup.submit(...args))),
|
|
8
|
+
onKeypress: _cache[1] || (_cache[1] = withKeys((...args) => ($setup.submit && $setup.submit(...args)), ["enter"]))
|
|
9
|
+
}, [
|
|
10
|
+
createElementVNode("fieldset", { disabled: $props.disabled }, [
|
|
11
|
+
renderSlot(_ctx.$slots, "default")
|
|
12
|
+
], 8, _hoisted_1)
|
|
13
|
+
], 32))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export { render };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { default as Spacer } from './spacer/Spacer.vue.js';
|
|
2
|
-
export { default as Colors } from './
|
|
2
|
+
export { default as Colors } from './colors.vue.js';
|
|
3
3
|
export { default as Avatar } from './avatar/Avatar.vue_vue_type_script_lang.js';
|
|
4
4
|
export { default as Button } from './button/Button.vue_vue_type_script_lang.js';
|
|
5
5
|
export { default as Card } from './card/Card.vue_vue_type_script_lang.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ref, watch, computed } from 'vue';
|
|
1
|
+
import { ref, watch, inject, computed, onMounted, onUnmounted } from 'vue';
|
|
2
2
|
import { withProps as withProps$1, useInteractive, withValidator as withValidator$1 } from './interactive.js';
|
|
3
3
|
|
|
4
4
|
const validator = {
|
|
@@ -48,10 +48,21 @@ const withEmits = (useListeners = true) => {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
51
|
+
const interactive = useInteractive();
|
|
52
|
+
|
|
51
53
|
const isFirstValidation = ref(true);
|
|
52
54
|
const errorInternal = ref(props.error);
|
|
53
55
|
|
|
56
|
+
const name = props.name ? props.name : (Math.random() + 1).toString(36).substring(7);
|
|
57
|
+
const nameInternal = ref(name);
|
|
58
|
+
|
|
54
59
|
watch(() => props.error, (val) => { errorInternal.value = val; });
|
|
60
|
+
watch(() => props.name, (val) => { if (val) nameInternal.value = val; });
|
|
61
|
+
|
|
62
|
+
const form = inject('form', {
|
|
63
|
+
registerInput: () => {},
|
|
64
|
+
unregisterInput: () => {},
|
|
65
|
+
});
|
|
55
66
|
|
|
56
67
|
const reset = () => {
|
|
57
68
|
errorInternal.value = '';
|
|
@@ -59,7 +70,7 @@ const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
|
59
70
|
emit('update:modelValue', '');
|
|
60
71
|
};
|
|
61
72
|
|
|
62
|
-
const
|
|
73
|
+
const setError = (val) => {
|
|
63
74
|
errorInternal.value = val;
|
|
64
75
|
};
|
|
65
76
|
|
|
@@ -116,8 +127,16 @@ const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
|
116
127
|
}
|
|
117
128
|
}) : ref({});
|
|
118
129
|
|
|
130
|
+
onMounted(() => {
|
|
131
|
+
form.registerInput(nameInternal.value, { focus: interactive.focus, validate, setError });
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
onUnmounted(() => {
|
|
135
|
+
form.unregisterInput(nameInternal.value);
|
|
136
|
+
});
|
|
137
|
+
|
|
119
138
|
return {
|
|
120
|
-
...
|
|
139
|
+
...interactive,
|
|
121
140
|
|
|
122
141
|
// data
|
|
123
142
|
isFirstValidation,
|
|
@@ -129,7 +148,7 @@ const useInputtable = (props, { attrs, emit, useListeners = true } = {}) => {
|
|
|
129
148
|
// methods
|
|
130
149
|
reset,
|
|
131
150
|
validate,
|
|
132
|
-
|
|
151
|
+
setError,
|
|
133
152
|
}
|
|
134
153
|
};
|
|
135
154
|
|
|
@@ -22,15 +22,13 @@ const withValidator = () => validator;
|
|
|
22
22
|
const useInteractive = () => {
|
|
23
23
|
const focusRef = ref(null);
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if (focusRef.value) focusRef.value.focus();
|
|
28
|
-
},
|
|
25
|
+
const focus = () => {
|
|
26
|
+
if (focusRef.value) focusRef.value.focus();
|
|
29
27
|
};
|
|
30
28
|
|
|
31
29
|
return {
|
|
32
30
|
focusRef,
|
|
33
|
-
|
|
31
|
+
focus,
|
|
34
32
|
}
|
|
35
33
|
};
|
|
36
34
|
|
package/lib/esm/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import './components/container/Container.vue.js';
|
|
|
13
13
|
export { default as Container } from './components/container/Container.vue_vue_type_script_lang.js';
|
|
14
14
|
import './components/divider/Divider.vue.js';
|
|
15
15
|
export { default as Divider } from './components/divider/Divider.vue_vue_type_script_lang.js';
|
|
16
|
+
import './components/form/Form.vue.js';
|
|
16
17
|
export { default as Form } from './components/form/Form.vue_vue_type_script_lang.js';
|
|
17
18
|
import './components/image/Image.vue.js';
|
|
18
19
|
export { default as Image } from './components/image/Image.vue_vue_type_script_lang.js';
|
|
@@ -67,7 +68,7 @@ export { default as TableCell } from './components/table/TableCell.vue_vue_type_
|
|
|
67
68
|
export { default as TableHead } from './components/table/TableHead.vue_vue_type_script_lang.js';
|
|
68
69
|
export { default as TableHeader } from './components/table/TableHeader.vue_vue_type_script_lang.js';
|
|
69
70
|
export { default as TableRow } from './components/table/TableRow.vue_vue_type_script_lang.js';
|
|
70
|
-
export { default as Colors } from './components/
|
|
71
|
+
export { default as Colors } from './components/colors.vue.js';
|
|
71
72
|
|
|
72
73
|
const install = (Vue, config = {}) => {
|
|
73
74
|
Object.entries(index).forEach(([name, component]) => {
|