@mouseless/baked 1.5.3 → 1.6.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/dist/module.json +1 -1
- package/dist/module.mjs +2 -1
- package/dist/runtime/components/AwaitLoading.d.ts +7 -4
- package/dist/runtime/components/AwaitLoading.js +39 -11
- package/dist/runtime/components/Bake.d.vue.ts +1 -3
- package/dist/runtime/components/Bake.vue +101 -60
- package/dist/runtime/components/Bake.vue.d.ts +1 -3
- package/dist/runtime/components/DataContainer.vue +4 -7
- package/dist/runtime/components/DataPanel.vue +5 -7
- package/dist/runtime/components/DataTable.vue +12 -3
- package/dist/runtime/components/ErrorPage.vue +6 -5
- package/dist/runtime/components/ErrorPopover.d.vue.ts +15 -0
- package/dist/runtime/components/ErrorPopover.vue +22 -0
- package/dist/runtime/components/ErrorPopover.vue.d.ts +15 -0
- package/dist/runtime/components/FormPage.vue +36 -8
- package/dist/runtime/components/InlineError.d.vue.ts +15 -0
- package/dist/runtime/components/InlineError.vue +27 -0
- package/dist/runtime/components/InlineError.vue.d.ts +15 -0
- package/dist/runtime/components/Input.d.vue.ts +9 -1
- package/dist/runtime/components/Input.vue +31 -5
- package/dist/runtime/components/Input.vue.d.ts +9 -1
- package/dist/runtime/components/InputNumber.vue +23 -23
- package/dist/runtime/components/InputText.vue +22 -22
- package/dist/runtime/components/Inputs.d.vue.ts +7 -0
- package/dist/runtime/components/Inputs.vue +4 -2
- package/dist/runtime/components/Inputs.vue.d.ts +7 -0
- package/dist/runtime/components/Labeler.d.vue.ts +9 -25
- package/dist/runtime/components/Labeler.vue +32 -25
- package/dist/runtime/components/Labeler.vue.d.ts +9 -25
- package/dist/runtime/components/Layout.vue +5 -1
- package/dist/runtime/components/LoadingError.d.vue.ts +13 -0
- package/dist/runtime/components/LoadingError.vue +27 -0
- package/dist/runtime/components/LoadingError.vue.d.ts +13 -0
- package/dist/runtime/components/Message.d.vue.ts +8 -1
- package/dist/runtime/components/Message.vue +48 -17
- package/dist/runtime/components/Message.vue.d.ts +8 -1
- package/dist/runtime/components/NavLink.vue +6 -3
- package/dist/runtime/components/Paginator.vue +1 -3
- package/dist/runtime/components/Select.vue +39 -39
- package/dist/runtime/components/SelectButton.vue +46 -40
- package/dist/runtime/components/SimpleForm.vue +46 -11
- package/dist/runtime/components/TabbedPage.vue +5 -7
- package/dist/runtime/components/Validation.d.vue.ts +17 -0
- package/dist/runtime/components/Validation.vue +48 -0
- package/dist/runtime/components/Validation.vue.d.ts +17 -0
- package/dist/runtime/composables/useBakeError.d.ts +13 -0
- package/dist/runtime/composables/useBakeError.js +51 -0
- package/dist/runtime/composables/useContext.d.ts +14 -0
- package/dist/runtime/composables/useContext.js +77 -2
- package/dist/runtime/composables/useDataMounter.d.ts +4 -2
- package/dist/runtime/composables/useDataMounter.js +15 -6
- package/dist/runtime/composables/useDefaultValidation.d.ts +4 -0
- package/dist/runtime/composables/useDefaultValidation.js +37 -0
- package/dist/runtime/composables/useRedirect.d.ts +1 -1
- package/dist/runtime/composables/useRedirect.js +7 -1
- package/dist/runtime/composables/useValidation.d.ts +15 -0
- package/dist/runtime/composables/useValidation.js +79 -0
- package/dist/runtime/plugins/errorHandling.js +2 -2
- package/package.json +14 -14
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
error: {
|
|
5
|
+
type: null;
|
|
6
|
+
default: undefined;
|
|
7
|
+
};
|
|
8
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
error: {
|
|
10
|
+
type: null;
|
|
11
|
+
default: undefined;
|
|
12
|
+
};
|
|
13
|
+
}>> & Readonly<{}>, {
|
|
14
|
+
error: any;
|
|
15
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -5,6 +5,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
5
5
|
type: ObjectConstructor;
|
|
6
6
|
required: true;
|
|
7
7
|
};
|
|
8
|
+
formMode: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
};
|
|
8
11
|
modelValue: {
|
|
9
12
|
type: import("vue").PropType<any>;
|
|
10
13
|
required: true;
|
|
@@ -16,10 +19,15 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
16
19
|
type: ObjectConstructor;
|
|
17
20
|
required: true;
|
|
18
21
|
};
|
|
22
|
+
formMode: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
};
|
|
19
25
|
modelValue: {
|
|
20
26
|
type: import("vue").PropType<any>;
|
|
21
27
|
required: true;
|
|
22
28
|
};
|
|
23
29
|
}>> & Readonly<{
|
|
24
30
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
25
|
-
}>, {
|
|
31
|
+
}>, {
|
|
32
|
+
formMode: boolean;
|
|
33
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -3,23 +3,46 @@
|
|
|
3
3
|
v-model="model"
|
|
4
4
|
:name="schema.name"
|
|
5
5
|
:descriptor="schema.component"
|
|
6
|
+
:invalid
|
|
7
|
+
@blur="onBlur"
|
|
6
8
|
/>
|
|
7
9
|
</template>
|
|
8
10
|
|
|
9
11
|
<script setup>
|
|
10
|
-
import { computed, watch } from "vue";
|
|
12
|
+
import { computed, ref, watch } from "vue";
|
|
11
13
|
import { useRoute, useRouter } from "#app";
|
|
12
|
-
import { useDataMounter } from "#imports";
|
|
14
|
+
import { useDataMounter, useContext } from "#imports";
|
|
13
15
|
import { Bake } from "#components";
|
|
16
|
+
const context = useContext();
|
|
14
17
|
const { mount: mountData, onAfterMount: onAfterMountData } = useDataMounter();
|
|
15
18
|
const route = useRoute();
|
|
16
19
|
const router = useRouter();
|
|
17
|
-
const { schema } = defineProps({
|
|
18
|
-
schema: { type: Object, required: true }
|
|
20
|
+
const { schema, formMode } = defineProps({
|
|
21
|
+
schema: { type: Object, required: true },
|
|
22
|
+
formMode: { type: Boolean }
|
|
19
23
|
});
|
|
20
24
|
const model = defineModel({ type: null, required: true });
|
|
25
|
+
const validations = context.injectValidations();
|
|
26
|
+
const mutableValidations = context.injectMutableValidations();
|
|
21
27
|
const defaultValue = mountData(schema.default);
|
|
22
28
|
const query = schema.queryBound ? computed(() => route.query[schema.name]) : void 0;
|
|
29
|
+
let validation = void 0;
|
|
30
|
+
let mutableValidation = void 0;
|
|
31
|
+
let touched = void 0;
|
|
32
|
+
let invalidInForm = void 0;
|
|
33
|
+
let invalid = void 0;
|
|
34
|
+
let onBlur = void 0;
|
|
35
|
+
if (validations) {
|
|
36
|
+
validation = computed(() => validations.value[schema.name]);
|
|
37
|
+
mutableValidation = ref({ valid: true });
|
|
38
|
+
touched = ref(false);
|
|
39
|
+
invalidInForm = computed(() => !validation.value?.valid && (validation.value?.persist || touched.value));
|
|
40
|
+
invalid = computed(() => !mutableValidation.value.valid || invalidInForm.value);
|
|
41
|
+
onBlur = () => touched.value = true;
|
|
42
|
+
mutableValidations[schema.name] = mutableValidation;
|
|
43
|
+
context.provideValidation(validation);
|
|
44
|
+
context.provideMutableValidation(mutableValidation);
|
|
45
|
+
}
|
|
23
46
|
onAfterMountData(async () => {
|
|
24
47
|
if (!checkValue(model.value)) {
|
|
25
48
|
if (schema.queryBound && checkValue(query.value)) {
|
|
@@ -39,7 +62,7 @@ onAfterMountData(async () => {
|
|
|
39
62
|
}, { immediate: true });
|
|
40
63
|
}
|
|
41
64
|
watch(model, async (newValue) => {
|
|
42
|
-
if (!checkValue(newValue)) {
|
|
65
|
+
if (!checkValue(newValue) && !formMode) {
|
|
43
66
|
newValue = schema.required ? defaultValue.value : void 0;
|
|
44
67
|
}
|
|
45
68
|
await set(newValue);
|
|
@@ -73,6 +96,9 @@ function checkValue(value) {
|
|
|
73
96
|
return value !== void 0 && value !== null;
|
|
74
97
|
}
|
|
75
98
|
function setModel(value) {
|
|
99
|
+
if (value === model.value) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
76
102
|
if (!schema.numeric) {
|
|
77
103
|
model.value = value;
|
|
78
104
|
} else {
|
|
@@ -5,6 +5,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
5
5
|
type: ObjectConstructor;
|
|
6
6
|
required: true;
|
|
7
7
|
};
|
|
8
|
+
formMode: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
};
|
|
8
11
|
modelValue: {
|
|
9
12
|
type: import("vue").PropType<any>;
|
|
10
13
|
required: true;
|
|
@@ -16,10 +19,15 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
16
19
|
type: ObjectConstructor;
|
|
17
20
|
required: true;
|
|
18
21
|
};
|
|
22
|
+
formMode: {
|
|
23
|
+
type: BooleanConstructor;
|
|
24
|
+
};
|
|
19
25
|
modelValue: {
|
|
20
26
|
type: import("vue").PropType<any>;
|
|
21
27
|
required: true;
|
|
22
28
|
};
|
|
23
29
|
}>> & Readonly<{
|
|
24
30
|
"onUpdate:modelValue"?: ((value: any) => any) | undefined;
|
|
25
|
-
}>, {
|
|
31
|
+
}>, {
|
|
32
|
+
formMode: boolean;
|
|
33
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AwaitLoading
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
</
|
|
2
|
+
<AwaitLoading
|
|
3
|
+
:skeleton="{
|
|
4
|
+
height: label?.mode === 'ifta' ? '3.6rem' : '2.6rem',
|
|
5
|
+
class: 'min-w-60'
|
|
6
|
+
}"
|
|
7
|
+
>
|
|
8
|
+
<Validation>
|
|
9
|
+
<Labeler
|
|
10
|
+
:label
|
|
11
|
+
:path
|
|
12
|
+
>
|
|
13
|
+
<InputNumber
|
|
14
|
+
v-model="model"
|
|
15
|
+
v-bind="$attrs"
|
|
16
|
+
:use-grouping="!noGrouping"
|
|
17
|
+
class="min-w-60"
|
|
18
|
+
@input="onInput"
|
|
19
|
+
/>
|
|
20
|
+
</Labeler>
|
|
21
|
+
</Validation>
|
|
22
22
|
</AwaitLoading>
|
|
23
23
|
</template>
|
|
24
24
|
|
|
25
25
|
<script setup>
|
|
26
|
-
import { InputNumber
|
|
26
|
+
import { InputNumber } from "primevue";
|
|
27
27
|
import { useContext } from "#imports";
|
|
28
|
-
import { AwaitLoading, Labeler } from "#components";
|
|
28
|
+
import { AwaitLoading, Labeler, Validation } from "#components";
|
|
29
29
|
const context = useContext();
|
|
30
30
|
const { schema } = defineProps({
|
|
31
31
|
schema: { type: null, required: true }
|
|
32
32
|
});
|
|
33
33
|
const model = defineModel({ type: null, required: true });
|
|
34
|
-
const { label,
|
|
34
|
+
const { label, noGrouping } = schema;
|
|
35
35
|
const path = context.injectPath();
|
|
36
36
|
function onInput(event) {
|
|
37
37
|
model.value = event.value;
|
|
@@ -1,37 +1,37 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AwaitLoading
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
</
|
|
2
|
+
<AwaitLoading
|
|
3
|
+
:skeleton="{
|
|
4
|
+
height: label?.mode === 'ifta' ? '3.6rem' : '2.6rem',
|
|
5
|
+
class: 'min-w-60'
|
|
6
|
+
}"
|
|
7
|
+
>
|
|
8
|
+
<Validation>
|
|
9
|
+
<Labeler
|
|
10
|
+
:label
|
|
11
|
+
:path
|
|
12
|
+
>
|
|
13
|
+
<InputText
|
|
14
|
+
v-model="input"
|
|
15
|
+
v-bind="$attrs"
|
|
16
|
+
class="min-w-60"
|
|
17
|
+
@update:model-value="onUpdate"
|
|
18
|
+
/>
|
|
19
|
+
</Labeler>
|
|
20
|
+
</Validation>
|
|
21
21
|
</AwaitLoading>
|
|
22
22
|
</template>
|
|
23
23
|
|
|
24
24
|
<script setup>
|
|
25
25
|
import { ref, watch } from "vue";
|
|
26
|
-
import { InputText
|
|
26
|
+
import { InputText } from "primevue";
|
|
27
27
|
import { useContext } from "#imports";
|
|
28
|
-
import { AwaitLoading, Labeler } from "#components";
|
|
28
|
+
import { AwaitLoading, Labeler, Validation } from "#components";
|
|
29
29
|
const context = useContext();
|
|
30
30
|
const { schema } = defineProps({
|
|
31
31
|
schema: { type: null, required: true }
|
|
32
32
|
});
|
|
33
33
|
const model = defineModel({ type: null, required: true });
|
|
34
|
-
const { label,
|
|
34
|
+
const { label, targetProp } = schema;
|
|
35
35
|
const path = context.injectPath();
|
|
36
36
|
const input = ref("");
|
|
37
37
|
watch(model, (newValue) => {
|
|
@@ -5,6 +5,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
5
5
|
type: ArrayConstructor;
|
|
6
6
|
required: true;
|
|
7
7
|
};
|
|
8
|
+
formMode: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
};
|
|
8
11
|
inputClass: {
|
|
9
12
|
type: StringConstructor;
|
|
10
13
|
default: string;
|
|
@@ -17,6 +20,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
17
20
|
type: ArrayConstructor;
|
|
18
21
|
required: true;
|
|
19
22
|
};
|
|
23
|
+
formMode: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
};
|
|
20
26
|
inputClass: {
|
|
21
27
|
type: StringConstructor;
|
|
22
28
|
default: string;
|
|
@@ -25,5 +31,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
25
31
|
onReady?: ((...args: any[]) => any) | undefined;
|
|
26
32
|
onChanged?: ((...args: any[]) => any) | undefined;
|
|
27
33
|
}>, {
|
|
34
|
+
formMode: boolean;
|
|
28
35
|
inputClass: string;
|
|
29
36
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
:key="input.name"
|
|
5
5
|
v-model="models[input.name]"
|
|
6
6
|
:schema="input"
|
|
7
|
+
:form-mode
|
|
7
8
|
:class="inputClass"
|
|
8
9
|
/>
|
|
9
10
|
</template>
|
|
@@ -14,8 +15,9 @@ import { useContext, useRoute } from "#imports";
|
|
|
14
15
|
import { Input } from "#components";
|
|
15
16
|
const context = useContext();
|
|
16
17
|
const route = useRoute();
|
|
17
|
-
const { inputs } = defineProps({
|
|
18
|
+
const { inputs, formMode } = defineProps({
|
|
18
19
|
inputs: { type: Array, required: true },
|
|
20
|
+
formMode: { type: Boolean },
|
|
19
21
|
inputClass: { type: String, default: "" }
|
|
20
22
|
});
|
|
21
23
|
const emit = defineEmits(["ready", "changed"]);
|
|
@@ -29,7 +31,7 @@ const values = computed(
|
|
|
29
31
|
);
|
|
30
32
|
context.providePath(`${parentPath}/inputs`);
|
|
31
33
|
watch(values, (newValues) => {
|
|
32
|
-
if (inputs.filter((i) => i.default || i.defaultSelfManaged).some((i) => !checkValue(newValues[i.name]))) {
|
|
34
|
+
if (!formMode && inputs.filter((i) => i.default || i.defaultSelfManaged).some((i) => !checkValue(newValues[i.name]))) {
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
emitChanged();
|
|
@@ -5,6 +5,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
5
5
|
type: ArrayConstructor;
|
|
6
6
|
required: true;
|
|
7
7
|
};
|
|
8
|
+
formMode: {
|
|
9
|
+
type: BooleanConstructor;
|
|
10
|
+
};
|
|
8
11
|
inputClass: {
|
|
9
12
|
type: StringConstructor;
|
|
10
13
|
default: string;
|
|
@@ -17,6 +20,9 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
17
20
|
type: ArrayConstructor;
|
|
18
21
|
required: true;
|
|
19
22
|
};
|
|
23
|
+
formMode: {
|
|
24
|
+
type: BooleanConstructor;
|
|
25
|
+
};
|
|
20
26
|
inputClass: {
|
|
21
27
|
type: StringConstructor;
|
|
22
28
|
default: string;
|
|
@@ -25,5 +31,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
25
31
|
onReady?: ((...args: any[]) => any) | undefined;
|
|
26
32
|
onChanged?: ((...args: any[]) => any) | undefined;
|
|
27
33
|
}>, {
|
|
34
|
+
formMode: boolean;
|
|
28
35
|
inputClass: string;
|
|
29
36
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -6,61 +6,45 @@ type __VLS_WithSlots<T, S> = T & (new () => {
|
|
|
6
6
|
});
|
|
7
7
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
8
|
label: {
|
|
9
|
-
type:
|
|
9
|
+
type: ObjectConstructor;
|
|
10
10
|
default: null;
|
|
11
11
|
};
|
|
12
12
|
path: {
|
|
13
13
|
type: StringConstructor;
|
|
14
14
|
required: true;
|
|
15
15
|
};
|
|
16
|
-
mode: {
|
|
17
|
-
type: StringConstructor;
|
|
18
|
-
default: null;
|
|
19
|
-
};
|
|
20
|
-
variant: {
|
|
21
|
-
type: StringConstructor;
|
|
22
|
-
default: string;
|
|
23
|
-
};
|
|
24
16
|
pt: {
|
|
25
17
|
type: ObjectConstructor;
|
|
26
|
-
default: () =>
|
|
18
|
+
default: () => {};
|
|
27
19
|
};
|
|
28
20
|
dt: {
|
|
29
21
|
type: ObjectConstructor;
|
|
30
|
-
default: () =>
|
|
22
|
+
default: () => {};
|
|
31
23
|
};
|
|
32
24
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
25
|
label: {
|
|
34
|
-
type:
|
|
26
|
+
type: ObjectConstructor;
|
|
35
27
|
default: null;
|
|
36
28
|
};
|
|
37
29
|
path: {
|
|
38
30
|
type: StringConstructor;
|
|
39
31
|
required: true;
|
|
40
32
|
};
|
|
41
|
-
mode: {
|
|
42
|
-
type: StringConstructor;
|
|
43
|
-
default: null;
|
|
44
|
-
};
|
|
45
|
-
variant: {
|
|
46
|
-
type: StringConstructor;
|
|
47
|
-
default: string;
|
|
48
|
-
};
|
|
49
33
|
pt: {
|
|
50
34
|
type: ObjectConstructor;
|
|
51
|
-
default: () =>
|
|
35
|
+
default: () => {};
|
|
52
36
|
};
|
|
53
37
|
dt: {
|
|
54
38
|
type: ObjectConstructor;
|
|
55
|
-
default: () =>
|
|
39
|
+
default: () => {};
|
|
56
40
|
};
|
|
57
41
|
}>> & Readonly<{}>, {
|
|
58
|
-
label: string
|
|
59
|
-
variant: string;
|
|
42
|
+
label: Record<string, any>;
|
|
60
43
|
dt: Record<string, any>;
|
|
61
44
|
pt: Record<string, any>;
|
|
62
|
-
mode: string;
|
|
63
45
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
46
|
type __VLS_Slots = {
|
|
65
47
|
default?: ((props: {}) => any) | undefined;
|
|
48
|
+
} & {
|
|
49
|
+
default?: ((props: {}) => any) | undefined;
|
|
66
50
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<template v-if="!text">
|
|
3
|
+
<slot />
|
|
4
|
+
</template>
|
|
2
5
|
<component
|
|
3
6
|
:is="labelComponent"
|
|
7
|
+
v-else
|
|
4
8
|
:dt
|
|
5
9
|
:pt
|
|
6
10
|
:variant
|
|
11
|
+
:required
|
|
7
12
|
>
|
|
8
13
|
<template #default>
|
|
9
14
|
<slot />
|
|
10
|
-
<label
|
|
11
|
-
|
|
12
|
-
class="max-sm:truncate max-sm:w-5/6"
|
|
13
|
-
:for="path"
|
|
14
|
-
>
|
|
15
|
-
{{ l(label) }}
|
|
15
|
+
<label :for="path">
|
|
16
|
+
{{ localizedText }}
|
|
16
17
|
</label>
|
|
17
18
|
</template>
|
|
18
19
|
</component>
|
|
@@ -21,29 +22,35 @@
|
|
|
21
22
|
<script setup>
|
|
22
23
|
import { computed } from "vue";
|
|
23
24
|
import { FloatLabel, IftaLabel } from "primevue";
|
|
24
|
-
import { useLocalization } from "#imports";
|
|
25
|
-
const
|
|
26
|
-
const {
|
|
27
|
-
|
|
25
|
+
import { useContext, useLocalization } from "#imports";
|
|
26
|
+
const context = useContext();
|
|
27
|
+
const { localize: l } = useLocalization({});
|
|
28
|
+
const { localize: lc } = useLocalization({ group: "Labeler" });
|
|
29
|
+
const { label } = defineProps({
|
|
30
|
+
label: { type: Object, default: null },
|
|
28
31
|
path: { type: String, required: true },
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
pt: { type: Object, default: () => ({}) },
|
|
33
|
+
dt: { type: Object, default: () => ({}) }
|
|
34
|
+
});
|
|
35
|
+
const { text, mode, variant = "on", showOptionality } = label ?? {};
|
|
36
|
+
const validation = context.injectValidation();
|
|
37
|
+
const required = computed(() => validation?.value?.required);
|
|
38
|
+
const localizedText = computed(() => {
|
|
39
|
+
if (!showOptionality) {
|
|
40
|
+
return l(text);
|
|
41
|
+
}
|
|
42
|
+
if (required.value) {
|
|
43
|
+
return lc("{label} (Required)", { label: l(text) });
|
|
44
|
+
}
|
|
45
|
+
return lc("{label} (Optional)", { label: l(text) });
|
|
35
46
|
});
|
|
36
47
|
const labelComponent = computed(() => {
|
|
37
|
-
if (
|
|
38
|
-
return
|
|
48
|
+
if (mode === "ifta") {
|
|
49
|
+
return IftaLabel;
|
|
39
50
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
return IftaLabel;
|
|
43
|
-
case "float":
|
|
44
|
-
return FloatLabel;
|
|
45
|
-
default:
|
|
46
|
-
return "div";
|
|
51
|
+
if (mode === "float") {
|
|
52
|
+
return FloatLabel;
|
|
47
53
|
}
|
|
54
|
+
throw new Error("`mode` must be set when `text` is set");
|
|
48
55
|
});
|
|
49
56
|
</script>
|
|
@@ -6,61 +6,45 @@ type __VLS_WithSlots<T, S> = T & (new () => {
|
|
|
6
6
|
});
|
|
7
7
|
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
8
8
|
label: {
|
|
9
|
-
type:
|
|
9
|
+
type: ObjectConstructor;
|
|
10
10
|
default: null;
|
|
11
11
|
};
|
|
12
12
|
path: {
|
|
13
13
|
type: StringConstructor;
|
|
14
14
|
required: true;
|
|
15
15
|
};
|
|
16
|
-
mode: {
|
|
17
|
-
type: StringConstructor;
|
|
18
|
-
default: null;
|
|
19
|
-
};
|
|
20
|
-
variant: {
|
|
21
|
-
type: StringConstructor;
|
|
22
|
-
default: string;
|
|
23
|
-
};
|
|
24
16
|
pt: {
|
|
25
17
|
type: ObjectConstructor;
|
|
26
|
-
default: () =>
|
|
18
|
+
default: () => {};
|
|
27
19
|
};
|
|
28
20
|
dt: {
|
|
29
21
|
type: ObjectConstructor;
|
|
30
|
-
default: () =>
|
|
22
|
+
default: () => {};
|
|
31
23
|
};
|
|
32
24
|
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
33
25
|
label: {
|
|
34
|
-
type:
|
|
26
|
+
type: ObjectConstructor;
|
|
35
27
|
default: null;
|
|
36
28
|
};
|
|
37
29
|
path: {
|
|
38
30
|
type: StringConstructor;
|
|
39
31
|
required: true;
|
|
40
32
|
};
|
|
41
|
-
mode: {
|
|
42
|
-
type: StringConstructor;
|
|
43
|
-
default: null;
|
|
44
|
-
};
|
|
45
|
-
variant: {
|
|
46
|
-
type: StringConstructor;
|
|
47
|
-
default: string;
|
|
48
|
-
};
|
|
49
33
|
pt: {
|
|
50
34
|
type: ObjectConstructor;
|
|
51
|
-
default: () =>
|
|
35
|
+
default: () => {};
|
|
52
36
|
};
|
|
53
37
|
dt: {
|
|
54
38
|
type: ObjectConstructor;
|
|
55
|
-
default: () =>
|
|
39
|
+
default: () => {};
|
|
56
40
|
};
|
|
57
41
|
}>> & Readonly<{}>, {
|
|
58
|
-
label: string
|
|
59
|
-
variant: string;
|
|
42
|
+
label: Record<string, any>;
|
|
60
43
|
dt: Record<string, any>;
|
|
61
44
|
pt: Record<string, any>;
|
|
62
|
-
mode: string;
|
|
63
45
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
64
46
|
type __VLS_Slots = {
|
|
65
47
|
default?: ((props: {}) => any) | undefined;
|
|
48
|
+
} & {
|
|
49
|
+
default?: ((props: {}) => any) | undefined;
|
|
66
50
|
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
error: {
|
|
5
|
+
type: ObjectConstructor;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
error: {
|
|
10
|
+
type: ObjectConstructor;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="
|
|
4
|
+
rounded-md pl-1
|
|
5
|
+
bg-red-500/10 text-red-500
|
|
6
|
+
"
|
|
7
|
+
>
|
|
8
|
+
<span
|
|
9
|
+
v-tooltip.bottom="{
|
|
10
|
+
value: `${title} - ${detail}`,
|
|
11
|
+
autoHide: false,
|
|
12
|
+
pt: {
|
|
13
|
+
text: { class: 'bg-red-500' },
|
|
14
|
+
arrow: { class: 'border-y-red-500' },
|
|
15
|
+
}
|
|
16
|
+
}"
|
|
17
|
+
class="text-sm"
|
|
18
|
+
>{{ title }}</span>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script setup>
|
|
23
|
+
const { error } = defineProps({
|
|
24
|
+
error: { type: Object, required: true }
|
|
25
|
+
});
|
|
26
|
+
const { title, detail } = error;
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare const _default: typeof __VLS_export;
|
|
2
|
+
export default _default;
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
error: {
|
|
5
|
+
type: ObjectConstructor;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
9
|
+
error: {
|
|
10
|
+
type: ObjectConstructor;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
declare const _default: typeof __VLS_export;
|
|
2
2
|
export default _default;
|
|
3
|
-
declare const __VLS_export:
|
|
3
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
4
|
+
type __VLS_WithSlots<T, S> = T & (new () => {
|
|
5
|
+
$slots: S;
|
|
6
|
+
});
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
8
|
schema: {
|
|
5
9
|
type: null;
|
|
6
10
|
required: true;
|
|
@@ -19,3 +23,6 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
19
23
|
required: true;
|
|
20
24
|
};
|
|
21
25
|
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
26
|
+
type __VLS_Slots = {
|
|
27
|
+
content?: ((props: {}) => any) | undefined;
|
|
28
|
+
};
|