@aerogel/core 0.0.0-next.980a397d575dcb5ff8c5a0bff769d09f938ea03c → 0.0.0-next.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2
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.d.ts +2255 -1046
- package/dist/aerogel-core.js +2763 -0
- package/dist/aerogel-core.js.map +1 -0
- package/package.json +23 -37
- package/src/bootstrap/bootstrap.test.ts +7 -11
- package/src/bootstrap/index.ts +36 -16
- package/src/bootstrap/options.ts +4 -1
- package/src/components/AGAppLayout.vue +3 -2
- package/src/components/AGAppModals.vue +1 -1
- package/src/components/AGAppOverlays.vue +6 -2
- package/src/components/AGAppSnackbars.vue +1 -1
- package/src/components/composition.ts +23 -0
- package/src/components/contracts/Modal.ts +16 -0
- package/src/components/contracts/index.ts +2 -0
- package/src/components/contracts/shared.ts +9 -0
- package/src/components/forms/AGButton.vue +2 -2
- package/src/components/forms/AGCheckbox.vue +10 -3
- package/src/components/forms/AGForm.vue +11 -12
- package/src/components/forms/AGInput.vue +13 -7
- package/src/components/forms/AGSelect.story.vue +21 -3
- package/src/components/forms/AGSelect.vue +20 -19
- package/src/components/headless/forms/AGHeadlessButton.ts +3 -0
- package/src/components/headless/forms/AGHeadlessButton.vue +24 -13
- package/src/components/headless/forms/AGHeadlessInput.ts +22 -14
- package/src/components/headless/forms/AGHeadlessInput.vue +19 -6
- package/src/components/headless/forms/AGHeadlessInputDescription.vue +28 -0
- package/src/components/headless/forms/AGHeadlessInputError.vue +2 -2
- package/src/components/headless/forms/AGHeadlessInputInput.vue +45 -6
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInputTextArea.vue +43 -0
- package/src/components/headless/forms/AGHeadlessSelect.ts +20 -22
- package/src/components/headless/forms/AGHeadlessSelect.vue +34 -33
- package/src/components/headless/forms/AGHeadlessSelectError.vue +2 -2
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +14 -22
- package/src/components/headless/forms/AGHeadlessSelectOptions.vue +19 -0
- package/src/components/headless/forms/AGHeadlessSelectTrigger.vue +25 -0
- package/src/components/headless/forms/composition.ts +10 -0
- package/src/components/headless/forms/index.ts +6 -3
- package/src/components/headless/modals/AGHeadlessModal.ts +25 -8
- package/src/components/headless/modals/AGHeadlessModal.vue +12 -12
- package/src/components/headless/modals/AGHeadlessModalContent.vue +25 -0
- package/src/components/headless/modals/index.ts +3 -2
- package/src/components/headless/snackbars/index.ts +25 -10
- package/src/components/index.ts +2 -0
- package/src/components/lib/AGErrorMessage.vue +4 -4
- package/src/components/lib/AGMarkdown.vue +24 -6
- package/src/components/lib/AGMeasured.vue +16 -0
- package/src/components/lib/AGProgressBar.vue +55 -0
- package/src/components/lib/AGStartupCrash.vue +1 -1
- package/src/components/lib/index.ts +2 -0
- package/src/components/modals/AGAlertModal.ts +18 -0
- package/src/components/modals/AGAlertModal.vue +3 -14
- package/src/components/modals/AGConfirmModal.ts +33 -1
- package/src/components/modals/AGConfirmModal.vue +10 -13
- package/src/components/modals/AGErrorReportModal.ts +32 -3
- package/src/components/modals/AGErrorReportModal.vue +9 -17
- package/src/components/modals/AGErrorReportModalButtons.vue +14 -12
- package/src/components/modals/AGErrorReportModalTitle.vue +2 -2
- package/src/components/modals/AGLoadingModal.ts +21 -1
- package/src/components/modals/AGLoadingModal.vue +3 -7
- package/src/components/modals/AGModal.vue +25 -22
- package/src/components/modals/AGModalContext.ts +1 -1
- package/src/components/modals/AGModalContext.vue +15 -5
- package/src/components/modals/AGModalTitle.vue +1 -1
- package/src/components/modals/AGPromptModal.ts +41 -0
- package/src/components/modals/AGPromptModal.vue +35 -0
- package/src/components/modals/index.ts +11 -20
- package/src/components/snackbars/AGSnackbar.vue +3 -9
- package/src/components/utils.ts +63 -0
- package/src/directives/index.ts +13 -5
- package/src/directives/measure.ts +40 -0
- package/src/errors/Errors.state.ts +1 -1
- package/src/errors/Errors.ts +32 -30
- package/src/errors/JobCancelledError.ts +3 -0
- package/src/errors/index.ts +11 -17
- package/src/errors/utils.ts +35 -0
- package/src/forms/Form.test.ts +32 -3
- package/src/forms/Form.ts +81 -20
- package/src/forms/composition.ts +2 -2
- package/src/forms/index.ts +3 -1
- package/src/forms/utils.ts +34 -3
- package/src/forms/validation.ts +19 -0
- package/src/{main.ts → index.ts} +3 -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 +44 -29
- package/src/lang/index.ts +8 -6
- package/src/plugins/Plugin.ts +1 -1
- package/src/plugins/index.ts +10 -7
- package/src/services/App.state.ts +27 -5
- package/src/services/App.ts +32 -6
- package/src/services/Cache.ts +43 -0
- package/src/services/Events.test.ts +39 -0
- package/src/services/Events.ts +112 -32
- package/src/services/Service.ts +150 -49
- package/src/services/Storage.ts +20 -0
- package/src/services/index.ts +15 -6
- package/src/services/store.ts +8 -5
- package/src/services/utils.ts +18 -0
- package/src/testing/index.ts +26 -0
- package/src/testing/setup.ts +11 -0
- package/src/ui/UI.state.ts +9 -2
- package/src/ui/UI.ts +233 -45
- package/src/ui/index.ts +13 -7
- package/src/ui/utils.ts +16 -0
- package/src/utils/composition/events.ts +3 -2
- 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 +24 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/markdown.test.ts +50 -0
- package/src/utils/markdown.ts +19 -6
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +33 -17
- 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/histoire.config.ts +0 -7
- package/noeldemartin.config.js +0 -5
- package/postcss.config.js +0 -6
- package/src/assets/histoire.css +0 -3
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +0 -24
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +0 -3
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +0 -28
- package/src/components/headless/modals/AGHeadlessModalTitle.vue +0 -13
- package/src/components/modals/AGModal.ts +0 -10
- package/src/directives/initial-focus.ts +0 -11
- package/src/main.histoire.ts +0 -1
- package/tailwind.config.js +0 -4
- package/tsconfig.json +0 -11
- package/vite.config.ts +0 -14
package/package.json
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
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.9a1c5ba39a454b316eba36ec7bdf579fed3d95d2",
|
|
4
|
+
"type": "module",
|
|
8
5
|
"sideEffects": false,
|
|
6
|
+
"exports": {
|
|
7
|
+
"types": "./dist/aerogel-core.d.ts",
|
|
8
|
+
"default": "./dist/aerogel-core.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": "Noel De Martin",
|
|
16
|
+
"repository": "github:NoelDeMartin/aerogel",
|
|
9
17
|
"scripts": {
|
|
10
|
-
"build": "
|
|
11
|
-
"build:js": "noeldemartin-build-javascript",
|
|
12
|
-
"build:types": "noeldemartin-build-types",
|
|
13
|
-
"histoire": "histoire dev",
|
|
18
|
+
"build": "vite build && ./scripts/fix-types.sh",
|
|
14
19
|
"lint": "noeldemartin-lint src",
|
|
15
|
-
"publish-next": "noeldemartin-publish-next",
|
|
16
20
|
"test": "vitest --run",
|
|
17
|
-
"test:ci": "vitest --run --reporter verbose"
|
|
18
|
-
|
|
19
|
-
"engines": {
|
|
20
|
-
"node": ">=18.x"
|
|
21
|
+
"test:ci": "vitest --run --reporter verbose",
|
|
22
|
+
"verify": "noeldemartin-verify"
|
|
21
23
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
24
|
-
"url": "https://github.com/NoelDeMartin/aerogeljs.git"
|
|
25
|
-
},
|
|
26
|
-
"keywords": [
|
|
27
|
-
"javascript",
|
|
28
|
-
"framework",
|
|
29
|
-
"solid"
|
|
30
|
-
],
|
|
31
|
-
"author": "Noel De Martin",
|
|
32
|
-
"license": "MIT",
|
|
33
|
-
"bugs": {
|
|
34
|
-
"url": "https://github.com/NoelDeMartin/aerogeljs/issues"
|
|
24
|
+
"peerDependencies": {
|
|
25
|
+
"vue": "^3.5.0"
|
|
35
26
|
},
|
|
36
27
|
"dependencies": {
|
|
37
|
-
"@
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
"marked": "^5.0.4",
|
|
28
|
+
"@noeldemartin/utils": "0.7.0-next.31cf84b4b57092d146528f27579439783aca71bb",
|
|
29
|
+
"dompurify": "^3.2.4",
|
|
30
|
+
"marked": "^15.0.7",
|
|
41
31
|
"pinia": "^2.1.6",
|
|
42
|
-
"
|
|
32
|
+
"reka-ui": "^2.2.0"
|
|
43
33
|
},
|
|
44
34
|
"devDependencies": {
|
|
45
|
-
"@aerogel/vite": "*"
|
|
46
|
-
"@histoire/plugin-vue": "^0.17.6",
|
|
47
|
-
"@types/dompurify": "^3.0.2",
|
|
48
|
-
"@types/marked": "^5.0.0",
|
|
49
|
-
"tailwindcss": "^3.3.5"
|
|
35
|
+
"@aerogel/vite": "*"
|
|
50
36
|
},
|
|
51
37
|
"eslintConfig": {
|
|
52
38
|
"extends": [
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
2
|
import { createApp } from 'vue';
|
|
3
|
-
import { mock } from '@noeldemartin/
|
|
3
|
+
import { mock } from '@noeldemartin/testing';
|
|
4
4
|
import type { Component } from 'vue';
|
|
5
5
|
|
|
6
|
-
import Events from '
|
|
7
|
-
import
|
|
6
|
+
import Events from '@aerogel/core/services/Events';
|
|
7
|
+
import measure from '@aerogel/core/directives/measure';
|
|
8
8
|
|
|
9
|
-
import {
|
|
9
|
+
import { bootstrap } from './index';
|
|
10
10
|
|
|
11
11
|
describe('Aerogel', () => {
|
|
12
12
|
|
|
13
13
|
beforeEach(() => {
|
|
14
|
-
vi.stubGlobal('document', { getElementById: () => null });
|
|
15
14
|
vi.mock('vue', async () => {
|
|
16
15
|
const vue = (await vi.importActual('vue')) as Object;
|
|
17
16
|
|
|
@@ -32,7 +31,7 @@ describe('Aerogel', () => {
|
|
|
32
31
|
const rootComponent = mock<Component>();
|
|
33
32
|
|
|
34
33
|
// Act
|
|
35
|
-
await
|
|
34
|
+
await bootstrap(rootComponent);
|
|
36
35
|
|
|
37
36
|
// Assert
|
|
38
37
|
const globals = vi.mocked(createApp).mock.results[0]?.value.config.globalProperties;
|
|
@@ -46,13 +45,10 @@ describe('Aerogel', () => {
|
|
|
46
45
|
const rootComponent = mock<Component>();
|
|
47
46
|
|
|
48
47
|
// Act
|
|
49
|
-
await
|
|
48
|
+
await bootstrap(rootComponent);
|
|
50
49
|
|
|
51
50
|
// Assert
|
|
52
|
-
expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith(
|
|
53
|
-
'initial-focus',
|
|
54
|
-
initialFocus,
|
|
55
|
-
);
|
|
51
|
+
expect(vi.mocked(createApp).mock.results[0]?.value.directive).toHaveBeenCalledWith('measure', measure);
|
|
56
52
|
});
|
|
57
53
|
|
|
58
54
|
});
|
package/src/bootstrap/index.ts
CHANGED
|
@@ -1,29 +1,49 @@
|
|
|
1
1
|
import { createApp } from 'vue';
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
22
|
|
|
17
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);
|
|
18
37
|
|
|
19
38
|
app.mount('#app');
|
|
20
39
|
app._container?.classList.remove('loading');
|
|
21
40
|
|
|
22
|
-
Events.emit('application-mounted');
|
|
41
|
+
await Events.emit('application-mounted');
|
|
23
42
|
}
|
|
24
43
|
|
|
25
|
-
declare module '
|
|
44
|
+
declare module '@aerogel/core/services/Events' {
|
|
26
45
|
export interface EventsPayload {
|
|
46
|
+
'application-ready': void;
|
|
27
47
|
'application-mounted': void;
|
|
28
48
|
}
|
|
29
49
|
}
|
package/src/bootstrap/options.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="flex min-h-full flex-col text-base font-normal leading-tight text-gray-900 antialiased">
|
|
3
3
|
<slot v-if="$errors.hasStartupErrors" name="startup-crash">
|
|
4
|
-
<
|
|
4
|
+
<component :is="$ui.requireComponent(UIComponents.StartupCrash)" />
|
|
5
5
|
</slot>
|
|
6
6
|
<slot v-else />
|
|
7
7
|
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script setup lang="ts">
|
|
13
|
+
import { UIComponents } from '@aerogel/core/ui/UI';
|
|
14
|
+
|
|
13
15
|
import AGAppOverlays from './AGAppOverlays.vue';
|
|
14
|
-
import AGStartupCrash from './lib/AGStartupCrash.vue';
|
|
15
16
|
</script>
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
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
|
+
/>
|
|
3
7
|
<AGAppModals />
|
|
4
8
|
<AGAppSnackbars />
|
|
5
9
|
</template>
|
|
@@ -7,7 +11,7 @@
|
|
|
7
11
|
<script setup lang="ts">
|
|
8
12
|
import { ref } from 'vue';
|
|
9
13
|
|
|
10
|
-
import { useEvent } from '
|
|
14
|
+
import { useEvent } from '@aerogel/core/utils/composition/events';
|
|
11
15
|
|
|
12
16
|
import AGAppModals from './AGAppModals.vue';
|
|
13
17
|
import AGAppSnackbars from './AGAppSnackbars.vue';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div aria-live="assertive" class="
|
|
2
|
+
<div aria-live="assertive" class="pointer-events-none fixed inset-0 z-50 flex items-end px-4 py-6 sm:p-6">
|
|
3
3
|
<div class="flex w-full flex-col items-end space-y-4">
|
|
4
4
|
<component
|
|
5
5
|
:is="snackbar.component"
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { customRef } from 'vue';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
|
|
4
|
+
import { getElement } from '@aerogel/core/components/utils';
|
|
5
|
+
|
|
6
|
+
export function elementRef(): Ref<HTMLElement | undefined> {
|
|
7
|
+
return customRef((track, trigger) => {
|
|
8
|
+
let value: HTMLElement | undefined = undefined;
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
get() {
|
|
12
|
+
track();
|
|
13
|
+
|
|
14
|
+
return value;
|
|
15
|
+
},
|
|
16
|
+
set(newValue) {
|
|
17
|
+
value = getElement(newValue);
|
|
18
|
+
|
|
19
|
+
trigger();
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Ref } from 'vue';
|
|
2
|
+
|
|
3
|
+
export interface IModal {
|
|
4
|
+
cancellable: Ref<boolean>;
|
|
5
|
+
close(result?: unknown): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface IModalProps {
|
|
9
|
+
cancellable: boolean;
|
|
10
|
+
title: string | null;
|
|
11
|
+
description: string | null;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface IModalDefaultSlotProps {
|
|
15
|
+
close(result?: unknown): Promise<void>;
|
|
16
|
+
}
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
|
|
10
|
-
import { enumProp } from '
|
|
11
|
-
import { Colors } from '
|
|
10
|
+
import { enumProp } from '@aerogel/core/utils/vue';
|
|
11
|
+
import { Colors } from '@aerogel/core/components/constants';
|
|
12
12
|
|
|
13
13
|
import AGHeadlessButton from '../headless/forms/AGHeadlessButton.vue';
|
|
14
14
|
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGHeadlessInput
|
|
2
|
+
<AGHeadlessInput
|
|
3
|
+
ref="$input"
|
|
4
|
+
:name="name"
|
|
5
|
+
class="flex"
|
|
6
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
7
|
+
>
|
|
3
8
|
<AGHeadlessInputInput
|
|
4
9
|
v-bind="$attrs"
|
|
5
10
|
type="checkbox"
|
|
@@ -19,9 +24,10 @@
|
|
|
19
24
|
</template>
|
|
20
25
|
|
|
21
26
|
<script setup lang="ts">
|
|
22
|
-
import { componentRef, stringProp } from '
|
|
27
|
+
import { componentRef, stringProp } from '@aerogel/core/utils/vue';
|
|
23
28
|
|
|
24
|
-
import
|
|
29
|
+
import { useInputEmits } from '@aerogel/core/components/headless/forms/AGHeadlessInput';
|
|
30
|
+
import type { IAGHeadlessInput } from '@aerogel/core/components/headless/forms/AGHeadlessInput';
|
|
25
31
|
|
|
26
32
|
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
27
33
|
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
@@ -30,6 +36,7 @@ import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
|
|
|
30
36
|
|
|
31
37
|
defineProps({ name: stringProp() });
|
|
32
38
|
defineOptions({ inheritAttrs: false });
|
|
39
|
+
defineEmits(useInputEmits());
|
|
33
40
|
|
|
34
41
|
const $input = componentRef<IAGHeadlessInput>();
|
|
35
42
|
</script>
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<form @submit.prevent="submit">
|
|
2
|
+
<form @submit.prevent="form?.submit()">
|
|
3
3
|
<slot />
|
|
4
4
|
</form>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
|
-
import { provide } from 'vue';
|
|
8
|
+
import { provide, watchEffect } from 'vue';
|
|
9
9
|
|
|
10
|
-
import { objectProp } from '
|
|
11
|
-
import type Form from '
|
|
10
|
+
import { objectProp } from '@aerogel/core/utils/vue';
|
|
11
|
+
import type Form from '@aerogel/core/forms/Form';
|
|
12
12
|
|
|
13
|
+
let offSubmit: (() => void) | undefined;
|
|
13
14
|
const props = defineProps({ form: objectProp<Form>() });
|
|
14
|
-
|
|
15
15
|
const emit = defineEmits<{ submit: [] }>();
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
watchEffect((onCleanup) => {
|
|
18
|
+
offSubmit?.();
|
|
19
|
+
offSubmit = props.form?.on('submit', () => emit('submit'));
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
21
|
+
onCleanup(() => offSubmit?.());
|
|
22
|
+
});
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
}
|
|
24
|
+
provide('form', props.form);
|
|
26
25
|
</script>
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
ref="$input"
|
|
4
4
|
class="relative flex flex-col items-center"
|
|
5
5
|
:class="className"
|
|
6
|
-
|
|
6
|
+
v-bind="props"
|
|
7
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
7
8
|
>
|
|
9
|
+
<AGHeadlessInputLabel class="sr-only" />
|
|
8
10
|
<AGHeadlessInputInput
|
|
9
11
|
v-bind="attrs"
|
|
10
12
|
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,6 +14,7 @@
|
|
|
12
14
|
'ring-1 ring-red-500': $input?.errors,
|
|
13
15
|
}"
|
|
14
16
|
/>
|
|
17
|
+
<AGHeadlessInputDescription />
|
|
15
18
|
<div class="absolute bottom-0 left-0 translate-y-full">
|
|
16
19
|
<AGHeadlessInputError class="mt-1 text-sm text-red-500" />
|
|
17
20
|
</div>
|
|
@@ -19,18 +22,21 @@
|
|
|
19
22
|
</template>
|
|
20
23
|
|
|
21
24
|
<script setup lang="ts">
|
|
22
|
-
import { componentRef
|
|
23
|
-
|
|
24
|
-
import {
|
|
25
|
-
import type { IAGHeadlessInput } from '
|
|
25
|
+
import { componentRef } from '@aerogel/core/utils/vue';
|
|
26
|
+
import { useInputAttrs } from '@aerogel/core/utils/composition/forms';
|
|
27
|
+
import { useInputEmits, useInputProps } from '@aerogel/core/components/headless/forms/AGHeadlessInput';
|
|
28
|
+
import type { IAGHeadlessInput } from '@aerogel/core/components/headless/forms/AGHeadlessInput';
|
|
26
29
|
|
|
27
30
|
import AGHeadlessInput from '../headless/forms/AGHeadlessInput.vue';
|
|
28
|
-
import
|
|
31
|
+
import AGHeadlessInputDescription from '../headless/forms/AGHeadlessInputDescription.vue';
|
|
29
32
|
import AGHeadlessInputError from '../headless/forms/AGHeadlessInputError.vue';
|
|
33
|
+
import AGHeadlessInputInput from '../headless/forms/AGHeadlessInputInput.vue';
|
|
34
|
+
import AGHeadlessInputLabel from '../headless/forms/AGHeadlessInputLabel.vue';
|
|
30
35
|
|
|
31
|
-
defineProps({ name: stringProp() });
|
|
32
36
|
defineOptions({ inheritAttrs: false });
|
|
37
|
+
defineEmits(useInputEmits());
|
|
33
38
|
|
|
39
|
+
const props = defineProps(useInputProps());
|
|
34
40
|
const $input = componentRef<IAGHeadlessInput>();
|
|
35
41
|
const [attrs, className] = useInputAttrs();
|
|
36
42
|
</script>
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<Story>
|
|
3
3
|
<div class="h-96">
|
|
4
|
-
<AGSelect v-model="bestMugiwara" :label="
|
|
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
|
+
/>
|
|
5
11
|
</div>
|
|
6
12
|
</Story>
|
|
7
13
|
</template>
|
|
@@ -12,8 +18,10 @@ import { ref } from 'vue';
|
|
|
12
18
|
import AGSelect from './AGSelect.vue';
|
|
13
19
|
|
|
14
20
|
const bestMugiwara = ref(null);
|
|
15
|
-
const
|
|
16
|
-
const
|
|
21
|
+
const bestFood = ref(null);
|
|
22
|
+
const bestMugiwaraLabel = 'Who\'s the best Mugiwara?';
|
|
23
|
+
const bestFoodLabel = 'What\'s the best food?';
|
|
24
|
+
const bestMugiwaraOptions = [
|
|
17
25
|
'Monkey D. Luffy',
|
|
18
26
|
'Roronoa Zoro',
|
|
19
27
|
'Nami',
|
|
@@ -25,4 +33,14 @@ const options = [
|
|
|
25
33
|
'Brook',
|
|
26
34
|
'Jinbe',
|
|
27
35
|
];
|
|
36
|
+
const bestFoodOptions = [
|
|
37
|
+
{
|
|
38
|
+
id: 'ramen',
|
|
39
|
+
name: 'Ramen',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'pizza',
|
|
43
|
+
name: 'Pizza',
|
|
44
|
+
},
|
|
45
|
+
];
|
|
28
46
|
</script>
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<AGHeadlessSelect
|
|
3
|
-
|
|
2
|
+
<AGHeadlessSelect
|
|
3
|
+
v-bind="props"
|
|
4
|
+
ref="$select"
|
|
5
|
+
as="div"
|
|
6
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
7
|
+
>
|
|
4
8
|
<div class="relative" :class="{ 'mt-2': $select?.label }">
|
|
5
|
-
<
|
|
6
|
-
class="relative w-full cursor-default bg-white py-1.5 pl-3
|
|
9
|
+
<AGHeadlessSelectTrigger
|
|
10
|
+
class="relative w-full cursor-default bg-white py-1.5 pr-10 pl-3 text-left text-gray-900 ring-1 ring-gray-300 ring-inset focus:ring-2 focus:ring-indigo-600 focus:outline-hidden"
|
|
7
11
|
text-class="block truncate"
|
|
8
12
|
:class="{
|
|
9
13
|
'ring-1 ring-red-500': $select?.errors,
|
|
@@ -11,22 +15,18 @@
|
|
|
11
15
|
>
|
|
12
16
|
<template #icon>
|
|
13
17
|
<span class="pointer-events-none absolute inset-y-0 right-0 flex items-center pr-2">
|
|
14
|
-
<IconCheveronDown class="
|
|
18
|
+
<IconCheveronDown class="size-5 text-gray-400" />
|
|
15
19
|
</span>
|
|
16
20
|
</template>
|
|
17
|
-
</
|
|
21
|
+
</AGHeadlessSelectTrigger>
|
|
18
22
|
<AGHeadlessSelectOptions
|
|
19
|
-
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border bg-white py-1 text-base ring-1 ring-black
|
|
23
|
+
class="absolute z-10 mt-1 max-h-60 w-full overflow-auto border border-gray-300 bg-white py-1 text-base ring-1 ring-black/5 focus:outline-hidden"
|
|
20
24
|
>
|
|
21
25
|
<AGHeadlessSelectOption
|
|
22
26
|
v-for="(option, index) in $select?.options ?? []"
|
|
23
27
|
:key="index"
|
|
24
|
-
:value="option
|
|
25
|
-
class="relative block cursor-default
|
|
26
|
-
selected-class="font-semibold"
|
|
27
|
-
unselected-class="font-normal"
|
|
28
|
-
active-class="bg-indigo-600 text-white"
|
|
29
|
-
inactive-class="text-gray-900"
|
|
28
|
+
:value="option"
|
|
29
|
+
class="relative block cursor-default truncate py-2 pr-9 pl-3 text-gray-900 select-none data-[highlighted]:bg-indigo-600 data-[highlighted]:text-white data-[state=checked]:font-semibold data-[state=unchecked]:font-normal"
|
|
30
30
|
/>
|
|
31
31
|
</AGHeadlessSelectOptions>
|
|
32
32
|
</div>
|
|
@@ -37,16 +37,17 @@
|
|
|
37
37
|
<script setup lang="ts">
|
|
38
38
|
import IconCheveronDown from '~icons/zondicons/cheveron-down';
|
|
39
39
|
|
|
40
|
-
import { componentRef } from '
|
|
41
|
-
import { useSelectProps } from '
|
|
42
|
-
import type { IAGHeadlessSelect } from '
|
|
40
|
+
import { componentRef } from '@aerogel/core/utils/vue';
|
|
41
|
+
import { useSelectEmits, useSelectProps } from '@aerogel/core/components/headless/forms/AGHeadlessSelect';
|
|
42
|
+
import type { IAGHeadlessSelect } from '@aerogel/core/components/headless/forms/AGHeadlessSelect';
|
|
43
43
|
|
|
44
44
|
import AGHeadlessSelect from '../headless/forms/AGHeadlessSelect.vue';
|
|
45
|
-
import
|
|
45
|
+
import AGHeadlessSelectTrigger from '../headless/forms/AGHeadlessSelectTrigger.vue';
|
|
46
46
|
import AGHeadlessSelectError from '../headless/forms/AGHeadlessSelectError.vue';
|
|
47
|
-
import AGHeadlessSelectLabel from '../headless/forms/AGHeadlessSelectLabel.vue';
|
|
48
47
|
import AGHeadlessSelectOption from '../headless/forms/AGHeadlessSelectOption.vue';
|
|
49
|
-
import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions';
|
|
48
|
+
import AGHeadlessSelectOptions from '../headless/forms/AGHeadlessSelectOptions.vue';
|
|
49
|
+
|
|
50
|
+
defineEmits(useSelectEmits());
|
|
50
51
|
|
|
51
52
|
const props = defineProps(useSelectProps());
|
|
52
53
|
const $select = componentRef<IAGHeadlessSelect>();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<component :is="component.
|
|
2
|
+
<component :is="component.as" ref="$root" v-bind="component.props">
|
|
3
3
|
<slot />
|
|
4
4
|
</component>
|
|
5
5
|
</template>
|
|
@@ -8,9 +8,13 @@
|
|
|
8
8
|
import { computed } from 'vue';
|
|
9
9
|
import { objectWithoutEmpty } from '@noeldemartin/utils';
|
|
10
10
|
|
|
11
|
-
import { booleanProp, objectProp, stringProp } from '
|
|
11
|
+
import { booleanProp, objectProp, stringProp } from '@aerogel/core/utils/vue';
|
|
12
|
+
import { elementRef } from '@aerogel/core/components/composition';
|
|
12
13
|
|
|
13
|
-
|
|
14
|
+
import type { IAGHeadlessButton } from './AGHeadlessButton';
|
|
15
|
+
|
|
16
|
+
const props = defineProps({
|
|
17
|
+
as: objectProp(),
|
|
14
18
|
href: stringProp(),
|
|
15
19
|
url: stringProp(),
|
|
16
20
|
route: stringProp(),
|
|
@@ -19,33 +23,40 @@ const { href, url, route, routeParams, routeQuery, submit } = defineProps({
|
|
|
19
23
|
submit: booleanProp(),
|
|
20
24
|
});
|
|
21
25
|
|
|
26
|
+
const $root = elementRef();
|
|
22
27
|
const component = computed(() => {
|
|
23
|
-
if (
|
|
28
|
+
if (props.as) {
|
|
29
|
+
return { as: props.as, props: {} };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (props.route) {
|
|
24
33
|
return {
|
|
25
|
-
|
|
34
|
+
as: 'router-link',
|
|
26
35
|
props: {
|
|
27
36
|
to: objectWithoutEmpty({
|
|
28
|
-
name: route,
|
|
29
|
-
params: routeParams,
|
|
30
|
-
query: routeQuery,
|
|
37
|
+
name: props.route,
|
|
38
|
+
params: props.routeParams,
|
|
39
|
+
query: props.routeQuery,
|
|
31
40
|
}),
|
|
32
41
|
},
|
|
33
42
|
};
|
|
34
43
|
}
|
|
35
44
|
|
|
36
|
-
if (href || url) {
|
|
45
|
+
if (props.href || props.url) {
|
|
37
46
|
return {
|
|
38
|
-
|
|
47
|
+
as: 'a',
|
|
39
48
|
props: {
|
|
40
49
|
target: '_blank',
|
|
41
|
-
href: href || url,
|
|
50
|
+
href: props.href || props.url,
|
|
42
51
|
},
|
|
43
52
|
};
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
return {
|
|
47
|
-
|
|
48
|
-
props: { type: submit ? 'submit' : 'button' },
|
|
56
|
+
as: 'button',
|
|
57
|
+
props: { type: props.submit ? 'submit' : 'button' },
|
|
49
58
|
};
|
|
50
59
|
});
|
|
60
|
+
|
|
61
|
+
defineExpose<IAGHeadlessButton>({ $el: $root });
|
|
51
62
|
</script>
|