@aerogel/core 0.0.0-next.b85327579d32f21c6a9fa21142f0165cdd320d7e → 0.0.0-next.d824b40e5d06757cd9f47c9f771d916185df4f05
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/aerogel-core.cjs.js +1 -1
- package/dist/aerogel-core.cjs.js.map +1 -1
- package/dist/aerogel-core.d.ts +355 -59
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/dist/virtual.d.ts +11 -0
- package/noeldemartin.config.js +4 -1
- package/package.json +3 -3
- package/src/bootstrap/index.ts +2 -1
- package/src/components/AGAppModals.vue +15 -0
- package/src/components/AGAppOverlays.vue +5 -7
- package/src/components/AGAppSnackbars.vue +13 -0
- package/src/components/basic/AGErrorMessage.vue +16 -0
- package/src/components/basic/AGLink.vue +9 -0
- package/src/components/basic/AGMarkdown.vue +7 -6
- package/src/components/basic/index.ts +3 -1
- package/src/components/constants.ts +8 -0
- package/src/components/forms/AGButton.vue +25 -15
- package/src/components/headless/forms/AGHeadlessButton.vue +4 -3
- package/src/components/headless/index.ts +1 -0
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
- package/src/components/headless/snackbars/index.ts +25 -0
- package/src/components/index.ts +2 -0
- package/src/components/modals/AGAlertModal.vue +0 -1
- package/src/components/modals/AGConfirmModal.vue +1 -1
- package/src/components/modals/AGErrorReportModal.ts +20 -0
- package/src/components/modals/AGErrorReportModal.vue +62 -0
- package/src/components/modals/AGErrorReportModalButtons.vue +109 -0
- package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
- package/src/components/modals/AGModal.vue +3 -2
- package/src/components/modals/AGModalTitle.vue +9 -0
- package/src/components/modals/index.ts +17 -2
- package/src/components/snackbars/AGSnackbar.vue +42 -0
- package/src/components/snackbars/index.ts +3 -0
- package/src/directives/index.ts +16 -3
- package/src/errors/Errors.ts +60 -9
- package/src/errors/index.ts +39 -1
- package/src/forms/Form.ts +3 -3
- package/src/lang/Lang.ts +1 -1
- package/src/main.ts +0 -2
- package/src/plugins/Plugin.ts +1 -0
- package/src/plugins/index.ts +19 -0
- package/src/services/App.state.ts +8 -3
- package/src/services/App.ts +5 -2
- package/src/services/Service.ts +7 -2
- package/src/services/index.ts +6 -3
- package/src/types/virtual.d.ts +11 -0
- package/src/ui/UI.state.ts +10 -1
- package/src/ui/UI.ts +37 -8
- package/src/ui/index.ts +4 -0
- package/src/utils/markdown.ts +11 -2
- package/src/utils/vue.ts +2 -0
- package/tsconfig.json +1 -0
- package/vite.config.ts +2 -1
- package/src/globals.ts +0 -6
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
import { computed, h } from 'vue';
|
|
7
7
|
|
|
8
8
|
import { renderMarkdown } from '@/utils/markdown';
|
|
9
|
-
import { booleanProp, stringProp } from '@/utils/vue';
|
|
9
|
+
import { booleanProp, objectProp, stringProp } from '@/utils/vue';
|
|
10
10
|
import { translate } from '@/lang';
|
|
11
11
|
|
|
12
12
|
const props = defineProps({
|
|
13
|
-
as: stringProp(
|
|
13
|
+
as: stringProp(),
|
|
14
|
+
inline: booleanProp(),
|
|
14
15
|
langKey: stringProp(),
|
|
16
|
+
langParams: objectProp<Record<string, unknown>>(),
|
|
15
17
|
text: stringProp(),
|
|
16
|
-
inline: booleanProp(),
|
|
17
|
-
raw: booleanProp(),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
-
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey)));
|
|
20
|
+
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
|
|
21
21
|
const html = computed(() => {
|
|
22
22
|
if (!markdown.value) {
|
|
23
23
|
return null;
|
|
@@ -31,5 +31,6 @@ const html = computed(() => {
|
|
|
31
31
|
|
|
32
32
|
return renderedHtml;
|
|
33
33
|
});
|
|
34
|
-
const root = () =>
|
|
34
|
+
const root = () =>
|
|
35
|
+
h(props.as ?? (props.inline ? 'span' : 'div'), { class: props.inline ? '' : 'prose', innerHTML: html.value });
|
|
35
36
|
</script>
|
|
@@ -7,28 +7,38 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
|
|
10
|
-
import {
|
|
10
|
+
import { enumProp } from '@/utils/vue';
|
|
11
|
+
import { Colors } from '@/components/constants';
|
|
11
12
|
|
|
12
13
|
import AGHeadlessButton from '../headless/forms/AGHeadlessButton.vue';
|
|
13
14
|
|
|
14
15
|
const props = defineProps({
|
|
15
|
-
|
|
16
|
-
secondary: booleanProp(),
|
|
16
|
+
color: enumProp(Colors, Colors.Primary),
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const colorClasses = computed(() => {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
switch (props.color) {
|
|
21
|
+
case Colors.Secondary:
|
|
22
|
+
return [
|
|
23
|
+
'text-white bg-gray-600',
|
|
24
|
+
'hover:bg-gray-500',
|
|
25
|
+
'focus-visible:outline-offset-2 focus-visible:outline-gray-600',
|
|
26
|
+
].join(' ');
|
|
27
|
+
case Colors.Clear:
|
|
28
|
+
return 'hover:bg-gray-500/20 focus-visible:outline-gray-500/60';
|
|
29
|
+
case Colors.Danger:
|
|
30
|
+
return [
|
|
31
|
+
'text-white bg-red-600',
|
|
32
|
+
'hover:bg-red-500',
|
|
33
|
+
'focus-visible:outline-offset-2 focus-visible:outline-red-600',
|
|
34
|
+
].join(' ');
|
|
35
|
+
case Colors.Primary:
|
|
36
|
+
default:
|
|
37
|
+
return [
|
|
38
|
+
'text-white bg-indigo-600',
|
|
39
|
+
'hover:bg-indigo-500',
|
|
40
|
+
'focus-visible:outline-offset-2 focus-visible:outline-indigo-600',
|
|
41
|
+
].join(' ');
|
|
22
42
|
}
|
|
23
|
-
|
|
24
|
-
if (props.clear) {
|
|
25
|
-
return 'hover:bg-gray-500/20 focus-visible:outline-gray-500/60';
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return [
|
|
29
|
-
'text-white bg-indigo-600',
|
|
30
|
-
'hover:bg-indigo-500',
|
|
31
|
-
'focus-visible:outline-offset-2 focus-visible:outline-indigo-600',
|
|
32
|
-
].join(' ');
|
|
33
43
|
});
|
|
34
44
|
</script>
|
|
@@ -10,7 +10,8 @@ import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
|
10
10
|
|
|
11
11
|
import { booleanProp, objectProp, stringProp } from '@/utils/vue';
|
|
12
12
|
|
|
13
|
-
const { url, route, routeParams, routeQuery, submit } = defineProps({
|
|
13
|
+
const { href, url, route, routeParams, routeQuery, submit } = defineProps({
|
|
14
|
+
href: stringProp(),
|
|
14
15
|
url: stringProp(),
|
|
15
16
|
route: stringProp(),
|
|
16
17
|
routeParams: objectProp(() => ({})),
|
|
@@ -32,12 +33,12 @@ const component = computed(() => {
|
|
|
32
33
|
};
|
|
33
34
|
}
|
|
34
35
|
|
|
35
|
-
if (url) {
|
|
36
|
+
if (href || url) {
|
|
36
37
|
return {
|
|
37
38
|
tag: 'a',
|
|
38
39
|
props: {
|
|
39
40
|
target: '_blank',
|
|
40
|
-
href: url,
|
|
41
|
+
href: href || url,
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
44
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
|
|
2
|
+
import { Colors } from '@/components/constants';
|
|
3
|
+
import { objectWithout } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
|
|
6
|
+
|
|
7
|
+
export interface SnackbarAction {
|
|
8
|
+
text: string;
|
|
9
|
+
dismiss?: boolean;
|
|
10
|
+
handler?(): unknown;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
|
|
14
|
+
|
|
15
|
+
export const SnackbarColors = objectWithout(Colors, ['Primary', 'Clear']);
|
|
16
|
+
export const snackbarProps = {
|
|
17
|
+
id: requiredStringProp(),
|
|
18
|
+
message: requiredStringProp(),
|
|
19
|
+
actions: arrayProp<SnackbarAction>(() => []),
|
|
20
|
+
color: enumProp(SnackbarColors, Colors.Secondary),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export function useSnackbarProps(): typeof snackbarProps {
|
|
24
|
+
return snackbarProps;
|
|
25
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { Component } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { requiredArrayProp } from '@/utils/vue';
|
|
4
|
+
import type { ErrorReport } from '@/errors';
|
|
5
|
+
|
|
6
|
+
export interface IAGErrorReportModalButtonsDefaultSlotProps {
|
|
7
|
+
id: string;
|
|
8
|
+
description: string;
|
|
9
|
+
iconComponent: Component;
|
|
10
|
+
url?: string;
|
|
11
|
+
handler?(): void;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const errorReportModalProps = {
|
|
15
|
+
reports: requiredArrayProp<ErrorReport>(),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
19
|
+
return errorReportModalProps;
|
|
20
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGModal>
|
|
3
|
+
<div>
|
|
4
|
+
<h2 class="flex items-center justify-between text-lg font-medium">
|
|
5
|
+
<div class="flex items-center">
|
|
6
|
+
<AGErrorReportModalTitle
|
|
7
|
+
:report="report"
|
|
8
|
+
:current-report="activeReportIndex + 1"
|
|
9
|
+
:total-reports="reports.length"
|
|
10
|
+
/>
|
|
11
|
+
<template v-if="reports.length > 1">
|
|
12
|
+
<AGButton
|
|
13
|
+
color="clear"
|
|
14
|
+
:disabled="activeReportIndex === 0"
|
|
15
|
+
:title="$td('errors.previousReport', 'Show previous report')"
|
|
16
|
+
:aria-label="$td('errors.previousReport', 'Show previous report')"
|
|
17
|
+
@click="activeReportIndex--"
|
|
18
|
+
>
|
|
19
|
+
<IconCheveronLeft aria-hidden="true" class="h-4 w-4" />
|
|
20
|
+
</AGButton>
|
|
21
|
+
<AGButton
|
|
22
|
+
color="clear"
|
|
23
|
+
:disabled="activeReportIndex === reports.length - 1"
|
|
24
|
+
:title="$td('errors.nextReport', 'Show next report')"
|
|
25
|
+
:aria-label="$td('errors.nextReport', 'Show next report')"
|
|
26
|
+
@click="activeReportIndex++"
|
|
27
|
+
>
|
|
28
|
+
<IconCheveronRight aria-hidden="true" class="h-4 w-4" />
|
|
29
|
+
</AGButton>
|
|
30
|
+
</template>
|
|
31
|
+
</div>
|
|
32
|
+
<AGErrorReportModalButtons :report="report" />
|
|
33
|
+
</h2>
|
|
34
|
+
<AGMarkdown v-if="report.description" :text="report.description" class="mt-2" />
|
|
35
|
+
</div>
|
|
36
|
+
<pre
|
|
37
|
+
class="h-full overflow-auto bg-gray-200 p-4 text-xs text-red-900"
|
|
38
|
+
v-text="report.details ?? $td('errors.detailsEmpty', 'This error is missing a stacktrace.')"
|
|
39
|
+
/>
|
|
40
|
+
</AGModal>
|
|
41
|
+
</template>
|
|
42
|
+
|
|
43
|
+
<script setup lang="ts">
|
|
44
|
+
import IconCheveronRight from '~icons/zondicons/cheveron-right';
|
|
45
|
+
import IconCheveronLeft from '~icons/zondicons/cheveron-left';
|
|
46
|
+
|
|
47
|
+
import { computed, ref } from 'vue';
|
|
48
|
+
|
|
49
|
+
import type { ErrorReport } from '@/errors';
|
|
50
|
+
|
|
51
|
+
import { useErrorReportModalProps } from './AGErrorReportModal';
|
|
52
|
+
|
|
53
|
+
import AGButton from '../forms/AGButton.vue';
|
|
54
|
+
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
55
|
+
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
56
|
+
import AGMarkdown from '../basic/AGMarkdown.vue';
|
|
57
|
+
import AGModal from './AGModal.vue';
|
|
58
|
+
|
|
59
|
+
const props = defineProps(useErrorReportModalProps());
|
|
60
|
+
const activeReportIndex = ref(0);
|
|
61
|
+
const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
62
|
+
</script>
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex">
|
|
3
|
+
<slot v-for="(button, i) of buttons" v-bind="(button as unknown as ComponentProps)" :key="i">
|
|
4
|
+
<AGButton
|
|
5
|
+
color="clear"
|
|
6
|
+
:url="button.url"
|
|
7
|
+
:title="$td(`errors.report_${button.id}`, button.description)"
|
|
8
|
+
:aria-label="$td(`errors.report_${button.id}`, button.description)"
|
|
9
|
+
@click="button.handler"
|
|
10
|
+
>
|
|
11
|
+
<component :is="button.iconComponent" class="h-4 w-4" aria-hidden="true" />
|
|
12
|
+
</AGButton>
|
|
13
|
+
</slot>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import IconConsole from '~icons/mdi/console';
|
|
19
|
+
import IconCopy from '~icons/zondicons/copy';
|
|
20
|
+
import IconGitHub from '~icons/mdi/github';
|
|
21
|
+
|
|
22
|
+
import { computed } from 'vue';
|
|
23
|
+
import { stringExcerpt, tap } from '@noeldemartin/utils';
|
|
24
|
+
|
|
25
|
+
import App from '@/services/App';
|
|
26
|
+
import UI from '@/ui/UI';
|
|
27
|
+
import { requiredObjectProp } from '@/utils/vue';
|
|
28
|
+
import { translateWithDefault } from '@/lang/utils';
|
|
29
|
+
import type { ComponentProps } from '@/utils/vue';
|
|
30
|
+
import type { ErrorReport } from '@/errors';
|
|
31
|
+
|
|
32
|
+
import AGButton from '../forms/AGButton.vue';
|
|
33
|
+
import type { IAGErrorReportModalButtonsDefaultSlotProps } from './AGErrorReportModal';
|
|
34
|
+
|
|
35
|
+
const props = defineProps({
|
|
36
|
+
report: requiredObjectProp<ErrorReport>(),
|
|
37
|
+
});
|
|
38
|
+
const summary = computed(() =>
|
|
39
|
+
props.report.description ? `${props.report.title}: ${props.report.description}` : props.report.title);
|
|
40
|
+
const githubReportUrl = computed(() => {
|
|
41
|
+
if (!App.sourceUrl) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const issueTitle = encodeURIComponent(summary.value);
|
|
46
|
+
const issueBody = encodeURIComponent(
|
|
47
|
+
[
|
|
48
|
+
'[Please, explain here what you were trying to do when this error appeared]',
|
|
49
|
+
'',
|
|
50
|
+
'Error details:',
|
|
51
|
+
'```',
|
|
52
|
+
stringExcerpt(
|
|
53
|
+
props.report.details ?? 'Details missing from report',
|
|
54
|
+
1800 - issueTitle.length - App.sourceUrl.length,
|
|
55
|
+
).trim(),
|
|
56
|
+
'```',
|
|
57
|
+
].join('\n'),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return `${App.sourceUrl}/issues/new?title=${issueTitle}&body=${issueBody}`;
|
|
61
|
+
});
|
|
62
|
+
const buttons = computed(() =>
|
|
63
|
+
tap(
|
|
64
|
+
[
|
|
65
|
+
{
|
|
66
|
+
id: 'clipboard',
|
|
67
|
+
description: 'Copy to clipboard',
|
|
68
|
+
iconComponent: IconCopy,
|
|
69
|
+
async handler() {
|
|
70
|
+
await navigator.clipboard.writeText(`${summary.value}\n\n${props.report.details}`);
|
|
71
|
+
|
|
72
|
+
UI.showSnackbar(
|
|
73
|
+
translateWithDefault('errors.copiedToClipboard', 'Debug information copied to clipboard'),
|
|
74
|
+
);
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'console',
|
|
79
|
+
description: 'Log to console',
|
|
80
|
+
iconComponent: IconConsole,
|
|
81
|
+
handler() {
|
|
82
|
+
(window as { error?: unknown }).error = props.report.error;
|
|
83
|
+
|
|
84
|
+
// eslint-disable-next-line no-console
|
|
85
|
+
console.error(props.report.error);
|
|
86
|
+
|
|
87
|
+
UI.showSnackbar(
|
|
88
|
+
translateWithDefault(
|
|
89
|
+
'errors.addedToConsole',
|
|
90
|
+
'You can now use the **error** variable in the console',
|
|
91
|
+
),
|
|
92
|
+
);
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
(reportButtons: IAGErrorReportModalButtonsDefaultSlotProps[]) => {
|
|
97
|
+
if (!githubReportUrl.value) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
reportButtons.push({
|
|
102
|
+
id: 'github',
|
|
103
|
+
description: 'Report in GitHub',
|
|
104
|
+
iconComponent: IconGitHub,
|
|
105
|
+
url: githubReportUrl.value,
|
|
106
|
+
});
|
|
107
|
+
},
|
|
108
|
+
));
|
|
109
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGMarkdown :text="text" inline />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { computed } from 'vue';
|
|
7
|
+
|
|
8
|
+
import { numberProp, requiredObjectProp } from '@/utils/vue';
|
|
9
|
+
import type { ErrorReport } from '@/errors';
|
|
10
|
+
|
|
11
|
+
import AGMarkdown from '../basic/AGMarkdown.vue';
|
|
12
|
+
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
report: requiredObjectProp<ErrorReport>(),
|
|
15
|
+
currentReport: numberProp(),
|
|
16
|
+
totalReports: numberProp(),
|
|
17
|
+
});
|
|
18
|
+
const text = computed(() => {
|
|
19
|
+
if (!props.totalReports || props.totalReports <= 1) {
|
|
20
|
+
return props.report.title;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return `${props.report.title} (${props.currentReport}/${props.totalReports})`;
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
:cancellable="cancellable"
|
|
6
6
|
class="relative z-50"
|
|
7
7
|
>
|
|
8
|
-
<div class="fixed inset-0 flex items-center justify-center">
|
|
8
|
+
<div class="fixed inset-0 flex items-center justify-center p-8">
|
|
9
9
|
<AGHeadlessModalPanel class="flex max-h-full max-w-full flex-col overflow-hidden bg-white">
|
|
10
|
-
<div class="flex max-h-full flex-col overflow-auto p-4">
|
|
10
|
+
<div class="flex max-h-full flex-col overflow-auto p-4" v-bind="$attrs">
|
|
11
11
|
<slot :close="close" />
|
|
12
12
|
</div>
|
|
13
13
|
</AGHeadlessModalPanel>
|
|
@@ -28,6 +28,7 @@ import AGHeadlessModalPanel from '../headless/modals/AGHeadlessModalPanel.vue';
|
|
|
28
28
|
|
|
29
29
|
const $headlessModal = ref<IAGHeadlessModal>();
|
|
30
30
|
|
|
31
|
+
defineOptions({ inheritAttrs: false });
|
|
31
32
|
defineProps({ cancellable: booleanProp(true) });
|
|
32
33
|
defineExpose<IAGModal>({
|
|
33
34
|
close: async () => $headlessModal.value?.close(),
|
|
@@ -1,8 +1,23 @@
|
|
|
1
1
|
import AGAlertModal from './AGAlertModal.vue';
|
|
2
2
|
import AGConfirmModal from './AGConfirmModal.vue';
|
|
3
|
+
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
4
|
+
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
3
5
|
import AGLoadingModal from './AGLoadingModal.vue';
|
|
4
6
|
import AGModal from './AGModal.vue';
|
|
7
|
+
import AGModalTitle from './AGModalTitle.vue';
|
|
5
8
|
import AGModalContext from './AGModalContext.vue';
|
|
6
|
-
import { IAGModal } from './AGModal';
|
|
7
9
|
|
|
8
|
-
export
|
|
10
|
+
export * from './AGErrorReportModal';
|
|
11
|
+
export * from './AGModal';
|
|
12
|
+
export * from './AGModalContext';
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
AGAlertModal,
|
|
16
|
+
AGConfirmModal,
|
|
17
|
+
AGErrorReportModalButtons,
|
|
18
|
+
AGErrorReportModalTitle,
|
|
19
|
+
AGLoadingModal,
|
|
20
|
+
AGModal,
|
|
21
|
+
AGModalTitle,
|
|
22
|
+
AGModalContext,
|
|
23
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGHeadlessSnackbar class="flex flex-row items-center justify-center gap-3 p-4" :class="styleClasses">
|
|
3
|
+
<AGMarkdown :text="message" inline />
|
|
4
|
+
<AGButton
|
|
5
|
+
v-for="(action, i) of actions"
|
|
6
|
+
:key="i"
|
|
7
|
+
:color="color"
|
|
8
|
+
@click="activate(action)"
|
|
9
|
+
>
|
|
10
|
+
{{ action.text }}
|
|
11
|
+
</AGButton>
|
|
12
|
+
</AGHeadlessSnackbar>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue';
|
|
17
|
+
|
|
18
|
+
import UI from '@/ui/UI';
|
|
19
|
+
import { Colors } from '@/components/constants';
|
|
20
|
+
import { useSnackbarProps } from '@/components/headless';
|
|
21
|
+
import type { SnackbarAction } from '@/components/headless';
|
|
22
|
+
|
|
23
|
+
import AGButton from '../forms/AGButton.vue';
|
|
24
|
+
import AGHeadlessSnackbar from '../headless/snackbars/AGHeadlessSnackbar.vue';
|
|
25
|
+
import AGMarkdown from '../basic/AGMarkdown.vue';
|
|
26
|
+
|
|
27
|
+
const props = defineProps(useSnackbarProps());
|
|
28
|
+
const styleClasses = computed(() => {
|
|
29
|
+
switch (props.color) {
|
|
30
|
+
case Colors.Danger:
|
|
31
|
+
return 'bg-red-200 text-red-900';
|
|
32
|
+
default:
|
|
33
|
+
case Colors.Secondary:
|
|
34
|
+
return 'bg-gray-900 text-white';
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function activate(action: SnackbarAction): void {
|
|
39
|
+
action.handler?.();
|
|
40
|
+
action.dismiss && UI.hideSnackbar(props.id);
|
|
41
|
+
}
|
|
42
|
+
</script>
|
package/src/directives/index.ts
CHANGED
|
@@ -4,12 +4,25 @@ import { definePlugin } from '@/plugins';
|
|
|
4
4
|
|
|
5
5
|
import initialFocus from './initial-focus';
|
|
6
6
|
|
|
7
|
-
const
|
|
7
|
+
const builtInDirectives: Record<string, Directive> = {
|
|
8
8
|
'initial-focus': initialFocus,
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
export default definePlugin({
|
|
12
|
-
install(app) {
|
|
13
|
-
|
|
12
|
+
install(app, options) {
|
|
13
|
+
const directives = {
|
|
14
|
+
...builtInDirectives,
|
|
15
|
+
...options.directives,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
for (const [name, directive] of Object.entries(directives)) {
|
|
19
|
+
app.directive(name, directive);
|
|
20
|
+
}
|
|
14
21
|
},
|
|
15
22
|
});
|
|
23
|
+
|
|
24
|
+
declare module '@/bootstrap/options' {
|
|
25
|
+
interface AerogelOptions {
|
|
26
|
+
directives?: Record<string, Directive>;
|
|
27
|
+
}
|
|
28
|
+
}
|