@merkaly/nuxt 0.11.1 → 0.11.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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script setup>
|
|
2
|
-
import { computed } from "
|
|
2
|
+
import { computed, useAttrs, useId } from "#imports";
|
|
3
3
|
import { Money3Component } from "v-money3";
|
|
4
4
|
import { useMoneyFormat } from "../../composables/useMoneyFormat";
|
|
5
5
|
import { isCurrencyCode } from "../../utils/formatMoney";
|
|
@@ -9,6 +9,9 @@ const money = defineModel({ type: null, ...{
|
|
|
9
9
|
set: (v) => Math.trunc(v * 100),
|
|
10
10
|
type: [String, Number]
|
|
11
11
|
} });
|
|
12
|
+
const attrs = useAttrs();
|
|
13
|
+
const generatedId = useId();
|
|
14
|
+
const inputId = computed(() => attrs.id ?? generatedId);
|
|
12
15
|
const props = defineProps({
|
|
13
16
|
/** ISO 4217 code (`BRL`). Falls back to the app default. */
|
|
14
17
|
currency: { type: String, default: void 0 },
|
|
@@ -52,6 +55,7 @@ const config = computed(() => ({
|
|
|
52
55
|
|
|
53
56
|
<template>
|
|
54
57
|
<Money3Component
|
|
58
|
+
:id="inputId"
|
|
55
59
|
v-model.number="money"
|
|
56
60
|
:max="props.max"
|
|
57
61
|
:min="props.min"
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { getCurrentInstance, onServerPrefetch, reactive, ref } from "
|
|
2
|
-
import { useNuxtApp, useState } from "#imports";
|
|
1
|
+
import { getCurrentInstance, onServerPrefetch, reactive, ref, useNuxtApp, useState } from "#imports";
|
|
3
2
|
function useApi(callback) {
|
|
4
3
|
const { $api } = useNuxtApp();
|
|
5
4
|
const controller = new AbortController();
|
|
@@ -14,7 +13,7 @@ function useApi(callback) {
|
|
|
14
13
|
const nuxtApp = useNuxtApp();
|
|
15
14
|
const ssr = import.meta.server || nuxtApp.payload.serverRendered === true;
|
|
16
15
|
const key = `merkaly:api:${initialOptions.method}:${initialOptions.uri}:${JSON.stringify(initialOptions.query ?? {})}`;
|
|
17
|
-
const loading = ref(
|
|
16
|
+
const loading = ref(Boolean(initialOptions.immediate) && !(import.meta.client && nuxtApp.isHydrating));
|
|
18
17
|
const data = ssr ? useState(`${key}:data`, () => initialOptions.default?.()) : ref(initialOptions.default?.());
|
|
19
18
|
const meta = ssr ? useState(`${key}:meta`, () => ({})) : ref({});
|
|
20
19
|
const prefetched = ssr ? useState(`${key}:prefetched`, () => false) : ref(false);
|
|
@@ -33,12 +32,15 @@ function useApi(callback) {
|
|
|
33
32
|
loading,
|
|
34
33
|
meta,
|
|
35
34
|
params
|
|
35
|
+
}).catch((reason) => {
|
|
36
|
+
loading.value = false;
|
|
37
|
+
throw reason;
|
|
36
38
|
});
|
|
37
39
|
};
|
|
38
40
|
if (initialOptions.immediate) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
const instance = getCurrentInstance();
|
|
42
|
+
if (instance) onServerPrefetch(() => execute().then(() => void (prefetched.value = true)));
|
|
43
|
+
if (import.meta.server ? !instance : !(nuxtApp.isHydrating && prefetched.value)) {
|
|
42
44
|
void execute();
|
|
43
45
|
}
|
|
44
46
|
}
|