@tak-ps/vue-tabler 4.4.0 → 4.5.0
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/CHANGELOG.md +8 -0
- package/components/Schema.vue +36 -6
- package/components/input/Input.vue +3 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
package/components/Schema.vue
CHANGED
|
@@ -158,23 +158,53 @@ watch(data, () => {
|
|
|
158
158
|
emit('update:modelValue', data.value);
|
|
159
159
|
}, { deep: true })
|
|
160
160
|
|
|
161
|
-
|
|
162
|
-
onMounted(async () => {
|
|
163
|
-
loading.value = true;
|
|
164
|
-
data.value = JSON.parse(JSON.stringify(props.modelValue));
|
|
161
|
+
const updateSchema = () => {
|
|
165
162
|
s.value = JSON.parse(JSON.stringify(props.schema));
|
|
166
|
-
|
|
167
163
|
if (s.value.type === 'object' && s.value.properties) {
|
|
168
164
|
for (const req of (s.value.required || [])) {
|
|
169
165
|
s.value.properties[req].required = true;
|
|
170
166
|
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
171
169
|
|
|
170
|
+
const updateDataDefaults = () => {
|
|
171
|
+
if (s.value.type === 'object' && s.value.properties) {
|
|
172
172
|
for (const key in s.value.properties) {
|
|
173
|
-
if (
|
|
173
|
+
if (data.value[key] !== undefined) continue;
|
|
174
|
+
|
|
175
|
+
const type = s.value.properties[key].type;
|
|
176
|
+
|
|
177
|
+
if (type === 'array') {
|
|
174
178
|
data.value[key] = [];
|
|
179
|
+
} else if (type === 'boolean') {
|
|
180
|
+
data.value[key] = false;
|
|
181
|
+
} else if (type === 'object') {
|
|
182
|
+
data.value[key] = {};
|
|
183
|
+
} else {
|
|
184
|
+
data.value[key] = '';
|
|
175
185
|
}
|
|
176
186
|
}
|
|
177
187
|
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
watch(() => props.schema, () => {
|
|
191
|
+
updateSchema();
|
|
192
|
+
updateDataDefaults();
|
|
193
|
+
}, { deep: true });
|
|
194
|
+
|
|
195
|
+
watch(() => props.modelValue, () => {
|
|
196
|
+
if (JSON.stringify(props.modelValue) !== JSON.stringify(data.value)) {
|
|
197
|
+
data.value = JSON.parse(JSON.stringify(props.modelValue));
|
|
198
|
+
updateDataDefaults();
|
|
199
|
+
}
|
|
200
|
+
}, { deep: true });
|
|
201
|
+
|
|
202
|
+
// Mounted lifecycle
|
|
203
|
+
onMounted(async () => {
|
|
204
|
+
loading.value = true;
|
|
205
|
+
data.value = JSON.parse(JSON.stringify(props.modelValue));
|
|
206
|
+
updateSchema();
|
|
207
|
+
updateDataDefaults();
|
|
178
208
|
|
|
179
209
|
loading.value = false;
|
|
180
210
|
})
|
|
@@ -217,8 +217,9 @@ const computed_type = computed(() => {
|
|
|
217
217
|
})
|
|
218
218
|
|
|
219
219
|
watch(() => props.modelValue, (newValue) => {
|
|
220
|
-
|
|
221
|
-
|
|
220
|
+
const n = newValue === undefined ? '' : String(newValue);
|
|
221
|
+
if (current.value !== n) {
|
|
222
|
+
current.value = n;
|
|
222
223
|
}
|
|
223
224
|
})
|
|
224
225
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tak-ps/vue-tabler",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"lib": "lib.ts",
|
|
6
6
|
"main": "lib.ts",
|
|
7
7
|
"module": "lib.ts",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@vue/cli-plugin-babel": "^5.0.8",
|
|
40
40
|
"eslint": "^9.12.0",
|
|
41
41
|
"eslint-plugin-vue": "^10.0.0",
|
|
42
|
-
"globals": "^
|
|
42
|
+
"globals": "^17.0.0",
|
|
43
43
|
"vue-tsc": "^3.2.1"
|
|
44
44
|
}
|
|
45
45
|
}
|