@qn-pandora/pandora-component 2.2.0 → 3.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 (106) hide show
  1. package/CHANGELOG.json +45 -0
  2. package/CHANGELOG.md +19 -0
  3. package/es/components/AutoComplete/style.css +7 -7
  4. package/es/components/Button/style.css +0 -1
  5. package/es/components/Button/style.less +0 -1
  6. package/es/components/Card/index.js +2 -1
  7. package/es/components/CheckTransformList/Item/index.js +1 -1
  8. package/es/components/CheckTransformList/style.css +16 -8
  9. package/es/components/CheckboxList/index.d.ts +1 -0
  10. package/es/components/CheckboxList/index.js +3 -2
  11. package/es/components/Collapse/index.js +2 -1
  12. package/es/components/CollapsiblePanel/index.d.ts +2 -2
  13. package/es/components/ConfigProvider/index.js +2 -1
  14. package/es/components/DateTimePicker/Base/index.js +2 -2
  15. package/es/components/DateTimePicker/Base/style.css +4 -4
  16. package/es/components/DateTimePicker/BaseMobile/index.d.ts +1 -0
  17. package/es/components/DateTimePicker/BaseMobile/index.js +2 -2
  18. package/es/components/DateTimePicker/DisplayInput/style.css +7 -7
  19. package/es/components/DateTimePicker/index.d.ts +6 -1
  20. package/es/components/DateTimePicker/index.js +2 -2
  21. package/es/components/Input/index.js +2 -1
  22. package/es/components/Input/style.css +7 -7
  23. package/es/components/InputNumber/style.css +2 -2
  24. package/es/components/Menu/index.d.ts +2 -2
  25. package/es/components/NameLimiter/index.d.ts +3 -13
  26. package/es/components/NameLimiter/index.js +30 -39
  27. package/es/components/NameLimiter/style.css +9 -1
  28. package/es/components/NameLimiter/style.less +10 -1
  29. package/es/components/OptionList/index.js +2 -1
  30. package/es/components/RangeInput/style.css +9 -9
  31. package/es/components/RemarkName/index.d.ts +0 -2
  32. package/es/components/RemarkName/index.js +2 -4
  33. package/es/components/RemarkName/style.css +9 -5
  34. package/es/components/RemarkName/style.less +0 -5
  35. package/es/components/Selector/style.css +7 -7
  36. package/es/components/SolidRadioGroup/index.js +7 -4
  37. package/es/components/SolidRadioGroup/style.css +6 -2
  38. package/es/components/SolidRadioGroup/style.less +5 -0
  39. package/es/components/Steps/index.js +2 -1
  40. package/es/components/Table/index.d.ts +9 -24
  41. package/es/components/Table/index.js +40 -8
  42. package/es/components/Table/style.css +5 -5
  43. package/es/components/TagList/Tag/style.css +3 -3
  44. package/es/components/TagList/Tag/style.less +3 -3
  45. package/es/components/TagList/index.js +3 -2
  46. package/es/components/TagList/style.css +3 -3
  47. package/es/components/TagList/style.less +8 -8
  48. package/es/index.css +2252 -2245
  49. package/es/index.d.ts +1 -1
  50. package/es/index.js +1 -1
  51. package/es/index.less +6 -6
  52. package/es/style/theme.less +8 -6
  53. package/lib/components/AutoComplete/style.css +7 -7
  54. package/lib/components/Button/style.css +0 -1
  55. package/lib/components/Button/style.less +0 -1
  56. package/lib/components/Card/index.js +1 -1
  57. package/lib/components/CheckTransformList/Item/index.js +1 -1
  58. package/lib/components/CheckTransformList/style.css +16 -8
  59. package/lib/components/CheckboxList/index.d.ts +1 -0
  60. package/lib/components/CheckboxList/index.js +3 -2
  61. package/lib/components/Collapse/index.js +1 -1
  62. package/lib/components/CollapsiblePanel/index.d.ts +2 -2
  63. package/lib/components/ConfigProvider/index.js +1 -1
  64. package/lib/components/DateTimePicker/Base/index.js +2 -2
  65. package/lib/components/DateTimePicker/Base/style.css +4 -4
  66. package/lib/components/DateTimePicker/BaseMobile/index.d.ts +1 -0
  67. package/lib/components/DateTimePicker/BaseMobile/index.js +2 -2
  68. package/lib/components/DateTimePicker/DisplayInput/style.css +7 -7
  69. package/lib/components/DateTimePicker/index.d.ts +6 -1
  70. package/lib/components/DateTimePicker/index.js +2 -2
  71. package/lib/components/Input/index.js +1 -1
  72. package/lib/components/Input/style.css +7 -7
  73. package/lib/components/InputNumber/style.css +2 -2
  74. package/lib/components/Menu/index.d.ts +2 -2
  75. package/lib/components/NameLimiter/index.d.ts +3 -13
  76. package/lib/components/NameLimiter/index.js +30 -38
  77. package/lib/components/NameLimiter/style.css +9 -1
  78. package/lib/components/NameLimiter/style.less +10 -1
  79. package/lib/components/OptionList/index.js +1 -1
  80. package/lib/components/RangeInput/style.css +9 -9
  81. package/lib/components/RemarkName/index.d.ts +0 -2
  82. package/lib/components/RemarkName/index.js +2 -4
  83. package/lib/components/RemarkName/style.css +9 -5
  84. package/lib/components/RemarkName/style.less +0 -5
  85. package/lib/components/Selector/style.css +7 -7
  86. package/lib/components/SolidRadioGroup/index.js +6 -3
  87. package/lib/components/SolidRadioGroup/style.css +6 -2
  88. package/lib/components/SolidRadioGroup/style.less +5 -0
  89. package/lib/components/Steps/index.js +1 -1
  90. package/lib/components/Table/index.d.ts +9 -24
  91. package/lib/components/Table/index.js +39 -7
  92. package/lib/components/Table/style.css +5 -5
  93. package/lib/components/TagList/Tag/style.css +3 -3
  94. package/lib/components/TagList/Tag/style.less +3 -3
  95. package/lib/components/TagList/index.js +2 -2
  96. package/lib/components/TagList/style.css +3 -3
  97. package/lib/components/TagList/style.less +8 -8
  98. package/lib/index.css +19 -12
  99. package/lib/index.d.ts +1 -1
  100. package/lib/index.js +0 -1
  101. package/lib/style/theme.less +8 -6
  102. package/package.json +23 -23
  103. package/es/components/NameLimiter/transformer.d.ts +0 -6
  104. package/es/components/NameLimiter/transformer.js +0 -84
  105. package/lib/components/NameLimiter/transformer.d.ts +0 -6
  106. package/lib/components/NameLimiter/transformer.js +0 -91
@@ -15,14 +15,14 @@
15
15
  }
16
16
  }
17
17
  }
18
+ }
18
19
 
19
- .@{sdk-prefix}-popover {
20
- max-width: 400px;
21
- max-height: 1000px;
22
- overflow: auto;
23
- padding: 16px;
24
- > div {
25
- margin: 4px;
26
- }
20
+ .@{sdk-prefix}-popover {
21
+ max-width: 400px;
22
+ max-height: 1000px;
23
+ overflow: auto;
24
+ padding: 8px !important;
25
+ > div {
26
+ margin: 4px;
27
27
  }
28
28
  }
package/lib/index.css CHANGED
@@ -2019,7 +2019,6 @@ a.ant-btn-sm {
2019
2019
  .pandora-sdk-button {
2020
2020
  -webkit-box-shadow: none;
2021
2021
  box-shadow: none;
2022
- border-radius: 2px;
2023
2022
  }
2024
2023
  .pandora-sdk-button.pandora-sdk-button-disabled {
2025
2024
  background: #eee !important;
@@ -6709,7 +6708,15 @@ textarea.ant-input-number {
6709
6708
  .ant-tooltip-rtl .ant-tooltip-inner {
6710
6709
  text-align: right;
6711
6710
  }
6712
- .pandora-sdk-name-tooltip .ant-tooltip-inner {
6711
+ .pandora-sdk-name-limit {
6712
+ max-width: 100%;
6713
+ display: inline-block;
6714
+ vertical-align: top;
6715
+ white-space: nowrap;
6716
+ text-overflow: ellipsis;
6717
+ overflow: hidden;
6718
+ }
6719
+ .pandora-sdk-name-limit-tooltip .ant-tooltip-inner {
6713
6720
  max-width: 400px !important;
6714
6721
  max-height: 200px !important;
6715
6722
  overflow: auto;
@@ -6745,10 +6752,6 @@ textarea.ant-input-number {
6745
6752
  .pandora-sdk-range-input input[type='number'] {
6746
6753
  -moz-appearance: textfield;
6747
6754
  }
6748
- .pandora-sdk-remark-name {
6749
- word-break: break-all;
6750
- white-space: nowrap;
6751
- }
6752
6755
  .ant-select-single .ant-select-selector {
6753
6756
  display: -webkit-box;
6754
6757
  display: -ms-flexbox;
@@ -7965,6 +7968,10 @@ span.ant-radio + * {
7965
7968
  border-color: #2c6dd2 !important;
7966
7969
  color: #2c6dd2 !important;
7967
7970
  }
7971
+ .pandora-sdk-solid-radio-group .ant-radio-button-wrapper-checked.ant-radio-button-wrapper-disabled {
7972
+ border-color: #d9d9d9 !important;
7973
+ color: rgba(0, 0, 0, 0.85) !important;
7974
+ }
7968
7975
  .pandora-sdk-solid-radio-group .ant-radio-button-wrapper:not(:first-child)::before {
7969
7976
  background-color: #d9d9d9;
7970
7977
  }
@@ -10953,13 +10960,13 @@ textarea.ant-pagination-options-quick-jumper input {
10953
10960
  .pandora-sdk-taglist-containter .pandora-sdk-simplify .pandora-sdk-icon:hover {
10954
10961
  color: #7a869a;
10955
10962
  }
10956
- .pandora-sdk-taglist-containter .pandora-sdk-popover {
10963
+ .pandora-sdk-popover {
10957
10964
  max-width: 400px;
10958
10965
  max-height: 1000px;
10959
10966
  overflow: auto;
10960
- padding: 16px;
10967
+ padding: 8px !important;
10961
10968
  }
10962
- .pandora-sdk-taglist-containter .pandora-sdk-popover > div {
10969
+ .pandora-sdk-popover > div {
10963
10970
  margin: 4px;
10964
10971
  }
10965
10972
  .pandora-sdk-timeline-container {
@@ -18901,7 +18908,7 @@ _:-ms-fullscreen .ant-picker-range-wrapper .ant-picker-year-panel .ant-picker-ce
18901
18908
  line-height: 24px;
18902
18909
  margin-right: 8px;
18903
18910
  border-radius: 1px;
18904
- color: #42526e;
18911
+ color: #333;
18905
18912
  text-align: center;
18906
18913
  vertical-align: middle;
18907
18914
  border-radius: 2px;
@@ -18939,8 +18946,8 @@ _:-ms-fullscreen .ant-picker-range-wrapper .ant-picker-year-panel .ant-picker-ce
18939
18946
  border-left: 1px solid rgba(44, 109, 210, 0.1);
18940
18947
  }
18941
18948
  .pandora-sdk-root .pandora-sdk-content {
18942
- padding: 0 4px;
18943
- max-width: 200px;
18949
+ padding: 0 8px;
18950
+ max-width: 150px;
18944
18951
  vertical-align: middle;
18945
18952
  overflow: hidden;
18946
18953
  white-space: nowrap;
package/lib/index.d.ts CHANGED
@@ -4,7 +4,7 @@ export { default as Button, IButtonProps } from './components/Button';
4
4
  export { default as Card } from './components/Card';
5
5
  export { default as Collapse } from './components/Collapse';
6
6
  export { default as ConfigProvider } from './components/ConfigProvider';
7
- export { default as NameLimiter, INameLimiterProps, SplitType } from './components/NameLimiter';
7
+ export { default as NameLimiter, INameLimiterProps } from './components/NameLimiter';
8
8
  export { default as Input, TInputProps } from './components/Input';
9
9
  export { default as Selector, ISelectorProps, IGroupOption as ISelectorGroupOption, IOptions as ISelectorOptions, SelectValue as ISelectValue } from './components/Selector';
10
10
  export { default as Table, ITableProps, IOptionItem as ITableOptionItem } from './components/Table';
package/lib/index.js CHANGED
@@ -16,7 +16,6 @@ var ConfigProvider_1 = require("./components/ConfigProvider");
16
16
  exports.ConfigProvider = ConfigProvider_1.default;
17
17
  var NameLimiter_1 = require("./components/NameLimiter");
18
18
  exports.NameLimiter = NameLimiter_1.default;
19
- exports.SplitType = NameLimiter_1.SplitType;
20
19
  var Input_1 = require("./components/Input");
21
20
  exports.Input = Input_1.default;
22
21
  var Selector_1 = require("./components/Selector");
@@ -123,8 +123,8 @@
123
123
  @zindex-popover: 1200; // antd
124
124
  @zindex-tooltip: 1300; // antd
125
125
  // pandora色
126
- @zindex-layout-navbar: 1100; // phoenix
127
- @zindex-layout-sidebar: 1100; // phoenix
126
+ @zindex-layout-navbar: 1210; // phoenix
127
+ @zindex-layout-sidebar: 1200; // phoenix
128
128
  @zindex-toaster: 3000; // app-platform phoenix
129
129
 
130
130
  // 组件色变量=========================================================
@@ -172,7 +172,7 @@
172
172
  @input-placeholder-color: #bfbfbf; // pandora-component antd 多 phoenix
173
173
  @input-border-color: #bfbfbf; // pandora-component antd
174
174
  @input-height-base: 32px; // phoenix antd
175
- @input-height-lg: 32px; // antd
175
+ @input-height-lg: 40px; // antd
176
176
  @input-height-sm: 26px; // antd
177
177
  @input-padding-vertical-base: 4px;
178
178
  @input-bg: transparent; // 多个 antd
@@ -201,7 +201,8 @@
201
201
 
202
202
  // Table------------------------
203
203
  // antd覆盖色
204
- @table-row-hover-bg: @theme-color-010; // pandora-component antd phoenix
204
+ // TODO: 暂时写死,后续通过函数计算@theme-color-010得到
205
+ @table-row-hover-bg: #e9f0fa;
205
206
  @table-selected-row-bg: @theme-color; // antd
206
207
  @table-padding-vertical: 14px; // antd
207
208
  @table-padding-horizontal: 12px; // antd
@@ -244,9 +245,10 @@
244
245
  @time-absolute-picker-title-div: #939393; // pandora-component
245
246
 
246
247
  // sidebar------------------------
247
- @layout-sidebar-width: 176px; // phoenix
248
+ @layout-sidebar-width: 240px; // phoenix
248
249
  @layout-sidebar-collapsed-width: 0px; // phoenix
249
- @layout-navbar-height: 48px; // phoenix
250
+ @layout-navbar-height: 52px; // phoenix
251
+ @layout-navbar-sub-height: 56px; // phoenix
250
252
  // 深色主题
251
253
  @side-bar-active-color: #6ac73c; // pandora-visualization
252
254
 
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@qn-pandora/pandora-component",
3
- "version": "2.2.0",
3
+ "version": "3.0.1",
4
4
  "description": "基础组件",
5
5
  "author": "pandora <pandora@qiniu.com>",
6
- "homepage": "https://github.com/qbox/pandora-visualization#readme",
6
+ "homepage": "https://github.com/qbox/phoenix#readme",
7
7
  "license": "ISC",
8
8
  "main": "lib/index.js",
9
9
  "module": "es/index.js",
@@ -22,28 +22,24 @@
22
22
  "**/*.css"
23
23
  ],
24
24
  "publishConfig": {
25
- "registry": "http://registry.npmjs.org/"
25
+ "registry": "https://registry.npmjs.org/"
26
26
  },
27
27
  "repository": {
28
28
  "type": "git",
29
- "url": "git+https://github.com/qbox/pandora-visualization.git"
29
+ "url": "git+https://github.com/qbox/phoenix.git"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "pandora-tools build esm && pandora-tools build cjs",
33
33
  "test": "jest",
34
- "storybook": "pandora-tools storybook start --port 9000 --static-dir ./public",
35
- "storybook:build": "pandora-tools storybook build --static-dir ./public",
36
- "prettier": "prettier -l 'src/**/*.{ts,tsx,less,css}'",
37
- "lint": "npm run prettier && ../../hack/check-tsc.sh && eslint 'src/**/*.ts*' && tslint './src/**/*.ts*'"
34
+ "storybook": "pandora-tools storybook start --port 9000",
35
+ "storybook:build": "pandora-tools storybook build",
36
+ "prettier": "prettier -l 'src/**/*.{ts,tsx,less,css}'"
38
37
  },
39
38
  "bugs": {
40
- "url": "https://github.com/qbox/pandora-visualization/issues"
39
+ "url": "https://github.com/qbox/phoenix/issues"
41
40
  },
42
41
  "peerDependencies": {
43
- "@ant-design/compatible": "^1.0.8",
44
- "@ant-design/icons": "^4.6.2",
45
- "@types/react": "^16.14.5",
46
- "antd": "^4.16.3",
42
+ "antd": "4.16.9",
47
43
  "lodash": "^4.17.15",
48
44
  "mobx": "^4.15.4",
49
45
  "mobx-react": "5.4.4",
@@ -52,9 +48,12 @@
52
48
  "devDependencies": {
53
49
  "@babel/helper-skip-transparent-expression-wrappers": "^7.11.0",
54
50
  "@babel/plugin-proposal-decorators": "^7.8.3",
55
- "@qn-pandora/pandora-tools": "^0.1.0",
56
- "@storybook/addon-docs": "^5.3.19",
51
+ "@qn-pandora/pandora-tools": "^1.0.1",
57
52
  "@svgr/webpack": "^5.4.0",
53
+ "@types/classnames": "^2.2.7",
54
+ "@types/react": "^16.14.5",
55
+ "@types/react-measure": "^2.0.4",
56
+ "@types/prop-types": "^15.7.1",
58
57
  "@types/css": "^0.0.31",
59
58
  "@types/jest": "^25.2.3",
60
59
  "@types/lodash": "^4.14.152",
@@ -62,7 +61,7 @@
62
61
  "@typescript-eslint/eslint-plugin": "^4.1.0",
63
62
  "@typescript-eslint/eslint-plugin-tslint": "^4.1.0",
64
63
  "@typescript-eslint/parser": "^4.1.0",
65
- "antd": "^4.16.3",
64
+ "antd": "4.16.9",
66
65
  "antd-mobile": "^2.3.3",
67
66
  "babel-loader": "^8.1.0",
68
67
  "copy-webpack-plugin": "^5.1.1",
@@ -78,7 +77,7 @@
78
77
  "mini-css-extract-plugin": "^0.9.0",
79
78
  "mobx": "^4.15.4",
80
79
  "mobx-react": "5.4.4",
81
- "prettier": "^2.1.2",
80
+ "prettier": "2.0.5",
82
81
  "query-string": "^6.12.1",
83
82
  "react": "^16.8.6",
84
83
  "ts-jest": "^26.0.0",
@@ -93,13 +92,14 @@
93
92
  "webpack-node-externals": "^1.7.2"
94
93
  },
95
94
  "dependencies": {
96
- "@ant-design/compatible": "^1.0.8",
97
- "@ant-design/icons": "^4.6.2",
98
- "@qn-pandora/pandora-component-icons": "^1.2.0",
99
- "antd-mobile": "^2.3.3",
95
+ "@ant-design/compatible": "1.0.8",
96
+ "@ant-design/icons": "4.6.2",
97
+ "@qn-pandora/pandora-component-icons": "^2.0.1",
98
+ "antd-mobile": "2.3.3",
100
99
  "css": "^2.2.4",
100
+ "classnames": "^2.2.6",
101
101
  "moment": "^2.29.1",
102
+ "prop-types": "^15.7.2",
102
103
  "react-measure": "^2.5.2"
103
- },
104
- "gitHead": "6709c45c909b88681e7c3a0add326e1b97009b1f"
104
+ }
105
105
  }
@@ -1,6 +0,0 @@
1
- import { SplitType } from './index';
2
- export declare function getBytes(value?: string): number;
3
- export declare function isChinese(char?: string): boolean;
4
- export declare function getPrefixString(value?: string, length?: number): string;
5
- export declare function getSuffixString(value?: string, length?: number): string;
6
- export declare function getTransformerString(value?: string, length?: number, type?: SplitType): string;
@@ -1,84 +0,0 @@
1
- var __values = (this && this.__values) || function(o) {
2
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
3
- if (m) return m.call(o);
4
- if (o && typeof o.length === "number") return {
5
- next: function () {
6
- if (o && i >= o.length) o = void 0;
7
- return { value: o && o[i++], done: !o };
8
- }
9
- };
10
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
11
- };
12
- import { SplitType } from './index';
13
- export function getBytes(value) {
14
- if (value === void 0) { value = ''; }
15
- return (value.replace(/[^\x00-\xff]/g, '--') || '').length;
16
- }
17
- export function isChinese(char) {
18
- if (char === void 0) { char = ''; }
19
- return /[^\x00-\xff]/g.test(char);
20
- }
21
- export function getPrefixString(value, length) {
22
- var e_1, _a;
23
- if (value === void 0) { value = ''; }
24
- if (length === void 0) { length = 8; }
25
- var len = length - 1;
26
- var res = '';
27
- if (getBytes(value) <= length) {
28
- return value;
29
- }
30
- try {
31
- for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
32
- var char = value_1_1.value;
33
- if (isChinese(char)) {
34
- len -= 2;
35
- }
36
- else {
37
- len -= 1;
38
- }
39
- res = res.concat(char);
40
- if (len <= 0) {
41
- return res;
42
- }
43
- }
44
- }
45
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
46
- finally {
47
- try {
48
- if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
49
- }
50
- finally { if (e_1) throw e_1.error; }
51
- }
52
- return value;
53
- }
54
- export function getSuffixString(value, length) {
55
- if (value === void 0) { value = ''; }
56
- if (length === void 0) { length = 8; }
57
- var len = length;
58
- var res = [];
59
- if (getBytes(value) <= length) {
60
- return value;
61
- }
62
- for (var i = value.length - 1; i >= 0; i--) {
63
- if (isChinese(value[i])) {
64
- len -= 2;
65
- }
66
- else {
67
- len -= 1;
68
- }
69
- res.unshift(value[i]);
70
- if (len <= 0) {
71
- return res.join('');
72
- }
73
- }
74
- return value;
75
- }
76
- export function getTransformerString(value, length, type) {
77
- if (value === void 0) { value = ''; }
78
- if (length === void 0) { length = 16; }
79
- if (type === void 0) { type = SplitType.Between; }
80
- if (type === SplitType.End) {
81
- return getPrefixString(value, length) + "...";
82
- }
83
- return getPrefixString(value.slice(0, length / 2), length / 2) + "..." + getSuffixString(value.slice(-length / 2), length / 2);
84
- }
@@ -1,6 +0,0 @@
1
- import { SplitType } from './index';
2
- export declare function getBytes(value?: string): number;
3
- export declare function isChinese(char?: string): boolean;
4
- export declare function getPrefixString(value?: string, length?: number): string;
5
- export declare function getSuffixString(value?: string, length?: number): string;
6
- export declare function getTransformerString(value?: string, length?: number, type?: SplitType): string;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- var __values = (this && this.__values) || function(o) {
3
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
4
- if (m) return m.call(o);
5
- if (o && typeof o.length === "number") return {
6
- next: function () {
7
- if (o && i >= o.length) o = void 0;
8
- return { value: o && o[i++], done: !o };
9
- }
10
- };
11
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- var index_1 = require("./index");
15
- function getBytes(value) {
16
- if (value === void 0) { value = ''; }
17
- return (value.replace(/[^\x00-\xff]/g, '--') || '').length;
18
- }
19
- exports.getBytes = getBytes;
20
- function isChinese(char) {
21
- if (char === void 0) { char = ''; }
22
- return /[^\x00-\xff]/g.test(char);
23
- }
24
- exports.isChinese = isChinese;
25
- function getPrefixString(value, length) {
26
- var e_1, _a;
27
- if (value === void 0) { value = ''; }
28
- if (length === void 0) { length = 8; }
29
- var len = length - 1;
30
- var res = '';
31
- if (getBytes(value) <= length) {
32
- return value;
33
- }
34
- try {
35
- for (var value_1 = __values(value), value_1_1 = value_1.next(); !value_1_1.done; value_1_1 = value_1.next()) {
36
- var char = value_1_1.value;
37
- if (isChinese(char)) {
38
- len -= 2;
39
- }
40
- else {
41
- len -= 1;
42
- }
43
- res = res.concat(char);
44
- if (len <= 0) {
45
- return res;
46
- }
47
- }
48
- }
49
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
50
- finally {
51
- try {
52
- if (value_1_1 && !value_1_1.done && (_a = value_1.return)) _a.call(value_1);
53
- }
54
- finally { if (e_1) throw e_1.error; }
55
- }
56
- return value;
57
- }
58
- exports.getPrefixString = getPrefixString;
59
- function getSuffixString(value, length) {
60
- if (value === void 0) { value = ''; }
61
- if (length === void 0) { length = 8; }
62
- var len = length;
63
- var res = [];
64
- if (getBytes(value) <= length) {
65
- return value;
66
- }
67
- for (var i = value.length - 1; i >= 0; i--) {
68
- if (isChinese(value[i])) {
69
- len -= 2;
70
- }
71
- else {
72
- len -= 1;
73
- }
74
- res.unshift(value[i]);
75
- if (len <= 0) {
76
- return res.join('');
77
- }
78
- }
79
- return value;
80
- }
81
- exports.getSuffixString = getSuffixString;
82
- function getTransformerString(value, length, type) {
83
- if (value === void 0) { value = ''; }
84
- if (length === void 0) { length = 16; }
85
- if (type === void 0) { type = index_1.SplitType.Between; }
86
- if (type === index_1.SplitType.End) {
87
- return getPrefixString(value, length) + "...";
88
- }
89
- return getPrefixString(value.slice(0, length / 2), length / 2) + "..." + getSuffixString(value.slice(-length / 2), length / 2);
90
- }
91
- exports.getTransformerString = getTransformerString;