fan-standard-comp 4.0.7 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fan-standard-comp.min.css +1 -1
- package/dist/fan-standard-comp.min.js +1 -1
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +24 -5
- package/es/FormComp/FieldComponent/index.d.ts +1 -1
- package/es/FormComp/FieldComponent/index.js +9 -11
- package/es/FormComp/FieldComponent/style/TreeSelect.js +2 -1
- package/es/FormComp/FieldComponent/style/index.less +1 -1
- package/es/FormComp/RenderItemGroup/index.js +4 -4
- package/es/FormComp/VarTemplate/index.js +27 -9
- package/es/FormComp/index.d.ts +1 -0
- package/es/FormComp/index.js +3 -1
- package/es/StandardContent/ContentHeader.d.ts +5 -1
- package/es/StandardContent/ContentHeader.js +52 -8
- package/es/StandardContent/SubfieldContent.d.ts +1 -1
- package/es/StandardContent/SubfieldContent.js +19 -4
- package/es/StandardContent/WrapperContent.d.ts +1 -1
- package/es/StandardContent/WrapperContent.js +21 -9
- package/es/StandardContent/styles/Header.js +29 -3
- package/es/StandardContent/styles/Wrapper.js +1 -0
- package/es/StandardForm/index.js +45 -40
- package/es/StandardForm/style/index.js +5 -0
- package/es/StandardModal/index.js +62 -62
- package/es/StandardModal/style/index.js +3 -1
- package/es/StandardPanel/index.d.ts +1 -0
- package/es/StandardPanel/index.js +8 -7
- package/es/StandardPanel/style/index.js +9 -2
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +24 -5
- package/lib/FormComp/FieldComponent/index.d.ts +1 -1
- package/lib/FormComp/FieldComponent/index.js +9 -11
- package/lib/FormComp/FieldComponent/style/TreeSelect.js +2 -1
- package/lib/FormComp/FieldComponent/style/index.less +1 -1
- package/lib/FormComp/RenderItemGroup/index.js +4 -4
- package/lib/FormComp/VarTemplate/index.js +27 -9
- package/lib/FormComp/index.d.ts +1 -0
- package/lib/FormComp/index.js +7 -0
- package/lib/StandardContent/ContentHeader.d.ts +5 -1
- package/lib/StandardContent/ContentHeader.js +50 -7
- package/lib/StandardContent/SubfieldContent.d.ts +1 -1
- package/lib/StandardContent/SubfieldContent.js +18 -3
- package/lib/StandardContent/WrapperContent.d.ts +1 -1
- package/lib/StandardContent/WrapperContent.js +20 -8
- package/lib/StandardContent/styles/Header.js +29 -3
- package/lib/StandardContent/styles/Wrapper.js +1 -0
- package/lib/StandardForm/index.js +45 -40
- package/lib/StandardForm/style/index.js +5 -0
- package/lib/StandardModal/index.js +62 -62
- package/lib/StandardModal/style/index.js +3 -1
- package/lib/StandardPanel/index.d.ts +1 -0
- package/lib/StandardPanel/index.js +8 -7
- package/lib/StandardPanel/style/index.js +9 -2
- package/lib/index.d.ts +1 -0
- package/lib/index.js +8 -0
- package/package.json +1 -1
|
@@ -54,6 +54,10 @@ var RefactorTreeSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
54
54
|
_useState2 = _slicedToArray(_useState, 2),
|
|
55
55
|
fullLevelName = _useState2[0],
|
|
56
56
|
setFullLevelName = _useState2[1];
|
|
57
|
+
var _useState3 = useState({}),
|
|
58
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
59
|
+
fullLevelStyle = _useState4[0],
|
|
60
|
+
setFullLevelStyle = _useState4[1];
|
|
57
61
|
var renderTreeNode = function renderTreeNode(data, dataOptionName) {
|
|
58
62
|
var nodeProps = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
59
63
|
return data.map(function (dataItem) {
|
|
@@ -151,13 +155,27 @@ var RefactorTreeSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
151
155
|
});
|
|
152
156
|
setFullLevelName(renderParenName(newNodeInfo));
|
|
153
157
|
if (_onSelect) _onSelect(value, _objectSpread(_objectSpread({}, node), newNodeInfo.matchNode[0]), extra, newNodeInfo.nodeParent);
|
|
158
|
+
},
|
|
159
|
+
onDropdownVisibleChange: function onDropdownVisibleChange(open) {
|
|
160
|
+
var _otherProps$onDropdow;
|
|
161
|
+
setFullLevelStyle({
|
|
162
|
+
opacity: open ? 0.3 : ''
|
|
163
|
+
});
|
|
164
|
+
otherProps === null || otherProps === void 0 || (_otherProps$onDropdow = otherProps.onDropdownVisibleChange) === null || _otherProps$onDropdow === void 0 || _otherProps$onDropdow.call(otherProps, open);
|
|
165
|
+
},
|
|
166
|
+
onSearch: function onSearch(value) {
|
|
167
|
+
var _otherProps$onSearch;
|
|
168
|
+
setFullLevelStyle({
|
|
169
|
+
opacity: value ? 0 : ''
|
|
170
|
+
});
|
|
171
|
+
otherProps === null || otherProps === void 0 || (_otherProps$onSearch = otherProps.onSearch) === null || _otherProps$onSearch === void 0 || _otherProps$onSearch.call(otherProps, value);
|
|
154
172
|
}
|
|
155
173
|
}), renderTreeNode(treeData, treeOptionName, protoTreeNode || {}));
|
|
156
174
|
};
|
|
157
|
-
var
|
|
158
|
-
|
|
159
|
-
showAllPath =
|
|
160
|
-
setShowAllPath =
|
|
175
|
+
var _useState5 = useState(false),
|
|
176
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
177
|
+
showAllPath = _useState6[0],
|
|
178
|
+
setShowAllPath = _useState6[1]; // 显示所有树选择路径
|
|
161
179
|
var renderTreeSelectNodePath = function renderTreeSelectNodePath() {
|
|
162
180
|
//获取节点路径
|
|
163
181
|
var pathNodes = getNodePaths(treeData, value, {
|
|
@@ -216,7 +234,8 @@ var RefactorTreeSelect = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
216
234
|
className: "".concat(componentName, " ").concat(hashId, " ").concat(disabled ? 'refactor-disabled' : '').concat(otherProps.size === 'small' ? ' refactor-tree-select-sm' : ''),
|
|
217
235
|
title: fullLevelName || ''
|
|
218
236
|
}, renderTreeSelectNode(), /*#__PURE__*/React.createElement("span", {
|
|
219
|
-
className: "refactor-tree-select-extra"
|
|
237
|
+
className: "refactor-tree-select-extra",
|
|
238
|
+
style: fullLevelStyle
|
|
220
239
|
}, fullLevelName)) : renderTreeSelectNode()));
|
|
221
240
|
});
|
|
222
241
|
export default RefactorTreeSelect;
|
|
@@ -25,7 +25,7 @@ export interface FieldComponentProps {
|
|
|
25
25
|
size?: 'large' | 'middle' | 'small' | string;
|
|
26
26
|
showFullLevel?: boolean;
|
|
27
27
|
separator?: string;
|
|
28
|
-
selectOptionRender?: (data: any) => void;
|
|
28
|
+
selectOptionRender?: (data: any, info?: any) => void;
|
|
29
29
|
style?: React.CSSProperties;
|
|
30
30
|
render?: (props?: any) => React.ReactNode | string;
|
|
31
31
|
disabledFields?: {
|
|
@@ -144,23 +144,21 @@ var FieldComponent = /*#__PURE__*/React.forwardRef(function (props, ref) {
|
|
|
144
144
|
allowClear: true,
|
|
145
145
|
placeholder: fieldStatus === 'disabled' || defaultProps.disabled ? '' : defaultProps.placeholder || placeholder || "".concat(defaultProps.showSearch ? '请输入选择' : '请选择'),
|
|
146
146
|
filterOption: function filterOption(inputValue, option) {
|
|
147
|
-
|
|
147
|
+
var _defaultProps$fieldNa;
|
|
148
|
+
return defaultProps.showSearch ? ((option === null || option === void 0 ? void 0 : option[(defaultProps === null || defaultProps === void 0 || (_defaultProps$fieldNa = defaultProps.fieldNames) === null || _defaultProps$fieldNa === void 0 ? void 0 : _defaultProps$fieldNa.label) || (selectOptionName === null || selectOptionName === void 0 ? void 0 : selectOptionName.label) || 'label']) || '').toLowerCase().includes(inputValue.toLowerCase()) : false;
|
|
148
149
|
},
|
|
149
|
-
value: value
|
|
150
|
-
|
|
151
|
-
|
|
150
|
+
value: value,
|
|
151
|
+
fieldNames: (defaultProps === null || defaultProps === void 0 ? void 0 : defaultProps.fieldNames) || selectOptionName,
|
|
152
|
+
options: selectOptions,
|
|
153
|
+
optionRender: function optionRender(option, info) {
|
|
154
|
+
var _defaultProps$optionR;
|
|
155
|
+
return (defaultProps === null || defaultProps === void 0 || (_defaultProps$optionR = defaultProps.optionRender) === null || _defaultProps$optionR === void 0 ? void 0 : _defaultProps$optionR.call(defaultProps, option, info)) || (selectOptionRender === null || selectOptionRender === void 0 ? void 0 : selectOptionRender(option, info)) || option.label;
|
|
156
|
+
}
|
|
152
157
|
}, defaultProps, {
|
|
153
158
|
// onChange返回参数:累加当前选中包括其他字段值的数据
|
|
154
159
|
onChange: function onChange(value, Option) {
|
|
155
160
|
return _onChange && _onChange(value, resetResultOption(Option));
|
|
156
161
|
} // 数据为对象
|
|
157
|
-
}), defaultProps !== null && defaultProps !== void 0 && defaultProps.fieldNames ? null : (selectOptions || []).map(function (val, index) {
|
|
158
|
-
return /*#__PURE__*/React.createElement(Option, {
|
|
159
|
-
value: val.value,
|
|
160
|
-
key: val.value || index,
|
|
161
|
-
title: selectOptionRender ? selectOptionRender(val) : val.title || val.label,
|
|
162
|
-
disabled: val.disabled
|
|
163
|
-
}, selectOptionRender ? selectOptionRender(val) : val.label);
|
|
164
162
|
}));
|
|
165
163
|
break;
|
|
166
164
|
case 'tree-select':
|
|
@@ -19,7 +19,8 @@ var RefactorTreeSelectStyleFunc = function RefactorTreeSelectStyleFunc(prefix) {
|
|
|
19
19
|
},
|
|
20
20
|
'.refactor-tree-select-extra': {
|
|
21
21
|
background: token.colorBgContainer,
|
|
22
|
-
height: token.controlHeight
|
|
22
|
+
height: token.controlHeight,
|
|
23
|
+
padding: "1px 22px 1px ".concat(token.paddingXS + 3, "px")
|
|
23
24
|
}
|
|
24
25
|
}), '.tree-select-viewonly-list', {
|
|
25
26
|
border: "1px solid ".concat(new TinyColor(token.colorSplit).setAlpha(0.6).toRgbString()),
|
|
@@ -201,11 +201,11 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
201
201
|
customRender = item.customRender,
|
|
202
202
|
filedName = item.filedName; // 当前可传参的配置值
|
|
203
203
|
if (layout === "horizontal" || layout === "vertical") {
|
|
204
|
-
return /*#__PURE__*/React.createElement(Col, {
|
|
204
|
+
return /*#__PURE__*/React.createElement(Col, _extends({
|
|
205
205
|
key: index,
|
|
206
206
|
span: item.colSpan || setColSpan(item.display, size, columnCount),
|
|
207
207
|
style: item.style
|
|
208
|
-
}, /*#__PURE__*/React.createElement(FormItem, _extends({
|
|
208
|
+
}, item.protoCol), /*#__PURE__*/React.createElement(FormItem, _extends({
|
|
209
209
|
name: type !== 'custom' && filedName,
|
|
210
210
|
className: classNames(fieldStatus === 'viewOnly' ? 'form-item-view-only' : '', 'spec-item-group-form-item'),
|
|
211
211
|
label: description ? /*#__PURE__*/React.createElement("span", null, label, /*#__PURE__*/React.createElement(Tooltip, {
|
|
@@ -251,10 +251,10 @@ var RenderItemGroup = function RenderItemGroup(props) {
|
|
|
251
251
|
}, function (FormInstance) {
|
|
252
252
|
var _item$protoConfig;
|
|
253
253
|
// isHide 返回为true则隐藏当前控件
|
|
254
|
-
return !itemIsHide(isHide, FormInstance.getFieldValue(), FormInstance) ? /*#__PURE__*/React.createElement(Col, {
|
|
254
|
+
return !itemIsHide(isHide, FormInstance.getFieldValue(), FormInstance) ? /*#__PURE__*/React.createElement(Col, _extends({
|
|
255
255
|
span: item.colSpan || 24,
|
|
256
256
|
style: item.style
|
|
257
|
-
}, type === 'title' ? /*#__PURE__*/React.createElement("h3", _extends({}, item.protoConfig, {
|
|
257
|
+
}, item.protoCol), type === 'title' ? /*#__PURE__*/React.createElement("h3", _extends({}, item.protoConfig, {
|
|
258
258
|
className: "modalPanelTitle ".concat((item === null || item === void 0 || (_item$protoConfig = item.protoConfig) === null || _item$protoConfig === void 0 ? void 0 : _item$protoConfig.className) || '')
|
|
259
259
|
}), label) : label) : /*#__PURE__*/React.createElement(React.Fragment, null, null);
|
|
260
260
|
});
|
|
@@ -197,27 +197,39 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
197
197
|
size = _this$props.size,
|
|
198
198
|
style = _this$props.style,
|
|
199
199
|
tags = _this$props.tags,
|
|
200
|
-
disabled = _this$props.disabled
|
|
200
|
+
disabled = _this$props.disabled,
|
|
201
|
+
fieldStatus = _this$props.fieldStatus,
|
|
202
|
+
_this$props$tagsOptio = _this$props.tagsOptionName,
|
|
203
|
+
tagsOptionName = _this$props$tagsOptio === void 0 ? {
|
|
204
|
+
key: 'key',
|
|
205
|
+
label: 'label',
|
|
206
|
+
value: 'value'
|
|
207
|
+
} : _this$props$tagsOptio,
|
|
208
|
+
showCountTip = _this$props.showCountTip;
|
|
201
209
|
var _this$state3 = this.state,
|
|
202
210
|
currentContent = _this$state3.currentContent,
|
|
203
211
|
wordCount = _this$state3.wordCount;
|
|
204
212
|
return /*#__PURE__*/React.createElement("div", {
|
|
205
|
-
className: "vart-wrap",
|
|
213
|
+
className: "spec-vart-wrap",
|
|
206
214
|
style: style,
|
|
207
215
|
ref: function ref(cRef) {
|
|
208
216
|
_this2.content = cRef;
|
|
209
217
|
}
|
|
210
218
|
}, tags && Array.isArray(tags) && /*#__PURE__*/React.createElement("div", {
|
|
211
|
-
className: "vart-header"
|
|
219
|
+
className: "spec-vart-header"
|
|
212
220
|
}, tags.map(function (item) {
|
|
213
221
|
return /*#__PURE__*/React.createElement(Tag, {
|
|
214
|
-
|
|
222
|
+
style: {
|
|
223
|
+
marginBottom: '4px',
|
|
224
|
+
cursor: 'pointer'
|
|
225
|
+
},
|
|
226
|
+
key: item[tagsOptionName === null || tagsOptionName === void 0 ? void 0 : tagsOptionName.key],
|
|
215
227
|
onClick: function onClick() {
|
|
216
|
-
return !disabled && _this2.setTagWords(item.
|
|
228
|
+
return !(disabled || fieldStatus === 'disabled') && _this2.setTagWords(item[tagsOptionName === null || tagsOptionName === void 0 ? void 0 : tagsOptionName.value]);
|
|
217
229
|
}
|
|
218
|
-
}, item.
|
|
230
|
+
}, item[tagsOptionName === null || tagsOptionName === void 0 ? void 0 : tagsOptionName.label]);
|
|
219
231
|
})), /*#__PURE__*/React.createElement("div", {
|
|
220
|
-
className: "vart-input"
|
|
232
|
+
className: "spec-vart-input"
|
|
221
233
|
}, /*#__PURE__*/React.createElement(TextArea, {
|
|
222
234
|
type: "text",
|
|
223
235
|
size: size,
|
|
@@ -228,8 +240,14 @@ var VarTemplate = /*#__PURE__*/function (_Component) {
|
|
|
228
240
|
onChange: function onChange(e) {
|
|
229
241
|
return _this2.handleInputChange(e);
|
|
230
242
|
},
|
|
231
|
-
disabled: disabled
|
|
232
|
-
}))
|
|
243
|
+
disabled: disabled || fieldStatus === 'disabled'
|
|
244
|
+
})), showCountTip && /*#__PURE__*/React.createElement("div", {
|
|
245
|
+
className: "spec-vart-desc",
|
|
246
|
+
style: {
|
|
247
|
+
marginTop: '4px',
|
|
248
|
+
fontSize: '12px'
|
|
249
|
+
}
|
|
250
|
+
}, " \u60A8\u5DF2\u5F55\u5165 ", /*#__PURE__*/React.createElement("b", null, wordCount), " \u4E2A\u5B57"));
|
|
233
251
|
}
|
|
234
252
|
}], [{
|
|
235
253
|
key: "getDerivedStateFromProps",
|
package/es/FormComp/index.d.ts
CHANGED
package/es/FormComp/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
export interface ContentHeaderProps {
|
|
3
3
|
title?: string | React.ReactNode;
|
|
4
|
-
breadcrumb?: object;
|
|
4
|
+
breadcrumb?: object | any;
|
|
5
5
|
componentName?: string;
|
|
6
|
+
prefix?: React.ReactNode;
|
|
7
|
+
extra?: React.ReactNode;
|
|
8
|
+
goBack?: (breadcrumbItems?: any, breadcrumb?: any) => void;
|
|
9
|
+
fixed?: Boolean;
|
|
6
10
|
[key: string]: any;
|
|
7
11
|
}
|
|
8
12
|
declare const ContentHeader: React.ForwardRefExoticComponent<Omit<ContentHeaderProps, "ref"> & React.RefAttributes<unknown>>;
|
|
@@ -1,3 +1,9 @@
|
|
|
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); }
|
|
1
7
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
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."); }
|
|
3
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); }
|
|
@@ -5,9 +11,10 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
5
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; } }
|
|
6
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
13
|
import React, { forwardRef, useImperativeHandle, useRef, useEffect, useState } from 'react';
|
|
8
|
-
import { Breadcrumb } from "antd";
|
|
14
|
+
import { Breadcrumb, Button } from "antd";
|
|
9
15
|
import classNames from 'classnames';
|
|
10
16
|
import useStyle from "./styles/Header";
|
|
17
|
+
import SpecIcon from "../SpecIcon/index";
|
|
11
18
|
var Child = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
12
19
|
var _useState = useState(0),
|
|
13
20
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -23,10 +30,14 @@ var Child = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
23
30
|
return /*#__PURE__*/React.createElement("div", null, "Count: ", count);
|
|
24
31
|
});
|
|
25
32
|
var ContentHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
33
|
+
var _breadcrumb$items;
|
|
26
34
|
var breadcrumb = props.breadcrumb,
|
|
27
35
|
className = props.className,
|
|
28
36
|
title = props.title,
|
|
29
|
-
getClientHeight = props.getClientHeight
|
|
37
|
+
getClientHeight = props.getClientHeight,
|
|
38
|
+
extra = props.extra,
|
|
39
|
+
prefix = props.prefix,
|
|
40
|
+
goBack = props.goBack;
|
|
30
41
|
var componentName = 'spec-content-header';
|
|
31
42
|
var _useStyle = useStyle(componentName),
|
|
32
43
|
_useStyle2 = _slicedToArray(_useStyle, 2),
|
|
@@ -41,17 +52,31 @@ var ContentHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
41
52
|
clientHeight = _useState6[0],
|
|
42
53
|
setClientHeight = _useState6[1];
|
|
43
54
|
var headerRef = useRef(null);
|
|
55
|
+
var handleGoBack = function handleGoBack() {
|
|
56
|
+
if (goBack) {
|
|
57
|
+
goBack(breadcrumb === null || breadcrumb === void 0 ? void 0 : breadcrumb.items, breadcrumb);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
44
60
|
useEffect(function () {
|
|
45
61
|
if (title || breadcrumb) {
|
|
46
62
|
setVisible(true);
|
|
47
63
|
}
|
|
48
64
|
}, [title, breadcrumb]);
|
|
65
|
+
|
|
66
|
+
// useImperativeHandle(ref, () => headerRef.current, [headerRef, breadcrumb, title]);
|
|
67
|
+
// useLayoutEffect(() => {
|
|
68
|
+
// if (headerRef.current) {
|
|
69
|
+
// // 确保在 DOM 更新后执行的逻辑
|
|
70
|
+
// // console.log('更新后执行的逻辑', contentRef.current)
|
|
71
|
+
// }
|
|
72
|
+
// });
|
|
73
|
+
|
|
49
74
|
useImperativeHandle(ref, function () {
|
|
50
|
-
return {
|
|
75
|
+
return _objectSpread({
|
|
51
76
|
getClientHeight: function getClientHeight() {
|
|
52
77
|
return clientHeight;
|
|
53
78
|
}
|
|
54
|
-
};
|
|
79
|
+
}, headerRef.current);
|
|
55
80
|
}, [clientHeight]);
|
|
56
81
|
useEffect(function () {
|
|
57
82
|
if (visible && headerRef.current) {
|
|
@@ -62,18 +87,37 @@ var ContentHeader = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
|
62
87
|
useEffect(function () {
|
|
63
88
|
getClientHeight && getClientHeight(clientHeight);
|
|
64
89
|
}, [clientHeight]);
|
|
90
|
+
|
|
65
91
|
// ref 的转发
|
|
66
92
|
// 将需要暴露给父组件的属性或方法定义在这个函数中
|
|
67
93
|
// useImperativeHandle(ref, () => headerRef.current, [headerRef, breadcrumb, title]);
|
|
68
94
|
|
|
69
95
|
// @ts-ignore
|
|
70
96
|
return wrapSSR( /*#__PURE__*/React.createElement("div", {
|
|
71
|
-
className: classNames(className, componentName, hashId),
|
|
97
|
+
className: classNames(className, componentName, !title ? componentName + '-no-title' : '', hashId),
|
|
72
98
|
ref: headerRef
|
|
73
|
-
}, breadcrumb ? /*#__PURE__*/React.createElement("div", {
|
|
99
|
+
}, breadcrumb && breadcrumb !== null && breadcrumb !== void 0 && (_breadcrumb$items = breadcrumb.items) !== null && _breadcrumb$items !== void 0 && _breadcrumb$items.length ? /*#__PURE__*/React.createElement("div", {
|
|
74
100
|
className: componentName + '-breadcrumb'
|
|
75
|
-
}, /*#__PURE__*/React.createElement(Breadcrumb, breadcrumb || {})) : null, title ? /*#__PURE__*/React.createElement("div", {
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Breadcrumb, breadcrumb || {})) : null, title || extra || prefix || goBack ? /*#__PURE__*/React.createElement("div", {
|
|
76
102
|
className: componentName + '-title'
|
|
77
|
-
},
|
|
103
|
+
}, goBack && /*#__PURE__*/React.createElement("div", {
|
|
104
|
+
className: componentName + '-title-goBack',
|
|
105
|
+
onClick: function onClick() {
|
|
106
|
+
return handleGoBack();
|
|
107
|
+
}
|
|
108
|
+
}, /*#__PURE__*/React.createElement(Button, {
|
|
109
|
+
size: 'small',
|
|
110
|
+
type: 'default',
|
|
111
|
+
icon: /*#__PURE__*/React.createElement(SpecIcon, {
|
|
112
|
+
noPrefix: true,
|
|
113
|
+
name: 'speci-redo'
|
|
114
|
+
})
|
|
115
|
+
})), prefix && /*#__PURE__*/React.createElement("div", {
|
|
116
|
+
className: componentName + '-title-prefix'
|
|
117
|
+
}, " ", prefix), title && /*#__PURE__*/React.createElement("div", {
|
|
118
|
+
className: componentName + '-title-name'
|
|
119
|
+
}, " ", title), extra && /*#__PURE__*/React.createElement("div", {
|
|
120
|
+
className: componentName + '-title-extra'
|
|
121
|
+
}, " ", extra)) : null));
|
|
78
122
|
});
|
|
79
123
|
export default ContentHeader;
|
|
@@ -16,5 +16,5 @@ interface SubfieldContentProps {
|
|
|
16
16
|
header?: ContentHeaderProps;
|
|
17
17
|
[k: string]: any;
|
|
18
18
|
}
|
|
19
|
-
declare const SubfieldContent:
|
|
19
|
+
declare const SubfieldContent: React.ForwardRefExoticComponent<Omit<SubfieldContentProps, "ref"> & React.RefAttributes<unknown>>;
|
|
20
20
|
export default SubfieldContent;
|
|
@@ -11,7 +11,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
11
|
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; }
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
13
|
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); }
|
|
14
|
-
import React, { useContext, useState } from 'react';
|
|
14
|
+
import React, { useContext, useRef, useState, forwardRef, useImperativeHandle, useLayoutEffect } from 'react';
|
|
15
15
|
import classNames from 'classnames';
|
|
16
16
|
import { Spin } from 'antd';
|
|
17
17
|
import DragContent from "../DragContent";
|
|
@@ -19,7 +19,7 @@ import ContentHeader from "./ContentHeader";
|
|
|
19
19
|
import useStyle from "./styles/Subfield";
|
|
20
20
|
import "./styles/index.less";
|
|
21
21
|
import { FanContext } from "../ConfigContext";
|
|
22
|
-
var SubfieldContent = function
|
|
22
|
+
var SubfieldContent = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
23
23
|
var _proLayoutProps$heade;
|
|
24
24
|
var InitFanContext = useContext(FanContext);
|
|
25
25
|
var providerConfig = InitFanContext['SubfieldContent'] || {}; // 使用上下文(全局配置)设置扩展的配置项
|
|
@@ -48,10 +48,25 @@ var SubfieldContent = function SubfieldContent(props) {
|
|
|
48
48
|
_useStyle2 = _slicedToArray(_useStyle, 2),
|
|
49
49
|
wrapSSR = _useStyle2[0],
|
|
50
50
|
hashId = _useStyle2[1];
|
|
51
|
+
var headerRef = useRef();
|
|
52
|
+
var contentRef = useRef();
|
|
53
|
+
useImperativeHandle(ref, function () {
|
|
54
|
+
return contentRef === null || contentRef === void 0 ? void 0 : contentRef.current;
|
|
55
|
+
});
|
|
56
|
+
// useImperativeHandle 是一个 React 钩子,它可以用来自定义使用 ref 时暴露给父组件的属性。如果你在自定义组件中使用 useImperativeHandle 来暴露一个方法,并且这个方法依赖于组件的 DOM 节点,比如 clientHeight,那么你可能会遇到在组件挂载之初调用这个方法时取不到 clientHeight 的问题,因为 DOM 节点可能还没有被渲染。
|
|
57
|
+
// 解决这个问题的方法是确保在调用这个方法之前 DOM 节点已经被渲染。你可以通过使用 useLayoutEffect 来确保你的方法在 DOM 更新后执行,例如
|
|
58
|
+
useLayoutEffect(function () {
|
|
59
|
+
if (contentRef.current) {
|
|
60
|
+
// 确保在 DOM 更新后执行的逻辑
|
|
61
|
+
// console.log('更新后执行的逻辑', contentRef.current)
|
|
62
|
+
}
|
|
63
|
+
});
|
|
51
64
|
return wrapSSR( /*#__PURE__*/React.createElement("div", {
|
|
52
65
|
className: classNames(componentName, className, hashId),
|
|
53
|
-
style: style
|
|
66
|
+
style: style,
|
|
67
|
+
ref: contentRef
|
|
54
68
|
}, proLayoutProps !== null && proLayoutProps !== void 0 && proLayoutProps.header || header ? /*#__PURE__*/React.createElement(ContentHeader, _extends({
|
|
69
|
+
ref: headerRef,
|
|
55
70
|
getClientHeight: setHeaderHeight,
|
|
56
71
|
className: classNames('spec-grid-content-header', proLayoutProps !== null && proLayoutProps !== void 0 && (_proLayoutProps$heade = proLayoutProps.header) !== null && _proLayoutProps$heade !== void 0 && _proLayoutProps$heade.fixed || header !== null && header !== void 0 && header.fixed ? 'spec-grid-content-header-fixed' : '')
|
|
57
72
|
}, (proLayoutProps === null || proLayoutProps === void 0 ? void 0 : proLayoutProps.header) || {}, header || {})) : null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -74,5 +89,5 @@ var SubfieldContent = function SubfieldContent(props) {
|
|
|
74
89
|
tip: loadingTip,
|
|
75
90
|
wrapperClassName: 'spec-grid-content-spinning'
|
|
76
91
|
}, children)))));
|
|
77
|
-
};
|
|
92
|
+
});
|
|
78
93
|
export default SubfieldContent;
|
|
@@ -11,5 +11,5 @@ interface WrapperContentProps {
|
|
|
11
11
|
light?: boolean;
|
|
12
12
|
header?: ContentHeaderProps;
|
|
13
13
|
}
|
|
14
|
-
declare const WrapperContent:
|
|
14
|
+
declare const WrapperContent: React.ForwardRefExoticComponent<WrapperContentProps & React.RefAttributes<unknown>>;
|
|
15
15
|
export default WrapperContent;
|
|
@@ -11,14 +11,14 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
11
11
|
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; }
|
|
12
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
13
13
|
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); }
|
|
14
|
-
import React, { useContext, useRef, useState } from 'react';
|
|
14
|
+
import React, { forwardRef, useContext, useImperativeHandle, useLayoutEffect, useRef, useState } from 'react';
|
|
15
15
|
import classNames from 'classnames';
|
|
16
16
|
import { Spin } from 'antd';
|
|
17
17
|
import "./styles/index.less";
|
|
18
18
|
import useStyle from "./styles/Wrapper";
|
|
19
19
|
import { FanContext } from "../ConfigContext";
|
|
20
20
|
import ContentHeader from "./ContentHeader";
|
|
21
|
-
var WrapperContent = function
|
|
21
|
+
var WrapperContent = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
22
22
|
var _proLayoutProps$heade, _proLayoutProps$heade2;
|
|
23
23
|
var InitFanContext = useContext(FanContext);
|
|
24
24
|
var providerConfig = InitFanContext['SubfieldContent'] || {}; // 使用上下文(全局配置)设置扩展的配置项
|
|
@@ -43,12 +43,23 @@ var WrapperContent = function WrapperContent(props) {
|
|
|
43
43
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
44
|
headerHeight = _useState2[0],
|
|
45
45
|
setHeaderHeight = _useState2[1];
|
|
46
|
-
var
|
|
46
|
+
var contentRef = useRef();
|
|
47
|
+
useImperativeHandle(ref, function () {
|
|
48
|
+
return contentRef === null || contentRef === void 0 ? void 0 : contentRef.current;
|
|
49
|
+
});
|
|
50
|
+
// useImperativeHandle 是一个 React 钩子,它可以用来自定义使用 ref 时暴露给父组件的属性。如果你在自定义组件中使用 useImperativeHandle 来暴露一个方法,并且这个方法依赖于组件的 DOM 节点,比如 clientHeight,那么你可能会遇到在组件挂载之初调用这个方法时取不到 clientHeight 的问题,因为 DOM 节点可能还没有被渲染。
|
|
51
|
+
// 解决这个问题的方法是确保在调用这个方法之前 DOM 节点已经被渲染。你可以通过使用 useLayoutEffect 来确保你的方法在 DOM 更新后执行,例如
|
|
52
|
+
useLayoutEffect(function () {
|
|
53
|
+
if (contentRef.current) {
|
|
54
|
+
// 确保在 DOM 更新后执行的逻辑
|
|
55
|
+
// console.log('更新后执行的逻辑', contentRef.current)
|
|
56
|
+
}
|
|
57
|
+
});
|
|
47
58
|
return wrapSSR( /*#__PURE__*/React.createElement("div", {
|
|
48
59
|
className: classNames(componentName, className, noMargin ? 'has-margin' : '', hashId),
|
|
49
|
-
style: style
|
|
60
|
+
style: style,
|
|
61
|
+
ref: contentRef
|
|
50
62
|
}, proLayoutProps !== null && proLayoutProps !== void 0 && proLayoutProps.header || header ? /*#__PURE__*/React.createElement(ContentHeader, _extends({
|
|
51
|
-
ref: headerRef,
|
|
52
63
|
getClientHeight: setHeaderHeight,
|
|
53
64
|
className: classNames('spec-wrapper-content-header', proLayoutProps !== null && proLayoutProps !== void 0 && (_proLayoutProps$heade = proLayoutProps.header) !== null && _proLayoutProps$heade !== void 0 && _proLayoutProps$heade.fixed || header !== null && header !== void 0 && header.fixed ? 'spec-wrapper-content-header-fixed' : '')
|
|
54
65
|
}, (proLayoutProps === null || proLayoutProps === void 0 ? void 0 : proLayoutProps.header) || {}, header || {})) : null, light ? /*#__PURE__*/React.createElement("div", {
|
|
@@ -61,13 +72,14 @@ var WrapperContent = function WrapperContent(props) {
|
|
|
61
72
|
wrapperClassName: 'spec-wrapper-content-spinning'
|
|
62
73
|
}, " ", children))) : /*#__PURE__*/React.createElement("div", {
|
|
63
74
|
className: 'spec-wrapper-content-body',
|
|
64
|
-
style: {
|
|
65
|
-
height:
|
|
66
|
-
|
|
75
|
+
style: proLayoutProps !== null && proLayoutProps !== void 0 && (_proLayoutProps$heade2 = proLayoutProps.header) !== null && _proLayoutProps$heade2 !== void 0 && _proLayoutProps$heade2.fixed || header !== null && header !== void 0 && header.fixed ? {
|
|
76
|
+
height: "calc(100% - ".concat(headerHeight ? headerHeight + 20 : 0, "px)"),
|
|
77
|
+
overflow: 'auto'
|
|
78
|
+
} : {}
|
|
67
79
|
}, /*#__PURE__*/React.createElement(Spin, {
|
|
68
80
|
spinning: loading,
|
|
69
81
|
tip: loadingTip,
|
|
70
82
|
wrapperClassName: 'spec-wrapper-content-spinning'
|
|
71
83
|
}, " ", children, " "))));
|
|
72
|
-
};
|
|
84
|
+
});
|
|
73
85
|
export default WrapperContent;
|
|
@@ -13,18 +13,44 @@ var SubfieldContentStyleFunc = function SubfieldContentStyleFunc(prefix) {
|
|
|
13
13
|
var prefixCls = ".".concat(prefix);
|
|
14
14
|
// console.log(' new TinyColor(token.colorPrimary).setAlpha(0.1)' ,new TinyColor(token.colorPrimary).setAlpha(0.1).toRgbString(), )
|
|
15
15
|
return [_defineProperty({}, prefixCls, {
|
|
16
|
-
marginBottom: token.marginMD,
|
|
16
|
+
// marginBottom: token.marginMD,
|
|
17
|
+
'&.spec-content-header-no-title': {
|
|
18
|
+
'.spec-content-header-breadcrumb': {
|
|
19
|
+
marginBottom: token.marginMD
|
|
20
|
+
}
|
|
21
|
+
},
|
|
17
22
|
'.spec-content-header-breadcrumb': {
|
|
18
|
-
height: '
|
|
23
|
+
height: '22px',
|
|
19
24
|
'& +.spec-content-header-title': {
|
|
20
25
|
marginTop: token.marginXS
|
|
21
26
|
// marginTop: token.margin
|
|
22
27
|
}
|
|
23
28
|
},
|
|
24
29
|
'.spec-content-header-title': {
|
|
30
|
+
marginBottom: token.marginMD,
|
|
31
|
+
display: 'flex',
|
|
32
|
+
alignItems: 'center'
|
|
33
|
+
},
|
|
34
|
+
'.spec-content-header-title-goBack + .spec-content-header-title-prefix ': {
|
|
35
|
+
marginLeft: token.marginXS
|
|
36
|
+
},
|
|
37
|
+
'.spec-content-header-title-prefix, .spec-content-header-title-goBack': {
|
|
38
|
+
'& + .spec-content-header-title-name': {
|
|
39
|
+
marginLeft: token.marginXS
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
'.spec-content-header-title-name': {
|
|
25
43
|
fontSize: token.fontSizeLG,
|
|
26
44
|
fontWeight: 'bold',
|
|
27
|
-
lineHeight: '20px'
|
|
45
|
+
lineHeight: '20px',
|
|
46
|
+
flex: 1,
|
|
47
|
+
'& + .spec-content-header-title-extra': {
|
|
48
|
+
paddingLeft: token.paddingMD
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
'.spec-content-header-title-extra': {
|
|
52
|
+
// flex: 1,
|
|
53
|
+
textAlign: 'right'
|
|
28
54
|
}
|
|
29
55
|
})];
|
|
30
56
|
}, prepareComponentToken // 当前组件扩展的变量
|
|
@@ -17,6 +17,7 @@ var WrapperContentStyleFunc = function WrapperContentStyleFunc(prefix) {
|
|
|
17
17
|
return [_defineProperty(_defineProperty(_defineProperty({}, prefixCls, _objectSpread(_objectSpread({
|
|
18
18
|
position: 'relative',
|
|
19
19
|
padding: token.paddingMD,
|
|
20
|
+
margin: -token.marginMD,
|
|
20
21
|
background: token.colorBgLayout,
|
|
21
22
|
height: '100%',
|
|
22
23
|
overflow: 'auto'
|