@aerogel/core 0.0.0-next.c8f032a868370824898e171969aec1bb6827688e → 0.0.0-next.d547095ca85c86c1e41f5c7fa170d0ba856c3f4d
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 +1511 -236
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/histoire.config.ts +7 -0
- package/noeldemartin.config.js +4 -1
- package/package.json +14 -4
- package/postcss.config.js +6 -0
- package/src/assets/histoire.css +3 -0
- package/src/bootstrap/bootstrap.test.ts +4 -3
- package/src/bootstrap/index.ts +27 -4
- package/src/bootstrap/options.ts +3 -0
- package/src/components/AGAppLayout.vue +7 -2
- package/src/components/AGAppModals.vue +15 -0
- package/src/components/AGAppOverlays.vue +10 -8
- package/src/components/AGAppSnackbars.vue +13 -0
- package/src/components/constants.ts +8 -0
- package/src/components/forms/AGButton.vue +33 -10
- package/src/components/forms/AGCheckbox.vue +41 -0
- package/src/components/forms/AGInput.vue +15 -9
- package/src/components/forms/AGSelect.story.vue +46 -0
- package/src/components/forms/AGSelect.vue +60 -0
- package/src/components/forms/index.ts +5 -5
- package/src/components/headless/forms/AGHeadlessButton.vue +12 -12
- package/src/components/headless/forms/AGHeadlessInput.ts +23 -3
- package/src/components/headless/forms/AGHeadlessInput.vue +11 -8
- package/src/components/headless/forms/AGHeadlessInputError.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInputInput.vue +17 -3
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
- package/src/components/headless/forms/AGHeadlessSelect.ts +42 -0
- package/src/components/headless/forms/AGHeadlessSelect.vue +77 -0
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectError.vue +26 -0
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +4 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +39 -0
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +3 -0
- package/src/components/headless/forms/index.ts +9 -1
- package/src/components/headless/index.ts +1 -0
- package/src/components/headless/modals/AGHeadlessModal.ts +27 -0
- package/src/components/headless/modals/AGHeadlessModal.vue +3 -5
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +5 -1
- package/src/components/headless/modals/index.ts +4 -6
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
- package/src/components/headless/snackbars/index.ts +40 -0
- package/src/components/index.ts +3 -1
- package/src/components/lib/AGErrorMessage.vue +16 -0
- package/src/components/lib/AGLink.vue +9 -0
- package/src/components/lib/AGMarkdown.vue +36 -0
- package/src/components/lib/AGMeasured.vue +15 -0
- package/src/components/lib/AGStartupCrash.vue +31 -0
- package/src/components/lib/index.ts +5 -0
- package/src/components/modals/AGAlertModal.ts +15 -0
- package/src/components/modals/AGAlertModal.vue +4 -16
- package/src/components/modals/AGConfirmModal.ts +27 -0
- package/src/components/modals/AGConfirmModal.vue +8 -12
- package/src/components/modals/AGErrorReportModal.ts +46 -0
- package/src/components/modals/AGErrorReportModal.vue +54 -0
- package/src/components/modals/AGErrorReportModalButtons.vue +111 -0
- package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
- package/src/components/modals/AGLoadingModal.ts +23 -0
- package/src/components/modals/AGLoadingModal.vue +15 -0
- package/src/components/modals/AGModal.ts +1 -1
- package/src/components/modals/AGModal.vue +26 -5
- package/src/components/modals/AGModalTitle.vue +9 -0
- package/src/components/modals/AGPromptModal.ts +30 -0
- package/src/components/modals/AGPromptModal.vue +34 -0
- package/src/components/modals/index.ts +16 -6
- package/src/components/snackbars/AGSnackbar.vue +36 -0
- package/src/components/snackbars/index.ts +3 -0
- package/src/components/utils.ts +10 -0
- package/src/directives/index.ts +20 -3
- package/src/directives/measure.ts +21 -0
- package/src/errors/Errors.state.ts +31 -0
- package/src/errors/Errors.ts +185 -0
- package/src/errors/index.ts +46 -0
- package/src/errors/utils.ts +19 -0
- package/src/forms/Form.test.ts +21 -0
- package/src/forms/Form.ts +34 -15
- package/src/forms/utils.ts +17 -0
- package/src/jobs/Job.ts +5 -0
- package/src/jobs/index.ts +7 -0
- package/src/lang/Lang.ts +11 -15
- package/src/lang/index.ts +3 -5
- package/src/lang/utils.ts +4 -0
- package/src/main.histoire.ts +1 -0
- package/src/main.ts +4 -2
- package/src/plugins/Plugin.ts +1 -0
- package/src/plugins/index.ts +19 -0
- package/src/services/App.state.ts +9 -2
- package/src/services/App.ts +43 -3
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +100 -30
- package/src/services/Service.ts +174 -53
- package/src/services/index.ts +22 -4
- package/src/services/store.ts +30 -0
- package/src/testing/index.ts +25 -0
- package/src/ui/UI.state.ts +11 -1
- package/src/ui/UI.ts +169 -20
- package/src/ui/index.ts +15 -4
- package/src/utils/composition/events.ts +1 -0
- package/src/utils/composition/forms.ts +11 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/markdown.ts +11 -2
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +15 -4
- package/tailwind.config.js +4 -0
- package/tsconfig.json +1 -0
- package/vite.config.ts +2 -1
- package/.eslintrc.js +0 -3
- package/src/components/basic/AGMarkdown.vue +0 -35
- package/src/components/basic/index.ts +0 -3
- package/src/globals.ts +0 -6
|
@@ -1,26 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal>
|
|
3
|
-
<AGMarkdown
|
|
4
|
-
v-if="title"
|
|
5
|
-
:text="title"
|
|
6
|
-
as="h2"
|
|
7
|
-
class="font-semibold"
|
|
8
|
-
raw
|
|
9
|
-
inline
|
|
10
|
-
/>
|
|
2
|
+
<AGModal :title="title">
|
|
11
3
|
<AGMarkdown :text="message" />
|
|
12
4
|
</AGModal>
|
|
13
5
|
</template>
|
|
14
6
|
|
|
15
7
|
<script setup lang="ts">
|
|
16
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
17
|
-
|
|
18
8
|
import AGModal from './AGModal.vue';
|
|
9
|
+
import { useAlertModalProps } from './AGAlertModal';
|
|
19
10
|
|
|
20
|
-
import AGMarkdown from '../
|
|
11
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
21
12
|
|
|
22
|
-
defineProps(
|
|
23
|
-
title: stringProp(),
|
|
24
|
-
message: requiredStringProp(),
|
|
25
|
-
});
|
|
13
|
+
defineProps(useAlertModalProps());
|
|
26
14
|
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { requiredStringProp, stringProp } from '@/utils';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
7
|
+
|
|
8
|
+
export const confirmModalProps = {
|
|
9
|
+
title: stringProp(),
|
|
10
|
+
message: requiredStringProp(),
|
|
11
|
+
acceptText: stringProp(),
|
|
12
|
+
cancelText: stringProp(),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type AGConfirmModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof confirmModalProps>>;
|
|
16
|
+
|
|
17
|
+
export function useConfirmModalProps(): typeof confirmModalProps {
|
|
18
|
+
return confirmModalProps;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
export function useConfirmModal(props: ExtractPropTypes<typeof confirmModalProps>) {
|
|
23
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
24
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
25
|
+
|
|
26
|
+
return { renderedAcceptText, renderedCancelText };
|
|
27
|
+
}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false">
|
|
3
|
-
<AGMarkdown v-if="title" :text="title" as="h1" />
|
|
2
|
+
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false" :title="title">
|
|
4
3
|
<AGMarkdown :text="message" />
|
|
5
4
|
|
|
6
5
|
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
7
6
|
<AGButton @click="close(true)">
|
|
8
|
-
{{
|
|
7
|
+
{{ renderedAcceptText }}
|
|
9
8
|
</AGButton>
|
|
10
|
-
<AGButton secondary @click="close()">
|
|
11
|
-
{{
|
|
9
|
+
<AGButton color="secondary" @click="close()">
|
|
10
|
+
{{ renderedCancelText }}
|
|
12
11
|
</AGButton>
|
|
13
12
|
</div>
|
|
14
13
|
</AGModal>
|
|
15
14
|
</template>
|
|
16
15
|
|
|
17
16
|
<script setup lang="ts">
|
|
18
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
19
|
-
|
|
20
17
|
import AGModal from './AGModal.vue';
|
|
18
|
+
import { useConfirmModal, useConfirmModalProps } from './AGConfirmModal';
|
|
21
19
|
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
22
20
|
|
|
23
21
|
import AGButton from '../forms/AGButton.vue';
|
|
24
|
-
import AGMarkdown from '../
|
|
22
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
25
23
|
|
|
26
|
-
defineProps(
|
|
27
|
-
|
|
28
|
-
message: requiredStringProp(),
|
|
29
|
-
});
|
|
24
|
+
const props = defineProps(useConfirmModalProps());
|
|
25
|
+
const { renderedAcceptText, renderedCancelText } = useConfirmModal(props);
|
|
30
26
|
</script>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
import type { Component, ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { requiredArrayProp } from '@/utils/vue';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
7
|
+
import type { ErrorReport } from '@/errors';
|
|
8
|
+
|
|
9
|
+
export interface IAGErrorReportModalButtonsDefaultSlotProps {
|
|
10
|
+
id: string;
|
|
11
|
+
description: string;
|
|
12
|
+
iconComponent: Component;
|
|
13
|
+
url?: string;
|
|
14
|
+
handler?(): void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export const errorReportModalProps = {
|
|
18
|
+
reports: requiredArrayProp<ErrorReport>(),
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type AGErrorReportModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof errorReportModalProps>>;
|
|
22
|
+
|
|
23
|
+
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
24
|
+
return errorReportModalProps;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
28
|
+
export function useErrorReportModal(props: ExtractPropTypes<typeof errorReportModalProps>) {
|
|
29
|
+
const activeReportIndex = ref(0);
|
|
30
|
+
const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
31
|
+
const details = computed(
|
|
32
|
+
() =>
|
|
33
|
+
report.value.details?.trim() ||
|
|
34
|
+
translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
|
|
35
|
+
);
|
|
36
|
+
const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
|
|
37
|
+
const nextReportText = translateWithDefault('errors.nextReport', 'Show next report');
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
activeReportIndex,
|
|
41
|
+
details,
|
|
42
|
+
nextReportText,
|
|
43
|
+
previousReportText,
|
|
44
|
+
report,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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="previousReportText"
|
|
16
|
+
:aria-label="previousReportText"
|
|
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="nextReportText"
|
|
25
|
+
:aria-label="nextReportText"
|
|
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 class="h-full overflow-auto bg-gray-200 p-4 text-xs text-red-900" v-text="details" />
|
|
37
|
+
</AGModal>
|
|
38
|
+
</template>
|
|
39
|
+
|
|
40
|
+
<script setup lang="ts">
|
|
41
|
+
import IconCheveronRight from '~icons/zondicons/cheveron-right';
|
|
42
|
+
import IconCheveronLeft from '~icons/zondicons/cheveron-left';
|
|
43
|
+
|
|
44
|
+
import { useErrorReportModal, useErrorReportModalProps } from './AGErrorReportModal';
|
|
45
|
+
|
|
46
|
+
import AGButton from '../forms/AGButton.vue';
|
|
47
|
+
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
48
|
+
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
49
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
50
|
+
import AGModal from './AGModal.vue';
|
|
51
|
+
|
|
52
|
+
const props = defineProps(useErrorReportModalProps());
|
|
53
|
+
const { activeReportIndex, details, nextReportText, previousReportText, report } = useErrorReportModal(props);
|
|
54
|
+
</script>
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
const error = props.report.error ?? props.report;
|
|
83
|
+
|
|
84
|
+
(window as { error?: unknown }).error = error;
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line no-console
|
|
87
|
+
console.error(error);
|
|
88
|
+
|
|
89
|
+
UI.showSnackbar(
|
|
90
|
+
translateWithDefault(
|
|
91
|
+
'errors.addedToConsole',
|
|
92
|
+
'You can now use the **error** variable in the console',
|
|
93
|
+
),
|
|
94
|
+
);
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
(reportButtons: IAGErrorReportModalButtonsDefaultSlotProps[]) => {
|
|
99
|
+
if (!githubReportUrl.value) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
reportButtons.push({
|
|
104
|
+
id: 'github',
|
|
105
|
+
description: 'Report in GitHub',
|
|
106
|
+
iconComponent: IconGitHub,
|
|
107
|
+
url: githubReportUrl.value,
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
));
|
|
111
|
+
</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 '../lib/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>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { stringProp } from '@/utils';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
7
|
+
|
|
8
|
+
export const loadingModalProps = {
|
|
9
|
+
message: stringProp(),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type AGLoadingModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof loadingModalProps>>;
|
|
13
|
+
|
|
14
|
+
export function useLoadingModalProps(): typeof loadingModalProps {
|
|
15
|
+
return loadingModalProps;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
19
|
+
export function useLoadingModal(props: ExtractPropTypes<typeof loadingModalProps>) {
|
|
20
|
+
const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
|
|
21
|
+
|
|
22
|
+
return { renderedMessage };
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGModal :cancellable="false">
|
|
3
|
+
<AGMarkdown :text="renderedMessage" />
|
|
4
|
+
</AGModal>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import AGModal from './AGModal.vue';
|
|
9
|
+
import { useLoadingModal, useLoadingModalProps } from './AGLoadingModal';
|
|
10
|
+
|
|
11
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
|
+
|
|
13
|
+
const props = defineProps(useLoadingModalProps());
|
|
14
|
+
const { renderedMessage } = useLoadingModal(props);
|
|
15
|
+
</script>
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGHeadlessModal
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<AGHeadlessModal
|
|
3
|
+
ref="$modal"
|
|
4
|
+
v-slot="{ close }: IAGHeadlessModalDefaultSlotProps"
|
|
5
|
+
v-bind="props"
|
|
6
|
+
class="relative z-50"
|
|
7
|
+
>
|
|
8
|
+
<div class="fixed inset-0 flex items-center justify-center p-8">
|
|
9
|
+
<AGHeadlessModalPanel class="flex max-h-full max-w-full flex-col overflow-hidden bg-white p-4">
|
|
10
|
+
<AGHeadlessModalTitle v-if="title" class="mb-2 text-lg font-semibold">
|
|
11
|
+
<AGMarkdown :text="title" inline />
|
|
12
|
+
</AGHeadlessModalTitle>
|
|
13
|
+
<div class="flex max-h-full flex-col overflow-auto" v-bind="$attrs">
|
|
6
14
|
<slot :close="close" />
|
|
7
15
|
</div>
|
|
8
16
|
</AGHeadlessModalPanel>
|
|
@@ -11,8 +19,21 @@
|
|
|
11
19
|
</template>
|
|
12
20
|
|
|
13
21
|
<script setup lang="ts">
|
|
14
|
-
import
|
|
22
|
+
import { ref } from 'vue';
|
|
23
|
+
|
|
24
|
+
import { useModalExpose, useModalProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
25
|
+
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
26
|
+
|
|
27
|
+
import type { IAGModal } from './AGModal';
|
|
15
28
|
|
|
16
29
|
import AGHeadlessModal from '../headless/modals/AGHeadlessModal.vue';
|
|
17
30
|
import AGHeadlessModalPanel from '../headless/modals/AGHeadlessModalPanel.vue';
|
|
31
|
+
import AGHeadlessModalTitle from '../headless/modals/AGHeadlessModalTitle.vue';
|
|
32
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
33
|
+
|
|
34
|
+
const props = defineProps(useModalProps());
|
|
35
|
+
const $modal = ref<IAGHeadlessModal>();
|
|
36
|
+
|
|
37
|
+
defineOptions({ inheritAttrs: false });
|
|
38
|
+
defineExpose<IAGModal>(useModalExpose($modal));
|
|
18
39
|
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { requiredStringProp, stringProp } from '@/utils';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
7
|
+
|
|
8
|
+
export const promptModalProps = {
|
|
9
|
+
title: stringProp(),
|
|
10
|
+
message: requiredStringProp(),
|
|
11
|
+
label: stringProp(),
|
|
12
|
+
defaultValue: stringProp(),
|
|
13
|
+
placeholder: stringProp(),
|
|
14
|
+
acceptText: stringProp(),
|
|
15
|
+
cancelText: stringProp(),
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type AGPromptModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof promptModalProps>>;
|
|
19
|
+
|
|
20
|
+
export function usePromptModalProps(): typeof promptModalProps {
|
|
21
|
+
return promptModalProps;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
25
|
+
export function usePromptModal(props: ExtractPropTypes<typeof promptModalProps>) {
|
|
26
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
27
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
28
|
+
|
|
29
|
+
return { renderedAcceptText, renderedCancelText };
|
|
30
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false" :title="title">
|
|
3
|
+
<AGMarkdown :text="message" />
|
|
4
|
+
|
|
5
|
+
<AGForm :form="form" @submit="close(form.draft)">
|
|
6
|
+
<AGInput name="draft" :placeholder="placeholder" :label="label" />
|
|
7
|
+
|
|
8
|
+
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
9
|
+
<AGButton submit>
|
|
10
|
+
{{ renderedAcceptText }}
|
|
11
|
+
</AGButton>
|
|
12
|
+
<AGButton color="secondary" @click="close()">
|
|
13
|
+
{{ renderedCancelText }}
|
|
14
|
+
</AGButton>
|
|
15
|
+
</div>
|
|
16
|
+
</AGForm>
|
|
17
|
+
</AGModal>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import AGModal from './AGModal.vue';
|
|
22
|
+
import { usePromptModal, usePromptModalProps } from './AGPromptModal';
|
|
23
|
+
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
24
|
+
|
|
25
|
+
import AGButton from '../forms/AGButton.vue';
|
|
26
|
+
import AGForm from '../forms/AGForm.vue';
|
|
27
|
+
import AGInput from '../forms/AGInput.vue';
|
|
28
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
29
|
+
import { requiredStringInput, useForm } from '../../forms';
|
|
30
|
+
|
|
31
|
+
const props = defineProps(usePromptModalProps());
|
|
32
|
+
const form = useForm({ draft: requiredStringInput(props.defaultValue ?? '') });
|
|
33
|
+
const { renderedAcceptText, renderedCancelText } = usePromptModal(props);
|
|
34
|
+
</script>
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
export * from './AGAlertModal';
|
|
2
|
+
export * from './AGConfirmModal';
|
|
3
|
+
export * from './AGErrorReportModal';
|
|
4
|
+
export * from './AGLoadingModal';
|
|
5
|
+
export * from './AGModal';
|
|
6
|
+
export * from './AGModalContext';
|
|
7
|
+
export * from './AGPromptModal';
|
|
6
8
|
|
|
7
|
-
export {
|
|
9
|
+
export { default as AGAlertModal } from './AGAlertModal.vue';
|
|
10
|
+
export { default as AGConfirmModal } from './AGConfirmModal.vue';
|
|
11
|
+
export { default as AGErrorReportModalButtons } from './AGErrorReportModalButtons.vue';
|
|
12
|
+
export { default as AGErrorReportModalTitle } from './AGErrorReportModalTitle.vue';
|
|
13
|
+
export { default as AGLoadingModal } from './AGLoadingModal.vue';
|
|
14
|
+
export { default as AGModal } from './AGModal.vue';
|
|
15
|
+
export { default as AGModalContext } from './AGModalContext.vue';
|
|
16
|
+
export { default as AGModalTitle } from './AGModalTitle.vue';
|
|
17
|
+
export { default as AGPromptModal } from './AGPromptModal.vue';
|
|
@@ -0,0 +1,36 @@
|
|
|
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 { Colors } from '@/components/constants';
|
|
19
|
+
import { useSnackbar, useSnackbarProps } from '@/components/headless/snackbars';
|
|
20
|
+
|
|
21
|
+
import AGButton from '../forms/AGButton.vue';
|
|
22
|
+
import AGHeadlessSnackbar from '../headless/snackbars/AGHeadlessSnackbar.vue';
|
|
23
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
24
|
+
|
|
25
|
+
const props = defineProps(useSnackbarProps());
|
|
26
|
+
const { activate } = useSnackbar(props);
|
|
27
|
+
const styleClasses = computed(() => {
|
|
28
|
+
switch (props.color) {
|
|
29
|
+
case Colors.Danger:
|
|
30
|
+
return 'bg-red-200 text-red-900';
|
|
31
|
+
default:
|
|
32
|
+
case Colors.Secondary:
|
|
33
|
+
return 'bg-gray-900 text-white';
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function extractComponentProps<T extends Record<string, unknown>>(
|
|
2
|
+
values: Record<string, unknown>,
|
|
3
|
+
definitions: Record<string, unknown>,
|
|
4
|
+
): T {
|
|
5
|
+
return Object.keys(definitions).reduce((extracted, prop) => {
|
|
6
|
+
extracted[prop] = values[prop];
|
|
7
|
+
|
|
8
|
+
return extracted;
|
|
9
|
+
}, {} as Record<string, unknown>) as T;
|
|
10
|
+
}
|
package/src/directives/index.ts
CHANGED
|
@@ -3,13 +3,30 @@ import type { Directive } from 'vue';
|
|
|
3
3
|
import { definePlugin } from '@/plugins';
|
|
4
4
|
|
|
5
5
|
import initialFocus from './initial-focus';
|
|
6
|
+
import measure from './measure';
|
|
6
7
|
|
|
7
|
-
const
|
|
8
|
+
const builtInDirectives: Record<string, Directive> = {
|
|
8
9
|
'initial-focus': initialFocus,
|
|
10
|
+
'measure': measure,
|
|
9
11
|
};
|
|
10
12
|
|
|
13
|
+
export * from './measure';
|
|
14
|
+
|
|
11
15
|
export default definePlugin({
|
|
12
|
-
install(app) {
|
|
13
|
-
|
|
16
|
+
install(app, options) {
|
|
17
|
+
const directives = {
|
|
18
|
+
...builtInDirectives,
|
|
19
|
+
...options.directives,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
for (const [name, directive] of Object.entries(directives)) {
|
|
23
|
+
app.directive(name, directive);
|
|
24
|
+
}
|
|
14
25
|
},
|
|
15
26
|
});
|
|
27
|
+
|
|
28
|
+
declare module '@/bootstrap/options' {
|
|
29
|
+
export interface AerogelOptions {
|
|
30
|
+
directives?: Record<string, Directive>;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { defineDirective } from '@/utils/vue';
|
|
2
|
+
|
|
3
|
+
export interface ElementSize {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type MeasureDirectiveListener = (size: ElementSize) => unknown;
|
|
9
|
+
|
|
10
|
+
export default defineDirective({
|
|
11
|
+
mounted(element: HTMLElement, { value }) {
|
|
12
|
+
const listener = typeof value === 'function' ? (value as MeasureDirectiveListener) : null;
|
|
13
|
+
const sizes = element.getBoundingClientRect();
|
|
14
|
+
|
|
15
|
+
// TODO guard with modifiers.css once typed properly
|
|
16
|
+
element.style.setProperty('--width', `${sizes.width}px`);
|
|
17
|
+
element.style.setProperty('--height', `${sizes.height}px`);
|
|
18
|
+
|
|
19
|
+
listener?.({ width: sizes.width, height: sizes.height });
|
|
20
|
+
},
|
|
21
|
+
});
|