@merkaly/nuxt 0.4.4 → 0.5.0
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 +10 -5
- package/dist/module.json +2 -2
- package/dist/module.mjs +141 -68
- package/dist/runtime/components/app.d.vue.ts +3 -3
- package/dist/runtime/components/app.vue +4 -5
- package/dist/runtime/components/app.vue.d.ts +3 -3
- package/dist/runtime/components/table/TableDatagrid.vue +48 -27
- package/dist/runtime/composables/useDatagrid.d.ts +15 -6
- package/dist/runtime/composables/useDatagrid.js +8 -7
- package/dist/runtime/plugins/sentry.global.d.ts +2 -0
- package/dist/runtime/plugins/sentry.global.js +14 -0
- package/package.json +4 -3
package/dist/module.d.mts
CHANGED
|
@@ -4,6 +4,10 @@ export { AdapterArgs, AdapterOptions } from '../dist/runtime/utils/withAdapter.j
|
|
|
4
4
|
export { ApiOptions, HooksOptions, ParamsOptions, RefOptions } from '../dist/runtime/plugins/api.global.js';
|
|
5
5
|
|
|
6
6
|
interface MerkalyModuleOptions {
|
|
7
|
+
api: {
|
|
8
|
+
url: string;
|
|
9
|
+
prefix?: string;
|
|
10
|
+
};
|
|
7
11
|
auth0: {
|
|
8
12
|
audience: string;
|
|
9
13
|
callbackUrl: string;
|
|
@@ -17,12 +21,13 @@ interface MerkalyModuleOptions {
|
|
|
17
21
|
domain: string;
|
|
18
22
|
localhost: string;
|
|
19
23
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
sentry: {
|
|
25
|
+
dsn: string;
|
|
26
|
+
project: string;
|
|
27
|
+
token: string;
|
|
23
28
|
};
|
|
24
29
|
}
|
|
25
|
-
declare const
|
|
30
|
+
declare const merkalyModule: _nuxt_schema.NuxtModule<MerkalyModuleOptions, MerkalyModuleOptions, false>;
|
|
26
31
|
|
|
27
|
-
export {
|
|
32
|
+
export { merkalyModule as default };
|
|
28
33
|
export type { MerkalyModuleOptions };
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,83 +1,156 @@
|
|
|
1
|
-
import { defineNuxtModule,
|
|
2
|
-
import { createJiti } from 'jiti';
|
|
1
|
+
import { defineNuxtModule, useLogger, createResolver, addPlugin, addRouteMiddleware, addImportsDir, addComponentsDir, addTypeTemplate } from '@nuxt/kit';
|
|
3
2
|
import { defu } from 'defu';
|
|
3
|
+
import { createJiti } from 'jiti';
|
|
4
4
|
import { existsSync } from 'node:fs';
|
|
5
5
|
import svgLoader from 'vite-svg-loader';
|
|
6
6
|
import 'reflect-metadata';
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
callbackUrl: "/auth",
|
|
13
|
-
client: "",
|
|
14
|
-
domain: "",
|
|
15
|
-
logoutUrl: "/",
|
|
16
|
-
params: {},
|
|
17
|
-
requiresAuth: false
|
|
18
|
-
},
|
|
19
|
-
plausible: {
|
|
20
|
-
domain: "",
|
|
21
|
-
localhost: ""
|
|
22
|
-
},
|
|
23
|
-
api: {
|
|
24
|
-
url: "/",
|
|
25
|
-
prefix: "/"
|
|
26
|
-
}
|
|
8
|
+
const defaultOptions = {
|
|
9
|
+
api: {
|
|
10
|
+
url: "/",
|
|
11
|
+
prefix: "/"
|
|
27
12
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
};
|
|
37
|
-
if (nuxt.options.merkaly?.plausible) {
|
|
38
|
-
dependencies["@nuxtjs/plausible"] = {};
|
|
39
|
-
}
|
|
40
|
-
return dependencies;
|
|
13
|
+
auth0: {
|
|
14
|
+
audience: "",
|
|
15
|
+
callbackUrl: "/auth",
|
|
16
|
+
client: "",
|
|
17
|
+
domain: "",
|
|
18
|
+
logoutUrl: "/",
|
|
19
|
+
params: {},
|
|
20
|
+
requiresAuth: false
|
|
41
21
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
plausible: {
|
|
23
|
+
domain: "",
|
|
24
|
+
localhost: ""
|
|
25
|
+
},
|
|
26
|
+
sentry: {
|
|
27
|
+
dsn: "",
|
|
28
|
+
project: "",
|
|
29
|
+
token: ""
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
function hasPlausibleConfig(options) {
|
|
33
|
+
return Boolean(options.plausible?.domain);
|
|
34
|
+
}
|
|
35
|
+
function buildModuleDependencies(options) {
|
|
36
|
+
const dependencies = {
|
|
37
|
+
"@bootstrap-vue-next/nuxt": {},
|
|
38
|
+
"@nuxt/eslint": {},
|
|
39
|
+
"@nuxt/fonts": {},
|
|
40
|
+
"@nuxt/image": {},
|
|
41
|
+
"@sentry/nuxt/module": {},
|
|
42
|
+
"@vueuse/nuxt": {}
|
|
43
|
+
};
|
|
44
|
+
if (hasPlausibleConfig(options)) {
|
|
45
|
+
dependencies["@nuxtjs/plausible"] = {};
|
|
46
|
+
}
|
|
47
|
+
const logger = useLogger("@merkaly/nuxt");
|
|
48
|
+
Object.keys(dependencies).forEach((it) => logger.info(`Loaded ${it} module`));
|
|
49
|
+
return dependencies;
|
|
50
|
+
}
|
|
51
|
+
function configureRuntimeConfig(nuxt, options) {
|
|
52
|
+
nuxt.options.runtimeConfig.public.merkaly = defu(
|
|
53
|
+
options,
|
|
54
|
+
nuxt.options.runtimeConfig.public.merkaly || {}
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
function configurePlausible(nuxt, options) {
|
|
58
|
+
nuxt.options.plausible = defu(
|
|
59
|
+
{
|
|
47
60
|
apiHost: "https://analytics.merkaly.io",
|
|
48
61
|
domain: options.plausible?.domain,
|
|
49
62
|
enableAutoOutboundTracking: true,
|
|
50
63
|
enableAutoPageviews: true,
|
|
51
|
-
enabled: process.env.NODE_ENV === "production",
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
64
|
+
enabled: process.env.NODE_ENV === "production" && hasPlausibleConfig(options),
|
|
65
|
+
ignoredHostnames: ["localhost", options.plausible?.localhost].filter(Boolean)
|
|
66
|
+
},
|
|
67
|
+
nuxt.options.plausible || {}
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
function configureSentry(nuxt, options) {
|
|
71
|
+
nuxt.options.sentry = defu({
|
|
72
|
+
authToken: options.sentry.token,
|
|
73
|
+
org: "merkaly",
|
|
74
|
+
project: options.sentry.project
|
|
75
|
+
});
|
|
76
|
+
nuxt.options.sourcemap = { client: "hidden" };
|
|
77
|
+
}
|
|
78
|
+
async function loadBootstrapConfig(nuxt) {
|
|
79
|
+
const rootDirResolver = createResolver(nuxt.options.rootDir);
|
|
80
|
+
const bootstrapConfigPath = rootDirResolver.resolve("bootstrap.config.ts");
|
|
81
|
+
if (!existsSync(bootstrapConfigPath)) {
|
|
82
|
+
return {};
|
|
83
|
+
}
|
|
84
|
+
const jiti = createJiti(import.meta.url);
|
|
85
|
+
const imported = await jiti.import(bootstrapConfigPath).catch(() => ({}));
|
|
86
|
+
return imported.default || {};
|
|
87
|
+
}
|
|
88
|
+
function configureBootstrapVueNext(nuxt, components) {
|
|
89
|
+
nuxt.options.bootstrapVueNext = defu(
|
|
90
|
+
nuxt.options.bootstrapVueNext || {},
|
|
91
|
+
{
|
|
92
|
+
plugin: {
|
|
93
|
+
components
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
function registerRuntimeFeatures(nuxt, options, resolver) {
|
|
99
|
+
addPlugin({ src: resolver.resolve("./runtime/plugins/api.global") });
|
|
100
|
+
addPlugin({ src: resolver.resolve("./runtime/plugins/auth0.client") });
|
|
101
|
+
addPlugin({ src: resolver.resolve("./runtime/plugins/sentry.global") });
|
|
102
|
+
addRouteMiddleware({
|
|
103
|
+
global: options.auth0.requiresAuth,
|
|
104
|
+
name: "auth",
|
|
105
|
+
path: resolver.resolve("./runtime/middleware/auth")
|
|
106
|
+
});
|
|
107
|
+
addImportsDir(resolver.resolve("./runtime/composables"));
|
|
108
|
+
addImportsDir(resolver.resolve("./runtime/utils"));
|
|
109
|
+
addComponentsDir({
|
|
110
|
+
path: resolver.resolve("./runtime/components"),
|
|
111
|
+
prefix: "MK"
|
|
112
|
+
});
|
|
113
|
+
addTypeTemplate({
|
|
114
|
+
filename: "types/merkaly.d.ts",
|
|
115
|
+
src: resolver.resolve("./runtime/types/nuxt.d.ts")
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function configureVite(nuxt) {
|
|
119
|
+
nuxt.options.vite = defu(
|
|
120
|
+
nuxt.options.vite || {},
|
|
121
|
+
{
|
|
122
|
+
plugins: [svgLoader()]
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
const merkalyModule = defineNuxtModule({
|
|
127
|
+
defaults: defaultOptions,
|
|
128
|
+
meta: {
|
|
129
|
+
name: "@merkaly/nuxt",
|
|
130
|
+
configKey: "merkaly",
|
|
131
|
+
compatibility: { nuxt: ">=3.14.0" }
|
|
132
|
+
},
|
|
133
|
+
moduleDependencies(nuxt) {
|
|
134
|
+
const options = defu(
|
|
135
|
+
nuxt.options.merkaly || {},
|
|
136
|
+
defaultOptions
|
|
137
|
+
);
|
|
138
|
+
return buildModuleDependencies(options);
|
|
139
|
+
},
|
|
140
|
+
async setup(options, nuxt) {
|
|
55
141
|
const logger = useLogger("@merkaly/nuxt");
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
path: moduleResolver.resolve("./runtime/middleware/auth")
|
|
68
|
-
});
|
|
69
|
-
addImportsDir(moduleResolver.resolve("./runtime/composables"));
|
|
70
|
-
addImportsDir(moduleResolver.resolve("./runtime/utils"));
|
|
71
|
-
addComponentsDir({
|
|
72
|
-
path: moduleResolver.resolve("./runtime/components"),
|
|
73
|
-
prefix: "MK"
|
|
74
|
-
});
|
|
75
|
-
nuxt.options["vite"] = defu(nuxt.options["vite"] || {}, { plugins: [svgLoader()] });
|
|
76
|
-
addTypeTemplate({
|
|
77
|
-
filename: "types/merkaly.d.ts",
|
|
78
|
-
src: moduleResolver.resolve("./runtime/types/nuxt.d.ts")
|
|
79
|
-
});
|
|
142
|
+
const resolver = createResolver(import.meta.url);
|
|
143
|
+
configureRuntimeConfig(nuxt, options);
|
|
144
|
+
configurePlausible(nuxt, options);
|
|
145
|
+
configureSentry(nuxt, options);
|
|
146
|
+
const bootstrapComponentsConfig = await loadBootstrapConfig(nuxt);
|
|
147
|
+
if (Object.keys(bootstrapComponentsConfig).length > 0) {
|
|
148
|
+
logger.info("Loading bootstrap.config.ts");
|
|
149
|
+
}
|
|
150
|
+
configureBootstrapVueNext(nuxt, bootstrapComponentsConfig);
|
|
151
|
+
registerRuntimeFeatures(nuxt, options, resolver);
|
|
152
|
+
configureVite(nuxt);
|
|
80
153
|
}
|
|
81
154
|
});
|
|
82
155
|
|
|
83
|
-
export {
|
|
156
|
+
export { merkalyModule as default };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare var
|
|
1
|
+
declare var __VLS_8: {}, __VLS_10: {};
|
|
2
2
|
type __VLS_Slots = {} & {
|
|
3
|
-
loading?: (props: typeof
|
|
3
|
+
loading?: (props: typeof __VLS_8) => any;
|
|
4
4
|
} & {
|
|
5
|
-
default?: (props: typeof
|
|
5
|
+
default?: (props: typeof __VLS_10) => any;
|
|
6
6
|
};
|
|
7
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
8
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -3,9 +3,11 @@ import { useRoute } from "#app";
|
|
|
3
3
|
import { useAuth, watchOnce, addRouteMiddleware, useNuxtApp } from "#imports";
|
|
4
4
|
import AuthMiddleware from "../middleware/auth";
|
|
5
5
|
import { useNavigation } from "../composables/useNavigation";
|
|
6
|
+
import { useColorMode } from "@vueuse/core";
|
|
6
7
|
const $route = useRoute();
|
|
7
8
|
const { isLoading } = useAuth();
|
|
8
9
|
const { hook } = useNuxtApp();
|
|
10
|
+
useColorMode({ attribute: "data-bs-theme" });
|
|
9
11
|
watchOnce(isLoading, () => AuthMiddleware($route, $route));
|
|
10
12
|
const { defer, regenerate } = useNavigation();
|
|
11
13
|
addRouteMiddleware("navigation", (to) => defer(to), { global: true });
|
|
@@ -13,10 +15,7 @@ hook("page:finish", () => regenerate());
|
|
|
13
15
|
</script>
|
|
14
16
|
|
|
15
17
|
<template>
|
|
16
|
-
<
|
|
17
|
-
<NuxtRouteAnnouncer />
|
|
18
|
-
<BOrchestrator />
|
|
19
|
-
|
|
18
|
+
<BApp>
|
|
20
19
|
<!-- Mostramos spinner mientras auth se carga -->
|
|
21
20
|
<slot v-if="isLoading" name="loading" />
|
|
22
21
|
|
|
@@ -24,5 +23,5 @@ hook("page:finish", () => regenerate());
|
|
|
24
23
|
<slot v-else>
|
|
25
24
|
<NuxtPage />
|
|
26
25
|
</slot>
|
|
27
|
-
</
|
|
26
|
+
</BApp>
|
|
28
27
|
</template>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
declare var
|
|
1
|
+
declare var __VLS_8: {}, __VLS_10: {};
|
|
2
2
|
type __VLS_Slots = {} & {
|
|
3
|
-
loading?: (props: typeof
|
|
3
|
+
loading?: (props: typeof __VLS_8) => any;
|
|
4
4
|
} & {
|
|
5
|
-
default?: (props: typeof
|
|
5
|
+
default?: (props: typeof __VLS_10) => any;
|
|
6
6
|
};
|
|
7
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
8
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
@@ -52,15 +52,26 @@ const visibleItems = computed(() => {
|
|
|
52
52
|
const start = Math.max(0, paginationText.value.values.current - 1);
|
|
53
53
|
return $datagrid.value.items.slice(start, paginationText.value.values.final);
|
|
54
54
|
});
|
|
55
|
-
const
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
const selectionState = computed(() => {
|
|
56
|
+
const selectedItems = [];
|
|
57
|
+
for (const item of $datagrid.value.items) {
|
|
58
|
+
if (item._checked) {
|
|
59
|
+
selectedItems.push(item);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const selectedCount = selectedItems.length;
|
|
63
|
+
const totalCount = $datagrid.value.items.length;
|
|
64
|
+
const allChecked = totalCount > 0 && selectedCount === totalCount;
|
|
65
|
+
const someChecked = selectedCount > 0;
|
|
66
|
+
return {
|
|
67
|
+
allChecked,
|
|
68
|
+
checkboxAllAttrs: {
|
|
69
|
+
checked: allChecked,
|
|
70
|
+
indeterminate: !allChecked && someChecked
|
|
71
|
+
},
|
|
72
|
+
selectedCount,
|
|
73
|
+
selectedItems
|
|
74
|
+
};
|
|
64
75
|
});
|
|
65
76
|
function toggleCheckAll() {
|
|
66
77
|
const allChecked = $datagrid.value.items.every((it) => it._checked);
|
|
@@ -78,15 +89,25 @@ function emitSearch() {
|
|
|
78
89
|
$datagrid.value.page = 1;
|
|
79
90
|
emit("fetch", "search");
|
|
80
91
|
}
|
|
92
|
+
function getRowKey(item, idx) {
|
|
93
|
+
return $datagrid.value.row?.(item, idx)?.key ?? idx;
|
|
94
|
+
}
|
|
95
|
+
function getRowAttrs(item, idx) {
|
|
96
|
+
const row = $datagrid.value.row?.(item, idx);
|
|
97
|
+
return {
|
|
98
|
+
...row?.attrs ?? {},
|
|
99
|
+
...row?.class ? { class: row.class } : {}
|
|
100
|
+
};
|
|
101
|
+
}
|
|
81
102
|
</script>
|
|
82
103
|
|
|
83
104
|
<template>
|
|
84
105
|
<BCard no-body>
|
|
85
|
-
<BCardHeader v-if="!props.hideHeader" class="align-items-center p-4">
|
|
106
|
+
<BCardHeader v-if="!props.hideHeader" class="align-items-center p-4 position-relative">
|
|
86
107
|
<BCardTitle>
|
|
87
|
-
<div v-if="hasBulkSlot && !props.hideSelect &&
|
|
108
|
+
<div v-if="hasBulkSlot && !props.hideSelect && selectionState.selectedCount" class="w-35px">
|
|
88
109
|
<DropdownIcon icon="caret-down" size="sm" toggle-class="p-2">
|
|
89
|
-
<slot name="bulk" v-bind="{ items: selectedItems, count:
|
|
110
|
+
<slot name="bulk" v-bind="{ items: selectionState.selectedItems, count: selectionState.selectedCount }" />
|
|
90
111
|
</DropdownIcon>
|
|
91
112
|
</div>
|
|
92
113
|
|
|
@@ -146,6 +167,14 @@ function emitSearch() {
|
|
|
146
167
|
</BButton>
|
|
147
168
|
</template>
|
|
148
169
|
</div>
|
|
170
|
+
|
|
171
|
+
<BProgress
|
|
172
|
+
v-if="$datagrid.loading"
|
|
173
|
+
:value="100"
|
|
174
|
+
animated
|
|
175
|
+
height="5px"
|
|
176
|
+
class="rounded-0 position-absolute w-100 start-0"
|
|
177
|
+
style="bottom: -6px; z-index: 10" />
|
|
149
178
|
</BCardHeader>
|
|
150
179
|
|
|
151
180
|
<BTableSimple
|
|
@@ -165,12 +194,12 @@ function emitSearch() {
|
|
|
165
194
|
:disabled="$datagrid.loading"
|
|
166
195
|
class="form-check-input"
|
|
167
196
|
type="checkbox"
|
|
168
|
-
v-bind="checkboxAllAttrs"
|
|
197
|
+
v-bind="selectionState.checkboxAllAttrs"
|
|
169
198
|
@input="toggleCheckAll()">
|
|
170
199
|
</div>
|
|
171
200
|
</BTh>
|
|
172
201
|
|
|
173
|
-
<template v-for="
|
|
202
|
+
<template v-for="[key, column] in visibleColumns" :key="key">
|
|
174
203
|
<BTh :class="[column.class, column.thClass]">
|
|
175
204
|
<slot :name="`head[${key}]`" v-bind="{ column, key }">
|
|
176
205
|
<span v-text="column.title ?? sentenceCase(key)" />
|
|
@@ -182,15 +211,7 @@ function emitSearch() {
|
|
|
182
211
|
</BTr>
|
|
183
212
|
</BThead>
|
|
184
213
|
|
|
185
|
-
<BTbody v-if="
|
|
186
|
-
<BTd :colspan="tableColspan">
|
|
187
|
-
<div class="text-center">
|
|
188
|
-
<BSpinner variant="primary" />
|
|
189
|
-
</div>
|
|
190
|
-
</BTd>
|
|
191
|
-
</BTbody>
|
|
192
|
-
|
|
193
|
-
<BTbody v-else-if="!visibleItems.length">
|
|
214
|
+
<BTbody v-if="!visibleItems.length">
|
|
194
215
|
<BTd :colspan="tableColspan">
|
|
195
216
|
<slot name="empty">
|
|
196
217
|
<div class="text-center text-muted" v-text="props.emptyText" />
|
|
@@ -199,8 +220,8 @@ function emitSearch() {
|
|
|
199
220
|
</BTbody>
|
|
200
221
|
|
|
201
222
|
<BTbody v-else class="fw-semibold text-gray-600">
|
|
202
|
-
<template v-for="(item, idx) in visibleItems" :key="idx">
|
|
203
|
-
<BTr>
|
|
223
|
+
<template v-for="(item, idx) in visibleItems" :key="getRowKey(item, idx)">
|
|
224
|
+
<BTr v-bind="getRowAttrs(item, idx)">
|
|
204
225
|
<BTd v-if="hasDetailsSlot" class="p-0 w-25px">
|
|
205
226
|
<BButton
|
|
206
227
|
class="w-25px h-100 rounded-0 p-0 border-end border-dashed"
|
|
@@ -217,10 +238,10 @@ function emitSearch() {
|
|
|
217
238
|
</div>
|
|
218
239
|
</BTd>
|
|
219
240
|
|
|
220
|
-
<template v-for="
|
|
241
|
+
<template v-for="[key, column] in visibleColumns" :key="key">
|
|
221
242
|
<BTd :class="[column.class, column.tdClass]">
|
|
222
243
|
<slot :name="`row[${key}]`" v-bind="{ column, idx, item, key }">
|
|
223
|
-
<span v-text="column.getter?.(item)
|
|
244
|
+
<span v-text="column.getter?.(item) ?? getItemValue(item, key)" />
|
|
224
245
|
</slot>
|
|
225
246
|
</BTd>
|
|
226
247
|
</template>
|
|
@@ -1,25 +1,33 @@
|
|
|
1
1
|
export interface ColumnDefinition<C = unknown> {
|
|
2
2
|
class?: string;
|
|
3
|
-
getter?: (row: C) =>
|
|
3
|
+
getter?: (row: C) => unknown;
|
|
4
4
|
tdClass?: string;
|
|
5
5
|
thClass?: string;
|
|
6
6
|
title?: string;
|
|
7
|
-
type?:
|
|
7
|
+
type?: unknown;
|
|
8
8
|
}
|
|
9
9
|
export type DataGridItem<C> = C;
|
|
10
|
+
export type DataGridRowAttrs = Record<string, unknown>;
|
|
11
|
+
export type DataGridRowKey = string | number;
|
|
12
|
+
export interface DataGridRowDefinition {
|
|
13
|
+
attrs?: DataGridRowAttrs;
|
|
14
|
+
class?: string;
|
|
15
|
+
key?: DataGridRowKey;
|
|
16
|
+
}
|
|
10
17
|
export interface DataGrid<C = unknown> {
|
|
11
18
|
columns: Record<string, ColumnDefinition<C>>;
|
|
12
19
|
error: unknown;
|
|
20
|
+
fn: {
|
|
21
|
+
addItem: (item: C) => DataGridItem<C>[];
|
|
22
|
+
removeItem: (predicate: (item: DataGridItem<C>, index: number) => boolean) => number;
|
|
23
|
+
};
|
|
13
24
|
items: DataGridItem<C>[];
|
|
14
25
|
limit: number;
|
|
15
26
|
loading: boolean;
|
|
16
27
|
page: number;
|
|
28
|
+
row?: (item: C, index: number) => DataGridRowDefinition;
|
|
17
29
|
search: string;
|
|
18
30
|
total: number;
|
|
19
|
-
fn: {
|
|
20
|
-
addItem: (item: C) => DataGridItem<C>[];
|
|
21
|
-
removeItem: (predicate: (item: DataGridItem<C>, index: number) => boolean) => number;
|
|
22
|
-
};
|
|
23
31
|
}
|
|
24
32
|
interface OptionArgs<D> {
|
|
25
33
|
columns: Record<string, ColumnDefinition<D>>;
|
|
@@ -27,6 +35,7 @@ interface OptionArgs<D> {
|
|
|
27
35
|
items?: D[];
|
|
28
36
|
limit?: number;
|
|
29
37
|
loading?: boolean;
|
|
38
|
+
row?: (item: D, index: number) => DataGridRowDefinition;
|
|
30
39
|
search?: string;
|
|
31
40
|
total?: number;
|
|
32
41
|
}
|
|
@@ -3,12 +3,6 @@ export function useDatagrid(params) {
|
|
|
3
3
|
const state = reactive({
|
|
4
4
|
columns: params.columns,
|
|
5
5
|
error: params.error ?? null,
|
|
6
|
-
items: params.items ?? [],
|
|
7
|
-
search: params.search,
|
|
8
|
-
limit: params.limit ?? 10,
|
|
9
|
-
loading: params.loading ?? false,
|
|
10
|
-
page: 1,
|
|
11
|
-
total: params.total ?? 0,
|
|
12
6
|
fn: {
|
|
13
7
|
addItem(item) {
|
|
14
8
|
state.items.push(item);
|
|
@@ -21,7 +15,14 @@ export function useDatagrid(params) {
|
|
|
21
15
|
}
|
|
22
16
|
return index;
|
|
23
17
|
}
|
|
24
|
-
}
|
|
18
|
+
},
|
|
19
|
+
items: params.items ?? [],
|
|
20
|
+
limit: params.limit ?? 10,
|
|
21
|
+
loading: params.loading ?? false,
|
|
22
|
+
page: 1,
|
|
23
|
+
row: params.row,
|
|
24
|
+
search: params.search ?? "",
|
|
25
|
+
total: params.total ?? 0
|
|
25
26
|
});
|
|
26
27
|
return state;
|
|
27
28
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "#app";
|
|
2
|
+
import { setUser } from "@sentry/nuxt";
|
|
3
|
+
export default defineNuxtPlugin(async ({ hook }) => {
|
|
4
|
+
hook("merkaly:auth", (user) => {
|
|
5
|
+
if (!user) {
|
|
6
|
+
return setUser(null);
|
|
7
|
+
}
|
|
8
|
+
return setUser({
|
|
9
|
+
id: user.sub,
|
|
10
|
+
email: user.email,
|
|
11
|
+
username: user.name
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@merkaly/nuxt",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/merkaly-io/nuxt.git"
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@auth0/auth0-spa-js": "^2.17.0",
|
|
46
|
-
"@bootstrap-vue-next/nuxt": "^0.
|
|
46
|
+
"@bootstrap-vue-next/nuxt": "^0.44.1",
|
|
47
47
|
"@nuxt/devtools": "^3.2.1",
|
|
48
48
|
"@nuxt/eslint": "1.15.1",
|
|
49
49
|
"@nuxt/eslint-config": "^1.15.1",
|
|
@@ -51,6 +51,7 @@
|
|
|
51
51
|
"@nuxt/image": "^2.0.0",
|
|
52
52
|
"@nuxt/kit": "^4.4.2",
|
|
53
53
|
"@nuxtjs/plausible": "^3.0.1",
|
|
54
|
+
"@sentry/nuxt": "^10.47.0",
|
|
54
55
|
"@types/node": "latest",
|
|
55
56
|
"@types/vue-select": "^3.16.8",
|
|
56
57
|
"@vueuse/components": "^14.2.0",
|
|
@@ -58,7 +59,7 @@
|
|
|
58
59
|
"@vueuse/integrations": "^14.2.0",
|
|
59
60
|
"@vueuse/nuxt": "^14.2.0",
|
|
60
61
|
"bootstrap": "^5.3.8",
|
|
61
|
-
"bootstrap-vue-next": "^0.
|
|
62
|
+
"bootstrap-vue-next": "^0.44.1",
|
|
62
63
|
"change-case": "^5",
|
|
63
64
|
"class-transformer": "^0.5.1",
|
|
64
65
|
"class-validator": "^0.15.1",
|