@aerogel/core 0.0.0-next.c8f032a868370824898e171969aec1bb6827688e → 0.0.0-next.d34923f3b144e8f6720e6a9cdadb2cd4fb4ab289
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.cjs.js +1 -1
- package/dist/aerogel-core.cjs.js.map +1 -1
- package/dist/aerogel-core.d.ts +1720 -243
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/histoire.config.ts +7 -0
- package/noeldemartin.config.js +4 -1
- package/package.json +14 -4
- package/postcss.config.js +6 -0
- package/src/assets/histoire.css +3 -0
- package/src/bootstrap/bootstrap.test.ts +4 -3
- package/src/bootstrap/index.ts +27 -4
- package/src/bootstrap/options.ts +3 -0
- package/src/components/AGAppLayout.vue +7 -2
- package/src/components/AGAppModals.vue +15 -0
- package/src/components/AGAppOverlays.vue +10 -8
- package/src/components/AGAppSnackbars.vue +13 -0
- package/src/components/constants.ts +8 -0
- package/src/components/forms/AGButton.vue +33 -10
- package/src/components/forms/AGCheckbox.vue +41 -0
- package/src/components/forms/AGForm.vue +9 -10
- package/src/components/forms/AGInput.vue +17 -9
- package/src/components/forms/AGSelect.story.vue +46 -0
- package/src/components/forms/AGSelect.vue +60 -0
- package/src/components/forms/index.ts +5 -5
- package/src/components/headless/forms/AGHeadlessButton.vue +21 -16
- package/src/components/headless/forms/AGHeadlessInput.ts +29 -4
- package/src/components/headless/forms/AGHeadlessInput.vue +17 -7
- package/src/components/headless/forms/AGHeadlessInputDescription.vue +28 -0
- package/src/components/headless/forms/AGHeadlessInputError.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInputInput.vue +56 -6
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
- package/src/components/headless/forms/AGHeadlessInputTextArea.vue +42 -0
- package/src/components/headless/forms/AGHeadlessSelect.ts +42 -0
- package/src/components/headless/forms/AGHeadlessSelect.vue +77 -0
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectError.vue +26 -0
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +4 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +39 -0
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +3 -0
- package/src/components/headless/forms/composition.ts +10 -0
- package/src/components/headless/forms/index.ts +12 -1
- package/src/components/headless/index.ts +1 -0
- package/src/components/headless/modals/AGHeadlessModal.ts +27 -0
- package/src/components/headless/modals/AGHeadlessModal.vue +3 -5
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +5 -1
- package/src/components/headless/modals/index.ts +4 -6
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
- package/src/components/headless/snackbars/index.ts +40 -0
- package/src/components/index.ts +4 -1
- package/src/components/interfaces.ts +9 -0
- package/src/components/lib/AGErrorMessage.vue +16 -0
- package/src/components/lib/AGLink.vue +9 -0
- package/src/components/lib/AGMarkdown.vue +41 -0
- package/src/components/lib/AGMeasured.vue +15 -0
- package/src/components/lib/AGStartupCrash.vue +31 -0
- package/src/components/lib/index.ts +5 -0
- package/src/components/modals/AGAlertModal.ts +15 -0
- package/src/components/modals/AGAlertModal.vue +4 -16
- package/src/components/modals/AGConfirmModal.ts +33 -0
- package/src/components/modals/AGConfirmModal.vue +9 -13
- package/src/components/modals/AGErrorReportModal.ts +46 -0
- package/src/components/modals/AGErrorReportModal.vue +54 -0
- package/src/components/modals/AGErrorReportModalButtons.vue +111 -0
- package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
- package/src/components/modals/AGLoadingModal.ts +23 -0
- package/src/components/modals/AGLoadingModal.vue +15 -0
- package/src/components/modals/AGModal.ts +1 -1
- package/src/components/modals/AGModal.vue +26 -5
- package/src/components/modals/AGModalTitle.vue +9 -0
- package/src/components/modals/AGPromptModal.ts +36 -0
- package/src/components/modals/AGPromptModal.vue +34 -0
- package/src/components/modals/index.ts +16 -6
- package/src/components/snackbars/AGSnackbar.vue +36 -0
- package/src/components/snackbars/index.ts +3 -0
- package/src/components/utils.ts +10 -0
- package/src/directives/index.ts +20 -3
- package/src/directives/measure.ts +21 -0
- package/src/errors/Errors.state.ts +31 -0
- package/src/errors/Errors.ts +185 -0
- package/src/errors/index.ts +46 -0
- package/src/errors/utils.ts +19 -0
- package/src/forms/Form.test.ts +21 -0
- package/src/forms/Form.ts +76 -18
- package/src/forms/index.ts +1 -0
- package/src/forms/utils.ts +32 -0
- package/src/jobs/Job.ts +5 -0
- package/src/jobs/index.ts +7 -0
- package/src/lang/Lang.ts +14 -14
- package/src/lang/index.ts +3 -5
- package/src/lang/utils.ts +4 -0
- package/src/main.histoire.ts +1 -0
- package/src/main.ts +4 -2
- package/src/plugins/Plugin.ts +1 -0
- package/src/plugins/index.ts +19 -0
- package/src/services/App.state.ts +23 -2
- package/src/services/App.ts +46 -3
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +100 -30
- package/src/services/Service.ts +174 -53
- package/src/services/index.ts +25 -5
- package/src/services/store.ts +30 -0
- package/src/testing/index.ts +25 -0
- package/src/ui/UI.state.ts +11 -1
- package/src/ui/UI.ts +177 -20
- package/src/ui/index.ts +15 -4
- package/src/utils/composition/events.ts +1 -0
- package/src/utils/composition/forms.ts +11 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/markdown.ts +11 -2
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +15 -4
- package/tailwind.config.js +4 -0
- package/tsconfig.json +1 -0
- package/vite.config.ts +2 -1
- package/.eslintrc.js +0 -3
- package/src/components/basic/AGMarkdown.vue +0 -35
- package/src/components/basic/index.ts +0 -3
- package/src/globals.ts +0 -6
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div class="flex h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
|
|
3
|
-
<slot
|
|
2
|
+
<div class="flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
|
|
3
|
+
<slot v-if="$errors.hasStartupErrors" name="startup-crash">
|
|
4
|
+
<component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
|
|
5
|
+
</slot>
|
|
6
|
+
<slot v-else />
|
|
4
7
|
|
|
5
8
|
<AGAppOverlays />
|
|
6
9
|
</div>
|
|
7
10
|
</template>
|
|
8
11
|
|
|
9
12
|
<script setup lang="ts">
|
|
13
|
+
import { UIComponents } from '@/ui/UI';
|
|
14
|
+
|
|
10
15
|
import AGAppOverlays from './AGAppOverlays.vue';
|
|
11
16
|
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<aside v-if="modal">
|
|
3
|
+
<AGModalContext :child-index="1" :modal="modal" />
|
|
4
|
+
</aside>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
|
|
10
|
+
import UI from '@/ui/UI';
|
|
11
|
+
|
|
12
|
+
import AGModalContext from './modals/AGModalContext.vue';
|
|
13
|
+
|
|
14
|
+
const modal = computed(() => UI.modals[0] ?? null);
|
|
15
|
+
</script>
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
<div
|
|
3
|
+
id="aerogel-overlays-backdrop"
|
|
4
|
+
ref="$backdrop"
|
|
5
|
+
class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
|
|
6
|
+
/>
|
|
7
|
+
<AGAppModals />
|
|
8
|
+
<AGAppSnackbars />
|
|
6
9
|
</template>
|
|
7
10
|
|
|
8
11
|
<script setup lang="ts">
|
|
9
|
-
import {
|
|
12
|
+
import { ref } from 'vue';
|
|
10
13
|
|
|
11
|
-
import UI from '@/ui/UI';
|
|
12
14
|
import { useEvent } from '@/utils/composition/events';
|
|
13
15
|
|
|
14
|
-
import
|
|
16
|
+
import AGAppModals from './AGAppModals.vue';
|
|
17
|
+
import AGAppSnackbars from './AGAppSnackbars.vue';
|
|
15
18
|
|
|
16
19
|
const $backdrop = ref<HTMLElement | null>(null);
|
|
17
20
|
const backdropHidden = ref(true);
|
|
18
|
-
const modal = computed(() => UI.modals[0] ?? null);
|
|
19
21
|
|
|
20
22
|
useEvent('show-overlays-backdrop', async () => {
|
|
21
23
|
if (!$backdrop.value || !backdropHidden.value) {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div aria-live="assertive" class="pointer-events-none fixed inset-0 z-50 flex items-end px-4 py-6 sm:p-6">
|
|
3
|
+
<div class="flex w-full flex-col items-end space-y-4">
|
|
4
|
+
<component
|
|
5
|
+
:is="snackbar.component"
|
|
6
|
+
v-for="snackbar of $ui.snackbars"
|
|
7
|
+
:id="snackbar.id"
|
|
8
|
+
:key="snackbar.id"
|
|
9
|
+
v-bind="snackbar.properties"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
@@ -1,21 +1,44 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGHeadlessButton
|
|
3
|
-
class="px-2.5 py-1.5 text-white focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2"
|
|
4
|
-
:class="{
|
|
5
|
-
'bg-indigo-600 hover:bg-indigo-500 focus-visible:outline-indigo-600': !secondary,
|
|
6
|
-
'bg-gray-600 hover:bg-gray-500 focus-visible:outline-gray-600': secondary,
|
|
7
|
-
}"
|
|
8
|
-
>
|
|
2
|
+
<AGHeadlessButton class="px-2.5 py-1.5 focus-visible:outline focus-visible:outline-2" :class="colorClasses">
|
|
9
3
|
<slot />
|
|
10
4
|
</AGHeadlessButton>
|
|
11
5
|
</template>
|
|
12
6
|
|
|
13
7
|
<script setup lang="ts">
|
|
14
|
-
import {
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
|
|
10
|
+
import { enumProp } from '@/utils/vue';
|
|
11
|
+
import { Colors } from '@/components/constants';
|
|
15
12
|
|
|
16
13
|
import AGHeadlessButton from '../headless/forms/AGHeadlessButton.vue';
|
|
17
14
|
|
|
18
|
-
defineProps({
|
|
19
|
-
|
|
15
|
+
const props = defineProps({
|
|
16
|
+
color: enumProp(Colors, Colors.Primary),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const colorClasses = computed(() => {
|
|
20
|
+
switch (props.color) {
|
|
21
|
+
case Colors.Secondary:
|
|
22
|
+
return [
|
|
23
|
+
'text-white bg-gray-600',
|
|
24
|
+
'hover:bg-gray-500',
|
|
25
|
+
'focus-visible:outline-offset-2 focus-visible:outline-gray-600',
|
|
26
|
+
].join(' ');
|
|
27
|
+
case Colors.Clear:
|
|
28
|
+
return 'hover:bg-gray-500/20 focus-visible:outline-gray-500/60';
|
|
29
|
+
case Colors.Danger:
|
|
30
|
+
return [
|
|
31
|
+
'text-white bg-red-600',
|
|
32
|
+
'hover:bg-red-500',
|
|
33
|
+
'focus-visible:outline-offset-2 focus-visible:outline-red-600',
|
|
34
|
+
].join(' ');
|
|
35
|
+
case Colors.Primary:
|
|
36
|
+
default:
|
|
37
|
+
return [
|
|
38
|
+
'text-white bg-indigo-600',
|
|
39
|
+
'hover:bg-indigo-500',
|
|
40
|
+
'focus-visible:outline-offset-2 focus-visible:outline-indigo-600',
|
|
41
|
+
].join(' ');
|
|
42
|
+
}
|
|
20
43
|
});
|
|
21
44
|
</script>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGHeadlessInput
|
|
3
|
+
ref="$input"
|
|
4
|
+
:name="name"
|
|
5
|
+
class="flex"
|
|
6
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
7
|
+
>
|
|
8
|
+
<AGHeadlessInputInput
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
type="checkbox"
|
|
11
|
+
:class="{
|
|
12
|
+
'text-indigo-600 focus:ring-indigo-600': !$input?.errors,
|
|
13
|
+
'border-red-200 text-red-600 focus:ring-red-600': $input?.errors,
|
|
14
|
+
}"
|
|
15
|
+
/>
|
|
16
|
+
|
|
17
|
+
<div class="ml-2">
|
|
18
|
+
<AGHeadlessInputLabel v-if="$slots.default">
|
|
19
|
+
<slot />
|
|
20
|
+
</AGHeadlessInputLabel>
|
|
21
|
+
<AGHeadlessInputError class="text-sm text-red-600" />
|
|
22
|
+
</div>
|
|
23
|
+
</AGHeadlessInput>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { componentRef, stringProp } from '@/utils/vue';
|
|
28
|
+
|
|
29
|
+
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
30
|
+
|
|
31
|
+
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
32
|
+
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
33
|
+
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
34
|
+
import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
|
|
35
|
+
|
|
36
|
+
defineProps({ name: stringProp() });
|
|
37
|
+
defineOptions({ inheritAttrs: false });
|
|
38
|
+
defineEmits(['update:modelValue']);
|
|
39
|
+
|
|
40
|
+
const $input = componentRef<IAGHeadlessInput>();
|
|
41
|
+
</script>
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<form @submit.prevent="submit">
|
|
2
|
+
<form @submit.prevent="form?.submit()">
|
|
3
3
|
<slot />
|
|
4
4
|
</form>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import { provide } from 'vue';
|
|
8
|
+
import { provide, watchEffect } from 'vue';
|
|
9
9
|
|
|
10
10
|
import { objectProp } from '@/utils/vue';
|
|
11
11
|
import type Form from '@/forms/Form';
|
|
12
12
|
|
|
13
|
+
let offSubmit: (() => void) | undefined;
|
|
13
14
|
const props = defineProps({ form: objectProp<Form>() });
|
|
14
|
-
|
|
15
15
|
const emit = defineEmits<{ submit: [] }>();
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
watchEffect((onCleanup) => {
|
|
18
|
+
offSubmit?.();
|
|
19
|
+
offSubmit = props.form?.on('submit', () => emit('submit'));
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
21
|
+
onCleanup(() => offSubmit?.());
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
provide('form', props.form);
|
|
26
25
|
</script>
|
|
@@ -1,32 +1,40 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<AGHeadlessInput
|
|
3
3
|
ref="$input"
|
|
4
|
-
|
|
5
|
-
class="
|
|
6
|
-
|
|
4
|
+
class="relative flex flex-col items-center"
|
|
5
|
+
:class="className"
|
|
6
|
+
v-bind="props"
|
|
7
7
|
>
|
|
8
|
+
<AGHeadlessInputLabel class="sr-only" />
|
|
8
9
|
<AGHeadlessInputInput
|
|
9
|
-
v-bind="
|
|
10
|
+
v-bind="attrs"
|
|
10
11
|
class="block w-full border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600"
|
|
11
12
|
:class="{
|
|
12
13
|
'ring-1 ring-red-500': $input?.errors,
|
|
13
14
|
}"
|
|
14
15
|
/>
|
|
15
|
-
<
|
|
16
|
+
<AGHeadlessInputDescription />
|
|
17
|
+
<div class="absolute bottom-0 left-0 translate-y-full">
|
|
18
|
+
<AGHeadlessInputError class="mt-1 text-sm text-red-500" />
|
|
19
|
+
</div>
|
|
16
20
|
</AGHeadlessInput>
|
|
17
21
|
</template>
|
|
18
22
|
|
|
19
23
|
<script setup lang="ts">
|
|
20
|
-
import { componentRef
|
|
21
|
-
|
|
24
|
+
import { componentRef } from '@/utils/vue';
|
|
25
|
+
import { useInputAttrs } from '@/utils/composition/forms';
|
|
26
|
+
import { useInputProps } from '@/components/headless/forms/AGHeadlessInput';
|
|
22
27
|
import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
|
|
23
28
|
|
|
24
29
|
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
25
|
-
import
|
|
30
|
+
import AGHeadlessInputDescription from '../headless/forms/AGHeadlessInputDescription.vue';
|
|
26
31
|
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
32
|
+
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
33
|
+
import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
|
|
27
34
|
|
|
28
|
-
defineProps({ name: stringProp() });
|
|
29
35
|
defineOptions({ inheritAttrs: false });
|
|
30
36
|
|
|
37
|
+
const props = defineProps(useInputProps());
|
|
31
38
|
const $input = componentRef<IAGHeadlessInput>();
|
|
39
|
+
const [attrs, className] = useInputAttrs();
|
|
32
40
|
</script>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Story>
|
|
3
|
+
<div class="h-96">
|
|
4
|
+
<AGSelect v-model="bestMugiwara" :label="bestMugiwaraLabel" :options="bestMugiwaraOptions" />
|
|
5
|
+
<AGSelect
|
|
6
|
+
v-model="bestFood"
|
|
7
|
+
:label="bestFoodLabel"
|
|
8
|
+
:options="bestFoodOptions"
|
|
9
|
+
options-text="name"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
</Story>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
import { ref } from 'vue';
|
|
17
|
+
|
|
18
|
+
import AGSelect from './AGSelect.vue';
|
|
19
|
+
|
|
20
|
+
const bestMugiwara = ref(null);
|
|
21
|
+
const bestFood = ref(null);
|
|
22
|
+
const bestMugiwaraLabel = 'Who\'s the best Mugiwara?';
|
|
23
|
+
const bestFoodLabel = 'What\'s the best food?';
|
|
24
|
+
const bestMugiwaraOptions = [
|
|
25
|
+
'Monkey D. Luffy',
|
|
26
|
+
'Roronoa Zoro',
|
|
27
|
+
'Nami',
|
|
28
|
+
'Usopp',
|
|
29
|
+
'Sanji',
|
|
30
|
+
'Tony Tony Chopper',
|
|
31
|
+
'Nico Robin',
|
|
32
|
+
'Franky',
|
|
33
|
+
'Brook',
|
|
34
|
+
'Jinbe',
|
|
35
|
+
];
|
|
36
|
+
const bestFoodOptions = [
|
|
37
|
+
{
|
|
38
|
+
id: 'ramen',
|
|
39
|
+
name: 'Ramen',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'pizza',
|
|
43
|
+
name: 'Pizza',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
46
|
+
</script>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<AGHeadlessSelect
|
|
3
|
+
v-bind="props"
|
|
4
|
+
ref="$select"
|
|
5
|
+
as="div"
|
|
6
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
7
|
+
>
|
|
8
|
+
<AGHeadlessSelectLabel class="block text-sm font-medium leading-6 text-gray-900" />
|
|
9
|
+
<div class="relative" :class="{ 'mt-2': $select?.label }">
|
|
10
|
+
<AGHeadlessSelectButton
|
|
11
|
+
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"
|
|
12
|
+
text-class="block truncate"
|
|
13
|
+
:class="{
|
|
14
|
+
'ring-1 ring-red-500': $select?.errors,
|
|
15
|
+
}"
|
|
16
|
+
>
|
|
17
|
+
<template #icon>
|
|
18
|
+
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
19
|
+
<IconCheveronDown class="h-5 w-5 text-gray-400" />
|
|
20
|
+
</span>
|
|
21
|
+
</template>
|
|
22
|
+
</AGHeadlessSelectButton>
|
|
23
|
+
<AGHeadlessSelectOptions
|
|
24
|
+
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"
|
|
25
|
+
>
|
|
26
|
+
<AGHeadlessSelectOption
|
|
27
|
+
v-for="(option, index) in $select?.options ?? []"
|
|
28
|
+
:key="index"
|
|
29
|
+
:value="option"
|
|
30
|
+
class="relative block cursor-default select-none truncate py-2 pl-3 pr-9"
|
|
31
|
+
selected-class="font-semibold"
|
|
32
|
+
unselected-class="font-normal"
|
|
33
|
+
active-class="bg-indigo-600 text-white"
|
|
34
|
+
inactive-class="text-gray-900"
|
|
35
|
+
/>
|
|
36
|
+
</AGHeadlessSelectOptions>
|
|
37
|
+
</div>
|
|
38
|
+
<AGHeadlessSelectError class="mt-2 text-sm text-red-600" />
|
|
39
|
+
</AGHeadlessSelect>
|
|
40
|
+
</template>
|
|
41
|
+
|
|
42
|
+
<script setup lang="ts">
|
|
43
|
+
import IconCheveronDown from '~icons/zondicons/cheveron-down';
|
|
44
|
+
|
|
45
|
+
import { componentRef } from '@/utils/vue';
|
|
46
|
+
import { useSelectEmits, useSelectProps } from '@/components/headless/forms/AGHeadlessSelect';
|
|
47
|
+
import type { IAGHeadlessSelect } from '@/components/headless/forms/AGHeadlessSelect';
|
|
48
|
+
|
|
49
|
+
import AGHeadlessSelect from '../headless/forms/AGHeadlessSelect.vue';
|
|
50
|
+
import AGHeadlessSelectButton from '../headless/forms/AGHeadlessSelectButton.vue';
|
|
51
|
+
import AGHeadlessSelectError from '../headless/forms/AGHeadlessSelectError.vue';
|
|
52
|
+
import AGHeadlessSelectLabel from '../headless/forms/AGHeadlessSelectLabel.vue';
|
|
53
|
+
import AGHeadlessSelectOption from '../headless/forms/AGHeadlessSelectOption.vue';
|
|
54
|
+
import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions';
|
|
55
|
+
|
|
56
|
+
defineEmits(useSelectEmits());
|
|
57
|
+
|
|
58
|
+
const props = defineProps(useSelectProps());
|
|
59
|
+
const $select = componentRef<IAGHeadlessSelect>();
|
|
60
|
+
</script>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export {
|
|
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,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="component.
|
|
2
|
+
<component :is="component.as" v-bind="component.props">
|
|
3
3
|
<slot />
|
|
4
4
|
</component>
|
|
5
5
|
</template>
|
|
@@ -7,45 +7,50 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
10
|
-
import type { LocationQuery, RouteLocation, RouteParams } from 'vue-router';
|
|
11
10
|
|
|
12
11
|
import { booleanProp, objectProp, stringProp } from '@/utils/vue';
|
|
13
12
|
|
|
14
|
-
const
|
|
13
|
+
const props = defineProps({
|
|
14
|
+
as: objectProp(),
|
|
15
|
+
href: stringProp(),
|
|
15
16
|
url: stringProp(),
|
|
16
17
|
route: stringProp(),
|
|
17
|
-
routeParams: objectProp
|
|
18
|
-
routeQuery: objectProp
|
|
18
|
+
routeParams: objectProp(() => ({})),
|
|
19
|
+
routeQuery: objectProp(() => ({})),
|
|
19
20
|
submit: booleanProp(),
|
|
20
21
|
});
|
|
21
22
|
|
|
22
23
|
const component = computed(() => {
|
|
23
|
-
if (
|
|
24
|
+
if (props.as) {
|
|
25
|
+
return { as: props.as, props: {} };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (props.route) {
|
|
24
29
|
return {
|
|
25
|
-
|
|
30
|
+
as: 'router-link',
|
|
26
31
|
props: {
|
|
27
|
-
to: objectWithoutEmpty
|
|
28
|
-
name: route,
|
|
29
|
-
params: routeParams,
|
|
30
|
-
query: routeQuery,
|
|
32
|
+
to: objectWithoutEmpty({
|
|
33
|
+
name: props.route,
|
|
34
|
+
params: props.routeParams,
|
|
35
|
+
query: props.routeQuery,
|
|
31
36
|
}),
|
|
32
37
|
},
|
|
33
38
|
};
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
if (url) {
|
|
41
|
+
if (props.href || props.url) {
|
|
37
42
|
return {
|
|
38
|
-
|
|
43
|
+
as: 'a',
|
|
39
44
|
props: {
|
|
40
45
|
target: '_blank',
|
|
41
|
-
href: url,
|
|
46
|
+
href: props.href || props.url,
|
|
42
47
|
},
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
return {
|
|
47
|
-
|
|
48
|
-
props: { type: submit ? 'submit' : 'button' },
|
|
52
|
+
as: 'button',
|
|
53
|
+
props: { type: props.submit ? 'submit' : 'button' },
|
|
49
54
|
};
|
|
50
55
|
});
|
|
51
56
|
</script>
|
|
@@ -1,8 +1,33 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
1
|
+
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { mixedProp, stringProp } from '@/utils';
|
|
4
|
+
import { extractComponentProps } from '@/components/utils';
|
|
5
|
+
import type { FormFieldValue } from '@/forms/Form';
|
|
6
|
+
import type { HasElement } from '@/components/interfaces';
|
|
7
|
+
|
|
8
|
+
export interface IAGHeadlessInput extends HasElement {
|
|
4
9
|
id: string;
|
|
5
|
-
|
|
10
|
+
name: ComputedRef<string | null>;
|
|
11
|
+
label: ComputedRef<string | null>;
|
|
12
|
+
description: ComputedRef<string | boolean | null>;
|
|
13
|
+
value: ComputedRef<FormFieldValue | null>;
|
|
6
14
|
errors: DeepReadonly<Ref<string[] | null>>;
|
|
7
|
-
update(value:
|
|
15
|
+
update(value: FormFieldValue | null): void;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const inputProps = {
|
|
19
|
+
name: stringProp(),
|
|
20
|
+
label: stringProp(),
|
|
21
|
+
description: stringProp(),
|
|
22
|
+
modelValue: mixedProp<FormFieldValue>([String, Number, Boolean]),
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function useInputProps(): typeof inputProps {
|
|
26
|
+
return inputProps;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
|
|
30
|
+
props: T,
|
|
31
|
+
): Pick<T, keyof typeof inputProps> {
|
|
32
|
+
return extractComponentProps(props, inputProps);
|
|
8
33
|
}
|
|
@@ -6,20 +6,23 @@
|
|
|
6
6
|
</template>
|
|
7
7
|
|
|
8
8
|
<script setup lang="ts">
|
|
9
|
-
import { computed, inject, provide, readonly } from 'vue';
|
|
9
|
+
import { computed, inject, provide, readonly, ref } from 'vue';
|
|
10
10
|
import { uuid } from '@noeldemartin/utils';
|
|
11
|
+
import type { Ref } from 'vue';
|
|
11
12
|
|
|
12
13
|
import { stringProp } from '@/utils/vue';
|
|
13
14
|
import type Form from '@/forms/Form';
|
|
15
|
+
import type { __HasElement } from '@/components/interfaces';
|
|
14
16
|
|
|
17
|
+
import { useInputProps } from './AGHeadlessInput';
|
|
15
18
|
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
16
19
|
|
|
17
20
|
const emit = defineEmits(['update:modelValue']);
|
|
18
21
|
const props = defineProps({
|
|
19
|
-
as: stringProp(),
|
|
20
|
-
|
|
21
|
-
modelValue: stringProp(),
|
|
22
|
+
as: stringProp('div'),
|
|
23
|
+
...useInputProps(),
|
|
22
24
|
});
|
|
25
|
+
const $el = ref<HTMLElement>();
|
|
23
26
|
const errors = computed(() => {
|
|
24
27
|
if (!form || !props.name) {
|
|
25
28
|
return null;
|
|
@@ -28,8 +31,12 @@ const errors = computed(() => {
|
|
|
28
31
|
return form.errors[props.name] ?? null;
|
|
29
32
|
});
|
|
30
33
|
const form = inject<Form | null>('form', null);
|
|
31
|
-
const
|
|
34
|
+
const api: IAGHeadlessInput & __HasElement = {
|
|
35
|
+
$el: readonly($el) as Readonly<Ref<HTMLElement>>,
|
|
32
36
|
id: `input-${uuid()}`,
|
|
37
|
+
name: computed(() => props.name),
|
|
38
|
+
label: computed(() => props.label),
|
|
39
|
+
description: computed(() => props.description),
|
|
33
40
|
value: computed(() => {
|
|
34
41
|
if (form && props.name) {
|
|
35
42
|
return form.getFieldValue(props.name);
|
|
@@ -47,8 +54,11 @@ const publicApi: IAGHeadlessInput = {
|
|
|
47
54
|
|
|
48
55
|
emit('update:modelValue', value);
|
|
49
56
|
},
|
|
57
|
+
__setElement(element) {
|
|
58
|
+
$el.value = element;
|
|
59
|
+
},
|
|
50
60
|
};
|
|
51
61
|
|
|
52
|
-
provide<IAGHeadlessInput>('input',
|
|
53
|
-
defineExpose<IAGHeadlessInput>(
|
|
62
|
+
provide<IAGHeadlessInput>('input', api);
|
|
63
|
+
defineExpose<IAGHeadlessInput>(api);
|
|
54
64
|
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<slot :id="`${input.id}-description`">
|
|
3
|
+
<AGMarkdown
|
|
4
|
+
v-if="show"
|
|
5
|
+
v-bind="$attrs"
|
|
6
|
+
:id="`${input.id}-description`"
|
|
7
|
+
:text="text"
|
|
8
|
+
/>
|
|
9
|
+
</slot>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed } from 'vue';
|
|
14
|
+
|
|
15
|
+
import { injectReactiveOrFail } from '@/utils/vue';
|
|
16
|
+
|
|
17
|
+
import AGMarkdown from '../../lib/AGMarkdown.vue';
|
|
18
|
+
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
19
|
+
|
|
20
|
+
defineOptions({ inheritAttrs: false });
|
|
21
|
+
|
|
22
|
+
const input = injectReactiveOrFail<IAGHeadlessInput>(
|
|
23
|
+
'input',
|
|
24
|
+
'<AGHeadlessInputDescription> must be a child of a <AGHeadlessInput>',
|
|
25
|
+
);
|
|
26
|
+
const text = computed(() => (typeof input.description === 'string' ? input.description : ''));
|
|
27
|
+
const show = computed(() => !!input.description);
|
|
28
|
+
</script>
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
|
|
10
10
|
import { injectReactiveOrFail } from '@/utils/vue';
|
|
11
|
-
import { translateWithDefault } from '@/lang';
|
|
11
|
+
import { translateWithDefault } from '@/lang/utils';
|
|
12
12
|
|
|
13
13
|
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
14
14
|
|