@aerogel/core 0.0.0-next.d824b40e5d06757cd9f47c9f771d916185df4f05 → 0.0.0-next.f1f5a990033d966dc0bb12d251110fbc9350dcc7
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 +641 -110
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/histoire.config.ts +7 -0
- package/package.json +14 -5
- 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 +18 -3
- package/src/components/AGAppLayout.vue +7 -2
- package/src/components/AGAppOverlays.vue +5 -1
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/forms/AGSelect.story.vue +28 -0
- package/src/components/forms/AGSelect.vue +53 -0
- package/src/components/forms/index.ts +5 -6
- package/src/components/headless/forms/AGHeadlessInput.ts +21 -1
- package/src/components/headless/forms/AGHeadlessInput.vue +8 -5
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
- package/src/components/headless/forms/AGHeadlessSelect.ts +39 -0
- package/src/components/headless/forms/AGHeadlessSelect.vue +76 -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/modals/AGHeadlessModal.ts +27 -0
- package/src/components/headless/modals/AGHeadlessModal.vue +3 -5
- package/src/components/headless/modals/index.ts +4 -6
- package/src/components/headless/snackbars/index.ts +23 -8
- package/src/components/index.ts +1 -1
- 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 -15
- package/src/components/modals/AGConfirmModal.ts +27 -0
- package/src/components/modals/AGConfirmModal.vue +7 -11
- package/src/components/modals/AGErrorReportModal.ts +27 -1
- package/src/components/modals/AGErrorReportModal.vue +8 -16
- package/src/components/modals/AGErrorReportModalButtons.vue +4 -2
- package/src/components/modals/AGErrorReportModalTitle.vue +1 -1
- package/src/components/modals/AGLoadingModal.ts +23 -0
- package/src/components/modals/AGLoadingModal.vue +4 -8
- package/src/components/modals/AGModal.ts +1 -1
- package/src/components/modals/AGModal.vue +14 -12
- package/src/components/modals/index.ts +3 -0
- package/src/components/snackbars/AGSnackbar.vue +3 -9
- 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 +10 -5
- package/src/errors/index.ts +9 -13
- package/src/forms/Form.ts +11 -3
- package/src/main.histoire.ts +1 -0
- package/src/services/App.state.ts +3 -3
- package/src/services/App.ts +10 -1
- package/src/services/Service.ts +8 -4
- package/src/services/index.ts +1 -1
- package/src/ui/UI.ts +77 -14
- package/src/ui/index.ts +6 -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 +13 -4
- package/tailwind.config.js +4 -0
- package/tsconfig.json +1 -1
- package/.eslintrc.js +0 -3
- package/dist/virtual.d.ts +0 -11
- package/src/components/basic/index.ts +0 -5
- package/src/types/virtual.d.ts +0 -11
- /package/src/components/{basic → lib}/AGErrorMessage.vue +0 -0
- /package/src/components/{basic → lib}/AGLink.vue +0 -0
- /package/src/components/{basic → lib}/AGMarkdown.vue +0 -0
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes, Ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
import { booleanProp, stringProp } from '@/utils';
|
|
5
|
+
import { extractComponentProps } from '@/components/utils';
|
|
1
6
|
import type { IAGModal } from '@/components/modals/AGModal';
|
|
2
7
|
|
|
3
8
|
export interface IAGHeadlessModal extends IAGModal {}
|
|
@@ -5,3 +10,25 @@ export interface IAGHeadlessModal extends IAGModal {}
|
|
|
5
10
|
export interface IAGHeadlessModalDefaultSlotProps {
|
|
6
11
|
close(result?: unknown): Promise<void>;
|
|
7
12
|
}
|
|
13
|
+
|
|
14
|
+
export const modalProps = {
|
|
15
|
+
cancellable: booleanProp(true),
|
|
16
|
+
title: stringProp(),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function useModalProps(): typeof modalProps {
|
|
20
|
+
return modalProps;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function extractModalProps<T extends ExtractPropTypes<typeof modalProps>>(
|
|
24
|
+
props: T,
|
|
25
|
+
): Pick<T, keyof typeof modalProps> {
|
|
26
|
+
return extractComponentProps(props, modalProps);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useModalExpose($modal: Ref<IAGHeadlessModal | undefined>): IAGModal {
|
|
30
|
+
return {
|
|
31
|
+
close: async () => $modal.value?.close(),
|
|
32
|
+
cancellable: computed(() => !!$modal.value?.cancellable),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -11,15 +11,13 @@ import type { VNode } from 'vue';
|
|
|
11
11
|
|
|
12
12
|
import Events from '@/services/Events';
|
|
13
13
|
import { useEvent } from '@/utils/composition/events';
|
|
14
|
-
import {
|
|
14
|
+
import { injectReactiveOrFail } from '@/utils/vue';
|
|
15
15
|
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
16
16
|
|
|
17
|
+
import { useModalProps } from './AGHeadlessModal';
|
|
17
18
|
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
18
19
|
|
|
19
|
-
const props = defineProps(
|
|
20
|
-
cancellable: booleanProp(true),
|
|
21
|
-
});
|
|
22
|
-
|
|
20
|
+
const props = defineProps(useModalProps());
|
|
23
21
|
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
24
22
|
const hidden = ref(true);
|
|
25
23
|
const closed = ref(false);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { AGHeadlessModal, AGHeadlessModalPanel, AGHeadlessModalTitle, IAGHeadlessModal };
|
|
1
|
+
export * from './AGHeadlessModal';
|
|
2
|
+
export { default as AGHeadlessModal } from './AGHeadlessModal.vue';
|
|
3
|
+
export { default as AGHeadlessModalPanel } from './AGHeadlessModalPanel.vue';
|
|
4
|
+
export { default as AGHeadlessModalTitle } from './AGHeadlessModalTitle.vue';
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import UI from '@/ui/UI';
|
|
1
5
|
import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
|
|
2
6
|
import { Colors } from '@/components/constants';
|
|
3
7
|
import { objectWithout } from '@noeldemartin/utils';
|
|
4
8
|
|
|
5
9
|
export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
|
|
6
10
|
|
|
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
11
|
export const SnackbarColors = objectWithout(Colors, ['Primary', 'Clear']);
|
|
16
12
|
export const snackbarProps = {
|
|
17
13
|
id: requiredStringProp(),
|
|
@@ -20,6 +16,25 @@ export const snackbarProps = {
|
|
|
20
16
|
color: enumProp(SnackbarColors, Colors.Secondary),
|
|
21
17
|
};
|
|
22
18
|
|
|
19
|
+
export interface SnackbarAction {
|
|
20
|
+
text: string;
|
|
21
|
+
dismiss?: boolean;
|
|
22
|
+
handler?(): unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
|
|
26
|
+
export type AGSnackbarProps = ObjectWithoutEmpty<ExtractPropTypes<typeof snackbarProps>>;
|
|
27
|
+
|
|
23
28
|
export function useSnackbarProps(): typeof snackbarProps {
|
|
24
29
|
return snackbarProps;
|
|
25
30
|
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
33
|
+
export function useSnackbar(props: ExtractPropTypes<typeof snackbarProps>) {
|
|
34
|
+
function activate(action: SnackbarAction): void {
|
|
35
|
+
action.handler?.();
|
|
36
|
+
action.dismiss && UI.hideSnackbar(props.id);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return { activate };
|
|
40
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ import AGAppOverlays from './AGAppOverlays.vue';
|
|
|
3
3
|
|
|
4
4
|
export { AGAppLayout, AGAppOverlays };
|
|
5
5
|
|
|
6
|
-
export * from './basic';
|
|
7
6
|
export * from './constants';
|
|
8
7
|
export * from './forms';
|
|
9
8
|
export * from './headless';
|
|
9
|
+
export * from './lib';
|
|
10
10
|
export * from './modals';
|
|
11
11
|
export * from './snackbars';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="as" v-measure="() => (measured = true)" :class="{ '!invisible !absolute !w-auto': !measured }">
|
|
3
|
+
<slot />
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { ref } from 'vue';
|
|
9
|
+
|
|
10
|
+
import { stringProp } from '@/utils/vue';
|
|
11
|
+
|
|
12
|
+
defineProps({ as: stringProp('span') });
|
|
13
|
+
|
|
14
|
+
const measured = ref(false);
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="grid flex-grow place-items-center">
|
|
3
|
+
<div class="flex flex-col items-center space-y-6 p-8">
|
|
4
|
+
<h1 class="mt-2 text-center text-4xl font-medium text-red-600">
|
|
5
|
+
{{ $td('startupCrash.title', 'Something went wrong!') }}
|
|
6
|
+
</h1>
|
|
7
|
+
<AGMarkdown
|
|
8
|
+
:text="
|
|
9
|
+
$td(
|
|
10
|
+
'startupCrash.message',
|
|
11
|
+
'Something failed trying to start the application.\n\nHere\'s some things you can do:'
|
|
12
|
+
)
|
|
13
|
+
"
|
|
14
|
+
class="mt-4 text-center"
|
|
15
|
+
/>
|
|
16
|
+
<div class="mt-4 flex flex-col space-y-4">
|
|
17
|
+
<AGButton color="danger" @click="$app.reload()">
|
|
18
|
+
{{ $td('startupCrash.reload', 'Try again') }}
|
|
19
|
+
</AGButton>
|
|
20
|
+
<AGButton color="danger" @click="$errors.inspect($errors.startupErrors)">
|
|
21
|
+
{{ $td('startupCrash.inspect', 'View error details') }}
|
|
22
|
+
</AGButton>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import AGMarkdown from './AGMarkdown.vue';
|
|
30
|
+
import AGButton from '../forms/AGButton.vue';
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AGErrorMessage } from './AGErrorMessage.vue';
|
|
2
|
+
export { default as AGLink } from './AGLink.vue';
|
|
3
|
+
export { default as AGMarkdown } from './AGMarkdown.vue';
|
|
4
|
+
export { default as AGMeasured } from './AGMeasured.vue';
|
|
5
|
+
export { default as AGStartupCrash } from './AGStartupCrash.vue';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import { requiredStringProp, stringProp } from '@/utils';
|
|
5
|
+
|
|
6
|
+
export const alertModalProps = {
|
|
7
|
+
title: stringProp(),
|
|
8
|
+
message: requiredStringProp(),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AGAlertModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof alertModalProps>>;
|
|
12
|
+
|
|
13
|
+
export function useAlertModalProps(): typeof alertModalProps {
|
|
14
|
+
return alertModalProps;
|
|
15
|
+
}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal>
|
|
3
|
-
<AGMarkdown
|
|
4
|
-
v-if="title"
|
|
5
|
-
:text="title"
|
|
6
|
-
as="h2"
|
|
7
|
-
class="font-semibold"
|
|
8
|
-
inline
|
|
9
|
-
/>
|
|
2
|
+
<AGModal :title="title">
|
|
10
3
|
<AGMarkdown :text="message" />
|
|
11
4
|
</AGModal>
|
|
12
5
|
</template>
|
|
13
6
|
|
|
14
7
|
<script setup lang="ts">
|
|
15
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
16
|
-
|
|
17
8
|
import AGModal from './AGModal.vue';
|
|
9
|
+
import { useAlertModalProps } from './AGAlertModal';
|
|
18
10
|
|
|
19
|
-
import AGMarkdown from '../
|
|
11
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
20
12
|
|
|
21
|
-
defineProps(
|
|
22
|
-
title: stringProp(),
|
|
23
|
-
message: requiredStringProp(),
|
|
24
|
-
});
|
|
13
|
+
defineProps(useAlertModalProps());
|
|
25
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
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
|
-
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>
|
|
@@ -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,19 +41,14 @@
|
|
|
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';
|
|
55
48
|
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
56
|
-
import AGMarkdown from '../
|
|
49
|
+
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(
|
|
@@ -8,7 +8,7 @@ import { computed } from 'vue';
|
|
|
8
8
|
import { numberProp, requiredObjectProp } from '@/utils/vue';
|
|
9
9
|
import type { ErrorReport } from '@/errors';
|
|
10
10
|
|
|
11
|
-
import AGMarkdown from '../
|
|
11
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
12
|
|
|
13
13
|
const props = defineProps({
|
|
14
14
|
report: requiredObjectProp<ErrorReport>(),
|
|
@@ -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
|
+
}
|
|
@@ -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
|
-
import AGMarkdown from '../
|
|
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>
|
|
@@ -7,7 +7,10 @@ import AGModal from './AGModal.vue';
|
|
|
7
7
|
import AGModalTitle from './AGModalTitle.vue';
|
|
8
8
|
import AGModalContext from './AGModalContext.vue';
|
|
9
9
|
|
|
10
|
+
export * from './AGAlertModal';
|
|
11
|
+
export * from './AGConfirmModal';
|
|
10
12
|
export * from './AGErrorReportModal';
|
|
13
|
+
export * from './AGLoadingModal';
|
|
11
14
|
export * from './AGModal';
|
|
12
15
|
export * from './AGModalContext';
|
|
13
16
|
|
|
@@ -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
|
-
import AGMarkdown from '../
|
|
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
|
+
});
|