@aerogel/core 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c → 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2
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.d.ts +2255 -1046
- package/dist/aerogel-core.js +2763 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +23 -37
- package/src/bootstrap/bootstrap.test.ts +7 -11
- package/src/bootstrap/index.ts +36 -16
- package/src/bootstrap/options.ts +4 -1
- package/src/components/AGAppLayout.vue +3 -2
- package/src/components/AGAppModals.vue +1 -1
- package/src/components/AGAppOverlays.vue +6 -2
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/composition.ts +23 -0
- package/src/components/contracts/Modal.ts +16 -0
- package/src/components/contracts/index.ts +2 -0
- package/src/components/contracts/shared.ts +9 -0
- package/src/components/forms/AGButton.vue +2 -2
- package/src/components/forms/AGCheckbox.vue +10 -3
- package/src/components/forms/AGForm.vue +11 -12
- package/src/components/forms/AGInput.vue +13 -7
- package/src/components/forms/AGSelect.story.vue +21 -3
- package/src/components/forms/AGSelect.vue +20 -19
- package/src/components/headless/forms/AGHeadlessButton.ts +3 -0
- package/src/components/headless/forms/AGHeadlessButton.vue +24 -13
- package/src/components/headless/forms/AGHeadlessInput.ts +22 -14
- package/src/components/headless/forms/AGHeadlessInput.vue +19 -6
- package/src/components/headless/forms/AGHeadlessInputDescription.vue +28 -0
- package/src/components/headless/forms/AGHeadlessInputError.vue +2 -2
- package/src/components/headless/forms/AGHeadlessInputInput.vue +45 -6
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInputTextArea.vue +43 -0
- package/src/components/headless/forms/AGHeadlessSelect.ts +20 -22
- package/src/components/headless/forms/AGHeadlessSelect.vue +34 -33
- package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +14 -22
- package/src/components/headless/forms/AGHeadlessSelectOptions.vue +19 -0
- package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +25 -0
- package/src/components/headless/forms/composition.ts +10 -0
- package/src/components/headless/forms/index.ts +6 -3
- package/src/components/headless/modals/AGHeadlessModal.ts +25 -8
- package/src/components/headless/modals/AGHeadlessModal.vue +12 -12
- package/src/components/headless/modals/AGHeadlessModalContent.vue +25 -0
- package/src/components/headless/modals/index.ts +3 -2
- package/src/components/headless/snackbars/index.ts +25 -10
- package/src/components/index.ts +2 -0
- package/src/components/lib/AGErrorMessage.vue +4 -4
- package/src/components/lib/AGMarkdown.vue +24 -6
- package/src/components/lib/AGMeasured.vue +16 -0
- package/src/components/lib/AGProgressBar.vue +55 -0
- package/src/components/lib/AGStartupCrash.vue +1 -1
- package/src/components/lib/index.ts +2 -0
- package/src/components/modals/AGAlertModal.ts +18 -0
- package/src/components/modals/AGAlertModal.vue +3 -14
- package/src/components/modals/AGConfirmModal.ts +33 -1
- package/src/components/modals/AGConfirmModal.vue +10 -13
- package/src/components/modals/AGErrorReportModal.ts +32 -3
- package/src/components/modals/AGErrorReportModal.vue +9 -17
- package/src/components/modals/AGErrorReportModalButtons.vue +14 -12
- package/src/components/modals/AGErrorReportModalTitle.vue +2 -2
- package/src/components/modals/AGLoadingModal.ts +21 -1
- package/src/components/modals/AGLoadingModal.vue +3 -7
- package/src/components/modals/AGModal.vue +25 -22
- package/src/components/modals/AGModalContext.ts +1 -1
- package/src/components/modals/AGModalContext.vue +15 -5
- package/src/components/modals/AGModalTitle.vue +1 -1
- package/src/components/modals/AGPromptModal.ts +41 -0
- package/src/components/modals/AGPromptModal.vue +35 -0
- package/src/components/modals/index.ts +11 -20
- package/src/components/snackbars/AGSnackbar.vue +3 -9
- package/src/components/utils.ts +63 -0
- package/src/directives/index.ts +13 -5
- package/src/directives/measure.ts +40 -0
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +32 -30
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +11 -17
- package/src/errors/utils.ts +35 -0
- package/src/forms/Form.test.ts +32 -3
- package/src/forms/Form.ts +81 -20
- package/src/forms/composition.ts +2 -2
- package/src/forms/index.ts +3 -1
- package/src/forms/utils.ts +34 -3
- package/src/forms/validation.ts +19 -0
- package/src/{main.ts → index.ts} +3 -0
- package/src/jobs/Job.ts +147 -0
- package/src/jobs/index.ts +10 -0
- package/src/jobs/listeners.ts +3 -0
- package/src/jobs/status.ts +4 -0
- package/src/lang/DefaultLangProvider.ts +46 -0
- package/src/lang/Lang.state.ts +11 -0
- package/src/lang/Lang.ts +44 -29
- package/src/lang/index.ts +8 -6
- package/src/plugins/Plugin.ts +1 -1
- package/src/plugins/index.ts +10 -7
- package/src/services/App.state.ts +27 -5
- package/src/services/App.ts +32 -6
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +112 -32
- package/src/services/Service.ts +150 -49
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +15 -6
- package/src/services/store.ts +8 -5
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +26 -0
- package/src/testing/setup.ts +11 -0
- package/src/ui/UI.state.ts +9 -2
- package/src/ui/UI.ts +233 -45
- package/src/ui/index.ts +13 -7
- package/src/ui/utils.ts +16 -0
- package/src/utils/composition/events.ts +3 -2
- package/src/utils/composition/persistent.test.ts +33 -0
- package/src/utils/composition/persistent.ts +11 -0
- package/src/utils/composition/state.test.ts +47 -0
- package/src/utils/composition/state.ts +24 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +19 -6
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +33 -17
- package/dist/aerogel-core.cjs.js +0 -2
- package/dist/aerogel-core.cjs.js.map +0 -1
- package/dist/aerogel-core.esm.js +0 -2
- package/dist/aerogel-core.esm.js.map +0 -1
- package/histoire.config.ts +0 -7
- package/noeldemartin.config.js +0 -5
- package/postcss.config.js +0 -6
- package/src/assets/histoire.css +0 -3
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/modals/AGModal.ts +0 -10
- package/src/directives/initial-focus.ts +0 -11
- package/src/main.histoire.ts +0 -1
- package/tailwind.config.js +0 -4
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
2
|
+
<DialogRoot ref="$root" :open="true" @update:open="cancellable && close()">
|
|
3
|
+
<DialogPortal>
|
|
4
|
+
<slot :close="close" />
|
|
5
|
+
</DialogPortal>
|
|
6
|
+
</DialogRoot>
|
|
5
7
|
</template>
|
|
6
8
|
|
|
7
9
|
<script setup lang="ts">
|
|
8
10
|
import { ref, toRef } from 'vue';
|
|
9
|
-
import {
|
|
11
|
+
import { DialogPortal, DialogRoot } from 'reka-ui';
|
|
10
12
|
import type { VNode } from 'vue';
|
|
11
13
|
|
|
12
|
-
import Events from '
|
|
13
|
-
import { useEvent } from '
|
|
14
|
-
import {
|
|
15
|
-
import type { IAGModalContext } from '
|
|
14
|
+
import Events from '@aerogel/core/services/Events';
|
|
15
|
+
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
16
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
+
import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
|
|
16
18
|
|
|
19
|
+
import { modalProps } from './AGHeadlessModal';
|
|
17
20
|
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
18
21
|
|
|
19
|
-
const props = defineProps(
|
|
20
|
-
cancellable: booleanProp(true),
|
|
21
|
-
});
|
|
22
|
-
|
|
22
|
+
const props = defineProps(modalProps());
|
|
23
23
|
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
24
24
|
const hidden = ref(true);
|
|
25
25
|
const closed = ref(false);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogContent>
|
|
3
|
+
<slot />
|
|
4
|
+
|
|
5
|
+
<AGModalContext v-if="childModal" :child-index="childIndex + 1" :modal="childModal" />
|
|
6
|
+
</DialogContent>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed } from 'vue';
|
|
11
|
+
import { DialogContent } from 'reka-ui';
|
|
12
|
+
|
|
13
|
+
import UI from '@aerogel/core/ui/UI';
|
|
14
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
15
|
+
import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
|
|
16
|
+
|
|
17
|
+
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
18
|
+
|
|
19
|
+
const { childIndex } = injectReactiveOrFail<IAGModalContext>(
|
|
20
|
+
'modal',
|
|
21
|
+
'could not obtain modal reference from <AGHeadlessModalContent>, ' +
|
|
22
|
+
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
23
|
+
);
|
|
24
|
+
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
25
|
+
</script>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export { DialogTitle as AGHeadlessModalTitle } from 'reka-ui';
|
|
2
|
+
|
|
1
3
|
export * from './AGHeadlessModal';
|
|
2
4
|
export { default as AGHeadlessModal } from './AGHeadlessModal.vue';
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as AGHeadlessModalTitle } from './AGHeadlessModalTitle.vue';
|
|
5
|
+
export { default as AGHeadlessModalContent } from './AGHeadlessModalContent.vue';
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import UI from '@aerogel/core/ui/UI';
|
|
5
|
+
import { arrayProp, enumProp, requiredStringProp } from '@aerogel/core/utils/vue';
|
|
6
|
+
import { Colors } from '@aerogel/core/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,7 +3,9 @@ import AGAppOverlays from './AGAppOverlays.vue';
|
|
|
3
3
|
|
|
4
4
|
export { AGAppLayout, AGAppOverlays };
|
|
5
5
|
|
|
6
|
+
export * from './composition';
|
|
6
7
|
export * from './constants';
|
|
8
|
+
export * from './contracts';
|
|
7
9
|
export * from './forms';
|
|
8
10
|
export * from './headless';
|
|
9
11
|
export * from './lib';
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { computed } from 'vue';
|
|
7
7
|
|
|
8
|
-
import
|
|
9
|
-
import {
|
|
10
|
-
import type { ErrorSource } from '
|
|
8
|
+
import { requiredObjectProp } from '@aerogel/core/utils/vue';
|
|
9
|
+
import { getErrorMessage } from '@aerogel/core/errors/utils';
|
|
10
|
+
import type { ErrorSource } from '@aerogel/core/errors/Errors.state';
|
|
11
11
|
|
|
12
12
|
import AGMarkdown from './AGMarkdown.vue';
|
|
13
13
|
|
|
14
14
|
const props = defineProps({ error: requiredObjectProp<ErrorSource>() });
|
|
15
|
-
const message = computed(() =>
|
|
15
|
+
const message = computed(() => getErrorMessage(props.error));
|
|
16
16
|
</script>
|
|
@@ -3,20 +3,23 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
|
-
import { computed, h } from 'vue';
|
|
6
|
+
import { computed, h, useAttrs } from 'vue';
|
|
7
|
+
import { isInstanceOf } from '@noeldemartin/utils';
|
|
7
8
|
|
|
8
|
-
import { renderMarkdown } from '
|
|
9
|
-
import { booleanProp, objectProp, stringProp } from '
|
|
10
|
-
import { translate } from '
|
|
9
|
+
import { renderMarkdown } from '@aerogel/core/utils/markdown';
|
|
10
|
+
import { booleanProp, mixedProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
|
|
11
|
+
import { translate } from '@aerogel/core/lang';
|
|
11
12
|
|
|
12
13
|
const props = defineProps({
|
|
13
14
|
as: stringProp(),
|
|
14
15
|
inline: booleanProp(),
|
|
15
16
|
langKey: stringProp(),
|
|
16
|
-
langParams:
|
|
17
|
+
langParams: mixedProp<number | Record<string, unknown>>(),
|
|
17
18
|
text: stringProp(),
|
|
19
|
+
actions: objectProp<Record<string, () => unknown>>(),
|
|
18
20
|
});
|
|
19
21
|
|
|
22
|
+
const attrs = useAttrs();
|
|
20
23
|
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
|
|
21
24
|
const html = computed(() => {
|
|
22
25
|
if (!markdown.value) {
|
|
@@ -32,5 +35,20 @@ const html = computed(() => {
|
|
|
32
35
|
return renderedHtml;
|
|
33
36
|
});
|
|
34
37
|
const root = () =>
|
|
35
|
-
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
38
|
+
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
39
|
+
innerHTML: html.value,
|
|
40
|
+
onClick,
|
|
41
|
+
...attrs,
|
|
42
|
+
class: `${attrs.class ?? ''} ${props.inline ? '' : 'prose'}`,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
async function onClick(event: Event) {
|
|
46
|
+
const { target } = event;
|
|
47
|
+
|
|
48
|
+
if (isInstanceOf(target, HTMLElement) && target.dataset.markdownAction) {
|
|
49
|
+
props.actions?.[target.dataset.markdownAction]?.();
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
36
54
|
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
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 '@aerogel/core/utils/vue';
|
|
11
|
+
|
|
12
|
+
defineProps({ as: stringProp('span') });
|
|
13
|
+
|
|
14
|
+
// TODO use v-measure.css
|
|
15
|
+
const measured = ref(false);
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200">
|
|
3
|
+
<div :class="barClasses" :style="`transform:translateX(-${(1 - renderedProgress) * 100}%)`" />
|
|
4
|
+
<span class="sr-only">
|
|
5
|
+
{{
|
|
6
|
+
$td('ui.progress', '{progress}% complete', {
|
|
7
|
+
progress: renderedProgress * 100,
|
|
8
|
+
})
|
|
9
|
+
}}
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { computed, onUnmounted, ref, watch } from 'vue';
|
|
16
|
+
|
|
17
|
+
import { numberProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
|
|
18
|
+
import type { Job } from '@aerogel/core/jobs';
|
|
19
|
+
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
progress: numberProp(),
|
|
22
|
+
barClass: stringProp(''),
|
|
23
|
+
job: objectProp<Job>(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
let cleanup: Function | undefined;
|
|
27
|
+
const jobProgress = ref(0);
|
|
28
|
+
const barClasses = computed(() => {
|
|
29
|
+
const classes = props.barClass ?? '';
|
|
30
|
+
|
|
31
|
+
return `size-full transition-transform duration-500 ease-linear ${
|
|
32
|
+
classes.includes('bg-') ? classes : `${classes} bg-gray-700`
|
|
33
|
+
}`;
|
|
34
|
+
});
|
|
35
|
+
const renderedProgress = computed(() => {
|
|
36
|
+
if (typeof props.progress === 'number') {
|
|
37
|
+
return props.progress;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return jobProgress.value;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
watch(
|
|
44
|
+
() => props.job,
|
|
45
|
+
() => {
|
|
46
|
+
cleanup?.();
|
|
47
|
+
|
|
48
|
+
jobProgress.value = props.job?.progress ?? 0;
|
|
49
|
+
cleanup = props.job?.listeners.add({ onUpdated: (progress) => (jobProgress.value = progress) });
|
|
50
|
+
},
|
|
51
|
+
{ immediate: true },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
onUnmounted(() => cleanup?.());
|
|
55
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="grid
|
|
2
|
+
<div class="grid grow place-items-center">
|
|
3
3
|
<div class="flex flex-col items-center space-y-6 p-8">
|
|
4
4
|
<h1 class="mt-2 text-center text-4xl font-medium text-red-600">
|
|
5
5
|
{{ $td('startupCrash.title', 'Something went wrong!') }}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { default as AGErrorMessage } from './AGErrorMessage.vue';
|
|
2
2
|
export { default as AGLink } from './AGLink.vue';
|
|
3
3
|
export { default as AGMarkdown } from './AGMarkdown.vue';
|
|
4
|
+
export { default as AGMeasured } from './AGMeasured.vue';
|
|
5
|
+
export { default as AGProgressBar } from './AGProgressBar.vue';
|
|
4
6
|
export { default as AGStartupCrash } from './AGStartupCrash.vue';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import { requiredStringProp, stringProp } from '@aerogel/core/utils';
|
|
5
|
+
import type { AcceptRefs } from '@aerogel/core/utils';
|
|
6
|
+
|
|
7
|
+
export const alertModalProps = {
|
|
8
|
+
title: stringProp(),
|
|
9
|
+
message: requiredStringProp(),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type AGAlertModalProps = Pretty<
|
|
13
|
+
AcceptRefs<ObjectWithout<ExtractPropTypes<typeof alertModalProps>, null | undefined>>
|
|
14
|
+
>;
|
|
15
|
+
|
|
16
|
+
export function useAlertModalProps(): typeof alertModalProps {
|
|
17
|
+
return alertModalProps;
|
|
18
|
+
}
|
|
@@ -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
11
|
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
20
12
|
|
|
21
|
-
defineProps(
|
|
22
|
-
title: stringProp(),
|
|
23
|
-
message: requiredStringProp(),
|
|
24
|
-
});
|
|
13
|
+
defineProps(useAlertModalProps());
|
|
25
14
|
</script>
|
|
@@ -1,10 +1,42 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithout, Pretty, SubPartial } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { Colors } from '@aerogel/core/components/constants';
|
|
6
|
+
import { booleanProp, enumProp, objectProp, requiredStringProp, stringProp } from '@aerogel/core/utils';
|
|
7
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
8
|
+
import type { AcceptRefs } from '@aerogel/core/utils';
|
|
9
|
+
import type { ConfirmCheckboxes } from '@aerogel/core/ui';
|
|
2
10
|
|
|
3
11
|
export const confirmModalProps = {
|
|
4
12
|
title: stringProp(),
|
|
5
13
|
message: requiredStringProp(),
|
|
14
|
+
acceptText: stringProp(),
|
|
15
|
+
acceptColor: enumProp(Colors, Colors.Primary),
|
|
16
|
+
cancelText: stringProp(),
|
|
17
|
+
cancelColor: enumProp(Colors, Colors.Clear),
|
|
18
|
+
checkboxes: objectProp<ConfirmCheckboxes>(),
|
|
19
|
+
actions: objectProp<Record<string, () => unknown>>(),
|
|
20
|
+
required: booleanProp(false),
|
|
6
21
|
};
|
|
7
22
|
|
|
23
|
+
export type AGConfirmModalProps = Pretty<
|
|
24
|
+
AcceptRefs<
|
|
25
|
+
SubPartial<
|
|
26
|
+
ObjectWithout<ExtractPropTypes<typeof confirmModalProps>, null | undefined>,
|
|
27
|
+
'acceptColor' | 'cancelColor'
|
|
28
|
+
>
|
|
29
|
+
>
|
|
30
|
+
>;
|
|
31
|
+
|
|
8
32
|
export function useConfirmModalProps(): typeof confirmModalProps {
|
|
9
33
|
return confirmModalProps;
|
|
10
34
|
}
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
37
|
+
export function useConfirmModal(props: ExtractPropTypes<typeof confirmModalProps>) {
|
|
38
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
39
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
40
|
+
|
|
41
|
+
return { renderedAcceptText, renderedCancelText };
|
|
42
|
+
}
|
|
@@ -1,30 +1,27 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal v-slot="{ close }:
|
|
3
|
-
<AGMarkdown
|
|
4
|
-
<AGMarkdown :text="message" />
|
|
2
|
+
<AGModal v-slot="{ close }: IModalDefaultSlotProps" :cancellable="false" :title="title">
|
|
3
|
+
<AGMarkdown :text="message" :actions="actions" />
|
|
5
4
|
|
|
6
5
|
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
7
|
-
<AGButton @click="close(true)">
|
|
8
|
-
{{
|
|
6
|
+
<AGButton :color="acceptColor" @click="close(true)">
|
|
7
|
+
{{ renderedAcceptText }}
|
|
9
8
|
</AGButton>
|
|
10
|
-
<AGButton color="
|
|
11
|
-
{{
|
|
9
|
+
<AGButton v-if="!required" :color="cancelColor" @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 {
|
|
17
|
+
import type { IModalDefaultSlotProps } from '@aerogel/core/components/contracts/Modal';
|
|
19
18
|
|
|
20
19
|
import AGModal from './AGModal.vue';
|
|
21
|
-
import
|
|
20
|
+
import { useConfirmModal, useConfirmModalProps } from './AGConfirmModal';
|
|
22
21
|
|
|
23
22
|
import AGButton from '../forms/AGButton.vue';
|
|
24
23
|
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
25
24
|
|
|
26
|
-
defineProps(
|
|
27
|
-
|
|
28
|
-
message: requiredStringProp(),
|
|
29
|
-
});
|
|
25
|
+
const props = defineProps(useConfirmModalProps());
|
|
26
|
+
const { renderedAcceptText, renderedCancelText } = useConfirmModal(props);
|
|
30
27
|
</script>
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
import type { Component, ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
|
|
2
4
|
|
|
3
|
-
import { requiredArrayProp } from '
|
|
4
|
-
import
|
|
5
|
+
import { requiredArrayProp } from '@aerogel/core/utils/vue';
|
|
6
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
7
|
+
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
8
|
+
import type { ErrorReport } from '@aerogel/core/errors';
|
|
5
9
|
|
|
6
10
|
export interface IAGErrorReportModalButtonsDefaultSlotProps {
|
|
7
11
|
id: string;
|
|
@@ -15,6 +19,31 @@ export const errorReportModalProps = {
|
|
|
15
19
|
reports: requiredArrayProp<ErrorReport>(),
|
|
16
20
|
};
|
|
17
21
|
|
|
22
|
+
export type AGErrorReportModalProps = Pretty<
|
|
23
|
+
AcceptRefs<ObjectWithout<ExtractPropTypes<typeof errorReportModalProps>, null | undefined>>
|
|
24
|
+
>;
|
|
25
|
+
|
|
18
26
|
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
19
27
|
return errorReportModalProps;
|
|
20
28
|
}
|
|
29
|
+
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
31
|
+
export function useErrorReportModal(props: ExtractPropTypes<typeof errorReportModalProps>) {
|
|
32
|
+
const activeReportIndex = ref(0);
|
|
33
|
+
const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
34
|
+
const details = computed(
|
|
35
|
+
() =>
|
|
36
|
+
report.value.details?.trim() ||
|
|
37
|
+
translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
|
|
38
|
+
);
|
|
39
|
+
const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
|
|
40
|
+
const nextReportText = translateWithDefault('errors.nextReport', 'Show next report');
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
activeReportIndex,
|
|
44
|
+
details,
|
|
45
|
+
nextReportText,
|
|
46
|
+
previousReportText,
|
|
47
|
+
report,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -12,20 +12,20 @@
|
|
|
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
|
-
<IconCheveronLeft aria-hidden="true" class="
|
|
19
|
+
<IconCheveronLeft aria-hidden="true" class="size-4" />
|
|
20
20
|
</AGButton>
|
|
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
|
-
<IconCheveronRight aria-hidden="true" class="
|
|
28
|
+
<IconCheveronRight aria-hidden="true" class="size-4" />
|
|
29
29
|
</AGButton>
|
|
30
30
|
</template>
|
|
31
31
|
</div>
|
|
@@ -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>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="flex">
|
|
3
|
-
<slot v-for="(button, i) of buttons" v-bind="
|
|
3
|
+
<slot v-for="(button, i) of buttons" v-bind="button as unknown as ComponentProps" :key="i">
|
|
4
4
|
<AGButton
|
|
5
5
|
color="clear"
|
|
6
6
|
:url="button.url"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
:aria-label="$td(`errors.report_${button.id}`, button.description)"
|
|
9
9
|
@click="button.handler"
|
|
10
10
|
>
|
|
11
|
-
<component :is="button.iconComponent" class="
|
|
11
|
+
<component :is="button.iconComponent" class="size-4" aria-hidden="true" />
|
|
12
12
|
</AGButton>
|
|
13
13
|
</slot>
|
|
14
14
|
</div>
|
|
@@ -22,12 +22,12 @@ import IconGitHub from '~icons/mdi/github';
|
|
|
22
22
|
import { computed } from 'vue';
|
|
23
23
|
import { stringExcerpt, tap } from '@noeldemartin/utils';
|
|
24
24
|
|
|
25
|
-
import App from '
|
|
26
|
-
import UI from '
|
|
27
|
-
import { requiredObjectProp } from '
|
|
28
|
-
import { translateWithDefault } from '
|
|
29
|
-
import type { ComponentProps } from '
|
|
30
|
-
import type { ErrorReport } from '
|
|
25
|
+
import App from '@aerogel/core/services/App';
|
|
26
|
+
import UI from '@aerogel/core/ui/UI';
|
|
27
|
+
import { requiredObjectProp } from '@aerogel/core/utils/vue';
|
|
28
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
29
|
+
import type { ComponentProps } from '@aerogel/core/utils/vue';
|
|
30
|
+
import type { ErrorReport } from '@aerogel/core/errors';
|
|
31
31
|
|
|
32
32
|
import AGButton from '../forms/AGButton.vue';
|
|
33
33
|
import type { IAGErrorReportModalButtonsDefaultSlotProps } from './AGErrorReportModal';
|
|
@@ -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(
|
|
@@ -92,8 +94,8 @@ const buttons = computed(() =>
|
|
|
92
94
|
);
|
|
93
95
|
},
|
|
94
96
|
},
|
|
95
|
-
],
|
|
96
|
-
(reportButtons
|
|
97
|
+
] as IAGErrorReportModalButtonsDefaultSlotProps[],
|
|
98
|
+
(reportButtons) => {
|
|
97
99
|
if (!githubReportUrl.value) {
|
|
98
100
|
return;
|
|
99
101
|
}
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { computed } from 'vue';
|
|
7
7
|
|
|
8
|
-
import { numberProp, requiredObjectProp } from '
|
|
9
|
-
import type { ErrorReport } from '
|
|
8
|
+
import { numberProp, requiredObjectProp } from '@aerogel/core/utils/vue';
|
|
9
|
+
import type { ErrorReport } from '@aerogel/core/errors';
|
|
10
10
|
|
|
11
11
|
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
12
|
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithout } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { numberProp, stringProp } from '@aerogel/core/utils';
|
|
6
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
7
|
+
import type { AcceptRefs } from '@aerogel/core/utils';
|
|
2
8
|
|
|
3
9
|
export const loadingModalProps = {
|
|
10
|
+
title: stringProp(),
|
|
4
11
|
message: stringProp(),
|
|
12
|
+
progress: numberProp(),
|
|
5
13
|
};
|
|
6
14
|
|
|
15
|
+
export type AGLoadingModalProps = AcceptRefs<
|
|
16
|
+
ObjectWithout<ExtractPropTypes<typeof loadingModalProps>, null | undefined>
|
|
17
|
+
>;
|
|
18
|
+
|
|
7
19
|
export function useLoadingModalProps(): typeof loadingModalProps {
|
|
8
20
|
return loadingModalProps;
|
|
9
21
|
}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
24
|
+
export function useLoadingModal(props: ExtractPropTypes<typeof loadingModalProps>) {
|
|
25
|
+
const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
|
|
26
|
+
const showProgress = computed(() => typeof props.progress === 'number');
|
|
27
|
+
|
|
28
|
+
return { renderedMessage, showProgress };
|
|
29
|
+
}
|