@simple-reporting/base 1.0.28 → 1.0.29

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 CHANGED
@@ -24,7 +24,7 @@
24
24
  "postinstall": "srl prepare"
25
25
  },
26
26
  "dependencies": {
27
- "@simple-reporting/base": "^1.0.28",
27
+ "@simple-reporting/base": "^1.0.29",
28
28
  "axios": "^1.12.2",
29
29
  "chalk": "^5.6.2",
30
30
  "exceljs": "^4.4.0",
@@ -1,5 +1,5 @@
1
1
  <div class="srl-table">
2
- <srl-ld-table data-remove-from-xhtml="transient" data-remove-from-pdf="transient">
2
+ <srl-ld-table data-replace-tag="div" data-remove-from-xhtml="transient" data-remove-from-pdf="transient">
3
3
  <div ref="wrapper" class="srl-table__container" doc-include="nswow-table">
4
4
  <p class="srl-grid srl-paragraph">
5
5
  <span class="srl-grid__inner srl-paragraph__text">
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-reporting/base",
3
- "version": "1.0.28",
3
+ "version": "1.0.29",
4
4
  "description": "Manage srl templates, build and publish",
5
5
  "repository": {
6
6
  "url": "https://github.com/mmssolutionsio/simple-reporting-library"
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from 'node:fs';
2
- import { join, relative } from 'node:path/posix';
2
+ import { join } from 'node:path/posix';
3
3
  import { execSync } from 'node:child_process';
4
4
  import folders from '../scripts/folders.js';
5
5
  import { beaver } from '../scripts/beaver.js';
@@ -77,11 +77,17 @@ function checkForUpdates() {
77
77
  try {
78
78
  if (!data.version) return;
79
79
 
80
+ /*
80
81
  const tag = `v${data.version.split('.')[0]}-lts`;
81
82
 
82
83
  const latest = execSync(`npm view ${packageName}@${tag} version`)
83
84
  .toString()
84
85
  .trim();
86
+ */
87
+
88
+ const latest = execSync(`npm view ${packageName} version`)
89
+ .toString()
90
+ .trim();
85
91
 
86
92
  if (isVersionGreater(latest, data.version)) {
87
93
  printPromptsMessage([
@@ -1,24 +1,24 @@
1
1
  import { computed, type ComputedRef } from 'vue';
2
- import { useRoute } from 'vue-router';
2
+ import { useInstance } from '#composables/instance.ts'
3
3
  import useArticles from './articles';
4
4
 
5
5
  const articles = useArticles();
6
+ const instance = useInstance();
6
7
 
7
- export default function useArticle(): ComputedRef<NsWowArticle | undefined> {
8
- const route = useRoute();
9
- return computed<NsWowArticle | undefined>(() => {
10
- const slug = route.params.slug
11
- ? (route.params.slug[0] as string)
12
- : undefined;
13
- const article = !slug
14
- ? articles.value.find((article) => article.index)
15
- : articles.value.find((article) => article.slug === slug);
8
+ const slug = computed(() => {
9
+ return instance.value?.config.globalProperties.$route?.params?.slug
10
+ ? (instance.value?.config.globalProperties.$route?.params?.slug[0] as string)
11
+ : undefined;
12
+ });
16
13
 
17
- if (!article) {
18
- console.error(`Article not found for slug: ${route.path}`);
19
- return undefined;
20
- }
14
+ const article = computed<NsWowArticle | undefined>(() => {
15
+ const slugValue = slug.value;
16
+ const a = articles.value
17
+ return !slugValue
18
+ ? a.find((article) => article.index)
19
+ : a.find((article) => article.slug === slugValue);
20
+ });
21
21
 
22
- return article;
23
- });
22
+ export default function useArticle(): ComputedRef<NsWowArticle | undefined> {
23
+ return article;
24
24
  }
@@ -29,11 +29,17 @@
29
29
  */
30
30
  import { computed, type ComputedRef } from 'vue';
31
31
  import useConfig from './config.ts';
32
+ import { useInstance } from '#composables/instance.ts';
32
33
 
33
34
  const config = useConfig();
35
+ const instance = useInstance();
36
+ const locale = computed(() => instance.value?.config.globalProperties.$route.params.locale);
34
37
 
35
38
  const articles = computed<NsWowArticle[]>(
36
- () => config.value?.articles[config.value.locale],
39
+ () => {
40
+ const lang = locale.value || config.value.locale;
41
+ return config.value?.articles[lang] ?? [];
42
+ },
37
43
  );
38
44
 
39
45
  export default function useArticles(): ComputedRef<NsWowArticle[]> {
@@ -1,3 +1,4 @@
1
+ import _instance from './instance';
1
2
  import _useArticle from './article';
2
3
  import _useArticles from './articles';
3
4
  import _useConfig from './config';
@@ -10,6 +11,8 @@ import _useViewPort from './viewPort';
10
11
  import _useLanguageSwitch from './languageSwitch';
11
12
  import * as cssStyles from './cssStyles.ts'
12
13
 
14
+ export const setInstance = _instance.setInstance;
15
+ export const useInstance = _instance.useInstance;
13
16
  export const useArticle = _useArticle;
14
17
  export const useArticles = _useArticles;
15
18
  export const useConfig = _useConfig;
@@ -24,6 +27,8 @@ export const addCssStyles = cssStyles.addCssStyles;
24
27
  export const useCssStyles = cssStyles.useCssStyles;
25
28
 
26
29
  export default {
30
+ setInstance,
31
+ useInstance,
27
32
  useArticle,
28
33
  useArticles,
29
34
  useConfig,
@@ -0,0 +1,13 @@
1
+ import { ref } from 'vue';
2
+ const app = ref();
3
+
4
+ export function setInstance(instance) {
5
+ app.value = instance;
6
+ }
7
+ export function useInstance() {
8
+ return app;
9
+ }
10
+ export default {
11
+ setInstance,
12
+ useInstance,
13
+ }
@@ -23,9 +23,6 @@ const languageSwitch = computed<NsWowLanguageSwitch>(() => {
23
23
  res.items.push({
24
24
  label: locale,
25
25
  href: `/${locale}`,
26
- callback: () => {
27
- Tr.switchLanguage(locale)
28
- }
29
26
  })
30
27
  }
31
28
  }
@@ -1,8 +1,10 @@
1
1
  import { setConfig } from '#composables/config';
2
+ import { setInstance } from '#composables/instance.ts'
2
3
  import { createApp } from 'vue';
3
4
  import { initI18n } from '@/i18n';
4
5
  import srlVuePlugin from '#plugins/vueSrlPlugin';
5
6
  import { clearPageState } from '#utils'
7
+ import Translate from '@/i18n/translation.ts'
6
8
 
7
9
  import '#imports/app.scss';
8
10
 
@@ -10,15 +12,24 @@ import SrlPageApp from '../App.vue';
10
12
  import router from '@/router';
11
13
 
12
14
  export default async function initProject() {
15
+ const config = await setConfig();
13
16
  router.beforeEach((to, from, next) => {
14
17
  clearPageState();
15
18
  next();
16
19
  });
17
- await setConfig();
20
+ router.afterEach(() => {
21
+ if (
22
+ router.currentRoute.value.params.locale
23
+ && config.value.locale !== router.currentRoute.value.params.locale
24
+ ) {
25
+ Translate.switchLanguage(router.currentRoute.value.params.locale as string);
26
+ }
27
+ })
18
28
  const i18n = initI18n();
19
29
  const app = (window.app = createApp(SrlPageApp));
20
30
  app.use(i18n);
21
31
  app.use(router);
22
32
  app.use(srlVuePlugin);
33
+ setInstance(app);
23
34
  return app;
24
35
  }
@@ -1,5 +1,5 @@
1
- import { isRouterPath, isExternalPath } from './uri';
2
- import { camelCase } from './camelCase';
1
+ import { isFilePath, isRouterPath, isExternalPath } from './uri';
2
+ import { camelCase } from './string';
3
3
  import { prepareHtmlContent } from './html';
4
4
  import {
5
5
  usePageState,
@@ -15,6 +15,7 @@ import {
15
15
  } from './pageState.ts';
16
16
 
17
17
  export {
18
+ isFilePath,
18
19
  isRouterPath,
19
20
  isExternalPath,
20
21
  camelCase,
@@ -1,36 +1,47 @@
1
+ export function isFilePath(path: string): boolean {
2
+ return (
3
+ path.endsWith('.pdf') ||
4
+ path.endsWith('.doc') ||
5
+ path.endsWith('.docx') ||
6
+ path.endsWith('.xls') ||
7
+ path.endsWith('.xlsx') ||
8
+ path.endsWith('.ppt') ||
9
+ path.endsWith('.pptx') ||
10
+ path.endsWith('.zip') ||
11
+ path.endsWith('.html') ||
12
+ path.endsWith('.htm') ||
13
+ path.endsWith('.php') ||
14
+ path.endsWith('.asp') ||
15
+ path.endsWith('.aspx') ||
16
+ path.endsWith('.jsp') ||
17
+ path.endsWith('.xml') ||
18
+ path.endsWith('.json') ||
19
+ path.endsWith('.txt') ||
20
+ path.endsWith('.svg') ||
21
+ path.endsWith('.png') ||
22
+ path.endsWith('.jpg') ||
23
+ path.endsWith('.jpeg') ||
24
+ path.endsWith('.gif') ||
25
+ path.endsWith('.webp')
26
+ );
27
+ }
28
+
1
29
  export function isRouterPath(path: string): boolean {
2
30
  return (
3
- (path.startsWith('/') || path.startsWith('./')) &&
4
- !path.startsWith('//') &&
5
- !path.startsWith('javascript:') &&
6
- !path.endsWith('.html') &&
7
- !path.endsWith('.htm') &&
8
- !path.endsWith('.php') &&
9
- !path.endsWith('.asp') &&
10
- !path.endsWith('.aspx') &&
11
- !path.endsWith('.jsp') &&
12
- !path.endsWith('.xml') &&
13
- !path.endsWith('.json') &&
14
- !path.endsWith('.txt') &&
15
- !path.endsWith('.svg') &&
16
- !path.endsWith('.png') &&
17
- !path.endsWith('.jpg') &&
18
- !path.endsWith('.jpeg') &&
19
- !path.endsWith('.gif') &&
20
- !path.endsWith('.webp') &&
21
- !path.endsWith('.pdf') &&
22
- !path.endsWith('.doc') &&
23
- !path.endsWith('.docx') &&
24
- !path.endsWith('.xls') &&
25
- !path.endsWith('.xlsx') &&
26
- !path.endsWith('.ppt') &&
27
- !path.endsWith('.pptx') &&
28
- !path.endsWith('.zip')
31
+ (
32
+ (
33
+ path.startsWith('/') &&
34
+ !path.startsWith('//')
35
+ ) ||
36
+ path.startsWith('./')
37
+ ) &&
38
+ !isFilePath(path)
29
39
  );
30
40
  }
31
41
 
32
42
  export function isExternalPath(path: string): boolean {
33
43
  return (
44
+ isFilePath(path) ||
34
45
  path.startsWith('http') ||
35
46
  path.startsWith('//') ||
36
47
  path.startsWith('mailto') ||
@@ -49,6 +60,7 @@ export function isExternalPath(path: string): boolean {
49
60
  }
50
61
 
51
62
  export default {
63
+ isFilePath,
52
64
  isRouterPath,
53
65
  isExternalPath,
54
66
  };
File without changes