@aerogel/core 0.0.0-next.7f6ed5a1f91688a86bf5ede2adc465e4fd6cfdea → 0.0.0-next.8323c60b905020dcb3bd9d4b0bc8d9b6529e1082
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.
- package/dist/aerogel-core.css +1 -0
- package/dist/aerogel-core.d.ts +2547 -422
- package/dist/aerogel-core.js +3722 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +39 -37
- package/src/bootstrap/bootstrap.test.ts +7 -66
- package/src/bootstrap/index.ts +46 -33
- package/src/bootstrap/options.ts +8 -1
- package/src/components/AppLayout.vue +14 -0
- package/src/components/AppModals.vue +14 -0
- package/src/components/AppOverlays.vue +9 -0
- package/src/components/AppToasts.vue +16 -0
- package/src/components/contracts/AlertModal.ts +19 -0
- package/src/components/contracts/Button.ts +16 -0
- package/src/components/contracts/ConfirmModal.ts +48 -0
- package/src/components/contracts/DropdownMenu.ts +25 -0
- package/src/components/contracts/ErrorReportModal.ts +33 -0
- package/src/components/contracts/Input.ts +26 -0
- package/src/components/contracts/LoadingModal.ts +26 -0
- package/src/components/contracts/Modal.ts +21 -0
- package/src/components/contracts/PromptModal.ts +34 -0
- package/src/components/contracts/Select.ts +45 -0
- package/src/components/contracts/Toast.ts +15 -0
- package/src/components/contracts/index.ts +11 -0
- package/src/components/headless/HeadlessButton.vue +51 -0
- package/src/components/headless/HeadlessInput.vue +59 -0
- package/src/components/headless/HeadlessInputDescription.vue +27 -0
- package/src/components/headless/HeadlessInputError.vue +22 -0
- package/src/components/headless/HeadlessInputInput.vue +86 -0
- package/src/components/headless/HeadlessInputLabel.vue +18 -0
- package/src/components/headless/HeadlessInputTextArea.vue +40 -0
- package/src/components/headless/HeadlessModal.vue +57 -0
- package/src/components/headless/HeadlessModalContent.vue +30 -0
- package/src/components/headless/HeadlessModalDescription.vue +12 -0
- package/src/components/headless/HeadlessModalOverlay.vue +12 -0
- package/src/components/headless/HeadlessModalTitle.vue +12 -0
- package/src/components/headless/HeadlessSelect.vue +120 -0
- package/src/components/headless/HeadlessSelectError.vue +25 -0
- package/src/components/headless/HeadlessSelectLabel.vue +25 -0
- package/src/components/headless/HeadlessSelectOption.vue +34 -0
- package/src/components/headless/HeadlessSelectOptions.vue +42 -0
- package/src/components/headless/HeadlessSelectTrigger.vue +22 -0
- package/src/components/headless/HeadlessSelectValue.vue +18 -0
- package/src/components/headless/HeadlessSwitch.vue +96 -0
- package/src/components/headless/HeadlessToast.vue +18 -0
- package/src/components/headless/HeadlessToastAction.vue +13 -0
- package/src/components/headless/index.ts +20 -2
- package/src/components/index.ts +6 -6
- package/src/components/ui/AdvancedOptions.vue +18 -0
- package/src/components/ui/AlertModal.vue +17 -0
- package/src/components/ui/Button.vue +115 -0
- package/src/components/ui/Checkbox.vue +56 -0
- package/src/components/ui/ConfirmModal.vue +50 -0
- package/src/components/ui/DropdownMenu.vue +32 -0
- package/src/components/ui/DropdownMenuOption.vue +22 -0
- package/src/components/ui/DropdownMenuOptions.vue +44 -0
- package/src/components/ui/EditableContent.vue +82 -0
- package/src/components/ui/ErrorLogs.vue +19 -0
- package/src/components/ui/ErrorLogsModal.vue +48 -0
- package/src/components/ui/ErrorMessage.vue +15 -0
- package/src/components/ui/ErrorReportModal.vue +73 -0
- package/src/components/ui/ErrorReportModalButtons.vue +118 -0
- package/src/components/ui/ErrorReportModalTitle.vue +24 -0
- package/src/components/ui/Form.vue +24 -0
- package/src/components/ui/Input.vue +56 -0
- package/src/components/ui/Link.vue +12 -0
- package/src/components/ui/LoadingModal.vue +34 -0
- package/src/components/ui/Markdown.vue +97 -0
- package/src/components/ui/Modal.vue +131 -0
- package/src/components/ui/ModalContext.vue +31 -0
- package/src/components/ui/ProgressBar.vue +51 -0
- package/src/components/ui/PromptModal.vue +38 -0
- package/src/components/ui/Select.vue +27 -0
- package/src/components/ui/SelectLabel.vue +21 -0
- package/src/components/ui/SelectOption.vue +29 -0
- package/src/components/ui/SelectOptions.vue +35 -0
- package/src/components/ui/SelectTrigger.vue +29 -0
- package/src/components/ui/Setting.vue +31 -0
- package/src/components/ui/SettingsModal.vue +15 -0
- package/src/components/ui/StartupCrash.vue +31 -0
- package/src/components/ui/Switch.vue +11 -0
- package/src/components/ui/TextArea.vue +56 -0
- package/src/components/ui/Toast.vue +46 -0
- package/src/components/ui/index.ts +35 -0
- package/src/directives/index.ts +29 -6
- package/src/directives/measure.ts +46 -0
- package/src/errors/Errors.state.ts +31 -0
- package/src/errors/Errors.ts +200 -0
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +53 -0
- package/src/errors/settings/Debug.vue +32 -0
- package/src/errors/settings/index.ts +10 -0
- package/src/errors/utils.ts +35 -0
- package/src/forms/FormController.test.ts +113 -0
- package/src/forms/FormController.ts +255 -0
- package/src/forms/index.ts +3 -2
- package/src/forms/utils.ts +87 -14
- package/src/forms/validation.ts +50 -0
- package/src/index.css +76 -0
- package/src/{main.ts → index.ts} +5 -0
- package/src/jobs/Job.ts +147 -0
- package/src/jobs/index.ts +10 -0
- package/src/jobs/listeners.ts +3 -0
- package/src/jobs/status.ts +4 -0
- package/src/lang/DefaultLangProvider.ts +46 -0
- package/src/lang/Lang.state.ts +11 -0
- package/src/lang/Lang.ts +63 -9
- package/src/lang/index.ts +22 -75
- package/src/lang/settings/Language.vue +48 -0
- package/src/lang/settings/index.ts +10 -0
- package/src/lang/utils.ts +4 -0
- package/src/plugins/Plugin.ts +8 -0
- package/src/plugins/index.ts +29 -0
- package/src/services/App.state.ts +50 -0
- package/src/services/App.ts +63 -0
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +110 -36
- package/src/services/Service.ts +273 -35
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +45 -8
- package/src/services/store.ts +30 -0
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +30 -0
- package/src/testing/setup.ts +11 -0
- package/src/types/vite.d.ts +0 -2
- package/src/ui/UI.state.ts +21 -13
- package/src/ui/UI.ts +350 -53
- package/src/ui/index.ts +40 -25
- package/src/ui/utils.ts +16 -0
- package/src/utils/app.ts +7 -0
- package/src/utils/classes.ts +41 -0
- package/src/utils/composition/events.ts +4 -5
- package/src/utils/composition/forms.ts +27 -0
- package/src/utils/composition/hooks.ts +9 -0
- package/src/utils/composition/persistent.test.ts +33 -0
- package/src/utils/composition/persistent.ts +11 -0
- package/src/utils/composition/state.test.ts +47 -0
- package/src/utils/composition/state.ts +33 -0
- package/src/utils/index.ts +9 -0
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +60 -4
- package/src/utils/types.ts +3 -0
- package/src/utils/vue.ts +38 -121
- package/.eslintrc.js +0 -3
- package/dist/aerogel-core.cjs.js +0 -2
- package/dist/aerogel-core.cjs.js.map +0 -1
- package/dist/aerogel-core.esm.js +0 -2
- package/dist/aerogel-core.esm.js.map +0 -1
- package/noeldemartin.config.js +0 -2
- package/src/bootstrap/hooks.ts +0 -19
- package/src/components/AGAppLayout.vue +0 -11
- package/src/components/AGAppOverlays.vue +0 -39
- package/src/components/basic/AGMarkdown.vue +0 -20
- package/src/components/basic/index.ts +0 -3
- package/src/components/forms/AGButton.vue +0 -11
- package/src/components/forms/AGForm.vue +0 -26
- package/src/components/forms/AGInput.vue +0 -32
- package/src/components/forms/index.ts +0 -5
- package/src/components/headless/forms/AGHeadlessButton.vue +0 -51
- package/src/components/headless/forms/AGHeadlessInput.ts +0 -8
- package/src/components/headless/forms/AGHeadlessInput.vue +0 -54
- package/src/components/headless/forms/AGHeadlessInputError.vue +0 -22
- package/src/components/headless/forms/AGHeadlessInputInput.vue +0 -29
- package/src/components/headless/forms/index.ts +0 -4
- package/src/components/headless/modals/AGHeadlessModal.ts +0 -7
- package/src/components/headless/modals/AGHeadlessModal.vue +0 -84
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -20
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/headless/modals/index.ts +0 -6
- package/src/components/modals/AGAlertModal.vue +0 -15
- package/src/components/modals/AGModal.ts +0 -6
- package/src/components/modals/AGModal.vue +0 -18
- package/src/components/modals/AGModalContext.ts +0 -8
- package/src/components/modals/AGModalContext.vue +0 -22
- package/src/components/modals/index.ts +0 -5
- package/src/directives/initial-focus.ts +0 -11
- package/src/forms/Form.test.ts +0 -37
- package/src/forms/Form.ts +0 -154
- package/src/forms/composition.ts +0 -6
- package/src/lang/helpers.ts +0 -5
- package/src/models/index.ts +0 -18
- package/src/routing/index.ts +0 -33
- package/src/testing/stubs/lang/en.yaml +0 -1
- package/src/testing/stubs/models/User.ts +0 -3
- package/tsconfig.json +0 -19
- package/vite.config.ts +0 -17
package/package.json
CHANGED
|
@@ -1,49 +1,51 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aerogel/core",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"main": "dist/aerogel-core.cjs.js",
|
|
6
|
-
"module": "dist/aerogel-core.esm.js",
|
|
7
|
-
"types": "dist/aerogel-core.d.ts",
|
|
3
|
+
"version": "0.0.0-next.8323c60b905020dcb3bd9d4b0bc8d9b6529e1082",
|
|
4
|
+
"type": "module",
|
|
8
5
|
"sideEffects": false,
|
|
9
|
-
"
|
|
10
|
-
"
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"lint": "noeldemartin-lint src",
|
|
14
|
-
"publish-next": "noeldemartin-publish-next",
|
|
15
|
-
"test": "vitest --run"
|
|
16
|
-
},
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=18.x"
|
|
6
|
+
"exports": {
|
|
7
|
+
"types": "./dist/aerogel-core.d.ts",
|
|
8
|
+
"style": "./src/index.css",
|
|
9
|
+
"default": "./dist/aerogel-core.js"
|
|
19
10
|
},
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
},
|
|
24
|
-
"keywords": [
|
|
25
|
-
"javascript",
|
|
26
|
-
"framework",
|
|
27
|
-
"solid"
|
|
11
|
+
"files": [
|
|
12
|
+
"src",
|
|
13
|
+
"dist"
|
|
28
14
|
],
|
|
29
|
-
"author": "Noel De Martin",
|
|
30
15
|
"license": "MIT",
|
|
31
|
-
"
|
|
32
|
-
|
|
16
|
+
"author": "Noel De Martin",
|
|
17
|
+
"repository": "github:NoelDeMartin/aerogel",
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "vite build && ./scripts/fix-types.sh",
|
|
20
|
+
"lint": "noeldemartin-lint src",
|
|
21
|
+
"test": "vitest --run",
|
|
22
|
+
"test:ci": "vitest --run --reporter verbose",
|
|
23
|
+
"verify": "noeldemartin-verify"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@tailwindcss/forms": "^0.5.10",
|
|
27
|
+
"@tailwindcss/typography": "^0.5.16",
|
|
28
|
+
"tailwindcss": "^4.1.4",
|
|
29
|
+
"vue": "^3.5.0"
|
|
33
30
|
},
|
|
34
31
|
"dependencies": {
|
|
35
|
-
"@
|
|
36
|
-
"
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
32
|
+
"@noeldemartin/utils": "0.7.0-next.31cf84b4b57092d146528f27579439783aca71bb",
|
|
33
|
+
"class-variance-authority": "^0.7.1",
|
|
34
|
+
"clsx": "^2.1.1",
|
|
35
|
+
"dompurify": "^3.2.4",
|
|
36
|
+
"eruda": "^3.4.1",
|
|
37
|
+
"marked": "^15.0.7",
|
|
38
|
+
"pinia": "^2.1.6",
|
|
39
|
+
"reka-ui": "^2.2.0",
|
|
40
|
+
"tailwind-merge": "^3.1.0",
|
|
41
|
+
"vue-component-type-helpers": "^2.2.8"
|
|
43
42
|
},
|
|
44
43
|
"devDependencies": {
|
|
45
|
-
"@
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
"@aerogel/vite": "*"
|
|
45
|
+
},
|
|
46
|
+
"eslintConfig": {
|
|
47
|
+
"extends": [
|
|
48
|
+
"@noeldemartin/eslint-config-vue"
|
|
49
|
+
]
|
|
48
50
|
}
|
|
49
51
|
}
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import { createApp } from 'vue';
|
|
3
|
-
import {
|
|
4
|
-
import { IndexedDBEngine, requireBootedModel, requireEngine } from 'soukai';
|
|
5
|
-
import { mock } from '@noeldemartin/utils';
|
|
3
|
+
import { mock } from '@noeldemartin/testing';
|
|
6
4
|
import type { Component } from 'vue';
|
|
7
5
|
|
|
8
|
-
import Events from '
|
|
9
|
-
import
|
|
10
|
-
import User from '@/testing/stubs/models/User';
|
|
6
|
+
import Events from '@aerogel/core/services/Events';
|
|
7
|
+
import measure from '@aerogel/core/directives/measure';
|
|
11
8
|
|
|
12
|
-
import {
|
|
9
|
+
import { bootstrap } from './index';
|
|
13
10
|
|
|
14
11
|
describe('Aerogel', () => {
|
|
15
12
|
|
|
@@ -29,65 +26,12 @@ describe('Aerogel', () => {
|
|
|
29
26
|
});
|
|
30
27
|
});
|
|
31
28
|
|
|
32
|
-
it('Initializes Soukai', async () => {
|
|
33
|
-
// Arrange
|
|
34
|
-
const rootComponent = mock<Component>();
|
|
35
|
-
|
|
36
|
-
// Act
|
|
37
|
-
await bootstrapApplication(rootComponent, {
|
|
38
|
-
models: import.meta.glob('@/testing/stubs/models/*', { eager: true }),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Assert
|
|
42
|
-
expect(requireBootedModel('User')).toEqual(User);
|
|
43
|
-
expect(requireEngine()).toBeInstanceOf(IndexedDBEngine);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('Initializes routes', async () => {
|
|
47
|
-
// Arrange
|
|
48
|
-
vi.mock('vue-router', () => ({
|
|
49
|
-
createRouter: vi.fn(() => ({ routerMock: true })),
|
|
50
|
-
createWebHistory: vi.fn(),
|
|
51
|
-
}));
|
|
52
|
-
|
|
53
|
-
const rootComponent = mock<Component>();
|
|
54
|
-
|
|
55
|
-
// Act
|
|
56
|
-
await bootstrapApplication(rootComponent, {
|
|
57
|
-
routes: [],
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
// Assert
|
|
61
|
-
expect(vi.mocked(createApp).mock.results[0]?.value.use).toHaveBeenCalledWith({ routerMock: true });
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('Initializes lang', async () => {
|
|
65
|
-
// Arrange
|
|
66
|
-
vi.mock('vue-i18n', () => ({ createI18n: vi.fn(() => ({ i18nMock: true })) }));
|
|
67
|
-
|
|
68
|
-
const rootComponent = mock<Component>();
|
|
69
|
-
|
|
70
|
-
// Act
|
|
71
|
-
await bootstrapApplication(rootComponent, {
|
|
72
|
-
langMessages: import.meta.glob('@/testing/stubs/lang/*'),
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
// Assert
|
|
76
|
-
const mockedCreateI18n = vi.mocked(createI18n);
|
|
77
|
-
const mockedCreateApp = vi.mocked(createApp);
|
|
78
|
-
|
|
79
|
-
expect(mockedCreateI18n).toHaveBeenCalled();
|
|
80
|
-
expect(mockedCreateI18n.mock.calls[0]?.[0].messages).key('en').to.exist;
|
|
81
|
-
expect(mockedCreateI18n.mock.calls[0]?.[0].messages?.['en']).key('foo').to.exist;
|
|
82
|
-
expect(mockedCreateApp.mock.results[0]?.value.use).toHaveBeenCalledWith({ i18nMock: true });
|
|
83
|
-
});
|
|
84
|
-
|
|
85
29
|
it('Boots services', async () => {
|
|
86
30
|
// Arrange
|
|
87
31
|
const rootComponent = mock<Component>();
|
|
88
32
|
|
|
89
33
|
// Act
|
|
90
|
-
await
|
|
34
|
+
await bootstrap(rootComponent);
|
|
91
35
|
|
|
92
36
|
// Assert
|
|
93
37
|
const globals = vi.mocked(createApp).mock.results[0]?.value.config.globalProperties;
|
|
@@ -101,13 +45,10 @@ describe('Aerogel', () => {
|
|
|
101
45
|
const rootComponent = mock<Component>();
|
|
102
46
|
|
|
103
47
|
// Act
|
|
104
|
-
await
|
|
48
|
+
await bootstrap(rootComponent);
|
|
105
49
|
|
|
106
50
|
// Assert
|
|
107
|
-
expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith(
|
|
108
|
-
'initial-focus',
|
|
109
|
-
initialFocus,
|
|
110
|
-
);
|
|
51
|
+
expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith('measure', measure);
|
|
111
52
|
});
|
|
112
53
|
|
|
113
54
|
});
|
package/src/bootstrap/index.ts
CHANGED
|
@@ -1,36 +1,49 @@
|
|
|
1
|
-
import { createApp
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { createApp } from 'vue';
|
|
2
|
+
import { isDevelopment } from '@noeldemartin/utils';
|
|
3
|
+
import type { App as AppInstance, Component } from 'vue';
|
|
4
|
+
|
|
5
|
+
import App from '@aerogel/core/services/App';
|
|
6
|
+
import directives from '@aerogel/core/directives';
|
|
7
|
+
import errors from '@aerogel/core/errors';
|
|
8
|
+
import Events from '@aerogel/core/services/Events';
|
|
9
|
+
import lang from '@aerogel/core/lang';
|
|
10
|
+
import services from '@aerogel/core/services';
|
|
11
|
+
import testing from '@aerogel/core/testing';
|
|
12
|
+
import ui from '@aerogel/core/ui';
|
|
13
|
+
import { installPlugins } from '@aerogel/core/plugins';
|
|
14
|
+
import type { AerogelOptions } from '@aerogel/core/bootstrap/options';
|
|
15
|
+
|
|
16
|
+
export type { AerogelOptions };
|
|
17
|
+
|
|
18
|
+
export async function bootstrapApplication(app: AppInstance, options: AerogelOptions = {}): Promise<void> {
|
|
19
|
+
const plugins = [testing, directives, errors, lang, services, ui, ...(options.plugins ?? [])];
|
|
20
|
+
|
|
21
|
+
App.instance = app;
|
|
22
|
+
|
|
23
|
+
await installPlugins(plugins, app, options);
|
|
24
|
+
await options.install?.(app);
|
|
25
|
+
await Events.emit('application-ready');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export async function bootstrap(rootComponent: Component, options: AerogelOptions = {}): Promise<void> {
|
|
29
|
+
const app = createApp(rootComponent);
|
|
30
|
+
|
|
31
|
+
if (isDevelopment()) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
33
|
+
(window as any).$aerogel = app;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
await bootstrapApplication(app, options);
|
|
34
37
|
|
|
35
38
|
app.mount('#app');
|
|
39
|
+
app._container?.classList.remove('loading');
|
|
40
|
+
|
|
41
|
+
await Events.emit('application-mounted');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
declare module '@aerogel/core/services/Events' {
|
|
45
|
+
export interface EventsPayload {
|
|
46
|
+
'application-ready': void;
|
|
47
|
+
'application-mounted': void;
|
|
48
|
+
}
|
|
36
49
|
}
|
package/src/bootstrap/options.ts
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="flex min-h-full flex-col text-base leading-tight font-normal text-gray-900 antialiased">
|
|
3
|
+
<slot v-if="$errors.hasStartupErrors" name="startup-crash">
|
|
4
|
+
<component :is="$ui.requireComponent('startup-crash')" />
|
|
5
|
+
</slot>
|
|
6
|
+
<slot v-else />
|
|
7
|
+
|
|
8
|
+
<AppOverlays />
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import AppOverlays from './AppOverlays.vue';
|
|
14
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<aside v-if="modal">
|
|
3
|
+
<ModalContext :child-index="1" :modal />
|
|
4
|
+
</aside>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { computed } from 'vue';
|
|
9
|
+
|
|
10
|
+
import ModalContext from '@aerogel/core/components/ui/ModalContext.vue';
|
|
11
|
+
import UI from '@aerogel/core/ui/UI';
|
|
12
|
+
|
|
13
|
+
const modal = computed(() => UI.modals[0] ?? null);
|
|
14
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ToastProvider>
|
|
3
|
+
<component
|
|
4
|
+
:is="toast.component"
|
|
5
|
+
v-for="toast of $ui.toasts"
|
|
6
|
+
:id="toast.id"
|
|
7
|
+
:key="toast.id"
|
|
8
|
+
v-bind="toast.properties"
|
|
9
|
+
/>
|
|
10
|
+
<ToastViewport class="fixed right-0 bottom-0 z-50 flex flex-col items-end space-y-4 px-4 py-6 sm:p-6" />
|
|
11
|
+
</ToastProvider>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script setup lang="ts">
|
|
15
|
+
import { ToastProvider, ToastViewport } from 'reka-ui';
|
|
16
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
5
|
+
|
|
6
|
+
export interface AlertModalProps {
|
|
7
|
+
title?: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface AlertModalExpose extends ModalExpose<void> {}
|
|
12
|
+
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
14
|
+
export function useAlertModal(props: AlertModalProps) {
|
|
15
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.alert', 'Alert'));
|
|
16
|
+
const titleHidden = computed(() => !props.title);
|
|
17
|
+
|
|
18
|
+
return { renderedTitle, titleHidden };
|
|
19
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { PrimitiveProps } from 'reka-ui';
|
|
2
|
+
import type { HTMLAttributes } from 'vue';
|
|
3
|
+
|
|
4
|
+
export type ButtonVariant = 'default' | 'secondary' | 'danger' | 'ghost' | 'outline' | 'link';
|
|
5
|
+
export type ButtonSize = 'default' | 'small' | 'large' | 'icon';
|
|
6
|
+
export interface ButtonProps extends PrimitiveProps {
|
|
7
|
+
class?: HTMLAttributes['class'];
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
href?: string;
|
|
10
|
+
route?: string;
|
|
11
|
+
routeParams?: object;
|
|
12
|
+
routeQuery?: object;
|
|
13
|
+
size?: ButtonSize;
|
|
14
|
+
submit?: boolean;
|
|
15
|
+
variant?: ButtonVariant;
|
|
16
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
+
import { useForm } from '@aerogel/core/utils/composition/forms';
|
|
5
|
+
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
|
6
|
+
import type { FormFieldDefinition } from '@aerogel/core/forms/FormController';
|
|
7
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
8
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
9
|
+
|
|
10
|
+
export type ConfirmModalCheckboxes = Record<string, { label: string; default?: boolean; required?: boolean }>;
|
|
11
|
+
|
|
12
|
+
export interface ConfirmModalProps {
|
|
13
|
+
title?: string;
|
|
14
|
+
message: string;
|
|
15
|
+
acceptText?: string;
|
|
16
|
+
acceptVariant?: ButtonVariant;
|
|
17
|
+
cancelText?: string;
|
|
18
|
+
cancelVariant?: ButtonVariant;
|
|
19
|
+
checkboxes?: ConfirmModalCheckboxes;
|
|
20
|
+
actions?: Record<string, () => unknown>;
|
|
21
|
+
required?: boolean;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface ConfirmModalExpose extends ModalExpose<boolean | [boolean, Record<string, Nullable<boolean>>]> {}
|
|
25
|
+
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
27
|
+
export function useConfirmModal(props: ConfirmModalProps) {
|
|
28
|
+
const form = useForm(
|
|
29
|
+
Object.entries(props.checkboxes ?? {}).reduce(
|
|
30
|
+
(values, [name, checkbox]) => ({
|
|
31
|
+
[name]: {
|
|
32
|
+
type: 'boolean',
|
|
33
|
+
default: checkbox.default,
|
|
34
|
+
required: checkbox.required ? 'required' : undefined,
|
|
35
|
+
},
|
|
36
|
+
...values,
|
|
37
|
+
}),
|
|
38
|
+
{} as Record<string, FormFieldDefinition<'boolean'>>,
|
|
39
|
+
),
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.confirm', 'Confirm'));
|
|
43
|
+
const titleHidden = computed(() => !props.title);
|
|
44
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
45
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
46
|
+
|
|
47
|
+
return { form, renderedTitle, titleHidden, renderedAcceptText, renderedCancelText };
|
|
48
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { DropdownMenuContentProps } from 'reka-ui';
|
|
2
|
+
|
|
3
|
+
import type { Falsifiable } from '@aerogel/core/utils/types';
|
|
4
|
+
|
|
5
|
+
export type DropdownMenuOptionData = {
|
|
6
|
+
label: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
route?: string;
|
|
9
|
+
routeParams?: object;
|
|
10
|
+
routeQuery?: object;
|
|
11
|
+
click?: () => unknown;
|
|
12
|
+
class?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface DropdownMenuProps {
|
|
16
|
+
align?: DropdownMenuContentProps['align'];
|
|
17
|
+
side?: DropdownMenuContentProps['side'];
|
|
18
|
+
options?: readonly Falsifiable<DropdownMenuOptionData>[];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DropdownMenuExpose {
|
|
22
|
+
align?: DropdownMenuContentProps['align'];
|
|
23
|
+
side?: DropdownMenuContentProps['side'];
|
|
24
|
+
options?: readonly DropdownMenuOptionData[];
|
|
25
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { computed, ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
+
import type { ErrorReport } from '@aerogel/core/errors';
|
|
5
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
6
|
+
|
|
7
|
+
export interface ErrorReportModalProps {
|
|
8
|
+
report: ErrorReport;
|
|
9
|
+
reports: ErrorReport[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ErrorReportModalExpose extends ModalExpose {}
|
|
13
|
+
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
15
|
+
export function useErrorReportModal(props: ErrorReportModalProps) {
|
|
16
|
+
const activeReportIndex = ref(props.reports.includes(props.report) ? props.reports.indexOf(props.report) : 0);
|
|
17
|
+
const activeReport = computed(() => props.reports[activeReportIndex.value] as ErrorReport);
|
|
18
|
+
const details = computed(
|
|
19
|
+
() =>
|
|
20
|
+
activeReport.value.details?.trim() ||
|
|
21
|
+
translateWithDefault('errors.detailsEmpty', 'This error is missing a stacktrace.'),
|
|
22
|
+
);
|
|
23
|
+
const previousReportText = translateWithDefault('errors.previousReport', 'Show previous report');
|
|
24
|
+
const nextReportText = translateWithDefault('errors.nextReport', 'Show next report');
|
|
25
|
+
|
|
26
|
+
return {
|
|
27
|
+
activeReportIndex,
|
|
28
|
+
details,
|
|
29
|
+
nextReportText,
|
|
30
|
+
previousReportText,
|
|
31
|
+
activeReport,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComputedRef, DeepReadonly, Ref } from 'vue';
|
|
2
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
3
|
+
|
|
4
|
+
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
5
|
+
|
|
6
|
+
export interface InputProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
|
|
7
|
+
name?: string;
|
|
8
|
+
label?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
modelValue?: T;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface InputEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
|
|
14
|
+
'update:modelValue': [value: T];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface InputExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> {
|
|
18
|
+
id: string;
|
|
19
|
+
name: ComputedRef<Nullable<string>>;
|
|
20
|
+
label: ComputedRef<Nullable<string>>;
|
|
21
|
+
description: ComputedRef<Nullable<string | boolean>>;
|
|
22
|
+
value: ComputedRef<T>;
|
|
23
|
+
required: ComputedRef<Nullable<boolean>>;
|
|
24
|
+
errors: DeepReadonly<Ref<Nullable<string[]>>>;
|
|
25
|
+
update(value: T): void;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
4
|
+
import type { Job } from '@aerogel/core/jobs';
|
|
5
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
6
|
+
|
|
7
|
+
export interface LoadingModalProps {
|
|
8
|
+
title?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
progress?: number;
|
|
11
|
+
job?: Job;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface LoadingModalExpose extends ModalExpose {}
|
|
15
|
+
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
17
|
+
export function useLoadingModal(props: LoadingModalProps) {
|
|
18
|
+
const renderedTitle = computed(() => props.title ?? translateWithDefault('ui.loading', 'Loading'));
|
|
19
|
+
const renderedMessage = computed(
|
|
20
|
+
() => props.message ?? translateWithDefault('ui.loadingInProgress', 'Loading in progress...'),
|
|
21
|
+
);
|
|
22
|
+
const showProgress = computed(() => typeof props.progress === 'number' || !!props.job);
|
|
23
|
+
const titleHidden = computed(() => !props.title);
|
|
24
|
+
|
|
25
|
+
return { renderedTitle, renderedMessage, titleHidden, showProgress };
|
|
26
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
2
|
+
import type { DialogContent } from 'reka-ui';
|
|
3
|
+
|
|
4
|
+
export type ModalContentInstance = Nullable<InstanceType<typeof DialogContent>>;
|
|
5
|
+
|
|
6
|
+
export interface ModalProps {
|
|
7
|
+
persistent?: boolean;
|
|
8
|
+
title?: string;
|
|
9
|
+
titleHidden?: boolean;
|
|
10
|
+
description?: string;
|
|
11
|
+
descriptionHidden?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ModalSlots<Result = void> {
|
|
15
|
+
default(props: { close(result?: Result): Promise<void> }): unknown;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface ModalExpose<Result = void> {
|
|
19
|
+
close(result?: Result): Promise<void>;
|
|
20
|
+
$content: ModalContentInstance;
|
|
21
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { computed } from 'vue';
|
|
2
|
+
|
|
3
|
+
import { useForm } from '@aerogel/core/utils/composition/forms';
|
|
4
|
+
import { requiredStringInput } from '@aerogel/core/forms/utils';
|
|
5
|
+
import { translateWithDefault } from '@aerogel/core/lang';
|
|
6
|
+
import type { ButtonVariant } from '@aerogel/core/components/contracts/Button';
|
|
7
|
+
import type { ModalExpose } from '@aerogel/core/components/contracts/Modal';
|
|
8
|
+
|
|
9
|
+
export interface PromptModalProps {
|
|
10
|
+
title?: string;
|
|
11
|
+
message: string;
|
|
12
|
+
label?: string;
|
|
13
|
+
defaultValue?: string;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
acceptText?: string;
|
|
16
|
+
acceptVariant?: ButtonVariant;
|
|
17
|
+
cancelText?: string;
|
|
18
|
+
cancelVariant?: ButtonVariant;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface PromptModalExpose extends ModalExpose<string> {}
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
|
24
|
+
export function usePromptModal(props: PromptModalProps) {
|
|
25
|
+
const form = useForm({
|
|
26
|
+
draft: requiredStringInput(props.defaultValue ?? ''),
|
|
27
|
+
});
|
|
28
|
+
const renderedTitle = computed(() => props.title ?? props.message);
|
|
29
|
+
const renderedMessage = computed(() => (props.title ? props.message : null));
|
|
30
|
+
const renderedAcceptText = computed(() => props.acceptText ?? translateWithDefault('ui.accept', 'Ok'));
|
|
31
|
+
const renderedCancelText = computed(() => props.cancelText ?? translateWithDefault('ui.cancel', 'Cancel'));
|
|
32
|
+
|
|
33
|
+
return { form, renderedTitle, renderedMessage, renderedAcceptText, renderedCancelText };
|
|
34
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { AcceptableValue, AsTag, SelectContentProps } from 'reka-ui';
|
|
2
|
+
import type { Component, ComputedRef, HTMLAttributes } from 'vue';
|
|
3
|
+
import type { Nullable } from '@noeldemartin/utils';
|
|
4
|
+
|
|
5
|
+
import type { FormFieldValue } from '@aerogel/core/forms';
|
|
6
|
+
|
|
7
|
+
import type { InputEmits, InputExpose, InputProps } from './Input';
|
|
8
|
+
|
|
9
|
+
export type SelectOptionData = {
|
|
10
|
+
key: string;
|
|
11
|
+
label: string;
|
|
12
|
+
value: AcceptableValue;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export interface HasSelectOptionLabel {
|
|
16
|
+
label: string | (() => string);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface SelectProps<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputProps<T> {
|
|
20
|
+
as?: AsTag | Component;
|
|
21
|
+
options?: readonly T[];
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
renderOption?: (option: T) => string;
|
|
24
|
+
compareOptions?: (a: T, b: T) => boolean;
|
|
25
|
+
labelClass?: HTMLAttributes['class'];
|
|
26
|
+
optionsClass?: HTMLAttributes['class'];
|
|
27
|
+
align?: SelectContentProps['align'];
|
|
28
|
+
side?: SelectContentProps['side'];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SelectEmits<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputEmits<T> {}
|
|
32
|
+
|
|
33
|
+
export interface SelectExpose<T extends Nullable<FormFieldValue> = Nullable<FormFieldValue>> extends InputExpose<T> {
|
|
34
|
+
options: ComputedRef<Nullable<readonly SelectOptionData[]>>;
|
|
35
|
+
selectedOption: ComputedRef<Nullable<SelectOptionData>>;
|
|
36
|
+
placeholder: ComputedRef<string>;
|
|
37
|
+
labelClass?: HTMLAttributes['class'];
|
|
38
|
+
optionsClass?: HTMLAttributes['class'];
|
|
39
|
+
align?: SelectContentProps['align'];
|
|
40
|
+
side?: SelectContentProps['side'];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function hasSelectOptionLabel(option: unknown): option is HasSelectOptionLabel {
|
|
44
|
+
return typeof option === 'object' && option !== null && 'label' in option;
|
|
45
|
+
}
|