@teamias/rex-design 0.1.3 → 0.1.4

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.
@@ -1,18 +1,25 @@
1
+ import { useRexProConfigProvider } from "../../context";
1
2
  import React from 'react';
2
3
  import { cellItemMap } from "./modules/cellItemMap";
3
4
  import { Wrapper } from "./style";
4
5
  import { jsx as _jsx } from "react/jsx-runtime";
5
6
  export var DataCell = function DataCell(_ref) {
6
7
  var items = _ref.items,
7
- onClick = _ref.onClick;
8
- // const arr = items.map(ii => cellItemMap[ii.type](ii, onClick));
9
- // return arr.map((node, index) => <div key={index} className={`data-cell-row-item ${ii.type}`}>{node}</div>);
8
+ onClick = _ref.onClick,
9
+ propSystemHistory = _ref.systemHistory;
10
+ var _useRexProConfigProvi = useRexProConfigProvider(),
11
+ contextSystemHistory = _useRexProConfigProvi.systemHistory;
12
+ var systemHistory = propSystemHistory !== null && propSystemHistory !== void 0 ? propSystemHistory : contextSystemHistory;
10
13
  return items.map(function (item, index) {
11
14
  var _cellItemMap$item$typ;
12
15
  return /*#__PURE__*/_jsx(Wrapper, {
13
16
  style: item.rootStyle,
14
17
  className: "data-cell-row-item ".concat(item.type),
15
- children: (_cellItemMap$item$typ = cellItemMap[item.type]) === null || _cellItemMap$item$typ === void 0 ? void 0 : _cellItemMap$item$typ.call(cellItemMap, item, onClick)
18
+ children: (_cellItemMap$item$typ = cellItemMap[item.type]) === null || _cellItemMap$item$typ === void 0 ? void 0 : _cellItemMap$item$typ.call(cellItemMap, {
19
+ item: item,
20
+ click: onClick,
21
+ systemHistory: systemHistory
22
+ })
16
23
  }, index);
17
24
  });
18
25
  };
@@ -1,3 +1,11 @@
1
+ import { useRexProConfigProvider } from "../../..";
1
2
  import React from 'react';
2
3
  import { IDataCellProps, TDataCellType, TGroupV2 } from '../types';
3
- export declare const cellItemMap: Record<TDataCellType, (item: IDataCellProps['items'][number], click?: (rawItem: IDataCellProps['items'][number], subItem?: Exclude<TGroupV2['props'], undefined>['items'][number]) => void) => React.ReactNode>;
4
+ export declare const cellItemMap: TCellItemMap;
5
+ type TCellItemFnData = {
6
+ item: IDataCellProps['items'][number];
7
+ click?: (rawItem: IDataCellProps['items'][number], subItem?: Exclude<TGroupV2['props'], undefined>['items'][number]) => void;
8
+ systemHistory?: ReturnType<typeof useRexProConfigProvider>['systemHistory'];
9
+ };
10
+ type TCellItemMap = Record<TDataCellType, (data: TCellItemFnData) => React.ReactNode>;
11
+ export {};
@@ -14,7 +14,6 @@ import { EyeOutlined } from '@ant-design/icons';
14
14
  import { downloadResourceFile, Icons, MediaViewer, showFileViewer } from "../../..";
15
15
  import { Tag, Tooltip, Typography } from 'antd';
16
16
  import React from 'react';
17
- import { Navigate } from 'react-router';
18
17
  import { DataCell } from "../data-cell";
19
18
  import { DataCellRowText, DataCellRowTextLabel, DataCellRowTextValue } from "../style";
20
19
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -27,7 +26,7 @@ var isEmpty = function isEmpty(val) {
27
26
  };
28
27
 
29
28
  /** 动作块渲染 */
30
- var actionRender = function actionRender(item, action, node, click) {
29
+ var actionRender = function actionRender(item, action, node, click, systemHistory) {
31
30
  var tooltipBox = function tooltipBox(content) {
32
31
  if (item.tooltip) {
33
32
  return /*#__PURE__*/_jsx(Tooltip, {
@@ -70,12 +69,9 @@ var actionRender = function actionRender(item, action, node, click) {
70
69
  onClick: function onClick(e) {
71
70
  if (target !== '_blank') {
72
71
  e.preventDefault();
73
- try {
74
- Navigate({
75
- to: item.value || '',
76
- replace: false
77
- });
78
- } catch (error) {
72
+ if (systemHistory) {
73
+ systemHistory === null || systemHistory === void 0 || systemHistory.push(item.value || '');
74
+ } else {
79
75
  window.location.href = item.value || '';
80
76
  }
81
77
  }
@@ -132,7 +128,10 @@ var actionRender = function actionRender(item, action, node, click) {
132
128
  };
133
129
  export var cellItemMap = {
134
130
  /** 文本块 */
135
- text: function text(item, click) {
131
+ text: function text(_ref) {
132
+ var item = _ref.item,
133
+ click = _ref.click,
134
+ systemHistory = _ref.systemHistory;
136
135
  var props = item.props;
137
136
  if (!props) return undefined;
138
137
  return !isEmpty(props.label) || !isEmpty(props.value) ? /*#__PURE__*/_jsxs(DataCellRowText, {
@@ -154,7 +153,11 @@ export var cellItemMap = {
154
153
  return /*#__PURE__*/_jsx(DataCellRowTextValue, {
155
154
  className: "data-cell-row-text-value",
156
155
  style: props === null || props === void 0 ? void 0 : props.valueStyle,
157
- children: cellItemMap[props.value.type](props.value, click)
156
+ children: cellItemMap[props.value.type]({
157
+ item: props.value,
158
+ click: click,
159
+ systemHistory: systemHistory
160
+ })
158
161
  });
159
162
  }
160
163
  return /*#__PURE__*/_jsx(DataCellRowTextValue, {
@@ -172,7 +175,8 @@ export var cellItemMap = {
172
175
  }) : undefined;
173
176
  },
174
177
  /** 图片块 */
175
- img: function img(item) {
178
+ img: function img(_ref2) {
179
+ var item = _ref2.item;
176
180
  var props = item.props;
177
181
  return /*#__PURE__*/_jsx(MediaViewer, _objectSpread({
178
182
  src: props === null || props === void 0 ? void 0 : props.value,
@@ -180,11 +184,12 @@ export var cellItemMap = {
180
184
  }, props));
181
185
  },
182
186
  /** 链接块 */
183
- link: function link(item, click) {
187
+ link: function link(_ref3) {
188
+ var item = _ref3.item,
189
+ click = _ref3.click,
190
+ systemHistory = _ref3.systemHistory;
184
191
  var props = item.props;
185
192
  if (!props) return undefined;
186
-
187
- // return actionRender(props, props.action, props.label, () => click?.(item));
188
193
  return /*#__PURE__*/_jsxs(DataCellRowText, {
189
194
  className: "data-cell-row-text link",
190
195
  children: [/*#__PURE__*/_jsx(DataCellRowTextValue, {
@@ -196,7 +201,7 @@ export var cellItemMap = {
196
201
  },
197
202
  children: actionRender(props, props.action, props.label, function () {
198
203
  return click === null || click === void 0 ? void 0 : click(item);
199
- })
204
+ }, systemHistory)
200
205
  }), props.copyable ? /*#__PURE__*/_jsx(Typography.Paragraph, {
201
206
  copyable: {
202
207
  text: typeof props.copyable === 'string' ? props.copyable : "".concat(props.label)
@@ -205,7 +210,10 @@ export var cellItemMap = {
205
210
  });
206
211
  },
207
212
  /** 链接组 */
208
- 'link-group': function linkGroup(item, click) {
213
+ 'link-group': function linkGroup(_ref4) {
214
+ var item = _ref4.item,
215
+ click = _ref4.click,
216
+ systemHistory = _ref4.systemHistory;
209
217
  var props = item.props;
210
218
  if (!props) return undefined;
211
219
  return /*#__PURE__*/_jsx("div", {
@@ -219,9 +227,13 @@ export var cellItemMap = {
219
227
  display: 'inline-flex'
220
228
  },
221
229
  children: [cellItemMap.link({
222
- props: child,
223
- type: 'link'
224
- }, click), (props === null || props === void 0 ? void 0 : props.items.length) - 1 === index ? '' : /*#__PURE__*/_jsx("span", {
230
+ item: {
231
+ props: child,
232
+ type: 'link'
233
+ },
234
+ click: click,
235
+ systemHistory: systemHistory
236
+ }), (props === null || props === void 0 ? void 0 : props.items.length) - 1 === index ? '' : /*#__PURE__*/_jsx("span", {
225
237
  style: {
226
238
  paddingInline: 2
227
239
  },
@@ -232,7 +244,9 @@ export var cellItemMap = {
232
244
  });
233
245
  },
234
246
  /** tag块 */
235
- tag: function tag(item, click) {
247
+ tag: function tag(_ref5) {
248
+ var item = _ref5.item,
249
+ click = _ref5.click;
236
250
  var props = item.props;
237
251
  if (!props) return undefined;
238
252
  var color = function () {
@@ -264,8 +278,12 @@ export var cellItemMap = {
264
278
  }) : '']
265
279
  })) : undefined;
266
280
  },
267
- icon: function icon(item, click) {
281
+ /** 图标块 */
282
+ icon: function icon(_ref6) {
268
283
  var _props$action;
284
+ var item = _ref6.item,
285
+ click = _ref6.click,
286
+ systemHistory = _ref6.systemHistory;
269
287
  var props = item.props;
270
288
  if (!props) return undefined;
271
289
  return actionRender(props, (_props$action = props.action) !== null && _props$action !== void 0 ? _props$action : 'default', /*#__PURE__*/_jsx(Icons, {
@@ -273,32 +291,39 @@ export var cellItemMap = {
273
291
  name: props.value
274
292
  }), function () {
275
293
  return click === null || click === void 0 ? void 0 : click(item);
276
- });
294
+ }, systemHistory);
277
295
  },
278
296
  /** 块组 */
279
- group: function group(item, click) {
297
+ group: function group(_ref7) {
298
+ var item = _ref7.item,
299
+ click = _ref7.click,
300
+ systemHistory = _ref7.systemHistory;
280
301
  var props = item.props;
281
302
  if (!props) return undefined;
282
303
  return /*#__PURE__*/_jsx("div", {
283
304
  style: props.style,
284
305
  children: /*#__PURE__*/_jsx(DataCell, {
285
306
  items: props.items,
286
- onClick: click
307
+ onClick: click,
308
+ systemHistory: systemHistory
287
309
  })
288
310
  });
289
311
  },
290
- 'group-v2': function groupV2(item, click) {
312
+ /** 块组v2 */
313
+ 'group-v2': function groupV2(_ref8) {
291
314
  var _props$items;
315
+ var item = _ref8.item,
316
+ click = _ref8.click,
317
+ systemHistory = _ref8.systemHistory;
292
318
  var props = item.props;
293
319
  if (!props) return undefined;
294
- // itemsSeparator itemsStyle itemsDirection itemsGap
295
- // ellipsis tooltip copyable action urlTarget url style
296
320
  var renderItem = function renderItem(subItem, index) {
297
321
  var count = 0;
298
322
  if (subItem.type === 'group-v2') {
299
323
  return /*#__PURE__*/_jsx(DataCell, {
300
324
  items: [subItem],
301
- onClick: click
325
+ onClick: click,
326
+ systemHistory: systemHistory
302
327
  }, "renderItem-".concat(index, "-").concat(count++));
303
328
  }
304
329
  var ellipsis = subItem.ellipsis,
@@ -312,9 +337,7 @@ export var cellItemMap = {
312
337
  other = _objectWithoutProperties(subItem, _excluded);
313
338
  var renderBox = function renderBox(content) {
314
339
  var afterContent = /*#__PURE__*/_jsx(DataCellRowTextValue, {
315
- className: "data-cell-group-v2-value-item"
316
- // title={typeof content === 'string' ? content : ''}
317
- ,
340
+ className: "data-cell-group-v2-value-item",
318
341
  ellipsis: ellipsis,
319
342
  children: content
320
343
  }, "renderItem-".concat(index, "-").concat(count++));
@@ -341,12 +364,24 @@ export var cellItemMap = {
341
364
  });
342
365
  }
343
366
  if (action === 'url') {
367
+ var target = urlTarget !== null && urlTarget !== void 0 ? urlTarget : '_blank';
344
368
  return /*#__PURE__*/_jsx("a", {
345
- href: url,
346
- target: urlTarget !== null && urlTarget !== void 0 ? urlTarget : '_blank',
369
+ href: target === '_blank' ? url : 'void',
370
+ target: target,
371
+ rel: "noreferrer",
347
372
  style: _objectSpread({
348
373
  display: 'inline-flex'
349
374
  }, style),
375
+ onClick: function onClick(e) {
376
+ if (target !== '_blank') {
377
+ e.preventDefault();
378
+ try {
379
+ systemHistory === null || systemHistory === void 0 || systemHistory.push(url || '');
380
+ } catch (_unused) {
381
+ window.location.href = url || '';
382
+ }
383
+ }
384
+ },
350
385
  children: afterContent
351
386
  }, "renderItem-".concat(index, "-").concat(count++));
352
387
  }
@@ -400,18 +435,18 @@ export var cellItemMap = {
400
435
  return renderBox(subItem.value);
401
436
  case 'img':
402
437
  {
403
- var _ref = other,
404
- mediaViewerType = _ref.mediaViewerType,
405
- otherProps = _objectWithoutProperties(_ref, _excluded2);
438
+ var _ref9 = other,
439
+ mediaViewerType = _ref9.mediaViewerType,
440
+ otherProps = _objectWithoutProperties(_ref9, _excluded2);
406
441
  return renderBox( /*#__PURE__*/_jsx(MediaViewer, _objectSpread({
407
442
  type: mediaViewerType
408
443
  }, otherProps)));
409
444
  }
410
445
  case 'tag':
411
446
  {
412
- var _ref2 = other,
413
- value = _ref2.value,
414
- _otherProps = _objectWithoutProperties(_ref2, _excluded3);
447
+ var _ref10 = other,
448
+ value = _ref10.value,
449
+ _otherProps = _objectWithoutProperties(_ref10, _excluded3);
415
450
  var color = function () {
416
451
  if (subItem.color !== null && _typeof(subItem.color) === 'object') {
417
452
  var _subItem$color, _subItem$color$toHexS;
@@ -429,9 +464,9 @@ export var cellItemMap = {
429
464
  }
430
465
  case 'icon':
431
466
  {
432
- var _ref3 = other,
433
- iconsType = _ref3.iconsType,
434
- _otherProps2 = _objectWithoutProperties(_ref3, _excluded4);
467
+ var _ref11 = other,
468
+ iconsType = _ref11.iconsType,
469
+ _otherProps2 = _objectWithoutProperties(_ref11, _excluded4);
435
470
  return renderBox( /*#__PURE__*/_jsx(Icons, _objectSpread({
436
471
  type: iconsType
437
472
  }, _otherProps2)));
@@ -1,4 +1,4 @@
1
- import { Icons, MediaViewer } from "../..";
1
+ import { Icons, MediaViewer, useRexProConfigProvider } from "../..";
2
2
  import { GetProps, Tag } from 'antd';
3
3
  import { HTMLAttributeAnchorTarget } from 'react';
4
4
  /** 组件props */
@@ -7,6 +7,8 @@ export interface IDataCellProps {
7
7
  items: Array<TGroupV2 | IDataCellItem<TDataCellType>>;
8
8
  /** 点击回调 */
9
9
  onClick?: (item: IDataCellItem, subItem?: Exclude<TGroupV2['props'], undefined>['items'][number]) => void;
10
+ /** 系统路由历史对象,用于内部跳转 */
11
+ systemHistory?: ReturnType<typeof useRexProConfigProvider>['systemHistory'];
10
12
  }
11
13
  export interface IDataCellItem<T extends TDataCellType = TDataCellType> {
12
14
  /** 组件类型 */
@@ -19,6 +19,11 @@ export interface RexProConfigContextType {
19
19
  }>;
20
20
  };
21
21
  }>>;
22
+ /** 系统路由,外部传入 */
23
+ systemHistory?: History & {
24
+ push: (to: string, state?: unknown) => void;
25
+ replace: (to: string, state?: unknown) => void;
26
+ };
22
27
  /** 支持一些自定义属性 */
23
28
  [key: string]: unknown | undefined;
24
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-design",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -80,7 +80,6 @@
80
80
  "react-dom": "^18.3.1",
81
81
  "react-intl": "^7.1.11",
82
82
  "react-quick-pinch-zoom": "^5.1.1",
83
- "react-router": "6",
84
83
  "styled-components": "^6.1.19"
85
84
  },
86
85
  "devDependencies": {
@@ -110,8 +109,7 @@
110
109
  "antd": ">=5.0.0",
111
110
  "react": ">=16.9.0",
112
111
  "react-dom": ">=16.9.0",
113
- "react-intl": ">=3.0.0",
114
- "react-router": ">=6.0.0"
112
+ "react-intl": ">=3.0.0"
115
113
  },
116
114
  "publishConfig": {
117
115
  "access": "public"