@simple-reporting/base 1.0.9 → 1.0.11
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/dev/package.json +2 -2
- package/package.json +1 -1
- package/scripts/doPublish.js +11 -1
- package/srl/components/Srl/Note/Accordion/Content.vue +12 -0
- package/srl/components/Srl/Note/Accordion/Toggle.vue +13 -0
- package/srl/components/Srl/Note/Accordion.vue +17 -0
- package/srl/plugins/vueSrlPlugin.ts +7 -0
- package/srl/utils/html.ts +101 -1
package/dev/package.json
CHANGED
|
@@ -16,10 +16,10 @@
|
|
|
16
16
|
"type-check": "vue-tsc --build",
|
|
17
17
|
"lint": "eslint . --fix",
|
|
18
18
|
"format": "prettier --write src/",
|
|
19
|
-
"postinstall": "srl prepare"
|
|
19
|
+
"postinstall": "npx srl prepare"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@simple-reporting/base": "^1.0.
|
|
22
|
+
"@simple-reporting/base": "^1.0.11",
|
|
23
23
|
"axios": "^1.9.0",
|
|
24
24
|
"chalk": "^5.4.1",
|
|
25
25
|
"exceljs": "^4.4.0",
|
package/package.json
CHANGED
package/scripts/doPublish.js
CHANGED
|
@@ -3,6 +3,16 @@ import { preparePublish } from './preparePublish.js';
|
|
|
3
3
|
import { packageName } from './config.js';
|
|
4
4
|
import { getPackageVersion } from './utils.js';
|
|
5
5
|
|
|
6
|
+
function isVersionGreater(v1, v2) {
|
|
7
|
+
const a = v1.split('.').map(Number);
|
|
8
|
+
const b = v2.split('.').map(Number);
|
|
9
|
+
for (let i = 0; i < 3; i++) {
|
|
10
|
+
if (a[i] > b[i]) return true;
|
|
11
|
+
if (a[i] < b[i]) return false;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
export async function doPublish(version = null) {
|
|
7
17
|
try {
|
|
8
18
|
const publishVersion = await preparePublish(version);
|
|
@@ -13,7 +23,7 @@ export async function doPublish(version = null) {
|
|
|
13
23
|
|
|
14
24
|
const latest = await getPackageVersion(packageName);
|
|
15
25
|
|
|
16
|
-
if (publishVersion
|
|
26
|
+
if (isVersionGreater(publishVersion, latest)) {
|
|
17
27
|
await execSync(
|
|
18
28
|
`npm dist-tag add ${packageName}@${publishVersion} latest`,
|
|
19
29
|
{
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const props = defineProps<{
|
|
3
|
+
id: string
|
|
4
|
+
open: boolean
|
|
5
|
+
toggle: () => void
|
|
6
|
+
}>()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<button @click="props.toggle()" :aria-expanded="props.open" :aria-controls="props.id">
|
|
11
|
+
<slot/>
|
|
12
|
+
</button>
|
|
13
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { ref, useId } from 'vue'
|
|
3
|
+
|
|
4
|
+
const id = ref(useId())
|
|
5
|
+
const accordion = ref<HTMLDivElement>()
|
|
6
|
+
const open = ref(false)
|
|
7
|
+
|
|
8
|
+
function toggle() {
|
|
9
|
+
open.value = !open.value
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<template>
|
|
14
|
+
<div ref="accordion">
|
|
15
|
+
<slot :id="id" :open="open" :toggle="toggle"/>
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
@@ -5,6 +5,10 @@ import SrlArticleRoot from '#components/Srl/Article/Root.vue';
|
|
|
5
5
|
import SrlArticleDialogButton from '#components/Srl/Article/DialogButton.vue';
|
|
6
6
|
import SrlMenu from '#components/Srl/Menu/List.vue';
|
|
7
7
|
import SrlPageDialog from '#components/Srl/Page/Dialog.vue';
|
|
8
|
+
import SrlNoteAccordion from '#components/Srl/Note/Accordion.vue';
|
|
9
|
+
import SrlNoteAccordionToggle from '#components/Srl/Note/Accordion/Toggle.vue';
|
|
10
|
+
import SrlNoteAccordionContent from '#components/Srl/Note/Accordion/Content.vue';
|
|
11
|
+
|
|
8
12
|
import asyncLdComponent from './asyncLdComponent.ts';
|
|
9
13
|
|
|
10
14
|
export default {
|
|
@@ -12,6 +16,9 @@ export default {
|
|
|
12
16
|
app.component('SrlAriaTabChain', defineComponent(SrlAriaTabChain));
|
|
13
17
|
app.component('SrlArticleAutoload', defineComponent(SrlArticleAutoload));
|
|
14
18
|
app.component('SrlArticleRoot', defineComponent(SrlArticleRoot));
|
|
19
|
+
app.component('SrlNoteAccordion', defineComponent(SrlNoteAccordion));
|
|
20
|
+
app.component('SrlNoteAccordionToggle', defineComponent(SrlNoteAccordionToggle));
|
|
21
|
+
app.component('SrlNoteAccordionContent', defineComponent(SrlNoteAccordionContent));
|
|
15
22
|
app.component(
|
|
16
23
|
'SrlArticleDialogButton',
|
|
17
24
|
defineComponent(SrlArticleDialogButton),
|
package/srl/utils/html.ts
CHANGED
|
@@ -1,13 +1,109 @@
|
|
|
1
1
|
import { isRouterPath } from '#utils/uri.ts';
|
|
2
2
|
import { useArticles, useLocale, addCssStyles } from '#composables';
|
|
3
3
|
|
|
4
|
+
type AttrObj = { [key: string]: string | null };
|
|
4
5
|
function attributesToString(attributes: Record<string, string | null>): string {
|
|
5
6
|
return Object.entries(attributes)
|
|
6
7
|
.map(([key, value]) => (value !== null ? `${key}="${value}"` : key))
|
|
7
8
|
.join(' ');
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
|
|
11
|
+
function replaceAccordionContainer(text: string): string {
|
|
12
|
+
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion\s[^"']*["'][^>]*)>/gi;
|
|
13
|
+
let result = '';
|
|
14
|
+
let lastIndex = 0;
|
|
15
|
+
let match;
|
|
16
|
+
|
|
17
|
+
while ((match = openTagRegex.exec(text)) !== null) {
|
|
18
|
+
const start = match.index;
|
|
19
|
+
const attrs = match[1];
|
|
20
|
+
let depth = 1;
|
|
21
|
+
let end = openTagRegex.lastIndex;
|
|
22
|
+
|
|
23
|
+
while (depth > 0) {
|
|
24
|
+
const nextOpen = text.indexOf('<div', end);
|
|
25
|
+
const nextClose = text.indexOf('</div>', end);
|
|
26
|
+
if (nextClose === -1) break;
|
|
27
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
28
|
+
depth++;
|
|
29
|
+
end = nextOpen + 4;
|
|
30
|
+
} else {
|
|
31
|
+
depth--;
|
|
32
|
+
end = nextClose + 6;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const innerContent = replaceAccordionContainer(text.slice(openTagRegex.lastIndex, end - 6));
|
|
37
|
+
|
|
38
|
+
result += text.slice(lastIndex, start);
|
|
39
|
+
result += `<srl-note-accordion${attrs}>${innerContent}</srl-note-accordion>`;
|
|
40
|
+
lastIndex = end;
|
|
41
|
+
openTagRegex.lastIndex = end;
|
|
42
|
+
}
|
|
43
|
+
result += text.slice(lastIndex);
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function replaceAccordionToggle(text: string): string {
|
|
48
|
+
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion__head\s[^"']*["'][^>]*)>/gi;
|
|
49
|
+
let result = '';
|
|
50
|
+
let lastIndex = 0;
|
|
51
|
+
let match;
|
|
52
|
+
|
|
53
|
+
while ((match = openTagRegex.exec(text)) !== null) {
|
|
54
|
+
const start = match.index;
|
|
55
|
+
const attrs = match[1];
|
|
56
|
+
const contentStart = openTagRegex.lastIndex;
|
|
57
|
+
const closeTag = '</div>';
|
|
58
|
+
const end = text.indexOf(closeTag, contentStart);
|
|
59
|
+
if (end === -1) break;
|
|
60
|
+
|
|
61
|
+
const innerContent = text.slice(contentStart, end);
|
|
62
|
+
|
|
63
|
+
result += text.slice(lastIndex, start);
|
|
64
|
+
result += `<srl-note-accordion-toggle${attrs}>${innerContent}</srl-note-accordion-toggle>`;
|
|
65
|
+
lastIndex = end + closeTag.length;
|
|
66
|
+
openTagRegex.lastIndex = lastIndex;
|
|
67
|
+
}
|
|
68
|
+
result += text.slice(lastIndex);
|
|
69
|
+
return result;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function replaceAccordionContent(text: string): string {
|
|
73
|
+
const openTagRegex = /<div([^>]*\bclass\s*=\s*["']lc-accordion__content(?:\s[^"']*)?["'][^>]*)>/gi;
|
|
74
|
+
let result = '';
|
|
75
|
+
let lastIndex = 0;
|
|
76
|
+
let match;
|
|
77
|
+
|
|
78
|
+
while ((match = openTagRegex.exec(text)) !== null) {
|
|
79
|
+
const start = match.index;
|
|
80
|
+
const attrs = match[1];
|
|
81
|
+
let depth = 1;
|
|
82
|
+
let end = openTagRegex.lastIndex;
|
|
83
|
+
|
|
84
|
+
while (depth > 0) {
|
|
85
|
+
const nextOpen = text.indexOf('<div', end);
|
|
86
|
+
const nextClose = text.indexOf('</div>', end);
|
|
87
|
+
if (nextClose === -1) break;
|
|
88
|
+
if (nextOpen !== -1 && nextOpen < nextClose) {
|
|
89
|
+
depth++;
|
|
90
|
+
end = nextOpen + 4;
|
|
91
|
+
} else {
|
|
92
|
+
depth--;
|
|
93
|
+
end = nextClose + 6;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const innerContent = replaceAccordionContent(text.slice(openTagRegex.lastIndex, end - 6));
|
|
98
|
+
|
|
99
|
+
result += text.slice(lastIndex, start);
|
|
100
|
+
result += `<srl-note-accordion-content${attrs}>${innerContent}</srl-note-accordion-content>`;
|
|
101
|
+
lastIndex = end;
|
|
102
|
+
openTagRegex.lastIndex = end;
|
|
103
|
+
}
|
|
104
|
+
result += text.slice(lastIndex);
|
|
105
|
+
return result;
|
|
106
|
+
}
|
|
11
107
|
|
|
12
108
|
export function prepareHtmlContent(text: string): string {
|
|
13
109
|
const articles = useArticles();
|
|
@@ -73,6 +169,10 @@ export function prepareHtmlContent(text: string): string {
|
|
|
73
169
|
(_match, name, content) => `<template #${name}>${content}</template>`
|
|
74
170
|
);
|
|
75
171
|
|
|
172
|
+
text = replaceAccordionContainer(text)
|
|
173
|
+
text = replaceAccordionToggle(text)
|
|
174
|
+
text = replaceAccordionContent(text)
|
|
175
|
+
|
|
76
176
|
text = text.replaceAll('../', `./`);
|
|
77
177
|
|
|
78
178
|
text = text.replace(/<style[^>]*>([\s\S]*?)<\/style>/gi, (match, p1) => {
|