@aerogel/core 0.0.0-next.fcfbfdc3428c34c4d1c0e781b61d244f13232fc9 → 0.1.0-next.c4b24f52d8b652bd5c14c2d12e1b38b779ab7682
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.css +1 -0
- package/dist/aerogel-core.d.ts +661 -919
- package/dist/aerogel-core.js +1983 -1440
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +7 -5
- package/src/components/AppLayout.vue +1 -3
- package/src/components/AppOverlays.vue +0 -27
- package/src/components/contracts/AlertModal.ts +15 -0
- package/src/components/contracts/ConfirmModal.ts +12 -5
- package/src/components/contracts/DropdownMenu.ts +8 -3
- package/src/components/contracts/ErrorReportModal.ts +8 -4
- package/src/components/contracts/Input.ts +7 -7
- package/src/components/contracts/LoadingModal.ts +6 -2
- package/src/components/contracts/Modal.ts +4 -4
- package/src/components/contracts/PromptModal.ts +5 -1
- package/src/components/contracts/Select.ts +9 -8
- package/src/components/contracts/Toast.ts +4 -2
- package/src/components/headless/HeadlessButton.vue +2 -2
- package/src/components/headless/HeadlessInputInput.vue +16 -5
- package/src/components/headless/HeadlessModal.vue +8 -43
- package/src/components/headless/HeadlessModalContent.vue +2 -2
- package/src/components/headless/HeadlessSelect.vue +10 -8
- package/src/components/headless/HeadlessSelectOptions.vue +8 -3
- package/src/components/headless/HeadlessSwitch.vue +96 -0
- package/src/components/headless/index.ts +1 -0
- package/src/components/ui/AdvancedOptions.vue +1 -1
- package/src/components/ui/AlertModal.vue +7 -3
- package/src/components/ui/Button.vue +27 -10
- package/src/components/ui/ConfirmModal.vue +11 -3
- package/src/components/ui/DropdownMenuOption.vue +12 -4
- package/src/components/ui/DropdownMenuOptions.vue +18 -1
- package/src/components/ui/ErrorLogs.vue +19 -0
- package/src/components/ui/ErrorLogsModal.vue +48 -0
- package/src/components/ui/ErrorReportModal.vue +18 -7
- package/src/components/ui/Input.vue +2 -2
- package/src/components/ui/LoadingModal.vue +3 -1
- package/src/components/ui/Markdown.vue +29 -1
- package/src/components/ui/Modal.vue +61 -21
- package/src/components/ui/ModalContext.vue +2 -1
- package/src/components/ui/PromptModal.vue +5 -2
- package/src/components/ui/Select.vue +5 -3
- package/src/components/ui/SelectLabel.vue +5 -1
- package/src/components/ui/SelectOptions.vue +6 -1
- package/src/components/ui/SelectTrigger.vue +1 -1
- package/src/components/ui/Setting.vue +31 -0
- package/src/components/ui/StartupCrash.vue +51 -6
- package/src/components/ui/Switch.vue +11 -0
- package/src/components/ui/TextArea.vue +56 -0
- package/src/components/ui/Toast.vue +19 -15
- package/src/components/ui/index.ts +5 -0
- package/src/directives/measure.ts +11 -5
- package/src/errors/Errors.state.ts +1 -0
- package/src/errors/Errors.ts +45 -21
- package/src/errors/index.ts +6 -2
- package/src/errors/settings/Debug.vue +14 -0
- package/src/errors/settings/index.ts +10 -0
- package/src/forms/FormController.test.ts +35 -9
- package/src/forms/FormController.ts +34 -24
- package/src/forms/index.ts +0 -1
- package/src/forms/utils.ts +58 -33
- package/src/forms/validation.ts +31 -0
- package/src/index.css +34 -12
- package/src/lang/index.ts +1 -1
- package/src/lang/settings/Language.vue +1 -1
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +2 -8
- package/src/services/Service.ts +11 -6
- package/src/services/index.ts +2 -2
- package/src/testing/index.ts +4 -0
- package/src/ui/UI.state.ts +3 -13
- package/src/ui/UI.ts +103 -84
- package/src/ui/index.ts +16 -17
- package/src/utils/app.ts +7 -0
- package/src/utils/classes.ts +9 -17
- package/src/utils/composition/events.ts +2 -4
- package/src/utils/composition/forms.ts +7 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/markdown.ts +35 -1
- package/src/utils/vue.ts +6 -1
- package/src/forms/composition.ts +0 -6
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { computed, provide, toRef, unref } from 'vue';
|
|
7
7
|
|
|
8
|
-
import type { UIModal
|
|
8
|
+
import type { UIModal } from '@aerogel/core/ui/UI.state';
|
|
9
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
9
10
|
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
10
11
|
|
|
11
12
|
const props = defineProps<{
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<!-- @vue-generic {import('@aerogel/core/ui/UI').ModalExposeResult<PromptModalExpose>} -->
|
|
2
3
|
<Modal v-slot="{ close }" :title="renderedTitle" persistent>
|
|
3
4
|
<Form :form @submit="close(form.draft)">
|
|
4
5
|
<Markdown v-if="renderedMessage" :text="renderedMessage" />
|
|
@@ -13,7 +14,7 @@
|
|
|
13
14
|
<Button :variant="acceptVariant" submit>
|
|
14
15
|
{{ renderedAcceptText }}
|
|
15
16
|
</Button>
|
|
16
|
-
<Button :variant="cancelVariant" @click="close(
|
|
17
|
+
<Button :variant="cancelVariant" @click="close()">
|
|
17
18
|
{{ renderedCancelText }}
|
|
18
19
|
</Button>
|
|
19
20
|
</div>
|
|
@@ -28,8 +29,10 @@ import Form from '@aerogel/core/components/ui/Form.vue';
|
|
|
28
29
|
import Input from '@aerogel/core/components/ui/Input.vue';
|
|
29
30
|
import Modal from '@aerogel/core/components/ui/Modal.vue';
|
|
30
31
|
import { usePromptModal } from '@aerogel/core/components/contracts/PromptModal';
|
|
31
|
-
import type { PromptModalProps } from '@aerogel/core/components/contracts/PromptModal';
|
|
32
|
+
import type { PromptModalExpose, PromptModalProps } from '@aerogel/core/components/contracts/PromptModal';
|
|
32
33
|
|
|
33
34
|
const { cancelVariant = 'secondary', ...props } = defineProps<PromptModalProps>();
|
|
34
35
|
const { form, renderedTitle, renderedMessage, renderedAcceptText, renderedCancelText } = usePromptModal(props);
|
|
36
|
+
|
|
37
|
+
defineExpose<PromptModalExpose>();
|
|
35
38
|
</script>
|
|
@@ -8,18 +8,20 @@
|
|
|
8
8
|
</HeadlessSelect>
|
|
9
9
|
</template>
|
|
10
10
|
|
|
11
|
-
<script setup lang="ts">
|
|
11
|
+
<script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
|
|
12
12
|
import { useForwardExpose } from 'reka-ui';
|
|
13
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
13
14
|
|
|
14
15
|
import HeadlessSelect from '@aerogel/core/components/headless/HeadlessSelect.vue';
|
|
15
16
|
import type { SelectEmits, SelectProps } from '@aerogel/core/components/contracts/Select';
|
|
17
|
+
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
16
18
|
|
|
17
19
|
import SelectLabel from './SelectLabel.vue';
|
|
18
20
|
import SelectOptions from './SelectOptions.vue';
|
|
19
21
|
import SelectTrigger from './SelectTrigger.vue';
|
|
20
22
|
|
|
21
|
-
defineProps<SelectProps
|
|
22
|
-
defineEmits<SelectEmits
|
|
23
|
+
defineProps<SelectProps<T>>();
|
|
24
|
+
defineEmits<SelectEmits<T>>();
|
|
23
25
|
|
|
24
26
|
const { forwardRef } = useForwardExpose();
|
|
25
27
|
</script>
|
|
@@ -7,11 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
<script setup lang="ts">
|
|
9
9
|
import { computed } from 'vue';
|
|
10
|
+
import type { HTMLAttributes } from 'vue';
|
|
10
11
|
|
|
11
12
|
import HeadlessSelectLabel from '@aerogel/core/components/headless/HeadlessSelectLabel.vue';
|
|
12
13
|
import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
|
|
13
14
|
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
14
15
|
|
|
16
|
+
const { class: rootClasses } = defineProps<{ class?: HTMLAttributes['class'] }>();
|
|
17
|
+
|
|
15
18
|
const select = injectReactiveOrFail<SelectExpose>('select', '<SelectLabel> must be a child of a <Select>');
|
|
16
|
-
const renderedClasses = computed(() =>
|
|
19
|
+
const renderedClasses = computed(() =>
|
|
20
|
+
classes('block text-sm leading-6 font-medium text-gray-900', select.labelClass, rootClasses));
|
|
17
21
|
</script>
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<HeadlessSelectOptions :class="renderedClasses">
|
|
3
|
-
<slot>
|
|
3
|
+
<slot v-if="select.options?.length">
|
|
4
4
|
<SelectOption v-for="option of select?.options ?? []" :key="option.key" :value="option.value">
|
|
5
5
|
{{ option.label }}
|
|
6
6
|
</SelectOption>
|
|
7
7
|
</slot>
|
|
8
|
+
<slot v-else>
|
|
9
|
+
<SelectOption disabled :value="null">
|
|
10
|
+
{{ $td('ui.selectEmpty', 'No options available') }}
|
|
11
|
+
</SelectOption>
|
|
12
|
+
</slot>
|
|
8
13
|
</HeadlessSelectOptions>
|
|
9
14
|
</template>
|
|
10
15
|
|
|
@@ -22,7 +22,7 @@ const select = injectReactiveOrFail<SelectExpose>('select', '<SelectTrigger> mus
|
|
|
22
22
|
const renderedClasses = computed(() =>
|
|
23
23
|
classes(
|
|
24
24
|
// eslint-disable-next-line vue/max-len
|
|
25
|
-
'focus:outline-primary-600 grid w-full cursor-default grid-cols-1 rounded-md bg-white py-1.5 pr-2 pl-3 text-left text-gray-900 outline-1 -outline-offset-1 outline-gray-300 focus:outline-2 focus:-outline-offset-2 sm:text-sm/6',
|
|
25
|
+
'focus:outline-primary-600 data-[state=open]:outline-primary-600 grid w-full cursor-default grid-cols-1 rounded-md bg-white py-1.5 pr-2 pl-3 text-left text-gray-900 outline-1 -outline-offset-1 outline-gray-300 focus:outline-2 focus:-outline-offset-2 sm:text-sm/6',
|
|
26
26
|
{ 'mt-1': select.label },
|
|
27
27
|
rootClasses,
|
|
28
28
|
));
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="mt-4 flex" :class="{ 'flex-col': layout === 'vertical' }">
|
|
3
|
+
<div class="flex-grow">
|
|
4
|
+
<h3 :id="titleId" class="text-base font-semibold">
|
|
5
|
+
{{ title }}
|
|
6
|
+
</h3>
|
|
7
|
+
<Markdown v-if="description" :text="description" class="mt-1 text-sm text-gray-500" />
|
|
8
|
+
</div>
|
|
9
|
+
|
|
10
|
+
<div :class="renderedRootClass">
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { computed } from 'vue';
|
|
18
|
+
import type { HTMLAttributes } from 'vue';
|
|
19
|
+
|
|
20
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
21
|
+
import { classes } from '@aerogel/core/utils';
|
|
22
|
+
|
|
23
|
+
const { layout = 'horizontal', class: rootClass } = defineProps<{
|
|
24
|
+
title: string;
|
|
25
|
+
titleId?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
class?: HTMLAttributes['class'];
|
|
28
|
+
layout?: 'vertical' | 'horizontal';
|
|
29
|
+
}>();
|
|
30
|
+
const renderedRootClass = computed(() => classes(rootClass, 'flex flex-col justify-center gap-1'));
|
|
31
|
+
</script>
|
|
@@ -1,31 +1,76 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="grid grow place-items-center">
|
|
3
|
-
<div class="flex flex-col items-center
|
|
4
|
-
<
|
|
5
|
-
|
|
3
|
+
<div class="flex flex-col items-center p-8">
|
|
4
|
+
<i-majesticons-exclamation class="size-20 text-red-600" />
|
|
5
|
+
<h1 class="mt-0 mb-0 text-center text-4xl font-medium text-red-600">
|
|
6
|
+
{{ $td('startupCrash.title', 'Oops, something went wrong!') }}
|
|
6
7
|
</h1>
|
|
7
8
|
<Markdown
|
|
8
9
|
:text="
|
|
9
10
|
$td(
|
|
10
11
|
'startupCrash.message',
|
|
11
|
-
'
|
|
12
|
+
'There was a problem starting the application, but here\'s some things you can do:'
|
|
12
13
|
)
|
|
13
14
|
"
|
|
14
15
|
class="mt-4 text-center"
|
|
15
16
|
/>
|
|
16
|
-
<div
|
|
17
|
+
<div
|
|
18
|
+
class="mt-4 grid grid-cols-1 gap-2 sm:grid-cols-2 [&_button]:justify-start sm:[&_button]:size-32 sm:[&_button]:flex-col sm:[&_button]:justify-center [&_svg]:size-6 sm:[&_svg]:size-8"
|
|
19
|
+
>
|
|
17
20
|
<Button variant="danger" @click="$app.reload()">
|
|
21
|
+
<IconRefresh />
|
|
18
22
|
{{ $td('startupCrash.reload', 'Try again') }}
|
|
19
23
|
</Button>
|
|
20
24
|
<Button variant="danger" @click="$errors.inspect($errors.startupErrors)">
|
|
25
|
+
<IconBug />
|
|
21
26
|
{{ $td('startupCrash.inspect', 'View error details') }}
|
|
22
27
|
</Button>
|
|
28
|
+
<Button variant="danger" @click="purgeDevice()">
|
|
29
|
+
<IconDelete />
|
|
30
|
+
{{ $td('startupCrash.purge', 'Purge device') }}
|
|
31
|
+
</Button>
|
|
32
|
+
<Button variant="danger" @click="$errors.debug = !$errors.debug">
|
|
33
|
+
<IconFrameInspect />
|
|
34
|
+
{{ $td('startupCrash.debug', 'Toggle debugging') }}
|
|
35
|
+
</Button>
|
|
23
36
|
</div>
|
|
24
37
|
</div>
|
|
25
38
|
</div>
|
|
26
39
|
</template>
|
|
27
40
|
|
|
28
41
|
<script setup lang="ts">
|
|
29
|
-
import
|
|
42
|
+
import IconBug from '~icons/material-symbols/bug-report';
|
|
43
|
+
import IconDelete from '~icons/material-symbols/delete-forever-rounded';
|
|
44
|
+
import IconFrameInspect from '~icons/material-symbols/frame-inspect';
|
|
45
|
+
import IconRefresh from '~icons/material-symbols/refresh-rounded';
|
|
46
|
+
|
|
47
|
+
import App from '@aerogel/core/services/App';
|
|
30
48
|
import Button from '@aerogel/core/components/ui/Button.vue';
|
|
49
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
50
|
+
import Storage from '@aerogel/core/services/Storage';
|
|
51
|
+
import UI from '@aerogel/core/ui/UI';
|
|
52
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
53
|
+
|
|
54
|
+
async function purgeDevice() {
|
|
55
|
+
const confirmed = await UI.confirm(
|
|
56
|
+
translateWithDefault('startupCrash.purgeConfirmTitle', 'Delete everything?'),
|
|
57
|
+
translateWithDefault(
|
|
58
|
+
'startupCrash.purgeConfirmMessage',
|
|
59
|
+
'If the problem persists, one drastic solution may be to wipe the storage in this device ' +
|
|
60
|
+
'to start from scratch. However, keep in mind that **all the data that you haven\'t ' +
|
|
61
|
+
'synchronized will be deleted forever**.\n\nDo you still want to proceed?',
|
|
62
|
+
),
|
|
63
|
+
{
|
|
64
|
+
acceptVariant: 'danger',
|
|
65
|
+
acceptText: translateWithDefault('startupCrash.purgeConfirmAccept', 'Purge device'),
|
|
66
|
+
},
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
if (!confirmed) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
await Storage.purge();
|
|
74
|
+
await App.reload();
|
|
75
|
+
}
|
|
31
76
|
</script>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessSwitch
|
|
3
|
+
class="flex flex-row items-center gap-1"
|
|
4
|
+
input-class="disabled:opacity-50 disabled:cursor-not-allowed data-[state=checked]:bg-primary-600 data-[state=unchecked]:bg-gray-200 relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focusdisabled:opacity-50 disabled:cursor-not-allowed :ring-2 focus:ring-primary-600 focus:ring-offset-2 focus:outline-hidden"
|
|
5
|
+
thumb-class="data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0 pointer-events-none inline-block size-5 transform rounded-full bg-white shadow-sm ring-0 transition duration-200 ease-in-out"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import HeadlessSwitch from '@aerogel/core/components/headless/HeadlessSwitch.vue';
|
|
11
|
+
</script>
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessInput
|
|
3
|
+
ref="$inputRef"
|
|
4
|
+
:label="label"
|
|
5
|
+
:class="rootClasses"
|
|
6
|
+
v-bind="props"
|
|
7
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
8
|
+
>
|
|
9
|
+
<HeadlessInputLabel class="block text-sm leading-6 font-medium text-gray-900" />
|
|
10
|
+
<div :class="renderedWrapperClasses">
|
|
11
|
+
<HeadlessInputTextArea v-bind="inputAttrs" :class="renderedInputClasses" />
|
|
12
|
+
<div v-if="$input?.errors" class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
|
|
13
|
+
<IconExclamationSolid class="size-5 text-red-500" />
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
<HeadlessInputDescription class="mt-2 text-sm text-gray-600" />
|
|
17
|
+
<HeadlessInputError class="mt-2 text-sm text-red-600" />
|
|
18
|
+
</HeadlessInput>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import IconExclamationSolid from '~icons/zondicons/exclamation-solid';
|
|
23
|
+
|
|
24
|
+
import { computed, useTemplateRef } from 'vue';
|
|
25
|
+
import type { HTMLAttributes } from 'vue';
|
|
26
|
+
|
|
27
|
+
import HeadlessInput from '@aerogel/core/components/headless/HeadlessInput.vue';
|
|
28
|
+
import HeadlessInputLabel from '@aerogel/core/components/headless/HeadlessInputLabel.vue';
|
|
29
|
+
import HeadlessInputTextArea from '@aerogel/core/components/headless/HeadlessInputTextArea.vue';
|
|
30
|
+
import HeadlessInputDescription from '@aerogel/core/components/headless/HeadlessInputDescription.vue';
|
|
31
|
+
import HeadlessInputError from '@aerogel/core/components/headless/HeadlessInputError.vue';
|
|
32
|
+
import { classes } from '@aerogel/core/utils/classes';
|
|
33
|
+
import { useInputAttrs } from '@aerogel/core/utils/composition/forms';
|
|
34
|
+
import type { InputEmits, InputProps } from '@aerogel/core/components/contracts/Input';
|
|
35
|
+
|
|
36
|
+
defineOptions({ inheritAttrs: false });
|
|
37
|
+
defineEmits<InputEmits>();
|
|
38
|
+
const { label, inputClass, wrapperClass, ...props } = defineProps<
|
|
39
|
+
InputProps & { inputClass?: HTMLAttributes['class']; wrapperClass?: HTMLAttributes['class'] }
|
|
40
|
+
>();
|
|
41
|
+
const $input = useTemplateRef('$inputRef');
|
|
42
|
+
const [inputAttrs, rootClasses] = useInputAttrs();
|
|
43
|
+
const renderedWrapperClasses = computed(() =>
|
|
44
|
+
classes('relative rounded-md shadow-2xs', { 'mt-1': label }, wrapperClass));
|
|
45
|
+
const renderedInputClasses = computed(() =>
|
|
46
|
+
classes(
|
|
47
|
+
// eslint-disable-next-line vue/max-len
|
|
48
|
+
'block w-full rounded-md border-0 py-1.5 ring-1 ring-inset focus:ring-2 focus:ring-inset sm:text-sm sm:leading-6',
|
|
49
|
+
{
|
|
50
|
+
'focus:ring-primary-600': !$input.value?.errors,
|
|
51
|
+
'text-gray-900 shadow-2xs ring-gray-900/10 placeholder:text-gray-400': !$input.value?.errors,
|
|
52
|
+
'pr-10 text-red-900 ring-red-900/10 placeholder:text-red-300 focus:ring-red-500': $input.value?.errors,
|
|
53
|
+
},
|
|
54
|
+
inputClass,
|
|
55
|
+
));
|
|
56
|
+
</script>
|
|
@@ -13,30 +13,34 @@
|
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue';
|
|
16
17
|
import type { HTMLAttributes } from 'vue';
|
|
17
18
|
|
|
18
19
|
import Button from '@aerogel/core/components/ui/Button.vue';
|
|
19
20
|
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
20
21
|
import HeadlessToast from '@aerogel/core/components/headless/HeadlessToast.vue';
|
|
21
22
|
import HeadlessToastAction from '@aerogel/core/components/headless/HeadlessToastAction.vue';
|
|
22
|
-
import {
|
|
23
|
-
import type { ToastProps } from '@aerogel/core/components/contracts/Toast';
|
|
23
|
+
import { variantClasses } from '@aerogel/core/utils/classes';
|
|
24
|
+
import type { ToastExpose, ToastProps } from '@aerogel/core/components/contracts/Toast';
|
|
24
25
|
import type { Variants } from '@aerogel/core/utils/classes';
|
|
25
26
|
|
|
26
27
|
const { class: baseClasses, variant = 'secondary' } = defineProps<ToastProps & { class?: HTMLAttributes['class'] }>();
|
|
27
|
-
const renderedClasses =
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
const renderedClasses = computed(() =>
|
|
29
|
+
variantClasses<Variants<Pick<ToastProps, 'variant'>>>(
|
|
30
|
+
{ baseClasses, variant },
|
|
31
|
+
{
|
|
32
|
+
baseClasses: 'flex items-center gap-2 rounded-md p-2 ring-1 shadow-lg border-gray-200',
|
|
33
|
+
variants: {
|
|
34
|
+
variant: {
|
|
35
|
+
secondary: 'bg-gray-900 text-white ring-black',
|
|
36
|
+
danger: 'bg-red-50 text-red-900 ring-red-100',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
variant: 'secondary',
|
|
35
41
|
},
|
|
36
42
|
},
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
);
|
|
43
|
+
));
|
|
44
|
+
|
|
45
|
+
defineExpose<ToastExpose>();
|
|
42
46
|
</script>
|
|
@@ -7,6 +7,8 @@ export { default as DropdownMenu } from './DropdownMenu.vue';
|
|
|
7
7
|
export { default as DropdownMenuOption } from './DropdownMenuOption.vue';
|
|
8
8
|
export { default as DropdownMenuOptions } from './DropdownMenuOptions.vue';
|
|
9
9
|
export { default as EditableContent } from './EditableContent.vue';
|
|
10
|
+
export { default as ErrorLogs } from './ErrorLogs.vue';
|
|
11
|
+
export { default as ErrorLogsModal } from './ErrorLogsModal.vue';
|
|
10
12
|
export { default as ErrorMessage } from './ErrorMessage.vue';
|
|
11
13
|
export { default as ErrorReportModal } from './ErrorReportModal.vue';
|
|
12
14
|
export { default as ErrorReportModalButtons } from './ErrorReportModalButtons.vue';
|
|
@@ -25,6 +27,9 @@ export { default as SelectLabel } from './SelectLabel.vue';
|
|
|
25
27
|
export { default as SelectOption } from './SelectOption.vue';
|
|
26
28
|
export { default as SelectOptions } from './SelectOptions.vue';
|
|
27
29
|
export { default as SelectTrigger } from './SelectTrigger.vue';
|
|
30
|
+
export { default as Setting } from './Setting.vue';
|
|
28
31
|
export { default as SettingsModal } from './SettingsModal.vue';
|
|
29
32
|
export { default as StartupCrash } from './StartupCrash.vue';
|
|
33
|
+
export { default as Switch } from './Switch.vue';
|
|
34
|
+
export { default as TextArea } from './TextArea.vue';
|
|
30
35
|
export { default as Toast } from './Toast.vue';
|
|
@@ -3,6 +3,15 @@ import { tap } from '@noeldemartin/utils';
|
|
|
3
3
|
|
|
4
4
|
const resizeObservers: WeakMap<HTMLElement, ResizeObserver> = new WeakMap();
|
|
5
5
|
|
|
6
|
+
export type MeasureDirectiveValue =
|
|
7
|
+
| MeasureDirectiveListener
|
|
8
|
+
| {
|
|
9
|
+
css?: boolean;
|
|
10
|
+
watch?: boolean;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type MeasureDirectiveModifiers = 'css' | 'watch';
|
|
14
|
+
|
|
6
15
|
export interface ElementSize {
|
|
7
16
|
width: number;
|
|
8
17
|
height: number;
|
|
@@ -10,11 +19,8 @@ export interface ElementSize {
|
|
|
10
19
|
|
|
11
20
|
export type MeasureDirectiveListener = (size: ElementSize) => unknown;
|
|
12
21
|
|
|
13
|
-
export default defineDirective({
|
|
14
|
-
mounted(element: HTMLElement, { value }) {
|
|
15
|
-
// TODO replace with argument when typed properly
|
|
16
|
-
const modifiers = { css: true, watch: true };
|
|
17
|
-
|
|
22
|
+
export default defineDirective<MeasureDirectiveValue, MeasureDirectiveModifiers>({
|
|
23
|
+
mounted(element: HTMLElement, { value, modifiers }) {
|
|
18
24
|
const listener = typeof value === 'function' ? (value as MeasureDirectiveListener) : null;
|
|
19
25
|
const update = () => {
|
|
20
26
|
const sizes = element.getBoundingClientRect();
|
package/src/errors/Errors.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { JSError, facade, isDevelopment, isObject, isTesting, objectWithoutEmpty, toString } from '@noeldemartin/utils';
|
|
2
|
+
import { watchEffect } from 'vue';
|
|
3
|
+
import type Eruda from 'eruda';
|
|
2
4
|
|
|
3
5
|
import App from '@aerogel/core/services/App';
|
|
4
6
|
import ServiceBootError from '@aerogel/core/errors/ServiceBootError';
|
|
5
|
-
import UI
|
|
7
|
+
import UI from '@aerogel/core/ui/UI';
|
|
6
8
|
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
7
9
|
import { Events } from '@aerogel/core/services';
|
|
8
|
-
import type { ErrorReportModalProps } from '@aerogel/core/components/contracts/ErrorReportModal';
|
|
9
|
-
import type { ModalComponent } from '@aerogel/core/ui/UI.state';
|
|
10
10
|
|
|
11
11
|
import Service from './Errors.state';
|
|
12
12
|
import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
@@ -15,6 +15,7 @@ export class ErrorsService extends Service {
|
|
|
15
15
|
|
|
16
16
|
public forceReporting: boolean = false;
|
|
17
17
|
private enabled: boolean = true;
|
|
18
|
+
private eruda: typeof Eruda | null = null;
|
|
18
19
|
|
|
19
20
|
public enable(): void {
|
|
20
21
|
this.enabled = true;
|
|
@@ -24,18 +25,23 @@ export class ErrorsService extends Service {
|
|
|
24
25
|
this.enabled = false;
|
|
25
26
|
}
|
|
26
27
|
|
|
27
|
-
public async inspect(error: ErrorSource | ErrorReport[]): Promise<void
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (
|
|
28
|
+
public async inspect(error: ErrorSource | ErrorReport, reports?: ErrorReport[]): Promise<void>;
|
|
29
|
+
public async inspect(reports: ErrorReport[]): Promise<void>;
|
|
30
|
+
public async inspect(errorOrReports: ErrorSource | ErrorReport[], _reports?: ErrorReport[]): Promise<void> {
|
|
31
|
+
if (Array.isArray(errorOrReports) && errorOrReports.length === 0) {
|
|
31
32
|
UI.alert(translateWithDefault('errors.inspectEmpty', 'Nothing to inspect!'));
|
|
32
33
|
|
|
33
34
|
return;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const report = Array.isArray(errorOrReports)
|
|
38
|
+
? (errorOrReports[0] as ErrorReport)
|
|
39
|
+
: this.isErrorReport(errorOrReports)
|
|
40
|
+
? errorOrReports
|
|
41
|
+
: await this.createErrorReport(errorOrReports);
|
|
42
|
+
const reports = Array.isArray(errorOrReports) ? (errorOrReports as ErrorReport[]) : (_reports ?? [report]);
|
|
43
|
+
|
|
44
|
+
UI.modal(UI.requireComponent('error-report-modal'), { report, reports });
|
|
39
45
|
}
|
|
40
46
|
|
|
41
47
|
public async report(error: ErrorSource, message?: string): Promise<void> {
|
|
@@ -79,11 +85,7 @@ export class ErrorsService extends Service {
|
|
|
79
85
|
{
|
|
80
86
|
label: translateWithDefault('errors.viewDetails', 'View details'),
|
|
81
87
|
dismiss: true,
|
|
82
|
-
click: () =>
|
|
83
|
-
UI.openModal<ModalComponent<ErrorReportModalProps>>(
|
|
84
|
-
UI.requireComponent(UIComponents.ErrorReportModal),
|
|
85
|
-
{ reports: [report] },
|
|
86
|
-
),
|
|
88
|
+
click: () => UI.modal(UI.requireComponent('error-report-modal'), { report, reports: [report] }),
|
|
87
89
|
},
|
|
88
90
|
],
|
|
89
91
|
},
|
|
@@ -92,6 +94,19 @@ export class ErrorsService extends Service {
|
|
|
92
94
|
this.setState({ logs: [log].concat(this.logs) });
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
public reportDevelopmentError(error: ErrorSource, message?: string): void {
|
|
98
|
+
if (!isDevelopment()) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (message) {
|
|
103
|
+
// eslint-disable-next-line no-console
|
|
104
|
+
console.warn(message);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
this.logError(error);
|
|
108
|
+
}
|
|
109
|
+
|
|
95
110
|
public see(report: ErrorReport): void {
|
|
96
111
|
this.setState({
|
|
97
112
|
logs: this.logs.map((log) => {
|
|
@@ -107,12 +122,17 @@ export class ErrorsService extends Service {
|
|
|
107
122
|
});
|
|
108
123
|
}
|
|
109
124
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
125
|
+
protected override async boot(): Promise<void> {
|
|
126
|
+
watchEffect(async () => {
|
|
127
|
+
if (!this.debug) {
|
|
128
|
+
this.eruda?.destroy();
|
|
129
|
+
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
this.eruda ??= (await import('eruda')).default;
|
|
134
|
+
|
|
135
|
+
this.eruda.init();
|
|
116
136
|
});
|
|
117
137
|
}
|
|
118
138
|
|
|
@@ -125,6 +145,10 @@ export class ErrorsService extends Service {
|
|
|
125
145
|
}
|
|
126
146
|
}
|
|
127
147
|
|
|
148
|
+
private isErrorReport(error: unknown): error is ErrorReport {
|
|
149
|
+
return isObject(error) && 'title' in error;
|
|
150
|
+
}
|
|
151
|
+
|
|
128
152
|
private async createErrorReport(error: ErrorSource): Promise<ErrorReport> {
|
|
129
153
|
if (typeof error === 'string') {
|
|
130
154
|
return { title: error };
|
package/src/errors/index.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { App } from 'vue';
|
|
1
|
+
import type { App as AppInstance } from 'vue';
|
|
2
2
|
|
|
3
|
+
import App from '@aerogel/core/services/App';
|
|
3
4
|
import { bootServices } from '@aerogel/core/services';
|
|
4
5
|
import { definePlugin } from '@aerogel/core/plugins';
|
|
5
6
|
|
|
6
7
|
import Errors from './Errors';
|
|
8
|
+
import settings from './settings';
|
|
7
9
|
import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
8
10
|
|
|
9
11
|
export * from './utils';
|
|
@@ -19,7 +21,7 @@ const frameworkHandler: ErrorHandler = (error) => {
|
|
|
19
21
|
return true;
|
|
20
22
|
};
|
|
21
23
|
|
|
22
|
-
function setUpErrorHandler(app:
|
|
24
|
+
function setUpErrorHandler(app: AppInstance, baseHandler: ErrorHandler = () => false): void {
|
|
23
25
|
const errorHandler: ErrorHandler = (error) => baseHandler(error) || frameworkHandler(error);
|
|
24
26
|
|
|
25
27
|
app.config.errorHandler = errorHandler;
|
|
@@ -34,6 +36,8 @@ export default definePlugin({
|
|
|
34
36
|
async install(app, options) {
|
|
35
37
|
setUpErrorHandler(app, options.handleError);
|
|
36
38
|
|
|
39
|
+
settings.forEach((setting) => App.addSetting(setting));
|
|
40
|
+
|
|
37
41
|
await bootServices(app, services);
|
|
38
42
|
},
|
|
39
43
|
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Setting
|
|
3
|
+
title-id="debug-setting"
|
|
4
|
+
:title="$td('settings.debug', 'Debugging')"
|
|
5
|
+
:description="$td('settings.debugDescription', 'Enable debugging with [Eruda](https://eruda.liriliri.io/).')"
|
|
6
|
+
>
|
|
7
|
+
<Switch v-model="$errors.debug" aria-labelledby="debug-setting" />
|
|
8
|
+
</Setting>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import Setting from '@aerogel/core/components/ui/Setting.vue';
|
|
13
|
+
import Switch from '@aerogel/core/components/ui/Switch.vue';
|
|
14
|
+
</script>
|