@aerogel/core 0.0.0-next.7f6ed5a1f91688a86bf5ede2adc465e4fd6cfdea → 0.0.0-next.b58141fee5d2fe7d25debdbca6b1d2bf1c13e48e

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 (85) hide show
  1. package/dist/aerogel-core.cjs.js +1 -1
  2. package/dist/aerogel-core.cjs.js.map +1 -1
  3. package/dist/aerogel-core.d.ts +711 -79
  4. package/dist/aerogel-core.esm.js +1 -1
  5. package/dist/aerogel-core.esm.js.map +1 -1
  6. package/dist/virtual.d.ts +11 -0
  7. package/noeldemartin.config.js +4 -1
  8. package/package.json +7 -9
  9. package/src/bootstrap/bootstrap.test.ts +0 -56
  10. package/src/bootstrap/index.ts +9 -25
  11. package/src/bootstrap/options.ts +5 -1
  12. package/src/components/AGAppModals.vue +15 -0
  13. package/src/components/AGAppOverlays.vue +5 -7
  14. package/src/components/AGAppSnackbars.vue +13 -0
  15. package/src/components/basic/AGErrorMessage.vue +16 -0
  16. package/src/components/basic/AGLink.vue +9 -0
  17. package/src/components/basic/AGMarkdown.vue +21 -5
  18. package/src/components/basic/index.ts +3 -1
  19. package/src/components/constants.ts +8 -0
  20. package/src/components/forms/AGButton.vue +36 -3
  21. package/src/components/forms/AGCheckbox.vue +35 -0
  22. package/src/components/forms/AGInput.vue +8 -4
  23. package/src/components/forms/index.ts +2 -1
  24. package/src/components/headless/forms/AGHeadlessButton.vue +7 -7
  25. package/src/components/headless/forms/AGHeadlessInput.ts +2 -2
  26. package/src/components/headless/forms/AGHeadlessInput.vue +5 -5
  27. package/src/components/headless/forms/AGHeadlessInputError.vue +9 -5
  28. package/src/components/headless/forms/AGHeadlessInputInput.vue +20 -4
  29. package/src/components/headless/forms/AGHeadlessInputLabel.vue +16 -0
  30. package/src/components/headless/forms/index.ts +6 -4
  31. package/src/components/headless/index.ts +1 -0
  32. package/src/components/headless/modals/AGHeadlessModal.vue +5 -1
  33. package/src/components/headless/modals/AGHeadlessModalPanel.vue +10 -2
  34. package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
  35. package/src/components/headless/snackbars/index.ts +25 -0
  36. package/src/components/index.ts +4 -1
  37. package/src/components/modals/AGAlertModal.vue +12 -2
  38. package/src/components/modals/AGConfirmModal.vue +30 -0
  39. package/src/components/modals/AGErrorReportModal.ts +20 -0
  40. package/src/components/modals/AGErrorReportModal.vue +62 -0
  41. package/src/components/modals/AGErrorReportModalButtons.vue +109 -0
  42. package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
  43. package/src/components/modals/AGLoadingModal.vue +19 -0
  44. package/src/components/modals/AGModal.ts +4 -0
  45. package/src/components/modals/AGModal.vue +23 -4
  46. package/src/components/modals/AGModalTitle.vue +9 -0
  47. package/src/components/modals/index.ts +20 -2
  48. package/src/components/snackbars/AGSnackbar.vue +42 -0
  49. package/src/components/snackbars/index.ts +3 -0
  50. package/src/directives/index.ts +19 -4
  51. package/src/errors/Errors.state.ts +31 -0
  52. package/src/errors/Errors.ts +183 -0
  53. package/src/errors/index.ts +59 -0
  54. package/src/forms/Form.test.ts +21 -0
  55. package/src/forms/Form.ts +38 -16
  56. package/src/forms/utils.ts +17 -0
  57. package/src/lang/Lang.ts +47 -8
  58. package/src/lang/index.ts +17 -76
  59. package/src/lang/utils.ts +4 -0
  60. package/src/main.ts +2 -0
  61. package/src/plugins/Plugin.ts +7 -0
  62. package/src/plugins/index.ts +7 -0
  63. package/src/services/App.state.ts +16 -0
  64. package/src/services/App.ts +15 -0
  65. package/src/services/Service.ts +157 -29
  66. package/src/services/index.ts +32 -7
  67. package/src/services/store.ts +27 -0
  68. package/src/types/virtual.d.ts +11 -0
  69. package/src/types/vite.d.ts +0 -2
  70. package/src/ui/UI.state.ts +12 -6
  71. package/src/ui/UI.ts +72 -10
  72. package/src/ui/index.ts +24 -14
  73. package/src/utils/composition/forms.ts +11 -0
  74. package/src/utils/composition/hooks.ts +9 -0
  75. package/src/utils/index.ts +3 -0
  76. package/src/utils/markdown.ts +11 -2
  77. package/src/utils/vue.ts +2 -0
  78. package/tsconfig.json +2 -10
  79. package/vite.config.ts +3 -6
  80. package/src/bootstrap/hooks.ts +0 -19
  81. package/src/lang/helpers.ts +0 -5
  82. package/src/models/index.ts +0 -18
  83. package/src/routing/index.ts +0 -33
  84. package/src/testing/stubs/lang/en.yaml +0 -1
  85. package/src/testing/stubs/models/User.ts +0 -3
@@ -1 +1,5 @@
1
- export interface BootstrapOptions {}
1
+ import type { Plugin } from '@/plugins';
2
+
3
+ export interface AerogelOptions {
4
+ plugins?: Plugin[];
5
+ }
@@ -0,0 +1,15 @@
1
+ <template>
2
+ <aside v-if="modal">
3
+ <AGModalContext :child-index="1" :modal="modal" />
4
+ </aside>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed } from 'vue';
9
+
10
+ import UI from '@/ui/UI';
11
+
12
+ import AGModalContext from './modals/AGModalContext.vue';
13
+
14
+ const modal = computed(() => UI.modals[0] ?? null);
15
+ </script>
@@ -1,21 +1,19 @@
1
1
  <template>
2
2
  <div ref="$backdrop" class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0" />
3
- <aside v-if="modal">
4
- <AGModalContext :child-index="1" :modal="modal" />
5
- </aside>
3
+ <AGAppModals />
4
+ <AGAppSnackbars />
6
5
  </template>
7
6
 
8
7
  <script setup lang="ts">
9
- import { computed, ref } from 'vue';
8
+ import { ref } from 'vue';
10
9
 
11
- import UI from '@/ui/UI';
12
10
  import { useEvent } from '@/utils/composition/events';
13
11
 
14
- import AGModalContext from './modals/AGModalContext.vue';
12
+ import AGAppModals from './AGAppModals.vue';
13
+ import AGAppSnackbars from './AGAppSnackbars.vue';
15
14
 
16
15
  const $backdrop = ref<HTMLElement | null>(null);
17
16
  const backdropHidden = ref(true);
18
- const modal = computed(() => UI.modals[0] ?? null);
19
17
 
20
18
  useEvent('show-overlays-backdrop', async () => {
21
19
  if (!$backdrop.value || !backdropHidden.value) {
@@ -0,0 +1,13 @@
1
+ <template>
2
+ <div aria-live="assertive" class="z-60 pointer-events-none fixed inset-0 flex items-end px-4 py-6 sm:p-6">
3
+ <div class="flex w-full flex-col items-center space-y-4 sm:items-end">
4
+ <component
5
+ :is="snackbar.component"
6
+ v-for="snackbar of $ui.snackbars"
7
+ :id="snackbar.id"
8
+ :key="snackbar.id"
9
+ v-bind="snackbar.properties"
10
+ />
11
+ </div>
12
+ </div>
13
+ </template>
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <AGMarkdown :text="message" inline />
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import { computed } from 'vue';
7
+
8
+ import Errors from '@/errors/Errors';
9
+ import { requiredObjectProp } from '@/utils/vue';
10
+ import type { ErrorSource } from '@/errors/Errors.state';
11
+
12
+ import AGMarkdown from './AGMarkdown.vue';
13
+
14
+ const props = defineProps({ error: requiredObjectProp<ErrorSource>() });
15
+ const message = computed(() => Errors.getErrorMessage(props.error));
16
+ </script>
@@ -0,0 +1,9 @@
1
+ <template>
2
+ <AGHeadlessButton class="font-medium hover:underline">
3
+ <slot />
4
+ </AGHeadlessButton>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import AGHeadlessButton from '../headless/forms/AGHeadlessButton.vue';
9
+ </script>
@@ -6,15 +6,31 @@
6
6
  import { computed, h } from 'vue';
7
7
 
8
8
  import { renderMarkdown } from '@/utils/markdown';
9
- import { stringProp } from '@/utils/vue';
10
- import { lang } from '@/lang/helpers';
9
+ import { booleanProp, objectProp, stringProp } from '@/utils/vue';
10
+ import { translate } from '@/lang';
11
11
 
12
12
  const props = defineProps({
13
+ as: stringProp(),
14
+ inline: booleanProp(),
13
15
  langKey: stringProp(),
16
+ langParams: objectProp<Record<string, unknown>>(),
14
17
  text: stringProp(),
15
18
  });
16
19
 
17
- const markdown = computed(() => props.text ?? (props.langKey && lang(props.langKey)));
18
- const html = computed(() => markdown.value && renderMarkdown(markdown.value));
19
- const root = () => h('div', { class: 'prose', innerHTML: html.value });
20
+ const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
21
+ const html = computed(() => {
22
+ if (!markdown.value) {
23
+ return null;
24
+ }
25
+
26
+ let renderedHtml = renderMarkdown(markdown.value);
27
+
28
+ if (props.inline) {
29
+ renderedHtml = renderedHtml.replace('<p>', '<span>').replace('</p>', '</span>');
30
+ }
31
+
32
+ return renderedHtml;
33
+ });
34
+ const root = () =>
35
+ h(props.as ?? (props.inline ? 'span' : 'div'), { class: props.inline ? '' : 'prose', innerHTML: html.value });
20
36
  </script>
@@ -1,3 +1,5 @@
1
+ import AGErrorMessage from './AGErrorMessage.vue';
2
+ import AGLink from './AGLink.vue';
1
3
  import AGMarkdown from './AGMarkdown.vue';
2
4
 
3
- export { AGMarkdown };
5
+ export { AGErrorMessage, AGLink, AGMarkdown };
@@ -0,0 +1,8 @@
1
+ export const Colors = {
2
+ Primary: 'primary',
3
+ Secondary: 'secondary',
4
+ Danger: 'danger',
5
+ Clear: 'clear',
6
+ } as const;
7
+
8
+ export type Color = (typeof Colors)[keyof typeof Colors];
@@ -1,11 +1,44 @@
1
1
  <template>
2
- <AGHeadlessButton
3
- class="bg-indigo-600 px-2.5 py-1.5 text-white hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600"
4
- >
2
+ <AGHeadlessButton class="px-2.5 py-1.5 focus-visible:outline focus-visible:outline-2" :class="colorClasses">
5
3
  <slot />
6
4
  </AGHeadlessButton>
7
5
  </template>
8
6
 
9
7
  <script setup lang="ts">
8
+ import { computed } from 'vue';
9
+
10
+ import { enumProp } from '@/utils/vue';
11
+ import { Colors } from '@/components/constants';
12
+
10
13
  import AGHeadlessButton from '../headless/forms/AGHeadlessButton.vue';
14
+
15
+ const props = defineProps({
16
+ color: enumProp(Colors, Colors.Primary),
17
+ });
18
+
19
+ const colorClasses = computed(() => {
20
+ switch (props.color) {
21
+ case Colors.Secondary:
22
+ return [
23
+ 'text-white bg-gray-600',
24
+ 'hover:bg-gray-500',
25
+ 'focus-visible:outline-offset-2 focus-visible:outline-gray-600',
26
+ ].join(' ');
27
+ case Colors.Clear:
28
+ return 'hover:bg-gray-500/20 focus-visible:outline-gray-500/60';
29
+ case Colors.Danger:
30
+ return [
31
+ 'text-white bg-red-600',
32
+ 'hover:bg-red-500',
33
+ 'focus-visible:outline-offset-2 focus-visible:outline-red-600',
34
+ ].join(' ');
35
+ case Colors.Primary:
36
+ default:
37
+ return [
38
+ 'text-white bg-indigo-600',
39
+ 'hover:bg-indigo-500',
40
+ 'focus-visible:outline-offset-2 focus-visible:outline-indigo-600',
41
+ ].join(' ');
42
+ }
43
+ });
11
44
  </script>
@@ -0,0 +1,35 @@
1
+ <template>
2
+ <AGHeadlessInput ref="$input" :name="name" class="flex">
3
+ <AGHeadlessInputInput
4
+ v-bind="$attrs"
5
+ type="checkbox"
6
+ :class="{
7
+ 'text-indigo-600 focus:ring-indigo-600': !$input?.errors,
8
+ 'border-red-200 text-red-600 focus:ring-red-600': $input?.errors,
9
+ }"
10
+ />
11
+
12
+ <div class="ml-2">
13
+ <AGHeadlessInputLabel v-if="$slots.default">
14
+ <slot />
15
+ </AGHeadlessInputLabel>
16
+ <AGHeadlessInputError class="text-sm text-red-600" />
17
+ </div>
18
+ </AGHeadlessInput>
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ import { componentRef, stringProp } from '@/utils/vue';
23
+
24
+ import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
25
+
26
+ import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
27
+ import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
28
+ import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
29
+ import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
30
+
31
+ defineProps({ name: stringProp() });
32
+ defineOptions({ inheritAttrs: false });
33
+
34
+ const $input = componentRef<IAGHeadlessInput>();
35
+ </script>
@@ -1,24 +1,27 @@
1
1
  <template>
2
2
  <AGHeadlessInput
3
3
  ref="$input"
4
- as="div"
5
- class="flex flex-col items-center"
4
+ class="relative flex flex-col items-center"
5
+ :class="className"
6
6
  :name="name"
7
7
  >
8
8
  <AGHeadlessInputInput
9
- v-bind="$attrs"
9
+ v-bind="attrs"
10
10
  class="block w-full border-0 py-1.5 text-gray-900 ring-1 ring-inset ring-gray-300 placeholder:text-gray-400 focus:ring-2 focus:ring-inset focus:ring-indigo-600"
11
11
  :class="{
12
12
  'ring-1 ring-red-500': $input?.errors,
13
13
  }"
14
14
  />
15
- <AGHeadlessInputError class="mt-1 text-sm text-red-500" />
15
+ <div class="absolute bottom-0 left-0 translate-y-full">
16
+ <AGHeadlessInputError class="mt-1 text-sm text-red-500" />
17
+ </div>
16
18
  </AGHeadlessInput>
17
19
  </template>
18
20
 
19
21
  <script setup lang="ts">
20
22
  import { componentRef, stringProp } from '@/utils/vue';
21
23
 
24
+ import { useInputAttrs } from '@/utils';
22
25
  import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
23
26
 
24
27
  import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
@@ -29,4 +32,5 @@ defineProps({ name: stringProp() });
29
32
  defineOptions({ inheritAttrs: false });
30
33
 
31
34
  const $input = componentRef<IAGHeadlessInput>();
35
+ const [attrs, className] = useInputAttrs();
32
36
  </script>
@@ -1,5 +1,6 @@
1
1
  import AGButton from './AGButton.vue';
2
+ import AGCheckbox from './AGCheckbox.vue';
2
3
  import AGForm from './AGForm.vue';
3
4
  import AGInput from './AGInput.vue';
4
5
 
5
- export { AGButton, AGForm, AGInput };
6
+ export { AGButton, AGCheckbox, AGForm, AGInput };
@@ -7,15 +7,15 @@
7
7
  <script setup lang="ts">
8
8
  import { computed } from 'vue';
9
9
  import { objectWithoutEmpty } from '@noeldemartin/utils';
10
- import type { LocationQuery, RouteLocation, RouteParams } from 'vue-router';
11
10
 
12
11
  import { booleanProp, objectProp, stringProp } from '@/utils/vue';
13
12
 
14
- const { url, route, routeParams, routeQuery, submit } = defineProps({
13
+ const { href, url, route, routeParams, routeQuery, submit } = defineProps({
14
+ href: stringProp(),
15
15
  url: stringProp(),
16
16
  route: stringProp(),
17
- routeParams: objectProp<RouteParams>(() => ({})),
18
- routeQuery: objectProp<LocationQuery>(() => ({})),
17
+ routeParams: objectProp(() => ({})),
18
+ routeQuery: objectProp(() => ({})),
19
19
  submit: booleanProp(),
20
20
  });
21
21
 
@@ -24,7 +24,7 @@ const component = computed(() => {
24
24
  return {
25
25
  tag: 'router-link',
26
26
  props: {
27
- to: objectWithoutEmpty<Partial<RouteLocation>>({
27
+ to: objectWithoutEmpty({
28
28
  name: route,
29
29
  params: routeParams,
30
30
  query: routeQuery,
@@ -33,12 +33,12 @@ const component = computed(() => {
33
33
  };
34
34
  }
35
35
 
36
- if (url) {
36
+ if (href || url) {
37
37
  return {
38
38
  tag: 'a',
39
39
  props: {
40
40
  target: '_blank',
41
- href: url,
41
+ href: href || url,
42
42
  },
43
43
  };
44
44
  }
@@ -2,7 +2,7 @@ import type { ComputedRef, DeepReadonly, Ref } from 'vue';
2
2
 
3
3
  export interface IAGHeadlessInput {
4
4
  id: string;
5
- value: ComputedRef<string | number | null>;
5
+ value: ComputedRef<string | number | boolean | null>;
6
6
  errors: DeepReadonly<Ref<string[] | null>>;
7
- update(value: string | number | null): void;
7
+ update(value: string | number | boolean | null): void;
8
8
  }
@@ -9,16 +9,16 @@
9
9
  import { computed, inject, provide, readonly } from 'vue';
10
10
  import { uuid } from '@noeldemartin/utils';
11
11
 
12
- import { stringProp } from '@/utils/vue';
12
+ import { mixedProp, stringProp } from '@/utils/vue';
13
13
  import type Form from '@/forms/Form';
14
14
 
15
15
  import type { IAGHeadlessInput } from './AGHeadlessInput';
16
16
 
17
17
  const emit = defineEmits(['update:modelValue']);
18
18
  const props = defineProps({
19
- as: stringProp(),
19
+ as: stringProp('div'),
20
20
  name: stringProp(),
21
- modelValue: stringProp(),
21
+ modelValue: mixedProp<string | number | boolean>([String, Number, Boolean]),
22
22
  });
23
23
  const errors = computed(() => {
24
24
  if (!form || !props.name) {
@@ -27,9 +27,9 @@ const errors = computed(() => {
27
27
 
28
28
  return form.errors[props.name] ?? null;
29
29
  });
30
- const form = inject<Form>('form');
30
+ const form = inject<Form | null>('form', null);
31
31
  const publicApi: IAGHeadlessInput = {
32
- id: uuid(),
32
+ id: `input-${uuid()}`,
33
33
  value: computed(() => {
34
34
  if (form && props.name) {
35
35
  return form.getFieldValue(props.name);
@@ -5,18 +5,22 @@
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
- import { injectReactiveOrFail } from '@/utils';
8
+ import { computed } from 'vue';
9
+
10
+ import { injectReactiveOrFail } from '@/utils/vue';
11
+ import { translateWithDefault } from '@/lang/utils';
9
12
 
10
13
  import type { IAGHeadlessInput } from './AGHeadlessInput';
11
- import { computed } from 'vue';
12
- import { lang } from '@/lang';
13
14
 
14
- const input = injectReactiveOrFail<IAGHeadlessInput>('input');
15
+ const input = injectReactiveOrFail<IAGHeadlessInput>(
16
+ 'input',
17
+ '<AGHeadlessInputError> must be a child of a <AGHeadlessInput>',
18
+ );
15
19
  const errorMessage = computed(() => {
16
20
  if (!input.errors) {
17
21
  return null;
18
22
  }
19
23
 
20
- return lang(`errors.${input.errors[0]}`);
24
+ return translateWithDefault(`errors.${input.errors[0]}`, `Error: ${input.errors[0]}`);
21
25
  });
22
26
  </script>
@@ -1,10 +1,12 @@
1
1
  <template>
2
2
  <input
3
+ :id="input.id"
3
4
  ref="$input"
4
- type="text"
5
+ :type="type"
5
6
  :value="value"
6
7
  :aria-invalid="input.errors ? 'true' : 'false'"
7
8
  :aria-describedby="input.errors ? `${input.id}-error` : undefined"
9
+ :checked="checked"
8
10
  @input="update"
9
11
  >
10
12
  </template>
@@ -12,18 +14,32 @@
12
14
  <script setup lang="ts">
13
15
  import { computed, ref } from 'vue';
14
16
 
15
- import { injectReactiveOrFail } from '@/utils';
17
+ import { injectReactiveOrFail, stringProp } from '@/utils';
16
18
  import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
17
19
 
20
+ const props = defineProps({
21
+ type: stringProp('text'),
22
+ });
23
+
18
24
  const $input = ref<HTMLInputElement>();
19
- const input = injectReactiveOrFail<IAGHeadlessInput>('input');
25
+ const input = injectReactiveOrFail<IAGHeadlessInput>(
26
+ 'input',
27
+ '<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>',
28
+ );
20
29
  const value = computed(() => input.value);
30
+ const checked = computed(() => {
31
+ if (props.type !== 'checkbox') {
32
+ return;
33
+ }
34
+
35
+ return !!value.value;
36
+ });
21
37
 
22
38
  function update() {
23
39
  if (!$input.value) {
24
40
  return;
25
41
  }
26
42
 
27
- input.update($input.value.value);
43
+ input.update(props.type === 'checkbox' ? $input.value.checked : $input.value.value);
28
44
  }
29
45
  </script>
@@ -0,0 +1,16 @@
1
+ <template>
2
+ <label :for="input.id">
3
+ <slot />
4
+ </label>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { injectReactiveOrFail } from '@/utils/vue';
9
+
10
+ import type { IAGHeadlessInput } from './AGHeadlessInput';
11
+
12
+ const input = injectReactiveOrFail<IAGHeadlessInput>(
13
+ 'input',
14
+ '<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>',
15
+ );
16
+ </script>
@@ -1,4 +1,6 @@
1
- import AGHeadlessButton from './AGHeadlessButton.vue';
2
- import AGHeadlessInput from './AGHeadlessInput.vue';
3
-
4
- export { AGHeadlessButton, AGHeadlessInput };
1
+ export { IAGHeadlessInput } from './AGHeadlessInput';
2
+ export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
3
+ export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
4
+ export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
5
+ export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
6
+ export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
@@ -1,2 +1,3 @@
1
1
  export * from './forms';
2
2
  export * from './modals';
3
+ export * from './snackbars';
@@ -23,7 +23,11 @@ const props = defineProps({
23
23
  const $root = ref<{ $el?: HTMLElement } | null>(null);
24
24
  const hidden = ref(true);
25
25
  const closed = ref(false);
26
- const { modal } = injectReactiveOrFail<IAGModalContext>('modal');
26
+ const { modal } = injectReactiveOrFail<IAGModalContext>(
27
+ 'modal',
28
+ 'could not obtain modal reference from <AGHeadlessModal>, ' +
29
+ 'did you render this component manually? Show it using $ui.openModal() instead',
30
+ );
27
31
 
28
32
  async function hide(): Promise<void> {
29
33
  if (!$root.value?.$el) {
@@ -1,7 +1,11 @@
1
1
  <template>
2
2
  <DialogPanel>
3
3
  <slot />
4
- <AGModalContext v-if="childModal" :child-index="modal.childIndex + 1" :modal="childModal" />
4
+
5
+ <template v-if="childModal">
6
+ <div class="pointer-events-none fixed inset-0 z-50 bg-black/30" />
7
+ <AGModalContext :child-index="modal.childIndex + 1" :modal="childModal" />
8
+ </template>
5
9
  </DialogPanel>
6
10
  </template>
7
11
 
@@ -15,6 +19,10 @@ import type { IAGModalContext } from '@/components/modals/AGModalContext';
15
19
 
16
20
  import AGModalContext from '../../modals/AGModalContext.vue';
17
21
 
18
- const modal = injectReactiveOrFail<IAGModalContext>('modal');
22
+ const modal = injectReactiveOrFail<IAGModalContext>(
23
+ 'modal',
24
+ 'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
25
+ 'did you render this component manually? Show it using $ui.openModal() instead',
26
+ );
19
27
  const childModal = computed(() => UI.modals[modal.childIndex] ?? null);
20
28
  </script>
@@ -0,0 +1,10 @@
1
+ <template>
2
+ <div class="pointer-events-auto">
3
+ <slot />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ // Stub import to fix build (otherwise, this file doesn't seem to be treated as a module).
9
+ import 'virtual:aerogel';
10
+ </script>
@@ -0,0 +1,25 @@
1
+ import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
2
+ import { Colors } from '@/components/constants';
3
+ import { objectWithout } from '@noeldemartin/utils';
4
+
5
+ export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
6
+
7
+ export interface SnackbarAction {
8
+ text: string;
9
+ dismiss?: boolean;
10
+ handler?(): unknown;
11
+ }
12
+
13
+ export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
14
+
15
+ export const SnackbarColors = objectWithout(Colors, ['Primary', 'Clear']);
16
+ export const snackbarProps = {
17
+ id: requiredStringProp(),
18
+ message: requiredStringProp(),
19
+ actions: arrayProp<SnackbarAction>(() => []),
20
+ color: enumProp(SnackbarColors, Colors.Secondary),
21
+ };
22
+
23
+ export function useSnackbarProps(): typeof snackbarProps {
24
+ return snackbarProps;
25
+ }
@@ -1,8 +1,11 @@
1
1
  import AGAppLayout from './AGAppLayout.vue';
2
+ import AGAppOverlays from './AGAppOverlays.vue';
2
3
 
3
- export { AGAppLayout };
4
+ export { AGAppLayout, AGAppOverlays };
4
5
 
5
6
  export * from './basic';
7
+ export * from './constants';
6
8
  export * from './forms';
7
9
  export * from './headless';
8
10
  export * from './modals';
11
+ export * from './snackbars';
@@ -1,15 +1,25 @@
1
1
  <template>
2
2
  <AGModal>
3
+ <AGMarkdown
4
+ v-if="title"
5
+ :text="title"
6
+ as="h2"
7
+ class="font-semibold"
8
+ inline
9
+ />
3
10
  <AGMarkdown :text="message" />
4
11
  </AGModal>
5
12
  </template>
6
13
 
7
14
  <script setup lang="ts">
8
- import { requiredStringProp } from '@/utils/vue';
15
+ import { requiredStringProp, stringProp } from '@/utils/vue';
9
16
 
10
17
  import AGModal from './AGModal.vue';
11
18
 
12
19
  import AGMarkdown from '../basic/AGMarkdown.vue';
13
20
 
14
- defineProps({ message: requiredStringProp() });
21
+ defineProps({
22
+ title: stringProp(),
23
+ message: requiredStringProp(),
24
+ });
15
25
  </script>
@@ -0,0 +1,30 @@
1
+ <template>
2
+ <AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false">
3
+ <AGMarkdown v-if="title" :text="title" as="h1" />
4
+ <AGMarkdown :text="message" />
5
+
6
+ <div class="mt-2 flex flex-row-reverse gap-2">
7
+ <AGButton @click="close(true)">
8
+ {{ $td('ui.ok', 'OK') }}
9
+ </AGButton>
10
+ <AGButton color="secondary" @click="close()">
11
+ {{ $td('ui.cancel', 'Cancel') }}
12
+ </AGButton>
13
+ </div>
14
+ </AGModal>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ import { requiredStringProp, stringProp } from '@/utils/vue';
19
+
20
+ import AGModal from './AGModal.vue';
21
+ import type { IAGModalDefaultSlotProps } from './AGModal';
22
+
23
+ import AGButton from '../forms/AGButton.vue';
24
+ import AGMarkdown from '../basic/AGMarkdown.vue';
25
+
26
+ defineProps({
27
+ title: stringProp(),
28
+ message: requiredStringProp(),
29
+ });
30
+ </script>
@@ -0,0 +1,20 @@
1
+ import type { Component } from 'vue';
2
+
3
+ import { requiredArrayProp } from '@/utils/vue';
4
+ import type { ErrorReport } from '@/errors';
5
+
6
+ export interface IAGErrorReportModalButtonsDefaultSlotProps {
7
+ id: string;
8
+ description: string;
9
+ iconComponent: Component;
10
+ url?: string;
11
+ handler?(): void;
12
+ }
13
+
14
+ export const errorReportModalProps = {
15
+ reports: requiredArrayProp<ErrorReport>(),
16
+ };
17
+
18
+ export function useErrorReportModalProps(): typeof errorReportModalProps {
19
+ return errorReportModalProps;
20
+ }