@kizmann/nano-ui 0.7.27 → 0.7.28
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/dist/nano-ui.js +1 -1
- package/dist/nano-ui.js.map +1 -1
- package/package.json +1 -1
- package/src/form/src/form/form.js +13 -48
- package/src/input/src/input/input.js +40 -16
package/package.json
CHANGED
@@ -4,6 +4,8 @@ export default {
|
|
4
4
|
|
5
5
|
name: 'NForm',
|
6
6
|
|
7
|
+
inheritAttrs: false,
|
8
|
+
|
7
9
|
model: {
|
8
10
|
prop: 'form'
|
9
11
|
},
|
@@ -73,7 +75,6 @@ export default {
|
|
73
75
|
onSubmit(event)
|
74
76
|
{
|
75
77
|
if ( this.prevent ) {
|
76
|
-
event.preventDefault();
|
77
78
|
event.stopPropagation();
|
78
79
|
}
|
79
80
|
|
@@ -96,28 +97,11 @@ export default {
|
|
96
97
|
});
|
97
98
|
},
|
98
99
|
|
99
|
-
|
100
|
+
emitChange(form)
|
100
101
|
{
|
101
|
-
|
102
|
-
|
103
|
-
if ( Any.md5(veForm) !== Any.md5(this.veForm) || this.forceChange ) {
|
104
|
-
this.$emit('change');
|
105
|
-
}
|
106
|
-
|
107
|
-
this.veForm = veForm;
|
102
|
+
this.$emit('change');
|
108
103
|
},
|
109
104
|
|
110
|
-
setErrors(errors)
|
111
|
-
{
|
112
|
-
let veErrors = Obj.clone(errors);
|
113
|
-
|
114
|
-
if ( Any.md5(veErrors) !== Any.md5(this.veErrors) || this.forceErrors ) {
|
115
|
-
this.$emit('errors');
|
116
|
-
}
|
117
|
-
|
118
|
-
this.veErrors = veErrors;
|
119
|
-
}
|
120
|
-
|
121
105
|
},
|
122
106
|
|
123
107
|
data()
|
@@ -137,36 +121,12 @@ export default {
|
|
137
121
|
|
138
122
|
mounted()
|
139
123
|
{
|
140
|
-
|
141
|
-
// { deep: true });
|
142
|
-
|
143
|
-
// this.$watch('errors', () => this.setErrors(this.errors),
|
144
|
-
// { deep: true });
|
145
|
-
|
146
|
-
// let ident = {
|
147
|
-
// _uid: this.uid
|
148
|
-
// };
|
149
|
-
|
150
|
-
// if ( this.propagation ) {
|
151
|
-
// return;
|
152
|
-
// }
|
153
|
-
|
154
|
-
// Dom.find(this.$el).on('submit',
|
155
|
-
// this.onSubmit, this._.uid);
|
124
|
+
Any.delay(this.ctor('ready'), 1000);
|
156
125
|
},
|
157
126
|
|
158
|
-
|
127
|
+
ready()
|
159
128
|
{
|
160
|
-
|
161
|
-
// _uid: this.uid
|
162
|
-
// };
|
163
|
-
|
164
|
-
// if ( this.propagation ) {
|
165
|
-
// return;
|
166
|
-
// }
|
167
|
-
|
168
|
-
// Dom.find(this.$el).off('submit',
|
169
|
-
// null, this._.uid);
|
129
|
+
this.$watch('form', this.emitChange, { deep: true });
|
170
130
|
},
|
171
131
|
|
172
132
|
render()
|
@@ -176,8 +136,13 @@ export default {
|
|
176
136
|
'n-form--' + this.align,
|
177
137
|
];
|
178
138
|
|
139
|
+
let attrs = Obj.except(this.$attrs, [
|
140
|
+
'onChange', 'onSubmit'
|
141
|
+
]);
|
142
|
+
|
143
|
+
|
179
144
|
return (
|
180
|
-
<form class={classList} onSubmit={this.onSubmit}>
|
145
|
+
<form class={classList} onSubmit={this.onSubmit} {...attrs}>
|
181
146
|
{ this.$slots.default && this.$slots.default() }
|
182
147
|
</form>
|
183
148
|
);
|
@@ -5,6 +5,14 @@ export default {
|
|
5
5
|
|
6
6
|
name: 'NInput',
|
7
7
|
|
8
|
+
inject: {
|
9
|
+
|
10
|
+
NForm: {
|
11
|
+
default: undefined
|
12
|
+
}
|
13
|
+
|
14
|
+
},
|
15
|
+
|
8
16
|
inheritAttrs: false,
|
9
17
|
|
10
18
|
props: {
|
@@ -111,10 +119,25 @@ export default {
|
|
111
119
|
|
112
120
|
onInput(event)
|
113
121
|
{
|
114
|
-
this.$emit('update:modelValue',
|
122
|
+
this.$emit('update:modelValue',
|
115
123
|
this.tempValue = event.target.value);
|
116
124
|
},
|
117
125
|
|
126
|
+
onKeydown(event)
|
127
|
+
{
|
128
|
+
if ( event.which !== 13 ) {
|
129
|
+
return;
|
130
|
+
}
|
131
|
+
|
132
|
+
event.preventDefault();
|
133
|
+
|
134
|
+
if ( ! this.NForm ) {
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
|
138
|
+
this.NForm.onSubmit();
|
139
|
+
},
|
140
|
+
|
118
141
|
onFocus(event)
|
119
142
|
{
|
120
143
|
this.focus = true;
|
@@ -129,22 +152,22 @@ export default {
|
|
129
152
|
|
130
153
|
renderIcon()
|
131
154
|
{
|
132
|
-
if ( !
|
155
|
+
if ( !this.icon ) {
|
133
156
|
return null;
|
134
157
|
}
|
135
158
|
|
136
|
-
let disabled = this.disabled ||
|
159
|
+
let disabled = this.disabled ||
|
137
160
|
this.iconDisabled;
|
138
161
|
|
139
162
|
let props = {
|
140
|
-
type:
|
141
|
-
icon:
|
142
|
-
size:
|
143
|
-
square:
|
144
|
-
disabled:
|
163
|
+
type: 'input',
|
164
|
+
icon: this.icon,
|
165
|
+
size: this.size,
|
166
|
+
square: true,
|
167
|
+
disabled: disabled,
|
145
168
|
};
|
146
169
|
|
147
|
-
if ( !
|
170
|
+
if ( !disabled ) {
|
148
171
|
props.onClick = this.onIconClick;
|
149
172
|
}
|
150
173
|
|
@@ -158,13 +181,14 @@ export default {
|
|
158
181
|
]);
|
159
182
|
|
160
183
|
Obj.assign(props, {
|
161
|
-
value:
|
162
|
-
type:
|
163
|
-
disabled:
|
164
|
-
placeholder:
|
165
|
-
onInput:
|
166
|
-
onFocus:
|
167
|
-
onBlur:
|
184
|
+
value: this.tempValue,
|
185
|
+
type: this.nativeType,
|
186
|
+
disabled: this.disabled,
|
187
|
+
placeholder: this.placeholder,
|
188
|
+
onInput: this.onInput,
|
189
|
+
onFocus: this.onFocus,
|
190
|
+
onBlur: this.onBlur,
|
191
|
+
onKeydown: this.onKeydown
|
168
192
|
});
|
169
193
|
|
170
194
|
return h('input', props);
|