@aerogel/core 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c → 0.0.0-next.9f9564ab9f8da05f60d7868db361edbc5601ee39
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 +689 -140
- 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 +16 -5
- package/src/bootstrap/options.ts +3 -0
- package/src/components/AGAppLayout.vue +3 -2
- package/src/components/AGAppOverlays.vue +5 -1
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/forms/AGCheckbox.vue +7 -1
- package/src/components/forms/AGForm.vue +9 -10
- package/src/components/forms/AGInput.vue +10 -6
- package/src/components/forms/AGSelect.story.vue +21 -3
- package/src/components/forms/AGSelect.vue +10 -3
- package/src/components/headless/forms/AGHeadlessButton.vue +17 -12
- package/src/components/headless/forms/AGHeadlessInput.ts +12 -13
- package/src/components/headless/forms/AGHeadlessInput.vue +3 -3
- package/src/components/headless/forms/AGHeadlessInputDescription.vue +28 -0
- package/src/components/headless/forms/AGHeadlessInputInput.vue +40 -4
- package/src/components/headless/forms/AGHeadlessInputTextArea.vue +40 -0
- 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/forms/composition.ts +10 -0
- package/src/components/headless/forms/index.ts +3 -0
- 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/AGErrorMessage.vue +2 -2
- package/src/components/lib/AGMarkdown.vue +9 -4
- 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 +5 -1
- package/src/directives/measure.ts +21 -0
- package/src/errors/Errors.ts +26 -24
- package/src/errors/index.ts +2 -11
- package/src/errors/utils.ts +19 -0
- package/src/forms/Form.ts +43 -3
- package/src/forms/index.ts +1 -0
- package/src/forms/utils.ts +15 -0
- package/src/jobs/Job.ts +5 -0
- package/src/jobs/index.ts +7 -0
- package/src/lang/Lang.ts +14 -22
- package/src/main.ts +3 -0
- package/src/services/App.state.ts +1 -2
- package/src/services/App.ts +21 -3
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +100 -30
- package/src/services/Service.ts +42 -12
- package/src/services/index.ts +5 -2
- package/src/services/store.ts +8 -5
- package/src/testing/index.ts +25 -0
- package/src/ui/UI.ts +101 -15
- 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,44 +1,42 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
1
|
+
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
|
+
import type { Writable } from '@noeldemartin/utils';
|
|
2
3
|
|
|
3
|
-
import { requiredArrayProp, stringProp } from '@/utils/vue';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
value: string | number | boolean | object | null;
|
|
7
|
-
text: string;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export type IAGSelectOptionValue = string | number | boolean | object | null;
|
|
4
|
+
import { mixedProp, requiredArrayProp, stringProp } from '@/utils/vue';
|
|
5
|
+
import { extractComponentProps } from '@/components/utils';
|
|
6
|
+
import type { FormFieldValue } from '@/forms/Form';
|
|
11
7
|
|
|
12
8
|
export interface IAGHeadlessSelect {
|
|
13
9
|
id: string;
|
|
14
10
|
label: ComputedRef<string | null>;
|
|
15
11
|
noSelectionText: ComputedRef<string>;
|
|
16
12
|
buttonText: ComputedRef<string>;
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
renderText: ComputedRef<(value: FormFieldValue) => string>;
|
|
14
|
+
selectedOption: ComputedRef<FormFieldValue | null>;
|
|
15
|
+
options: ComputedRef<FormFieldValue[]>;
|
|
19
16
|
errors: DeepReadonly<Ref<string[] | null>>;
|
|
20
|
-
update(value:
|
|
17
|
+
update(value: FormFieldValue): void;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
20
|
export const selectProps = {
|
|
24
21
|
name: stringProp(),
|
|
25
22
|
label: stringProp(),
|
|
26
|
-
options: requiredArrayProp<
|
|
23
|
+
options: requiredArrayProp<FormFieldValue>(),
|
|
27
24
|
noSelectionText: stringProp(),
|
|
25
|
+
optionsText: mixedProp<string | ((option: FormFieldValue) => string)>(),
|
|
28
26
|
};
|
|
29
27
|
|
|
28
|
+
export const selectEmits = ['update:modelValue'] as const;
|
|
29
|
+
|
|
30
30
|
export function useSelectProps(): typeof selectProps {
|
|
31
31
|
return selectProps;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export function
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return Object.keys(selectProps).reduce((extractedProps, selectProp) => {
|
|
38
|
-
const prop = selectProp as keyof typeof selectProps;
|
|
39
|
-
|
|
40
|
-
extractedProps[prop] = componentProps[prop];
|
|
34
|
+
export function useSelectEmits(): Writable<typeof selectEmits> {
|
|
35
|
+
return [...selectEmits];
|
|
36
|
+
}
|
|
41
37
|
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
export function extractSelectProps<T extends ExtractPropTypes<typeof selectProps>>(
|
|
39
|
+
props: T,
|
|
40
|
+
): Pick<T, keyof typeof selectProps> {
|
|
41
|
+
return extractComponentProps(props, selectProps);
|
|
44
42
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Listbox
|
|
3
3
|
v-slot="{ value, open, disabled }: ComponentProps"
|
|
4
|
-
:model-value="selectedOption
|
|
4
|
+
:model-value="selectedOption"
|
|
5
5
|
@update:model-value="update($event)"
|
|
6
6
|
>
|
|
7
7
|
<slot :value="value" :open="open" :disabled="disabled" />
|
|
@@ -10,38 +10,37 @@
|
|
|
10
10
|
|
|
11
11
|
<script setup lang="ts">
|
|
12
12
|
import { computed, inject, provide } from 'vue';
|
|
13
|
-
import {
|
|
13
|
+
import { toString, uuid } from '@noeldemartin/utils';
|
|
14
14
|
import { Listbox } from '@headlessui/vue';
|
|
15
15
|
|
|
16
16
|
import { mixedProp } from '@/utils/vue';
|
|
17
17
|
import { translateWithDefault } from '@/lang/utils';
|
|
18
18
|
import type Form from '@/forms/Form';
|
|
19
|
+
import type { FormFieldValue } from '@/forms/Form';
|
|
19
20
|
import type { ComponentProps } from '@/utils/vue';
|
|
20
21
|
|
|
21
|
-
import { useSelectProps } from './AGHeadlessSelect';
|
|
22
|
-
import type { IAGHeadlessSelect
|
|
22
|
+
import { useSelectEmits, useSelectProps } from './AGHeadlessSelect';
|
|
23
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
23
24
|
|
|
24
|
-
const emit = defineEmits(
|
|
25
|
+
const emit = defineEmits(useSelectEmits());
|
|
25
26
|
const props = defineProps({
|
|
26
|
-
modelValue: mixedProp<
|
|
27
|
+
modelValue: mixedProp<FormFieldValue>(),
|
|
27
28
|
...useSelectProps(),
|
|
28
29
|
});
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const option: IAGSelectOption = {
|
|
34
|
-
value,
|
|
35
|
-
text: toString(isObject(value) && 'text' in value ? value.text : value),
|
|
36
|
-
};
|
|
30
|
+
const renderText = computed(() => {
|
|
31
|
+
if (typeof props.optionsText === 'function') {
|
|
32
|
+
return props.optionsText;
|
|
33
|
+
}
|
|
37
34
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const selectedOptionValue = form && props.name ? form.getFieldValue(props.name) : props.modelValue;
|
|
35
|
+
if (typeof props.optionsText === 'string') {
|
|
36
|
+
return (option: FormFieldValue): string => toString(option[props.optionsText as keyof FormFieldValue]);
|
|
37
|
+
}
|
|
42
38
|
|
|
43
|
-
return
|
|
39
|
+
return (option: FormFieldValue) => toString(option);
|
|
44
40
|
});
|
|
41
|
+
const form = inject<Form | null>('form', null);
|
|
42
|
+
const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
|
|
43
|
+
const selectedOption = computed(() => (form && props.name ? form.getFieldValue(props.name) : props.modelValue));
|
|
45
44
|
const errors = computed(() => {
|
|
46
45
|
if (!form || !props.name) {
|
|
47
46
|
return null;
|
|
@@ -50,7 +49,7 @@ const errors = computed(() => {
|
|
|
50
49
|
return form.errors[props.name] ?? null;
|
|
51
50
|
});
|
|
52
51
|
|
|
53
|
-
function update(value:
|
|
52
|
+
function update(value: FormFieldValue) {
|
|
54
53
|
if (form && props.name) {
|
|
55
54
|
form.setFieldValue(props.name, value);
|
|
56
55
|
|
|
@@ -62,12 +61,14 @@ function update(value: IAGSelectOptionValue) {
|
|
|
62
61
|
|
|
63
62
|
const api: IAGHeadlessSelect = {
|
|
64
63
|
id: `select-${uuid()}`,
|
|
65
|
-
options,
|
|
66
64
|
noSelectionText,
|
|
67
65
|
selectedOption,
|
|
68
66
|
errors,
|
|
67
|
+
options: computed(() => props.options),
|
|
69
68
|
label: computed(() => props.label),
|
|
70
|
-
buttonText: computed(() =>
|
|
69
|
+
buttonText: computed(() =>
|
|
70
|
+
selectedOption.value === null ? noSelectionText.value : renderText.value(selectedOption.value)),
|
|
71
|
+
renderText,
|
|
71
72
|
update,
|
|
72
73
|
};
|
|
73
74
|
|
|
@@ -9,31 +9,31 @@
|
|
|
9
9
|
[unselectedClass ?? 'unselected']: !selected,
|
|
10
10
|
}"
|
|
11
11
|
>
|
|
12
|
-
{{
|
|
12
|
+
{{ select.renderText(value) }}
|
|
13
13
|
</li>
|
|
14
14
|
</slot>
|
|
15
15
|
</ListboxOption>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script setup lang="ts">
|
|
19
|
-
import { computed } from 'vue';
|
|
20
19
|
import { ListboxOption } from '@headlessui/vue';
|
|
21
20
|
|
|
22
21
|
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@/utils/vue';
|
|
23
22
|
import type { ComponentProps } from '@/utils/vue';
|
|
23
|
+
import type { FormFieldValue } from '@/forms/Form';
|
|
24
24
|
|
|
25
|
-
import type { IAGHeadlessSelect
|
|
25
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
26
26
|
|
|
27
|
-
|
|
28
|
-
value: requiredMixedProp<
|
|
27
|
+
defineProps({
|
|
28
|
+
value: requiredMixedProp<FormFieldValue>(),
|
|
29
29
|
selectedClass: stringProp(),
|
|
30
30
|
unselectedClass: stringProp(),
|
|
31
31
|
activeClass: stringProp(),
|
|
32
32
|
inactiveClass: stringProp(),
|
|
33
33
|
});
|
|
34
|
+
|
|
34
35
|
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
35
36
|
'select',
|
|
36
37
|
'<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>',
|
|
37
38
|
);
|
|
38
|
-
const option = computed(() => select.options.find((selectOption) => selectOption.value === props.value));
|
|
39
39
|
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { inject, onUnmounted } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type Form from '@/forms/Form';
|
|
4
|
+
|
|
5
|
+
export function onFormFocus(input: { name: string | null }, listener: () => unknown): void {
|
|
6
|
+
const form = inject<Form | null>('form', null);
|
|
7
|
+
const stop = form?.on('focus', (name) => input.name === name && listener());
|
|
8
|
+
|
|
9
|
+
onUnmounted(() => stop?.());
|
|
10
|
+
}
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
export * from './composition';
|
|
1
2
|
export * from './AGHeadlessInput';
|
|
2
3
|
export * from './AGHeadlessSelect';
|
|
3
4
|
export * from './AGHeadlessSelectOption';
|
|
4
5
|
export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
|
|
5
6
|
export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
|
|
7
|
+
export { default as AGHeadlessInputDescription } from './AGHeadlessInputDescription.vue';
|
|
6
8
|
export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
|
|
7
9
|
export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
|
|
8
10
|
export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
|
|
11
|
+
export { default as AGHeadlessInputTextArea } from './AGHeadlessInputTextArea.vue';
|
|
9
12
|
export { default as AGHeadlessSelect } from './AGHeadlessSelect.vue';
|
|
10
13
|
export { default as AGHeadlessSelectButton } from './AGHeadlessSelectButton.vue';
|
|
11
14
|
export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
|
|
@@ -1,5 +1,9 @@
|
|
|
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
|
-
import { booleanProp } from '@/utils';
|
|
3
7
|
|
|
4
8
|
export interface IAGHeadlessModal extends IAGModal {}
|
|
5
9
|
|
|
@@ -9,8 +13,22 @@ export interface IAGHeadlessModalDefaultSlotProps {
|
|
|
9
13
|
|
|
10
14
|
export const modalProps = {
|
|
11
15
|
cancellable: booleanProp(true),
|
|
16
|
+
title: stringProp(),
|
|
12
17
|
};
|
|
13
18
|
|
|
14
19
|
export function useModalProps(): typeof modalProps {
|
|
15
20
|
return modalProps;
|
|
16
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,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
|
+
}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { computed } from 'vue';
|
|
7
7
|
|
|
8
|
-
import Errors from '@/errors/Errors';
|
|
9
8
|
import { requiredObjectProp } from '@/utils/vue';
|
|
9
|
+
import { getErrorMessage } from '@/errors/utils';
|
|
10
10
|
import type { ErrorSource } from '@/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,21 @@
|
|
|
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
7
|
|
|
8
8
|
import { renderMarkdown } from '@/utils/markdown';
|
|
9
|
-
import { booleanProp,
|
|
9
|
+
import { booleanProp, mixedProp, stringProp } from '@/utils/vue';
|
|
10
10
|
import { translate } from '@/lang';
|
|
11
11
|
|
|
12
12
|
const props = defineProps({
|
|
13
13
|
as: stringProp(),
|
|
14
14
|
inline: booleanProp(),
|
|
15
15
|
langKey: stringProp(),
|
|
16
|
-
langParams:
|
|
16
|
+
langParams: mixedProp<number | Record<string, unknown>>(),
|
|
17
17
|
text: stringProp(),
|
|
18
18
|
});
|
|
19
19
|
|
|
20
|
+
const attrs = useAttrs();
|
|
20
21
|
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
|
|
21
22
|
const html = computed(() => {
|
|
22
23
|
if (!markdown.value) {
|
|
@@ -32,5 +33,9 @@ const html = computed(() => {
|
|
|
32
33
|
return renderedHtml;
|
|
33
34
|
});
|
|
34
35
|
const root = () =>
|
|
35
|
-
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
36
|
+
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
37
|
+
innerHTML: html.value,
|
|
38
|
+
...attrs,
|
|
39
|
+
class: `${attrs.class ?? ''} ${props.inline ? '' : 'prose'}`,
|
|
40
|
+
});
|
|
36
41
|
</script>
|
|
@@ -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>
|
|
@@ -1,4 +1,5 @@
|
|
|
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';
|
|
4
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
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,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
|
+
}
|