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

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 (190) hide show
  1. package/dist/aerogel-core.d.ts +2004 -1034
  2. package/dist/aerogel-core.js +3223 -0
  3. package/dist/aerogel-core.js.map +1 -0
  4. package/package.json +27 -37
  5. package/src/bootstrap/bootstrap.test.ts +7 -11
  6. package/src/bootstrap/index.ts +36 -16
  7. package/src/bootstrap/options.ts +4 -1
  8. package/src/components/AppLayout.vue +16 -0
  9. package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
  10. package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +5 -6
  11. package/src/components/AppToasts.vue +16 -0
  12. package/src/components/composition.ts +23 -0
  13. package/src/components/contracts/AlertModal.ts +4 -0
  14. package/src/components/contracts/Button.ts +16 -0
  15. package/src/components/contracts/ConfirmModal.ts +41 -0
  16. package/src/components/contracts/DropdownMenu.ts +11 -0
  17. package/src/components/contracts/ErrorReportModal.ts +29 -0
  18. package/src/components/contracts/Input.ts +26 -0
  19. package/src/components/contracts/LoadingModal.ts +18 -0
  20. package/src/components/contracts/Modal.ts +13 -0
  21. package/src/components/contracts/PromptModal.ts +28 -0
  22. package/src/components/contracts/Select.ts +36 -0
  23. package/src/components/contracts/Toast.ts +13 -0
  24. package/src/components/contracts/index.ts +9 -0
  25. package/src/components/contracts/shared.ts +9 -0
  26. package/src/components/headless/HeadlessButton.vue +50 -0
  27. package/src/components/headless/HeadlessInput.vue +59 -0
  28. package/src/components/headless/HeadlessInputDescription.vue +27 -0
  29. package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
  30. package/src/components/headless/HeadlessInputInput.vue +75 -0
  31. package/src/components/headless/HeadlessInputLabel.vue +18 -0
  32. package/src/components/headless/HeadlessInputTextArea.vue +40 -0
  33. package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +17 -19
  34. package/src/components/headless/HeadlessModalContent.vue +24 -0
  35. package/src/components/headless/HeadlessModalOverlay.vue +12 -0
  36. package/src/components/headless/HeadlessModalTitle.vue +12 -0
  37. package/src/components/headless/HeadlessSelect.vue +105 -0
  38. package/src/components/headless/{forms/AGHeadlessSelectError.vue → HeadlessSelectError.vue} +5 -6
  39. package/src/components/headless/HeadlessSelectLabel.vue +25 -0
  40. package/src/components/headless/HeadlessSelectOption.vue +34 -0
  41. package/src/components/headless/HeadlessSelectOptions.vue +30 -0
  42. package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
  43. package/src/components/headless/HeadlessSelectValue.vue +15 -0
  44. package/src/components/headless/HeadlessToast.vue +18 -0
  45. package/src/components/headless/HeadlessToastAction.vue +13 -0
  46. package/src/components/headless/index.ts +18 -3
  47. package/src/components/index.ts +5 -9
  48. package/src/components/ui/AdvancedOptions.vue +18 -0
  49. package/src/components/ui/AlertModal.vue +13 -0
  50. package/src/components/ui/Button.vue +98 -0
  51. package/src/components/ui/Checkbox.vue +56 -0
  52. package/src/components/ui/ConfirmModal.vue +42 -0
  53. package/src/components/ui/DropdownMenu.vue +33 -0
  54. package/src/components/ui/EditableContent.vue +82 -0
  55. package/src/components/ui/ErrorMessage.vue +15 -0
  56. package/src/components/ui/ErrorReportModal.vue +62 -0
  57. package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +38 -29
  58. package/src/components/ui/ErrorReportModalTitle.vue +24 -0
  59. package/src/components/ui/Form.vue +24 -0
  60. package/src/components/ui/Input.vue +56 -0
  61. package/src/components/ui/Link.vue +12 -0
  62. package/src/components/ui/LoadingModal.vue +32 -0
  63. package/src/components/ui/Markdown.vue +69 -0
  64. package/src/components/ui/Modal.vue +70 -0
  65. package/src/components/ui/ModalContext.vue +30 -0
  66. package/src/components/ui/ProgressBar.vue +50 -0
  67. package/src/components/ui/PromptModal.vue +35 -0
  68. package/src/components/ui/Select.vue +21 -0
  69. package/src/components/ui/SelectLabel.vue +10 -0
  70. package/src/components/ui/SelectOptions.vue +31 -0
  71. package/src/components/ui/SelectTrigger.vue +29 -0
  72. package/src/components/ui/SettingsModal.vue +51 -0
  73. package/src/components/{lib/AGStartupCrash.vue → ui/StartupCrash.vue} +8 -8
  74. package/src/components/ui/Toast.vue +42 -0
  75. package/src/components/ui/index.ts +27 -0
  76. package/src/components/utils.ts +107 -0
  77. package/src/directives/index.ts +13 -5
  78. package/src/directives/measure.ts +40 -0
  79. package/src/errors/Errors.state.ts +1 -1
  80. package/src/errors/Errors.ts +35 -34
  81. package/src/errors/JobCancelledError.ts +3 -0
  82. package/src/errors/index.ts +11 -17
  83. package/src/errors/utils.ts +35 -0
  84. package/src/forms/{Form.test.ts → FormController.test.ts} +33 -4
  85. package/src/forms/{Form.ts → FormController.ts} +86 -25
  86. package/src/forms/composition.ts +4 -4
  87. package/src/forms/index.ts +3 -1
  88. package/src/forms/utils.ts +36 -5
  89. package/src/forms/validation.ts +19 -0
  90. package/src/index.css +41 -0
  91. package/src/{main.ts → index.ts} +3 -0
  92. package/src/jobs/Job.ts +147 -0
  93. package/src/jobs/index.ts +10 -0
  94. package/src/jobs/listeners.ts +3 -0
  95. package/src/jobs/status.ts +4 -0
  96. package/src/lang/DefaultLangProvider.ts +46 -0
  97. package/src/lang/Lang.state.ts +11 -0
  98. package/src/lang/Lang.ts +44 -29
  99. package/src/lang/index.ts +8 -6
  100. package/src/plugins/Plugin.ts +1 -1
  101. package/src/plugins/index.ts +10 -7
  102. package/src/services/App.state.ts +27 -5
  103. package/src/services/App.ts +32 -6
  104. package/src/services/Cache.ts +43 -0
  105. package/src/services/Events.test.ts +39 -0
  106. package/src/services/Events.ts +112 -32
  107. package/src/services/Service.ts +154 -49
  108. package/src/services/Storage.ts +20 -0
  109. package/src/services/index.ts +15 -6
  110. package/src/services/store.ts +8 -5
  111. package/src/services/utils.ts +18 -0
  112. package/src/testing/index.ts +26 -0
  113. package/src/testing/setup.ts +11 -0
  114. package/src/ui/UI.state.ts +19 -7
  115. package/src/ui/UI.ts +252 -63
  116. package/src/ui/index.ts +23 -17
  117. package/src/ui/utils.ts +16 -0
  118. package/src/utils/composition/events.ts +3 -2
  119. package/src/utils/composition/forms.ts +4 -3
  120. package/src/utils/composition/persistent.test.ts +33 -0
  121. package/src/utils/composition/persistent.ts +11 -0
  122. package/src/utils/composition/state.test.ts +47 -0
  123. package/src/utils/composition/state.ts +24 -0
  124. package/src/utils/index.ts +3 -0
  125. package/src/utils/markdown.test.ts +50 -0
  126. package/src/utils/markdown.ts +19 -6
  127. package/src/utils/tailwindcss.test.ts +26 -0
  128. package/src/utils/tailwindcss.ts +7 -0
  129. package/src/utils/vdom.ts +31 -0
  130. package/src/utils/vue.ts +31 -19
  131. package/dist/aerogel-core.cjs.js +0 -2
  132. package/dist/aerogel-core.cjs.js.map +0 -1
  133. package/dist/aerogel-core.esm.js +0 -2
  134. package/dist/aerogel-core.esm.js.map +0 -1
  135. package/histoire.config.ts +0 -7
  136. package/noeldemartin.config.js +0 -5
  137. package/postcss.config.js +0 -6
  138. package/src/assets/histoire.css +0 -3
  139. package/src/components/AGAppLayout.vue +0 -15
  140. package/src/components/AGAppSnackbars.vue +0 -13
  141. package/src/components/constants.ts +0 -8
  142. package/src/components/forms/AGButton.vue +0 -44
  143. package/src/components/forms/AGCheckbox.vue +0 -35
  144. package/src/components/forms/AGForm.vue +0 -26
  145. package/src/components/forms/AGInput.vue +0 -36
  146. package/src/components/forms/AGSelect.story.vue +0 -28
  147. package/src/components/forms/AGSelect.vue +0 -53
  148. package/src/components/forms/index.ts +0 -5
  149. package/src/components/headless/forms/AGHeadlessButton.vue +0 -51
  150. package/src/components/headless/forms/AGHeadlessInput.ts +0 -8
  151. package/src/components/headless/forms/AGHeadlessInput.vue +0 -54
  152. package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -45
  153. package/src/components/headless/forms/AGHeadlessInputLabel.vue +0 -16
  154. package/src/components/headless/forms/AGHeadlessSelect.ts +0 -43
  155. package/src/components/headless/forms/AGHeadlessSelect.vue +0 -77
  156. package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
  157. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -21
  158. package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
  159. package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -39
  160. package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
  161. package/src/components/headless/forms/index.ts +0 -14
  162. package/src/components/headless/modals/AGHeadlessModal.ts +0 -7
  163. package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
  164. package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
  165. package/src/components/headless/modals/index.ts +0 -6
  166. package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
  167. package/src/components/headless/snackbars/index.ts +0 -25
  168. package/src/components/lib/AGErrorMessage.vue +0 -16
  169. package/src/components/lib/AGLink.vue +0 -9
  170. package/src/components/lib/AGMarkdown.vue +0 -36
  171. package/src/components/lib/index.ts +0 -4
  172. package/src/components/modals/AGAlertModal.vue +0 -25
  173. package/src/components/modals/AGConfirmModal.vue +0 -30
  174. package/src/components/modals/AGErrorReportModal.ts +0 -20
  175. package/src/components/modals/AGErrorReportModal.vue +0 -62
  176. package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
  177. package/src/components/modals/AGLoadingModal.vue +0 -19
  178. package/src/components/modals/AGModal.ts +0 -10
  179. package/src/components/modals/AGModal.vue +0 -37
  180. package/src/components/modals/AGModalContext.ts +0 -8
  181. package/src/components/modals/AGModalContext.vue +0 -22
  182. package/src/components/modals/AGModalTitle.vue +0 -9
  183. package/src/components/modals/index.ts +0 -23
  184. package/src/components/snackbars/AGSnackbar.vue +0 -42
  185. package/src/components/snackbars/index.ts +0 -3
  186. package/src/directives/initial-focus.ts +0 -11
  187. package/src/main.histoire.ts +0 -1
  188. package/tailwind.config.js +0 -4
  189. package/tsconfig.json +0 -11
  190. package/vite.config.ts +0 -14
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.a56c0f4966eb71571173f8502f3f36d357ceebc7",
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.aa6e27a9c197d1ee10c9fe018ee8c0fc6ff77767",
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:dev": "histoire dev",
14
- "histoire:prod": "histoire build",
19
+ "build": "vite build && ./scripts/fix-types.sh",
15
20
  "lint": "noeldemartin-lint src",
16
- "publish-next": "noeldemartin-publish-next",
17
21
  "test": "vitest --run",
18
- "test:ci": "vitest --run --reporter verbose"
19
- },
20
- "engines": {
21
- "node": ">=18.x"
22
+ "test:ci": "vitest --run --reporter verbose",
23
+ "verify": "noeldemartin-verify"
22
24
  },
23
- "repository": {
24
- "type": "git",
25
- "url": "https://github.com/NoelDeMartin/aerogeljs.git"
26
- },
27
- "keywords": [
28
- "javascript",
29
- "framework",
30
- "solid"
31
- ],
32
- "author": "Noel De Martin",
33
- "license": "MIT",
34
- "bugs": {
35
- "url": "https://github.com/NoelDeMartin/aerogeljs/issues"
25
+ "peerDependencies": {
26
+ "vue": "^3.5.0"
36
27
  },
37
28
  "dependencies": {
38
- "@headlessui/vue": "^1.7.14",
39
- "@noeldemartin/utils": "0.5.0-next.dce7f1ca99862fde01601bb39d71d0eaaed3abe5",
40
- "dompurify": "^3.0.3",
41
- "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",
42
34
  "pinia": "^2.1.6",
43
- "vue": "^3.3.0"
35
+ "reka-ui": "^2.2.0",
36
+ "tailwind-merge": "^3.1.0"
44
37
  },
45
38
  "devDependencies": {
46
- "@aerogel/vite": "*",
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,17 +1,16 @@
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
- import { bootstrapApplication } from './index';
9
+ import { bootstrap } from './index';
10
10
 
11
11
  describe('Aerogel', () => {
12
12
 
13
13
  beforeEach(() => {
14
- vi.stubGlobal('document', { getElementById: () => null });
15
14
  vi.mock('vue', async () => {
16
15
  const vue = (await vi.importActual('vue')) as Object;
17
16
 
@@ -32,7 +31,7 @@ describe('Aerogel', () => {
32
31
  const rootComponent = mock<Component>();
33
32
 
34
33
  // Act
35
- await bootstrapApplication(rootComponent);
34
+ await bootstrap(rootComponent);
36
35
 
37
36
  // Assert
38
37
  const globals = vi.mocked(createApp).mock.results[0]?.value.config.globalProperties;
@@ -46,13 +45,10 @@ describe('Aerogel', () => {
46
45
  const rootComponent = mock<Component>();
47
46
 
48
47
  // Act
49
- await bootstrapApplication(rootComponent);
48
+ await bootstrap(rootComponent);
50
49
 
51
50
  // Assert
52
- expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith(
53
- 'initial-focus',
54
- initialFocus,
55
- );
51
+ expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith('measure', measure);
56
52
  });
57
53
 
58
54
  });
@@ -1,29 +1,49 @@
1
1
  import { createApp } from 'vue';
2
- import type { 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 ui from '@/ui';
10
- import { installPlugins } from '@/plugins';
11
- import type { AerogelOptions } from '@/bootstrap/options';
12
-
13
- export async function bootstrapApplication(rootComponent: Component, options: AerogelOptions = {}): Promise<void> {
14
- const plugins = [directives, errors, lang, services, ui, ...(options.plugins ?? [])];
15
- const app = createApp(rootComponent);
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> {
19
+ const plugins = [testing, directives, errors, lang, services, ui, ...(options.plugins ?? [])];
20
+
21
+ App.instance = app;
16
22
 
17
23
  await installPlugins(plugins, app, options);
24
+ await options.install?.(app);
25
+ await Events.emit('application-ready');
26
+ }
27
+
28
+ export async function bootstrap(rootComponent: Component, options: AerogelOptions = {}): Promise<void> {
29
+ const app = createApp(rootComponent);
30
+
31
+ if (isDevelopment()) {
32
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
33
+ (window as any).$aerogel = app;
34
+ }
35
+
36
+ await bootstrapApplication(app, options);
18
37
 
19
38
  app.mount('#app');
20
39
  app._container?.classList.remove('loading');
21
40
 
22
- Events.emit('application-mounted');
41
+ await Events.emit('application-mounted');
23
42
  }
24
43
 
25
- declare module '@/services/Events' {
44
+ declare module '@aerogel/core/services/Events' {
26
45
  export interface EventsPayload {
46
+ 'application-ready': void;
27
47
  'application-mounted': void;
28
48
  }
29
49
  }
@@ -1,5 +1,8 @@
1
- import type { Plugin } from '@/plugins';
1
+ import type { App } from 'vue';
2
+
3
+ import type { Plugin } from '@aerogel/core/plugins';
2
4
 
3
5
  export interface AerogelOptions {
4
6
  plugins?: Plugin[];
7
+ install?(app: App): void | Promise<void>;
5
8
  }
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <div class="flex min-h-full flex-col text-base leading-tight font-normal text-gray-900 antialiased">
3
+ <slot v-if="$errors.hasStartupErrors" name="startup-crash">
4
+ <component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
5
+ </slot>
6
+ <slot v-else />
7
+
8
+ <AppOverlays />
9
+ </div>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { UIComponents } from '@aerogel/core/ui/UI';
14
+
15
+ import AppOverlays from './AppOverlays.vue';
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 />
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>
@@ -1,16 +1,15 @@
1
1
  <template>
2
- <div ref="$backdrop" class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0" />
3
- <AGAppModals />
4
- <AGAppSnackbars />
2
+ <AppModals />
3
+ <AppToasts />
5
4
  </template>
6
5
 
7
6
  <script setup lang="ts">
8
7
  import { ref } from 'vue';
9
8
 
10
- import { useEvent } from '@/utils/composition/events';
9
+ import { useEvent } from '@aerogel/core/utils/composition/events';
11
10
 
12
- import AGAppModals from './AGAppModals.vue';
13
- import AGAppSnackbars from './AGAppSnackbars.vue';
11
+ import AppModals from './AppModals.vue';
12
+ import AppToasts from './AppToasts.vue';
14
13
 
15
14
  const $backdrop = ref<HTMLElement | null>(null);
16
15
  const backdropHidden = ref(true);
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <ToastProvider>
3
+ <component
4
+ :is="toast.component"
5
+ v-for="toast of $ui.toasts"
6
+ :id="toast.id"
7
+ :key="toast.id"
8
+ v-bind="toast.properties"
9
+ />
10
+ <ToastViewport class="fixed right-0 bottom-0 z-50 flex flex-col items-end space-y-4 px-4 py-6 sm:p-6" />
11
+ </ToastProvider>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { ToastProvider, ToastViewport } from 'reka-ui';
16
+ </script>
@@ -0,0 +1,23 @@
1
+ import { customRef } from 'vue';
2
+ import type { Ref } from 'vue';
3
+
4
+ import { getElement } from '@aerogel/core/components/utils';
5
+
6
+ export function elementRef(): Ref<HTMLElement | undefined> {
7
+ return customRef((track, trigger) => {
8
+ let value: HTMLElement | undefined = undefined;
9
+
10
+ return {
11
+ get() {
12
+ track();
13
+
14
+ return value;
15
+ },
16
+ set(newValue) {
17
+ value = getElement(newValue);
18
+
19
+ trigger();
20
+ },
21
+ };
22
+ });
23
+ }
@@ -0,0 +1,4 @@
1
+ export interface AlertModalProps {
2
+ title?: string;
3
+ message: string;
4
+ }
@@ -0,0 +1,16 @@
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
+ disabled?: boolean;
9
+ href?: string;
10
+ route?: string;
11
+ routeParams?: object;
12
+ routeQuery?: object;
13
+ size?: ButtonSize;
14
+ submit?: boolean;
15
+ variant?: ButtonVariant;
16
+ }
@@ -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,11 @@
1
+ import type { DropdownMenuContentProps } from 'reka-ui';
2
+
3
+ export type DropdownMenuOption = {
4
+ label: string;
5
+ click: () => unknown;
6
+ };
7
+
8
+ export interface DropdownMenuProps {
9
+ align?: DropdownMenuContentProps['align'];
10
+ options?: DropdownMenuOption[];
11
+ }
@@ -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 { ComputedRef, DeepReadonly, Ref } from 'vue';
2
+ import type { Nullable } from '@noeldemartin/utils';
3
+
4
+ import type { FormFieldValue } from '@aerogel/core/forms';
5
+
6
+ export interface InputProps {
7
+ name?: string;
8
+ label?: string;
9
+ description?: string;
10
+ modelValue?: Nullable<FormFieldValue>;
11
+ }
12
+
13
+ export interface InputEmits {
14
+ 'update:modelValue': [value: Nullable<FormFieldValue>];
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,13 @@
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
+ }
10
+
11
+ export interface ModalExpose {
12
+ close(result?: unknown): Promise<void>;
13
+ }
@@ -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,36 @@
1
+ import type { AcceptableValue, AsTag } from 'reka-ui';
2
+ import type { Component, ComputedRef } from 'vue';
3
+ import type { Nullable } from '@noeldemartin/utils';
4
+
5
+ import type { InputEmits, InputExpose, InputProps } from './Input';
6
+
7
+ export type SelectOption = {
8
+ key: string;
9
+ label: string;
10
+ value: AcceptableValue;
11
+ };
12
+
13
+ export interface HasSelectOptionLabel {
14
+ label: string | (() => string);
15
+ }
16
+
17
+ export interface SelectProps extends InputProps {
18
+ as?: AsTag | Component;
19
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
20
+ options?: any[];
21
+ placeholder?: string;
22
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
23
+ renderOption?: (option: any) => string;
24
+ }
25
+
26
+ export interface SelectEmits extends InputEmits {}
27
+
28
+ export interface SelectExpose extends InputExpose {
29
+ options: ComputedRef<Nullable<SelectOption[]>>;
30
+ selectedOption: ComputedRef<Nullable<SelectOption>>;
31
+ placeholder: ComputedRef<string>;
32
+ }
33
+
34
+ export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
35
+ return typeof option === 'object' && option !== null && 'label' in option;
36
+ }
@@ -0,0 +1,13 @@
1
+ export interface ToastAction {
2
+ label: string;
3
+ dismiss?: boolean;
4
+ click?(): unknown;
5
+ }
6
+
7
+ export type ToastVariant = 'secondary' | 'danger';
8
+
9
+ export interface ToastProps {
10
+ message?: string;
11
+ actions?: ToastAction[];
12
+ variant?: ToastVariant;
13
+ }
@@ -0,0 +1,9 @@
1
+ export * from './AlertModal';
2
+ export * from './Button';
3
+ export * from './ConfirmModal';
4
+ export * from './DropdownMenu';
5
+ export * from './LoadingModal';
6
+ export * from './Modal';
7
+ export * from './PromptModal';
8
+ export * from './Select';
9
+ 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
+ }
@@ -0,0 +1,50 @@
1
+ <template>
2
+ <Primitive
3
+ :class="classes"
4
+ :as-child
5
+ :disabled
6
+ v-bind="props"
7
+ >
8
+ <slot />
9
+ </Primitive>
10
+ </template>
11
+
12
+ <script setup lang="ts">
13
+ import { computed } from 'vue';
14
+ import { Primitive } from 'reka-ui';
15
+ import { objectWithoutEmpty } from '@noeldemartin/utils';
16
+
17
+ import type { ButtonProps } from '@aerogel/core/components/contracts/Button';
18
+
19
+ const { as, href, route, routeParams, routeQuery, submit, disabled, class: classes } = defineProps<ButtonProps>();
20
+
21
+ const props = computed(() => {
22
+ if (as) {
23
+ return { as };
24
+ }
25
+
26
+ if (route) {
27
+ return {
28
+ as: 'router-link',
29
+ to: objectWithoutEmpty({
30
+ name: route,
31
+ params: routeParams,
32
+ query: routeQuery,
33
+ }),
34
+ };
35
+ }
36
+
37
+ if (href) {
38
+ return {
39
+ as: 'a',
40
+ target: '_blank',
41
+ href,
42
+ };
43
+ }
44
+
45
+ return {
46
+ as: 'button',
47
+ type: submit ? 'submit' : 'button',
48
+ };
49
+ });
50
+ </script>