@aerogel/core 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2 → 0.0.0-next.9aa7c279868edbedbcee075aef52212597d803fb
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 +1283 -1588
- package/dist/aerogel-core.js +2496 -1994
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +10 -2
- package/src/components/AppLayout.vue +14 -0
- package/src/components/{AGAppModals.vue → AppModals.vue} +2 -3
- package/src/components/AppOverlays.vue +9 -0
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +8 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +46 -0
- package/src/components/contracts/DropdownMenu.ts +20 -0
- package/src/components/{modals/AGErrorReportModal.ts → contracts/ErrorReportModal.ts} +5 -22
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +26 -0
- package/src/components/contracts/Modal.ts +15 -10
- package/src/components/contracts/PromptModal.ts +34 -0
- package/src/components/contracts/Select.ts +45 -0
- package/src/components/contracts/Toast.ts +15 -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/HeadlessModal.vue +57 -0
- 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 +120 -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 +42 -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 +14 -0
- package/src/components/ui/Button.vue +98 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +45 -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 +67 -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 +34 -0
- package/src/components/ui/Markdown.vue +69 -0
- package/src/components/ui/Modal.vue +122 -0
- package/src/components/{modals/AGModalContext.vue → ui/ModalContext.vue} +8 -9
- package/src/components/ui/ProgressBar.vue +51 -0
- package/src/components/ui/PromptModal.vue +38 -0
- package/src/components/ui/Select.vue +27 -0
- package/src/components/ui/SelectLabel.vue +17 -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/SettingsModal.vue +15 -0
- package/src/components/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +7 -7
- package/src/components/ui/Toast.vue +44 -0
- package/src/components/ui/index.ts +30 -0
- package/src/errors/Errors.ts +7 -16
- package/src/forms/{Form.test.ts → FormController.test.ts} +32 -9
- package/src/forms/{Form.ts → FormController.ts} +28 -27
- package/src/forms/index.ts +2 -3
- package/src/forms/utils.ts +35 -35
- package/src/index.css +72 -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/Events.test.ts +8 -8
- package/src/services/Events.ts +2 -8
- package/src/services/index.ts +3 -0
- package/src/ui/UI.state.ts +7 -12
- package/src/ui/UI.ts +102 -103
- package/src/ui/index.ts +23 -24
- package/src/utils/classes.ts +49 -0
- package/src/utils/composition/events.ts +2 -4
- package/src/utils/composition/forms.ts +20 -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/AGAppLayout.vue +0 -16
- package/src/components/AGAppOverlays.vue +0 -41
- 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/AGHeadlessModal.vue +0 -88
- 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/forms/composition.ts +0 -6
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
|
@@ -1,42 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<input
|
|
3
3
|
:id="input.id"
|
|
4
|
-
ref="$
|
|
5
|
-
:name
|
|
6
|
-
:type
|
|
4
|
+
ref="$inputRef"
|
|
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>
|
|
16
16
|
|
|
17
17
|
<script setup lang="ts">
|
|
18
|
-
import { computed,
|
|
18
|
+
import { computed, useTemplateRef, watchEffect } from 'vue';
|
|
19
19
|
|
|
20
|
-
import { injectReactiveOrFail
|
|
21
|
-
import
|
|
22
|
-
import type { FormFieldValue } from '@aerogel/core/forms/
|
|
23
|
-
import type {
|
|
20
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
|
+
import { onFormFocus } from '@aerogel/core/utils/composition/forms';
|
|
22
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
23
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
type: stringProp('text'),
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const $input = ref<HTMLInputElement>();
|
|
32
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
33
|
-
'input',
|
|
34
|
-
'<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>',
|
|
35
|
-
);
|
|
25
|
+
const { type = 'text' } = defineProps<{ type?: string }>();
|
|
26
|
+
const $input = useTemplateRef('$inputRef');
|
|
27
|
+
const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputInput> must be a child of a <HeadlessInput>');
|
|
36
28
|
const name = computed(() => input.name ?? undefined);
|
|
37
29
|
const value = computed(() => input.value);
|
|
38
30
|
const checked = computed(() => {
|
|
39
|
-
if (
|
|
31
|
+
if (type !== 'checkbox') {
|
|
40
32
|
return;
|
|
41
33
|
}
|
|
42
34
|
|
|
@@ -56,7 +48,7 @@ function getValue(): FormFieldValue | null {
|
|
|
56
48
|
return null;
|
|
57
49
|
}
|
|
58
50
|
|
|
59
|
-
switch (
|
|
51
|
+
switch (type) {
|
|
60
52
|
case 'checkbox':
|
|
61
53
|
return $input.value.checked;
|
|
62
54
|
case 'date':
|
|
@@ -67,18 +59,17 @@ function getValue(): FormFieldValue | null {
|
|
|
67
59
|
}
|
|
68
60
|
|
|
69
61
|
onFormFocus(input, () => $input.value?.focus());
|
|
70
|
-
watchEffect(() => (input as unknown as __SetsElement).__setElement($input.value));
|
|
71
62
|
watchEffect(() => {
|
|
72
63
|
if (!$input.value) {
|
|
73
64
|
return;
|
|
74
65
|
}
|
|
75
66
|
|
|
76
|
-
if (
|
|
67
|
+
if (type === 'date') {
|
|
77
68
|
$input.value.valueAsDate = value.value as Date;
|
|
78
69
|
|
|
79
70
|
return;
|
|
80
71
|
}
|
|
81
72
|
|
|
82
|
-
$input.value.value = value.value as string;
|
|
73
|
+
$input.value.value = (value.value as string) ?? null;
|
|
83
74
|
});
|
|
84
75
|
</script>
|
|
@@ -10,13 +10,9 @@
|
|
|
10
10
|
import { computed, useSlots } from 'vue';
|
|
11
11
|
|
|
12
12
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
13
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
17
|
-
'input',
|
|
18
|
-
'<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>',
|
|
19
|
-
);
|
|
15
|
+
const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputLabel> must be a child of a <HeadlessInput>');
|
|
20
16
|
const slots = useSlots();
|
|
21
17
|
const show = computed(() => !!(input.label || slots.default));
|
|
22
18
|
</script>
|
package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<textarea
|
|
3
3
|
:id="input.id"
|
|
4
|
-
ref="$
|
|
5
|
-
:name
|
|
4
|
+
ref="$textAreaRef"
|
|
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
|
|
@@ -14,18 +14,16 @@
|
|
|
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/utils/composition/forms';
|
|
19
20
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
20
|
-
import type {
|
|
21
|
-
import type { __SetsElement } from '@aerogel/core/components/contracts/shared';
|
|
21
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const $textArea = ref<HTMLTextAreaElement>();
|
|
26
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
23
|
+
const $textArea = useTemplateRef('$textAreaRef');
|
|
24
|
+
const input = injectReactiveOrFail<InputExpose>(
|
|
27
25
|
'input',
|
|
28
|
-
'<
|
|
26
|
+
'<HeadlessInputTextArea> must be a child of a <HeadlessInput>',
|
|
29
27
|
);
|
|
30
28
|
const name = computed(() => input.name ?? undefined);
|
|
31
29
|
const value = computed(() => input.value as string);
|
|
@@ -38,6 +36,5 @@ function update() {
|
|
|
38
36
|
input.update($textArea.value.value);
|
|
39
37
|
}
|
|
40
38
|
|
|
41
|
-
watchEffect(() => (input as unknown as __SetsElement).__setElement($textArea.value));
|
|
42
39
|
onFormFocus(input, () => $textArea.value?.focus());
|
|
43
40
|
</script>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogRoot :ref="forwardRef" open @update:open="persistent || close()">
|
|
3
|
+
<DialogPortal>
|
|
4
|
+
<slot :close="close" />
|
|
5
|
+
</DialogPortal>
|
|
6
|
+
</DialogRoot>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
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';
|
|
14
|
+
|
|
15
|
+
import Events from '@aerogel/core/services/Events';
|
|
16
|
+
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
17
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
18
|
+
import type { AcceptRefs } from '@aerogel/core/utils/vue';
|
|
19
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
20
|
+
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
21
|
+
|
|
22
|
+
const $content = ref<Nullable<InstanceType<typeof DialogContent>>>(null);
|
|
23
|
+
const { modal } = injectReactiveOrFail<UIModalContext>(
|
|
24
|
+
'modal',
|
|
25
|
+
'could not obtain modal reference from <HeadlessModal>, ' +
|
|
26
|
+
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
defineProps<ModalProps>();
|
|
30
|
+
defineSlots<ModalSlots<T>>();
|
|
31
|
+
defineExpose<AcceptRefs<ModalExpose<T>>>({ close, $content });
|
|
32
|
+
|
|
33
|
+
const { forwardRef } = useForwardExpose();
|
|
34
|
+
const closed = ref(false);
|
|
35
|
+
|
|
36
|
+
provide('$modalContentRef', $content);
|
|
37
|
+
|
|
38
|
+
useEvent('close-modal', async ({ id, result }) => {
|
|
39
|
+
if (id !== modal.id) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
await close(result);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
async function close(result?: unknown) {
|
|
47
|
+
if (closed.value) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
await Events.emit('modal-will-close', { modal, result });
|
|
52
|
+
|
|
53
|
+
closed.value = true;
|
|
54
|
+
|
|
55
|
+
await Events.emit('modal-has-closed', { modal, result });
|
|
56
|
+
}
|
|
57
|
+
</script>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogContent ref="$contentRef">
|
|
3
|
+
<slot />
|
|
4
|
+
|
|
5
|
+
<ModalContext v-if="childModal" :child-index="childIndex + 1" :modal="childModal" />
|
|
6
|
+
</DialogContent>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed, useTemplateRef, watchEffect } from 'vue';
|
|
11
|
+
import { DialogContent } from 'reka-ui';
|
|
12
|
+
import type { Ref } from 'vue';
|
|
13
|
+
|
|
14
|
+
import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
|
|
15
|
+
import UI from '@aerogel/core/ui/UI';
|
|
16
|
+
import { injectOrFail, injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
18
|
+
import type { ModalContentInstance } from '@aerogel/core/components/contracts/Modal';
|
|
19
|
+
|
|
20
|
+
const { childIndex = 0 } = injectReactiveOrFail<UIModalContext>(
|
|
21
|
+
'modal',
|
|
22
|
+
'could not obtain modal reference from <HeadlessModalContent>, ' +
|
|
23
|
+
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
24
|
+
);
|
|
25
|
+
const $modalContentRef = injectOrFail<Ref<ModalContentInstance>>('$modalContentRef');
|
|
26
|
+
const $content = useTemplateRef('$contentRef');
|
|
27
|
+
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
28
|
+
|
|
29
|
+
watchEffect(() => ($modalContentRef.value = $content.value));
|
|
30
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogDescription v-bind="$props">
|
|
3
|
+
<slot />
|
|
4
|
+
</DialogDescription>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { DialogDescription } from 'reka-ui';
|
|
9
|
+
import type { DialogDescriptionProps } from 'reka-ui';
|
|
10
|
+
|
|
11
|
+
defineProps<DialogDescriptionProps>();
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogOverlay v-bind="$props">
|
|
3
|
+
<slot />
|
|
4
|
+
</DialogOverlay>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { DialogOverlay } from 'reka-ui';
|
|
9
|
+
import type { DialogOverlayProps } from 'reka-ui';
|
|
10
|
+
|
|
11
|
+
defineProps<DialogOverlayProps>();
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogTitle v-bind="$props">
|
|
3
|
+
<slot />
|
|
4
|
+
</DialogTitle>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { DialogTitle } from 'reka-ui';
|
|
9
|
+
import type { DialogTitleProps } from 'reka-ui';
|
|
10
|
+
|
|
11
|
+
defineProps<DialogTitleProps>();
|
|
12
|
+
</script>
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectRoot
|
|
3
|
+
v-slot="{ open }"
|
|
4
|
+
:model-value="acceptableValue"
|
|
5
|
+
:by="compareOptions as Closure<[AcceptableValue, AcceptableValue], boolean>"
|
|
6
|
+
@update:model-value="update($event)"
|
|
7
|
+
>
|
|
8
|
+
<component :is="as" v-bind="$attrs">
|
|
9
|
+
<slot :model-value :open>
|
|
10
|
+
<HeadlessSelectTrigger />
|
|
11
|
+
<HeadlessSelectOptions />
|
|
12
|
+
</slot>
|
|
13
|
+
</component>
|
|
14
|
+
</SelectRoot>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
|
|
18
|
+
import { computed, inject, provide, readonly } from 'vue';
|
|
19
|
+
import { value as evaluate, toString, uuid } from '@noeldemartin/utils';
|
|
20
|
+
import { SelectRoot } from 'reka-ui';
|
|
21
|
+
import type { AcceptableValue } from 'reka-ui';
|
|
22
|
+
import type { Closure, Nullable } from '@noeldemartin/utils';
|
|
23
|
+
|
|
24
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
25
|
+
import { hasSelectOptionLabel } from '@aerogel/core/components/contracts/Select';
|
|
26
|
+
import type FormController from '@aerogel/core/forms/FormController';
|
|
27
|
+
import type { SelectEmits, SelectExpose, SelectProps } from '@aerogel/core/components/contracts/Select';
|
|
28
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
29
|
+
|
|
30
|
+
import HeadlessSelectTrigger from './HeadlessSelectTrigger.vue';
|
|
31
|
+
import HeadlessSelectOptions from './HeadlessSelectOptions.vue';
|
|
32
|
+
|
|
33
|
+
defineOptions({ inheritAttrs: false });
|
|
34
|
+
|
|
35
|
+
const {
|
|
36
|
+
name,
|
|
37
|
+
as = 'div',
|
|
38
|
+
label,
|
|
39
|
+
options,
|
|
40
|
+
labelClass,
|
|
41
|
+
optionsClass,
|
|
42
|
+
renderOption,
|
|
43
|
+
compareOptions = (a, b) => a === b,
|
|
44
|
+
description,
|
|
45
|
+
placeholder,
|
|
46
|
+
modelValue,
|
|
47
|
+
align,
|
|
48
|
+
side,
|
|
49
|
+
} = defineProps<SelectProps<T>>();
|
|
50
|
+
const emit = defineEmits<SelectEmits<T>>();
|
|
51
|
+
const form = inject<FormController | null>('form', null);
|
|
52
|
+
const computedValue = computed(() => {
|
|
53
|
+
if (form && name) {
|
|
54
|
+
return form.getFieldValue(name) as T;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return modelValue as T;
|
|
58
|
+
});
|
|
59
|
+
const acceptableValue = computed(() => computedValue.value as AcceptableValue);
|
|
60
|
+
const errors = computed(() => {
|
|
61
|
+
if (!form || !name) {
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return form.errors[name] ?? null;
|
|
66
|
+
});
|
|
67
|
+
const computedOptions = computed(() => {
|
|
68
|
+
if (!options) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return options.map((option) => ({
|
|
73
|
+
key: uuid(),
|
|
74
|
+
label: renderOption
|
|
75
|
+
? renderOption(option)
|
|
76
|
+
: hasSelectOptionLabel(option)
|
|
77
|
+
? evaluate(option.label as string)
|
|
78
|
+
: toString(option),
|
|
79
|
+
value: option as AcceptableValue,
|
|
80
|
+
}));
|
|
81
|
+
});
|
|
82
|
+
const expose = {
|
|
83
|
+
labelClass,
|
|
84
|
+
optionsClass,
|
|
85
|
+
align,
|
|
86
|
+
side,
|
|
87
|
+
value: computedValue,
|
|
88
|
+
id: `select-${uuid()}`,
|
|
89
|
+
name: computed(() => name),
|
|
90
|
+
label: computed(() => label),
|
|
91
|
+
description: computed(() => description),
|
|
92
|
+
placeholder: computed(() => placeholder ?? translateWithDefault('ui.select', 'Select an option')),
|
|
93
|
+
options: computedOptions,
|
|
94
|
+
selectedOption: computed(() => computedOptions.value?.find((option) => option.value === modelValue)),
|
|
95
|
+
errors: readonly(errors),
|
|
96
|
+
required: computed(() => {
|
|
97
|
+
if (!name || !form) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return form.getFieldRules(name).includes('required');
|
|
102
|
+
}),
|
|
103
|
+
update(value) {
|
|
104
|
+
if (form && name) {
|
|
105
|
+
form.setFieldValue(name, value as FormFieldValue);
|
|
106
|
+
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
emit('update:modelValue', value);
|
|
111
|
+
},
|
|
112
|
+
} satisfies SelectExpose<T>;
|
|
113
|
+
|
|
114
|
+
function update(value: AcceptableValue) {
|
|
115
|
+
expose.update(value as T);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
provide('select', expose);
|
|
119
|
+
defineExpose(expose);
|
|
120
|
+
</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>
|
|
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,42 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectPortal>
|
|
3
|
+
<SelectContent
|
|
4
|
+
position="popper"
|
|
5
|
+
:class="renderedClasses"
|
|
6
|
+
:align="select.align"
|
|
7
|
+
:side="select.side"
|
|
8
|
+
:side-offset="4"
|
|
9
|
+
>
|
|
10
|
+
<SelectViewport :class="innerClass">
|
|
11
|
+
<slot>
|
|
12
|
+
<HeadlessSelectOption
|
|
13
|
+
v-for="option in select.options ?? []"
|
|
14
|
+
:key="option.key"
|
|
15
|
+
:value="option.value"
|
|
16
|
+
/>
|
|
17
|
+
</slot>
|
|
18
|
+
</SelectViewport>
|
|
19
|
+
</SelectContent>
|
|
20
|
+
</SelectPortal>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { SelectContent, SelectPortal, SelectViewport } from 'reka-ui';
|
|
25
|
+
import { computed } from 'vue';
|
|
26
|
+
import type { HTMLAttributes } from 'vue';
|
|
27
|
+
|
|
28
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
29
|
+
import { classes } from '@aerogel/core/utils/classes';
|
|
30
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
31
|
+
|
|
32
|
+
import HeadlessSelectOption from './HeadlessSelectOption.vue';
|
|
33
|
+
|
|
34
|
+
const { class: rootClass } = defineProps<{ class?: HTMLAttributes['class']; innerClass?: HTMLAttributes['class'] }>();
|
|
35
|
+
|
|
36
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
37
|
+
'select',
|
|
38
|
+
'<HeadlessSelectOptions> must be a child of a <HeadlessSelect>',
|
|
39
|
+
);
|
|
40
|
+
const renderedClasses = computed(() =>
|
|
41
|
+
classes('min-w-(--reka-select-trigger-width) max-h-(--reka-select-content-available-height)', rootClass));
|
|
42
|
+
</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,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectValue v-if="$slots.default" :placeholder="select.placeholder">
|
|
3
|
+
<slot />
|
|
4
|
+
</SelectValue>
|
|
5
|
+
<SelectValue v-else :placeholder="select.placeholder" />
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { SelectValue } from 'reka-ui';
|
|
10
|
+
|
|
11
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
12
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
13
|
+
|
|
14
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
15
|
+
'select',
|
|
16
|
+
'<HeadlessSelectValue> must be a child of a <HeadlessSelect>',
|
|
17
|
+
);
|
|
18
|
+
</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,3 +1,19 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
export { default as HeadlessButton } from './HeadlessButton.vue';
|
|
2
|
+
export { default as HeadlessInput } from './HeadlessInput.vue';
|
|
3
|
+
export { default as HeadlessInputDescription } from './HeadlessInputDescription.vue';
|
|
4
|
+
export { default as HeadlessInputError } from './HeadlessInputError.vue';
|
|
5
|
+
export { default as HeadlessInputInput } from './HeadlessInputInput.vue';
|
|
6
|
+
export { default as HeadlessInputLabel } from './HeadlessInputLabel.vue';
|
|
7
|
+
export { default as HeadlessInputTextArea } from './HeadlessInputTextArea.vue';
|
|
8
|
+
export { default as HeadlessModal } from './HeadlessModal.vue';
|
|
9
|
+
export { default as HeadlessModalContent } from './HeadlessModalContent.vue';
|
|
10
|
+
export { default as HeadlessModalDescription } from './HeadlessModalDescription.vue';
|
|
11
|
+
export { default as HeadlessModalOverlay } from './HeadlessModalOverlay.vue';
|
|
12
|
+
export { default as HeadlessModalTitle } from './HeadlessModalTitle.vue';
|
|
13
|
+
export { default as HeadlessSelect } from './HeadlessSelect.vue';
|
|
14
|
+
export { default as HeadlessSelectLabel } from './HeadlessSelectLabel.vue';
|
|
15
|
+
export { default as HeadlessSelectOption } from './HeadlessSelectOption.vue';
|
|
16
|
+
export { default as HeadlessSelectOptions } from './HeadlessSelectOptions.vue';
|
|
17
|
+
export { default as HeadlessSelectTrigger } from './HeadlessSelectTrigger.vue';
|
|
18
|
+
export { default as HeadlessSelectValue } from './HeadlessSelectValue.vue';
|
|
19
|
+
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 { AGAppLayout, AGAppOverlays };
|
|
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 './
|
|
12
|
-
export * from './modals';
|
|
13
|
-
export * from './snackbars';
|
|
8
|
+
export * from './ui';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<details class="group">
|
|
3
|
+
<summary
|
|
4
|
+
class="-ml-2 flex w-[max-content] cursor-pointer items-center rounded-lg py-2 pr-3 pl-1 hover:bg-gray-100 focus-visible:outline focus-visible:outline-gray-700"
|
|
5
|
+
>
|
|
6
|
+
<IconCheveronRight class="size-6 transition-transform group-open:rotate-90" />
|
|
7
|
+
<span>{{ $td('ui.advancedOptions', 'Advanced options') }}</span>
|
|
8
|
+
</summary>
|
|
9
|
+
|
|
10
|
+
<div class="pt-2 pl-4">
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
</details>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import IconCheveronRight from '~icons/zondicons/cheveron-right';
|
|
18
|
+
</script>
|