@aerogel/core 0.0.0-next.b243de4e2590f02709edeebd8c13b74087592c04 → 0.0.0-next.b3caf219a503ce9b8c65ef1463132c9507f56c0a

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 (162) hide show
  1. package/dist/aerogel-core.d.ts +1346 -1647
  2. package/dist/aerogel-core.js +2960 -0
  3. package/dist/aerogel-core.js.map +1 -0
  4. package/package.json +27 -37
  5. package/src/bootstrap/bootstrap.test.ts +4 -7
  6. package/src/bootstrap/index.ts +25 -16
  7. package/src/bootstrap/options.ts +1 -1
  8. package/src/components/{AGAppLayout.vue → AppLayout.vue} +4 -4
  9. package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
  10. package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +5 -5
  11. package/src/components/composition.ts +1 -1
  12. package/src/components/contracts/AlertModal.ts +4 -0
  13. package/src/components/contracts/Button.ts +15 -0
  14. package/src/components/contracts/ConfirmModal.ts +41 -0
  15. package/src/components/contracts/ErrorReportModal.ts +29 -0
  16. package/src/components/contracts/Input.ts +26 -0
  17. package/src/components/contracts/LoadingModal.ts +18 -0
  18. package/src/components/contracts/Modal.ts +9 -0
  19. package/src/components/contracts/PromptModal.ts +28 -0
  20. package/src/components/contracts/index.ts +7 -0
  21. package/src/components/contracts/shared.ts +9 -0
  22. package/src/components/forms/AGSelect.vue +11 -17
  23. package/src/components/forms/index.ts +0 -4
  24. package/src/components/headless/HeadlessButton.vue +45 -0
  25. package/src/components/headless/HeadlessInput.vue +59 -0
  26. package/src/components/headless/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +5 -6
  27. package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
  28. package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +10 -19
  29. package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
  30. package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +6 -9
  31. package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +16 -18
  32. package/src/components/headless/HeadlessModalContent.vue +24 -0
  33. package/src/components/headless/HeadlessModalOverlay.vue +12 -0
  34. package/src/components/headless/HeadlessModalTitle.vue +12 -0
  35. package/src/components/headless/forms/AGHeadlessSelect.ts +3 -3
  36. package/src/components/headless/forms/AGHeadlessSelect.vue +16 -16
  37. package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
  38. package/src/components/headless/forms/AGHeadlessSelectOption.vue +10 -18
  39. package/src/components/headless/forms/AGHeadlessSelectOptions.vue +19 -0
  40. package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +25 -0
  41. package/src/components/headless/forms/composition.ts +2 -2
  42. package/src/components/headless/forms/index.ts +2 -12
  43. package/src/components/headless/index.ts +12 -1
  44. package/src/components/headless/snackbars/index.ts +3 -3
  45. package/src/components/index.ts +5 -5
  46. package/src/components/lib/AGErrorMessage.vue +3 -3
  47. package/src/components/lib/AGMarkdown.vue +16 -3
  48. package/src/components/lib/AGMeasured.vue +2 -2
  49. package/src/components/lib/AGStartupCrash.vue +6 -6
  50. package/src/components/lib/index.ts +0 -1
  51. package/src/components/snackbars/AGSnackbar.vue +8 -6
  52. package/src/components/ui/AlertModal.vue +13 -0
  53. package/src/components/ui/Button.vue +58 -0
  54. package/src/components/ui/Checkbox.vue +49 -0
  55. package/src/components/ui/ConfirmModal.vue +42 -0
  56. package/src/components/ui/ErrorReportModal.vue +62 -0
  57. package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +29 -20
  58. package/src/components/ui/ErrorReportModalTitle.vue +24 -0
  59. package/src/components/{forms/AGForm.vue → ui/Form.vue} +4 -5
  60. package/src/components/ui/Input.vue +52 -0
  61. package/src/components/ui/Link.vue +12 -0
  62. package/src/components/ui/LoadingModal.vue +32 -0
  63. package/src/components/ui/Modal.vue +55 -0
  64. package/src/components/ui/ModalContext.vue +30 -0
  65. package/src/components/ui/ProgressBar.vue +50 -0
  66. package/src/components/ui/PromptModal.vue +35 -0
  67. package/src/components/ui/index.ts +15 -0
  68. package/src/components/utils.ts +106 -9
  69. package/src/directives/index.ts +9 -5
  70. package/src/directives/measure.ts +1 -1
  71. package/src/errors/Errors.state.ts +1 -1
  72. package/src/errors/Errors.ts +14 -14
  73. package/src/errors/JobCancelledError.ts +3 -0
  74. package/src/errors/index.ts +9 -6
  75. package/src/errors/utils.ts +17 -1
  76. package/src/forms/{Form.test.ts → FormController.test.ts} +5 -4
  77. package/src/forms/{Form.ts → FormController.ts} +22 -19
  78. package/src/forms/composition.ts +4 -4
  79. package/src/forms/index.ts +2 -2
  80. package/src/forms/utils.ts +2 -2
  81. package/src/index.css +8 -0
  82. package/src/jobs/Job.ts +144 -2
  83. package/src/jobs/index.ts +4 -1
  84. package/src/jobs/listeners.ts +3 -0
  85. package/src/jobs/status.ts +4 -0
  86. package/src/lang/DefaultLangProvider.ts +7 -4
  87. package/src/lang/Lang.state.ts +1 -1
  88. package/src/lang/Lang.ts +1 -1
  89. package/src/lang/index.ts +8 -6
  90. package/src/plugins/Plugin.ts +1 -1
  91. package/src/plugins/index.ts +10 -7
  92. package/src/services/App.state.ts +13 -4
  93. package/src/services/App.ts +8 -3
  94. package/src/services/Cache.ts +1 -1
  95. package/src/services/Events.ts +15 -5
  96. package/src/services/Service.ts +116 -53
  97. package/src/services/Storage.ts +20 -0
  98. package/src/services/index.ts +11 -5
  99. package/src/services/utils.ts +18 -0
  100. package/src/testing/index.ts +4 -3
  101. package/src/testing/setup.ts +5 -13
  102. package/src/ui/UI.state.ts +10 -5
  103. package/src/ui/UI.ts +145 -59
  104. package/src/ui/index.ts +16 -16
  105. package/src/utils/composition/events.ts +2 -2
  106. package/src/utils/composition/forms.ts +4 -3
  107. package/src/utils/composition/persistent.test.ts +33 -0
  108. package/src/utils/composition/persistent.ts +11 -0
  109. package/src/utils/composition/state.test.ts +47 -0
  110. package/src/utils/composition/state.ts +24 -0
  111. package/src/utils/index.ts +2 -0
  112. package/src/utils/markdown.test.ts +50 -0
  113. package/src/utils/markdown.ts +19 -6
  114. package/src/utils/vue.ts +11 -13
  115. package/dist/aerogel-core.cjs.js +0 -2
  116. package/dist/aerogel-core.cjs.js.map +0 -1
  117. package/dist/aerogel-core.esm.js +0 -2
  118. package/dist/aerogel-core.esm.js.map +0 -1
  119. package/histoire.config.ts +0 -7
  120. package/noeldemartin.config.js +0 -5
  121. package/postcss.config.js +0 -6
  122. package/src/assets/histoire.css +0 -3
  123. package/src/components/forms/AGButton.vue +0 -44
  124. package/src/components/forms/AGCheckbox.vue +0 -41
  125. package/src/components/forms/AGInput.vue +0 -40
  126. package/src/components/headless/forms/AGHeadlessButton.ts +0 -3
  127. package/src/components/headless/forms/AGHeadlessButton.vue +0 -62
  128. package/src/components/headless/forms/AGHeadlessInput.ts +0 -34
  129. package/src/components/headless/forms/AGHeadlessInput.vue +0 -70
  130. package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
  131. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
  132. package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
  133. package/src/components/headless/modals/AGHeadlessModal.ts +0 -34
  134. package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
  135. package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
  136. package/src/components/headless/modals/index.ts +0 -4
  137. package/src/components/interfaces.ts +0 -24
  138. package/src/components/lib/AGLink.vue +0 -9
  139. package/src/components/modals/AGAlertModal.ts +0 -15
  140. package/src/components/modals/AGAlertModal.vue +0 -14
  141. package/src/components/modals/AGConfirmModal.ts +0 -33
  142. package/src/components/modals/AGConfirmModal.vue +0 -26
  143. package/src/components/modals/AGErrorReportModal.ts +0 -46
  144. package/src/components/modals/AGErrorReportModal.vue +0 -54
  145. package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
  146. package/src/components/modals/AGLoadingModal.ts +0 -23
  147. package/src/components/modals/AGLoadingModal.vue +0 -15
  148. package/src/components/modals/AGModal.ts +0 -10
  149. package/src/components/modals/AGModal.vue +0 -39
  150. package/src/components/modals/AGModalContext.ts +0 -8
  151. package/src/components/modals/AGModalContext.vue +0 -22
  152. package/src/components/modals/AGModalTitle.vue +0 -9
  153. package/src/components/modals/AGPromptModal.ts +0 -36
  154. package/src/components/modals/AGPromptModal.vue +0 -34
  155. package/src/components/modals/index.ts +0 -17
  156. package/src/directives/initial-focus.ts +0 -11
  157. package/src/main.histoire.ts +0 -1
  158. package/tailwind.config.js +0 -4
  159. package/tsconfig.json +0 -11
  160. package/vite.config.ts +0 -17
  161. /package/src/components/{AGAppSnackbars.vue → AppSnackbars.vue} +0 -0
  162. /package/src/{main.ts → index.ts} +0 -0
package/package.json CHANGED
@@ -1,52 +1,42 @@
1
1
  {
2
2
  "name": "@aerogel/core",
3
- "description": "The Lightest Solid",
4
- "version": "0.0.0-next.b243de4e2590f02709edeebd8c13b74087592c04",
5
- "main": "dist/aerogel-core.cjs.js",
6
- "module": "dist/aerogel-core.esm.js",
7
- "types": "dist/aerogel-core.d.ts",
3
+ "version": "0.0.0-next.b3caf219a503ce9b8c65ef1463132c9507f56c0a",
4
+ "type": "module",
8
5
  "sideEffects": false,
6
+ "exports": {
7
+ "types": "./dist/aerogel-core.d.ts",
8
+ "style": "./src/index.css",
9
+ "default": "./dist/aerogel-core.js"
10
+ },
11
+ "files": [
12
+ "src",
13
+ "dist"
14
+ ],
15
+ "license": "MIT",
16
+ "author": "Noel De Martin",
17
+ "repository": "github:NoelDeMartin/aerogel",
9
18
  "scripts": {
10
- "build": "rm dist -rf && npm run build:js && npm run build:types",
11
- "build:js": "noeldemartin-build-javascript",
12
- "build:types": "noeldemartin-build-types",
13
- "histoire": "histoire dev",
19
+ "build": "vite build && ./scripts/fix-types.sh",
14
20
  "lint": "noeldemartin-lint src",
15
- "publish-next": "noeldemartin-publish-next",
16
21
  "test": "vitest --run",
17
- "test:ci": "vitest --run --reporter verbose"
18
- },
19
- "engines": {
20
- "node": ">=18.x"
22
+ "test:ci": "vitest --run --reporter verbose",
23
+ "verify": "noeldemartin-verify"
21
24
  },
22
- "repository": {
23
- "type": "git",
24
- "url": "https://github.com/NoelDeMartin/aerogeljs.git"
25
- },
26
- "keywords": [
27
- "javascript",
28
- "framework",
29
- "solid"
30
- ],
31
- "author": "Noel De Martin",
32
- "license": "MIT",
33
- "bugs": {
34
- "url": "https://github.com/NoelDeMartin/aerogeljs/issues"
25
+ "peerDependencies": {
26
+ "vue": "^3.5.0"
35
27
  },
36
28
  "dependencies": {
37
- "@headlessui/vue": "^1.7.14",
38
- "@noeldemartin/utils": "0.5.1-next.82707467527729a9fe7c2155959beb4b5ea30b81",
39
- "dompurify": "^3.0.3",
40
- "marked": "^5.0.4",
29
+ "@noeldemartin/utils": "0.7.0-next.31cf84b4b57092d146528f27579439783aca71bb",
30
+ "class-variance-authority": "^0.7.1",
31
+ "clsx": "^2.1.1",
32
+ "dompurify": "^3.2.4",
33
+ "marked": "^15.0.7",
41
34
  "pinia": "^2.1.6",
42
- "vue": "^3.3.0"
35
+ "reka-ui": "^2.2.0",
36
+ "tailwind-merge": "^3.1.0"
43
37
  },
44
38
  "devDependencies": {
45
- "@aerogel/vite": "*",
46
- "@histoire/plugin-vue": "0.17.6",
47
- "@types/dompurify": "^3.0.2",
48
- "@types/marked": "^5.0.0",
49
- "tailwindcss": "^3.3.5"
39
+ "@aerogel/vite": "*"
50
40
  },
51
41
  "eslintConfig": {
52
42
  "extends": [
@@ -1,10 +1,10 @@
1
1
  import { beforeEach, describe, expect, it, vi } from 'vitest';
2
2
  import { createApp } from 'vue';
3
- import { mock } from '@noeldemartin/utils';
3
+ import { mock } from '@noeldemartin/testing';
4
4
  import type { Component } from 'vue';
5
5
 
6
- import Events from '@/services/Events';
7
- import initialFocus from '@/directives/initial-focus';
6
+ import Events from '@aerogel/core/services/Events';
7
+ import measure from '@aerogel/core/directives/measure';
8
8
 
9
9
  import { bootstrap } from './index';
10
10
 
@@ -48,10 +48,7 @@ describe('Aerogel', () => {
48
48
  await bootstrap(rootComponent);
49
49
 
50
50
  // Assert
51
- expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith(
52
- 'initial-focus',
53
- initialFocus,
54
- );
51
+ expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith('measure', measure);
55
52
  });
56
53
 
57
54
  });
@@ -1,21 +1,25 @@
1
1
  import { createApp } from 'vue';
2
- import type { App, Component } from 'vue';
3
-
4
- import directives from '@/directives';
5
- import errors from '@/errors';
6
- import Events from '@/services/Events';
7
- import lang from '@/lang';
8
- import services from '@/services';
9
- import testing from '@/testing';
10
- import ui from '@/ui';
11
- import { installPlugins } from '@/plugins';
12
- import type { AerogelOptions } from '@/bootstrap/options';
13
-
14
- export { AerogelOptions };
15
-
16
- export async function bootstrapApplication(app: App, options: AerogelOptions = {}): Promise<void> {
2
+ import { isDevelopment } from '@noeldemartin/utils';
3
+ import type { App as AppInstance, Component } from 'vue';
4
+
5
+ import App from '@aerogel/core/services/App';
6
+ import directives from '@aerogel/core/directives';
7
+ import errors from '@aerogel/core/errors';
8
+ import Events from '@aerogel/core/services/Events';
9
+ import lang from '@aerogel/core/lang';
10
+ import services from '@aerogel/core/services';
11
+ import testing from '@aerogel/core/testing';
12
+ import ui from '@aerogel/core/ui';
13
+ import { installPlugins } from '@aerogel/core/plugins';
14
+ import type { AerogelOptions } from '@aerogel/core/bootstrap/options';
15
+
16
+ export type { AerogelOptions };
17
+
18
+ export async function bootstrapApplication(app: AppInstance, options: AerogelOptions = {}): Promise<void> {
17
19
  const plugins = [testing, directives, errors, lang, services, ui, ...(options.plugins ?? [])];
18
20
 
21
+ App.instance = app;
22
+
19
23
  await installPlugins(plugins, app, options);
20
24
  await options.install?.(app);
21
25
  await Events.emit('application-ready');
@@ -24,6 +28,11 @@ export async function bootstrapApplication(app: App, options: AerogelOptions = {
24
28
  export async function bootstrap(rootComponent: Component, options: AerogelOptions = {}): Promise<void> {
25
29
  const app = createApp(rootComponent);
26
30
 
31
+ if (isDevelopment()) {
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ (window as any).$aerogel = app;
34
+ }
35
+
27
36
  await bootstrapApplication(app, options);
28
37
 
29
38
  app.mount('#app');
@@ -32,7 +41,7 @@ export async function bootstrap(rootComponent: Component, options: AerogelOption
32
41
  await Events.emit('application-mounted');
33
42
  }
34
43
 
35
- declare module '@/services/Events' {
44
+ declare module '@aerogel/core/services/Events' {
36
45
  export interface EventsPayload {
37
46
  'application-ready': void;
38
47
  'application-mounted': void;
@@ -1,6 +1,6 @@
1
1
  import type { App } from 'vue';
2
2
 
3
- import type { Plugin } from '@/plugins';
3
+ import type { Plugin } from '@aerogel/core/plugins';
4
4
 
5
5
  export interface AerogelOptions {
6
6
  plugins?: Plugin[];
@@ -1,16 +1,16 @@
1
1
  <template>
2
- <div class="flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
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
4
  <component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
5
5
  </slot>
6
6
  <slot v-else />
7
7
 
8
- <AGAppOverlays />
8
+ <AppOverlays />
9
9
  </div>
10
10
  </template>
11
11
 
12
12
  <script setup lang="ts">
13
- import { UIComponents } from '@/ui/UI';
13
+ import { UIComponents } from '@aerogel/core/ui/UI';
14
14
 
15
- import AGAppOverlays from './AGAppOverlays.vue';
15
+ import AppOverlays from './AppOverlays.vue';
16
16
  </script>
@@ -1,15 +1,14 @@
1
1
  <template>
2
2
  <aside v-if="modal">
3
- <AGModalContext :child-index="1" :modal="modal" />
3
+ <ModalContext :child-index="1" :modal="modal" />
4
4
  </aside>
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
8
  import { computed } from 'vue';
9
9
 
10
- import UI from '@/ui/UI';
11
-
12
- import AGModalContext from './modals/AGModalContext.vue';
10
+ import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
11
+ import UI from '@aerogel/core/ui/UI';
13
12
 
14
13
  const modal = computed(() => UI.modals[0] ?? null);
15
14
  </script>
@@ -4,17 +4,17 @@
4
4
  ref="$backdrop"
5
5
  class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
6
6
  />
7
- <AGAppModals />
8
- <AGAppSnackbars />
7
+ <AppModals />
8
+ <AppSnackbars />
9
9
  </template>
10
10
 
11
11
  <script setup lang="ts">
12
12
  import { ref } from 'vue';
13
13
 
14
- import { useEvent } from '@/utils/composition/events';
14
+ import { useEvent } from '@aerogel/core/utils/composition/events';
15
15
 
16
- import AGAppModals from './AGAppModals.vue';
17
- import AGAppSnackbars from './AGAppSnackbars.vue';
16
+ import AppModals from './AppModals.vue';
17
+ import AppSnackbars from './AppSnackbars.vue';
18
18
 
19
19
  const $backdrop = ref<HTMLElement | null>(null);
20
20
  const backdropHidden = ref(true);
@@ -1,7 +1,7 @@
1
1
  import { customRef } from 'vue';
2
2
  import type { Ref } from 'vue';
3
3
 
4
- import { getElement } from '@/components/interfaces';
4
+ import { getElement } from '@aerogel/core/components/utils';
5
5
 
6
6
  export function elementRef(): Ref<HTMLElement | undefined> {
7
7
  return customRef((track, trigger) => {
@@ -0,0 +1,4 @@
1
+ export interface AlertModalProps {
2
+ title?: string;
3
+ message: string;
4
+ }
@@ -0,0 +1,15 @@
1
+ import type { PrimitiveProps } from 'reka-ui';
2
+ import type { HTMLAttributes } from 'vue';
3
+
4
+ export type ButtonVariant = 'default' | 'secondary' | 'danger' | 'ghost' | 'outline' | 'link';
5
+ export type ButtonSize = 'default' | 'small' | 'large' | 'icon';
6
+ export interface ButtonProps extends PrimitiveProps {
7
+ class?: HTMLAttributes['class'];
8
+ href?: string;
9
+ route?: string;
10
+ routeParams?: object;
11
+ routeQuery?: object;
12
+ size?: ButtonSize;
13
+ submit?: boolean;
14
+ variant?: ButtonVariant;
15
+ }
@@ -0,0 +1,41 @@
1
+ import { computed } from 'vue';
2
+
3
+ import { translateWithDefault } from '@aerogel/core/lang';
4
+ import { FormFieldTypes, useForm } from '@aerogel/core/forms';
5
+ import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
6
+ import type { FormFieldDefinition } from '@aerogel/core/forms';
7
+
8
+ export type ConfirmModalCheckboxes = Record<string, { label: string; default?: boolean; required?: boolean }>;
9
+
10
+ export interface ConfirmModalProps {
11
+ title?: string;
12
+ message: string;
13
+ acceptText?: string;
14
+ acceptVariant?: ButtonVariant;
15
+ cancelText?: string;
16
+ cancelVariant?: ButtonVariant;
17
+ checkboxes?: ConfirmModalCheckboxes;
18
+ actions?: Record<string, () => unknown>;
19
+ required?: boolean;
20
+ }
21
+
22
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
23
+ export function useConfirmModal(props: ConfirmModalProps) {
24
+ const form = useForm(
25
+ Object.entries(props.checkboxes ?? {}).reduce(
26
+ (values, [name, checkbox]) => ({
27
+ [name]: {
28
+ type: FormFieldTypes.Boolean,
29
+ default: checkbox.default,
30
+ required: checkbox.required ? 'required' : undefined,
31
+ },
32
+ ...values,
33
+ }),
34
+ {} as Record<string, FormFieldDefinition>,
35
+ ),
36
+ );
37
+ const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
38
+ const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
39
+
40
+ return { form, renderedAcceptText, renderedCancelText };
41
+ }
@@ -0,0 +1,29 @@
1
+ import { computed, ref } from 'vue';
2
+
3
+ import { translateWithDefault } from '@aerogel/core/lang';
4
+ import type { ErrorReport } from '@aerogel/core/errors';
5
+
6
+ export interface ErrorReportModalProps {
7
+ reports: ErrorReport[];
8
+ }
9
+
10
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
11
+ export function useErrorReportModal(props: ErrorReportModalProps) {
12
+ const activeReportIndex = ref(0);
13
+ const report = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
14
+ const details = computed(
15
+ () =>
16
+ report.value.details?.trim() ||
17
+ translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
18
+ );
19
+ const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
20
+ const nextReportText = translateWithDefault('errors.nextReport', 'Show next report');
21
+
22
+ return {
23
+ activeReportIndex,
24
+ details,
25
+ nextReportText,
26
+ previousReportText,
27
+ report,
28
+ };
29
+ }
@@ -0,0 +1,26 @@
1
+ import type { Nullable } from '@noeldemartin/utils';
2
+
3
+ import type { FormFieldValue } from '@aerogel/core/forms';
4
+ import type { ComputedRef, DeepReadonly, Ref } from 'vue';
5
+
6
+ export interface InputProps {
7
+ name?: string;
8
+ label?: string;
9
+ description?: string;
10
+ modelValue?: FormFieldValue;
11
+ }
12
+
13
+ export type InputEmits = {
14
+ (event: 'update:modelValue', value: Nullable<FormFieldValue>): void;
15
+ };
16
+
17
+ export interface InputExpose {
18
+ id: string;
19
+ name: ComputedRef<Nullable<string>>;
20
+ label: ComputedRef<Nullable<string>>;
21
+ description: ComputedRef<Nullable<string | boolean>>;
22
+ value: ComputedRef<Nullable<FormFieldValue>>;
23
+ required: ComputedRef<Nullable<boolean>>;
24
+ errors: DeepReadonly<Ref<Nullable<string[]>>>;
25
+ update(value: Nullable<FormFieldValue>): void;
26
+ }
@@ -0,0 +1,18 @@
1
+ import type { Job } from '@aerogel/core/jobs';
2
+ import { translateWithDefault } from '@aerogel/core/lang';
3
+ import { computed } from 'vue';
4
+
5
+ export interface LoadingModalProps {
6
+ title?: string;
7
+ message?: string;
8
+ progress?: number;
9
+ job?: Job;
10
+ }
11
+
12
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
13
+ export function useLoadingModal(props: LoadingModalProps) {
14
+ const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
15
+ const showProgress = computed(() => typeof props.progress === 'number' || !!props.job);
16
+
17
+ return { renderedMessage, showProgress };
18
+ }
@@ -0,0 +1,9 @@
1
+ export interface ModalProps {
2
+ persistent?: boolean;
3
+ title?: string;
4
+ description?: string;
5
+ }
6
+
7
+ export interface ModalSlots {
8
+ default(props: { close(result?: unknown): Promise<void> }): unknown;
9
+ }
@@ -0,0 +1,28 @@
1
+ import { computed } from 'vue';
2
+
3
+ import { requiredStringInput, useForm } from '@aerogel/core/forms';
4
+ import { translateWithDefault } from '@aerogel/core/lang';
5
+ import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
6
+
7
+ export interface PromptModalProps {
8
+ title?: string;
9
+ message: string;
10
+ label?: string;
11
+ defaultValue?: string;
12
+ placeholder?: string;
13
+ acceptText?: string;
14
+ acceptVariant?: ButtonVariant;
15
+ cancelText?: string;
16
+ cancelVariant?: ButtonVariant;
17
+ }
18
+
19
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
20
+ export function usePromptModal(props: PromptModalProps) {
21
+ const form = useForm({
22
+ draft: requiredStringInput(props.defaultValue ?? ''),
23
+ });
24
+ const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
25
+ const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
26
+
27
+ return { form, renderedAcceptText, renderedCancelText };
28
+ }
@@ -0,0 +1,7 @@
1
+ export * from './AlertModal';
2
+ export * from './Button';
3
+ export * from './ConfirmModal';
4
+ export * from './LoadingModal';
5
+ export * from './Modal';
6
+ export * from './PromptModal';
7
+ export * from './shared';
@@ -0,0 +1,9 @@
1
+ import type { Ref } from 'vue';
2
+
3
+ export interface HasElement {
4
+ $el: Readonly<Ref<HTMLElement | undefined>>;
5
+ }
6
+
7
+ export interface __SetsElement {
8
+ __setElement(element?: HTMLElement): void;
9
+ }
@@ -5,10 +5,9 @@
5
5
  as="div"
6
6
  @update:model-value="$emit('update:modelValue', $event)"
7
7
  >
8
- <AGHeadlessSelectLabel class="block text-sm font-medium leading-6 text-gray-900" />
9
8
  <div class="relative" :class="{ 'mt-2': $select?.label }">
10
- <AGHeadlessSelectButton
11
- class="relative w-full cursor-default bg-white py-1.5 pl-3 pr-10 text-left text-gray-900 ring-1 ring-inset ring-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-600"
9
+ <AGHeadlessSelectTrigger
10
+ class="relative w-full cursor-default bg-white py-1.5 pr-10 pl-3 text-left text-gray-900 ring-1 ring-gray-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-hidden"
12
11
  text-class="block truncate"
13
12
  :class="{
14
13
  'ring-1 ring-red-500': $select?.errors,
@@ -16,22 +15,18 @@
16
15
  >
17
16
  <template #icon>
18
17
  <span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
19
- <IconCheveronDown class="h-5 w-5 text-gray-400" />
18
+ <IconCheveronDown class="size-5 text-gray-400" />
20
19
  </span>
21
20
  </template>
22
- </AGHeadlessSelectButton>
21
+ </AGHeadlessSelectTrigger>
23
22
  <AGHeadlessSelectOptions
24
- class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border bg-white py-1 text-base ring-1 ring-black ring-opacity-5 focus:outline-none"
23
+ class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border border-gray-300 bg-white py-1 text-base ring-1 ring-black/5 focus:outline-hidden"
25
24
  >
26
25
  <AGHeadlessSelectOption
27
26
  v-for="(option, index) in $select?.options ?? []"
28
27
  :key="index"
29
28
  :value="option"
30
- class="relative block cursor-default select-none truncate py-2 pl-3 pr-9"
31
- selected-class="font-semibold"
32
- unselected-class="font-normal"
33
- active-class="bg-indigo-600 text-white"
34
- inactive-class="text-gray-900"
29
+ class="relative block cursor-default truncate py-2 pr-9 pl-3 text-gray-900 select-none data-[highlighted]:bg-indigo-600 data-[highlighted]:text-white data-[state=checked]:font-semibold data-[state=unchecked]:font-normal"
35
30
  />
36
31
  </AGHeadlessSelectOptions>
37
32
  </div>
@@ -42,16 +37,15 @@
42
37
  <script setup lang="ts">
43
38
  import IconCheveronDown from '~icons/zondicons/cheveron-down';
44
39
 
45
- import { componentRef } from '@/utils/vue';
46
- import { useSelectEmits, useSelectProps } from '@/components/headless/forms/AGHeadlessSelect';
47
- import type { IAGHeadlessSelect } from '@/components/headless/forms/AGHeadlessSelect';
40
+ import { componentRef } from '@aerogel/core/utils/vue';
41
+ import { useSelectEmits, useSelectProps } from '@aerogel/core/components/headless/forms/AGHeadlessSelect';
42
+ import type { IAGHeadlessSelect } from '@aerogel/core/components/headless/forms/AGHeadlessSelect';
48
43
 
49
44
  import AGHeadlessSelect from '../headless/forms/AGHeadlessSelect.vue';
50
- import AGHeadlessSelectButton from '../headless/forms/AGHeadlessSelectButton.vue';
45
+ import AGHeadlessSelectTrigger from '../headless/forms/AGHeadlessSelectTrigger.vue';
51
46
  import AGHeadlessSelectError from '../headless/forms/AGHeadlessSelectError.vue';
52
- import AGHeadlessSelectLabel from '../headless/forms/AGHeadlessSelectLabel.vue';
53
47
  import AGHeadlessSelectOption from '../headless/forms/AGHeadlessSelectOption.vue';
54
- import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions';
48
+ import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions.vue';
55
49
 
56
50
  defineEmits(useSelectEmits());
57
51
 
@@ -1,5 +1 @@
1
- export { default as AGButton } from './AGButton.vue';
2
- export { default as AGCheckbox } from './AGCheckbox.vue';
3
- export { default as AGForm } from './AGForm.vue';
4
- export { default as AGInput } from './AGInput.vue';
5
1
  export { default as AGSelect } from './AGSelect.vue';
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <Primitive :class="classes" :as-child="asChild" v-bind="props">
3
+ <slot />
4
+ </Primitive>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed } from 'vue';
9
+ import { Primitive } from 'reka-ui';
10
+ import { objectWithoutEmpty } from '@noeldemartin/utils';
11
+
12
+ import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
13
+
14
+ const { as, href, route, routeParams, routeQuery, submit, class: classes } = defineProps<ButtonProps>();
15
+
16
+ const props = computed(() => {
17
+ if (as) {
18
+ return { as };
19
+ }
20
+
21
+ if (route) {
22
+ return {
23
+ as: 'router-link',
24
+ to: objectWithoutEmpty({
25
+ name: route,
26
+ params: routeParams,
27
+ query: routeQuery,
28
+ }),
29
+ };
30
+ }
31
+
32
+ if (href) {
33
+ return {
34
+ as: 'a',
35
+ target: '_blank',
36
+ href,
37
+ };
38
+ }
39
+
40
+ return {
41
+ as: 'button',
42
+ type: submit ? 'submit' : 'button',
43
+ };
44
+ });
45
+ </script>
@@ -0,0 +1,59 @@
1
+ <template>
2
+ <component :is="as">
3
+ <slot />
4
+ </component>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed, inject, provide, readonly } from 'vue';
9
+ import { uuid } from '@noeldemartin/utils';
10
+
11
+ import type FormController from '@aerogel/core/forms/FormController';
12
+ import type { FormFieldValue } from '@aerogel/core/forms/FormController';
13
+ import type { InputEmits, InputExpose, InputProps } from '@aerogel/core/components/contracts/Input';
14
+
15
+ const { as = 'div', name, label, description, modelValue } = defineProps<InputProps & { as?: string }>();
16
+ const emit = defineEmits<InputEmits>();
17
+ const form = inject<FormController | null>('form', null);
18
+ const errors = computed(() => {
19
+ if (!form || !name) {
20
+ return null;
21
+ }
22
+
23
+ return form.errors[name] ?? null;
24
+ });
25
+
26
+ const context = {
27
+ id: `input-${uuid()}`,
28
+ name: computed(() => name),
29
+ label: computed(() => label),
30
+ description: computed(() => description),
31
+ value: computed(() => {
32
+ if (form && name) {
33
+ return form.getFieldValue(name);
34
+ }
35
+
36
+ return modelValue;
37
+ }),
38
+ errors: readonly(errors),
39
+ required: computed(() => {
40
+ if (!name || !form) {
41
+ return;
42
+ }
43
+
44
+ return form.getFieldRules(name).includes('required');
45
+ }),
46
+ update(value) {
47
+ if (form && name) {
48
+ form.setFieldValue(name, value as FormFieldValue);
49
+
50
+ return;
51
+ }
52
+
53
+ emit('update:modelValue', value);
54
+ },
55
+ } satisfies InputExpose;
56
+
57
+ provide('input', context);
58
+ defineExpose(context);
59
+ </script>
@@ -12,16 +12,15 @@
12
12
  <script setup lang="ts">
13
13
  import { computed } from 'vue';
14
14
 
15
- import { injectReactiveOrFail } from '@/utils/vue';
16
-
17
- import AGMarkdown from '../../lib/AGMarkdown.vue';
18
- import type { IAGHeadlessInput } from './AGHeadlessInput';
15
+ import AGMarkdown from '@aerogel/core/components/lib/AGMarkdown.vue';
16
+ import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
17
+ import type { InputExpose } from '@aerogel/core/components/contracts/Input';
19
18
 
20
19
  defineOptions({ inheritAttrs: false });
21
20
 
22
- const input = injectReactiveOrFail<IAGHeadlessInput>(
21
+ const input = injectReactiveOrFail<InputExpose>(
23
22
  'input',
24
- '<AGHeadlessInputDescription> must be a child of a <AGHeadlessInput>',
23
+ '<HeadlessInputDescription> must be a child of a <HeadlessInput>',
25
24
  );
26
25
  const text = computed(() => (typeof input.description === 'string' ? input.description : ''));
27
26
  const show = computed(() => !!input.description);