@aerogel/core 0.0.0-next.ea2e864c719d0a4d01b04729a9b681c0e9c85ea7 → 0.0.0-next.ec720bb060627e76b204dc15f6bf955d11a77cbc

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerogel/core",
3
- "version": "0.0.0-next.ea2e864c719d0a4d01b04729a9b681c0e9c85ea7",
3
+ "version": "0.0.0-next.ec720bb060627e76b204dc15f6bf955d11a77cbc",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <div class="mt-4 flex" :class="{ 'flex-col': layout === 'vertical' }">
3
+ <div class="flex-grow">
4
+ <h3 :id="titleId" class="text-base font-semibold">
5
+ {{ title }}
6
+ </h3>
7
+ <Markdown v-if="description" :text="description" class="mt-1 text-sm text-gray-500" />
8
+ </div>
9
+
10
+ <div :class="renderedRootClass">
11
+ <slot />
12
+ </div>
13
+ </div>
14
+ </template>
15
+
16
+ <script setup lang="ts">
17
+ import { computed } from 'vue';
18
+ import type { HTMLAttributes } from 'vue';
19
+
20
+ import Markdown from '@aerogel/core/components/ui/Markdown.vue';
21
+ import { classes } from '@aerogel/core/utils';
22
+
23
+ const { layout = 'horizontal', class: rootClass } = defineProps<{
24
+ title: string;
25
+ titleId?: string;
26
+ description?: string;
27
+ class?: HTMLAttributes['class'];
28
+ layout?: 'vertical' | 'horizontal';
29
+ }>();
30
+ const renderedRootClass = computed(() => classes(rootClass, 'flex flex-col justify-center gap-1'));
31
+ </script>
@@ -27,6 +27,7 @@ export { default as SelectLabel } from './SelectLabel.vue';
27
27
  export { default as SelectOption } from './SelectOption.vue';
28
28
  export { default as SelectOptions } from './SelectOptions.vue';
29
29
  export { default as SelectTrigger } from './SelectTrigger.vue';
30
+ export { default as Setting } from './Setting.vue';
30
31
  export { default as SettingsModal } from './SettingsModal.vue';
31
32
  export { default as StartupCrash } from './StartupCrash.vue';
32
33
  export { default as Switch } from './Switch.vue';
@@ -1,26 +1,19 @@
1
1
  <template>
2
- <div class="mt-4 flex flex-row">
3
- <div class="flex-grow">
4
- <h3 id="debug-setting" class="text-base font-semibold">
5
- {{ $td('settings.debug', 'Debugging') }}
6
- </h3>
7
- <Markdown
8
- lang-key="settings.debugDescription"
9
- lang-default="Enable debugging with [Eruda](https://eruda.liriliri.io/)."
10
- class="mt-1 text-sm text-gray-500"
11
- />
12
- </div>
13
-
2
+ <Setting
3
+ title-id="debug-setting"
4
+ :title="$td('settings.debug', 'Debugging')"
5
+ :description="$td('settings.debugDescription', 'Enable debugging with [Eruda](https://eruda.liriliri.io/).')"
6
+ >
14
7
  <Switch v-model="enabled" aria-labelledby="debug-setting" />
15
- </div>
8
+ </Setting>
16
9
  </template>
17
10
 
18
11
  <script setup lang="ts">
19
12
  import { ref, watchEffect } from 'vue';
20
13
  import type Eruda from 'eruda';
21
14
 
15
+ import Setting from '@aerogel/core/components/ui/Setting.vue';
22
16
  import Switch from '@aerogel/core/components/ui/Switch.vue';
23
- import Markdown from '@aerogel/core/components/ui/Markdown.vue';
24
17
 
25
18
  let eruda: typeof Eruda | null = null;
26
19
  const enabled = ref(false);
@@ -2,10 +2,13 @@ import { isTesting } from '@noeldemartin/utils';
2
2
  import type { GetClosureArgs } from '@noeldemartin/utils';
3
3
 
4
4
  import Events from '@aerogel/core/services/Events';
5
+ import { App } from '@aerogel/core/services';
5
6
  import { definePlugin } from '@aerogel/core/plugins';
7
+ import type { Services } from '@aerogel/core/services';
6
8
 
7
9
  export interface AerogelTestingRuntime {
8
10
  on: (typeof Events)['on'];
11
+ service<T extends keyof Services>(name: T): Services[T] | null;
9
12
  }
10
13
 
11
14
  export default definePlugin({
@@ -16,6 +19,7 @@ export default definePlugin({
16
19
 
17
20
  globalThis.testingRuntime = {
18
21
  on: ((...args: GetClosureArgs<(typeof Events)['on']>) => Events.on(...args)) as (typeof Events)['on'],
22
+ service: (name) => App.service(name),
19
23
  };
20
24
  },
21
25
  });
package/src/ui/UI.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { after, facade, fail, isDevelopment, required, uuid } from '@noeldemartin/utils';
2
- import { markRaw, nextTick } from 'vue';
2
+ import { markRaw, nextTick, unref } from 'vue';
3
3
  import type { ComponentExposed, ComponentProps } from 'vue-component-type-helpers';
4
4
  import type { Component } from 'vue';
5
5
  import type { ClosureArgs } from '@noeldemartin/utils';
@@ -64,6 +64,7 @@ export type LoadingOptions = AcceptRefs<{
64
64
  title?: string;
65
65
  message?: string;
66
66
  progress?: number;
67
+ delay?: number;
67
68
  }>;
68
69
 
69
70
  export interface ConfirmOptionsWithCheckboxes<T extends ConfirmModalCheckboxes = ConfirmModalCheckboxes>
@@ -218,7 +219,11 @@ export class UIService extends Service {
218
219
  operation?: Promise<T> | (() => T),
219
220
  ): Promise<T> {
220
221
  const processOperation = (o: Promise<T> | (() => T)) => (typeof o === 'function' ? Promise.resolve(o()) : o);
221
- const processArgs = (): { operationPromise: Promise<T>; props?: AcceptRefs<LoadingModalProps> } => {
222
+ const processArgs = (): {
223
+ operationPromise: Promise<T>;
224
+ props?: AcceptRefs<LoadingModalProps>;
225
+ delay?: number;
226
+ } => {
222
227
  if (typeof operationOrMessageOrOptions === 'string') {
223
228
  return {
224
229
  props: { message: operationOrMessageOrOptions },
@@ -230,13 +235,24 @@ export class UIService extends Service {
230
235
  return { operationPromise: processOperation(operationOrMessageOrOptions) };
231
236
  }
232
237
 
238
+ const { delay, ...props } = operationOrMessageOrOptions;
239
+
233
240
  return {
234
- props: operationOrMessageOrOptions,
241
+ props,
242
+ delay: unref(delay),
235
243
  operationPromise: processOperation(operation as Promise<T> | (() => T)),
236
244
  };
237
245
  };
238
246
 
239
- const { operationPromise, props } = processArgs();
247
+ let delayed = false;
248
+ const { operationPromise, props, delay } = processArgs();
249
+
250
+ delay && (await Promise.race([after({ ms: delay }).then(() => (delayed = true)), operationPromise]));
251
+
252
+ if (delay && !delayed) {
253
+ return operationPromise;
254
+ }
255
+
240
256
  const modal = await this.modal(this.requireComponent('loading-modal'), props);
241
257
 
242
258
  try {