@aerogel/core 0.0.0-next.88c59e62f64db70aedfbc4c31b5bbc287be44483 → 0.0.0-next.8e6b2bcc764fa682decbb41aa6848c77a744dec3
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.cjs.js +1 -1
- package/dist/aerogel-core.cjs.js.map +1 -1
- package/dist/aerogel-core.d.ts +856 -124
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/histoire.config.ts +7 -0
- package/package.json +14 -5
- package/postcss.config.js +6 -0
- package/src/assets/histoire.css +3 -0
- package/src/bootstrap/bootstrap.test.ts +4 -3
- package/src/bootstrap/index.ts +22 -5
- package/src/bootstrap/options.ts +3 -0
- package/src/components/AGAppLayout.vue +7 -2
- package/src/components/AGAppOverlays.vue +5 -1
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/forms/AGCheckbox.vue +7 -1
- package/src/components/forms/AGInput.vue +8 -6
- package/src/components/forms/AGSelect.story.vue +46 -0
- package/src/components/forms/AGSelect.vue +60 -0
- package/src/components/forms/index.ts +1 -0
- package/src/components/headless/forms/AGHeadlessButton.vue +8 -8
- package/src/components/headless/forms/AGHeadlessInput.ts +21 -1
- package/src/components/headless/forms/AGHeadlessInput.vue +7 -4
- package/src/components/headless/forms/AGHeadlessInputInput.vue +2 -0
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
- package/src/components/headless/forms/AGHeadlessSelect.ts +28 -17
- package/src/components/headless/forms/AGHeadlessSelect.vue +60 -28
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectError.vue +26 -0
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +39 -0
- package/src/components/headless/forms/index.ts +5 -3
- package/src/components/headless/modals/AGHeadlessModal.ts +27 -0
- package/src/components/headless/modals/AGHeadlessModal.vue +3 -5
- package/src/components/headless/modals/index.ts +4 -6
- package/src/components/headless/snackbars/index.ts +23 -8
- package/src/components/index.ts +1 -1
- package/src/components/{basic → lib}/AGErrorMessage.vue +2 -2
- package/src/components/lib/AGMeasured.vue +15 -0
- package/src/components/lib/AGStartupCrash.vue +31 -0
- package/src/components/lib/index.ts +5 -0
- package/src/components/modals/AGAlertModal.ts +15 -0
- package/src/components/modals/AGAlertModal.vue +4 -15
- package/src/components/modals/AGConfirmModal.ts +27 -0
- package/src/components/modals/AGConfirmModal.vue +8 -12
- package/src/components/modals/AGErrorReportModal.ts +27 -1
- package/src/components/modals/AGErrorReportModal.vue +8 -16
- package/src/components/modals/AGErrorReportModalButtons.vue +4 -2
- package/src/components/modals/AGErrorReportModalTitle.vue +1 -1
- package/src/components/modals/AGLoadingModal.ts +23 -0
- package/src/components/modals/AGLoadingModal.vue +4 -8
- package/src/components/modals/AGModal.ts +2 -2
- package/src/components/modals/AGModal.vue +14 -12
- package/src/components/modals/AGPromptModal.ts +30 -0
- package/src/components/modals/AGPromptModal.vue +34 -0
- package/src/components/modals/index.ts +13 -19
- package/src/components/snackbars/AGSnackbar.vue +3 -9
- package/src/components/utils.ts +10 -0
- package/src/directives/index.ts +5 -1
- package/src/directives/measure.ts +21 -0
- package/src/errors/Errors.ts +26 -24
- package/src/errors/index.ts +10 -23
- package/src/errors/utils.ts +19 -0
- package/src/forms/Form.ts +9 -3
- package/src/jobs/Job.ts +5 -0
- package/src/jobs/index.ts +7 -0
- package/src/lang/Lang.ts +11 -23
- package/src/main.histoire.ts +1 -0
- package/src/main.ts +3 -0
- package/src/services/App.state.ts +4 -5
- package/src/services/App.ts +30 -3
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +100 -30
- package/src/services/Service.ts +50 -16
- package/src/services/index.ts +2 -1
- package/src/services/store.ts +8 -5
- package/src/testing/index.ts +25 -0
- package/src/ui/UI.ts +124 -19
- package/src/ui/index.ts +8 -3
- package/src/utils/composition/events.ts +1 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +11 -2
- package/tailwind.config.js +4 -0
- package/tsconfig.json +1 -1
- package/.eslintrc.js +0 -3
- package/dist/virtual.d.ts +0 -11
- package/src/components/basic/index.ts +0 -5
- package/src/components/headless/forms/AGHeadlessSelectButton.ts +0 -3
- package/src/components/headless/forms/AGHeadlessSelectLabel.ts +0 -3
- package/src/types/virtual.d.ts +0 -11
- /package/src/components/{basic → lib}/AGLink.vue +0 -0
- /package/src/components/{basic → lib}/AGMarkdown.vue +0 -0
|
@@ -1,45 +1,77 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Listbox
|
|
3
|
-
|
|
2
|
+
<Listbox
|
|
3
|
+
v-slot="{ value, open, disabled }: ComponentProps"
|
|
4
|
+
:model-value="selectedOption"
|
|
5
|
+
@update:model-value="update($event)"
|
|
6
|
+
>
|
|
7
|
+
<slot :value="value" :open="open" :disabled="disabled" />
|
|
4
8
|
</Listbox>
|
|
5
9
|
</template>
|
|
6
10
|
|
|
7
11
|
<script setup lang="ts">
|
|
8
|
-
import { computed, inject } from 'vue';
|
|
12
|
+
import { computed, inject, provide } from 'vue';
|
|
13
|
+
import { toString, uuid } from '@noeldemartin/utils';
|
|
9
14
|
import { Listbox } from '@headlessui/vue';
|
|
10
15
|
|
|
11
|
-
import { mixedProp
|
|
16
|
+
import { mixedProp } from '@/utils/vue';
|
|
17
|
+
import { translateWithDefault } from '@/lang/utils';
|
|
12
18
|
import type Form from '@/forms/Form';
|
|
19
|
+
import type { FormFieldValue } from '@/forms/Form';
|
|
20
|
+
import type { ComponentProps } from '@/utils/vue';
|
|
13
21
|
|
|
14
|
-
import { useSelectProps } from './AGHeadlessSelect';
|
|
15
|
-
import type { IAGHeadlessSelect
|
|
22
|
+
import { useSelectEmits, useSelectProps } from './AGHeadlessSelect';
|
|
23
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
16
24
|
|
|
17
|
-
const emit = defineEmits(
|
|
25
|
+
const emit = defineEmits(useSelectEmits());
|
|
18
26
|
const props = defineProps({
|
|
19
|
-
|
|
20
|
-
modelValue: mixedProp<SelectOptionValue>(),
|
|
27
|
+
modelValue: mixedProp<FormFieldValue>(),
|
|
21
28
|
...useSelectProps(),
|
|
22
29
|
});
|
|
30
|
+
const renderText = computed(() => {
|
|
31
|
+
if (typeof props.optionsText === 'function') {
|
|
32
|
+
return props.optionsText;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof props.optionsText === 'string') {
|
|
36
|
+
return (option: FormFieldValue): string => toString(option[props.optionsText as keyof FormFieldValue]);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (option: FormFieldValue) => toString(option);
|
|
40
|
+
});
|
|
23
41
|
const form = inject<Form | null>('form', null);
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
+
const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
|
|
43
|
+
const selectedOption = computed(() => (form && props.name ? form.getFieldValue(props.name) : props.modelValue));
|
|
44
|
+
const errors = computed(() => {
|
|
45
|
+
if (!form || !props.name) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return form.errors[props.name] ?? null;
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
function update(value: FormFieldValue) {
|
|
53
|
+
if (form && props.name) {
|
|
54
|
+
form.setFieldValue(props.name, value);
|
|
55
|
+
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
emit('update:modelValue', value);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const api: IAGHeadlessSelect = {
|
|
63
|
+
id: `select-${uuid()}`,
|
|
64
|
+
noSelectionText,
|
|
65
|
+
selectedOption,
|
|
66
|
+
errors,
|
|
67
|
+
options: computed(() => props.options),
|
|
68
|
+
label: computed(() => props.label),
|
|
69
|
+
buttonText: computed(() =>
|
|
70
|
+
selectedOption.value === null ? noSelectionText.value : renderText.value(selectedOption.value)),
|
|
71
|
+
renderText,
|
|
72
|
+
update,
|
|
42
73
|
};
|
|
43
74
|
|
|
44
|
-
|
|
75
|
+
provide<IAGHeadlessSelect>('select', api);
|
|
76
|
+
defineExpose<IAGHeadlessSelect>(api);
|
|
45
77
|
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ListboxButton v-slot="{ value, open, disabled }: ComponentProps">
|
|
3
|
+
<slot :value="value" :open="open" :disabled="disabled">
|
|
4
|
+
<span :class="textClass">{{ select?.buttonText }}</span>
|
|
5
|
+
</slot>
|
|
6
|
+
<slot name="icon" />
|
|
7
|
+
</ListboxButton>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script setup lang="ts">
|
|
11
|
+
import { ListboxButton } from '@headlessui/vue';
|
|
12
|
+
|
|
13
|
+
import { injectReactiveOrFail, stringProp } from '@/utils/vue';
|
|
14
|
+
import type { ComponentProps } from '@/utils/vue';
|
|
15
|
+
|
|
16
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
17
|
+
|
|
18
|
+
defineProps({ textClass: stringProp() });
|
|
19
|
+
|
|
20
|
+
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
21
|
+
'select',
|
|
22
|
+
'<AGHeadlessSelectButton> must be a child of a <AGHeadlessSelect>',
|
|
23
|
+
);
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,26 @@
|
|
|
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 '@/utils/vue';
|
|
11
|
+
import { translateWithDefault } from '@/lang/utils';
|
|
12
|
+
|
|
13
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
14
|
+
|
|
15
|
+
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
16
|
+
'select',
|
|
17
|
+
'<AGHeadlessSelectError> must be a child of a <AGHeadlessSelect>',
|
|
18
|
+
);
|
|
19
|
+
const errorMessage = computed(() => {
|
|
20
|
+
if (!select.errors) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return translateWithDefault(`errors.${select.errors[0]}`, `Error: ${select.errors[0]}`);
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ListboxLabel v-if="show" v-slot="{ open, disabled }: ComponentProps">
|
|
3
|
+
<slot :open="open" :disabled="disabled">
|
|
4
|
+
{{ select.label }}
|
|
5
|
+
</slot>
|
|
6
|
+
</ListboxLabel>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import { computed, useSlots } from 'vue';
|
|
11
|
+
import { ListboxLabel } from '@headlessui/vue';
|
|
12
|
+
|
|
13
|
+
import { injectReactiveOrFail } from '@/utils/vue';
|
|
14
|
+
import type { ComponentProps } from '@/utils/vue';
|
|
15
|
+
|
|
16
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
17
|
+
|
|
18
|
+
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
19
|
+
'select',
|
|
20
|
+
'<AGHeadlessSelectLabel> must be a child of a <AGHeadlessSelect>',
|
|
21
|
+
);
|
|
22
|
+
const slots = useSlots();
|
|
23
|
+
const show = computed(() => !!(select.label || slots.default));
|
|
24
|
+
</script>
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ListboxOption v-slot="{ active, selected, disabled }: ComponentProps" :value="value" as="template">
|
|
3
|
+
<slot :active="active" :selected="selected" :disabled="disabled">
|
|
4
|
+
<li
|
|
5
|
+
:class="{
|
|
6
|
+
[activeClass ?? 'active']: active,
|
|
7
|
+
[inactiveClass ?? 'inactive']: !active,
|
|
8
|
+
[selectedClass ?? 'selected']: selected,
|
|
9
|
+
[unselectedClass ?? 'unselected']: !selected,
|
|
10
|
+
}"
|
|
11
|
+
>
|
|
12
|
+
{{ select.renderText(value) }}
|
|
13
|
+
</li>
|
|
14
|
+
</slot>
|
|
15
|
+
</ListboxOption>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { ListboxOption } from '@headlessui/vue';
|
|
20
|
+
|
|
21
|
+
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@/utils/vue';
|
|
22
|
+
import type { ComponentProps } from '@/utils/vue';
|
|
23
|
+
import type { FormFieldValue } from '@/forms/Form';
|
|
24
|
+
|
|
25
|
+
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
26
|
+
|
|
27
|
+
defineProps({
|
|
28
|
+
value: requiredMixedProp<FormFieldValue>(),
|
|
29
|
+
selectedClass: stringProp(),
|
|
30
|
+
unselectedClass: stringProp(),
|
|
31
|
+
activeClass: stringProp(),
|
|
32
|
+
inactiveClass: stringProp(),
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
36
|
+
'select',
|
|
37
|
+
'<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>',
|
|
38
|
+
);
|
|
39
|
+
</script>
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
export * from './AGHeadlessInput';
|
|
2
2
|
export * from './AGHeadlessSelect';
|
|
3
|
+
export * from './AGHeadlessSelectOption';
|
|
3
4
|
export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
|
|
4
5
|
export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
|
|
5
6
|
export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
|
|
6
7
|
export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
|
|
7
8
|
export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
|
|
8
9
|
export { default as AGHeadlessSelect } from './AGHeadlessSelect.vue';
|
|
9
|
-
export { default as AGHeadlessSelectButton } from './AGHeadlessSelectButton';
|
|
10
|
-
export { default as
|
|
11
|
-
export { default as
|
|
10
|
+
export { default as AGHeadlessSelectButton } from './AGHeadlessSelectButton.vue';
|
|
11
|
+
export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
|
|
12
|
+
export { default as AGHeadlessSelectLabel } from './AGHeadlessSelectLabel.vue';
|
|
13
|
+
export { default as AGHeadlessSelectOption } from './AGHeadlessSelectOption.vue';
|
|
12
14
|
export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions';
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes, Ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
import { booleanProp, stringProp } from '@/utils';
|
|
5
|
+
import { extractComponentProps } from '@/components/utils';
|
|
1
6
|
import type { IAGModal } from '@/components/modals/AGModal';
|
|
2
7
|
|
|
3
8
|
export interface IAGHeadlessModal extends IAGModal {}
|
|
@@ -5,3 +10,25 @@ export interface IAGHeadlessModal extends IAGModal {}
|
|
|
5
10
|
export interface IAGHeadlessModalDefaultSlotProps {
|
|
6
11
|
close(result?: unknown): Promise<void>;
|
|
7
12
|
}
|
|
13
|
+
|
|
14
|
+
export const modalProps = {
|
|
15
|
+
cancellable: booleanProp(true),
|
|
16
|
+
title: stringProp(),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function useModalProps(): typeof modalProps {
|
|
20
|
+
return modalProps;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function extractModalProps<T extends ExtractPropTypes<typeof modalProps>>(
|
|
24
|
+
props: T,
|
|
25
|
+
): Pick<T, keyof typeof modalProps> {
|
|
26
|
+
return extractComponentProps(props, modalProps);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function useModalExpose($modal: Ref<IAGHeadlessModal | undefined>): IAGModal {
|
|
30
|
+
return {
|
|
31
|
+
close: async () => $modal.value?.close(),
|
|
32
|
+
cancellable: computed(() => !!$modal.value?.cancellable),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
@@ -11,15 +11,13 @@ import type { VNode } from 'vue';
|
|
|
11
11
|
|
|
12
12
|
import Events from '@/services/Events';
|
|
13
13
|
import { useEvent } from '@/utils/composition/events';
|
|
14
|
-
import {
|
|
14
|
+
import { injectReactiveOrFail } from '@/utils/vue';
|
|
15
15
|
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
16
16
|
|
|
17
|
+
import { useModalProps } from './AGHeadlessModal';
|
|
17
18
|
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
18
19
|
|
|
19
|
-
const props = defineProps(
|
|
20
|
-
cancellable: booleanProp(true),
|
|
21
|
-
});
|
|
22
|
-
|
|
20
|
+
const props = defineProps(useModalProps());
|
|
23
21
|
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
24
22
|
const hidden = ref(true);
|
|
25
23
|
const closed = ref(false);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { AGHeadlessModal, AGHeadlessModalPanel, AGHeadlessModalTitle, IAGHeadlessModal };
|
|
1
|
+
export * from './AGHeadlessModal';
|
|
2
|
+
export { default as AGHeadlessModal } from './AGHeadlessModal.vue';
|
|
3
|
+
export { default as AGHeadlessModalPanel } from './AGHeadlessModalPanel.vue';
|
|
4
|
+
export { default as AGHeadlessModalTitle } from './AGHeadlessModalTitle.vue';
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import UI from '@/ui/UI';
|
|
1
5
|
import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
|
|
2
6
|
import { Colors } from '@/components/constants';
|
|
3
7
|
import { objectWithout } from '@noeldemartin/utils';
|
|
4
8
|
|
|
5
9
|
export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
|
|
6
10
|
|
|
7
|
-
export interface SnackbarAction {
|
|
8
|
-
text: string;
|
|
9
|
-
dismiss?: boolean;
|
|
10
|
-
handler?(): unknown;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
|
|
14
|
-
|
|
15
11
|
export const SnackbarColors = objectWithout(Colors, ['Primary', 'Clear']);
|
|
16
12
|
export const snackbarProps = {
|
|
17
13
|
id: requiredStringProp(),
|
|
@@ -20,6 +16,25 @@ export const snackbarProps = {
|
|
|
20
16
|
color: enumProp(SnackbarColors, Colors.Secondary),
|
|
21
17
|
};
|
|
22
18
|
|
|
19
|
+
export interface SnackbarAction {
|
|
20
|
+
text: string;
|
|
21
|
+
dismiss?: boolean;
|
|
22
|
+
handler?(): unknown;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
|
|
26
|
+
export type AGSnackbarProps = ObjectWithoutEmpty<ExtractPropTypes<typeof snackbarProps>>;
|
|
27
|
+
|
|
23
28
|
export function useSnackbarProps(): typeof snackbarProps {
|
|
24
29
|
return snackbarProps;
|
|
25
30
|
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
33
|
+
export function useSnackbar(props: ExtractPropTypes<typeof snackbarProps>) {
|
|
34
|
+
function activate(action: SnackbarAction): void {
|
|
35
|
+
action.handler?.();
|
|
36
|
+
action.dismiss && UI.hideSnackbar(props.id);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return { activate };
|
|
40
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -3,9 +3,9 @@ import AGAppOverlays from './AGAppOverlays.vue';
|
|
|
3
3
|
|
|
4
4
|
export { AGAppLayout, AGAppOverlays };
|
|
5
5
|
|
|
6
|
-
export * from './basic';
|
|
7
6
|
export * from './constants';
|
|
8
7
|
export * from './forms';
|
|
9
8
|
export * from './headless';
|
|
9
|
+
export * from './lib';
|
|
10
10
|
export * from './modals';
|
|
11
11
|
export * from './snackbars';
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
<script setup lang="ts">
|
|
6
6
|
import { computed } from 'vue';
|
|
7
7
|
|
|
8
|
-
import Errors from '@/errors/Errors';
|
|
9
8
|
import { requiredObjectProp } from '@/utils/vue';
|
|
9
|
+
import { getErrorMessage } from '@/errors/utils';
|
|
10
10
|
import type { ErrorSource } from '@/errors/Errors.state';
|
|
11
11
|
|
|
12
12
|
import AGMarkdown from './AGMarkdown.vue';
|
|
13
13
|
|
|
14
14
|
const props = defineProps({ error: requiredObjectProp<ErrorSource>() });
|
|
15
|
-
const message = computed(() =>
|
|
15
|
+
const message = computed(() => getErrorMessage(props.error));
|
|
16
16
|
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component :is="as" v-measure="() => (measured = true)" :class="{ '!invisible !absolute !w-auto': !measured }">
|
|
3
|
+
<slot />
|
|
4
|
+
</component>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { ref } from 'vue';
|
|
9
|
+
|
|
10
|
+
import { stringProp } from '@/utils/vue';
|
|
11
|
+
|
|
12
|
+
defineProps({ as: stringProp('span') });
|
|
13
|
+
|
|
14
|
+
const measured = ref(false);
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="grid flex-grow place-items-center">
|
|
3
|
+
<div class="flex flex-col items-center space-y-6 p-8">
|
|
4
|
+
<h1 class="mt-2 text-center text-4xl font-medium text-red-600">
|
|
5
|
+
{{ $td('startupCrash.title', 'Something went wrong!') }}
|
|
6
|
+
</h1>
|
|
7
|
+
<AGMarkdown
|
|
8
|
+
:text="
|
|
9
|
+
$td(
|
|
10
|
+
'startupCrash.message',
|
|
11
|
+
'Something failed trying to start the application.\n\nHere\'s some things you can do:'
|
|
12
|
+
)
|
|
13
|
+
"
|
|
14
|
+
class="mt-4 text-center"
|
|
15
|
+
/>
|
|
16
|
+
<div class="mt-4 flex flex-col space-y-4">
|
|
17
|
+
<AGButton color="danger" @click="$app.reload()">
|
|
18
|
+
{{ $td('startupCrash.reload', 'Try again') }}
|
|
19
|
+
</AGButton>
|
|
20
|
+
<AGButton color="danger" @click="$errors.inspect($errors.startupErrors)">
|
|
21
|
+
{{ $td('startupCrash.inspect', 'View error details') }}
|
|
22
|
+
</AGButton>
|
|
23
|
+
</div>
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
</template>
|
|
27
|
+
|
|
28
|
+
<script setup lang="ts">
|
|
29
|
+
import AGMarkdown from './AGMarkdown.vue';
|
|
30
|
+
import AGButton from '../forms/AGButton.vue';
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { default as AGErrorMessage } from './AGErrorMessage.vue';
|
|
2
|
+
export { default as AGLink } from './AGLink.vue';
|
|
3
|
+
export { default as AGMarkdown } from './AGMarkdown.vue';
|
|
4
|
+
export { default as AGMeasured } from './AGMeasured.vue';
|
|
5
|
+
export { default as AGStartupCrash } from './AGStartupCrash.vue';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ExtractPropTypes } from 'vue';
|
|
2
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import { requiredStringProp, stringProp } from '@/utils';
|
|
5
|
+
|
|
6
|
+
export const alertModalProps = {
|
|
7
|
+
title: stringProp(),
|
|
8
|
+
message: requiredStringProp(),
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AGAlertModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof alertModalProps>>;
|
|
12
|
+
|
|
13
|
+
export function useAlertModalProps(): typeof alertModalProps {
|
|
14
|
+
return alertModalProps;
|
|
15
|
+
}
|
|
@@ -1,25 +1,14 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal>
|
|
3
|
-
<AGMarkdown
|
|
4
|
-
v-if="title"
|
|
5
|
-
:text="title"
|
|
6
|
-
as="h2"
|
|
7
|
-
class="font-semibold"
|
|
8
|
-
inline
|
|
9
|
-
/>
|
|
2
|
+
<AGModal :title="title">
|
|
10
3
|
<AGMarkdown :text="message" />
|
|
11
4
|
</AGModal>
|
|
12
5
|
</template>
|
|
13
6
|
|
|
14
7
|
<script setup lang="ts">
|
|
15
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
16
|
-
|
|
17
8
|
import AGModal from './AGModal.vue';
|
|
9
|
+
import { useAlertModalProps } from './AGAlertModal';
|
|
18
10
|
|
|
19
|
-
import AGMarkdown from '../
|
|
11
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
20
12
|
|
|
21
|
-
defineProps(
|
|
22
|
-
title: stringProp(),
|
|
23
|
-
message: requiredStringProp(),
|
|
24
|
-
});
|
|
13
|
+
defineProps(useAlertModalProps());
|
|
25
14
|
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
import type { ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import { requiredStringProp, stringProp } from '@/utils';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
7
|
+
|
|
8
|
+
export const confirmModalProps = {
|
|
9
|
+
title: stringProp(),
|
|
10
|
+
message: requiredStringProp(),
|
|
11
|
+
acceptText: stringProp(),
|
|
12
|
+
cancelText: stringProp(),
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type AGConfirmModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof confirmModalProps>>;
|
|
16
|
+
|
|
17
|
+
export function useConfirmModalProps(): typeof confirmModalProps {
|
|
18
|
+
return confirmModalProps;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
22
|
+
export function useConfirmModal(props: ExtractPropTypes<typeof confirmModalProps>) {
|
|
23
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
24
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
25
|
+
|
|
26
|
+
return { renderedAcceptText, renderedCancelText };
|
|
27
|
+
}
|
|
@@ -1,30 +1,26 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGModal v-slot="{ close }:
|
|
3
|
-
<AGMarkdown v-if="title" :text="title" as="h1" />
|
|
2
|
+
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false" :title="title">
|
|
4
3
|
<AGMarkdown :text="message" />
|
|
5
4
|
|
|
6
5
|
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
7
6
|
<AGButton @click="close(true)">
|
|
8
|
-
{{
|
|
7
|
+
{{ renderedAcceptText }}
|
|
9
8
|
</AGButton>
|
|
10
9
|
<AGButton color="secondary" @click="close()">
|
|
11
|
-
{{
|
|
10
|
+
{{ renderedCancelText }}
|
|
12
11
|
</AGButton>
|
|
13
12
|
</div>
|
|
14
13
|
</AGModal>
|
|
15
14
|
</template>
|
|
16
15
|
|
|
17
16
|
<script setup lang="ts">
|
|
18
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
19
|
-
|
|
20
17
|
import AGModal from './AGModal.vue';
|
|
21
|
-
import
|
|
18
|
+
import { useConfirmModal, useConfirmModalProps } from './AGConfirmModal';
|
|
19
|
+
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
22
20
|
|
|
23
21
|
import AGButton from '../forms/AGButton.vue';
|
|
24
|
-
import AGMarkdown from '../
|
|
22
|
+
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
25
23
|
|
|
26
|
-
defineProps(
|
|
27
|
-
|
|
28
|
-
message: requiredStringProp(),
|
|
29
|
-
});
|
|
24
|
+
const props = defineProps(useConfirmModalProps());
|
|
25
|
+
const { renderedAcceptText, renderedCancelText } = useConfirmModal(props);
|
|
30
26
|
</script>
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
import type { Component, ExtractPropTypes } from 'vue';
|
|
3
|
+
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
2
4
|
|
|
3
5
|
import { requiredArrayProp } from '@/utils/vue';
|
|
6
|
+
import { translateWithDefault } from '@/lang';
|
|
4
7
|
import type { ErrorReport } from '@/errors';
|
|
5
8
|
|
|
6
9
|
export interface IAGErrorReportModalButtonsDefaultSlotProps {
|
|
@@ -15,6 +18,29 @@ export const errorReportModalProps = {
|
|
|
15
18
|
reports: requiredArrayProp<ErrorReport>(),
|
|
16
19
|
};
|
|
17
20
|
|
|
21
|
+
export type AGErrorReportModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof errorReportModalProps>>;
|
|
22
|
+
|
|
18
23
|
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
19
24
|
return errorReportModalProps;
|
|
20
25
|
}
|
|
26
|
+
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
28
|
+
export function useErrorReportModal(props: ExtractPropTypes<typeof errorReportModalProps>) {
|
|
29
|
+
const activeReportIndex = ref(0);
|
|
30
|
+
const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
31
|
+
const details = computed(
|
|
32
|
+
() =>
|
|
33
|
+
report.value.details?.trim() ||
|
|
34
|
+
translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
|
|
35
|
+
);
|
|
36
|
+
const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
|
|
37
|
+
const nextReportText = translateWithDefault('errors.nextReport', 'Show next report');
|
|
38
|
+
|
|
39
|
+
return {
|
|
40
|
+
activeReportIndex,
|
|
41
|
+
details,
|
|
42
|
+
nextReportText,
|
|
43
|
+
previousReportText,
|
|
44
|
+
report,
|
|
45
|
+
};
|
|
46
|
+
}
|