@merkaly/nuxt 0.4.0 → 0.4.2
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 +1 -4
- package/dist/runtime/components/auth.vue +4 -12
- package/dist/runtime/components/format/FormatMoney.d.vue.ts +3 -3
- package/dist/runtime/components/format/FormatMoney.vue +12 -12
- package/dist/runtime/components/format/FormatMoney.vue.d.ts +3 -3
- package/dist/runtime/components/input/InputAddress.d.vue.ts +1 -1
- package/dist/runtime/components/input/InputAddress.vue.d.ts +1 -1
- package/dist/runtime/components/input/InputMoney.d.vue.ts +1 -1
- package/dist/runtime/components/input/InputMoney.vue.d.ts +1 -1
- package/dist/runtime/composables/useMoney.d.ts +7 -0
- package/dist/runtime/composables/useMoney.js +10 -0
- package/dist/runtime/middleware/auth.js +2 -1
- package/dist/runtime/plugins/auth0.client.js +2 -1
- package/dist/runtime/utils/formatMoney.d.ts +7 -0
- package/dist/runtime/utils/formatMoney.js +6 -0
- package/package.json +6 -6
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -51,10 +51,7 @@ const module = defineNuxtModule({
|
|
|
51
51
|
const bootstrapConfigPath = rootResolver.resolve("bootstrap.config.ts");
|
|
52
52
|
logger.info(`Loading bootstrap.config.ts from: ${bootstrapConfigPath} (exists: ${existsSync(bootstrapConfigPath)})`);
|
|
53
53
|
const jiti = createJiti(import.meta.url);
|
|
54
|
-
const BootstrapConfig = await jiti.import(bootstrapConfigPath).then((m) => m.default || {}).catch((
|
|
55
|
-
logger.error(`Failed to load bootstrap.config.ts:`, err.message);
|
|
56
|
-
return {};
|
|
57
|
-
});
|
|
54
|
+
const BootstrapConfig = await jiti.import(bootstrapConfigPath).then((m) => m.default || {}).catch(() => ({}));
|
|
58
55
|
logger.info(`Bootstrap config keys: ${Object.keys(BootstrapConfig).join(", ") || "(empty)"}`);
|
|
59
56
|
nuxt.options["bootstrapVueNext"] = defu(nuxt.options["bootstrapVueNext"] || {}, { plugin: { components: BootstrapConfig } });
|
|
60
57
|
addPlugin({ src: moduleResolver.resolve("./runtime/plugins/api.global") });
|
|
@@ -24,18 +24,10 @@ function handleCode() {
|
|
|
24
24
|
return void $auth0.handleRedirectCallback().then(() => emit("success"));
|
|
25
25
|
}
|
|
26
26
|
callOnce(async () => {
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return handleError();
|
|
32
|
-
}
|
|
33
|
-
if (code) {
|
|
34
|
-
return handleCode();
|
|
35
|
-
}
|
|
36
|
-
return $auth0.loginWithRedirect({
|
|
37
|
-
appState: { target: redirect || "/" }
|
|
38
|
-
});
|
|
27
|
+
if (error) return handleError();
|
|
28
|
+
if (code) return handleCode();
|
|
29
|
+
if (invitation && organization) return handleInvite();
|
|
30
|
+
return $auth0.loginWithRedirect({ appState: { target: redirect || "/" } });
|
|
39
31
|
});
|
|
40
32
|
</script>
|
|
41
33
|
|
|
@@ -59,12 +59,12 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
59
59
|
};
|
|
60
60
|
}>> & Readonly<{}>, {
|
|
61
61
|
mode: keyof Intl.NumberFormatOptionsStyleRegistry;
|
|
62
|
-
base: number;
|
|
63
|
-
tag: string;
|
|
64
62
|
currency: string;
|
|
65
|
-
|
|
63
|
+
base: number;
|
|
66
64
|
locale: string;
|
|
67
65
|
value: number;
|
|
66
|
+
tag: string;
|
|
67
|
+
hideDecimal: boolean;
|
|
68
68
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
69
69
|
declare const _default: typeof __VLS_export;
|
|
70
70
|
export default _default;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
<script setup>
|
|
2
2
|
import { computed } from "vue";
|
|
3
|
+
import { useMoney } from "../../composables/useMoney";
|
|
3
4
|
const props = defineProps({
|
|
4
5
|
base: { type: Number, default: 100 },
|
|
5
6
|
currency: { type: String, default: () => "USD" },
|
|
@@ -9,24 +10,23 @@ const props = defineProps({
|
|
|
9
10
|
tag: { type: String, default: "span" },
|
|
10
11
|
value: { type: Number, default: 0 }
|
|
11
12
|
});
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
});
|
|
18
|
-
return {
|
|
19
|
-
currency: money[0],
|
|
20
|
-
value: money.slice(1, -3),
|
|
21
|
-
digits: money.slice(-3)
|
|
22
|
-
};
|
|
13
|
+
const money = useMoney(() => props.value, {
|
|
14
|
+
base: () => props.base,
|
|
15
|
+
currency: () => props.currency,
|
|
16
|
+
locale: () => props.locale,
|
|
17
|
+
mode: () => props.mode
|
|
23
18
|
});
|
|
19
|
+
const price = computed(() => ({
|
|
20
|
+
currency: money.value[0],
|
|
21
|
+
amount: money.value.slice(1, -3),
|
|
22
|
+
digits: money.value.slice(-3)
|
|
23
|
+
}));
|
|
24
24
|
</script>
|
|
25
25
|
|
|
26
26
|
<template>
|
|
27
27
|
<component :is="tag" class="format-money">
|
|
28
28
|
<span class="currency" v-text="price.currency" />
|
|
29
|
-
<span class="value" v-text="price.
|
|
29
|
+
<span class="value" v-text="price.amount" />
|
|
30
30
|
<sup v-if="!props.hideDecimal" class="digits" v-text="price.digits" />
|
|
31
31
|
</component>
|
|
32
32
|
</template>
|
|
@@ -59,12 +59,12 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
59
59
|
};
|
|
60
60
|
}>> & Readonly<{}>, {
|
|
61
61
|
mode: keyof Intl.NumberFormatOptionsStyleRegistry;
|
|
62
|
-
base: number;
|
|
63
|
-
tag: string;
|
|
64
62
|
currency: string;
|
|
65
|
-
|
|
63
|
+
base: number;
|
|
66
64
|
locale: string;
|
|
67
65
|
value: number;
|
|
66
|
+
tag: string;
|
|
67
|
+
hideDecimal: boolean;
|
|
68
68
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
69
69
|
declare const _default: typeof __VLS_export;
|
|
70
70
|
export default _default;
|
|
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
}>, {
|
|
82
82
|
mode: PlaceTypes;
|
|
83
83
|
disabled: boolean;
|
|
84
|
-
placeholder: string;
|
|
85
84
|
countries: string[];
|
|
85
|
+
placeholder: string;
|
|
86
86
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
87
87
|
declare const _default: typeof __VLS_export;
|
|
88
88
|
export default _default;
|
|
@@ -81,8 +81,8 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
81
81
|
}>, {
|
|
82
82
|
mode: PlaceTypes;
|
|
83
83
|
disabled: boolean;
|
|
84
|
-
placeholder: string;
|
|
85
84
|
countries: string[];
|
|
85
|
+
placeholder: string;
|
|
86
86
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
87
87
|
declare const _default: typeof __VLS_export;
|
|
88
88
|
export default _default;
|
|
@@ -74,10 +74,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
74
74
|
}>> & Readonly<{
|
|
75
75
|
"onUpdate:modelValue"?: ((value: Numberish) => any) | undefined;
|
|
76
76
|
}>, {
|
|
77
|
+
decimal: string;
|
|
77
78
|
min: number;
|
|
78
79
|
max: number;
|
|
79
80
|
prefix: string;
|
|
80
|
-
decimal: string;
|
|
81
81
|
placeholder: string;
|
|
82
82
|
precision: number;
|
|
83
83
|
suffix: string;
|
|
@@ -74,10 +74,10 @@ declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractP
|
|
|
74
74
|
}>> & Readonly<{
|
|
75
75
|
"onUpdate:modelValue"?: ((value: Numberish) => any) | undefined;
|
|
76
76
|
}>, {
|
|
77
|
+
decimal: string;
|
|
77
78
|
min: number;
|
|
78
79
|
max: number;
|
|
79
80
|
prefix: string;
|
|
80
|
-
decimal: string;
|
|
81
81
|
placeholder: string;
|
|
82
82
|
precision: number;
|
|
83
83
|
suffix: string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { MaybeRefOrGetter } from 'vue';
|
|
2
|
+
import type { FormatMoneyOptions } from '../utils/formatMoney.js';
|
|
3
|
+
type UseMoneyOptions = {
|
|
4
|
+
[K in keyof FormatMoneyOptions]: MaybeRefOrGetter<FormatMoneyOptions[K]>;
|
|
5
|
+
};
|
|
6
|
+
export declare function useMoney(value: MaybeRefOrGetter<number>, options?: Partial<UseMoneyOptions>): import("vue").ComputedRef<string>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
import { formatMoney } from "../utils/formatMoney.js";
|
|
3
|
+
export function useMoney(value, options = {}) {
|
|
4
|
+
return computed(() => formatMoney(toValue(value), {
|
|
5
|
+
base: toValue(options.base),
|
|
6
|
+
currency: toValue(options.currency),
|
|
7
|
+
locale: toValue(options.locale),
|
|
8
|
+
mode: toValue(options.mode)
|
|
9
|
+
}));
|
|
10
|
+
}
|
|
@@ -3,10 +3,11 @@ import { useAuth } from "../composables/useAuth.js";
|
|
|
3
3
|
export default defineNuxtRouteMiddleware((to) => {
|
|
4
4
|
const { isLoading, isAuthenticated } = useAuth();
|
|
5
5
|
const { public: { merkaly } } = useRuntimeConfig();
|
|
6
|
+
const callbackPath = URL.canParse(merkaly.auth0.callbackUrl) ? new URL(merkaly.auth0.callbackUrl).pathname : merkaly.auth0.callbackUrl;
|
|
6
7
|
if (isLoading.value) {
|
|
7
8
|
return;
|
|
8
9
|
}
|
|
9
|
-
if (to.path ===
|
|
10
|
+
if (to.path === callbackPath) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
const requiresAuth = typeof to.meta.requiresAuth === "boolean" ? to.meta.requiresAuth : merkaly.auth0.requiresAuth;
|
|
@@ -5,6 +5,7 @@ import { defu } from "defu";
|
|
|
5
5
|
import { useAuth } from "../composables/useAuth.js";
|
|
6
6
|
export default defineNuxtPlugin(async ({ callHook, hook }) => {
|
|
7
7
|
const { public: $config } = useRuntimeConfig();
|
|
8
|
+
const callbackPath = URL.canParse($config.merkaly.auth0.callbackUrl) ? new URL($config.merkaly.auth0.callbackUrl).pathname : $config.merkaly.auth0.callbackUrl;
|
|
8
9
|
const auth0 = await createAuth0Client({
|
|
9
10
|
cacheLocation: "localstorage",
|
|
10
11
|
clientId: $config.merkaly.auth0.client,
|
|
@@ -51,7 +52,7 @@ export default defineNuxtPlugin(async ({ callHook, hook }) => {
|
|
|
51
52
|
return $api("/identities", { method: "POST", prefix: "/", body });
|
|
52
53
|
});
|
|
53
54
|
};
|
|
54
|
-
const isAuthCallback = window.location.pathname ===
|
|
55
|
+
const isAuthCallback = window.location.pathname === callbackPath;
|
|
55
56
|
if (!isAuthCallback) {
|
|
56
57
|
await Promise.allSettled([auth0.getUser(), auth0.getTokenSilently()]).then(() => hook("app:created", () => callHook("merkaly:auth", user.value))).catch(() => void 0);
|
|
57
58
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkaly/nuxt",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/merkaly-io/nuxt.git"
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"@auth0/auth0-spa-js": "^2.15.0",
|
|
46
46
|
"@bootstrap-vue-next/nuxt": "^0.43.0",
|
|
47
47
|
"@nuxt/devtools": "^3.2.1",
|
|
48
|
-
"@nuxt/eslint": "1.
|
|
49
|
-
"@nuxt/eslint-config": "^1.
|
|
50
|
-
"@nuxt/fonts": "0.
|
|
48
|
+
"@nuxt/eslint": "1.15.1",
|
|
49
|
+
"@nuxt/eslint-config": "^1.15.1",
|
|
50
|
+
"@nuxt/fonts": "0.14.0",
|
|
51
51
|
"@nuxt/image": "^2.0.0",
|
|
52
52
|
"@nuxt/kit": "^4.3.0",
|
|
53
|
-
"@nuxtjs/plausible": "^
|
|
53
|
+
"@nuxtjs/plausible": "^3.0.1",
|
|
54
54
|
"@types/node": "latest",
|
|
55
55
|
"@types/vue-select": "^3.16.8",
|
|
56
56
|
"@vueuse/components": "^14.2.0",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@nuxt/module-builder": "^1.0.2",
|
|
79
79
|
"@nuxt/schema": "^4.3.0",
|
|
80
|
-
"@nuxt/test-utils": "^
|
|
80
|
+
"@nuxt/test-utils": "^4.0.0",
|
|
81
81
|
"changelogen": "^0.6.2",
|
|
82
82
|
"eslint-plugin-storybook": "^10.1.11",
|
|
83
83
|
"vitest": "^4.0.6",
|