@aerogel/core 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c → 0.0.0-next.a68f133e2c9a1ae9ba84b4e2e42df909289e5fba
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 +493 -107
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/bootstrap/bootstrap.test.ts +3 -3
- package/src/bootstrap/index.ts +13 -3
- package/src/bootstrap/options.ts +3 -0
- package/src/components/AGAppLayout.vue +3 -2
- package/src/components/AGAppOverlays.vue +5 -1
- package/src/components/forms/AGCheckbox.vue +7 -1
- package/src/components/forms/AGInput.vue +8 -6
- package/src/components/forms/AGSelect.story.vue +21 -3
- package/src/components/forms/AGSelect.vue +10 -3
- package/src/components/headless/forms/AGHeadlessInput.ts +5 -10
- package/src/components/headless/forms/AGHeadlessSelect.ts +20 -22
- package/src/components/headless/forms/AGHeadlessSelect.vue +23 -22
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +6 -6
- package/src/components/headless/modals/AGHeadlessModal.ts +19 -1
- package/src/components/headless/modals/AGHeadlessModal.vue +3 -5
- package/src/components/headless/snackbars/index.ts +23 -8
- package/src/components/lib/AGMeasured.vue +15 -0
- package/src/components/lib/index.ts +1 -0
- package/src/components/modals/AGAlertModal.ts +15 -0
- package/src/components/modals/AGAlertModal.vue +3 -14
- package/src/components/modals/AGConfirmModal.ts +17 -0
- package/src/components/modals/AGConfirmModal.vue +6 -10
- package/src/components/modals/AGErrorReportModal.ts +27 -1
- package/src/components/modals/AGErrorReportModal.vue +7 -15
- package/src/components/modals/AGErrorReportModalButtons.vue +4 -2
- package/src/components/modals/AGLoadingModal.ts +14 -0
- package/src/components/modals/AGLoadingModal.vue +3 -7
- package/src/components/modals/AGModal.vue +14 -12
- package/src/components/modals/AGPromptModal.ts +30 -0
- package/src/components/modals/AGPromptModal.vue +34 -0
- package/src/components/modals/index.ts +11 -19
- package/src/components/snackbars/AGSnackbar.vue +2 -8
- package/src/components/utils.ts +10 -0
- package/src/directives/index.ts +3 -1
- package/src/directives/measure.ts +12 -0
- package/src/errors/Errors.ts +17 -8
- package/src/errors/index.ts +1 -11
- package/src/forms/Form.ts +1 -0
- package/src/lang/Lang.ts +1 -1
- package/src/services/App.state.ts +1 -2
- package/src/services/App.ts +21 -3
- package/src/services/Events.ts +1 -1
- package/src/services/Service.ts +36 -10
- package/src/services/index.ts +2 -1
- package/src/services/store.ts +8 -5
- package/src/ui/UI.ts +93 -12
- package/src/ui/index.ts +8 -3
- package/src/utils/composition/events.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +10 -1
|
@@ -1,10 +1,27 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
1
5
|
import { requiredStringProp, stringProp } from '@/utils';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
2
7
|
|
|
3
8
|
export const confirmModalProps = {
|
|
4
9
|
title: stringProp(),
|
|
5
10
|
message: requiredStringProp(),
|
|
11
|
+
acceptText: stringProp(),
|
|
12
|
+
cancelText: stringProp(),
|
|
6
13
|
};
|
|
7
14
|
|
|
15
|
+
export type AGConfirmModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof confirmModalProps>>;
|
|
16
|
+
|
|
8
17
|
export function useConfirmModalProps(): typeof confirmModalProps {
|
|
9
18
|
return confirmModalProps;
|
|
10
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
9
|
<AGButton color="secondary" @click="close()">
|
|
11
|
-
{{
|
|
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
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>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
import type { Component, ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
2
4
|
|
|
3
5
|
import { requiredArrayProp } from '@/utils/vue';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
4
7
|
import type { ErrorReport } from '@/errors';
|
|
5
8
|
|
|
6
9
|
export interface IAGErrorReportModalButtonsDefaultSlotProps {
|
|
@@ -15,6 +18,29 @@ export const errorReportModalProps = {
|
|
|
15
18
|
reports: requiredArrayProp<ErrorReport>(),
|
|
16
19
|
};
|
|
17
20
|
|
|
21
|
+
export type AGErrorReportModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof errorReportModalProps>>;
|
|
22
|
+
|
|
18
23
|
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
19
24
|
return errorReportModalProps;
|
|
20
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
|
+
}
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
<AGButton
|
|
13
13
|
color="clear"
|
|
14
14
|
:disabled="activeReportIndex === 0"
|
|
15
|
-
:title="
|
|
16
|
-
:aria-label="
|
|
15
|
+
:title="previousReportText"
|
|
16
|
+
:aria-label="previousReportText"
|
|
17
17
|
@click="activeReportIndex--"
|
|
18
18
|
>
|
|
19
19
|
<IconCheveronLeft aria-hidden="true" class="h-4 w-4" />
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
<AGButton
|
|
22
22
|
color="clear"
|
|
23
23
|
:disabled="activeReportIndex === reports.length - 1"
|
|
24
|
-
:title="
|
|
25
|
-
:aria-label="
|
|
24
|
+
:title="nextReportText"
|
|
25
|
+
:aria-label="nextReportText"
|
|
26
26
|
@click="activeReportIndex++"
|
|
27
27
|
>
|
|
28
28
|
<IconCheveronRight aria-hidden="true" class="h-4 w-4" />
|
|
@@ -33,10 +33,7 @@
|
|
|
33
33
|
</h2>
|
|
34
34
|
<AGMarkdown v-if="report.description" :text="report.description" class="mt-2" />
|
|
35
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
|
-
/>
|
|
36
|
+
<pre class="h-full overflow-auto bg-gray-200 p-4 text-xs text-red-900" v-text="details" />
|
|
40
37
|
</AGModal>
|
|
41
38
|
</template>
|
|
42
39
|
|
|
@@ -44,11 +41,7 @@
|
|
|
44
41
|
import IconCheveronRight from '~icons/zondicons/cheveron-right';
|
|
45
42
|
import IconCheveronLeft from '~icons/zondicons/cheveron-left';
|
|
46
43
|
|
|
47
|
-
import {
|
|
48
|
-
|
|
49
|
-
import type { ErrorReport } from '@/errors';
|
|
50
|
-
|
|
51
|
-
import { useErrorReportModalProps } from './AGErrorReportModal';
|
|
44
|
+
import { useErrorReportModal, useErrorReportModalProps } from './AGErrorReportModal';
|
|
52
45
|
|
|
53
46
|
import AGButton from '../forms/AGButton.vue';
|
|
54
47
|
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
@@ -57,6 +50,5 @@ import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
|
57
50
|
import AGModal from './AGModal.vue';
|
|
58
51
|
|
|
59
52
|
const props = defineProps(useErrorReportModalProps());
|
|
60
|
-
const activeReportIndex =
|
|
61
|
-
const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
53
|
+
const { activeReportIndex, details, nextReportText, previousReportText, report } = useErrorReportModal(props);
|
|
62
54
|
</script>
|
|
@@ -79,10 +79,12 @@ const buttons = computed(() =>
|
|
|
79
79
|
description: 'Log to console',
|
|
80
80
|
iconComponent: IconConsole,
|
|
81
81
|
handler() {
|
|
82
|
-
|
|
82
|
+
const error = props.report.error ?? props.report;
|
|
83
|
+
|
|
84
|
+
(window as { error?: unknown }).error = error;
|
|
83
85
|
|
|
84
86
|
// eslint-disable-next-line no-console
|
|
85
|
-
console.error(
|
|
87
|
+
console.error(error);
|
|
86
88
|
|
|
87
89
|
UI.showSnackbar(
|
|
88
90
|
translateWithDefault(
|
|
@@ -1,9 +1,23 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
1
5
|
import { stringProp } from '@/utils';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
2
7
|
|
|
3
8
|
export const loadingModalProps = {
|
|
4
9
|
message: stringProp(),
|
|
5
10
|
};
|
|
6
11
|
|
|
12
|
+
export type AGLoadingModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof loadingModalProps>>;
|
|
13
|
+
|
|
7
14
|
export function useLoadingModalProps(): typeof loadingModalProps {
|
|
8
15
|
return loadingModalProps;
|
|
9
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
|
+
}
|
|
@@ -5,15 +5,11 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
|
|
10
|
-
import { stringProp } from '@/utils/vue';
|
|
11
|
-
import { translateWithDefault } from '@/lang/utils';
|
|
12
|
-
|
|
13
8
|
import AGModal from './AGModal.vue';
|
|
9
|
+
import { useLoadingModal, useLoadingModalProps } from './AGLoadingModal';
|
|
14
10
|
|
|
15
11
|
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
16
12
|
|
|
17
|
-
const props = defineProps(
|
|
18
|
-
const renderedMessage =
|
|
13
|
+
const props = defineProps(useLoadingModalProps());
|
|
14
|
+
const { renderedMessage } = useLoadingModal(props);
|
|
19
15
|
</script>
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<AGHeadlessModal
|
|
3
|
-
ref="$
|
|
3
|
+
ref="$modal"
|
|
4
4
|
v-slot="{ close }: IAGHeadlessModalDefaultSlotProps"
|
|
5
|
-
|
|
5
|
+
v-bind="props"
|
|
6
6
|
class="relative z-50"
|
|
7
7
|
>
|
|
8
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">
|
|
10
|
-
<
|
|
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">
|
|
11
14
|
<slot :close="close" />
|
|
12
15
|
</div>
|
|
13
16
|
</AGHeadlessModalPanel>
|
|
@@ -16,22 +19,21 @@
|
|
|
16
19
|
</template>
|
|
17
20
|
|
|
18
21
|
<script setup lang="ts">
|
|
19
|
-
import {
|
|
22
|
+
import { ref } from 'vue';
|
|
20
23
|
|
|
21
|
-
import {
|
|
24
|
+
import { useModalExpose, useModalProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
22
25
|
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
23
26
|
|
|
24
27
|
import type { IAGModal } from './AGModal';
|
|
25
28
|
|
|
26
29
|
import AGHeadlessModal from '../headless/modals/AGHeadlessModal.vue';
|
|
27
30
|
import AGHeadlessModalPanel from '../headless/modals/AGHeadlessModalPanel.vue';
|
|
31
|
+
import AGHeadlessModalTitle from '../headless/modals/AGHeadlessModalTitle.vue';
|
|
32
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
28
33
|
|
|
29
|
-
const
|
|
34
|
+
const props = defineProps(useModalProps());
|
|
35
|
+
const $modal = ref<IAGHeadlessModal>();
|
|
30
36
|
|
|
31
37
|
defineOptions({ inheritAttrs: false });
|
|
32
|
-
|
|
33
|
-
defineExpose<IAGModal>({
|
|
34
|
-
close: async () => $headlessModal.value?.close(),
|
|
35
|
-
cancellable: computed(() => !!$headlessModal.value?.cancellable),
|
|
36
|
-
});
|
|
38
|
+
defineExpose<IAGModal>(useModalExpose($modal));
|
|
37
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,25 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import AGConfirmModal from './AGConfirmModal.vue';
|
|
3
|
-
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
4
|
-
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
5
|
-
import AGLoadingModal from './AGLoadingModal.vue';
|
|
6
|
-
import AGModal from './AGModal.vue';
|
|
7
|
-
import AGModalTitle from './AGModalTitle.vue';
|
|
8
|
-
import AGModalContext from './AGModalContext.vue';
|
|
9
|
-
|
|
1
|
+
export * from './AGAlertModal';
|
|
10
2
|
export * from './AGConfirmModal';
|
|
11
3
|
export * from './AGErrorReportModal';
|
|
12
4
|
export * from './AGLoadingModal';
|
|
13
5
|
export * from './AGModal';
|
|
14
6
|
export * from './AGModalContext';
|
|
7
|
+
export * from './AGPromptModal';
|
|
15
8
|
|
|
16
|
-
export {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
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';
|
|
@@ -15,16 +15,15 @@
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
16
|
import { computed } from 'vue';
|
|
17
17
|
|
|
18
|
-
import UI from '@/ui/UI';
|
|
19
18
|
import { Colors } from '@/components/constants';
|
|
20
|
-
import { useSnackbarProps } from '@/components/headless';
|
|
21
|
-
import type { SnackbarAction } from '@/components/headless';
|
|
19
|
+
import { useSnackbar, useSnackbarProps } from '@/components/headless/snackbars';
|
|
22
20
|
|
|
23
21
|
import AGButton from '../forms/AGButton.vue';
|
|
24
22
|
import AGHeadlessSnackbar from '../headless/snackbars/AGHeadlessSnackbar.vue';
|
|
25
23
|
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
26
24
|
|
|
27
25
|
const props = defineProps(useSnackbarProps());
|
|
26
|
+
const { activate } = useSnackbar(props);
|
|
28
27
|
const styleClasses = computed(() => {
|
|
29
28
|
switch (props.color) {
|
|
30
29
|
case Colors.Danger:
|
|
@@ -34,9 +33,4 @@ const styleClasses = computed(() => {
|
|
|
34
33
|
return 'bg-gray-900 text-white';
|
|
35
34
|
}
|
|
36
35
|
});
|
|
37
|
-
|
|
38
|
-
function activate(action: SnackbarAction): void {
|
|
39
|
-
action.handler?.();
|
|
40
|
-
action.dismiss && UI.hideSnackbar(props.id);
|
|
41
|
-
}
|
|
42
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,9 +3,11 @@ 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
8
|
const builtInDirectives: Record<string, Directive> = {
|
|
8
9
|
'initial-focus': initialFocus,
|
|
10
|
+
'measure': measure,
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
export default definePlugin({
|
|
@@ -22,7 +24,7 @@ export default definePlugin({
|
|
|
22
24
|
});
|
|
23
25
|
|
|
24
26
|
declare module '@/bootstrap/options' {
|
|
25
|
-
interface AerogelOptions {
|
|
27
|
+
export interface AerogelOptions {
|
|
26
28
|
directives?: Record<string, Directive>;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineDirective } from '@/utils/vue';
|
|
2
|
+
|
|
3
|
+
export default defineDirective({
|
|
4
|
+
mounted(element: HTMLElement, { value }: { value?: () => unknown }) {
|
|
5
|
+
const sizes = element.getBoundingClientRect();
|
|
6
|
+
|
|
7
|
+
element.style.setProperty('--width', `${sizes.width}px`);
|
|
8
|
+
element.style.setProperty('--height', `${sizes.height}px`);
|
|
9
|
+
|
|
10
|
+
value?.();
|
|
11
|
+
},
|
|
12
|
+
});
|
package/src/errors/Errors.ts
CHANGED
|
@@ -7,7 +7,9 @@ import { translateWithDefault } from '@/lang/utils';
|
|
|
7
7
|
|
|
8
8
|
import Service from './Errors.state';
|
|
9
9
|
import { Colors } from '@/components/constants';
|
|
10
|
+
import type { AGErrorReportModalProps } from '@/components/modals/AGErrorReportModal';
|
|
10
11
|
import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
12
|
+
import type { ModalComponent } from '@/ui/UI.state';
|
|
11
13
|
|
|
12
14
|
export class ErrorsService extends Service {
|
|
13
15
|
|
|
@@ -23,7 +25,7 @@ export class ErrorsService extends Service {
|
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
public async inspect(error: ErrorSource | ErrorReport[]): Promise<void> {
|
|
26
|
-
const reports = Array.isArray(error) ? error : [await this.createErrorReport(error)];
|
|
28
|
+
const reports = Array.isArray(error) ? (error as ErrorReport[]) : [await this.createErrorReport(error)];
|
|
27
29
|
|
|
28
30
|
if (reports.length === 0) {
|
|
29
31
|
UI.alert(translateWithDefault('errors.inspectEmpty', 'Nothing to inspect!'));
|
|
@@ -31,11 +33,17 @@ export class ErrorsService extends Service {
|
|
|
31
33
|
return;
|
|
32
34
|
}
|
|
33
35
|
|
|
34
|
-
UI.openModal(UI.requireComponent(UIComponents.ErrorReportModal), {
|
|
36
|
+
UI.openModal<ModalComponent<AGErrorReportModalProps>>(UI.requireComponent(UIComponents.ErrorReportModal), {
|
|
37
|
+
reports,
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
|
|
37
41
|
public async report(error: ErrorSource, message?: string): Promise<void> {
|
|
38
|
-
if (App.
|
|
42
|
+
if (App.testing) {
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (App.development) {
|
|
39
47
|
this.logError(error);
|
|
40
48
|
}
|
|
41
49
|
|
|
@@ -43,7 +51,7 @@ export class ErrorsService extends Service {
|
|
|
43
51
|
throw error;
|
|
44
52
|
}
|
|
45
53
|
|
|
46
|
-
if (!App.isMounted) {
|
|
54
|
+
if (!App.isMounted()) {
|
|
47
55
|
const startupError = await this.createStartupErrorReport(error);
|
|
48
56
|
|
|
49
57
|
if (startupError) {
|
|
@@ -70,9 +78,10 @@ export class ErrorsService extends Service {
|
|
|
70
78
|
text: translateWithDefault('errors.viewDetails', 'View details'),
|
|
71
79
|
dismiss: true,
|
|
72
80
|
handler: () =>
|
|
73
|
-
UI.openModal(
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
UI.openModal<ModalComponent<AGErrorReportModalProps>>(
|
|
82
|
+
UI.requireComponent(UIComponents.ErrorReportModal),
|
|
83
|
+
{ reports: [report] },
|
|
84
|
+
),
|
|
76
85
|
},
|
|
77
86
|
],
|
|
78
87
|
},
|
|
@@ -180,4 +189,4 @@ export class ErrorsService extends Service {
|
|
|
180
189
|
|
|
181
190
|
}
|
|
182
191
|
|
|
183
|
-
export default facade(
|
|
192
|
+
export default facade(ErrorsService);
|
package/src/errors/index.ts
CHANGED
|
@@ -10,16 +10,6 @@ export { Errors, ErrorSource, ErrorReport, ErrorReportLog };
|
|
|
10
10
|
|
|
11
11
|
const services = { $errors: Errors };
|
|
12
12
|
const frameworkHandler: ErrorHandler = (error) => {
|
|
13
|
-
if (!Errors.instance) {
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.warn('Errors service hasn\'t been initialized properly!');
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line no-console
|
|
18
|
-
console.error(error);
|
|
19
|
-
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
13
|
Errors.report(error);
|
|
24
14
|
|
|
25
15
|
return true;
|
|
@@ -45,7 +35,7 @@ export default definePlugin({
|
|
|
45
35
|
});
|
|
46
36
|
|
|
47
37
|
declare module '@/bootstrap/options' {
|
|
48
|
-
interface AerogelOptions {
|
|
38
|
+
export interface AerogelOptions {
|
|
49
39
|
handleError?(error: ErrorSource): boolean;
|
|
50
40
|
}
|
|
51
41
|
}
|
package/src/forms/Form.ts
CHANGED
|
@@ -18,6 +18,7 @@ export interface FormFieldDefinition<TType extends FormFieldType = FormFieldType
|
|
|
18
18
|
|
|
19
19
|
export type FormFieldDefinitions = Record<string, FormFieldDefinition>;
|
|
20
20
|
export type FormFieldType = ObjectValues<typeof FormFieldTypes>;
|
|
21
|
+
export type FormFieldValue = GetFormFieldValue<FormFieldType>;
|
|
21
22
|
|
|
22
23
|
export type FormData<T> = {
|
|
23
24
|
-readonly [k in keyof T]: T[k] extends FormFieldDefinition<infer TType, infer TRules>
|
package/src/lang/Lang.ts
CHANGED
|
@@ -9,10 +9,9 @@ export default defineServiceState({
|
|
|
9
9
|
plugins: {} as Record<string, Plugin>,
|
|
10
10
|
environment: Aerogel.environment,
|
|
11
11
|
sourceUrl: Aerogel.sourceUrl,
|
|
12
|
-
isMounted: false,
|
|
13
12
|
},
|
|
14
13
|
computed: {
|
|
15
14
|
development: (state) => state.environment === 'development',
|
|
16
|
-
testing: (state) => state.environment === 'testing',
|
|
15
|
+
testing: (state) => state.environment === 'test' || state.environment === 'testing',
|
|
17
16
|
},
|
|
18
17
|
});
|
package/src/services/App.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { facade, forever, updateLocationQueryParameters } from '@noeldemartin/utils';
|
|
1
|
+
import { PromisedValue, facade, forever, updateLocationQueryParameters } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
3
|
import Events from '@/services/Events';
|
|
4
4
|
import type { Plugin } from '@/plugins';
|
|
@@ -7,6 +7,23 @@ import Service from './App.state';
|
|
|
7
7
|
|
|
8
8
|
export class AppService extends Service {
|
|
9
9
|
|
|
10
|
+
public readonly ready = new PromisedValue<void>();
|
|
11
|
+
public readonly mounted = new PromisedValue<void>();
|
|
12
|
+
|
|
13
|
+
public isReady(): boolean {
|
|
14
|
+
return this.ready.isResolved();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
public isMounted(): boolean {
|
|
18
|
+
return this.mounted.isResolved();
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public async whenReady<T>(callback: () => T): Promise<T> {
|
|
22
|
+
const result = await this.ready.then(callback);
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
10
27
|
public async reload(queryParameters?: Record<string, string | undefined>): Promise<void> {
|
|
11
28
|
queryParameters && updateLocationQueryParameters(queryParameters);
|
|
12
29
|
|
|
@@ -21,9 +38,10 @@ export class AppService extends Service {
|
|
|
21
38
|
}
|
|
22
39
|
|
|
23
40
|
protected async boot(): Promise<void> {
|
|
24
|
-
Events.once('application-
|
|
41
|
+
Events.once('application-ready', () => this.ready.resolve());
|
|
42
|
+
Events.once('application-mounted', () => this.mounted.resolve());
|
|
25
43
|
}
|
|
26
44
|
|
|
27
45
|
}
|
|
28
46
|
|
|
29
|
-
export default facade(
|
|
47
|
+
export default facade(AppService);
|
package/src/services/Events.ts
CHANGED