@aerogel/core 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2 → 0.0.0-next.9e0c0bbdcff5db68a1087ef53cbdc0f53299f6bb
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.d.ts +1615 -1452
- package/dist/aerogel-core.js +2505 -2003
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +10 -3
- package/src/components/{AGAppLayout.vue → AppLayout.vue} +3 -3
- package/src/components/{AGAppModals.vue → AppModals.vue} +2 -3
- package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +4 -9
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +4 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +41 -0
- package/src/components/contracts/DropdownMenu.ts +20 -0
- package/src/components/{modals/AGErrorReportModal.ts → contracts/ErrorReportModal.ts} +3 -23
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +22 -0
- package/src/components/contracts/Modal.ts +14 -9
- package/src/components/contracts/PromptModal.ts +30 -0
- package/src/components/contracts/Select.ts +44 -0
- package/src/components/contracts/Toast.ts +13 -0
- package/src/components/contracts/index.ts +10 -1
- 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} +6 -7
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +2 -6
- package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +16 -25
- package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +2 -6
- package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +9 -12
- package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +47 -43
- 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 +113 -0
- package/src/components/headless/{forms/AGHeadlessSelectError.vue → HeadlessSelectError.vue} +3 -4
- package/src/components/headless/HeadlessSelectLabel.vue +25 -0
- package/src/components/headless/HeadlessSelectOption.vue +34 -0
- package/src/components/headless/HeadlessSelectOptions.vue +37 -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 +5 -10
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +13 -0
- package/src/components/ui/Button.vue +98 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +42 -0
- package/src/components/ui/DropdownMenu.vue +32 -0
- package/src/components/ui/DropdownMenuOption.vue +14 -0
- package/src/components/ui/DropdownMenuOptions.vue +27 -0
- package/src/components/ui/EditableContent.vue +82 -0
- package/src/components/ui/ErrorMessage.vue +15 -0
- package/src/components/ui/ErrorReportModal.vue +62 -0
- package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +28 -21
- 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 +32 -0
- package/src/components/ui/Markdown.vue +69 -0
- package/src/components/ui/Modal.vue +91 -0
- package/src/components/{modals/AGModalContext.vue → ui/ModalContext.vue} +7 -9
- package/src/components/ui/ProgressBar.vue +51 -0
- package/src/components/ui/PromptModal.vue +35 -0
- package/src/components/ui/Select.vue +25 -0
- package/src/components/ui/SelectLabel.vue +17 -0
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +30 -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} +7 -7
- package/src/components/ui/Toast.vue +42 -0
- package/src/components/ui/index.ts +30 -0
- package/src/errors/Errors.ts +9 -10
- package/src/forms/{Form.test.ts → FormController.test.ts} +2 -2
- package/src/forms/{Form.ts → FormController.ts} +5 -5
- package/src/forms/composition.ts +4 -4
- package/src/forms/index.ts +2 -2
- package/src/forms/utils.ts +2 -2
- package/src/index.css +54 -0
- package/src/lang/index.ts +4 -0
- 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/index.ts +3 -0
- package/src/ui/UI.state.ts +10 -5
- package/src/ui/UI.ts +59 -53
- package/src/ui/index.ts +14 -14
- package/src/utils/classes.ts +49 -0
- package/src/utils/composition/forms.ts +14 -4
- package/src/utils/composition/state.ts +11 -2
- package/src/utils/index.ts +3 -1
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +22 -128
- package/src/components/AGAppSnackbars.vue +0 -13
- package/src/components/composition.ts +0 -23
- package/src/components/constants.ts +0 -8
- package/src/components/contracts/shared.ts +0 -9
- package/src/components/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -42
- package/src/components/forms/AGInput.vue +0 -42
- package/src/components/forms/AGSelect.story.vue +0 -46
- package/src/components/forms/AGSelect.vue +0 -54
- 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 -41
- 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/AGHeadlessSelectOption.ts +0 -4
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -31
- package/src/components/headless/forms/AGHeadlessSelectOptions.vue +0 -19
- package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +0 -25
- package/src/components/headless/forms/composition.ts +0 -10
- package/src/components/headless/forms/index.ts +0 -17
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -33
- package/src/components/headless/modals/AGHeadlessModalContent.vue +0 -25
- package/src/components/headless/modals/index.ts +0 -5
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
- package/src/components/headless/snackbars/index.ts +0 -40
- package/src/components/lib/AGErrorMessage.vue +0 -16
- package/src/components/lib/AGLink.vue +0 -9
- package/src/components/lib/AGMarkdown.vue +0 -54
- package/src/components/lib/AGMeasured.vue +0 -16
- package/src/components/lib/AGProgressBar.vue +0 -55
- package/src/components/lib/index.ts +0 -6
- package/src/components/modals/AGAlertModal.ts +0 -18
- package/src/components/modals/AGAlertModal.vue +0 -14
- package/src/components/modals/AGConfirmModal.ts +0 -42
- package/src/components/modals/AGConfirmModal.vue +0 -27
- package/src/components/modals/AGErrorReportModal.vue +0 -54
- package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
- package/src/components/modals/AGLoadingModal.ts +0 -29
- package/src/components/modals/AGLoadingModal.vue +0 -15
- package/src/components/modals/AGModal.vue +0 -40
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalTitle.vue +0 -9
- package/src/components/modals/AGPromptModal.ts +0 -41
- package/src/components/modals/AGPromptModal.vue +0 -35
- package/src/components/modals/index.ts +0 -16
- package/src/components/snackbars/AGSnackbar.vue +0 -36
- package/src/components/snackbars/index.ts +0 -3
- package/src/components/utils.ts +0 -63
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerogel/core",
|
|
3
|
-
"version": "0.0.0-next.
|
|
3
|
+
"version": "0.0.0-next.9e0c0bbdcff5db68a1087ef53cbdc0f53299f6bb",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
7
7
|
"types": "./dist/aerogel-core.d.ts",
|
|
8
|
+
"style": "./src/index.css",
|
|
8
9
|
"default": "./dist/aerogel-core.js"
|
|
9
10
|
},
|
|
10
11
|
"files": [
|
|
@@ -22,14 +23,20 @@
|
|
|
22
23
|
"verify": "noeldemartin-verify"
|
|
23
24
|
},
|
|
24
25
|
"peerDependencies": {
|
|
25
|
-
"
|
|
26
|
+
"@tailwindcss/forms": "^0.5.10",
|
|
27
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
28
|
+
"vue": "^3.5.0",
|
|
29
|
+
"tailwindcss": "^4.1.1"
|
|
26
30
|
},
|
|
27
31
|
"dependencies": {
|
|
28
32
|
"@noeldemartin/utils": "0.7.0-next.31cf84b4b57092d146528f27579439783aca71bb",
|
|
33
|
+
"class-variance-authority": "^0.7.1",
|
|
34
|
+
"clsx": "^2.1.1",
|
|
29
35
|
"dompurify": "^3.2.4",
|
|
30
36
|
"marked": "^15.0.7",
|
|
31
37
|
"pinia": "^2.1.6",
|
|
32
|
-
"reka-ui": "^2.2.0"
|
|
38
|
+
"reka-ui": "^2.2.0",
|
|
39
|
+
"tailwind-merge": "^3.1.0"
|
|
33
40
|
},
|
|
34
41
|
"devDependencies": {
|
|
35
42
|
"@aerogel/vite": "*"
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex min-h-full flex-col text-base font-normal
|
|
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
4
|
<component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
|
|
5
5
|
</slot>
|
|
6
6
|
<slot v-else />
|
|
7
7
|
|
|
8
|
-
<
|
|
8
|
+
<AppOverlays />
|
|
9
9
|
</div>
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
13
|
import { UIComponents } from '@aerogel/core/ui/UI';
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import AppOverlays from './AppOverlays.vue';
|
|
16
16
|
</script>
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<aside v-if="modal">
|
|
3
|
-
<
|
|
3
|
+
<ModalContext :child-index="1" :modal />
|
|
4
4
|
</aside>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
|
|
10
|
+
import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
|
|
10
11
|
import UI from '@aerogel/core/ui/UI';
|
|
11
12
|
|
|
12
|
-
import AGModalContext from './modals/AGModalContext.vue';
|
|
13
|
-
|
|
14
13
|
const modal = computed(() => UI.modals[0] ?? null);
|
|
15
14
|
</script>
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
ref="$backdrop"
|
|
5
|
-
class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
|
|
6
|
-
/>
|
|
7
|
-
<AGAppModals />
|
|
8
|
-
<AGAppSnackbars />
|
|
2
|
+
<AppModals />
|
|
3
|
+
<AppToasts />
|
|
9
4
|
</template>
|
|
10
5
|
|
|
11
6
|
<script setup lang="ts">
|
|
@@ -13,8 +8,8 @@ import { ref } from 'vue';
|
|
|
13
8
|
|
|
14
9
|
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
15
10
|
|
|
16
|
-
import
|
|
17
|
-
import
|
|
11
|
+
import AppModals from './AppModals.vue';
|
|
12
|
+
import AppToasts from './AppToasts.vue';
|
|
18
13
|
|
|
19
14
|
const $backdrop = ref<HTMLElement | null>(null);
|
|
20
15
|
const backdropHidden = ref(true);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ToastProvider>
|
|
3
|
+
<component
|
|
4
|
+
:is="toast.component"
|
|
5
|
+
v-for="toast of $ui.toasts"
|
|
6
|
+
:id="toast.id"
|
|
7
|
+
:key="toast.id"
|
|
8
|
+
v-bind="toast.properties"
|
|
9
|
+
/>
|
|
10
|
+
<ToastViewport class="fixed right-0 bottom-0 z-50 flex flex-col items-end space-y-4 px-4 py-6 sm:p-6" />
|
|
11
|
+
</ToastProvider>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { ToastProvider, ToastViewport } from 'reka-ui';
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
|
|
4
|
+
export type ButtonVariant = 'default' | 'secondary' | 'danger' | 'ghost' | 'outline' | 'link';
|
|
5
|
+
export type ButtonSize = 'default' | 'small' | 'large' | 'icon';
|
|
6
|
+
export interface ButtonProps extends PrimitiveProps {
|
|
7
|
+
class?: HTMLAttributes['class'];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
href?: string;
|
|
10
|
+
route?: string;
|
|
11
|
+
routeParams?: object;
|
|
12
|
+
routeQuery?: object;
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
submit?: boolean;
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
+
import { FormFieldTypes, useForm } from '@aerogel/core/forms';
|
|
5
|
+
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
|
6
|
+
import type { FormFieldDefinition } from '@aerogel/core/forms';
|
|
7
|
+
|
|
8
|
+
export type ConfirmModalCheckboxes = Record<string, { label: string; default?: boolean; required?: boolean }>;
|
|
9
|
+
|
|
10
|
+
export interface ConfirmModalProps {
|
|
11
|
+
title?: string;
|
|
12
|
+
message: string;
|
|
13
|
+
acceptText?: string;
|
|
14
|
+
acceptVariant?: ButtonVariant;
|
|
15
|
+
cancelText?: string;
|
|
16
|
+
cancelVariant?: ButtonVariant;
|
|
17
|
+
checkboxes?: ConfirmModalCheckboxes;
|
|
18
|
+
actions?: Record<string, () => unknown>;
|
|
19
|
+
required?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
23
|
+
export function useConfirmModal(props: ConfirmModalProps) {
|
|
24
|
+
const form = useForm(
|
|
25
|
+
Object.entries(props.checkboxes ?? {}).reduce(
|
|
26
|
+
(values, [name, checkbox]) => ({
|
|
27
|
+
[name]: {
|
|
28
|
+
type: FormFieldTypes.Boolean,
|
|
29
|
+
default: checkbox.default,
|
|
30
|
+
required: checkbox.required ? 'required' : undefined,
|
|
31
|
+
},
|
|
32
|
+
...values,
|
|
33
|
+
}),
|
|
34
|
+
{} as Record<string, FormFieldDefinition>,
|
|
35
|
+
),
|
|
36
|
+
);
|
|
37
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
38
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
39
|
+
|
|
40
|
+
return { form, renderedAcceptText, renderedCancelText };
|
|
41
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { DropdownMenuContentProps } from 'reka-ui';
|
|
2
|
+
|
|
3
|
+
import type { Falsifiable } from '@aerogel/core/utils/types';
|
|
4
|
+
|
|
5
|
+
export type DropdownMenuOptionData = {
|
|
6
|
+
label: string;
|
|
7
|
+
click: () => unknown;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export interface DropdownMenuProps {
|
|
11
|
+
align?: DropdownMenuContentProps['align'];
|
|
12
|
+
side?: DropdownMenuContentProps['side'];
|
|
13
|
+
options?: Falsifiable<DropdownMenuOptionData>[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface DropdownMenuExpose {
|
|
17
|
+
align?: DropdownMenuContentProps['align'];
|
|
18
|
+
side?: DropdownMenuContentProps['side'];
|
|
19
|
+
options?: DropdownMenuOptionData[];
|
|
20
|
+
}
|
|
@@ -1,34 +1,14 @@
|
|
|
1
1
|
import { computed, ref } from 'vue';
|
|
2
|
-
import type { Component, ExtractPropTypes } from 'vue';
|
|
3
|
-
import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
|
|
4
2
|
|
|
5
|
-
import { requiredArrayProp } from '@aerogel/core/utils/vue';
|
|
6
3
|
import { translateWithDefault } from '@aerogel/core/lang';
|
|
7
|
-
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
8
4
|
import type { ErrorReport } from '@aerogel/core/errors';
|
|
9
5
|
|
|
10
|
-
export interface
|
|
11
|
-
|
|
12
|
-
description: string;
|
|
13
|
-
iconComponent: Component;
|
|
14
|
-
url?: string;
|
|
15
|
-
handler?(): void;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const errorReportModalProps = {
|
|
19
|
-
reports: requiredArrayProp<ErrorReport>(),
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type AGErrorReportModalProps = Pretty<
|
|
23
|
-
AcceptRefs<ObjectWithout<ExtractPropTypes<typeof errorReportModalProps>, null | undefined>>
|
|
24
|
-
>;
|
|
25
|
-
|
|
26
|
-
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
27
|
-
return errorReportModalProps;
|
|
6
|
+
export interface ErrorReportModalProps {
|
|
7
|
+
reports: ErrorReport[];
|
|
28
8
|
}
|
|
29
9
|
|
|
30
10
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
31
|
-
export function useErrorReportModal(props:
|
|
11
|
+
export function useErrorReportModal(props: ErrorReportModalProps) {
|
|
32
12
|
const activeReportIndex = ref(0);
|
|
33
13
|
const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
34
14
|
const details = computed(
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
2
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
5
|
+
|
|
6
|
+
export interface InputProps {
|
|
7
|
+
name?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
modelValue?: Nullable<FormFieldValue>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface InputEmits {
|
|
14
|
+
'update:modelValue': [value: Nullable<FormFieldValue>];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface InputExpose {
|
|
18
|
+
id: string;
|
|
19
|
+
name: ComputedRef<Nullable<string>>;
|
|
20
|
+
label: ComputedRef<Nullable<string>>;
|
|
21
|
+
description: ComputedRef<Nullable<string | boolean>>;
|
|
22
|
+
value: ComputedRef<Nullable<FormFieldValue>>;
|
|
23
|
+
required: ComputedRef<Nullable<boolean>>;
|
|
24
|
+
errors: DeepReadonly<Ref<Nullable<string[]>>>;
|
|
25
|
+
update(value: Nullable<FormFieldValue>): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Job } from '@aerogel/core/jobs';
|
|
2
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
3
|
+
import { computed } from 'vue';
|
|
4
|
+
|
|
5
|
+
export interface LoadingModalProps {
|
|
6
|
+
title?: string;
|
|
7
|
+
message?: string;
|
|
8
|
+
progress?: number;
|
|
9
|
+
job?: Job;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
13
|
+
export function useLoadingModal(props: LoadingModalProps) {
|
|
14
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.loading', 'Loading'));
|
|
15
|
+
const renderedMessage = computed(
|
|
16
|
+
() => props.message ?? translateWithDefault('ui.loadingInProgress', 'Loading in progress...'),
|
|
17
|
+
);
|
|
18
|
+
const showProgress = computed(() => typeof props.progress === 'number' || !!props.job);
|
|
19
|
+
const titleHidden = computed(() => !props.title);
|
|
20
|
+
|
|
21
|
+
return { renderedTitle, renderedMessage, titleHidden, showProgress };
|
|
22
|
+
}
|
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
2
|
+
import type { DialogContent } from 'reka-ui';
|
|
2
3
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
export type ModalContentInstance = Nullable<InstanceType<typeof DialogContent>>;
|
|
5
|
+
|
|
6
|
+
export interface ModalProps {
|
|
7
|
+
persistent?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
titleHidden?: boolean;
|
|
10
|
+
description?: string;
|
|
11
|
+
descriptionHidden?: boolean;
|
|
6
12
|
}
|
|
7
13
|
|
|
8
|
-
export interface
|
|
9
|
-
|
|
10
|
-
title: string | null;
|
|
11
|
-
description: string | null;
|
|
14
|
+
export interface ModalSlots {
|
|
15
|
+
default(props: { close(result?: unknown): Promise<void> }): unknown;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
|
-
export interface
|
|
18
|
+
export interface ModalExpose {
|
|
15
19
|
close(result?: unknown): Promise<void>;
|
|
20
|
+
$content: ModalContentInstance;
|
|
16
21
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { requiredStringInput, useForm } from '@aerogel/core/forms';
|
|
4
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
5
|
+
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
|
6
|
+
|
|
7
|
+
export interface PromptModalProps {
|
|
8
|
+
title?: string;
|
|
9
|
+
message: string;
|
|
10
|
+
label?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
placeholder?: string;
|
|
13
|
+
acceptText?: string;
|
|
14
|
+
acceptVariant?: ButtonVariant;
|
|
15
|
+
cancelText?: string;
|
|
16
|
+
cancelVariant?: ButtonVariant;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
20
|
+
export function usePromptModal(props: PromptModalProps) {
|
|
21
|
+
const form = useForm({
|
|
22
|
+
draft: requiredStringInput(props.defaultValue ?? ''),
|
|
23
|
+
});
|
|
24
|
+
const renderedTitle = computed(() => props.title ?? props.message);
|
|
25
|
+
const renderedMessage = computed(() => (props.title ? props.message : null));
|
|
26
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
27
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
28
|
+
|
|
29
|
+
return { form, renderedTitle, renderedMessage, renderedAcceptText, renderedCancelText };
|
|
30
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
|
|
2
|
+
import type { Component, ComputedRef, HTMLAttributes } from 'vue';
|
|
3
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import type { InputEmits, InputExpose, InputProps } from './Input';
|
|
6
|
+
|
|
7
|
+
export type SelectOptionData = {
|
|
8
|
+
key: string;
|
|
9
|
+
label: string;
|
|
10
|
+
value: AcceptableValue;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export interface HasSelectOptionLabel {
|
|
14
|
+
label: string | (() => string);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface SelectProps extends InputProps {
|
|
18
|
+
as?: AsTag | Component;
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
options?: any[];
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
renderOption?: (option: any) => string;
|
|
24
|
+
labelClass?: HTMLAttributes['class'];
|
|
25
|
+
optionsClass?: HTMLAttributes['class'];
|
|
26
|
+
align?: SelectContentProps['align'];
|
|
27
|
+
side?: SelectContentProps['side'];
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface SelectEmits extends InputEmits {}
|
|
31
|
+
|
|
32
|
+
export interface SelectExpose extends InputExpose {
|
|
33
|
+
options: ComputedRef<Nullable<SelectOptionData[]>>;
|
|
34
|
+
selectedOption: ComputedRef<Nullable<SelectOptionData>>;
|
|
35
|
+
placeholder: ComputedRef<string>;
|
|
36
|
+
labelClass?: HTMLAttributes['class'];
|
|
37
|
+
optionsClass?: HTMLAttributes['class'];
|
|
38
|
+
align?: SelectContentProps['align'];
|
|
39
|
+
side?: SelectContentProps['side'];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
|
|
43
|
+
return typeof option === 'object' && option !== null && 'label' in option;
|
|
44
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ToastAction {
|
|
2
|
+
label: string;
|
|
3
|
+
dismiss?: boolean;
|
|
4
|
+
click?(): unknown;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type ToastVariant = 'secondary' | 'danger';
|
|
8
|
+
|
|
9
|
+
export interface ToastProps {
|
|
10
|
+
message?: string;
|
|
11
|
+
actions?: ToastAction[];
|
|
12
|
+
variant?: ToastVariant;
|
|
13
|
+
}
|
|
@@ -1,2 +1,11 @@
|
|
|
1
|
+
export * from './AlertModal';
|
|
2
|
+
export * from './Button';
|
|
3
|
+
export * from './ConfirmModal';
|
|
4
|
+
export * from './DropdownMenu';
|
|
5
|
+
export * from './ErrorReportModal';
|
|
6
|
+
export * from './Input';
|
|
7
|
+
export * from './LoadingModal';
|
|
1
8
|
export * from './Modal';
|
|
2
|
-
export * from './
|
|
9
|
+
export * from './PromptModal';
|
|
10
|
+
export * from './Select';
|
|
11
|
+
export * from './Toast';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Primitive
|
|
3
|
+
:class="classes"
|
|
4
|
+
:as-child
|
|
5
|
+
:disabled
|
|
6
|
+
v-bind="props"
|
|
7
|
+
>
|
|
8
|
+
<slot />
|
|
9
|
+
</Primitive>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
import { Primitive } from 'reka-ui';
|
|
15
|
+
import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
16
|
+
|
|
17
|
+
import UI, { UIComponents } from '@aerogel/core/ui/UI';
|
|
18
|
+
import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
|
|
19
|
+
|
|
20
|
+
const { as, href, route, routeParams, routeQuery, submit, disabled, class: classes } = defineProps<ButtonProps>();
|
|
21
|
+
|
|
22
|
+
const props = computed(() => {
|
|
23
|
+
if (as) {
|
|
24
|
+
return { as };
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (route) {
|
|
28
|
+
return {
|
|
29
|
+
as: UI.resolveComponent(UIComponents.RouterLink) ?? 'a',
|
|
30
|
+
to: objectWithoutEmpty({
|
|
31
|
+
name: route,
|
|
32
|
+
params: routeParams,
|
|
33
|
+
query: routeQuery,
|
|
34
|
+
}),
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
if (href) {
|
|
39
|
+
return {
|
|
40
|
+
as: 'a',
|
|
41
|
+
target: '_blank',
|
|
42
|
+
href,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
as: 'button',
|
|
48
|
+
type: submit ? 'submit' : 'button',
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="as">
|
|
3
|
+
<slot />
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed, inject, provide, readonly } from 'vue';
|
|
9
|
+
import { uuid } from '@noeldemartin/utils';
|
|
10
|
+
|
|
11
|
+
import type FormController from '@aerogel/core/forms/FormController';
|
|
12
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
13
|
+
import type { InputEmits, InputExpose, InputProps } from '@aerogel/core/components/contracts/Input';
|
|
14
|
+
|
|
15
|
+
const { as = 'div', name, label, description, modelValue } = defineProps<InputProps & { as?: string }>();
|
|
16
|
+
const emit = defineEmits<InputEmits>();
|
|
17
|
+
const form = inject<FormController | null>('form', null);
|
|
18
|
+
const errors = computed(() => {
|
|
19
|
+
if (!form || !name) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return form.errors[name] ?? null;
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const expose = {
|
|
27
|
+
id: `input-${uuid()}`,
|
|
28
|
+
name: computed(() => name),
|
|
29
|
+
label: computed(() => label),
|
|
30
|
+
description: computed(() => description),
|
|
31
|
+
value: computed(() => {
|
|
32
|
+
if (form && name) {
|
|
33
|
+
return form.getFieldValue(name);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return modelValue;
|
|
37
|
+
}),
|
|
38
|
+
errors: readonly(errors),
|
|
39
|
+
required: computed(() => {
|
|
40
|
+
if (!name || !form) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return form.getFieldRules(name).includes('required');
|
|
45
|
+
}),
|
|
46
|
+
update(value) {
|
|
47
|
+
if (form && name) {
|
|
48
|
+
form.setFieldValue(name, value as FormFieldValue);
|
|
49
|
+
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
emit('update:modelValue', value);
|
|
54
|
+
},
|
|
55
|
+
} satisfies InputExpose;
|
|
56
|
+
|
|
57
|
+
provide('input', expose);
|
|
58
|
+
defineExpose(expose);
|
|
59
|
+
</script>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot :id="`${input.id}-description`">
|
|
3
|
-
<
|
|
3
|
+
<Markdown
|
|
4
4
|
v-if="show"
|
|
5
5
|
v-bind="$attrs"
|
|
6
6
|
:id="`${input.id}-description`"
|
|
7
|
-
:text
|
|
7
|
+
:text
|
|
8
8
|
/>
|
|
9
9
|
</slot>
|
|
10
10
|
</template>
|
|
@@ -12,16 +12,15 @@
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
13
|
import { computed } from 'vue';
|
|
14
14
|
|
|
15
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
15
16
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
16
|
-
|
|
17
|
-
import AGMarkdown from '../../lib/AGMarkdown.vue';
|
|
18
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
17
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
19
18
|
|
|
20
19
|
defineOptions({ inheritAttrs: false });
|
|
21
20
|
|
|
22
|
-
const input = injectReactiveOrFail<
|
|
21
|
+
const input = injectReactiveOrFail<InputExpose>(
|
|
23
22
|
'input',
|
|
24
|
-
'<
|
|
23
|
+
'<HeadlessInputDescription> must be a child of a <HeadlessInput>',
|
|
25
24
|
);
|
|
26
25
|
const text = computed(() => (typeof input.description === 'string' ? input.description : ''));
|
|
27
26
|
const show = computed(() => !!input.description);
|
|
@@ -9,13 +9,9 @@ import { computed } from 'vue';
|
|
|
9
9
|
|
|
10
10
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
11
11
|
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
12
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
16
|
-
'input',
|
|
17
|
-
'<AGHeadlessInputError> must be a child of a <AGHeadlessInput>',
|
|
18
|
-
);
|
|
14
|
+
const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputError> must be a child of a <HeadlessInput>');
|
|
19
15
|
const errorMessage = computed(() => {
|
|
20
16
|
if (!input.errors) {
|
|
21
17
|
return null;
|