@mouseless/baked 1.8.3 → 1.8.5
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/assets/components.css +1 -1
- package/dist/runtime/components/Bake.vue +15 -0
- package/dist/runtime/components/Message.vue +14 -3
- package/dist/runtime/composables/useActionExecuter.js +10 -4
- package/dist/runtime/composables/useContext.d.ts +1 -1
- package/dist/runtime/composables/useContext.js +1 -1
- package/dist/runtime/composables/useToken.js +2 -1
- package/dist/runtime/composables/useUnref.js +20 -4
- package/package.json +1 -1
package/dist/module.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
dark:bg-red-950/95 dark:text-red-500 dark:border-red-700/65}.b-component--Message.message-warn{@apply bg-yellow-50/95 text-yellow-600 border-yellow-200
|
|
4
4
|
dark:bg-yellow-950/95 dark:text-yellow-500 dark:border-yellow-700/65}.b-component--Message.message-success{@apply bg-green-50/95 text-green-600 border-green-200
|
|
5
5
|
dark:bg-green-950/95 dark:text-green-500 dark:border-green-700/65}.b-component--Message.message-secondary{@apply bg-transparent text-slate-500 border-slate-500
|
|
6
|
-
dark:text-
|
|
6
|
+
dark:text-zinc-400 dark:border-zinc-400}.b-component--Message.message-contrast{@apply bg-transparent text-slate-950 border-slate-950
|
|
7
7
|
dark:text-white dark:border-white}.c--missing-component-dialog code:not(:has(pre)){@apply rounded p-1 text-xs bg-zinc-50 text-orange-700
|
|
8
8
|
dark:bg-zinc-950 dark:text-orange-400}.c--missing-component-dialog pre{@apply block rounded-lg overflow-auto max-h-[20em]
|
|
9
9
|
bg-zinc-950 p-4 text-xs text-sky-300}.c--missing-component-dialog pre .c--code-comment{@apply text-green-800}.c--missing-component-dialog pre .c--code-string{@apply text-orange-400}.c--missing-component-dialog pre .c--code-keyword{@apply text-purple-400}.c--missing-component-dialog pre .c--code-symbol{@apply text-gray-100}.c--missing-component-dialog pre .c--code-type{@apply text-blue-400}.c--missing-component-dialog pre .c--code-method{@apply text-yellow-100}.p-scrolltop{@apply right-6 bottom-6 max-md:bottom-24 py-icon-only-width}.b-component--Select .p-placeholder{@apply opacity-0}.b-component--Select .p-select-label{@apply text-[length:inherit]}.p-popover-content .b-component--Select{@apply max-md:w-full}.b-component--SelectButton .p-togglebutton-content{@apply whitespace-nowrap}.p-popover-content .b-component--SelectButton .p-selectbutton,.p-popover-content .b-component--SelectButton.p-selectbutton{@apply max-sm:flex max-sm:flex-col}.p-popover-content .b-component--SelectButton .p-selectbutton .p-togglebutton:first-child,.p-popover-content .b-component--SelectButton.p-selectbutton .p-togglebutton:first-child{@apply max-sm:rounded-t-lg max-sm:rounded-es-none}.p-popover-content .b-component--SelectButton .p-selectbutton .p-togglebutton:last-child,.p-popover-content .b-component--SelectButton.p-selectbutton .p-togglebutton:last-child{@apply max-sm:rounded-b-lg max-sm:rounded-se-none}.b-component--SimpleForm.horizontal :has(.p-iftalabel) .p-button[data-p=large]{@apply mt-1}.b-component--SimpleForm.horizontal :has(.p-iftalabel) .p-button:not([data-p=large]){@apply mt-2}.b-component--PageSize .p-select-label{@apply text-[length:inherit]}.b-component--PageTitle .p-button{@apply self-stretch}.b-component--PageTitle .p-button .p-button-icon+.p-button-label{@apply max-sm:hidden}.p-popover-content>div{@apply max-sm:p-0}}
|
|
@@ -164,6 +164,9 @@ async function executeAction(newModel) {
|
|
|
164
164
|
if (!descriptor.action) {
|
|
165
165
|
return;
|
|
166
166
|
}
|
|
167
|
+
if (descriptor.actionSkipsEmptyModel && isEmpty(newModel)) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
167
170
|
try {
|
|
168
171
|
executing.value = true;
|
|
169
172
|
await actionExecuter.execute({
|
|
@@ -180,4 +183,16 @@ async function executeAction(newModel) {
|
|
|
180
183
|
executing.value = false;
|
|
181
184
|
}
|
|
182
185
|
}
|
|
186
|
+
function isEmpty(value) {
|
|
187
|
+
if (value === null || value === void 0) {
|
|
188
|
+
return true;
|
|
189
|
+
}
|
|
190
|
+
if (typeof value === "string" && value.trim() === "") {
|
|
191
|
+
return true;
|
|
192
|
+
}
|
|
193
|
+
if (Array.isArray(value) && value.length === 0) {
|
|
194
|
+
return true;
|
|
195
|
+
}
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
183
198
|
</script>
|
|
@@ -2,12 +2,19 @@
|
|
|
2
2
|
<div
|
|
3
3
|
class="
|
|
4
4
|
b-message
|
|
5
|
-
grid grid-cols-[1fr_auto]
|
|
5
|
+
grid grid-cols-[1fr_auto]
|
|
6
6
|
items-center
|
|
7
|
+
md:gap-2
|
|
8
|
+
max-md:flex max-md:flex-col max-md:space-between
|
|
7
9
|
"
|
|
8
10
|
:class="[`message-${severity}`, `message-${variant}`]"
|
|
9
11
|
>
|
|
10
|
-
<div
|
|
12
|
+
<div
|
|
13
|
+
class="
|
|
14
|
+
min-h-0
|
|
15
|
+
max-md:w-full
|
|
16
|
+
"
|
|
17
|
+
>
|
|
11
18
|
<div
|
|
12
19
|
:class="sizeClass"
|
|
13
20
|
class="
|
|
@@ -31,10 +38,14 @@
|
|
|
31
38
|
</div>
|
|
32
39
|
<div
|
|
33
40
|
v-if="action"
|
|
34
|
-
class="
|
|
41
|
+
class="
|
|
42
|
+
b-message-action p-2
|
|
43
|
+
max-md:w-full
|
|
44
|
+
"
|
|
35
45
|
>
|
|
36
46
|
<Bake
|
|
37
47
|
name="action"
|
|
48
|
+
class="max-md:w-full"
|
|
38
49
|
:descriptor="{ ...action, schema: { ...action.schema, severity } }"
|
|
39
50
|
/>
|
|
40
51
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#app";
|
|
2
|
-
import { useComposableResolver, useDataFetcher, usePathBuilder, useUnref } from "#imports";
|
|
2
|
+
import { useComposableResolver, useContext, useDataFetcher, usePathBuilder, useUnref, useValidation } from "#imports";
|
|
3
|
+
import { bfetch } from "../utils/bfetch.js";
|
|
3
4
|
|
|
4
5
|
export default function() {
|
|
5
6
|
const actions = {
|
|
@@ -35,9 +36,14 @@ function Composite({ actionExecuter }) {
|
|
|
35
36
|
function Local() {
|
|
36
37
|
const composableResolver = useComposableResolver();
|
|
37
38
|
const dataFetcher = useDataFetcher();
|
|
39
|
+
const validation = useValidation();
|
|
40
|
+
const context = useContext();
|
|
41
|
+
|
|
42
|
+
const mutableValidation = validation.injectMutable();
|
|
43
|
+
const events = context.injectEvents();
|
|
38
44
|
|
|
39
45
|
async function execute({ action, contextData }) {
|
|
40
|
-
const composable = composableResolver.resolve(action.composable).default();
|
|
46
|
+
const composable = composableResolver.resolve(action.composable).default({ mutableValidation, events });
|
|
41
47
|
|
|
42
48
|
if(composable.run) {
|
|
43
49
|
const options = action.options ? await dataFetcher.fetch({ data: action.options, contextData }) : { };
|
|
@@ -87,7 +93,7 @@ function Remote({ actionExecuter }) {
|
|
|
87
93
|
? null
|
|
88
94
|
: (action.body ? unref.deepUnref(await dataFetcher.fetch({ data: action.body, contextData })) : { });
|
|
89
95
|
|
|
90
|
-
const response = await
|
|
96
|
+
const response = await bfetch(pathBuilder.build(action.path, params), {
|
|
91
97
|
baseURL: apiBaseURL,
|
|
92
98
|
method: action.method,
|
|
93
99
|
headers: headers,
|
|
@@ -105,4 +111,4 @@ function Remote({ actionExecuter }) {
|
|
|
105
111
|
return {
|
|
106
112
|
execute
|
|
107
113
|
};
|
|
108
|
-
}
|
|
114
|
+
}
|
|
@@ -11,7 +11,7 @@ export default function _default(): {
|
|
|
11
11
|
handle?: boolean | undefined;
|
|
12
12
|
}) => import("vue").Ref<{}, {}>;
|
|
13
13
|
provideError: (error: any) => import("vue").Ref<boolean, boolean>;
|
|
14
|
-
injectEvents: () =>
|
|
14
|
+
injectEvents: () => null;
|
|
15
15
|
provideEvents: (value: any) => void;
|
|
16
16
|
injectExecuting: () => import("vue").Ref<boolean, boolean>;
|
|
17
17
|
provideExecuting: (value: any) => void;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { useRuntimeConfig } from "#app";
|
|
2
2
|
import { createError, useMutex } from "#imports";
|
|
3
|
+
import { bfetch } from "../utils/bfetch.js";
|
|
3
4
|
|
|
4
5
|
export default function() {
|
|
5
6
|
const mutex = useMutex();
|
|
@@ -31,7 +32,7 @@ export default function() {
|
|
|
31
32
|
const token = await current(false);
|
|
32
33
|
if(!token?.accessIsExpired()) { return; }
|
|
33
34
|
|
|
34
|
-
const result = await
|
|
35
|
+
const result = await bfetch(auth.refreshApiRoute,
|
|
35
36
|
{
|
|
36
37
|
baseURL: apiBaseURL,
|
|
37
38
|
method: "POST",
|
|
@@ -20,7 +20,6 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
20
20
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
21
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
22
|
SOFTWARE.
|
|
23
|
-
|
|
24
23
|
*/
|
|
25
24
|
|
|
26
25
|
import { isRef, unref } from "vue";
|
|
@@ -29,7 +28,7 @@ const isObject = val => val !== null && typeof val === "object";
|
|
|
29
28
|
const isArray = Array.isArray;
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
|
-
* Deeply unref a value, recursing into objects and arrays.
|
|
31
|
+
* Deeply unref a value, recursing into objects, plain object and arrays.
|
|
33
32
|
*
|
|
34
33
|
* @param {Mixed} val - The value to deeply unref.
|
|
35
34
|
*
|
|
@@ -38,7 +37,7 @@ const isArray = Array.isArray;
|
|
|
38
37
|
const deepUnref = val => {
|
|
39
38
|
const checkedVal = isRef(val) ? unref(val) : val;
|
|
40
39
|
|
|
41
|
-
if(!
|
|
40
|
+
if(!isObject(checkedVal)) {
|
|
42
41
|
return checkedVal;
|
|
43
42
|
}
|
|
44
43
|
|
|
@@ -46,9 +45,26 @@ const deepUnref = val => {
|
|
|
46
45
|
return unrefArray(checkedVal);
|
|
47
46
|
}
|
|
48
47
|
|
|
48
|
+
if(!isPlainObject(checkedVal)) {
|
|
49
|
+
return checkedVal;
|
|
50
|
+
}
|
|
51
|
+
|
|
49
52
|
return unrefObject(checkedVal);
|
|
50
53
|
};
|
|
51
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Is this value a plain object?
|
|
57
|
+
*
|
|
58
|
+
* @param {Object} val - The object to check.
|
|
59
|
+
*
|
|
60
|
+
* @return {Boolean}
|
|
61
|
+
*/
|
|
62
|
+
const isPlainObject = val => {
|
|
63
|
+
const proto = Object.getPrototypeOf(val);
|
|
64
|
+
|
|
65
|
+
return proto === Object.prototype || proto === null;
|
|
66
|
+
};
|
|
67
|
+
|
|
52
68
|
/**
|
|
53
69
|
* Unref a value, recursing into it if it's an object.
|
|
54
70
|
*
|
|
@@ -58,7 +74,7 @@ const deepUnref = val => {
|
|
|
58
74
|
*/
|
|
59
75
|
const smartUnref = val => {
|
|
60
76
|
// Non-ref object? Go deeper!
|
|
61
|
-
if(val !== null && !
|
|
77
|
+
if(val !== null && !isRef(val) && typeof val === "object") {
|
|
62
78
|
return deepUnref(val);
|
|
63
79
|
}
|
|
64
80
|
|