tsv2-library 0.0.1

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.
Files changed (40) hide show
  1. package/README.md +1 -0
  2. package/dist/components/v2/Button/Button.vue.d.ts +4 -0
  3. package/dist/components/v2/Button/Button.vue.d.ts.map +1 -0
  4. package/dist/components/v2/Checkbox/Checkbox.vue.d.ts +4 -0
  5. package/dist/components/v2/Checkbox/Checkbox.vue.d.ts.map +1 -0
  6. package/dist/components/v2/icon/Icon.vue.d.ts +4 -0
  7. package/dist/components/v2/icon/Icon.vue.d.ts.map +1 -0
  8. package/dist/components/v2/index.d.ts +8 -0
  9. package/dist/img/TS-FULL-BLACK.png +0 -0
  10. package/dist/img/TS-FULL-WHITE.png +0 -0
  11. package/dist/img/TS-HEAD-BLACK.png +0 -0
  12. package/dist/img/TS-HEAD-WHITE.png +0 -0
  13. package/dist/main.d.ts +0 -0
  14. package/dist/routers/index.d.ts +2 -0
  15. package/dist/services/category.service.d.ts +4 -0
  16. package/dist/services/group.service.d.ts +4 -0
  17. package/dist/services/scanner.service.d.ts +10 -0
  18. package/dist/services/scanner_old.service.d.ts +9 -0
  19. package/dist/tsv2-library.cjs.js +79 -0
  20. package/dist/tsv2-library.cjs.js.map +1 -0
  21. package/dist/tsv2-library.es.js +2771 -0
  22. package/dist/tsv2-library.es.js.map +1 -0
  23. package/dist/tsv2-library.umd.js +79 -0
  24. package/dist/tsv2-library.umd.js.map +1 -0
  25. package/dist/types/columns.d.ts +26 -0
  26. package/dist/types/fieldValidation.type.d.ts +8 -0
  27. package/dist/types/options.d.ts +9 -0
  28. package/dist/types/table.type.d.ts +28 -0
  29. package/dist/utils/date.util.d.ts +4 -0
  30. package/dist/utils/exportToExcel.util.d.ts +7 -0
  31. package/dist/utils/index.d.ts +8 -0
  32. package/dist/utils/string.util.d.ts +4 -0
  33. package/dist/utils/textFormater.util.d.ts +3 -0
  34. package/dist/vite.svg +1 -0
  35. package/package.json +103 -0
  36. package/src/utils/date.util.ts +58 -0
  37. package/src/utils/exportToExcel.util.ts +32 -0
  38. package/src/utils/index.ts +45 -0
  39. package/src/utils/string.util.ts +23 -0
  40. package/src/utils/textFormater.util.ts +46 -0
@@ -0,0 +1,26 @@
1
+ import { Component } from 'vue';
2
+ export type TableColumn = {
3
+ header: string;
4
+ field: string;
5
+ style?: string;
6
+ sortable?: boolean;
7
+ bodyStyle?: (props: any) => string;
8
+ bodyTemplate?: (data: any) => string;
9
+ bodyComponent?: (data: any) => {
10
+ component: string | Component;
11
+ props?: any;
12
+ model?: any;
13
+ events?: any;
14
+ onChange?: any;
15
+ disabled?: boolean;
16
+ };
17
+ headerTemplate?: () => string;
18
+ headerComponent?: () => {
19
+ component: string | Component;
20
+ props?: any;
21
+ model?: any;
22
+ events?: any;
23
+ onChange?: any;
24
+ disabled?: boolean;
25
+ };
26
+ };
@@ -0,0 +1,8 @@
1
+ import { FieldContext } from 'vee-validate';
2
+ import { Ref } from 'vue';
3
+ type FieldValue = string | string[] | number | number[] | boolean | undefined | null | object;
4
+ export type FieldValidation = {
5
+ value?: FieldValue;
6
+ errorMessage?: Ref<string | undefined>;
7
+ } | FieldContext;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ export type MenuOption = {
2
+ label: string;
3
+ command: (data?: any) => any;
4
+ icon?: string;
5
+ items?: any[];
6
+ class?: string;
7
+ disabled?: boolean | any;
8
+ danger?: boolean;
9
+ };
@@ -0,0 +1,28 @@
1
+ import { Component } from 'vue';
2
+ export type TableColumn = {
3
+ header: string;
4
+ field: string;
5
+ style?: string;
6
+ sortable?: boolean;
7
+ bodyStyle?: (props: any) => string;
8
+ bodyTemplate?: (data: any) => string | undefined;
9
+ bodyComponent?: (data: any) => {
10
+ component: string | Component;
11
+ props?: any;
12
+ model?: any;
13
+ events?: any;
14
+ onChange?: any;
15
+ disabled?: boolean;
16
+ };
17
+ };
18
+ export type TableOption = {
19
+ label?: string;
20
+ command?: (data?: any) => any;
21
+ icon?: string;
22
+ items?: any[];
23
+ class?: string;
24
+ disabled?: boolean | any;
25
+ separator?: boolean;
26
+ danger?: boolean;
27
+ visible?: boolean | any;
28
+ };
@@ -0,0 +1,4 @@
1
+ declare const DateUtils: {
2
+ formatDate: (date: string, useTime?: boolean) => string;
3
+ };
4
+ export default DateUtils;
@@ -0,0 +1,7 @@
1
+ interface IExcelOptions {
2
+ headers: string[];
3
+ data: object[];
4
+ filename: string;
5
+ }
6
+ declare const exportToExcel: (options: IExcelOptions) => Promise<void>;
7
+ export default exportToExcel;
@@ -0,0 +1,8 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { formatUserName, formatVowelSoundLabel } from './textFormater.util';
3
+ import exportToExcel from './exportToExcel.util';
4
+ declare const isObjectEmpty: (obj: object) => boolean;
5
+ declare const addTokenExpirationHandling: (instance: AxiosInstance) => void;
6
+ declare const filterSelectedTreeKeys: (keys: any) => number[];
7
+ declare const getImgURL: (fileName: string) => string;
8
+ export { isObjectEmpty, addTokenExpirationHandling, filterSelectedTreeKeys, getImgURL, formatUserName, formatVowelSoundLabel, exportToExcel, };
@@ -0,0 +1,4 @@
1
+ declare const StringUtils: {
2
+ formatUserName: (name: string) => string;
3
+ };
4
+ export default StringUtils;
@@ -0,0 +1,3 @@
1
+ export declare const formatVowelSoundLabel: (label?: string) => string;
2
+ export declare const formatUserName: (name: string) => string;
3
+ export default formatUserName;
package/dist/vite.svg ADDED
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="31.88" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 257"><defs><linearGradient id="IconifyId1813088fe1fbc01fb466" x1="-.828%" x2="57.636%" y1="7.652%" y2="78.411%"><stop offset="0%" stop-color="#41D1FF"></stop><stop offset="100%" stop-color="#BD34FE"></stop></linearGradient><linearGradient id="IconifyId1813088fe1fbc01fb467" x1="43.376%" x2="50.316%" y1="2.242%" y2="89.03%"><stop offset="0%" stop-color="#FFEA83"></stop><stop offset="8.333%" stop-color="#FFDD35"></stop><stop offset="100%" stop-color="#FFA800"></stop></linearGradient></defs><path fill="url(#IconifyId1813088fe1fbc01fb466)" d="M255.153 37.938L134.897 252.976c-2.483 4.44-8.862 4.466-11.382.048L.875 37.958c-2.746-4.814 1.371-10.646 6.827-9.67l120.385 21.517a6.537 6.537 0 0 0 2.322-.004l117.867-21.483c5.438-.991 9.574 4.796 6.877 9.62Z"></path><path fill="url(#IconifyId1813088fe1fbc01fb467)" d="M185.432.063L96.44 17.501a3.268 3.268 0 0 0-2.634 3.014l-5.474 92.456a3.268 3.268 0 0 0 3.997 3.378l24.777-5.718c2.318-.535 4.413 1.507 3.936 3.838l-7.361 36.047c-.495 2.426 1.782 4.5 4.151 3.78l15.304-4.649c2.372-.72 4.652 1.36 4.15 3.788l-11.698 56.621c-.732 3.542 3.979 5.473 5.943 2.437l1.313-2.028l72.516-144.72c1.215-2.423-.88-5.186-3.54-4.672l-25.505 4.922c-2.396.462-4.435-1.77-3.759-4.114l16.646-57.705c.677-2.35-1.37-4.583-3.769-4.113Z"></path></svg>
package/package.json ADDED
@@ -0,0 +1,103 @@
1
+ {
2
+ "name": "tsv2-library",
3
+ "private": false,
4
+ "version": "0.0.1",
5
+ "author": "fixedassetv2-fe",
6
+ "license": "ISC",
7
+ "homepage": "https://github.com/fixedassetv2-fe/tsv2-library#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/fixedassetv2-fe/tsv2-library.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/fixedassetv2-fe/tsv2-library/issues"
14
+ },
15
+ "type": "module",
16
+ "files": [
17
+ "dist",
18
+ "src/utils"
19
+ ],
20
+ "scripts": {
21
+ "dev": "vite",
22
+ "build": "vue-tsc && vite build",
23
+ "build:dev": "vue-tsc && vite build --watch",
24
+ "build:pub": "npm run build && npm link && npm publish",
25
+ "preview": "vite preview",
26
+ "lint": "eslint . --ext .vue,.js,.ts --fix --ignore-path .gitignore",
27
+ "tailwind": "tailwind -i ./src/assets/css/main.css -o ./cypress/support/tailwind.css",
28
+ "cy:run-ct": "npm run tailwind && cypress run --component",
29
+ "cy:open-ct": "npm run tailwind && cypress open --component",
30
+ "cy:run-e2e": "npm run tailwind && cypress run",
31
+ "cy:open-e2e": "npm run tailwind && cypress open",
32
+ "cy:test-all": "npm run tailwind && start-server-and-test dev http://localhost:8080 cy:run-e2e && npm run cy:run-ct"
33
+ },
34
+ "dependencies": {
35
+ "@vueuse/core": "^10.7.2",
36
+ "axios": "^1.3.4",
37
+ "base64toblob": "^0.0.2",
38
+ "primeicons": "^6.0.1",
39
+ "primevue": "^3.48.0",
40
+ "rfs": "^10.0.0",
41
+ "sass": "^1.62.1",
42
+ "vee-validate": "^4.9.5",
43
+ "vue": "^3.4.15",
44
+ "vue-advanced-cropper": "^2.8.8",
45
+ "vue-router": "^4.1.6",
46
+ "vuex": "^4.0.2",
47
+ "xlsx": "^0.18.5"
48
+ },
49
+ "devDependencies": {
50
+ "@cypress/code-coverage": "^3.12.19",
51
+ "@cypress/vue": "^6.0.0",
52
+ "@originjs/vite-plugin-federation": "^1.3.4",
53
+ "@tsconfig/node18": "^18.2.2",
54
+ "@types/mocha": "^10.0.6",
55
+ "@types/node": "^18.19.3",
56
+ "@typescript-eslint/eslint-plugin": "^6.21.0",
57
+ "@typescript-eslint/parser": "^6.21.0",
58
+ "@vitejs/plugin-vue": "^4.5.2",
59
+ "@vue/eslint-config-typescript": "^12.0.0",
60
+ "@vue/test-utils": "^2.4.3",
61
+ "@vue/tsconfig": "^0.5.0",
62
+ "autoprefixer": "^10.4.17",
63
+ "concurrently": "^8.2.2",
64
+ "cypress": "^13.6.4",
65
+ "eslint": "^8.49.0",
66
+ "eslint-config-ts-code-standard": "^1.0.5",
67
+ "eslint-plugin-css": "^0.9.1",
68
+ "eslint-plugin-cypress": "^2.15.1",
69
+ "eslint-plugin-prettier": "^5.1.3",
70
+ "eslint-plugin-promise": "^6.1.1",
71
+ "eslint-plugin-vue": "^9.21.1",
72
+ "highlight.js": "^11.9.0",
73
+ "istanbul-lib-coverage": "^3.2.2",
74
+ "nyc": "^15.1.0",
75
+ "postcss": "^8.4.35",
76
+ "postcss-nested": "^6.0.1",
77
+ "prettier": "^3.0.3",
78
+ "rollup-plugin-typescript2": "^0.36.0",
79
+ "start-server-and-test": "^2.0.3",
80
+ "tailwindcss": "^3.4.1",
81
+ "ts-node": "^10.9.2",
82
+ "typescript": "^5.1.6",
83
+ "vite": "^5.0.10",
84
+ "vite-plugin-dts": "^3.7.1",
85
+ "vite-plugin-istanbul": "^5.0.0",
86
+ "vue-tsc": "^1.8.25",
87
+ "wait-on": "^7.2.0"
88
+ },
89
+ "description": "Global reusable components for micro frontend",
90
+ "main": "./dist/tsv2-library.umd.js",
91
+ "module": "./dist/tsv2-library.es.js",
92
+ "exports": {
93
+ ".": {
94
+ "import": "./dist/tsv2-library.es.js",
95
+ "require": "./dist/tsv2-library.umd.js"
96
+ },
97
+ "./dist/style.css": {
98
+ "import": "./dist/style.css",
99
+ "require": "./dist/style.css"
100
+ }
101
+ },
102
+ "types": "./dist/main.d.ts"
103
+ }
@@ -0,0 +1,58 @@
1
+ const formatDate = (date: string, useTime?: boolean) => {
2
+ let dateFormat: DateFormat, timeFormat, timeZone;
3
+ interface DateFormat {
4
+ locale: string;
5
+ year: string;
6
+ month: string;
7
+ day: string;
8
+ weekday?: string;
9
+ }
10
+ dateFormat = {
11
+ locale: 'en-gb',
12
+ year: '2-digit',
13
+ month: '2-digit',
14
+ day: '2-digit',
15
+ };
16
+
17
+ const userStr = localStorage.getItem('user');
18
+
19
+ if (userStr) {
20
+ const user = JSON.parse(userStr);
21
+
22
+ if (user.generalSetting.dateFormat) {
23
+ dateFormat = user.generalSetting.dateFormat;
24
+ }
25
+
26
+ if (user.generalSetting.timeFormat) {
27
+ timeFormat = user.generalSetting.timeFormat;
28
+ }
29
+
30
+ if (user.generalSetting.timezone) {
31
+ timeZone = user.generalSetting.timezone;
32
+ }
33
+ }
34
+
35
+ let options: any = {
36
+ year: dateFormat.year,
37
+ month: dateFormat.month,
38
+ day: dateFormat.day,
39
+ weekday: dateFormat.weekday,
40
+ hour12: timeFormat,
41
+ timeZone: timeZone,
42
+ };
43
+
44
+ if (useTime) {
45
+ options = {
46
+ ...options,
47
+ hour: '2-digit',
48
+ minute: '2-digit',
49
+ second: '2-digit',
50
+ };
51
+ }
52
+
53
+ return new Date(date).toLocaleString(dateFormat.locale, options);
54
+ };
55
+
56
+ const DateUtils = { formatDate };
57
+
58
+ export default DateUtils;
@@ -0,0 +1,32 @@
1
+ import * as XLSX from 'xlsx';
2
+
3
+ interface IExcelOptions {
4
+ headers: string[];
5
+ data: object[];
6
+ filename: string;
7
+ }
8
+
9
+ const exportToExcel = async (options: IExcelOptions): Promise<void> => {
10
+ const heading = [options.headers];
11
+ const workbook = XLSX.utils.book_new();
12
+ const workSheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet([]);
13
+ XLSX.utils.sheet_add_aoa(workSheet, heading);
14
+
15
+ XLSX.utils.sheet_add_json(workSheet, options.data, {
16
+ origin: 'A2',
17
+ skipHeader: true,
18
+ });
19
+
20
+ XLSX.utils.book_append_sheet(workbook, workSheet, 'Sheet1');
21
+ const timestamps = new Date()
22
+ .toLocaleDateString('en-gb', {
23
+ day: '2-digit',
24
+ month: '2-digit',
25
+ year: '2-digit',
26
+ })
27
+ .replaceAll('/', '');
28
+
29
+ XLSX.writeFile(workbook, `${options.filename}-${timestamps}.xlsx`);
30
+ };
31
+
32
+ export default exportToExcel;
@@ -0,0 +1,45 @@
1
+ import { AxiosError, AxiosInstance, AxiosResponse } from 'axios';
2
+ import { formatUserName, formatVowelSoundLabel } from './textFormater.util';
3
+ import exportToExcel from './exportToExcel.util';
4
+
5
+ const isObjectEmpty = (obj: object) => {
6
+ if (!obj) return true;
7
+ const keys = Object.keys(obj);
8
+ return !keys.length;
9
+ };
10
+
11
+ const addTokenExpirationHandling = (instance: AxiosInstance) => {
12
+ instance.interceptors.response.use(
13
+ (response: AxiosResponse) => {
14
+ return response;
15
+ },
16
+ (error: AxiosError) => {
17
+ if (error.response?.status === 401) {
18
+ localStorage.removeItem('user');
19
+ window.location.reload();
20
+ }
21
+ },
22
+ );
23
+ };
24
+
25
+ const filterSelectedTreeKeys = (keys: any) => {
26
+ const formatted = Object.entries(keys);
27
+ const filtered = formatted
28
+ .filter((data: any) => data[1].checked && !data[1].partialChecked)
29
+ .map((data) => parseInt(data[0]));
30
+ return filtered;
31
+ };
32
+
33
+ const getImgURL = (fileName: string) => {
34
+ return `https://assets.tagsamurai.com/img/${fileName}`;
35
+ };
36
+
37
+ export {
38
+ isObjectEmpty,
39
+ addTokenExpirationHandling,
40
+ filterSelectedTreeKeys,
41
+ getImgURL,
42
+ formatUserName,
43
+ formatVowelSoundLabel,
44
+ exportToExcel,
45
+ };
@@ -0,0 +1,23 @@
1
+ const formatUserName = (name: string) => {
2
+ if (name.length > 8) {
3
+ const splitted = name.split(' ');
4
+ if (splitted.length > 1) {
5
+ let firstWord;
6
+ const lastWord = splitted[splitted.length - 1];
7
+ const firstToRestWord = splitted.slice(0, -1).join(' ');
8
+ if (firstToRestWord.length > 8) {
9
+ firstWord = `${firstToRestWord.slice(0, 8)}..`;
10
+ } else {
11
+ firstWord = firstToRestWord;
12
+ }
13
+ return `${firstWord} ${lastWord.slice(0, 1)}`;
14
+ }
15
+ const word = splitted[0];
16
+ return word.length > 8 ? `${word.slice(0, 8)}..` : word;
17
+ }
18
+ return name;
19
+ };
20
+
21
+ const StringUtils = { formatUserName };
22
+
23
+ export default StringUtils;
@@ -0,0 +1,46 @@
1
+ export const formatVowelSoundLabel = (label?: string): string => {
2
+ if (!label) return '';
3
+
4
+ const vowelSound = ['a', 'e', 'i', 'o', 'h'];
5
+ const vocalSound = ['a', 'e', 'i', 'o', 'u'];
6
+ const word = label.toLowerCase();
7
+ const firstLetter = word[0];
8
+ const isStartWithVowel = vowelSound.includes(firstLetter);
9
+
10
+ if (firstLetter === 'h') {
11
+ const silent = ['hour', 'honest', 'heir', 'honor'];
12
+ const includeSilent = silent.some((phrase) => word.includes(phrase));
13
+
14
+ if (!vocalSound.includes(word.slice(2, 3)) && !includeSilent)
15
+ return `a ${label}`;
16
+ return `an ${label}`;
17
+ }
18
+
19
+ return isStartWithVowel ||
20
+ (firstLetter === 'u' && !vowelSound.includes(word.slice(2, 3)))
21
+ ? `an ${label}`
22
+ : `a ${label}`;
23
+ };
24
+
25
+ export const formatUserName = (name: string): string => {
26
+ if (name.length <= 8) return name;
27
+
28
+ const splitted = name.split(' ');
29
+
30
+ if (splitted.length === 1) {
31
+ return `${splitted[0].slice(0, 8)}..`;
32
+ }
33
+
34
+ const firstToRestWord = splitted.slice(0, -1).join(' ');
35
+
36
+ const firstWord =
37
+ firstToRestWord.length > 8
38
+ ? `${firstToRestWord.slice(0, 8)}..`
39
+ : firstToRestWord;
40
+
41
+ const lastWord = splitted[splitted.length - 1];
42
+
43
+ return `${firstWord} ${lastWord.slice(0, 1)}`;
44
+ };
45
+
46
+ export default formatUserName;