@aerogel/cli 0.0.0-next.c2e6acc000e97a1020c2e232678563c53884dd0e → 0.0.0-next.c33ad773d3eb977461630ff22012d99eeedf46cb

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.
@@ -1,85 +0,0 @@
1
- import { arrayFrom } from '@noeldemartin/utils';
2
-
3
- import Command from '@aerogel/cli/commands/Command';
4
- import File from '@aerogel/cli/lib/File';
5
- import Log from '@aerogel/cli/lib/Log';
6
- import Template from '@aerogel/cli/lib/Template';
7
- import { templatePath } from '@aerogel/cli/lib/utils/paths';
8
- import type { CommandOptions } from '@aerogel/cli/commands/Command';
9
-
10
- export interface Options {
11
- story?: boolean;
12
- }
13
-
14
- export class GenerateOverridesCommand extends Command {
15
-
16
- protected static override command: string = 'generate:overrides';
17
- protected static override description: string = 'Generate AerogelJS component overrides';
18
-
19
- protected static override options: CommandOptions = {
20
- story: {
21
- description: 'Create overrides story using Histoire',
22
- type: 'boolean',
23
- },
24
- };
25
-
26
- private options: Options;
27
-
28
- constructor(options: Options = {}) {
29
- super();
30
-
31
- this.options = options;
32
- }
33
-
34
- protected override async run(): Promise<void> {
35
- this.assertAerogelOrDirectory('src/components');
36
- this.assertHistoireInstalled();
37
-
38
- const files = new Set<string>();
39
-
40
- await this.createComponents(files);
41
- await this.createStory(files);
42
-
43
- const filesList = arrayFrom(files)
44
- .map((file) => `- ${file}`)
45
- .join('\n');
46
-
47
- Log.info(`Overrides created successfully! The following files were created:\n\n${filesList}`);
48
- Log.info('\nRemember to declare your components in main.ts and main.histoire.ts!');
49
- }
50
-
51
- protected assertHistoireInstalled(): void {
52
- if (!this.options.story) {
53
- return;
54
- }
55
-
56
- if (!File.contains('package.json', '"histoire"') && !File.contains('package.json', '"@aerogel/histoire"')) {
57
- Log.fail(`
58
- Histoire is not installed yet! You can install it running:
59
- npx gel install histoire
60
- `);
61
- }
62
- }
63
-
64
- protected async createComponents(files: Set<string>): Promise<void> {
65
- await Log.animate('Creating components', async () => {
66
- if (File.exists('src/components/ModalWrapper.vue')) {
67
- Log.fail('ModalWrapper component already exists!');
68
- }
69
-
70
- Template.instantiate(templatePath('overrides'), 'src').forEach((file) => files.add(file));
71
- });
72
- }
73
-
74
- protected async createStory(files: Set<string>): Promise<void> {
75
- if (!this.options.story) {
76
- return;
77
- }
78
-
79
- await Log.animate('Creating story', async () => {
80
- Template.instantiate(templatePath('overrides-story'), 'src/components/overrides/').forEach((file) =>
81
- files.add(file));
82
- });
83
- }
84
-
85
- }
@@ -1,15 +0,0 @@
1
- import { UIComponents } from '@aerogel/core';
2
-
3
- import AlertModal from './overrides/AlertModal.vue';
4
- import ConfirmModal from './overrides/ConfirmModal.vue';
5
- import ErrorReportModal from './overrides/ErrorReportModal.vue';
6
- import LoadingModal from './overrides/LoadingModal.vue';
7
- import SnackbarNotification from './overrides/SnackbarNotification.vue';
8
-
9
- export const components = {
10
- [UIComponents.AlertModal]: AlertModal,
11
- [UIComponents.ConfirmModal]: ConfirmModal,
12
- [UIComponents.ErrorReportModal]: ErrorReportModal,
13
- [UIComponents.LoadingModal]: LoadingModal,
14
- [UIComponents.Snackbar]: SnackbarNotification,
15
- };
@@ -1,11 +0,0 @@
1
- <template>
2
- <ModalWrapper :title="title">
3
- <Markdown :text="message" />
4
- </ModalWrapper>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { useAlertModalProps } from '@aerogel/core';
9
-
10
- defineProps(useAlertModalProps());
11
- </script>
@@ -1,20 +0,0 @@
1
- <template>
2
- <ModalWrapper v-slot="{ close }" :title="title" persistent>
3
- <Markdown :text="message" :actions="actions" />
4
- <div class="mt-4 flex flex-row-reverse">
5
- <Button :variant="acceptColor" @click="close(true)">
6
- {{ renderedAcceptText }}
7
- </Button>
8
- <Button v-if="!required" :variant="cancelColor" class="mr-2" @click="close(false)">
9
- {{ renderedCancelText }}
10
- </Button>
11
- </div>
12
- </ModalWrapper>
13
- </template>
14
-
15
- <script setup lang="ts">
16
- import { useConfirmModal, useConfirmModalProps } from '@aerogel/core';
17
-
18
- const props = defineProps(useConfirmModalProps());
19
- const { renderedAcceptText, renderedCancelText } = useConfirmModal(props);
20
- </script>
@@ -1,12 +0,0 @@
1
- <template>
2
- <ModalWrapper persistent>
3
- <Markdown :text="renderedMessage" />
4
- </ModalWrapper>
5
- </template>
6
-
7
- <script setup lang="ts">
8
- import { useLoadingModal, useLoadingModalProps } from '@aerogel/core';
9
-
10
- const props = defineProps(useLoadingModalProps());
11
- const { renderedMessage } = useLoadingModal(props);
12
- </script>
@@ -1,22 +0,0 @@
1
- <template>
2
- <AGHeadlessModal ref="$modal" v-slot="{ close }" v-bind="props">
3
- <AGHeadlessModalPanel>
4
- <AGHeadlessModalTitle v-if="title">
5
- <Markdown :text="title" inline />
6
- </AGHeadlessModalTitle>
7
- <slot :close="close" />
8
- </AGHeadlessModalPanel>
9
- </AGHeadlessModal>
10
- </template>
11
-
12
- <script setup lang="ts">
13
- import { ref } from 'vue';
14
- import { modalExpose, modalProps } from '@aerogel/core';
15
- import type { IAGHeadlessModal, IAGModal } from '@aerogel/core';
16
-
17
- const props = defineProps(modalProps());
18
- const $modal = ref<IAGHeadlessModal>();
19
-
20
- defineOptions({ inheritAttrs: false });
21
- defineExpose(modalExpose($modal));
22
- </script>
@@ -1,34 +0,0 @@
1
- <template>
2
- <AGHeadlessSnackbar :class="colorClasses">
3
- <Markdown :text="message" inline />
4
-
5
- <Button
6
- v-for="(action, i) of actions"
7
- :key="i"
8
- :variant="color"
9
- @click="activate(action)"
10
- >
11
- {{ action.text }}
12
- </Button>
13
- </AGHeadlessSnackbar>
14
- </template>
15
-
16
- <script setup lang="ts">
17
- import { computed } from 'vue';
18
- import { Colors, useSnackbar, useSnackbarProps } from '@aerogel/core';
19
-
20
- const props = defineProps(useSnackbarProps());
21
- const { activate } = useSnackbar(props);
22
-
23
- const colorClasses = computed(() => {
24
- switch (props.color) {
25
- case Colors.Danger:
26
- // Add your custom color classes here.
27
- return '';
28
- case Colors.Secondary:
29
- default:
30
- // Add your custom color classes here.
31
- return '';
32
- }
33
- });
34
- </script>
@@ -1,86 +0,0 @@
1
- <template>
2
- <Story :layout="{ type: 'grid', width: '90%' }">
3
- <Variant title="Playground">
4
- <div class="flex space-x-3">
5
- <Button @click="$ui.alert(alertTitle, alertMessage)">
6
- Alert
7
- </Button>
8
- <Button @click="$ui.confirm(confirmTitle, confirmMessage)">
9
- Confirm
10
- </Button>
11
- <Button @click="$ui.loading(loadingMessage, after({ seconds: loadingDuration }))">
12
- Loading
13
- </Button>
14
- <Button @click="$ui.showSnackbar(snackbarMessage, snackbarOptions)">
15
- Snackbar
16
- </Button>
17
- <Button @click="$errors.inspect(errorReports)">
18
- Error Report
19
- </Button>
20
- </div>
21
-
22
- <AppOverlays />
23
-
24
- <template #controls>
25
- <HstText v-model="alertTitle" title="Alert Title" />
26
- <HstText v-model="alertMessage" title="Alert Message" />
27
- <HstText v-model="confirmTitle" title="Confirm Title" />
28
- <HstText v-model="confirmMessage" title="Confirm Message" />
29
- <HstText v-model="loadingMessage" title="Loading Message" />
30
- <HstNumber v-model="loadingDuration" title="Loading Duration" />
31
- <HstText v-model="snackbarMessage" title="Snackbar Message" />
32
- <HstSelect v-model="snackbarColor" title="Snackbar Color" :options="snackbarColors" />
33
- <HstText v-model="snackbarAction" title="Snackbar Action" />
34
- <HstText v-model="errorReportTitle" title="Error Report Title" />
35
- <HstText v-model="errorReportDescription" title="Error Report Description" />
36
- </template>
37
- </Variant>
38
- </Story>
39
- </template>
40
-
41
- <script setup lang="ts">
42
- import { computed, ref } from 'vue';
43
- import { after, invert } from '@noeldemartin/utils';
44
- import { Colors, SnackbarColors } from '@aerogel/core';
45
- import type { ErrorReport, ShowSnackbarOptions } from '@aerogel/core';
46
-
47
- const alertTitle = ref('Something important happened');
48
- const alertMessage = ref('And here you can read the details...');
49
- const confirmTitle = ref('Confirmation');
50
- const confirmMessage = ref('Are you sure?');
51
- const loadingMessage = ref('Loading...');
52
- const loadingDuration = ref(3);
53
- const snackbarMessage = ref('Something happened');
54
- const snackbarColor = ref(Colors.Secondary);
55
- const snackbarColors = invert(SnackbarColors);
56
- const snackbarAction = ref('Ok');
57
- const snackbarOptions = computed((): ShowSnackbarOptions => {
58
- if (!snackbarAction.value) {
59
- return {};
60
- }
61
-
62
- return {
63
- color: snackbarColor.value,
64
- actions: [
65
- {
66
- text: snackbarAction.value,
67
- dismiss: true,
68
- },
69
- ],
70
- };
71
- });
72
- const errorReportTitle = ref('Error');
73
- const errorReportDescription = ref('Something went wrong!');
74
- const errorReports = computed((): ErrorReport[] => [
75
- {
76
- title: errorReportTitle.value,
77
- description: errorReportDescription.value,
78
- details: new Error().stack,
79
- },
80
- {
81
- title: errorReportTitle.value,
82
- description: errorReportDescription.value,
83
- details: new Error().stack,
84
- },
85
- ]);
86
- </script>