@aerogel/core 0.0.0-next.71f28064caa2ea968f0e99396b672de218176260 → 0.0.0-next.73a6df428477c011a1aebe0a932ebef0aa5e1b16
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.css +1 -0
- package/dist/aerogel-core.d.ts +2285 -1681
- package/dist/aerogel-core.js +3809 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +32 -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/AppLayout.vue +14 -0
- package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
- package/src/components/AppOverlays.vue +9 -0
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +19 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +48 -0
- package/src/components/contracts/DropdownMenu.ts +25 -0
- package/src/components/contracts/ErrorReportModal.ts +33 -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/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +7 -8
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
- package/src/components/headless/HeadlessInputInput.vue +86 -0
- package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
- package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +11 -11
- 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/{forms/AGHeadlessSelectError.vue → HeadlessSelectError.vue} +5 -6
- package/src/components/headless/HeadlessSelectLabel.vue +25 -0
- package/src/components/headless/HeadlessSelectOption.vue +34 -0
- package/src/components/headless/HeadlessSelectOptions.vue +42 -0
- package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
- package/src/components/headless/HeadlessSelectValue.vue +18 -0
- package/src/components/headless/HeadlessSwitch.vue +96 -0
- package/src/components/headless/HeadlessToast.vue +18 -0
- package/src/components/headless/HeadlessToastAction.vue +13 -0
- package/src/components/headless/index.ts +20 -3
- package/src/components/index.ts +6 -9
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +17 -0
- package/src/components/ui/Button.vue +115 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +50 -0
- package/src/components/ui/DropdownMenu.vue +32 -0
- package/src/components/ui/DropdownMenuOption.vue +22 -0
- package/src/components/ui/DropdownMenuOptions.vue +44 -0
- package/src/components/ui/EditableContent.vue +82 -0
- package/src/components/ui/ErrorLogs.vue +19 -0
- package/src/components/ui/ErrorLogsModal.vue +48 -0
- package/src/components/ui/ErrorMessage.vue +15 -0
- package/src/components/ui/ErrorReportModal.vue +73 -0
- package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +34 -27
- 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 +97 -0
- package/src/components/ui/Modal.vue +131 -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 +21 -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/Setting.vue +31 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/ui/StartupCrash.vue +76 -0
- package/src/components/ui/Switch.vue +11 -0
- package/src/components/ui/TextArea.vue +56 -0
- package/src/components/ui/Toast.vue +46 -0
- package/src/components/ui/index.ts +35 -0
- package/src/directives/index.ts +9 -5
- package/src/directives/measure.ts +33 -8
- package/src/errors/Errors.state.ts +2 -1
- package/src/errors/Errors.ts +56 -33
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +15 -8
- package/src/errors/settings/Debug.vue +14 -0
- package/src/errors/settings/index.ts +10 -0
- package/src/errors/utils.ts +17 -1
- package/src/forms/FormController.test.ts +113 -0
- package/src/forms/FormController.ts +255 -0
- package/src/forms/index.ts +3 -2
- package/src/forms/utils.ts +76 -20
- package/src/forms/validation.ts +50 -0
- package/src/index.css +76 -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 +12 -6
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/plugins/Plugin.ts +1 -1
- package/src/plugins/index.ts +10 -7
- package/src/services/App.state.ts +36 -3
- package/src/services/App.ts +19 -3
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +16 -12
- package/src/services/Service.ts +135 -59
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +18 -7
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +8 -3
- package/src/testing/setup.ts +11 -0
- package/src/ui/UI.state.ts +14 -12
- package/src/ui/UI.ts +252 -122
- package/src/ui/index.ts +28 -28
- package/src/ui/utils.ts +16 -0
- package/src/utils/app.ts +7 -0
- package/src/utils/classes.ts +41 -0
- package/src/utils/composition/events.ts +4 -6
- package/src/utils/composition/forms.ts +20 -4
- 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 -1
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +53 -6
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +38 -132
- 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/AGAppLayout.vue +0 -16
- package/src/components/AGAppOverlays.vue +0 -41
- package/src/components/AGAppSnackbars.vue +0 -13
- package/src/components/constants.ts +0 -8
- package/src/components/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -41
- package/src/components/forms/AGForm.vue +0 -26
- package/src/components/forms/AGInput.vue +0 -40
- package/src/components/forms/AGSelect.story.vue +0 -46
- package/src/components/forms/AGSelect.vue +0 -60
- package/src/components/forms/index.ts +0 -5
- package/src/components/headless/forms/AGHeadlessButton.vue +0 -51
- package/src/components/headless/forms/AGHeadlessInput.ts +0 -31
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -57
- package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -53
- package/src/components/headless/forms/AGHeadlessSelect.ts +0 -42
- package/src/components/headless/forms/AGHeadlessSelect.vue +0 -77
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -39
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
- package/src/components/headless/forms/composition.ts +0 -10
- package/src/components/headless/forms/index.ts +0 -16
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -34
- package/src/components/headless/modals/AGHeadlessModal.vue +0 -86
- 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/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
- package/src/components/headless/snackbars/index.ts +0 -40
- package/src/components/lib/AGErrorMessage.vue +0 -16
- package/src/components/lib/AGLink.vue +0 -9
- package/src/components/lib/AGMarkdown.vue +0 -41
- package/src/components/lib/AGMeasured.vue +0 -15
- package/src/components/lib/AGStartupCrash.vue +0 -31
- package/src/components/lib/index.ts +0 -5
- package/src/components/modals/AGAlertModal.ts +0 -15
- package/src/components/modals/AGAlertModal.vue +0 -14
- package/src/components/modals/AGConfirmModal.ts +0 -27
- 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 -30
- package/src/components/modals/AGPromptModal.vue +0 -34
- package/src/components/modals/index.ts +0 -17
- package/src/components/snackbars/AGSnackbar.vue +0 -36
- package/src/components/snackbars/index.ts +0 -3
- package/src/components/utils.ts +0 -10
- package/src/directives/initial-focus.ts +0 -11
- package/src/forms/Form.test.ts +0 -58
- package/src/forms/Form.ts +0 -205
- package/src/forms/composition.ts +0 -6
- package/src/main.histoire.ts +0 -1
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
- package/tailwind.config.js +0 -4
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -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>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessModal
|
|
3
|
-
ref="$modal"
|
|
4
|
-
v-slot="{ close }: IAGHeadlessModalDefaultSlotProps"
|
|
5
|
-
v-bind="props"
|
|
6
|
-
class="relative z-50"
|
|
7
|
-
>
|
|
8
|
-
<div class="fixed inset-0 flex items-center justify-center p-8">
|
|
9
|
-
<AGHeadlessModalPanel class="flex max-h-full max-w-full flex-col overflow-hidden bg-white p-4">
|
|
10
|
-
<AGHeadlessModalTitle v-if="title" class="mb-2 text-lg font-semibold">
|
|
11
|
-
<AGMarkdown :text="title" inline />
|
|
12
|
-
</AGHeadlessModalTitle>
|
|
13
|
-
<div class="flex max-h-full flex-col overflow-auto" v-bind="$attrs">
|
|
14
|
-
<slot :close="close" />
|
|
15
|
-
</div>
|
|
16
|
-
</AGHeadlessModalPanel>
|
|
17
|
-
</div>
|
|
18
|
-
</AGHeadlessModal>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import { ref } from 'vue';
|
|
23
|
-
|
|
24
|
-
import { useModalExpose, useModalProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
25
|
-
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from '@/components/headless/modals/AGHeadlessModal';
|
|
26
|
-
|
|
27
|
-
import type { IAGModal } from './AGModal';
|
|
28
|
-
|
|
29
|
-
import AGHeadlessModal from '../headless/modals/AGHeadlessModal.vue';
|
|
30
|
-
import AGHeadlessModalPanel from '../headless/modals/AGHeadlessModalPanel.vue';
|
|
31
|
-
import AGHeadlessModalTitle from '../headless/modals/AGHeadlessModalTitle.vue';
|
|
32
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
33
|
-
|
|
34
|
-
const props = defineProps(useModalProps());
|
|
35
|
-
const $modal = ref<IAGHeadlessModal>();
|
|
36
|
-
|
|
37
|
-
defineOptions({ inheritAttrs: false });
|
|
38
|
-
defineExpose<IAGModal>(useModalExpose($modal));
|
|
39
|
-
</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,30 +0,0 @@
|
|
|
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 promptModalProps = {
|
|
9
|
-
title: stringProp(),
|
|
10
|
-
message: requiredStringProp(),
|
|
11
|
-
label: stringProp(),
|
|
12
|
-
defaultValue: stringProp(),
|
|
13
|
-
placeholder: stringProp(),
|
|
14
|
-
acceptText: stringProp(),
|
|
15
|
-
cancelText: stringProp(),
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export type AGPromptModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof promptModalProps>>;
|
|
19
|
-
|
|
20
|
-
export function usePromptModalProps(): typeof promptModalProps {
|
|
21
|
-
return promptModalProps;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
25
|
-
export function usePromptModal(props: ExtractPropTypes<typeof promptModalProps>) {
|
|
26
|
-
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
27
|
-
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
28
|
-
|
|
29
|
-
return { renderedAcceptText, renderedCancelText };
|
|
30
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false" :title="title">
|
|
3
|
-
<AGMarkdown :text="message" />
|
|
4
|
-
|
|
5
|
-
<AGForm :form="form" @submit="close(form.draft)">
|
|
6
|
-
<AGInput name="draft" :placeholder="placeholder" :label="label" />
|
|
7
|
-
|
|
8
|
-
<div class="mt-2 flex flex-row-reverse gap-2">
|
|
9
|
-
<AGButton submit>
|
|
10
|
-
{{ renderedAcceptText }}
|
|
11
|
-
</AGButton>
|
|
12
|
-
<AGButton color="secondary" @click="close()">
|
|
13
|
-
{{ renderedCancelText }}
|
|
14
|
-
</AGButton>
|
|
15
|
-
</div>
|
|
16
|
-
</AGForm>
|
|
17
|
-
</AGModal>
|
|
18
|
-
</template>
|
|
19
|
-
|
|
20
|
-
<script setup lang="ts">
|
|
21
|
-
import AGModal from './AGModal.vue';
|
|
22
|
-
import { usePromptModal, usePromptModalProps } from './AGPromptModal';
|
|
23
|
-
import type { IAGModalDefaultSlotProps } from './AGModal';
|
|
24
|
-
|
|
25
|
-
import AGButton from '../forms/AGButton.vue';
|
|
26
|
-
import AGForm from '../forms/AGForm.vue';
|
|
27
|
-
import AGInput from '../forms/AGInput.vue';
|
|
28
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
29
|
-
import { requiredStringInput, useForm } from '../../forms';
|
|
30
|
-
|
|
31
|
-
const props = defineProps(usePromptModalProps());
|
|
32
|
-
const form = useForm({ draft: requiredStringInput(props.defaultValue ?? '') });
|
|
33
|
-
const { renderedAcceptText, renderedCancelText } = usePromptModal(props);
|
|
34
|
-
</script>
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export * from './AGAlertModal';
|
|
2
|
-
export * from './AGConfirmModal';
|
|
3
|
-
export * from './AGErrorReportModal';
|
|
4
|
-
export * from './AGLoadingModal';
|
|
5
|
-
export * from './AGModal';
|
|
6
|
-
export * from './AGModalContext';
|
|
7
|
-
export * from './AGPromptModal';
|
|
8
|
-
|
|
9
|
-
export { default as AGAlertModal } from './AGAlertModal.vue';
|
|
10
|
-
export { default as AGConfirmModal } from './AGConfirmModal.vue';
|
|
11
|
-
export { default as AGErrorReportModalButtons } from './AGErrorReportModalButtons.vue';
|
|
12
|
-
export { default as AGErrorReportModalTitle } from './AGErrorReportModalTitle.vue';
|
|
13
|
-
export { default as AGLoadingModal } from './AGLoadingModal.vue';
|
|
14
|
-
export { default as AGModal } from './AGModal.vue';
|
|
15
|
-
export { default as AGModalContext } from './AGModalContext.vue';
|
|
16
|
-
export { default as AGModalTitle } from './AGModalTitle.vue';
|
|
17
|
-
export { default as AGPromptModal } from './AGPromptModal.vue';
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessSnackbar class="flex flex-row items-center justify-center gap-3 p-4" :class="styleClasses">
|
|
3
|
-
<AGMarkdown :text="message" inline />
|
|
4
|
-
<AGButton
|
|
5
|
-
v-for="(action, i) of actions"
|
|
6
|
-
:key="i"
|
|
7
|
-
:color="color"
|
|
8
|
-
@click="activate(action)"
|
|
9
|
-
>
|
|
10
|
-
{{ action.text }}
|
|
11
|
-
</AGButton>
|
|
12
|
-
</AGHeadlessSnackbar>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { computed } from 'vue';
|
|
17
|
-
|
|
18
|
-
import { Colors } from '@/components/constants';
|
|
19
|
-
import { useSnackbar, useSnackbarProps } from '@/components/headless/snackbars';
|
|
20
|
-
|
|
21
|
-
import AGButton from '../forms/AGButton.vue';
|
|
22
|
-
import AGHeadlessSnackbar from '../headless/snackbars/AGHeadlessSnackbar.vue';
|
|
23
|
-
import AGMarkdown from '../lib/AGMarkdown.vue';
|
|
24
|
-
|
|
25
|
-
const props = defineProps(useSnackbarProps());
|
|
26
|
-
const { activate } = useSnackbar(props);
|
|
27
|
-
const styleClasses = computed(() => {
|
|
28
|
-
switch (props.color) {
|
|
29
|
-
case Colors.Danger:
|
|
30
|
-
return 'bg-red-200 text-red-900';
|
|
31
|
-
default:
|
|
32
|
-
case Colors.Secondary:
|
|
33
|
-
return 'bg-gray-900 text-white';
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
</script>
|
package/src/components/utils.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export function extractComponentProps<T extends Record<string, unknown>>(
|
|
2
|
-
values: Record<string, unknown>,
|
|
3
|
-
definitions: Record<string, unknown>,
|
|
4
|
-
): T {
|
|
5
|
-
return Object.keys(definitions).reduce((extracted, prop) => {
|
|
6
|
-
extracted[prop] = values[prop];
|
|
7
|
-
|
|
8
|
-
return extracted;
|
|
9
|
-
}, {} as Record<string, unknown>) as T;
|
|
10
|
-
}
|
package/src/forms/Form.test.ts
DELETED
|
@@ -1,58 +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
|
-
it('resets form', () => {
|
|
38
|
-
// Arrange
|
|
39
|
-
const form = useForm({
|
|
40
|
-
name: {
|
|
41
|
-
type: FormFieldTypes.String,
|
|
42
|
-
rules: 'required',
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
form.name = 'Foo bar';
|
|
47
|
-
form.submit();
|
|
48
|
-
|
|
49
|
-
// Act
|
|
50
|
-
form.reset();
|
|
51
|
-
|
|
52
|
-
// Assert
|
|
53
|
-
expect(form.valid).toBe(true);
|
|
54
|
-
expect(form.submitted).toBe(false);
|
|
55
|
-
expect(form.name).toBeNull();
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
});
|
package/src/forms/Form.ts
DELETED
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { MagicObject, arrayRemove } from '@noeldemartin/utils';
|
|
2
|
-
import { computed, nextTick, reactive, readonly, ref } from 'vue';
|
|
3
|
-
import type { ObjectValues } from '@noeldemartin/utils';
|
|
4
|
-
import type { ComputedRef, DeepReadonly, Ref, UnwrapNestedRefs } from 'vue';
|
|
5
|
-
|
|
6
|
-
export const FormFieldTypes = {
|
|
7
|
-
String: 'string',
|
|
8
|
-
Number: 'number',
|
|
9
|
-
Boolean: 'boolean',
|
|
10
|
-
Object: 'object',
|
|
11
|
-
} as const;
|
|
12
|
-
|
|
13
|
-
export interface FormFieldDefinition<TType extends FormFieldType = FormFieldType, TRules extends string = string> {
|
|
14
|
-
type: TType;
|
|
15
|
-
default?: GetFormFieldValue<TType>;
|
|
16
|
-
rules?: TRules;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export type FormFieldDefinitions = Record<string, FormFieldDefinition>;
|
|
20
|
-
export type FormFieldType = ObjectValues<typeof FormFieldTypes>;
|
|
21
|
-
export type FormFieldValue = GetFormFieldValue<FormFieldType>;
|
|
22
|
-
|
|
23
|
-
export type FormData<T> = {
|
|
24
|
-
-readonly [k in keyof T]: T[k] extends FormFieldDefinition<infer TType, infer TRules>
|
|
25
|
-
? TRules extends 'required'
|
|
26
|
-
? GetFormFieldValue<TType>
|
|
27
|
-
: GetFormFieldValue<TType> | null
|
|
28
|
-
: never;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type FormErrors<T> = {
|
|
32
|
-
[k in keyof T]: string[] | null;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
export type GetFormFieldValue<TType> = TType extends typeof FormFieldTypes.String
|
|
36
|
-
? string
|
|
37
|
-
: TType extends typeof FormFieldTypes.Number
|
|
38
|
-
? number
|
|
39
|
-
: TType extends typeof FormFieldTypes.Boolean
|
|
40
|
-
? boolean
|
|
41
|
-
: TType extends typeof FormFieldTypes.Object
|
|
42
|
-
? object
|
|
43
|
-
: never;
|
|
44
|
-
|
|
45
|
-
const validForms: WeakMap<Form, ComputedRef<boolean>> = new WeakMap();
|
|
46
|
-
|
|
47
|
-
export type FormListener = (input: string) => unknown;
|
|
48
|
-
|
|
49
|
-
export default class Form<Fields extends FormFieldDefinitions = FormFieldDefinitions> extends MagicObject {
|
|
50
|
-
|
|
51
|
-
public errors: DeepReadonly<UnwrapNestedRefs<FormErrors<Fields>>>;
|
|
52
|
-
|
|
53
|
-
private _fields: Fields;
|
|
54
|
-
private _data: FormData<Fields>;
|
|
55
|
-
private _submitted: Ref<boolean>;
|
|
56
|
-
private _errors: FormErrors<Fields>;
|
|
57
|
-
private _listeners: Record<string, FormListener[]> = {};
|
|
58
|
-
|
|
59
|
-
constructor(fields: Fields) {
|
|
60
|
-
super();
|
|
61
|
-
|
|
62
|
-
this._fields = fields;
|
|
63
|
-
this._submitted = ref(false);
|
|
64
|
-
this._data = this.getInitialData(fields);
|
|
65
|
-
this._errors = this.getInitialErrors(fields);
|
|
66
|
-
|
|
67
|
-
validForms.set(
|
|
68
|
-
this,
|
|
69
|
-
computed(() => !Object.values(this._errors).some((error) => error !== null)),
|
|
70
|
-
);
|
|
71
|
-
|
|
72
|
-
this.errors = readonly(this._errors);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
public get valid(): boolean {
|
|
76
|
-
return !!validForms.get(this)?.value;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
public get submitted(): boolean {
|
|
80
|
-
return this._submitted.value;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
public setFieldValue<T extends keyof Fields>(field: T, value: FormData<Fields>[T]): void {
|
|
84
|
-
this._data[field] = value;
|
|
85
|
-
|
|
86
|
-
if (this._submitted.value) {
|
|
87
|
-
this.validate();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
public getFieldValue<T extends keyof Fields>(field: T): GetFormFieldValue<Fields[T]['type']> {
|
|
92
|
-
return this._data[field] as unknown as GetFormFieldValue<Fields[T]['type']>;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
public validate(): boolean {
|
|
96
|
-
const errors = Object.entries(this._fields).reduce((formErrors, [name, definition]) => {
|
|
97
|
-
formErrors[name] = this.getFieldErrors(name, definition);
|
|
98
|
-
|
|
99
|
-
return formErrors;
|
|
100
|
-
}, {} as Record<string, string[] | null>);
|
|
101
|
-
|
|
102
|
-
this.resetErrors(errors);
|
|
103
|
-
|
|
104
|
-
return this.valid;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
public reset(options: { keepData?: boolean; keepErrors?: boolean } = {}): void {
|
|
108
|
-
this._submitted.value = false;
|
|
109
|
-
|
|
110
|
-
options.keepData || this.resetData();
|
|
111
|
-
options.keepErrors || this.resetErrors();
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
public submit(): boolean {
|
|
115
|
-
this._submitted.value = true;
|
|
116
|
-
|
|
117
|
-
return this.validate();
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
public on(event: string, listener: FormListener): () => void {
|
|
121
|
-
this._listeners[event] ??= [];
|
|
122
|
-
this._listeners[event]?.push(listener);
|
|
123
|
-
|
|
124
|
-
return () => this.off(event, listener);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public off(event: string, listener: FormListener): void {
|
|
128
|
-
arrayRemove(this._listeners[event] ?? [], listener);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
public async focus(input: string): Promise<void> {
|
|
132
|
-
await nextTick();
|
|
133
|
-
|
|
134
|
-
this._listeners['focus']?.forEach((listener) => listener(input));
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected __get(property: string): unknown {
|
|
138
|
-
if (!(property in this._fields)) {
|
|
139
|
-
return super.__get(property);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return this._data[property];
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
protected __set(property: string, value: unknown): void {
|
|
146
|
-
if (!(property in this._fields)) {
|
|
147
|
-
super.__set(property, value);
|
|
148
|
-
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
Object.assign(this._data, { [property]: value });
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
private getFieldErrors(name: keyof Fields, definition: FormFieldDefinition): string[] | null {
|
|
156
|
-
const errors = [];
|
|
157
|
-
|
|
158
|
-
if (definition.rules?.includes('required') && !this._data[name]) {
|
|
159
|
-
errors.push('required');
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
return errors.length > 0 ? errors : null;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
private getInitialData(fields: Fields): FormData<Fields> {
|
|
166
|
-
if (this.static().isConjuring()) {
|
|
167
|
-
return {} as FormData<Fields>;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
const data = Object.entries(fields).reduce((formData, [name, definition]) => {
|
|
171
|
-
formData[name as keyof Fields] = (definition.default ?? null) as FormData<Fields>[keyof Fields];
|
|
172
|
-
|
|
173
|
-
return formData;
|
|
174
|
-
}, {} as FormData<Fields>);
|
|
175
|
-
|
|
176
|
-
return reactive(data) as FormData<Fields>;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
private getInitialErrors(fields: Fields): FormErrors<Fields> {
|
|
180
|
-
if (this.static().isConjuring()) {
|
|
181
|
-
return {} as FormErrors<Fields>;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const errors = Object.keys(fields).reduce((formErrors, name) => {
|
|
185
|
-
formErrors[name as keyof Fields] = null;
|
|
186
|
-
|
|
187
|
-
return formErrors;
|
|
188
|
-
}, {} as FormErrors<Fields>);
|
|
189
|
-
|
|
190
|
-
return reactive(errors) as FormErrors<Fields>;
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
private resetData(): void {
|
|
194
|
-
for (const [name, field] of Object.entries(this._fields)) {
|
|
195
|
-
this._data[name as keyof Fields] = (field.default ?? null) as FormData<Fields>[keyof Fields];
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
private resetErrors(errors?: Record<string, string[] | null>): void {
|
|
200
|
-
Object.keys(this._errors).forEach((key) => delete this._errors[key as keyof Fields]);
|
|
201
|
-
|
|
202
|
-
errors && Object.assign(this._errors, errors);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
}
|
package/src/forms/composition.ts
DELETED
package/src/main.histoire.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import './assets/histoire.css';
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
|
|
3
|
-
import { removeInteractiveClasses } from './tailwindcss';
|
|
4
|
-
|
|
5
|
-
describe('TailwindCSS utils', () => {
|
|
6
|
-
|
|
7
|
-
it('Removes interactive classes', () => {
|
|
8
|
-
const cases: [string, string][] = [
|
|
9
|
-
['text-red hover:text-green', 'text-red'],
|
|
10
|
-
['text-red hover:text-green text-lg', 'text-red text-lg'],
|
|
11
|
-
[
|
|
12
|
-
`
|
|
13
|
-
text-red text-lg
|
|
14
|
-
focus:text-yellow
|
|
15
|
-
hover:focus:text-black
|
|
16
|
-
`,
|
|
17
|
-
'text-red text-lg',
|
|
18
|
-
],
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
cases.forEach(([original, expected]) => {
|
|
22
|
-
expect(removeInteractiveClasses(original)).toEqual(expected);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
});
|
package/src/utils/tailwindcss.ts
DELETED
package/tailwind.config.js
DELETED
package/tsconfig.json
DELETED
package/vite.config.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import Aerogel from '@aerogel/vite';
|
|
2
|
-
import Icons from 'unplugin-icons/vite';
|
|
3
|
-
import { defineConfig } from 'vitest/config';
|
|
4
|
-
import { resolve } from 'path';
|
|
5
|
-
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
test: { clearMocks: true },
|
|
8
|
-
plugins: [Aerogel(), Icons()],
|
|
9
|
-
resolve: {
|
|
10
|
-
alias: {
|
|
11
|
-
'@': resolve(__dirname, './src'),
|
|
12
|
-
},
|
|
13
|
-
},
|
|
14
|
-
});
|
|
File without changes
|