@aerogel/core 0.0.0-next.c29ffcd25bffdbed37ecce3aac1ba14cde3e9d39 → 0.0.0-next.c33ad773d3eb977461630ff22012d99eeedf46cb
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 +1840 -1813
- package/dist/aerogel-core.js +3129 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +27 -37
- package/src/bootstrap/bootstrap.test.ts +4 -7
- package/src/bootstrap/index.ts +14 -15
- package/src/bootstrap/options.ts +1 -1
- package/src/components/{AGAppLayout.vue → AppLayout.vue} +4 -4
- package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
- package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +5 -10
- package/src/components/AppToasts.vue +16 -0
- package/src/components/composition.ts +1 -1
- 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 +33 -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/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +7 -8
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
- package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +13 -22
- package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
- package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +8 -11
- package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +17 -23
- 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 +92 -0
- package/src/components/headless/{forms/AGHeadlessSelectError.vue → HeadlessSelectError.vue} +5 -6
- 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 +4 -10
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +13 -0
- package/src/components/ui/Button.vue +98 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +42 -0
- package/src/components/ui/DropdownMenu.vue +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} +34 -27
- package/src/components/ui/ErrorReportModalTitle.vue +24 -0
- package/src/components/{forms/AGForm.vue → ui/Form.vue} +4 -5
- package/src/components/ui/Input.vue +56 -0
- package/src/components/ui/Link.vue +12 -0
- package/src/components/ui/LoadingModal.vue +32 -0
- package/src/components/ui/Markdown.vue +69 -0
- package/src/components/ui/Modal.vue +70 -0
- package/src/components/{modals/AGModalContext.vue → ui/ModalContext.vue} +7 -9
- package/src/components/ui/ProgressBar.vue +50 -0
- package/src/components/ui/PromptModal.vue +35 -0
- package/src/components/ui/Select.vue +53 -0
- package/src/components/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +8 -8
- package/src/components/ui/Toast.vue +42 -0
- package/src/components/ui/index.ts +23 -0
- package/src/components/utils.ts +106 -9
- package/src/directives/index.ts +9 -5
- package/src/directives/measure.ts +1 -1
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +17 -18
- package/src/errors/index.ts +9 -6
- package/src/errors/utils.ts +1 -1
- package/src/forms/{Form.test.ts → FormController.test.ts} +5 -4
- package/src/forms/{Form.ts → FormController.ts} +22 -19
- package/src/forms/composition.ts +4 -4
- package/src/forms/index.ts +2 -2
- package/src/forms/utils.ts +2 -2
- package/src/index.css +41 -0
- package/src/jobs/Job.ts +2 -2
- package/src/lang/DefaultLangProvider.ts +7 -4
- package/src/lang/Lang.state.ts +1 -1
- package/src/lang/Lang.ts +1 -1
- package/src/lang/index.ts +8 -6
- package/src/plugins/Plugin.ts +1 -1
- package/src/plugins/index.ts +10 -7
- package/src/services/App.state.ts +4 -3
- package/src/services/App.ts +4 -4
- package/src/services/Cache.ts +1 -1
- package/src/services/Events.ts +2 -2
- package/src/services/Service.ts +21 -21
- package/src/services/Storage.ts +3 -3
- package/src/services/index.ts +5 -4
- package/src/services/utils.ts +2 -2
- package/src/testing/index.ts +4 -3
- package/src/testing/setup.ts +3 -19
- package/src/ui/UI.state.ts +12 -7
- package/src/ui/UI.ts +63 -58
- package/src/ui/index.ts +18 -18
- package/src/utils/composition/events.ts +2 -2
- package/src/utils/composition/forms.ts +4 -3
- package/src/utils/markdown.ts +3 -5
- package/src/utils/vdom.ts +31 -0
- package/src/utils/vue.ts +7 -16
- 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/histoire.config.ts +0 -7
- package/noeldemartin.config.js +0 -5
- package/postcss.config.js +0 -6
- package/src/assets/histoire.css +0 -3
- package/src/components/AGAppSnackbars.vue +0 -13
- package/src/components/constants.ts +0 -8
- package/src/components/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -41
- package/src/components/forms/AGInput.vue +0 -40
- package/src/components/forms/AGSelect.story.vue +0 -46
- package/src/components/forms/AGSelect.vue +0 -60
- 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 -34
- 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/AGHeadlessSelectButton.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -39
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
- package/src/components/headless/forms/composition.ts +0 -10
- package/src/components/headless/forms/index.ts +0 -18
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -36
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -32
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -23
- package/src/components/headless/modals/index.ts +0 -4
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
- package/src/components/headless/snackbars/index.ts +0 -40
- package/src/components/interfaces.ts +0 -24
- 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 -45
- 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 -26
- package/src/components/modals/AGErrorReportModal.ts +0 -49
- 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.ts +0 -11
- package/src/components/modals/AGModal.vue +0 -39
- 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 -34
- package/src/components/modals/index.ts +0 -17
- package/src/components/snackbars/AGSnackbar.vue +0 -36
- package/src/components/snackbars/index.ts +0 -3
- package/src/directives/initial-focus.ts +0 -11
- package/src/main.histoire.ts +0 -1
- package/tailwind.config.js +0 -4
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -17
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<slot :id="`${input.id}-description`">
|
|
3
|
-
<
|
|
3
|
+
<Markdown
|
|
4
4
|
v-if="show"
|
|
5
5
|
v-bind="$attrs"
|
|
6
6
|
:id="`${input.id}-description`"
|
|
7
|
-
:text
|
|
7
|
+
:text
|
|
8
8
|
/>
|
|
9
9
|
</slot>
|
|
10
10
|
</template>
|
|
@@ -12,16 +12,15 @@
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
13
|
import { computed } from 'vue';
|
|
14
14
|
|
|
15
|
-
import
|
|
16
|
-
|
|
17
|
-
import
|
|
18
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
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';
|
|
19
18
|
|
|
20
19
|
defineOptions({ inheritAttrs: false });
|
|
21
20
|
|
|
22
|
-
const input = injectReactiveOrFail<
|
|
21
|
+
const input = injectReactiveOrFail<InputExpose>(
|
|
23
22
|
'input',
|
|
24
|
-
'<
|
|
23
|
+
'<HeadlessInputDescription> must be a child of a <HeadlessInput>',
|
|
25
24
|
);
|
|
26
25
|
const text = computed(() => (typeof input.description === 'string' ? input.description : ''));
|
|
27
26
|
const show = computed(() => !!input.description);
|
|
@@ -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;
|
|
@@ -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>
|
|
@@ -17,26 +17,18 @@
|
|
|
17
17
|
<script setup lang="ts">
|
|
18
18
|
import { computed, ref, watchEffect } from 'vue';
|
|
19
19
|
|
|
20
|
-
import { injectReactiveOrFail
|
|
21
|
-
import
|
|
22
|
-
import type { FormFieldValue } from '
|
|
23
|
-
import type {
|
|
24
|
-
|
|
25
|
-
import { onFormFocus } from './composition';
|
|
26
|
-
|
|
27
|
-
const props = defineProps({
|
|
28
|
-
type: stringProp('text'),
|
|
29
|
-
});
|
|
20
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
|
+
import { onFormFocus } from '@aerogel/core/components/utils';
|
|
22
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
23
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
30
24
|
|
|
25
|
+
const { type = 'text' } = defineProps<{ type?: string }>();
|
|
31
26
|
const $input = ref<HTMLInputElement>();
|
|
32
|
-
const input = injectReactiveOrFail<
|
|
33
|
-
'input',
|
|
34
|
-
'<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>',
|
|
35
|
-
);
|
|
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>
|
|
@@ -9,14 +9,10 @@
|
|
|
9
9
|
<script setup lang="ts">
|
|
10
10
|
import { computed, useSlots } from 'vue';
|
|
11
11
|
|
|
12
|
-
import { injectReactiveOrFail } from '
|
|
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
|
@@ -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
|
|
@@ -14,18 +14,16 @@
|
|
|
14
14
|
</template>
|
|
15
15
|
|
|
16
16
|
<script setup lang="ts">
|
|
17
|
-
import { computed, ref
|
|
17
|
+
import { computed, ref } from 'vue';
|
|
18
18
|
|
|
19
|
-
import {
|
|
20
|
-
import
|
|
21
|
-
import type {
|
|
22
|
-
|
|
23
|
-
import { onFormFocus } from './composition';
|
|
19
|
+
import { onFormFocus } from '@aerogel/core/components/utils';
|
|
20
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
|
+
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
24
22
|
|
|
25
23
|
const $textArea = ref<HTMLTextAreaElement>();
|
|
26
|
-
const input = injectReactiveOrFail<
|
|
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>
|
|
@@ -1,37 +1,32 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
>
|
|
8
|
-
<slot :close="close" />
|
|
9
|
-
</component>
|
|
2
|
+
<DialogRoot ref="$root" open @update:open="persistent || close()">
|
|
3
|
+
<DialogPortal>
|
|
4
|
+
<slot :close="close" />
|
|
5
|
+
</DialogPortal>
|
|
6
|
+
</DialogRoot>
|
|
10
7
|
</template>
|
|
11
8
|
|
|
12
9
|
<script setup lang="ts">
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import type { VNode } from 'vue';
|
|
10
|
+
import { ref } from 'vue';
|
|
11
|
+
import { DialogPortal, DialogRoot } from 'reka-ui';
|
|
16
12
|
|
|
17
|
-
import Events from '
|
|
18
|
-
import { useEvent } from '
|
|
19
|
-
import { injectReactiveOrFail } from '
|
|
20
|
-
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';
|
|
21
18
|
|
|
22
|
-
|
|
23
|
-
|
|
19
|
+
defineProps<ModalProps>();
|
|
20
|
+
defineSlots<ModalSlots>();
|
|
24
21
|
|
|
25
|
-
const props = defineProps(useModalProps());
|
|
26
22
|
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
27
23
|
const hidden = ref(true);
|
|
28
24
|
const closed = ref(false);
|
|
29
|
-
const { modal } = injectReactiveOrFail<
|
|
25
|
+
const { modal } = injectReactiveOrFail<UIModalContext>(
|
|
30
26
|
'modal',
|
|
31
|
-
'could not obtain modal reference from <
|
|
27
|
+
'could not obtain modal reference from <HeadlessModal>, ' +
|
|
32
28
|
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
33
29
|
);
|
|
34
|
-
const rootComponent = computed(() => (modal.properties.inline ? 'div' : Dialog));
|
|
35
30
|
|
|
36
31
|
async function hide(): Promise<void> {
|
|
37
32
|
if (!$root.value?.$el) {
|
|
@@ -87,6 +82,5 @@ useEvent('show-modal', async ({ id }) => {
|
|
|
87
82
|
await show();
|
|
88
83
|
});
|
|
89
84
|
|
|
90
|
-
|
|
91
|
-
defineExpose<IAGHeadlessModal>({ close, cancellable: toRef(props, 'cancellable'), inline: toRef(props, 'inline') });
|
|
85
|
+
defineExpose<ModalExpose>({ close });
|
|
92
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,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectRoot v-slot="{ open }: ComponentProps" :model-value="acceptableValue" @update:model-value="update($event)">
|
|
3
|
+
<slot :model-value :open>
|
|
4
|
+
<HeadlessSelectTrigger />
|
|
5
|
+
<HeadlessSelectOptions />
|
|
6
|
+
</slot>
|
|
7
|
+
</SelectRoot>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { computed, inject, provide, readonly } from 'vue';
|
|
12
|
+
import { value as evaluate, toString, uuid } from '@noeldemartin/utils';
|
|
13
|
+
import { SelectRoot } from 'reka-ui';
|
|
14
|
+
import type { AcceptableValue } from 'reka-ui';
|
|
15
|
+
|
|
16
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
17
|
+
import { hasSelectOptionLabel } from '@aerogel/core/components/contracts/Select';
|
|
18
|
+
import type FormController from '@aerogel/core/forms/FormController';
|
|
19
|
+
import type { ComponentProps } from '@aerogel/core/utils/vue';
|
|
20
|
+
import type { SelectEmits, SelectExpose, SelectProps } from '@aerogel/core/components/contracts/Select';
|
|
21
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
22
|
+
|
|
23
|
+
import HeadlessSelectTrigger from './HeadlessSelectTrigger.vue';
|
|
24
|
+
import HeadlessSelectOptions from './HeadlessSelectOptions.vue';
|
|
25
|
+
|
|
26
|
+
const { name, label, options, renderOption, description, placeholder, modelValue } = defineProps<SelectProps>();
|
|
27
|
+
const emit = defineEmits<SelectEmits>();
|
|
28
|
+
const form = inject<FormController | null>('form', null);
|
|
29
|
+
const acceptableValue = computed(() => modelValue as AcceptableValue);
|
|
30
|
+
const errors = computed(() => {
|
|
31
|
+
if (!form || !name) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return form.errors[name] ?? null;
|
|
36
|
+
});
|
|
37
|
+
const computedOptions = computed(() => {
|
|
38
|
+
if (!options) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return options.map((option) => ({
|
|
43
|
+
key: uuid(),
|
|
44
|
+
label: renderOption
|
|
45
|
+
? renderOption(option)
|
|
46
|
+
: hasSelectOptionLabel(option)
|
|
47
|
+
? evaluate(option.label as string)
|
|
48
|
+
: toString(option),
|
|
49
|
+
value: option as AcceptableValue,
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
52
|
+
const context = {
|
|
53
|
+
id: `select-${uuid()}`,
|
|
54
|
+
name: computed(() => name),
|
|
55
|
+
label: computed(() => label),
|
|
56
|
+
description: computed(() => description),
|
|
57
|
+
placeholder: computed(() => placeholder ?? translateWithDefault('ui.select', 'Select an option')),
|
|
58
|
+
options: computedOptions,
|
|
59
|
+
selectedOption: computed(() => computedOptions.value?.find((option) => option.value === modelValue)),
|
|
60
|
+
value: computed(() => {
|
|
61
|
+
if (form && name) {
|
|
62
|
+
return form.getFieldValue(name);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return modelValue;
|
|
66
|
+
}),
|
|
67
|
+
errors: readonly(errors),
|
|
68
|
+
required: computed(() => {
|
|
69
|
+
if (!name || !form) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return form.getFieldRules(name).includes('required');
|
|
74
|
+
}),
|
|
75
|
+
update(value) {
|
|
76
|
+
if (form && name) {
|
|
77
|
+
form.setFieldValue(name, value as FormFieldValue);
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
emit('update:modelValue', value);
|
|
83
|
+
},
|
|
84
|
+
} satisfies SelectExpose;
|
|
85
|
+
|
|
86
|
+
function update(value: AcceptableValue) {
|
|
87
|
+
context.update(value as FormFieldValue);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
provide('select', context);
|
|
91
|
+
defineExpose(context);
|
|
92
|
+
</script>
|
|
@@ -7,14 +7,13 @@
|
|
|
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 { 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,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,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { AGAppLayout, AGAppOverlays };
|
|
1
|
+
export { default as AppLayout } from './AppLayout.vue';
|
|
2
|
+
export { default as AppOverlays } from './AppOverlays.vue';
|
|
5
3
|
|
|
6
4
|
export * from './composition';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './forms';
|
|
5
|
+
export * from './contracts';
|
|
9
6
|
export * from './headless';
|
|
10
|
-
export * from './
|
|
11
|
-
export * from './lib';
|
|
12
|
-
export * from './modals';
|
|
13
|
-
export * from './snackbars';
|
|
7
|
+
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>
|