@aerogel/core 0.1.1-next.97f5cf5c97f16ab8a0ef63b82aaab049a0f9e15b → 0.1.1-next.a33efa4fd6560f7df50d8a64a9e9e2a2f62e79bb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aerogel-core.d.ts +101 -69
- package/dist/aerogel-core.js +1021 -980
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +1 -1
- package/src/components/contracts/Button.ts +1 -1
- package/src/components/contracts/Modal.ts +2 -0
- package/src/components/contracts/Toast.ts +1 -1
- package/src/components/headless/HeadlessInputInput.vue +13 -5
- package/src/components/ui/AdvancedOptions.vue +4 -13
- package/src/components/ui/Button.vue +1 -0
- package/src/components/ui/Details.vue +20 -0
- package/src/components/ui/Modal.vue +25 -10
- package/src/components/ui/Toast.vue +1 -0
- package/src/components/ui/index.ts +1 -0
- package/src/forms/FormController.ts +4 -0
- package/src/index.css +9 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/time.ts +2 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PrimitiveProps } from 'reka-ui';
|
|
2
2
|
import type { HTMLAttributes } from 'vue';
|
|
3
3
|
|
|
4
|
-
export type ButtonVariant = 'default' | 'secondary' | 'danger' | 'ghost' | 'outline' | 'link';
|
|
4
|
+
export type ButtonVariant = 'default' | 'secondary' | 'danger' | 'warning' | 'ghost' | 'outline' | 'link';
|
|
5
5
|
export type ButtonSize = 'default' | 'small' | 'large' | 'icon';
|
|
6
6
|
export interface ButtonProps extends PrimitiveProps {
|
|
7
7
|
class?: HTMLAttributes['class'];
|
|
@@ -19,6 +19,7 @@ import { computed, inject, useTemplateRef, watchEffect } from 'vue';
|
|
|
19
19
|
|
|
20
20
|
import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
|
|
21
21
|
import { onFormFocus } from '@aerogel/core/utils/composition/forms';
|
|
22
|
+
import { LOCAL_TIMEZONE_OFFSET } from '@aerogel/core/utils';
|
|
22
23
|
import type FormController from '@aerogel/core/forms/FormController';
|
|
23
24
|
import type { FormFieldValue } from '@aerogel/core/forms/FormController';
|
|
24
25
|
import type { InputExpose } from '@aerogel/core/components/contracts/Input';
|
|
@@ -39,7 +40,7 @@ const renderedType = computed(() => {
|
|
|
39
40
|
return ['text', 'email', 'number', 'tel', 'url'].includes(fieldType) ? fieldType : 'text';
|
|
40
41
|
});
|
|
41
42
|
const checked = computed(() => {
|
|
42
|
-
if (
|
|
43
|
+
if (renderedType.value !== 'checkbox') {
|
|
43
44
|
return;
|
|
44
45
|
}
|
|
45
46
|
|
|
@@ -59,11 +60,15 @@ function getValue(): FormFieldValue | null {
|
|
|
59
60
|
return null;
|
|
60
61
|
}
|
|
61
62
|
|
|
62
|
-
switch (
|
|
63
|
+
switch (renderedType.value) {
|
|
63
64
|
case 'checkbox':
|
|
64
65
|
return $input.value.checked;
|
|
65
66
|
case 'date':
|
|
66
|
-
|
|
67
|
+
case 'time':
|
|
68
|
+
case 'datetime-local':
|
|
69
|
+
return new Date(Math.round($input.value.valueAsNumber / 60000) * 60000 + LOCAL_TIMEZONE_OFFSET);
|
|
70
|
+
case 'number':
|
|
71
|
+
return $input.value.valueAsNumber;
|
|
67
72
|
default:
|
|
68
73
|
return $input.value.value;
|
|
69
74
|
}
|
|
@@ -75,8 +80,11 @@ watchEffect(() => {
|
|
|
75
80
|
return;
|
|
76
81
|
}
|
|
77
82
|
|
|
78
|
-
if (
|
|
79
|
-
|
|
83
|
+
if (['date', 'time', 'datetime-local'].includes(renderedType.value) && value.value instanceof Date) {
|
|
84
|
+
const roundedValue = Math.round(value.value.getTime() / 60000) * 60000;
|
|
85
|
+
|
|
86
|
+
$input.value.valueAsNumber = roundedValue - LOCAL_TIMEZONE_OFFSET;
|
|
87
|
+
input.update(new Date(roundedValue));
|
|
80
88
|
|
|
81
89
|
return;
|
|
82
90
|
}
|
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
>
|
|
6
|
-
<IconCheveronRight class="size-6 transition-transform group-open:rotate-90" />
|
|
7
|
-
<span>{{ $td('ui.advancedOptions', 'Advanced options') }}</span>
|
|
8
|
-
</summary>
|
|
9
|
-
|
|
10
|
-
<div class="pt-2 pl-4">
|
|
11
|
-
<slot />
|
|
12
|
-
</div>
|
|
13
|
-
</details>
|
|
2
|
+
<Details :label="$td('ui.advancedOptions', 'Advanced options')">
|
|
3
|
+
<slot />
|
|
4
|
+
</Details>
|
|
14
5
|
</template>
|
|
15
6
|
|
|
16
7
|
<script setup lang="ts">
|
|
17
|
-
import
|
|
8
|
+
import Details from './Details.vue';
|
|
18
9
|
</script>
|
|
@@ -25,6 +25,7 @@ const renderedClasses = computed(() => variantClasses<Variants<Pick<ButtonProps,
|
|
|
25
25
|
default: 'bg-primary-600 text-white focus-visible:outline-primary-600',
|
|
26
26
|
secondary: 'bg-background text-gray-900 ring-gray-300',
|
|
27
27
|
danger: 'bg-red-600 text-white focus-visible:outline-red-600',
|
|
28
|
+
warning: 'bg-yellow-600 text-white focus-visible:outline-yellow-600',
|
|
28
29
|
ghost: 'bg-transparent',
|
|
29
30
|
outline: 'bg-transparent text-primary-600 ring-primary-600',
|
|
30
31
|
link: 'text-links',
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<details class="group">
|
|
3
|
+
<summary
|
|
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
|
+
>
|
|
6
|
+
<IconCheveronRight class="size-6 transition-transform group-open:rotate-90" />
|
|
7
|
+
<span>{{ label }}</span>
|
|
8
|
+
</summary>
|
|
9
|
+
|
|
10
|
+
<div class="pt-2 pl-4">
|
|
11
|
+
<slot />
|
|
12
|
+
</div>
|
|
13
|
+
</details>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import IconCheveronRight from '~icons/zondicons/cheveron-right';
|
|
18
|
+
|
|
19
|
+
defineProps<{ label: string }>();
|
|
20
|
+
</script>
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
'animate-[fade-in_var(--tw-duration)_ease-in-out]': !hasRenderedModals,
|
|
13
13
|
'bg-black/30': firstVisibleModal?.id === id || (!firstVisibleModal && modals[0]?.id === id),
|
|
14
14
|
'opacity-0': !firstVisibleModal,
|
|
15
|
+
hidden: renderFullscreen,
|
|
15
16
|
}"
|
|
16
17
|
/>
|
|
17
18
|
<HeadlessModalContent v-bind="contentProps" :class="renderedWrapperClass">
|
|
@@ -67,6 +68,7 @@ import HeadlessModalContent from '@aerogel/core/components/headless/HeadlessModa
|
|
|
67
68
|
import HeadlessModalDescription from '@aerogel/core/components/headless/HeadlessModalDescription.vue';
|
|
68
69
|
import HeadlessModalOverlay from '@aerogel/core/components/headless/HeadlessModalOverlay.vue';
|
|
69
70
|
import HeadlessModalTitle from '@aerogel/core/components/headless/HeadlessModalTitle.vue';
|
|
71
|
+
import UI from '@aerogel/core/ui/UI';
|
|
70
72
|
import { classes } from '@aerogel/core/utils/classes';
|
|
71
73
|
import { reactiveSet } from '@aerogel/core/utils';
|
|
72
74
|
import { injectModal, modals, useModal } from '@aerogel/core/ui/modals';
|
|
@@ -88,6 +90,8 @@ const {
|
|
|
88
90
|
description,
|
|
89
91
|
persistent,
|
|
90
92
|
closeHidden,
|
|
93
|
+
fullscreen,
|
|
94
|
+
fullscreenMobile,
|
|
91
95
|
...props
|
|
92
96
|
} = defineProps<
|
|
93
97
|
ModalProps & {
|
|
@@ -113,18 +117,29 @@ const firstVisibleModal = computed(() => modals.value.find((modal) => modal.visi
|
|
|
113
117
|
const hasRenderedModals = computed(() => modals.value.some((modal) => renderedModals.has(modal)));
|
|
114
118
|
const contentProps = computed(() => (description ? {} : { 'aria-describedby': undefined }));
|
|
115
119
|
const renderedContentClass = computed(() =>
|
|
116
|
-
classes(
|
|
120
|
+
classes(
|
|
121
|
+
'overflow-auto px-4 pb-4',
|
|
122
|
+
{ 'pt-4': !title || titleHidden, 'max-h-[90vh]': !renderFullscreen.value },
|
|
123
|
+
contentClass,
|
|
124
|
+
));
|
|
125
|
+
const renderFullscreen = computed(() => fullscreen || (fullscreenMobile && UI.mobile));
|
|
117
126
|
const renderedWrapperClass = computed(() =>
|
|
118
127
|
classes(
|
|
119
|
-
'isolate fixed
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
'isolate fixed z-50 flex flex-col overflow-hidden bg-white text-left duration-300',
|
|
129
|
+
renderFullscreen.value
|
|
130
|
+
? [
|
|
131
|
+
'inset-0 transition-[transform,translate] will-change-[transform,translate]',
|
|
132
|
+
renderedModals.has(modal.value) || 'animate-[slide-in_var(--tw-duration)_ease-in-out]',
|
|
133
|
+
inForeground.value ? 'translate-y-0' : 'translate-y-full',
|
|
134
|
+
]
|
|
135
|
+
: [
|
|
136
|
+
'top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-full',
|
|
137
|
+
'max-w-[calc(100%-2rem)] rounded-lg shadow-xl sm:max-w-lg',
|
|
138
|
+
'transition-[scale,opacity] will-change-[scale,opacity]',
|
|
139
|
+
renderedModals.has(modal.value) ||
|
|
140
|
+
'animate-[fade-in_var(--tw-duration)_ease-in-out,grow_var(--tw-duration)_ease-in-out]',
|
|
141
|
+
inForeground.value ? 'scale-100 opacity-100' : 'scale-50 opacity-0',
|
|
142
|
+
],
|
|
128
143
|
wrapperClass,
|
|
129
144
|
));
|
|
130
145
|
|
|
@@ -3,6 +3,7 @@ export { default as AlertModal } from './AlertModal.vue';
|
|
|
3
3
|
export { default as Button } from './Button.vue';
|
|
4
4
|
export { default as Checkbox } from './Checkbox.vue';
|
|
5
5
|
export { default as ConfirmModal } from './ConfirmModal.vue';
|
|
6
|
+
export { default as Details } from './Details.vue';
|
|
6
7
|
export { default as DropdownMenu } from './DropdownMenu.vue';
|
|
7
8
|
export { default as DropdownMenuOption } from './DropdownMenuOption.vue';
|
|
8
9
|
export { default as DropdownMenuOptions } from './DropdownMenuOptions.vue';
|
|
@@ -112,6 +112,10 @@ export default class FormController<Fields extends FormFieldDefinitions = FormFi
|
|
|
112
112
|
return this._fields[field]?.rules?.split('|') ?? [];
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
+
public setFieldErrors<T extends keyof Fields>(field: T, errors: string[] | null): void {
|
|
116
|
+
this._errors[field] = errors;
|
|
117
|
+
}
|
|
118
|
+
|
|
115
119
|
public getFieldType<T extends keyof Fields>(field: T): FormFieldType | null {
|
|
116
120
|
return this._fields[field]?.type ?? null;
|
|
117
121
|
}
|
package/src/index.css
CHANGED
package/src/utils/index.ts
CHANGED