@kizmann/nano-ui 0.7.28 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kizmann/nano-ui",
3
- "version": "0.7.28",
3
+ "version": "0.8.0",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "author": "Eduard Kizmann <kizmann@protonmail.ch>",
@@ -1,4 +1,5 @@
1
1
  import { UUID, Num, Arr, Obj, Any, Dom, Locale } from "@kizmann/pico-js";
2
+ import { h } from "vue";
2
3
 
3
4
  export default {
4
5
 
@@ -12,6 +13,14 @@ export default {
12
13
 
13
14
  props: {
14
15
 
16
+ dom: {
17
+ default()
18
+ {
19
+ return 'div';
20
+ },
21
+ type: [String]
22
+ },
23
+
15
24
  form: {
16
25
  default()
17
26
  {
@@ -70,15 +79,32 @@ export default {
70
79
 
71
80
  },
72
81
 
82
+ computed: {
83
+
84
+ classList()
85
+ {
86
+ if ( ! this.$attrs.class ) {
87
+ return [];
88
+ }
89
+
90
+ return Any.isArray(this.$attrs) ? this.$attrs.class :
91
+ [this.$attrs.class];
92
+ }
93
+
94
+ },
95
+
73
96
  methods: {
74
97
 
75
98
  onSubmit(event)
76
99
  {
77
100
  if ( this.prevent ) {
101
+ event.preventDefault();
78
102
  event.stopPropagation();
79
103
  }
80
104
 
81
- this.$emit('submit', event);
105
+ if ( Dom.find(event.target).is('input') ) {
106
+ this.$emit('submit', event);
107
+ }
82
108
 
83
109
  return this.prevent;
84
110
  },
@@ -136,15 +162,17 @@ export default {
136
162
  'n-form--' + this.align,
137
163
  ];
138
164
 
139
- let attrs = Obj.except(this.$attrs, [
140
- 'onChange', 'onSubmit'
141
- ]);
165
+ let attrs = Obj.except(this.$attrs, ['class', 'onChange', 'onSubmit'], {
166
+ class: this.cmer(classList)
167
+ });
142
168
 
169
+ attrs['onSubmit'] = (e) => {
170
+ return false;
171
+ }
143
172
 
144
- return (
145
- <form class={classList} onSubmit={this.onSubmit} {...attrs}>
146
- { this.$slots.default && this.$slots.default() }
147
- </form>
148
- );
173
+ return h(this.dom, { ...attrs }, [
174
+ this.$slots.default && this.$slots.default()
175
+ ]);
149
176
  }
177
+
150
178
  }
@@ -135,7 +135,7 @@ export default {
135
135
  return;
136
136
  }
137
137
 
138
- this.NForm.onSubmit();
138
+ this.NForm.onSubmit(event);
139
139
  },
140
140
 
141
141
  onFocus(event)