@aerogel/core 0.0.0-next.c29ffcd25bffdbed37ecce3aac1ba14cde3e9d39 → 0.0.0-next.c3236837f7f8fc319a4a56022accb32757b3db89
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 +2061 -1962
- package/dist/aerogel-core.js +3669 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +32 -37
- package/src/bootstrap/bootstrap.test.ts +4 -7
- package/src/bootstrap/index.ts +14 -15
- 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} +10 -13
- 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 -11
- 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/{forms/AGForm.vue → ui/Form.vue} +4 -5
- 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/{modals/AGModalContext.vue → ui/ModalContext.vue} +8 -9
- 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/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +8 -8
- 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 +12 -6
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +29 -27
- package/src/errors/index.ts +15 -8
- package/src/errors/settings/Debug.vue +32 -0
- package/src/errors/settings/index.ts +10 -0
- package/src/errors/utils.ts +1 -1
- package/src/forms/{Form.test.ts → FormController.test.ts} +32 -8
- package/src/forms/{Form.ts → FormController.ts} +46 -38
- package/src/forms/index.ts +2 -3
- package/src/forms/utils.ts +35 -35
- package/src/index.css +75 -0
- package/src/jobs/Job.ts +2 -2
- 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 +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 +15 -4
- package/src/services/App.ts +12 -4
- package/src/services/Cache.ts +1 -1
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +4 -10
- package/src/services/Service.ts +21 -21
- package/src/services/Storage.ts +3 -3
- package/src/services/index.ts +10 -6
- package/src/services/utils.ts +2 -2
- package/src/testing/index.ts +8 -3
- package/src/testing/setup.ts +3 -19
- package/src/ui/UI.state.ts +8 -13
- package/src/ui/UI.ts +143 -114
- package/src/ui/index.ts +27 -28
- 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/state.ts +11 -2
- package/src/utils/index.ts +3 -1
- package/src/utils/markdown.ts +37 -5
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +31 -137
- 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/composition.ts +0 -23
- 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/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.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/AGHeadlessInputInput.vue +0 -84
- 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 -18
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -36
- package/src/components/headless/modals/AGHeadlessModal.vue +0 -92
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -32
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -23
- 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/interfaces.ts +0 -24
- package/src/components/lib/AGErrorMessage.vue +0 -16
- package/src/components/lib/AGLink.vue +0 -9
- package/src/components/lib/AGMarkdown.vue +0 -54
- package/src/components/lib/AGMeasured.vue +0 -16
- package/src/components/lib/AGProgressBar.vue +0 -45
- package/src/components/lib/index.ts +0 -6
- package/src/components/modals/AGAlertModal.ts +0 -18
- package/src/components/modals/AGAlertModal.vue +0 -14
- package/src/components/modals/AGConfirmModal.ts +0 -42
- package/src/components/modals/AGConfirmModal.vue +0 -26
- package/src/components/modals/AGErrorReportModal.ts +0 -49
- package/src/components/modals/AGErrorReportModal.vue +0 -54
- package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
- package/src/components/modals/AGLoadingModal.ts +0 -29
- package/src/components/modals/AGLoadingModal.vue +0 -15
- package/src/components/modals/AGModal.ts +0 -11
- package/src/components/modals/AGModal.vue +0 -39
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalTitle.vue +0 -9
- package/src/components/modals/AGPromptModal.ts +0 -41
- 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/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 -17
- /package/src/{main.ts → index.ts} +0 -0
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Listbox
|
|
3
|
-
v-slot="{ value, open, disabled }: ComponentProps"
|
|
4
|
-
:model-value="selectedOption"
|
|
5
|
-
@update:model-value="update($event)"
|
|
6
|
-
>
|
|
7
|
-
<slot :value="value" :open="open" :disabled="disabled" />
|
|
8
|
-
</Listbox>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup lang="ts">
|
|
12
|
-
import { computed, inject, provide } from 'vue';
|
|
13
|
-
import { toString, uuid } from '@noeldemartin/utils';
|
|
14
|
-
import { Listbox } from '@headlessui/vue';
|
|
15
|
-
|
|
16
|
-
import { mixedProp } from '@/utils/vue';
|
|
17
|
-
import { translateWithDefault } from '@/lang/utils';
|
|
18
|
-
import type Form from '@/forms/Form';
|
|
19
|
-
import type { FormFieldValue } from '@/forms/Form';
|
|
20
|
-
import type { ComponentProps } from '@/utils/vue';
|
|
21
|
-
|
|
22
|
-
import { useSelectEmits, useSelectProps } from './AGHeadlessSelect';
|
|
23
|
-
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
24
|
-
|
|
25
|
-
const emit = defineEmits(useSelectEmits());
|
|
26
|
-
const props = defineProps({
|
|
27
|
-
modelValue: mixedProp<FormFieldValue>(),
|
|
28
|
-
...useSelectProps(),
|
|
29
|
-
});
|
|
30
|
-
const renderText = computed(() => {
|
|
31
|
-
if (typeof props.optionsText === 'function') {
|
|
32
|
-
return props.optionsText;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
if (typeof props.optionsText === 'string') {
|
|
36
|
-
return (option: FormFieldValue): string => toString(option[props.optionsText as keyof FormFieldValue]);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return (option: FormFieldValue) => toString(option);
|
|
40
|
-
});
|
|
41
|
-
const form = inject<Form | null>('form', null);
|
|
42
|
-
const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
|
|
43
|
-
const selectedOption = computed(() => (form && props.name ? form.getFieldValue(props.name) : props.modelValue));
|
|
44
|
-
const errors = computed(() => {
|
|
45
|
-
if (!form || !props.name) {
|
|
46
|
-
return null;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return form.errors[props.name] ?? null;
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
function update(value: FormFieldValue) {
|
|
53
|
-
if (form && props.name) {
|
|
54
|
-
form.setFieldValue(props.name, value);
|
|
55
|
-
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
emit('update:modelValue', value);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const api: IAGHeadlessSelect = {
|
|
63
|
-
id: `select-${uuid()}`,
|
|
64
|
-
noSelectionText,
|
|
65
|
-
selectedOption,
|
|
66
|
-
errors,
|
|
67
|
-
options: computed(() => props.options),
|
|
68
|
-
label: computed(() => props.label),
|
|
69
|
-
buttonText: computed(() =>
|
|
70
|
-
selectedOption.value === null ? noSelectionText.value : renderText.value(selectedOption.value)),
|
|
71
|
-
renderText,
|
|
72
|
-
update,
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
provide<IAGHeadlessSelect>('select', api);
|
|
76
|
-
defineExpose<IAGHeadlessSelect>(api);
|
|
77
|
-
</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,39 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<ListboxOption v-slot="{ active, selected, disabled }: ComponentProps" :value="value" as="template">
|
|
3
|
-
<slot :active="active" :selected="selected" :disabled="disabled">
|
|
4
|
-
<li
|
|
5
|
-
:class="{
|
|
6
|
-
[activeClass ?? 'active']: active,
|
|
7
|
-
[inactiveClass ?? 'inactive']: !active,
|
|
8
|
-
[selectedClass ?? 'selected']: selected,
|
|
9
|
-
[unselectedClass ?? 'unselected']: !selected,
|
|
10
|
-
}"
|
|
11
|
-
>
|
|
12
|
-
{{ select.renderText(value) }}
|
|
13
|
-
</li>
|
|
14
|
-
</slot>
|
|
15
|
-
</ListboxOption>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { ListboxOption } from '@headlessui/vue';
|
|
20
|
-
|
|
21
|
-
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@/utils/vue';
|
|
22
|
-
import type { ComponentProps } from '@/utils/vue';
|
|
23
|
-
import type { FormFieldValue } from '@/forms/Form';
|
|
24
|
-
|
|
25
|
-
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
26
|
-
|
|
27
|
-
defineProps({
|
|
28
|
-
value: requiredMixedProp<FormFieldValue>(),
|
|
29
|
-
selectedClass: stringProp(),
|
|
30
|
-
unselectedClass: stringProp(),
|
|
31
|
-
activeClass: stringProp(),
|
|
32
|
-
inactiveClass: stringProp(),
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
36
|
-
'select',
|
|
37
|
-
'<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>',
|
|
38
|
-
);
|
|
39
|
-
</script>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { inject, onUnmounted } from 'vue';
|
|
2
|
-
|
|
3
|
-
import type Form from '@/forms/Form';
|
|
4
|
-
|
|
5
|
-
export function onFormFocus(input: { name: string | null }, listener: () => unknown): void {
|
|
6
|
-
const form = inject<Form | null>('form', null);
|
|
7
|
-
const stop = form?.on('focus', (name) => input.name === name && listener());
|
|
8
|
-
|
|
9
|
-
onUnmounted(() => stop?.());
|
|
10
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export * from './composition';
|
|
2
|
-
export * from './AGHeadlessButton';
|
|
3
|
-
export * from './AGHeadlessInput';
|
|
4
|
-
export * from './AGHeadlessSelect';
|
|
5
|
-
export * from './AGHeadlessSelectOption';
|
|
6
|
-
export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
|
|
7
|
-
export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
|
|
8
|
-
export { default as AGHeadlessInputDescription } from './AGHeadlessInputDescription.vue';
|
|
9
|
-
export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
|
|
10
|
-
export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
|
|
11
|
-
export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
|
|
12
|
-
export { default as AGHeadlessInputTextArea } from './AGHeadlessInputTextArea.vue';
|
|
13
|
-
export { default as AGHeadlessSelect } from './AGHeadlessSelect.vue';
|
|
14
|
-
export { default as AGHeadlessSelectButton } from './AGHeadlessSelectButton.vue';
|
|
15
|
-
export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
|
|
16
|
-
export { default as AGHeadlessSelectLabel } from './AGHeadlessSelectLabel.vue';
|
|
17
|
-
export { default as AGHeadlessSelectOption } from './AGHeadlessSelectOption.vue';
|
|
18
|
-
export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions';
|
|
@@ -1,36 +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
|
-
inline: booleanProp(),
|
|
17
|
-
title: stringProp(),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function useModalProps(): typeof modalProps {
|
|
21
|
-
return modalProps;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function extractModalProps<T extends ExtractPropTypes<typeof modalProps>>(
|
|
25
|
-
props: T,
|
|
26
|
-
): Pick<T, keyof typeof modalProps> {
|
|
27
|
-
return extractComponentProps(props, modalProps);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function useModalExpose($modal: Ref<IAGHeadlessModal | undefined>): IAGModal {
|
|
31
|
-
return {
|
|
32
|
-
inline: computed(() => !!$modal.value?.inline),
|
|
33
|
-
cancellable: computed(() => !!$modal.value?.cancellable),
|
|
34
|
-
close: async () => $modal.value?.close(),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component
|
|
3
|
-
:is="rootComponent"
|
|
4
|
-
ref="$root"
|
|
5
|
-
:open="true"
|
|
6
|
-
@close="cancellable && close()"
|
|
7
|
-
>
|
|
8
|
-
<slot :close="close" />
|
|
9
|
-
</component>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup lang="ts">
|
|
13
|
-
import { computed, ref, toRef } from 'vue';
|
|
14
|
-
import { Dialog } from '@headlessui/vue';
|
|
15
|
-
import type { VNode } from 'vue';
|
|
16
|
-
|
|
17
|
-
import Events from '@/services/Events';
|
|
18
|
-
import { useEvent } from '@/utils/composition/events';
|
|
19
|
-
import { injectReactiveOrFail } from '@/utils/vue';
|
|
20
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
21
|
-
|
|
22
|
-
import { useModalProps } from './AGHeadlessModal';
|
|
23
|
-
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
24
|
-
|
|
25
|
-
const props = defineProps(useModalProps());
|
|
26
|
-
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
27
|
-
const hidden = ref(true);
|
|
28
|
-
const closed = ref(false);
|
|
29
|
-
const { modal } = injectReactiveOrFail<IAGModalContext>(
|
|
30
|
-
'modal',
|
|
31
|
-
'could not obtain modal reference from <AGHeadlessModal>, ' +
|
|
32
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
33
|
-
);
|
|
34
|
-
const rootComponent = computed(() => (modal.properties.inline ? 'div' : Dialog));
|
|
35
|
-
|
|
36
|
-
async function hide(): Promise<void> {
|
|
37
|
-
if (!$root.value?.$el) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
hidden.value = true;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
async function show(): Promise<void> {
|
|
45
|
-
if (!$root.value?.$el) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
hidden.value = false;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
async function close(result?: unknown) {
|
|
53
|
-
if (closed.value) {
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
Events.emit('modal-will-close', { modal, result });
|
|
58
|
-
|
|
59
|
-
await hide();
|
|
60
|
-
|
|
61
|
-
closed.value = true;
|
|
62
|
-
|
|
63
|
-
Events.emit('modal-closed', { modal, result });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
useEvent('close-modal', async ({ id, result }) => {
|
|
67
|
-
if (id !== modal.id) {
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
await close(result);
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
useEvent('hide-modal', async ({ id }) => {
|
|
75
|
-
if (id !== modal.id) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
await hide();
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
useEvent('show-modal', async ({ id }) => {
|
|
83
|
-
if (id !== modal.id) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
await show();
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
defineSlots<{ default(props: IAGHeadlessModalDefaultSlotProps): VNode[] }>();
|
|
91
|
-
defineExpose<IAGHeadlessModal>({ close, cancellable: toRef(props, 'cancellable'), inline: toRef(props, 'inline') });
|
|
92
|
-
</script>
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="rootComponent">
|
|
3
|
-
<slot />
|
|
4
|
-
|
|
5
|
-
<template v-if="childModal">
|
|
6
|
-
<div
|
|
7
|
-
class="pointer-events-none inset-0 z-50 bg-black/30"
|
|
8
|
-
:class="childModal.properties.inline ? 'absolute' : 'fixed'"
|
|
9
|
-
/>
|
|
10
|
-
<AGModalContext :child-index="childIndex + 1" :modal="childModal" />
|
|
11
|
-
</template>
|
|
12
|
-
</component>
|
|
13
|
-
</template>
|
|
14
|
-
|
|
15
|
-
<script setup lang="ts">
|
|
16
|
-
import { computed } from 'vue';
|
|
17
|
-
import { DialogPanel } from '@headlessui/vue';
|
|
18
|
-
|
|
19
|
-
import UI from '@/ui/UI';
|
|
20
|
-
import { injectReactiveOrFail } from '@/utils/vue';
|
|
21
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
22
|
-
|
|
23
|
-
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
24
|
-
|
|
25
|
-
const { modal, childIndex } = injectReactiveOrFail<IAGModalContext>(
|
|
26
|
-
'modal',
|
|
27
|
-
'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
|
|
28
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
29
|
-
);
|
|
30
|
-
const rootComponent = computed(() => (modal.properties.inline ? 'div' : DialogPanel));
|
|
31
|
-
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
32
|
-
</script>
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="rootComponent" v-bind="rootProps">
|
|
3
|
-
<slot />
|
|
4
|
-
</component>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed } from 'vue';
|
|
9
|
-
import { DialogTitle } from '@headlessui/vue';
|
|
10
|
-
|
|
11
|
-
import { injectReactiveOrFail, stringProp } from '@/utils/vue';
|
|
12
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
13
|
-
|
|
14
|
-
const props = defineProps({ as: stringProp('h2') });
|
|
15
|
-
|
|
16
|
-
const { modal } = injectReactiveOrFail<IAGModalContext>(
|
|
17
|
-
'modal',
|
|
18
|
-
'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
|
|
19
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
20
|
-
);
|
|
21
|
-
const rootComponent = computed(() => (modal.properties.inline ? 'div' : DialogTitle));
|
|
22
|
-
const rootProps = computed(() => (modal.properties.inline ? {} : { as: props.as }));
|
|
23
|
-
</script>
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type { ExtractPropTypes } from 'vue';
|
|
2
|
-
import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
|
|
3
|
-
|
|
4
|
-
import UI from '@/ui/UI';
|
|
5
|
-
import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
|
|
6
|
-
import { Colors } from '@/components/constants';
|
|
7
|
-
import { objectWithout } from '@noeldemartin/utils';
|
|
8
|
-
|
|
9
|
-
export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
|
|
10
|
-
|
|
11
|
-
export const SnackbarColors = objectWithout(Colors, ['Primary', 'Clear']);
|
|
12
|
-
export const snackbarProps = {
|
|
13
|
-
id: requiredStringProp(),
|
|
14
|
-
message: requiredStringProp(),
|
|
15
|
-
actions: arrayProp<SnackbarAction>(() => []),
|
|
16
|
-
color: enumProp(SnackbarColors, Colors.Secondary),
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export interface SnackbarAction {
|
|
20
|
-
text: string;
|
|
21
|
-
dismiss?: boolean;
|
|
22
|
-
handler?(): unknown;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
|
|
26
|
-
export type AGSnackbarProps = ObjectWithoutEmpty<ExtractPropTypes<typeof snackbarProps>>;
|
|
27
|
-
|
|
28
|
-
export function useSnackbarProps(): typeof snackbarProps {
|
|
29
|
-
return snackbarProps;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
33
|
-
export function useSnackbar(props: ExtractPropTypes<typeof snackbarProps>) {
|
|
34
|
-
function activate(action: SnackbarAction): void {
|
|
35
|
-
action.handler?.();
|
|
36
|
-
action.dismiss && UI.hideSnackbar(props.id);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return { activate };
|
|
40
|
-
}
|
|
@@ -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,16 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGMarkdown :text="message" inline />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import { computed } from 'vue';
|
|
7
|
-
|
|
8
|
-
import { requiredObjectProp } from '@/utils/vue';
|
|
9
|
-
import { getErrorMessage } from '@/errors/utils';
|
|
10
|
-
import type { ErrorSource } from '@/errors/Errors.state';
|
|
11
|
-
|
|
12
|
-
import AGMarkdown from './AGMarkdown.vue';
|
|
13
|
-
|
|
14
|
-
const props = defineProps({ error: requiredObjectProp<ErrorSource>() });
|
|
15
|
-
const message = computed(() => getErrorMessage(props.error));
|
|
16
|
-
</script>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<root />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import { computed, h, useAttrs } from 'vue';
|
|
7
|
-
import { isInstanceOf } from '@noeldemartin/utils';
|
|
8
|
-
|
|
9
|
-
import { renderMarkdown } from '@/utils/markdown';
|
|
10
|
-
import { booleanProp, mixedProp, objectProp, stringProp } from '@/utils/vue';
|
|
11
|
-
import { translate } from '@/lang';
|
|
12
|
-
|
|
13
|
-
const props = defineProps({
|
|
14
|
-
as: stringProp(),
|
|
15
|
-
inline: booleanProp(),
|
|
16
|
-
langKey: stringProp(),
|
|
17
|
-
langParams: mixedProp<number | Record<string, unknown>>(),
|
|
18
|
-
text: stringProp(),
|
|
19
|
-
actions: objectProp<Record<string, () => unknown>>(),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const attrs = useAttrs();
|
|
23
|
-
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
|
|
24
|
-
const html = computed(() => {
|
|
25
|
-
if (!markdown.value) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let renderedHtml = renderMarkdown(markdown.value);
|
|
30
|
-
|
|
31
|
-
if (props.inline) {
|
|
32
|
-
renderedHtml = renderedHtml.replace('<p>', '<span>').replace('</p>', '</span>');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return renderedHtml;
|
|
36
|
-
});
|
|
37
|
-
const root = () =>
|
|
38
|
-
h(props.as ?? (props.inline ? 'span' : 'div'), {
|
|
39
|
-
innerHTML: html.value,
|
|
40
|
-
onClick,
|
|
41
|
-
...attrs,
|
|
42
|
-
class: `${attrs.class ?? ''} ${props.inline ? '' : 'prose'}`,
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
async function onClick(event: Event) {
|
|
46
|
-
const { target } = event;
|
|
47
|
-
|
|
48
|
-
if (isInstanceOf(target, HTMLElement) && target.dataset.markdownAction) {
|
|
49
|
-
props.actions?.[target.dataset.markdownAction]?.();
|
|
50
|
-
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
</script>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="as" v-measure="() => (measured = true)" :class="{ '!invisible !absolute !w-auto': !measured }">
|
|
3
|
-
<slot />
|
|
4
|
-
</component>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { ref } from 'vue';
|
|
9
|
-
|
|
10
|
-
import { stringProp } from '@/utils/vue';
|
|
11
|
-
|
|
12
|
-
defineProps({ as: stringProp('span') });
|
|
13
|
-
|
|
14
|
-
// TODO use v-measure.css
|
|
15
|
-
const measured = ref(false);
|
|
16
|
-
</script>
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="mt-1 h-2 w-full min-w-[min(400px,80vw)] overflow-hidden rounded-full bg-gray-200">
|
|
3
|
-
<div :class="barClasses" :style="`transform:translateX(-${(1 - renderedProgress) * 100}%)`" />
|
|
4
|
-
<span class="sr-only">
|
|
5
|
-
{{
|
|
6
|
-
$td('ui.progress', '{progress}% complete', {
|
|
7
|
-
progress: renderedProgress * 100,
|
|
8
|
-
})
|
|
9
|
-
}}
|
|
10
|
-
</span>
|
|
11
|
-
</div>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script setup lang="ts">
|
|
15
|
-
import { computed, onMounted, onUnmounted, ref } from 'vue';
|
|
16
|
-
|
|
17
|
-
import { numberProp, objectProp, stringProp } from '@/utils/vue';
|
|
18
|
-
import type { Job } from '@/jobs';
|
|
19
|
-
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
progress: numberProp(),
|
|
22
|
-
barClass: stringProp(''),
|
|
23
|
-
job: objectProp<Job>(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
let cleanup: Function | undefined;
|
|
27
|
-
const jobProgress = ref(0);
|
|
28
|
-
const barClasses = computed(() => {
|
|
29
|
-
const classes = props.barClass ?? '';
|
|
30
|
-
|
|
31
|
-
return `h-full w-full transition-transform duration-500 ease-linear ${
|
|
32
|
-
classes.includes('bg-') ? classes : `${classes} bg-gray-700`
|
|
33
|
-
}`;
|
|
34
|
-
});
|
|
35
|
-
const renderedProgress = computed(() => {
|
|
36
|
-
if (typeof props.progress === 'number') {
|
|
37
|
-
return props.progress;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return jobProgress.value;
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
onMounted(() => (cleanup = props.job?.listeners.add({ onUpdated: (progress) => (jobProgress.value = progress) })));
|
|
44
|
-
onUnmounted(() => cleanup?.());
|
|
45
|
-
</script>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { default as AGErrorMessage } from './AGErrorMessage.vue';
|
|
2
|
-
export { default as AGLink } from './AGLink.vue';
|
|
3
|
-
export { default as AGMarkdown } from './AGMarkdown.vue';
|
|
4
|
-
export { default as AGMeasured } from './AGMeasured.vue';
|
|
5
|
-
export { default as AGProgressBar } from './AGProgressBar.vue';
|
|
6
|
-
export { default as AGStartupCrash } from './AGStartupCrash.vue';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { ExtractPropTypes } from 'vue';
|
|
2
|
-
import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
|
|
3
|
-
|
|
4
|
-
import { requiredStringProp, stringProp } from '@/utils';
|
|
5
|
-
import type { AcceptRefs } from '@/utils';
|
|
6
|
-
|
|
7
|
-
export const alertModalProps = {
|
|
8
|
-
title: stringProp(),
|
|
9
|
-
message: requiredStringProp(),
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export type AGAlertModalProps = Pretty<
|
|
13
|
-
AcceptRefs<ObjectWithout<ExtractPropTypes<typeof alertModalProps>, null | undefined>>
|
|
14
|
-
>;
|
|
15
|
-
|
|
16
|
-
export function useAlertModalProps(): typeof alertModalProps {
|
|
17
|
-
return alertModalProps;
|
|
18
|
-
}
|
|
@@ -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>
|