@mouseless/baked 1.1.1 → 1.1.3
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/module.json
CHANGED
|
@@ -223,5 +223,5 @@ function exportFunction({ data: data2, field }) {
|
|
|
223
223
|
</script>
|
|
224
224
|
|
|
225
225
|
<style>
|
|
226
|
-
.b-component--DataTable
|
|
226
|
+
.b-component--DataTable a{@apply text-sm}.b-component--DataTable .p-button{@apply -my-2}
|
|
227
227
|
</style>
|
|
@@ -26,10 +26,12 @@ onMounted(async () => {
|
|
|
26
26
|
if (schema.default && dataFetcher.shouldLoad(schema.default.type)) {
|
|
27
27
|
defaultValue = await dataFetcher.fetch({ data: schema.default, contextData });
|
|
28
28
|
}
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
if (!checkValue(model.value)) {
|
|
30
|
+
if (schema.queryBound && checkValue(query.value)) {
|
|
31
|
+
model.value = query.value;
|
|
32
|
+
} else {
|
|
33
|
+
await set(defaultValue);
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
if (schema.queryBound) {
|
|
35
37
|
watch(() => route.query, async (newQuery) => {
|
|
@@ -2,49 +2,62 @@
|
|
|
2
2
|
<Input
|
|
3
3
|
v-for="input in inputs"
|
|
4
4
|
:key="input.name"
|
|
5
|
-
v-model="
|
|
5
|
+
v-model="models[input.name]"
|
|
6
6
|
:schema="input"
|
|
7
7
|
:class="inputClass"
|
|
8
8
|
/>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
11
|
<script setup>
|
|
12
|
-
import {
|
|
13
|
-
import { useContext } from "#imports";
|
|
12
|
+
import { computed, reactive, watch } from "vue";
|
|
13
|
+
import { useContext, useRoute } from "#imports";
|
|
14
14
|
import { Input } from "#components";
|
|
15
15
|
const context = useContext();
|
|
16
|
+
const route = useRoute();
|
|
16
17
|
const { inputs } = defineProps({
|
|
17
18
|
inputs: { type: Array, required: true },
|
|
18
19
|
inputClass: { type: String, default: "" }
|
|
19
20
|
});
|
|
20
21
|
const emit = defineEmits(["ready", "changed"]);
|
|
21
22
|
const parentPath = context.injectPath();
|
|
22
|
-
const
|
|
23
|
+
const models = reactive({});
|
|
24
|
+
const values = computed(
|
|
25
|
+
() => inputs.reduce((result, input) => {
|
|
26
|
+
result[input.name] = getValue(input);
|
|
27
|
+
return result;
|
|
28
|
+
}, {})
|
|
29
|
+
);
|
|
23
30
|
context.providePath(`${parentPath}/inputs`);
|
|
24
|
-
watch(values,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
onMounted(async () => {
|
|
31
|
+
watch(values, (newValues) => {
|
|
32
|
+
if (inputs.filter((i) => i.default || i.defaultSelfManaged).some((i) => !checkValue(newValues[i.name]))) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
29
35
|
emitChanged();
|
|
30
36
|
emitReady();
|
|
31
|
-
});
|
|
37
|
+
}, { immediate: true });
|
|
32
38
|
function emitReady() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
inputs.filter((i) => i.required).reduce((result, i) => result && checkValue(values[i.name]), true)
|
|
36
|
-
);
|
|
39
|
+
const ready = inputs.filter((i) => i.required).map(getValue).reduce((result, value) => result && checkValue(value), true);
|
|
40
|
+
emit("ready", ready);
|
|
37
41
|
}
|
|
38
42
|
function emitChanged() {
|
|
43
|
+
const uniqueKey = inputs.map(getValue).filter(checkValue).join("-");
|
|
39
44
|
emit("changed", {
|
|
40
|
-
uniqueKey
|
|
41
|
-
values
|
|
45
|
+
uniqueKey,
|
|
46
|
+
values: values.value
|
|
42
47
|
});
|
|
43
48
|
}
|
|
44
49
|
function checkValue(value) {
|
|
45
50
|
if (typeof value === "string") {
|
|
46
51
|
return value !== "";
|
|
52
|
+
} else {
|
|
53
|
+
return value !== void 0 && value !== null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function getValue(input) {
|
|
57
|
+
if (input.queryBound) {
|
|
58
|
+
return route.query[input.name];
|
|
59
|
+
} else {
|
|
60
|
+
return models[input.name];
|
|
47
61
|
}
|
|
48
|
-
return value !== void 0 && value !== null;
|
|
49
62
|
}
|
|
50
63
|
</script>
|