@aerogel/core 0.1.1-next.d3af81f1f7f69a65742c4d298e0c77c6c3977d2b → 0.1.1-next.d6144642389e7fbf7ef662ecdbb069e185750112

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.d3af81f1f7f69a65742c4d298e0c77c6c3977d2b",
3
+ "version": "0.1.1-next.d6144642389e7fbf7ef662ecdbb069e185750112",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -10,13 +10,14 @@ import lang from '@aerogel/core/lang';
10
10
  import services from '@aerogel/core/services';
11
11
  import testing from '@aerogel/core/testing';
12
12
  import ui from '@aerogel/core/ui';
13
+ import forms from '@aerogel/core/forms';
13
14
  import { installPlugins } from '@aerogel/core/plugins';
14
15
  import type { AerogelOptions } from '@aerogel/core/bootstrap/options';
15
16
 
16
17
  export type { AerogelOptions };
17
18
 
18
19
  export async function bootstrapApplication(app: AppInstance, options: AerogelOptions = {}): Promise<void> {
19
- const plugins = [testing, directives, errors, lang, services, ui, ...(options.plugins ?? [])];
20
+ const plugins = [testing, directives, errors, lang, services, ui, forms, ...(options.plugins ?? [])];
20
21
 
21
22
  App.instance = app;
22
23
 
@@ -0,0 +1,5 @@
1
+ export type ComboboxContext = {
2
+ input: string;
3
+ preventChange: boolean;
4
+ $group: HTMLDivElement | null;
5
+ };
@@ -1,7 +1,8 @@
1
1
  import { computed, inject, provide, readonly } from 'vue';
2
2
  import { evaluate, toString, uuid } from '@noeldemartin/utils';
3
+ import type { AcceptRefs } from '@aerogel/core/utils';
3
4
  import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
4
- import type { Component, ComputedRef, EmitFn, HTMLAttributes } from 'vue';
5
+ import type { Component, ComputedRef, EmitFn, HTMLAttributes, Ref } from 'vue';
5
6
  import type { Nullable } from '@noeldemartin/utils';
6
7
 
7
8
  import { translateWithDefault } from '@aerogel/core/lang';
@@ -37,8 +38,8 @@ export interface SelectExpose<T extends Nullable<FormFieldValue> = Nullable<Form
37
38
  options: ComputedRef<Nullable<readonly SelectOptionData[]>>;
38
39
  selectedOption: ComputedRef<Nullable<SelectOptionData>>;
39
40
  placeholder: ComputedRef<string>;
40
- labelClass?: HTMLAttributes['class'];
41
- optionsClass?: HTMLAttributes['class'];
41
+ labelClass: ComputedRef<HTMLAttributes['class']>;
42
+ optionsClass: ComputedRef<HTMLAttributes['class']>;
42
43
  align?: SelectContentProps['align'];
43
44
  side?: SelectContentProps['side'];
44
45
  renderOption: (option: T) => string;
@@ -49,40 +50,45 @@ export function hasSelectOptionLabel(option: unknown): option is HasSelectOption
49
50
  }
50
51
 
51
52
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
52
- export function useSelect<T extends Nullable<FormFieldValue>>(props: SelectProps<T>, emit: EmitFn<SelectEmits<T>>) {
53
+ export function useSelect<T extends Nullable<FormFieldValue>>(
54
+ props: Ref<SelectProps<T>>,
55
+ emit: EmitFn<SelectEmits<T>>,
56
+ ) {
53
57
  const form = inject<FormController | null>('form', null);
54
58
  const renderOption = (option: T): string => {
55
59
  if (option === undefined) {
56
60
  return '';
57
61
  }
58
62
 
59
- return props.renderOption
60
- ? props.renderOption(option)
63
+ return props.value.renderOption
64
+ ? props.value.renderOption(option)
61
65
  : hasSelectOptionLabel(option)
62
66
  ? evaluate(option.label as string)
63
67
  : toString(option);
64
68
  };
65
69
  const computedValue = computed(() => {
66
- if (form && props.name) {
67
- return form.getFieldValue(props.name) as T;
70
+ const { name, modelValue } = props.value;
71
+
72
+ if (form && name) {
73
+ return form.getFieldValue(name) as T;
68
74
  }
69
75
 
70
- return props.modelValue as T;
76
+ return modelValue as T;
71
77
  });
72
78
  const acceptableValue = computed(() => computedValue.value as AcceptableValue);
73
79
  const errors = computed(() => {
74
- if (!form || !props.name) {
80
+ if (!form || !props.value.name) {
75
81
  return null;
76
82
  }
77
83
 
78
- return form.errors[props.name] ?? null;
84
+ return form.errors[props.value.name] ?? null;
79
85
  });
80
86
  const computedOptions = computed(() => {
81
- if (!props.options) {
87
+ if (!props.value.options) {
82
88
  return null;
83
89
  }
84
90
 
85
- return props.options.map((option) => ({
91
+ return props.value.options.map((option) => ({
86
92
  key: uuid(),
87
93
  label: renderOption(option),
88
94
  value: option as AcceptableValue,
@@ -91,36 +97,37 @@ export function useSelect<T extends Nullable<FormFieldValue>>(props: SelectProps
91
97
 
92
98
  const expose = {
93
99
  renderOption,
94
- labelClass: props.labelClass,
95
- optionsClass: props.optionsClass,
96
- align: props.align,
97
- side: props.side,
100
+ labelClass: computed(() => props.value.labelClass),
101
+ optionsClass: computed(() => props.value.optionsClass),
102
+ align: computed(() => props.value.align),
103
+ side: computed(() => props.value.side),
98
104
  value: computedValue,
99
105
  id: `select-${uuid()}`,
100
- name: computed(() => props.name),
101
- label: computed(() => props.label),
102
- description: computed(() => props.description),
103
- placeholder: computed(() => props.placeholder ?? translateWithDefault('ui.select', 'Select an option')),
106
+ name: computed(() => props.value.name),
107
+ label: computed(() => props.value.label),
108
+ description: computed(() => props.value.description),
109
+ placeholder: computed(() => props.value.placeholder ?? translateWithDefault('ui.select', 'Select an option')),
104
110
  options: computedOptions,
105
- selectedOption: computed(() => computedOptions.value?.find((option) => option.value === props.modelValue)),
111
+ selectedOption: computed(() =>
112
+ computedOptions.value?.find((option) => option.value === props.value.modelValue)),
106
113
  errors: readonly(errors),
107
114
  required: computed(() => {
108
- if (!props.name || !form) {
115
+ if (!props.value.name || !form) {
109
116
  return;
110
117
  }
111
118
 
112
- return form.getFieldRules(props.name).includes('required');
119
+ return form.getFieldRules(props.value.name).includes('required');
113
120
  }),
114
121
  update(value) {
115
- if (form && props.name) {
116
- form.setFieldValue(props.name, value as FormFieldValue);
122
+ if (form && props.value.name) {
123
+ form.setFieldValue(props.value.name, value as FormFieldValue);
117
124
 
118
125
  return;
119
126
  }
120
127
 
121
128
  emit('update:modelValue', value);
122
129
  },
123
- } satisfies SelectExpose<T>;
130
+ } satisfies AcceptRefs<SelectExpose<T>>;
124
131
 
125
132
  function update(value: AcceptableValue) {
126
133
  expose.update(value as T);
@@ -1,5 +1,6 @@
1
1
  export * from './AlertModal';
2
2
  export * from './Button';
3
+ export * from './Combobox';
3
4
  export * from './ConfirmModal';
4
5
  export * from './DropdownMenu';
5
6
  export * from './ErrorReportModal';
@@ -19,7 +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
+ import { getLocalTimezoneOffset } from '@aerogel/core/utils';
23
23
  import type FormController from '@aerogel/core/forms/FormController';
24
24
  import type { FormFieldValue } from '@aerogel/core/forms/FormController';
25
25
  import type { InputExpose } from '@aerogel/core/components/contracts/Input';
@@ -65,8 +65,19 @@ function getValue(): FormFieldValue | null {
65
65
  return $input.value.checked;
66
66
  case 'date':
67
67
  case 'time':
68
- case 'datetime-local':
69
- return new Date(Math.round($input.value.valueAsNumber / 60000) * 60000 + LOCAL_TIMEZONE_OFFSET);
68
+ case 'datetime-local': {
69
+ const date = new Date(
70
+ Math.round($input.value.valueAsNumber / 60000) * 60000 +
71
+ getLocalTimezoneOffset($input.value.valueAsDate ?? new Date($input.value.valueAsNumber)),
72
+ );
73
+
74
+ if (isNaN(date.getTime())) {
75
+ return null;
76
+ }
77
+
78
+ return date;
79
+ }
80
+
70
81
  case 'number':
71
82
  return $input.value.valueAsNumber;
72
83
  default:
@@ -83,8 +94,11 @@ watchEffect(() => {
83
94
  if (['date', 'time', 'datetime-local'].includes(renderedType.value) && value.value instanceof Date) {
84
95
  const roundedValue = Math.round(value.value.getTime() / 60000) * 60000;
85
96
 
86
- $input.value.valueAsNumber = roundedValue - LOCAL_TIMEZONE_OFFSET;
87
- input.update(new Date(roundedValue));
97
+ $input.value.valueAsNumber = roundedValue - getLocalTimezoneOffset(value.value);
98
+
99
+ if (value.value.getTime() !== roundedValue) {
100
+ input.update(new Date(roundedValue));
101
+ }
88
102
 
89
103
  return;
90
104
  }
@@ -16,6 +16,7 @@
16
16
 
17
17
  <script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
18
18
  import { SelectRoot } from 'reka-ui';
19
+ import { computed } from 'vue';
19
20
  import type { Nullable } from '@noeldemartin/utils';
20
21
 
21
22
  import { useSelect } from '@aerogel/core/components/contracts/Select';
@@ -29,7 +30,10 @@ defineOptions({ inheritAttrs: false });
29
30
 
30
31
  const emit = defineEmits<SelectEmits<T>>();
31
32
  const { as = 'div', compareOptions = (a, b) => a === b, ...props } = defineProps<SelectProps<T>>();
32
- const { expose, acceptableValue, update } = useSelect({ as, compareOptions, ...props }, emit);
33
+ const { expose, acceptableValue, update } = useSelect(
34
+ computed(() => ({ as, compareOptions, ...props })),
35
+ emit,
36
+ );
33
37
 
34
38
  defineExpose(expose);
35
39
  </script>
@@ -1,41 +1,94 @@
1
1
  <template>
2
2
  <ComboboxRoot
3
- open-on-focus
4
3
  ignore-filter
4
+ :open
5
+ :reset-search-term-on-blur="false"
6
+ :reset-search-term-on-select="false"
5
7
  :model-value="acceptableValue"
6
8
  :by="compareOptions"
7
9
  @update:model-value="update($event)"
8
10
  >
9
- <ProvideRef v-model="input" name="combobox-input">
11
+ <Provide name="combobox" :value="combobox">
10
12
  <ComboboxLabel />
11
- <ComboboxTrigger />
12
- <ComboboxOptions :new-input-value />
13
- </ProvideRef>
13
+ <ComboboxTrigger @focus="open = true" @change="open = true" @blur="open = false" />
14
+ <HeadlessSelectError class="mt-2 text-sm text-red-600" />
15
+ <ComboboxOptions :new-input-value @select="open = false" />
16
+ </Provide>
14
17
  </ComboboxRoot>
15
18
  </template>
16
19
 
17
20
  <script setup lang="ts" generic="T extends Nullable<FormFieldValue>">
18
21
  import { ComboboxRoot } from 'reka-ui';
19
- import { ref } from 'vue';
22
+ import { computed, ref, watch } from 'vue';
23
+ import type { AcceptableValue } from 'reka-ui';
20
24
  import type { Nullable } from '@noeldemartin/utils';
21
25
 
22
- import ProvideRef from '@aerogel/core/components/vue/ProvideRef.vue';
26
+ import Provide from '@aerogel/core/components/vue/Provide.vue';
23
27
  import { useSelect } from '@aerogel/core/components/contracts/Select';
28
+ import type { AcceptRefs } from '@aerogel/core/utils';
29
+ import type { ComboboxContext } from '@aerogel/core/components/contracts/Combobox';
24
30
  import type { SelectEmits, SelectProps } from '@aerogel/core/components/contracts/Select';
25
31
  import type { FormFieldValue } from '@aerogel/core/forms';
26
32
 
27
33
  import ComboboxOptions from './ComboboxOptions.vue';
28
34
  import ComboboxTrigger from './ComboboxTrigger.vue';
29
35
  import ComboboxLabel from './ComboboxLabel.vue';
36
+ import HeadlessSelectError from '../headless/HeadlessSelectError.vue';
30
37
 
31
38
  const emit = defineEmits<SelectEmits<T>>();
32
39
  const {
33
40
  as = 'div',
34
41
  compareOptions = (a, b) => a === b,
42
+ newInputValue,
35
43
  ...props
36
44
  } = defineProps<SelectProps<T> & { newInputValue?: (value: string) => T }>();
37
- const { expose, acceptableValue, update, renderOption } = useSelect({ as, compareOptions, ...props }, emit);
38
- const input = ref(acceptableValue.value ? renderOption(acceptableValue.value as T) : '');
45
+ const {
46
+ expose,
47
+ acceptableValue,
48
+ update: baseUpdate,
49
+ renderOption,
50
+ } = useSelect(
51
+ computed(() => ({ as, compareOptions, ...props })),
52
+ emit,
53
+ );
54
+ const open = ref(false);
55
+ const optionsByLabel = computed(() =>
56
+ Object.fromEntries(expose.options.value?.map((option) => [option.label, option.value]) ?? []));
57
+ const combobox = {
58
+ input: ref(acceptableValue.value ? renderOption(acceptableValue.value as T) : ''),
59
+ preventChange: ref(false),
60
+ $group: ref(null),
61
+ } satisfies AcceptRefs<ComboboxContext>;
62
+
63
+ function update(value: AcceptableValue) {
64
+ combobox.input.value = renderOption(value as T);
65
+
66
+ baseUpdate(value);
67
+ }
68
+
69
+ watch(expose.value, (value) => {
70
+ const newOptionLabel = renderOption(value as T);
71
+
72
+ if (combobox.input.value === newOptionLabel) {
73
+ return;
74
+ }
75
+
76
+ combobox.preventChange.value = true;
77
+ combobox.input.value = newOptionLabel;
78
+ });
79
+
80
+ watch(combobox.input, (value) => {
81
+ const newInputOption = newInputValue ? (newInputValue(value) as AcceptableValue) : value;
82
+ const newInputOptionLabel = renderOption(newInputOption as T);
83
+
84
+ if (newInputOptionLabel in optionsByLabel.value) {
85
+ update(optionsByLabel.value[newInputOptionLabel] as AcceptableValue);
86
+
87
+ return;
88
+ }
89
+
90
+ update(newInputOption);
91
+ });
39
92
 
40
93
  defineExpose(expose);
41
94
  </script>
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <ComboboxItem v-bind="$props" class="group p-1 outline-none">
2
+ <ComboboxItem v-bind="$props" class="group p-1 outline-none" @select="onSelect($event)">
3
3
  <div
4
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
5
  >
@@ -12,17 +12,35 @@
12
12
 
13
13
  <script setup lang="ts">
14
14
  import { computed } from 'vue';
15
- import { ComboboxItem, type ComboboxItemProps } from 'reka-ui';
15
+ import { ComboboxItem, injectComboboxRootContext } from 'reka-ui';
16
16
  import { toString } from '@noeldemartin/utils';
17
+ import type { ComboboxItemProps, SelectItemSelectEvent } from 'reka-ui';
17
18
 
18
19
  import { injectReactiveOrFail } from '@aerogel/core/utils';
20
+ import type { ComboboxContext } from '@aerogel/core/components/contracts/Combobox';
19
21
  import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
20
22
 
23
+ const emit = defineEmits<{ select: [] }>();
24
+
21
25
  const { value } = defineProps<ComboboxItemProps>();
22
26
  const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxOption> must be a child of a <Combobox>');
27
+ const rootContext = injectComboboxRootContext();
28
+ const combobox = injectReactiveOrFail<ComboboxContext>('combobox');
23
29
  const renderedLabel = computed(() => {
24
30
  const itemOption = select.options?.find((option) => option.value === value);
25
31
 
26
32
  return itemOption ? select.renderOption(itemOption.value) : toString(value);
27
33
  });
34
+
35
+ function onSelect(event: SelectItemSelectEvent<unknown>) {
36
+ if (rootContext.multiple.value || rootContext.disabled.value) {
37
+ return;
38
+ }
39
+
40
+ event.preventDefault();
41
+ combobox.preventChange = true;
42
+ rootContext.modelValue.value = value;
43
+
44
+ emit('select');
45
+ }
28
46
  </script>
@@ -16,14 +16,20 @@
16
16
  </div>
17
17
  </ComboboxEmpty>
18
18
 
19
- <ComboboxGroup>
19
+ <ComboboxGroup ref="$group">
20
20
  <ComboboxOption
21
21
  v-if="showInputOption"
22
- :value="newInputValue?.(input) ?? (input as AcceptableValue)"
22
+ :value="newInputValue?.(combobox.input) ?? (combobox.input as AcceptableValue)"
23
+ @select="$emit('select')"
23
24
  >
24
- {{ input }}
25
+ {{ combobox.input }}
25
26
  </ComboboxOption>
26
- <ComboboxOption v-for="option in filteredOptions" :key="option.key" :value="option.value" />
27
+ <ComboboxOption
28
+ v-for="option in filteredOptions"
29
+ :key="option.key"
30
+ :value="option.value"
31
+ @select="$emit('select')"
32
+ />
27
33
  </ComboboxGroup>
28
34
  </ComboboxViewport>
29
35
  </ComboboxContent>
@@ -32,27 +38,34 @@
32
38
 
33
39
  <script setup lang="ts">
34
40
  import { ComboboxContent, ComboboxEmpty, ComboboxGroup, ComboboxPortal, ComboboxViewport, useFilter } from 'reka-ui';
35
- import { computed } from 'vue';
36
- import type { Ref } from 'vue';
41
+ import { computed, useTemplateRef, watch } from 'vue';
37
42
  import type { Nullable } from '@noeldemartin/utils';
38
43
  import type { AcceptableValue } from 'reka-ui';
39
44
 
40
- import { classes, injectOrFail, injectReactiveOrFail } from '@aerogel/core/utils';
45
+ import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
41
46
  import type { FormFieldValue } from '@aerogel/core/forms';
42
47
  import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
48
+ import type { ComboboxContext } from '@aerogel/core/components/contracts/Combobox';
43
49
 
44
50
  import ComboboxOption from './ComboboxOption.vue';
45
51
 
46
- const { contains } = useFilter({ sensitivity: 'base' });
52
+ defineEmits<{ select: [] }>();
53
+
47
54
  const { newInputValue } = defineProps<{ newInputValue?: (value: string) => Nullable<FormFieldValue> }>();
55
+ const { contains } = useFilter({ sensitivity: 'base' });
48
56
  const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxOptions> must be a child of a <Combobox>');
49
- const input = injectOrFail<Ref<string>>('combobox-input');
50
- const filteredOptions = computed(() => select.options?.filter((option) => contains(option.label, input.value)) ?? []);
57
+ const combobox = injectReactiveOrFail<ComboboxContext>('combobox');
58
+ const $group = useTemplateRef('$group');
59
+ const filteredOptions = computed(
60
+ () => select.options?.filter((option) => contains(option.label, combobox.input)) ?? [],
61
+ );
51
62
  const showInputOption = computed(
52
- () => input.value && !filteredOptions.value.some((option) => option.label === input.value),
63
+ () => combobox.input && !filteredOptions.value.some((option) => option.label === combobox.input),
53
64
  );
54
65
  const renderedClasses = classes(
55
66
  'max-h-(--reka-combobox-content-available-height) min-w-(--reka-combobox-trigger-width)',
56
67
  'z-50 overflow-auto rounded-lg bg-white text-base shadow-lg ring-1 ring-black/5 focus:outline-hidden',
57
68
  );
69
+
70
+ watch($group, () => (combobox.$group = $group.value?.$el ?? null));
58
71
  </script>
@@ -1,26 +1,35 @@
1
1
  <template>
2
- <ComboboxAnchor>
2
+ <ComboboxAnchor class="relative">
3
3
  <ComboboxInput
4
4
  :id="select.id"
5
- v-model="input"
5
+ v-model="combobox.input"
6
6
  :placeholder="select.placeholder"
7
7
  :class="renderedRootClasses"
8
8
  :display-value="select.renderOption"
9
9
  :name="select.name"
10
+ @focus="$emit('focus')"
11
+ @blur="onBlur()"
12
+ @keydown.esc="$emit('blur')"
10
13
  />
14
+ <div v-if="select?.errors" class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
15
+ <IconExclamationSolid class="size-5 text-red-500" />
16
+ </div>
11
17
  </ComboboxAnchor>
12
18
  </template>
13
19
 
14
20
  <script setup lang="ts">
21
+ import IconExclamationSolid from '~icons/zondicons/exclamation-solid';
22
+
15
23
  import { ComboboxAnchor, ComboboxInput } from 'reka-ui';
16
- import { computed } from 'vue';
17
- import type { Ref } from 'vue';
24
+ import { computed, watch } from 'vue';
18
25
 
19
- import { classes, injectOrFail, injectReactiveOrFail } from '@aerogel/core/utils';
26
+ import { classes, injectReactiveOrFail } from '@aerogel/core/utils';
20
27
  import type { SelectExpose } from '@aerogel/core/components/contracts/Select';
28
+ import type { ComboboxContext } from '@aerogel/core/components/contracts/Combobox';
21
29
 
30
+ const emit = defineEmits<{ focus: []; change: []; blur: [] }>();
22
31
  const select = injectReactiveOrFail<SelectExpose>('select', '<ComboboxTrigger> must be a child of a <Combobox>');
23
- const input = injectOrFail<Ref<string>>('combobox-input');
32
+ const combobox = injectReactiveOrFail<ComboboxContext>('combobox');
24
33
  const renderedRootClasses = computed(() =>
25
34
  classes(
26
35
  // eslint-disable-next-line vue/max-len
@@ -32,4 +41,27 @@ const renderedRootClasses = computed(() =>
32
41
  'pr-10 text-red-900 ring-red-900/10 placeholder:text-red-300 focus:ring-red-500': select.errors,
33
42
  },
34
43
  ));
44
+
45
+ function onBlur() {
46
+ const elements = Array.from(document.querySelectorAll(':hover'));
47
+
48
+ if (elements.some((element) => combobox.$group?.contains(element))) {
49
+ return;
50
+ }
51
+
52
+ emit('blur');
53
+ }
54
+
55
+ watch(
56
+ () => combobox.input,
57
+ () => {
58
+ if (combobox.preventChange) {
59
+ combobox.preventChange = false;
60
+
61
+ return;
62
+ }
63
+
64
+ emit('change');
65
+ },
66
+ );
35
67
  </script>
@@ -3,6 +3,7 @@
3
3
  <SelectLabel />
4
4
  <slot>
5
5
  <SelectTrigger />
6
+ <HeadlessSelectError class="mt-2 text-sm text-red-600" />
6
7
  <SelectOptions />
7
8
  </slot>
8
9
  </HeadlessSelect>
@@ -19,6 +20,7 @@ import type { FormFieldValue } from '@aerogel/core/forms';
19
20
  import SelectLabel from './SelectLabel.vue';
20
21
  import SelectOptions from './SelectOptions.vue';
21
22
  import SelectTrigger from './SelectTrigger.vue';
23
+ import HeadlessSelectError from '../headless/HeadlessSelectError.vue';
22
24
 
23
25
  defineProps<SelectProps<T>>();
24
26
  defineEmits<SelectEmits<T>>();
@@ -2,11 +2,15 @@
2
2
  <HeadlessSelectTrigger :class="renderedClasses">
3
3
  <HeadlessSelectValue class="col-start-1 row-start-1 truncate pr-6" />
4
4
  <IconCheveronDown class="col-start-1 row-start-1 size-5 self-center justify-self-end text-gray-500 sm:size-4" />
5
+ <div v-if="select?.errors" class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3">
6
+ <IconExclamationSolid class="size-5 text-red-500" />
7
+ </div>
5
8
  </HeadlessSelectTrigger>
6
9
  </template>
7
10
 
8
11
  <script setup lang="ts">
9
12
  import IconCheveronDown from '~icons/zondicons/cheveron-down';
13
+ import IconExclamationSolid from '~icons/zondicons/exclamation-solid';
10
14
 
11
15
  import { computed } from 'vue';
12
16
  import type { HTMLAttributes } from 'vue';
@@ -22,8 +26,15 @@ const select = injectReactiveOrFail<SelectExpose>('select', '<SelectTrigger> mus
22
26
  const renderedClasses = computed(() =>
23
27
  classes(
24
28
  // eslint-disable-next-line vue/max-len
25
- 'focus:outline-primary-600 data-[state=open]:outline-primary-600 grid w-full cursor-default grid-cols-1 rounded-md bg-white py-1.5 pr-2 pl-3 text-left text-gray-900 outline-1 -outline-offset-1 outline-gray-300 focus:outline-2 focus:-outline-offset-2 sm:text-sm/6',
26
- { 'mt-1': select.label },
29
+ 'relative grid w-full cursor-default grid-cols-1 rounded-md bg-white py-1.5 pr-2 pl-3 text-left text-gray-900 outline-1 -outline-offset-1',
30
+ 'focus:outline-2 focus:-outline-offset-2 sm:text-sm/6',
31
+ {
32
+ 'mt-1': select.label,
33
+ 'outline-gray-300 focus:outline-primary-600 data-[state=open]:outline-primary-600': !select.errors,
34
+ 'text-gray-900 shadow-2xs ring-gray-900/10 placeholder:text-gray-400': !select.errors,
35
+ 'outline-red-900/10 pr-10 text-red-900 placeholder:text-red-300': select.errors,
36
+ 'focus:outline-red-500 data-[state=open]:outline-red-500': select.errors,
37
+ },
27
38
  rootClasses,
28
39
  ));
29
40
  </script>
@@ -0,0 +1,11 @@
1
+ <template>
2
+ <slot />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { provide } from 'vue';
7
+
8
+ const { name, value } = defineProps<{ name: string; value: unknown }>();
9
+
10
+ provide(name, value);
11
+ </script>
@@ -1 +1 @@
1
- export { default as ProvideRef } from './ProvideRef.vue';
1
+ export { default as Provide } from './Provide.vue';
@@ -3,6 +3,7 @@ import type { App as AppInstance } from 'vue';
3
3
  import App from '@aerogel/core/services/App';
4
4
  import { bootServices } from '@aerogel/core/services';
5
5
  import { definePlugin } from '@aerogel/core/plugins';
6
+ import { getErrorMessage } from '@aerogel/core/errors/utils';
6
7
 
7
8
  import Errors from './Errors';
8
9
  import settings from './settings';
@@ -16,6 +17,10 @@ export type { ErrorSource, ErrorReport, ErrorReportLog };
16
17
 
17
18
  const services = { $errors: Errors };
18
19
  const frameworkHandler: ErrorHandler = (error) => {
20
+ if (getErrorMessage(error).includes('ResizeObserver loop completed with undelivered notifications.')) {
21
+ return true;
22
+ }
23
+
19
24
  Errors.report(error);
20
25
 
21
26
  return true;
@@ -30,7 +30,7 @@ describe('FormController', () => {
30
30
  const form = useForm({
31
31
  name: {
32
32
  type: 'string',
33
- rules: 'required',
33
+ rules: ['required'],
34
34
  },
35
35
  });
36
36
 
@@ -48,7 +48,7 @@ describe('FormController', () => {
48
48
  const form = useForm({
49
49
  name: {
50
50
  type: 'string',
51
- rules: 'required',
51
+ rules: ['required'],
52
52
  },
53
53
  });
54
54
 
@@ -69,11 +69,11 @@ describe('FormController', () => {
69
69
  const form = useForm({
70
70
  trimmed: {
71
71
  type: 'string',
72
- rules: 'required',
72
+ rules: ['required'],
73
73
  },
74
74
  untrimmed: {
75
75
  type: 'string',
76
- rules: 'required',
76
+ rules: ['required'],
77
77
  trim: false,
78
78
  },
79
79
  });