@lingxiteam/ebe-utils 0.1.32 → 0.1.35

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/es/index.d.ts CHANGED
@@ -71,7 +71,7 @@ export declare const init: () => Promise<void>;
71
71
  export declare const fetchData: ({ appId, services, platform, baseUrl, onProgress, needTranslatePagePathToEnglish, incrementalConstruction, hasAppFileResource, hasExtendsApp, }: CodeOptions) => Promise<{
72
72
  options: {
73
73
  platform: string;
74
- appId: string;
74
+ appId: any;
75
75
  pageIdMapping: any;
76
76
  compAssetList: any;
77
77
  baseUrl: string;
package/es/index.js CHANGED
@@ -32,11 +32,15 @@ var isArray = function isArray(arr) {
32
32
  }
33
33
  };
34
34
  export var clearAppInfo = function clearAppInfo(appInfo) {
35
- var includes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['appId', 'appCode', 'appName', 'applicationIcon', 'updatorId', 'updatedTime'];
35
+ var includes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ['appId', 'appCode', 'appName', 'applicationIcon', 'updatorId', 'initialAppId', 'updatedTime'];
36
36
  return Object.keys(appInfo || {}).reduce(function (pre, key) {
37
37
  if (includes.includes(key)) {
38
38
  pre[key] = appInfo[key];
39
39
  }
40
+ // 如果存在 initialAppId 则需要覆盖 appId
41
+ if (pre.initialAppId) {
42
+ pre.appId = pre.initialAppId;
43
+ }
40
44
  return pre;
41
45
  }, {});
42
46
  };
@@ -426,14 +430,21 @@ export var fetchData = /*#__PURE__*/function () {
426
430
  requestQueue = new RequestQueue(8);
427
431
  requests = needFindDataPages.map(function (i) {
428
432
  lastPageId = i.pageId;
429
- pageIdMapping[i.pagePath] = i.pageId;
433
+ // 增量构建时,没有 pagePath 只有 pageId
434
+ if (i.pagePath) {
435
+ pageIdMapping[i.pagePath] = i.pageId;
436
+ }
430
437
  return new Promise(function (resolve, reject) {
431
438
  requestQueue.sendRequest(function () {
432
439
  return services.findPageInstByVersionId({
433
440
  appId: appId,
434
441
  pageId: i.pageId
435
442
  });
436
- }).then(resolve).catch(reject);
443
+ }).then(function (data) {
444
+ // @ts-ignore
445
+ pageIdMapping[data.pagePath] = data.pageId;
446
+ resolve(data);
447
+ }).catch(reject);
437
448
  });
438
449
  });
439
450
  _context3.next = 60;
@@ -741,7 +752,7 @@ export var fetchData = /*#__PURE__*/function () {
741
752
  pageRules = _context3.sent;
742
753
  options = {
743
754
  platform: getPlatform(platform),
744
- appId: appId,
755
+ appId: appInfo.initialAppId,
745
756
  pageIdMapping: pageIdMapping,
746
757
  compAssetList: compAssetList || [],
747
758
  baseUrl: baseUrl,
@@ -1,4 +1,4 @@
1
- import fs from 'fs';
1
+ import fs from 'fs-extra';
2
2
  import path from 'path';
3
3
 
4
4
  /**
@@ -32,21 +32,21 @@ __export(copyStatic_exports, {
32
32
  copyStatic: () => copyStatic
33
33
  });
34
34
  module.exports = __toCommonJS(copyStatic_exports);
35
- var import_fs = __toESM(require("fs"));
35
+ var import_fs_extra = __toESM(require("fs-extra"));
36
36
  var import_path = __toESM(require("path"));
37
37
  var copyStatic = (target, output) => {
38
38
  const copyRecursive = (source, destination) => {
39
- if (import_fs.default.lstatSync(source).isDirectory()) {
40
- if (!import_fs.default.existsSync(destination)) {
41
- import_fs.default.mkdirSync(destination);
39
+ if (import_fs_extra.default.lstatSync(source).isDirectory()) {
40
+ if (!import_fs_extra.default.existsSync(destination)) {
41
+ import_fs_extra.default.mkdirSync(destination);
42
42
  }
43
- import_fs.default.readdirSync(source).forEach((file) => {
43
+ import_fs_extra.default.readdirSync(source).forEach((file) => {
44
44
  const sourcePath = import_path.default.join(source, file);
45
45
  const destinationPath = import_path.default.join(destination, file);
46
46
  copyRecursive(sourcePath, destinationPath);
47
47
  });
48
48
  } else {
49
- import_fs.default.copyFileSync(source, destination);
49
+ import_fs_extra.default.copyFileSync(source, destination);
50
50
  }
51
51
  };
52
52
  copyRecursive(target, output);
@@ -163,6 +163,7 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
163
163
  }, [format, edittype, initValue]);
164
164
 
165
165
  const initialValueType = typeof initialValue;
166
+ const isNaNValue = useMemo(() => isNaN(initialValue), [initialValue]);
166
167
 
167
168
  const validateDateCustomExpress = useMemo<any>(() => {
168
169
  if (customExpression && customExpression.code && sandBoxSafeRun) {
@@ -230,15 +231,25 @@ const EditComponent: React.FC<MyEditComponent> = (props) => {
230
231
  });
231
232
  };
232
233
  res = getRules(res);
234
+ const requiredType = rules?.[0]?.type;
233
235
  // 添加数组类型校验
234
- if (rules?.[0]?.type && rules?.[0]?.type !== initialValueType) {
235
- res.push({
236
- type: rules?.[0]?.type,
237
- message: getLocale?.('Table.dateTypeWarning'),
238
- });
236
+ if (requiredType && requiredType !== initialValueType) {
237
+ // 数字输入框时,格式为数字型字符串视为合法类型
238
+ if (
239
+ !(
240
+ requiredType === 'number' &&
241
+ initialValueType === 'string' &&
242
+ !isNaNValue
243
+ )
244
+ ) {
245
+ res.push({
246
+ type: requiredType,
247
+ message: getLocale?.('Table.dateTypeWarning'),
248
+ });
249
+ }
239
250
  }
240
251
  return res?.length > 0 ? res : null;
241
- }, [initialValueType, rules, validateDateCustomExpress]);
252
+ }, [initialValueType, isNaNValue, rules, validateDateCustomExpress]);
242
253
 
243
254
  const getDisabledDate = useCallback(
244
255
  (current: Moment) => {
@@ -21,6 +21,7 @@ const useDataSource = (props: any) => {
21
21
  setReplaceBoundDataSource,
22
22
  outerDataSource,
23
23
  outerDataSourceRef,
24
+ setCurrentPage,
24
25
  } = props;
25
26
 
26
27
  const [dataSource, setDataSource] = useState<any[]>([]);
@@ -155,7 +156,17 @@ const useDataSource = (props: any) => {
155
156
  };
156
157
  });
157
158
  setDataSource(fd);
158
- }, [outerDataSourceRef.current, currentRowKey, boundDataSource]);
159
+ if (!hasPageChangeEvent && page && typeof setCurrentPage === 'function') {
160
+ // 前端分页时,数据变化重置分页
161
+ setCurrentPage(1);
162
+ }
163
+ }, [
164
+ outerDataSourceRef.current,
165
+ currentRowKey,
166
+ boundDataSource,
167
+ hasPageChangeEvent,
168
+ page,
169
+ ]);
159
170
 
160
171
  return {
161
172
  outerDataSource,
@@ -246,7 +246,9 @@ const useSelection = <T extends { [key: string]: unknown }>(
246
246
 
247
247
  // 当选中数据变更时,才需要触发选中回调
248
248
  if (JSON.stringify(oldSelectedKeys) !== JSON.stringify(newSelectedKeys)) {
249
- onSelectChange(sltkeys, sltrows);
249
+ setTimeout(() => {
250
+ onSelectChange(sltkeys, sltrows);
251
+ }, 10);
250
252
  }
251
253
  }
252
254
  };
@@ -128,6 +128,7 @@ const MyTable = React.forwardRef<any, MyTableProps>((props, ref) => {
128
128
  setReplaceBoundDataSource,
129
129
  outerDataSource,
130
130
  outerDataSourceRef,
131
+ setCurrentPage,
131
132
  });
132
133
 
133
134
  const {
@@ -32,7 +32,16 @@
32
32
  &-wrapper:first-child {
33
33
  height: 100%;
34
34
  }
35
-
35
+ // 表单校验提示出现时不影响布局
36
+ .@{form-item-prefix-cls}-explain {
37
+ position: relative;
38
+ min-height: 0;
39
+ &-error {
40
+ position: absolute;
41
+ top: 0;
42
+ left: 0;
43
+ }
44
+ }
36
45
  &.has-error {
37
46
  .@{form-prefix-cls}-explain {
38
47
  position: absolute;
@@ -228,12 +228,12 @@ const ExpSQLServiceModal = forwardRef<
228
228
 
229
229
  const onCheckAllChange = (e: any) => {
230
230
  if (e.target.checked) {
231
- setSelectedKeys(curDataSource.map((item) => item.attrCode));
231
+ setSelectedKeys(curDataSource.map((item) => item.code));
232
232
  } else {
233
233
  setSelectedKeys(
234
234
  curDataSource
235
235
  .filter((item) => item.isRequired === 'T')
236
- .map((item) => item.attrCode),
236
+ .map((item) => item.code),
237
237
  );
238
238
  }
239
239
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/ebe-utils",
3
- "version": "0.1.32",
3
+ "version": "0.1.35",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -19,7 +19,7 @@
19
19
  "@babel/types": "^7.12.12",
20
20
  "cac": "^6.7.14",
21
21
  "fs-extra": "9.x",
22
- "@lingxiteam/ebe": "0.1.32"
22
+ "@lingxiteam/ebe": "0.1.35"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"