@etsoo/appscript 1.2.75 → 1.2.76

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.
@@ -0,0 +1,9 @@
1
+ import { BusinessUtils } from '../../src/business/BusinessUtils';
2
+
3
+ test('Tests for BusinessUtils.formatAvatarTitle', () => {
4
+ // Assert
5
+ expect(BusinessUtils.formatAvatarTitle('Garry Xiao')).toBe('GX');
6
+ expect(BusinessUtils.formatAvatarTitle('Etsoo')).toBe('ME');
7
+ expect(BusinessUtils.formatAvatarTitle('Etsoo', 3, 'E')).toBe('E');
8
+ expect(BusinessUtils.formatAvatarTitle('Etsoo', 5)).toBe('ETSOO');
9
+ });
@@ -6,6 +6,14 @@ import { ProductUnit } from './ProductUnit';
6
6
  * Business utils
7
7
  */
8
8
  export declare namespace BusinessUtils {
9
+ /**
10
+ * Format avatar title
11
+ * @param title Title
12
+ * @param maxChars Max characters
13
+ * @param defaultTitle Default title
14
+ * @returns Result
15
+ */
16
+ function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
9
17
  /**
10
18
  * Get currency collection
11
19
  * @param currencyNames Names like CNY, USD
@@ -2,13 +2,45 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BusinessUtils = void 0;
4
4
  const shared_1 = require("@etsoo/shared");
5
- const __1 = require("..");
6
5
  const ProductUnit_1 = require("./ProductUnit");
6
+ const RepeatOption_1 = require("./RepeatOption");
7
7
  /**
8
8
  * Business utils
9
9
  */
10
10
  var BusinessUtils;
11
11
  (function (BusinessUtils) {
12
+ /**
13
+ * Format avatar title
14
+ * @param title Title
15
+ * @param maxChars Max characters
16
+ * @param defaultTitle Default title
17
+ * @returns Result
18
+ */
19
+ function formatAvatarTitle(title, maxChars = 3, defaultTitle = 'ME') {
20
+ // Just return for empty cases
21
+ if (title == null || title === '')
22
+ return defaultTitle;
23
+ // split with words
24
+ const items = title.trim().split(/\s+/g);
25
+ if (items.length === 1) {
26
+ // 2-3 Chinese names
27
+ const titleLen = title.length;
28
+ if (titleLen <= maxChars)
29
+ return title.toUpperCase();
30
+ // Return default for simplicity
31
+ return defaultTitle;
32
+ }
33
+ // First letter of each item
34
+ var firstLetters = items
35
+ .map((item) => item[0])
36
+ .join('')
37
+ .toUpperCase();
38
+ const flen = firstLetters.length;
39
+ if (flen <= maxChars)
40
+ return firstLetters;
41
+ return defaultTitle;
42
+ }
43
+ BusinessUtils.formatAvatarTitle = formatAvatarTitle;
12
44
  /**
13
45
  * Get currency collection
14
46
  * @param currencyNames Names like CNY, USD
@@ -90,7 +122,7 @@ var BusinessUtils;
90
122
  * @returns Units
91
123
  */
92
124
  function getRepeatOptions(func, options, isJoined = true) {
93
- options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(__1.RepeatOption));
125
+ options !== null && options !== void 0 ? options : (options = shared_1.DataTypes.getEnumKeys(RepeatOption_1.RepeatOption));
94
126
  isJoined !== null && isJoined !== void 0 ? isJoined : (isJoined = true);
95
127
  return getUnits(func, options, isJoined);
96
128
  }
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}' already exists",
54
54
  "loading": "Loading...",
55
55
  "login": "Login",
56
+ "me": "ME",
56
57
  "menuHome": "Home",
57
58
  "message": "Message",
58
59
  "mobile": "Mobile number",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "Employer identification number",
141
142
  "timeDifferenceInvalid": "The time difference between the device and the server is {0}, which exceeds the limit of {1} seconds. Please adjust the device time. If it is abnormal, please inform the administrator",
142
143
  "tokenExpiry": "Your session is about to expire. Click the Cancel button to continue",
144
+ "type": "Type",
143
145
  "yes": "Yes",
144
146
  "unknownError": "Unknown Error",
145
147
  "unitJoin": "per {0}",
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}'已经存在",
54
54
  "loading": "正在加载...",
55
55
  "login": "登录",
56
+ "me": "我",
56
57
  "menuHome": "首页",
57
58
  "message": "留言",
58
59
  "mobile": "手机号码",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "雇主识别号码(EIN)",
141
142
  "timeDifferenceInvalid": "设备时间和服务器时间差为{0},超过{1}秒的限制,请调整设备时间,如果异常请告知管理员",
142
143
  "tokenExpiry": "您的会话即将过期。点击 取消 按钮继续使用",
144
+ "type": "类型",
143
145
  "yes": "是",
144
146
  "unknownError": "未知错误",
145
147
  "unitJoin": "每{0}",
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}'已经存在",
54
54
  "loading": "正在加載...",
55
55
  "login": "登錄",
56
+ "me": "我",
56
57
  "menuHome": "首頁",
57
58
  "message": "留言",
58
59
  "mobilePhone": "手機號碼",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "雇主識別號碼(EIN)",
141
142
  "timeDifferenceInvalid": "設備時間和服務器時間差為{0},超過{1}秒的限制,請調整設備時間,如果異常請告知管理員",
142
143
  "tokenExpiry": "您的會話即將過期。點擊 取消 按鈕繼續使用",
144
+ "type": "類型",
143
145
  "yes": "是",
144
146
  "unknownError": "未知錯誤",
145
147
  "unitJoin": "每{0}",
@@ -6,6 +6,14 @@ import { ProductUnit } from './ProductUnit';
6
6
  * Business utils
7
7
  */
8
8
  export declare namespace BusinessUtils {
9
+ /**
10
+ * Format avatar title
11
+ * @param title Title
12
+ * @param maxChars Max characters
13
+ * @param defaultTitle Default title
14
+ * @returns Result
15
+ */
16
+ function formatAvatarTitle(title?: string, maxChars?: number, defaultTitle?: string): string;
9
17
  /**
10
18
  * Get currency collection
11
19
  * @param currencyNames Names like CNY, USD
@@ -1,11 +1,43 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { RepeatOption } from '..';
3
2
  import { ProductUnit } from './ProductUnit';
3
+ import { RepeatOption } from './RepeatOption';
4
4
  /**
5
5
  * Business utils
6
6
  */
7
7
  export var BusinessUtils;
8
8
  (function (BusinessUtils) {
9
+ /**
10
+ * Format avatar title
11
+ * @param title Title
12
+ * @param maxChars Max characters
13
+ * @param defaultTitle Default title
14
+ * @returns Result
15
+ */
16
+ function formatAvatarTitle(title, maxChars = 3, defaultTitle = 'ME') {
17
+ // Just return for empty cases
18
+ if (title == null || title === '')
19
+ return defaultTitle;
20
+ // split with words
21
+ const items = title.trim().split(/\s+/g);
22
+ if (items.length === 1) {
23
+ // 2-3 Chinese names
24
+ const titleLen = title.length;
25
+ if (titleLen <= maxChars)
26
+ return title.toUpperCase();
27
+ // Return default for simplicity
28
+ return defaultTitle;
29
+ }
30
+ // First letter of each item
31
+ var firstLetters = items
32
+ .map((item) => item[0])
33
+ .join('')
34
+ .toUpperCase();
35
+ const flen = firstLetters.length;
36
+ if (flen <= maxChars)
37
+ return firstLetters;
38
+ return defaultTitle;
39
+ }
40
+ BusinessUtils.formatAvatarTitle = formatAvatarTitle;
9
41
  /**
10
42
  * Get currency collection
11
43
  * @param currencyNames Names like CNY, USD
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}' already exists",
54
54
  "loading": "Loading...",
55
55
  "login": "Login",
56
+ "me": "ME",
56
57
  "menuHome": "Home",
57
58
  "message": "Message",
58
59
  "mobile": "Mobile number",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "Employer identification number",
141
142
  "timeDifferenceInvalid": "The time difference between the device and the server is {0}, which exceeds the limit of {1} seconds. Please adjust the device time. If it is abnormal, please inform the administrator",
142
143
  "tokenExpiry": "Your session is about to expire. Click the Cancel button to continue",
144
+ "type": "Type",
143
145
  "yes": "Yes",
144
146
  "unknownError": "Unknown Error",
145
147
  "unitJoin": "per {0}",
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}'已经存在",
54
54
  "loading": "正在加载...",
55
55
  "login": "登录",
56
+ "me": "我",
56
57
  "menuHome": "首页",
57
58
  "message": "留言",
58
59
  "mobile": "手机号码",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "雇主识别号码(EIN)",
141
142
  "timeDifferenceInvalid": "设备时间和服务器时间差为{0},超过{1}秒的限制,请调整设备时间,如果异常请告知管理员",
142
143
  "tokenExpiry": "您的会话即将过期。点击 取消 按钮继续使用",
144
+ "type": "类型",
143
145
  "yes": "是",
144
146
  "unknownError": "未知错误",
145
147
  "unitJoin": "每{0}",
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}'已经存在",
54
54
  "loading": "正在加載...",
55
55
  "login": "登錄",
56
+ "me": "我",
56
57
  "menuHome": "首頁",
57
58
  "message": "留言",
58
59
  "mobilePhone": "手機號碼",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "雇主識別號碼(EIN)",
141
142
  "timeDifferenceInvalid": "設備時間和服務器時間差為{0},超過{1}秒的限制,請調整設備時間,如果異常請告知管理員",
142
143
  "tokenExpiry": "您的會話即將過期。點擊 取消 按鈕繼續使用",
144
+ "type": "類型",
143
145
  "yes": "是",
144
146
  "unknownError": "未知錯誤",
145
147
  "unitJoin": "每{0}",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@etsoo/appscript",
3
- "version": "1.2.75",
3
+ "version": "1.2.76",
4
4
  "description": "Applications shared TypeScript framework",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -54,7 +54,7 @@
54
54
  "dependencies": {
55
55
  "@etsoo/notificationbase": "^1.1.5",
56
56
  "@etsoo/restclient": "^1.0.70",
57
- "@etsoo/shared": "^1.1.44",
57
+ "@etsoo/shared": "^1.1.45",
58
58
  "@types/crypto-js": "^4.1.1",
59
59
  "crypto-js": "^4.1.1"
60
60
  },
@@ -64,15 +64,15 @@
64
64
  "@babel/plugin-transform-runtime": "^7.18.10",
65
65
  "@babel/preset-env": "^7.18.10",
66
66
  "@babel/runtime-corejs3": "^7.18.9",
67
- "@types/jest": "^28.1.6",
68
- "@typescript-eslint/eslint-plugin": "^5.33.0",
69
- "@typescript-eslint/parser": "^5.33.0",
67
+ "@types/jest": "^28.1.7",
68
+ "@typescript-eslint/eslint-plugin": "^5.33.1",
69
+ "@typescript-eslint/parser": "^5.33.1",
70
70
  "eslint": "^8.22.0",
71
71
  "eslint-config-airbnb-base": "^15.0.0",
72
72
  "eslint-plugin-import": "^2.26.0",
73
73
  "jest": "^28.1.3",
74
74
  "jest-environment-jsdom": "^28.1.3",
75
- "ts-jest": "^28.0.7",
75
+ "ts-jest": "^28.0.8",
76
76
  "typescript": "^4.7.4"
77
77
  }
78
78
  }
@@ -1,13 +1,52 @@
1
1
  import { DataTypes } from '@etsoo/shared';
2
- import { RepeatOption } from '..';
3
2
  import { IdLabelDto } from '../dto/IdLabelDto';
4
3
  import { ICultureGet } from '../state/Culture';
5
4
  import { ProductUnit } from './ProductUnit';
5
+ import { RepeatOption } from './RepeatOption';
6
6
 
7
7
  /**
8
8
  * Business utils
9
9
  */
10
10
  export namespace BusinessUtils {
11
+ /**
12
+ * Format avatar title
13
+ * @param title Title
14
+ * @param maxChars Max characters
15
+ * @param defaultTitle Default title
16
+ * @returns Result
17
+ */
18
+ export function formatAvatarTitle(
19
+ title?: string,
20
+ maxChars: number = 3,
21
+ defaultTitle: string = 'ME'
22
+ ): string {
23
+ // Just return for empty cases
24
+ if (title == null || title === '') return defaultTitle;
25
+
26
+ // split with words
27
+ const items = title.trim().split(/\s+/g);
28
+
29
+ if (items.length === 1) {
30
+ // 2-3 Chinese names
31
+ const titleLen = title.length;
32
+ if (titleLen <= maxChars) return title.toUpperCase();
33
+
34
+ // Return default for simplicity
35
+ return defaultTitle;
36
+ }
37
+
38
+ // First letter of each item
39
+ var firstLetters = items
40
+ .map((item) => item[0])
41
+ .join('')
42
+ .toUpperCase();
43
+
44
+ const flen = firstLetters.length;
45
+ if (flen <= maxChars) return firstLetters;
46
+
47
+ return defaultTitle;
48
+ }
49
+
11
50
  /**
12
51
  * Get currency collection
13
52
  * @param currencyNames Names like CNY, USD
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}' already exists",
54
54
  "loading": "Loading...",
55
55
  "login": "Login",
56
+ "me": "ME",
56
57
  "menuHome": "Home",
57
58
  "message": "Message",
58
59
  "mobile": "Mobile number",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "Employer identification number",
141
142
  "timeDifferenceInvalid": "The time difference between the device and the server is {0}, which exceeds the limit of {1} seconds. Please adjust the device time. If it is abnormal, please inform the administrator",
142
143
  "tokenExpiry": "Your session is about to expire. Click the Cancel button to continue",
144
+ "type": "Type",
143
145
  "yes": "Yes",
144
146
  "unknownError": "Unknown Error",
145
147
  "unitJoin": "per {0}",
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}'已经存在",
54
54
  "loading": "正在加载...",
55
55
  "login": "登录",
56
+ "me": "我",
56
57
  "menuHome": "首页",
57
58
  "message": "留言",
58
59
  "mobile": "手机号码",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "雇主识别号码(EIN)",
141
142
  "timeDifferenceInvalid": "设备时间和服务器时间差为{0},超过{1}秒的限制,请调整设备时间,如果异常请告知管理员",
142
143
  "tokenExpiry": "您的会话即将过期。点击 取消 按钮继续使用",
144
+ "type": "类型",
143
145
  "yes": "是",
144
146
  "unknownError": "未知错误",
145
147
  "unitJoin": "每{0}",
@@ -53,6 +53,7 @@
53
53
  "itemExists": "'{0}'已经存在",
54
54
  "loading": "正在加載...",
55
55
  "login": "登錄",
56
+ "me": "我",
56
57
  "menuHome": "首頁",
57
58
  "message": "留言",
58
59
  "mobilePhone": "手機號碼",
@@ -140,6 +141,7 @@
140
141
  "taxUSEIN": "雇主識別號碼(EIN)",
141
142
  "timeDifferenceInvalid": "設備時間和服務器時間差為{0},超過{1}秒的限制,請調整設備時間,如果異常請告知管理員",
142
143
  "tokenExpiry": "您的會話即將過期。點擊 取消 按鈕繼續使用",
144
+ "type": "類型",
143
145
  "yes": "是",
144
146
  "unknownError": "未知錯誤",
145
147
  "unitJoin": "每{0}",