@aerogel/core 0.0.0-next.b58141fee5d2fe7d25debdbca6b1d2bf1c13e48e → 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 +2082 -813
- package/dist/aerogel-core.js +3119 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +36 -34
- package/src/bootstrap/bootstrap.test.ts +7 -10
- package/src/bootstrap/index.ts +43 -14
- package/src/bootstrap/options.ts +4 -1
- package/src/components/AppLayout.vue +16 -0
- package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
- package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +5 -6
- 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 +11 -0
- package/src/components/contracts/ErrorReportModal.ts +29 -0
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +18 -0
- package/src/components/contracts/Modal.ts +13 -0
- package/src/components/contracts/PromptModal.ts +28 -0
- package/src/components/contracts/Select.ts +36 -0
- package/src/components/contracts/Toast.ts +13 -0
- package/src/components/contracts/index.ts +9 -0
- package/src/components/contracts/shared.ts +9 -0
- package/src/components/headless/HeadlessButton.vue +50 -0
- package/src/components/headless/HeadlessInput.vue +59 -0
- package/src/components/headless/HeadlessInputDescription.vue +27 -0
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
- package/src/components/headless/HeadlessInputInput.vue +75 -0
- package/src/components/headless/HeadlessInputLabel.vue +18 -0
- package/src/components/headless/HeadlessInputTextArea.vue +40 -0
- package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +17 -19
- package/src/components/headless/HeadlessModalContent.vue +24 -0
- package/src/components/headless/HeadlessModalOverlay.vue +12 -0
- package/src/components/headless/HeadlessModalTitle.vue +12 -0
- package/src/components/headless/HeadlessSelect.vue +104 -0
- package/src/components/headless/HeadlessSelectError.vue +25 -0
- 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 +18 -3
- package/src/components/index.ts +6 -9
- 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 +33 -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} +38 -29
- package/src/components/ui/ErrorReportModalTitle.vue +24 -0
- package/src/components/ui/Form.vue +24 -0
- 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 +70 -0
- package/src/components/ui/ModalContext.vue +30 -0
- package/src/components/ui/ProgressBar.vue +50 -0
- package/src/components/ui/PromptModal.vue +35 -0
- 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/ui/StartupCrash.vue +31 -0
- package/src/components/ui/Toast.vue +42 -0
- package/src/components/ui/index.ts +27 -0
- package/src/directives/index.ts +13 -5
- package/src/directives/measure.ts +40 -0
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +35 -34
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +19 -29
- package/src/errors/utils.ts +35 -0
- package/src/forms/{Form.test.ts → FormController.test.ts} +33 -4
- package/src/forms/{Form.ts → FormController.ts} +94 -25
- package/src/forms/composition.ts +4 -4
- package/src/forms/index.ts +3 -1
- package/src/forms/utils.ts +36 -5
- package/src/forms/validation.ts +19 -0
- package/src/index.css +46 -0
- package/src/{main.ts → index.ts} +3 -0
- package/src/jobs/Job.ts +147 -0
- package/src/jobs/index.ts +10 -0
- package/src/jobs/listeners.ts +3 -0
- package/src/jobs/status.ts +4 -0
- package/src/lang/DefaultLangProvider.ts +46 -0
- package/src/lang/Lang.state.ts +11 -0
- package/src/lang/Lang.ts +44 -29
- package/src/lang/index.ts +11 -6
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/plugins/Plugin.ts +2 -1
- package/src/plugins/index.ts +22 -0
- package/src/services/App.state.ts +40 -6
- package/src/services/App.ts +48 -5
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +112 -32
- package/src/services/Service.ts +154 -49
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +18 -6
- package/src/services/store.ts +8 -5
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +26 -0
- package/src/testing/setup.ts +11 -0
- package/src/ui/UI.state.ts +19 -7
- package/src/ui/UI.ts +268 -57
- package/src/ui/index.ts +23 -17
- package/src/ui/utils.ts +16 -0
- package/src/utils/classes.ts +49 -0
- package/src/utils/composition/events.ts +3 -2
- package/src/utils/composition/forms.ts +14 -4
- package/src/utils/composition/persistent.test.ts +33 -0
- package/src/utils/composition/persistent.ts +11 -0
- package/src/utils/composition/state.test.ts +47 -0
- package/src/utils/composition/state.ts +33 -0
- package/src/utils/index.ts +4 -0
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +19 -6
- package/src/utils/vue.ts +28 -118
- package/.eslintrc.js +0 -3
- package/dist/aerogel-core.cjs.js +0 -2
- package/dist/aerogel-core.cjs.js.map +0 -1
- package/dist/aerogel-core.esm.js +0 -2
- package/dist/aerogel-core.esm.js.map +0 -1
- package/dist/virtual.d.ts +0 -11
- package/noeldemartin.config.js +0 -5
- package/src/components/AGAppLayout.vue +0 -11
- package/src/components/AGAppSnackbars.vue +0 -13
- package/src/components/basic/AGErrorMessage.vue +0 -16
- package/src/components/basic/AGLink.vue +0 -9
- package/src/components/basic/AGMarkdown.vue +0 -36
- package/src/components/basic/index.ts +0 -5
- package/src/components/constants.ts +0 -8
- package/src/components/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -35
- package/src/components/forms/AGForm.vue +0 -26
- package/src/components/forms/AGInput.vue +0 -36
- package/src/components/forms/index.ts +0 -6
- package/src/components/headless/forms/AGHeadlessButton.vue +0 -51
- package/src/components/headless/forms/AGHeadlessInput.ts +0 -8
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -54
- package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -45
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +0 -16
- package/src/components/headless/forms/index.ts +0 -6
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -7
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/headless/modals/index.ts +0 -6
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
- package/src/components/headless/snackbars/index.ts +0 -25
- package/src/components/modals/AGAlertModal.vue +0 -25
- package/src/components/modals/AGConfirmModal.vue +0 -30
- package/src/components/modals/AGErrorReportModal.ts +0 -20
- package/src/components/modals/AGErrorReportModal.vue +0 -62
- package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
- package/src/components/modals/AGLoadingModal.vue +0 -19
- package/src/components/modals/AGModal.ts +0 -10
- package/src/components/modals/AGModal.vue +0 -37
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalContext.vue +0 -22
- package/src/components/modals/AGModalTitle.vue +0 -9
- package/src/components/modals/index.ts +0 -23
- package/src/components/snackbars/AGSnackbar.vue +0 -42
- package/src/components/snackbars/index.ts +0 -3
- package/src/directives/initial-focus.ts +0 -11
- package/src/types/virtual.d.ts +0 -11
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot :id="`${input.id}-description`">
|
|
3
|
+
<Markdown
|
|
4
|
+
v-if="show"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
:id="`${input.id}-description`"
|
|
7
|
+
:text
|
|
8
|
+
/>
|
|
9
|
+
</slot>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
|
|
15
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
16
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
18
|
+
|
|
19
|
+
defineOptions({ inheritAttrs: false });
|
|
20
|
+
|
|
21
|
+
const input = injectReactiveOrFail<InputExpose>(
|
|
22
|
+
'input',
|
|
23
|
+
'<HeadlessInputDescription> must be a child of a <HeadlessInput>',
|
|
24
|
+
);
|
|
25
|
+
const text = computed(() => (typeof input.description === 'string' ? input.description : ''));
|
|
26
|
+
const show = computed(() => !!input.description);
|
|
27
|
+
</script>
|
|
@@ -7,15 +7,11 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
|
|
10
|
-
import { injectReactiveOrFail } from '
|
|
11
|
-
import { translateWithDefault } from '
|
|
10
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
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;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<input
|
|
3
|
+
:id="input.id"
|
|
4
|
+
ref="$input"
|
|
5
|
+
:name
|
|
6
|
+
:type
|
|
7
|
+
:checked
|
|
8
|
+
:required="input.required ?? undefined"
|
|
9
|
+
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
10
|
+
:aria-describedby="
|
|
11
|
+
input.errors ? `${input.id}-error` : input.description ? `${input.id}-description` : undefined
|
|
12
|
+
"
|
|
13
|
+
@input="update"
|
|
14
|
+
>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup lang="ts">
|
|
18
|
+
import { computed, ref, watchEffect } from 'vue';
|
|
19
|
+
|
|
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
|
+
|
|
25
|
+
const { type = 'text' } = defineProps<{ type?: string }>();
|
|
26
|
+
const $input = ref<HTMLInputElement>();
|
|
27
|
+
const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputInput> must be a child of a <HeadlessInput>');
|
|
28
|
+
const name = computed(() => input.name ?? undefined);
|
|
29
|
+
const value = computed(() => input.value);
|
|
30
|
+
const checked = computed(() => {
|
|
31
|
+
if (type !== 'checkbox') {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return !!value.value;
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function update() {
|
|
39
|
+
if (!$input.value) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
input.update(getValue());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function getValue(): FormFieldValue | null {
|
|
47
|
+
if (!$input.value) {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
switch (type) {
|
|
52
|
+
case 'checkbox':
|
|
53
|
+
return $input.value.checked;
|
|
54
|
+
case 'date':
|
|
55
|
+
return $input.value.valueAsDate;
|
|
56
|
+
default:
|
|
57
|
+
return $input.value.value;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
onFormFocus(input, () => $input.value?.focus());
|
|
62
|
+
watchEffect(() => {
|
|
63
|
+
if (!$input.value) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (type === 'date') {
|
|
68
|
+
$input.value.valueAsDate = value.value as Date;
|
|
69
|
+
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
$input.value.value = (value.value as string) ?? null;
|
|
74
|
+
});
|
|
75
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<label v-if="show" :for="input.id">
|
|
3
|
+
<slot>
|
|
4
|
+
{{ input.label }}
|
|
5
|
+
</slot>
|
|
6
|
+
</label>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed, useSlots } from 'vue';
|
|
11
|
+
|
|
12
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
13
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
14
|
+
|
|
15
|
+
const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputLabel> must be a child of a <HeadlessInput>');
|
|
16
|
+
const slots = useSlots();
|
|
17
|
+
const show = computed(() => !!(input.label || slots.default));
|
|
18
|
+
</script>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<textarea
|
|
3
|
+
:id="input.id"
|
|
4
|
+
ref="$textArea"
|
|
5
|
+
:name
|
|
6
|
+
:value
|
|
7
|
+
:required="input.required ?? undefined"
|
|
8
|
+
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
9
|
+
:aria-describedby="
|
|
10
|
+
input.errors ? `${input.id}-error` : input.description ? `${input.id}-description` : undefined
|
|
11
|
+
"
|
|
12
|
+
@input="update"
|
|
13
|
+
/>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { computed, ref } from 'vue';
|
|
18
|
+
|
|
19
|
+
import { onFormFocus } from '@aerogel/core/utils/composition/forms';
|
|
20
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
22
|
+
|
|
23
|
+
const $textArea = ref<HTMLTextAreaElement>();
|
|
24
|
+
const input = injectReactiveOrFail<InputExpose>(
|
|
25
|
+
'input',
|
|
26
|
+
'<HeadlessInputTextArea> must be a child of a <HeadlessInput>',
|
|
27
|
+
);
|
|
28
|
+
const name = computed(() => input.name ?? undefined);
|
|
29
|
+
const value = computed(() => input.value as string);
|
|
30
|
+
|
|
31
|
+
function update() {
|
|
32
|
+
if (!$textArea.value) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
input.update($textArea.value.value);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
onFormFocus(input, () => $textArea.value?.focus());
|
|
40
|
+
</script>
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
2
|
+
<DialogRoot ref="$root" open @update:open="persistent || close()">
|
|
3
|
+
<DialogPortal>
|
|
4
|
+
<slot :close="close" />
|
|
5
|
+
</DialogPortal>
|
|
6
|
+
</DialogRoot>
|
|
5
7
|
</template>
|
|
6
8
|
|
|
7
9
|
<script setup lang="ts">
|
|
8
|
-
import { ref
|
|
9
|
-
import {
|
|
10
|
-
import type { VNode } from 'vue';
|
|
10
|
+
import { ref } from 'vue';
|
|
11
|
+
import { DialogPortal, DialogRoot } from 'reka-ui';
|
|
11
12
|
|
|
12
|
-
import Events from '
|
|
13
|
-
import { useEvent } from '
|
|
14
|
-
import {
|
|
15
|
-
import type {
|
|
13
|
+
import Events from '@aerogel/core/services/Events';
|
|
14
|
+
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
15
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
16
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI.state';
|
|
17
|
+
import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
|
|
16
18
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
cancellable: booleanProp(true),
|
|
21
|
-
});
|
|
19
|
+
defineProps<ModalProps>();
|
|
20
|
+
defineSlots<ModalSlots>();
|
|
22
21
|
|
|
23
22
|
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
24
23
|
const hidden = ref(true);
|
|
25
24
|
const closed = ref(false);
|
|
26
|
-
const { modal } = injectReactiveOrFail<
|
|
25
|
+
const { modal } = injectReactiveOrFail<UIModalContext>(
|
|
27
26
|
'modal',
|
|
28
|
-
'could not obtain modal reference from <
|
|
27
|
+
'could not obtain modal reference from <HeadlessModal>, ' +
|
|
29
28
|
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
30
29
|
);
|
|
31
30
|
|
|
@@ -83,6 +82,5 @@ useEvent('show-modal', async ({ id }) => {
|
|
|
83
82
|
await show();
|
|
84
83
|
});
|
|
85
84
|
|
|
86
|
-
|
|
87
|
-
defineExpose<IAGHeadlessModal>({ close, cancellable: toRef(props, 'cancellable') });
|
|
85
|
+
defineExpose<ModalExpose>({ close });
|
|
88
86
|
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogContent>
|
|
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 } from 'vue';
|
|
11
|
+
import { DialogContent } from 'reka-ui';
|
|
12
|
+
|
|
13
|
+
import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
|
|
14
|
+
import UI from '@aerogel/core/ui/UI';
|
|
15
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
16
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI.state';
|
|
17
|
+
|
|
18
|
+
const { childIndex = 0 } = injectReactiveOrFail<UIModalContext>(
|
|
19
|
+
'modal',
|
|
20
|
+
'could not obtain modal reference from <HeadlessModalContent>, ' +
|
|
21
|
+
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
22
|
+
);
|
|
23
|
+
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
24
|
+
</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,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>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<p v-if="errorMessage" :id="`${select.id}-error`">
|
|
3
|
+
{{ errorMessage }}
|
|
4
|
+
</p>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
|
|
10
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
11
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
12
|
+
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
13
|
+
|
|
14
|
+
const select = injectReactiveOrFail<SelectExpose>(
|
|
15
|
+
'select',
|
|
16
|
+
'<HeadlessSelectError> must be a child of a <HeadlessSelect>',
|
|
17
|
+
);
|
|
18
|
+
const errorMessage = computed(() => {
|
|
19
|
+
if (!select.errors) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return translateWithDefault(`errors.${select.errors[0]}`, `Error: ${select.errors[0]}`);
|
|
24
|
+
});
|
|
25
|
+
</script>
|
|
@@ -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,3 +1,18 @@
|
|
|
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 HeadlessModalOverlay } from './HeadlessModalOverlay.vue';
|
|
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,11 +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
|
|
5
|
-
|
|
6
|
-
export * from './basic';
|
|
7
|
-
export * from './constants';
|
|
8
|
-
export * from './forms';
|
|
6
|
+
export * from './contracts';
|
|
9
7
|
export * from './headless';
|
|
10
|
-
export * from './
|
|
11
|
-
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>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Modal :title>
|
|
3
|
+
<Markdown :text="message" />
|
|
4
|
+
</Modal>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import Modal from '@aerogel/core/components/ui/Modal.vue';
|
|
9
|
+
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
10
|
+
import type { AlertModalProps } from '@aerogel/core/components/contracts/AlertModal';
|
|
11
|
+
|
|
12
|
+
defineProps<AlertModalProps>();
|
|
13
|
+
</script>
|