@aerogel/core 0.0.0-next.b3caf219a503ce9b8c65ef1463132c9507f56c0a → 0.0.0-next.b656a964404fbde17d9cce7668722596098e47fd
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 +958 -491
- package/dist/aerogel-core.js +1987 -1828
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +5 -2
- package/src/components/AppModals.vue +1 -1
- package/src/components/AppOverlays.vue +2 -7
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/Button.ts +1 -0
- package/src/components/contracts/DropdownMenu.ts +11 -0
- package/src/components/contracts/Input.ts +5 -5
- package/src/components/contracts/Modal.ts +4 -0
- package/src/components/contracts/Select.ts +36 -0
- package/src/components/contracts/Toast.ts +13 -0
- package/src/components/contracts/index.ts +2 -0
- package/src/components/headless/HeadlessButton.vue +7 -2
- package/src/components/headless/HeadlessInputDescription.vue +3 -3
- package/src/components/headless/HeadlessInputInput.vue +4 -4
- package/src/components/headless/HeadlessInputTextArea.vue +3 -3
- package/src/components/headless/HeadlessModal.vue +4 -2
- package/src/components/headless/HeadlessModalOverlay.vue +2 -2
- package/src/components/headless/HeadlessModalTitle.vue +2 -2
- package/src/components/headless/HeadlessSelect.vue +104 -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 +30 -0
- package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
- package/src/components/headless/HeadlessSelectValue.vue +15 -0
- package/src/components/headless/HeadlessToast.vue +18 -0
- package/src/components/headless/HeadlessToastAction.vue +13 -0
- package/src/components/headless/index.ts +7 -3
- package/src/components/index.ts +4 -9
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +3 -3
- package/src/components/ui/Button.vue +56 -16
- package/src/components/ui/Checkbox.vue +18 -11
- package/src/components/ui/ConfirmModal.vue +4 -4
- package/src/components/ui/DropdownMenu.vue +33 -0
- package/src/components/ui/EditableContent.vue +82 -0
- package/src/components/ui/ErrorMessage.vue +15 -0
- package/src/components/ui/ErrorReportModal.vue +3 -3
- package/src/components/ui/ErrorReportModalButtons.vue +6 -8
- package/src/components/ui/ErrorReportModalTitle.vue +2 -2
- package/src/components/ui/Input.vue +9 -5
- package/src/components/ui/Link.vue +2 -2
- package/src/components/ui/LoadingModal.vue +5 -5
- package/src/components/ui/Markdown.vue +69 -0
- package/src/components/ui/Modal.vue +26 -11
- package/src/components/ui/ProgressBar.vue +1 -1
- package/src/components/ui/PromptModal.vue +6 -6
- package/src/components/ui/Select.vue +21 -0
- package/src/components/ui/SelectLabel.vue +10 -0
- package/src/components/ui/SelectOptions.vue +31 -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} +3 -3
- package/src/components/ui/Toast.vue +42 -0
- package/src/components/ui/index.ts +12 -0
- package/src/errors/Errors.ts +4 -5
- package/src/index.css +38 -0
- package/src/lang/index.ts +3 -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 +3 -0
- package/src/services/index.ts +3 -0
- package/src/ui/UI.state.ts +2 -2
- package/src/ui/UI.ts +12 -20
- package/src/ui/index.ts +4 -4
- package/src/utils/classes.ts +49 -0
- package/src/utils/composition/forms.ts +10 -1
- package/src/utils/composition/state.ts +11 -2
- package/src/utils/index.ts +2 -1
- package/src/utils/vue.ts +22 -128
- package/src/components/AppSnackbars.vue +0 -13
- package/src/components/composition.ts +0 -23
- package/src/components/constants.ts +0 -8
- package/src/components/forms/AGSelect.story.vue +0 -46
- package/src/components/forms/AGSelect.vue +0 -54
- package/src/components/forms/index.ts +0 -1
- 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 -8
- 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/AGMarkdown.vue +0 -54
- package/src/components/lib/AGMeasured.vue +0 -16
- package/src/components/lib/index.ts +0 -4
- package/src/components/snackbars/AGSnackbar.vue +0 -38
- package/src/components/snackbars/index.ts +0 -3
- package/src/components/utils.ts +0 -107
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
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.b656a964404fbde17d9cce7668722596098e47fd",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"exports": {
|
|
@@ -23,7 +23,10 @@
|
|
|
23
23
|
"verify": "noeldemartin-verify"
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"
|
|
26
|
+
"@tailwindcss/forms": "^0.5.10",
|
|
27
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
28
|
+
"vue": "^3.5.0",
|
|
29
|
+
"tailwindcss": "^4.1.1"
|
|
27
30
|
},
|
|
28
31
|
"dependencies": {
|
|
29
32
|
"@noeldemartin/utils": "0.7.0-next.31cf84b4b57092d146528f27579439783aca71bb",
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
id="aerogel-overlays-backdrop"
|
|
4
|
-
ref="$backdrop"
|
|
5
|
-
class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
|
|
6
|
-
/>
|
|
7
2
|
<AppModals />
|
|
8
|
-
<
|
|
3
|
+
<AppToasts />
|
|
9
4
|
</template>
|
|
10
5
|
|
|
11
6
|
<script setup lang="ts">
|
|
@@ -14,7 +9,7 @@ import { ref } from 'vue';
|
|
|
14
9
|
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
15
10
|
|
|
16
11
|
import AppModals from './AppModals.vue';
|
|
17
|
-
import
|
|
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>
|
|
@@ -5,6 +5,7 @@ export type ButtonVariant = 'default' | 'secondary' | 'danger' | 'ghost' | 'outl
|
|
|
5
5
|
export type ButtonSize = 'default' | 'small' | 'large' | 'icon';
|
|
6
6
|
export interface ButtonProps extends PrimitiveProps {
|
|
7
7
|
class?: HTMLAttributes['class'];
|
|
8
|
+
disabled?: boolean;
|
|
8
9
|
href?: string;
|
|
9
10
|
route?: string;
|
|
10
11
|
routeParams?: object;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DropdownMenuContentProps } from 'reka-ui';
|
|
2
|
+
|
|
3
|
+
export type DropdownMenuOption = {
|
|
4
|
+
label: string;
|
|
5
|
+
click: () => unknown;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export interface DropdownMenuProps {
|
|
9
|
+
align?: DropdownMenuContentProps['align'];
|
|
10
|
+
options?: DropdownMenuOption[];
|
|
11
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
+
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
1
2
|
import type { Nullable } from '@noeldemartin/utils';
|
|
2
3
|
|
|
3
4
|
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
4
|
-
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
5
5
|
|
|
6
6
|
export interface InputProps {
|
|
7
7
|
name?: string;
|
|
8
8
|
label?: string;
|
|
9
9
|
description?: string;
|
|
10
|
-
modelValue?: FormFieldValue
|
|
10
|
+
modelValue?: Nullable<FormFieldValue>;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
|
|
15
|
-
}
|
|
13
|
+
export interface InputEmits {
|
|
14
|
+
'update:modelValue': [value: Nullable<FormFieldValue>];
|
|
15
|
+
}
|
|
16
16
|
|
|
17
17
|
export interface InputExpose {
|
|
18
18
|
id: string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { AcceptableValue, AsTag } from 'reka-ui';
|
|
2
|
+
import type { Component, ComputedRef } from 'vue';
|
|
3
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import type { InputEmits, InputExpose, InputProps } from './Input';
|
|
6
|
+
|
|
7
|
+
export type SelectOption = {
|
|
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
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SelectEmits extends InputEmits {}
|
|
27
|
+
|
|
28
|
+
export interface SelectExpose extends InputExpose {
|
|
29
|
+
options: ComputedRef<Nullable<SelectOption[]>>;
|
|
30
|
+
selectedOption: ComputedRef<Nullable<SelectOption>>;
|
|
31
|
+
placeholder: ComputedRef<string>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
|
|
35
|
+
return typeof option === 'object' && option !== null && 'label' in option;
|
|
36
|
+
}
|
|
@@ -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,7 +1,9 @@
|
|
|
1
1
|
export * from './AlertModal';
|
|
2
2
|
export * from './Button';
|
|
3
3
|
export * from './ConfirmModal';
|
|
4
|
+
export * from './DropdownMenu';
|
|
4
5
|
export * from './LoadingModal';
|
|
5
6
|
export * from './Modal';
|
|
6
7
|
export * from './PromptModal';
|
|
8
|
+
export * from './Select';
|
|
7
9
|
export * from './shared';
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Primitive
|
|
2
|
+
<Primitive
|
|
3
|
+
:class="classes"
|
|
4
|
+
:as-child
|
|
5
|
+
:disabled
|
|
6
|
+
v-bind="props"
|
|
7
|
+
>
|
|
3
8
|
<slot />
|
|
4
9
|
</Primitive>
|
|
5
10
|
</template>
|
|
@@ -11,7 +16,7 @@ import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
|
11
16
|
|
|
12
17
|
import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
|
|
13
18
|
|
|
14
|
-
const { as, href, route, routeParams, routeQuery, submit, class: classes } = defineProps<ButtonProps>();
|
|
19
|
+
const { as, href, route, routeParams, routeQuery, submit, disabled, class: classes } = defineProps<ButtonProps>();
|
|
15
20
|
|
|
16
21
|
const props = computed(() => {
|
|
17
22
|
if (as) {
|
|
@@ -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,7 +12,7 @@
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
13
|
import { computed } from 'vue';
|
|
14
14
|
|
|
15
|
-
import
|
|
15
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
16
16
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
17
|
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
18
18
|
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
<input
|
|
3
3
|
:id="input.id"
|
|
4
4
|
ref="$input"
|
|
5
|
-
:name
|
|
6
|
-
:type
|
|
5
|
+
:name
|
|
6
|
+
:type
|
|
7
|
+
:checked
|
|
7
8
|
:required="input.required ?? undefined"
|
|
8
9
|
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
9
10
|
:aria-describedby="
|
|
10
11
|
input.errors ? `${input.id}-error` : input.description ? `${input.id}-description` : undefined
|
|
11
12
|
"
|
|
12
|
-
:checked="checked"
|
|
13
13
|
@input="update"
|
|
14
14
|
>
|
|
15
15
|
</template>
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { computed, ref, 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
22
|
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
23
23
|
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
24
24
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
<textarea
|
|
3
3
|
:id="input.id"
|
|
4
4
|
ref="$textArea"
|
|
5
|
-
:name
|
|
5
|
+
:name
|
|
6
|
+
:value
|
|
6
7
|
:required="input.required ?? undefined"
|
|
7
|
-
:value="value"
|
|
8
8
|
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
9
9
|
:aria-describedby="
|
|
10
10
|
input.errors ? `${input.id}-error` : input.description ? `${input.id}-description` : undefined
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
17
|
import { computed, ref } 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
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DialogRoot ref="$root"
|
|
2
|
+
<DialogRoot ref="$root" open @update:open="persistent || close()">
|
|
3
3
|
<DialogPortal>
|
|
4
4
|
<slot :close="close" />
|
|
5
5
|
</DialogPortal>
|
|
@@ -14,7 +14,7 @@ import Events from '@aerogel/core/services/Events';
|
|
|
14
14
|
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
15
15
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
16
16
|
import type { UIModalContext } from '@aerogel/core/ui/UI.state';
|
|
17
|
-
import type { ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
17
|
+
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
18
18
|
|
|
19
19
|
defineProps<ModalProps>();
|
|
20
20
|
defineSlots<ModalSlots>();
|
|
@@ -81,4 +81,6 @@ useEvent('show-modal', async ({ id }) => {
|
|
|
81
81
|
|
|
82
82
|
await show();
|
|
83
83
|
});
|
|
84
|
+
|
|
85
|
+
defineExpose<ModalExpose>({ close });
|
|
84
86
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DialogOverlay v-bind="props">
|
|
2
|
+
<DialogOverlay v-bind="$props">
|
|
3
3
|
<slot />
|
|
4
4
|
</DialogOverlay>
|
|
5
5
|
</template>
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
import { DialogOverlay } from 'reka-ui';
|
|
9
9
|
import type { DialogOverlayProps } from 'reka-ui';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
defineProps<DialogOverlayProps>();
|
|
12
12
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DialogTitle v-bind="props">
|
|
2
|
+
<DialogTitle v-bind="$props">
|
|
3
3
|
<slot />
|
|
4
4
|
</DialogTitle>
|
|
5
5
|
</template>
|
|
@@ -8,5 +8,5 @@
|
|
|
8
8
|
import { DialogTitle } from 'reka-ui';
|
|
9
9
|
import type { DialogTitleProps } from 'reka-ui';
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
defineProps<DialogTitleProps>();
|
|
12
12
|
</script>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectRoot v-slot="{ open }" :model-value="acceptableValue" @update:model-value="update($event)">
|
|
3
|
+
<component :is="as" v-bind="$attrs">
|
|
4
|
+
<slot :model-value :open>
|
|
5
|
+
<HeadlessSelectTrigger />
|
|
6
|
+
<HeadlessSelectOptions />
|
|
7
|
+
</slot>
|
|
8
|
+
</component>
|
|
9
|
+
</SelectRoot>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed, inject, provide, readonly } from 'vue';
|
|
14
|
+
import { value as evaluate, toString, uuid } from '@noeldemartin/utils';
|
|
15
|
+
import { SelectRoot } from 'reka-ui';
|
|
16
|
+
import type { AcceptableValue } from 'reka-ui';
|
|
17
|
+
|
|
18
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
19
|
+
import { hasSelectOptionLabel } from '@aerogel/core/components/contracts/Select';
|
|
20
|
+
import type FormController from '@aerogel/core/forms/FormController';
|
|
21
|
+
import type { SelectEmits, SelectExpose, SelectProps } from '@aerogel/core/components/contracts/Select';
|
|
22
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
23
|
+
|
|
24
|
+
import HeadlessSelectTrigger from './HeadlessSelectTrigger.vue';
|
|
25
|
+
import HeadlessSelectOptions from './HeadlessSelectOptions.vue';
|
|
26
|
+
|
|
27
|
+
defineOptions({ inheritAttrs: false });
|
|
28
|
+
|
|
29
|
+
const {
|
|
30
|
+
name,
|
|
31
|
+
as = 'template',
|
|
32
|
+
label,
|
|
33
|
+
options,
|
|
34
|
+
renderOption,
|
|
35
|
+
description,
|
|
36
|
+
placeholder,
|
|
37
|
+
modelValue,
|
|
38
|
+
} = defineProps<SelectProps>();
|
|
39
|
+
const emit = defineEmits<SelectEmits>();
|
|
40
|
+
const form = inject<FormController | null>('form', null);
|
|
41
|
+
const acceptableValue = computed(() => modelValue as AcceptableValue);
|
|
42
|
+
const errors = computed(() => {
|
|
43
|
+
if (!form || !name) {
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return form.errors[name] ?? null;
|
|
48
|
+
});
|
|
49
|
+
const computedOptions = computed(() => {
|
|
50
|
+
if (!options) {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return options.map((option) => ({
|
|
55
|
+
key: uuid(),
|
|
56
|
+
label: renderOption
|
|
57
|
+
? renderOption(option)
|
|
58
|
+
: hasSelectOptionLabel(option)
|
|
59
|
+
? evaluate(option.label as string)
|
|
60
|
+
: toString(option),
|
|
61
|
+
value: option as AcceptableValue,
|
|
62
|
+
}));
|
|
63
|
+
});
|
|
64
|
+
const context = {
|
|
65
|
+
id: `select-${uuid()}`,
|
|
66
|
+
name: computed(() => name),
|
|
67
|
+
label: computed(() => label),
|
|
68
|
+
description: computed(() => description),
|
|
69
|
+
placeholder: computed(() => placeholder ?? translateWithDefault('ui.select', 'Select an option')),
|
|
70
|
+
options: computedOptions,
|
|
71
|
+
selectedOption: computed(() => computedOptions.value?.find((option) => option.value === modelValue)),
|
|
72
|
+
value: computed(() => {
|
|
73
|
+
if (form && name) {
|
|
74
|
+
return form.getFieldValue(name);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return modelValue;
|
|
78
|
+
}),
|
|
79
|
+
errors: readonly(errors),
|
|
80
|
+
required: computed(() => {
|
|
81
|
+
if (!name || !form) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return form.getFieldRules(name).includes('required');
|
|
86
|
+
}),
|
|
87
|
+
update(value) {
|
|
88
|
+
if (form && name) {
|
|
89
|
+
form.setFieldValue(name, value as FormFieldValue);
|
|
90
|
+
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
emit('update:modelValue', value);
|
|
95
|
+
},
|
|
96
|
+
} satisfies SelectExpose;
|
|
97
|
+
|
|
98
|
+
function update(value: AcceptableValue) {
|
|
99
|
+
context.update(value as FormFieldValue);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
provide('select', context);
|
|
103
|
+
defineExpose(context);
|
|
104
|
+
</script>
|
|
@@ -9,12 +9,11 @@ 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 { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
14
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
16
15
|
'select',
|
|
17
|
-
'<
|
|
16
|
+
'<HeadlessSelectError> must be a child of a <HeadlessSelect>',
|
|
18
17
|
);
|
|
19
18
|
const errorMessage = computed(() => {
|
|
20
19
|
if (!select.errors) {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Label v-if="show" :for="select.id" v-bind="$props">
|
|
3
|
+
<slot>
|
|
4
|
+
{{ select.label }}
|
|
5
|
+
</slot>
|
|
6
|
+
</Label>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed, useSlots } from 'vue';
|
|
11
|
+
import { Label } from 'reka-ui';
|
|
12
|
+
import type { LabelProps } from 'reka-ui';
|
|
13
|
+
|
|
14
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
15
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
16
|
+
|
|
17
|
+
defineProps<Omit<LabelProps, 'for'>>();
|
|
18
|
+
|
|
19
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
20
|
+
'select',
|
|
21
|
+
'<HeadlessSelectLabel> must be a child of a <HeadlessSelect>',
|
|
22
|
+
);
|
|
23
|
+
const slots = useSlots();
|
|
24
|
+
const show = computed(() => !!(select.label || slots.default));
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectItem v-bind="$props">
|
|
3
|
+
<SelectItemText class="the-text">
|
|
4
|
+
<slot>
|
|
5
|
+
{{ renderedLabel }}
|
|
6
|
+
</slot>
|
|
7
|
+
</SelectItemText>
|
|
8
|
+
</SelectItem>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { SelectItem, SelectItemText } from 'reka-ui';
|
|
14
|
+
import { toString } from '@noeldemartin/utils';
|
|
15
|
+
import type { SelectItemProps } from 'reka-ui';
|
|
16
|
+
|
|
17
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
18
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
19
|
+
|
|
20
|
+
const { value } = defineProps<SelectItemProps>();
|
|
21
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
22
|
+
'select',
|
|
23
|
+
'<HeadlessSelectOption> must be a child of a <HeadlessSelect>',
|
|
24
|
+
);
|
|
25
|
+
const renderedLabel = computed(() => {
|
|
26
|
+
const itemOption = select.options?.find((option) => option.value === value);
|
|
27
|
+
|
|
28
|
+
if (itemOption) {
|
|
29
|
+
return itemOption.label;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return toString(value);
|
|
33
|
+
});
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectPortal>
|
|
3
|
+
<SelectContent :class="classes">
|
|
4
|
+
<SelectViewport>
|
|
5
|
+
<slot>
|
|
6
|
+
<HeadlessSelectOption
|
|
7
|
+
v-for="option in select.options ?? []"
|
|
8
|
+
:key="option.key"
|
|
9
|
+
:value="option.value"
|
|
10
|
+
/>
|
|
11
|
+
</slot>
|
|
12
|
+
</SelectViewport>
|
|
13
|
+
</SelectContent>
|
|
14
|
+
</SelectPortal>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { SelectContent, SelectPortal, SelectViewport } from 'reka-ui';
|
|
19
|
+
|
|
20
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils';
|
|
21
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
22
|
+
|
|
23
|
+
import HeadlessSelectOption from './HeadlessSelectOption.vue';
|
|
24
|
+
|
|
25
|
+
const { class: classes } = defineProps<{ class?: string }>();
|
|
26
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
27
|
+
'select',
|
|
28
|
+
'<HeadlessSelectOptions> must be a child of a <HeadlessSelect>',
|
|
29
|
+
);
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectTrigger :id="select.id">
|
|
3
|
+
<slot>
|
|
4
|
+
<HeadlessSelectValue :placeholder="select.placeholder" />
|
|
5
|
+
<SelectIcon />
|
|
6
|
+
</slot>
|
|
7
|
+
</SelectTrigger>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { SelectIcon, SelectTrigger } from 'reka-ui';
|
|
12
|
+
|
|
13
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils';
|
|
14
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
15
|
+
|
|
16
|
+
import HeadlessSelectValue from './HeadlessSelectValue.vue';
|
|
17
|
+
|
|
18
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
19
|
+
'select',
|
|
20
|
+
'<HeadlessSelectTrigger> must be a child of a <HeadlessSelect>',
|
|
21
|
+
);
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectValue :placeholder="select.placeholder" />
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script setup lang="ts">
|
|
6
|
+
import { SelectValue } from 'reka-ui';
|
|
7
|
+
|
|
8
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
9
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
10
|
+
|
|
11
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
12
|
+
'select',
|
|
13
|
+
'<HeadlessSelectValue> must be a child of a <HeadlessSelect>',
|
|
14
|
+
);
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ToastRoot>
|
|
3
|
+
<slot>
|
|
4
|
+
<span v-if="message">{{ message }}</span>
|
|
5
|
+
<HeadlessToastAction v-for="(action, key) of actions" :key :action />
|
|
6
|
+
</slot>
|
|
7
|
+
</ToastRoot>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { ToastRoot } from 'reka-ui';
|
|
12
|
+
|
|
13
|
+
import type { ToastProps } from '@aerogel/core/components/contracts/Toast';
|
|
14
|
+
|
|
15
|
+
import HeadlessToastAction from './HeadlessToastAction.vue';
|
|
16
|
+
|
|
17
|
+
defineProps<ToastProps>();
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="action.dismiss ? ToastClose : 'button'" type="button" @click="action.click">
|
|
3
|
+
{{ action.label }}
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { ToastClose } from 'reka-ui';
|
|
9
|
+
|
|
10
|
+
import type { ToastAction as IToastAction } from '@aerogel/core/components/contracts/Toast';
|
|
11
|
+
|
|
12
|
+
defineProps<{ action: IToastAction }>();
|
|
13
|
+
</script>
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export * from './forms';
|
|
2
|
-
export * from './snackbars';
|
|
3
|
-
|
|
4
1
|
export { default as HeadlessButton } from './HeadlessButton.vue';
|
|
5
2
|
export { default as HeadlessInput } from './HeadlessInput.vue';
|
|
6
3
|
export { default as HeadlessInputDescription } from './HeadlessInputDescription.vue';
|
|
@@ -12,3 +9,10 @@ export { default as HeadlessModal } from './HeadlessModal.vue';
|
|
|
12
9
|
export { default as HeadlessModalContent } from './HeadlessModalContent.vue';
|
|
13
10
|
export { default as HeadlessModalOverlay } from './HeadlessModalOverlay.vue';
|
|
14
11
|
export { default as HeadlessModalTitle } from './HeadlessModalTitle.vue';
|
|
12
|
+
export { default as HeadlessSelect } from './HeadlessSelect.vue';
|
|
13
|
+
export { default as HeadlessSelectLabel } from './HeadlessSelectLabel.vue';
|
|
14
|
+
export { default as HeadlessSelectOption } from './HeadlessSelectOption.vue';
|
|
15
|
+
export { default as HeadlessSelectOptions } from './HeadlessSelectOptions.vue';
|
|
16
|
+
export { default as HeadlessSelectTrigger } from './HeadlessSelectTrigger.vue';
|
|
17
|
+
export { default as HeadlessSelectValue } from './HeadlessSelectValue.vue';
|
|
18
|
+
export { default as HeadlessToast } from './HeadlessToast.vue';
|
package/src/components/index.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
export { default as AppLayout } from './AppLayout.vue';
|
|
2
|
+
export { default as AppModals } from './AppModals.vue';
|
|
3
|
+
export { default as AppOverlays } from './AppOverlays.vue';
|
|
4
|
+
export { default as AppToasts } from './AppToasts.vue';
|
|
3
5
|
|
|
4
|
-
export { AppLayout, AppOverlays };
|
|
5
|
-
|
|
6
|
-
export * from './composition';
|
|
7
|
-
export * from './constants';
|
|
8
6
|
export * from './contracts';
|
|
9
|
-
export * from './forms';
|
|
10
7
|
export * from './headless';
|
|
11
|
-
export * from './lib';
|
|
12
|
-
export * from './snackbars';
|
|
13
8
|
export * from './ui';
|