@aerogel/core 0.0.0-next.d7394c3aa6aac799b0971e63819a8713d05a5123 → 0.0.0-next.e4c0d5bd2801fbe93545477ea515af53df69b522
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 +2038 -1801
- package/dist/aerogel-core.js +3432 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +31 -37
- package/src/bootstrap/bootstrap.test.ts +4 -7
- package/src/bootstrap/index.ts +25 -16
- package/src/bootstrap/options.ts +1 -1
- package/src/components/AppLayout.vue +14 -0
- package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
- package/src/components/AppOverlays.vue +9 -0
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +19 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +48 -0
- package/src/components/contracts/DropdownMenu.ts +25 -0
- package/src/components/contracts/ErrorReportModal.ts +33 -0
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +26 -0
- package/src/components/contracts/Modal.ts +21 -0
- package/src/components/contracts/PromptModal.ts +34 -0
- package/src/components/contracts/Select.ts +45 -0
- package/src/components/contracts/Toast.ts +15 -0
- package/src/components/contracts/index.ts +11 -0
- package/src/components/headless/HeadlessButton.vue +51 -0
- package/src/components/headless/HeadlessInput.vue +59 -0
- package/src/components/headless/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +7 -8
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
- package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +16 -25
- package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
- package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +10 -13
- package/src/components/headless/HeadlessModal.vue +57 -0
- package/src/components/headless/HeadlessModalContent.vue +30 -0
- package/src/components/headless/HeadlessModalDescription.vue +12 -0
- package/src/components/headless/HeadlessModalOverlay.vue +12 -0
- package/src/components/headless/HeadlessModalTitle.vue +12 -0
- package/src/components/headless/HeadlessSelect.vue +120 -0
- package/src/components/headless/{forms/AGHeadlessSelectError.vue → HeadlessSelectError.vue} +5 -6
- package/src/components/headless/HeadlessSelectLabel.vue +25 -0
- package/src/components/headless/HeadlessSelectOption.vue +34 -0
- package/src/components/headless/HeadlessSelectOptions.vue +42 -0
- package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
- package/src/components/headless/HeadlessSelectValue.vue +18 -0
- package/src/components/headless/HeadlessToast.vue +18 -0
- package/src/components/headless/HeadlessToastAction.vue +13 -0
- package/src/components/headless/index.ts +19 -3
- package/src/components/index.ts +6 -11
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +17 -0
- package/src/components/ui/Button.vue +100 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +50 -0
- package/src/components/ui/DropdownMenu.vue +32 -0
- package/src/components/ui/DropdownMenuOption.vue +22 -0
- package/src/components/ui/DropdownMenuOptions.vue +44 -0
- package/src/components/ui/EditableContent.vue +82 -0
- package/src/components/ui/ErrorLogs.vue +19 -0
- package/src/components/ui/ErrorLogsModal.vue +48 -0
- package/src/components/ui/ErrorMessage.vue +15 -0
- package/src/components/ui/ErrorReportModal.vue +73 -0
- package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +34 -27
- package/src/components/ui/ErrorReportModalTitle.vue +24 -0
- package/src/components/{forms/AGForm.vue → ui/Form.vue} +4 -5
- package/src/components/ui/Input.vue +56 -0
- package/src/components/ui/Link.vue +12 -0
- package/src/components/ui/LoadingModal.vue +34 -0
- package/src/components/ui/Markdown.vue +97 -0
- package/src/components/ui/Modal.vue +123 -0
- package/src/components/ui/ModalContext.vue +31 -0
- package/src/components/ui/ProgressBar.vue +51 -0
- package/src/components/ui/PromptModal.vue +38 -0
- package/src/components/ui/Select.vue +27 -0
- package/src/components/ui/SelectLabel.vue +17 -0
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +35 -0
- package/src/components/ui/SelectTrigger.vue +29 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +8 -8
- package/src/components/ui/Toast.vue +46 -0
- package/src/components/ui/index.ts +32 -0
- package/src/directives/index.ts +9 -5
- package/src/directives/measure.ts +12 -6
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +29 -27
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +9 -6
- package/src/errors/utils.ts +17 -1
- package/src/forms/{Form.test.ts → FormController.test.ts} +32 -8
- package/src/forms/{Form.ts → FormController.ts} +51 -40
- package/src/forms/index.ts +3 -3
- package/src/forms/utils.ts +40 -24
- package/src/forms/validation.ts +19 -0
- package/src/index.css +73 -0
- package/src/jobs/Job.ts +144 -2
- package/src/jobs/index.ts +4 -1
- package/src/jobs/listeners.ts +3 -0
- package/src/jobs/status.ts +4 -0
- package/src/lang/DefaultLangProvider.ts +7 -4
- package/src/lang/Lang.state.ts +1 -1
- package/src/lang/Lang.ts +5 -1
- package/src/lang/index.ts +12 -6
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/plugins/Plugin.ts +1 -1
- package/src/plugins/index.ts +10 -7
- package/src/services/App.state.ts +23 -4
- package/src/services/App.ts +16 -3
- package/src/services/Cache.ts +1 -1
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +16 -12
- package/src/services/Service.ts +116 -53
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +14 -5
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +4 -3
- package/src/testing/setup.ts +5 -19
- package/src/ui/UI.state.ts +8 -13
- package/src/ui/UI.ts +222 -128
- package/src/ui/index.ts +27 -28
- package/src/ui/utils.ts +1 -1
- package/src/utils/classes.ts +41 -0
- package/src/utils/composition/events.ts +4 -6
- package/src/utils/composition/forms.ts +20 -4
- 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 +33 -0
- package/src/utils/index.ts +5 -1
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +53 -6
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +38 -134
- 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/AGAppLayout.vue +0 -16
- package/src/components/AGAppOverlays.vue +0 -41
- package/src/components/AGAppSnackbars.vue +0 -13
- package/src/components/composition.ts +0 -23
- package/src/components/constants.ts +0 -8
- package/src/components/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -41
- package/src/components/forms/AGInput.vue +0 -40
- package/src/components/forms/AGSelect.story.vue +0 -46
- package/src/components/forms/AGSelect.vue +0 -60
- package/src/components/forms/index.ts +0 -5
- package/src/components/headless/forms/AGHeadlessButton.ts +0 -3
- package/src/components/headless/forms/AGHeadlessButton.vue +0 -62
- package/src/components/headless/forms/AGHeadlessInput.ts +0 -34
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -70
- package/src/components/headless/forms/AGHeadlessSelect.ts +0 -42
- package/src/components/headless/forms/AGHeadlessSelect.vue +0 -77
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -39
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
- package/src/components/headless/forms/composition.ts +0 -10
- package/src/components/headless/forms/index.ts +0 -18
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -34
- package/src/components/headless/modals/AGHeadlessModal.vue +0 -86
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/headless/modals/index.ts +0 -4
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
- package/src/components/headless/snackbars/index.ts +0 -40
- package/src/components/interfaces.ts +0 -24
- package/src/components/lib/AGErrorMessage.vue +0 -16
- package/src/components/lib/AGLink.vue +0 -9
- package/src/components/lib/AGMarkdown.vue +0 -41
- package/src/components/lib/AGMeasured.vue +0 -16
- package/src/components/lib/index.ts +0 -5
- package/src/components/modals/AGAlertModal.ts +0 -15
- package/src/components/modals/AGAlertModal.vue +0 -14
- package/src/components/modals/AGConfirmModal.ts +0 -33
- package/src/components/modals/AGConfirmModal.vue +0 -26
- package/src/components/modals/AGErrorReportModal.ts +0 -46
- package/src/components/modals/AGErrorReportModal.vue +0 -54
- package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
- package/src/components/modals/AGLoadingModal.ts +0 -23
- package/src/components/modals/AGLoadingModal.vue +0 -15
- package/src/components/modals/AGModal.ts +0 -10
- package/src/components/modals/AGModal.vue +0 -39
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalContext.vue +0 -22
- package/src/components/modals/AGModalTitle.vue +0 -9
- package/src/components/modals/AGPromptModal.ts +0 -36
- package/src/components/modals/AGPromptModal.vue +0 -34
- package/src/components/modals/index.ts +0 -17
- package/src/components/snackbars/AGSnackbar.vue +0 -36
- package/src/components/snackbars/index.ts +0 -3
- package/src/components/utils.ts +0 -10
- package/src/directives/initial-focus.ts +0 -11
- package/src/forms/composition.ts +0 -6
- package/src/main.histoire.ts +0 -1
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
- package/tailwind.config.js +0 -4
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -17
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- @vue-generic {import('@aerogel/core/ui/UI').ModalExposeResult<PromptModalExpose>} -->
|
|
3
|
+
<Modal v-slot="{ close }" :title="renderedTitle" persistent>
|
|
4
|
+
<Form :form @submit="close(form.draft)">
|
|
5
|
+
<Markdown v-if="renderedMessage" :text="renderedMessage" />
|
|
6
|
+
<Input
|
|
7
|
+
name="draft"
|
|
8
|
+
class="mt-2"
|
|
9
|
+
:placeholder
|
|
10
|
+
:label
|
|
11
|
+
/>
|
|
12
|
+
|
|
13
|
+
<div class="mt-4 flex flex-row-reverse gap-2">
|
|
14
|
+
<Button :variant="acceptVariant" submit>
|
|
15
|
+
{{ renderedAcceptText }}
|
|
16
|
+
</Button>
|
|
17
|
+
<Button :variant="cancelVariant" @click="close()">
|
|
18
|
+
{{ renderedCancelText }}
|
|
19
|
+
</Button>
|
|
20
|
+
</div>
|
|
21
|
+
</Form>
|
|
22
|
+
</Modal>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<script setup lang="ts">
|
|
26
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
27
|
+
import Button from '@aerogel/core/components/ui/Button.vue';
|
|
28
|
+
import Form from '@aerogel/core/components/ui/Form.vue';
|
|
29
|
+
import Input from '@aerogel/core/components/ui/Input.vue';
|
|
30
|
+
import Modal from '@aerogel/core/components/ui/Modal.vue';
|
|
31
|
+
import { usePromptModal } from '@aerogel/core/components/contracts/PromptModal';
|
|
32
|
+
import type { PromptModalExpose, PromptModalProps } from '@aerogel/core/components/contracts/PromptModal';
|
|
33
|
+
|
|
34
|
+
const { cancelVariant = 'secondary', ...props } = defineProps<PromptModalProps>();
|
|
35
|
+
const { form, renderedTitle, renderedMessage, renderedAcceptText, renderedCancelText } = usePromptModal(props);
|
|
36
|
+
|
|
37
|
+
defineExpose<PromptModalExpose>();
|
|
38
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessSelect :ref="forwardRef" v-bind="$props" @update:model-value="$emit('update:modelValue', $event)">
|
|
3
|
+
<SelectLabel />
|
|
4
|
+
<slot>
|
|
5
|
+
<SelectTrigger />
|
|
6
|
+
<SelectOptions />
|
|
7
|
+
</slot>
|
|
8
|
+
</HeadlessSelect>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
|
|
12
|
+
import { useForwardExpose } from 'reka-ui';
|
|
13
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
14
|
+
|
|
15
|
+
import HeadlessSelect from '@aerogel/core/components/headless/HeadlessSelect.vue';
|
|
16
|
+
import type { SelectEmits, SelectProps } from '@aerogel/core/components/contracts/Select';
|
|
17
|
+
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
18
|
+
|
|
19
|
+
import SelectLabel from './SelectLabel.vue';
|
|
20
|
+
import SelectOptions from './SelectOptions.vue';
|
|
21
|
+
import SelectTrigger from './SelectTrigger.vue';
|
|
22
|
+
|
|
23
|
+
defineProps<SelectProps<T>>();
|
|
24
|
+
defineEmits<SelectEmits<T>>();
|
|
25
|
+
|
|
26
|
+
const { forwardRef } = useForwardExpose();
|
|
27
|
+
</script>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessSelectLabel v-if="$slots.default" :class="renderedClasses">
|
|
3
|
+
<slot />
|
|
4
|
+
</HeadlessSelectLabel>
|
|
5
|
+
<HeadlessSelectLabel v-else :class="renderedClasses" />
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { computed } from 'vue';
|
|
10
|
+
|
|
11
|
+
import HeadlessSelectLabel from '@aerogel/core/components/headless/HeadlessSelectLabel.vue';
|
|
12
|
+
import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
|
|
13
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
14
|
+
|
|
15
|
+
const select = injectReactiveOrFail<SelectExpose>('select', '<SelectLabel> must be a child of a <Select>');
|
|
16
|
+
const renderedClasses = computed(() => classes('block text-sm leading-6 font-medium text-gray-900', select.labelClass));
|
|
17
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessSelectOption :class="renderedOuterClasses" :value>
|
|
3
|
+
<div :class="renderedInnerClasses">
|
|
4
|
+
<slot />
|
|
5
|
+
</div>
|
|
6
|
+
</HeadlessSelectOption>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed } from 'vue';
|
|
11
|
+
import type { AcceptableValue } from 'reka-ui';
|
|
12
|
+
import type { HTMLAttributes } from 'vue';
|
|
13
|
+
|
|
14
|
+
import HeadlessSelectOption from '@aerogel/core/components/headless/HeadlessSelectOption.vue';
|
|
15
|
+
import { classes } from '@aerogel/core/utils';
|
|
16
|
+
|
|
17
|
+
const { class: outerClass, innerClass } = defineProps<{
|
|
18
|
+
value: AcceptableValue;
|
|
19
|
+
class?: HTMLAttributes['class'];
|
|
20
|
+
innerClass?: HTMLAttributes['class'];
|
|
21
|
+
}>();
|
|
22
|
+
const renderedOuterClasses = computed(() => classes('group p-1 outline-none', outerClass));
|
|
23
|
+
const renderedInnerClasses = computed(() =>
|
|
24
|
+
classes(
|
|
25
|
+
// eslint-disable-next-line vue/max-len
|
|
26
|
+
'relative flex max-w-[calc(100vw-2rem)] cursor-pointer items-center truncate rounded-md gap-2 px-2 py-1 text-sm select-none *:truncate group-data-[highlighted]:bg-gray-100 group-data-[state=checked]:font-semibold group-data-[state=unchecked]:opacity-50',
|
|
27
|
+
innerClass,
|
|
28
|
+
));
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessSelectOptions :class="renderedClasses">
|
|
3
|
+
<slot v-if="select.options?.length">
|
|
4
|
+
<SelectOption v-for="option of select?.options ?? []" :key="option.key" :value="option.value">
|
|
5
|
+
{{ option.label }}
|
|
6
|
+
</SelectOption>
|
|
7
|
+
</slot>
|
|
8
|
+
<slot v-else>
|
|
9
|
+
<SelectOption disabled :value="null">
|
|
10
|
+
{{ $td('ui.selectEmpty', 'No options available') }}
|
|
11
|
+
</SelectOption>
|
|
12
|
+
</slot>
|
|
13
|
+
</HeadlessSelectOptions>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { computed } from 'vue';
|
|
18
|
+
import type { HTMLAttributes } from 'vue';
|
|
19
|
+
|
|
20
|
+
import HeadlessSelectOptions from '@aerogel/core/components/headless/HeadlessSelectOptions.vue';
|
|
21
|
+
import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
|
|
22
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
23
|
+
|
|
24
|
+
import SelectOption from './SelectOption.vue';
|
|
25
|
+
|
|
26
|
+
const { class: rootClasses } = defineProps<{ class?: HTMLAttributes['class'] }>();
|
|
27
|
+
|
|
28
|
+
const select = injectReactiveOrFail<SelectExpose>('select', '<SelectOptions> must be a child of a <Select>');
|
|
29
|
+
const renderedClasses = computed(() =>
|
|
30
|
+
classes(
|
|
31
|
+
'z-50 overflow-auto rounded-lg bg-white text-base shadow-lg ring-1 ring-black/5 focus:outline-hidden',
|
|
32
|
+
select.optionsClass,
|
|
33
|
+
rootClasses,
|
|
34
|
+
));
|
|
35
|
+
</script>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessSelectTrigger :class="renderedClasses">
|
|
3
|
+
<HeadlessSelectValue class="col-start-1 row-start-1 truncate pr-6" />
|
|
4
|
+
<IconCheveronDown class="col-start-1 row-start-1 size-5 self-center justify-self-end text-gray-500 sm:size-4" />
|
|
5
|
+
</HeadlessSelectTrigger>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import IconCheveronDown from '~icons/zondicons/cheveron-down';
|
|
10
|
+
|
|
11
|
+
import { computed } from 'vue';
|
|
12
|
+
import type { HTMLAttributes } from 'vue';
|
|
13
|
+
|
|
14
|
+
import HeadlessSelectTrigger from '@aerogel/core/components/headless/HeadlessSelectTrigger.vue';
|
|
15
|
+
import HeadlessSelectValue from '@aerogel/core/components/headless/HeadlessSelectValue.vue';
|
|
16
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils';
|
|
17
|
+
import { classes } from '@aerogel/core/utils/classes';
|
|
18
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
19
|
+
|
|
20
|
+
const { class: rootClasses } = defineProps<{ class?: HTMLAttributes['class'] }>();
|
|
21
|
+
const select = injectReactiveOrFail<SelectExpose>('select', '<SelectTrigger> must be a child of a <Select>');
|
|
22
|
+
const renderedClasses = computed(() =>
|
|
23
|
+
classes(
|
|
24
|
+
// eslint-disable-next-line vue/max-len
|
|
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
|
+
{ 'mt-1': select.label },
|
|
27
|
+
rootClasses,
|
|
28
|
+
));
|
|
29
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal :title="$td('settings.title', 'Settings')">
|
|
3
|
+
<component :is="setting.component" v-for="(setting, key) in settings" :key />
|
|
4
|
+
</Modal>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { arraySorted } from '@noeldemartin/utils';
|
|
9
|
+
import { computed } from 'vue';
|
|
10
|
+
|
|
11
|
+
import App from '@aerogel/core/services/App';
|
|
12
|
+
import Modal from '@aerogel/core/components/ui/Modal.vue';
|
|
13
|
+
|
|
14
|
+
const settings = computed(() => arraySorted(App.settings, 'priority', 'desc'));
|
|
15
|
+
</script>
|
|
@@ -1,10 +1,10 @@
|
|
|
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!') }}
|
|
6
6
|
</h1>
|
|
7
|
-
<
|
|
7
|
+
<Markdown
|
|
8
8
|
:text="
|
|
9
9
|
$td(
|
|
10
10
|
'startupCrash.message',
|
|
@@ -14,18 +14,18 @@
|
|
|
14
14
|
class="mt-4 text-center"
|
|
15
15
|
/>
|
|
16
16
|
<div class="mt-4 flex flex-col space-y-4">
|
|
17
|
-
<
|
|
17
|
+
<Button variant="danger" @click="$app.reload()">
|
|
18
18
|
{{ $td('startupCrash.reload', 'Try again') }}
|
|
19
|
-
</
|
|
20
|
-
<
|
|
19
|
+
</Button>
|
|
20
|
+
<Button variant="danger" @click="$errors.inspect($errors.startupErrors)">
|
|
21
21
|
{{ $td('startupCrash.inspect', 'View error details') }}
|
|
22
|
-
</
|
|
22
|
+
</Button>
|
|
23
23
|
</div>
|
|
24
24
|
</div>
|
|
25
25
|
</div>
|
|
26
26
|
</template>
|
|
27
27
|
|
|
28
28
|
<script setup lang="ts">
|
|
29
|
-
import
|
|
30
|
-
import
|
|
29
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
30
|
+
import Button from '@aerogel/core/components/ui/Button.vue';
|
|
31
31
|
</script>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<HeadlessToast :class="renderedClasses">
|
|
3
|
+
<Markdown v-if="message" :text="message" inline />
|
|
4
|
+
|
|
5
|
+
<Button
|
|
6
|
+
v-for="(action, key) of actions"
|
|
7
|
+
:key
|
|
8
|
+
:action
|
|
9
|
+
:variant
|
|
10
|
+
:as="HeadlessToastAction"
|
|
11
|
+
/>
|
|
12
|
+
</HeadlessToast>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { computed } from 'vue';
|
|
17
|
+
import type { HTMLAttributes } from 'vue';
|
|
18
|
+
|
|
19
|
+
import Button from '@aerogel/core/components/ui/Button.vue';
|
|
20
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
21
|
+
import HeadlessToast from '@aerogel/core/components/headless/HeadlessToast.vue';
|
|
22
|
+
import HeadlessToastAction from '@aerogel/core/components/headless/HeadlessToastAction.vue';
|
|
23
|
+
import { variantClasses } from '@aerogel/core/utils/classes';
|
|
24
|
+
import type { ToastExpose, ToastProps } from '@aerogel/core/components/contracts/Toast';
|
|
25
|
+
import type { Variants } from '@aerogel/core/utils/classes';
|
|
26
|
+
|
|
27
|
+
const { class: baseClasses, variant = 'secondary' } = defineProps<ToastProps & { class?: HTMLAttributes['class'] }>();
|
|
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',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
));
|
|
44
|
+
|
|
45
|
+
defineExpose<ToastExpose>();
|
|
46
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export { default as AdvancedOptions } from './AdvancedOptions.vue';
|
|
2
|
+
export { default as AlertModal } from './AlertModal.vue';
|
|
3
|
+
export { default as Button } from './Button.vue';
|
|
4
|
+
export { default as Checkbox } from './Checkbox.vue';
|
|
5
|
+
export { default as ConfirmModal } from './ConfirmModal.vue';
|
|
6
|
+
export { default as DropdownMenu } from './DropdownMenu.vue';
|
|
7
|
+
export { default as DropdownMenuOption } from './DropdownMenuOption.vue';
|
|
8
|
+
export { default as DropdownMenuOptions } from './DropdownMenuOptions.vue';
|
|
9
|
+
export { default as EditableContent } from './EditableContent.vue';
|
|
10
|
+
export { default as ErrorLogs } from './ErrorLogs.vue';
|
|
11
|
+
export { default as ErrorLogsModal } from './ErrorLogsModal.vue';
|
|
12
|
+
export { default as ErrorMessage } from './ErrorMessage.vue';
|
|
13
|
+
export { default as ErrorReportModal } from './ErrorReportModal.vue';
|
|
14
|
+
export { default as ErrorReportModalButtons } from './ErrorReportModalButtons.vue';
|
|
15
|
+
export { default as ErrorReportModalTitle } from './ErrorReportModalTitle.vue';
|
|
16
|
+
export { default as Form } from './Form.vue';
|
|
17
|
+
export { default as Input } from './Input.vue';
|
|
18
|
+
export { default as Link } from './Link.vue';
|
|
19
|
+
export { default as LoadingModal } from './LoadingModal.vue';
|
|
20
|
+
export { default as Markdown } from './Markdown.vue';
|
|
21
|
+
export { default as Modal } from './Modal.vue';
|
|
22
|
+
export { default as ModalContext } from './ModalContext.vue';
|
|
23
|
+
export { default as ProgressBar } from './ProgressBar.vue';
|
|
24
|
+
export { default as PromptModal } from './PromptModal.vue';
|
|
25
|
+
export { default as Select } from './Select.vue';
|
|
26
|
+
export { default as SelectLabel } from './SelectLabel.vue';
|
|
27
|
+
export { default as SelectOption } from './SelectOption.vue';
|
|
28
|
+
export { default as SelectOptions } from './SelectOptions.vue';
|
|
29
|
+
export { default as SelectTrigger } from './SelectTrigger.vue';
|
|
30
|
+
export { default as SettingsModal } from './SettingsModal.vue';
|
|
31
|
+
export { default as StartupCrash } from './StartupCrash.vue';
|
|
32
|
+
export { default as Toast } from './Toast.vue';
|
package/src/directives/index.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { Directive } from 'vue';
|
|
2
2
|
|
|
3
|
-
import { definePlugin } from '
|
|
3
|
+
import { definePlugin } from '@aerogel/core/plugins';
|
|
4
4
|
|
|
5
|
-
import initialFocus from './initial-focus';
|
|
6
5
|
import measure from './measure';
|
|
7
6
|
|
|
8
7
|
const builtInDirectives: Record<string, Directive> = {
|
|
9
|
-
|
|
10
|
-
'measure': measure,
|
|
8
|
+
measure: measure,
|
|
11
9
|
};
|
|
12
10
|
|
|
13
11
|
export * from './measure';
|
|
@@ -25,8 +23,14 @@ export default definePlugin({
|
|
|
25
23
|
},
|
|
26
24
|
});
|
|
27
25
|
|
|
28
|
-
declare module '
|
|
26
|
+
declare module '@aerogel/core/bootstrap/options' {
|
|
29
27
|
export interface AerogelOptions {
|
|
30
28
|
directives?: Record<string, Directive>;
|
|
31
29
|
}
|
|
32
30
|
}
|
|
31
|
+
|
|
32
|
+
declare module 'vue' {
|
|
33
|
+
interface ComponentCustomDirectives {
|
|
34
|
+
measure: Directive<string, string>;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import { defineDirective } from '
|
|
1
|
+
import { defineDirective } from '@aerogel/core/utils/vue';
|
|
2
2
|
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,16 +1,13 @@
|
|
|
1
|
-
import { JSError, facade, isObject, objectWithoutEmpty, toString } from '@noeldemartin/utils';
|
|
1
|
+
import { JSError, facade, isDevelopment, isObject, isTesting, objectWithoutEmpty, toString } from '@noeldemartin/utils';
|
|
2
2
|
|
|
3
|
-
import App from '
|
|
4
|
-
import ServiceBootError from '
|
|
5
|
-
import UI
|
|
6
|
-
import { translateWithDefault } from '
|
|
3
|
+
import App from '@aerogel/core/services/App';
|
|
4
|
+
import ServiceBootError from '@aerogel/core/errors/ServiceBootError';
|
|
5
|
+
import UI from '@aerogel/core/ui/UI';
|
|
6
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
7
|
+
import { Events } from '@aerogel/core/services';
|
|
7
8
|
|
|
8
9
|
import Service from './Errors.state';
|
|
9
|
-
import { Colors } from '@/components/constants';
|
|
10
|
-
import { Events } from '@/services';
|
|
11
|
-
import type { AGErrorReportModalProps } from '@/components/modals/AGErrorReportModal';
|
|
12
10
|
import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
13
|
-
import type { ModalComponent } from '@/ui/UI.state';
|
|
14
11
|
|
|
15
12
|
export class ErrorsService extends Service {
|
|
16
13
|
|
|
@@ -25,28 +22,33 @@ export class ErrorsService extends Service {
|
|
|
25
22
|
this.enabled = false;
|
|
26
23
|
}
|
|
27
24
|
|
|
28
|
-
public async inspect(error: ErrorSource | ErrorReport[]): Promise<void
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (
|
|
25
|
+
public async inspect(error: ErrorSource | ErrorReport, reports?: ErrorReport[]): Promise<void>;
|
|
26
|
+
public async inspect(reports: ErrorReport[]): Promise<void>;
|
|
27
|
+
public async inspect(errorOrReports: ErrorSource | ErrorReport[], _reports?: ErrorReport[]): Promise<void> {
|
|
28
|
+
if (Array.isArray(errorOrReports) && errorOrReports.length === 0) {
|
|
32
29
|
UI.alert(translateWithDefault('errors.inspectEmpty', 'Nothing to inspect!'));
|
|
33
30
|
|
|
34
31
|
return;
|
|
35
32
|
}
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
34
|
+
const report = Array.isArray(errorOrReports)
|
|
35
|
+
? (errorOrReports[0] as ErrorReport)
|
|
36
|
+
: this.isErrorReport(errorOrReports)
|
|
37
|
+
? errorOrReports
|
|
38
|
+
: await this.createErrorReport(errorOrReports);
|
|
39
|
+
const reports = Array.isArray(errorOrReports) ? (errorOrReports as ErrorReport[]) : (_reports ?? [report]);
|
|
40
|
+
|
|
41
|
+
UI.modal(UI.requireComponent('error-report-modal'), { report, reports });
|
|
40
42
|
}
|
|
41
43
|
|
|
42
44
|
public async report(error: ErrorSource, message?: string): Promise<void> {
|
|
43
45
|
await Events.emit('error', { error, message });
|
|
44
46
|
|
|
45
|
-
if (
|
|
47
|
+
if (isTesting('unit')) {
|
|
46
48
|
throw error;
|
|
47
49
|
}
|
|
48
50
|
|
|
49
|
-
if (
|
|
51
|
+
if (isDevelopment()) {
|
|
50
52
|
this.logError(error);
|
|
51
53
|
}
|
|
52
54
|
|
|
@@ -71,20 +73,16 @@ export class ErrorsService extends Service {
|
|
|
71
73
|
date: new Date(),
|
|
72
74
|
};
|
|
73
75
|
|
|
74
|
-
UI.
|
|
76
|
+
UI.toast(
|
|
75
77
|
message ??
|
|
76
78
|
translateWithDefault('errors.notice', 'Something went wrong, but it\'s not your fault. Try again!'),
|
|
77
79
|
{
|
|
78
|
-
|
|
80
|
+
variant: 'danger',
|
|
79
81
|
actions: [
|
|
80
82
|
{
|
|
81
|
-
|
|
83
|
+
label: translateWithDefault('errors.viewDetails', 'View details'),
|
|
82
84
|
dismiss: true,
|
|
83
|
-
|
|
84
|
-
UI.openModal<ModalComponent<AGErrorReportModalProps>>(
|
|
85
|
-
UI.requireComponent(UIComponents.ErrorReportModal),
|
|
86
|
-
{ reports: [report] },
|
|
87
|
-
),
|
|
85
|
+
click: () => UI.modal(UI.requireComponent('error-report-modal'), { report, reports: [report] }),
|
|
88
86
|
},
|
|
89
87
|
],
|
|
90
88
|
},
|
|
@@ -126,6 +124,10 @@ export class ErrorsService extends Service {
|
|
|
126
124
|
}
|
|
127
125
|
}
|
|
128
126
|
|
|
127
|
+
private isErrorReport(error: unknown): error is ErrorReport {
|
|
128
|
+
return isObject(error) && 'title' in error;
|
|
129
|
+
}
|
|
130
|
+
|
|
129
131
|
private async createErrorReport(error: ErrorSource): Promise<ErrorReport> {
|
|
130
132
|
if (typeof error === 'string') {
|
|
131
133
|
return { title: error };
|
|
@@ -178,7 +180,7 @@ export class ErrorsService extends Service {
|
|
|
178
180
|
|
|
179
181
|
export default facade(ErrorsService);
|
|
180
182
|
|
|
181
|
-
declare module '
|
|
183
|
+
declare module '@aerogel/core/services/Events' {
|
|
182
184
|
export interface EventsPayload {
|
|
183
185
|
error: { error: ErrorSource; message?: string };
|
|
184
186
|
}
|
package/src/errors/index.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import type { App } from 'vue';
|
|
2
2
|
|
|
3
|
-
import { bootServices } from '
|
|
4
|
-
import { definePlugin } from '
|
|
3
|
+
import { bootServices } from '@aerogel/core/services';
|
|
4
|
+
import { definePlugin } from '@aerogel/core/plugins';
|
|
5
5
|
|
|
6
6
|
import Errors from './Errors';
|
|
7
|
-
import { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
7
|
+
import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
8
8
|
|
|
9
9
|
export * from './utils';
|
|
10
|
-
export { Errors
|
|
10
|
+
export { Errors };
|
|
11
|
+
export { default as JobCancelledError } from './JobCancelledError';
|
|
12
|
+
export { default as ServiceBootError } from './ServiceBootError';
|
|
13
|
+
export type { ErrorSource, ErrorReport, ErrorReportLog };
|
|
11
14
|
|
|
12
15
|
const services = { $errors: Errors };
|
|
13
16
|
const frameworkHandler: ErrorHandler = (error) => {
|
|
@@ -35,12 +38,12 @@ export default definePlugin({
|
|
|
35
38
|
},
|
|
36
39
|
});
|
|
37
40
|
|
|
38
|
-
declare module '
|
|
41
|
+
declare module '@aerogel/core/bootstrap/options' {
|
|
39
42
|
export interface AerogelOptions {
|
|
40
43
|
handleError?(error: ErrorSource): boolean;
|
|
41
44
|
}
|
|
42
45
|
}
|
|
43
46
|
|
|
44
|
-
declare module '
|
|
47
|
+
declare module '@aerogel/core/services' {
|
|
45
48
|
export interface Services extends ErrorsServices {}
|
|
46
49
|
}
|
package/src/errors/utils.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
1
|
import { JSError, isObject, toString } from '@noeldemartin/utils';
|
|
2
|
-
import { translateWithDefault } from '
|
|
2
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
3
3
|
import type { ErrorSource } from './Errors.state';
|
|
4
4
|
|
|
5
|
+
const handlers: ErrorHandler[] = [];
|
|
6
|
+
|
|
7
|
+
export type ErrorHandler = (error: ErrorSource) => string | undefined;
|
|
8
|
+
|
|
9
|
+
export function registerErrorHandler(handler: ErrorHandler): void {
|
|
10
|
+
handlers.push(handler);
|
|
11
|
+
}
|
|
12
|
+
|
|
5
13
|
export function getErrorMessage(error: ErrorSource): string {
|
|
14
|
+
for (const handler of handlers) {
|
|
15
|
+
const result = handler(error);
|
|
16
|
+
|
|
17
|
+
if (result) {
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
if (typeof error === 'string') {
|
|
7
23
|
return error;
|
|
8
24
|
}
|
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
2
|
+
import { tt } from '@noeldemartin/testing';
|
|
3
|
+
import type { Equals } from '@noeldemartin/utils';
|
|
4
|
+
import type { Expect } from '@noeldemartin/testing';
|
|
2
5
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
import {
|
|
7
|
+
numberInput,
|
|
8
|
+
objectInput,
|
|
9
|
+
requiredObjectInput,
|
|
10
|
+
requiredStringInput,
|
|
11
|
+
stringInput,
|
|
12
|
+
} from '@aerogel/core/forms/utils';
|
|
13
|
+
import { useForm } from '@aerogel/core/utils/composition/forms';
|
|
6
14
|
|
|
7
|
-
describe('
|
|
15
|
+
describe('FormController', () => {
|
|
8
16
|
|
|
9
17
|
it('defines magic fields', () => {
|
|
10
18
|
const form = useForm({
|
|
@@ -20,7 +28,7 @@ describe('Form', () => {
|
|
|
20
28
|
// Arrange
|
|
21
29
|
const form = useForm({
|
|
22
30
|
name: {
|
|
23
|
-
type:
|
|
31
|
+
type: 'string',
|
|
24
32
|
rules: 'required',
|
|
25
33
|
},
|
|
26
34
|
});
|
|
@@ -38,7 +46,7 @@ describe('Form', () => {
|
|
|
38
46
|
// Arrange
|
|
39
47
|
const form = useForm({
|
|
40
48
|
name: {
|
|
41
|
-
type:
|
|
49
|
+
type: 'string',
|
|
42
50
|
rules: 'required',
|
|
43
51
|
},
|
|
44
52
|
});
|
|
@@ -59,11 +67,11 @@ describe('Form', () => {
|
|
|
59
67
|
// Arrange
|
|
60
68
|
const form = useForm({
|
|
61
69
|
trimmed: {
|
|
62
|
-
type:
|
|
70
|
+
type: 'string',
|
|
63
71
|
rules: 'required',
|
|
64
72
|
},
|
|
65
73
|
untrimmed: {
|
|
66
|
-
type:
|
|
74
|
+
type: 'string',
|
|
67
75
|
rules: 'required',
|
|
68
76
|
trim: false,
|
|
69
77
|
},
|
|
@@ -83,4 +91,20 @@ describe('Form', () => {
|
|
|
83
91
|
expect(form.errors).toEqual({ trimmed: ['required'], untrimmed: null });
|
|
84
92
|
});
|
|
85
93
|
|
|
94
|
+
it('infers field types', () => {
|
|
95
|
+
const form = useForm({
|
|
96
|
+
one: stringInput(),
|
|
97
|
+
two: requiredStringInput(),
|
|
98
|
+
three: objectInput(),
|
|
99
|
+
four: requiredObjectInput<{ foo: string; bar?: number }>(),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
tt<
|
|
103
|
+
| Expect<Equals<typeof form.one, string | null>>
|
|
104
|
+
| Expect<Equals<typeof form.two, string>>
|
|
105
|
+
| Expect<Equals<typeof form.three, object | null>>
|
|
106
|
+
| Expect<Equals<typeof form.four, { foo: string; bar?: number }>>
|
|
107
|
+
>();
|
|
108
|
+
});
|
|
109
|
+
|
|
86
110
|
});
|