ns-base-module 1.0.0

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 (148) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -0
  3. package/dist/Button/AntdIconButton.d.ts +11 -0
  4. package/dist/Button/AntdIconButton.d.ts.map +1 -0
  5. package/dist/Button/AntdIconButton.js +22 -0
  6. package/dist/Button/ConfigButton.d.ts +18 -0
  7. package/dist/Button/ConfigButton.d.ts.map +1 -0
  8. package/dist/Button/ConfigButton.js +78 -0
  9. package/dist/Button/index.d.ts +8 -0
  10. package/dist/Button/index.d.ts.map +1 -0
  11. package/dist/Button/index.js +19 -0
  12. package/dist/ClassFilter/index.d.ts +11 -0
  13. package/dist/ClassFilter/index.d.ts.map +1 -0
  14. package/dist/ClassFilter/index.js +119 -0
  15. package/dist/ClassFilter/indexVertical.d.ts +10 -0
  16. package/dist/ClassFilter/indexVertical.d.ts.map +1 -0
  17. package/dist/ClassFilter/indexVertical.js +69 -0
  18. package/dist/ClassFilter/util.d.ts +17 -0
  19. package/dist/ClassFilter/util.d.ts.map +1 -0
  20. package/dist/ClassFilter/util.js +135 -0
  21. package/dist/CopyCol/index.d.ts +4 -0
  22. package/dist/CopyCol/index.d.ts.map +1 -0
  23. package/dist/CopyCol/index.js +57 -0
  24. package/dist/Entry/EntryCriteria.d.ts +17 -0
  25. package/dist/Entry/EntryCriteria.d.ts.map +1 -0
  26. package/dist/Entry/EntryCriteria.js +138 -0
  27. package/dist/Entry/EntryItem.d.ts +34 -0
  28. package/dist/Entry/EntryItem.d.ts.map +1 -0
  29. package/dist/Entry/EntryItem.js +757 -0
  30. package/dist/Entry/components/Checkbox.d.ts +12 -0
  31. package/dist/Entry/components/Checkbox.d.ts.map +1 -0
  32. package/dist/Entry/components/Checkbox.js +15 -0
  33. package/dist/Entry/components/ChooseModalTable.d.ts +15 -0
  34. package/dist/Entry/components/ChooseModalTable.d.ts.map +1 -0
  35. package/dist/Entry/components/ChooseModalTable.js +407 -0
  36. package/dist/Entry/components/Condition.d.ts +9 -0
  37. package/dist/Entry/components/Condition.d.ts.map +1 -0
  38. package/dist/Entry/components/Condition.js +30 -0
  39. package/dist/Entry/components/DatePicker.d.ts +12 -0
  40. package/dist/Entry/components/DatePicker.d.ts.map +1 -0
  41. package/dist/Entry/components/DatePicker.js +12 -0
  42. package/dist/Entry/components/Etable2Modal.d.ts +4 -0
  43. package/dist/Entry/components/Etable2Modal.d.ts.map +1 -0
  44. package/dist/Entry/components/Etable2Modal.js +122 -0
  45. package/dist/Entry/components/Express.d.ts +8 -0
  46. package/dist/Entry/components/Express.d.ts.map +1 -0
  47. package/dist/Entry/components/Express.js +30 -0
  48. package/dist/Entry/components/GroupInput.d.ts +13 -0
  49. package/dist/Entry/components/GroupInput.d.ts.map +1 -0
  50. package/dist/Entry/components/GroupInput.js +77 -0
  51. package/dist/Entry/components/ImageText.d.ts +13 -0
  52. package/dist/Entry/components/ImageText.d.ts.map +1 -0
  53. package/dist/Entry/components/ImageText.js +235 -0
  54. package/dist/Entry/components/Input.d.ts +27 -0
  55. package/dist/Entry/components/Input.d.ts.map +1 -0
  56. package/dist/Entry/components/Input.js +86 -0
  57. package/dist/Entry/components/InputNumber.d.ts +18 -0
  58. package/dist/Entry/components/InputNumber.d.ts.map +1 -0
  59. package/dist/Entry/components/InputNumber.js +111 -0
  60. package/dist/Entry/components/InputNumberRange.d.ts +10 -0
  61. package/dist/Entry/components/InputNumberRange.d.ts.map +1 -0
  62. package/dist/Entry/components/InputNumberRange.js +58 -0
  63. package/dist/Entry/components/ListSelect.d.ts +15 -0
  64. package/dist/Entry/components/ListSelect.d.ts.map +1 -0
  65. package/dist/Entry/components/ListSelect.js +110 -0
  66. package/dist/Entry/components/ObjectSelect.d.ts +14 -0
  67. package/dist/Entry/components/ObjectSelect.d.ts.map +1 -0
  68. package/dist/Entry/components/ObjectSelect.js +91 -0
  69. package/dist/Entry/components/Progress.d.ts +11 -0
  70. package/dist/Entry/components/Progress.d.ts.map +1 -0
  71. package/dist/Entry/components/Progress.js +63 -0
  72. package/dist/Entry/components/Radio.d.ts +15 -0
  73. package/dist/Entry/components/Radio.d.ts.map +1 -0
  74. package/dist/Entry/components/Radio.js +17 -0
  75. package/dist/Entry/components/Select.d.ts +29 -0
  76. package/dist/Entry/components/Select.d.ts.map +1 -0
  77. package/dist/Entry/components/Select.js +113 -0
  78. package/dist/Entry/components/Switch.d.ts +6 -0
  79. package/dist/Entry/components/Switch.d.ts.map +1 -0
  80. package/dist/Entry/components/Switch.js +19 -0
  81. package/dist/Entry/components/TagsDatePicker.d.ts +7 -0
  82. package/dist/Entry/components/TagsDatePicker.d.ts.map +1 -0
  83. package/dist/Entry/components/TagsDatePicker.js +229 -0
  84. package/dist/Entry/components/TimePicker.d.ts +6 -0
  85. package/dist/Entry/components/TimePicker.d.ts.map +1 -0
  86. package/dist/Entry/components/TimePicker.js +6 -0
  87. package/dist/Entry/components/TreeSelect.d.ts +6 -0
  88. package/dist/Entry/components/TreeSelect.d.ts.map +1 -0
  89. package/dist/Entry/components/TreeSelect.js +18 -0
  90. package/dist/Entry/components/index.scss +97 -0
  91. package/dist/Entry/components/utils.d.ts +1 -0
  92. package/dist/Entry/components/utils.d.ts.map +1 -0
  93. package/dist/Entry/components/utils.js +6 -0
  94. package/dist/Entry/data.d.ts +133 -0
  95. package/dist/Entry/index.d.ts +54 -0
  96. package/dist/Entry/index.d.ts.map +1 -0
  97. package/dist/Entry/index.js +45 -0
  98. package/dist/FilterPopover/Filter.d.ts +24 -0
  99. package/dist/FilterPopover/Filter.d.ts.map +1 -0
  100. package/dist/FilterPopover/Filter.js +370 -0
  101. package/dist/FilterPopover/FilterClearIcon.d.ts +8 -0
  102. package/dist/FilterPopover/FilterClearIcon.d.ts.map +1 -0
  103. package/dist/FilterPopover/FilterClearIcon.js +45 -0
  104. package/dist/FilterPopover/index.d.ts +20 -0
  105. package/dist/FilterPopover/index.d.ts.map +1 -0
  106. package/dist/FilterPopover/index.js +136 -0
  107. package/dist/Icon/IconCreate.d.ts +11 -0
  108. package/dist/Icon/IconCreate.d.ts.map +1 -0
  109. package/dist/Icon/IconCreate.js +22 -0
  110. package/dist/Icon/index.d.ts +6 -0
  111. package/dist/Icon/index.d.ts.map +1 -0
  112. package/dist/Icon/index.js +22 -0
  113. package/dist/WidgetConfig/index.d.ts +40 -0
  114. package/dist/WidgetConfig/index.d.ts.map +1 -0
  115. package/dist/WidgetConfig/index.js +129 -0
  116. package/dist/index.d.ts +2 -0
  117. package/dist/index.d.ts.map +1 -0
  118. package/dist/index.js +4 -0
  119. package/dist/test/index.d.ts +4 -0
  120. package/dist/test/index.d.ts.map +1 -0
  121. package/dist/test/index.js +7 -0
  122. package/dist/umd/ns-base-module.min.js +1 -0
  123. package/dist/utils/cache.d.ts +17 -0
  124. package/dist/utils/cache.d.ts.map +1 -0
  125. package/dist/utils/cache.js +127 -0
  126. package/dist/utils/enum.d.ts +22 -0
  127. package/dist/utils/enum.d.ts.map +1 -0
  128. package/dist/utils/enum.js +37 -0
  129. package/dist/utils/language.d.ts +241 -0
  130. package/dist/utils/language.d.ts.map +1 -0
  131. package/dist/utils/language.js +247 -0
  132. package/dist/utils/request.d.ts +15 -0
  133. package/dist/utils/request.d.ts.map +1 -0
  134. package/dist/utils/request.js +180 -0
  135. package/dist/utils/utils.d.ts +113 -0
  136. package/dist/utils/utils.d.ts.map +1 -0
  137. package/dist/utils/utils.js +462 -0
  138. package/package.json +97 -0
  139. package/style/basics.scss +671 -0
  140. package/style/components/ClassFilter.scss +69 -0
  141. package/style/components/FilterPopover.scss +34 -0
  142. package/style/components/index.scss +2 -0
  143. package/style/default.scss +1219 -0
  144. package/style/index.scss +1 -0
  145. package/style/mixins/index.scss +28 -0
  146. package/style/mixins/libs/tint.scss +23 -0
  147. package/style/variables.scss +684 -0
  148. package/types/Action.d.ts +43 -0
@@ -0,0 +1,462 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ import { parse } from 'querystring';
3
+ import { initLang } from '@/utils/language';
4
+ import Cookies from 'js-cookie';
5
+ import { TagConditionEnum } from '@/utils/enum';
6
+ import { get, isEmpty, isString } from 'lodash';
7
+ var interpret = require('aexpr');
8
+
9
+ // /* eslint no-useless-escape:0 import/prefer-default-export:0 */
10
+ var reg = /(((^https?:(?:\/\/)?)(?:[-;:&=\+\$,\w]+@)?[A-Za-z0-9.-]+(?::\d+)?|(?:www.|[-;:&=\+\$,\w]+@)[A-Za-z0-9.-]+)((?:\/[\+~%\/.\w-_]*)?\??(?:[-\+=&;%@.\w_]*)#?(?:[\w]*))?)$/;
11
+ export var isUrl = function isUrl(path) {
12
+ return reg.test(path);
13
+ };
14
+ export var regMap = {
15
+ phone: {
16
+ message: '请输入正确手机号',
17
+ pattern: new RegExp(/^1\d{10}$/)
18
+ },
19
+ email: {
20
+ message: '请输入正确邮箱',
21
+ pattern: new RegExp(/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/)
22
+ },
23
+ card: {
24
+ message: '请输入正确身份证号',
25
+ pattern: new RegExp(/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/)
26
+ }
27
+ };
28
+ export var isAntDesignPro = function isAntDesignPro() {
29
+ if (ANT_DESIGN_PRO_ONLY_DO_NOT_USE_IN_YOUR_PRODUCTION === 'site') {
30
+ return true;
31
+ }
32
+ return window.location.hostname === 'preview.pro.ant.design';
33
+ };
34
+
35
+ // 给官方演示站点用,用于关闭真实开发环境不需要使用的特性
36
+ export var isAntDesignProOrDev = function isAntDesignProOrDev() {
37
+ var NODE_ENV = process.env.NODE_ENV;
38
+ if (NODE_ENV === 'development') {
39
+ return true;
40
+ }
41
+ return isAntDesignPro();
42
+ };
43
+ export var getPageQuery = function getPageQuery() {
44
+ return parse(window.location.href.split('?')[1]);
45
+ };
46
+
47
+ /**
48
+ * @description: 替换字符串中${} 占位
49
+ * @return {*}
50
+ */
51
+
52
+ var replaceCode = function replaceCode(path, data) {
53
+ return path.replace(/\${(.*?)}/g, function (match, key) {
54
+ return data && data[key];
55
+ });
56
+ };
57
+
58
+ // 路由参数加ids
59
+ export var pathAddIds = function pathAddIds(url, dataSource, hasPageTurning) {
60
+ if (!hasPageTurning) return url;
61
+ var __ids = '';
62
+ __ids = dataSource.map(function (item) {
63
+ return item.id;
64
+ });
65
+ __ids = __ids.join();
66
+ if (!__ids) return url;
67
+ var _path = url.includes('?') ? "".concat(url, "&__ids=").concat(__ids) : "".concat(url, "?__ids=").concat(__ids);
68
+ return _path;
69
+ };
70
+ /**
71
+ * 处理动态路径的动态参数
72
+ * @param detail 按钮详情
73
+ * @param record 数据
74
+ * @returns
75
+ */
76
+ export var dynamicPath = function dynamicPath(detail, record, dataSource) {
77
+ var _detail$config, _detail$config2, _detail$config3;
78
+ // console.log(detail, record);
79
+ var pathParam = ((detail === null || detail === void 0 || (_detail$config = detail.config) === null || _detail$config === void 0 ? void 0 : _detail$config.path) || '').split('?');
80
+ if (pathParam.length > 2) return detail === null || detail === void 0 || (_detail$config2 = detail.config) === null || _detail$config2 === void 0 ? void 0 : _detail$config2.path; // 有两个?号 跳转不是我们自己的域名
81
+
82
+ var path = get(pathParam, '[0]', '');
83
+ var keys = path.split(':');
84
+ keys.splice(0, 1);
85
+ keys = keys.map(function (key) {
86
+ return key.indexOf('/') == -1 ? key : key.split('/')[0];
87
+ });
88
+ keys.forEach(function (key) {
89
+ if (key && !((record === null || record === void 0 ? void 0 : record[key]) === null || (record === null || record === void 0 ? void 0 : record[key]) === undefined)) path = path.replace(":".concat(key), record === null || record === void 0 ? void 0 : record[key]);
90
+ });
91
+ var url = get(pathParam, '[1]') ? path + '?' + get(pathParam, '[1]') : path;
92
+ url = replaceCode(url, record);
93
+
94
+ // 上下条 拼接ids
95
+ if (dataSource && detail !== null && detail !== void 0 && (_detail$config3 = detail.config) !== null && _detail$config3 !== void 0 && _detail$config3.hasPageTurning) {
96
+ var _detail$config4;
97
+ url = pathAddIds(url, dataSource, detail === null || detail === void 0 || (_detail$config4 = detail.config) === null || _detail$config4 === void 0 ? void 0 : _detail$config4.hasPageTurning);
98
+ }
99
+ return url;
100
+ };
101
+ export var dynamicRedirect = function dynamicRedirect(detail, record) {
102
+ var _detail$config5;
103
+ console.log(detail, record);
104
+ var pathParam = ((detail === null || detail === void 0 || (_detail$config5 = detail.config) === null || _detail$config5 === void 0 ? void 0 : _detail$config5.path) || '').split('?');
105
+ var path = get(pathParam, '[0]', '');
106
+ var keys = path.split(':');
107
+ keys.splice(0, 1);
108
+ keys = keys.map(function (key) {
109
+ return key.indexOf('/') == -1 ? key : key.split('/')[0];
110
+ });
111
+ keys.forEach(function (key) {
112
+ if (key && !((record === null || record === void 0 ? void 0 : record[key]) === null || (record === null || record === void 0 ? void 0 : record[key]) === undefined)) path = path.replace(":".concat(key), record === null || record === void 0 ? void 0 : record[key]);
113
+ });
114
+ var url = get(pathParam, '[1]', null) ? path + '?' + get(pathParam, '[1]', null) : path;
115
+ return url;
116
+ };
117
+ export var formatUnit = function formatUnit(value, unit) {
118
+ if (!unit) return value;
119
+ switch (unit) {
120
+ case '万':
121
+ return value / 10000;
122
+ case '亿':
123
+ return value / 100000000;
124
+ case 'K':
125
+ return value / 1000;
126
+ case 'M':
127
+ return value / 1000000;
128
+ case 'G':
129
+ return value / 1000000000;
130
+ }
131
+ };
132
+
133
+ // 数据格式化
134
+ export var formatData = function formatData(value, format) {
135
+ // console.log(value, format);
136
+ if (value === null || value === undefined || value === '') return value;
137
+ switch (format === null || format === void 0 ? void 0 : format.type) {
138
+ case 'percentage':
139
+ var preValue = (Number(value) * 100).toFixed((format === null || format === void 0 ? void 0 : format.decimalPlaces) || 0) + '%';
140
+ return format.isShowZero ? preValue : Number(value) !== 0 ? preValue : '';
141
+ case 'scientific':
142
+ var sciValue = Number(value).toFixed((format === null || format === void 0 ? void 0 : format.decimalPlaces) || 0);
143
+ return format.isShowZero ? sciValue : Number(value) !== 0 ? sciValue : '';
144
+ case 'number':
145
+ // debugger;
146
+ // console.log(typeof Number(formatUnit(value, format.unit)).toFixed(format.decimalPlaces));
147
+ var numValue = (format !== null && format !== void 0 && format.isThousands ? format !== null && format !== void 0 && format.decimalPlaces ? Number(Number(formatUnit(value, format.unit)).toFixed(format.decimalPlaces)).toLocaleString() : Number(formatUnit(value, format.unit)).toFixed(0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') : Number(formatUnit(value, format.unit)).toFixed(format.decimalPlaces || 0)) + "".concat(format.unit || '');
148
+ return format.isShowZero ? numValue : Number(value) !== 0 ? numValue : '';
149
+ case 'money':
150
+ var monValue = "".concat((format === null || format === void 0 ? void 0 : format.prefix) || '') + (format !== null && format !== void 0 && format.isThousands ? format !== null && format !== void 0 && format.decimalPlaces ? Number(Number(formatUnit(value, format.unit)).toFixed(format.decimalPlaces)).toLocaleString() : Number(formatUnit(value, format.unit)).toFixed(0).toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,') : Number(formatUnit(value, format.unit)).toFixed(format.decimalPlaces || 0)) + "".concat(format.unit || '') + "".concat((format === null || format === void 0 ? void 0 : format.suffix) || '');
151
+ return format.isShowZero ? monValue : Number(value) !== 0 ? monValue : '';
152
+ case 'default':
153
+ default:
154
+ return format !== null && format !== void 0 && format.isShowZero ? value : Number(value) !== 0 ? value : '';
155
+ }
156
+ };
157
+ export var re = /[0-9]/;
158
+ export var isDomain = !(window.location.hostname == 'localhost' || re.test(window.location.host));
159
+
160
+ // 获取当前token
161
+ export var getToken = function getToken() {
162
+ // const { NODE_ENV } = process.env;
163
+ var domain = ".".concat(window.location.host);
164
+ // console.log('get', NODE_ENV, domain);
165
+ return Cookies.get('token', !isDomain ? undefined : {
166
+ path: '/',
167
+ domain: domain
168
+ });
169
+ };
170
+ export var rulesCustom = function rulesCustom(type) {
171
+ return regMap[type];
172
+ };
173
+ export var rules = function rules(required, entryType, label, entryAttr //默认校验类型
174
+ ) {
175
+ if (!required) return [];
176
+ if (entryAttr && entryAttr.rulesType && rulesCustom(entryAttr.rulesType)) {
177
+ return [{
178
+ required: true,
179
+ message: "".concat(initLang({
180
+ id: 'rules.warning.please',
181
+ defaultValue: '请'
182
+ })).concat(entryType && ['Input', 'InputNumber', 'Textarea', 'MbInput', 'MbInputNumber', 'MbTextarea'].includes(entryType) ? initLang({
183
+ id: 'rules.warning.input',
184
+ defaultValue: '输入'
185
+ }) : initLang({
186
+ id: 'rules.warning.select',
187
+ defaultValue: '选择'
188
+ })).concat(label)
189
+ }, entryAttr && entryAttr.rulesType && rulesCustom(entryAttr.rulesType) //默认类型存在添加
190
+ ];
191
+ }
192
+ return [{
193
+ required: true,
194
+ message: "".concat(initLang({
195
+ id: 'rules.warning.please',
196
+ defaultValue: '请'
197
+ })).concat(entryType && ['Input', 'InputNumber', 'Textarea', 'MbInput', 'MbInputNumber', 'MbTextarea'].includes(entryType) ? initLang({
198
+ id: 'rules.warning.input',
199
+ defaultValue: '输入'
200
+ }) : initLang({
201
+ id: 'rules.warning.select',
202
+ defaultValue: '选择'
203
+ })).concat(label)
204
+ }
205
+ // entryAttr && entryAttr.rulesType && rulesCustom(entryAttr.rulesType), //默认类型存在添加
206
+ ];
207
+ };
208
+
209
+ // 匹配条件返回匹配结果是否匹配
210
+ export var matchCondition = function matchCondition(condition, value, cdtValue) {
211
+ switch (condition) {
212
+ case TagConditionEnum.Equals:
213
+ return cdtValue == value;
214
+ case TagConditionEnum.NotEqual:
215
+ return cdtValue != value;
216
+ case TagConditionEnum.Contains:
217
+ return (value === null || value === void 0 ? void 0 : value.toString().indexOf(cdtValue.toString())) !== -1;
218
+ case TagConditionEnum.LessThan:
219
+ return value < cdtValue;
220
+ case TagConditionEnum.LessOrEqual:
221
+ return value <= cdtValue;
222
+ case TagConditionEnum.GreaterThan:
223
+ return value > cdtValue;
224
+ case TagConditionEnum.GreaterOrEqual:
225
+ return value >= cdtValue;
226
+ case TagConditionEnum.Default:
227
+ return true;
228
+ default:
229
+ return;
230
+ }
231
+ };
232
+
233
+ /**
234
+ * 取对象多级key下的值
235
+ * @param keysStr 对象的多级key,用.分割,a.a1 = obj[a][a1]
236
+ * @param obj 取值的对象
237
+ * @returns
238
+ */
239
+ export var getMuilObjectValue = function getMuilObjectValue(keysStr, obj) {
240
+ var keys = keysStr.split('.');
241
+ var curObj = obj;
242
+ for (var i = 0; i < keys.length; i++) {
243
+ var _curObj;
244
+ var nextValue = (_curObj = curObj) === null || _curObj === void 0 ? void 0 : _curObj[keys[i]];
245
+ if (i == keys.length - 1) {
246
+ return nextValue;
247
+ } else {
248
+ if (_typeof(nextValue) !== 'object') {
249
+ return undefined;
250
+ }
251
+ curObj = nextValue;
252
+ }
253
+ }
254
+ };
255
+
256
+ // 计算宽度转换百分比
257
+ export var handlePercentage = function handlePercentage(width) {
258
+ if (!width) return undefined;
259
+ // 如果参数是一个单个数字字符串,直接返回该字符串
260
+ if (/^\d+$/.test(width)) {
261
+ return width + 'px';
262
+ }
263
+
264
+ // 如果参数包含百分比符号(%),则尝试提取百分比值并乘以页面宽度
265
+ if (width.includes('%')) {
266
+ var WDwidth = window.innerWidth; // 获取页面宽度
267
+ var percentage = parseFloat("".concat(WDwidth));
268
+ var widthNum = width.replace('%', '');
269
+ // const bodyElement = document.body;
270
+ // const percentage = bodyElement.offsetWidth;
271
+ if (!isNaN(percentage)) {
272
+ // console.log('(percentage / 100) * (widthNum as any)', (percentage / 100) * (widthNum as any));
273
+ return percentage / 100 * widthNum;
274
+ }
275
+ }
276
+
277
+ // 如果都不符合,返回默认值
278
+ return undefined; // 或者你可以返回任何你想要的默认值
279
+ };
280
+ export var buttonCount = function buttonCount(buttonConfig, record) {
281
+ return buttonConfig.filter(function (item, index_) {
282
+ var status = true;
283
+ // if (!item.config.showExpression) {
284
+ // }
285
+ if (item.config.showExpression && isString(item.config.showExpression)) {
286
+ for (var index = 0; index < record.length; index++) {
287
+ var element = record[index];
288
+ if (!element || isEmpty(element)) {
289
+ status = false;
290
+ return;
291
+ }
292
+ try {
293
+ var status_ = interpret(item.config.showExpression, element);
294
+ if (status_ == false) {
295
+ status = false;
296
+ return;
297
+ }
298
+ } catch (error) {
299
+ console.log('表达式错误', error);
300
+ status = false;
301
+ return;
302
+ }
303
+ }
304
+ }
305
+ return status;
306
+ });
307
+ };
308
+ export function flattenArrayObjects(arr) {
309
+ var children = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'children';
310
+ var result = [];
311
+ if (!arr) return result;
312
+ for (var i = 0; i < arr.length; i++) {
313
+ if (Array.isArray(arr[i][children])) {
314
+ result = result.concat(flattenArrayObjects(arr[i][children], children));
315
+ } else {
316
+ result.push(arr[i]);
317
+ }
318
+ }
319
+ return result;
320
+ }
321
+ /**
322
+ * 255颜色值转16进制颜色值
323
+ * @param n 255颜色值
324
+ * @returns hex 16进制颜色值
325
+ */
326
+ export var toHex = function toHex(n) {
327
+ return "".concat(n > 15 ? '' : 0).concat(n.toString(16));
328
+ };
329
+
330
+ /**
331
+ * 颜色对象转化为16进制颜色字符串
332
+ * @param colorObj 颜色对象
333
+ */
334
+ export var toHexString = function toHexString(colorObj) {
335
+ var r = colorObj.r,
336
+ g = colorObj.g,
337
+ b = colorObj.b,
338
+ _colorObj$a = colorObj.a,
339
+ a = _colorObj$a === void 0 ? 1 : _colorObj$a;
340
+ return "#".concat(toHex(r)).concat(toHex(g)).concat(toHex(b)).concat(a === 1 ? '' : toHex(Math.floor(a * 255)));
341
+ };
342
+
343
+ /**
344
+ * 颜色对象转化为rgb颜色字符串
345
+ * @param colorObj 颜色对象
346
+ */
347
+ export var toRgbString = function toRgbString(colorObj) {
348
+ var r = colorObj.r,
349
+ g = colorObj.g,
350
+ b = colorObj.b;
351
+ return "rgb(".concat(r, ",").concat(g, ",").concat(b, ")");
352
+ };
353
+
354
+ /**
355
+ * 颜色对象转化为rgba颜色字符串
356
+ * @param colorObj 颜色对象
357
+ */
358
+ export var toRgbaString = function toRgbaString(colorObj) {
359
+ var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 10000;
360
+ var r = colorObj.r,
361
+ g = colorObj.g,
362
+ b = colorObj.b,
363
+ _colorObj$a2 = colorObj.a,
364
+ a = _colorObj$a2 === void 0 ? 1 : _colorObj$a2;
365
+ return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(Math.floor(a * n) / n, ")");
366
+ };
367
+
368
+ /**
369
+ * 16进制颜色字符串解析为颜色对象
370
+ * @param color 颜色字符串
371
+ * @returns IColorObj
372
+ */
373
+ export var parseHexColor = function parseHexColor(color, op) {
374
+ var hex = color.slice(1);
375
+ var a = 1;
376
+ if (hex.length === 3) {
377
+ hex = "".concat(hex[0]).concat(hex[0]).concat(hex[1]).concat(hex[1]).concat(hex[2]).concat(hex[2]);
378
+ }
379
+ if (hex.length === 8) {
380
+ a = parseInt(hex.slice(6), 16) / 255;
381
+ hex = hex.slice(0, 6);
382
+ }
383
+ var bigint = parseInt(hex, 16);
384
+ return {
385
+ r: bigint >> 16 & 255,
386
+ g: bigint >> 8 & 255,
387
+ b: bigint & 255,
388
+ a: op || a
389
+ };
390
+ };
391
+
392
+ /**
393
+ * rgba颜色字符串解析为颜色对象
394
+ * @param color 颜色字符串
395
+ * @returns IColorObj
396
+ */
397
+ export var parseRgbaColor = function parseRgbaColor(color, op) {
398
+ var arr = color.match(/(\d(\.\d+)?)+/g) || [];
399
+ var res = arr.map(function (s) {
400
+ return parseInt(s, 10);
401
+ });
402
+ return {
403
+ r: res[0],
404
+ g: res[1],
405
+ b: res[2],
406
+ a: op || parseFloat(arr[3])
407
+ };
408
+ };
409
+
410
+ /**
411
+ * 颜色字符串解析为颜色对象
412
+ * @param color 颜色字符串
413
+ * @returns IColorObj
414
+ */
415
+ export var parseColorString = function parseColorString(color, op) {
416
+ if (color.startsWith('#')) {
417
+ return parseHexColor(color, op);
418
+ } else if (color.startsWith('rgb')) {
419
+ return parseRgbaColor(color, op);
420
+ } else if (color === 'transparent') {
421
+ return parseHexColor('#00000000');
422
+ }
423
+ throw new Error("color string error: ".concat(color));
424
+ };
425
+
426
+ /**
427
+ * 颜色字符串解析为各种颜色表达方式
428
+ * @param color 颜色字符串
429
+ * @returns IColorObj
430
+ */
431
+ export var getColorInfo = function getColorInfo(color, op) {
432
+ var colorObj = parseColorString(color, op);
433
+ var hex = toHexString(colorObj);
434
+ var rgba = toRgbaString(colorObj);
435
+ var rgb = toRgbString(colorObj);
436
+ return {
437
+ hex: hex,
438
+ rgba: rgba,
439
+ rgb: rgb,
440
+ rgbaObj: colorObj
441
+ };
442
+ };
443
+
444
+ /**
445
+ * 16进制颜色字符串转化为rgba颜色字符串
446
+ * @param hex 16进制颜色字符串
447
+ * @returns rgba颜色字符串
448
+ */
449
+ export var hexToRgba = function hexToRgba(hex, op) {
450
+ var colorObj = parseColorString(hex, op);
451
+ return toRgbaString(colorObj);
452
+ };
453
+
454
+ /**
455
+ * rgba颜色字符串转化为16进制颜色字符串
456
+ * @param rgba rgba颜色字符串
457
+ * @returns 16进制颜色字符串
458
+ */
459
+ export var rgbaToHex = function rgbaToHex(rgba) {
460
+ var colorObj = parseColorString(rgba);
461
+ return toHexString(colorObj);
462
+ };
package/package.json ADDED
@@ -0,0 +1,97 @@
1
+ {
2
+ "name": "ns-base-module",
3
+ "version": "1.0.0",
4
+ "description": "ns通用组件库",
5
+ "license": "MIT",
6
+ "module": "./src/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "/dist",
10
+ "/types",
11
+ "/style"
12
+ ],
13
+ "scripts": {
14
+ "build": "father build",
15
+ "build:watch": "father dev",
16
+ "dev": "dumi dev",
17
+ "docs:build": "dumi build",
18
+ "doctor": "father doctor",
19
+ "lint": "npm run lint:es && npm run lint:css",
20
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
21
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
22
+ "start": "npm run dev",
23
+ "version": "node ./updateVersion.js"
24
+ },
25
+ "commitlint": {
26
+ "extends": [
27
+ "@commitlint/config-conventional"
28
+ ]
29
+ },
30
+ "lint-staged": {
31
+ "*.{md,json}": [
32
+ "prettier --write --no-error-on-unmatched-pattern"
33
+ ],
34
+ "*.{css,less}": [
35
+ "stylelint --fix",
36
+ "prettier --write"
37
+ ],
38
+ "*.{js,jsx}": [
39
+ "eslint --fix",
40
+ "prettier --write"
41
+ ],
42
+ "*.{ts,tsx}": [
43
+ "eslint --fix",
44
+ "prettier --parser=typescript --write"
45
+ ]
46
+ },
47
+ "dependencies": {
48
+ "@ant-design/icons": "^4.0.0",
49
+ "@ant-design/pro-components": "^2.4.14",
50
+ "@ant-design/pro-layout": "^6.9.0",
51
+ "antd": "^4.21.0",
52
+ "aexpr": "^1.0.2",
53
+ "axios": "^1.6.4",
54
+ "classnames": "",
55
+ "events": "^3.3.0",
56
+ "lodash": "^4.17.21",
57
+ "react-sortablejs": "6.1.1",
58
+ "umi-request": "^1.0.8",
59
+ "js-cookie": "^2.2.1",
60
+ "sortablejs": "1.14.0"
61
+ },
62
+ "devDependencies": {
63
+ "@commitlint/cli": "^17.1.2",
64
+ "@commitlint/config-conventional": "^17.1.0",
65
+ "@types/events": "^3.0.3",
66
+ "@types/lodash": "^4.14.191",
67
+ "@types/react": "^18.0.0",
68
+ "@types/react-dom": "^18.0.0",
69
+ "@umijs/lint": "^4.0.0",
70
+ "dumi": "^2.0.2",
71
+ "eslint": "^8.23.0",
72
+ "father": "^4.2.3",
73
+ "husky": "^8.0.1",
74
+ "js-cookie": "^3.0.5",
75
+ "lint-staged": "^13.0.3",
76
+ "prettier": "^2.7.1",
77
+ "prettier-plugin-organize-imports": "^3.0.0",
78
+ "prettier-plugin-packagejson": "^2.2.18",
79
+ "react": "^18.0.0",
80
+ "react-dom": "^18.0.0",
81
+ "react-infinite-scroll-component": "^6.1.0",
82
+ "stylelint": "^14.9.1"
83
+ },
84
+ "peerDependencies": {
85
+ "@ant-design/icons": "",
86
+ "classnames": "",
87
+ "react": ">=16.9.0",
88
+ "react-dom": ">=16.9.0"
89
+ },
90
+ "publishConfig": {
91
+ "access": "public"
92
+ },
93
+ "authors": [
94
+ "735249091@qq.com"
95
+ ],
96
+ "private": false
97
+ }