@aerogel/core 0.0.0-next.b656a964404fbde17d9cce7668722596098e47fd → 0.0.0-next.b9379d15fd4f40346d655134b49c9015ead9c536
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 +649 -560
- package/dist/aerogel-core.js +1878 -1455
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +6 -4
- package/src/components/AppLayout.vue +1 -3
- package/src/components/AppOverlays.vue +0 -27
- package/src/components/contracts/AlertModal.ts +15 -0
- package/src/components/contracts/ConfirmModal.ts +12 -5
- package/src/components/contracts/DropdownMenu.ts +17 -3
- package/src/components/contracts/ErrorReportModal.ts +8 -4
- package/src/components/contracts/Input.ts +7 -7
- package/src/components/contracts/LoadingModal.ts +12 -4
- package/src/components/contracts/Modal.ts +12 -4
- package/src/components/contracts/PromptModal.ts +8 -2
- package/src/components/contracts/Select.ts +21 -12
- package/src/components/contracts/Toast.ts +4 -2
- package/src/components/contracts/index.ts +3 -1
- package/src/components/headless/HeadlessButton.vue +2 -1
- package/src/components/headless/HeadlessInput.vue +3 -3
- package/src/components/headless/HeadlessInputInput.vue +5 -5
- package/src/components/headless/HeadlessInputTextArea.vue +3 -3
- package/src/components/headless/HeadlessModal.vue +22 -51
- package/src/components/headless/HeadlessModalContent.vue +11 -5
- package/src/components/headless/HeadlessModalDescription.vue +12 -0
- package/src/components/headless/HeadlessSelect.vue +34 -18
- package/src/components/headless/HeadlessSelectOption.vue +1 -1
- package/src/components/headless/HeadlessSelectOptions.vue +16 -4
- package/src/components/headless/HeadlessSelectValue.vue +4 -1
- package/src/components/headless/HeadlessSwitch.vue +96 -0
- package/src/components/headless/index.ts +2 -0
- package/src/components/ui/AdvancedOptions.vue +1 -1
- package/src/components/ui/AlertModal.vue +7 -3
- package/src/components/ui/Button.vue +17 -15
- package/src/components/ui/Checkbox.vue +4 -4
- package/src/components/ui/ConfirmModal.vue +12 -4
- package/src/components/ui/DropdownMenu.vue +18 -19
- package/src/components/ui/DropdownMenuOption.vue +22 -0
- package/src/components/ui/DropdownMenuOptions.vue +44 -0
- package/src/components/ui/EditableContent.vue +3 -3
- package/src/components/ui/ErrorLogs.vue +19 -0
- package/src/components/ui/ErrorLogsModal.vue +48 -0
- package/src/components/ui/ErrorReportModal.vue +18 -7
- package/src/components/ui/Input.vue +3 -3
- package/src/components/ui/LoadingModal.vue +6 -4
- package/src/components/ui/Markdown.vue +29 -1
- package/src/components/ui/Modal.vue +74 -21
- package/src/components/ui/ModalContext.vue +2 -1
- package/src/components/ui/ProgressBar.vue +8 -7
- package/src/components/ui/PromptModal.vue +8 -5
- package/src/components/ui/Select.vue +10 -4
- package/src/components/ui/SelectLabel.vue +13 -2
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +24 -20
- package/src/components/ui/SelectTrigger.vue +2 -2
- package/src/components/ui/Switch.vue +11 -0
- package/src/components/ui/Toast.vue +19 -15
- package/src/components/ui/index.ts +6 -0
- package/src/directives/measure.ts +11 -5
- package/src/errors/Errors.ts +18 -15
- package/src/errors/index.ts +6 -2
- package/src/errors/settings/Debug.vue +39 -0
- package/src/errors/settings/index.ts +10 -0
- package/src/forms/FormController.test.ts +32 -9
- package/src/forms/FormController.ts +23 -22
- package/src/forms/index.ts +0 -1
- package/src/forms/utils.ts +34 -34
- package/src/index.css +34 -7
- package/src/lang/index.ts +3 -2
- package/src/lang/settings/Language.vue +2 -2
- package/src/services/App.ts +6 -1
- package/src/services/Events.test.ts +8 -8
- package/src/services/Events.ts +2 -8
- package/src/services/index.ts +3 -3
- package/src/ui/UI.state.ts +3 -13
- package/src/ui/UI.ts +87 -79
- package/src/ui/index.ts +16 -17
- package/src/utils/classes.ts +9 -17
- package/src/utils/composition/events.ts +2 -4
- package/src/utils/composition/forms.ts +7 -1
- package/src/utils/index.ts +1 -0
- package/src/utils/markdown.ts +35 -1
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +6 -1
- package/src/components/contracts/shared.ts +0 -9
- package/src/forms/composition.ts +0 -6
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<DialogContent>
|
|
2
|
+
<DialogContent ref="$contentRef">
|
|
3
3
|
<slot />
|
|
4
4
|
|
|
5
5
|
<ModalContext v-if="childModal" :child-index="childIndex + 1" :modal="childModal" />
|
|
@@ -7,18 +7,24 @@
|
|
|
7
7
|
</template>
|
|
8
8
|
|
|
9
9
|
<script setup lang="ts">
|
|
10
|
-
import { computed } from 'vue';
|
|
10
|
+
import { computed, useTemplateRef, watchEffect } from 'vue';
|
|
11
11
|
import { DialogContent } from 'reka-ui';
|
|
12
|
+
import type { Ref } from 'vue';
|
|
12
13
|
|
|
13
14
|
import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
|
|
14
15
|
import UI from '@aerogel/core/ui/UI';
|
|
15
|
-
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
16
|
-
import type { UIModalContext } from '@aerogel/core/ui/UI
|
|
16
|
+
import { injectOrFail, injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
17
|
+
import type { UIModalContext } from '@aerogel/core/ui/UI';
|
|
18
|
+
import type { ModalContentInstance } from '@aerogel/core/components/contracts/Modal';
|
|
17
19
|
|
|
18
20
|
const { childIndex = 0 } = injectReactiveOrFail<UIModalContext>(
|
|
19
21
|
'modal',
|
|
20
22
|
'could not obtain modal reference from <HeadlessModalContent>, ' +
|
|
21
|
-
'did you render this component manually? Show it using $ui.
|
|
23
|
+
'did you render this component manually? Show it using $ui.modal() instead',
|
|
22
24
|
);
|
|
25
|
+
const $modalContentRef = injectOrFail<Ref<ModalContentInstance>>('$modalContentRef');
|
|
26
|
+
const $content = useTemplateRef('$contentRef');
|
|
23
27
|
const childModal = computed(() => UI.modals[childIndex] ?? null);
|
|
28
|
+
|
|
29
|
+
watchEffect(() => ($modalContentRef.value = $content.value));
|
|
24
30
|
</script>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DialogDescription v-bind="$props">
|
|
3
|
+
<slot />
|
|
4
|
+
</DialogDescription>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { DialogDescription } from 'reka-ui';
|
|
9
|
+
import type { DialogDescriptionProps } from 'reka-ui';
|
|
10
|
+
|
|
11
|
+
defineProps<DialogDescriptionProps>();
|
|
12
|
+
</script>
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<SelectRoot
|
|
2
|
+
<SelectRoot
|
|
3
|
+
v-slot="{ open }"
|
|
4
|
+
:model-value="acceptableValue"
|
|
5
|
+
:by="compareOptions as Closure<[AcceptableValue, AcceptableValue], boolean>"
|
|
6
|
+
@update:model-value="update($event)"
|
|
7
|
+
>
|
|
3
8
|
<component :is="as" v-bind="$attrs">
|
|
4
9
|
<slot :model-value :open>
|
|
5
10
|
<HeadlessSelectTrigger />
|
|
@@ -9,11 +14,12 @@
|
|
|
9
14
|
</SelectRoot>
|
|
10
15
|
</template>
|
|
11
16
|
|
|
12
|
-
<script setup lang="ts">
|
|
17
|
+
<script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
|
|
13
18
|
import { computed, inject, provide, readonly } from 'vue';
|
|
14
19
|
import { value as evaluate, toString, uuid } from '@noeldemartin/utils';
|
|
15
20
|
import { SelectRoot } from 'reka-ui';
|
|
16
21
|
import type { AcceptableValue } from 'reka-ui';
|
|
22
|
+
import type { Closure, Nullable } from '@noeldemartin/utils';
|
|
17
23
|
|
|
18
24
|
import { translateWithDefault } from '@aerogel/core/lang';
|
|
19
25
|
import { hasSelectOptionLabel } from '@aerogel/core/components/contracts/Select';
|
|
@@ -28,17 +34,29 @@ defineOptions({ inheritAttrs: false });
|
|
|
28
34
|
|
|
29
35
|
const {
|
|
30
36
|
name,
|
|
31
|
-
as = '
|
|
37
|
+
as = 'div',
|
|
32
38
|
label,
|
|
33
39
|
options,
|
|
40
|
+
labelClass,
|
|
41
|
+
optionsClass,
|
|
34
42
|
renderOption,
|
|
43
|
+
compareOptions = (a, b) => a === b,
|
|
35
44
|
description,
|
|
36
45
|
placeholder,
|
|
37
46
|
modelValue,
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
align,
|
|
48
|
+
side,
|
|
49
|
+
} = defineProps<SelectProps<T>>();
|
|
50
|
+
const emit = defineEmits<SelectEmits<T>>();
|
|
40
51
|
const form = inject<FormController | null>('form', null);
|
|
41
|
-
const
|
|
52
|
+
const computedValue = computed(() => {
|
|
53
|
+
if (form && name) {
|
|
54
|
+
return form.getFieldValue(name) as T;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return modelValue as T;
|
|
58
|
+
});
|
|
59
|
+
const acceptableValue = computed(() => computedValue.value as AcceptableValue);
|
|
42
60
|
const errors = computed(() => {
|
|
43
61
|
if (!form || !name) {
|
|
44
62
|
return null;
|
|
@@ -61,7 +79,12 @@ const computedOptions = computed(() => {
|
|
|
61
79
|
value: option as AcceptableValue,
|
|
62
80
|
}));
|
|
63
81
|
});
|
|
64
|
-
const
|
|
82
|
+
const expose = {
|
|
83
|
+
labelClass,
|
|
84
|
+
optionsClass,
|
|
85
|
+
align,
|
|
86
|
+
side,
|
|
87
|
+
value: computedValue,
|
|
65
88
|
id: `select-${uuid()}`,
|
|
66
89
|
name: computed(() => name),
|
|
67
90
|
label: computed(() => label),
|
|
@@ -69,13 +92,6 @@ const context = {
|
|
|
69
92
|
placeholder: computed(() => placeholder ?? translateWithDefault('ui.select', 'Select an option')),
|
|
70
93
|
options: computedOptions,
|
|
71
94
|
selectedOption: computed(() => computedOptions.value?.find((option) => option.value === modelValue)),
|
|
72
|
-
value: computed(() => {
|
|
73
|
-
if (form && name) {
|
|
74
|
-
return form.getFieldValue(name);
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return modelValue;
|
|
78
|
-
}),
|
|
79
95
|
errors: readonly(errors),
|
|
80
96
|
required: computed(() => {
|
|
81
97
|
if (!name || !form) {
|
|
@@ -93,12 +109,12 @@ const context = {
|
|
|
93
109
|
|
|
94
110
|
emit('update:modelValue', value);
|
|
95
111
|
},
|
|
96
|
-
} satisfies SelectExpose
|
|
112
|
+
} satisfies SelectExpose<T>;
|
|
97
113
|
|
|
98
114
|
function update(value: AcceptableValue) {
|
|
99
|
-
|
|
115
|
+
expose.update(value as T);
|
|
100
116
|
}
|
|
101
117
|
|
|
102
|
-
provide('select',
|
|
103
|
-
defineExpose(
|
|
118
|
+
provide('select', expose);
|
|
119
|
+
defineExpose(expose);
|
|
104
120
|
</script>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<SelectPortal>
|
|
3
|
-
<SelectContent
|
|
4
|
-
|
|
3
|
+
<SelectContent
|
|
4
|
+
position="popper"
|
|
5
|
+
:class="renderedClasses"
|
|
6
|
+
:align="select.align"
|
|
7
|
+
:side="select.side"
|
|
8
|
+
:side-offset="4"
|
|
9
|
+
>
|
|
10
|
+
<SelectViewport :class="innerClass">
|
|
5
11
|
<slot>
|
|
6
12
|
<HeadlessSelectOption
|
|
7
13
|
v-for="option in select.options ?? []"
|
|
@@ -16,15 +22,21 @@
|
|
|
16
22
|
|
|
17
23
|
<script setup lang="ts">
|
|
18
24
|
import { SelectContent, SelectPortal, SelectViewport } from 'reka-ui';
|
|
25
|
+
import { computed } from 'vue';
|
|
26
|
+
import type { HTMLAttributes } from 'vue';
|
|
19
27
|
|
|
20
|
-
import { injectReactiveOrFail } from '@aerogel/core/utils';
|
|
28
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
29
|
+
import { classes } from '@aerogel/core/utils/classes';
|
|
21
30
|
import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
|
|
22
31
|
|
|
23
32
|
import HeadlessSelectOption from './HeadlessSelectOption.vue';
|
|
24
33
|
|
|
25
|
-
const { class:
|
|
34
|
+
const { class: rootClass } = defineProps<{ class?: HTMLAttributes['class']; innerClass?: HTMLAttributes['class'] }>();
|
|
35
|
+
|
|
26
36
|
const select = injectReactiveOrFail<SelectExpose>(
|
|
27
37
|
'select',
|
|
28
38
|
'<HeadlessSelectOptions> must be a child of a <HeadlessSelect>',
|
|
29
39
|
);
|
|
40
|
+
const renderedClasses = computed(() =>
|
|
41
|
+
classes('min-w-(--reka-select-trigger-width) max-h-(--reka-select-content-available-height)', rootClass));
|
|
30
42
|
</script>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<SelectValue :placeholder="select.placeholder"
|
|
2
|
+
<SelectValue v-if="$slots.default" :placeholder="select.placeholder">
|
|
3
|
+
<slot />
|
|
4
|
+
</SelectValue>
|
|
5
|
+
<SelectValue v-else :placeholder="select.placeholder" />
|
|
3
6
|
</template>
|
|
4
7
|
|
|
5
8
|
<script setup lang="ts">
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="rootClass">
|
|
3
|
+
<label v-if="label" :for="expose.id" :class="labelClass">
|
|
4
|
+
{{ label }}
|
|
5
|
+
</label>
|
|
6
|
+
<SwitchRoot
|
|
7
|
+
:id="expose.id"
|
|
8
|
+
:name
|
|
9
|
+
:model-value="expose.value.value"
|
|
10
|
+
v-bind="$attrs"
|
|
11
|
+
:class="inputClass"
|
|
12
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
13
|
+
>
|
|
14
|
+
<SwitchThumb :class="thumbClass" />
|
|
15
|
+
</SwitchRoot>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts" generic="T extends boolean = boolean">
|
|
20
|
+
import { SwitchRoot, SwitchThumb } from 'reka-ui';
|
|
21
|
+
import { computed, inject, readonly, watchEffect } from 'vue';
|
|
22
|
+
import { uuid } from '@noeldemartin/utils';
|
|
23
|
+
import type { HTMLAttributes } from 'vue';
|
|
24
|
+
|
|
25
|
+
import type FormController from '@aerogel/core/forms/FormController';
|
|
26
|
+
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
27
|
+
import type { InputEmits, InputExpose, InputProps } from '@aerogel/core/components/contracts/Input';
|
|
28
|
+
|
|
29
|
+
defineOptions({ inheritAttrs: false });
|
|
30
|
+
|
|
31
|
+
const {
|
|
32
|
+
name,
|
|
33
|
+
label,
|
|
34
|
+
description,
|
|
35
|
+
modelValue,
|
|
36
|
+
class: rootClass,
|
|
37
|
+
} = defineProps<
|
|
38
|
+
InputProps<T> & {
|
|
39
|
+
class?: HTMLAttributes['class'];
|
|
40
|
+
labelClass?: HTMLAttributes['class'];
|
|
41
|
+
inputClass?: HTMLAttributes['class'];
|
|
42
|
+
thumbClass?: HTMLAttributes['class'];
|
|
43
|
+
}
|
|
44
|
+
>();
|
|
45
|
+
const emit = defineEmits<InputEmits>();
|
|
46
|
+
const form = inject<FormController | null>('form', null);
|
|
47
|
+
const errors = computed(() => {
|
|
48
|
+
if (!form || !name) {
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return form.errors[name] ?? null;
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const expose = {
|
|
56
|
+
id: `switch-${uuid()}`,
|
|
57
|
+
name: computed(() => name),
|
|
58
|
+
label: computed(() => label),
|
|
59
|
+
description: computed(() => description),
|
|
60
|
+
value: computed(() => {
|
|
61
|
+
if (form && name) {
|
|
62
|
+
return form.getFieldValue(name) as boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return modelValue;
|
|
66
|
+
}),
|
|
67
|
+
errors: readonly(errors),
|
|
68
|
+
required: computed(() => {
|
|
69
|
+
if (!name || !form) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return form.getFieldRules(name).includes('required');
|
|
74
|
+
}),
|
|
75
|
+
update(value) {
|
|
76
|
+
if (form && name) {
|
|
77
|
+
form.setFieldValue(name, value as FormFieldValue);
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
emit('update:modelValue', value);
|
|
83
|
+
},
|
|
84
|
+
} satisfies InputExpose;
|
|
85
|
+
|
|
86
|
+
defineExpose(expose);
|
|
87
|
+
|
|
88
|
+
watchEffect(() => {
|
|
89
|
+
if (!description && !errors.value) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// eslint-disable-next-line no-console
|
|
94
|
+
console.warn('Errors and description not implemented in <HeadlessSwitch>');
|
|
95
|
+
});
|
|
96
|
+
</script>
|
|
@@ -7,6 +7,7 @@ export { default as HeadlessInputLabel } from './HeadlessInputLabel.vue';
|
|
|
7
7
|
export { default as HeadlessInputTextArea } from './HeadlessInputTextArea.vue';
|
|
8
8
|
export { default as HeadlessModal } from './HeadlessModal.vue';
|
|
9
9
|
export { default as HeadlessModalContent } from './HeadlessModalContent.vue';
|
|
10
|
+
export { default as HeadlessModalDescription } from './HeadlessModalDescription.vue';
|
|
10
11
|
export { default as HeadlessModalOverlay } from './HeadlessModalOverlay.vue';
|
|
11
12
|
export { default as HeadlessModalTitle } from './HeadlessModalTitle.vue';
|
|
12
13
|
export { default as HeadlessSelect } from './HeadlessSelect.vue';
|
|
@@ -15,4 +16,5 @@ export { default as HeadlessSelectOption } from './HeadlessSelectOption.vue';
|
|
|
15
16
|
export { default as HeadlessSelectOptions } from './HeadlessSelectOptions.vue';
|
|
16
17
|
export { default as HeadlessSelectTrigger } from './HeadlessSelectTrigger.vue';
|
|
17
18
|
export { default as HeadlessSelectValue } from './HeadlessSelectValue.vue';
|
|
19
|
+
export { default as HeadlessSwitch } from './HeadlessSwitch.vue';
|
|
18
20
|
export { default as HeadlessToast } from './HeadlessToast.vue';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<details class="group">
|
|
3
3
|
<summary
|
|
4
|
-
class="-ml-2 flex w-[max-content]
|
|
4
|
+
class="-ml-2 flex w-[max-content] items-center rounded-lg py-2 pr-3 pl-1 hover:bg-gray-100 focus-visible:outline focus-visible:outline-gray-700"
|
|
5
5
|
>
|
|
6
6
|
<IconCheveronRight class="size-6 transition-transform group-open:rotate-90" />
|
|
7
7
|
<span>{{ $td('ui.advancedOptions', 'Advanced options') }}</span>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<Modal :title>
|
|
2
|
+
<Modal :title="renderedTitle" :title-hidden="titleHidden">
|
|
3
3
|
<Markdown :text="message" />
|
|
4
4
|
</Modal>
|
|
5
5
|
</template>
|
|
@@ -7,7 +7,11 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import Modal from '@aerogel/core/components/ui/Modal.vue';
|
|
9
9
|
import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
10
|
-
import
|
|
10
|
+
import { useAlertModal } from '@aerogel/core/components/contracts/AlertModal';
|
|
11
|
+
import type { AlertModalExpose, AlertModalProps } from '@aerogel/core/components/contracts/AlertModal';
|
|
11
12
|
|
|
12
|
-
defineProps<AlertModalProps>();
|
|
13
|
+
const props = defineProps<AlertModalProps>();
|
|
14
|
+
const { renderedTitle, titleHidden } = useAlertModal(props);
|
|
15
|
+
|
|
16
|
+
defineExpose<AlertModalExpose>();
|
|
13
17
|
</script>
|
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
|
|
8
10
|
import HeadlessButton from '@aerogel/core/components/headless/HeadlessButton.vue';
|
|
9
|
-
import {
|
|
11
|
+
import { variantClasses } from '@aerogel/core/utils/classes';
|
|
10
12
|
import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
|
|
11
13
|
import type { Variants } from '@aerogel/core/utils/classes';
|
|
12
14
|
|
|
@@ -14,23 +16,23 @@ const { class: baseClasses, size, variant, disabled, ...props } = defineProps<Bu
|
|
|
14
16
|
|
|
15
17
|
/* eslint-disable vue/max-len */
|
|
16
18
|
// prettier-ignore
|
|
17
|
-
const renderedClasses =
|
|
19
|
+
const renderedClasses = computed(() => variantClasses<Variants<Pick<ButtonProps, 'size' | 'variant' | 'disabled'>>>(
|
|
18
20
|
{ baseClasses, variant, size, disabled },
|
|
19
21
|
{
|
|
20
|
-
baseClasses: '
|
|
22
|
+
baseClasses: 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2',
|
|
21
23
|
variants: {
|
|
22
24
|
variant: {
|
|
23
|
-
default: 'bg-primary text-white focus-visible:outline-primary',
|
|
25
|
+
default: 'bg-primary-600 text-white focus-visible:outline-primary-600',
|
|
24
26
|
secondary: 'bg-background text-gray-900 ring-gray-300',
|
|
25
|
-
danger: 'bg-
|
|
27
|
+
danger: 'bg-red-600 text-white focus-visible:outline-red-600',
|
|
26
28
|
ghost: 'bg-transparent',
|
|
27
|
-
outline: 'bg-transparent text-primary ring-primary',
|
|
28
|
-
link: 'text-
|
|
29
|
+
outline: 'bg-transparent text-primary-600 ring-primary-600',
|
|
30
|
+
link: 'text-links',
|
|
29
31
|
},
|
|
30
32
|
size: {
|
|
31
|
-
small: 'text-xs',
|
|
32
|
-
default: 'text-sm',
|
|
33
|
-
large: 'text-base',
|
|
33
|
+
small: 'text-xs min-h-6',
|
|
34
|
+
default: 'text-sm min-h-8',
|
|
35
|
+
large: 'text-base min-h-10',
|
|
34
36
|
icon: 'rounded-full p-2.5',
|
|
35
37
|
},
|
|
36
38
|
disabled: {
|
|
@@ -41,7 +43,7 @@ const renderedClasses = computedVariantClasses<Variants<Pick<ButtonProps, 'size'
|
|
|
41
43
|
compoundVariants: [
|
|
42
44
|
{
|
|
43
45
|
variant: ['default', 'secondary', 'danger', 'ghost', 'outline'],
|
|
44
|
-
class: 'font-medium',
|
|
46
|
+
class: 'flex items-center justify-center gap-1 font-medium',
|
|
45
47
|
},
|
|
46
48
|
{
|
|
47
49
|
variant: ['default', 'danger'],
|
|
@@ -69,17 +71,17 @@ const renderedClasses = computedVariantClasses<Variants<Pick<ButtonProps, 'size'
|
|
|
69
71
|
{
|
|
70
72
|
variant: 'default',
|
|
71
73
|
disabled: false,
|
|
72
|
-
class: 'hover:bg-primary
|
|
74
|
+
class: 'hover:bg-primary-500',
|
|
73
75
|
},
|
|
74
76
|
{
|
|
75
77
|
variant: ['secondary', 'ghost', 'outline'],
|
|
76
78
|
disabled: false,
|
|
77
|
-
class: 'hover:bg-
|
|
79
|
+
class: 'hover:bg-gray-50',
|
|
78
80
|
},
|
|
79
81
|
{
|
|
80
82
|
variant: 'danger',
|
|
81
83
|
disabled: false,
|
|
82
|
-
class: 'hover:bg-
|
|
84
|
+
class: 'hover:bg-red-500',
|
|
83
85
|
},
|
|
84
86
|
{
|
|
85
87
|
variant: 'link',
|
|
@@ -93,6 +95,6 @@ const renderedClasses = computedVariantClasses<Variants<Pick<ButtonProps, 'size'
|
|
|
93
95
|
disabled: false,
|
|
94
96
|
},
|
|
95
97
|
},
|
|
96
|
-
);
|
|
98
|
+
));
|
|
97
99
|
/* eslint-enable vue/max-len */
|
|
98
100
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<HeadlessInput
|
|
3
|
-
ref="$
|
|
3
|
+
ref="$inputRef"
|
|
4
4
|
:class="renderedClasses"
|
|
5
5
|
v-bind="props"
|
|
6
6
|
@update:model-value="$emit('update:modelValue', $event)"
|
|
@@ -40,14 +40,14 @@ const { inputClass, labelClass, ...props } = defineProps<
|
|
|
40
40
|
InputProps & { inputClass?: HTMLAttributes['class']; labelClass?: HTMLAttributes['class'] }
|
|
41
41
|
>();
|
|
42
42
|
|
|
43
|
-
const $input = useTemplateRef('$
|
|
43
|
+
const $input = useTemplateRef('$inputRef');
|
|
44
44
|
const [inputAttrs, rootClasses] = useInputAttrs();
|
|
45
45
|
const renderedClasses = computed(() => classes('relative flex items-start', rootClasses.value));
|
|
46
46
|
const renderedInputClasses = computed(() =>
|
|
47
47
|
classes(
|
|
48
|
-
'size-4 rounded text-primary hover:bg-gray-200 checked:hover:
|
|
48
|
+
'size-4 rounded text-primary-600 not-checked:hover:bg-gray-200 checked:hover:text-primary-500 checked:border-0',
|
|
49
49
|
{
|
|
50
|
-
'border-gray-300 focus:ring-primary': !$input.value?.errors,
|
|
50
|
+
'border-gray-300 focus:ring-primary-600': !$input.value?.errors,
|
|
51
51
|
'border-red-400 border-2 focus:ring-red-600': $input.value?.errors,
|
|
52
52
|
},
|
|
53
53
|
inputClass,
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
2
|
+
<!-- @vue-generic {import('@aerogel/core/ui/UI').ModalExposeResult<ConfirmModalExpose>} -->
|
|
3
|
+
<Modal
|
|
4
|
+
v-slot="{ close }"
|
|
5
|
+
:title="renderedTitle"
|
|
6
|
+
:title-hidden="titleHidden"
|
|
7
|
+
persistent
|
|
8
|
+
>
|
|
3
9
|
<Form :form @submit="close([true, form.data()])">
|
|
4
10
|
<Markdown :text="message" :actions />
|
|
5
11
|
|
|
@@ -10,7 +16,7 @@
|
|
|
10
16
|
v-model="form[name]"
|
|
11
17
|
type="checkbox"
|
|
12
18
|
:required="checkbox.required"
|
|
13
|
-
class="border-primary text-primary hover:bg-primary
|
|
19
|
+
class="border-primary-600 text-primary-600 hover:bg-primary-50 hover:checked:bg-primary-500 focus:ring-primary-600 focus-visible:ring-primary-600 rounded border-2"
|
|
14
20
|
>
|
|
15
21
|
<span class="ml-1.5">{{ checkbox.label }}</span>
|
|
16
22
|
</label>
|
|
@@ -35,8 +41,10 @@ import Markdown from '@aerogel/core/components/ui/Markdown.vue';
|
|
|
35
41
|
import Button from '@aerogel/core/components/ui/Button.vue';
|
|
36
42
|
import Modal from '@aerogel/core/components/ui/Modal.vue';
|
|
37
43
|
import { useConfirmModal } from '@aerogel/core/components/contracts/ConfirmModal';
|
|
38
|
-
import type { ConfirmModalProps } from '@aerogel/core/components/contracts/ConfirmModal';
|
|
44
|
+
import type { ConfirmModalExpose, ConfirmModalProps } from '@aerogel/core/components/contracts/ConfirmModal';
|
|
39
45
|
|
|
40
46
|
const { cancelVariant = 'secondary', ...props } = defineProps<ConfirmModalProps>();
|
|
41
|
-
const { form, renderedAcceptText, renderedCancelText } = useConfirmModal(props);
|
|
47
|
+
const { form, renderedTitle, titleHidden, renderedAcceptText, renderedCancelText } = useConfirmModal(props);
|
|
48
|
+
|
|
49
|
+
defineExpose<ConfirmModalExpose>();
|
|
42
50
|
</script>
|
|
@@ -4,30 +4,29 @@
|
|
|
4
4
|
<slot />
|
|
5
5
|
</DropdownMenuTrigger>
|
|
6
6
|
<DropdownMenuPortal>
|
|
7
|
-
<
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
:key
|
|
11
|
-
class="flex w-full items-center rounded-lg px-2 py-2 text-sm text-gray-900 data-[highlighted]:bg-gray-100"
|
|
12
|
-
@select="option.click"
|
|
13
|
-
>
|
|
14
|
-
{{ option.label }}
|
|
15
|
-
</DropdownMenuItem>
|
|
16
|
-
</DropdownMenuContent>
|
|
7
|
+
<slot name="options">
|
|
8
|
+
<DropdownMenuOptions />
|
|
9
|
+
</slot>
|
|
17
10
|
</DropdownMenuPortal>
|
|
18
11
|
</DropdownMenuRoot>
|
|
19
12
|
</template>
|
|
20
13
|
|
|
21
14
|
<script setup lang="ts">
|
|
22
|
-
import {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
DropdownMenuPortal,
|
|
26
|
-
DropdownMenuRoot,
|
|
27
|
-
DropdownMenuTrigger,
|
|
28
|
-
} from 'reka-ui';
|
|
15
|
+
import { DropdownMenuPortal, DropdownMenuRoot, DropdownMenuTrigger } from 'reka-ui';
|
|
16
|
+
import { computed, provide } from 'vue';
|
|
17
|
+
import type { AcceptRefs } from '@aerogel/core/utils';
|
|
29
18
|
|
|
30
|
-
import type { DropdownMenuProps } from '@aerogel/core/components/contracts/DropdownMenu';
|
|
19
|
+
import type { DropdownMenuExpose, DropdownMenuProps } from '@aerogel/core/components/contracts/DropdownMenu';
|
|
31
20
|
|
|
32
|
-
|
|
21
|
+
import DropdownMenuOptions from './DropdownMenuOptions.vue';
|
|
22
|
+
|
|
23
|
+
const { align, side, options } = defineProps<DropdownMenuProps>();
|
|
24
|
+
const expose = {
|
|
25
|
+
align,
|
|
26
|
+
side,
|
|
27
|
+
options: computed(() => options?.filter(Boolean)),
|
|
28
|
+
} satisfies AcceptRefs<DropdownMenuExpose>;
|
|
29
|
+
|
|
30
|
+
provide('dropdown-menu', expose);
|
|
31
|
+
defineExpose(expose);
|
|
33
32
|
</script>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DropdownMenuItem :class="renderedClasses" v-bind="props" @select="$emit('select')">
|
|
3
|
+
<slot />
|
|
4
|
+
</DropdownMenuItem>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { classes } from '@aerogel/core/utils';
|
|
9
|
+
import { computed } from 'vue';
|
|
10
|
+
import { DropdownMenuItem } from 'reka-ui';
|
|
11
|
+
import type { HTMLAttributes } from 'vue';
|
|
12
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
13
|
+
|
|
14
|
+
defineEmits<{ select: [] }>();
|
|
15
|
+
|
|
16
|
+
const { class: rootClass, ...props } = defineProps<{ class?: HTMLAttributes['class'] } & PrimitiveProps>();
|
|
17
|
+
const renderedClasses = computed(() =>
|
|
18
|
+
classes(
|
|
19
|
+
'flex w-full items-center gap-2 rounded-lg px-2 py-2 text-sm text-gray-900 data-[highlighted]:bg-gray-100',
|
|
20
|
+
rootClass,
|
|
21
|
+
));
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<DropdownMenuContent
|
|
3
|
+
class="gap-y-0.5 rounded-lg bg-white p-1.5 shadow-lg ring-1 ring-black/5"
|
|
4
|
+
:align="dropdownMenu.align"
|
|
5
|
+
:side="dropdownMenu.side"
|
|
6
|
+
>
|
|
7
|
+
<slot>
|
|
8
|
+
<DropdownMenuOption
|
|
9
|
+
v-for="(option, key) in dropdownMenu.options"
|
|
10
|
+
:key
|
|
11
|
+
:as="option.route || option.href ? HeadlessButton : undefined"
|
|
12
|
+
:class="option.class"
|
|
13
|
+
v-bind="
|
|
14
|
+
option.route || option.href
|
|
15
|
+
? {
|
|
16
|
+
href: option.href,
|
|
17
|
+
route: option.route,
|
|
18
|
+
routeParams: option.routeParams,
|
|
19
|
+
routeQuery: option.routeQuery,
|
|
20
|
+
}
|
|
21
|
+
: {}
|
|
22
|
+
"
|
|
23
|
+
@select="option.click?.()"
|
|
24
|
+
>
|
|
25
|
+
{{ option.label }}
|
|
26
|
+
</DropdownMenuOption>
|
|
27
|
+
</slot>
|
|
28
|
+
</DropdownMenuContent>
|
|
29
|
+
</template>
|
|
30
|
+
|
|
31
|
+
<script setup lang="ts">
|
|
32
|
+
import { DropdownMenuContent } from 'reka-ui';
|
|
33
|
+
|
|
34
|
+
import { injectReactiveOrFail } from '@aerogel/core/utils';
|
|
35
|
+
import type { DropdownMenuExpose } from '@aerogel/core/components/contracts/DropdownMenu';
|
|
36
|
+
|
|
37
|
+
import DropdownMenuOption from './DropdownMenuOption.vue';
|
|
38
|
+
import HeadlessButton from '../headless/HeadlessButton.vue';
|
|
39
|
+
|
|
40
|
+
const dropdownMenu = injectReactiveOrFail<DropdownMenuExpose>(
|
|
41
|
+
'dropdown-menu',
|
|
42
|
+
'<DropdownMenuOptions> must be a child of a <DropdownMenu>',
|
|
43
|
+
);
|
|
44
|
+
</script>
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<span v-if="type === 'number'" class="inline-block transition-[width]" :class="editing ? 'w-5' : 'w-0'" />
|
|
10
10
|
<form class="w-full" :aria-hidden="formAriaHidden" @submit.prevent="$input?.blur()">
|
|
11
11
|
<input
|
|
12
|
-
ref="$
|
|
12
|
+
ref="$inputRef"
|
|
13
13
|
v-model="draft"
|
|
14
14
|
:tabindex="tabindex ?? undefined"
|
|
15
15
|
:aria-label="ariaLabel ?? undefined"
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
</template>
|
|
28
28
|
|
|
29
29
|
<script setup lang="ts">
|
|
30
|
-
import { computed, ref, watchEffect } from 'vue';
|
|
30
|
+
import { computed, ref, useTemplateRef, watchEffect } from 'vue';
|
|
31
31
|
import type { HTMLAttributes } from 'vue';
|
|
32
32
|
|
|
33
33
|
import { classes } from '@aerogel/core/utils/classes';
|
|
@@ -50,7 +50,7 @@ const {
|
|
|
50
50
|
text: string;
|
|
51
51
|
disabled?: boolean;
|
|
52
52
|
}>();
|
|
53
|
-
const $input =
|
|
53
|
+
const $input = useTemplateRef('$inputRef');
|
|
54
54
|
const editing = ref<string | null>(null);
|
|
55
55
|
const draft = ref(text);
|
|
56
56
|
const renderedContentClass = computed(() => classes('inline whitespace-pre', contentClass));
|