@aerogel/core 0.0.0-next.fd1bd21aea7a9ab8c4eab69a5f5776db5de8bf35 → 0.1.0-next.c4b24f52d8b652bd5c14c2d12e1b38b779ab7682

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 (213) hide show
  1. package/dist/aerogel-core.css +1 -0
  2. package/dist/aerogel-core.d.ts +2263 -1698
  3. package/dist/aerogel-core.js +3809 -0
  4. package/dist/aerogel-core.js.map +1 -0
  5. package/package.json +32 -37
  6. package/src/bootstrap/bootstrap.test.ts +4 -8
  7. package/src/bootstrap/index.ts +25 -16
  8. package/src/bootstrap/options.ts +1 -1
  9. package/src/components/AppLayout.vue +14 -0
  10. package/src/components/{AGAppModals.vue → AppModals.vue} +3 -4
  11. package/src/components/AppOverlays.vue +9 -0
  12. package/src/components/AppToasts.vue +16 -0
  13. package/src/components/contracts/AlertModal.ts +19 -0
  14. package/src/components/contracts/Button.ts +16 -0
  15. package/src/components/contracts/ConfirmModal.ts +48 -0
  16. package/src/components/contracts/DropdownMenu.ts +25 -0
  17. package/src/components/contracts/ErrorReportModal.ts +33 -0
  18. package/src/components/contracts/Input.ts +26 -0
  19. package/src/components/contracts/LoadingModal.ts +26 -0
  20. package/src/components/contracts/Modal.ts +21 -0
  21. package/src/components/contracts/PromptModal.ts +34 -0
  22. package/src/components/contracts/Select.ts +45 -0
  23. package/src/components/contracts/Toast.ts +15 -0
  24. package/src/components/contracts/index.ts +11 -0
  25. package/src/components/headless/HeadlessButton.vue +51 -0
  26. package/src/components/headless/HeadlessInput.vue +59 -0
  27. package/src/components/headless/{forms/AGHeadlessInputDescription.vue → HeadlessInputDescription.vue} +7 -8
  28. package/src/components/headless/{forms/AGHeadlessInputError.vue → HeadlessInputError.vue} +4 -8
  29. package/src/components/headless/HeadlessInputInput.vue +86 -0
  30. package/src/components/headless/{forms/AGHeadlessInputLabel.vue → HeadlessInputLabel.vue} +3 -7
  31. package/src/components/headless/{forms/AGHeadlessInputTextArea.vue → HeadlessInputTextArea.vue} +11 -11
  32. package/src/components/headless/HeadlessModal.vue +57 -0
  33. package/src/components/headless/HeadlessModalContent.vue +30 -0
  34. package/src/components/headless/HeadlessModalDescription.vue +12 -0
  35. package/src/components/headless/HeadlessModalOverlay.vue +12 -0
  36. package/src/components/headless/HeadlessModalTitle.vue +12 -0
  37. package/src/components/headless/HeadlessSelect.vue +120 -0
  38. package/src/components/headless/{forms/AGHeadlessSelectError.vue → HeadlessSelectError.vue} +5 -6
  39. package/src/components/headless/HeadlessSelectLabel.vue +25 -0
  40. package/src/components/headless/HeadlessSelectOption.vue +34 -0
  41. package/src/components/headless/HeadlessSelectOptions.vue +42 -0
  42. package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
  43. package/src/components/headless/HeadlessSelectValue.vue +18 -0
  44. package/src/components/headless/HeadlessSwitch.vue +96 -0
  45. package/src/components/headless/HeadlessToast.vue +18 -0
  46. package/src/components/headless/HeadlessToastAction.vue +13 -0
  47. package/src/components/headless/index.ts +20 -3
  48. package/src/components/index.ts +6 -9
  49. package/src/components/ui/AdvancedOptions.vue +18 -0
  50. package/src/components/ui/AlertModal.vue +17 -0
  51. package/src/components/ui/Button.vue +115 -0
  52. package/src/components/ui/Checkbox.vue +56 -0
  53. package/src/components/ui/ConfirmModal.vue +50 -0
  54. package/src/components/ui/DropdownMenu.vue +32 -0
  55. package/src/components/ui/DropdownMenuOption.vue +22 -0
  56. package/src/components/ui/DropdownMenuOptions.vue +44 -0
  57. package/src/components/ui/EditableContent.vue +82 -0
  58. package/src/components/ui/ErrorLogs.vue +19 -0
  59. package/src/components/ui/ErrorLogsModal.vue +48 -0
  60. package/src/components/ui/ErrorMessage.vue +15 -0
  61. package/src/components/ui/ErrorReportModal.vue +73 -0
  62. package/src/components/{modals/AGErrorReportModalButtons.vue → ui/ErrorReportModalButtons.vue} +34 -27
  63. package/src/components/ui/ErrorReportModalTitle.vue +24 -0
  64. package/src/components/{forms/AGForm.vue → ui/Form.vue} +4 -5
  65. package/src/components/ui/Input.vue +56 -0
  66. package/src/components/ui/Link.vue +12 -0
  67. package/src/components/ui/LoadingModal.vue +34 -0
  68. package/src/components/ui/Markdown.vue +97 -0
  69. package/src/components/ui/Modal.vue +131 -0
  70. package/src/components/ui/ModalContext.vue +31 -0
  71. package/src/components/ui/ProgressBar.vue +51 -0
  72. package/src/components/ui/PromptModal.vue +38 -0
  73. package/src/components/ui/Select.vue +27 -0
  74. package/src/components/ui/SelectLabel.vue +21 -0
  75. package/src/components/ui/SelectOption.vue +29 -0
  76. package/src/components/ui/SelectOptions.vue +35 -0
  77. package/src/components/ui/SelectTrigger.vue +29 -0
  78. package/src/components/ui/Setting.vue +31 -0
  79. package/src/components/ui/SettingsModal.vue +15 -0
  80. package/src/components/ui/StartupCrash.vue +76 -0
  81. package/src/components/ui/Switch.vue +11 -0
  82. package/src/components/ui/TextArea.vue +56 -0
  83. package/src/components/ui/Toast.vue +46 -0
  84. package/src/components/ui/index.ts +35 -0
  85. package/src/directives/index.ts +9 -5
  86. package/src/directives/measure.ts +33 -8
  87. package/src/errors/Errors.state.ts +2 -1
  88. package/src/errors/Errors.ts +56 -33
  89. package/src/errors/JobCancelledError.ts +3 -0
  90. package/src/errors/index.ts +15 -8
  91. package/src/errors/settings/Debug.vue +14 -0
  92. package/src/errors/settings/index.ts +10 -0
  93. package/src/errors/utils.ts +17 -1
  94. package/src/forms/FormController.test.ts +113 -0
  95. package/src/forms/{Form.ts → FormController.ts} +73 -42
  96. package/src/forms/index.ts +3 -3
  97. package/src/forms/utils.ts +65 -24
  98. package/src/forms/validation.ts +50 -0
  99. package/src/index.css +76 -0
  100. package/src/jobs/Job.ts +144 -2
  101. package/src/jobs/index.ts +4 -1
  102. package/src/jobs/listeners.ts +3 -0
  103. package/src/jobs/status.ts +4 -0
  104. package/src/lang/DefaultLangProvider.ts +46 -0
  105. package/src/lang/Lang.state.ts +11 -0
  106. package/src/lang/Lang.ts +48 -21
  107. package/src/lang/index.ts +12 -6
  108. package/src/lang/settings/Language.vue +48 -0
  109. package/src/lang/settings/index.ts +10 -0
  110. package/src/plugins/Plugin.ts +1 -1
  111. package/src/plugins/index.ts +10 -7
  112. package/src/services/App.state.ts +36 -3
  113. package/src/services/App.ts +19 -3
  114. package/src/services/Cache.ts +1 -1
  115. package/src/services/Events.test.ts +8 -8
  116. package/src/services/Events.ts +16 -12
  117. package/src/services/Service.ts +135 -59
  118. package/src/services/Storage.ts +20 -0
  119. package/src/services/index.ts +16 -7
  120. package/src/services/utils.ts +18 -0
  121. package/src/testing/index.ts +8 -3
  122. package/src/testing/setup.ts +11 -0
  123. package/src/ui/UI.state.ts +14 -12
  124. package/src/ui/UI.ts +250 -123
  125. package/src/ui/index.ts +28 -28
  126. package/src/ui/utils.ts +16 -0
  127. package/src/utils/app.ts +7 -0
  128. package/src/utils/classes.ts +41 -0
  129. package/src/utils/composition/events.ts +4 -6
  130. package/src/utils/composition/forms.ts +20 -4
  131. package/src/utils/composition/persistent.test.ts +33 -0
  132. package/src/utils/composition/persistent.ts +11 -0
  133. package/src/utils/composition/state.test.ts +47 -0
  134. package/src/utils/composition/state.ts +33 -0
  135. package/src/utils/index.ts +6 -1
  136. package/src/utils/markdown.test.ts +50 -0
  137. package/src/utils/markdown.ts +53 -6
  138. package/src/utils/types.ts +3 -0
  139. package/src/utils/vue.ts +38 -132
  140. package/dist/aerogel-core.cjs.js +0 -2
  141. package/dist/aerogel-core.cjs.js.map +0 -1
  142. package/dist/aerogel-core.esm.js +0 -2
  143. package/dist/aerogel-core.esm.js.map +0 -1
  144. package/histoire.config.ts +0 -7
  145. package/noeldemartin.config.js +0 -5
  146. package/postcss.config.js +0 -6
  147. package/src/assets/histoire.css +0 -3
  148. package/src/components/AGAppLayout.vue +0 -16
  149. package/src/components/AGAppOverlays.vue +0 -41
  150. package/src/components/AGAppSnackbars.vue +0 -13
  151. package/src/components/constants.ts +0 -8
  152. package/src/components/forms/AGButton.vue +0 -44
  153. package/src/components/forms/AGCheckbox.vue +0 -41
  154. package/src/components/forms/AGInput.vue +0 -40
  155. package/src/components/forms/AGSelect.story.vue +0 -46
  156. package/src/components/forms/AGSelect.vue +0 -60
  157. package/src/components/forms/index.ts +0 -5
  158. package/src/components/headless/forms/AGHeadlessButton.vue +0 -56
  159. package/src/components/headless/forms/AGHeadlessInput.ts +0 -32
  160. package/src/components/headless/forms/AGHeadlessInput.vue +0 -57
  161. package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -81
  162. package/src/components/headless/forms/AGHeadlessSelect.ts +0 -42
  163. package/src/components/headless/forms/AGHeadlessSelect.vue +0 -77
  164. package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
  165. package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
  166. package/src/components/headless/forms/AGHeadlessSelectOption.ts +0 -4
  167. package/src/components/headless/forms/AGHeadlessSelectOption.vue +0 -39
  168. package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
  169. package/src/components/headless/forms/composition.ts +0 -10
  170. package/src/components/headless/forms/index.ts +0 -17
  171. package/src/components/headless/modals/AGHeadlessModal.ts +0 -34
  172. package/src/components/headless/modals/AGHeadlessModal.vue +0 -86
  173. package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
  174. package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
  175. package/src/components/headless/modals/index.ts +0 -4
  176. package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +0 -10
  177. package/src/components/headless/snackbars/index.ts +0 -40
  178. package/src/components/lib/AGErrorMessage.vue +0 -16
  179. package/src/components/lib/AGLink.vue +0 -9
  180. package/src/components/lib/AGMarkdown.vue +0 -41
  181. package/src/components/lib/AGMeasured.vue +0 -15
  182. package/src/components/lib/AGStartupCrash.vue +0 -31
  183. package/src/components/lib/index.ts +0 -5
  184. package/src/components/modals/AGAlertModal.ts +0 -15
  185. package/src/components/modals/AGAlertModal.vue +0 -14
  186. package/src/components/modals/AGConfirmModal.ts +0 -27
  187. package/src/components/modals/AGConfirmModal.vue +0 -26
  188. package/src/components/modals/AGErrorReportModal.ts +0 -46
  189. package/src/components/modals/AGErrorReportModal.vue +0 -54
  190. package/src/components/modals/AGErrorReportModalTitle.vue +0 -25
  191. package/src/components/modals/AGLoadingModal.ts +0 -23
  192. package/src/components/modals/AGLoadingModal.vue +0 -15
  193. package/src/components/modals/AGModal.ts +0 -10
  194. package/src/components/modals/AGModal.vue +0 -39
  195. package/src/components/modals/AGModalContext.ts +0 -8
  196. package/src/components/modals/AGModalContext.vue +0 -22
  197. package/src/components/modals/AGModalTitle.vue +0 -9
  198. package/src/components/modals/AGPromptModal.ts +0 -30
  199. package/src/components/modals/AGPromptModal.vue +0 -34
  200. package/src/components/modals/index.ts +0 -17
  201. package/src/components/snackbars/AGSnackbar.vue +0 -36
  202. package/src/components/snackbars/index.ts +0 -3
  203. package/src/components/utils.ts +0 -10
  204. package/src/directives/initial-focus.ts +0 -11
  205. package/src/forms/Form.test.ts +0 -58
  206. package/src/forms/composition.ts +0 -6
  207. package/src/main.histoire.ts +0 -1
  208. package/src/utils/tailwindcss.test.ts +0 -26
  209. package/src/utils/tailwindcss.ts +0 -7
  210. package/tailwind.config.js +0 -4
  211. package/tsconfig.json +0 -11
  212. package/vite.config.ts +0 -14
  213. /package/src/{main.ts → index.ts} +0 -0
@@ -1,3 +0,0 @@
1
- @tailwind base;
2
- @tailwind components;
3
- @tailwind utilities;
@@ -1,16 +0,0 @@
1
- <template>
2
- <div class="flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
3
- <slot v-if="$errors.hasStartupErrors" name="startup-crash">
4
- <component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
5
- </slot>
6
- <slot v-else />
7
-
8
- <AGAppOverlays />
9
- </div>
10
- </template>
11
-
12
- <script setup lang="ts">
13
- import { UIComponents } from '@/ui/UI';
14
-
15
- import AGAppOverlays from './AGAppOverlays.vue';
16
- </script>
@@ -1,41 +0,0 @@
1
- <template>
2
- <div
3
- id="aerogel-overlays-backdrop"
4
- ref="$backdrop"
5
- class="pointer-events-none fixed inset-0 z-50 bg-black/30 opacity-0"
6
- />
7
- <AGAppModals />
8
- <AGAppSnackbars />
9
- </template>
10
-
11
- <script setup lang="ts">
12
- import { ref } from 'vue';
13
-
14
- import { useEvent } from '@/utils/composition/events';
15
-
16
- import AGAppModals from './AGAppModals.vue';
17
- import AGAppSnackbars from './AGAppSnackbars.vue';
18
-
19
- const $backdrop = ref<HTMLElement | null>(null);
20
- const backdropHidden = ref(true);
21
-
22
- useEvent('show-overlays-backdrop', async () => {
23
- if (!$backdrop.value || !backdropHidden.value) {
24
- return;
25
- }
26
-
27
- backdropHidden.value = false;
28
-
29
- $backdrop.value.classList.remove('opacity-0');
30
- });
31
-
32
- useEvent('hide-overlays-backdrop', async () => {
33
- if (!$backdrop.value || backdropHidden.value) {
34
- return;
35
- }
36
-
37
- backdropHidden.value = true;
38
-
39
- $backdrop.value.classList.add('opacity-0');
40
- });
41
- </script>
@@ -1,13 +0,0 @@
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-end space-y-4">
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>
@@ -1,8 +0,0 @@
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,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,46 +0,0 @@
1
- <template>
2
- <Story>
3
- <div class="h-96">
4
- <AGSelect v-model="bestMugiwara" :label="bestMugiwaraLabel" :options="bestMugiwaraOptions" />
5
- <AGSelect
6
- v-model="bestFood"
7
- :label="bestFoodLabel"
8
- :options="bestFoodOptions"
9
- options-text="name"
10
- />
11
- </div>
12
- </Story>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import { ref } from 'vue';
17
-
18
- import AGSelect from './AGSelect.vue';
19
-
20
- const bestMugiwara = ref(null);
21
- const bestFood = ref(null);
22
- const bestMugiwaraLabel = 'Who\'s the best Mugiwara?';
23
- const bestFoodLabel = 'What\'s the best food?';
24
- const bestMugiwaraOptions = [
25
- 'Monkey D. Luffy',
26
- 'Roronoa Zoro',
27
- 'Nami',
28
- 'Usopp',
29
- 'Sanji',
30
- 'Tony Tony Chopper',
31
- 'Nico Robin',
32
- 'Franky',
33
- 'Brook',
34
- 'Jinbe',
35
- ];
36
- const bestFoodOptions = [
37
- {
38
- id: 'ramen',
39
- name: 'Ramen',
40
- },
41
- {
42
- id: 'pizza',
43
- name: 'Pizza',
44
- },
45
- ];
46
- </script>
@@ -1,60 +0,0 @@
1
- <template>
2
- <AGHeadlessSelect
3
- v-bind="props"
4
- ref="$select"
5
- as="div"
6
- @update:model-value="$emit('update:modelValue', $event)"
7
- >
8
- <AGHeadlessSelectLabel class="block text-sm font-medium leading-6 text-gray-900" />
9
- <div class="relative" :class="{ 'mt-2': $select?.label }">
10
- <AGHeadlessSelectButton
11
- class="relative w-full cursor-default bg-white py-1.5 pl-3 pr-10 text-left text-gray-900 ring-1 ring-inset ring-gray-300 focus:outline-none focus:ring-2 focus:ring-indigo-600"
12
- text-class="block truncate"
13
- :class="{
14
- 'ring-1 ring-red-500': $select?.errors,
15
- }"
16
- >
17
- <template #icon>
18
- <span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
19
- <IconCheveronDown class="h-5 w-5 text-gray-400" />
20
- </span>
21
- </template>
22
- </AGHeadlessSelectButton>
23
- <AGHeadlessSelectOptions
24
- class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border bg-white py-1 text-base ring-1 ring-black ring-opacity-5 focus:outline-none"
25
- >
26
- <AGHeadlessSelectOption
27
- v-for="(option, index) in $select?.options ?? []"
28
- :key="index"
29
- :value="option"
30
- class="relative block cursor-default select-none truncate py-2 pl-3 pr-9"
31
- selected-class="font-semibold"
32
- unselected-class="font-normal"
33
- active-class="bg-indigo-600 text-white"
34
- inactive-class="text-gray-900"
35
- />
36
- </AGHeadlessSelectOptions>
37
- </div>
38
- <AGHeadlessSelectError class="mt-2 text-sm text-red-600" />
39
- </AGHeadlessSelect>
40
- </template>
41
-
42
- <script setup lang="ts">
43
- import IconCheveronDown from '~icons/zondicons/cheveron-down';
44
-
45
- import { componentRef } from '@/utils/vue';
46
- import { useSelectEmits, useSelectProps } from '@/components/headless/forms/AGHeadlessSelect';
47
- import type { IAGHeadlessSelect } from '@/components/headless/forms/AGHeadlessSelect';
48
-
49
- import AGHeadlessSelect from '../headless/forms/AGHeadlessSelect.vue';
50
- import AGHeadlessSelectButton from '../headless/forms/AGHeadlessSelectButton.vue';
51
- import AGHeadlessSelectError from '../headless/forms/AGHeadlessSelectError.vue';
52
- import AGHeadlessSelectLabel from '../headless/forms/AGHeadlessSelectLabel.vue';
53
- import AGHeadlessSelectOption from '../headless/forms/AGHeadlessSelectOption.vue';
54
- import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions';
55
-
56
- defineEmits(useSelectEmits());
57
-
58
- const props = defineProps(useSelectProps());
59
- const $select = componentRef<IAGHeadlessSelect>();
60
- </script>
@@ -1,5 +0,0 @@
1
- export { default as AGButton } from './AGButton.vue';
2
- export { default as AGCheckbox } from './AGCheckbox.vue';
3
- export { default as AGForm } from './AGForm.vue';
4
- export { default as AGInput } from './AGInput.vue';
5
- export { default as AGSelect } from './AGSelect.vue';
@@ -1,56 +0,0 @@
1
- <template>
2
- <component :is="component.as" 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
-
13
- const props = defineProps({
14
- as: objectProp(),
15
- href: stringProp(),
16
- url: stringProp(),
17
- route: stringProp(),
18
- routeParams: objectProp(() => ({})),
19
- routeQuery: objectProp(() => ({})),
20
- submit: booleanProp(),
21
- });
22
-
23
- const component = computed(() => {
24
- if (props.as) {
25
- return { as: props.as, props: {} };
26
- }
27
-
28
- if (props.route) {
29
- return {
30
- as: 'router-link',
31
- props: {
32
- to: objectWithoutEmpty({
33
- name: props.route,
34
- params: props.routeParams,
35
- query: props.routeQuery,
36
- }),
37
- },
38
- };
39
- }
40
-
41
- if (props.href || props.url) {
42
- return {
43
- as: 'a',
44
- props: {
45
- target: '_blank',
46
- href: props.href || props.url,
47
- },
48
- };
49
- }
50
-
51
- return {
52
- as: 'button',
53
- props: { type: props.submit ? 'submit' : 'button' },
54
- };
55
- });
56
- </script>
@@ -1,32 +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
-
7
- export interface IAGHeadlessInput {
8
- id: string;
9
- name: ComputedRef<string | null>;
10
- label: ComputedRef<string | null>;
11
- description: ComputedRef<string | boolean | null>;
12
- value: ComputedRef<FormFieldValue | null>;
13
- errors: DeepReadonly<Ref<string[] | null>>;
14
- update(value: FormFieldValue | null): void;
15
- }
16
-
17
- export const inputProps = {
18
- name: stringProp(),
19
- label: stringProp(),
20
- description: stringProp(),
21
- modelValue: mixedProp<FormFieldValue>([String, Number, Boolean]),
22
- };
23
-
24
- export function useInputProps(): typeof inputProps {
25
- return inputProps;
26
- }
27
-
28
- export function extractInputProps<T extends ExtractPropTypes<typeof inputProps>>(
29
- props: T,
30
- ): Pick<T, keyof typeof inputProps> {
31
- return extractComponentProps(props, inputProps);
32
- }
@@ -1,57 +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 } from 'vue';
10
- import { uuid } from '@noeldemartin/utils';
11
-
12
- import { stringProp } from '@/utils/vue';
13
- import type Form from '@/forms/Form';
14
-
15
- import { useInputProps } from './AGHeadlessInput';
16
- import type { IAGHeadlessInput } from './AGHeadlessInput';
17
-
18
- const emit = defineEmits(['update:modelValue']);
19
- const props = defineProps({
20
- as: stringProp('div'),
21
- ...useInputProps(),
22
- });
23
- const errors = computed(() => {
24
- if (!form || !props.name) {
25
- return null;
26
- }
27
-
28
- return form.errors[props.name] ?? null;
29
- });
30
- const form = inject<Form | null>('form', null);
31
- const api: IAGHeadlessInput = {
32
- id: `input-${uuid()}`,
33
- name: computed(() => props.name),
34
- label: computed(() => props.label),
35
- description: computed(() => props.description),
36
- value: computed(() => {
37
- if (form && props.name) {
38
- return form.getFieldValue(props.name);
39
- }
40
-
41
- return props.modelValue;
42
- }),
43
- errors: readonly(errors),
44
- update(value) {
45
- if (form && props.name) {
46
- form.setFieldValue(props.name, value);
47
-
48
- return;
49
- }
50
-
51
- emit('update:modelValue', value);
52
- },
53
- };
54
-
55
- provide<IAGHeadlessInput>('input', api);
56
- defineExpose<IAGHeadlessInput>(api);
57
- </script>
@@ -1,81 +0,0 @@
1
- <template>
2
- <input
3
- :id="input.id"
4
- ref="$input"
5
- :name="name"
6
- :type="type"
7
- :aria-invalid="input.errors ? 'true' : 'false'"
8
- :aria-describedby="
9
- input.errors ? `${input.id}-error` : input.description ? `${input.id}-description` : undefined
10
- "
11
- :checked="checked"
12
- @input="update"
13
- >
14
- </template>
15
-
16
- <script setup lang="ts">
17
- import { computed, ref, watchEffect } from 'vue';
18
-
19
- import { injectReactiveOrFail, stringProp } from '@/utils';
20
- import type { IAGHeadlessInput } from '@/components/headless/forms/AGHeadlessInput';
21
- import type { FormFieldValue } from '@/forms/Form';
22
-
23
- import { onFormFocus } from './composition';
24
-
25
- const props = defineProps({
26
- type: stringProp('text'),
27
- });
28
-
29
- const $input = ref<HTMLInputElement>();
30
- const input = injectReactiveOrFail<IAGHeadlessInput>(
31
- 'input',
32
- '<AGHeadlessInputInput> must be a child of a <AGHeadlessInput>',
33
- );
34
- const name = computed(() => input.name ?? undefined);
35
- const value = computed(() => input.value);
36
- const checked = computed(() => {
37
- if (props.type !== 'checkbox') {
38
- return;
39
- }
40
-
41
- return !!value.value;
42
- });
43
-
44
- function update() {
45
- if (!$input.value) {
46
- return;
47
- }
48
-
49
- input.update(getValue());
50
- }
51
-
52
- function getValue(): FormFieldValue | null {
53
- if (!$input.value) {
54
- return null;
55
- }
56
-
57
- switch (props.type) {
58
- case 'checkbox':
59
- return $input.value.checked;
60
- case 'date':
61
- return $input.value.valueAsDate;
62
- default:
63
- return $input.value.value;
64
- }
65
- }
66
-
67
- onFormFocus(input, () => $input.value?.focus());
68
- watchEffect(() => {
69
- if (!$input.value) {
70
- return;
71
- }
72
-
73
- if (props.type === 'date') {
74
- $input.value.valueAsDate = value.value as Date;
75
-
76
- return;
77
- }
78
-
79
- $input.value.value = value.value as string;
80
- });
81
- </script>
@@ -1,42 +0,0 @@
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
- }
@@ -1,77 +0,0 @@
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>