@teamias/rex-design 0.0.36 → 0.0.38

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.
@@ -41,6 +41,7 @@ export var BaseDescriptions = function BaseDescriptions(_ref) {
41
41
  padding: '12px'
42
42
  }
43
43
  }, styles),
44
+ column: column,
44
45
  items: items === null || items === void 0 ? void 0 : items.map(function (item, index) {
45
46
  try {
46
47
  var _item$children;
@@ -1,3 +1,3 @@
1
1
  import { FC } from 'react';
2
2
  import { IBaseFormProps } from '../types';
3
- export declare const BaseForm: FC<IBaseFormProps>;
3
+ export declare const Core: FC<IBaseFormProps>;
@@ -19,7 +19,7 @@ import { BaseFormStyle } from "../style";
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  import { Fragment as _Fragment } from "react/jsx-runtime";
21
21
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
- export var BaseForm = function BaseForm(props) {
22
+ export var Core = function Core(props) {
23
23
  var rawAllProps = props;
24
24
  var outFields = props.fields,
25
25
  outFieldProps = props.fieldProps,
@@ -13,7 +13,7 @@ import { Descriptions, Form } from 'antd';
13
13
  import { merge } from 'lodash';
14
14
  import { useMemo } from 'react';
15
15
  import { DescriptionsStyle } from "../style";
16
- import { BaseForm } from "./base-form";
16
+ import { Core } from "./core";
17
17
  import { jsx as _jsx } from "react/jsx-runtime";
18
18
  export var DescriptionsModel = function DescriptionsModel(_ref) {
19
19
  var _ref$descriptionsProp = _ref.descriptionsProps,
@@ -73,7 +73,7 @@ export var DescriptionsModel = function DescriptionsModel(_ref) {
73
73
  }
74
74
  }
75
75
  }),
76
- children: /*#__PURE__*/_jsx(BaseForm, _objectSpread(_objectSpread({}, baseFormProps), {}, {
76
+ children: /*#__PURE__*/_jsx(Core, _objectSpread(_objectSpread({}, baseFormProps), {}, {
77
77
  itemMarginBottom: 0,
78
78
  fields: [_objectSpread(_objectSpread({}, otherData), {}, {
79
79
  rules: rules,
@@ -1,4 +1,4 @@
1
- import { BaseForm as RawBaseForm } from './base-form';
1
+ import { Core } from './core';
2
2
  import { DescriptionsModel as BaseDescriptionsForm } from './descriptions-model';
3
- declare const BaseForm: typeof RawBaseForm;
3
+ declare const BaseForm: typeof Core;
4
4
  export { BaseDescriptionsForm, BaseForm };
@@ -4,13 +4,13 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
- import { BaseForm as RawBaseForm } from "./base-form";
7
+ import { Core } from "./core";
8
8
  import { DescriptionsModel as BaseDescriptionsForm } from "./descriptions-model";
9
9
  import { jsx as _jsx } from "react/jsx-runtime";
10
10
  var BaseForm = function BaseForm(props) {
11
11
  if (props.type === 'descriptions') {
12
12
  return /*#__PURE__*/_jsx(BaseDescriptionsForm, _objectSpread({}, props));
13
13
  }
14
- return /*#__PURE__*/_jsx(RawBaseForm, _objectSpread({}, props));
14
+ return /*#__PURE__*/_jsx(Core, _objectSpread({}, props));
15
15
  };
16
16
  export { BaseDescriptionsForm, BaseForm };
@@ -4,16 +4,25 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
4
4
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
5
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
6
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
13
  import enUS from "../../../locales/en-US.json";
8
14
  import { UserOutlined } from '@ant-design/icons';
9
15
  import { ProForm } from '@ant-design/pro-components';
10
- import { RexProConfigProvider } from "../../..";
16
+ import { resetFormTouched, RexProConfigProvider } from "../../..";
11
17
  import { crush } from 'radash';
12
18
  import { createIntl } from 'react-intl';
13
19
  import { BaseForm } from "../core";
14
20
  import { getFieldsDefaultValues } from "../modules/handlerData";
15
21
  import { jsx as _jsx } from "react/jsx-runtime";
16
22
  export default (function () {
23
+ var _ProForm$useForm = ProForm.useForm(),
24
+ _ProForm$useForm2 = _slicedToArray(_ProForm$useForm, 1),
25
+ form = _ProForm$useForm2[0];
17
26
  var fields = [{
18
27
  label: '成本区间',
19
28
  valueType: 'multipleComponents',
@@ -70,7 +79,11 @@ export default (function () {
70
79
  }, {
71
80
  valueType: 'datePicker',
72
81
  field: 'multipleComponents-datePicker',
73
- defaultValue: '2025-05-05'
82
+ defaultValue: '2025-05-05',
83
+ dependenciesV2: [{
84
+ action: 'clear',
85
+ field: 'multipleComponents-treeSelect'
86
+ }]
74
87
  }, {
75
88
  valueType: 'treeSelect',
76
89
  field: 'multipleComponents-treeSelect2',
@@ -237,6 +250,47 @@ export default (function () {
237
250
  // target: true,
238
251
  // }
239
252
  // ],
253
+ }, {
254
+ valueType: 'select',
255
+ field: 'org_id',
256
+ label: '部门',
257
+ itemWidth: '200px',
258
+ options: [{
259
+ label: '1',
260
+ value: '1'
261
+ }, {
262
+ label: '2',
263
+ value: '2'
264
+ }, {
265
+ label: '3',
266
+ value: '3'
267
+ }]
268
+ }, {
269
+ valueType: 'select',
270
+ field: 'job_id',
271
+ label: '岗位',
272
+ itemWidth: '200px',
273
+ options: [{
274
+ label: '1',
275
+ value: '1'
276
+ }, {
277
+ label: '2',
278
+ value: '2'
279
+ }, {
280
+ label: '3',
281
+ value: '3'
282
+ }],
283
+ dependenciesV2: [{
284
+ field: 'org_id',
285
+ action: 'show',
286
+ op: 'notEmpty'
287
+ }, {
288
+ field: 'org_id',
289
+ action: 'updateData'
290
+ }, {
291
+ field: 'org_id',
292
+ action: 'clear'
293
+ }]
240
294
  }];
241
295
  var initialValues = getFieldsDefaultValues(fields);
242
296
  // console.log(initialValues);
@@ -251,9 +305,12 @@ export default (function () {
251
305
  children: /*#__PURE__*/_jsx(ProForm, {
252
306
  initialValues: initialValues
253
307
  // size="small"
308
+ ,
309
+ form: form
254
310
  // readonly
255
311
  ,
256
312
  onFinish: function onFinish(values) {
313
+ resetFormTouched(values, form);
257
314
  console.log(values);
258
315
  },
259
316
  children: /*#__PURE__*/_jsx(BaseForm, {
@@ -2,3 +2,4 @@ export * from './core';
2
2
  export * from './modules/handlerData';
3
3
  export * from './modules/valuesToFields';
4
4
  export * from './types';
5
+ export * from './utils';
@@ -1,4 +1,5 @@
1
1
  export * from "./core";
2
2
  export * from "./modules/handlerData";
3
3
  export * from "./modules/valuesToFields";
4
- export * from "./types";
4
+ export * from "./types";
5
+ export * from "./utils";
@@ -22,7 +22,7 @@ import classNames from 'classnames';
22
22
  import dayjs from 'dayjs';
23
23
  import { ProFormDateRangePickerV2 } from "../components/ProFormDateRangePickerV2";
24
24
  import { ProFormDigitRangeV2 } from "../components/ProFormDigitRangeV2";
25
- import { BaseForm } from "../core/base-form";
25
+ import { Core } from "../core/core";
26
26
  import { getFieldsDefaultValues } from "./handlerData";
27
27
  import { createElement as _createElement } from "react";
28
28
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -167,7 +167,7 @@ export var renderComponentNode = function renderComponentNode(outConfig, values,
167
167
  className: classNames('base-form-field-multiple-group', {
168
168
  compact: inlineItem.compact
169
169
  }),
170
- children: /*#__PURE__*/_jsx(BaseForm, _objectSpread(_objectSpread({}, outConfig.rawAllProps), {}, {
170
+ children: /*#__PURE__*/_jsx(Core, _objectSpread(_objectSpread({}, outConfig.rawAllProps), {}, {
171
171
  itemWidth: "".concat(100 / ((_inlineItem$subItems$ = (_inlineItem$subItems = inlineItem.subItems) === null || _inlineItem$subItems === void 0 ? void 0 : _inlineItem$subItems.length) !== null && _inlineItem$subItems$ !== void 0 ? _inlineItem$subItems$ : 1), "%"),
172
172
  fields: inlineItem.subItems,
173
173
  itemMarginBottom: 0
@@ -0,0 +1,47 @@
1
+ import { FormInstance } from 'antd';
2
+ /**
3
+ * @desc 重置表单的 touched 状态
4
+ * @example 解决场景:表单提交后,某些字段依赖其他字段变化触发清空,导致表单项的 touched 状态异常,从而影响表单提交后自动清空值。
5
+ * - 使用该函数可以在表单提交后,重置所有字段的 touched 状态,确保表单能够正确显示。
6
+ * @example 使用示例:
7
+ ```tsx
8
+ const fields: GetProps<typeof BaseForm>['fields'] = [
9
+ {
10
+ valueType: 'select',
11
+ field: 'org_id',
12
+ label: '部门',
13
+ options: [
14
+ { label: '1', value: '1' },
15
+ { label: '2', value: '2' },
16
+ { label: '3', value: '3' },
17
+ ],
18
+ },
19
+ {
20
+ valueType: 'select',
21
+ field: 'job_id',
22
+ label: '岗位',
23
+ options: [
24
+ { label: '1', value: '1' },
25
+ { label: '2', value: '2' },
26
+ { label: '3', value: '3' },
27
+ ],
28
+ dependenciesV2: [
29
+ {
30
+ field: 'org_id',
31
+ action: 'show',
32
+ op: 'notEmpty',
33
+ },
34
+ {
35
+ field: 'org_id',
36
+ action: 'updateData',
37
+ },
38
+ {
39
+ field: 'org_id',
40
+ action: 'clear',
41
+ },
42
+ ],
43
+ },
44
+ ]
45
+ ```
46
+ */
47
+ export declare const resetFormTouched: (data: Record<string, any>, form: FormInstance) => void;
@@ -0,0 +1,56 @@
1
+ import { crush } from 'radash';
2
+
3
+ /**
4
+ * @desc 重置表单的 touched 状态
5
+ * @example 解决场景:表单提交后,某些字段依赖其他字段变化触发清空,导致表单项的 touched 状态异常,从而影响表单提交后自动清空值。
6
+ * - 使用该函数可以在表单提交后,重置所有字段的 touched 状态,确保表单能够正确显示。
7
+ * @example 使用示例:
8
+ ```tsx
9
+ const fields: GetProps<typeof BaseForm>['fields'] = [
10
+ {
11
+ valueType: 'select',
12
+ field: 'org_id',
13
+ label: '部门',
14
+ options: [
15
+ { label: '1', value: '1' },
16
+ { label: '2', value: '2' },
17
+ { label: '3', value: '3' },
18
+ ],
19
+ },
20
+ {
21
+ valueType: 'select',
22
+ field: 'job_id',
23
+ label: '岗位',
24
+ options: [
25
+ { label: '1', value: '1' },
26
+ { label: '2', value: '2' },
27
+ { label: '3', value: '3' },
28
+ ],
29
+ dependenciesV2: [
30
+ {
31
+ field: 'org_id',
32
+ action: 'show',
33
+ op: 'notEmpty',
34
+ },
35
+ {
36
+ field: 'org_id',
37
+ action: 'updateData',
38
+ },
39
+ {
40
+ field: 'org_id',
41
+ action: 'clear',
42
+ },
43
+ ],
44
+ },
45
+ ]
46
+ ```
47
+ */
48
+ export var resetFormTouched = function resetFormTouched(data, form) {
49
+ var keys = Object.keys(crush(data));
50
+ form.setFields(keys.map(function (key) {
51
+ return {
52
+ name: key.split('.'),
53
+ touched: false
54
+ };
55
+ }));
56
+ };
@@ -33,8 +33,12 @@ export interface IBaseTableProps<T extends object = object> extends Omit<TRawTab
33
33
  useDataCellConfig?: boolean;
34
34
  /** dataCell 组件配置项, 通过这种方式来配置单元格内容,简化bff层的逻辑 */
35
35
  dataCellConfig?: TDataCellConfig;
36
- /** dataCell组件中的点击回调 */
36
+ /**
37
+ * @desc dataCell组件中的点击回调
38
+ * @deprecated 请使用 onDataCellClickV2
39
+ */
37
40
  onDataCellClick?: (item: IDataCellItem, dataIndex: string, record: T, index: number) => void;
41
+ /** dataCell组件中的点击回调 */
38
42
  onDataCellClickV2?: (data: {
39
43
  item: IDataCellItem;
40
44
  subItem?: Exclude<TGroupV2['props'], undefined>['items'][number];
@@ -4,7 +4,12 @@ import { Fragment as _Fragment } from "react/jsx-runtime";
4
4
  import { jsxs as _jsxs } from "react/jsx-runtime";
5
5
  export default (function () {
6
6
  return /*#__PURE__*/_jsxs(_Fragment, {
7
- children: [/*#__PURE__*/_jsx(DataCell, {
7
+ children: [/*#__PURE__*/_jsx("a", {
8
+ href: "http://baidu.com",
9
+ target: "_blank",
10
+ rel: "noreferrer",
11
+ children: "baidu"
12
+ }), /*#__PURE__*/_jsx(DataCell, {
8
13
  items: [{
9
14
  type: 'text',
10
15
  props: {
@@ -26,8 +31,16 @@ export default (function () {
26
31
  }, {
27
32
  type: 'link',
28
33
  props: {
29
- label: 'ssss',
30
- value: 'http://'
34
+ label: 'link-baidu-blank',
35
+ value: 'http://baidu.com'
36
+ // urlTarget: '_self',
37
+ }
38
+ }, {
39
+ type: 'link',
40
+ props: {
41
+ label: 'link-baidu-self',
42
+ value: 'http://baidu.com',
43
+ urlTarget: '_self'
31
44
  }
32
45
  }, {
33
46
  type: 'icon',
@@ -13,6 +13,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
13
13
  import { Icons, MediaViewer } from "../../..";
14
14
  import { Tag, Tooltip, Typography } from 'antd';
15
15
  import React from 'react';
16
+ import { Navigate } from 'react-router';
16
17
  import { DataCell } from "../data-cell";
17
18
  import { DataCellRowText, DataCellRowTextLabel, DataCellRowTextValue } from "../style";
18
19
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -26,7 +27,6 @@ var isEmpty = function isEmpty(val) {
26
27
 
27
28
  /** 动作块渲染 */
28
29
  var actionRender = function actionRender(item, action, node, click) {
29
- var _item$urlTarget;
30
30
  var tooltipBox = function tooltipBox(content) {
31
31
  if (item.tooltip) {
32
32
  return /*#__PURE__*/_jsx(Tooltip, {
@@ -43,15 +43,9 @@ var actionRender = function actionRender(item, action, node, click) {
43
43
  }
44
44
  return content;
45
45
  };
46
- if (action === 'default') {
47
- return tooltipBox( /*#__PURE__*/_jsx("span", {
48
- style: item.style,
49
- children: node
50
- }));
51
- }
52
46
 
53
- // 自定义
54
- if (action === 'custom') {
47
+ /** 创建自定义 node */
48
+ var createCustomNode = function createCustomNode() {
55
49
  return tooltipBox( /*#__PURE__*/_jsx("a", {
56
50
  href: "void",
57
51
  style: item.style,
@@ -61,21 +55,49 @@ var actionRender = function actionRender(item, action, node, click) {
61
55
  },
62
56
  children: node
63
57
  }));
58
+ };
59
+
60
+ /** 创建 link node */
61
+ var createLinkNode = function createLinkNode() {
62
+ var _item$urlTarget;
63
+ var target = (_item$urlTarget = item.urlTarget) !== null && _item$urlTarget !== void 0 ? _item$urlTarget : '_blank';
64
+ return tooltipBox( /*#__PURE__*/_jsx("a", {
65
+ style: item.style,
66
+ href: target === '_blank' ? item.value : 'void',
67
+ target: target,
68
+ rel: "noreferrer",
69
+ onClick: function onClick(e) {
70
+ if (target !== '_blank') {
71
+ e.preventDefault();
72
+ try {
73
+ Navigate({
74
+ to: item.value || '',
75
+ replace: false
76
+ });
77
+ } catch (error) {
78
+ window.location.href = item.value || '';
79
+ }
80
+ }
81
+ },
82
+ children: node
83
+ }));
84
+ };
85
+ if (action === 'default') {
86
+ return tooltipBox( /*#__PURE__*/_jsx("span", {
87
+ style: item.style,
88
+ children: node
89
+ }));
90
+ }
91
+
92
+ // 自定义
93
+ if (action === 'custom') {
94
+ return createCustomNode();
64
95
  }
65
96
 
66
97
  // TODO: 窗口-未实现
67
- // if (action === 'modal') {
68
- // return <a href="javascript:void;" onClick={() => click?.()}>{node}</a>
69
- // }
70
98
 
71
99
  // 默认url
72
- return tooltipBox( /*#__PURE__*/_jsx("a", {
73
- style: item.style,
74
- href: item.value,
75
- target: (_item$urlTarget = item.urlTarget) !== null && _item$urlTarget !== void 0 ? _item$urlTarget : '_blank',
76
- rel: "noreferrer",
77
- children: node
78
- }));
100
+ return createLinkNode();
79
101
  };
80
102
  export var cellItemMap = {
81
103
  /** 文本块 */
@@ -176,7 +176,7 @@ export type TCellActionExtend = {
176
176
  * - custom 透传出去
177
177
  * - default 什么都不做
178
178
  */
179
- action: 'url' | 'modal-form' | 'modal-search' | 'custom' | 'default';
179
+ action: 'url' | 'custom' | 'default';
180
180
  /**
181
181
  * url 跳转类型
182
182
  * - a 标签的 target 属性
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-design",
3
- "version": "0.0.36",
3
+ "version": "0.0.38",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -76,6 +76,7 @@
76
76
  "radash": "^12.1.1",
77
77
  "rc-virtual-list": "^3.19.1",
78
78
  "react-intl": "^7.1.11",
79
+ "react-router": "6",
79
80
  "styled-components": "^6.1.19"
80
81
  },
81
82
  "devDependencies": {
@@ -107,7 +108,8 @@
107
108
  "antd": ">=5.0.0",
108
109
  "react": ">=16.9.0",
109
110
  "react-dom": ">=16.9.0",
110
- "react-intl": ">=3.0.0"
111
+ "react-intl": ">=3.0.0",
112
+ "react-router": ">=6.0.0"
111
113
  },
112
114
  "publishConfig": {
113
115
  "access": "public"