@teamias/rex-design 0.0.21 → 0.0.22

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 (28) hide show
  1. package/dist/components/base-table/base-table.d.ts +2 -6
  2. package/dist/components/base-table/base-table.js +1 -8
  3. package/dist/components/big-input/big-input.d.ts +4 -0
  4. package/dist/components/big-input/big-input.js +173 -0
  5. package/dist/components/big-input/demo/index.js +64 -0
  6. package/dist/components/big-input/index.d.ts +2 -0
  7. package/dist/components/big-input/index.js +2 -0
  8. package/dist/components/big-input/types.d.ts +13 -0
  9. package/dist/components/big-input/types.js +1 -0
  10. package/dist/components/data-cell/index.d.ts +0 -1
  11. package/dist/components/data-cell/index.js +1 -2
  12. package/dist/components/data-cell/types.d.ts +0 -6
  13. package/dist/components/index.d.ts +2 -0
  14. package/dist/components/index.js +3 -1
  15. package/dist/components/upload-plus/demo/index.js +53 -0
  16. package/dist/components/upload-plus/index.d.ts +2 -0
  17. package/dist/components/upload-plus/index.js +2 -0
  18. package/dist/components/upload-plus/types.d.ts +3 -0
  19. package/dist/components/upload-plus/types.js +1 -0
  20. package/dist/components/upload-plus/upload-plus.d.ts +3 -0
  21. package/dist/components/upload-plus/upload-plus.js +83 -0
  22. package/package.json +1 -1
  23. package/dist/components/base-table/demo/DynamicData.js +0 -67
  24. package/dist/components/data-cell/demo/DynamicData.js +0 -80
  25. package/dist/components/data-cell/utils/index.d.ts +0 -3
  26. package/dist/components/data-cell/utils/index.js +0 -68
  27. /package/dist/components/{base-table/demo/DynamicData.d.ts → big-input/demo/index.d.ts} +0 -0
  28. /package/dist/components/{data-cell/demo/DynamicData.d.ts → upload-plus/demo/index.d.ts} +0 -0
@@ -1,7 +1,7 @@
1
1
  /// <reference types="react" />
2
2
  import { GetProps, Table } from 'antd';
3
- import { IDataCellItem, TDataCellConfig, TGroupV2 } from '../data-cell';
4
- export declare const BaseTable: <T extends object = object>({ useDataCellRender, fields: outFields, fieldsConfig, fieldProps: outFieldProps, requestFields, requestFieldsUrl, requestFieldsParams, fieldPropsFn, indexColumn, extraColumns, onDataCellClick, onDataCellClickV2, scroll, rootClassName, customEmptyText, headerStyle: topHeaderStyle, useDataCellConfig, dataCellConfig, dataSource, ...otherProps }: IBaseTableProps<T>) => import("react/jsx-runtime").JSX.Element;
3
+ import { IDataCellItem, TGroupV2 } from '../data-cell/types';
4
+ export declare const BaseTable: <T extends object = object>({ useDataCellRender, fields: outFields, fieldsConfig, fieldProps: outFieldProps, requestFields, requestFieldsUrl, requestFieldsParams, fieldPropsFn, indexColumn, extraColumns, onDataCellClick, onDataCellClickV2, scroll, rootClassName, customEmptyText, headerStyle: topHeaderStyle, ...otherProps }: IBaseTableProps<T>) => import("react/jsx-runtime").JSX.Element;
5
5
  /** 组件props */
6
6
  export interface IBaseTableProps<T extends object = object> extends Omit<TRawTableProps<T>, 'size' | 'bordered' | 'tableLayout' | 'scroll'> {
7
7
  /** @deprecated 使用 fieldsConfig */
@@ -29,10 +29,6 @@ export interface IBaseTableProps<T extends object = object> extends Omit<TRawTab
29
29
  * @default true
30
30
  */
31
31
  useDataCellRender?: boolean;
32
- /** 是否使用 dataCell 配置,进行渲染 */
33
- useDataCellConfig?: boolean;
34
- /** dataCell 组件配置项, 通过这种方式来配置单元格内容,简化bff层的逻辑 */
35
- dataCellConfig?: TDataCellConfig;
36
32
  /** dataCell组件中的点击回调 */
37
33
  onDataCellClick?: (item: IDataCellItem, dataIndex: string, record: T, index: number) => void;
38
34
  onDataCellClickV2?: (data: {
@@ -1,4 +1,4 @@
1
- var _excluded = ["useDataCellRender", "fields", "fieldsConfig", "fieldProps", "requestFields", "requestFieldsUrl", "requestFieldsParams", "fieldPropsFn", "indexColumn", "extraColumns", "onDataCellClick", "onDataCellClickV2", "scroll", "rootClassName", "customEmptyText", "headerStyle", "useDataCellConfig", "dataCellConfig", "dataSource"];
1
+ var _excluded = ["useDataCellRender", "fields", "fieldsConfig", "fieldProps", "requestFields", "requestFieldsUrl", "requestFieldsParams", "fieldPropsFn", "indexColumn", "extraColumns", "onDataCellClick", "onDataCellClickV2", "scroll", "rootClassName", "customEmptyText", "headerStyle"];
2
2
  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); }
3
3
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
4
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
@@ -12,7 +12,6 @@ import { useDebounceEffect } from 'ahooks';
12
12
  import { ConfigProvider, Empty, Skeleton, Table } from 'antd';
13
13
  import classNames from 'classnames';
14
14
  import { useMemo } from 'react';
15
- import { dataToDataCellData } from "../data-cell";
16
15
  import { DataCell } from "../data-cell/data-cell";
17
16
  import { BaseTableRow } from "./components/BaseTableRow";
18
17
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -36,10 +35,6 @@ export var BaseTable = function BaseTable(_ref) {
36
35
  rootClassName = _ref.rootClassName,
37
36
  customEmptyText = _ref.customEmptyText,
38
37
  topHeaderStyle = _ref.headerStyle,
39
- useDataCellConfig = _ref.useDataCellConfig,
40
- _ref$dataCellConfig = _ref.dataCellConfig,
41
- dataCellConfig = _ref$dataCellConfig === void 0 ? [] : _ref$dataCellConfig,
42
- dataSource = _ref.dataSource,
43
38
  otherProps = _objectWithoutProperties(_ref, _excluded);
44
39
  var responseConfig = useRequestFieldsConfig();
45
40
  var _useRexProConfigProvi = useRexProConfigProvider(),
@@ -65,7 +60,6 @@ export var BaseTable = function BaseTable(_ref) {
65
60
  }),
66
61
  loading = _useRequestFields.loading,
67
62
  fields = _useRequestFields.fields;
68
- // const newDataSrouce = useMemo(() => useDataCellConfig ? dataToDataCellData(dataSource as [], dataCellConfig) as [] : dataSource, [])
69
63
 
70
64
  /** 表格点击事件 */
71
65
  var cellClick = function cellClick(data) {
@@ -278,7 +272,6 @@ export var BaseTable = function BaseTable(_ref) {
278
272
  })),
279
273
  rowKey: "key"
280
274
  }, otherProps), {}, {
281
- dataSource: useDataCellConfig ? dataToDataCellData(dataSource, dataCellConfig) : dataSource,
282
275
  rootClassName: classNames(state.tableKey, rootClassName),
283
276
  onRow: function onRow() {
284
277
  return {
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { BigInputProps } from './types';
3
+ export declare const BigInput: React.FC<BigInputProps>;
4
+ export default BigInput;
@@ -0,0 +1,173 @@
1
+ var _excluded = ["placeholder", "onChange", "onBlur", "onFocus", "autoSize", "value", "disabled", "style", "className"];
2
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
9
+ 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; }
10
+ import React, { useState, useRef, useEffect, useCallback } from 'react';
11
+ import Input from 'antd/es/input';
12
+ import { jsx as _jsx } from "react/jsx-runtime";
13
+ import { Fragment as _Fragment } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ var TextArea = Input.TextArea;
16
+ export var BigInput = function BigInput(props) {
17
+ var _props$placeholder = props.placeholder,
18
+ placeholder = _props$placeholder === void 0 ? "请输入" : _props$placeholder,
19
+ handleChange = props.onChange,
20
+ handleBlur = props.onBlur,
21
+ handleFocus = props.onFocus,
22
+ autoSize = props.autoSize,
23
+ propsValue = props.value,
24
+ disabled = props.disabled,
25
+ style = props.style,
26
+ className = props.className,
27
+ rest = _objectWithoutProperties(props, _excluded);
28
+
29
+ // 状态管理
30
+ var _useState = useState(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ isExpanded = _useState2[0],
33
+ setIsExpanded = _useState2[1];
34
+ var _useState3 = useState(propsValue || ''),
35
+ _useState4 = _slicedToArray(_useState3, 2),
36
+ localValue = _useState4[0],
37
+ setLocalValue = _useState4[1];
38
+ var _useState5 = useState({
39
+ height: 32,
40
+ width: '100%'
41
+ }),
42
+ _useState6 = _slicedToArray(_useState5, 2),
43
+ inputSize = _useState6[0],
44
+ setInputSize = _useState6[1];
45
+ var textAreaRef = useRef(null);
46
+ var inputRef = useRef(null);
47
+
48
+ // 当外部value变化时更新本地状态
49
+ useEffect(function () {
50
+ setLocalValue(propsValue || '');
51
+ }, [propsValue]);
52
+
53
+ // 当isExpanded状态变为true时,自动聚焦到文本域并将光标移到文本末尾
54
+ useEffect(function () {
55
+ if (isExpanded && textAreaRef.current) {
56
+ var timer = setTimeout(function () {
57
+ var textarea = textAreaRef.current;
58
+ if (textarea) {
59
+ var _textarea$resizableTe;
60
+ // 对于Ant Design的TextArea,我们需要获取内部的DOM元素
61
+ // 获取内部DOM元素的安全方式
62
+ var domNode = (textarea === null || textarea === void 0 || (_textarea$resizableTe = textarea.resizableTextArea) === null || _textarea$resizableTe === void 0 ? void 0 : _textarea$resizableTe.textArea) || textarea;
63
+ if (domNode) {
64
+ domNode.focus();
65
+ var value = domNode.value || '';
66
+ var length = value.length;
67
+
68
+ // 检查元素是否支持setSelectionRange方法
69
+ if (typeof domNode.setSelectionRange === 'function') {
70
+ domNode.setSelectionRange(length, length);
71
+ }
72
+ }
73
+ }
74
+ }, 0);
75
+ // 清理定时器,避免内存泄漏
76
+ return function () {
77
+ return clearTimeout(timer);
78
+ };
79
+ }
80
+ }, [isExpanded]);
81
+ useEffect(function () {
82
+ // 确保inputRef.current存在
83
+ if (!isExpanded && inputRef.current) {
84
+ var _inputRef$current;
85
+ // 安全地获取DOM元素并检查方法存在性
86
+ var inputElement = (_inputRef$current = inputRef.current) === null || _inputRef$current === void 0 ? void 0 : _inputRef$current.input;
87
+ if (inputElement && typeof inputElement.getBoundingClientRect === 'function') {
88
+ var rect = inputElement.getBoundingClientRect();
89
+ setInputSize({
90
+ height: rect.height,
91
+ width: '100%'
92
+ });
93
+ }
94
+ }
95
+ }, [isExpanded]);
96
+
97
+ // 处理输入框的focus事件 - 只用于切换到文本域
98
+ var handleInputFocus = useCallback(function (e) {
99
+ setIsExpanded(true);
100
+ }, [handleFocus]);
101
+
102
+ // 处理文本域的blur事件 - 用于切回输入框
103
+ var handleTextAreaBlur = useCallback(function (e) {
104
+ setIsExpanded(false);
105
+ handleBlur === null || handleBlur === void 0 || handleBlur(e);
106
+ }, [handleBlur]);
107
+
108
+ // 处理文本域的onChange事件 - 主要的数据修改逻辑
109
+ var handleTextAreaChange = useCallback(function (e) {
110
+ var newValue = e.target.value;
111
+ setLocalValue(newValue);
112
+ // 直接使用文本域的change事件,不需要转换为输入框类型
113
+ handleChange === null || handleChange === void 0 || handleChange(e);
114
+ }, [handleChange]);
115
+
116
+ // 处理文本域的focus事件
117
+ var handleTextAreaFocus = useCallback(function (e) {
118
+ handleFocus === null || handleFocus === void 0 || handleFocus(e);
119
+ }, [handleFocus]);
120
+ return /*#__PURE__*/_jsx("div", {
121
+ style: {
122
+ position: 'relative'
123
+ },
124
+ children: isExpanded ? /*#__PURE__*/_jsxs(_Fragment, {
125
+ children: [/*#__PURE__*/_jsx("div", {
126
+ style: {
127
+ height: "".concat(inputSize.height, "px"),
128
+ width: inputSize.width,
129
+ backgroundColor: disabled ? '#f5f5f5' : 'transparent',
130
+ borderRadius: '2px',
131
+ boxSizing: 'border-box'
132
+ }
133
+ }), /*#__PURE__*/_jsx(TextArea, {
134
+ style: {
135
+ position: 'absolute',
136
+ top: 0,
137
+ left: 0,
138
+ right: 0,
139
+ zIndex: 1,
140
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
141
+ transition: 'all 0.3s ease-out',
142
+ transform: 'translateY(-2px)'
143
+ }
144
+ // 显式列出TextArea支持的属性,避免类型冲突
145
+ ,
146
+ value: localValue,
147
+ onChange: handleTextAreaChange,
148
+ onBlur: handleTextAreaBlur,
149
+ onFocus: handleTextAreaFocus,
150
+ placeholder: placeholder,
151
+ disabled: disabled,
152
+ autoSize: autoSize || {
153
+ minRows: 2,
154
+ maxRows: 6
155
+ },
156
+ ref: textAreaRef
157
+ // 传递TextArea特有属性
158
+ ,
159
+ showCount: rest.showCount,
160
+ maxLength: rest.maxLength
161
+ }, "textarea")]
162
+ }) : /*#__PURE__*/_jsx(Input, {
163
+ ref: inputRef,
164
+ onFocus: handleInputFocus,
165
+ placeholder: placeholder,
166
+ value: localValue,
167
+ disabled: disabled,
168
+ style: style,
169
+ className: className
170
+ }, "input")
171
+ });
172
+ };
173
+ export default BigInput;
@@ -0,0 +1,64 @@
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
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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; }
13
+ import { RexProConfigProvider } from "../../../context";
14
+ import enUS from "antd/es/calendar/locale/en_US";
15
+ import { crush } from "radash";
16
+ import { createIntl } from "react-intl";
17
+ import { BigInput } from "../../..";
18
+ import { useState } from "react";
19
+ import { jsx as _jsx } from "react/jsx-runtime";
20
+ import { jsxs as _jsxs } from "react/jsx-runtime";
21
+ export default (function () {
22
+ var _useState = useState(''),
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ localValue1 = _useState2[0],
25
+ setLocalValue1 = _useState2[1];
26
+ var _useState3 = useState(''),
27
+ _useState4 = _slicedToArray(_useState3, 2),
28
+ localValue2 = _useState4[0],
29
+ setLocalValue2 = _useState4[1];
30
+ return /*#__PURE__*/_jsxs(RexProConfigProvider, {
31
+ value: {
32
+ intl: createIntl({
33
+ locale: 'en-us',
34
+ messages: _objectSpread({}, crush(enUS))
35
+ })
36
+ },
37
+ children: [/*#__PURE__*/_jsx("p", {
38
+ children: "\u6587\u672C\u57DF1"
39
+ }), /*#__PURE__*/_jsx(BigInput, {
40
+ placeholder: "\u8BF7\u8F93\u5165",
41
+ onChange: function onChange(e) {
42
+ return setLocalValue1(e.target.value);
43
+ }
44
+ }), /*#__PURE__*/_jsxs("p", {
45
+ children: ["\u503C1\uFF1A", localValue1]
46
+ }), /*#__PURE__*/_jsx("p", {
47
+ children: "\u6587\u672C\u57DF2"
48
+ }), /*#__PURE__*/_jsx(BigInput, {
49
+ placeholder: "\u8BF7\u8F93\u5165",
50
+ allowClear: true,
51
+ showCount: true,
52
+ maxLength: 20,
53
+ autoSize: {
54
+ minRows: 4,
55
+ maxRows: 6
56
+ },
57
+ onChange: function onChange(e) {
58
+ return setLocalValue2(e.target.value);
59
+ }
60
+ }), /*#__PURE__*/_jsxs("p", {
61
+ children: ["\u503C2\uFF1A", localValue2]
62
+ })]
63
+ });
64
+ });
@@ -0,0 +1,2 @@
1
+ export * from './big-input';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export * from "./big-input";
2
+ export * from "./types";
@@ -0,0 +1,13 @@
1
+ import { InputProps } from 'antd/es/input';
2
+ import React from 'react';
3
+ export interface BigInputProps extends Omit<InputProps, 'prefix' | 'suffix' | 'addonBefore' | 'addonAfter' | 'onChange' | 'onBlur' | 'onFocus'> {
4
+ autoSize?: {
5
+ minRows: number;
6
+ maxRows: number;
7
+ } | boolean;
8
+ showCount?: boolean;
9
+ maxLength?: number;
10
+ onChange?: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
11
+ onBlur?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
12
+ onFocus?: (e: React.FocusEvent<HTMLTextAreaElement>) => void;
13
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,2 @@
1
1
  export * from './data-cell';
2
2
  export * from './types';
3
- export * from './utils';
@@ -1,3 +1,2 @@
1
1
  export * from "./data-cell";
2
- export * from "./types";
3
- export * from "./utils";
2
+ export * from "./types";
@@ -190,9 +190,3 @@ export type TCellActionExtend = {
190
190
  };
191
191
  /** 支持配置的展示类型 */
192
192
  export type TDataCellType = 'text' | 'link' | 'tag' | 'link-group' | 'img' | 'icon' | 'group' | 'group-v2';
193
- /** 数据单元格配置 */
194
- export type TDataCellConfig = Array<{
195
- field: string;
196
- key: string;
197
- items: Array<TGroupV2>;
198
- }>;
@@ -7,3 +7,5 @@ export * from './data-cell';
7
7
  export * from './icons';
8
8
  export * from './media-viewer';
9
9
  export * from './tiptap-editor';
10
+ export * from './big-input';
11
+ export * from './upload-plus';
@@ -6,4 +6,6 @@ export * from "./base-table";
6
6
  export * from "./data-cell";
7
7
  export * from "./icons";
8
8
  export * from "./media-viewer";
9
- export * from "./tiptap-editor";
9
+ export * from "./tiptap-editor";
10
+ export * from "./big-input";
11
+ export * from "./upload-plus";
@@ -0,0 +1,53 @@
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
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 { RexProConfigProvider } from "../../../context";
8
+ import enUS from "antd/es/calendar/locale/en_US";
9
+ import { crush } from "radash";
10
+ import { createIntl } from "react-intl";
11
+ import UploadPlus from "../upload-plus";
12
+ import { Card, message } from "antd";
13
+ import { jsx as _jsx } from "react/jsx-runtime";
14
+ import { jsxs as _jsxs } from "react/jsx-runtime";
15
+ export default (function () {
16
+ var props = {
17
+ name: 'file',
18
+ multiple: true,
19
+ action: 'https://www.mocky.io/v2/5cc8019d300000980a055e76',
20
+ onChange: function onChange(info) {
21
+ var status = info.file.status;
22
+ if (status !== 'uploading') {
23
+ console.log(info.file, info.fileList);
24
+ }
25
+ if (status === 'done') {
26
+ message.success("".concat(info.file.name, " file uploaded successfully."));
27
+ } else if (status === 'error') {
28
+ message.error("".concat(info.file.name, " file upload failed."));
29
+ }
30
+ },
31
+ onDrop: function onDrop(e) {
32
+ console.log('Dropped files', e.dataTransfer.files);
33
+ }
34
+ };
35
+ return /*#__PURE__*/_jsxs(RexProConfigProvider, {
36
+ value: {
37
+ intl: createIntl({
38
+ locale: 'en-us',
39
+ messages: _objectSpread({}, crush(enUS))
40
+ })
41
+ },
42
+ children: [/*#__PURE__*/_jsx("p", {
43
+ children: "\u4E0A\u4F20\u7EC4\u4EF61"
44
+ }), /*#__PURE__*/_jsx(Card, {
45
+ children: /*#__PURE__*/_jsx("div", {
46
+ style: {
47
+ padding: 12
48
+ },
49
+ children: /*#__PURE__*/_jsx(UploadPlus, _objectSpread({}, props))
50
+ })
51
+ })]
52
+ });
53
+ });
@@ -0,0 +1,2 @@
1
+ export * from './upload-plus';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ export * from "./upload-plus";
2
+ export * from "./types";
@@ -0,0 +1,3 @@
1
+ import { UploadProps } from 'antd';
2
+ export interface UploadPlusProps extends UploadProps {
3
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const App: React.FC;
3
+ export default App;
@@ -0,0 +1,83 @@
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
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 { InboxOutlined } from '@ant-design/icons';
8
+ import { Upload } from 'antd';
9
+ import React from 'react';
10
+ import { jsx as _jsx } from "react/jsx-runtime";
11
+ import { jsxs as _jsxs } from "react/jsx-runtime";
12
+ var Dragger = Upload.Dragger;
13
+ var App = function App(props) {
14
+ var draggerRef = React.useRef(null);
15
+
16
+ // 处理粘贴事件
17
+ React.useEffect(function () {
18
+ var handlePaste = function handlePaste(e) {
19
+ var _e$clipboardData;
20
+ var items = (_e$clipboardData = e.clipboardData) === null || _e$clipboardData === void 0 ? void 0 : _e$clipboardData.items;
21
+ if (!items) return;
22
+ var files = [];
23
+ for (var i = 0; i < items.length; i++) {
24
+ if (items[i].kind === 'file') {
25
+ var file = items[i].getAsFile();
26
+ if (file) files.push(file);
27
+ }
28
+ }
29
+ if (files.length > 0 && draggerRef.current) {
30
+ // 通过 Dragger 的 input 手动触发上传
31
+ var input = draggerRef.current.querySelector('input[type="file"]');
32
+ if (input) {
33
+ // 创建 DataTransfer 对象模拟文件选择
34
+ var dt = new DataTransfer();
35
+ files.forEach(function (f) {
36
+ return dt.items.add(f);
37
+ });
38
+ input.files = dt.files;
39
+ // 触发 change 事件
40
+ var event = new Event('change', {
41
+ bubbles: true
42
+ });
43
+ input.dispatchEvent(event);
44
+ }
45
+ }
46
+ };
47
+ var ref = draggerRef.current;
48
+ if (ref) {
49
+ ref.addEventListener('paste', handlePaste);
50
+ }
51
+ return function () {
52
+ if (ref) {
53
+ ref.removeEventListener('paste', handlePaste);
54
+ }
55
+ };
56
+ }, []);
57
+ return /*#__PURE__*/_jsx("div", {
58
+ ref: draggerRef,
59
+ tabIndex: 0,
60
+ style: {
61
+ outline: 'none'
62
+ },
63
+ children: /*#__PURE__*/_jsxs(Dragger, _objectSpread(_objectSpread({}, props), {}, {
64
+ children: [/*#__PURE__*/_jsx("p", {
65
+ className: "ant-upload-drag-icon",
66
+ children: /*#__PURE__*/_jsx(InboxOutlined, {})
67
+ }), /*#__PURE__*/_jsx("p", {
68
+ className: "ant-upload-text",
69
+ children: "\u70B9\u51FB\u3001\u62D6\u62FD\u6216\u7C98\u8D34\u6587\u4EF6\u5230\u6B64\u533A\u57DF\u4E0A\u4F20"
70
+ }), /*#__PURE__*/_jsx("p", {
71
+ className: "ant-upload-hint",
72
+ children: "\u652F\u6301\u5355\u4E2A\u6216\u6279\u91CF\u4E0A\u4F20\u3002\u4E25\u7981\u4E0A\u4F20\u516C\u53F8\u6570\u636E\u6216\u5176\u4ED6\u654F\u611F\u6587\u4EF6\u3002"
73
+ }), /*#__PURE__*/_jsx("p", {
74
+ style: {
75
+ color: '#888',
76
+ fontSize: 12
77
+ },
78
+ children: "\u73B0\u5728\u652F\u6301\u7C98\u8D34\u6587\u4EF6\u4E0A\u4F20"
79
+ })]
80
+ }))
81
+ });
82
+ };
83
+ export default App;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamias/rex-design",
3
- "version": "0.0.21",
3
+ "version": "0.0.22",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -1,67 +0,0 @@
1
- import { BaseTable } from "../base-table";
2
- import { jsx as _jsx } from "react/jsx-runtime";
3
- export default (function () {
4
- var config = [{
5
- field: 'goods_image',
6
- items: [{
7
- type: 'group-v2',
8
- props: {
9
- items: [{
10
- type: 'text',
11
- action: 'default',
12
- value: '{{ dqewe }}'
13
- }]
14
- },
15
- extra: {}
16
- }],
17
- key: '1763099807878ve0lbd1'
18
- }, {
19
- field: 'sku_size',
20
- items: [{
21
- type: 'group-v2',
22
- props: {
23
- items: [{
24
- type: 'text',
25
- action: 'default',
26
- value: '{{ qweqwe }}'
27
- }, {
28
- type: 'text',
29
- action: 'default',
30
- value: '{{ eeeeeeqw }}'
31
- }, {
32
- type: 'text',
33
- action: 'default',
34
- value: 'eeeeeeqw'
35
- }],
36
- itemsDirection: 'row',
37
- itemsGap: 4,
38
- itemsSeparator: '/',
39
- label: 'weqw'
40
- },
41
- extra: {}
42
- }],
43
- key: '1763099807878dft337k'
44
- }];
45
- var data = [{
46
- qweqwe: 1,
47
- dqewe: '图片1',
48
- eeeeeeqw: 'false'
49
- }, {
50
- qweqwe: 2,
51
- dqewe: '图片2',
52
- eeeeeeqw: 'true'
53
- }];
54
- return /*#__PURE__*/_jsx(BaseTable, {
55
- fieldsConfig: [{
56
- title: 'sku_size',
57
- dataIndex: 'sku_size'
58
- }, {
59
- title: 'goods_image',
60
- dataIndex: 'goods_image'
61
- }],
62
- useDataCellRender: true,
63
- useDataCellConfig: true,
64
- dataCellConfig: config,
65
- dataSource: data
66
- });
67
- });
@@ -1,80 +0,0 @@
1
- import { DataCell } from "../data-cell";
2
- import { dataToDataCellData } from "../utils";
3
- import { jsx as _jsx } from "react/jsx-runtime";
4
- import { Fragment as _Fragment } from "react/jsx-runtime";
5
- import { jsxs as _jsxs } from "react/jsx-runtime";
6
- export default (function () {
7
- var _dataSource$, _dataSource$2, _dataSource$3, _dataSource$4;
8
- var config = [{
9
- field: 'goods_image',
10
- items: [{
11
- type: 'group-v2',
12
- props: {
13
- items: [{
14
- type: 'text',
15
- action: 'default',
16
- value: '{{ dqewe }}'
17
- }]
18
- },
19
- extra: {}
20
- }],
21
- key: '1763099807878ve0lbd1'
22
- }, {
23
- field: 'sku_size',
24
- items: [{
25
- type: 'group-v2',
26
- props: {
27
- items: [{
28
- type: 'text',
29
- action: 'default',
30
- value: '{{ qweqwe }}'
31
- }, {
32
- type: 'text',
33
- action: 'default',
34
- value: '{{ eeeeeeqw }}'
35
- }, {
36
- type: 'text',
37
- action: 'default',
38
- value: 'eeeeeeqw'
39
- }],
40
- itemsDirection: 'row',
41
- itemsGap: 4,
42
- itemsSeparator: '/',
43
- label: 'weqw'
44
- },
45
- extra: {}
46
- }],
47
- key: '1763099807878dft337k'
48
- }];
49
- var data = [{
50
- qweqwe: 1,
51
- dqewe: '图片1',
52
- eeeeeeqw: 'false'
53
- }, {
54
- qweqwe: 2,
55
- dqewe: '图片2',
56
- eeeeeeqw: 'true'
57
- }];
58
- var dataSource = dataToDataCellData(data, config) || [];
59
- // console.log(dataSource);
60
-
61
- return /*#__PURE__*/_jsxs(_Fragment, {
62
- children: [/*#__PURE__*/_jsx("div", {
63
- children: /*#__PURE__*/_jsx(DataCell, {
64
- items: (_dataSource$ = dataSource[0]) === null || _dataSource$ === void 0 ? void 0 : _dataSource$.goods_image
65
- })
66
- }), /*#__PURE__*/_jsx("div", {
67
- children: /*#__PURE__*/_jsx(DataCell, {
68
- items: (_dataSource$2 = dataSource[0]) === null || _dataSource$2 === void 0 ? void 0 : _dataSource$2.sku_size
69
- })
70
- }), /*#__PURE__*/_jsx("div", {
71
- children: /*#__PURE__*/_jsx(DataCell, {
72
- items: (_dataSource$3 = dataSource[1]) === null || _dataSource$3 === void 0 ? void 0 : _dataSource$3.goods_image
73
- })
74
- }), /*#__PURE__*/_jsx("div", {
75
- children: /*#__PURE__*/_jsx(DataCell, {
76
- items: (_dataSource$4 = dataSource[1]) === null || _dataSource$4 === void 0 ? void 0 : _dataSource$4.sku_size
77
- })
78
- })]
79
- });
80
- });
@@ -1,3 +0,0 @@
1
- import { TDataCellConfig } from '../types';
2
- /** 将 普通数据 转 dataCell 数据 */
3
- export declare const dataToDataCellData: (oldDataSource?: Record<string, any>[], config?: TDataCellConfig) => Record<string, any>[] | undefined;
@@ -1,68 +0,0 @@
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 { get } from 'radash';
3
- // 缓存编译后的正则表达式
4
- var TEMPLATE_REGEX = /"{{\s*(.+?)\s*}}"/g;
5
-
6
- // 缓存字符串转义函数
7
- var escapeString = function escapeString(str) {
8
- // 使用更高效的替换方式
9
- var result = '';
10
- for (var i = 0; i < str.length; i++) {
11
- var char = str[i];
12
- if (char === '\\') result += '\\\\';else if (char === '"') result += '\\"';else result += char;
13
- }
14
- return result;
15
- };
16
-
17
- // 提取替换逻辑为独立函数,避免重复创建
18
- var replaceTemplate = function replaceTemplate(item) {
19
- return function (rawStr, matchKey) {
20
- var trimmedKey = matchKey.trim();
21
- var newVal = get(item, trimmedKey);
22
- if (typeof newVal === 'string') {
23
- return "\"".concat(escapeString(newVal), "\"");
24
- } else if (typeof newVal === 'number' || typeof newVal === 'boolean') {
25
- return String(newVal);
26
- } else if (newVal === null || typeof newVal === 'undefined') {
27
- return 'null';
28
- } else if (_typeof(newVal) === 'object') {
29
- return JSON.stringify(newVal);
30
- }
31
- return rawStr;
32
- };
33
- };
34
-
35
- /** 将 普通数据 转 dataCell 数据 */
36
- export var dataToDataCellData = function dataToDataCellData(oldDataSource, config) {
37
- if (!Array.isArray(config) || !config.length) return oldDataSource;
38
- if (!oldDataSource || !oldDataSource.length) return oldDataSource;
39
- var newDataSource = [];
40
-
41
- // 预编译配置的 JSON 字符串,避免重复 stringify
42
- var preCompiledConfigs = config.map(function (cfg) {
43
- return {
44
- field: cfg.field,
45
- items: cfg.items,
46
- jsonStr: JSON.stringify(cfg.items)
47
- };
48
- });
49
- oldDataSource.forEach(function (item) {
50
- // 保留原始数据的所有字段
51
- var newItem = {
52
- _raw: item
53
- };
54
- var replacer = replaceTemplate(item);
55
- preCompiledConfigs.forEach(function (config) {
56
- // 重置正则表达式的 lastIndex(虽然使用了 g 标志,但 replace 会自动处理)
57
- var newJson = config.jsonStr.replace(TEMPLATE_REGEX, replacer);
58
- try {
59
- newItem[config.field] = JSON.parse(newJson);
60
- } catch (error) {
61
- console.error("DataCell config parse error for key \"".concat(config.field, "\":"), error, '\nJSON:', newJson);
62
- newItem[config.field] = config.items;
63
- }
64
- });
65
- newDataSource.push(newItem);
66
- });
67
- return newDataSource;
68
- };