@aerogel/core 0.0.0-next.926bde19326fe7b6b24b277666936862b64d8295 → 0.0.0-next.97312fd206b83ac5ae520da32b1bb3f12fb55969
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.cjs.js +1 -1
- package/dist/aerogel-core.cjs.js.map +1 -1
- package/dist/aerogel-core.d.ts +1436 -232
- package/dist/aerogel-core.esm.js +1 -1
- package/dist/aerogel-core.esm.js.map +1 -1
- package/histoire.config.ts +7 -0
- package/noeldemartin.config.js +4 -1
- package/package.json +14 -4
- package/postcss.config.js +6 -0
- package/src/assets/histoire.css +3 -0
- package/src/bootstrap/bootstrap.test.ts +4 -3
- package/src/bootstrap/index.ts +26 -4
- package/src/bootstrap/options.ts +3 -0
- package/src/components/AGAppLayout.vue +7 -2
- package/src/components/AGAppModals.vue +15 -0
- package/src/components/AGAppOverlays.vue +10 -8
- package/src/components/AGAppSnackbars.vue +13 -0
- package/src/components/constants.ts +8 -0
- package/src/components/forms/AGButton.vue +33 -10
- package/src/components/forms/AGCheckbox.vue +41 -0
- package/src/components/forms/AGInput.vue +15 -9
- package/src/components/forms/AGSelect.story.vue +46 -0
- package/src/components/forms/AGSelect.vue +60 -0
- package/src/components/forms/index.ts +5 -5
- package/src/components/headless/forms/AGHeadlessButton.vue +7 -7
- package/src/components/headless/forms/AGHeadlessInput.ts +23 -3
- package/src/components/headless/forms/AGHeadlessInput.vue +11 -8
- package/src/components/headless/forms/AGHeadlessInputError.vue +1 -1
- package/src/components/headless/forms/AGHeadlessInputInput.vue +15 -3
- package/src/components/headless/forms/AGHeadlessInputLabel.vue +8 -2
- package/src/components/headless/forms/AGHeadlessSelect.ts +42 -0
- package/src/components/headless/forms/AGHeadlessSelect.vue +77 -0
- package/src/components/headless/forms/AGHeadlessSelectButton.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectError.vue +26 -0
- package/src/components/headless/forms/AGHeadlessSelectLabel.vue +24 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.ts +4 -0
- package/src/components/headless/forms/AGHeadlessSelectOption.vue +39 -0
- package/src/components/headless/forms/AGHeadlessSelectOptions.ts +3 -0
- package/src/components/headless/forms/index.ts +9 -1
- package/src/components/headless/index.ts +1 -0
- package/src/components/headless/modals/AGHeadlessModal.ts +27 -0
- package/src/components/headless/modals/AGHeadlessModal.vue +3 -5
- package/src/components/headless/modals/AGHeadlessModalPanel.vue +5 -1
- package/src/components/headless/modals/index.ts +4 -6
- package/src/components/headless/snackbars/AGHeadlessSnackbar.vue +10 -0
- package/src/components/headless/snackbars/index.ts +40 -0
- package/src/components/index.ts +3 -1
- package/src/components/lib/AGErrorMessage.vue +16 -0
- package/src/components/lib/AGLink.vue +9 -0
- package/src/components/lib/AGMarkdown.vue +36 -0
- package/src/components/lib/AGMeasured.vue +15 -0
- package/src/components/lib/AGStartupCrash.vue +31 -0
- package/src/components/lib/index.ts +5 -0
- package/src/components/modals/AGAlertModal.ts +15 -0
- package/src/components/modals/AGAlertModal.vue +4 -16
- package/src/components/modals/AGConfirmModal.ts +27 -0
- package/src/components/modals/AGConfirmModal.vue +8 -12
- package/src/components/modals/AGErrorReportModal.ts +46 -0
- package/src/components/modals/AGErrorReportModal.vue +54 -0
- package/src/components/modals/AGErrorReportModalButtons.vue +111 -0
- package/src/components/modals/AGErrorReportModalTitle.vue +25 -0
- package/src/components/modals/AGLoadingModal.ts +23 -0
- package/src/components/modals/AGLoadingModal.vue +15 -0
- package/src/components/modals/AGModal.ts +1 -1
- package/src/components/modals/AGModal.vue +26 -5
- package/src/components/modals/AGModalTitle.vue +9 -0
- package/src/components/modals/AGPromptModal.ts +30 -0
- package/src/components/modals/AGPromptModal.vue +34 -0
- package/src/components/modals/index.ts +16 -6
- package/src/components/snackbars/AGSnackbar.vue +36 -0
- package/src/components/snackbars/index.ts +3 -0
- package/src/components/utils.ts +10 -0
- package/src/directives/index.ts +18 -3
- package/src/directives/measure.ts +12 -0
- package/src/errors/Errors.state.ts +31 -0
- package/src/errors/Errors.ts +188 -0
- package/src/errors/index.ts +55 -0
- package/src/forms/Form.ts +27 -15
- package/src/forms/utils.ts +17 -0
- package/src/lang/Lang.ts +12 -4
- package/src/lang/index.ts +3 -5
- package/src/lang/utils.ts +4 -0
- package/src/main.histoire.ts +1 -0
- package/src/main.ts +1 -2
- package/src/plugins/Plugin.ts +1 -0
- package/src/plugins/index.ts +19 -0
- package/src/services/App.state.ts +9 -2
- package/src/services/App.ts +36 -2
- package/src/services/Service.ts +146 -49
- package/src/services/index.ts +21 -4
- package/src/services/store.ts +27 -0
- package/src/ui/UI.state.ts +11 -1
- package/src/ui/UI.ts +164 -17
- package/src/ui/index.ts +15 -4
- package/src/utils/composition/events.ts +1 -0
- package/src/utils/composition/forms.ts +11 -0
- package/src/utils/index.ts +2 -0
- package/src/utils/markdown.ts +11 -2
- package/src/utils/tailwindcss.test.ts +26 -0
- package/src/utils/tailwindcss.ts +7 -0
- package/src/utils/vue.ts +15 -4
- package/tailwind.config.js +4 -0
- package/tsconfig.json +1 -0
- package/vite.config.ts +2 -1
- package/.eslintrc.js +0 -3
- package/src/components/basic/AGMarkdown.vue +0 -35
- package/src/components/basic/index.ts +0 -3
- package/src/globals.ts +0 -6
package/src/utils/markdown.ts
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import { tap } from '@noeldemartin/utils';
|
|
1
2
|
import DOMPurify from 'dompurify';
|
|
2
|
-
import { marked } from 'marked';
|
|
3
|
+
import { Renderer, marked } from 'marked';
|
|
4
|
+
|
|
5
|
+
function makeRenderer(): Renderer {
|
|
6
|
+
return tap(new Renderer(), (renderer) => {
|
|
7
|
+
renderer.link = function(href, title, text) {
|
|
8
|
+
return Renderer.prototype.link.apply(this, [href, title, text]).replace('<a', '<a target="_blank"');
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
}
|
|
3
12
|
|
|
4
13
|
export function renderMarkdown(markdown: string): string {
|
|
5
|
-
return safeHtml(marked(markdown, { mangle: false, headerIds: false }));
|
|
14
|
+
return safeHtml(marked(markdown, { mangle: false, headerIds: false, renderer: makeRenderer() }));
|
|
6
15
|
}
|
|
7
16
|
|
|
8
17
|
export function safeHtml(html: string): string {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
|
|
3
|
+
import { removeInteractiveClasses } from './tailwindcss';
|
|
4
|
+
|
|
5
|
+
describe('TailwindCSS utils', () => {
|
|
6
|
+
|
|
7
|
+
it('Removes interactive classes', () => {
|
|
8
|
+
const cases: [string, string][] = [
|
|
9
|
+
['text-red hover:text-green', 'text-red'],
|
|
10
|
+
['text-red hover:text-green text-lg', 'text-red text-lg'],
|
|
11
|
+
[
|
|
12
|
+
`
|
|
13
|
+
text-red text-lg
|
|
14
|
+
focus:text-yellow
|
|
15
|
+
hover:focus:text-black
|
|
16
|
+
`,
|
|
17
|
+
'text-red text-lg',
|
|
18
|
+
],
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
cases.forEach(([original, expected]) => {
|
|
22
|
+
expect(removeInteractiveClasses(original)).toEqual(expected);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
});
|
package/src/utils/vue.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import { fail } from '@noeldemartin/utils';
|
|
2
|
-
import { inject, reactive, ref } from 'vue';
|
|
2
|
+
import { computed, inject, reactive, ref, watch } from 'vue';
|
|
3
3
|
import type { Directive, InjectionKey, PropType, Ref, UnwrapNestedRefs } from 'vue';
|
|
4
4
|
|
|
5
5
|
type BaseProp<T> = {
|
|
6
|
-
type
|
|
6
|
+
type?: PropType<T>;
|
|
7
7
|
validator?(value: unknown): boolean;
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
type RequiredProp<T> = BaseProp<T> & { required: true };
|
|
11
11
|
type OptionalProp<T> = BaseProp<T> & { default: T | (() => T) | null };
|
|
12
12
|
|
|
13
|
+
export type ComponentProps = Record<string, unknown>;
|
|
14
|
+
|
|
13
15
|
export function arrayProp<T>(defaultValue?: () => T[]): OptionalProp<T[]> {
|
|
14
16
|
return {
|
|
15
17
|
type: Array as PropType<T[]>,
|
|
@@ -28,6 +30,15 @@ export function componentRef<T>(): Ref<UnwrapNestedRefs<T> | undefined> {
|
|
|
28
30
|
return ref<UnwrapNestedRefs<T>>();
|
|
29
31
|
}
|
|
30
32
|
|
|
33
|
+
export function computedAsync<T>(getter: () => Promise<T>): Ref<T | undefined> {
|
|
34
|
+
const result = ref<T>();
|
|
35
|
+
const asyncValue = computed(getter);
|
|
36
|
+
|
|
37
|
+
watch(asyncValue, async () => (result.value = await asyncValue.value), { immediate: true });
|
|
38
|
+
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
31
42
|
export function defineDirective(directive: Directive): Directive {
|
|
32
43
|
return directive;
|
|
33
44
|
}
|
|
@@ -62,7 +73,7 @@ export function injectOrFail<T>(key: InjectionKey<T> | string, errorMessage?: st
|
|
|
62
73
|
return inject(key) ?? fail(errorMessage ?? `Could not resolve '${key}' injection key`);
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
export function mixedProp<T>(type
|
|
76
|
+
export function mixedProp<T>(type?: PropType<T>): OptionalProp<T | null> {
|
|
66
77
|
return {
|
|
67
78
|
type,
|
|
68
79
|
default: null,
|
|
@@ -106,7 +117,7 @@ export function requiredEnumProp<Enum extends Record<string, unknown>>(
|
|
|
106
117
|
};
|
|
107
118
|
}
|
|
108
119
|
|
|
109
|
-
export function requiredMixedProp<T>(type
|
|
120
|
+
export function requiredMixedProp<T>(type?: PropType<T>): RequiredProp<T> {
|
|
110
121
|
return {
|
|
111
122
|
type,
|
|
112
123
|
required: true,
|
package/tsconfig.json
CHANGED
package/vite.config.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import Aerogel from '@aerogel/vite';
|
|
2
|
+
import Icons from 'unplugin-icons/vite';
|
|
2
3
|
import { defineConfig } from 'vitest/config';
|
|
3
4
|
import { resolve } from 'path';
|
|
4
5
|
|
|
5
6
|
export default defineConfig({
|
|
6
7
|
test: { clearMocks: true },
|
|
7
|
-
plugins: [Aerogel()],
|
|
8
|
+
plugins: [Aerogel(), Icons()],
|
|
8
9
|
resolve: {
|
|
9
10
|
alias: {
|
|
10
11
|
'@': resolve(__dirname, './src'),
|
package/.eslintrc.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<root />
|
|
3
|
-
</template>
|
|
4
|
-
|
|
5
|
-
<script setup lang="ts">
|
|
6
|
-
import { computed, h } from 'vue';
|
|
7
|
-
|
|
8
|
-
import { renderMarkdown } from '@/utils/markdown';
|
|
9
|
-
import { booleanProp, stringProp } from '@/utils/vue';
|
|
10
|
-
import { translate } from '@/lang';
|
|
11
|
-
|
|
12
|
-
const props = defineProps({
|
|
13
|
-
as: stringProp('div'),
|
|
14
|
-
langKey: stringProp(),
|
|
15
|
-
text: stringProp(),
|
|
16
|
-
inline: booleanProp(),
|
|
17
|
-
raw: booleanProp(),
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const markdown = computed(() => props.text ?? (props.langKey && translate(props.langKey)));
|
|
21
|
-
const html = computed(() => {
|
|
22
|
-
if (!markdown.value) {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
let html = renderMarkdown(markdown.value);
|
|
27
|
-
|
|
28
|
-
if (props.inline) {
|
|
29
|
-
html = html.replace('<p>', '<span>').replace('</p>', '</span>');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return html;
|
|
33
|
-
});
|
|
34
|
-
const root = () => h(props.as, { class: props.raw ? '' : 'prose', innerHTML: html.value });
|
|
35
|
-
</script>
|