@aerogel/core 0.0.0-next.f1f5a990033d966dc0bb12d251110fbc9350dcc7 → 0.0.0-next.f8c757d83e1e0d001a2836fa45aba318ec17b9b9
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 +2144 -1268
- package/dist/aerogel-core.js +3234 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +30 -37
- package/src/bootstrap/bootstrap.test.ts +4 -8
- package/src/bootstrap/index.ts +27 -14
- package/src/bootstrap/options.ts +4 -1
- package/src/components/{AGAppLayout.vue → AppLayout.vue} +4 -4
- package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
- package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +5 -10
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +4 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +41 -0
- package/src/components/contracts/DropdownMenu.ts +18 -0
- package/src/components/contracts/ErrorReportModal.ts +29 -0
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +18 -0
- package/src/components/contracts/Modal.ts +13 -0
- package/src/components/contracts/PromptModal.ts +30 -0
- package/src/components/contracts/Select.ts +44 -0
- package/src/components/contracts/Toast.ts +13 -0
- package/src/components/contracts/index.ts +9 -0
- package/src/components/contracts/shared.ts +9 -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/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
- package/src/components/headless/HeadlessInputTextArea.vue +40 -0
- package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +18 -18
- package/src/components/headless/HeadlessModalContent.vue +24 -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 +113 -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 +37 -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 -3
- package/src/components/index.ts +6 -9
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +13 -0
- package/src/components/ui/Button.vue +98 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +42 -0
- package/src/components/ui/DropdownMenu.vue +27 -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 +62 -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 +32 -0
- package/src/components/ui/Markdown.vue +69 -0
- package/src/components/ui/Modal.vue +75 -0
- package/src/components/ui/ModalContext.vue +30 -0
- package/src/components/ui/ProgressBar.vue +50 -0
- package/src/components/ui/PromptModal.vue +35 -0
- package/src/components/ui/Select.vue +25 -0
- package/src/components/ui/SelectLabel.vue +17 -0
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +30 -0
- package/src/components/ui/SelectTrigger.vue +29 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +8 -8
- package/src/components/ui/Toast.vue +42 -0
- package/src/components/ui/index.ts +30 -0
- package/src/directives/index.ts +11 -5
- package/src/directives/measure.ts +34 -6
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +29 -33
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +10 -16
- package/src/errors/utils.ts +35 -0
- package/src/forms/{Form.test.ts → FormController.test.ts} +33 -4
- package/src/forms/{Form.ts → FormController.ts} +86 -25
- package/src/forms/composition.ts +4 -4
- package/src/forms/index.ts +3 -1
- package/src/forms/utils.ts +36 -5
- package/src/forms/validation.ts +19 -0
- package/src/index.css +46 -0
- package/src/{main.ts → index.ts} +3 -0
- 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 +44 -29
- package/src/lang/index.ts +11 -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 +37 -5
- package/src/services/App.ts +35 -6
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +112 -32
- package/src/services/Service.ts +150 -49
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +17 -5
- package/src/services/store.ts +8 -5
- 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 +19 -7
- package/src/ui/UI.ts +218 -70
- package/src/ui/index.ts +19 -16
- package/src/ui/utils.ts +16 -0
- package/src/utils/classes.ts +49 -0
- package/src/utils/composition/events.ts +2 -2
- package/src/utils/composition/forms.ts +14 -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 +4 -1
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +19 -6
- package/src/utils/vue.ts +28 -127
- 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/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 -35
- package/src/components/forms/AGForm.vue +0 -26
- package/src/components/forms/AGInput.vue +0 -36
- package/src/components/forms/AGSelect.story.vue +0 -28
- package/src/components/forms/AGSelect.vue +0 -53
- 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 -28
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -57
- package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -45
- package/src/components/headless/forms/AGHeadlessSelect.ts +0 -39
- package/src/components/headless/forms/AGHeadlessSelect.vue +0 -76
- 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/index.ts +0 -14
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -34
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/headless/modals/index.ts +0 -4
- package/src/components/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 -36
- package/src/components/lib/AGMeasured.vue +0 -15
- 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/index.ts +0 -26
- 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/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
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessInput ref="$input" :name="name" class="flex">
|
|
3
|
-
<AGHeadlessInputInput
|
|
4
|
-
v-bind="$attrs"
|
|
5
|
-
type="checkbox"
|
|
6
|
-
:class="{
|
|
7
|
-
'text-indigo-600 focus:ring-indigo-600': !$input?.errors,
|
|
8
|
-
'border-red-200 text-red-600 focus:ring-red-600': $input?.errors,
|
|
9
|
-
}"
|
|
10
|
-
/>
|
|
11
|
-
|
|
12
|
-
<div class="ml-2">
|
|
13
|
-
<AGHeadlessInputLabel v-if="$slots.default">
|
|
14
|
-
<slot />
|
|
15
|
-
</AGHeadlessInputLabel>
|
|
16
|
-
<AGHeadlessInputError class="text-sm text-red-600" />
|
|
17
|
-
</div>
|
|
18
|
-
</AGHeadlessInput>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import { componentRef, stringProp } from '@/utils/vue';
|
|
23
|
-
|
|
24
|
-
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
25
|
-
|
|
26
|
-
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
27
|
-
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
28
|
-
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
29
|
-
import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
|
|
30
|
-
|
|
31
|
-
defineProps({ name: stringProp() });
|
|
32
|
-
defineOptions({ inheritAttrs: false });
|
|
33
|
-
|
|
34
|
-
const $input = componentRef<IAGHeadlessInput>();
|
|
35
|
-
</script>
|
|
@@ -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,36 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessInput
|
|
3
|
-
ref="$input"
|
|
4
|
-
class="relative flex flex-col items-center"
|
|
5
|
-
:class="className"
|
|
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
|
-
<div class="absolute bottom-0 left-0 translate-y-full">
|
|
16
|
-
<AGHeadlessInputError class="mt-1 text-sm text-red-500" />
|
|
17
|
-
</div>
|
|
18
|
-
</AGHeadlessInput>
|
|
19
|
-
</template>
|
|
20
|
-
|
|
21
|
-
<script setup lang="ts">
|
|
22
|
-
import { componentRef, stringProp } from '@/utils/vue';
|
|
23
|
-
|
|
24
|
-
import { useInputAttrs } from '@/utils';
|
|
25
|
-
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
26
|
-
|
|
27
|
-
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
28
|
-
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
29
|
-
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
30
|
-
|
|
31
|
-
defineProps({ name: stringProp() });
|
|
32
|
-
defineOptions({ inheritAttrs: false });
|
|
33
|
-
|
|
34
|
-
const $input = componentRef<IAGHeadlessInput>();
|
|
35
|
-
const [attrs, className] = useInputAttrs();
|
|
36
|
-
</script>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Story>
|
|
3
|
-
<div class="h-96">
|
|
4
|
-
<AGSelect v-model="bestMugiwara" :label="label" :options="options" />
|
|
5
|
-
</div>
|
|
6
|
-
</Story>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { ref } from 'vue';
|
|
11
|
-
|
|
12
|
-
import AGSelect from './AGSelect.vue';
|
|
13
|
-
|
|
14
|
-
const bestMugiwara = ref(null);
|
|
15
|
-
const label = 'Who\'s the best Mugiwara?';
|
|
16
|
-
const options = [
|
|
17
|
-
'Monkey D. Luffy',
|
|
18
|
-
'Roronoa Zoro',
|
|
19
|
-
'Nami',
|
|
20
|
-
'Usopp',
|
|
21
|
-
'Sanji',
|
|
22
|
-
'Tony Tony Chopper',
|
|
23
|
-
'Nico Robin',
|
|
24
|
-
'Franky',
|
|
25
|
-
'Brook',
|
|
26
|
-
'Jinbe',
|
|
27
|
-
];
|
|
28
|
-
</script>
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessSelect v-bind="props" ref="$select" as="div">
|
|
3
|
-
<AGHeadlessSelectLabel class="block text-sm font-medium leading-6 text-gray-900" />
|
|
4
|
-
<div class="relative" :class="{ 'mt-2': $select?.label }">
|
|
5
|
-
<AGHeadlessSelectButton
|
|
6
|
-
class="relative w-full cursor-default bg-white py-1.5 pl-3 pr-10 text-left text-gray-900 ring-1 ring-inset ring-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-600"
|
|
7
|
-
text-class="block truncate"
|
|
8
|
-
:class="{
|
|
9
|
-
'ring-1 ring-red-500': $select?.errors,
|
|
10
|
-
}"
|
|
11
|
-
>
|
|
12
|
-
<template #icon>
|
|
13
|
-
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
14
|
-
<IconCheveronDown class="h-5 w-5 text-gray-400" />
|
|
15
|
-
</span>
|
|
16
|
-
</template>
|
|
17
|
-
</AGHeadlessSelectButton>
|
|
18
|
-
<AGHeadlessSelectOptions
|
|
19
|
-
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border bg-white py-1 text-base ring-1 ring-black ring-opacity-5 focus:outline-none"
|
|
20
|
-
>
|
|
21
|
-
<AGHeadlessSelectOption
|
|
22
|
-
v-for="(option, index) in $select?.options ?? []"
|
|
23
|
-
:key="index"
|
|
24
|
-
:value="option.value"
|
|
25
|
-
class="relative block cursor-default select-none truncate py-2 pl-3 pr-9"
|
|
26
|
-
selected-class="font-semibold"
|
|
27
|
-
unselected-class="font-normal"
|
|
28
|
-
active-class="bg-indigo-600 text-white"
|
|
29
|
-
inactive-class="text-gray-900"
|
|
30
|
-
/>
|
|
31
|
-
</AGHeadlessSelectOptions>
|
|
32
|
-
</div>
|
|
33
|
-
<AGHeadlessSelectError class="mt-2 text-sm text-red-600" />
|
|
34
|
-
</AGHeadlessSelect>
|
|
35
|
-
</template>
|
|
36
|
-
|
|
37
|
-
<script setup lang="ts">
|
|
38
|
-
import IconCheveronDown from '~icons/zondicons/cheveron-down';
|
|
39
|
-
|
|
40
|
-
import { componentRef } from '@/utils/vue';
|
|
41
|
-
import { useSelectProps } from '@/components/headless/forms/AGHeadlessSelect';
|
|
42
|
-
import type { IAGHeadlessSelect } from '@/components/headless/forms/AGHeadlessSelect';
|
|
43
|
-
|
|
44
|
-
import AGHeadlessSelect from '../headless/forms/AGHeadlessSelect.vue';
|
|
45
|
-
import AGHeadlessSelectButton from '../headless/forms/AGHeadlessSelectButton.vue';
|
|
46
|
-
import AGHeadlessSelectError from '../headless/forms/AGHeadlessSelectError.vue';
|
|
47
|
-
import AGHeadlessSelectLabel from '../headless/forms/AGHeadlessSelectLabel.vue';
|
|
48
|
-
import AGHeadlessSelectOption from '../headless/forms/AGHeadlessSelectOption.vue';
|
|
49
|
-
import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions';
|
|
50
|
-
|
|
51
|
-
const props = defineProps(useSelectProps());
|
|
52
|
-
const $select = componentRef<IAGHeadlessSelect>();
|
|
53
|
-
</script>
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { default as AGButton } from './AGButton.vue';
|
|
2
|
-
export { default as AGCheckbox } from './AGCheckbox.vue';
|
|
3
|
-
export { default as AGForm } from './AGForm.vue';
|
|
4
|
-
export { default as AGInput } from './AGInput.vue';
|
|
5
|
-
export { default as AGSelect } from './AGSelect.vue';
|
|
@@ -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
|
-
|
|
11
|
-
import { booleanProp, objectProp, stringProp } from '@/utils/vue';
|
|
12
|
-
|
|
13
|
-
const { href, url, route, routeParams, routeQuery, submit } = defineProps({
|
|
14
|
-
href: stringProp(),
|
|
15
|
-
url: stringProp(),
|
|
16
|
-
route: stringProp(),
|
|
17
|
-
routeParams: objectProp(() => ({})),
|
|
18
|
-
routeQuery: objectProp(() => ({})),
|
|
19
|
-
submit: booleanProp(),
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const component = computed(() => {
|
|
23
|
-
if (route) {
|
|
24
|
-
return {
|
|
25
|
-
tag: 'router-link',
|
|
26
|
-
props: {
|
|
27
|
-
to: objectWithoutEmpty({
|
|
28
|
-
name: route,
|
|
29
|
-
params: routeParams,
|
|
30
|
-
query: routeQuery,
|
|
31
|
-
}),
|
|
32
|
-
},
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (href || url) {
|
|
37
|
-
return {
|
|
38
|
-
tag: 'a',
|
|
39
|
-
props: {
|
|
40
|
-
target: '_blank',
|
|
41
|
-
href: href || url,
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return {
|
|
47
|
-
tag: 'button',
|
|
48
|
-
props: { type: submit ? 'submit' : 'button' },
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
</script>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
import { stringProp } from '@/utils';
|
|
4
|
-
import { extractComponentProps } from '@/components/utils';
|
|
5
|
-
|
|
6
|
-
export interface IAGHeadlessInput {
|
|
7
|
-
id: string;
|
|
8
|
-
name: ComputedRef<string | null>;
|
|
9
|
-
label: ComputedRef<string | null>;
|
|
10
|
-
value: ComputedRef<string | number | boolean | null>;
|
|
11
|
-
errors: DeepReadonly<Ref<string[] | null>>;
|
|
12
|
-
update(value: string | number | boolean | null): void;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const inputProps = {
|
|
16
|
-
name: stringProp(),
|
|
17
|
-
label: stringProp(),
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function useInputProps(): typeof inputProps {
|
|
21
|
-
return inputProps;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
|
|
25
|
-
props: T,
|
|
26
|
-
): Pick<T, keyof typeof inputProps> {
|
|
27
|
-
return extractComponentProps(props, inputProps);
|
|
28
|
-
}
|
|
@@ -1,57 +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 { mixedProp, stringProp } from '@/utils/vue';
|
|
13
|
-
import type Form from '@/forms/Form';
|
|
14
|
-
|
|
15
|
-
import { useInputProps } from './AGHeadlessInput';
|
|
16
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
17
|
-
|
|
18
|
-
const emit = defineEmits(['update:modelValue']);
|
|
19
|
-
const props = defineProps({
|
|
20
|
-
as: stringProp('div'),
|
|
21
|
-
modelValue: mixedProp<string | number | boolean>([String, Number, Boolean]),
|
|
22
|
-
...useInputProps(),
|
|
23
|
-
});
|
|
24
|
-
const errors = computed(() => {
|
|
25
|
-
if (!form || !props.name) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return form.errors[props.name] ?? null;
|
|
30
|
-
});
|
|
31
|
-
const form = inject<Form | null>('form', null);
|
|
32
|
-
const api: IAGHeadlessInput = {
|
|
33
|
-
id: `input-${uuid()}`,
|
|
34
|
-
name: computed(() => props.name),
|
|
35
|
-
label: computed(() => props.label),
|
|
36
|
-
value: computed(() => {
|
|
37
|
-
if (form && props.name) {
|
|
38
|
-
return form.getFieldValue(props.name) as string | number | boolean | null;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return props.modelValue;
|
|
42
|
-
}),
|
|
43
|
-
errors: readonly(errors),
|
|
44
|
-
update(value) {
|
|
45
|
-
if (form && props.name) {
|
|
46
|
-
form.setFieldValue(props.name, value);
|
|
47
|
-
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
emit('update:modelValue', value);
|
|
52
|
-
},
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
provide<IAGHeadlessInput>('input', api);
|
|
56
|
-
defineExpose<IAGHeadlessInput>(api);
|
|
57
|
-
</script>
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<input
|
|
3
|
-
:id="input.id"
|
|
4
|
-
ref="$input"
|
|
5
|
-
:type="type"
|
|
6
|
-
:value="value"
|
|
7
|
-
:aria-invalid="input.errors ? 'true' : 'false'"
|
|
8
|
-
:aria-describedby="input.errors ? `${input.id}-error` : undefined"
|
|
9
|
-
:checked="checked"
|
|
10
|
-
@input="update"
|
|
11
|
-
>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script setup lang="ts">
|
|
15
|
-
import { computed, ref } from 'vue';
|
|
16
|
-
|
|
17
|
-
import { injectReactiveOrFail, stringProp } from '@/utils';
|
|
18
|
-
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
19
|
-
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
type: stringProp('text'),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
const $input = ref<HTMLInputElement>();
|
|
25
|
-
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
26
|
-
'input',
|
|
27
|
-
'<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>',
|
|
28
|
-
);
|
|
29
|
-
const value = computed(() => input.value);
|
|
30
|
-
const checked = computed(() => {
|
|
31
|
-
if (props.type !== 'checkbox') {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return !!value.value;
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
function update() {
|
|
39
|
-
if (!$input.value) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
input.update(props.type === 'checkbox' ? $input.value.checked : $input.value.value);
|
|
44
|
-
}
|
|
45
|
-
</script>
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
|
-
|
|
3
|
-
import { requiredArrayProp, stringProp } from '@/utils/vue';
|
|
4
|
-
import { extractComponentProps } from '@/components/utils';
|
|
5
|
-
|
|
6
|
-
export interface IAGSelectOption {
|
|
7
|
-
value: string | number | boolean | object | null;
|
|
8
|
-
text: string;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type IAGSelectOptionValue = string | number | boolean | object | null;
|
|
12
|
-
|
|
13
|
-
export interface IAGHeadlessSelect {
|
|
14
|
-
id: string;
|
|
15
|
-
label: ComputedRef<string | null>;
|
|
16
|
-
noSelectionText: ComputedRef<string>;
|
|
17
|
-
buttonText: ComputedRef<string>;
|
|
18
|
-
selectedOption: ComputedRef<IAGSelectOption | undefined>;
|
|
19
|
-
options: ComputedRef<IAGSelectOption[]>;
|
|
20
|
-
errors: DeepReadonly<Ref<string[] | null>>;
|
|
21
|
-
update(value: IAGSelectOptionValue): void;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const selectProps = {
|
|
25
|
-
name: stringProp(),
|
|
26
|
-
label: stringProp(),
|
|
27
|
-
options: requiredArrayProp<IAGSelectOptionValue>(),
|
|
28
|
-
noSelectionText: stringProp(),
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export function useSelectProps(): typeof selectProps {
|
|
32
|
-
return selectProps;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function extractSelectProps<T extends ExtractPropTypes<typeof selectProps>>(
|
|
36
|
-
props: T,
|
|
37
|
-
): Pick<T, keyof typeof selectProps> {
|
|
38
|
-
return extractComponentProps(props, selectProps);
|
|
39
|
-
}
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<Listbox
|
|
3
|
-
v-slot="{ value, open, disabled }: ComponentProps"
|
|
4
|
-
:model-value="selectedOption?.value"
|
|
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 { isObject, 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 { ComponentProps } from '@/utils/vue';
|
|
20
|
-
|
|
21
|
-
import { useSelectProps } from './AGHeadlessSelect';
|
|
22
|
-
import type { IAGHeadlessSelect, IAGSelectOption, IAGSelectOptionValue } from './AGHeadlessSelect';
|
|
23
|
-
|
|
24
|
-
const emit = defineEmits(['update:modelValue']);
|
|
25
|
-
const props = defineProps({
|
|
26
|
-
modelValue: mixedProp<IAGSelectOptionValue>(),
|
|
27
|
-
...useSelectProps(),
|
|
28
|
-
});
|
|
29
|
-
const form = inject<Form | null>('form', null);
|
|
30
|
-
const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
|
|
31
|
-
const options = computed(() =>
|
|
32
|
-
props.options.map((value) => {
|
|
33
|
-
const option: IAGSelectOption = {
|
|
34
|
-
value,
|
|
35
|
-
text: toString(isObject(value) && 'text' in value ? value.text : value),
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
return option;
|
|
39
|
-
}));
|
|
40
|
-
const selectedOption = computed(() => {
|
|
41
|
-
const selectedOptionValue = form && props.name ? form.getFieldValue(props.name) : props.modelValue;
|
|
42
|
-
|
|
43
|
-
return options.value.find((option) => option.value === selectedOptionValue);
|
|
44
|
-
});
|
|
45
|
-
const errors = computed(() => {
|
|
46
|
-
if (!form || !props.name) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return form.errors[props.name] ?? null;
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
function update(value: IAGSelectOptionValue) {
|
|
54
|
-
if (form && props.name) {
|
|
55
|
-
form.setFieldValue(props.name, value);
|
|
56
|
-
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
emit('update:modelValue', value);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const api: IAGHeadlessSelect = {
|
|
64
|
-
id: `select-${uuid()}`,
|
|
65
|
-
options,
|
|
66
|
-
noSelectionText,
|
|
67
|
-
selectedOption,
|
|
68
|
-
errors,
|
|
69
|
-
label: computed(() => props.label),
|
|
70
|
-
buttonText: computed(() => selectedOption.value?.text ?? noSelectionText.value),
|
|
71
|
-
update,
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
provide<IAGHeadlessSelect>('select', api);
|
|
75
|
-
defineExpose<IAGHeadlessSelect>(api);
|
|
76
|
-
</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
|
-
{{ option?.text }}
|
|
13
|
-
</li>
|
|
14
|
-
</slot>
|
|
15
|
-
</ListboxOption>
|
|
16
|
-
</template>
|
|
17
|
-
|
|
18
|
-
<script setup lang="ts">
|
|
19
|
-
import { computed } from 'vue';
|
|
20
|
-
import { ListboxOption } from '@headlessui/vue';
|
|
21
|
-
|
|
22
|
-
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@/utils/vue';
|
|
23
|
-
import type { ComponentProps } from '@/utils/vue';
|
|
24
|
-
|
|
25
|
-
import type { IAGHeadlessSelect, IAGSelectOptionValue } from './AGHeadlessSelect';
|
|
26
|
-
|
|
27
|
-
const props = defineProps({
|
|
28
|
-
value: requiredMixedProp<IAGSelectOptionValue>(),
|
|
29
|
-
selectedClass: stringProp(),
|
|
30
|
-
unselectedClass: stringProp(),
|
|
31
|
-
activeClass: stringProp(),
|
|
32
|
-
inactiveClass: stringProp(),
|
|
33
|
-
});
|
|
34
|
-
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
35
|
-
'select',
|
|
36
|
-
'<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>',
|
|
37
|
-
);
|
|
38
|
-
const option = computed(() => select.options.find((selectOption) => selectOption.value === props.value));
|
|
39
|
-
</script>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export * from './AGHeadlessInput';
|
|
2
|
-
export * from './AGHeadlessSelect';
|
|
3
|
-
export * from './AGHeadlessSelectOption';
|
|
4
|
-
export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
|
|
5
|
-
export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
|
|
6
|
-
export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
|
|
7
|
-
export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
|
|
8
|
-
export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
|
|
9
|
-
export { default as AGHeadlessSelect } from './AGHeadlessSelect.vue';
|
|
10
|
-
export { default as AGHeadlessSelectButton } from './AGHeadlessSelectButton.vue';
|
|
11
|
-
export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
|
|
12
|
-
export { default as AGHeadlessSelectLabel } from './AGHeadlessSelectLabel.vue';
|
|
13
|
-
export { default as AGHeadlessSelectOption } from './AGHeadlessSelectOption.vue';
|
|
14
|
-
export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
2
|
-
import type { ExtractPropTypes, Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
import { booleanProp, stringProp } from '@/utils';
|
|
5
|
-
import { extractComponentProps } from '@/components/utils';
|
|
6
|
-
import type { IAGModal } from '@/components/modals/AGModal';
|
|
7
|
-
|
|
8
|
-
export interface IAGHeadlessModal extends IAGModal {}
|
|
9
|
-
|
|
10
|
-
export interface IAGHeadlessModalDefaultSlotProps {
|
|
11
|
-
close(result?: unknown): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export const modalProps = {
|
|
15
|
-
cancellable: booleanProp(true),
|
|
16
|
-
title: stringProp(),
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function useModalProps(): typeof modalProps {
|
|
20
|
-
return modalProps;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function extractModalProps<T extends ExtractPropTypes<typeof modalProps>>(
|
|
24
|
-
props: T,
|
|
25
|
-
): Pick<T, keyof typeof modalProps> {
|
|
26
|
-
return extractComponentProps(props, modalProps);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function useModalExpose($modal: Ref<IAGHeadlessModal | undefined>): IAGModal {
|
|
30
|
-
return {
|
|
31
|
-
close: async () => $modal.value?.close(),
|
|
32
|
-
cancellable: computed(() => !!$modal.value?.cancellable),
|
|
33
|
-
};
|
|
34
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DialogPanel>
|
|
3
|
-
<slot />
|
|
4
|
-
|
|
5
|
-
<template v-if="childModal">
|
|
6
|
-
<div class="pointer-events-none fixed inset-0 z-50 bg-black/30" />
|
|
7
|
-
<AGModalContext :child-index="modal.childIndex + 1" :modal="childModal" />
|
|
8
|
-
</template>
|
|
9
|
-
</DialogPanel>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup lang="ts">
|
|
13
|
-
import { computed } from 'vue';
|
|
14
|
-
import { DialogPanel } from '@headlessui/vue';
|
|
15
|
-
|
|
16
|
-
import UI from '@/ui/UI';
|
|
17
|
-
import { injectReactiveOrFail } from '@/utils/vue';
|
|
18
|
-
import type { IAGModalContext } from '@/components/modals/AGModalContext';
|
|
19
|
-
|
|
20
|
-
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
21
|
-
|
|
22
|
-
const modal = injectReactiveOrFail<IAGModalContext>(
|
|
23
|
-
'modal',
|
|
24
|
-
'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
|
|
25
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
26
|
-
);
|
|
27
|
-
const childModal = computed(() => UI.modals[modal.childIndex] ?? null);
|
|
28
|
-
</script>
|