@aerogel/core 0.1.1-next.7f33b133934b479bdeee0808001759d92e987cf9 → 0.1.1-next.83b702b110078faef3926d147f4746121b64a2d5

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.1.1-next.7f33b133934b479bdeee0808001759d92e987cf9",
3
+ "version": "0.1.1-next.83b702b110078faef3926d147f4746121b64a2d5",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -35,6 +35,7 @@
35
35
  "clsx": "^2.1.1",
36
36
  "dompurify": "^3.2.4",
37
37
  "eruda": "^3.4.1",
38
+ "eruda-indexeddb": "^0.1.1",
38
39
  "marked": "^15.0.7",
39
40
  "pinia": "^2.1.6",
40
41
  "reka-ui": "^2.2.0",
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="flex min-h-full flex-col text-base leading-tight font-normal text-gray-900 antialiased">
2
+ <div class="text-primary-text flex min-h-full flex-col text-base leading-tight font-normal antialiased">
3
3
  <slot v-if="$errors.hasStartupErrors" name="startup-crash">
4
4
  <component :is="$ui.requireComponent('startup-crash')" />
5
5
  </slot>
@@ -5,6 +5,8 @@ export type ModalContentInstance = Nullable<InstanceType<typeof DialogContent>>;
5
5
 
6
6
  export interface ModalProps {
7
7
  persistent?: boolean;
8
+ fullscreen?: boolean;
9
+ fullscreenOnMobile?: boolean;
8
10
  title?: string;
9
11
  titleHidden?: boolean;
10
12
  description?: string;
@@ -1,8 +1,11 @@
1
+ import { computed, inject, provide, readonly } from 'vue';
2
+ import { evaluate, toString, uuid } from '@noeldemartin/utils';
1
3
  import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
2
- import type { Component, ComputedRef, HTMLAttributes } from 'vue';
4
+ import type { Component, ComputedRef, EmitFn, HTMLAttributes } from 'vue';
3
5
  import type { Nullable } from '@noeldemartin/utils';
4
6
 
5
- import type { FormFieldValue } from '@aerogel/core/forms';
7
+ import { translateWithDefault } from '@aerogel/core/lang';
8
+ import type { FormController, FormFieldValue } from '@aerogel/core/forms';
6
9
 
7
10
  import type { InputEmits, InputExpose, InputProps } from './Input';
8
11
 
@@ -43,3 +46,78 @@ export interface SelectExpose<T extends Nullable<FormFieldValue> = Nullable<Form
43
46
  export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
44
47
  return typeof option === 'object' && option !== null && 'label' in option;
45
48
  }
49
+
50
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
51
+ export function useSelect<T extends Nullable<FormFieldValue>>(props: SelectProps<T>, emit: EmitFn<SelectEmits<T>>) {
52
+ const form = inject<FormController | null>('form', null);
53
+ const computedValue = computed(() => {
54
+ if (form && props.name) {
55
+ return form.getFieldValue(props.name) as T;
56
+ }
57
+
58
+ return props.modelValue as T;
59
+ });
60
+ const acceptableValue = computed(() => computedValue.value as AcceptableValue);
61
+ const errors = computed(() => {
62
+ if (!form || !props.name) {
63
+ return null;
64
+ }
65
+
66
+ return form.errors[props.name] ?? null;
67
+ });
68
+ const computedOptions = computed(() => {
69
+ if (!props.options) {
70
+ return null;
71
+ }
72
+
73
+ return props.options.map((option) => ({
74
+ key: uuid(),
75
+ label: props.renderOption
76
+ ? props.renderOption(option)
77
+ : hasSelectOptionLabel(option)
78
+ ? evaluate(option.label as string)
79
+ : toString(option),
80
+ value: option as AcceptableValue,
81
+ }));
82
+ });
83
+
84
+ const expose = {
85
+ labelClass: props.labelClass,
86
+ optionsClass: props.optionsClass,
87
+ align: props.align,
88
+ side: props.side,
89
+ value: computedValue,
90
+ id: `select-${uuid()}`,
91
+ name: computed(() => props.name),
92
+ label: computed(() => props.label),
93
+ description: computed(() => props.description),
94
+ placeholder: computed(() => props.placeholder ?? translateWithDefault('ui.select', 'Select an option')),
95
+ options: computedOptions,
96
+ selectedOption: computed(() => computedOptions.value?.find((option) => option.value === props.modelValue)),
97
+ errors: readonly(errors),
98
+ required: computed(() => {
99
+ if (!props.name || !form) {
100
+ return;
101
+ }
102
+
103
+ return form.getFieldRules(props.name).includes('required');
104
+ }),
105
+ update(value) {
106
+ if (form && props.name) {
107
+ form.setFieldValue(props.name, value as FormFieldValue);
108
+
109
+ return;
110
+ }
111
+
112
+ emit('update:modelValue', value);
113
+ },
114
+ } satisfies SelectExpose<T>;
115
+
116
+ function update(value: AcceptableValue) {
117
+ expose.update(value as T);
118
+ }
119
+
120
+ provide('select', expose);
121
+
122
+ return { expose, update, acceptableValue };
123
+ }
@@ -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
- return $input.value.valueAsDate;
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 (renderedType.value === 'date' && value.value instanceof Date) {
81
- $input.value.valueAsDate = value.value;
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
  }
@@ -2,7 +2,7 @@
2
2
  <SelectRoot
3
3
  v-slot="{ open }"
4
4
  :model-value="acceptableValue"
5
- :by="compareOptions as Closure<[AcceptableValue, AcceptableValue], boolean>"
5
+ :by="compareOptions"
6
6
  @update:model-value="update($event)"
7
7
  >
8
8
  <component :is="as" v-bind="$attrs">
@@ -15,16 +15,11 @@
15
15
  </template>
16
16
 
17
17
  <script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
18
- import { computed, inject, provide, readonly } from 'vue';
19
- import { value as evaluate, toString, uuid } from '@noeldemartin/utils';
20
18
  import { SelectRoot } from 'reka-ui';
21
- import type { AcceptableValue } from 'reka-ui';
22
- import type { Closure, Nullable } from '@noeldemartin/utils';
19
+ import type { Nullable } from '@noeldemartin/utils';
23
20
 
24
- import { translateWithDefault } from '@aerogel/core/lang';
25
- import { hasSelectOptionLabel } from '@aerogel/core/components/contracts/Select';
26
- import type FormController from '@aerogel/core/forms/FormController';
27
- import type { SelectEmits, SelectExpose, SelectProps } from '@aerogel/core/components/contracts/Select';
21
+ import { useSelect } from '@aerogel/core/components/contracts/Select';
22
+ import type { SelectEmits, SelectProps } from '@aerogel/core/components/contracts/Select';
28
23
  import type { FormFieldValue } from '@aerogel/core/forms/FormController';
29
24
 
30
25
  import HeadlessSelectTrigger from './HeadlessSelectTrigger.vue';
@@ -32,89 +27,9 @@ import HeadlessSelectOptions from './HeadlessSelectOptions.vue';
32
27
 
33
28
  defineOptions({ inheritAttrs: false });
34
29
 
35
- const {
36
- name,
37
- as = 'div',
38
- label,
39
- options,
40
- labelClass,
41
- optionsClass,
42
- renderOption,
43
- compareOptions = (a, b) => a === b,
44
- description,
45
- placeholder,
46
- modelValue,
47
- align,
48
- side,
49
- } = defineProps<SelectProps<T>>();
50
30
  const emit = defineEmits<SelectEmits<T>>();
51
- const form = inject<FormController | null>('form', null);
52
- const computedValue = computed(() => {
53
- if (form && name) {
54
- return form.getFieldValue(name) as T;
55
- }
31
+ const { as = 'div', compareOptions = (a, b) => a === b, ...props } = defineProps<SelectProps<T>>();
32
+ const { expose, acceptableValue, update } = useSelect({ as, compareOptions, ...props }, emit);
56
33
 
57
- return modelValue as T;
58
- });
59
- const acceptableValue = computed(() => computedValue.value as AcceptableValue);
60
- const errors = computed(() => {
61
- if (!form || !name) {
62
- return null;
63
- }
64
-
65
- return form.errors[name] ?? null;
66
- });
67
- const computedOptions = computed(() => {
68
- if (!options) {
69
- return null;
70
- }
71
-
72
- return options.map((option) => ({
73
- key: uuid(),
74
- label: renderOption
75
- ? renderOption(option)
76
- : hasSelectOptionLabel(option)
77
- ? evaluate(option.label as string)
78
- : toString(option),
79
- value: option as AcceptableValue,
80
- }));
81
- });
82
- const expose = {
83
- labelClass,
84
- optionsClass,
85
- align,
86
- side,
87
- value: computedValue,
88
- id: `select-${uuid()}`,
89
- name: computed(() => name),
90
- label: computed(() => label),
91
- description: computed(() => description),
92
- placeholder: computed(() => placeholder ?? translateWithDefault('ui.select', 'Select an option')),
93
- options: computedOptions,
94
- selectedOption: computed(() => computedOptions.value?.find((option) => option.value === modelValue)),
95
- errors: readonly(errors),
96
- required: computed(() => {
97
- if (!name || !form) {
98
- return;
99
- }
100
-
101
- return form.getFieldRules(name).includes('required');
102
- }),
103
- update(value) {
104
- if (form && name) {
105
- form.setFieldValue(name, value as FormFieldValue);
106
-
107
- return;
108
- }
109
-
110
- emit('update:modelValue', value);
111
- },
112
- } satisfies SelectExpose<T>;
113
-
114
- function update(value: AcceptableValue) {
115
- expose.update(value as T);
116
- }
117
-
118
- provide('select', expose);
119
34
  defineExpose(expose);
120
35
  </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <ComboboxRoot
3
+ open-on-focus
4
+ :model-value="acceptableValue"
5
+ :by="compareOptions"
6
+ @update:model-value="update($event)"
7
+ >
8
+ <ComboboxLabel />
9
+ <ComboboxTrigger />
10
+ <ComboboxOptions />
11
+ </ComboboxRoot>
12
+ </template>
13
+
14
+ <script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
15
+ import { ComboboxRoot } from 'reka-ui';
16
+ import { useSelect } from '@aerogel/core/components/contracts/Select';
17
+ import type { SelectEmits, SelectProps } from '@aerogel/core/components/contracts/Select';
18
+ import type { FormFieldValue } from '@aerogel/core/forms';
19
+ import type { Nullable } from '@noeldemartin/utils';
20
+
21
+ import ComboboxOptions from './ComboboxOptions.vue';
22
+ import ComboboxTrigger from './ComboboxTrigger.vue';
23
+ import ComboboxLabel from './ComboboxLabel.vue';
24
+
25
+ const emit = defineEmits<SelectEmits<T>>();
26
+ const { as = 'div', compareOptions = (a, b) => a === b, ...props } = defineProps<SelectProps<T>>();
27
+ const { expose, acceptableValue, update } = useSelect({ as, compareOptions, ...props }, emit);
28
+
29
+ defineExpose(expose);
30
+ </script>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <Label
3
+ v-if="show"
4
+ :for="select.id"
5
+ v-bind="$props"
6
+ class="block text-sm leading-6 font-medium text-gray-900"
7
+ >
8
+ <slot>
9
+ {{ select.label }}
10
+ </slot>
11
+ </Label>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { computed, useSlots } from 'vue';
16
+ import { Label } from 'reka-ui';
17
+ import type { LabelProps } from 'reka-ui';
18
+
19
+ import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
20
+ import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
21
+
22
+ defineProps<Omit<LabelProps, 'for'>>();
23
+
24
+ const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxLabel> must be a child of a <Combobox>');
25
+ const slots = useSlots();
26
+ const show = computed(() => !!(select.label || slots.default));
27
+ </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <ComboboxItem v-bind="$props" class="group p-1 outline-none">
3
+ <div
4
+ class="relative flex max-w-[calc(100vw-2rem)] cursor-pointer items-center gap-2 truncate rounded-md px-2 py-1 text-sm select-none *:truncate group-data-[highlighted]:bg-gray-100 group-data-[state=checked]:font-semibold group-data-[state=unchecked]:opacity-50"
5
+ >
6
+ {{ renderedLabel }}
7
+ </div>
8
+ </ComboboxItem>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { computed } from 'vue';
13
+ import { ComboboxItem, type ComboboxItemProps } from 'reka-ui';
14
+ import { toString } from '@noeldemartin/utils';
15
+
16
+ import { injectReactiveOrFail } from '@aerogel/core/utils';
17
+ import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
18
+
19
+ const { value } = defineProps<ComboboxItemProps>();
20
+ const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxOption> must be a child of a <Combobox>');
21
+ const renderedLabel = computed(() => {
22
+ const itemOption = select.options?.find((option) => option.value === value);
23
+
24
+ if (itemOption) {
25
+ return itemOption.label;
26
+ }
27
+
28
+ return toString(value);
29
+ });
30
+ </script>
@@ -0,0 +1,40 @@
1
+ <template>
2
+ <ComboboxPortal>
3
+ <ComboboxContent
4
+ position="popper"
5
+ :align="select.align"
6
+ :side="select.side"
7
+ :side-offset="4"
8
+ :class="renderedClasses"
9
+ >
10
+ <ComboboxViewport>
11
+ <ComboboxEmpty class="group p-1 outline-none">
12
+ <div
13
+ class="relative flex max-w-[calc(100vw-2rem)] items-center gap-2 truncate rounded-md px-2 py-1 text-sm select-none *:truncate"
14
+ >
15
+ {{ $td('ui.comboboxEmpty', 'No options found') }}
16
+ </div>
17
+ </ComboboxEmpty>
18
+
19
+ <ComboboxGroup>
20
+ <ComboboxOption v-for="option in select.options ?? []" :key="option.key" :value="option.value" />
21
+ </ComboboxGroup>
22
+ </ComboboxViewport>
23
+ </ComboboxContent>
24
+ </ComboboxPortal>
25
+ </template>
26
+
27
+ <script setup lang="ts">
28
+ import { ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxPortal, ComboboxViewport } from 'reka-ui';
29
+
30
+ import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
31
+ import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
32
+
33
+ import ComboboxOption from './ComboboxOption.vue';
34
+
35
+ const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxOptions> must be a child of a <Combobox>');
36
+ const renderedClasses = classes(
37
+ 'max-h-(--reka-combobox-content-available-height) min-w-(--reka-combobox-trigger-width)',
38
+ 'z-50 overflow-auto rounded-lg bg-white text-base shadow-lg ring-1 ring-black/5 focus:outline-hidden',
39
+ );
40
+ </script>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <ComboboxAnchor>
3
+ <ComboboxInput :id="select.id" :placeholder="select.placeholder" :class="renderedRootClasses" />
4
+ </ComboboxAnchor>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { ComboboxAnchor, ComboboxInput } from 'reka-ui';
9
+
10
+ import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
11
+ import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
12
+ import { computed } from 'vue';
13
+
14
+ const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxTrigger> must be a child of a <Combobox>');
15
+ const renderedRootClasses = computed(() =>
16
+ classes(
17
+ // eslint-disable-next-line vue/max-len
18
+ 'block w-full rounded-md border-0 py-1.5 ring-1 ring-inset focus:ring-2 focus:ring-inset sm:text-sm sm:leading-6',
19
+ {
20
+ 'mt-1': select.label,
21
+ 'focus:ring-primary-600': !select.errors,
22
+ 'text-gray-900 shadow-2xs ring-gray-900/10 placeholder:text-gray-400': !select.errors,
23
+ 'pr-10 text-red-900 ring-red-900/10 placeholder:text-red-300 focus:ring-red-500': select.errors,
24
+ },
25
+ ));
26
+ </script>
@@ -1,13 +1,13 @@
1
1
  <template>
2
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
- >
3
+ <summary :class="renderedSummaryClasses">
6
4
  <IconCheveronRight class="size-6 transition-transform group-open:rotate-90" />
7
- <span>{{ label }}</span>
5
+ <slot name="label">
6
+ <span>{{ label ?? $td('ui.details', 'Details') }}</span>
7
+ </slot>
8
8
  </summary>
9
9
 
10
- <div class="pt-2 pl-4">
10
+ <div :class="renderedContentClasses">
11
11
  <slot />
12
12
  </div>
13
13
  </details>
@@ -15,6 +15,19 @@
15
15
 
16
16
  <script setup lang="ts">
17
17
  import IconCheveronRight from '~icons/zondicons/cheveron-right';
18
+ import { classes } from '@aerogel/core/utils';
19
+ import { type HTMLAttributes, computed } from 'vue';
18
20
 
19
- defineProps<{ label: string }>();
21
+ const {
22
+ label = undefined,
23
+ contentClass,
24
+ summaryClass,
25
+ } = defineProps<{ label?: string; contentClass?: HTMLAttributes['class']; summaryClass?: HTMLAttributes['class'] }>();
26
+ const renderedContentClasses = computed(() => classes('pt-2 pl-4', contentClass));
27
+ const renderedSummaryClasses = computed(() =>
28
+ classes(
29
+ '-ml-2 flex w-[max-content] items-center rounded-lg py-2 pr-3 pl-1 max-w-full',
30
+ 'hover:bg-gray-100 focus-visible:outline focus-visible:outline-gray-700',
31
+ summaryClass,
32
+ ));
20
33
  </script>
@@ -13,8 +13,8 @@
13
13
  <IconExclamationSolid class="size-5 text-red-500" />
14
14
  </div>
15
15
  </div>
16
- <HeadlessInputDescription class="mt-2 text-sm text-gray-600" />
17
- <HeadlessInputError class="mt-2 text-sm text-red-600" />
16
+ <HeadlessInputDescription :class="renderedDescriptionClasses" />
17
+ <HeadlessInputError :class="renderedErrorClasses" />
18
18
  </HeadlessInput>
19
19
  </template>
20
20
 
@@ -35,13 +35,21 @@ import type { InputEmits, InputProps } from '@aerogel/core/components/contracts/
35
35
 
36
36
  defineOptions({ inheritAttrs: false });
37
37
  defineEmits<InputEmits>();
38
- const { label, inputClass, wrapperClass, ...props } = defineProps<
39
- InputProps & { inputClass?: HTMLAttributes['class']; wrapperClass?: HTMLAttributes['class'] }
38
+
39
+ const { label, inputClass, wrapperClass, descriptionClass, errorClass, ...props } = defineProps<
40
+ InputProps & {
41
+ inputClass?: HTMLAttributes['class'];
42
+ wrapperClass?: HTMLAttributes['class'];
43
+ descriptionClass?: HTMLAttributes['class'];
44
+ errorClass?: HTMLAttributes['class'];
45
+ }
40
46
  >();
41
47
  const $input = useTemplateRef('$inputRef');
42
48
  const [inputAttrs, rootClasses] = useInputAttrs();
43
49
  const renderedWrapperClasses = computed(() =>
44
50
  classes('relative rounded-md shadow-2xs', { 'mt-1': label }, wrapperClass));
51
+ const renderedDescriptionClasses = computed(() => classes('mt-2 text-sm text-gray-600', descriptionClass));
52
+ const renderedErrorClasses = computed(() => classes('mt-2 text-sm text-red-600', errorClass));
45
53
  const renderedInputClasses = computed(() =>
46
54
  classes(
47
55
  // eslint-disable-next-line vue/max-len
@@ -1,11 +1,10 @@
1
1
  <template>
2
2
  <Modal
3
3
  persistent
4
- class="flex"
5
4
  wrapper-class="w-auto"
6
5
  :title="renderedTitle"
7
6
  :title-hidden
8
- :class="{ 'flex-col-reverse': showProgress, 'items-center justify-center gap-2': !showProgress }"
7
+ :class="{ 'flex-col-reverse': showProgress, 'flex-row items-center justify-center gap-2': !showProgress }"
9
8
  >
10
9
  <ProgressBar
11
10
  v-if="showProgress"
@@ -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 v-if="!persistent && !closeHidden" class="absolute top-0 right-0 hidden pt-3.5 pr-2.5 sm:block">
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
+ fullscreenOnMobile,
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('max-h-[90vh] overflow-auto px-4 pb-4', { 'pt-4': !title || titleHidden }, contentClass));
124
+ classes(
125
+ 'overflow-auto px-4 pb-4 flex flex-col flex-1',
126
+ { 'pt-4': !title || titleHidden, 'max-h-[90vh]': !renderFullscreen.value },
127
+ contentClass,
128
+ ));
129
+ const renderFullscreen = computed(() => fullscreen || (fullscreenOnMobile && UI.mobile));
117
130
  const renderedWrapperClass = computed(() =>
118
131
  classes(
119
- 'isolate fixed top-1/2 left-1/2 z-50 w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2',
120
- 'overflow-hidden rounded-lg bg-white text-left shadow-xl sm:max-w-lg',
121
- renderedModals.has(modal.value) ||
122
- 'animate-[fade-in_var(--tw-duration)_ease-in-out,grow_var(--tw-duration)_ease-in-out]',
123
- 'transition-[scale,opacity] will-change-[scale,opacity] duration-300',
124
- {
125
- 'scale-50 opacity-0': !inForeground.value,
126
- 'scale-100 opacity-100': inForeground.value,
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
 
@@ -1,6 +1,11 @@
1
1
  <template>
2
- <div class="mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200">
2
+ <div class="relative mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200">
3
3
  <div :class="filledClasses" :style="`transform:translateX(-${(1 - renderedProgress) * 100}%)`" />
4
+ <div
5
+ v-if="overflowWidthPercentage"
6
+ :class="overflowClasses"
7
+ :style="{ width: `${overflowWidthPercentage}%` }"
8
+ />
4
9
  <span class="sr-only">
5
10
  {{
6
11
  $td('ui.progress', '{progress}% complete', {
@@ -18,8 +23,9 @@ import { classes } from '@aerogel/core/utils/classes';
18
23
  import type Job from '@aerogel/core/jobs/Job';
19
24
  import type { Falsifiable } from '@aerogel/core/utils';
20
25
 
21
- const { filledClass, progress, job } = defineProps<{
26
+ const { filledClass, overflowClass, progress, job } = defineProps<{
22
27
  filledClass?: string;
28
+ overflowClass?: string;
23
29
  progress?: number;
24
30
  job?: Falsifiable<Job>;
25
31
  }>();
@@ -28,6 +34,12 @@ let cleanup: Falsifiable<Function>;
28
34
  const jobProgress = ref(0);
29
35
  const filledClasses = computed(() =>
30
36
  classes('size-full transition-transform duration-500 rounded-r-full ease-linear bg-primary-600', filledClass));
37
+ const overflowClasses = computed(() =>
38
+ classes(
39
+ 'absolute inset-y-0 right-0 size-full rounded-r-full',
40
+ 'bg-primary-900 transition-[width] duration-500 ease-linear',
41
+ overflowClass,
42
+ ));
31
43
  const renderedProgress = computed(() => {
32
44
  if (typeof progress === 'number') {
33
45
  return progress;
@@ -35,6 +47,8 @@ const renderedProgress = computed(() => {
35
47
 
36
48
  return jobProgress.value;
37
49
  });
50
+ const overflowWidthPercentage = computed(() =>
51
+ renderedProgress.value > 1 ? 100 * ((renderedProgress.value - 1) / renderedProgress.value) : null);
38
52
 
39
53
  watch(
40
54
  () => job,
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <Modal :title="$td('settings.title', 'Settings')">
2
+ <Modal :title="$td('settings.title', 'Settings')" :fullscreen-on-mobile="$app.settingsFullscreenOnMobile">
3
3
  <component :is="setting.component" v-for="(setting, key) in settings" :key />
4
4
  </Modal>
5
5
  </template>