@aerogel/core 0.0.0-next.9a02fcd3bcf698211dd7a71d4c48257c96dd7832 → 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2
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 +2130 -1361
- package/dist/aerogel-core.js +2763 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +23 -37
- package/src/bootstrap/bootstrap.test.ts +4 -8
- package/src/bootstrap/index.ts +25 -16
- package/src/bootstrap/options.ts +1 -1
- package/src/components/AGAppLayout.vue +1 -1
- package/src/components/AGAppModals.vue +1 -1
- package/src/components/AGAppOverlays.vue +1 -1
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/composition.ts +23 -0
- package/src/components/contracts/Modal.ts +16 -0
- package/src/components/contracts/index.ts +2 -0
- package/src/components/contracts/shared.ts +9 -0
- package/src/components/forms/AGButton.vue +2 -2
- package/src/components/forms/AGCheckbox.vue +4 -3
- package/src/components/forms/AGForm.vue +11 -12
- package/src/components/forms/AGInput.vue +8 -4
- package/src/components/forms/AGSelect.vue +11 -17
- package/src/components/headless/forms/AGHeadlessButton.ts +3 -0
- package/src/components/headless/forms/AGHeadlessButton.vue +16 -5
- package/src/components/headless/forms/AGHeadlessInput.ts +18 -5
- package/src/components/headless/forms/AGHeadlessInput.vue +19 -6
- package/src/components/headless/forms/AGHeadlessInputDescription.vue +28 -0
- package/src/components/headless/forms/AGHeadlessInputError.vue +2 -2
- package/src/components/headless/forms/AGHeadlessInputInput.vue +43 -6
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInputTextArea.vue +43 -0
- package/src/components/headless/forms/AGHeadlessSelect.ts +3 -3
- package/src/components/headless/forms/AGHeadlessSelect.vue +15 -15
- package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +10 -18
- package/src/components/headless/forms/AGHeadlessSelectOptions.vue +19 -0
- package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +25 -0
- package/src/components/headless/forms/composition.ts +10 -0
- package/src/components/headless/forms/index.ts +6 -3
- package/src/components/headless/modals/AGHeadlessModal.ts +17 -18
- package/src/components/headless/modals/AGHeadlessModal.vue +12 -10
- package/src/components/headless/modals/AGHeadlessModalContent.vue +25 -0
- package/src/components/headless/modals/index.ts +3 -2
- package/src/components/headless/snackbars/index.ts +3 -3
- package/src/components/index.ts +2 -0
- package/src/components/lib/AGErrorMessage.vue +3 -3
- package/src/components/lib/AGMarkdown.vue +24 -6
- package/src/components/lib/AGMeasured.vue +3 -2
- package/src/components/lib/AGProgressBar.vue +55 -0
- package/src/components/lib/AGStartupCrash.vue +1 -1
- package/src/components/lib/index.ts +1 -0
- package/src/components/modals/AGAlertModal.ts +6 -3
- package/src/components/modals/AGConfirmModal.ts +19 -4
- package/src/components/modals/AGConfirmModal.vue +6 -5
- package/src/components/modals/AGErrorReportModal.ts +8 -5
- package/src/components/modals/AGErrorReportModal.vue +2 -2
- package/src/components/modals/AGErrorReportModalButtons.vue +10 -10
- package/src/components/modals/AGErrorReportModalTitle.vue +2 -2
- package/src/components/modals/AGLoadingModal.ts +11 -5
- package/src/components/modals/AGModal.vue +20 -19
- package/src/components/modals/AGModalContext.ts +1 -1
- package/src/components/modals/AGModalContext.vue +15 -5
- package/src/components/modals/AGModalTitle.vue +1 -1
- package/src/components/modals/AGPromptModal.ts +15 -4
- package/src/components/modals/AGPromptModal.vue +5 -4
- package/src/components/modals/index.ts +0 -1
- package/src/components/snackbars/AGSnackbar.vue +2 -2
- package/src/components/utils.ts +62 -9
- package/src/directives/index.ts +11 -5
- package/src/directives/measure.ts +34 -6
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +12 -12
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +9 -6
- package/src/errors/utils.ts +17 -1
- package/src/forms/Form.test.ts +32 -3
- package/src/forms/Form.ts +80 -20
- package/src/forms/composition.ts +2 -2
- package/src/forms/index.ts +3 -1
- package/src/forms/utils.ts +34 -3
- package/src/forms/validation.ts +19 -0
- package/src/{main.ts → index.ts} +1 -0
- package/src/jobs/Job.ts +144 -2
- package/src/jobs/index.ts +4 -1
- 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 +48 -21
- 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 +26 -3
- package/src/services/App.ts +11 -3
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.ts +15 -5
- package/src/services/Service.ts +125 -54
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +13 -5
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +4 -3
- package/src/testing/setup.ts +11 -0
- package/src/ui/UI.state.ts +9 -2
- package/src/ui/UI.ts +157 -52
- package/src/ui/index.ts +5 -4
- package/src/ui/utils.ts +16 -0
- package/src/utils/composition/events.ts +2 -2
- 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 +24 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +19 -6
- package/src/utils/vue.ts +22 -15
- 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/headless/forms/AGHeadlessSelectButton.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/modals/AGModal.ts +0 -10
- 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 -14
|
@@ -7,8 +7,8 @@
|
|
|
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
12
|
|
|
13
13
|
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
14
14
|
|
|
@@ -4,19 +4,25 @@
|
|
|
4
4
|
ref="$input"
|
|
5
5
|
:name="name"
|
|
6
6
|
:type="type"
|
|
7
|
-
:
|
|
7
|
+
:required="input.required ?? undefined"
|
|
8
8
|
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
9
|
-
:aria-describedby="
|
|
9
|
+
:aria-describedby="
|
|
10
|
+
input.errors ? `${input.id}-error` : input.description ? `${input.id}-description` : undefined
|
|
11
|
+
"
|
|
10
12
|
:checked="checked"
|
|
11
13
|
@input="update"
|
|
12
14
|
>
|
|
13
15
|
</template>
|
|
14
16
|
|
|
15
17
|
<script setup lang="ts">
|
|
16
|
-
import { computed, ref } from 'vue';
|
|
18
|
+
import { computed, ref, watchEffect } from 'vue';
|
|
17
19
|
|
|
18
|
-
import { injectReactiveOrFail, stringProp } from '
|
|
19
|
-
import type {
|
|
20
|
+
import { injectReactiveOrFail, stringProp } from '@aerogel/core/utils/vue';
|
|
21
|
+
import type { __SetsElement } from '@aerogel/core/components/contracts/shared';
|
|
22
|
+
import type { FormFieldValue } from '@aerogel/core/forms/Form';
|
|
23
|
+
import type { IAGHeadlessInput } from '@aerogel/core/components/headless/forms/AGHeadlessInput';
|
|
24
|
+
|
|
25
|
+
import { onFormFocus } from './composition';
|
|
20
26
|
|
|
21
27
|
const props = defineProps({
|
|
22
28
|
type: stringProp('text'),
|
|
@@ -42,6 +48,37 @@ function update() {
|
|
|
42
48
|
return;
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
input.update(
|
|
51
|
+
input.update(getValue());
|
|
46
52
|
}
|
|
53
|
+
|
|
54
|
+
function getValue(): FormFieldValue | null {
|
|
55
|
+
if (!$input.value) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
switch (props.type) {
|
|
60
|
+
case 'checkbox':
|
|
61
|
+
return $input.value.checked;
|
|
62
|
+
case 'date':
|
|
63
|
+
return $input.value.valueAsDate;
|
|
64
|
+
default:
|
|
65
|
+
return $input.value.value;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
onFormFocus(input, () => $input.value?.focus());
|
|
70
|
+
watchEffect(() => (input as unknown as __SetsElement).__setElement($input.value));
|
|
71
|
+
watchEffect(() => {
|
|
72
|
+
if (!$input.value) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (props.type === 'date') {
|
|
77
|
+
$input.value.valueAsDate = value.value as Date;
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$input.value.value = value.value as string;
|
|
83
|
+
});
|
|
47
84
|
</script>
|
|
@@ -9,7 +9,7 @@
|
|
|
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
13
|
|
|
14
14
|
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
15
15
|
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<textarea
|
|
3
|
+
:id="input.id"
|
|
4
|
+
ref="$textArea"
|
|
5
|
+
:name="name"
|
|
6
|
+
:required="input.required ?? undefined"
|
|
7
|
+
:value="value"
|
|
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, watchEffect } from 'vue';
|
|
18
|
+
|
|
19
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
20
|
+
import type { IAGHeadlessInput } from '@aerogel/core/components/headless/forms/AGHeadlessInput';
|
|
21
|
+
import type { __SetsElement } from '@aerogel/core/components/contracts/shared';
|
|
22
|
+
|
|
23
|
+
import { onFormFocus } from './composition';
|
|
24
|
+
|
|
25
|
+
const $textArea = ref<HTMLTextAreaElement>();
|
|
26
|
+
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
27
|
+
'input',
|
|
28
|
+
'<AGHeadlessInputTextArea> must be a child of a <AGHeadlessInput>',
|
|
29
|
+
);
|
|
30
|
+
const name = computed(() => input.name ?? undefined);
|
|
31
|
+
const value = computed(() => input.value as string);
|
|
32
|
+
|
|
33
|
+
function update() {
|
|
34
|
+
if (!$textArea.value) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
input.update($textArea.value.value);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
watchEffect(() => (input as unknown as __SetsElement).__setElement($textArea.value));
|
|
42
|
+
onFormFocus(input, () => $textArea.value?.focus());
|
|
43
|
+
</script>
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
2
|
import type { Writable } from '@noeldemartin/utils';
|
|
3
3
|
|
|
4
|
-
import { mixedProp, requiredArrayProp, stringProp } from '
|
|
5
|
-
import { extractComponentProps } from '
|
|
6
|
-
import type { FormFieldValue } from '
|
|
4
|
+
import { mixedProp, requiredArrayProp, stringProp } from '@aerogel/core/utils/vue';
|
|
5
|
+
import { extractComponentProps } from '@aerogel/core/components/utils';
|
|
6
|
+
import type { FormFieldValue } from '@aerogel/core/forms/Form';
|
|
7
7
|
|
|
8
8
|
export interface IAGHeadlessSelect {
|
|
9
9
|
id: string;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
@update:model-value="update($event)"
|
|
6
|
-
>
|
|
7
|
-
<slot :value="value" :open="open" :disabled="disabled" />
|
|
8
|
-
</Listbox>
|
|
2
|
+
<SelectRoot v-slot="{ open }: ComponentProps" :model-value="selectedOption" @update:model-value="update($event)">
|
|
3
|
+
<slot :model-value="modelValue" :open="open" />
|
|
4
|
+
</SelectRoot>
|
|
9
5
|
</template>
|
|
10
6
|
|
|
11
7
|
<script setup lang="ts">
|
|
12
8
|
import { computed, inject, provide } from 'vue';
|
|
13
9
|
import { toString, uuid } from '@noeldemartin/utils';
|
|
14
|
-
import {
|
|
10
|
+
import { SelectRoot } from 'reka-ui';
|
|
11
|
+
import type { AcceptableValue } from 'reka-ui';
|
|
15
12
|
|
|
16
|
-
import { mixedProp } from '
|
|
17
|
-
import { translateWithDefault } from '
|
|
18
|
-
import type Form from '
|
|
19
|
-
import type { FormFieldValue } from '
|
|
20
|
-
import type { ComponentProps } from '
|
|
13
|
+
import { mixedProp } from '@aerogel/core/utils/vue';
|
|
14
|
+
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
15
|
+
import type Form from '@aerogel/core/forms/Form';
|
|
16
|
+
import type { FormFieldValue } from '@aerogel/core/forms/Form';
|
|
17
|
+
import type { ComponentProps } from '@aerogel/core/utils/vue';
|
|
21
18
|
|
|
22
19
|
import { useSelectEmits, useSelectProps } from './AGHeadlessSelect';
|
|
23
20
|
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
@@ -40,7 +37,9 @@ const renderText = computed(() => {
|
|
|
40
37
|
});
|
|
41
38
|
const form = inject<Form | null>('form', null);
|
|
42
39
|
const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
|
|
43
|
-
const selectedOption = computed(
|
|
40
|
+
const selectedOption = computed(
|
|
41
|
+
() => (form && props.name ? form.getFieldValue(props.name) : props.modelValue) as AcceptableValue,
|
|
42
|
+
);
|
|
44
43
|
const errors = computed(() => {
|
|
45
44
|
if (!form || !props.name) {
|
|
46
45
|
return null;
|
|
@@ -49,7 +48,8 @@ const errors = computed(() => {
|
|
|
49
48
|
return form.errors[props.name] ?? null;
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
|
|
51
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
+
function update(value: any) {
|
|
53
53
|
if (form && props.name) {
|
|
54
54
|
form.setFieldValue(props.name, value);
|
|
55
55
|
|
|
@@ -7,8 +7,8 @@
|
|
|
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
12
|
|
|
13
13
|
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
14
14
|
|
|
@@ -1,31 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
:class="{
|
|
6
|
-
[activeClass ?? 'active']: active,
|
|
7
|
-
[inactiveClass ?? 'inactive']: !active,
|
|
8
|
-
[selectedClass ?? 'selected']: selected,
|
|
9
|
-
[unselectedClass ?? 'unselected']: !selected,
|
|
10
|
-
}"
|
|
11
|
-
>
|
|
2
|
+
<SelectItem :value="value" as="template">
|
|
3
|
+
<SelectItemText>
|
|
4
|
+
<slot>
|
|
12
5
|
{{ select.renderText(value) }}
|
|
13
|
-
</
|
|
14
|
-
</
|
|
15
|
-
</
|
|
6
|
+
</slot>
|
|
7
|
+
</SelectItemText>
|
|
8
|
+
</SelectItem>
|
|
16
9
|
</template>
|
|
17
10
|
|
|
18
11
|
<script setup lang="ts">
|
|
19
|
-
import {
|
|
12
|
+
import { SelectItem, SelectItemText } from 'reka-ui';
|
|
20
13
|
|
|
21
|
-
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '
|
|
22
|
-
import type { ComponentProps } from '@/utils/vue';
|
|
23
|
-
import type { FormFieldValue } from '@/forms/Form';
|
|
14
|
+
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@aerogel/core/utils/vue';
|
|
24
15
|
|
|
25
16
|
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
26
17
|
|
|
27
18
|
defineProps({
|
|
28
|
-
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
value: requiredMixedProp<any>(),
|
|
29
21
|
selectedClass: stringProp(),
|
|
30
22
|
unselectedClass: stringProp(),
|
|
31
23
|
activeClass: stringProp(),
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectPortal>
|
|
3
|
+
<SelectContent :class="classes">
|
|
4
|
+
<SelectViewport>
|
|
5
|
+
<slot />
|
|
6
|
+
</SelectViewport>
|
|
7
|
+
</SelectContent>
|
|
8
|
+
</SelectPortal>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script setup lang="ts">
|
|
12
|
+
import { computed } from 'vue';
|
|
13
|
+
import { SelectContent, SelectPortal, SelectViewport } from 'reka-ui';
|
|
14
|
+
|
|
15
|
+
import { stringProp } from '@aerogel/core/utils/vue';
|
|
16
|
+
|
|
17
|
+
const props = defineProps({ class: stringProp('') });
|
|
18
|
+
const classes = computed(() => props.class);
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<SelectTrigger>
|
|
3
|
+
<SelectValue>
|
|
4
|
+
<slot>
|
|
5
|
+
<span :class="textClass">{{ select?.buttonText }}</span>
|
|
6
|
+
</slot>
|
|
7
|
+
<slot name="icon" />
|
|
8
|
+
</SelectValue>
|
|
9
|
+
</SelectTrigger>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { SelectTrigger, SelectValue } from 'reka-ui';
|
|
14
|
+
|
|
15
|
+
import { injectReactiveOrFail, stringProp } from '@aerogel/core/utils/vue';
|
|
16
|
+
|
|
17
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
18
|
+
|
|
19
|
+
defineProps({ textClass: stringProp() });
|
|
20
|
+
|
|
21
|
+
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
22
|
+
'select',
|
|
23
|
+
'<AGHeadlessSelectTrigger> must be a child of a <AGHeadlessSelect>',
|
|
24
|
+
);
|
|
25
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { inject, onUnmounted } from 'vue';
|
|
2
|
+
|
|
3
|
+
import type Form from '@aerogel/core/forms/Form';
|
|
4
|
+
|
|
5
|
+
export function onFormFocus(input: { name: string | null }, listener: () => unknown): void {
|
|
6
|
+
const form = inject<Form | null>('form', null);
|
|
7
|
+
const stop = form?.on('focus', (name) => input.name === name && listener());
|
|
8
|
+
|
|
9
|
+
onUnmounted(() => stop?.());
|
|
10
|
+
}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
export * from './composition';
|
|
2
|
+
export * from './AGHeadlessButton';
|
|
1
3
|
export * from './AGHeadlessInput';
|
|
2
4
|
export * from './AGHeadlessSelect';
|
|
3
5
|
export * from './AGHeadlessSelectOption';
|
|
4
6
|
export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
|
|
5
7
|
export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
|
|
8
|
+
export { default as AGHeadlessInputDescription } from './AGHeadlessInputDescription.vue';
|
|
6
9
|
export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
|
|
7
10
|
export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
|
|
8
11
|
export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
|
|
12
|
+
export { default as AGHeadlessInputTextArea } from './AGHeadlessInputTextArea.vue';
|
|
9
13
|
export { default as AGHeadlessSelect } from './AGHeadlessSelect.vue';
|
|
10
|
-
export { default as
|
|
14
|
+
export { default as AGHeadlessSelectTrigger } from './AGHeadlessSelectTrigger.vue';
|
|
11
15
|
export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
|
|
12
|
-
export { default as AGHeadlessSelectLabel } from './AGHeadlessSelectLabel.vue';
|
|
13
16
|
export { default as AGHeadlessSelectOption } from './AGHeadlessSelectOption.vue';
|
|
14
|
-
export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions';
|
|
17
|
+
export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions.vue';
|
|
@@ -1,34 +1,33 @@
|
|
|
1
1
|
import { computed } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
3
|
|
|
4
|
-
import { booleanProp, stringProp } from '
|
|
5
|
-
import { extractComponentProps } from '
|
|
6
|
-
import type {
|
|
4
|
+
import { booleanProp, stringProp } from '@aerogel/core/utils/vue';
|
|
5
|
+
import { extractComponentProps } from '@aerogel/core/components/utils';
|
|
6
|
+
import type { ComponentPropDefinitions } from '@aerogel/core/components/utils';
|
|
7
|
+
import type { ComponentProps } from '@aerogel/core/utils/vue';
|
|
8
|
+
import type { IModal, IModalProps } from '@aerogel/core/components/contracts/Modal';
|
|
7
9
|
|
|
8
|
-
export interface IAGHeadlessModal extends
|
|
10
|
+
export interface IAGHeadlessModal extends IModal {}
|
|
9
11
|
|
|
10
12
|
export interface IAGHeadlessModalDefaultSlotProps {
|
|
11
13
|
close(result?: unknown): Promise<void>;
|
|
12
14
|
}
|
|
13
15
|
|
|
14
|
-
export
|
|
15
|
-
|
|
16
|
-
title: stringProp(),
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function useModalProps(): typeof modalProps {
|
|
20
|
-
return modalProps;
|
|
16
|
+
export function extractModalProps<T extends IModalProps>(props: T): ComponentProps<IModalProps> {
|
|
17
|
+
return extractComponentProps(props, modalProps());
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
export function
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
export function modalProps(): ComponentPropDefinitions<IModalProps> {
|
|
21
|
+
return {
|
|
22
|
+
cancellable: booleanProp(true),
|
|
23
|
+
description: stringProp(),
|
|
24
|
+
title: stringProp(),
|
|
25
|
+
};
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
export function
|
|
28
|
+
export function modalExpose($modal: Ref<IAGHeadlessModal | undefined>): IModal {
|
|
30
29
|
return {
|
|
31
|
-
close: async () => $modal.value?.close(),
|
|
32
30
|
cancellable: computed(() => !!$modal.value?.cancellable),
|
|
31
|
+
close: async () => $modal.value?.close(),
|
|
33
32
|
};
|
|
34
33
|
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
2
|
+
<DialogRoot ref="$root" :open="true" @update:open="cancellable && close()">
|
|
3
|
+
<DialogPortal>
|
|
4
|
+
<slot :close="close" />
|
|
5
|
+
</DialogPortal>
|
|
6
|
+
</DialogRoot>
|
|
5
7
|
</template>
|
|
6
8
|
|
|
7
9
|
<script setup lang="ts">
|
|
8
10
|
import { ref, toRef } from 'vue';
|
|
9
|
-
import {
|
|
11
|
+
import { DialogPortal, DialogRoot } from 'reka-ui';
|
|
10
12
|
import type { VNode } from 'vue';
|
|
11
13
|
|
|
12
|
-
import Events from '
|
|
13
|
-
import { useEvent } from '
|
|
14
|
-
import { injectReactiveOrFail } from '
|
|
15
|
-
import type { IAGModalContext } from '
|
|
14
|
+
import Events from '@aerogel/core/services/Events';
|
|
15
|
+
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
16
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
+
import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
|
|
16
18
|
|
|
17
|
-
import {
|
|
19
|
+
import { modalProps } from './AGHeadlessModal';
|
|
18
20
|
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
19
21
|
|
|
20
|
-
const props = defineProps(
|
|
22
|
+
const props = defineProps(modalProps());
|
|
21
23
|
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
22
24
|
const hidden = ref(true);
|
|
23
25
|
const closed = ref(false);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogContent>
|
|
3
|
+
<slot />
|
|
4
|
+
|
|
5
|
+
<AGModalContext 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 UI from '@aerogel/core/ui/UI';
|
|
14
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
15
|
+
import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
|
|
16
|
+
|
|
17
|
+
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
18
|
+
|
|
19
|
+
const { childIndex } = injectReactiveOrFail<IAGModalContext>(
|
|
20
|
+
'modal',
|
|
21
|
+
'could not obtain modal reference from <AGHeadlessModalContent>, ' +
|
|
22
|
+
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
23
|
+
);
|
|
24
|
+
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
25
|
+
</script>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export { DialogTitle as AGHeadlessModalTitle } from 'reka-ui';
|
|
2
|
+
|
|
1
3
|
export * from './AGHeadlessModal';
|
|
2
4
|
export { default as AGHeadlessModal } from './AGHeadlessModal.vue';
|
|
3
|
-
export { default as
|
|
4
|
-
export { default as AGHeadlessModalTitle } from './AGHeadlessModalTitle.vue';
|
|
5
|
+
export { default as AGHeadlessModalContent } from './AGHeadlessModalContent.vue';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ExtractPropTypes } from 'vue';
|
|
2
2
|
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
3
|
|
|
4
|
-
import UI from '
|
|
5
|
-
import { arrayProp, enumProp, requiredStringProp } from '
|
|
6
|
-
import { Colors } from '
|
|
4
|
+
import UI from '@aerogel/core/ui/UI';
|
|
5
|
+
import { arrayProp, enumProp, requiredStringProp } from '@aerogel/core/utils/vue';
|
|
6
|
+
import { Colors } from '@aerogel/core/components/constants';
|
|
7
7
|
import { objectWithout } from '@noeldemartin/utils';
|
|
8
8
|
|
|
9
9
|
export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
|
package/src/components/index.ts
CHANGED
|
@@ -3,7 +3,9 @@ import AGAppOverlays from './AGAppOverlays.vue';
|
|
|
3
3
|
|
|
4
4
|
export { AGAppLayout, AGAppOverlays };
|
|
5
5
|
|
|
6
|
+
export * from './composition';
|
|
6
7
|
export * from './constants';
|
|
8
|
+
export * from './contracts';
|
|
7
9
|
export * from './forms';
|
|
8
10
|
export * from './headless';
|
|
9
11
|
export * from './lib';
|
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { computed } from 'vue';
|
|
7
7
|
|
|
8
|
-
import { requiredObjectProp } from '
|
|
9
|
-
import { getErrorMessage } from '
|
|
10
|
-
import type { ErrorSource } from '
|
|
8
|
+
import { requiredObjectProp } from '@aerogel/core/utils/vue';
|
|
9
|
+
import { getErrorMessage } from '@aerogel/core/errors/utils';
|
|
10
|
+
import type { ErrorSource } from '@aerogel/core/errors/Errors.state';
|
|
11
11
|
|
|
12
12
|
import AGMarkdown from './AGMarkdown.vue';
|
|
13
13
|
|
|
@@ -3,20 +3,23 @@
|
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
|
-
import { computed, h } from 'vue';
|
|
6
|
+
import { computed, h, useAttrs } from 'vue';
|
|
7
|
+
import { isInstanceOf } from '@noeldemartin/utils';
|
|
7
8
|
|
|
8
|
-
import { renderMarkdown } from '
|
|
9
|
-
import { booleanProp, objectProp, stringProp } from '
|
|
10
|
-
import { translate } from '
|
|
9
|
+
import { renderMarkdown } from '@aerogel/core/utils/markdown';
|
|
10
|
+
import { booleanProp, mixedProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
|
|
11
|
+
import { translate } from '@aerogel/core/lang';
|
|
11
12
|
|
|
12
13
|
const props = defineProps({
|
|
13
14
|
as: stringProp(),
|
|
14
15
|
inline: booleanProp(),
|
|
15
16
|
langKey: stringProp(),
|
|
16
|
-
langParams:
|
|
17
|
+
langParams: mixedProp<number | Record<string, unknown>>(),
|
|
17
18
|
text: stringProp(),
|
|
19
|
+
actions: objectProp<Record<string, () => unknown>>(),
|
|
18
20
|
});
|
|
19
21
|
|
|
22
|
+
const attrs = useAttrs();
|
|
20
23
|
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
|
|
21
24
|
const html = computed(() => {
|
|
22
25
|
if (!markdown.value) {
|
|
@@ -32,5 +35,20 @@ const html = computed(() => {
|
|
|
32
35
|
return renderedHtml;
|
|
33
36
|
});
|
|
34
37
|
const root = () =>
|
|
35
|
-
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
38
|
+
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
39
|
+
innerHTML: html.value,
|
|
40
|
+
onClick,
|
|
41
|
+
...attrs,
|
|
42
|
+
class: `${attrs.class ?? ''} ${props.inline ? '' : 'prose'}`,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
async function onClick(event: Event) {
|
|
46
|
+
const { target } = event;
|
|
47
|
+
|
|
48
|
+
if (isInstanceOf(target, HTMLElement) && target.dataset.markdownAction) {
|
|
49
|
+
props.actions?.[target.dataset.markdownAction]?.();
|
|
50
|
+
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
36
54
|
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="as" v-measure="() => (measured = true)" :class="{ '!
|
|
2
|
+
<component :is="as" v-measure="() => (measured = true)" :class="{ 'invisible! absolute! w-auto!': !measured }">
|
|
3
3
|
<slot />
|
|
4
4
|
</component>
|
|
5
5
|
</template>
|
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { ref } from 'vue';
|
|
9
9
|
|
|
10
|
-
import { stringProp } from '
|
|
10
|
+
import { stringProp } from '@aerogel/core/utils/vue';
|
|
11
11
|
|
|
12
12
|
defineProps({ as: stringProp('span') });
|
|
13
13
|
|
|
14
|
+
// TODO use v-measure.css
|
|
14
15
|
const measured = ref(false);
|
|
15
16
|
</script>
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200">
|
|
3
|
+
<div :class="barClasses" :style="`transform:translateX(-${(1 - renderedProgress) * 100}%)`" />
|
|
4
|
+
<span class="sr-only">
|
|
5
|
+
{{
|
|
6
|
+
$td('ui.progress', '{progress}% complete', {
|
|
7
|
+
progress: renderedProgress * 100,
|
|
8
|
+
})
|
|
9
|
+
}}
|
|
10
|
+
</span>
|
|
11
|
+
</div>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { computed, onUnmounted, ref, watch } from 'vue';
|
|
16
|
+
|
|
17
|
+
import { numberProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
|
|
18
|
+
import type { Job } from '@aerogel/core/jobs';
|
|
19
|
+
|
|
20
|
+
const props = defineProps({
|
|
21
|
+
progress: numberProp(),
|
|
22
|
+
barClass: stringProp(''),
|
|
23
|
+
job: objectProp<Job>(),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
let cleanup: Function | undefined;
|
|
27
|
+
const jobProgress = ref(0);
|
|
28
|
+
const barClasses = computed(() => {
|
|
29
|
+
const classes = props.barClass ?? '';
|
|
30
|
+
|
|
31
|
+
return `size-full transition-transform duration-500 ease-linear ${
|
|
32
|
+
classes.includes('bg-') ? classes : `${classes} bg-gray-700`
|
|
33
|
+
}`;
|
|
34
|
+
});
|
|
35
|
+
const renderedProgress = computed(() => {
|
|
36
|
+
if (typeof props.progress === 'number') {
|
|
37
|
+
return props.progress;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return jobProgress.value;
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
watch(
|
|
44
|
+
() => props.job,
|
|
45
|
+
() => {
|
|
46
|
+
cleanup?.();
|
|
47
|
+
|
|
48
|
+
jobProgress.value = props.job?.progress ?? 0;
|
|
49
|
+
cleanup = props.job?.listeners.add({ onUpdated: (progress) => (jobProgress.value = progress) });
|
|
50
|
+
},
|
|
51
|
+
{ immediate: true },
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
onUnmounted(() => cleanup?.());
|
|
55
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="grid
|
|
2
|
+
<div class="grid grow place-items-center">
|
|
3
3
|
<div class="flex flex-col items-center space-y-6 p-8">
|
|
4
4
|
<h1 class="mt-2 text-center text-4xl font-medium text-red-600">
|
|
5
5
|
{{ $td('startupCrash.title', 'Something went wrong!') }}
|
|
@@ -2,4 +2,5 @@ export { default as AGErrorMessage } from './AGErrorMessage.vue';
|
|
|
2
2
|
export { default as AGLink } from './AGLink.vue';
|
|
3
3
|
export { default as AGMarkdown } from './AGMarkdown.vue';
|
|
4
4
|
export { default as AGMeasured } from './AGMeasured.vue';
|
|
5
|
+
export { default as AGProgressBar } from './AGProgressBar.vue';
|
|
5
6
|
export { default as AGStartupCrash } from './AGStartupCrash.vue';
|