@mouseless/baked 1.6.1 → 1.6.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 +1 -1
- package/dist/runtime/components/Button.vue +2 -1
- package/dist/runtime/components/DataContainer.vue +31 -14
- package/dist/runtime/components/DataTable.vue +1 -1
- package/dist/runtime/components/Message.vue +17 -4
- package/dist/runtime/components/SimpleForm.vue +26 -19
- package/dist/runtime/components/Validation.vue +6 -2
- package/dist/runtime/composables/useReactionHandler.js +12 -2
- package/dist/runtime/composables/useValidation.d.ts +4 -0
- package/dist/runtime/composables/useValidation.js +11 -4
- package/package.json +3 -2
package/dist/module.json
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
:label="l(label)"
|
|
7
7
|
:rounded
|
|
8
8
|
:severity
|
|
9
|
+
:size
|
|
9
10
|
:variant
|
|
10
11
|
@click="$emit('submit')"
|
|
11
12
|
/>
|
|
@@ -21,6 +22,6 @@ const { schema } = defineProps({
|
|
|
21
22
|
ready: { type: Boolean, default: true }
|
|
22
23
|
});
|
|
23
24
|
defineEmits(["submit"]);
|
|
24
|
-
const { icon, label, rounded, severity = "secondary", variant } = schema;
|
|
25
|
+
const { icon, label, rounded, severity = "secondary", size, variant } = schema;
|
|
25
26
|
const executing = context.injectExecuting();
|
|
26
27
|
</script>
|
|
@@ -7,19 +7,36 @@
|
|
|
7
7
|
"
|
|
8
8
|
>
|
|
9
9
|
<div
|
|
10
|
-
v-if="
|
|
11
|
-
class="
|
|
12
|
-
py-2 px-4
|
|
13
|
-
bg-transparent
|
|
14
|
-
rounded-none text-sm
|
|
15
|
-
flex gap-2 items-center justify-end
|
|
16
|
-
"
|
|
10
|
+
v-if="actions.length || inputs.length"
|
|
11
|
+
class="w-full flex justify-between py-2 px-4"
|
|
17
12
|
>
|
|
18
|
-
<
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
<div
|
|
14
|
+
class="
|
|
15
|
+
min-w-min flex gap-2 row-span-2 items-end text-nowrap
|
|
16
|
+
max-xs:text-xs max-md:text-sm
|
|
17
|
+
md:max-md:items-center
|
|
18
|
+
"
|
|
19
|
+
>
|
|
20
|
+
<Bake
|
|
21
|
+
v-for="action in actions"
|
|
22
|
+
:key="action.schema.name"
|
|
23
|
+
:name="`actions/${action.schema.name}`"
|
|
24
|
+
:descriptor="action"
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
<div
|
|
28
|
+
class="
|
|
29
|
+
bg-transparent
|
|
30
|
+
rounded-none text-sm
|
|
31
|
+
flex gap-2 items-center justify-end
|
|
32
|
+
"
|
|
33
|
+
>
|
|
34
|
+
<Inputs
|
|
35
|
+
:inputs="inputs"
|
|
36
|
+
@ready="onReady"
|
|
37
|
+
@changed="onChanged"
|
|
38
|
+
/>
|
|
39
|
+
</div>
|
|
23
40
|
</div>
|
|
24
41
|
<div
|
|
25
42
|
class="p-4 [contain:inline-size]"
|
|
@@ -49,7 +66,7 @@ const { localize: lc } = useLocalization({ group: "DataContainer" });
|
|
|
49
66
|
const { schema } = defineProps({
|
|
50
67
|
schema: { type: null, required: true }
|
|
51
68
|
});
|
|
52
|
-
const { content, inputs } = schema;
|
|
69
|
+
const { actions = [], content, inputs } = schema;
|
|
53
70
|
const contextData = context.injectContextData();
|
|
54
71
|
const loaded = ref(true);
|
|
55
72
|
const ready = ref(inputs.length === 0);
|
|
@@ -68,5 +85,5 @@ function onChanged(event) {
|
|
|
68
85
|
</script>
|
|
69
86
|
|
|
70
87
|
<style>
|
|
71
|
-
.p-panel-content:has(.b-component--DataContainer) .b-component--DataContainer{@apply border-none rounded-none}.b-component--DataContainer div{@apply [&:has(.p-datatable)]:p-0}
|
|
88
|
+
.p-panel-content:has(.b-component--DataContainer) .b-component--DataContainer{@apply border-none rounded-none}.b-component--DataContainer div{@apply [&:has(.p-datatable)]:p-0}.b-component--DataContainer .p-button{@apply self-stretch}.b-component--DataContainer .p-button .p-button-icon+.p-button-label{@apply max-sm:hidden}
|
|
72
89
|
</style>
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
|
-
class="
|
|
3
|
+
class="
|
|
4
|
+
b-message
|
|
5
|
+
grid grid-cols-[1fr_auto] gap-2
|
|
6
|
+
items-center
|
|
7
|
+
"
|
|
4
8
|
:class="[`message-${severity}`, `message-${variant}`]"
|
|
5
9
|
>
|
|
6
10
|
<div class="min-h-0">
|
|
@@ -25,18 +29,27 @@
|
|
|
25
29
|
<slot name="content" />
|
|
26
30
|
</div>
|
|
27
31
|
</div>
|
|
32
|
+
<div
|
|
33
|
+
v-if="action"
|
|
34
|
+
class="b-message-action p-2"
|
|
35
|
+
>
|
|
36
|
+
<Bake
|
|
37
|
+
name="action"
|
|
38
|
+
:descriptor="{ ...action, schema: { ...action.schema, severity } }"
|
|
39
|
+
/>
|
|
40
|
+
</div>
|
|
28
41
|
</div>
|
|
29
42
|
</template>
|
|
30
43
|
|
|
31
44
|
<script setup>
|
|
32
45
|
import { computed, useLocalization } from "#imports";
|
|
33
|
-
import { AwaitLoading } from "#components";
|
|
46
|
+
import { AwaitLoading, Bake } from "#components";
|
|
34
47
|
const { localize: l } = useLocalization();
|
|
35
48
|
const { schema, data } = defineProps({
|
|
36
49
|
schema: { type: null, required: true },
|
|
37
50
|
data: { type: null, required: true }
|
|
38
51
|
});
|
|
39
|
-
const { icon, localizeMessage, severity = "info", size, variant = "outlined" } = schema;
|
|
52
|
+
const { action, icon, localizeMessage, severity = "info", size, variant = "outlined" } = schema;
|
|
40
53
|
const sizeClass = computed(() => {
|
|
41
54
|
switch (size) {
|
|
42
55
|
case "small":
|
|
@@ -50,7 +63,7 @@ const sizeClass = computed(() => {
|
|
|
50
63
|
</script>
|
|
51
64
|
|
|
52
65
|
<style scoped>
|
|
53
|
-
.message-outlined{@apply border rounded-md}.message-outlined .b-message-body{@apply py-[0.50rem] px-[0.75rem] min-w-[10rem] min-h-[1.5rem]}.message-simple{@apply !bg-transparent}.message-simple .b-message-body{@apply px-0}.message-info{@apply bg-blue-50/95 text-blue-600 border-blue-200
|
|
66
|
+
.message-outlined{@apply border rounded-md}.message-outlined .b-message-body{@apply py-[0.50rem] px-[0.75rem] min-w-[10rem] min-h-[1.5rem]}.message-simple{@apply !bg-transparent}.message-simple .b-message-icon{@apply text-sm}.message-simple .b-message-body{@apply px-0}.message-info{@apply bg-blue-50/95 text-blue-600 border-blue-200
|
|
54
67
|
dark:bg-blue-950/95 dark:text-blue-500 dark:border-blue-700/65}.message-error{@apply bg-red-50/95 text-red-600 border-red-200
|
|
55
68
|
dark:bg-red-950/95 dark:text-red-500 dark:border-red-700/65}.message-warn{@apply bg-yellow-50/95 text-yellow-600 border-yellow-200
|
|
56
69
|
dark:bg-yellow-950/95 dark:text-yellow-500 dark:border-yellow-700/65}.message-success{@apply bg-green-50/95 text-green-600 border-green-200
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
<Inputs
|
|
32
32
|
v-if="inputs"
|
|
33
33
|
:inputs
|
|
34
|
+
form-mode
|
|
34
35
|
input-class="w-full"
|
|
35
36
|
@ready="onReady"
|
|
36
37
|
@changed="onChanged"
|
|
@@ -55,12 +56,16 @@
|
|
|
55
56
|
<template v-else>
|
|
56
57
|
<div
|
|
57
58
|
v-bind="$attrs"
|
|
58
|
-
class="flex flex-col gap-
|
|
59
|
+
class="flex flex-col gap-4"
|
|
60
|
+
:class="{ 'gap-8': !horizontal }"
|
|
59
61
|
>
|
|
60
|
-
<
|
|
62
|
+
<h2 class="font-bold text-xl truncate">
|
|
61
63
|
{{ l(title) }}
|
|
62
|
-
</
|
|
63
|
-
<div
|
|
64
|
+
</h2>
|
|
65
|
+
<div
|
|
66
|
+
class="flex gap-4"
|
|
67
|
+
:class="{ 'flex-col': !horizontal }"
|
|
68
|
+
>
|
|
64
69
|
<Inputs
|
|
65
70
|
v-if="inputs"
|
|
66
71
|
:inputs
|
|
@@ -69,21 +74,23 @@
|
|
|
69
74
|
@ready="onReady"
|
|
70
75
|
@changed="onChanged"
|
|
71
76
|
/>
|
|
77
|
+
<Button
|
|
78
|
+
ref="submitRef"
|
|
79
|
+
v-tooltip.top="{
|
|
80
|
+
disabled: !showValidationSummary,
|
|
81
|
+
value: messages,
|
|
82
|
+
pt: { text: 'text-sm' }
|
|
83
|
+
}"
|
|
84
|
+
:schema="submit"
|
|
85
|
+
:ready
|
|
86
|
+
class="min-w-min"
|
|
87
|
+
:class="{ 'mt-4': !horizontal && inputs.length }"
|
|
88
|
+
@submit="$emit('submit', model)"
|
|
89
|
+
/>
|
|
90
|
+
<ErrorPopover ref="errorPopoverRef">
|
|
91
|
+
<InlineError :error />
|
|
92
|
+
</ErrorPopover>
|
|
72
93
|
</div>
|
|
73
|
-
<Button
|
|
74
|
-
ref="submitRef"
|
|
75
|
-
v-tooltip.top="{
|
|
76
|
-
disabled: !showValidationSummary,
|
|
77
|
-
value: messages,
|
|
78
|
-
pt: { text: 'text-sm' }
|
|
79
|
-
}"
|
|
80
|
-
:schema="submit"
|
|
81
|
-
:ready
|
|
82
|
-
@submit="$emit('submit', model)"
|
|
83
|
-
/>
|
|
84
|
-
<ErrorPopover ref="errorPopoverRef">
|
|
85
|
-
<InlineError :error />
|
|
86
|
-
</ErrorPopover>
|
|
87
94
|
</div>
|
|
88
95
|
</template>
|
|
89
96
|
</template>
|
|
@@ -100,7 +107,7 @@ const { schema } = defineProps({
|
|
|
100
107
|
schema: { type: null, required: true }
|
|
101
108
|
});
|
|
102
109
|
const emit = defineEmits(["submit"]);
|
|
103
|
-
const { dialogOptions, inputs, submit, title, validations = [], showValidationSummary = false } = schema;
|
|
110
|
+
const { dialogOptions, inputs, horizontal, submit, title, validations = [], showValidationSummary = false } = schema;
|
|
104
111
|
const model = ref({});
|
|
105
112
|
const readyData = ref({});
|
|
106
113
|
const submitted = ref(false);
|
|
@@ -14,10 +14,13 @@
|
|
|
14
14
|
>
|
|
15
15
|
<Message
|
|
16
16
|
v-if="message"
|
|
17
|
+
:key="`${severity}:${icon}`"
|
|
18
|
+
icon="pi pi-info-circle"
|
|
17
19
|
:schema="{
|
|
18
|
-
severity
|
|
20
|
+
severity,
|
|
19
21
|
variant: 'simple',
|
|
20
|
-
size: 'small'
|
|
22
|
+
size: 'small',
|
|
23
|
+
icon
|
|
21
24
|
}"
|
|
22
25
|
:data="message || ''"
|
|
23
26
|
class="ml-3"
|
|
@@ -45,4 +48,5 @@ const message = computed(() => {
|
|
|
45
48
|
return null;
|
|
46
49
|
});
|
|
47
50
|
const severity = computed(() => mutableValidation?.value.severity || validation?.value.severity);
|
|
51
|
+
const icon = computed(() => mutableValidation?.value.icon || validation?.value.icon);
|
|
48
52
|
</script>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { watch } from "vue";
|
|
1
|
+
import { watch, unref } from "vue";
|
|
2
2
|
import { useConstraintEvaluator, useContext } from "#imports";
|
|
3
3
|
|
|
4
4
|
export default function() {
|
|
@@ -74,12 +74,22 @@ function On({ evaluate, eventId, events }) {
|
|
|
74
74
|
|
|
75
75
|
function When({ contextData, evaluate }) {
|
|
76
76
|
function bind({ trigger, react }) {
|
|
77
|
-
watch(() => contextData.page
|
|
77
|
+
watch(() => access(contextData[trigger.key ?? "page"], trigger.when), async value => {
|
|
78
|
+
react(false);
|
|
78
79
|
react(await evaluate(trigger.constraint, value));
|
|
79
80
|
}, { immediate: true });
|
|
80
81
|
|
|
81
82
|
return [];
|
|
82
83
|
}
|
|
84
|
+
function access(data, propChain) {
|
|
85
|
+
data = unref(data);
|
|
86
|
+
for(const prop of propChain.split(".")) {
|
|
87
|
+
data = data?.[prop];
|
|
88
|
+
data = unref(data);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return data;
|
|
92
|
+
}
|
|
83
93
|
|
|
84
94
|
return {
|
|
85
95
|
bind
|
|
@@ -11,5 +11,9 @@ export default function _default(): {
|
|
|
11
11
|
injectMutable: () => {
|
|
12
12
|
clear: () => void;
|
|
13
13
|
setError: (message: any) => void;
|
|
14
|
+
setMessage: (message: any, { persist, severity, icon }?: {
|
|
15
|
+
persist?: boolean | undefined;
|
|
16
|
+
severity?: string | undefined;
|
|
17
|
+
}) => void;
|
|
14
18
|
} | null;
|
|
15
19
|
};
|
|
@@ -38,7 +38,7 @@ export default function() {
|
|
|
38
38
|
|
|
39
39
|
const messages = computed(() =>
|
|
40
40
|
[...Object.values(validations.value), ...Object.values(mutableValidations).map(v => v.value)]
|
|
41
|
-
.filter(v => v.message)
|
|
41
|
+
.filter(v => v.message && v.severity === "error")
|
|
42
42
|
.map((v, i) => `${i > 0 ? "\n" : ""} - ${v.message}`)
|
|
43
43
|
.join("")
|
|
44
44
|
);
|
|
@@ -67,13 +67,20 @@ function MutableValidation(ref) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
function setError(message) {
|
|
70
|
-
|
|
70
|
+
setMessage(message, { persist: true, severity: "error" });
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function setMessage(message, { persist = false, severity = "secondary", icon } = {}) {
|
|
74
|
+
ref.value.valid = severity !== "error";
|
|
71
75
|
ref.value.message = message;
|
|
72
|
-
ref.value.
|
|
76
|
+
ref.value.persist = persist;
|
|
77
|
+
ref.value.severity = severity;
|
|
78
|
+
ref.value.icon = icon;
|
|
73
79
|
}
|
|
74
80
|
|
|
75
81
|
return {
|
|
76
82
|
clear,
|
|
77
|
-
setError
|
|
83
|
+
setError,
|
|
84
|
+
setMessage
|
|
78
85
|
};
|
|
79
86
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mouseless/baked",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.3",
|
|
4
4
|
"description": "Baked is an opinionated framework for .NET and Vue. This is the UI package of Baked project.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"baked",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"@nuxtjs/tailwindcss": "6.14.0",
|
|
48
48
|
"@primeuix/themes": "2.0.3",
|
|
49
49
|
"async-mutex": "0.5.0",
|
|
50
|
+
"playwright": "^1.60.0",
|
|
50
51
|
"primeicons": "7.0.0",
|
|
51
52
|
"primevue": "4.5.5"
|
|
52
53
|
},
|
|
@@ -71,4 +72,4 @@
|
|
|
71
72
|
"@oxc-parser/binding-linux-x64-musl": "0.133.0",
|
|
72
73
|
"@oxc-parser/binding-win32-x64-msvc": "0.133.0"
|
|
73
74
|
}
|
|
74
|
-
}
|
|
75
|
+
}
|