@simple-reporting/base 1.0.27 → 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.27",
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-xbrl="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">
@@ -1,7 +1,7 @@
1
1
  <div class="srl-video" data-remove-from-word="complete">
2
2
  <div class="srl-grid srl-grid--media">
3
3
  <div class="srl-grid__inner srl-video__inner">
4
- <srl-ld-video data-remove-from-xbrl="transient" data-remove-from-pdf="transient">
4
+ <srl-ld-video data-remove-from-xhtml="transient" data-remove-from-pdf="transient">
5
5
  <div class="srl-video__video-container" doc-html="free-html" data-remove-from-pdf="complete"></div>
6
6
  <img class="srl-video__thumbnail" doc-image="video-thumbnail"></img>
7
7
  <div class="srl-video__play" data-remove-from-pdf="complete">
@@ -1,4 +1,4 @@
1
- <p class="srl-anchor srl-editor-component" data-remove-from-translate-plus="true" data-remove-from-xhtml="complete"
1
+ <p class="srl-anchor srl-editor-component" data-remove-from-translate-plus="true" data-remove-from-word="complete" data-remove-from-xhtml="complete"
2
2
  data-is-anchor="true">
3
3
  <span class="srl-anchor__text srl-editor-component__text" doc-editable="anchor-text">
4
4
  Must start with a letter (A–Z or a–z); a number is not allowed. After the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simple-reporting/base",
3
- "version": "1.0.27",
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([
package/scripts/beaver.js CHANGED
@@ -126,6 +126,11 @@ function hasPointsOutsideOfParentheses(text) {
126
126
  return false;
127
127
  }
128
128
 
129
+ function isUnitSize(value) {
130
+ const unitSizePattern = /^-?\d*\.?\d+(px|em|rem|%|vw|vh|vmin|vmax|cm|mm|in|pt|pc|ex|ch)?$/;
131
+ return unitSizePattern.test(value);
132
+ }
133
+
129
134
  /**
130
135
  * Converts a JavaScript object into SCSS variables.
131
136
  *
@@ -155,6 +160,7 @@ function makeScssVariables(values, indent = 2) {
155
160
  if (
156
161
  typeof values === 'string' &&
157
162
  values !== `""` &&
163
+ !isUnitSize(values) &&
158
164
  (hasPointsOutsideOfParentheses(values) ||
159
165
  hasCommasOutsideOfParentheses(values))
160
166
  ) {
package/scripts/build.js CHANGED
@@ -1065,7 +1065,11 @@ async function mapJs() {
1065
1065
 
1066
1066
  for (let i = 0; i < jsFiles.length; i++) {
1067
1067
  const file = jsFiles[i];
1068
- const className = camelCase(file.parent.name);
1068
+ let className = file.parent.name.split('.');
1069
+ if (className.length > 1) {
1070
+ className.shift();
1071
+ }
1072
+ className = camelCase(className.join('.'));
1069
1073
  const path = [file.name];
1070
1074
  let parent = file.parent;
1071
1075
  while (parent) {
@@ -1,6 +1,7 @@
1
1
  @use "variables";
2
2
  @use "../system";
3
3
  @use "sass:map";
4
+ @use "sass:meta";
4
5
 
5
6
  @each $spacer, $spacerValue in variables.$spacer {
6
7
  $varName: #{variables.$variable-prefix}spacer-#{$spacer};
@@ -20,35 +21,70 @@
20
21
  @if map.has-key($spacerValue, media) {
21
22
  @each $breakpoint, $breakpointValue in map.get($spacerValue, media) {
22
23
  @if $breakpoint == print {
23
- @include system.add-root-style(
24
- $varName,
25
- system.size-unit(map.get($breakpointValue, size)),
26
- print
27
- );
28
- } @else if $breakpoint == up {
29
- @each $upBreakpoint, $upBreakpointValue in $breakpointValue {
24
+ @if (meta.type-of($breakpointValue) == 'map' and map.has-key($breakpointValue, size)) {
25
+ @include system.add-root-style(
26
+ $varName,
27
+ system.size-unit(map.get($breakpointValue, size)),
28
+ print
29
+ );
30
+ } @else {
30
31
  @include system.add-root-style(
31
32
  $varName,
32
- system.size-unit($upBreakpointValue),
33
- $upBreakpoint,
34
- up
33
+ system.size-unit($breakpointValue),
34
+ print
35
35
  );
36
36
  }
37
+
38
+ } @else if $breakpoint == up {
39
+ @each $upBreakpoint, $upBreakpointValue in $breakpointValue {
40
+ @if meta.type-of($upBreakpointValue) == 'map' and map.has-key($upBreakpointValue, size) {
41
+ @include system.add-root-style(
42
+ $varName,
43
+ system.size-unit(map.get($upBreakpointValue, size)),
44
+ $upBreakpoint,
45
+ up
46
+ );
47
+ } @else {
48
+ @include system.add-root-style(
49
+ $varName,
50
+ system.size-unit($upBreakpointValue),
51
+ $upBreakpoint,
52
+ up
53
+ );
54
+ }
55
+ }
37
56
  } @else if $breakpoint == down {
38
57
  @each $downBreakpoint, $downBreakpointValue in $breakpointValue {
58
+ @if meta.type-of($downBreakpointValue) == 'map' and map.has-key($downBreakpointValue, size) {
59
+ @include system.add-root-style(
60
+ $varName,
61
+ system.size-unit(map.get($downBreakpointValue, size)),
62
+ $downBreakpoint,
63
+ down
64
+ );
65
+ } @else {
66
+ @include system.add-root-style(
67
+ $varName,
68
+ system.size-unit($downBreakpointValue),
69
+ $downBreakpoint,
70
+ down
71
+ );
72
+ }
73
+ }
74
+ } @else {
75
+ @if meta.type-of($breakpointValue) == 'map' and map.has-key($breakpointValue, size) {
39
76
  @include system.add-root-style(
40
77
  $varName,
41
- system.size-unit($downBreakpointValue),
42
- $downBreakpoint,
43
- down
78
+ system.size-unit(map.get($breakpointValue, size)),
79
+ $breakpoint
80
+ );
81
+ } @else {
82
+ @include system.add-root-style(
83
+ $varName,
84
+ system.size-unit($breakpointValue),
85
+ $breakpoint
44
86
  );
45
87
  }
46
- } @else {
47
- @include system.add-root-style(
48
- $varName,
49
- system.size-unit($breakpointValue),
50
- $breakpoint
51
- );
52
88
  }
53
89
  }
54
90
  }
@@ -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