@aerogel/core 0.0.0-next.7f6ed5a1f91688a86bf5ede2adc465e4fd6cfdea → 0.0.0-next.824cf5311c4335d119158f507dad094ed4f4f0b6

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 (120) 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 +1630 -204
  4. package/dist/aerogel-core.esm.js +1 -1
  5. package/dist/aerogel-core.esm.js.map +1 -1
  6. package/histoire.config.ts +7 -0
  7. package/noeldemartin.config.js +4 -1
  8. package/package.json +15 -8
  9. package/postcss.config.js +6 -0
  10. package/src/assets/histoire.css +3 -0
  11. package/src/bootstrap/bootstrap.test.ts +4 -59
  12. package/src/bootstrap/index.ts +31 -28
  13. package/src/bootstrap/options.ts +8 -1
  14. package/src/components/AGAppLayout.vue +7 -2
  15. package/src/components/AGAppModals.vue +15 -0
  16. package/src/components/AGAppOverlays.vue +10 -8
  17. package/src/components/AGAppSnackbars.vue +13 -0
  18. package/src/components/constants.ts +8 -0
  19. package/src/components/forms/AGButton.vue +36 -3
  20. package/src/components/forms/AGCheckbox.vue +41 -0
  21. package/src/components/forms/AGInput.vue +15 -9
  22. package/src/components/forms/AGSelect.story.vue +46 -0
  23. package/src/components/forms/AGSelect.vue +60 -0
  24. package/src/components/forms/index.ts +5 -5
  25. package/src/components/headless/forms/AGHeadlessButton.vue +7 -7
  26. package/src/components/headless/forms/AGHeadlessInput.ts +23 -3
  27. package/src/components/headless/forms/AGHeadlessInput.vue +13 -10
  28. package/src/components/headless/forms/AGHeadlessInputError.vue +9 -5
  29. package/src/components/headless/forms/AGHeadlessInputInput.vue +20 -4
  30. package/src/components/headless/forms/AGHeadlessInputLabel.vue +22 -0
  31. package/src/components/headless/forms/AGHeadlessSelect.ts +42 -0
  32. package/src/components/headless/forms/AGHeadlessSelect.vue +77 -0
  33. package/src/components/headless/forms/AGHeadlessSelectButton.vue +24 -0
  34. package/src/components/headless/forms/AGHeadlessSelectError.vue +26 -0
  35. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +24 -0
  36. package/src/components/headless/forms/AGHeadlessSelectOption.ts +4 -0
  37. package/src/components/headless/forms/AGHeadlessSelectOption.vue +39 -0
  38. package/src/components/headless/forms/AGHeadlessSelectOptions.ts +3 -0
  39. package/src/components/headless/forms/index.ts +14 -4
  40. package/src/components/headless/index.ts +1 -0
  41. package/src/components/headless/modals/AGHeadlessModal.ts +27 -0
  42. package/src/components/headless/modals/AGHeadlessModal.vue +8 -6
  43. package/src/components/headless/modals/AGHeadlessModalPanel.vue +10 -2
  44. package/src/components/headless/modals/index.ts +4 -6
  45. package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
  46. package/src/components/headless/snackbars/index.ts +40 -0
  47. package/src/components/index.ts +5 -2
  48. package/src/components/lib/AGErrorMessage.vue +16 -0
  49. package/src/components/lib/AGLink.vue +9 -0
  50. package/src/components/lib/AGMarkdown.vue +36 -0
  51. package/src/components/lib/AGMeasured.vue +15 -0
  52. package/src/components/lib/AGStartupCrash.vue +31 -0
  53. package/src/components/lib/index.ts +5 -0
  54. package/src/components/modals/AGAlertModal.ts +15 -0
  55. package/src/components/modals/AGAlertModal.vue +4 -5
  56. package/src/components/modals/AGConfirmModal.ts +27 -0
  57. package/src/components/modals/AGConfirmModal.vue +26 -0
  58. package/src/components/modals/AGErrorReportModal.ts +46 -0
  59. package/src/components/modals/AGErrorReportModal.vue +54 -0
  60. package/src/components/modals/AGErrorReportModalButtons.vue +111 -0
  61. package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
  62. package/src/components/modals/AGLoadingModal.ts +23 -0
  63. package/src/components/modals/AGLoadingModal.vue +15 -0
  64. package/src/components/modals/AGModal.ts +5 -1
  65. package/src/components/modals/AGModal.vue +26 -5
  66. package/src/components/modals/AGModalTitle.vue +9 -0
  67. package/src/components/modals/AGPromptModal.ts +30 -0
  68. package/src/components/modals/AGPromptModal.vue +34 -0
  69. package/src/components/modals/index.ts +16 -4
  70. package/src/components/snackbars/AGSnackbar.vue +36 -0
  71. package/src/components/snackbars/index.ts +3 -0
  72. package/src/components/utils.ts +10 -0
  73. package/src/directives/index.ts +21 -4
  74. package/src/directives/measure.ts +12 -0
  75. package/src/errors/Errors.state.ts +31 -0
  76. package/src/errors/Errors.ts +192 -0
  77. package/src/errors/index.ts +45 -0
  78. package/src/forms/Form.test.ts +21 -0
  79. package/src/forms/Form.ts +48 -17
  80. package/src/forms/utils.ts +17 -0
  81. package/src/jobs/Job.ts +5 -0
  82. package/src/jobs/index.ts +7 -0
  83. package/src/lang/Lang.ts +48 -9
  84. package/src/lang/index.ts +17 -76
  85. package/src/lang/utils.ts +4 -0
  86. package/src/main.histoire.ts +1 -0
  87. package/src/main.ts +3 -0
  88. package/src/plugins/Plugin.ts +8 -0
  89. package/src/plugins/index.ts +26 -0
  90. package/src/services/App.state.ts +17 -0
  91. package/src/services/App.ts +47 -0
  92. package/src/services/Events.test.ts +39 -0
  93. package/src/services/Events.ts +88 -30
  94. package/src/services/Service.ts +195 -33
  95. package/src/services/index.ts +33 -7
  96. package/src/services/store.ts +30 -0
  97. package/src/types/vite.d.ts +0 -2
  98. package/src/ui/UI.state.ts +12 -6
  99. package/src/ui/UI.ts +177 -12
  100. package/src/ui/index.ts +31 -16
  101. package/src/utils/composition/events.ts +1 -0
  102. package/src/utils/composition/forms.ts +11 -0
  103. package/src/utils/composition/hooks.ts +9 -0
  104. package/src/utils/index.ts +4 -0
  105. package/src/utils/markdown.ts +11 -2
  106. package/src/utils/tailwindcss.test.ts +26 -0
  107. package/src/utils/tailwindcss.ts +7 -0
  108. package/src/utils/vue.ts +15 -4
  109. package/tailwind.config.js +4 -0
  110. package/tsconfig.json +2 -10
  111. package/vite.config.ts +3 -6
  112. package/.eslintrc.js +0 -3
  113. package/src/bootstrap/hooks.ts +0 -19
  114. package/src/components/basic/AGMarkdown.vue +0 -20
  115. package/src/components/basic/index.ts +0 -3
  116. package/src/lang/helpers.ts +0 -5
  117. package/src/models/index.ts +0 -18
  118. package/src/routing/index.ts +0 -33
  119. package/src/testing/stubs/lang/en.yaml +0 -1
  120. package/src/testing/stubs/models/User.ts +0 -3
@@ -1,8 +1,28 @@
1
- import type { ComputedRef, DeepReadonly, Ref } from 'vue';
1
+ import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
2
+
3
+ import { stringProp } from '@/utils';
4
+ import { extractComponentProps } from '@/components/utils';
2
5
 
3
6
  export interface IAGHeadlessInput {
4
7
  id: string;
5
- value: ComputedRef<string | number | null>;
8
+ name: ComputedRef<string | null>;
9
+ label: ComputedRef<string | null>;
10
+ value: ComputedRef<string | number | boolean | null>;
6
11
  errors: DeepReadonly<Ref<string[] | null>>;
7
- update(value: string | number | null): void;
12
+ update(value: string | number | boolean | null): void;
13
+ }
14
+
15
+ export const inputProps = {
16
+ name: stringProp(),
17
+ label: stringProp(),
18
+ };
19
+
20
+ export function useInputProps(): typeof inputProps {
21
+ return inputProps;
22
+ }
23
+
24
+ export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
25
+ props: T,
26
+ ): Pick<T, keyof typeof inputProps> {
27
+ return extractComponentProps(props, inputProps);
8
28
  }
@@ -9,16 +9,17 @@
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
+ import { useInputProps } from './AGHeadlessInput';
15
16
  import type { IAGHeadlessInput } from './AGHeadlessInput';
16
17
 
17
18
  const emit = defineEmits(['update:modelValue']);
18
19
  const props = defineProps({
19
- as: stringProp(),
20
- name: stringProp(),
21
- modelValue: stringProp(),
20
+ as: stringProp('div'),
21
+ modelValue: mixedProp<string | number | boolean>([String, Number, Boolean]),
22
+ ...useInputProps(),
22
23
  });
23
24
  const errors = computed(() => {
24
25
  if (!form || !props.name) {
@@ -27,12 +28,14 @@ const errors = computed(() => {
27
28
 
28
29
  return form.errors[props.name] ?? null;
29
30
  });
30
- const form = inject<Form>('form');
31
- const publicApi: IAGHeadlessInput = {
32
- id: uuid(),
31
+ const form = inject<Form | null>('form', null);
32
+ const api: IAGHeadlessInput = {
33
+ id: `input-${uuid()}`,
34
+ name: computed(() => props.name),
35
+ label: computed(() => props.label),
33
36
  value: computed(() => {
34
37
  if (form && props.name) {
35
- return form.getFieldValue(props.name);
38
+ return form.getFieldValue(props.name) as string | number | boolean | null;
36
39
  }
37
40
 
38
41
  return props.modelValue;
@@ -49,6 +52,6 @@ const publicApi: IAGHeadlessInput = {
49
52
  },
50
53
  };
51
54
 
52
- provide<IAGHeadlessInput>('input', publicApi);
53
- defineExpose<IAGHeadlessInput>(publicApi);
55
+ provide<IAGHeadlessInput>('input', api);
56
+ defineExpose<IAGHeadlessInput>(api);
54
57
  </script>
@@ -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,22 @@
1
+ <template>
2
+ <label v-if="show" :for="input.id">
3
+ <slot>
4
+ {{ input.label }}
5
+ </slot>
6
+ </label>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { computed, useSlots } from 'vue';
11
+
12
+ import { injectReactiveOrFail } from '@/utils/vue';
13
+
14
+ import type { IAGHeadlessInput } from './AGHeadlessInput';
15
+
16
+ const input = injectReactiveOrFail<IAGHeadlessInput>(
17
+ 'input',
18
+ '<AGHeadlessInputLabel> must be a child of a <AGHeadlessInput>',
19
+ );
20
+ const slots = useSlots();
21
+ const show = computed(() => !!(input.label || slots.default));
22
+ </script>
@@ -0,0 +1,42 @@
1
+ import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
2
+ import type { Writable } from '@noeldemartin/utils';
3
+
4
+ import { mixedProp, requiredArrayProp, stringProp } from '@/utils/vue';
5
+ import { extractComponentProps } from '@/components/utils';
6
+ import type { FormFieldValue } from '@/forms/Form';
7
+
8
+ export interface IAGHeadlessSelect {
9
+ id: string;
10
+ label: ComputedRef<string | null>;
11
+ noSelectionText: ComputedRef<string>;
12
+ buttonText: ComputedRef<string>;
13
+ renderText: ComputedRef<(value: FormFieldValue) => string>;
14
+ selectedOption: ComputedRef<FormFieldValue | null>;
15
+ options: ComputedRef<FormFieldValue[]>;
16
+ errors: DeepReadonly<Ref<string[] | null>>;
17
+ update(value: FormFieldValue): void;
18
+ }
19
+
20
+ export const selectProps = {
21
+ name: stringProp(),
22
+ label: stringProp(),
23
+ options: requiredArrayProp<FormFieldValue>(),
24
+ noSelectionText: stringProp(),
25
+ optionsText: mixedProp<string | ((option: FormFieldValue) => string)>(),
26
+ };
27
+
28
+ export const selectEmits = ['update:modelValue'] as const;
29
+
30
+ export function useSelectProps(): typeof selectProps {
31
+ return selectProps;
32
+ }
33
+
34
+ export function useSelectEmits(): Writable<typeof selectEmits> {
35
+ return [...selectEmits];
36
+ }
37
+
38
+ export function extractSelectProps<T extends ExtractPropTypes<typeof selectProps>>(
39
+ props: T,
40
+ ): Pick<T, keyof typeof selectProps> {
41
+ return extractComponentProps(props, selectProps);
42
+ }
@@ -0,0 +1,77 @@
1
+ <template>
2
+ <Listbox
3
+ v-slot="{ value, open, disabled }: ComponentProps"
4
+ :model-value="selectedOption"
5
+ @update:model-value="update($event)"
6
+ >
7
+ <slot :value="value" :open="open" :disabled="disabled" />
8
+ </Listbox>
9
+ </template>
10
+
11
+ <script setup lang="ts">
12
+ import { computed, inject, provide } from 'vue';
13
+ import { toString, uuid } from '@noeldemartin/utils';
14
+ import { Listbox } from '@headlessui/vue';
15
+
16
+ import { mixedProp } from '@/utils/vue';
17
+ import { translateWithDefault } from '@/lang/utils';
18
+ import type Form from '@/forms/Form';
19
+ import type { FormFieldValue } from '@/forms/Form';
20
+ import type { ComponentProps } from '@/utils/vue';
21
+
22
+ import { useSelectEmits, useSelectProps } from './AGHeadlessSelect';
23
+ import type { IAGHeadlessSelect } from './AGHeadlessSelect';
24
+
25
+ const emit = defineEmits(useSelectEmits());
26
+ const props = defineProps({
27
+ modelValue: mixedProp<FormFieldValue>(),
28
+ ...useSelectProps(),
29
+ });
30
+ const renderText = computed(() => {
31
+ if (typeof props.optionsText === 'function') {
32
+ return props.optionsText;
33
+ }
34
+
35
+ if (typeof props.optionsText === 'string') {
36
+ return (option: FormFieldValue): string => toString(option[props.optionsText as keyof FormFieldValue]);
37
+ }
38
+
39
+ return (option: FormFieldValue) => toString(option);
40
+ });
41
+ const form = inject<Form | null>('form', null);
42
+ const noSelectionText = computed(() => props.noSelectionText ?? translateWithDefault('select.noSelection', '-'));
43
+ const selectedOption = computed(() => (form && props.name ? form.getFieldValue(props.name) : props.modelValue));
44
+ const errors = computed(() => {
45
+ if (!form || !props.name) {
46
+ return null;
47
+ }
48
+
49
+ return form.errors[props.name] ?? null;
50
+ });
51
+
52
+ function update(value: FormFieldValue) {
53
+ if (form && props.name) {
54
+ form.setFieldValue(props.name, value);
55
+
56
+ return;
57
+ }
58
+
59
+ emit('update:modelValue', value);
60
+ }
61
+
62
+ const api: IAGHeadlessSelect = {
63
+ id: `select-${uuid()}`,
64
+ noSelectionText,
65
+ selectedOption,
66
+ errors,
67
+ options: computed(() => props.options),
68
+ label: computed(() => props.label),
69
+ buttonText: computed(() =>
70
+ selectedOption.value === null ? noSelectionText.value : renderText.value(selectedOption.value)),
71
+ renderText,
72
+ update,
73
+ };
74
+
75
+ provide<IAGHeadlessSelect>('select', api);
76
+ defineExpose<IAGHeadlessSelect>(api);
77
+ </script>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <ListboxButton v-slot="{ value, open, disabled }: ComponentProps">
3
+ <slot :value="value" :open="open" :disabled="disabled">
4
+ <span :class="textClass">{{ select?.buttonText }}</span>
5
+ </slot>
6
+ <slot name="icon" />
7
+ </ListboxButton>
8
+ </template>
9
+
10
+ <script setup lang="ts">
11
+ import { ListboxButton } from '@headlessui/vue';
12
+
13
+ import { injectReactiveOrFail, stringProp } from '@/utils/vue';
14
+ import type { ComponentProps } from '@/utils/vue';
15
+
16
+ import type { IAGHeadlessSelect } from './AGHeadlessSelect';
17
+
18
+ defineProps({ textClass: stringProp() });
19
+
20
+ const select = injectReactiveOrFail<IAGHeadlessSelect>(
21
+ 'select',
22
+ '<AGHeadlessSelectButton> must be a child of a <AGHeadlessSelect>',
23
+ );
24
+ </script>
@@ -0,0 +1,26 @@
1
+ <template>
2
+ <p v-if="errorMessage" :id="`${select.id}-error`">
3
+ {{ errorMessage }}
4
+ </p>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { computed } from 'vue';
9
+
10
+ import { injectReactiveOrFail } from '@/utils/vue';
11
+ import { translateWithDefault } from '@/lang/utils';
12
+
13
+ import type { IAGHeadlessSelect } from './AGHeadlessSelect';
14
+
15
+ const select = injectReactiveOrFail<IAGHeadlessSelect>(
16
+ 'select',
17
+ '<AGHeadlessSelectError> must be a child of a <AGHeadlessSelect>',
18
+ );
19
+ const errorMessage = computed(() => {
20
+ if (!select.errors) {
21
+ return null;
22
+ }
23
+
24
+ return translateWithDefault(`errors.${select.errors[0]}`, `Error: ${select.errors[0]}`);
25
+ });
26
+ </script>
@@ -0,0 +1,24 @@
1
+ <template>
2
+ <ListboxLabel v-if="show" v-slot="{ open, disabled }: ComponentProps">
3
+ <slot :open="open" :disabled="disabled">
4
+ {{ select.label }}
5
+ </slot>
6
+ </ListboxLabel>
7
+ </template>
8
+
9
+ <script setup lang="ts">
10
+ import { computed, useSlots } from 'vue';
11
+ import { ListboxLabel } from '@headlessui/vue';
12
+
13
+ import { injectReactiveOrFail } from '@/utils/vue';
14
+ import type { ComponentProps } from '@/utils/vue';
15
+
16
+ import type { IAGHeadlessSelect } from './AGHeadlessSelect';
17
+
18
+ const select = injectReactiveOrFail<IAGHeadlessSelect>(
19
+ 'select',
20
+ '<AGHeadlessSelectLabel> must be a child of a <AGHeadlessSelect>',
21
+ );
22
+ const slots = useSlots();
23
+ const show = computed(() => !!(select.label || slots.default));
24
+ </script>
@@ -0,0 +1,4 @@
1
+ export type IAGHeadlessSelectOptionSlotProps = {
2
+ active: boolean;
3
+ selected: boolean;
4
+ };
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <ListboxOption v-slot="{ active, selected, disabled }: ComponentProps" :value="value" as="template">
3
+ <slot :active="active" :selected="selected" :disabled="disabled">
4
+ <li
5
+ :class="{
6
+ [activeClass ?? 'active']: active,
7
+ [inactiveClass ?? 'inactive']: !active,
8
+ [selectedClass ?? 'selected']: selected,
9
+ [unselectedClass ?? 'unselected']: !selected,
10
+ }"
11
+ >
12
+ {{ select.renderText(value) }}
13
+ </li>
14
+ </slot>
15
+ </ListboxOption>
16
+ </template>
17
+
18
+ <script setup lang="ts">
19
+ import { ListboxOption } from '@headlessui/vue';
20
+
21
+ import { injectReactiveOrFail, requiredMixedProp, stringProp } from '@/utils/vue';
22
+ import type { ComponentProps } from '@/utils/vue';
23
+ import type { FormFieldValue } from '@/forms/Form';
24
+
25
+ import type { IAGHeadlessSelect } from './AGHeadlessSelect';
26
+
27
+ defineProps({
28
+ value: requiredMixedProp<FormFieldValue>(),
29
+ selectedClass: stringProp(),
30
+ unselectedClass: stringProp(),
31
+ activeClass: stringProp(),
32
+ inactiveClass: stringProp(),
33
+ });
34
+
35
+ const select = injectReactiveOrFail<IAGHeadlessSelect>(
36
+ 'select',
37
+ '<AGHeadlessSelectOption> must be a child of a <AGHeadlessSelect>',
38
+ );
39
+ </script>
@@ -0,0 +1,3 @@
1
+ import { ListboxOptions } from '@headlessui/vue';
2
+
3
+ export default ListboxOptions;
@@ -1,4 +1,14 @@
1
- import AGHeadlessButton from './AGHeadlessButton.vue';
2
- import AGHeadlessInput from './AGHeadlessInput.vue';
3
-
4
- export { AGHeadlessButton, AGHeadlessInput };
1
+ export * from './AGHeadlessInput';
2
+ export * from './AGHeadlessSelect';
3
+ export * from './AGHeadlessSelectOption';
4
+ export { default as AGHeadlessButton } from './AGHeadlessButton.vue';
5
+ export { default as AGHeadlessInput } from './AGHeadlessInput.vue';
6
+ export { default as AGHeadlessInputError } from './AGHeadlessInputError.vue';
7
+ export { default as AGHeadlessInputInput } from './AGHeadlessInputInput.vue';
8
+ export { default as AGHeadlessInputLabel } from './AGHeadlessInputLabel.vue';
9
+ export { default as AGHeadlessSelect } from './AGHeadlessSelect.vue';
10
+ export { default as AGHeadlessSelectButton } from './AGHeadlessSelectButton.vue';
11
+ export { default as AGHeadlessSelectError } from './AGHeadlessSelectError.vue';
12
+ export { default as AGHeadlessSelectLabel } from './AGHeadlessSelectLabel.vue';
13
+ export { default as AGHeadlessSelectOption } from './AGHeadlessSelectOption.vue';
14
+ export { default as AGHeadlessSelectOptions } from './AGHeadlessSelectOptions';
@@ -1,2 +1,3 @@
1
1
  export * from './forms';
2
2
  export * from './modals';
3
+ export * from './snackbars';
@@ -1,3 +1,8 @@
1
+ import { computed } from 'vue';
2
+ import type { ExtractPropTypes, Ref } from 'vue';
3
+
4
+ import { booleanProp, stringProp } from '@/utils';
5
+ import { extractComponentProps } from '@/components/utils';
1
6
  import type { IAGModal } from '@/components/modals/AGModal';
2
7
 
3
8
  export interface IAGHeadlessModal extends IAGModal {}
@@ -5,3 +10,25 @@ export interface IAGHeadlessModal extends IAGModal {}
5
10
  export interface IAGHeadlessModalDefaultSlotProps {
6
11
  close(result?: unknown): Promise<void>;
7
12
  }
13
+
14
+ export const modalProps = {
15
+ cancellable: booleanProp(true),
16
+ title: stringProp(),
17
+ };
18
+
19
+ export function useModalProps(): typeof modalProps {
20
+ return modalProps;
21
+ }
22
+
23
+ export function extractModalProps<T extends ExtractPropTypes<typeof modalProps>>(
24
+ props: T,
25
+ ): Pick<T, keyof typeof modalProps> {
26
+ return extractComponentProps(props, modalProps);
27
+ }
28
+
29
+ export function useModalExpose($modal: Ref<IAGHeadlessModal | undefined>): IAGModal {
30
+ return {
31
+ close: async () => $modal.value?.close(),
32
+ cancellable: computed(() => !!$modal.value?.cancellable),
33
+ };
34
+ }
@@ -11,19 +11,21 @@ import type { VNode } from 'vue';
11
11
 
12
12
  import Events from '@/services/Events';
13
13
  import { useEvent } from '@/utils/composition/events';
14
- import { booleanProp, injectReactiveOrFail } from '@/utils/vue';
14
+ import { injectReactiveOrFail } from '@/utils/vue';
15
15
  import type { IAGModalContext } from '@/components/modals/AGModalContext';
16
16
 
17
+ import { useModalProps } from './AGHeadlessModal';
17
18
  import type { IAGHeadlessModal, IAGHeadlessModalDefaultSlotProps } from './AGHeadlessModal';
18
19
 
19
- const props = defineProps({
20
- cancellable: booleanProp(true),
21
- });
22
-
20
+ const props = defineProps(useModalProps());
23
21
  const $root = ref<{ $el?: HTMLElement } | null>(null);
24
22
  const hidden = ref(true);
25
23
  const closed = ref(false);
26
- const { modal } = injectReactiveOrFail<IAGModalContext>('modal');
24
+ const { modal } = injectReactiveOrFail<IAGModalContext>(
25
+ 'modal',
26
+ 'could not obtain modal reference from <AGHeadlessModal>, ' +
27
+ 'did you render this component manually? Show it using $ui.openModal() instead',
28
+ );
27
29
 
28
30
  async function hide(): Promise<void> {
29
31
  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>
@@ -1,6 +1,4 @@
1
- import AGHeadlessModal from './AGHeadlessModal.vue';
2
- import AGHeadlessModalPanel from './AGHeadlessModalPanel.vue';
3
- import AGHeadlessModalTitle from './AGHeadlessModalTitle.vue';
4
- import type { IAGHeadlessModal } from './AGHeadlessModal';
5
-
6
- export { AGHeadlessModal, AGHeadlessModalPanel, AGHeadlessModalTitle, IAGHeadlessModal };
1
+ export * from './AGHeadlessModal';
2
+ export { default as AGHeadlessModal } from './AGHeadlessModal.vue';
3
+ export { default as AGHeadlessModalPanel } from './AGHeadlessModalPanel.vue';
4
+ export { default as AGHeadlessModalTitle } from './AGHeadlessModalTitle.vue';
@@ -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,40 @@
1
+ import type { ExtractPropTypes } from 'vue';
2
+ import type { ObjectWithoutEmpty } from '@noeldemartin/utils';
3
+
4
+ import UI from '@/ui/UI';
5
+ import { arrayProp, enumProp, requiredStringProp } from '@/utils/vue';
6
+ import { Colors } from '@/components/constants';
7
+ import { objectWithout } from '@noeldemartin/utils';
8
+
9
+ export { default as AGHeadlessSnackbar } from './AGHeadlessSnackbar.vue';
10
+
11
+ export const SnackbarColors = objectWithout(Colors, ['Primary', 'Clear']);
12
+ export const snackbarProps = {
13
+ id: requiredStringProp(),
14
+ message: requiredStringProp(),
15
+ actions: arrayProp<SnackbarAction>(() => []),
16
+ color: enumProp(SnackbarColors, Colors.Secondary),
17
+ };
18
+
19
+ export interface SnackbarAction {
20
+ text: string;
21
+ dismiss?: boolean;
22
+ handler?(): unknown;
23
+ }
24
+
25
+ export type SnackbarColor = (typeof SnackbarColors)[keyof typeof SnackbarColors];
26
+ export type AGSnackbarProps = ObjectWithoutEmpty<ExtractPropTypes<typeof snackbarProps>>;
27
+
28
+ export function useSnackbarProps(): typeof snackbarProps {
29
+ return snackbarProps;
30
+ }
31
+
32
+ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
33
+ export function useSnackbar(props: ExtractPropTypes<typeof snackbarProps>) {
34
+ function activate(action: SnackbarAction): void {
35
+ action.handler?.();
36
+ action.dismiss && UI.hideSnackbar(props.id);
37
+ }
38
+
39
+ return { activate };
40
+ }
@@ -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
- export * from './basic';
6
+ export * from './constants';
6
7
  export * from './forms';
7
8
  export * from './headless';
9
+ export * from './lib';
8
10
  export * from './modals';
11
+ export * from './snackbars';
@@ -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>