@aerogel/core 0.0.0-next.9aa7c279868edbedbcee075aef52212597d803fb → 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 +93 -66
- package/dist/aerogel-core.js +1064 -920
- package/dist/aerogel-core.js.map +1 -1
- package/package.json +2 -2
- package/src/components/contracts/AlertModal.ts +11 -0
- package/src/components/contracts/ConfirmModal.ts +3 -1
- package/src/components/contracts/DropdownMenu.ts +6 -1
- package/src/components/contracts/ErrorReportModal.ts +5 -4
- package/src/components/headless/HeadlessModal.vue +1 -1
- package/src/components/headless/HeadlessModalContent.vue +1 -1
- package/src/components/ui/AdvancedOptions.vue +1 -1
- package/src/components/ui/AlertModal.vue +5 -2
- package/src/components/ui/Button.vue +11 -9
- package/src/components/ui/ConfirmModal.vue +7 -2
- package/src/components/ui/DropdownMenuOption.vue +12 -4
- package/src/components/ui/DropdownMenuOptions.vue +18 -1
- package/src/components/ui/ErrorLogs.vue +19 -0
- package/src/components/ui/ErrorLogsModal.vue +48 -0
- package/src/components/ui/ErrorReportModal.vue +12 -6
- package/src/components/ui/Markdown.vue +16 -0
- package/src/components/ui/Modal.vue +7 -6
- package/src/components/ui/SelectOptions.vue +2 -2
- package/src/components/ui/Toast.vue +16 -14
- package/src/components/ui/index.ts +2 -0
- package/src/directives/measure.ts +11 -5
- package/src/errors/Errors.ts +17 -6
- package/src/index.css +3 -2
- package/src/ui/UI.ts +22 -12
- package/src/utils/classes.ts +9 -17
- package/src/utils/vue.ts +6 -1
package/src/ui/UI.ts
CHANGED
|
@@ -119,7 +119,7 @@ export class UIService extends Service {
|
|
|
119
119
|
};
|
|
120
120
|
};
|
|
121
121
|
|
|
122
|
-
this.
|
|
122
|
+
this.modal(this.requireComponent('alert-modal'), getProperties());
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/* eslint-disable max-len */
|
|
@@ -152,9 +152,7 @@ export class UIService extends Service {
|
|
|
152
152
|
};
|
|
153
153
|
|
|
154
154
|
const properties = getProperties();
|
|
155
|
-
const
|
|
156
|
-
const result = await modal.beforeClose;
|
|
157
|
-
|
|
155
|
+
const result = await this.modalForm(this.requireComponent('confirm-modal'), properties);
|
|
158
156
|
const confirmed = typeof result === 'object' ? result[0] : (result ?? false);
|
|
159
157
|
const checkboxes =
|
|
160
158
|
typeof result === 'object'
|
|
@@ -206,8 +204,7 @@ export class UIService extends Service {
|
|
|
206
204
|
} as PromptModalProps;
|
|
207
205
|
};
|
|
208
206
|
|
|
209
|
-
const
|
|
210
|
-
const rawResult = await modal.beforeClose;
|
|
207
|
+
const rawResult = await this.modalForm(this.requireComponent('prompt-modal'), getProperties());
|
|
211
208
|
const result = trim && typeof rawResult === 'string' ? rawResult?.trim() : rawResult;
|
|
212
209
|
|
|
213
210
|
return result ?? null;
|
|
@@ -240,7 +237,7 @@ export class UIService extends Service {
|
|
|
240
237
|
};
|
|
241
238
|
|
|
242
239
|
const { operationPromise, props } = processArgs();
|
|
243
|
-
const modal = await this.
|
|
240
|
+
const modal = await this.modal(this.requireComponent('loading-modal'), props);
|
|
244
241
|
|
|
245
242
|
try {
|
|
246
243
|
const result = await operationPromise;
|
|
@@ -264,16 +261,13 @@ export class UIService extends Service {
|
|
|
264
261
|
this.setState('toasts', this.toasts.concat(toast));
|
|
265
262
|
}
|
|
266
263
|
|
|
267
|
-
public
|
|
264
|
+
public modal<T extends Component>(
|
|
268
265
|
...args: {} extends ComponentProps<T>
|
|
269
266
|
? [component: T, props?: AcceptRefs<ComponentProps<T>>]
|
|
270
267
|
: [component: T, props: AcceptRefs<ComponentProps<T>>]
|
|
271
268
|
): Promise<UIModal<ModalResult<T>>>;
|
|
272
269
|
|
|
273
|
-
public async
|
|
274
|
-
component: T,
|
|
275
|
-
props?: ComponentProps<T>,
|
|
276
|
-
): Promise<UIModal<ModalResult<T>>> {
|
|
270
|
+
public async modal<T extends Component>(component: T, props?: ComponentProps<T>): Promise<UIModal<ModalResult<T>>> {
|
|
277
271
|
const id = uuid();
|
|
278
272
|
const callbacks: Partial<ModalCallbacks<ModalResult<T>>> = {};
|
|
279
273
|
const modal: UIModal<ModalResult<T>> = {
|
|
@@ -295,6 +289,22 @@ export class UIService extends Service {
|
|
|
295
289
|
return modal;
|
|
296
290
|
}
|
|
297
291
|
|
|
292
|
+
public modalForm<T extends Component>(
|
|
293
|
+
...args: {} extends ComponentProps<T>
|
|
294
|
+
? [component: T, props?: AcceptRefs<ComponentProps<T>>]
|
|
295
|
+
: [component: T, props: AcceptRefs<ComponentProps<T>>]
|
|
296
|
+
): Promise<ModalResult<T> | undefined>;
|
|
297
|
+
|
|
298
|
+
public async modalForm<T extends Component>(
|
|
299
|
+
component: T,
|
|
300
|
+
props?: ComponentProps<T>,
|
|
301
|
+
): Promise<ModalResult<T> | undefined> {
|
|
302
|
+
const modal = await this.modal<T>(component, props as ComponentProps<T>);
|
|
303
|
+
const result = await modal.beforeClose;
|
|
304
|
+
|
|
305
|
+
return result;
|
|
306
|
+
}
|
|
307
|
+
|
|
298
308
|
public async closeModal(id: string, result?: unknown): Promise<void> {
|
|
299
309
|
if (!App.isMounted()) {
|
|
300
310
|
await this.removeModal(id, result);
|
package/src/utils/classes.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import {
|
|
2
|
+
import { unref } from 'vue';
|
|
3
3
|
import { cva } from 'class-variance-authority';
|
|
4
4
|
import { twMerge } from 'tailwind-merge';
|
|
5
5
|
import type { ClassValue } from 'clsx';
|
|
6
|
-
import type {
|
|
6
|
+
import type { PropType } from 'vue';
|
|
7
7
|
import type { GetClosureArgs, GetClosureResult } from '@noeldemartin/utils';
|
|
8
8
|
|
|
9
9
|
export type CVAConfig<T> = NonNullable<GetClosureArgs<typeof cva<T>>[1]>;
|
|
10
10
|
export type CVAProps<T> = NonNullable<GetClosureArgs<GetClosureResult<typeof cva<T>>>[0]>;
|
|
11
|
-
export type RefsObject<T> = { [K in keyof T]: Ref<T[K]> | T[K] };
|
|
12
11
|
export type Variants<T extends Record<string, string | boolean>> = Required<{
|
|
13
12
|
[K in keyof T]: Exclude<T[K], undefined> extends string
|
|
14
13
|
? { [key in Exclude<T[K], undefined>]: string | null }
|
|
@@ -26,22 +25,15 @@ export type PickComponentProps<TValues, TDefinitions> = {
|
|
|
26
25
|
[K in keyof TValues]: K extends keyof TDefinitions ? TValues[K] : never;
|
|
27
26
|
};
|
|
28
27
|
|
|
29
|
-
export function
|
|
30
|
-
value:
|
|
28
|
+
export function variantClasses<T>(
|
|
29
|
+
value: { baseClasses?: string } & CVAProps<T>,
|
|
31
30
|
config: { baseClasses?: string } & CVAConfig<T>,
|
|
32
|
-
):
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const variants = cva(configBaseClasses, configs as CVAConfig<T>);
|
|
37
|
-
const values = Object.entries(valueRefs).reduce((extractedValues, [name, valueRef]) => {
|
|
38
|
-
extractedValues[name as keyof CVAProps<T>] = unref(valueRef);
|
|
31
|
+
): string {
|
|
32
|
+
const { baseClasses: valueBaseClasses, ...values } = value;
|
|
33
|
+
const { baseClasses: configBaseClasses, ...configs } = config;
|
|
34
|
+
const variants = cva(configBaseClasses, configs as CVAConfig<T>);
|
|
39
35
|
|
|
40
|
-
|
|
41
|
-
}, {} as CVAProps<T>);
|
|
42
|
-
|
|
43
|
-
return classes(variants(values), unref(valueBaseClasses));
|
|
44
|
-
});
|
|
36
|
+
return classes(variants(values as CVAProps<T>), unref(valueBaseClasses));
|
|
45
37
|
}
|
|
46
38
|
|
|
47
39
|
export function classes(...inputs: ClassValue[]): string {
|
package/src/utils/vue.ts
CHANGED
|
@@ -12,7 +12,12 @@ function renderVNodeAttrs(node: VNode): string {
|
|
|
12
12
|
}, '');
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
|
+
export function defineDirective<TValue = any, TModifiers extends string = string>(
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
directive: Directive<any, TValue, TModifiers>,
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
20
|
+
): Directive<any, TValue, TModifiers> {
|
|
16
21
|
return directive;
|
|
17
22
|
}
|
|
18
23
|
|