@aerogel/core 0.0.0-next.d7394c3aa6aac799b0971e63819a8713d05a5123 → 0.0.0-next.eed7a057cf5b844cd9f7fc6bda2d8df49fcd6736

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 (116) hide show
  1. package/dist/aerogel-core.d.ts +2317 -667
  2. package/dist/aerogel-core.js +2789 -0
  3. package/dist/aerogel-core.js.map +1 -0
  4. package/package.json +19 -34
  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 +1 -1
  9. package/src/components/AGAppModals.vue +1 -1
  10. package/src/components/AGAppOverlays.vue +1 -1
  11. package/src/components/composition.ts +1 -1
  12. package/src/components/forms/AGButton.vue +2 -2
  13. package/src/components/forms/AGCheckbox.vue +4 -3
  14. package/src/components/forms/AGForm.vue +2 -2
  15. package/src/components/forms/AGInput.vue +6 -4
  16. package/src/components/forms/AGSelect.vue +3 -3
  17. package/src/components/headless/forms/AGHeadlessButton.ts +1 -1
  18. package/src/components/headless/forms/AGHeadlessButton.vue +2 -2
  19. package/src/components/headless/forms/AGHeadlessInput.ts +11 -4
  20. package/src/components/headless/forms/AGHeadlessInput.vue +3 -3
  21. package/src/components/headless/forms/AGHeadlessInputDescription.vue +1 -1
  22. package/src/components/headless/forms/AGHeadlessInputError.vue +2 -2
  23. package/src/components/headless/forms/AGHeadlessInputInput.vue +4 -4
  24. package/src/components/headless/forms/AGHeadlessInputLabel.vue +1 -1
  25. package/src/components/headless/forms/AGHeadlessInputTextArea.vue +3 -3
  26. package/src/components/headless/forms/AGHeadlessSelect.ts +3 -3
  27. package/src/components/headless/forms/AGHeadlessSelect.vue +5 -5
  28. package/src/components/headless/forms/AGHeadlessSelectButton.vue +2 -2
  29. package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
  30. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +2 -2
  31. package/src/components/headless/forms/AGHeadlessSelectOption.vue +3 -3
  32. package/src/components/headless/forms/composition.ts +1 -1
  33. package/src/components/headless/modals/AGHeadlessModal.ts +6 -4
  34. package/src/components/headless/modals/AGHeadlessModal.vue +14 -8
  35. package/src/components/headless/modals/AGHeadlessModalPanel.vue +13 -9
  36. package/src/components/headless/modals/AGHeadlessModalTitle.vue +14 -4
  37. package/src/components/headless/snackbars/index.ts +3 -3
  38. package/src/components/lib/AGErrorMessage.vue +3 -3
  39. package/src/components/lib/AGMarkdown.vue +16 -3
  40. package/src/components/lib/AGMeasured.vue +1 -1
  41. package/src/components/lib/AGProgressBar.vue +55 -0
  42. package/src/components/lib/index.ts +1 -0
  43. package/src/components/modals/AGAlertModal.ts +6 -3
  44. package/src/components/modals/AGConfirmModal.ts +16 -7
  45. package/src/components/modals/AGConfirmModal.vue +2 -2
  46. package/src/components/modals/AGErrorReportModal.ts +8 -5
  47. package/src/components/modals/AGErrorReportModalButtons.vue +9 -9
  48. package/src/components/modals/AGErrorReportModalTitle.vue +2 -2
  49. package/src/components/modals/AGLoadingModal.ts +11 -5
  50. package/src/components/modals/AGModal.ts +1 -0
  51. package/src/components/modals/AGModal.vue +5 -2
  52. package/src/components/modals/AGModalContext.ts +1 -1
  53. package/src/components/modals/AGModalContext.vue +15 -5
  54. package/src/components/modals/AGPromptModal.ts +12 -7
  55. package/src/components/snackbars/AGSnackbar.vue +2 -2
  56. package/src/components/utils.ts +7 -4
  57. package/src/directives/index.ts +3 -5
  58. package/src/directives/measure.ts +1 -1
  59. package/src/errors/Errors.state.ts +1 -1
  60. package/src/errors/Errors.ts +12 -12
  61. package/src/errors/JobCancelledError.ts +3 -0
  62. package/src/errors/index.ts +9 -6
  63. package/src/errors/utils.ts +17 -1
  64. package/src/forms/Form.test.ts +4 -3
  65. package/src/forms/Form.ts +27 -17
  66. package/src/forms/composition.ts +2 -2
  67. package/src/forms/index.ts +2 -1
  68. package/src/forms/utils.ts +20 -4
  69. package/src/forms/validation.ts +19 -0
  70. package/src/jobs/Job.ts +144 -2
  71. package/src/jobs/index.ts +4 -1
  72. package/src/jobs/listeners.ts +3 -0
  73. package/src/jobs/status.ts +4 -0
  74. package/src/lang/DefaultLangProvider.ts +7 -4
  75. package/src/lang/Lang.state.ts +1 -1
  76. package/src/lang/Lang.ts +5 -1
  77. package/src/lang/index.ts +7 -5
  78. package/src/plugins/Plugin.ts +1 -1
  79. package/src/plugins/index.ts +10 -7
  80. package/src/services/App.state.ts +13 -4
  81. package/src/services/App.ts +8 -3
  82. package/src/services/Cache.ts +1 -1
  83. package/src/services/Events.ts +15 -5
  84. package/src/services/Service.ts +116 -53
  85. package/src/services/Storage.ts +20 -0
  86. package/src/services/index.ts +10 -4
  87. package/src/services/utils.ts +18 -0
  88. package/src/testing/index.ts +4 -3
  89. package/src/testing/setup.ts +5 -19
  90. package/src/ui/UI.state.ts +2 -2
  91. package/src/ui/UI.ts +139 -54
  92. package/src/ui/index.ts +4 -4
  93. package/src/ui/utils.ts +1 -1
  94. package/src/utils/composition/events.ts +2 -2
  95. package/src/utils/composition/persistent.test.ts +33 -0
  96. package/src/utils/composition/persistent.ts +11 -0
  97. package/src/utils/composition/state.test.ts +47 -0
  98. package/src/utils/composition/state.ts +24 -0
  99. package/src/utils/index.ts +2 -0
  100. package/src/utils/markdown.test.ts +50 -0
  101. package/src/utils/markdown.ts +19 -6
  102. package/src/utils/vue.ts +14 -4
  103. package/dist/aerogel-core.cjs.js +0 -2
  104. package/dist/aerogel-core.cjs.js.map +0 -1
  105. package/dist/aerogel-core.esm.js +0 -2
  106. package/dist/aerogel-core.esm.js.map +0 -1
  107. package/histoire.config.ts +0 -7
  108. package/noeldemartin.config.js +0 -5
  109. package/postcss.config.js +0 -6
  110. package/src/assets/histoire.css +0 -3
  111. package/src/directives/initial-focus.ts +0 -11
  112. package/src/main.histoire.ts +0 -1
  113. package/tailwind.config.js +0 -4
  114. package/tsconfig.json +0 -11
  115. package/vite.config.ts +0 -17
  116. /package/src/{main.ts → index.ts} +0 -0
@@ -1,28 +1,32 @@
1
1
  <template>
2
- <DialogPanel>
2
+ <component :is="rootComponent">
3
3
  <slot />
4
4
 
5
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" />
6
+ <div
7
+ class="pointer-events-none inset-0 z-50 bg-black/30"
8
+ :class="childModal.properties.inline ? 'absolute' : 'fixed'"
9
+ />
10
+ <AGModalContext :child-index="childIndex + 1" :modal="childModal" />
8
11
  </template>
9
- </DialogPanel>
12
+ </component>
10
13
  </template>
11
14
 
12
15
  <script setup lang="ts">
13
16
  import { computed } from 'vue';
14
17
  import { DialogPanel } from '@headlessui/vue';
15
18
 
16
- import UI from '@/ui/UI';
17
- import { injectReactiveOrFail } from '@/utils/vue';
18
- import type { IAGModalContext } from '@/components/modals/AGModalContext';
19
+ import UI from '@aerogel/core/ui/UI';
20
+ import { injectReactiveOrFail } from '@aerogel/core/utils/vue';
21
+ import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
19
22
 
20
23
  import AGModalContext from '../../modals/AGModalContext.vue';
21
24
 
22
- const modal = injectReactiveOrFail<IAGModalContext>(
25
+ const { modal, childIndex } = injectReactiveOrFail<IAGModalContext>(
23
26
  'modal',
24
27
  'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
25
28
  'did you render this component manually? Show it using $ui.openModal() instead',
26
29
  );
27
- const childModal = computed(() => UI.modals[modal.childIndex] ?? null);
30
+ const rootComponent = computed(() => (modal.properties.inline ? 'div' : DialogPanel));
31
+ const childModal = computed(() => UI.modals[childIndex] ?? null);
28
32
  </script>
@@ -1,13 +1,23 @@
1
1
  <template>
2
- <DialogTitle :as="as">
2
+ <component :is="rootComponent" v-bind="rootProps">
3
3
  <slot />
4
- </DialogTitle>
4
+ </component>
5
5
  </template>
6
6
 
7
7
  <script setup lang="ts">
8
+ import { computed } from 'vue';
8
9
  import { DialogTitle } from '@headlessui/vue';
9
10
 
10
- import { stringProp } from '@/utils/vue';
11
+ import { injectReactiveOrFail, stringProp } from '@aerogel/core/utils/vue';
12
+ import type { IAGModalContext } from '@aerogel/core/components/modals/AGModalContext';
11
13
 
12
- defineProps({ as: stringProp('h2') });
14
+ const props = defineProps({ as: stringProp('h2') });
15
+
16
+ const { modal } = injectReactiveOrFail<IAGModalContext>(
17
+ 'modal',
18
+ 'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
19
+ 'did you render this component manually? Show it using $ui.openModal() instead',
20
+ );
21
+ const rootComponent = computed(() => (modal.properties.inline ? 'div' : DialogTitle));
22
+ const rootProps = computed(() => (modal.properties.inline ? {} : { as: props.as }));
13
23
  </script>
@@ -1,9 +1,9 @@
1
1
  import type { ExtractPropTypes } from 'vue';
2
2
  import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
3
3
 
4
- import UI from '@/ui/UI';
5
- import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
6
- import { Colors } from '@/components/constants';
4
+ import UI from '@aerogel/core/ui/UI';
5
+ import { arrayProp, enumProp, requiredStringProp } from '@aerogel/core/utils/vue';
6
+ import { Colors } from '@aerogel/core/components/constants';
7
7
  import { objectWithout } from '@noeldemartin/utils';
8
8
 
9
9
  export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
@@ -5,9 +5,9 @@
5
5
  <script setup lang="ts">
6
6
  import { computed } from 'vue';
7
7
 
8
- import { requiredObjectProp } from '@/utils/vue';
9
- import { getErrorMessage } from '@/errors/utils';
10
- import type { ErrorSource } from '@/errors/Errors.state';
8
+ import { requiredObjectProp } from '@aerogel/core/utils/vue';
9
+ import { getErrorMessage } from '@aerogel/core/errors/utils';
10
+ import type { ErrorSource } from '@aerogel/core/errors/Errors.state';
11
11
 
12
12
  import AGMarkdown from './AGMarkdown.vue';
13
13
 
@@ -4,10 +4,11 @@
4
4
 
5
5
  <script setup lang="ts">
6
6
  import { computed, h, useAttrs } from 'vue';
7
+ import { isInstanceOf } from '@noeldemartin/utils';
7
8
 
8
- import { renderMarkdown } from '@/utils/markdown';
9
- import { booleanProp, mixedProp, stringProp } from '@/utils/vue';
10
- import { translate } from '@/lang';
9
+ import { renderMarkdown } from '@aerogel/core/utils/markdown';
10
+ import { booleanProp, mixedProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
11
+ import { translate } from '@aerogel/core/lang';
11
12
 
12
13
  const props = defineProps({
13
14
  as: stringProp(),
@@ -15,6 +16,7 @@ const props = defineProps({
15
16
  langKey: stringProp(),
16
17
  langParams: mixedProp<number | Record<string, unknown>>(),
17
18
  text: stringProp(),
19
+ actions: objectProp<Record<string, () => unknown>>(),
18
20
  });
19
21
 
20
22
  const attrs = useAttrs();
@@ -35,7 +37,18 @@ const html = computed(() => {
35
37
  const root = () =>
36
38
  h(props.as ?? (props.inline ? 'span' : 'div'), {
37
39
  innerHTML: html.value,
40
+ onClick,
38
41
  ...attrs,
39
42
  class: `${attrs.class ?? ''} ${props.inline ? '' : 'prose'}`,
40
43
  });
44
+
45
+ async function onClick(event: Event) {
46
+ const { target } = event;
47
+
48
+ if (isInstanceOf(target, HTMLElement) && target.dataset.markdownAction) {
49
+ props.actions?.[target.dataset.markdownAction]?.();
50
+
51
+ return;
52
+ }
53
+ }
41
54
  </script>
@@ -7,7 +7,7 @@
7
7
  <script setup lang="ts">
8
8
  import { ref } from 'vue';
9
9
 
10
- import { stringProp } from '@/utils/vue';
10
+ import { stringProp } from '@aerogel/core/utils/vue';
11
11
 
12
12
  defineProps({ as: stringProp('span') });
13
13
 
@@ -0,0 +1,55 @@
1
+ <template>
2
+ <div class="mt-1 h-2 w-full overflow-hidden rounded-full bg-gray-200">
3
+ <div :class="barClasses" :style="`transform:translateX(-${(1 - renderedProgress) * 100}%)`" />
4
+ <span class="sr-only">
5
+ {{
6
+ $td('ui.progress', '{progress}% complete', {
7
+ progress: renderedProgress * 100,
8
+ })
9
+ }}
10
+ </span>
11
+ </div>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { computed, onUnmounted, ref, watch } from 'vue';
16
+
17
+ import { numberProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
18
+ import type { Job } from '@aerogel/core/jobs';
19
+
20
+ const props = defineProps({
21
+ progress: numberProp(),
22
+ barClass: stringProp(''),
23
+ job: objectProp<Job>(),
24
+ });
25
+
26
+ let cleanup: Function | undefined;
27
+ const jobProgress = ref(0);
28
+ const barClasses = computed(() => {
29
+ const classes = props.barClass ?? '';
30
+
31
+ return `h-full w-full transition-transform duration-500 ease-linear ${
32
+ classes.includes('bg-') ? classes : `${classes} bg-gray-700`
33
+ }`;
34
+ });
35
+ const renderedProgress = computed(() => {
36
+ if (typeof props.progress === 'number') {
37
+ return props.progress;
38
+ }
39
+
40
+ return jobProgress.value;
41
+ });
42
+
43
+ watch(
44
+ () => props.job,
45
+ () => {
46
+ cleanup?.();
47
+
48
+ jobProgress.value = props.job?.progress ?? 0;
49
+ cleanup = props.job?.listeners.add({ onUpdated: (progress) => (jobProgress.value = progress) });
50
+ },
51
+ { immediate: true },
52
+ );
53
+
54
+ onUnmounted(() => cleanup?.());
55
+ </script>
@@ -2,4 +2,5 @@ export { default as AGErrorMessage } from './AGErrorMessage.vue';
2
2
  export { default as AGLink } from './AGLink.vue';
3
3
  export { default as AGMarkdown } from './AGMarkdown.vue';
4
4
  export { default as AGMeasured } from './AGMeasured.vue';
5
+ export { default as AGProgressBar } from './AGProgressBar.vue';
5
6
  export { default as AGStartupCrash } from './AGStartupCrash.vue';
@@ -1,14 +1,17 @@
1
1
  import type { ExtractPropTypes } from 'vue';
2
- import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
2
+ import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
3
3
 
4
- import { requiredStringProp, stringProp } from '@/utils';
4
+ import { requiredStringProp, stringProp } from '@aerogel/core/utils';
5
+ import type { AcceptRefs } from '@aerogel/core/utils';
5
6
 
6
7
  export const alertModalProps = {
7
8
  title: stringProp(),
8
9
  message: requiredStringProp(),
9
10
  };
10
11
 
11
- export type AGAlertModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof alertModalProps>>;
12
+ export type AGAlertModalProps = Pretty<
13
+ AcceptRefs<ObjectWithout<ExtractPropTypes<typeof alertModalProps>, null | undefined>>
14
+ >;
12
15
 
13
16
  export function useAlertModalProps(): typeof alertModalProps {
14
17
  return alertModalProps;
@@ -1,10 +1,12 @@
1
1
  import { computed } from 'vue';
2
2
  import type { ExtractPropTypes } from 'vue';
3
- import type { ObjectWithoutEmpty, SubPartial } from '@noeldemartin/utils';
3
+ import type { ObjectWithout, Pretty, SubPartial } from '@noeldemartin/utils';
4
4
 
5
- import { Colors } from '@/components/constants';
6
- import { enumProp, requiredStringProp, stringProp } from '@/utils';
7
- import { translateWithDefault } from '@/lang';
5
+ import { Colors } from '@aerogel/core/components/constants';
6
+ import { booleanProp, enumProp, objectProp, requiredStringProp, stringProp } from '@aerogel/core/utils';
7
+ import { translateWithDefault } from '@aerogel/core/lang';
8
+ import type { AcceptRefs } from '@aerogel/core/utils';
9
+ import type { ConfirmCheckboxes } from '@aerogel/core/ui';
8
10
 
9
11
  export const confirmModalProps = {
10
12
  title: stringProp(),
@@ -13,11 +15,18 @@ export const confirmModalProps = {
13
15
  acceptColor: enumProp(Colors, Colors.Primary),
14
16
  cancelText: stringProp(),
15
17
  cancelColor: enumProp(Colors, Colors.Clear),
18
+ checkboxes: objectProp<ConfirmCheckboxes>(),
19
+ actions: objectProp<Record<string, () => unknown>>(),
20
+ required: booleanProp(false),
16
21
  };
17
22
 
18
- export type AGConfirmModalProps = SubPartial<
19
- ObjectWithoutEmpty<ExtractPropTypes<typeof confirmModalProps>>,
20
- 'acceptColor' | 'cancelColor'
23
+ export type AGConfirmModalProps = Pretty<
24
+ AcceptRefs<
25
+ SubPartial<
26
+ ObjectWithout<ExtractPropTypes<typeof confirmModalProps>, null | undefined>,
27
+ 'acceptColor' | 'cancelColor'
28
+ >
29
+ >
21
30
  >;
22
31
 
23
32
  export function useConfirmModalProps(): typeof confirmModalProps {
@@ -1,12 +1,12 @@
1
1
  <template>
2
2
  <AGModal v-slot="{ close }: IAGModalDefaultSlotProps" :cancellable="false" :title="title">
3
- <AGMarkdown :text="message" />
3
+ <AGMarkdown :text="message" :actions="actions" />
4
4
 
5
5
  <div class="mt-2 flex flex-row-reverse gap-2">
6
6
  <AGButton :color="acceptColor" @click="close(true)">
7
7
  {{ renderedAcceptText }}
8
8
  </AGButton>
9
- <AGButton :color="cancelColor" @click="close()">
9
+ <AGButton v-if="!required" :color="cancelColor" @click="close()">
10
10
  {{ renderedCancelText }}
11
11
  </AGButton>
12
12
  </div>
@@ -1,10 +1,11 @@
1
1
  import { computed, ref } from 'vue';
2
2
  import type { Component, ExtractPropTypes } from 'vue';
3
- import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
3
+ import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
4
4
 
5
- import { requiredArrayProp } from '@/utils/vue';
6
- import { translateWithDefault } from '@/lang';
7
- import type { ErrorReport } from '@/errors';
5
+ import { requiredArrayProp } from '@aerogel/core/utils/vue';
6
+ import { translateWithDefault } from '@aerogel/core/lang';
7
+ import type { AcceptRefs } from '@aerogel/core/utils/vue';
8
+ import type { ErrorReport } from '@aerogel/core/errors';
8
9
 
9
10
  export interface IAGErrorReportModalButtonsDefaultSlotProps {
10
11
  id: string;
@@ -18,7 +19,9 @@ export const errorReportModalProps = {
18
19
  reports: requiredArrayProp<ErrorReport>(),
19
20
  };
20
21
 
21
- export type AGErrorReportModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof errorReportModalProps>>;
22
+ export type AGErrorReportModalProps = Pretty<
23
+ AcceptRefs<ObjectWithout<ExtractPropTypes<typeof errorReportModalProps>, null | undefined>>
24
+ >;
22
25
 
23
26
  export function useErrorReportModalProps(): typeof errorReportModalProps {
24
27
  return errorReportModalProps;
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="flex">
3
- <slot v-for="(button, i) of buttons" v-bind="(button as unknown as ComponentProps)" :key="i">
3
+ <slot v-for="(button, i) of buttons" v-bind="button as unknown as ComponentProps" :key="i">
4
4
  <AGButton
5
5
  color="clear"
6
6
  :url="button.url"
@@ -22,12 +22,12 @@ import IconGitHub from '~icons/mdi/github';
22
22
  import { computed } from 'vue';
23
23
  import { stringExcerpt, tap } from '@noeldemartin/utils';
24
24
 
25
- import App from '@/services/App';
26
- import UI from '@/ui/UI';
27
- import { requiredObjectProp } from '@/utils/vue';
28
- import { translateWithDefault } from '@/lang/utils';
29
- import type { ComponentProps } from '@/utils/vue';
30
- import type { ErrorReport } from '@/errors';
25
+ import App from '@aerogel/core/services/App';
26
+ import UI from '@aerogel/core/ui/UI';
27
+ import { requiredObjectProp } from '@aerogel/core/utils/vue';
28
+ import { translateWithDefault } from '@aerogel/core/lang/utils';
29
+ import type { ComponentProps } from '@aerogel/core/utils/vue';
30
+ import type { ErrorReport } from '@aerogel/core/errors';
31
31
 
32
32
  import AGButton from '../forms/AGButton.vue';
33
33
  import type { IAGErrorReportModalButtonsDefaultSlotProps } from './AGErrorReportModal';
@@ -94,8 +94,8 @@ const buttons = computed(() =>
94
94
  );
95
95
  },
96
96
  },
97
- ],
98
- (reportButtons: IAGErrorReportModalButtonsDefaultSlotProps[]) => {
97
+ ] as IAGErrorReportModalButtonsDefaultSlotProps[],
98
+ (reportButtons) => {
99
99
  if (!githubReportUrl.value) {
100
100
  return;
101
101
  }
@@ -5,8 +5,8 @@
5
5
  <script setup lang="ts">
6
6
  import { computed } from 'vue';
7
7
 
8
- import { numberProp, requiredObjectProp } from '@/utils/vue';
9
- import type { ErrorReport } from '@/errors';
8
+ import { numberProp, requiredObjectProp } from '@aerogel/core/utils/vue';
9
+ import type { ErrorReport } from '@aerogel/core/errors';
10
10
 
11
11
  import AGMarkdown from '../lib/AGMarkdown.vue';
12
12
 
@@ -1,15 +1,20 @@
1
1
  import { computed } from 'vue';
2
2
  import type { ExtractPropTypes } from 'vue';
3
- import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
3
+ import type { ObjectWithout } from '@noeldemartin/utils';
4
4
 
5
- import { stringProp } from '@/utils';
6
- import { translateWithDefault } from '@/lang';
5
+ import { numberProp, stringProp } from '@aerogel/core/utils';
6
+ import { translateWithDefault } from '@aerogel/core/lang';
7
+ import type { AcceptRefs } from '@aerogel/core/utils';
7
8
 
8
9
  export const loadingModalProps = {
10
+ title: stringProp(),
9
11
  message: stringProp(),
12
+ progress: numberProp(),
10
13
  };
11
14
 
12
- export type AGLoadingModalProps = ObjectWithoutEmpty<ExtractPropTypes<typeof loadingModalProps>>;
15
+ export type AGLoadingModalProps = AcceptRefs<
16
+ ObjectWithout<ExtractPropTypes<typeof loadingModalProps>, null | undefined>
17
+ >;
13
18
 
14
19
  export function useLoadingModalProps(): typeof loadingModalProps {
15
20
  return loadingModalProps;
@@ -18,6 +23,7 @@ export function useLoadingModalProps(): typeof loadingModalProps {
18
23
  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
19
24
  export function useLoadingModal(props: ExtractPropTypes<typeof loadingModalProps>) {
20
25
  const renderedMessage = computed(() => props.message ?? translateWithDefault('ui.loading', 'Loading...'));
26
+ const showProgress = computed(() => typeof props.progress === 'number');
21
27
 
22
- return { renderedMessage };
28
+ return { renderedMessage, showProgress };
23
29
  }
@@ -1,6 +1,7 @@
1
1
  import type { Ref } from 'vue';
2
2
 
3
3
  export interface IAGModal {
4
+ inline: Ref<boolean>;
4
5
  cancellable: Ref<boolean>;
5
6
  close(result?: unknown): Promise<void>;
6
7
  }
@@ -21,8 +21,11 @@
21
21
  <script setup lang="ts">
22
22
  import { ref } from 'vue';
23
23
 
24
- import { useModalExpose, useModalProps } from '@/components/headless/modals/AGHeadlessModal';
25
- import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from '@/components/headless/modals/AGHeadlessModal';
24
+ import { useModalExpose, useModalProps } from '@aerogel/core/components/headless/modals/AGHeadlessModal';
25
+ import type {
26
+ IAGHeadlessModal,
27
+ IAGHeadlessModalDefaultSlotProps,
28
+ } from '@aerogel/core/components/headless/modals/AGHeadlessModal';
26
29
 
27
30
  import type { IAGModal } from './AGModal';
28
31
 
@@ -1,6 +1,6 @@
1
1
  import type { Ref } from 'vue';
2
2
 
3
- import type { Modal } from '@/ui/UI.state';
3
+ import type { Modal } from '@aerogel/core/ui/UI.state';
4
4
 
5
5
  export interface IAGModalContext {
6
6
  modal: Ref<Modal>;
@@ -1,18 +1,28 @@
1
1
  <template>
2
- <component :is="modal.component" v-bind="modal.properties" />
2
+ <component :is="modal.component" v-bind="modalProperties" />
3
3
  </template>
4
4
 
5
5
  <script setup lang="ts">
6
- import { provide, toRef } from 'vue';
6
+ import { computed, provide, toRef, unref } from 'vue';
7
7
 
8
- import { requiredNumberProp, requiredObjectProp } from '@/utils/vue';
9
- import type { Modal } from '@/ui/UI.state';
8
+ import { numberProp, requiredObjectProp } from '@aerogel/core/utils/vue';
9
+ import type { Modal } from '@aerogel/core/ui/UI.state';
10
10
 
11
11
  import type { IAGModalContext } from './AGModalContext';
12
12
 
13
13
  const props = defineProps({
14
14
  modal: requiredObjectProp<Modal>(),
15
- childIndex: requiredNumberProp(),
15
+ childIndex: numberProp(0),
16
+ });
17
+
18
+ const modalProperties = computed(() => {
19
+ const properties = {} as typeof props.modal.properties;
20
+
21
+ for (const property in props.modal.properties) {
22
+ properties[property] = unref(props.modal.properties[property]);
23
+ }
24
+
25
+ return properties;
16
26
  });
17
27
 
18
28
  provide<IAGModalContext>('modal', {
@@ -1,10 +1,11 @@
1
1
  import { computed } from 'vue';
2
2
  import type { ExtractPropTypes } from 'vue';
3
- import type { ObjectWithoutEmpty, SubPartial } from '@noeldemartin/utils';
3
+ import type { ObjectWithout, Pretty, SubPartial } from '@noeldemartin/utils';
4
4
 
5
- import { Colors } from '@/components/constants';
6
- import { enumProp, requiredStringProp, stringProp } from '@/utils';
7
- import { translateWithDefault } from '@/lang';
5
+ import { Colors } from '@aerogel/core/components/constants';
6
+ import { enumProp, requiredStringProp, stringProp } from '@aerogel/core/utils';
7
+ import { translateWithDefault } from '@aerogel/core/lang';
8
+ import type { AcceptRefs } from '@aerogel/core/utils';
8
9
 
9
10
  export const promptModalProps = {
10
11
  title: stringProp(),
@@ -18,9 +19,13 @@ export const promptModalProps = {
18
19
  cancelColor: enumProp(Colors, Colors.Clear),
19
20
  };
20
21
 
21
- export type AGPromptModalProps = SubPartial<
22
- ObjectWithoutEmpty<ExtractPropTypes<typeof promptModalProps>>,
23
- 'acceptColor' | 'cancelColor'
22
+ export type AGPromptModalProps = Pretty<
23
+ AcceptRefs<
24
+ SubPartial<
25
+ ObjectWithout<ExtractPropTypes<typeof promptModalProps>, null | undefined>,
26
+ 'acceptColor' | 'cancelColor'
27
+ >
28
+ >
24
29
  >;
25
30
 
26
31
  export function usePromptModalProps(): typeof promptModalProps {
@@ -15,8 +15,8 @@
15
15
  <script setup lang="ts">
16
16
  import { computed } from 'vue';
17
17
 
18
- import { Colors } from '@/components/constants';
19
- import { useSnackbar, useSnackbarProps } from '@/components/headless/snackbars';
18
+ import { Colors } from '@aerogel/core/components/constants';
19
+ import { useSnackbar, useSnackbarProps } from '@aerogel/core/components/headless/snackbars';
20
20
 
21
21
  import AGButton from '../forms/AGButton.vue';
22
22
  import AGHeadlessSnackbar from '../headless/snackbars/AGHeadlessSnackbar.vue';
@@ -2,9 +2,12 @@ export function extractComponentProps<T extends Record<string, unknown>>(
2
2
  values: Record<string, unknown>,
3
3
  definitions: Record<string, unknown>,
4
4
  ): T {
5
- return Object.keys(definitions).reduce((extracted, prop) => {
6
- extracted[prop] = values[prop];
5
+ return Object.keys(definitions).reduce(
6
+ (extracted, prop) => {
7
+ extracted[prop] = values[prop];
7
8
 
8
- return extracted;
9
- }, {} as Record<string, unknown>) as T;
9
+ return extracted;
10
+ },
11
+ {} as Record<string, unknown>,
12
+ ) as T;
10
13
  }
@@ -1,13 +1,11 @@
1
1
  import type { Directive } from 'vue';
2
2
 
3
- import { definePlugin } from '@/plugins';
3
+ import { definePlugin } from '@aerogel/core/plugins';
4
4
 
5
- import initialFocus from './initial-focus';
6
5
  import measure from './measure';
7
6
 
8
7
  const builtInDirectives: Record<string, Directive> = {
9
- 'initial-focus': initialFocus,
10
- 'measure': measure,
8
+ measure: measure,
11
9
  };
12
10
 
13
11
  export * from './measure';
@@ -25,7 +23,7 @@ export default definePlugin({
25
23
  },
26
24
  });
27
25
 
28
- declare module '@/bootstrap/options' {
26
+ declare module '@aerogel/core/bootstrap/options' {
29
27
  export interface AerogelOptions {
30
28
  directives?: Record<string, Directive>;
31
29
  }
@@ -1,4 +1,4 @@
1
- import { defineDirective } from '@/utils/vue';
1
+ import { defineDirective } from '@aerogel/core/utils/vue';
2
2
  import { tap } from '@noeldemartin/utils';
3
3
 
4
4
  const resizeObservers: WeakMap<HTMLElement, ResizeObserver> = new WeakMap();
@@ -1,6 +1,6 @@
1
1
  import type { JSError } from '@noeldemartin/utils';
2
2
 
3
- import { defineServiceState } from '@/services';
3
+ import { defineServiceState } from '@aerogel/core/services';
4
4
 
5
5
  export type ErrorSource = string | Error | JSError | unknown;
6
6
 
@@ -1,16 +1,16 @@
1
- import { JSError, facade, isObject, objectWithoutEmpty, toString } from '@noeldemartin/utils';
1
+ import { JSError, facade, isDevelopment, isObject, isTesting, objectWithoutEmpty, toString } from '@noeldemartin/utils';
2
2
 
3
- import App from '@/services/App';
4
- import ServiceBootError from '@/errors/ServiceBootError';
5
- import UI, { UIComponents } from '@/ui/UI';
6
- import { translateWithDefault } from '@/lang/utils';
3
+ import App from '@aerogel/core/services/App';
4
+ import ServiceBootError from '@aerogel/core/errors/ServiceBootError';
5
+ import UI, { UIComponents } from '@aerogel/core/ui/UI';
6
+ import { translateWithDefault } from '@aerogel/core/lang/utils';
7
7
 
8
8
  import Service from './Errors.state';
9
- import { Colors } from '@/components/constants';
10
- import { Events } from '@/services';
11
- import type { AGErrorReportModalProps } from '@/components/modals/AGErrorReportModal';
9
+ import { Colors } from '@aerogel/core/components/constants';
10
+ import { Events } from '@aerogel/core/services';
11
+ import type { AGErrorReportModalProps } from '@aerogel/core/components/modals/AGErrorReportModal';
12
12
  import type { ErrorReport, ErrorReportLog, ErrorSource } from './Errors.state';
13
- import type { ModalComponent } from '@/ui/UI.state';
13
+ import type { ModalComponent } from '@aerogel/core/ui/UI.state';
14
14
 
15
15
  export class ErrorsService extends Service {
16
16
 
@@ -42,11 +42,11 @@ export class ErrorsService extends Service {
42
42
  public async report(error: ErrorSource, message?: string): Promise<void> {
43
43
  await Events.emit('error', { error, message });
44
44
 
45
- if (App.testing) {
45
+ if (isTesting('unit')) {
46
46
  throw error;
47
47
  }
48
48
 
49
- if (App.development) {
49
+ if (isDevelopment()) {
50
50
  this.logError(error);
51
51
  }
52
52
 
@@ -178,7 +178,7 @@ export class ErrorsService extends Service {
178
178
 
179
179
  export default facade(ErrorsService);
180
180
 
181
- declare module '@/services/Events' {
181
+ declare module '@aerogel/core/services/Events' {
182
182
  export interface EventsPayload {
183
183
  error: { error: ErrorSource; message?: string };
184
184
  }
@@ -0,0 +1,3 @@
1
+ import { JSError } from '@noeldemartin/utils';
2
+
3
+ export default class JobCancelledError extends JSError {}