@aerogel/core 0.0.0-next.c33ad773d3eb977461630ff22012d99eeedf46cb → 0.0.0-next.c38a10cd5e81c5f04469ef79e59a53e6bfd3df55
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 +895 -814
- package/dist/aerogel-core.js +2412 -1829
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +7 -2
- 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 +17 -3
- package/src/components/contracts/ErrorReportModal.ts +8 -4
- package/src/components/contracts/Input.ts +7 -7
- package/src/components/contracts/LoadingModal.ts +12 -4
- package/src/components/contracts/Modal.ts +12 -4
- package/src/components/contracts/PromptModal.ts +8 -2
- package/src/components/contracts/Select.ts +22 -10
- package/src/components/contracts/Toast.ts +4 -2
- package/src/components/contracts/index.ts +3 -1
- package/src/components/headless/HeadlessButton.vue +2 -1
- package/src/components/headless/HeadlessInput.vue +3 -3
- package/src/components/headless/HeadlessInputInput.vue +19 -8
- package/src/components/headless/HeadlessInputTextArea.vue +4 -4
- package/src/components/headless/HeadlessModal.vue +22 -51
- package/src/components/headless/HeadlessModalContent.vue +11 -5
- package/src/components/headless/HeadlessModalDescription.vue +12 -0
- package/src/components/headless/HeadlessSelect.vue +50 -22
- package/src/components/headless/HeadlessSelectOption.vue +1 -1
- package/src/components/headless/HeadlessSelectOptions.vue +16 -4
- package/src/components/headless/HeadlessSelectValue.vue +4 -1
- package/src/components/headless/HeadlessSwitch.vue +96 -0
- package/src/components/headless/index.ts +2 -0
- package/src/components/index.ts +2 -1
- package/src/components/ui/AdvancedOptions.vue +1 -1
- package/src/components/ui/AlertModal.vue +7 -3
- package/src/components/ui/Button.vue +33 -16
- package/src/components/ui/Checkbox.vue +5 -5
- package/src/components/ui/ConfirmModal.vue +12 -4
- package/src/components/ui/DropdownMenu.vue +18 -19
- package/src/components/ui/DropdownMenuOption.vue +22 -0
- package/src/components/ui/DropdownMenuOptions.vue +44 -0
- package/src/components/ui/EditableContent.vue +4 -4
- 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 +6 -6
- package/src/components/ui/LoadingModal.vue +6 -4
- package/src/components/ui/Markdown.vue +31 -3
- package/src/components/ui/Modal.vue +83 -22
- package/src/components/ui/ModalContext.vue +2 -1
- package/src/components/ui/ProgressBar.vue +9 -8
- package/src/components/ui/PromptModal.vue +8 -5
- package/src/components/ui/Select.vue +15 -41
- package/src/components/ui/SelectLabel.vue +21 -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/Setting.vue +31 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/ui/Switch.vue +11 -0
- package/src/components/ui/TextArea.vue +56 -0
- package/src/components/ui/Toast.vue +20 -16
- package/src/components/ui/index.ts +13 -1
- package/src/directives/measure.ts +11 -5
- package/src/errors/Errors.ts +18 -15
- package/src/errors/index.ts +6 -2
- package/src/errors/settings/Debug.vue +32 -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 +40 -5
- package/src/lang/index.ts +5 -1
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/services/App.state.ts +11 -1
- package/src/services/App.ts +9 -1
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +2 -8
- package/src/services/index.ts +5 -2
- package/src/testing/index.ts +4 -0
- package/src/ui/UI.state.ts +3 -13
- package/src/ui/UI.ts +107 -83
- package/src/ui/index.ts +16 -17
- package/src/utils/classes.ts +41 -0
- package/src/utils/composition/events.ts +2 -4
- package/src/utils/composition/forms.ts +16 -1
- package/src/utils/composition/state.ts +11 -2
- package/src/utils/index.ts +3 -1
- package/src/utils/markdown.ts +35 -1
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +28 -125
- package/src/components/composition.ts +0 -23
- package/src/components/contracts/shared.ts +0 -9
- package/src/components/utils.ts +0 -107
- package/src/forms/composition.ts +0 -6
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
- package/src/utils/vdom.ts +0 -31
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
import type { HTMLAttributes } from 'vue';
|
|
11
|
+
|
|
12
|
+
import HeadlessSelectLabel from '@aerogel/core/components/headless/HeadlessSelectLabel.vue';
|
|
13
|
+
import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
|
|
14
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
15
|
+
|
|
16
|
+
const { class: rootClasses } = defineProps<{ class?: HTMLAttributes['class'] }>();
|
|
17
|
+
|
|
18
|
+
const select = injectReactiveOrFail<SelectExpose>('select', '<SelectLabel> must be a child of a <Select>');
|
|
19
|
+
const renderedClasses = computed(() =>
|
|
20
|
+
classes('block text-sm leading-6 font-medium text-gray-900', select.labelClass, rootClasses));
|
|
21
|
+
</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,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>
|
|
@@ -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>
|
|
@@ -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';
|
|
24
|
-
import type { Variants } from '@aerogel/core/
|
|
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';
|
|
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>
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
export { default as AlertModal } from './AlertModal.vue';
|
|
2
1
|
export { default as AdvancedOptions } from './AdvancedOptions.vue';
|
|
2
|
+
export { default as AlertModal } from './AlertModal.vue';
|
|
3
3
|
export { default as Button } from './Button.vue';
|
|
4
4
|
export { default as Checkbox } from './Checkbox.vue';
|
|
5
5
|
export { default as ConfirmModal } from './ConfirmModal.vue';
|
|
6
6
|
export { default as DropdownMenu } from './DropdownMenu.vue';
|
|
7
|
+
export { default as DropdownMenuOption } from './DropdownMenuOption.vue';
|
|
8
|
+
export { default as DropdownMenuOptions } from './DropdownMenuOptions.vue';
|
|
7
9
|
export { default as EditableContent } from './EditableContent.vue';
|
|
10
|
+
export { default as ErrorLogs } from './ErrorLogs.vue';
|
|
11
|
+
export { default as ErrorLogsModal } from './ErrorLogsModal.vue';
|
|
8
12
|
export { default as ErrorMessage } from './ErrorMessage.vue';
|
|
9
13
|
export { default as ErrorReportModal } from './ErrorReportModal.vue';
|
|
10
14
|
export { default as ErrorReportModalButtons } from './ErrorReportModalButtons.vue';
|
|
@@ -19,5 +23,13 @@ export { default as ModalContext } from './ModalContext.vue';
|
|
|
19
23
|
export { default as ProgressBar } from './ProgressBar.vue';
|
|
20
24
|
export { default as PromptModal } from './PromptModal.vue';
|
|
21
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 Setting } from './Setting.vue';
|
|
31
|
+
export { default as SettingsModal } from './SettingsModal.vue';
|
|
22
32
|
export { default as StartupCrash } from './StartupCrash.vue';
|
|
33
|
+
export { default as Switch } from './Switch.vue';
|
|
34
|
+
export { default as TextArea } from './TextArea.vue';
|
|
23
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
|
@@ -2,11 +2,9 @@ import { JSError, facade, isDevelopment, isObject, isTesting, objectWithoutEmpty
|
|
|
2
2
|
|
|
3
3
|
import App from '@aerogel/core/services/App';
|
|
4
4
|
import ServiceBootError from '@aerogel/core/errors/ServiceBootError';
|
|
5
|
-
import UI
|
|
5
|
+
import UI from '@aerogel/core/ui/UI';
|
|
6
6
|
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
7
7
|
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
8
|
|
|
11
9
|
import Service from './Errors.state';
|
|
12
10
|
import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
|
|
@@ -24,18 +22,23 @@ export class ErrorsService extends Service {
|
|
|
24
22
|
this.enabled = false;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
public async inspect(error: ErrorSource | ErrorReport[]): Promise<void
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
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) {
|
|
31
29
|
UI.alert(translateWithDefault('errors.inspectEmpty', 'Nothing to inspect!'));
|
|
32
30
|
|
|
33
31
|
return;
|
|
34
32
|
}
|
|
35
33
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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 });
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
public async report(error: ErrorSource, message?: string): Promise<void> {
|
|
@@ -79,11 +82,7 @@ export class ErrorsService extends Service {
|
|
|
79
82
|
{
|
|
80
83
|
label: translateWithDefault('errors.viewDetails', 'View details'),
|
|
81
84
|
dismiss: true,
|
|
82
|
-
click: () =>
|
|
83
|
-
UI.openModal<ModalComponent<ErrorReportModalProps>>(
|
|
84
|
-
UI.requireComponent(UIComponents.ErrorReportModal),
|
|
85
|
-
{ reports: [report] },
|
|
86
|
-
),
|
|
85
|
+
click: () => UI.modal(UI.requireComponent('error-report-modal'), { report, reports: [report] }),
|
|
87
86
|
},
|
|
88
87
|
],
|
|
89
88
|
},
|
|
@@ -125,6 +124,10 @@ export class ErrorsService extends Service {
|
|
|
125
124
|
}
|
|
126
125
|
}
|
|
127
126
|
|
|
127
|
+
private isErrorReport(error: unknown): error is ErrorReport {
|
|
128
|
+
return isObject(error) && 'title' in error;
|
|
129
|
+
}
|
|
130
|
+
|
|
128
131
|
private async createErrorReport(error: ErrorSource): Promise<ErrorReport> {
|
|
129
132
|
if (typeof error === 'string') {
|
|
130
133
|
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,32 @@
|
|
|
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="enabled" aria-labelledby="debug-setting" />
|
|
8
|
+
</Setting>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { ref, watchEffect } from 'vue';
|
|
13
|
+
import type Eruda from 'eruda';
|
|
14
|
+
|
|
15
|
+
import Setting from '@aerogel/core/components/ui/Setting.vue';
|
|
16
|
+
import Switch from '@aerogel/core/components/ui/Switch.vue';
|
|
17
|
+
|
|
18
|
+
let eruda: typeof Eruda | null = null;
|
|
19
|
+
const enabled = ref(false);
|
|
20
|
+
|
|
21
|
+
watchEffect(async () => {
|
|
22
|
+
if (!enabled.value) {
|
|
23
|
+
eruda?.destroy();
|
|
24
|
+
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
eruda ??= (await import('eruda')).default;
|
|
29
|
+
|
|
30
|
+
eruda.init();
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
2
|
+
import { tt } from '@noeldemartin/testing';
|
|
3
|
+
import type { Equals } from '@noeldemartin/utils';
|
|
4
|
+
import type { Expect } from '@noeldemartin/testing';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
enumInput,
|
|
8
|
+
numberInput,
|
|
9
|
+
objectInput,
|
|
10
|
+
requiredObjectInput,
|
|
11
|
+
requiredStringInput,
|
|
12
|
+
stringInput,
|
|
13
|
+
} from '@aerogel/core/forms/utils';
|
|
14
|
+
import { useForm } from '@aerogel/core/utils/composition/forms';
|
|
7
15
|
|
|
8
16
|
describe('FormController', () => {
|
|
9
17
|
|
|
@@ -21,7 +29,7 @@ describe('FormController', () => {
|
|
|
21
29
|
// Arrange
|
|
22
30
|
const form = useForm({
|
|
23
31
|
name: {
|
|
24
|
-
type:
|
|
32
|
+
type: 'string',
|
|
25
33
|
rules: 'required',
|
|
26
34
|
},
|
|
27
35
|
});
|
|
@@ -39,7 +47,7 @@ describe('FormController', () => {
|
|
|
39
47
|
// Arrange
|
|
40
48
|
const form = useForm({
|
|
41
49
|
name: {
|
|
42
|
-
type:
|
|
50
|
+
type: 'string',
|
|
43
51
|
rules: 'required',
|
|
44
52
|
},
|
|
45
53
|
});
|
|
@@ -60,11 +68,11 @@ describe('FormController', () => {
|
|
|
60
68
|
// Arrange
|
|
61
69
|
const form = useForm({
|
|
62
70
|
trimmed: {
|
|
63
|
-
type:
|
|
71
|
+
type: 'string',
|
|
64
72
|
rules: 'required',
|
|
65
73
|
},
|
|
66
74
|
untrimmed: {
|
|
67
|
-
type:
|
|
75
|
+
type: 'string',
|
|
68
76
|
rules: 'required',
|
|
69
77
|
trim: false,
|
|
70
78
|
},
|
|
@@ -84,4 +92,22 @@ describe('FormController', () => {
|
|
|
84
92
|
expect(form.errors).toEqual({ trimmed: ['required'], untrimmed: null });
|
|
85
93
|
});
|
|
86
94
|
|
|
95
|
+
it('infers field types', () => {
|
|
96
|
+
const form = useForm({
|
|
97
|
+
one: stringInput(),
|
|
98
|
+
two: requiredStringInput(),
|
|
99
|
+
three: objectInput(),
|
|
100
|
+
four: requiredObjectInput<{ foo: string; bar?: number }>(),
|
|
101
|
+
five: enumInput(['foo', 'bar']),
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
tt<
|
|
105
|
+
| Expect<Equals<typeof form.one, string | null>>
|
|
106
|
+
| Expect<Equals<typeof form.two, string>>
|
|
107
|
+
| Expect<Equals<typeof form.three, object | null>>
|
|
108
|
+
| Expect<Equals<typeof form.four, { foo: string; bar?: number }>>
|
|
109
|
+
| Expect<Equals<typeof form.five, 'foo' | 'bar' | null>>
|
|
110
|
+
>();
|
|
111
|
+
});
|
|
112
|
+
|
|
87
113
|
});
|