@merkaly/nuxt 0.1.4 → 0.1.8
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.d.mts +26 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +123 -13
- package/dist/runtime/components/app.d.vue.ts +15 -0
- package/dist/runtime/components/app.vue +23 -0
- package/dist/runtime/components/app.vue.d.ts +15 -0
- package/dist/runtime/components/auth.d.vue.ts +9 -0
- package/dist/runtime/components/auth.vue +44 -0
- package/dist/runtime/components/auth.vue.d.ts +9 -0
- package/dist/runtime/components/format/FormatIcon.d.vue.ts +97 -0
- package/dist/runtime/components/format/FormatIcon.vue +40 -0
- package/dist/runtime/components/format/FormatIcon.vue.d.ts +97 -0
- package/dist/runtime/components/format/FormatMoney.d.vue.ts +70 -0
- package/dist/runtime/components/format/FormatMoney.vue +39 -0
- package/dist/runtime/components/format/FormatMoney.vue.d.ts +70 -0
- package/dist/runtime/components/input/InputMoney.d.vue.ts +88 -0
- package/dist/runtime/components/input/InputMoney.vue +35 -0
- package/dist/runtime/components/input/InputMoney.vue.d.ts +88 -0
- package/dist/runtime/composables/useApi.d.ts +18 -0
- package/dist/runtime/composables/useApi.js +42 -0
- package/dist/runtime/composables/useAuth.d.ts +8 -0
- package/dist/runtime/composables/useAuth.js +15 -0
- package/dist/runtime/middleware/auth.d.ts +2 -0
- package/dist/runtime/middleware/auth.js +20 -0
- package/dist/runtime/plugins/api.global.d.ts +47 -0
- package/dist/runtime/plugins/api.global.js +54 -0
- package/dist/runtime/plugins/auth0.client.d.ts +6 -0
- package/dist/runtime/plugins/auth0.client.js +34 -0
- package/dist/runtime/server/tsconfig.json +3 -0
- package/dist/runtime/types/nuxt.d.ts +16 -0
- package/dist/runtime/utils/withAdapter.d.ts +22 -0
- package/dist/runtime/utils/withAdapter.js +9 -0
- package/dist/types.d.mts +6 -10
- package/package.json +16 -13
- package/dist/module.d.cts +0 -2
package/dist/module.d.mts
CHANGED
|
@@ -1,2 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
|
+
import { ClientAuthorizationParams } from '@auth0/auth0-spa-js';
|
|
3
|
+
|
|
4
|
+
interface MerkalyModuleOptions {
|
|
5
|
+
auth0: {
|
|
6
|
+
audience: string;
|
|
7
|
+
callbackUrl: string;
|
|
8
|
+
client: string;
|
|
9
|
+
domain: string;
|
|
10
|
+
logoutUrl?: string;
|
|
11
|
+
params?: Omit<ClientAuthorizationParams, 'redirect_uri'>;
|
|
12
|
+
requiresAuth: boolean;
|
|
13
|
+
};
|
|
14
|
+
plausible?: {
|
|
15
|
+
domain: string;
|
|
16
|
+
localhost: string;
|
|
17
|
+
};
|
|
18
|
+
api: {
|
|
19
|
+
url: string;
|
|
20
|
+
prefix?: string;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
declare const _default: _nuxt_schema.NuxtModule<MerkalyModuleOptions, MerkalyModuleOptions, false>;
|
|
24
|
+
|
|
25
|
+
export { _default as default };
|
|
26
|
+
export type { MerkalyModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,18 +1,128 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineNuxtModule, createResolver, addPlugin, addRouteMiddleware, addImportsDir, addComponentsDir } from '@nuxt/kit';
|
|
2
|
+
import { existsSync } from 'node:fs';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
function isPlainObject(value) {
|
|
5
|
+
if (value === null || typeof value !== "object") {
|
|
6
|
+
return false;
|
|
7
|
+
}
|
|
8
|
+
const prototype = Object.getPrototypeOf(value);
|
|
9
|
+
if (prototype !== null && prototype !== Object.prototype && Object.getPrototypeOf(prototype) !== null) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
if (Symbol.iterator in value) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
if (Symbol.toStringTag in value) {
|
|
16
|
+
return Object.prototype.toString.call(value) === "[object Module]";
|
|
17
|
+
}
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function _defu(baseObject, defaults, namespace = ".", merger) {
|
|
22
|
+
if (!isPlainObject(defaults)) {
|
|
23
|
+
return _defu(baseObject, {}, namespace, merger);
|
|
24
|
+
}
|
|
25
|
+
const object = Object.assign({}, defaults);
|
|
26
|
+
for (const key in baseObject) {
|
|
27
|
+
if (key === "__proto__" || key === "constructor") {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
const value = baseObject[key];
|
|
31
|
+
if (value === null || value === void 0) {
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
if (merger && merger(object, key, value, namespace)) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
if (Array.isArray(value) && Array.isArray(object[key])) {
|
|
38
|
+
object[key] = [...value, ...object[key]];
|
|
39
|
+
} else if (isPlainObject(value) && isPlainObject(object[key])) {
|
|
40
|
+
object[key] = _defu(
|
|
41
|
+
value,
|
|
42
|
+
object[key],
|
|
43
|
+
(namespace ? `${namespace}.` : "") + key.toString(),
|
|
44
|
+
merger
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
object[key] = value;
|
|
11
48
|
}
|
|
12
49
|
}
|
|
13
|
-
|
|
50
|
+
return object;
|
|
51
|
+
}
|
|
52
|
+
function createDefu(merger) {
|
|
53
|
+
return (...arguments_) => (
|
|
54
|
+
// eslint-disable-next-line unicorn/no-array-reduce
|
|
55
|
+
arguments_.reduce((p, c) => _defu(p, c, "", merger), {})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
const defu = createDefu();
|
|
14
59
|
|
|
15
|
-
|
|
16
|
-
|
|
60
|
+
const module = defineNuxtModule({
|
|
61
|
+
defaults: {
|
|
62
|
+
auth0: {
|
|
63
|
+
audience: "",
|
|
64
|
+
callbackUrl: "/auth",
|
|
65
|
+
client: "",
|
|
66
|
+
domain: "",
|
|
67
|
+
logoutUrl: "/",
|
|
68
|
+
params: {},
|
|
69
|
+
requiresAuth: false
|
|
70
|
+
},
|
|
71
|
+
plausible: {
|
|
72
|
+
domain: "",
|
|
73
|
+
localhost: ""
|
|
74
|
+
},
|
|
75
|
+
api: {
|
|
76
|
+
url: "/",
|
|
77
|
+
prefix: "/"
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
meta: { name: "@merkaly/nuxt", configKey: "merkaly", compatibility: { nuxt: ">=3.0.0" } },
|
|
81
|
+
moduleDependencies: {
|
|
82
|
+
"@bootstrap-vue-next/nuxt": {},
|
|
83
|
+
"@nuxt/eslint": {},
|
|
84
|
+
"@nuxt/fonts": {},
|
|
85
|
+
"@nuxt/image": {},
|
|
86
|
+
"@nuxtjs/plausible": {},
|
|
87
|
+
"@vueuse/nuxt": {}
|
|
88
|
+
},
|
|
89
|
+
async setup(options, nuxt) {
|
|
90
|
+
const moduleResolver = createResolver(import.meta.url);
|
|
91
|
+
const rootResolver = createResolver(nuxt.options.rootDir);
|
|
92
|
+
nuxt.options.runtimeConfig.public.merkaly = defu(options, nuxt.options.runtimeConfig.public.merkaly || {});
|
|
93
|
+
nuxt.options.plausible = defu({
|
|
94
|
+
apiHost: "https://analytics.merkaly.io",
|
|
95
|
+
domain: options.plausible?.domain,
|
|
96
|
+
enableAutoOutboundTracking: true,
|
|
97
|
+
enableAutoPageviews: true,
|
|
98
|
+
enabled: process.env.NODE_ENV === "production",
|
|
99
|
+
// ✅ Solo en producción
|
|
100
|
+
ignoredHostnames: ["localhost"].concat(options.plausible?.localhost || "").filter(Boolean)
|
|
101
|
+
}, nuxt.options.plausible || {});
|
|
102
|
+
const bootstrapConfigPath = rootResolver.resolve("bootstrap.config.ts");
|
|
103
|
+
let BootstrapConfig;
|
|
104
|
+
if (existsSync(bootstrapConfigPath)) {
|
|
105
|
+
BootstrapConfig = await import(bootstrapConfigPath) || {};
|
|
106
|
+
}
|
|
107
|
+
if (!BootstrapConfig) {
|
|
108
|
+
BootstrapConfig = {};
|
|
109
|
+
}
|
|
110
|
+
nuxt.options["bootstrapVueNext"] = defu(nuxt.options["bootstrapVueNext"] || {}, { plugin: { components: BootstrapConfig } });
|
|
111
|
+
addPlugin({ src: moduleResolver.resolve("./runtime/plugins/api.global") });
|
|
112
|
+
addPlugin({ src: moduleResolver.resolve("./runtime/plugins/auth0.client"), mode: "client" });
|
|
113
|
+
addRouteMiddleware({
|
|
114
|
+
global: options.auth0.requiresAuth,
|
|
115
|
+
name: "auth",
|
|
116
|
+
path: moduleResolver.resolve("./runtime/middleware/auth")
|
|
117
|
+
});
|
|
118
|
+
addImportsDir(moduleResolver.resolve("./runtime/composables"));
|
|
119
|
+
addImportsDir(moduleResolver.resolve("./runtime/utils"));
|
|
120
|
+
addComponentsDir({
|
|
121
|
+
path: moduleResolver.resolve("./runtime/components"),
|
|
122
|
+
prefix: "MK"
|
|
123
|
+
});
|
|
124
|
+
nuxt.options["vite"] = defu(nuxt.options["vite"] || {}, { plugins: [require("vite-svg-loader")()] });
|
|
125
|
+
}
|
|
126
|
+
});
|
|
17
127
|
|
|
18
|
-
export
|
|
128
|
+
export { module as default };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare var __VLS_11: {}, __VLS_13: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
loading?: (props: typeof __VLS_11) => any;
|
|
4
|
+
} & {
|
|
5
|
+
default?: (props: typeof __VLS_13) => any;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useRoute } from "#app";
|
|
3
|
+
import { useAuth, watchOnce } from "#imports";
|
|
4
|
+
import AuthMiddleware from "../middleware/auth";
|
|
5
|
+
const $route = useRoute();
|
|
6
|
+
const { isLoading } = useAuth();
|
|
7
|
+
watchOnce(isLoading, () => AuthMiddleware($route, $route));
|
|
8
|
+
</script>
|
|
9
|
+
|
|
10
|
+
<template>
|
|
11
|
+
<main>
|
|
12
|
+
<NuxtRouteAnnouncer />
|
|
13
|
+
<BOrchestrator />
|
|
14
|
+
|
|
15
|
+
<!-- Mostramos spinner mientras auth se carga -->
|
|
16
|
+
<slot v-if="isLoading" name="loading" />
|
|
17
|
+
|
|
18
|
+
<!-- Renderizamos páginas solo cuando isLoading = false -->
|
|
19
|
+
<slot v-else>
|
|
20
|
+
<NuxtPage />
|
|
21
|
+
</slot>
|
|
22
|
+
</main>
|
|
23
|
+
</template>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare var __VLS_11: {}, __VLS_13: {};
|
|
2
|
+
type __VLS_Slots = {} & {
|
|
3
|
+
loading?: (props: typeof __VLS_11) => any;
|
|
4
|
+
} & {
|
|
5
|
+
default?: (props: typeof __VLS_13) => any;
|
|
6
|
+
};
|
|
7
|
+
declare const __VLS_base: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
9
|
+
declare const _default: typeof __VLS_export;
|
|
10
|
+
export default _default;
|
|
11
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
12
|
+
new (): {
|
|
13
|
+
$slots: S;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
2
|
+
error: (reason: string) => any;
|
|
3
|
+
success: () => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
5
|
+
onError?: ((reason: string) => any) | undefined;
|
|
6
|
+
onSuccess?: (() => any) | undefined;
|
|
7
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useNuxtApp, showError } from "#app";
|
|
3
|
+
import { callOnce } from "#imports";
|
|
4
|
+
const { $auth0 } = useNuxtApp();
|
|
5
|
+
const emit = defineEmits(["success", "error"]);
|
|
6
|
+
const params = new URLSearchParams(window.location.search);
|
|
7
|
+
const code = params.get("code");
|
|
8
|
+
const error = params.get("error");
|
|
9
|
+
const invitation = params.get("invitation");
|
|
10
|
+
const organization = params.get("organization");
|
|
11
|
+
function handleInvite() {
|
|
12
|
+
return $auth0.loginWithRedirect({ authorizationParams: { organization, invitation } });
|
|
13
|
+
}
|
|
14
|
+
function handleError() {
|
|
15
|
+
const errorDescription = params.get("error_description") ?? "Auth error";
|
|
16
|
+
emit("error", errorDescription);
|
|
17
|
+
return showError({
|
|
18
|
+
statusCode: 400,
|
|
19
|
+
statusMessage: errorDescription
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function handleCode() {
|
|
23
|
+
return void $auth0.handleRedirectCallback().then(() => emit("success"));
|
|
24
|
+
}
|
|
25
|
+
callOnce(async () => {
|
|
26
|
+
if (invitation && organization) {
|
|
27
|
+
return handleInvite();
|
|
28
|
+
}
|
|
29
|
+
if (error) {
|
|
30
|
+
return handleError();
|
|
31
|
+
}
|
|
32
|
+
if (code) {
|
|
33
|
+
return handleCode();
|
|
34
|
+
}
|
|
35
|
+
return $auth0.loginWithRedirect();
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
38
|
+
|
|
39
|
+
<template>
|
|
40
|
+
<div class="d-flex gap-3 justify-content-center align-items-center h-100">
|
|
41
|
+
<BSpinner variant="primary" />
|
|
42
|
+
<span v-text="'Loading...'" />
|
|
43
|
+
</div>
|
|
44
|
+
</template>
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
2
|
+
error: (reason: string) => any;
|
|
3
|
+
success: () => any;
|
|
4
|
+
}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{
|
|
5
|
+
onError?: ((reason: string) => any) | undefined;
|
|
6
|
+
onSuccess?: (() => any) | undefined;
|
|
7
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
8
|
+
declare const _default: typeof __VLS_export;
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ColorVariant } from 'bootstrap-vue-next';
|
|
2
|
+
import type { PropType } from '#imports';
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
mode: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
name: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
opacity: {
|
|
13
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
14
|
+
default: () => string;
|
|
15
|
+
};
|
|
16
|
+
provider: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
reversed: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
size: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: () => string;
|
|
27
|
+
};
|
|
28
|
+
spin: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
32
|
+
tag: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: () => string;
|
|
35
|
+
};
|
|
36
|
+
text: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: () => string;
|
|
39
|
+
};
|
|
40
|
+
variant: {
|
|
41
|
+
type: PropType<ColorVariant | string>;
|
|
42
|
+
default: () => string;
|
|
43
|
+
};
|
|
44
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
45
|
+
mode: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
name: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
required: true;
|
|
52
|
+
};
|
|
53
|
+
opacity: {
|
|
54
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
55
|
+
default: () => string;
|
|
56
|
+
};
|
|
57
|
+
provider: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
reversed: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
size: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
default: () => string;
|
|
68
|
+
};
|
|
69
|
+
spin: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
73
|
+
tag: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: () => string;
|
|
76
|
+
};
|
|
77
|
+
text: {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
default: () => string;
|
|
80
|
+
};
|
|
81
|
+
variant: {
|
|
82
|
+
type: PropType<ColorVariant | string>;
|
|
83
|
+
default: () => string;
|
|
84
|
+
};
|
|
85
|
+
}>> & Readonly<{}>, {
|
|
86
|
+
text: string;
|
|
87
|
+
mode: string;
|
|
88
|
+
size: string;
|
|
89
|
+
tag: string;
|
|
90
|
+
variant: string;
|
|
91
|
+
opacity: string | number;
|
|
92
|
+
provider: string;
|
|
93
|
+
reversed: boolean;
|
|
94
|
+
spin: boolean;
|
|
95
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
96
|
+
declare const _default: typeof __VLS_export;
|
|
97
|
+
export default _default;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "#imports";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
mode: { type: String, default: "duotone" },
|
|
5
|
+
name: { type: String, required: true },
|
|
6
|
+
opacity: { type: [String, Number], default: () => "" },
|
|
7
|
+
provider: { type: String, default: "fa" },
|
|
8
|
+
reversed: { type: Boolean, default: false },
|
|
9
|
+
size: { type: String, default: () => "" },
|
|
10
|
+
spin: { type: Boolean, default: false },
|
|
11
|
+
tag: { type: String, default: () => "i" },
|
|
12
|
+
text: { type: String, default: () => "" },
|
|
13
|
+
variant: { type: String, default: () => "" }
|
|
14
|
+
});
|
|
15
|
+
const iconName = computed(() => `${props.provider}-${props.name}`);
|
|
16
|
+
const iconMode = computed(() => `${props.provider}-${props.mode}`);
|
|
17
|
+
const animateSpin = computed(() => props.spin ? `${props.provider}-spin` : void 0);
|
|
18
|
+
const iconOpacity = computed(() => props.opacity ? `opacity-${props.opacity}` : void 0);
|
|
19
|
+
const fontSize = computed(() => props.size ? `fs-${props.size}` : void 0);
|
|
20
|
+
const fontColor = computed(() => props.variant ? `text-${props.variant}` : void 0);
|
|
21
|
+
const classList = computed(() => [
|
|
22
|
+
iconName.value,
|
|
23
|
+
iconMode.value,
|
|
24
|
+
animateSpin.value,
|
|
25
|
+
iconOpacity.value,
|
|
26
|
+
fontSize.value,
|
|
27
|
+
fontColor.value
|
|
28
|
+
].filter(Boolean));
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<template v-if="props.text">
|
|
33
|
+
<span :class="{ 'flex-row-reverse': props.reversed }" class="d-flex align-items-center">
|
|
34
|
+
<component :is="props.tag" :class="classList" />
|
|
35
|
+
<span class="ps-1" v-text="props.text" />
|
|
36
|
+
</span>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<component :is="props.tag" v-else :class="classList" />
|
|
40
|
+
</template>
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ColorVariant } from 'bootstrap-vue-next';
|
|
2
|
+
import type { PropType } from '#imports';
|
|
3
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
4
|
+
mode: {
|
|
5
|
+
type: StringConstructor;
|
|
6
|
+
default: string;
|
|
7
|
+
};
|
|
8
|
+
name: {
|
|
9
|
+
type: StringConstructor;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
opacity: {
|
|
13
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
14
|
+
default: () => string;
|
|
15
|
+
};
|
|
16
|
+
provider: {
|
|
17
|
+
type: StringConstructor;
|
|
18
|
+
default: string;
|
|
19
|
+
};
|
|
20
|
+
reversed: {
|
|
21
|
+
type: BooleanConstructor;
|
|
22
|
+
default: boolean;
|
|
23
|
+
};
|
|
24
|
+
size: {
|
|
25
|
+
type: StringConstructor;
|
|
26
|
+
default: () => string;
|
|
27
|
+
};
|
|
28
|
+
spin: {
|
|
29
|
+
type: BooleanConstructor;
|
|
30
|
+
default: boolean;
|
|
31
|
+
};
|
|
32
|
+
tag: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: () => string;
|
|
35
|
+
};
|
|
36
|
+
text: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: () => string;
|
|
39
|
+
};
|
|
40
|
+
variant: {
|
|
41
|
+
type: PropType<ColorVariant | string>;
|
|
42
|
+
default: () => string;
|
|
43
|
+
};
|
|
44
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
45
|
+
mode: {
|
|
46
|
+
type: StringConstructor;
|
|
47
|
+
default: string;
|
|
48
|
+
};
|
|
49
|
+
name: {
|
|
50
|
+
type: StringConstructor;
|
|
51
|
+
required: true;
|
|
52
|
+
};
|
|
53
|
+
opacity: {
|
|
54
|
+
type: (NumberConstructor | StringConstructor)[];
|
|
55
|
+
default: () => string;
|
|
56
|
+
};
|
|
57
|
+
provider: {
|
|
58
|
+
type: StringConstructor;
|
|
59
|
+
default: string;
|
|
60
|
+
};
|
|
61
|
+
reversed: {
|
|
62
|
+
type: BooleanConstructor;
|
|
63
|
+
default: boolean;
|
|
64
|
+
};
|
|
65
|
+
size: {
|
|
66
|
+
type: StringConstructor;
|
|
67
|
+
default: () => string;
|
|
68
|
+
};
|
|
69
|
+
spin: {
|
|
70
|
+
type: BooleanConstructor;
|
|
71
|
+
default: boolean;
|
|
72
|
+
};
|
|
73
|
+
tag: {
|
|
74
|
+
type: StringConstructor;
|
|
75
|
+
default: () => string;
|
|
76
|
+
};
|
|
77
|
+
text: {
|
|
78
|
+
type: StringConstructor;
|
|
79
|
+
default: () => string;
|
|
80
|
+
};
|
|
81
|
+
variant: {
|
|
82
|
+
type: PropType<ColorVariant | string>;
|
|
83
|
+
default: () => string;
|
|
84
|
+
};
|
|
85
|
+
}>> & Readonly<{}>, {
|
|
86
|
+
text: string;
|
|
87
|
+
mode: string;
|
|
88
|
+
size: string;
|
|
89
|
+
tag: string;
|
|
90
|
+
variant: string;
|
|
91
|
+
opacity: string | number;
|
|
92
|
+
provider: string;
|
|
93
|
+
reversed: boolean;
|
|
94
|
+
spin: boolean;
|
|
95
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
96
|
+
declare const _default: typeof __VLS_export;
|
|
97
|
+
export default _default;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { PropType } from '#imports';
|
|
2
|
+
declare const __VLS_export: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
3
|
+
base: {
|
|
4
|
+
type: NumberConstructor;
|
|
5
|
+
default: number;
|
|
6
|
+
};
|
|
7
|
+
currency: {
|
|
8
|
+
type: StringConstructor;
|
|
9
|
+
default: () => string;
|
|
10
|
+
};
|
|
11
|
+
hideDecimal: {
|
|
12
|
+
type: BooleanConstructor;
|
|
13
|
+
default: () => boolean;
|
|
14
|
+
};
|
|
15
|
+
locale: {
|
|
16
|
+
type: StringConstructor;
|
|
17
|
+
default: () => string;
|
|
18
|
+
};
|
|
19
|
+
mode: {
|
|
20
|
+
type: PropType<Intl.NumberFormatOptionsStyle>;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
tag: {
|
|
24
|
+
type: StringConstructor;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
value: {
|
|
28
|
+
type: NumberConstructor;
|
|
29
|
+
default: number;
|
|
30
|
+
};
|
|
31
|
+
}>, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
32
|
+
base: {
|
|
33
|
+
type: NumberConstructor;
|
|
34
|
+
default: number;
|
|
35
|
+
};
|
|
36
|
+
currency: {
|
|
37
|
+
type: StringConstructor;
|
|
38
|
+
default: () => string;
|
|
39
|
+
};
|
|
40
|
+
hideDecimal: {
|
|
41
|
+
type: BooleanConstructor;
|
|
42
|
+
default: () => boolean;
|
|
43
|
+
};
|
|
44
|
+
locale: {
|
|
45
|
+
type: StringConstructor;
|
|
46
|
+
default: () => string;
|
|
47
|
+
};
|
|
48
|
+
mode: {
|
|
49
|
+
type: PropType<Intl.NumberFormatOptionsStyle>;
|
|
50
|
+
default: string;
|
|
51
|
+
};
|
|
52
|
+
tag: {
|
|
53
|
+
type: StringConstructor;
|
|
54
|
+
default: string;
|
|
55
|
+
};
|
|
56
|
+
value: {
|
|
57
|
+
type: NumberConstructor;
|
|
58
|
+
default: number;
|
|
59
|
+
};
|
|
60
|
+
}>> & Readonly<{}>, {
|
|
61
|
+
value: number;
|
|
62
|
+
mode: keyof Intl.NumberFormatOptionsStyleRegistry;
|
|
63
|
+
base: number;
|
|
64
|
+
tag: string;
|
|
65
|
+
currency: string;
|
|
66
|
+
hideDecimal: boolean;
|
|
67
|
+
locale: string;
|
|
68
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
69
|
+
declare const _default: typeof __VLS_export;
|
|
70
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { computed } from "#imports";
|
|
3
|
+
const props = defineProps({
|
|
4
|
+
base: { type: Number, default: 100 },
|
|
5
|
+
currency: { type: String, default: () => "USD" },
|
|
6
|
+
hideDecimal: { type: Boolean, default: () => false },
|
|
7
|
+
locale: { type: String, default: () => "en-US" },
|
|
8
|
+
mode: { type: String, default: "currency" },
|
|
9
|
+
tag: { type: String, default: "span" },
|
|
10
|
+
value: { type: Number, default: 0 }
|
|
11
|
+
});
|
|
12
|
+
const price = computed(() => {
|
|
13
|
+
const price2 = props.value / props.base;
|
|
14
|
+
const money = price2.toLocaleString(props.locale, {
|
|
15
|
+
style: props.mode,
|
|
16
|
+
currency: props.currency
|
|
17
|
+
});
|
|
18
|
+
return {
|
|
19
|
+
currency: money[0],
|
|
20
|
+
value: money.slice(1, -3),
|
|
21
|
+
digits: money.slice(-3)
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
</script>
|
|
25
|
+
|
|
26
|
+
<template>
|
|
27
|
+
<component :is="tag" class="format-money">
|
|
28
|
+
<span class="currency" v-text="price.currency" />
|
|
29
|
+
<span class="value" v-text="price.value" />
|
|
30
|
+
<sup v-if="!props.hideDecimal" class="digits" v-text="price.digits" />
|
|
31
|
+
</component>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<style scoped>
|
|
35
|
+
.format-money {
|
|
36
|
+
font-variant-numeric: tabular-nums;
|
|
37
|
+
font-feature-settings: "tnum";
|
|
38
|
+
}
|
|
39
|
+
</style>
|