@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerogel/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.1.0-next.c4b24f52d8b652bd5c14c2d12e1b38b779ab7682",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -25,18 +25,20 @@
|
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@tailwindcss/forms": "^0.5.10",
|
|
27
27
|
"@tailwindcss/typography": "^0.5.16",
|
|
28
|
-
"
|
|
29
|
-
"
|
|
28
|
+
"tailwindcss": "^4.1.4",
|
|
29
|
+
"vue": "^3.5.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@noeldemartin/utils": "0.7.
|
|
32
|
+
"@noeldemartin/utils": "^0.7.1",
|
|
33
33
|
"class-variance-authority": "^0.7.1",
|
|
34
34
|
"clsx": "^2.1.1",
|
|
35
35
|
"dompurify": "^3.2.4",
|
|
36
|
+
"eruda": "^3.4.1",
|
|
36
37
|
"marked": "^15.0.7",
|
|
37
38
|
"pinia": "^2.1.6",
|
|
38
39
|
"reka-ui": "^2.2.0",
|
|
39
|
-
"tailwind-merge": "^3.1.0"
|
|
40
|
+
"tailwind-merge": "^3.1.0",
|
|
41
|
+
"vue-component-type-helpers": "^2.2.8"
|
|
40
42
|
},
|
|
41
43
|
"devDependencies": {
|
|
42
44
|
"@aerogel/vite": "*"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="flex min-h-full flex-col text-base leading-tight font-normal text-gray-900 antialiased">
|
|
3
3
|
<slot v-if="$errors.hasStartupErrors" name="startup-crash">
|
|
4
|
-
<component :is="$ui.requireComponent(
|
|
4
|
+
<component :is="$ui.requireComponent('startup-crash')" />
|
|
5
5
|
</slot>
|
|
6
6
|
<slot v-else />
|
|
7
7
|
|
|
@@ -10,7 +10,5 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
|
-
import { UIComponents } from '@aerogel/core/ui/UI';
|
|
14
|
-
|
|
15
13
|
import AppOverlays from './AppOverlays.vue';
|
|
16
14
|
</script>
|
|
@@ -4,33 +4,6 @@
|
|
|
4
4
|
</template>
|
|
5
5
|
|
|
6
6
|
<script setup lang="ts">
|
|
7
|
-
import { ref } from 'vue';
|
|
8
|
-
|
|
9
|
-
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
10
|
-
|
|
11
7
|
import AppModals from './AppModals.vue';
|
|
12
8
|
import AppToasts from './AppToasts.vue';
|
|
13
|
-
|
|
14
|
-
const $backdrop = ref<HTMLElement | null>(null);
|
|
15
|
-
const backdropHidden = ref(true);
|
|
16
|
-
|
|
17
|
-
useEvent('show-overlays-backdrop', async () => {
|
|
18
|
-
if (!$backdrop.value || !backdropHidden.value) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
backdropHidden.value = false;
|
|
23
|
-
|
|
24
|
-
$backdrop.value.classList.remove('opacity-0');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
useEvent('hide-overlays-backdrop', async () => {
|
|
28
|
-
if (!$backdrop.value || backdropHidden.value) {
|
|
29
|
-
return;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
backdropHidden.value = true;
|
|
33
|
-
|
|
34
|
-
$backdrop.value.classList.add('opacity-0');
|
|
35
|
-
});
|
|
36
9
|
</script>
|
|
@@ -1,4 +1,19 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
4
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
5
|
+
|
|
1
6
|
export interface AlertModalProps {
|
|
2
7
|
title?: string;
|
|
3
8
|
message: string;
|
|
4
9
|
}
|
|
10
|
+
|
|
11
|
+
export interface AlertModalExpose extends ModalExpose<void> {}
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
export function useAlertModal(props: AlertModalProps) {
|
|
15
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.alert', 'Alert'));
|
|
16
|
+
const titleHidden = computed(() => !props.title);
|
|
17
|
+
|
|
18
|
+
return { renderedTitle, titleHidden };
|
|
19
|
+
}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
2
|
|
|
3
3
|
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
-
import {
|
|
4
|
+
import { useForm } from '@aerogel/core/utils/composition/forms';
|
|
5
5
|
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
|
6
|
-
import type { FormFieldDefinition } from '@aerogel/core/forms';
|
|
6
|
+
import type { FormFieldDefinition } from '@aerogel/core/forms/FormController';
|
|
7
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
8
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
7
9
|
|
|
8
10
|
export type ConfirmModalCheckboxes = Record<string, { label: string; default?: boolean; required?: boolean }>;
|
|
9
11
|
|
|
@@ -19,23 +21,28 @@ export interface ConfirmModalProps {
|
|
|
19
21
|
required?: boolean;
|
|
20
22
|
}
|
|
21
23
|
|
|
24
|
+
export interface ConfirmModalExpose extends ModalExpose<boolean | [boolean, Record<string, Nullable<boolean>>]> {}
|
|
25
|
+
|
|
22
26
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
23
27
|
export function useConfirmModal(props: ConfirmModalProps) {
|
|
24
28
|
const form = useForm(
|
|
25
29
|
Object.entries(props.checkboxes ?? {}).reduce(
|
|
26
30
|
(values, [name, checkbox]) => ({
|
|
27
31
|
[name]: {
|
|
28
|
-
type:
|
|
32
|
+
type: 'boolean',
|
|
29
33
|
default: checkbox.default,
|
|
30
34
|
required: checkbox.required ? 'required' : undefined,
|
|
31
35
|
},
|
|
32
36
|
...values,
|
|
33
37
|
}),
|
|
34
|
-
{} as Record<string, FormFieldDefinition
|
|
38
|
+
{} as Record<string, FormFieldDefinition<'boolean'>>,
|
|
35
39
|
),
|
|
36
40
|
);
|
|
41
|
+
|
|
42
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.confirm', 'Confirm'));
|
|
43
|
+
const titleHidden = computed(() => !props.title);
|
|
37
44
|
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
38
45
|
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
39
46
|
|
|
40
|
-
return { form, renderedAcceptText, renderedCancelText };
|
|
47
|
+
return { form, renderedTitle, titleHidden, renderedAcceptText, renderedCancelText };
|
|
41
48
|
}
|
|
@@ -4,17 +4,22 @@ import type { Falsifiable } from '@aerogel/core/utils/types';
|
|
|
4
4
|
|
|
5
5
|
export type DropdownMenuOptionData = {
|
|
6
6
|
label: string;
|
|
7
|
-
|
|
7
|
+
href?: string;
|
|
8
|
+
route?: string;
|
|
9
|
+
routeParams?: object;
|
|
10
|
+
routeQuery?: object;
|
|
11
|
+
click?: () => unknown;
|
|
12
|
+
class?: string;
|
|
8
13
|
};
|
|
9
14
|
|
|
10
15
|
export interface DropdownMenuProps {
|
|
11
16
|
align?: DropdownMenuContentProps['align'];
|
|
12
17
|
side?: DropdownMenuContentProps['side'];
|
|
13
|
-
options?: Falsifiable<DropdownMenuOptionData>[];
|
|
18
|
+
options?: readonly Falsifiable<DropdownMenuOptionData>[];
|
|
14
19
|
}
|
|
15
20
|
|
|
16
21
|
export interface DropdownMenuExpose {
|
|
17
22
|
align?: DropdownMenuContentProps['align'];
|
|
18
23
|
side?: DropdownMenuContentProps['side'];
|
|
19
|
-
options?: DropdownMenuOptionData[];
|
|
24
|
+
options?: readonly DropdownMenuOptionData[];
|
|
20
25
|
}
|
|
@@ -2,18 +2,22 @@ import { computed, ref } from 'vue';
|
|
|
2
2
|
|
|
3
3
|
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
4
|
import type { ErrorReport } from '@aerogel/core/errors';
|
|
5
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
5
6
|
|
|
6
7
|
export interface ErrorReportModalProps {
|
|
8
|
+
report: ErrorReport;
|
|
7
9
|
reports: ErrorReport[];
|
|
8
10
|
}
|
|
9
11
|
|
|
12
|
+
export interface ErrorReportModalExpose extends ModalExpose {}
|
|
13
|
+
|
|
10
14
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
11
15
|
export function useErrorReportModal(props: ErrorReportModalProps) {
|
|
12
|
-
const activeReportIndex = ref(0);
|
|
13
|
-
const
|
|
16
|
+
const activeReportIndex = ref(props.reports.includes(props.report) ? props.reports.indexOf(props.report) : 0);
|
|
17
|
+
const activeReport = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
14
18
|
const details = computed(
|
|
15
19
|
() =>
|
|
16
|
-
|
|
20
|
+
activeReport.value.details?.trim() ||
|
|
17
21
|
translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
|
|
18
22
|
);
|
|
19
23
|
const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
|
|
@@ -24,6 +28,6 @@ export function useErrorReportModal(props: ErrorReportModalProps) {
|
|
|
24
28
|
details,
|
|
25
29
|
nextReportText,
|
|
26
30
|
previousReportText,
|
|
27
|
-
|
|
31
|
+
activeReport,
|
|
28
32
|
};
|
|
29
33
|
}
|
|
@@ -3,24 +3,24 @@ import type { Nullable } from '@noeldemartin/utils';
|
|
|
3
3
|
|
|
4
4
|
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
5
5
|
|
|
6
|
-
export interface InputProps {
|
|
6
|
+
export interface InputProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
|
|
7
7
|
name?: string;
|
|
8
8
|
label?: string;
|
|
9
9
|
description?: string;
|
|
10
|
-
modelValue?:
|
|
10
|
+
modelValue?: T;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export interface InputEmits {
|
|
14
|
-
'update:modelValue': [value:
|
|
13
|
+
export interface InputEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
|
|
14
|
+
'update:modelValue': [value: T];
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export interface InputExpose {
|
|
17
|
+
export interface InputExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
|
|
18
18
|
id: string;
|
|
19
19
|
name: ComputedRef<Nullable<string>>;
|
|
20
20
|
label: ComputedRef<Nullable<string>>;
|
|
21
21
|
description: ComputedRef<Nullable<string | boolean>>;
|
|
22
|
-
value: ComputedRef<
|
|
22
|
+
value: ComputedRef<T>;
|
|
23
23
|
required: ComputedRef<Nullable<boolean>>;
|
|
24
24
|
errors: DeepReadonly<Ref<Nullable<string[]>>>;
|
|
25
|
-
update(value:
|
|
25
|
+
update(value: T): void;
|
|
26
26
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { Job } from '@aerogel/core/jobs';
|
|
2
|
-
import { translateWithDefault } from '@aerogel/core/lang';
|
|
3
1
|
import { computed } from 'vue';
|
|
4
2
|
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
+
import type { Job } from '@aerogel/core/jobs';
|
|
5
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
6
|
+
|
|
5
7
|
export interface LoadingModalProps {
|
|
6
8
|
title?: string;
|
|
7
9
|
message?: string;
|
|
@@ -9,6 +11,8 @@ export interface LoadingModalProps {
|
|
|
9
11
|
job?: Job;
|
|
10
12
|
}
|
|
11
13
|
|
|
14
|
+
export interface LoadingModalExpose extends ModalExpose {}
|
|
15
|
+
|
|
12
16
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
13
17
|
export function useLoadingModal(props: LoadingModalProps) {
|
|
14
18
|
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.loading', 'Loading'));
|
|
@@ -11,11 +11,11 @@ export interface ModalProps {
|
|
|
11
11
|
descriptionHidden?: boolean;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export interface ModalSlots {
|
|
15
|
-
default(props: { close(result?:
|
|
14
|
+
export interface ModalSlots<Result = void> {
|
|
15
|
+
default(props: { close(result?: Result): Promise<void> }): unknown;
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
export interface ModalExpose {
|
|
19
|
-
close(result?:
|
|
18
|
+
export interface ModalExpose<Result = void> {
|
|
19
|
+
close(result?: Result): Promise<void>;
|
|
20
20
|
$content: ModalContentInstance;
|
|
21
21
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { useForm } from '@aerogel/core/utils/composition/forms';
|
|
4
|
+
import { requiredStringInput } from '@aerogel/core/forms/utils';
|
|
4
5
|
import { translateWithDefault } from '@aerogel/core/lang';
|
|
5
6
|
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
|
7
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
6
8
|
|
|
7
9
|
export interface PromptModalProps {
|
|
8
10
|
title?: string;
|
|
@@ -16,6 +18,8 @@ export interface PromptModalProps {
|
|
|
16
18
|
cancelVariant?: ButtonVariant;
|
|
17
19
|
}
|
|
18
20
|
|
|
21
|
+
export interface PromptModalExpose extends ModalExpose<string> {}
|
|
22
|
+
|
|
19
23
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
20
24
|
export function usePromptModal(props: PromptModalProps) {
|
|
21
25
|
const form = useForm({
|
|
@@ -2,6 +2,8 @@ import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
|
|
|
2
2
|
import type { Component, ComputedRef, HTMLAttributes } from 'vue';
|
|
3
3
|
import type { Nullable } from '@noeldemartin/utils';
|
|
4
4
|
|
|
5
|
+
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
6
|
+
|
|
5
7
|
import type { InputEmits, InputExpose, InputProps } from './Input';
|
|
6
8
|
|
|
7
9
|
export type SelectOptionData = {
|
|
@@ -14,23 +16,22 @@ export interface HasSelectOptionLabel {
|
|
|
14
16
|
label: string | (() => string);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export interface SelectProps extends InputProps {
|
|
19
|
+
export interface SelectProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputProps<T> {
|
|
18
20
|
as?: AsTag | Component;
|
|
19
|
-
|
|
20
|
-
options?: any[];
|
|
21
|
+
options?: readonly T[];
|
|
21
22
|
placeholder?: string;
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
renderOption?: (option: T) => string;
|
|
24
|
+
compareOptions?: (a: T, b: T) => boolean;
|
|
24
25
|
labelClass?: HTMLAttributes['class'];
|
|
25
26
|
optionsClass?: HTMLAttributes['class'];
|
|
26
27
|
align?: SelectContentProps['align'];
|
|
27
28
|
side?: SelectContentProps['side'];
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
export interface SelectEmits extends InputEmits {}
|
|
31
|
+
export interface SelectEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputEmits<T> {}
|
|
31
32
|
|
|
32
|
-
export interface SelectExpose extends InputExpose {
|
|
33
|
-
options: ComputedRef<Nullable<SelectOptionData[]>>;
|
|
33
|
+
export interface SelectExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputExpose<T> {
|
|
34
|
+
options: ComputedRef<Nullable<readonly SelectOptionData[]>>;
|
|
34
35
|
selectedOption: ComputedRef<Nullable<SelectOptionData>>;
|
|
35
36
|
placeholder: ComputedRef<string>;
|
|
36
37
|
labelClass?: HTMLAttributes['class'];
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
+
export type ToastVariant = 'secondary' | 'danger';
|
|
2
|
+
|
|
1
3
|
export interface ToastAction {
|
|
2
4
|
label: string;
|
|
3
5
|
dismiss?: boolean;
|
|
4
6
|
click?(): unknown;
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
export type ToastVariant = 'secondary' | 'danger';
|
|
8
|
-
|
|
9
9
|
export interface ToastProps {
|
|
10
10
|
message?: string;
|
|
11
11
|
actions?: ToastAction[];
|
|
12
12
|
variant?: ToastVariant;
|
|
13
13
|
}
|
|
14
|
+
|
|
15
|
+
export interface ToastExpose {}
|
|
@@ -14,7 +14,7 @@ import { computed } from 'vue';
|
|
|
14
14
|
import { Primitive } from 'reka-ui';
|
|
15
15
|
import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
16
16
|
|
|
17
|
-
import UI
|
|
17
|
+
import UI from '@aerogel/core/ui/UI';
|
|
18
18
|
import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
|
|
19
19
|
|
|
20
20
|
const { as, href, route, routeParams, routeQuery, submit, disabled, class: classes } = defineProps<ButtonProps>();
|
|
@@ -26,7 +26,7 @@ const props = computed(() => {
|
|
|
26
26
|
|
|
27
27
|
if (route) {
|
|
28
28
|
return {
|
|
29
|
-
as: UI.resolveComponent(
|
|
29
|
+
as: UI.resolveComponent('router-link') ?? 'a',
|
|
30
30
|
to: objectWithoutEmpty({
|
|
31
31
|
name: route,
|
|
32
32
|
params: routeParams,
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
:id="input.id"
|
|
4
4
|
ref="$inputRef"
|
|
5
5
|
:name
|
|
6
|
-
:type
|
|
7
6
|
:checked
|
|
7
|
+
:type="renderedType"
|
|
8
8
|
:required="input.required ?? undefined"
|
|
9
9
|
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
10
10
|
:aria-describedby="
|
|
@@ -15,18 +15,29 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<script setup lang="ts">
|
|
18
|
-
import { computed, useTemplateRef, watchEffect } from 'vue';
|
|
18
|
+
import { computed, inject, useTemplateRef, watchEffect } from 'vue';
|
|
19
19
|
|
|
20
20
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
21
|
import { onFormFocus } from '@aerogel/core/utils/composition/forms';
|
|
22
|
+
import type FormController from '@aerogel/core/forms/FormController';
|
|
22
23
|
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
23
24
|
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
24
25
|
|
|
25
|
-
const { type
|
|
26
|
+
const { type } = defineProps<{ type?: string }>();
|
|
26
27
|
const $input = useTemplateRef('$inputRef');
|
|
27
28
|
const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputInput> must be a child of a <HeadlessInput>');
|
|
29
|
+
const form = inject<FormController | null>('form', null);
|
|
28
30
|
const name = computed(() => input.name ?? undefined);
|
|
29
31
|
const value = computed(() => input.value);
|
|
32
|
+
const renderedType = computed(() => {
|
|
33
|
+
if (type) {
|
|
34
|
+
return type;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const fieldType = (name.value && form?.getFieldType(name.value)) ?? '';
|
|
38
|
+
|
|
39
|
+
return ['text', 'email', 'number', 'tel', 'url'].includes(fieldType) ? fieldType : 'text';
|
|
40
|
+
});
|
|
30
41
|
const checked = computed(() => {
|
|
31
42
|
if (type !== 'checkbox') {
|
|
32
43
|
return;
|
|
@@ -64,8 +75,8 @@ watchEffect(() => {
|
|
|
64
75
|
return;
|
|
65
76
|
}
|
|
66
77
|
|
|
67
|
-
if (type === 'date') {
|
|
68
|
-
$input.value.valueAsDate = value.value
|
|
78
|
+
if (type === 'date' && value.value instanceof Date) {
|
|
79
|
+
$input.value.valueAsDate = value.value;
|
|
69
80
|
|
|
70
81
|
return;
|
|
71
82
|
}
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
</DialogRoot>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
|
-
<script setup lang="ts">
|
|
9
|
+
<script setup lang="ts" generic="T = void">
|
|
10
10
|
import { provide, ref } from 'vue';
|
|
11
11
|
import { DialogPortal, DialogRoot, useForwardExpose } from 'reka-ui';
|
|
12
12
|
import type { DialogContent } from 'reka-ui';
|
|
@@ -16,22 +16,21 @@ import Events from '@aerogel/core/services/Events';
|
|
|
16
16
|
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
17
17
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
18
18
|
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
19
|
-
import type { UIModalContext } from '@aerogel/core/ui/UI
|
|
19
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
20
20
|
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
21
21
|
|
|
22
22
|
const $content = ref<Nullable<InstanceType<typeof DialogContent>>>(null);
|
|
23
23
|
const { modal } = injectReactiveOrFail<UIModalContext>(
|
|
24
24
|
'modal',
|
|
25
25
|
'could not obtain modal reference from <HeadlessModal>, ' +
|
|
26
|
-
'did you render this component manually? Show it using $ui.
|
|
26
|
+
'did you render this component manually? Show it using $ui.modal() instead',
|
|
27
27
|
);
|
|
28
28
|
|
|
29
29
|
defineProps<ModalProps>();
|
|
30
|
-
defineSlots<ModalSlots
|
|
31
|
-
defineExpose<AcceptRefs<ModalExpose
|
|
30
|
+
defineSlots<ModalSlots<T>>();
|
|
31
|
+
defineExpose<AcceptRefs<ModalExpose<T>>>({ close, $content });
|
|
32
32
|
|
|
33
|
-
const { forwardRef
|
|
34
|
-
const hidden = ref(true);
|
|
33
|
+
const { forwardRef } = useForwardExpose();
|
|
35
34
|
const closed = ref(false);
|
|
36
35
|
|
|
37
36
|
provide('$modalContentRef', $content);
|
|
@@ -44,49 +43,15 @@ useEvent('close-modal', async ({ id, result }) => {
|
|
|
44
43
|
await close(result);
|
|
45
44
|
});
|
|
46
45
|
|
|
47
|
-
useEvent('hide-modal', async ({ id }) => {
|
|
48
|
-
if (id !== modal.id) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
await hide();
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
useEvent('show-modal', async ({ id }) => {
|
|
56
|
-
if (id !== modal.id) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
await show();
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
async function hide(): Promise<void> {
|
|
64
|
-
if (!currentElement.value) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
hidden.value = true;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
async function show(): Promise<void> {
|
|
72
|
-
if (!currentElement.value) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
hidden.value = false;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
46
|
async function close(result?: unknown) {
|
|
80
47
|
if (closed.value) {
|
|
81
48
|
return;
|
|
82
49
|
}
|
|
83
50
|
|
|
84
|
-
Events.emit('modal-will-close', { modal, result });
|
|
85
|
-
|
|
86
|
-
await hide();
|
|
51
|
+
await Events.emit('modal-will-close', { modal, result });
|
|
87
52
|
|
|
88
53
|
closed.value = true;
|
|
89
54
|
|
|
90
|
-
Events.emit('modal-closed', { modal, result });
|
|
55
|
+
await Events.emit('modal-has-closed', { modal, result });
|
|
91
56
|
}
|
|
92
57
|
</script>
|
|
@@ -14,13 +14,13 @@ import type { Ref } from 'vue';
|
|
|
14
14
|
import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
|
|
15
15
|
import UI from '@aerogel/core/ui/UI';
|
|
16
16
|
import { injectOrFail, injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
-
import type { UIModalContext } from '@aerogel/core/ui/UI
|
|
17
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
18
18
|
import type { ModalContentInstance } from '@aerogel/core/components/contracts/Modal';
|
|
19
19
|
|
|
20
20
|
const { childIndex = 0 } = injectReactiveOrFail<UIModalContext>(
|
|
21
21
|
'modal',
|
|
22
22
|
'could not obtain modal reference from <HeadlessModalContent>, ' +
|
|
23
|
-
'did you render this component manually? Show it using $ui.
|
|
23
|
+
'did you render this component manually? Show it using $ui.modal() instead',
|
|
24
24
|
);
|
|
25
25
|
const $modalContentRef = injectOrFail<Ref<ModalContentInstance>>('$modalContentRef');
|
|
26
26
|
const $content = useTemplateRef('$contentRef');
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<SelectRoot
|
|
3
3
|
v-slot="{ open }"
|
|
4
4
|
:model-value="acceptableValue"
|
|
5
|
-
:by="
|
|
5
|
+
:by="compareOptions as Closure<[AcceptableValue, AcceptableValue], boolean>"
|
|
6
6
|
@update:model-value="update($event)"
|
|
7
7
|
>
|
|
8
8
|
<component :is="as" v-bind="$attrs">
|
|
@@ -14,11 +14,12 @@
|
|
|
14
14
|
</SelectRoot>
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
|
-
<script setup lang="ts">
|
|
17
|
+
<script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
|
|
18
18
|
import { computed, inject, provide, readonly } from 'vue';
|
|
19
19
|
import { value as evaluate, toString, uuid } from '@noeldemartin/utils';
|
|
20
20
|
import { SelectRoot } from 'reka-ui';
|
|
21
21
|
import type { AcceptableValue } from 'reka-ui';
|
|
22
|
+
import type { Closure, Nullable } from '@noeldemartin/utils';
|
|
22
23
|
|
|
23
24
|
import { translateWithDefault } from '@aerogel/core/lang';
|
|
24
25
|
import { hasSelectOptionLabel } from '@aerogel/core/components/contracts/Select';
|
|
@@ -39,20 +40,21 @@ const {
|
|
|
39
40
|
labelClass,
|
|
40
41
|
optionsClass,
|
|
41
42
|
renderOption,
|
|
43
|
+
compareOptions = (a, b) => a === b,
|
|
42
44
|
description,
|
|
43
45
|
placeholder,
|
|
44
46
|
modelValue,
|
|
45
47
|
align,
|
|
46
48
|
side,
|
|
47
|
-
} = defineProps<SelectProps
|
|
48
|
-
const emit = defineEmits<SelectEmits
|
|
49
|
+
} = defineProps<SelectProps<T>>();
|
|
50
|
+
const emit = defineEmits<SelectEmits<T>>();
|
|
49
51
|
const form = inject<FormController | null>('form', null);
|
|
50
52
|
const computedValue = computed(() => {
|
|
51
53
|
if (form && name) {
|
|
52
|
-
return form.getFieldValue(name);
|
|
54
|
+
return form.getFieldValue(name) as T;
|
|
53
55
|
}
|
|
54
56
|
|
|
55
|
-
return modelValue;
|
|
57
|
+
return modelValue as T;
|
|
56
58
|
});
|
|
57
59
|
const acceptableValue = computed(() => computedValue.value as AcceptableValue);
|
|
58
60
|
const errors = computed(() => {
|
|
@@ -107,10 +109,10 @@ const expose = {
|
|
|
107
109
|
|
|
108
110
|
emit('update:modelValue', value);
|
|
109
111
|
},
|
|
110
|
-
} satisfies SelectExpose
|
|
112
|
+
} satisfies SelectExpose<T>;
|
|
111
113
|
|
|
112
114
|
function update(value: AcceptableValue) {
|
|
113
|
-
expose.update(value as
|
|
115
|
+
expose.update(value as T);
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
provide('select', expose);
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
<SelectPortal>
|
|
3
3
|
<SelectContent
|
|
4
4
|
position="popper"
|
|
5
|
-
:class="
|
|
5
|
+
:class="renderedClasses"
|
|
6
6
|
:align="select.align"
|
|
7
7
|
:side="select.side"
|
|
8
|
+
:side-offset="4"
|
|
8
9
|
>
|
|
9
10
|
<SelectViewport :class="innerClass">
|
|
10
11
|
<slot>
|
|
@@ -21,17 +22,21 @@
|
|
|
21
22
|
|
|
22
23
|
<script setup lang="ts">
|
|
23
24
|
import { SelectContent, SelectPortal, SelectViewport } from 'reka-ui';
|
|
25
|
+
import { computed } from 'vue';
|
|
24
26
|
import type { HTMLAttributes } from 'vue';
|
|
25
27
|
|
|
26
|
-
import { injectReactiveOrFail } from '@aerogel/core/utils';
|
|
28
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
29
|
+
import { classes } from '@aerogel/core/utils/classes';
|
|
27
30
|
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
28
31
|
|
|
29
32
|
import HeadlessSelectOption from './HeadlessSelectOption.vue';
|
|
30
33
|
|
|
31
|
-
defineProps<{ class?: HTMLAttributes['class']; innerClass?: HTMLAttributes['class'] }>();
|
|
34
|
+
const { class: rootClass } = defineProps<{ class?: HTMLAttributes['class']; innerClass?: HTMLAttributes['class'] }>();
|
|
32
35
|
|
|
33
36
|
const select = injectReactiveOrFail<SelectExpose>(
|
|
34
37
|
'select',
|
|
35
38
|
'<HeadlessSelectOptions> must be a child of a <HeadlessSelect>',
|
|
36
39
|
);
|
|
40
|
+
const renderedClasses = computed(() =>
|
|
41
|
+
classes('min-w-(--reka-select-trigger-width) max-h-(--reka-select-content-available-height)', rootClass));
|
|
37
42
|
</script>
|