@teamix/pro 1.5.44 → 1.5.46-beat.2

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 (37) hide show
  1. package/dist/pro.all.min.css +1 -1
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +21836 -21394
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/dist/pro.xconsole.min.css +1 -1
  7. package/es/actions/quick.js +1 -0
  8. package/es/form/Components/SelectTable2/index.d.ts +1 -0
  9. package/es/form/Filter/useBindUrl.d.ts +14 -2
  10. package/es/form/Filter/useBindUrl.js +90 -36
  11. package/es/index.d.ts +1 -1
  12. package/es/index.js +1 -1
  13. package/es/page-header/index.js +2 -2
  14. package/es/sidebar/utils/index.d.ts +1 -1
  15. package/es/table/components/Cell/index.js +23 -3
  16. package/es/table/components/Filter/index.js +3 -1
  17. package/es/table/components/ToolBar/RefreshIcon.js +2 -0
  18. package/es/table/index.js +7 -4
  19. package/es/table/typing.d.ts +2 -0
  20. package/es/table/utils/genAutoWidthColumns.js +4 -1
  21. package/es/table/utils/useTableSelection.js +5 -1
  22. package/lib/actions/quick.js +1 -0
  23. package/lib/form/Components/SelectTable2/index.d.ts +1 -0
  24. package/lib/form/Filter/useBindUrl.d.ts +14 -2
  25. package/lib/form/Filter/useBindUrl.js +90 -37
  26. package/lib/index.d.ts +1 -1
  27. package/lib/index.js +1 -1
  28. package/lib/page-header/index.js +1 -1
  29. package/lib/sidebar/utils/index.d.ts +1 -1
  30. package/lib/table/components/Cell/index.js +23 -3
  31. package/lib/table/components/Filter/index.js +3 -1
  32. package/lib/table/components/ToolBar/RefreshIcon.js +2 -0
  33. package/lib/table/index.js +7 -4
  34. package/lib/table/typing.d.ts +2 -0
  35. package/lib/table/utils/genAutoWidthColumns.js +4 -1
  36. package/lib/table/utils/useTableSelection.js +5 -1
  37. package/package.json +2 -2
@@ -16,6 +16,7 @@ export function createAction(props) {
16
16
  var divDom = document.createElement('div');
17
17
  divDom.style.display = 'none';
18
18
  divDom.setAttribute('class', 'teamix-pro-actions-identification');
19
+ //@ts-ignore
19
20
  ReactDom.render( /*#__PURE__*/React.createElement(ProAction, _objectSpread({}, props)), divDom);
20
21
  parentDom.appendChild(divDom);
21
22
  setTimeout(function () {
@@ -93,5 +93,6 @@ declare const SelectTable2: React.ForwardRefExoticComponent<Partial<{
93
93
  columnProps?: (() => any) | undefined;
94
94
  titleAddons?: (() => any) | undefined;
95
95
  }) | undefined;
96
+ key?: React.Key | null | undefined;
96
97
  } & Omit<import("@alifd/next/types/table").TableProps, "rowSelection" | "columns"> & import("../../../table").ProTableTopAreaProps> & React.RefAttributes<unknown>>;
97
98
  export default SelectTable2;
@@ -1,2 +1,14 @@
1
- declare const _default: (bindUrl: any, functions: any, formRef: any) => any;
2
- export default _default;
1
+ /// <reference types="react" />
2
+ import { UrlStateOptions } from '@teamix/hooks';
3
+ import type { Form } from '@formily/core';
4
+ export interface BindUrlInitFunctions {
5
+ onInit?: (values: Record<string, any>) => void;
6
+ onFilter?: (values: Record<string, any>) => void;
7
+ onReset?: (values: Record<string, any>) => void;
8
+ }
9
+ export default function useBindUrl<S = unknown>(bindUrl: boolean | UrlStateOptions<S> | undefined, functions: BindUrlInitFunctions, formRef: React.MutableRefObject<Form<any> | undefined>): {
10
+ onInit?: ((values: Record<string, any>) => void) | undefined;
11
+ onFilter?: ((values: Record<string, any>) => void) | undefined;
12
+ onReset?: ((values: Record<string, any>) => void) | undefined;
13
+ setValuesByUrlState: (form: any) => void;
14
+ };
@@ -7,9 +7,10 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
8
8
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
9
9
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
10
- import { useUrlState } from '@teamix/hooks';
10
+ import { useUpdate, useUrlState } from '@teamix/hooks';
11
11
  import { isUsable, isPlainObj } from '@teamix/utils';
12
- export default (function (bindUrl, functions, formRef) {
12
+ export default function useBindUrl(bindUrl, functions, formRef) {
13
+ var update = useUpdate();
13
14
  // 预处理 bindUrl 参数(主要兼容 SelectGroup 组件)
14
15
  var initializeBindUrl = function initializeBindUrl(options) {
15
16
  return options ? _objectSpread(_objectSpread({}, options), {}, {
@@ -23,9 +24,10 @@ export default (function (bindUrl, functions, formRef) {
23
24
  key = _ref2[0],
24
25
  value = _ref2[1];
25
26
  var form = formRef.current;
26
- var field = (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
27
- if ((field === null || field === void 0 ? void 0 : field.component[0]) === 'SelectGroup') {
28
- newValues[key] = value.map(function (_ref3) {
27
+ var field = form === null || form === void 0 ? void 0 : (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
28
+ var component = field === null || field === void 0 ? void 0 : field.component;
29
+ if (component instanceof Array && component[0] === 'SelectGroup') {
30
+ newValues[key] = (value !== null && value !== void 0 ? value : []).map(function (_ref3) {
29
31
  var key = _ref3.key,
30
32
  value = _ref3.value;
31
33
  return key && value ? "".concat(key, "||").concat(value === null || value === void 0 ? void 0 : value.join('|')) : '';
@@ -33,52 +35,104 @@ export default (function (bindUrl, functions, formRef) {
33
35
  }
34
36
  });
35
37
  return beforeStringify ? beforeStringify(newValues) : newValues;
38
+ },
39
+ beforeParse: function beforeParse(values) {
40
+ var _Object$entries2;
41
+ var beforeParse = options.beforeParse;
42
+ var newValues = _objectSpread({}, values);
43
+ (_Object$entries2 = Object.entries(values)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref4) {
44
+ var _form$query2;
45
+ var _ref5 = _slicedToArray(_ref4, 2),
46
+ key = _ref5[0],
47
+ value = _ref5[1];
48
+ var form = formRef.current;
49
+ var field = form === null || form === void 0 ? void 0 : (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
50
+ var component = field === null || field === void 0 ? void 0 : field.component;
51
+ if (component instanceof Array && component[0] === 'SelectGroup') {
52
+ newValues[key] = (value !== null && value !== void 0 ? value : []).map(function (item) {
53
+ var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
54
+ _item$split2 = _slicedToArray(_item$split, 2),
55
+ key = _item$split2[0],
56
+ value = _item$split2[1];
57
+ return {
58
+ key: key,
59
+ value: value === null || value === void 0 ? void 0 : value.split('|')
60
+ };
61
+ });
62
+ }
63
+ });
64
+ return beforeParse ? beforeParse(newValues) : newValues;
36
65
  }
37
66
  }) : options;
38
67
  };
39
68
  // 通过 useUrlState 获取 url 上的参数和 url 配置方法
40
- var _ref4 = bindUrl ? useUrlState(undefined, initializeBindUrl(isPlainObj(bindUrl) ? bindUrl : {})) : [],
41
- _ref5 = _slicedToArray(_ref4, 2),
42
- urlState = _ref5[0],
43
- setUrlState = _ref5[1];
69
+ var _ref6 = bindUrl ? useUrlState(undefined, _objectSpread(_objectSpread({}, initializeBindUrl(isPlainObj(bindUrl) ? bindUrl : {})), {}, {
70
+ navigateMode: 'replace'
71
+ })) : [],
72
+ _ref7 = _slicedToArray(_ref6, 4),
73
+ urlState = _ref7[0],
74
+ setUrlState = _ref7[1],
75
+ queryFromUrl = _ref7[2],
76
+ stringify = _ref7[3];
44
77
  // 输出配置url参数的函数
45
- var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref6) {
46
- var _ref7 = _slicedToArray(_ref6, 2),
47
- key = _ref7[0],
48
- fun = _ref7[1];
49
- prev[key] = function (values) {
50
- fun === null || fun === void 0 ? void 0 : fun(values);
51
- setUrlState === null || setUrlState === void 0 ? void 0 : setUrlState(values);
78
+ var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref8) {
79
+ var _ref9 = _slicedToArray(_ref8, 2),
80
+ listenerKey = _ref9[0],
81
+ originalFunction = _ref9[1];
82
+ prev[listenerKey] = function (values) {
83
+ originalFunction === null || originalFunction === void 0 ? void 0 : originalFunction(values);
84
+ if (bindUrl) {
85
+ // guard: onInit 会在 mount 时被自动调用,需要避免其在任何情况下都调用 setUrlState。故增加幂等判断
86
+ var hasStringifiedDiff = false;
87
+ var hasValuesDiff = false;
88
+ for (var paramName in values) {
89
+ if (Object.hasOwn(values, paramName)) {
90
+ var oldValue = queryFromUrl === null || queryFromUrl === void 0 ? void 0 : queryFromUrl[paramName];
91
+ var newValue = values[paramName];
92
+ // 这里我们必须使用 stringify 来判断是否有变化,因为 special case 太多。例如,默认配置下:
93
+ // { a: [undefined, undefined], b: undefined, c: [], d: null, e: ''} 会生成 'd=&e='
94
+ // 类似地,{ a: [''], b: [null], c: [undefined] } 会生成 'a=&b='。更不用说还有非默认配置的情况
95
+ // 想要避免这种 hazard,我们必须使用钩子内部导出的、经过柯里化的 stringify 来判断生成的字符串是否无变化。
96
+ if (stringify(_defineProperty({}, paramName, newValue)) !== stringify(_defineProperty({}, paramName, oldValue))) {
97
+ hasStringifiedDiff = true;
98
+ break;
99
+ } else if (oldValue !== newValue) {
100
+ hasValuesDiff = true;
101
+ }
102
+ }
103
+ }
104
+ if (hasStringifiedDiff) {
105
+ setUrlState(values);
106
+ } else if (hasValuesDiff) {
107
+ // guard: 虽然 url 字符串没有变化,但是 values 变化了,还是需要触发组件的 update 以保证行为一致。
108
+ update();
109
+ }
110
+ }
52
111
  };
53
112
  return prev;
54
113
  }, {});
55
114
  // 使用 url 参数配置 QueryFilter 默认值(移除非表单值,兼容数组数据,兼容 SelectGroup 组件)
56
115
  var setValuesByUrlState = function setValuesByUrlState(form) {
57
116
  if (urlState) {
58
- var _Object$entries2;
59
- (_Object$entries2 = Object.entries(urlState)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref8) {
60
- var _form$query2;
61
- var _ref9 = _slicedToArray(_ref8, 2),
62
- key = _ref9[0],
63
- value = _ref9[1];
64
- var field = (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
117
+ var _Object$entries3;
118
+ (_Object$entries3 = Object.entries(urlState)) === null || _Object$entries3 === void 0 ? void 0 : _Object$entries3.forEach(function (_ref10) {
119
+ var _form$query3;
120
+ var _ref11 = _slicedToArray(_ref10, 2),
121
+ key = _ref11[0],
122
+ value = _ref11[1];
123
+ var field = (_form$query3 = form.query(key)) === null || _form$query3 === void 0 ? void 0 : _form$query3.take();
65
124
  if (field) {
66
125
  var newValue = value;
67
126
  if (field.displayName === 'ArrayField') {
68
127
  newValue = [].concat(isUsable(newValue) ? newValue : []);
69
128
  }
70
- if (field.component[0] === 'SelectGroup') {
71
- newValue = newValue.map(function (item) {
72
- var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
73
- _item$split2 = _slicedToArray(_item$split, 2),
74
- key = _item$split2[0],
75
- value = _item$split2[1];
76
- return {
77
- key: key,
78
- value: value === null || value === void 0 ? void 0 : value.split('|')
79
- };
80
- });
81
- }
129
+ // 这部分应该挪到上面的 beforeParse 里面做,beforeParse 和 beforeStringify 应该是互逆的
130
+ // if (field.component[0] === 'SelectGroup') {
131
+ // newValue = newValue.map((item: any) => {
132
+ // const [key, value] = item?.split('||');
133
+ // return { key, value: value?.split('|') };
134
+ // });
135
+ // }
82
136
  form.setValuesIn(key, newValue);
83
137
  }
84
138
  });
@@ -87,4 +141,4 @@ export default (function (bindUrl, functions, formRef) {
87
141
  return _objectSpread({
88
142
  setValuesByUrlState: setValuesByUrlState
89
143
  }, initializedFunctions);
90
- });
144
+ }
package/es/index.d.ts CHANGED
@@ -30,5 +30,5 @@ export * from './sidebar';
30
30
  export * from './utils';
31
31
  export * from './timeline';
32
32
  export * from './image';
33
- declare const version = "1.5.44";
33
+ declare const version = "1.5.46-beta.2";
34
34
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, ProImage, hooks, nocode, templates, utils, };
package/es/index.js CHANGED
@@ -37,7 +37,7 @@ export * from './sidebar';
37
37
  export * from './utils';
38
38
  export * from './timeline';
39
39
  export * from './image';
40
- var version = '1.5.44';
40
+ var version = '1.5.46-beta.2';
41
41
  // By TeamixTest
42
42
  window.postMessage({
43
43
  source: 'teamix-test-devtools',
@@ -8,7 +8,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
8
8
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
9
9
  import React from 'react';
10
10
  // import { useHistory } from 'react-router-dom';
11
- import { useRealHistory } from '@teamix/utils';
11
+ import { useReactHistory } from '@teamix/utils';
12
12
  import classnames from 'classnames';
13
13
  import TeamixIcon from '@teamix/icon';
14
14
  import { Breadcrumb, Balloon } from '@alicloudfe/components';
@@ -132,7 +132,7 @@ var ProPageHeader = function ProPageHeader(props) {
132
132
  style = props.style,
133
133
  tabs = props.tabs,
134
134
  others = _objectWithoutProperties(props, _excluded3);
135
- var history = useRealHistory();
135
+ var history = useReactHistory();
136
136
  var backgroundImage = image ? "url('".concat(image, "')") : undefined;
137
137
  var showList = function showList(list) {
138
138
  var _list$actions;
@@ -152,7 +152,7 @@ export declare function getTreeNodeProps(item: ProSidebarDataSourceItem): {
152
152
  'aria-colindex'?: number | undefined;
153
153
  'aria-colspan'?: number | undefined;
154
154
  'aria-controls'?: string | undefined;
155
- 'aria-current'?: boolean | "date" | "time" | "page" | "false" | "true" | "step" | "location" | undefined;
155
+ 'aria-current'?: boolean | "location" | "date" | "time" | "page" | "false" | "true" | "step" | undefined;
156
156
  'aria-describedby'?: string | undefined;
157
157
  'aria-details'?: string | undefined;
158
158
  'aria-disabled'?: (boolean | "false" | "true") | undefined;
@@ -189,11 +189,31 @@ var processBuriedPoint = function processBuriedPoint() {
189
189
  }))));
190
190
  };
191
191
  var equalColumns = function equalColumns(prevProps, nextProps) {
192
- var preValue = prevProps.value;
192
+ var preValue = prevProps.value,
193
+ preItem = prevProps.item,
194
+ preRecord = prevProps.record,
195
+ preContext = prevProps.context;
193
196
  var nextValue = nextProps.value,
194
- item = nextProps.item;
197
+ nextItem = nextProps.item,
198
+ nextRecord = nextProps.record,
199
+ nextContext = nextProps.context;
200
+ // if (nextItem?.render) {
201
+ // let renderCache = true;
202
+ // Object.keys(nextItem?.render).forEach((key) => {
203
+ // // 如果 preItem 不包含 render 的属性,则强制刷新
204
+ // if (!preItem?.render[key]) {
205
+ // renderCache = false;
206
+ // return false
207
+ // }
208
+ // let preRenderValue = getTargetValue(preItem?.render[key], {...preRecord, ...preContext});
209
+ // let nextRenderValue = getTargetValue(nextItem?.render[key], {...nextRecord, ...nextContext})
210
+ // if (preRenderValue !== nextRenderValue) {
211
+ // renderCache = false;
212
+ // }
213
+ // })
214
+ // }
195
215
  // columns 强制更新参数
196
- if (item === null || item === void 0 ? void 0 : item.forcedUpdate) {
216
+ if (nextItem === null || nextItem === void 0 ? void 0 : nextItem.forcedUpdate) {
197
217
  return false;
198
218
  }
199
219
  // 操作列的时候强制刷新 || 当 value 值拿不到的时候
@@ -33,7 +33,9 @@ var Filter = function Filter(props) {
33
33
  filtersWidth = _column$filtersWidth === void 0 ? 130 : _column$filtersWidth,
34
34
  _column$defaultFilter = column.defaultFilterSelectedKeys,
35
35
  defaultFilterSelectedKeys = _column$defaultFilter === void 0 ? [] : _column$defaultFilter;
36
- var _ref = bindUrl ? useUrlState() : [],
36
+ var _ref = bindUrl ? useUrlState({}, {
37
+ navigateMode: 'replace'
38
+ }) : [],
37
39
  _ref2 = _slicedToArray(_ref, 2),
38
40
  urlState = _ref2[0],
39
41
  setUrlState = _ref2[1];
@@ -59,6 +59,7 @@ var LayoutIcon = function LayoutIcon(props) {
59
59
  setTimes(timer);
60
60
  timerRef.current.remain = timer / 1000;
61
61
  if (timerRef.current.timer) {
62
+ //@ts-ignore
62
63
  clearInterval(timerRef.current.timer);
63
64
  timerRef.current.timer = undefined;
64
65
  }
@@ -84,6 +85,7 @@ var LayoutIcon = function LayoutIcon(props) {
84
85
  var _actionRef$current2, _actionRef$current2$c;
85
86
  (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$c = _actionRef$current2.clearAutoRefreshTimers) === null || _actionRef$current2$c === void 0 ? void 0 : _actionRef$current2$c.call(_actionRef$current2);
86
87
  if (timerRef.current.timer) {
88
+ //@ts-ignore
87
89
  clearInterval(timerRef.current.timer);
88
90
  timerRef.current.timer = undefined;
89
91
  timerRef.current.remain = times / 1000;
package/es/table/index.js CHANGED
@@ -135,7 +135,9 @@ var ProTable = function ProTable(props) {
135
135
  var targetPageKey = pageKey || globalPageKey;
136
136
  var targetPageSizeKey = pageSizeKey || globalPageSizeKey;
137
137
  var targetFormatSort = formatSort || globalFormatSort;
138
- var _ref = bindUrl ? useUrlState() : [],
138
+ var _ref = bindUrl ? useUrlState({}, {
139
+ navigateMode: 'replace'
140
+ }) : [],
139
141
  _ref2 = _slicedToArray(_ref, 2),
140
142
  urlState = _ref2[0],
141
143
  setUrlState = _ref2[1];
@@ -337,9 +339,9 @@ var ProTable = function ProTable(props) {
337
339
  setFooterSuctionState(false);
338
340
  }
339
341
  // 如果有切换区tab,那么重新计算
340
- if (headerFixedTopSectionDom.clientHeight) {
342
+ if (headerFixedTopSectionDom === null || headerFixedTopSectionDom === void 0 ? void 0 : headerFixedTopSectionDom.clientHeight) {
341
343
  var _headerFixedTopSectio;
342
- var headerFixedTopSectionHeight = (_headerFixedTopSectio = headerFixedTopSectionDom.clientHeight) !== null && _headerFixedTopSectio !== void 0 ? _headerFixedTopSectio : 0;
344
+ var headerFixedTopSectionHeight = (_headerFixedTopSectio = headerFixedTopSectionDom === null || headerFixedTopSectionDom === void 0 ? void 0 : headerFixedTopSectionDom.clientHeight) !== null && _headerFixedTopSectio !== void 0 ? _headerFixedTopSectio : 0;
343
345
  // const clientTableBodyHeight =
344
346
  // document.body.clientHeight - offsetHeaderHeight;
345
347
  setHeaderHeight(headerFixedTopSectionHeight + teamixNavHeight + footerRowSelectionHeight + tableHeaderHeight + 1);
@@ -1199,7 +1201,8 @@ var ProTable = function ProTable(props) {
1199
1201
  }, [fullscreenState, fixedTableBody, footerSuction, footerSuctionState]);
1200
1202
  return /*#__PURE__*/React.createElement(FullScreen, {
1201
1203
  visible: fullscreenState,
1202
- actionRef: actionRef
1204
+ actionRef: actionRef,
1205
+ key: props.key
1203
1206
  }, function (isFullScreen) {
1204
1207
  return /*#__PURE__*/React.createElement("div", {
1205
1208
  className: cls({
@@ -189,6 +189,8 @@ export declare type ProTableProps = {
189
189
  /** 使用超大数据模式 **/
190
190
  useMaxData?: boolean;
191
191
  rowSelection?: rowSelectionType;
192
+ /** React Key **/
193
+ key?: React.Key | null;
192
194
  } & Omit<TableProps, 'columns' | 'rowSelection'> & ProTableTopAreaProps;
193
195
  export declare type rowSelectionType = {
194
196
  getProps?: (record: any, index: number) => any;
@@ -38,7 +38,10 @@ export function genAutoWidthColumns(columns, ref, data, size, useRowSelection, a
38
38
  return columns;
39
39
  }
40
40
  var finalColumns = [];
41
- var filterdColumnsResult = _.cloneDeep(columns);
41
+ // @FIXME: lodash cloneDeep 无法正确处理 columns 内部含有 ReactNode 的情况。我们也不该用 React 以外的工具来复制 ReactNode
42
+ // 因为它里面的 fiber node id 等等的在复制后并不会变,对于 React 来讲这就意味着两个 ReactNode 有相同的 fiber node id,不符合预期。
43
+ // 先注释掉,后续再想办法
44
+ var filterdColumnsResult = columns; // _.cloneDeep(columns);
42
45
  filterdColumnsResult.forEach(function (column, index) {
43
46
  var render = column.render,
44
47
  _column$valueType = column.valueType,
@@ -41,6 +41,10 @@ function useTableSelection() {
41
41
  var dataRef = useRef({
42
42
  selectedRowKeys: config.selectedRowKeys || defaultSelectedRowKeys
43
43
  });
44
+ var onSetSelectedRowKeys = function onSetSelectedRowKeys(keys) {
45
+ setSelectedRowKeys(keys);
46
+ dataRef.current.selectedRowKeys = keys;
47
+ };
44
48
  useEffect(function () {
45
49
  var _config$selectedRowKe, _config$selectedRowKe2;
46
50
  setSelectedRowKeys((_config$selectedRowKe = config === null || config === void 0 ? void 0 : config.selectedRowKeys) !== null && _config$selectedRowKe !== void 0 ? _config$selectedRowKe : []);
@@ -148,7 +152,7 @@ function useTableSelection() {
148
152
  return {
149
153
  rowSelection: rowSelection,
150
154
  selectedRowKeys: selectedRowKeys,
151
- setSelectedRowKeys: setSelectedRowKeys,
155
+ setSelectedRowKeys: onSetSelectedRowKeys,
152
156
  selectedRecords: selectedRecords,
153
157
  setSelectedRecords: setSelectedRecords
154
158
  };
@@ -23,6 +23,7 @@ function createAction(props) {
23
23
  var divDom = document.createElement('div');
24
24
  divDom.style.display = 'none';
25
25
  divDom.setAttribute('class', 'teamix-pro-actions-identification');
26
+ //@ts-ignore
26
27
  _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_.default, _objectSpread({}, props)), divDom);
27
28
  parentDom.appendChild(divDom);
28
29
  setTimeout(function () {
@@ -93,5 +93,6 @@ declare const SelectTable2: React.ForwardRefExoticComponent<Partial<{
93
93
  columnProps?: (() => any) | undefined;
94
94
  titleAddons?: (() => any) | undefined;
95
95
  }) | undefined;
96
+ key?: React.Key | null | undefined;
96
97
  } & Omit<import("@alifd/next/types/table").TableProps, "rowSelection" | "columns"> & import("../../../table").ProTableTopAreaProps> & React.RefAttributes<unknown>>;
97
98
  export default SelectTable2;
@@ -1,2 +1,14 @@
1
- declare const _default: (bindUrl: any, functions: any, formRef: any) => any;
2
- export default _default;
1
+ /// <reference types="react" />
2
+ import { UrlStateOptions } from '@teamix/hooks';
3
+ import type { Form } from '@formily/core';
4
+ export interface BindUrlInitFunctions {
5
+ onInit?: (values: Record<string, any>) => void;
6
+ onFilter?: (values: Record<string, any>) => void;
7
+ onReset?: (values: Record<string, any>) => void;
8
+ }
9
+ export default function useBindUrl<S = unknown>(bindUrl: boolean | UrlStateOptions<S> | undefined, functions: BindUrlInitFunctions, formRef: React.MutableRefObject<Form<any> | undefined>): {
10
+ onInit?: ((values: Record<string, any>) => void) | undefined;
11
+ onFilter?: ((values: Record<string, any>) => void) | undefined;
12
+ onReset?: ((values: Record<string, any>) => void) | undefined;
13
+ setValuesByUrlState: (form: any) => void;
14
+ };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.default = useBindUrl;
7
7
  var _hooks = require("@teamix/hooks");
8
8
  var _utils = require("@teamix/utils");
9
9
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
@@ -15,7 +15,8 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
15
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
17
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
- var _default = function _default(bindUrl, functions, formRef) {
18
+ function useBindUrl(bindUrl, functions, formRef) {
19
+ var update = (0, _hooks.useUpdate)();
19
20
  // 预处理 bindUrl 参数(主要兼容 SelectGroup 组件)
20
21
  var initializeBindUrl = function initializeBindUrl(options) {
21
22
  return options ? _objectSpread(_objectSpread({}, options), {}, {
@@ -29,9 +30,10 @@ var _default = function _default(bindUrl, functions, formRef) {
29
30
  key = _ref2[0],
30
31
  value = _ref2[1];
31
32
  var form = formRef.current;
32
- var field = (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
33
- if ((field === null || field === void 0 ? void 0 : field.component[0]) === 'SelectGroup') {
34
- newValues[key] = value.map(function (_ref3) {
33
+ var field = form === null || form === void 0 ? void 0 : (_form$query = form.query(key)) === null || _form$query === void 0 ? void 0 : _form$query.take();
34
+ var component = field === null || field === void 0 ? void 0 : field.component;
35
+ if (component instanceof Array && component[0] === 'SelectGroup') {
36
+ newValues[key] = (value !== null && value !== void 0 ? value : []).map(function (_ref3) {
35
37
  var key = _ref3.key,
36
38
  value = _ref3.value;
37
39
  return key && value ? "".concat(key, "||").concat(value === null || value === void 0 ? void 0 : value.join('|')) : '';
@@ -39,52 +41,104 @@ var _default = function _default(bindUrl, functions, formRef) {
39
41
  }
40
42
  });
41
43
  return beforeStringify ? beforeStringify(newValues) : newValues;
44
+ },
45
+ beforeParse: function beforeParse(values) {
46
+ var _Object$entries2;
47
+ var beforeParse = options.beforeParse;
48
+ var newValues = _objectSpread({}, values);
49
+ (_Object$entries2 = Object.entries(values)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref4) {
50
+ var _form$query2;
51
+ var _ref5 = _slicedToArray(_ref4, 2),
52
+ key = _ref5[0],
53
+ value = _ref5[1];
54
+ var form = formRef.current;
55
+ var field = form === null || form === void 0 ? void 0 : (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
56
+ var component = field === null || field === void 0 ? void 0 : field.component;
57
+ if (component instanceof Array && component[0] === 'SelectGroup') {
58
+ newValues[key] = (value !== null && value !== void 0 ? value : []).map(function (item) {
59
+ var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
60
+ _item$split2 = _slicedToArray(_item$split, 2),
61
+ key = _item$split2[0],
62
+ value = _item$split2[1];
63
+ return {
64
+ key: key,
65
+ value: value === null || value === void 0 ? void 0 : value.split('|')
66
+ };
67
+ });
68
+ }
69
+ });
70
+ return beforeParse ? beforeParse(newValues) : newValues;
42
71
  }
43
72
  }) : options;
44
73
  };
45
74
  // 通过 useUrlState 获取 url 上的参数和 url 配置方法
46
- var _ref4 = bindUrl ? (0, _hooks.useUrlState)(undefined, initializeBindUrl((0, _utils.isPlainObj)(bindUrl) ? bindUrl : {})) : [],
47
- _ref5 = _slicedToArray(_ref4, 2),
48
- urlState = _ref5[0],
49
- setUrlState = _ref5[1];
75
+ var _ref6 = bindUrl ? (0, _hooks.useUrlState)(undefined, _objectSpread(_objectSpread({}, initializeBindUrl((0, _utils.isPlainObj)(bindUrl) ? bindUrl : {})), {}, {
76
+ navigateMode: 'replace'
77
+ })) : [],
78
+ _ref7 = _slicedToArray(_ref6, 4),
79
+ urlState = _ref7[0],
80
+ setUrlState = _ref7[1],
81
+ queryFromUrl = _ref7[2],
82
+ stringify = _ref7[3];
50
83
  // 输出配置url参数的函数
51
- var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref6) {
52
- var _ref7 = _slicedToArray(_ref6, 2),
53
- key = _ref7[0],
54
- fun = _ref7[1];
55
- prev[key] = function (values) {
56
- fun === null || fun === void 0 ? void 0 : fun(values);
57
- setUrlState === null || setUrlState === void 0 ? void 0 : setUrlState(values);
84
+ var initializedFunctions = Object.entries(functions).reduce(function (prev, _ref8) {
85
+ var _ref9 = _slicedToArray(_ref8, 2),
86
+ listenerKey = _ref9[0],
87
+ originalFunction = _ref9[1];
88
+ prev[listenerKey] = function (values) {
89
+ originalFunction === null || originalFunction === void 0 ? void 0 : originalFunction(values);
90
+ if (bindUrl) {
91
+ // guard: onInit 会在 mount 时被自动调用,需要避免其在任何情况下都调用 setUrlState。故增加幂等判断
92
+ var hasStringifiedDiff = false;
93
+ var hasValuesDiff = false;
94
+ for (var paramName in values) {
95
+ if (Object.hasOwn(values, paramName)) {
96
+ var oldValue = queryFromUrl === null || queryFromUrl === void 0 ? void 0 : queryFromUrl[paramName];
97
+ var newValue = values[paramName];
98
+ // 这里我们必须使用 stringify 来判断是否有变化,因为 special case 太多。例如,默认配置下:
99
+ // { a: [undefined, undefined], b: undefined, c: [], d: null, e: ''} 会生成 'd=&e='
100
+ // 类似地,{ a: [''], b: [null], c: [undefined] } 会生成 'a=&b='。更不用说还有非默认配置的情况
101
+ // 想要避免这种 hazard,我们必须使用钩子内部导出的、经过柯里化的 stringify 来判断生成的字符串是否无变化。
102
+ if (stringify(_defineProperty({}, paramName, newValue)) !== stringify(_defineProperty({}, paramName, oldValue))) {
103
+ hasStringifiedDiff = true;
104
+ break;
105
+ } else if (oldValue !== newValue) {
106
+ hasValuesDiff = true;
107
+ }
108
+ }
109
+ }
110
+ if (hasStringifiedDiff) {
111
+ setUrlState(values);
112
+ } else if (hasValuesDiff) {
113
+ // guard: 虽然 url 字符串没有变化,但是 values 变化了,还是需要触发组件的 update 以保证行为一致。
114
+ update();
115
+ }
116
+ }
58
117
  };
59
118
  return prev;
60
119
  }, {});
61
120
  // 使用 url 参数配置 QueryFilter 默认值(移除非表单值,兼容数组数据,兼容 SelectGroup 组件)
62
121
  var setValuesByUrlState = function setValuesByUrlState(form) {
63
122
  if (urlState) {
64
- var _Object$entries2;
65
- (_Object$entries2 = Object.entries(urlState)) === null || _Object$entries2 === void 0 ? void 0 : _Object$entries2.forEach(function (_ref8) {
66
- var _form$query2;
67
- var _ref9 = _slicedToArray(_ref8, 2),
68
- key = _ref9[0],
69
- value = _ref9[1];
70
- var field = (_form$query2 = form.query(key)) === null || _form$query2 === void 0 ? void 0 : _form$query2.take();
123
+ var _Object$entries3;
124
+ (_Object$entries3 = Object.entries(urlState)) === null || _Object$entries3 === void 0 ? void 0 : _Object$entries3.forEach(function (_ref10) {
125
+ var _form$query3;
126
+ var _ref11 = _slicedToArray(_ref10, 2),
127
+ key = _ref11[0],
128
+ value = _ref11[1];
129
+ var field = (_form$query3 = form.query(key)) === null || _form$query3 === void 0 ? void 0 : _form$query3.take();
71
130
  if (field) {
72
131
  var newValue = value;
73
132
  if (field.displayName === 'ArrayField') {
74
133
  newValue = [].concat((0, _utils.isUsable)(newValue) ? newValue : []);
75
134
  }
76
- if (field.component[0] === 'SelectGroup') {
77
- newValue = newValue.map(function (item) {
78
- var _item$split = item === null || item === void 0 ? void 0 : item.split('||'),
79
- _item$split2 = _slicedToArray(_item$split, 2),
80
- key = _item$split2[0],
81
- value = _item$split2[1];
82
- return {
83
- key: key,
84
- value: value === null || value === void 0 ? void 0 : value.split('|')
85
- };
86
- });
87
- }
135
+ // 这部分应该挪到上面的 beforeParse 里面做,beforeParse 和 beforeStringify 应该是互逆的
136
+ // if (field.component[0] === 'SelectGroup') {
137
+ // newValue = newValue.map((item: any) => {
138
+ // const [key, value] = item?.split('||');
139
+ // return { key, value: value?.split('|') };
140
+ // });
141
+ // }
88
142
  form.setValuesIn(key, newValue);
89
143
  }
90
144
  });
@@ -93,5 +147,4 @@ var _default = function _default(bindUrl, functions, formRef) {
93
147
  return _objectSpread({
94
148
  setValuesByUrlState: setValuesByUrlState
95
149
  }, initializedFunctions);
96
- };
97
- exports.default = _default;
150
+ }
package/lib/index.d.ts CHANGED
@@ -30,5 +30,5 @@ export * from './sidebar';
30
30
  export * from './utils';
31
31
  export * from './timeline';
32
32
  export * from './image';
33
- declare const version = "1.5.44";
33
+ declare const version = "1.5.46-beta.2";
34
34
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, ProSidebar, ProTimeline, TeamixIcon, ProImage, hooks, nocode, templates, utils, };
package/lib/index.js CHANGED
@@ -299,7 +299,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
299
299
  if (!((_window = window) === null || _window === void 0 ? void 0 : _window.TEAMIXPRO_WITHOUT_ICON)) {
300
300
  _icon.default.setConfig(_utils.default.getTeamixIconConfig());
301
301
  }
302
- var version = '1.5.44';
302
+ var version = '1.5.46-beta.2';
303
303
  // By TeamixTest
304
304
  exports.version = version;
305
305
  window.postMessage({
@@ -137,7 +137,7 @@ var ProPageHeader = function ProPageHeader(props) {
137
137
  style = props.style,
138
138
  tabs = props.tabs,
139
139
  others = _objectWithoutProperties(props, _excluded3);
140
- var history = (0, _utils.useRealHistory)();
140
+ var history = (0, _utils.useReactHistory)();
141
141
  var backgroundImage = image ? "url('".concat(image, "')") : undefined;
142
142
  var showList = function showList(list) {
143
143
  var _list$actions;