@aerogel/core 0.0.0-next.b243de4e2590f02709edeebd8c13b74087592c04 → 0.0.0-next.b3caf219a503ce9b8c65ef1463132c9507f56c0a
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 +1346 -1647
- package/dist/aerogel-core.js +2960 -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 +25 -16
- 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 -5
- package/src/components/composition.ts +1 -1
- package/src/components/contracts/AlertModal.ts +4 -0
- package/src/components/contracts/Button.ts +15 -0
- package/src/components/contracts/ConfirmModal.ts +41 -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 +9 -0
- package/src/components/contracts/PromptModal.ts +28 -0
- package/src/components/contracts/index.ts +7 -0
- package/src/components/contracts/shared.ts +9 -0
- package/src/components/forms/AGSelect.vue +11 -17
- package/src/components/forms/index.ts +0 -4
- package/src/components/headless/HeadlessButton.vue +45 -0
- package/src/components/headless/HeadlessInput.vue +59 -0
- package/src/components/headless/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +5 -6
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
- package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +10 -19
- package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
- package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +6 -9
- package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +16 -18
- 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/forms/AGHeadlessSelect.ts +3 -3
- package/src/components/headless/forms/AGHeadlessSelect.vue +16 -16
- 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 +2 -2
- package/src/components/headless/forms/index.ts +2 -12
- package/src/components/headless/index.ts +12 -1
- package/src/components/headless/snackbars/index.ts +3 -3
- package/src/components/index.ts +5 -5
- package/src/components/lib/AGErrorMessage.vue +3 -3
- package/src/components/lib/AGMarkdown.vue +16 -3
- package/src/components/lib/AGMeasured.vue +2 -2
- package/src/components/lib/AGStartupCrash.vue +6 -6
- package/src/components/lib/index.ts +0 -1
- package/src/components/snackbars/AGSnackbar.vue +8 -6
- package/src/components/ui/AlertModal.vue +13 -0
- package/src/components/ui/Button.vue +58 -0
- package/src/components/ui/Checkbox.vue +49 -0
- package/src/components/ui/ConfirmModal.vue +42 -0
- package/src/components/ui/ErrorReportModal.vue +62 -0
- package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +29 -20
- 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 +52 -0
- package/src/components/ui/Link.vue +12 -0
- package/src/components/ui/LoadingModal.vue +32 -0
- package/src/components/ui/Modal.vue +55 -0
- package/src/components/ui/ModalContext.vue +30 -0
- package/src/components/ui/ProgressBar.vue +50 -0
- package/src/components/ui/PromptModal.vue +35 -0
- package/src/components/ui/index.ts +15 -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 +14 -14
- 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 → 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 +8 -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 +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 +13 -4
- package/src/services/App.ts +8 -3
- package/src/services/Cache.ts +1 -1
- package/src/services/Events.ts +15 -5
- package/src/services/Service.ts +116 -53
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +11 -5
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +4 -3
- package/src/testing/setup.ts +5 -13
- package/src/ui/UI.state.ts +10 -5
- package/src/ui/UI.ts +145 -59
- package/src/ui/index.ts +16 -16
- package/src/utils/composition/events.ts +2 -2
- package/src/utils/composition/forms.ts +4 -3
- 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 +11 -13
- 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/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -41
- package/src/components/forms/AGInput.vue +0 -40
- 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/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/AGHeadlessModal.ts +0 -34
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/headless/modals/index.ts +0 -4
- package/src/components/interfaces.ts +0 -24
- package/src/components/lib/AGLink.vue +0 -9
- package/src/components/modals/AGAlertModal.ts +0 -15
- package/src/components/modals/AGAlertModal.vue +0 -14
- package/src/components/modals/AGConfirmModal.ts +0 -33
- package/src/components/modals/AGConfirmModal.vue +0 -26
- package/src/components/modals/AGErrorReportModal.ts +0 -46
- package/src/components/modals/AGErrorReportModal.vue +0 -54
- package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
- package/src/components/modals/AGLoadingModal.ts +0 -23
- package/src/components/modals/AGLoadingModal.vue +0 -15
- package/src/components/modals/AGModal.ts +0 -10
- package/src/components/modals/AGModal.vue +0 -39
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalContext.vue +0 -22
- package/src/components/modals/AGModalTitle.vue +0 -9
- package/src/components/modals/AGPromptModal.ts +0 -36
- package/src/components/modals/AGPromptModal.vue +0 -34
- package/src/components/modals/index.ts +0 -17
- 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/components/{AGAppSnackbars.vue → AppSnackbars.vue} +0 -0
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessInput
|
|
3
|
-
ref="$input"
|
|
4
|
-
class="relative flex flex-col items-center"
|
|
5
|
-
:class="className"
|
|
6
|
-
v-bind="props"
|
|
7
|
-
>
|
|
8
|
-
<AGHeadlessInputLabel class="sr-only" />
|
|
9
|
-
<AGHeadlessInputInput
|
|
10
|
-
v-bind="attrs"
|
|
11
|
-
class="block w-full border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600"
|
|
12
|
-
:class="{
|
|
13
|
-
'ring-1 ring-red-500': $input?.errors,
|
|
14
|
-
}"
|
|
15
|
-
/>
|
|
16
|
-
<AGHeadlessInputDescription />
|
|
17
|
-
<div class="absolute bottom-0 left-0 translate-y-full">
|
|
18
|
-
<AGHeadlessInputError class="mt-1 text-sm text-red-500" />
|
|
19
|
-
</div>
|
|
20
|
-
</AGHeadlessInput>
|
|
21
|
-
</template>
|
|
22
|
-
|
|
23
|
-
<script setup lang="ts">
|
|
24
|
-
import { componentRef } from '@/utils/vue';
|
|
25
|
-
import { useInputAttrs } from '@/utils/composition/forms';
|
|
26
|
-
import { useInputProps } from '@/components/headless/forms/AGHeadlessInput';
|
|
27
|
-
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
28
|
-
|
|
29
|
-
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
30
|
-
import AGHeadlessInputDescription from '../headless/forms/AGHeadlessInputDescription.vue';
|
|
31
|
-
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
32
|
-
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
33
|
-
import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
|
|
34
|
-
|
|
35
|
-
defineOptions({ inheritAttrs: false });
|
|
36
|
-
|
|
37
|
-
const props = defineProps(useInputProps());
|
|
38
|
-
const $input = componentRef<IAGHeadlessInput>();
|
|
39
|
-
const [attrs, className] = useInputAttrs();
|
|
40
|
-
</script>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="component.as" ref="$root" v-bind="component.props">
|
|
3
|
-
<slot />
|
|
4
|
-
</component>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
10
|
-
|
|
11
|
-
import { booleanProp, objectProp, stringProp } from '@/utils/vue';
|
|
12
|
-
import { elementRef } from '@/components/composition';
|
|
13
|
-
|
|
14
|
-
import type { IAGHeadlessButton } from './AGHeadlessButton';
|
|
15
|
-
|
|
16
|
-
const props = defineProps({
|
|
17
|
-
as: objectProp(),
|
|
18
|
-
href: stringProp(),
|
|
19
|
-
url: stringProp(),
|
|
20
|
-
route: stringProp(),
|
|
21
|
-
routeParams: objectProp(() => ({})),
|
|
22
|
-
routeQuery: objectProp(() => ({})),
|
|
23
|
-
submit: booleanProp(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const $root = elementRef();
|
|
27
|
-
const component = computed(() => {
|
|
28
|
-
if (props.as) {
|
|
29
|
-
return { as: props.as, props: {} };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (props.route) {
|
|
33
|
-
return {
|
|
34
|
-
as: 'router-link',
|
|
35
|
-
props: {
|
|
36
|
-
to: objectWithoutEmpty({
|
|
37
|
-
name: props.route,
|
|
38
|
-
params: props.routeParams,
|
|
39
|
-
query: props.routeQuery,
|
|
40
|
-
}),
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (props.href || props.url) {
|
|
46
|
-
return {
|
|
47
|
-
as: 'a',
|
|
48
|
-
props: {
|
|
49
|
-
target: '_blank',
|
|
50
|
-
href: props.href || props.url,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
as: 'button',
|
|
57
|
-
props: { type: props.submit ? 'submit' : 'button' },
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
defineExpose<IAGHeadlessButton>({ $el: $root });
|
|
62
|
-
</script>
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
import { mixedProp, stringProp } from '@/utils';
|
|
4
|
-
import { extractComponentProps } from '@/components/utils';
|
|
5
|
-
import type { FormFieldValue } from '@/forms/Form';
|
|
6
|
-
import type { HasElement } from '@/components/interfaces';
|
|
7
|
-
|
|
8
|
-
export interface IAGHeadlessInput extends HasElement {
|
|
9
|
-
id: string;
|
|
10
|
-
name: ComputedRef<string | null>;
|
|
11
|
-
label: ComputedRef<string | null>;
|
|
12
|
-
description: ComputedRef<string | boolean | null>;
|
|
13
|
-
value: ComputedRef<FormFieldValue | null>;
|
|
14
|
-
required: ComputedRef<boolean | null>;
|
|
15
|
-
errors: DeepReadonly<Ref<string[] | null>>;
|
|
16
|
-
update(value: FormFieldValue | null): void;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const inputProps = {
|
|
20
|
-
name: stringProp(),
|
|
21
|
-
label: stringProp(),
|
|
22
|
-
description: stringProp(),
|
|
23
|
-
modelValue: mixedProp<FormFieldValue>([String, Number, Boolean]),
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export function useInputProps(): typeof inputProps {
|
|
27
|
-
return inputProps;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
|
|
31
|
-
props: T,
|
|
32
|
-
): Pick<T, keyof typeof inputProps> {
|
|
33
|
-
return extractComponentProps(props, inputProps);
|
|
34
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="as" v-if="as">
|
|
3
|
-
<slot />
|
|
4
|
-
</component>
|
|
5
|
-
<slot v-else />
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup lang="ts">
|
|
9
|
-
import { computed, inject, provide, readonly, ref } from 'vue';
|
|
10
|
-
import { uuid } from '@noeldemartin/utils';
|
|
11
|
-
|
|
12
|
-
import { stringProp } from '@/utils/vue';
|
|
13
|
-
import type Form from '@/forms/Form';
|
|
14
|
-
import type { __SetsElement } from '@/components/interfaces';
|
|
15
|
-
|
|
16
|
-
import { useInputProps } from './AGHeadlessInput';
|
|
17
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
18
|
-
|
|
19
|
-
const emit = defineEmits(['update:modelValue']);
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
as: stringProp('div'),
|
|
22
|
-
...useInputProps(),
|
|
23
|
-
});
|
|
24
|
-
const $el = ref<HTMLElement>();
|
|
25
|
-
const errors = computed(() => {
|
|
26
|
-
if (!form || !props.name) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return form.errors[props.name] ?? null;
|
|
31
|
-
});
|
|
32
|
-
const form = inject<Form | null>('form', null);
|
|
33
|
-
const api: IAGHeadlessInput & __SetsElement = {
|
|
34
|
-
$el,
|
|
35
|
-
id: `input-${uuid()}`,
|
|
36
|
-
name: computed(() => props.name),
|
|
37
|
-
label: computed(() => props.label),
|
|
38
|
-
description: computed(() => props.description),
|
|
39
|
-
value: computed(() => {
|
|
40
|
-
if (form && props.name) {
|
|
41
|
-
return form.getFieldValue(props.name);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return props.modelValue;
|
|
45
|
-
}),
|
|
46
|
-
errors: readonly(errors),
|
|
47
|
-
required: computed(() => {
|
|
48
|
-
if (!props.name || !form) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return form.getFieldRules(props.name).includes('required');
|
|
53
|
-
}),
|
|
54
|
-
update(value) {
|
|
55
|
-
if (form && props.name) {
|
|
56
|
-
form.setFieldValue(props.name, value);
|
|
57
|
-
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
emit('update:modelValue', value);
|
|
62
|
-
},
|
|
63
|
-
__setElement(element) {
|
|
64
|
-
$el.value = element;
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
provide<IAGHeadlessInput>('input', api);
|
|
69
|
-
defineExpose<IAGHeadlessInput>(api);
|
|
70
|
-
</script>
|
|
@@ -1,24 +0,0 @@
|
|
|
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>
|
|
@@ -1,24 +0,0 @@
|
|
|
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>
|
|
@@ -1,34 +0,0 @@
|
|
|
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';
|
|
6
|
-
import type { IAGModal } from '@/components/modals/AGModal';
|
|
7
|
-
|
|
8
|
-
export interface IAGHeadlessModal extends IAGModal {}
|
|
9
|
-
|
|
10
|
-
export interface IAGHeadlessModalDefaultSlotProps {
|
|
11
|
-
close(result?: unknown): Promise<void>;
|
|
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
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DialogPanel>
|
|
3
|
-
<slot />
|
|
4
|
-
|
|
5
|
-
<template v-if="childModal">
|
|
6
|
-
<div class="pointer-events-none fixed inset-0 z-50 bg-black/30" />
|
|
7
|
-
<AGModalContext :child-index="modal.childIndex + 1" :modal="childModal" />
|
|
8
|
-
</template>
|
|
9
|
-
</DialogPanel>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup lang="ts">
|
|
13
|
-
import { computed } from 'vue';
|
|
14
|
-
import { DialogPanel } from '@headlessui/vue';
|
|
15
|
-
|
|
16
|
-
import UI from '@/ui/UI';
|
|
17
|
-
import { injectReactiveOrFail } from '@/utils/vue';
|
|
18
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
19
|
-
|
|
20
|
-
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
21
|
-
|
|
22
|
-
const modal = injectReactiveOrFail<IAGModalContext>(
|
|
23
|
-
'modal',
|
|
24
|
-
'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
|
|
25
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
26
|
-
);
|
|
27
|
-
const childModal = computed(() => UI.modals[modal.childIndex] ?? null);
|
|
28
|
-
</script>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DialogTitle :as="as">
|
|
3
|
-
<slot />
|
|
4
|
-
</DialogTitle>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { DialogTitle } from '@headlessui/vue';
|
|
9
|
-
|
|
10
|
-
import { stringProp } from '@/utils/vue';
|
|
11
|
-
|
|
12
|
-
defineProps({ as: stringProp('h2') });
|
|
13
|
-
</script>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { isObject } from '@noeldemartin/utils';
|
|
2
|
-
import type { Ref, UnwrapNestedRefs } from 'vue';
|
|
3
|
-
|
|
4
|
-
export function getElement(value: unknown): HTMLElement | undefined {
|
|
5
|
-
if (value instanceof HTMLElement) {
|
|
6
|
-
return value;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (hasElement(value)) {
|
|
10
|
-
return value.$el;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function hasElement(value: unknown): value is UnwrapNestedRefs<HasElement> {
|
|
15
|
-
return isObject(value) && '$el' in value;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export interface __SetsElement {
|
|
19
|
-
__setElement(element?: HTMLElement): void;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export interface HasElement {
|
|
23
|
-
$el: Readonly<Ref<HTMLElement | undefined>>;
|
|
24
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
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,14 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal :title="title">
|
|
3
|
-
<AGMarkdown :text="message" />
|
|
4
|
-
</AGModal>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import AGModal from './AGModal.vue';
|
|
9
|
-
import { useAlertModalProps } from './AGAlertModal';
|
|
10
|
-
|
|
11
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
|
-
|
|
13
|
-
defineProps(useAlertModalProps());
|
|
14
|
-
</script>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
2
|
-
import type { ExtractPropTypes } from 'vue';
|
|
3
|
-
import type { ObjectWithoutEmpty, SubPartial } from '@noeldemartin/utils';
|
|
4
|
-
|
|
5
|
-
import { Colors } from '@/components/constants';
|
|
6
|
-
import { enumProp, requiredStringProp, stringProp } from '@/utils';
|
|
7
|
-
import { translateWithDefault } from '@/lang';
|
|
8
|
-
|
|
9
|
-
export const confirmModalProps = {
|
|
10
|
-
title: stringProp(),
|
|
11
|
-
message: requiredStringProp(),
|
|
12
|
-
acceptText: stringProp(),
|
|
13
|
-
acceptColor: enumProp(Colors, Colors.Primary),
|
|
14
|
-
cancelText: stringProp(),
|
|
15
|
-
cancelColor: enumProp(Colors, Colors.Clear),
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type AGConfirmModalProps = SubPartial<
|
|
19
|
-
ObjectWithoutEmpty<ExtractPropTypes<typeof confirmModalProps>>,
|
|
20
|
-
'acceptColor' | 'cancelColor'
|
|
21
|
-
>;
|
|
22
|
-
|
|
23
|
-
export function useConfirmModalProps(): typeof confirmModalProps {
|
|
24
|
-
return confirmModalProps;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
28
|
-
export function useConfirmModal(props: ExtractPropTypes<typeof confirmModalProps>) {
|
|
29
|
-
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
30
|
-
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
31
|
-
|
|
32
|
-
return { renderedAcceptText, renderedCancelText };
|
|
33
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false" :title="title">
|
|
3
|
-
<AGMarkdown :text="message" />
|
|
4
|
-
|
|
5
|
-
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
6
|
-
<AGButton :color="acceptColor" @click="close(true)">
|
|
7
|
-
{{ renderedAcceptText }}
|
|
8
|
-
</AGButton>
|
|
9
|
-
<AGButton :color="cancelColor" @click="close()">
|
|
10
|
-
{{ renderedCancelText }}
|
|
11
|
-
</AGButton>
|
|
12
|
-
</div>
|
|
13
|
-
</AGModal>
|
|
14
|
-
</template>
|
|
15
|
-
|
|
16
|
-
<script setup lang="ts">
|
|
17
|
-
import AGModal from './AGModal.vue';
|
|
18
|
-
import { useConfirmModal, useConfirmModalProps } from './AGConfirmModal';
|
|
19
|
-
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
20
|
-
|
|
21
|
-
import AGButton from '../forms/AGButton.vue';
|
|
22
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
23
|
-
|
|
24
|
-
const props = defineProps(useConfirmModalProps());
|
|
25
|
-
const { renderedAcceptText, renderedCancelText } = useConfirmModal(props);
|
|
26
|
-
</script>
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { computed, ref } from 'vue';
|
|
2
|
-
import type { Component, ExtractPropTypes } from 'vue';
|
|
3
|
-
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
-
|
|
5
|
-
import { requiredArrayProp } from '@/utils/vue';
|
|
6
|
-
import { translateWithDefault } from '@/lang';
|
|
7
|
-
import type { ErrorReport } from '@/errors';
|
|
8
|
-
|
|
9
|
-
export interface IAGErrorReportModalButtonsDefaultSlotProps {
|
|
10
|
-
id: string;
|
|
11
|
-
description: string;
|
|
12
|
-
iconComponent: Component;
|
|
13
|
-
url?: string;
|
|
14
|
-
handler?(): void;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const errorReportModalProps = {
|
|
18
|
-
reports: requiredArrayProp<ErrorReport>(),
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export type AGErrorReportModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof errorReportModalProps>>;
|
|
22
|
-
|
|
23
|
-
export function useErrorReportModalProps(): typeof errorReportModalProps {
|
|
24
|
-
return errorReportModalProps;
|
|
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
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal>
|
|
3
|
-
<div>
|
|
4
|
-
<h2 class="flex items-center justify-between text-lg font-medium">
|
|
5
|
-
<div class="flex items-center">
|
|
6
|
-
<AGErrorReportModalTitle
|
|
7
|
-
:report="report"
|
|
8
|
-
:current-report="activeReportIndex + 1"
|
|
9
|
-
:total-reports="reports.length"
|
|
10
|
-
/>
|
|
11
|
-
<template v-if="reports.length > 1">
|
|
12
|
-
<AGButton
|
|
13
|
-
color="clear"
|
|
14
|
-
:disabled="activeReportIndex === 0"
|
|
15
|
-
:title="previousReportText"
|
|
16
|
-
:aria-label="previousReportText"
|
|
17
|
-
@click="activeReportIndex--"
|
|
18
|
-
>
|
|
19
|
-
<IconCheveronLeft aria-hidden="true" class="h-4 w-4" />
|
|
20
|
-
</AGButton>
|
|
21
|
-
<AGButton
|
|
22
|
-
color="clear"
|
|
23
|
-
:disabled="activeReportIndex === reports.length - 1"
|
|
24
|
-
:title="nextReportText"
|
|
25
|
-
:aria-label="nextReportText"
|
|
26
|
-
@click="activeReportIndex++"
|
|
27
|
-
>
|
|
28
|
-
<IconCheveronRight aria-hidden="true" class="h-4 w-4" />
|
|
29
|
-
</AGButton>
|
|
30
|
-
</template>
|
|
31
|
-
</div>
|
|
32
|
-
<AGErrorReportModalButtons :report="report" />
|
|
33
|
-
</h2>
|
|
34
|
-
<AGMarkdown v-if="report.description" :text="report.description" class="mt-2" />
|
|
35
|
-
</div>
|
|
36
|
-
<pre class="h-full overflow-auto bg-gray-200 p-4 text-xs text-red-900" v-text="details" />
|
|
37
|
-
</AGModal>
|
|
38
|
-
</template>
|
|
39
|
-
|
|
40
|
-
<script setup lang="ts">
|
|
41
|
-
import IconCheveronRight from '~icons/zondicons/cheveron-right';
|
|
42
|
-
import IconCheveronLeft from '~icons/zondicons/cheveron-left';
|
|
43
|
-
|
|
44
|
-
import { useErrorReportModal, useErrorReportModalProps } from './AGErrorReportModal';
|
|
45
|
-
|
|
46
|
-
import AGButton from '../forms/AGButton.vue';
|
|
47
|
-
import AGErrorReportModalButtons from './AGErrorReportModalButtons.vue';
|
|
48
|
-
import AGErrorReportModalTitle from './AGErrorReportModalTitle.vue';
|
|
49
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
50
|
-
import AGModal from './AGModal.vue';
|
|
51
|
-
|
|
52
|
-
const props = defineProps(useErrorReportModalProps());
|
|
53
|
-
const { activeReportIndex, details, nextReportText, previousReportText, report } = useErrorReportModal(props);
|
|
54
|
-
</script>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGMarkdown :text="text" inline />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import { computed } from 'vue';
|
|
7
|
-
|
|
8
|
-
import { numberProp, requiredObjectProp } from '@/utils/vue';
|
|
9
|
-
import type { ErrorReport } from '@/errors';
|
|
10
|
-
|
|
11
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
report: requiredObjectProp<ErrorReport>(),
|
|
15
|
-
currentReport: numberProp(),
|
|
16
|
-
totalReports: numberProp(),
|
|
17
|
-
});
|
|
18
|
-
const text = computed(() => {
|
|
19
|
-
if (!props.totalReports || props.totalReports <= 1) {
|
|
20
|
-
return props.report.title;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return `${props.report.title} (${props.currentReport}/${props.totalReports})`;
|
|
24
|
-
});
|
|
25
|
-
</script>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
2
|
-
import type { ExtractPropTypes } from 'vue';
|
|
3
|
-
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
4
|
-
|
|
5
|
-
import { stringProp } from '@/utils';
|
|
6
|
-
import { translateWithDefault } from '@/lang';
|
|
7
|
-
|
|
8
|
-
export const loadingModalProps = {
|
|
9
|
-
message: stringProp(),
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type AGLoadingModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof loadingModalProps>>;
|
|
13
|
-
|
|
14
|
-
export function useLoadingModalProps(): typeof loadingModalProps {
|
|
15
|
-
return loadingModalProps;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
19
|
-
export function useLoadingModal(props: ExtractPropTypes<typeof loadingModalProps>) {
|
|
20
|
-
const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
|
|
21
|
-
|
|
22
|
-
return { renderedMessage };
|
|
23
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal :cancellable="false">
|
|
3
|
-
<AGMarkdown :text="renderedMessage" />
|
|
4
|
-
</AGModal>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import AGModal from './AGModal.vue';
|
|
9
|
-
import { useLoadingModal, useLoadingModalProps } from './AGLoadingModal';
|
|
10
|
-
|
|
11
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
12
|
-
|
|
13
|
-
const props = defineProps(useLoadingModalProps());
|
|
14
|
-
const { renderedMessage } = useLoadingModal(props);
|
|
15
|
-
</script>
|