@aerogel/core 0.0.0-next.c29ffcd25bffdbed37ecce3aac1ba14cde3e9d39 → 0.0.0-next.c2e6acc000e97a1020c2e232678563c53884dd0e

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 (154) hide show
  1. package/dist/aerogel-core.d.ts +1223 -1792
  2. package/dist/aerogel-core.js +2968 -0
  3. package/dist/aerogel-core.js.map +1 -0
  4. package/package.json +27 -37
  5. package/src/bootstrap/bootstrap.test.ts +4 -7
  6. package/src/bootstrap/index.ts +14 -15
  7. package/src/bootstrap/options.ts +1 -1
  8. package/src/components/{AGAppLayout.vue → AppLayout.vue} +4 -4
  9. package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
  10. package/src/components/{AGAppOverlays.vue → AppOverlays.vue} +5 -5
  11. package/src/components/composition.ts +1 -1
  12. package/src/components/contracts/AlertModal.ts +4 -0
  13. package/src/components/contracts/Button.ts +15 -0
  14. package/src/components/contracts/ConfirmModal.ts +41 -0
  15. package/src/components/contracts/ErrorReportModal.ts +29 -0
  16. package/src/components/contracts/Input.ts +26 -0
  17. package/src/components/contracts/LoadingModal.ts +18 -0
  18. package/src/components/contracts/Modal.ts +9 -0
  19. package/src/components/contracts/PromptModal.ts +28 -0
  20. package/src/components/contracts/index.ts +7 -0
  21. package/src/components/contracts/shared.ts +9 -0
  22. package/src/components/forms/AGSelect.vue +11 -17
  23. package/src/components/forms/index.ts +0 -4
  24. package/src/components/headless/HeadlessButton.vue +45 -0
  25. package/src/components/headless/HeadlessInput.vue +59 -0
  26. package/src/components/headless/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +6 -7
  27. package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
  28. package/src/components/headless/{forms/AGHeadlessInputInput.vue → HeadlessInputInput.vue} +10 -19
  29. package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
  30. package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +6 -9
  31. package/src/components/headless/{modals/AGHeadlessModal.vue → HeadlessModal.vue} +16 -24
  32. package/src/components/headless/HeadlessModalContent.vue +24 -0
  33. package/src/components/headless/HeadlessModalOverlay.vue +12 -0
  34. package/src/components/headless/HeadlessModalTitle.vue +12 -0
  35. package/src/components/headless/forms/AGHeadlessSelect.ts +3 -3
  36. package/src/components/headless/forms/AGHeadlessSelect.vue +16 -16
  37. package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
  38. package/src/components/headless/forms/AGHeadlessSelectOption.vue +10 -18
  39. package/src/components/headless/forms/AGHeadlessSelectOptions.vue +19 -0
  40. package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +25 -0
  41. package/src/components/headless/forms/composition.ts +2 -2
  42. package/src/components/headless/forms/index.ts +2 -12
  43. package/src/components/headless/index.ts +12 -1
  44. package/src/components/headless/snackbars/index.ts +3 -3
  45. package/src/components/index.ts +5 -5
  46. package/src/components/lib/AGErrorMessage.vue +5 -5
  47. package/src/components/lib/AGMeasured.vue +2 -2
  48. package/src/components/lib/AGStartupCrash.vue +8 -8
  49. package/src/components/lib/index.ts +0 -3
  50. package/src/components/snackbars/AGSnackbar.vue +10 -8
  51. package/src/components/ui/AlertModal.vue +13 -0
  52. package/src/components/ui/Button.vue +58 -0
  53. package/src/components/ui/Checkbox.vue +49 -0
  54. package/src/components/ui/ConfirmModal.vue +42 -0
  55. package/src/components/ui/ErrorReportModal.vue +62 -0
  56. package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +29 -20
  57. package/src/components/ui/ErrorReportModalTitle.vue +24 -0
  58. package/src/components/{forms/AGForm.vue → ui/Form.vue} +4 -5
  59. package/src/components/ui/Input.vue +52 -0
  60. package/src/components/ui/Link.vue +12 -0
  61. package/src/components/ui/LoadingModal.vue +32 -0
  62. package/src/components/ui/Markdown.vue +62 -0
  63. package/src/components/ui/Modal.vue +55 -0
  64. package/src/components/{modals/AGModalContext.vue → ui/ModalContext.vue} +7 -9
  65. package/src/components/ui/ProgressBar.vue +50 -0
  66. package/src/components/ui/PromptModal.vue +35 -0
  67. package/src/components/ui/index.ts +16 -0
  68. package/src/components/utils.ts +106 -9
  69. package/src/directives/index.ts +9 -5
  70. package/src/directives/measure.ts +1 -1
  71. package/src/errors/Errors.state.ts +1 -1
  72. package/src/errors/Errors.ts +14 -14
  73. package/src/errors/index.ts +9 -6
  74. package/src/errors/utils.ts +1 -1
  75. package/src/forms/{Form.test.ts → FormController.test.ts} +5 -4
  76. package/src/forms/{Form.ts → FormController.ts} +22 -19
  77. package/src/forms/composition.ts +4 -4
  78. package/src/forms/index.ts +2 -2
  79. package/src/forms/utils.ts +2 -2
  80. package/src/index.css +8 -0
  81. package/src/jobs/Job.ts +2 -2
  82. package/src/lang/DefaultLangProvider.ts +7 -4
  83. package/src/lang/Lang.state.ts +1 -1
  84. package/src/lang/Lang.ts +1 -1
  85. package/src/lang/index.ts +8 -6
  86. package/src/plugins/Plugin.ts +1 -1
  87. package/src/plugins/index.ts +10 -7
  88. package/src/services/App.state.ts +4 -3
  89. package/src/services/App.ts +4 -4
  90. package/src/services/Cache.ts +1 -1
  91. package/src/services/Events.ts +2 -2
  92. package/src/services/Service.ts +21 -21
  93. package/src/services/Storage.ts +3 -3
  94. package/src/services/index.ts +5 -4
  95. package/src/services/utils.ts +2 -2
  96. package/src/testing/index.ts +4 -3
  97. package/src/testing/setup.ts +3 -19
  98. package/src/ui/UI.state.ts +10 -5
  99. package/src/ui/UI.ts +53 -40
  100. package/src/ui/index.ts +16 -16
  101. package/src/utils/composition/events.ts +2 -2
  102. package/src/utils/composition/forms.ts +4 -3
  103. package/src/utils/markdown.ts +3 -5
  104. package/src/utils/vdom.ts +31 -0
  105. package/src/utils/vue.ts +7 -12
  106. package/dist/aerogel-core.cjs.js +0 -2
  107. package/dist/aerogel-core.cjs.js.map +0 -1
  108. package/dist/aerogel-core.esm.js +0 -2
  109. package/dist/aerogel-core.esm.js.map +0 -1
  110. package/histoire.config.ts +0 -7
  111. package/noeldemartin.config.js +0 -5
  112. package/postcss.config.js +0 -6
  113. package/src/assets/histoire.css +0 -3
  114. package/src/components/forms/AGButton.vue +0 -44
  115. package/src/components/forms/AGCheckbox.vue +0 -41
  116. package/src/components/forms/AGInput.vue +0 -40
  117. package/src/components/headless/forms/AGHeadlessButton.ts +0 -3
  118. package/src/components/headless/forms/AGHeadlessButton.vue +0 -62
  119. package/src/components/headless/forms/AGHeadlessInput.ts +0 -34
  120. package/src/components/headless/forms/AGHeadlessInput.vue +0 -70
  121. package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
  122. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
  123. package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
  124. package/src/components/headless/modals/AGHeadlessModal.ts +0 -36
  125. package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -32
  126. package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -23
  127. package/src/components/headless/modals/index.ts +0 -4
  128. package/src/components/interfaces.ts +0 -24
  129. package/src/components/lib/AGLink.vue +0 -9
  130. package/src/components/lib/AGMarkdown.vue +0 -54
  131. package/src/components/lib/AGProgressBar.vue +0 -45
  132. package/src/components/modals/AGAlertModal.ts +0 -18
  133. package/src/components/modals/AGAlertModal.vue +0 -14
  134. package/src/components/modals/AGConfirmModal.ts +0 -42
  135. package/src/components/modals/AGConfirmModal.vue +0 -26
  136. package/src/components/modals/AGErrorReportModal.ts +0 -49
  137. package/src/components/modals/AGErrorReportModal.vue +0 -54
  138. package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
  139. package/src/components/modals/AGLoadingModal.ts +0 -29
  140. package/src/components/modals/AGLoadingModal.vue +0 -15
  141. package/src/components/modals/AGModal.ts +0 -11
  142. package/src/components/modals/AGModal.vue +0 -39
  143. package/src/components/modals/AGModalContext.ts +0 -8
  144. package/src/components/modals/AGModalTitle.vue +0 -9
  145. package/src/components/modals/AGPromptModal.ts +0 -41
  146. package/src/components/modals/AGPromptModal.vue +0 -34
  147. package/src/components/modals/index.ts +0 -17
  148. package/src/directives/initial-focus.ts +0 -11
  149. package/src/main.histoire.ts +0 -1
  150. package/tailwind.config.js +0 -4
  151. package/tsconfig.json +0 -11
  152. package/vite.config.ts +0 -17
  153. /package/src/components/{AGAppSnackbars.vue → AppSnackbars.vue} +0 -0
  154. /package/src/{main.ts → index.ts} +0 -0
@@ -1,44 +0,0 @@
1
- <template>
2
- <AGHeadlessButton class="px-2.5 py-1.5 focus-visible:outline focus-visible:outline-2" :class="colorClasses">
3
- <slot />
4
- </AGHeadlessButton>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from 'vue';
9
-
10
- import { enumProp } from '@/utils/vue';
11
- import { Colors } from '@/components/constants';
12
-
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
- });
44
- </script>
@@ -1,41 +0,0 @@
1
- <template>
2
- <AGHeadlessInput
3
- ref="$input"
4
- :name="name"
5
- class="flex"
6
- @update:model-value="$emit('update:modelValue', $event)"
7
- >
8
- <AGHeadlessInputInput
9
- v-bind="$attrs"
10
- type="checkbox"
11
- :class="{
12
- 'text-indigo-600 focus:ring-indigo-600': !$input?.errors,
13
- 'border-red-200 text-red-600 focus:ring-red-600': $input?.errors,
14
- }"
15
- />
16
-
17
- <div class="ml-2">
18
- <AGHeadlessInputLabel v-if="$slots.default">
19
- <slot />
20
- </AGHeadlessInputLabel>
21
- <AGHeadlessInputError class="text-sm text-red-600" />
22
- </div>
23
- </AGHeadlessInput>
24
- </template>
25
-
26
- <script setup lang="ts">
27
- import { componentRef, stringProp } from '@/utils/vue';
28
-
29
- import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
30
-
31
- import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
32
- import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
33
- import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
34
- import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
35
-
36
- defineProps({ name: stringProp() });
37
- defineOptions({ inheritAttrs: false });
38
- defineEmits(['update:modelValue']);
39
-
40
- const $input = componentRef<IAGHeadlessInput>();
41
- </script>
@@ -1,40 +0,0 @@
1
- <template>
2
- <AGHeadlessInput
3
- ref="$input"
4
- class="relative flex flex-col items-center"
5
- :class="className"
6
- v-bind="props"
7
- >
8
- <AGHeadlessInputLabel class="sr-only" />
9
- <AGHeadlessInputInput
10
- v-bind="attrs"
11
- 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"
12
- :class="{
13
- 'ring-1 ring-red-500': $input?.errors,
14
- }"
15
- />
16
- <AGHeadlessInputDescription />
17
- <div class="absolute bottom-0 left-0 translate-y-full">
18
- <AGHeadlessInputError class="mt-1 text-sm text-red-500" />
19
- </div>
20
- </AGHeadlessInput>
21
- </template>
22
-
23
- <script setup lang="ts">
24
- import { componentRef } from '@/utils/vue';
25
- import { useInputAttrs } from '@/utils/composition/forms';
26
- import { useInputProps } from '@/components/headless/forms/AGHeadlessInput';
27
- import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
28
-
29
- import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
30
- import AGHeadlessInputDescription from '../headless/forms/AGHeadlessInputDescription.vue';
31
- import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
32
- import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
33
- import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
34
-
35
- defineOptions({ inheritAttrs: false });
36
-
37
- const props = defineProps(useInputProps());
38
- const $input = componentRef<IAGHeadlessInput>();
39
- const [attrs, className] = useInputAttrs();
40
- </script>
@@ -1,3 +0,0 @@
1
- import type { HasElement } from '@/components/interfaces';
2
-
3
- export interface IAGHeadlessButton extends HasElement {}
@@ -1,62 +0,0 @@
1
- <template>
2
- <component :is="component.as" ref="$root" v-bind="component.props">
3
- <slot />
4
- </component>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from 'vue';
9
- import { objectWithoutEmpty } from '@noeldemartin/utils';
10
-
11
- import { booleanProp, objectProp, stringProp } from '@/utils/vue';
12
- import { elementRef } from '@/components/composition';
13
-
14
- import type { IAGHeadlessButton } from './AGHeadlessButton';
15
-
16
- const props = defineProps({
17
- as: objectProp(),
18
- href: stringProp(),
19
- url: stringProp(),
20
- route: stringProp(),
21
- routeParams: objectProp(() => ({})),
22
- routeQuery: objectProp(() => ({})),
23
- submit: booleanProp(),
24
- });
25
-
26
- const $root = elementRef();
27
- const component = computed(() => {
28
- if (props.as) {
29
- return { as: props.as, props: {} };
30
- }
31
-
32
- if (props.route) {
33
- return {
34
- as: 'router-link',
35
- props: {
36
- to: objectWithoutEmpty({
37
- name: props.route,
38
- params: props.routeParams,
39
- query: props.routeQuery,
40
- }),
41
- },
42
- };
43
- }
44
-
45
- if (props.href || props.url) {
46
- return {
47
- as: 'a',
48
- props: {
49
- target: '_blank',
50
- href: props.href || props.url,
51
- },
52
- };
53
- }
54
-
55
- return {
56
- as: 'button',
57
- props: { type: props.submit ? 'submit' : 'button' },
58
- };
59
- });
60
-
61
- defineExpose<IAGHeadlessButton>({ $el: $root });
62
- </script>
@@ -1,34 +0,0 @@
1
- import type { ComputedRef, DeepReadonly, ExtractPropTypes, Ref } from 'vue';
2
-
3
- import { mixedProp, stringProp } from '@/utils';
4
- import { extractComponentProps } from '@/components/utils';
5
- import type { FormFieldValue } from '@/forms/Form';
6
- import type { HasElement } from '@/components/interfaces';
7
-
8
- export interface IAGHeadlessInput extends HasElement {
9
- id: string;
10
- name: ComputedRef<string | null>;
11
- label: ComputedRef<string | null>;
12
- description: ComputedRef<string | boolean | null>;
13
- value: ComputedRef<FormFieldValue | null>;
14
- required: ComputedRef<boolean | null>;
15
- errors: DeepReadonly<Ref<string[] | null>>;
16
- update(value: FormFieldValue | null): void;
17
- }
18
-
19
- export const inputProps = {
20
- name: stringProp(),
21
- label: stringProp(),
22
- description: stringProp(),
23
- modelValue: mixedProp<FormFieldValue>([String, Number, Boolean]),
24
- };
25
-
26
- export function useInputProps(): typeof inputProps {
27
- return inputProps;
28
- }
29
-
30
- export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
31
- props: T,
32
- ): Pick<T, keyof typeof inputProps> {
33
- return extractComponentProps(props, inputProps);
34
- }
@@ -1,70 +0,0 @@
1
- <template>
2
- <component :is="as" v-if="as">
3
- <slot />
4
- </component>
5
- <slot v-else />
6
- </template>
7
-
8
- <script setup lang="ts">
9
- import { computed, inject, provide, readonly, ref } from 'vue';
10
- import { uuid } from '@noeldemartin/utils';
11
-
12
- import { stringProp } from '@/utils/vue';
13
- import type Form from '@/forms/Form';
14
- import type { __SetsElement } from '@/components/interfaces';
15
-
16
- import { useInputProps } from './AGHeadlessInput';
17
- import type { IAGHeadlessInput } from './AGHeadlessInput';
18
-
19
- const emit = defineEmits(['update:modelValue']);
20
- const props = defineProps({
21
- as: stringProp('div'),
22
- ...useInputProps(),
23
- });
24
- const $el = ref<HTMLElement>();
25
- const errors = computed(() => {
26
- if (!form || !props.name) {
27
- return null;
28
- }
29
-
30
- return form.errors[props.name] ?? null;
31
- });
32
- const form = inject<Form | null>('form', null);
33
- const api: IAGHeadlessInput & __SetsElement = {
34
- $el,
35
- id: `input-${uuid()}`,
36
- name: computed(() => props.name),
37
- label: computed(() => props.label),
38
- description: computed(() => props.description),
39
- value: computed(() => {
40
- if (form && props.name) {
41
- return form.getFieldValue(props.name);
42
- }
43
-
44
- return props.modelValue;
45
- }),
46
- errors: readonly(errors),
47
- required: computed(() => {
48
- if (!props.name || !form) {
49
- return null;
50
- }
51
-
52
- return form.getFieldRules(props.name).includes('required');
53
- }),
54
- update(value) {
55
- if (form && props.name) {
56
- form.setFieldValue(props.name, value);
57
-
58
- return;
59
- }
60
-
61
- emit('update:modelValue', value);
62
- },
63
- __setElement(element) {
64
- $el.value = element;
65
- },
66
- };
67
-
68
- provide<IAGHeadlessInput>('input', api);
69
- defineExpose<IAGHeadlessInput>(api);
70
- </script>
@@ -1,24 +0,0 @@
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>
@@ -1,24 +0,0 @@
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>
@@ -1,3 +0,0 @@
1
- import { ListboxOptions } from '@headlessui/vue';
2
-
3
- export default ListboxOptions;
@@ -1,36 +0,0 @@
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';
6
- import type { IAGModal } from '@/components/modals/AGModal';
7
-
8
- export interface IAGHeadlessModal extends IAGModal {}
9
-
10
- export interface IAGHeadlessModalDefaultSlotProps {
11
- close(result?: unknown): Promise<void>;
12
- }
13
-
14
- export const modalProps = {
15
- cancellable: booleanProp(true),
16
- inline: booleanProp(),
17
- title: stringProp(),
18
- };
19
-
20
- export function useModalProps(): typeof modalProps {
21
- return modalProps;
22
- }
23
-
24
- export function extractModalProps<T extends ExtractPropTypes<typeof modalProps>>(
25
- props: T,
26
- ): Pick<T, keyof typeof modalProps> {
27
- return extractComponentProps(props, modalProps);
28
- }
29
-
30
- export function useModalExpose($modal: Ref<IAGHeadlessModal | undefined>): IAGModal {
31
- return {
32
- inline: computed(() => !!$modal.value?.inline),
33
- cancellable: computed(() => !!$modal.value?.cancellable),
34
- close: async () => $modal.value?.close(),
35
- };
36
- }
@@ -1,32 +0,0 @@
1
- <template>
2
- <component :is="rootComponent">
3
- <slot />
4
-
5
- <template v-if="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" />
11
- </template>
12
- </component>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import { computed } from 'vue';
17
- import { DialogPanel } from '@headlessui/vue';
18
-
19
- import UI from '@/ui/UI';
20
- import { injectReactiveOrFail } from '@/utils/vue';
21
- import type { IAGModalContext } from '@/components/modals/AGModalContext';
22
-
23
- import AGModalContext from '../../modals/AGModalContext.vue';
24
-
25
- const { modal, childIndex } = injectReactiveOrFail<IAGModalContext>(
26
- 'modal',
27
- 'could not obtain modal reference from <AGHeadlessModalPanel>, ' +
28
- 'did you render this component manually? Show it using $ui.openModal() instead',
29
- );
30
- const rootComponent = computed(() => (modal.properties.inline ? 'div' : DialogPanel));
31
- const childModal = computed(() => UI.modals[childIndex] ?? null);
32
- </script>
@@ -1,23 +0,0 @@
1
- <template>
2
- <component :is="rootComponent" v-bind="rootProps">
3
- <slot />
4
- </component>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { computed } from 'vue';
9
- import { DialogTitle } from '@headlessui/vue';
10
-
11
- import { injectReactiveOrFail, stringProp } from '@/utils/vue';
12
- import type { IAGModalContext } from '@/components/modals/AGModalContext';
13
-
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 }));
23
- </script>
@@ -1,4 +0,0 @@
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';
@@ -1,24 +0,0 @@
1
- import { isObject } from '@noeldemartin/utils';
2
- import type { Ref, UnwrapNestedRefs } from 'vue';
3
-
4
- export function getElement(value: unknown): HTMLElement | undefined {
5
- if (value instanceof HTMLElement) {
6
- return value;
7
- }
8
-
9
- if (hasElement(value)) {
10
- return value.$el;
11
- }
12
- }
13
-
14
- export function hasElement(value: unknown): value is UnwrapNestedRefs<HasElement> {
15
- return isObject(value) && '$el' in value;
16
- }
17
-
18
- export interface __SetsElement {
19
- __setElement(element?: HTMLElement): void;
20
- }
21
-
22
- export interface HasElement {
23
- $el: Readonly<Ref<HTMLElement | undefined>>;
24
- }
@@ -1,9 +0,0 @@
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>
@@ -1,54 +0,0 @@
1
- <template>
2
- <root />
3
- </template>
4
-
5
- <script setup lang="ts">
6
- import { computed, h, useAttrs } from 'vue';
7
- import { isInstanceOf } from '@noeldemartin/utils';
8
-
9
- import { renderMarkdown } from '@/utils/markdown';
10
- import { booleanProp, mixedProp, objectProp, stringProp } from '@/utils/vue';
11
- import { translate } from '@/lang';
12
-
13
- const props = defineProps({
14
- as: stringProp(),
15
- inline: booleanProp(),
16
- langKey: stringProp(),
17
- langParams: mixedProp<number | Record<string, unknown>>(),
18
- text: stringProp(),
19
- actions: objectProp<Record<string, () => unknown>>(),
20
- });
21
-
22
- const attrs = useAttrs();
23
- const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey, props.langParams ?? {})));
24
- const html = computed(() => {
25
- if (!markdown.value) {
26
- return null;
27
- }
28
-
29
- let renderedHtml = renderMarkdown(markdown.value);
30
-
31
- if (props.inline) {
32
- renderedHtml = renderedHtml.replace('<p>', '<span>').replace('</p>', '</span>');
33
- }
34
-
35
- return renderedHtml;
36
- });
37
- const root = () =>
38
- h(props.as ?? (props.inline ? 'span' : 'div'), {
39
- innerHTML: html.value,
40
- onClick,
41
- ...attrs,
42
- class: `${attrs.class ?? ''} ${props.inline ? '' : 'prose'}`,
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
- }
54
- </script>
@@ -1,45 +0,0 @@
1
- <template>
2
- <div class="mt-1 h-2 w-full min-w-[min(400px,80vw)] 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, onMounted, onUnmounted, ref } from 'vue';
16
-
17
- import { numberProp, objectProp, stringProp } from '@/utils/vue';
18
- import type { Job } from '@/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
- onMounted(() => (cleanup = props.job?.listeners.add({ onUpdated: (progress) => (jobProgress.value = progress) })));
44
- onUnmounted(() => cleanup?.());
45
- </script>
@@ -1,18 +0,0 @@
1
- import type { ExtractPropTypes } from 'vue';
2
- import type { ObjectWithout, Pretty } from '@noeldemartin/utils';
3
-
4
- import { requiredStringProp, stringProp } from '@/utils';
5
- import type { AcceptRefs } from '@/utils';
6
-
7
- export const alertModalProps = {
8
- title: stringProp(),
9
- message: requiredStringProp(),
10
- };
11
-
12
- export type AGAlertModalProps = Pretty<
13
- AcceptRefs<ObjectWithout<ExtractPropTypes<typeof alertModalProps>, null | undefined>>
14
- >;
15
-
16
- export function useAlertModalProps(): typeof alertModalProps {
17
- return alertModalProps;
18
- }
@@ -1,14 +0,0 @@
1
- <template>
2
- <AGModal :title="title">
3
- <AGMarkdown :text="message" />
4
- </AGModal>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import AGModal from './AGModal.vue';
9
- import { useAlertModalProps } from './AGAlertModal';
10
-
11
- import AGMarkdown from '../lib/AGMarkdown.vue';
12
-
13
- defineProps(useAlertModalProps());
14
- </script>
@@ -1,42 +0,0 @@
1
- import { computed } from 'vue';
2
- import type { ExtractPropTypes } from 'vue';
3
- import type { ObjectWithout, Pretty, SubPartial } from '@noeldemartin/utils';
4
-
5
- import { Colors } from '@/components/constants';
6
- import { booleanProp, enumProp, objectProp, requiredStringProp, stringProp } from '@/utils';
7
- import { translateWithDefault } from '@/lang';
8
- import type { AcceptRefs } from '@/utils';
9
- import type { ConfirmCheckboxes } from '@/ui';
10
-
11
- export const confirmModalProps = {
12
- title: stringProp(),
13
- message: requiredStringProp(),
14
- acceptText: stringProp(),
15
- acceptColor: enumProp(Colors, Colors.Primary),
16
- cancelText: stringProp(),
17
- cancelColor: enumProp(Colors, Colors.Clear),
18
- checkboxes: objectProp<ConfirmCheckboxes>(),
19
- actions: objectProp<Record<string, () => unknown>>(),
20
- required: booleanProp(false),
21
- };
22
-
23
- export type AGConfirmModalProps = Pretty<
24
- AcceptRefs<
25
- SubPartial<
26
- ObjectWithout<ExtractPropTypes<typeof confirmModalProps>, null | undefined>,
27
- 'acceptColor' | 'cancelColor'
28
- >
29
- >
30
- >;
31
-
32
- export function useConfirmModalProps(): typeof confirmModalProps {
33
- return confirmModalProps;
34
- }
35
-
36
- // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
37
- export function useConfirmModal(props: ExtractPropTypes<typeof confirmModalProps>) {
38
- const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
39
- const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
40
-
41
- return { renderedAcceptText, renderedCancelText };
42
- }