@aerogel/core 0.0.0-next.c8f032a868370824898e171969aec1bb6827688e → 0.0.0-next.d197d66a9d339318d752a1d8a96b2919faba3003
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 +2310 -574
- package/dist/aerogel-core.js +3268 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +38 -34
- package/src/bootstrap/bootstrap.test.ts +7 -10
- package/src/bootstrap/index.ts +41 -9
- package/src/bootstrap/options.ts +4 -1
- package/src/components/AppLayout.vue +14 -0
- package/src/components/AppModals.vue +14 -0
- package/src/components/AppOverlays.vue +9 -0
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +8 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +46 -0
- package/src/components/contracts/DropdownMenu.ts +20 -0
- package/src/components/contracts/ErrorReportModal.ts +32 -0
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +26 -0
- package/src/components/contracts/Modal.ts +21 -0
- package/src/components/contracts/PromptModal.ts +34 -0
- package/src/components/contracts/Select.ts +45 -0
- package/src/components/contracts/Toast.ts +15 -0
- package/src/components/contracts/index.ts +11 -0
- package/src/components/headless/HeadlessButton.vue +51 -0
- package/src/components/headless/HeadlessInput.vue +59 -0
- package/src/components/headless/HeadlessInputDescription.vue +27 -0
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
- package/src/components/headless/HeadlessInputInput.vue +75 -0
- package/src/components/headless/HeadlessInputLabel.vue +18 -0
- package/src/components/headless/HeadlessInputTextArea.vue +40 -0
- package/src/components/headless/HeadlessModal.vue +57 -0
- package/src/components/headless/HeadlessModalContent.vue +30 -0
- package/src/components/headless/HeadlessModalDescription.vue +12 -0
- package/src/components/headless/HeadlessModalOverlay.vue +12 -0
- package/src/components/headless/HeadlessModalTitle.vue +12 -0
- package/src/components/headless/HeadlessSelect.vue +120 -0
- package/src/components/headless/HeadlessSelectError.vue +25 -0
- package/src/components/headless/HeadlessSelectLabel.vue +25 -0
- package/src/components/headless/HeadlessSelectOption.vue +34 -0
- package/src/components/headless/HeadlessSelectOptions.vue +42 -0
- package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
- package/src/components/headless/HeadlessSelectValue.vue +18 -0
- package/src/components/headless/HeadlessToast.vue +18 -0
- package/src/components/headless/HeadlessToastAction.vue +13 -0
- package/src/components/headless/index.ts +19 -2
- package/src/components/index.ts +6 -7
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +14 -0
- package/src/components/ui/Button.vue +98 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +45 -0
- package/src/components/ui/DropdownMenu.vue +32 -0
- package/src/components/ui/DropdownMenuOption.vue +14 -0
- package/src/components/ui/DropdownMenuOptions.vue +27 -0
- package/src/components/ui/EditableContent.vue +82 -0
- package/src/components/ui/ErrorMessage.vue +15 -0
- package/src/components/ui/ErrorReportModal.vue +67 -0
- package/src/components/ui/ErrorReportModalButtons.vue +118 -0
- package/src/components/ui/ErrorReportModalTitle.vue +24 -0
- package/src/components/ui/Form.vue +24 -0
- package/src/components/ui/Input.vue +56 -0
- package/src/components/ui/Link.vue +12 -0
- package/src/components/ui/LoadingModal.vue +34 -0
- package/src/components/ui/Markdown.vue +69 -0
- package/src/components/ui/Modal.vue +122 -0
- package/src/components/ui/ModalContext.vue +31 -0
- package/src/components/ui/ProgressBar.vue +51 -0
- package/src/components/ui/PromptModal.vue +38 -0
- package/src/components/ui/Select.vue +27 -0
- package/src/components/ui/SelectLabel.vue +17 -0
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +35 -0
- package/src/components/ui/SelectTrigger.vue +29 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/ui/StartupCrash.vue +31 -0
- package/src/components/ui/Toast.vue +44 -0
- package/src/components/ui/index.ts +30 -0
- package/src/directives/index.ts +27 -6
- package/src/directives/measure.ts +40 -0
- package/src/errors/Errors.state.ts +31 -0
- package/src/errors/Errors.ts +176 -0
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +49 -0
- package/src/errors/utils.ts +35 -0
- package/src/forms/FormController.test.ts +110 -0
- package/src/forms/FormController.ts +246 -0
- package/src/forms/index.ts +3 -2
- package/src/forms/utils.ts +62 -14
- package/src/forms/validation.ts +19 -0
- package/src/index.css +72 -0
- package/src/{main.ts → index.ts} +4 -2
- package/src/jobs/Job.ts +147 -0
- package/src/jobs/index.ts +10 -0
- package/src/jobs/listeners.ts +3 -0
- package/src/jobs/status.ts +4 -0
- package/src/lang/DefaultLangProvider.ts +46 -0
- package/src/lang/Lang.state.ts +11 -0
- package/src/lang/Lang.ts +45 -22
- package/src/lang/index.ts +14 -10
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/lang/utils.ts +4 -0
- package/src/plugins/Plugin.ts +2 -1
- package/src/plugins/index.ts +22 -0
- package/src/services/App.state.ts +43 -3
- package/src/services/App.ts +59 -3
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +110 -36
- package/src/services/Service.ts +245 -53
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +36 -7
- package/src/services/store.ts +30 -0
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +26 -0
- package/src/testing/setup.ts +11 -0
- package/src/ui/UI.state.ts +21 -9
- package/src/ui/UI.ts +327 -64
- package/src/ui/index.ts +33 -22
- package/src/ui/utils.ts +16 -0
- package/src/utils/classes.ts +49 -0
- package/src/utils/composition/events.ts +4 -5
- package/src/utils/composition/forms.ts +27 -0
- package/src/utils/composition/persistent.test.ts +33 -0
- package/src/utils/composition/persistent.ts +11 -0
- package/src/utils/composition/state.test.ts +47 -0
- package/src/utils/composition/state.ts +33 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +26 -4
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +28 -116
- package/.eslintrc.js +0 -3
- package/dist/aerogel-core.cjs.js +0 -2
- package/dist/aerogel-core.cjs.js.map +0 -1
- package/dist/aerogel-core.esm.js +0 -2
- package/dist/aerogel-core.esm.js.map +0 -1
- package/noeldemartin.config.js +0 -2
- package/src/components/AGAppLayout.vue +0 -11
- package/src/components/AGAppOverlays.vue +0 -39
- package/src/components/basic/AGMarkdown.vue +0 -35
- package/src/components/basic/index.ts +0 -3
- package/src/components/forms/AGButton.vue +0 -21
- package/src/components/forms/AGForm.vue +0 -26
- package/src/components/forms/AGInput.vue +0 -32
- package/src/components/forms/index.ts +0 -5
- package/src/components/headless/forms/AGHeadlessButton.vue +0 -51
- package/src/components/headless/forms/AGHeadlessInput.ts +0 -8
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -54
- package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -33
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +0 -16
- package/src/components/headless/forms/index.ts +0 -6
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -7
- package/src/components/headless/modals/AGHeadlessModal.vue +0 -88
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -24
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/headless/modals/index.ts +0 -6
- package/src/components/modals/AGAlertModal.vue +0 -26
- package/src/components/modals/AGConfirmModal.vue +0 -30
- package/src/components/modals/AGModal.ts +0 -10
- package/src/components/modals/AGModal.vue +0 -18
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalContext.vue +0 -22
- package/src/components/modals/index.ts +0 -7
- package/src/directives/initial-focus.ts +0 -11
- package/src/forms/Form.test.ts +0 -37
- package/src/forms/Form.ts +0 -166
- package/src/forms/composition.ts +0 -6
- package/src/globals.ts +0 -6
- package/tsconfig.json +0 -10
- package/vite.config.ts +0 -13
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<form @submit.prevent="submit">
|
|
3
|
-
<slot />
|
|
4
|
-
</form>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { provide } from 'vue';
|
|
9
|
-
|
|
10
|
-
import { objectProp } from '@/utils/vue';
|
|
11
|
-
import type Form from '@/forms/Form';
|
|
12
|
-
|
|
13
|
-
const props = defineProps({ form: objectProp<Form>() });
|
|
14
|
-
|
|
15
|
-
const emit = defineEmits<{ submit: [] }>();
|
|
16
|
-
|
|
17
|
-
provide('form', props.form);
|
|
18
|
-
|
|
19
|
-
function submit() {
|
|
20
|
-
if (props.form && !props.form.submit()) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
emit('submit');
|
|
25
|
-
}
|
|
26
|
-
</script>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessInput
|
|
3
|
-
ref="$input"
|
|
4
|
-
as="div"
|
|
5
|
-
class="flex flex-col items-center"
|
|
6
|
-
:name="name"
|
|
7
|
-
>
|
|
8
|
-
<AGHeadlessInputInput
|
|
9
|
-
v-bind="$attrs"
|
|
10
|
-
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"
|
|
11
|
-
:class="{
|
|
12
|
-
'ring-1 ring-red-500': $input?.errors,
|
|
13
|
-
}"
|
|
14
|
-
/>
|
|
15
|
-
<AGHeadlessInputError class="mt-1 text-sm text-red-500" />
|
|
16
|
-
</AGHeadlessInput>
|
|
17
|
-
</template>
|
|
18
|
-
|
|
19
|
-
<script setup lang="ts">
|
|
20
|
-
import { componentRef, stringProp } from '@/utils/vue';
|
|
21
|
-
|
|
22
|
-
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
23
|
-
|
|
24
|
-
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
25
|
-
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
26
|
-
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
27
|
-
|
|
28
|
-
defineProps({ name: stringProp() });
|
|
29
|
-
defineOptions({ inheritAttrs: false });
|
|
30
|
-
|
|
31
|
-
const $input = componentRef<IAGHeadlessInput>();
|
|
32
|
-
</script>
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="component.tag" 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
|
-
import type { LocationQuery, RouteLocation, RouteParams } from 'vue-router';
|
|
11
|
-
|
|
12
|
-
import { booleanProp, objectProp, stringProp } from '@/utils/vue';
|
|
13
|
-
|
|
14
|
-
const { url, route, routeParams, routeQuery, submit } = defineProps({
|
|
15
|
-
url: stringProp(),
|
|
16
|
-
route: stringProp(),
|
|
17
|
-
routeParams: objectProp<RouteParams>(() => ({})),
|
|
18
|
-
routeQuery: objectProp<LocationQuery>(() => ({})),
|
|
19
|
-
submit: booleanProp(),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const component = computed(() => {
|
|
23
|
-
if (route) {
|
|
24
|
-
return {
|
|
25
|
-
tag: 'router-link',
|
|
26
|
-
props: {
|
|
27
|
-
to: objectWithoutEmpty<Partial<RouteLocation>>({
|
|
28
|
-
name: route,
|
|
29
|
-
params: routeParams,
|
|
30
|
-
query: routeQuery,
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (url) {
|
|
37
|
-
return {
|
|
38
|
-
tag: 'a',
|
|
39
|
-
props: {
|
|
40
|
-
target: '_blank',
|
|
41
|
-
href: url,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
tag: 'button',
|
|
48
|
-
props: { type: submit ? 'submit' : 'button' },
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
</script>
|
|
@@ -1,54 +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 } from 'vue';
|
|
10
|
-
import { uuid } from '@noeldemartin/utils';
|
|
11
|
-
|
|
12
|
-
import { stringProp } from '@/utils/vue';
|
|
13
|
-
import type Form from '@/forms/Form';
|
|
14
|
-
|
|
15
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
16
|
-
|
|
17
|
-
const emit = defineEmits(['update:modelValue']);
|
|
18
|
-
const props = defineProps({
|
|
19
|
-
as: stringProp(),
|
|
20
|
-
name: stringProp(),
|
|
21
|
-
modelValue: stringProp(),
|
|
22
|
-
});
|
|
23
|
-
const errors = computed(() => {
|
|
24
|
-
if (!form || !props.name) {
|
|
25
|
-
return null;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return form.errors[props.name] ?? null;
|
|
29
|
-
});
|
|
30
|
-
const form = inject<Form | null>('form', null);
|
|
31
|
-
const publicApi: IAGHeadlessInput = {
|
|
32
|
-
id: `input-${uuid()}`,
|
|
33
|
-
value: computed(() => {
|
|
34
|
-
if (form && props.name) {
|
|
35
|
-
return form.getFieldValue(props.name);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return props.modelValue;
|
|
39
|
-
}),
|
|
40
|
-
errors: readonly(errors),
|
|
41
|
-
update(value) {
|
|
42
|
-
if (form && props.name) {
|
|
43
|
-
form.setFieldValue(props.name, value);
|
|
44
|
-
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
emit('update:modelValue', value);
|
|
49
|
-
},
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
provide<IAGHeadlessInput>('input', publicApi);
|
|
53
|
-
defineExpose<IAGHeadlessInput>(publicApi);
|
|
54
|
-
</script>
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<input
|
|
3
|
-
:id="input.id"
|
|
4
|
-
ref="$input"
|
|
5
|
-
type="text"
|
|
6
|
-
:value="value"
|
|
7
|
-
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
8
|
-
:aria-describedby="input.errors ? `${input.id}-error` : undefined"
|
|
9
|
-
@input="update"
|
|
10
|
-
>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup lang="ts">
|
|
14
|
-
import { computed, ref } from 'vue';
|
|
15
|
-
|
|
16
|
-
import { injectReactiveOrFail } from '@/utils';
|
|
17
|
-
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
18
|
-
|
|
19
|
-
const $input = ref<HTMLInputElement>();
|
|
20
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
21
|
-
'input',
|
|
22
|
-
'<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>',
|
|
23
|
-
);
|
|
24
|
-
const value = computed(() => input.value);
|
|
25
|
-
|
|
26
|
-
function update() {
|
|
27
|
-
if (!$input.value) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
input.update($input.value.value);
|
|
32
|
-
}
|
|
33
|
-
</script>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<label :for="input.id">
|
|
3
|
-
<slot />
|
|
4
|
-
</label>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { injectReactiveOrFail } from '@/utils/vue';
|
|
9
|
-
|
|
10
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
11
|
-
|
|
12
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
13
|
-
'input',
|
|
14
|
-
'<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>',
|
|
15
|
-
);
|
|
16
|
-
</script>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { IAGHeadlessInput } from './AGHeadlessInput';
|
|
2
|
-
export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
|
|
3
|
-
export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
|
|
4
|
-
export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
|
|
5
|
-
export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
|
|
6
|
-
export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Dialog ref="$root" :open="true" @close="cancellable && close()">
|
|
3
|
-
<slot :close="close" />
|
|
4
|
-
</Dialog>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { ref, toRef } from 'vue';
|
|
9
|
-
import { Dialog } from '@headlessui/vue';
|
|
10
|
-
import type { VNode } from 'vue';
|
|
11
|
-
|
|
12
|
-
import Events from '@/services/Events';
|
|
13
|
-
import { useEvent } from '@/utils/composition/events';
|
|
14
|
-
import { booleanProp, injectReactiveOrFail } from '@/utils/vue';
|
|
15
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
16
|
-
|
|
17
|
-
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
18
|
-
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
cancellable: booleanProp(true),
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
24
|
-
const hidden = ref(true);
|
|
25
|
-
const closed = ref(false);
|
|
26
|
-
const { modal } = injectReactiveOrFail<IAGModalContext>(
|
|
27
|
-
'modal',
|
|
28
|
-
'could not obtain modal reference from <AGHeadlessModal>, ' +
|
|
29
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
async function hide(): Promise<void> {
|
|
33
|
-
if (!$root.value?.$el) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
hidden.value = true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function show(): Promise<void> {
|
|
41
|
-
if (!$root.value?.$el) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
hidden.value = false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function close(result?: unknown) {
|
|
49
|
-
if (closed.value) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
Events.emit('modal-will-close', { modal, result });
|
|
54
|
-
|
|
55
|
-
await hide();
|
|
56
|
-
|
|
57
|
-
closed.value = true;
|
|
58
|
-
|
|
59
|
-
Events.emit('modal-closed', { modal, result });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
useEvent('close-modal', async ({ id, result }) => {
|
|
63
|
-
if (id !== modal.id) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
await close(result);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
useEvent('hide-modal', async ({ id }) => {
|
|
71
|
-
if (id !== modal.id) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
await hide();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
useEvent('show-modal', async ({ id }) => {
|
|
79
|
-
if (id !== modal.id) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
await show();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
defineSlots<{ default(props: IAGHeadlessModalDefaultSlotProps): VNode[] }>();
|
|
87
|
-
defineExpose<IAGHeadlessModal>({ close, cancellable: toRef(props, 'cancellable') });
|
|
88
|
-
</script>
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DialogPanel>
|
|
3
|
-
<slot />
|
|
4
|
-
<AGModalContext v-if="childModal" :child-index="modal.childIndex + 1" :modal="childModal" />
|
|
5
|
-
</DialogPanel>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup lang="ts">
|
|
9
|
-
import { computed } from 'vue';
|
|
10
|
-
import { DialogPanel } from '@headlessui/vue';
|
|
11
|
-
|
|
12
|
-
import UI from '@/ui/UI';
|
|
13
|
-
import { injectReactiveOrFail } from '@/utils/vue';
|
|
14
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
15
|
-
|
|
16
|
-
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
17
|
-
|
|
18
|
-
const modal = injectReactiveOrFail<IAGModalContext>(
|
|
19
|
-
'modal',
|
|
20
|
-
'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
|
|
21
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
22
|
-
);
|
|
23
|
-
const childModal = computed(() => UI.modals[modal.childIndex] ?? null);
|
|
24
|
-
</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,6 +0,0 @@
|
|
|
1
|
-
import AGHeadlessModal from './AGHeadlessModal.vue';
|
|
2
|
-
import AGHeadlessModalPanel from './AGHeadlessModalPanel.vue';
|
|
3
|
-
import AGHeadlessModalTitle from './AGHeadlessModalTitle.vue';
|
|
4
|
-
import type { IAGHeadlessModal } from './AGHeadlessModal';
|
|
5
|
-
|
|
6
|
-
export { AGHeadlessModal, AGHeadlessModalPanel, AGHeadlessModalTitle, IAGHeadlessModal };
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal>
|
|
3
|
-
<AGMarkdown
|
|
4
|
-
v-if="title"
|
|
5
|
-
:text="title"
|
|
6
|
-
as="h2"
|
|
7
|
-
class="font-semibold"
|
|
8
|
-
raw
|
|
9
|
-
inline
|
|
10
|
-
/>
|
|
11
|
-
<AGMarkdown :text="message" />
|
|
12
|
-
</AGModal>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
17
|
-
|
|
18
|
-
import AGModal from './AGModal.vue';
|
|
19
|
-
|
|
20
|
-
import AGMarkdown from '../basic/AGMarkdown.vue';
|
|
21
|
-
|
|
22
|
-
defineProps({
|
|
23
|
-
title: stringProp(),
|
|
24
|
-
message: requiredStringProp(),
|
|
25
|
-
});
|
|
26
|
-
</script>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false">
|
|
3
|
-
<AGMarkdown v-if="title" :text="title" as="h1" />
|
|
4
|
-
<AGMarkdown :text="message" />
|
|
5
|
-
|
|
6
|
-
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
7
|
-
<AGButton @click="close(true)">
|
|
8
|
-
{{ $td('ui.ok', 'OK') }}
|
|
9
|
-
</AGButton>
|
|
10
|
-
<AGButton secondary @click="close()">
|
|
11
|
-
{{ $td('ui.cancel', 'Cancel') }}
|
|
12
|
-
</AGButton>
|
|
13
|
-
</div>
|
|
14
|
-
</AGModal>
|
|
15
|
-
</template>
|
|
16
|
-
|
|
17
|
-
<script setup lang="ts">
|
|
18
|
-
import { requiredStringProp, stringProp } from '@/utils/vue';
|
|
19
|
-
|
|
20
|
-
import AGModal from './AGModal.vue';
|
|
21
|
-
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
22
|
-
|
|
23
|
-
import AGButton from '../forms/AGButton.vue';
|
|
24
|
-
import AGMarkdown from '../basic/AGMarkdown.vue';
|
|
25
|
-
|
|
26
|
-
defineProps({
|
|
27
|
-
title: stringProp(),
|
|
28
|
-
message: requiredStringProp(),
|
|
29
|
-
});
|
|
30
|
-
</script>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessModal v-slot="{ close }: IAGHeadlessModalDefaultSlotProps" class="relative z-50">
|
|
3
|
-
<div class="fixed inset-0 flex items-center justify-center">
|
|
4
|
-
<AGHeadlessModalPanel class="flex max-h-full max-w-full flex-col overflow-hidden bg-white">
|
|
5
|
-
<div class="flex max-h-full flex-col overflow-auto p-4">
|
|
6
|
-
<slot :close="close" />
|
|
7
|
-
</div>
|
|
8
|
-
</AGHeadlessModalPanel>
|
|
9
|
-
</div>
|
|
10
|
-
</AGHeadlessModal>
|
|
11
|
-
</template>
|
|
12
|
-
|
|
13
|
-
<script setup lang="ts">
|
|
14
|
-
import type { IAGHeadlessModalDefaultSlotProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
15
|
-
|
|
16
|
-
import AGHeadlessModal from '../headless/modals/AGHeadlessModal.vue';
|
|
17
|
-
import AGHeadlessModalPanel from '../headless/modals/AGHeadlessModalPanel.vue';
|
|
18
|
-
</script>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="modal.component" v-bind="modal.properties" />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import { provide, toRef } from 'vue';
|
|
7
|
-
|
|
8
|
-
import { requiredNumberProp, requiredObjectProp } from '@/utils/vue';
|
|
9
|
-
import type { Modal } from '@/ui/UI.state';
|
|
10
|
-
|
|
11
|
-
import type { IAGModalContext } from './AGModalContext';
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
modal: requiredObjectProp<Modal>(),
|
|
15
|
-
childIndex: requiredNumberProp(),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
provide<IAGModalContext>('modal', {
|
|
19
|
-
modal: toRef(props, 'modal'),
|
|
20
|
-
childIndex: toRef(props, 'childIndex'),
|
|
21
|
-
});
|
|
22
|
-
</script>
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import AGAlertModal from './AGAlertModal.vue';
|
|
2
|
-
import AGConfirmModal from './AGConfirmModal.vue';
|
|
3
|
-
import AGModal from './AGModal.vue';
|
|
4
|
-
import AGModalContext from './AGModalContext.vue';
|
|
5
|
-
import { IAGModal } from './AGModal';
|
|
6
|
-
|
|
7
|
-
export { AGAlertModal, AGConfirmModal, AGModal, AGModalContext, IAGModal };
|
package/src/forms/Form.test.ts
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { describe, expect, expectTypeOf, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { useForm } from './composition';
|
|
4
|
-
import { FormFieldTypes } from '@/main';
|
|
5
|
-
import { numberInput, requiredStringInput } from '@/forms/utils';
|
|
6
|
-
|
|
7
|
-
describe('Form', () => {
|
|
8
|
-
|
|
9
|
-
it('defines magic fields', () => {
|
|
10
|
-
const form = useForm({
|
|
11
|
-
name: requiredStringInput(),
|
|
12
|
-
age: numberInput(),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
expectTypeOf(form.name).toEqualTypeOf<string>();
|
|
16
|
-
expectTypeOf(form.age).toEqualTypeOf<number | null>();
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it('validates required fields', () => {
|
|
20
|
-
// Arrange
|
|
21
|
-
const form = useForm({
|
|
22
|
-
name: {
|
|
23
|
-
type: FormFieldTypes.String,
|
|
24
|
-
rules: 'required',
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
// Act
|
|
29
|
-
form.submit();
|
|
30
|
-
|
|
31
|
-
// Assert
|
|
32
|
-
expect(form.valid).toBe(false);
|
|
33
|
-
expect(form.submitted).toBe(true);
|
|
34
|
-
expect(form.errors.name).toEqual(['required']);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
});
|