@aerogel/core 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2 → 0.0.0-next.9d1e54cc195274e9dd7d57a73fcb8a9a51927dcb
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 +1309 -1587
- package/dist/aerogel-core.js +2637 -1991
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +10 -2
- package/src/components/AppLayout.vue +14 -0
- package/src/components/{AGAppModals.vue → AppModals.vue} +2 -3
- 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 +15 -10
- 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 +10 -1
- 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} +6 -7
- package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +2 -6
- package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +16 -25
- package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +2 -6
- package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +9 -12
- 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} +3 -4
- package/src/components/headless/HeadlessSelectLabel.vue +25 -0
- package/src/components/headless/HeadlessSelectOption.vue +34 -0
- package/src/components/headless/HeadlessSelectOptions.vue +42 -0
- package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
- package/src/components/headless/HeadlessSelectValue.vue +18 -0
- package/src/components/headless/HeadlessToast.vue +18 -0
- package/src/components/headless/HeadlessToastAction.vue +13 -0
- package/src/components/headless/index.ts +19 -3
- package/src/components/index.ts +5 -10
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +17 -0
- package/src/components/ui/Button.vue +100 -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} +28 -21
- 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 +85 -0
- package/src/components/ui/Modal.vue +123 -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 +17 -0
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +35 -0
- package/src/components/ui/SelectTrigger.vue +29 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +7 -7
- package/src/components/ui/Toast.vue +46 -0
- package/src/components/ui/index.ts +32 -0
- package/src/directives/measure.ts +11 -5
- package/src/errors/Errors.ts +22 -20
- package/src/forms/{Form.test.ts → FormController.test.ts} +32 -9
- package/src/forms/{Form.ts → FormController.ts} +28 -27
- package/src/forms/index.ts +2 -3
- package/src/forms/utils.ts +35 -35
- package/src/index.css +73 -0
- package/src/lang/index.ts +4 -0
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/services/App.state.ts +11 -1
- package/src/services/App.ts +9 -1
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +2 -8
- package/src/services/index.ts +3 -0
- package/src/ui/UI.state.ts +7 -12
- package/src/ui/UI.ts +115 -106
- package/src/ui/index.ts +23 -24
- package/src/utils/classes.ts +41 -0
- package/src/utils/composition/events.ts +2 -4
- 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/types.ts +3 -0
- package/src/utils/vue.ts +28 -129
- 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/contracts/shared.ts +0 -9
- package/src/components/forms/AGButton.vue +0 -44
- package/src/components/forms/AGCheckbox.vue +0 -42
- package/src/components/forms/AGInput.vue +0 -42
- package/src/components/forms/AGSelect.story.vue +0 -46
- package/src/components/forms/AGSelect.vue +0 -54
- 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 -41
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -70
- package/src/components/headless/forms/AGHeadlessSelect.ts +0 -42
- package/src/components/headless/forms/AGHeadlessSelect.vue +0 -77
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -31
- package/src/components/headless/forms/AGHeadlessSelectOptions.vue +0 -19
- package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +0 -25
- package/src/components/headless/forms/composition.ts +0 -10
- package/src/components/headless/forms/index.ts +0 -17
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -33
- package/src/components/headless/modals/AGHeadlessModal.vue +0 -88
- package/src/components/headless/modals/AGHeadlessModalContent.vue +0 -25
- package/src/components/headless/modals/index.ts +0 -5
- 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 -54
- package/src/components/lib/AGMeasured.vue +0 -16
- package/src/components/lib/AGProgressBar.vue +0 -55
- 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 -27
- 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.vue +0 -40
- 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 -35
- package/src/components/modals/index.ts +0 -16
- package/src/components/snackbars/AGSnackbar.vue +0 -36
- package/src/components/snackbars/index.ts +0 -3
- package/src/components/utils.ts +0 -63
- package/src/forms/composition.ts +0 -6
- package/src/utils/tailwindcss.test.ts +0 -26
- package/src/utils/tailwindcss.ts +0 -7
|
@@ -1,46 +0,0 @@
|
|
|
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>
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<AGHeadlessSelect
|
|
3
|
-
v-bind="props"
|
|
4
|
-
ref="$select"
|
|
5
|
-
as="div"
|
|
6
|
-
@update:model-value="$emit('update:modelValue', $event)"
|
|
7
|
-
>
|
|
8
|
-
<div class="relative" :class="{ 'mt-2': $select?.label }">
|
|
9
|
-
<AGHeadlessSelectTrigger
|
|
10
|
-
class="relative w-full cursor-default bg-white py-1.5 pr-10 pl-3 text-left text-gray-900 ring-1 ring-gray-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-hidden"
|
|
11
|
-
text-class="block truncate"
|
|
12
|
-
:class="{
|
|
13
|
-
'ring-1 ring-red-500': $select?.errors,
|
|
14
|
-
}"
|
|
15
|
-
>
|
|
16
|
-
<template #icon>
|
|
17
|
-
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
18
|
-
<IconCheveronDown class="size-5 text-gray-400" />
|
|
19
|
-
</span>
|
|
20
|
-
</template>
|
|
21
|
-
</AGHeadlessSelectTrigger>
|
|
22
|
-
<AGHeadlessSelectOptions
|
|
23
|
-
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border border-gray-300 bg-white py-1 text-base ring-1 ring-black/5 focus:outline-hidden"
|
|
24
|
-
>
|
|
25
|
-
<AGHeadlessSelectOption
|
|
26
|
-
v-for="(option, index) in $select?.options ?? []"
|
|
27
|
-
:key="index"
|
|
28
|
-
:value="option"
|
|
29
|
-
class="relative block cursor-default truncate py-2 pr-9 pl-3 text-gray-900 select-none data-[highlighted]:bg-indigo-600 data-[highlighted]:text-white data-[state=checked]:font-semibold data-[state=unchecked]:font-normal"
|
|
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 '@aerogel/core/utils/vue';
|
|
41
|
-
import { useSelectEmits, useSelectProps } from '@aerogel/core/components/headless/forms/AGHeadlessSelect';
|
|
42
|
-
import type { IAGHeadlessSelect } from '@aerogel/core/components/headless/forms/AGHeadlessSelect';
|
|
43
|
-
|
|
44
|
-
import AGHeadlessSelect from '../headless/forms/AGHeadlessSelect.vue';
|
|
45
|
-
import AGHeadlessSelectTrigger from '../headless/forms/AGHeadlessSelectTrigger.vue';
|
|
46
|
-
import AGHeadlessSelectError from '../headless/forms/AGHeadlessSelectError.vue';
|
|
47
|
-
import AGHeadlessSelectOption from '../headless/forms/AGHeadlessSelectOption.vue';
|
|
48
|
-
import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions.vue';
|
|
49
|
-
|
|
50
|
-
defineEmits(useSelectEmits());
|
|
51
|
-
|
|
52
|
-
const props = defineProps(useSelectProps());
|
|
53
|
-
const $select = componentRef<IAGHeadlessSelect>();
|
|
54
|
-
</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,62 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<component :is="component.as" ref="$root" 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 '@aerogel/core/utils/vue';
|
|
12
|
-
import { elementRef } from '@aerogel/core/components/composition';
|
|
13
|
-
|
|
14
|
-
import type { IAGHeadlessButton } from './AGHeadlessButton';
|
|
15
|
-
|
|
16
|
-
const props = defineProps({
|
|
17
|
-
as: objectProp(),
|
|
18
|
-
href: stringProp(),
|
|
19
|
-
url: stringProp(),
|
|
20
|
-
route: stringProp(),
|
|
21
|
-
routeParams: objectProp(() => ({})),
|
|
22
|
-
routeQuery: objectProp(() => ({})),
|
|
23
|
-
submit: booleanProp(),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const $root = elementRef();
|
|
27
|
-
const component = computed(() => {
|
|
28
|
-
if (props.as) {
|
|
29
|
-
return { as: props.as, props: {} };
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (props.route) {
|
|
33
|
-
return {
|
|
34
|
-
as: 'router-link',
|
|
35
|
-
props: {
|
|
36
|
-
to: objectWithoutEmpty({
|
|
37
|
-
name: props.route,
|
|
38
|
-
params: props.routeParams,
|
|
39
|
-
query: props.routeQuery,
|
|
40
|
-
}),
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (props.href || props.url) {
|
|
46
|
-
return {
|
|
47
|
-
as: 'a',
|
|
48
|
-
props: {
|
|
49
|
-
target: '_blank',
|
|
50
|
-
href: props.href || props.url,
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return {
|
|
56
|
-
as: 'button',
|
|
57
|
-
props: { type: props.submit ? 'submit' : 'button' },
|
|
58
|
-
};
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
defineExpose<IAGHeadlessButton>({ $el: $root });
|
|
62
|
-
</script>
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
|
-
import type { Writable } from '@noeldemartin/utils';
|
|
3
|
-
|
|
4
|
-
import { mixedProp, stringProp } from '@aerogel/core/utils';
|
|
5
|
-
import { extractComponentProps } from '@aerogel/core/components/utils';
|
|
6
|
-
import type { FormFieldValue } from '@aerogel/core/forms/Form';
|
|
7
|
-
import type { HasElement } from '@aerogel/core/components/contracts/shared';
|
|
8
|
-
|
|
9
|
-
export interface IAGHeadlessInput extends HasElement {
|
|
10
|
-
id: string;
|
|
11
|
-
name: ComputedRef<string | null>;
|
|
12
|
-
label: ComputedRef<string | null>;
|
|
13
|
-
description: ComputedRef<string | boolean | null>;
|
|
14
|
-
value: ComputedRef<FormFieldValue | null>;
|
|
15
|
-
required: ComputedRef<boolean | null>;
|
|
16
|
-
errors: DeepReadonly<Ref<string[] | null>>;
|
|
17
|
-
update(value: FormFieldValue | null): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const inputProps = {
|
|
21
|
-
name: stringProp(),
|
|
22
|
-
label: stringProp(),
|
|
23
|
-
description: stringProp(),
|
|
24
|
-
modelValue: mixedProp<FormFieldValue>([String, Number, Boolean]),
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const inputEmits = ['update:modelValue'] as const;
|
|
28
|
-
|
|
29
|
-
export function useInputEmits(): Writable<typeof inputEmits> {
|
|
30
|
-
return [...inputEmits];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function useInputProps(): typeof inputProps {
|
|
34
|
-
return inputProps;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
|
|
38
|
-
props: T,
|
|
39
|
-
): Pick<T, keyof typeof inputProps> {
|
|
40
|
-
return extractComponentProps(props, inputProps);
|
|
41
|
-
}
|
|
@@ -1,70 +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, ref } from 'vue';
|
|
10
|
-
import { uuid } from '@noeldemartin/utils';
|
|
11
|
-
|
|
12
|
-
import { stringProp } from '@aerogel/core/utils/vue';
|
|
13
|
-
import type Form from '@aerogel/core/forms/Form';
|
|
14
|
-
import type { __SetsElement } from '@aerogel/core/components/contracts/shared';
|
|
15
|
-
|
|
16
|
-
import { useInputProps } from './AGHeadlessInput';
|
|
17
|
-
import type { IAGHeadlessInput } from './AGHeadlessInput';
|
|
18
|
-
|
|
19
|
-
const emit = defineEmits(['update:modelValue']);
|
|
20
|
-
const props = defineProps({
|
|
21
|
-
as: stringProp('div'),
|
|
22
|
-
...useInputProps(),
|
|
23
|
-
});
|
|
24
|
-
const $el = ref<HTMLElement>();
|
|
25
|
-
const errors = computed(() => {
|
|
26
|
-
if (!form || !props.name) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return form.errors[props.name] ?? null;
|
|
31
|
-
});
|
|
32
|
-
const form = inject<Form | null>('form', null);
|
|
33
|
-
const api: IAGHeadlessInput & __SetsElement = {
|
|
34
|
-
$el,
|
|
35
|
-
id: `input-${uuid()}`,
|
|
36
|
-
name: computed(() => props.name),
|
|
37
|
-
label: computed(() => props.label),
|
|
38
|
-
description: computed(() => props.description),
|
|
39
|
-
value: computed(() => {
|
|
40
|
-
if (form && props.name) {
|
|
41
|
-
return form.getFieldValue(props.name);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return props.modelValue;
|
|
45
|
-
}),
|
|
46
|
-
errors: readonly(errors),
|
|
47
|
-
required: computed(() => {
|
|
48
|
-
if (!props.name || !form) {
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return form.getFieldRules(props.name).includes('required');
|
|
53
|
-
}),
|
|
54
|
-
update(value) {
|
|
55
|
-
if (form && props.name) {
|
|
56
|
-
form.setFieldValue(props.name, value);
|
|
57
|
-
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
emit('update:modelValue', value);
|
|
62
|
-
},
|
|
63
|
-
__setElement(element) {
|
|
64
|
-
$el.value = element;
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
provide<IAGHeadlessInput>('input', api);
|
|
69
|
-
defineExpose<IAGHeadlessInput>(api);
|
|
70
|
-
</script>
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
|
|
2
|
-
import type { Writable } from '@noeldemartin/utils';
|
|
3
|
-
|
|
4
|
-
import { mixedProp, requiredArrayProp, stringProp } from '@aerogel/core/utils/vue';
|
|
5
|
-
import { extractComponentProps } from '@aerogel/core/components/utils';
|
|
6
|
-
import type { FormFieldValue } from '@aerogel/core/forms/Form';
|
|
7
|
-
|
|
8
|
-
export interface IAGHeadlessSelect {
|
|
9
|
-
id: string;
|
|
10
|
-
label: ComputedRef<string | null>;
|
|
11
|
-
noSelectionText: ComputedRef<string>;
|
|
12
|
-
buttonText: ComputedRef<string>;
|
|
13
|
-
renderText: ComputedRef<(value: FormFieldValue) => string>;
|
|
14
|
-
selectedOption: ComputedRef<FormFieldValue | null>;
|
|
15
|
-
options: ComputedRef<FormFieldValue[]>;
|
|
16
|
-
errors: DeepReadonly<Ref<string[] | null>>;
|
|
17
|
-
update(value: FormFieldValue): void;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const selectProps = {
|
|
21
|
-
name: stringProp(),
|
|
22
|
-
label: stringProp(),
|
|
23
|
-
options: requiredArrayProp<FormFieldValue>(),
|
|
24
|
-
noSelectionText: stringProp(),
|
|
25
|
-
optionsText: mixedProp<string | ((option: FormFieldValue) => string)>(),
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const selectEmits = ['update:modelValue'] as const;
|
|
29
|
-
|
|
30
|
-
export function useSelectProps(): typeof selectProps {
|
|
31
|
-
return selectProps;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export function useSelectEmits(): Writable<typeof selectEmits> {
|
|
35
|
-
return [...selectEmits];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export function extractSelectProps<T extends ExtractPropTypes<typeof selectProps>>(
|
|
39
|
-
props: T,
|
|
40
|
-
): Pick<T, keyof typeof selectProps> {
|
|
41
|
-
return extractComponentProps(props, selectProps);
|
|
42
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SelectRoot v-slot="{ open }: ComponentProps" :model-value="selectedOption" @update:model-value="update($event)">
|
|
3
|
-
<slot :model-value="modelValue" :open="open" />
|
|
4
|
-
</SelectRoot>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script setup lang="ts">
|
|
8
|
-
import { computed, inject, provide } from 'vue';
|
|
9
|
-
import { toString, uuid } from '@noeldemartin/utils';
|
|
10
|
-
import { SelectRoot } from 'reka-ui';
|
|
11
|
-
import type { AcceptableValue } from 'reka-ui';
|
|
12
|
-
|
|
13
|
-
import { mixedProp } from '@aerogel/core/utils/vue';
|
|
14
|
-
import { translateWithDefault } from '@aerogel/core/lang/utils';
|
|
15
|
-
import type Form from '@aerogel/core/forms/Form';
|
|
16
|
-
import type { FormFieldValue } from '@aerogel/core/forms/Form';
|
|
17
|
-
import type { ComponentProps } from '@aerogel/core/utils/vue';
|
|
18
|
-
|
|
19
|
-
import { useSelectEmits, useSelectProps } from './AGHeadlessSelect';
|
|
20
|
-
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
21
|
-
|
|
22
|
-
const emit = defineEmits(useSelectEmits());
|
|
23
|
-
const props = defineProps({
|
|
24
|
-
modelValue: mixedProp<FormFieldValue>(),
|
|
25
|
-
...useSelectProps(),
|
|
26
|
-
});
|
|
27
|
-
const renderText = computed(() => {
|
|
28
|
-
if (typeof props.optionsText === 'function') {
|
|
29
|
-
return props.optionsText;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (typeof props.optionsText === 'string') {
|
|
33
|
-
return (option: FormFieldValue): string => toString(option[props.optionsText as keyof FormFieldValue]);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (option: FormFieldValue) => toString(option);
|
|
37
|
-
});
|
|
38
|
-
const form = inject<Form | null>('form', null);
|
|
39
|
-
const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
|
|
40
|
-
const selectedOption = computed(
|
|
41
|
-
() => (form && props.name ? form.getFieldValue(props.name) : props.modelValue) as AcceptableValue,
|
|
42
|
-
);
|
|
43
|
-
const errors = computed(() => {
|
|
44
|
-
if (!form || !props.name) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return form.errors[props.name] ?? null;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
52
|
-
function update(value: any) {
|
|
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,31 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SelectItem :value="value" as="template">
|
|
3
|
-
<SelectItemText>
|
|
4
|
-
<slot>
|
|
5
|
-
{{ select.renderText(value) }}
|
|
6
|
-
</slot>
|
|
7
|
-
</SelectItemText>
|
|
8
|
-
</SelectItem>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup lang="ts">
|
|
12
|
-
import { SelectItem, SelectItemText } from 'reka-ui';
|
|
13
|
-
|
|
14
|
-
import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@aerogel/core/utils/vue';
|
|
15
|
-
|
|
16
|
-
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
17
|
-
|
|
18
|
-
defineProps({
|
|
19
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
-
value: requiredMixedProp<any>(),
|
|
21
|
-
selectedClass: stringProp(),
|
|
22
|
-
unselectedClass: stringProp(),
|
|
23
|
-
activeClass: stringProp(),
|
|
24
|
-
inactiveClass: stringProp(),
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
28
|
-
'select',
|
|
29
|
-
'<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>',
|
|
30
|
-
);
|
|
31
|
-
</script>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SelectPortal>
|
|
3
|
-
<SelectContent :class="classes">
|
|
4
|
-
<SelectViewport>
|
|
5
|
-
<slot />
|
|
6
|
-
</SelectViewport>
|
|
7
|
-
</SelectContent>
|
|
8
|
-
</SelectPortal>
|
|
9
|
-
</template>
|
|
10
|
-
|
|
11
|
-
<script setup lang="ts">
|
|
12
|
-
import { computed } from 'vue';
|
|
13
|
-
import { SelectContent, SelectPortal, SelectViewport } from 'reka-ui';
|
|
14
|
-
|
|
15
|
-
import { stringProp } from '@aerogel/core/utils/vue';
|
|
16
|
-
|
|
17
|
-
const props = defineProps({ class: stringProp('') });
|
|
18
|
-
const classes = computed(() => props.class);
|
|
19
|
-
</script>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<SelectTrigger>
|
|
3
|
-
<SelectValue>
|
|
4
|
-
<slot>
|
|
5
|
-
<span :class="textClass">{{ select?.buttonText }}</span>
|
|
6
|
-
</slot>
|
|
7
|
-
<slot name="icon" />
|
|
8
|
-
</SelectValue>
|
|
9
|
-
</SelectTrigger>
|
|
10
|
-
</template>
|
|
11
|
-
|
|
12
|
-
<script setup lang="ts">
|
|
13
|
-
import { SelectTrigger, SelectValue } from 'reka-ui';
|
|
14
|
-
|
|
15
|
-
import { injectReactiveOrFail, stringProp } from '@aerogel/core/utils/vue';
|
|
16
|
-
|
|
17
|
-
import type { IAGHeadlessSelect } from './AGHeadlessSelect';
|
|
18
|
-
|
|
19
|
-
defineProps({ textClass: stringProp() });
|
|
20
|
-
|
|
21
|
-
const select = injectReactiveOrFail<IAGHeadlessSelect>(
|
|
22
|
-
'select',
|
|
23
|
-
'<AGHeadlessSelectTrigger> must be a child of a <AGHeadlessSelect>',
|
|
24
|
-
);
|
|
25
|
-
</script>
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { inject, onUnmounted } from 'vue';
|
|
2
|
-
|
|
3
|
-
import type Form from '@aerogel/core/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,17 +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 AGHeadlessSelectTrigger } from './AGHeadlessSelectTrigger.vue';
|
|
15
|
-
export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
|
|
16
|
-
export { default as AGHeadlessSelectOption } from './AGHeadlessSelectOption.vue';
|
|
17
|
-
export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions.vue';
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { computed } from 'vue';
|
|
2
|
-
import type { Ref } from 'vue';
|
|
3
|
-
|
|
4
|
-
import { booleanProp, stringProp } from '@aerogel/core/utils/vue';
|
|
5
|
-
import { extractComponentProps } from '@aerogel/core/components/utils';
|
|
6
|
-
import type { ComponentPropDefinitions } from '@aerogel/core/components/utils';
|
|
7
|
-
import type { ComponentProps } from '@aerogel/core/utils/vue';
|
|
8
|
-
import type { IModal, IModalProps } from '@aerogel/core/components/contracts/Modal';
|
|
9
|
-
|
|
10
|
-
export interface IAGHeadlessModal extends IModal {}
|
|
11
|
-
|
|
12
|
-
export interface IAGHeadlessModalDefaultSlotProps {
|
|
13
|
-
close(result?: unknown): Promise<void>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function extractModalProps<T extends IModalProps>(props: T): ComponentProps<IModalProps> {
|
|
17
|
-
return extractComponentProps(props, modalProps());
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function modalProps(): ComponentPropDefinitions<IModalProps> {
|
|
21
|
-
return {
|
|
22
|
-
cancellable: booleanProp(true),
|
|
23
|
-
description: stringProp(),
|
|
24
|
-
title: stringProp(),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export function modalExpose($modal: Ref<IAGHeadlessModal | undefined>): IModal {
|
|
29
|
-
return {
|
|
30
|
-
cancellable: computed(() => !!$modal.value?.cancellable),
|
|
31
|
-
close: async () => $modal.value?.close(),
|
|
32
|
-
};
|
|
33
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DialogRoot ref="$root" :open="true" @update:open="cancellable && close()">
|
|
3
|
-
<DialogPortal>
|
|
4
|
-
<slot :close="close" />
|
|
5
|
-
</DialogPortal>
|
|
6
|
-
</DialogRoot>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { ref, toRef } from 'vue';
|
|
11
|
-
import { DialogPortal, DialogRoot } from 'reka-ui';
|
|
12
|
-
import type { VNode } from 'vue';
|
|
13
|
-
|
|
14
|
-
import Events from '@aerogel/core/services/Events';
|
|
15
|
-
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
16
|
-
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
-
import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
|
|
18
|
-
|
|
19
|
-
import { modalProps } from './AGHeadlessModal';
|
|
20
|
-
import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
|
|
21
|
-
|
|
22
|
-
const props = defineProps(modalProps());
|
|
23
|
-
const $root = ref<{ $el?: HTMLElement } | null>(null);
|
|
24
|
-
const hidden = ref(true);
|
|
25
|
-
const closed = ref(false);
|
|
26
|
-
const { modal } = injectReactiveOrFail<IAGModalContext>(
|
|
27
|
-
'modal',
|
|
28
|
-
'could not obtain modal reference from <AGHeadlessModal>, ' +
|
|
29
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
async function hide(): Promise<void> {
|
|
33
|
-
if (!$root.value?.$el) {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
hidden.value = true;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
async function show(): Promise<void> {
|
|
41
|
-
if (!$root.value?.$el) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
hidden.value = false;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
async function close(result?: unknown) {
|
|
49
|
-
if (closed.value) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
Events.emit('modal-will-close', { modal, result });
|
|
54
|
-
|
|
55
|
-
await hide();
|
|
56
|
-
|
|
57
|
-
closed.value = true;
|
|
58
|
-
|
|
59
|
-
Events.emit('modal-closed', { modal, result });
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
useEvent('close-modal', async ({ id, result }) => {
|
|
63
|
-
if (id !== modal.id) {
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
await close(result);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
useEvent('hide-modal', async ({ id }) => {
|
|
71
|
-
if (id !== modal.id) {
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
await hide();
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
useEvent('show-modal', async ({ id }) => {
|
|
79
|
-
if (id !== modal.id) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
await show();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
defineSlots<{ default(props: IAGHeadlessModalDefaultSlotProps): VNode[] }>();
|
|
87
|
-
defineExpose<IAGHeadlessModal>({ close, cancellable: toRef(props, 'cancellable') });
|
|
88
|
-
</script>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<DialogContent>
|
|
3
|
-
<slot />
|
|
4
|
-
|
|
5
|
-
<AGModalContext v-if="childModal" :child-index="childIndex + 1" :modal="childModal" />
|
|
6
|
-
</DialogContent>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script setup lang="ts">
|
|
10
|
-
import { computed } from 'vue';
|
|
11
|
-
import { DialogContent } from 'reka-ui';
|
|
12
|
-
|
|
13
|
-
import UI from '@aerogel/core/ui/UI';
|
|
14
|
-
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
15
|
-
import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
|
|
16
|
-
|
|
17
|
-
import AGModalContext from '../../modals/AGModalContext.vue';
|
|
18
|
-
|
|
19
|
-
const { childIndex } = injectReactiveOrFail<IAGModalContext>(
|
|
20
|
-
'modal',
|
|
21
|
-
'could not obtain modal reference from <AGHeadlessModalContent>, ' +
|
|
22
|
-
'did you render this component manually? Show it using $ui.openModal() instead',
|
|
23
|
-
);
|
|
24
|
-
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
25
|
-
</script>
|