@aerogel/core 0.1.1-next.1e4498f367b830c7a83435800066bb8261d179f5 → 0.1.1-next.3efa6858f5942a7048392e08e88f511c6c5ca343
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 +1032 -993
- 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 +9 -3
- 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 +30 -11
- 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';
|
|
@@ -63,7 +64,9 @@ function getValue(): FormFieldValue | null {
|
|
|
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);
|
|
67
70
|
case 'number':
|
|
68
71
|
return $input.value.valueAsNumber;
|
|
69
72
|
default:
|
|
@@ -77,8 +80,11 @@ watchEffect(() => {
|
|
|
77
80
|
return;
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
if (
|
|
81
|
-
|
|
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));
|
|
82
88
|
|
|
83
89
|
return;
|
|
84
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,10 +12,15 @@
|
|
|
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">
|
|
18
|
-
<div
|
|
19
|
+
<div
|
|
20
|
+
v-if="!persistent && !closeHidden"
|
|
21
|
+
class="absolute top-0 right-0 pt-3.5 pr-2.5"
|
|
22
|
+
:class="{ 'hidden sm:block': !renderFullscreen }"
|
|
23
|
+
>
|
|
19
24
|
<button
|
|
20
25
|
type="button"
|
|
21
26
|
class="clickable z-10 rounded-full p-2.5 text-gray-400 hover:text-gray-500"
|
|
@@ -67,6 +72,7 @@ import HeadlessModalContent from '@aerogel/core/components/headless/HeadlessModa
|
|
|
67
72
|
import HeadlessModalDescription from '@aerogel/core/components/headless/HeadlessModalDescription.vue';
|
|
68
73
|
import HeadlessModalOverlay from '@aerogel/core/components/headless/HeadlessModalOverlay.vue';
|
|
69
74
|
import HeadlessModalTitle from '@aerogel/core/components/headless/HeadlessModalTitle.vue';
|
|
75
|
+
import UI from '@aerogel/core/ui/UI';
|
|
70
76
|
import { classes } from '@aerogel/core/utils/classes';
|
|
71
77
|
import { reactiveSet } from '@aerogel/core/utils';
|
|
72
78
|
import { injectModal, modals, useModal } from '@aerogel/core/ui/modals';
|
|
@@ -88,6 +94,8 @@ const {
|
|
|
88
94
|
description,
|
|
89
95
|
persistent,
|
|
90
96
|
closeHidden,
|
|
97
|
+
fullscreen,
|
|
98
|
+
fullscreenMobile,
|
|
91
99
|
...props
|
|
92
100
|
} = defineProps<
|
|
93
101
|
ModalProps & {
|
|
@@ -113,18 +121,29 @@ const firstVisibleModal = computed(() => modals.value.find((modal) => modal.visi
|
|
|
113
121
|
const hasRenderedModals = computed(() => modals.value.some((modal) => renderedModals.has(modal)));
|
|
114
122
|
const contentProps = computed(() => (description ? {} : { 'aria-describedby': undefined }));
|
|
115
123
|
const renderedContentClass = computed(() =>
|
|
116
|
-
classes(
|
|
124
|
+
classes(
|
|
125
|
+
'overflow-auto px-4 pb-4',
|
|
126
|
+
{ 'pt-4': !title || titleHidden, 'max-h-[90vh]': !renderFullscreen.value },
|
|
127
|
+
contentClass,
|
|
128
|
+
));
|
|
129
|
+
const renderFullscreen = computed(() => fullscreen || (fullscreenMobile && UI.mobile));
|
|
117
130
|
const renderedWrapperClass = computed(() =>
|
|
118
131
|
classes(
|
|
119
|
-
'isolate fixed
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
132
|
+
'isolate fixed z-50 flex flex-col overflow-hidden bg-white text-left duration-300',
|
|
133
|
+
renderFullscreen.value
|
|
134
|
+
? [
|
|
135
|
+
'inset-0 transition-[transform,translate] will-change-[transform,translate]',
|
|
136
|
+
renderedModals.has(modal.value) || 'animate-[slide-in_var(--tw-duration)_ease-in-out]',
|
|
137
|
+
inForeground.value ? 'translate-y-0' : 'translate-y-full',
|
|
138
|
+
]
|
|
139
|
+
: [
|
|
140
|
+
'top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-full',
|
|
141
|
+
'max-w-[calc(100%-2rem)] rounded-lg shadow-xl sm:max-w-lg',
|
|
142
|
+
'transition-[scale,opacity] will-change-[scale,opacity]',
|
|
143
|
+
renderedModals.has(modal.value) ||
|
|
144
|
+
'animate-[fade-in_var(--tw-duration)_ease-in-out,grow_var(--tw-duration)_ease-in-out]',
|
|
145
|
+
inForeground.value ? 'scale-100 opacity-100' : 'scale-50 opacity-0',
|
|
146
|
+
],
|
|
128
147
|
wrapperClass,
|
|
129
148
|
));
|
|
130
149
|
|
|
@@ -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