@aerogel/core 0.0.0-next.aa6e27a9c197d1ee10c9fe018ee8c0fc6ff77767 → 0.0.0-next.abea39863ad0f7c484b8b1f365870e43e9bdd0ba

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.
Files changed (97) hide show
  1. package/dist/aerogel-core.css +1 -0
  2. package/dist/aerogel-core.d.ts +683 -579
  3. package/dist/aerogel-core.js +2180 -1828
  4. package/dist/aerogel-core.js.map +1 -1
  5. package/package.json +7 -2
  6. package/src/components/AppLayout.vue +1 -3
  7. package/src/components/AppOverlays.vue +0 -27
  8. package/src/components/contracts/AlertModal.ts +15 -0
  9. package/src/components/contracts/ConfirmModal.ts +12 -5
  10. package/src/components/contracts/DropdownMenu.ts +17 -3
  11. package/src/components/contracts/ErrorReportModal.ts +8 -4
  12. package/src/components/contracts/Input.ts +7 -7
  13. package/src/components/contracts/LoadingModal.ts +12 -4
  14. package/src/components/contracts/Modal.ts +12 -4
  15. package/src/components/contracts/PromptModal.ts +8 -2
  16. package/src/components/contracts/Select.ts +21 -12
  17. package/src/components/contracts/Toast.ts +4 -2
  18. package/src/components/contracts/index.ts +3 -1
  19. package/src/components/headless/HeadlessButton.vue +2 -1
  20. package/src/components/headless/HeadlessInput.vue +3 -3
  21. package/src/components/headless/HeadlessInputInput.vue +6 -6
  22. package/src/components/headless/HeadlessInputTextArea.vue +4 -4
  23. package/src/components/headless/HeadlessModal.vue +22 -51
  24. package/src/components/headless/HeadlessModalContent.vue +11 -5
  25. package/src/components/headless/HeadlessModalDescription.vue +12 -0
  26. package/src/components/headless/HeadlessSelect.vue +34 -19
  27. package/src/components/headless/HeadlessSelectOption.vue +1 -1
  28. package/src/components/headless/HeadlessSelectOptions.vue +16 -4
  29. package/src/components/headless/HeadlessSelectValue.vue +4 -1
  30. package/src/components/headless/HeadlessSwitch.vue +96 -0
  31. package/src/components/headless/index.ts +2 -0
  32. package/src/components/index.ts +2 -1
  33. package/src/components/ui/AdvancedOptions.vue +1 -1
  34. package/src/components/ui/AlertModal.vue +7 -3
  35. package/src/components/ui/Button.vue +33 -16
  36. package/src/components/ui/Checkbox.vue +5 -5
  37. package/src/components/ui/ConfirmModal.vue +12 -4
  38. package/src/components/ui/DropdownMenu.vue +18 -19
  39. package/src/components/ui/DropdownMenuOption.vue +22 -0
  40. package/src/components/ui/DropdownMenuOptions.vue +44 -0
  41. package/src/components/ui/EditableContent.vue +4 -4
  42. package/src/components/ui/ErrorLogs.vue +19 -0
  43. package/src/components/ui/ErrorLogsModal.vue +48 -0
  44. package/src/components/ui/ErrorReportModal.vue +18 -7
  45. package/src/components/ui/Input.vue +4 -4
  46. package/src/components/ui/LoadingModal.vue +6 -4
  47. package/src/components/ui/Markdown.vue +31 -3
  48. package/src/components/ui/Modal.vue +83 -22
  49. package/src/components/ui/ModalContext.vue +2 -1
  50. package/src/components/ui/ProgressBar.vue +9 -8
  51. package/src/components/ui/PromptModal.vue +8 -5
  52. package/src/components/ui/Select.vue +10 -4
  53. package/src/components/ui/SelectLabel.vue +13 -2
  54. package/src/components/ui/SelectOption.vue +29 -0
  55. package/src/components/ui/SelectOptions.vue +24 -20
  56. package/src/components/ui/SelectTrigger.vue +3 -3
  57. package/src/components/ui/SettingsModal.vue +4 -40
  58. package/src/components/ui/Switch.vue +11 -0
  59. package/src/components/ui/Toast.vue +20 -16
  60. package/src/components/ui/index.ts +6 -0
  61. package/src/directives/measure.ts +11 -5
  62. package/src/errors/Errors.ts +18 -15
  63. package/src/errors/index.ts +6 -2
  64. package/src/errors/settings/Debug.vue +39 -0
  65. package/src/errors/settings/index.ts +10 -0
  66. package/src/forms/FormController.test.ts +32 -9
  67. package/src/forms/FormController.ts +23 -22
  68. package/src/forms/index.ts +0 -1
  69. package/src/forms/utils.ts +34 -34
  70. package/src/index.css +37 -5
  71. package/src/lang/index.ts +5 -1
  72. package/src/lang/settings/Language.vue +48 -0
  73. package/src/lang/settings/index.ts +10 -0
  74. package/src/services/App.state.ts +11 -1
  75. package/src/services/App.ts +9 -1
  76. package/src/services/Events.test.ts +8 -8
  77. package/src/services/Events.ts +2 -8
  78. package/src/services/index.ts +5 -2
  79. package/src/testing/index.ts +4 -0
  80. package/src/ui/UI.state.ts +3 -13
  81. package/src/ui/UI.ts +107 -83
  82. package/src/ui/index.ts +16 -17
  83. package/src/utils/classes.ts +41 -0
  84. package/src/utils/composition/events.ts +2 -4
  85. package/src/utils/composition/forms.ts +16 -1
  86. package/src/utils/composition/state.ts +11 -2
  87. package/src/utils/index.ts +3 -1
  88. package/src/utils/markdown.ts +35 -1
  89. package/src/utils/types.ts +3 -0
  90. package/src/utils/vue.ts +28 -125
  91. package/src/components/composition.ts +0 -23
  92. package/src/components/contracts/shared.ts +0 -9
  93. package/src/components/utils.ts +0 -107
  94. package/src/forms/composition.ts +0 -6
  95. package/src/utils/tailwindcss.test.ts +0 -26
  96. package/src/utils/tailwindcss.ts +0 -7
  97. package/src/utils/vdom.ts +0 -31
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aerogel/core",
3
- "version": "0.0.0-next.aa6e27a9c197d1ee10c9fe018ee8c0fc6ff77767",
3
+ "version": "0.0.0-next.abea39863ad0f7c484b8b1f365870e43e9bdd0ba",
4
4
  "type": "module",
5
5
  "sideEffects": false,
6
6
  "exports": {
@@ -23,6 +23,9 @@
23
23
  "verify": "noeldemartin-verify"
24
24
  },
25
25
  "peerDependencies": {
26
+ "@tailwindcss/forms": "^0.5.10",
27
+ "@tailwindcss/typography": "^0.5.16",
28
+ "tailwindcss": "^4.1.4",
26
29
  "vue": "^3.5.0"
27
30
  },
28
31
  "dependencies": {
@@ -30,10 +33,12 @@
30
33
  "class-variance-authority": "^0.7.1",
31
34
  "clsx": "^2.1.1",
32
35
  "dompurify": "^3.2.4",
36
+ "eruda": "^3.4.1",
33
37
  "marked": "^15.0.7",
34
38
  "pinia": "^2.1.6",
35
39
  "reka-ui": "^2.2.0",
36
- "tailwind-merge": "^3.1.0"
40
+ "tailwind-merge": "^3.1.0",
41
+ "vue-component-type-helpers": "^2.2.8"
37
42
  },
38
43
  "devDependencies": {
39
44
  "@aerogel/vite": "*"
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="flex min-h-full flex-col text-base leading-tight font-normal text-gray-900 antialiased">
3
3
  <slot v-if="$errors.hasStartupErrors" name="startup-crash">
4
- <component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
4
+ <component :is="$ui.requireComponent('startup-crash')" />
5
5
  </slot>
6
6
  <slot v-else />
7
7
 
@@ -10,7 +10,5 @@
10
10
  </template>
11
11
 
12
12
  <script setup lang="ts">
13
- import { UIComponents } from '@aerogel/core/ui/UI';
14
-
15
13
  import AppOverlays from './AppOverlays.vue';
16
14
  </script>
@@ -4,33 +4,6 @@
4
4
  </template>
5
5
 
6
6
  <script setup lang="ts">
7
- import { ref } from 'vue';
8
-
9
- import { useEvent } from '@aerogel/core/utils/composition/events';
10
-
11
7
  import AppModals from './AppModals.vue';
12
8
  import AppToasts from './AppToasts.vue';
13
-
14
- const $backdrop = ref<HTMLElement | null>(null);
15
- const backdropHidden = ref(true);
16
-
17
- useEvent('show-overlays-backdrop', async () => {
18
- if (!$backdrop.value || !backdropHidden.value) {
19
- return;
20
- }
21
-
22
- backdropHidden.value = false;
23
-
24
- $backdrop.value.classList.remove('opacity-0');
25
- });
26
-
27
- useEvent('hide-overlays-backdrop', async () => {
28
- if (!$backdrop.value || backdropHidden.value) {
29
- return;
30
- }
31
-
32
- backdropHidden.value = true;
33
-
34
- $backdrop.value.classList.add('opacity-0');
35
- });
36
9
  </script>
@@ -1,4 +1,19 @@
1
+ import { computed } from 'vue';
2
+
3
+ import { translateWithDefault } from '@aerogel/core/lang';
4
+ import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
5
+
1
6
  export interface AlertModalProps {
2
7
  title?: string;
3
8
  message: string;
4
9
  }
10
+
11
+ export interface AlertModalExpose extends ModalExpose<void> {}
12
+
13
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
14
+ export function useAlertModal(props: AlertModalProps) {
15
+ const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.alert', 'Alert'));
16
+ const titleHidden = computed(() => !props.title);
17
+
18
+ return { renderedTitle, titleHidden };
19
+ }
@@ -1,9 +1,11 @@
1
1
  import { computed } from 'vue';
2
2
 
3
3
  import { translateWithDefault } from '@aerogel/core/lang';
4
- import { FormFieldTypes, useForm } from '@aerogel/core/forms';
4
+ import { useForm } from '@aerogel/core/utils/composition/forms';
5
5
  import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
6
- import type { FormFieldDefinition } from '@aerogel/core/forms';
6
+ import type { FormFieldDefinition } from '@aerogel/core/forms/FormController';
7
+ import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
8
+ import type { Nullable } from '@noeldemartin/utils';
7
9
 
8
10
  export type ConfirmModalCheckboxes = Record<string, { label: string; default?: boolean; required?: boolean }>;
9
11
 
@@ -19,23 +21,28 @@ export interface ConfirmModalProps {
19
21
  required?: boolean;
20
22
  }
21
23
 
24
+ export interface ConfirmModalExpose extends ModalExpose<boolean | [boolean, Record<string, Nullable<boolean>>]> {}
25
+
22
26
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
23
27
  export function useConfirmModal(props: ConfirmModalProps) {
24
28
  const form = useForm(
25
29
  Object.entries(props.checkboxes ?? {}).reduce(
26
30
  (values, [name, checkbox]) => ({
27
31
  [name]: {
28
- type: FormFieldTypes.Boolean,
32
+ type: 'boolean',
29
33
  default: checkbox.default,
30
34
  required: checkbox.required ? 'required' : undefined,
31
35
  },
32
36
  ...values,
33
37
  }),
34
- {} as Record<string, FormFieldDefinition>,
38
+ {} as Record<string, FormFieldDefinition<'boolean'>>,
35
39
  ),
36
40
  );
41
+
42
+ const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.confirm', 'Confirm'));
43
+ const titleHidden = computed(() => !props.title);
37
44
  const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
38
45
  const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
39
46
 
40
- return { form, renderedAcceptText, renderedCancelText };
47
+ return { form, renderedTitle, titleHidden, renderedAcceptText, renderedCancelText };
41
48
  }
@@ -1,11 +1,25 @@
1
1
  import type { DropdownMenuContentProps } from 'reka-ui';
2
2
 
3
- export type DropdownMenuOption = {
3
+ import type { Falsifiable } from '@aerogel/core/utils/types';
4
+
5
+ export type DropdownMenuOptionData = {
4
6
  label: string;
5
- click: () => unknown;
7
+ href?: string;
8
+ route?: string;
9
+ routeParams?: object;
10
+ routeQuery?: object;
11
+ click?: () => unknown;
12
+ class?: string;
6
13
  };
7
14
 
8
15
  export interface DropdownMenuProps {
9
16
  align?: DropdownMenuContentProps['align'];
10
- options?: DropdownMenuOption[];
17
+ side?: DropdownMenuContentProps['side'];
18
+ options?: Falsifiable<DropdownMenuOptionData>[];
19
+ }
20
+
21
+ export interface DropdownMenuExpose {
22
+ align?: DropdownMenuContentProps['align'];
23
+ side?: DropdownMenuContentProps['side'];
24
+ options?: DropdownMenuOptionData[];
11
25
  }
@@ -2,18 +2,22 @@ import { computed, ref } from 'vue';
2
2
 
3
3
  import { translateWithDefault } from '@aerogel/core/lang';
4
4
  import type { ErrorReport } from '@aerogel/core/errors';
5
+ import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
5
6
 
6
7
  export interface ErrorReportModalProps {
8
+ report: ErrorReport;
7
9
  reports: ErrorReport[];
8
10
  }
9
11
 
12
+ export interface ErrorReportModalExpose extends ModalExpose {}
13
+
10
14
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
11
15
  export function useErrorReportModal(props: ErrorReportModalProps) {
12
- const activeReportIndex = ref(0);
13
- const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
16
+ const activeReportIndex = ref(props.reports.includes(props.report) ? props.reports.indexOf(props.report) : 0);
17
+ const activeReport = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
14
18
  const details = computed(
15
19
  () =>
16
- report.value.details?.trim() ||
20
+ activeReport.value.details?.trim() ||
17
21
  translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
18
22
  );
19
23
  const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
@@ -24,6 +28,6 @@ export function useErrorReportModal(props: ErrorReportModalProps) {
24
28
  details,
25
29
  nextReportText,
26
30
  previousReportText,
27
- report,
31
+ activeReport,
28
32
  };
29
33
  }
@@ -3,24 +3,24 @@ import type { Nullable } from '@noeldemartin/utils';
3
3
 
4
4
  import type { FormFieldValue } from '@aerogel/core/forms';
5
5
 
6
- export interface InputProps {
6
+ export interface InputProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
7
7
  name?: string;
8
8
  label?: string;
9
9
  description?: string;
10
- modelValue?: Nullable<FormFieldValue>;
10
+ modelValue?: T;
11
11
  }
12
12
 
13
- export interface InputEmits {
14
- 'update:modelValue': [value: Nullable<FormFieldValue>];
13
+ export interface InputEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
14
+ 'update:modelValue': [value: T];
15
15
  }
16
16
 
17
- export interface InputExpose {
17
+ export interface InputExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
18
18
  id: string;
19
19
  name: ComputedRef<Nullable<string>>;
20
20
  label: ComputedRef<Nullable<string>>;
21
21
  description: ComputedRef<Nullable<string | boolean>>;
22
- value: ComputedRef<Nullable<FormFieldValue>>;
22
+ value: ComputedRef<T>;
23
23
  required: ComputedRef<Nullable<boolean>>;
24
24
  errors: DeepReadonly<Ref<Nullable<string[]>>>;
25
- update(value: Nullable<FormFieldValue>): void;
25
+ update(value: T): void;
26
26
  }
@@ -1,7 +1,9 @@
1
- import type { Job } from '@aerogel/core/jobs';
2
- import { translateWithDefault } from '@aerogel/core/lang';
3
1
  import { computed } from 'vue';
4
2
 
3
+ import { translateWithDefault } from '@aerogel/core/lang';
4
+ import type { Job } from '@aerogel/core/jobs';
5
+ import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
6
+
5
7
  export interface LoadingModalProps {
6
8
  title?: string;
7
9
  message?: string;
@@ -9,10 +11,16 @@ export interface LoadingModalProps {
9
11
  job?: Job;
10
12
  }
11
13
 
14
+ export interface LoadingModalExpose extends ModalExpose {}
15
+
12
16
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
13
17
  export function useLoadingModal(props: LoadingModalProps) {
14
- const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
18
+ const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.loading', 'Loading'));
19
+ const renderedMessage = computed(
20
+ () => props.message ?? translateWithDefault('ui.loadingInProgress', 'Loading in progress...'),
21
+ );
15
22
  const showProgress = computed(() => typeof props.progress === 'number' || !!props.job);
23
+ const titleHidden = computed(() => !props.title);
16
24
 
17
- return { renderedMessage, showProgress };
25
+ return { renderedTitle, renderedMessage, titleHidden, showProgress };
18
26
  }
@@ -1,13 +1,21 @@
1
+ import type { Nullable } from '@noeldemartin/utils';
2
+ import type { DialogContent } from 'reka-ui';
3
+
4
+ export type ModalContentInstance = Nullable<InstanceType<typeof DialogContent>>;
5
+
1
6
  export interface ModalProps {
2
7
  persistent?: boolean;
3
8
  title?: string;
9
+ titleHidden?: boolean;
4
10
  description?: string;
11
+ descriptionHidden?: boolean;
5
12
  }
6
13
 
7
- export interface ModalSlots {
8
- default(props: { close(result?: unknown): Promise<void> }): unknown;
14
+ export interface ModalSlots<Result = void> {
15
+ default(props: { close(result?: Result): Promise<void> }): unknown;
9
16
  }
10
17
 
11
- export interface ModalExpose {
12
- close(result?: unknown): Promise<void>;
18
+ export interface ModalExpose<Result = void> {
19
+ close(result?: Result): Promise<void>;
20
+ $content: ModalContentInstance;
13
21
  }
@@ -1,8 +1,10 @@
1
1
  import { computed } from 'vue';
2
2
 
3
- import { requiredStringInput, useForm } from '@aerogel/core/forms';
3
+ import { useForm } from '@aerogel/core/utils/composition/forms';
4
+ import { requiredStringInput } from '@aerogel/core/forms/utils';
4
5
  import { translateWithDefault } from '@aerogel/core/lang';
5
6
  import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
7
+ import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
6
8
 
7
9
  export interface PromptModalProps {
8
10
  title?: string;
@@ -16,13 +18,17 @@ export interface PromptModalProps {
16
18
  cancelVariant?: ButtonVariant;
17
19
  }
18
20
 
21
+ export interface PromptModalExpose extends ModalExpose<string> {}
22
+
19
23
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
20
24
  export function usePromptModal(props: PromptModalProps) {
21
25
  const form = useForm({
22
26
  draft: requiredStringInput(props.defaultValue ?? ''),
23
27
  });
28
+ const renderedTitle = computed(() => props.title ?? props.message);
29
+ const renderedMessage = computed(() => (props.title ? props.message : null));
24
30
  const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
25
31
  const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
26
32
 
27
- return { form, renderedAcceptText, renderedCancelText };
33
+ return { form, renderedTitle, renderedMessage, renderedAcceptText, renderedCancelText };
28
34
  }
@@ -1,10 +1,12 @@
1
- import type { AcceptableValue, AsTag } from 'reka-ui';
2
- import type { Component, ComputedRef } from 'vue';
1
+ import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
2
+ import type { Component, ComputedRef, HTMLAttributes } from 'vue';
3
3
  import type { Nullable } from '@noeldemartin/utils';
4
4
 
5
+ import type { FormFieldValue } from '@aerogel/core/forms';
6
+
5
7
  import type { InputEmits, InputExpose, InputProps } from './Input';
6
8
 
7
- export type SelectOption = {
9
+ export type SelectOptionData = {
8
10
  key: string;
9
11
  label: string;
10
12
  value: AcceptableValue;
@@ -14,21 +16,28 @@ export interface HasSelectOptionLabel {
14
16
  label: string | (() => string);
15
17
  }
16
18
 
17
- export interface SelectProps extends InputProps {
19
+ export interface SelectProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputProps<T> {
18
20
  as?: AsTag | Component;
19
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
- options?: any[];
21
+ options?: T[];
21
22
  placeholder?: string;
22
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
- renderOption?: (option: any) => string;
23
+ renderOption?: (option: T) => string;
24
+ compareOptions?: (a: T, b: T) => boolean;
25
+ labelClass?: HTMLAttributes['class'];
26
+ optionsClass?: HTMLAttributes['class'];
27
+ align?: SelectContentProps['align'];
28
+ side?: SelectContentProps['side'];
24
29
  }
25
30
 
26
- export interface SelectEmits extends InputEmits {}
31
+ export interface SelectEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputEmits<T> {}
27
32
 
28
- export interface SelectExpose extends InputExpose {
29
- options: ComputedRef<Nullable<SelectOption[]>>;
30
- selectedOption: ComputedRef<Nullable<SelectOption>>;
33
+ export interface SelectExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputExpose<T> {
34
+ options: ComputedRef<Nullable<SelectOptionData[]>>;
35
+ selectedOption: ComputedRef<Nullable<SelectOptionData>>;
31
36
  placeholder: ComputedRef<string>;
37
+ labelClass?: HTMLAttributes['class'];
38
+ optionsClass?: HTMLAttributes['class'];
39
+ align?: SelectContentProps['align'];
40
+ side?: SelectContentProps['side'];
32
41
  }
33
42
 
34
43
  export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
@@ -1,13 +1,15 @@
1
+ export type ToastVariant = 'secondary' | 'danger';
2
+
1
3
  export interface ToastAction {
2
4
  label: string;
3
5
  dismiss?: boolean;
4
6
  click?(): unknown;
5
7
  }
6
8
 
7
- export type ToastVariant = 'secondary' | 'danger';
8
-
9
9
  export interface ToastProps {
10
10
  message?: string;
11
11
  actions?: ToastAction[];
12
12
  variant?: ToastVariant;
13
13
  }
14
+
15
+ export interface ToastExpose {}
@@ -2,8 +2,10 @@ export * from './AlertModal';
2
2
  export * from './Button';
3
3
  export * from './ConfirmModal';
4
4
  export * from './DropdownMenu';
5
+ export * from './ErrorReportModal';
6
+ export * from './Input';
5
7
  export * from './LoadingModal';
6
8
  export * from './Modal';
7
9
  export * from './PromptModal';
8
10
  export * from './Select';
9
- export * from './shared';
11
+ export * from './Toast';
@@ -14,6 +14,7 @@ import { computed } from 'vue';
14
14
  import { Primitive } from 'reka-ui';
15
15
  import { objectWithoutEmpty } from '@noeldemartin/utils';
16
16
 
17
+ import UI from '@aerogel/core/ui/UI';
17
18
  import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
18
19
 
19
20
  const { as, href, route, routeParams, routeQuery, submit, disabled, class: classes } = defineProps<ButtonProps>();
@@ -25,7 +26,7 @@ const props = computed(() => {
25
26
 
26
27
  if (route) {
27
28
  return {
28
- as: 'router-link',
29
+ as: UI.resolveComponent('router-link') ?? 'a',
29
30
  to: objectWithoutEmpty({
30
31
  name: route,
31
32
  params: routeParams,
@@ -23,7 +23,7 @@ const errors = computed(() => {
23
23
  return form.errors[name] ?? null;
24
24
  });
25
25
 
26
- const context = {
26
+ const expose = {
27
27
  id: `input-${uuid()}`,
28
28
  name: computed(() => name),
29
29
  label: computed(() => label),
@@ -54,6 +54,6 @@ const context = {
54
54
  },
55
55
  } satisfies InputExpose;
56
56
 
57
- provide('input', context);
58
- defineExpose(context);
57
+ provide('input', expose);
58
+ defineExpose(expose);
59
59
  </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <input
3
3
  :id="input.id"
4
- ref="$input"
4
+ ref="$inputRef"
5
5
  :name
6
6
  :type
7
7
  :checked
@@ -15,15 +15,15 @@
15
15
  </template>
16
16
 
17
17
  <script setup lang="ts">
18
- import { computed, ref, watchEffect } from 'vue';
18
+ import { computed, useTemplateRef, watchEffect } from 'vue';
19
19
 
20
20
  import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
21
- import { onFormFocus } from '@aerogel/core/components/utils';
21
+ import { onFormFocus } from '@aerogel/core/utils/composition/forms';
22
22
  import type { FormFieldValue } from '@aerogel/core/forms/FormController';
23
23
  import type { InputExpose } from '@aerogel/core/components/contracts/Input';
24
24
 
25
25
  const { type = 'text' } = defineProps<{ type?: string }>();
26
- const $input = ref<HTMLInputElement>();
26
+ const $input = useTemplateRef('$inputRef');
27
27
  const input = injectReactiveOrFail<InputExpose>('input', '<HeadlessInputInput> must be a child of a <HeadlessInput>');
28
28
  const name = computed(() => input.name ?? undefined);
29
29
  const value = computed(() => input.value);
@@ -64,8 +64,8 @@ watchEffect(() => {
64
64
  return;
65
65
  }
66
66
 
67
- if (type === 'date') {
68
- $input.value.valueAsDate = value.value as Date;
67
+ if (type === 'date' && value.value instanceof Date) {
68
+ $input.value.valueAsDate = value.value;
69
69
 
70
70
  return;
71
71
  }
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <textarea
3
3
  :id="input.id"
4
- ref="$textArea"
4
+ ref="$textAreaRef"
5
5
  :name
6
6
  :value
7
7
  :required="input.required ?? undefined"
@@ -14,13 +14,13 @@
14
14
  </template>
15
15
 
16
16
  <script setup lang="ts">
17
- import { computed, ref } from 'vue';
17
+ import { computed, useTemplateRef } from 'vue';
18
18
 
19
- import { onFormFocus } from '@aerogel/core/components/utils';
19
+ import { onFormFocus } from '@aerogel/core/utils/composition/forms';
20
20
  import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
21
21
  import type { InputExpose } from '@aerogel/core/components/contracts/Input';
22
22
 
23
- const $textArea = ref<HTMLTextAreaElement>();
23
+ const $textArea = useTemplateRef('$textAreaRef');
24
24
  const input = injectReactiveOrFail<InputExpose>(
25
25
  'input',
26
26
  '<HeadlessInputTextArea> must be a child of a <HeadlessInput>',
@@ -1,62 +1,39 @@
1
1
  <template>
2
- <DialogRoot ref="$root" open @update:open="persistent || close()">
2
+ <DialogRoot :ref="forwardRef" open @update:open="persistent || close()">
3
3
  <DialogPortal>
4
4
  <slot :close="close" />
5
5
  </DialogPortal>
6
6
  </DialogRoot>
7
7
  </template>
8
8
 
9
- <script setup lang="ts">
10
- import { ref } from 'vue';
11
- import { DialogPortal, DialogRoot } from 'reka-ui';
9
+ <script setup lang="ts" generic="T = void">
10
+ import { provide, ref } from 'vue';
11
+ import { DialogPortal, DialogRoot, useForwardExpose } from 'reka-ui';
12
+ import type { DialogContent } from 'reka-ui';
13
+ import type { Nullable } from '@noeldemartin/utils';
12
14
 
13
15
  import Events from '@aerogel/core/services/Events';
14
16
  import { useEvent } from '@aerogel/core/utils/composition/events';
15
17
  import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
16
- import type { UIModalContext } from '@aerogel/core/ui/UI.state';
18
+ import type { AcceptRefs } from '@aerogel/core/utils/vue';
19
+ import type { UIModalContext } from '@aerogel/core/ui/UI';
17
20
  import type { ModalExpose, ModalProps, ModalSlots } from '@aerogel/core/components/contracts/Modal';
18
21
 
19
- defineProps<ModalProps>();
20
- defineSlots<ModalSlots>();
21
-
22
- const $root = ref<{ $el?: HTMLElement } | null>(null);
23
- const hidden = ref(true);
24
- const closed = ref(false);
22
+ const $content = ref<Nullable<InstanceType<typeof DialogContent>>>(null);
25
23
  const { modal } = injectReactiveOrFail<UIModalContext>(
26
24
  'modal',
27
25
  'could not obtain modal reference from <HeadlessModal>, ' +
28
- 'did you render this component manually? Show it using $ui.openModal() instead',
26
+ 'did you render this component manually? Show it using $ui.modal() instead',
29
27
  );
30
28
 
31
- async function hide(): Promise<void> {
32
- if (!$root.value?.$el) {
33
- return;
34
- }
35
-
36
- hidden.value = true;
37
- }
38
-
39
- async function show(): Promise<void> {
40
- if (!$root.value?.$el) {
41
- return;
42
- }
43
-
44
- hidden.value = false;
45
- }
46
-
47
- async function close(result?: unknown) {
48
- if (closed.value) {
49
- return;
50
- }
51
-
52
- Events.emit('modal-will-close', { modal, result });
29
+ defineProps<ModalProps>();
30
+ defineSlots<ModalSlots<T>>();
31
+ defineExpose<AcceptRefs<ModalExpose<T>>>({ close, $content });
53
32
 
54
- await hide();
33
+ const { forwardRef } = useForwardExpose();
34
+ const closed = ref(false);
55
35
 
56
- closed.value = true;
57
-
58
- Events.emit('modal-closed', { modal, result });
59
- }
36
+ provide('$modalContentRef', $content);
60
37
 
61
38
  useEvent('close-modal', async ({ id, result }) => {
62
39
  if (id !== modal.id) {
@@ -66,21 +43,15 @@ useEvent('close-modal', async ({ id, result }) => {
66
43
  await close(result);
67
44
  });
68
45
 
69
- useEvent('hide-modal', async ({ id }) => {
70
- if (id !== modal.id) {
46
+ async function close(result?: unknown) {
47
+ if (closed.value) {
71
48
  return;
72
49
  }
73
50
 
74
- await hide();
75
- });
76
-
77
- useEvent('show-modal', async ({ id }) => {
78
- if (id !== modal.id) {
79
- return;
80
- }
51
+ await Events.emit('modal-will-close', { modal, result });
81
52
 
82
- await show();
83
- });
53
+ closed.value = true;
84
54
 
85
- defineExpose<ModalExpose>({ close });
55
+ await Events.emit('modal-has-closed', { modal, result });
56
+ }
86
57
  </script>