@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerogel/core",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.c38a10cd5e81c5f04469ef79e59a53e6bfd3df55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -23,6 +23,9 @@
|
|
|
23
23
|
"verify": "noeldemartin-verify"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
+
"@tailwindcss/forms": "^0.5.10",
|
|
27
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
28
|
+
"tailwindcss": "^4.1.4",
|
|
26
29
|
"vue": "^3.5.0"
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
@@ -30,10 +33,12 @@
|
|
|
30
33
|
"class-variance-authority": "^0.7.1",
|
|
31
34
|
"clsx": "^2.1.1",
|
|
32
35
|
"dompurify": "^3.2.4",
|
|
36
|
+
"eruda": "^3.4.1",
|
|
33
37
|
"marked": "^15.0.7",
|
|
34
38
|
"pinia": "^2.1.6",
|
|
35
39
|
"reka-ui": "^2.2.0",
|
|
36
|
-
"tailwind-merge": "^3.1.0"
|
|
40
|
+
"tailwind-merge": "^3.1.0",
|
|
41
|
+
"vue-component-type-helpers": "^2.2.8"
|
|
37
42
|
},
|
|
38
43
|
"devDependencies": {
|
|
39
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';
|
|
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
|
}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import type { DropdownMenuContentProps } from 'reka-ui';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import type { Falsifiable } from '@aerogel/core/utils/types';
|
|
4
|
+
|
|
5
|
+
export type DropdownMenuOptionData = {
|
|
4
6
|
label: string;
|
|
5
|
-
|
|
7
|
+
href?: string;
|
|
8
|
+
route?: string;
|
|
9
|
+
routeParams?: object;
|
|
10
|
+
routeQuery?: object;
|
|
11
|
+
click?: () => unknown;
|
|
12
|
+
class?: string;
|
|
6
13
|
};
|
|
7
14
|
|
|
8
15
|
export interface DropdownMenuProps {
|
|
9
16
|
align?: DropdownMenuContentProps['align'];
|
|
10
|
-
|
|
17
|
+
side?: DropdownMenuContentProps['side'];
|
|
18
|
+
options?: Falsifiable<DropdownMenuOptionData>[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DropdownMenuExpose {
|
|
22
|
+
align?: DropdownMenuContentProps['align'];
|
|
23
|
+
side?: DropdownMenuContentProps['side'];
|
|
24
|
+
options?: DropdownMenuOptionData[];
|
|
11
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,10 +11,16 @@ 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
|
-
const
|
|
18
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.loading', 'Loading'));
|
|
19
|
+
const renderedMessage = computed(
|
|
20
|
+
() => props.message ?? translateWithDefault('ui.loadingInProgress', 'Loading in progress...'),
|
|
21
|
+
);
|
|
15
22
|
const showProgress = computed(() => typeof props.progress === 'number' || !!props.job);
|
|
23
|
+
const titleHidden = computed(() => !props.title);
|
|
16
24
|
|
|
17
|
-
return { renderedMessage, showProgress };
|
|
25
|
+
return { renderedTitle, renderedMessage, titleHidden, showProgress };
|
|
18
26
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
2
|
+
import type { DialogContent } from 'reka-ui';
|
|
3
|
+
|
|
4
|
+
export type ModalContentInstance = Nullable<InstanceType<typeof DialogContent>>;
|
|
5
|
+
|
|
1
6
|
export interface ModalProps {
|
|
2
7
|
persistent?: boolean;
|
|
3
8
|
title?: string;
|
|
9
|
+
titleHidden?: boolean;
|
|
4
10
|
description?: string;
|
|
11
|
+
descriptionHidden?: boolean;
|
|
5
12
|
}
|
|
6
13
|
|
|
7
|
-
export interface ModalSlots {
|
|
8
|
-
default(props: { close(result?:
|
|
14
|
+
export interface ModalSlots<Result = void> {
|
|
15
|
+
default(props: { close(result?: Result): Promise<void> }): unknown;
|
|
9
16
|
}
|
|
10
17
|
|
|
11
|
-
export interface ModalExpose {
|
|
12
|
-
close(result?:
|
|
18
|
+
export interface ModalExpose<Result = void> {
|
|
19
|
+
close(result?: Result): Promise<void>;
|
|
20
|
+
$content: ModalContentInstance;
|
|
13
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,13 +18,17 @@ 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({
|
|
22
26
|
draft: requiredStringInput(props.defaultValue ?? ''),
|
|
23
27
|
});
|
|
28
|
+
const renderedTitle = computed(() => props.title ?? props.message);
|
|
29
|
+
const renderedMessage = computed(() => (props.title ? props.message : null));
|
|
24
30
|
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
25
31
|
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
26
32
|
|
|
27
|
-
return { form, renderedAcceptText, renderedCancelText };
|
|
33
|
+
return { form, renderedTitle, renderedMessage, renderedAcceptText, renderedCancelText };
|
|
28
34
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import type { AcceptableValue } from 'reka-ui';
|
|
2
|
-
import type { ComputedRef } from 'vue';
|
|
1
|
+
import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
|
|
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
|
-
export type
|
|
9
|
+
export type SelectOptionData = {
|
|
8
10
|
key: string;
|
|
9
11
|
label: string;
|
|
10
12
|
value: AcceptableValue;
|
|
@@ -14,18 +16,28 @@ export interface HasSelectOptionLabel {
|
|
|
14
16
|
label: string | (() => string);
|
|
15
17
|
}
|
|
16
18
|
|
|
17
|
-
export interface SelectProps extends InputProps {
|
|
18
|
-
|
|
19
|
+
export interface SelectProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputProps<T> {
|
|
20
|
+
as?: AsTag | Component;
|
|
21
|
+
options?: T[];
|
|
19
22
|
placeholder?: string;
|
|
20
|
-
renderOption?: (option:
|
|
23
|
+
renderOption?: (option: T) => string;
|
|
24
|
+
compareOptions?: (a: T, b: T) => boolean;
|
|
25
|
+
labelClass?: HTMLAttributes['class'];
|
|
26
|
+
optionsClass?: HTMLAttributes['class'];
|
|
27
|
+
align?: SelectContentProps['align'];
|
|
28
|
+
side?: SelectContentProps['side'];
|
|
21
29
|
}
|
|
22
30
|
|
|
23
|
-
export interface SelectEmits extends InputEmits {}
|
|
31
|
+
export interface SelectEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputEmits<T> {}
|
|
24
32
|
|
|
25
|
-
export interface SelectExpose extends InputExpose {
|
|
26
|
-
options: ComputedRef<Nullable<
|
|
27
|
-
selectedOption: ComputedRef<Nullable<
|
|
33
|
+
export interface SelectExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputExpose<T> {
|
|
34
|
+
options: ComputedRef<Nullable<SelectOptionData[]>>;
|
|
35
|
+
selectedOption: ComputedRef<Nullable<SelectOptionData>>;
|
|
28
36
|
placeholder: ComputedRef<string>;
|
|
37
|
+
labelClass?: HTMLAttributes['class'];
|
|
38
|
+
optionsClass?: HTMLAttributes['class'];
|
|
39
|
+
align?: SelectContentProps['align'];
|
|
40
|
+
side?: SelectContentProps['side'];
|
|
29
41
|
}
|
|
30
42
|
|
|
31
43
|
export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
|
|
@@ -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 {}
|
|
@@ -2,8 +2,10 @@ export * from './AlertModal';
|
|
|
2
2
|
export * from './Button';
|
|
3
3
|
export * from './ConfirmModal';
|
|
4
4
|
export * from './DropdownMenu';
|
|
5
|
+
export * from './ErrorReportModal';
|
|
6
|
+
export * from './Input';
|
|
5
7
|
export * from './LoadingModal';
|
|
6
8
|
export * from './Modal';
|
|
7
9
|
export * from './PromptModal';
|
|
8
10
|
export * from './Select';
|
|
9
|
-
export * from './
|
|
11
|
+
export * from './Toast';
|
|
@@ -14,6 +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 from '@aerogel/core/ui/UI';
|
|
17
18
|
import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
|
|
18
19
|
|
|
19
20
|
const { as, href, route, routeParams, routeQuery, submit, disabled, class: classes } = defineProps<ButtonProps>();
|
|
@@ -25,7 +26,7 @@ const props = computed(() => {
|
|
|
25
26
|
|
|
26
27
|
if (route) {
|
|
27
28
|
return {
|
|
28
|
-
as: 'router-link',
|
|
29
|
+
as: UI.resolveComponent('router-link') ?? 'a',
|
|
29
30
|
to: objectWithoutEmpty({
|
|
30
31
|
name: route,
|
|
31
32
|
params: routeParams,
|
|
@@ -23,7 +23,7 @@ const errors = computed(() => {
|
|
|
23
23
|
return form.errors[name] ?? null;
|
|
24
24
|
});
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const expose = {
|
|
27
27
|
id: `input-${uuid()}`,
|
|
28
28
|
name: computed(() => name),
|
|
29
29
|
label: computed(() => label),
|
|
@@ -54,6 +54,6 @@ const context = {
|
|
|
54
54
|
},
|
|
55
55
|
} satisfies InputExpose;
|
|
56
56
|
|
|
57
|
-
provide('input',
|
|
58
|
-
defineExpose(
|
|
57
|
+
provide('input', expose);
|
|
58
|
+
defineExpose(expose);
|
|
59
59
|
</script>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
3
|
:id="input.id"
|
|
4
|
-
ref="$
|
|
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,
|
|
18
|
+
import { computed, inject, useTemplateRef, watchEffect } from 'vue';
|
|
19
19
|
|
|
20
20
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
|
-
import { onFormFocus } from '@aerogel/core/
|
|
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 $input =
|
|
26
|
+
const { type } = defineProps<{ type?: string }>();
|
|
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
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<textarea
|
|
3
3
|
:id="input.id"
|
|
4
|
-
ref="$
|
|
4
|
+
ref="$textAreaRef"
|
|
5
5
|
:name
|
|
6
6
|
:value
|
|
7
7
|
:required="input.required ?? undefined"
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
|
-
import { computed,
|
|
17
|
+
import { computed, useTemplateRef } from 'vue';
|
|
18
18
|
|
|
19
|
-
import { onFormFocus } from '@aerogel/core/
|
|
19
|
+
import { onFormFocus } from '@aerogel/core/utils/composition/forms';
|
|
20
20
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
21
|
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
22
22
|
|
|
23
|
-
const $textArea =
|
|
23
|
+
const $textArea = useTemplateRef('$textAreaRef');
|
|
24
24
|
const input = injectReactiveOrFail<InputExpose>(
|
|
25
25
|
'input',
|
|
26
26
|
'<HeadlessInputTextArea> must be a child of a <HeadlessInput>',
|
|
@@ -1,62 +1,39 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DialogRoot ref="
|
|
2
|
+
<DialogRoot :ref="forwardRef" open @update:open="persistent || close()">
|
|
3
3
|
<DialogPortal>
|
|
4
4
|
<slot :close="close" />
|
|
5
5
|
</DialogPortal>
|
|
6
6
|
</DialogRoot>
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { ref } from 'vue';
|
|
11
|
-
import { DialogPortal, DialogRoot } from 'reka-ui';
|
|
9
|
+
<script setup lang="ts" generic="T = void">
|
|
10
|
+
import { provide, ref } from 'vue';
|
|
11
|
+
import { DialogPortal, DialogRoot, useForwardExpose } from 'reka-ui';
|
|
12
|
+
import type { DialogContent } from 'reka-ui';
|
|
13
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
12
14
|
|
|
13
15
|
import Events from '@aerogel/core/services/Events';
|
|
14
16
|
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
15
17
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
16
|
-
import type {
|
|
18
|
+
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
19
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
17
20
|
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
defineSlots<ModalSlots>();
|
|
21
|
-
|
|
22
|
-
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
23
|
-
const hidden = ref(true);
|
|
24
|
-
const closed = ref(false);
|
|
22
|
+
const $content = ref<Nullable<InstanceType<typeof DialogContent>>>(null);
|
|
25
23
|
const { modal } = injectReactiveOrFail<UIModalContext>(
|
|
26
24
|
'modal',
|
|
27
25
|
'could not obtain modal reference from <HeadlessModal>, ' +
|
|
28
|
-
'did you render this component manually? Show it using $ui.
|
|
26
|
+
'did you render this component manually? Show it using $ui.modal() instead',
|
|
29
27
|
);
|
|
30
28
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
hidden.value = true;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
async function show(): Promise<void> {
|
|
40
|
-
if (!$root.value?.$el) {
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
hidden.value = false;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async function close(result?: unknown) {
|
|
48
|
-
if (closed.value) {
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
Events.emit('modal-will-close', { modal, result });
|
|
29
|
+
defineProps<ModalProps>();
|
|
30
|
+
defineSlots<ModalSlots<T>>();
|
|
31
|
+
defineExpose<AcceptRefs<ModalExpose<T>>>({ close, $content });
|
|
53
32
|
|
|
54
|
-
|
|
33
|
+
const { forwardRef } = useForwardExpose();
|
|
34
|
+
const closed = ref(false);
|
|
55
35
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
Events.emit('modal-closed', { modal, result });
|
|
59
|
-
}
|
|
36
|
+
provide('$modalContentRef', $content);
|
|
60
37
|
|
|
61
38
|
useEvent('close-modal', async ({ id, result }) => {
|
|
62
39
|
if (id !== modal.id) {
|
|
@@ -66,21 +43,15 @@ useEvent('close-modal', async ({ id, result }) => {
|
|
|
66
43
|
await close(result);
|
|
67
44
|
});
|
|
68
45
|
|
|
69
|
-
|
|
70
|
-
if (
|
|
46
|
+
async function close(result?: unknown) {
|
|
47
|
+
if (closed.value) {
|
|
71
48
|
return;
|
|
72
49
|
}
|
|
73
50
|
|
|
74
|
-
await
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
useEvent('show-modal', async ({ id }) => {
|
|
78
|
-
if (id !== modal.id) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
51
|
+
await Events.emit('modal-will-close', { modal, result });
|
|
81
52
|
|
|
82
|
-
|
|
83
|
-
});
|
|
53
|
+
closed.value = true;
|
|
84
54
|
|
|
85
|
-
|
|
55
|
+
await Events.emit('modal-has-closed', { modal, result });
|
|
56
|
+
}
|
|
86
57
|
</script>
|