@chengkejie/form-page 1.0.2 → 1.2.0
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/README.md +57 -2
- package/dist/cjs/FormPage.d.ts +30 -30
- package/dist/cjs/FormPage.d.ts.map +1 -1
- package/dist/cjs/FormPage.js +792 -716
- package/dist/cjs/components/CompanySelect/index.d.ts +6 -6
- package/dist/cjs/components/CompanySelect/index.js +80 -80
- package/dist/cjs/components/CustomNode/index.d.ts +6 -6
- package/dist/cjs/components/CustomNode/index.js +12 -12
- package/dist/cjs/components/ExtraDatePicker/index.d.ts +7 -7
- package/dist/cjs/components/ExtraDatePicker/index.js +139 -139
- package/dist/cjs/components/Section/index.d.ts +6 -6
- package/dist/cjs/components/Section/index.js +32 -32
- package/dist/cjs/components/SelectSearch/index.d.ts +6 -6
- package/dist/cjs/components/SelectSearch/index.d.ts.map +1 -1
- package/dist/cjs/components/SelectSearch/index.js +66 -39
- package/dist/cjs/components/SettingDialog/index.d.ts +11 -11
- package/dist/cjs/components/SettingDialog/index.js +130 -130
- package/dist/cjs/context.d.ts +33 -33
- package/dist/cjs/context.js +22 -22
- package/dist/cjs/index.d.ts +11 -11
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +76 -76
- package/dist/cjs/styles/index.module.scss +21 -28
- package/dist/cjs/tableKeyMap.d.ts +2 -2
- package/dist/cjs/tableKeyMap.js +12 -12
- package/dist/cjs/types.d.ts +236 -207
- package/dist/cjs/types.d.ts.map +1 -1
- package/dist/cjs/types.js +4 -4
- package/dist/esm/FormPage.d.ts +30 -30
- package/dist/esm/FormPage.d.ts.map +1 -1
- package/dist/esm/FormPage.js +790 -714
- package/dist/esm/components/CompanySelect/index.d.ts +6 -6
- package/dist/esm/components/CompanySelect/index.js +74 -74
- package/dist/esm/components/CustomNode/index.d.ts +6 -6
- package/dist/esm/components/CustomNode/index.js +6 -6
- package/dist/esm/components/ExtraDatePicker/index.d.ts +7 -7
- package/dist/esm/components/ExtraDatePicker/index.js +132 -132
- package/dist/esm/components/Section/index.d.ts +6 -6
- package/dist/esm/components/Section/index.js +27 -27
- package/dist/esm/components/SelectSearch/index.d.ts +6 -6
- package/dist/esm/components/SelectSearch/index.d.ts.map +1 -1
- package/dist/esm/components/SelectSearch/index.js +60 -33
- package/dist/esm/components/SettingDialog/index.d.ts +11 -11
- package/dist/esm/components/SettingDialog/index.js +122 -122
- package/dist/esm/context.d.ts +33 -33
- package/dist/esm/context.js +13 -13
- package/dist/esm/index.d.ts +11 -11
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -8
- package/dist/esm/styles/index.module.scss +21 -28
- package/dist/esm/tableKeyMap.d.ts +2 -2
- package/dist/esm/tableKeyMap.js +6 -6
- package/dist/esm/types.d.ts +236 -207
- package/dist/esm/types.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,34 +1,61 @@
|
|
|
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
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { Select } from '@alifd/next';
|
|
10
|
-
import { useRequest } from 'ahooks';
|
|
11
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
-
function SelectSearch(_ref) {
|
|
13
|
-
var field = _ref.field,
|
|
14
|
-
data = _ref.data;
|
|
15
|
-
var _useRequest = useRequest(function () {
|
|
16
|
-
var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
17
|
-
return data === null || data === void 0 ? void 0 : data.request(v);
|
|
18
|
-
}, {
|
|
19
|
-
manual: true,
|
|
20
|
-
debounceWait: 500
|
|
21
|
-
}),
|
|
22
|
-
dataSource = _useRequest.data,
|
|
23
|
-
getData = _useRequest.run;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { Select } from '@alifd/next';
|
|
10
|
+
import { useRequest } from 'ahooks';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function SelectSearch(_ref) {
|
|
13
|
+
var field = _ref.field,
|
|
14
|
+
data = _ref.data;
|
|
15
|
+
var _useRequest = useRequest(function () {
|
|
16
|
+
var v = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
|
|
17
|
+
return data === null || data === void 0 ? void 0 : data.request(v);
|
|
18
|
+
}, {
|
|
19
|
+
manual: true,
|
|
20
|
+
debounceWait: 500
|
|
21
|
+
}),
|
|
22
|
+
dataSource = _useRequest.data,
|
|
23
|
+
getData = _useRequest.run;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* AutoComplete 模式:输入触发 onChange(value, 'change'),选中项触发 onChange(value, 'itemClick' | 'enter'),
|
|
27
|
+
* 不像 Select 那样触发 onSearch。onChange 需放入 customProps(field.init 第三个参数),
|
|
28
|
+
* 由 Field 内部链式调用,避免覆盖表单取值逻辑
|
|
29
|
+
*/
|
|
30
|
+
var handleAutoCompleteChange = function handleAutoCompleteChange(value, actionType, item) {
|
|
31
|
+
var _data$customProps, _data$customProps$onC;
|
|
32
|
+
if (actionType === 'change') {
|
|
33
|
+
getData(value);
|
|
34
|
+
}
|
|
35
|
+
(_data$customProps = data.customProps) === null || _data$customProps === void 0 || (_data$customProps$onC = _data$customProps.onChange) === null || _data$customProps$onC === void 0 || _data$customProps$onC.call(_data$customProps, value, actionType, item);
|
|
36
|
+
};
|
|
37
|
+
if (data !== null && data !== void 0 && data.autoComplete) {
|
|
38
|
+
var _data$customProps$fil, _data$customProps2;
|
|
39
|
+
return /*#__PURE__*/_jsx(Select.AutoComplete, _objectSpread(_objectSpread({}, field.init(data.name, _objectSpread({}, data.options), _objectSpread(_objectSpread({}, data.customProps), {}, {
|
|
40
|
+
onChange: handleAutoCompleteChange
|
|
41
|
+
}))), {}, {
|
|
42
|
+
// 选中候选项默认回填 label(Fusion 默认为 value),可通过 customProps.fillProps 覆盖
|
|
43
|
+
fillProps: (_data$customProps$fil = (_data$customProps2 = data.customProps) === null || _data$customProps2 === void 0 ? void 0 : _data$customProps2.fillProps) !== null && _data$customProps$fil !== void 0 ? _data$customProps$fil : 'label',
|
|
44
|
+
onVisibleChange: function onVisibleChange(v) {
|
|
45
|
+
return v && getData();
|
|
46
|
+
},
|
|
47
|
+
dataSource: dataSource,
|
|
48
|
+
filterLocal: false
|
|
49
|
+
}));
|
|
50
|
+
}
|
|
51
|
+
return /*#__PURE__*/_jsx(Select, _objectSpread(_objectSpread({}, field.init(data.name, _objectSpread({}, data.options), _objectSpread({}, data.customProps))), {}, {
|
|
52
|
+
showSearch: true,
|
|
53
|
+
onSearch: getData,
|
|
54
|
+
onVisibleChange: function onVisibleChange(v) {
|
|
55
|
+
return v && getData();
|
|
56
|
+
},
|
|
57
|
+
dataSource: dataSource,
|
|
58
|
+
filterLocal: false
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
34
61
|
export default SelectSearch;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
interface SettingDialogProps {
|
|
3
|
-
onChange: (id: string) => void;
|
|
4
|
-
id: string;
|
|
5
|
-
dataSource: any[];
|
|
6
|
-
container?: HTMLElement | null;
|
|
7
|
-
hiddenKeys: string[];
|
|
8
|
-
onSave: (params: any) => Promise<any>;
|
|
9
|
-
}
|
|
10
|
-
declare const _default: React.ForwardRefExoticComponent<SettingDialogProps & React.RefAttributes<any>>;
|
|
11
|
-
export default _default;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface SettingDialogProps {
|
|
3
|
+
onChange: (id: string) => void;
|
|
4
|
+
id: string;
|
|
5
|
+
dataSource: any[];
|
|
6
|
+
container?: HTMLElement | null;
|
|
7
|
+
hiddenKeys: string[];
|
|
8
|
+
onSave: (params: any) => Promise<any>;
|
|
9
|
+
}
|
|
10
|
+
declare const _default: React.ForwardRefExoticComponent<SettingDialogProps & React.RefAttributes<any>>;
|
|
11
|
+
export default _default;
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
-
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
|
-
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); }
|
|
4
|
-
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; }
|
|
5
|
-
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
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
-
/* eslint-disable react/jsx-props-no-spreading */
|
|
8
|
-
import { Box, Button, Checkbox, Dialog, Message } from '@alifd/next';
|
|
9
|
-
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
10
|
-
import { useRequest, useToggle } from 'ahooks';
|
|
11
|
-
import styles from "./index.module.scss";
|
|
12
|
-
import { useConfig } from "../../context";
|
|
13
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
function SettingDialog(props, ref) {
|
|
16
|
-
var _props$container;
|
|
17
|
-
var _useToggle = useToggle(false),
|
|
18
|
-
_useToggle2 = _slicedToArray(_useToggle, 2),
|
|
19
|
-
visible = _useToggle2[0],
|
|
20
|
-
toggle = _useToggle2[1].toggle;
|
|
21
|
-
var _useState = useState([]),
|
|
22
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
-
dataSource = _useState2[0],
|
|
24
|
-
setDataSource = _useState2[1];
|
|
25
|
-
// 勾选状态用本地 React state 控制(value + onChange),
|
|
26
|
-
// 不再使用 Field:Field + Dialog(popupContainer) 会导致 Checkbox 受控值落后一个渲染周期,
|
|
27
|
-
// 表现为「点击当前项无反应,点击下一项时上一项才更新」。
|
|
28
|
-
var _useState3 = useState([]),
|
|
29
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
-
checkedKeys = _useState4[0],
|
|
31
|
-
setCheckedKeys = _useState4[1];
|
|
32
|
-
var _useConfig = useConfig(),
|
|
33
|
-
getTableName = _useConfig.getTableName;
|
|
34
|
-
var _useRequest = useRequest(props.onSave, {
|
|
35
|
-
manual: true,
|
|
36
|
-
onSuccess: function onSuccess() {
|
|
37
|
-
Message.success('保存成功');
|
|
38
|
-
props.onChange(props.id);
|
|
39
|
-
toggle();
|
|
40
|
-
}
|
|
41
|
-
}),
|
|
42
|
-
run = _useRequest.run;
|
|
43
|
-
var init = function init() {
|
|
44
|
-
// 已隐藏的列不出现在勾选(可见)集合中
|
|
45
|
-
var list = dataSource.filter(function (f) {
|
|
46
|
-
return !props.hiddenKeys.includes(f.value);
|
|
47
|
-
});
|
|
48
|
-
setCheckedKeys(list.map(function (e) {
|
|
49
|
-
return e.value;
|
|
50
|
-
}));
|
|
51
|
-
};
|
|
52
|
-
useEffect(function () {
|
|
53
|
-
var _props$dataSource$map, _props$dataSource;
|
|
54
|
-
setDataSource((_props$dataSource$map = (_props$dataSource = props.dataSource) === null || _props$dataSource === void 0 ? void 0 : _props$dataSource.map(function (e) {
|
|
55
|
-
return {
|
|
56
|
-
label: e.title,
|
|
57
|
-
value: e.dataIndex
|
|
58
|
-
};
|
|
59
|
-
})) !== null && _props$dataSource$map !== void 0 ? _props$dataSource$map : []);
|
|
60
|
-
}, [props.dataSource]);
|
|
61
|
-
useImperativeHandle(ref, function () {
|
|
62
|
-
return {
|
|
63
|
-
show: function show() {
|
|
64
|
-
toggle();
|
|
65
|
-
init();
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
var handleOk = function handleOk() {
|
|
70
|
-
// 未勾选的列 = 要隐藏的列
|
|
71
|
-
var hiddenList = dataSource.filter(function (f) {
|
|
72
|
-
return !checkedKeys.includes(f.value);
|
|
73
|
-
});
|
|
74
|
-
run({
|
|
75
|
-
tableId: props.id,
|
|
76
|
-
value: hiddenList.map(function (e) {
|
|
77
|
-
return e.value;
|
|
78
|
-
}).join(','),
|
|
79
|
-
name: hiddenList.map(function (e) {
|
|
80
|
-
return e.label;
|
|
81
|
-
}).join(','),
|
|
82
|
-
tableName: getTableName === null || getTableName === void 0 ? void 0 : getTableName()
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
return /*#__PURE__*/_jsx(Dialog, {
|
|
86
|
-
title: "\u5B9A\u5236\u5217",
|
|
87
|
-
visible: visible,
|
|
88
|
-
onClose: function onClose() {
|
|
89
|
-
toggle();
|
|
90
|
-
},
|
|
91
|
-
className: styles.carDilog,
|
|
92
|
-
footer: false,
|
|
93
|
-
popupContainer: (_props$container = props.container) !== null && _props$container !== void 0 ? _props$container : undefined,
|
|
94
|
-
v2: true,
|
|
95
|
-
centered: true,
|
|
96
|
-
width: 800,
|
|
97
|
-
children: /*#__PURE__*/_jsxs("div", {
|
|
98
|
-
className: styles.filterForm,
|
|
99
|
-
children: [/*#__PURE__*/_jsx(Checkbox.Group, {
|
|
100
|
-
dataSource: dataSource,
|
|
101
|
-
value: checkedKeys,
|
|
102
|
-
onChange: function onChange(v) {
|
|
103
|
-
return setCheckedKeys(v);
|
|
104
|
-
}
|
|
105
|
-
}), /*#__PURE__*/_jsxs(Box, {
|
|
106
|
-
direction: "row",
|
|
107
|
-
spacing: 8,
|
|
108
|
-
justify: "flex-end",
|
|
109
|
-
children: [/*#__PURE__*/_jsx(Button, {
|
|
110
|
-
onClick: function onClick() {
|
|
111
|
-
toggle();
|
|
112
|
-
},
|
|
113
|
-
children: "\u53D6\u6D88"
|
|
114
|
-
}), /*#__PURE__*/_jsx(Button, {
|
|
115
|
-
type: "primary",
|
|
116
|
-
onClick: handleOk,
|
|
117
|
-
children: "\u786E\u5B9A"
|
|
118
|
-
})]
|
|
119
|
-
})]
|
|
120
|
-
})
|
|
121
|
-
});
|
|
122
|
-
}
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
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
|
+
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); }
|
|
4
|
+
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; }
|
|
5
|
+
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
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
/* eslint-disable react/jsx-props-no-spreading */
|
|
8
|
+
import { Box, Button, Checkbox, Dialog, Message } from '@alifd/next';
|
|
9
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
|
|
10
|
+
import { useRequest, useToggle } from 'ahooks';
|
|
11
|
+
import styles from "./index.module.scss";
|
|
12
|
+
import { useConfig } from "../../context";
|
|
13
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
14
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
+
function SettingDialog(props, ref) {
|
|
16
|
+
var _props$container;
|
|
17
|
+
var _useToggle = useToggle(false),
|
|
18
|
+
_useToggle2 = _slicedToArray(_useToggle, 2),
|
|
19
|
+
visible = _useToggle2[0],
|
|
20
|
+
toggle = _useToggle2[1].toggle;
|
|
21
|
+
var _useState = useState([]),
|
|
22
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
23
|
+
dataSource = _useState2[0],
|
|
24
|
+
setDataSource = _useState2[1];
|
|
25
|
+
// 勾选状态用本地 React state 控制(value + onChange),
|
|
26
|
+
// 不再使用 Field:Field + Dialog(popupContainer) 会导致 Checkbox 受控值落后一个渲染周期,
|
|
27
|
+
// 表现为「点击当前项无反应,点击下一项时上一项才更新」。
|
|
28
|
+
var _useState3 = useState([]),
|
|
29
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
30
|
+
checkedKeys = _useState4[0],
|
|
31
|
+
setCheckedKeys = _useState4[1];
|
|
32
|
+
var _useConfig = useConfig(),
|
|
33
|
+
getTableName = _useConfig.getTableName;
|
|
34
|
+
var _useRequest = useRequest(props.onSave, {
|
|
35
|
+
manual: true,
|
|
36
|
+
onSuccess: function onSuccess() {
|
|
37
|
+
Message.success('保存成功');
|
|
38
|
+
props.onChange(props.id);
|
|
39
|
+
toggle();
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
run = _useRequest.run;
|
|
43
|
+
var init = function init() {
|
|
44
|
+
// 已隐藏的列不出现在勾选(可见)集合中
|
|
45
|
+
var list = dataSource.filter(function (f) {
|
|
46
|
+
return !props.hiddenKeys.includes(f.value);
|
|
47
|
+
});
|
|
48
|
+
setCheckedKeys(list.map(function (e) {
|
|
49
|
+
return e.value;
|
|
50
|
+
}));
|
|
51
|
+
};
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
var _props$dataSource$map, _props$dataSource;
|
|
54
|
+
setDataSource((_props$dataSource$map = (_props$dataSource = props.dataSource) === null || _props$dataSource === void 0 ? void 0 : _props$dataSource.map(function (e) {
|
|
55
|
+
return {
|
|
56
|
+
label: e.title,
|
|
57
|
+
value: e.dataIndex
|
|
58
|
+
};
|
|
59
|
+
})) !== null && _props$dataSource$map !== void 0 ? _props$dataSource$map : []);
|
|
60
|
+
}, [props.dataSource]);
|
|
61
|
+
useImperativeHandle(ref, function () {
|
|
62
|
+
return {
|
|
63
|
+
show: function show() {
|
|
64
|
+
toggle();
|
|
65
|
+
init();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
var handleOk = function handleOk() {
|
|
70
|
+
// 未勾选的列 = 要隐藏的列
|
|
71
|
+
var hiddenList = dataSource.filter(function (f) {
|
|
72
|
+
return !checkedKeys.includes(f.value);
|
|
73
|
+
});
|
|
74
|
+
run({
|
|
75
|
+
tableId: props.id,
|
|
76
|
+
value: hiddenList.map(function (e) {
|
|
77
|
+
return e.value;
|
|
78
|
+
}).join(','),
|
|
79
|
+
name: hiddenList.map(function (e) {
|
|
80
|
+
return e.label;
|
|
81
|
+
}).join(','),
|
|
82
|
+
tableName: getTableName === null || getTableName === void 0 ? void 0 : getTableName()
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
return /*#__PURE__*/_jsx(Dialog, {
|
|
86
|
+
title: "\u5B9A\u5236\u5217",
|
|
87
|
+
visible: visible,
|
|
88
|
+
onClose: function onClose() {
|
|
89
|
+
toggle();
|
|
90
|
+
},
|
|
91
|
+
className: styles.carDilog,
|
|
92
|
+
footer: false,
|
|
93
|
+
popupContainer: (_props$container = props.container) !== null && _props$container !== void 0 ? _props$container : undefined,
|
|
94
|
+
v2: true,
|
|
95
|
+
centered: true,
|
|
96
|
+
width: 800,
|
|
97
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
98
|
+
className: styles.filterForm,
|
|
99
|
+
children: [/*#__PURE__*/_jsx(Checkbox.Group, {
|
|
100
|
+
dataSource: dataSource,
|
|
101
|
+
value: checkedKeys,
|
|
102
|
+
onChange: function onChange(v) {
|
|
103
|
+
return setCheckedKeys(v);
|
|
104
|
+
}
|
|
105
|
+
}), /*#__PURE__*/_jsxs(Box, {
|
|
106
|
+
direction: "row",
|
|
107
|
+
spacing: 8,
|
|
108
|
+
justify: "flex-end",
|
|
109
|
+
children: [/*#__PURE__*/_jsx(Button, {
|
|
110
|
+
onClick: function onClick() {
|
|
111
|
+
toggle();
|
|
112
|
+
},
|
|
113
|
+
children: "\u53D6\u6D88"
|
|
114
|
+
}), /*#__PURE__*/_jsx(Button, {
|
|
115
|
+
type: "primary",
|
|
116
|
+
onClick: handleOk,
|
|
117
|
+
children: "\u786E\u5B9A"
|
|
118
|
+
})]
|
|
119
|
+
})]
|
|
120
|
+
})
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
123
|
export default /*#__PURE__*/forwardRef(SettingDialog);
|
package/dist/esm/context.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
export interface FormPageConfig {
|
|
3
|
-
/** Fetch table key configuration for a given table ID */
|
|
4
|
-
fetchTableKeys?: (tableId: string) => Promise<Array<{
|
|
5
|
-
tableId: string;
|
|
6
|
-
value: string;
|
|
7
|
-
}>>;
|
|
8
|
-
/** Save/update table key configuration */
|
|
9
|
-
onSaveTableKeys?: (params: {
|
|
10
|
-
tableId: string;
|
|
11
|
-
value: string;
|
|
12
|
-
name: string;
|
|
13
|
-
tableName?: string;
|
|
14
|
-
}) => Promise<any>;
|
|
15
|
-
/** Resolve the table name for column customization */
|
|
16
|
-
getTableName?: () => string;
|
|
17
|
-
/** Search for companies by name */
|
|
18
|
-
onSearchCompany?: (keyword: string) => Promise<Array<{
|
|
19
|
-
name: string;
|
|
20
|
-
id: string;
|
|
21
|
-
}>>;
|
|
22
|
-
/** Get current company info */
|
|
23
|
-
getCompanyInfo?: () => {
|
|
24
|
-
id: string;
|
|
25
|
-
name: string;
|
|
26
|
-
isManage: boolean;
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export declare const FormPageProvider: React.FC<{
|
|
30
|
-
config: FormPageConfig;
|
|
31
|
-
children: React.ReactNode;
|
|
32
|
-
}>;
|
|
33
|
-
export declare const useConfig: () => FormPageConfig;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface FormPageConfig {
|
|
3
|
+
/** Fetch table key configuration for a given table ID */
|
|
4
|
+
fetchTableKeys?: (tableId: string) => Promise<Array<{
|
|
5
|
+
tableId: string;
|
|
6
|
+
value: string;
|
|
7
|
+
}>>;
|
|
8
|
+
/** Save/update table key configuration */
|
|
9
|
+
onSaveTableKeys?: (params: {
|
|
10
|
+
tableId: string;
|
|
11
|
+
value: string;
|
|
12
|
+
name: string;
|
|
13
|
+
tableName?: string;
|
|
14
|
+
}) => Promise<any>;
|
|
15
|
+
/** Resolve the table name for column customization */
|
|
16
|
+
getTableName?: () => string;
|
|
17
|
+
/** Search for companies by name */
|
|
18
|
+
onSearchCompany?: (keyword: string) => Promise<Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
id: string;
|
|
21
|
+
}>>;
|
|
22
|
+
/** Get current company info */
|
|
23
|
+
getCompanyInfo?: () => {
|
|
24
|
+
id: string;
|
|
25
|
+
name: string;
|
|
26
|
+
isManage: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare const FormPageProvider: React.FC<{
|
|
30
|
+
config: FormPageConfig;
|
|
31
|
+
children: React.ReactNode;
|
|
32
|
+
}>;
|
|
33
|
+
export declare const useConfig: () => FormPageConfig;
|
|
34
34
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/esm/context.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import React, { createContext, useContext } from 'react';
|
|
2
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
-
var FormPageConfigContext = /*#__PURE__*/createContext({});
|
|
4
|
-
export var FormPageProvider = function FormPageProvider(_ref) {
|
|
5
|
-
var config = _ref.config,
|
|
6
|
-
children = _ref.children;
|
|
7
|
-
return /*#__PURE__*/_jsx(FormPageConfigContext.Provider, {
|
|
8
|
-
value: config,
|
|
9
|
-
children: children
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
export var useConfig = function useConfig() {
|
|
13
|
-
return useContext(FormPageConfigContext);
|
|
1
|
+
import React, { createContext, useContext } from 'react';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
var FormPageConfigContext = /*#__PURE__*/createContext({});
|
|
4
|
+
export var FormPageProvider = function FormPageProvider(_ref) {
|
|
5
|
+
var config = _ref.config,
|
|
6
|
+
children = _ref.children;
|
|
7
|
+
return /*#__PURE__*/_jsx(FormPageConfigContext.Provider, {
|
|
8
|
+
value: config,
|
|
9
|
+
children: children
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
export var useConfig = function useConfig() {
|
|
13
|
+
return useContext(FormPageConfigContext);
|
|
14
14
|
};
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export { default as FormPage } from './FormPage';
|
|
2
|
-
export { FormPageData, stringWidth } from './FormPage';
|
|
3
|
-
export type { FormPageRef, FormPageProps, ConditionItem, TableConfigProps, ButtonConfigProps, SelectCondition, InputCondition, TreeSelectCondition, CascaderSelectCondition, DatePickerCondition, MonthPickerCondition, RangePickerCondition, SectionCondition, CompanySelectCondition, ExtraDatePickerCondition, SelectSearchCondition, CustomNodeCondition, CustomCondition, } from './FormPage';
|
|
4
|
-
export { FormPageProvider } from './context';
|
|
5
|
-
export type { FormPageConfig } from './context';
|
|
6
|
-
export { default as CustomNode } from './components/CustomNode';
|
|
7
|
-
export { default as Section } from './components/Section';
|
|
8
|
-
export { default as SelectSearch } from './components/SelectSearch';
|
|
9
|
-
export { default as CompanySelect } from './components/CompanySelect';
|
|
10
|
-
export { default as ExtraDatePicker } from './components/ExtraDatePicker';
|
|
11
|
-
export { default as SettingDialog } from './components/SettingDialog';
|
|
1
|
+
export { default as FormPage } from './FormPage';
|
|
2
|
+
export { FormPageData, stringWidth } from './FormPage';
|
|
3
|
+
export type { FormPageRef, FormPageProps, ConditionItem, TableConfigProps, ButtonConfigProps, ButtonItemConfig, SelectCondition, InputCondition, TreeSelectCondition, CascaderSelectCondition, DatePickerCondition, MonthPickerCondition, RangePickerCondition, SectionCondition, CompanySelectCondition, ExtraDatePickerCondition, SelectSearchCondition, CustomNodeCondition, CustomCondition, } from './FormPage';
|
|
4
|
+
export { FormPageProvider } from './context';
|
|
5
|
+
export type { FormPageConfig } from './context';
|
|
6
|
+
export { default as CustomNode } from './components/CustomNode';
|
|
7
|
+
export { default as Section } from './components/Section';
|
|
8
|
+
export { default as SelectSearch } from './components/SelectSearch';
|
|
9
|
+
export { default as CompanySelect } from './components/CompanySelect';
|
|
10
|
+
export { default as ExtraDatePicker } from './components/ExtraDatePicker';
|
|
11
|
+
export { default as SettingDialog } from './components/SettingDialog';
|
|
12
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EACV,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACvD,YAAY,EACV,WAAW,EAAE,aAAa,EAAE,aAAa,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,gBAAgB,EAChG,eAAe,EAAE,cAAc,EAAE,mBAAmB,EAAE,uBAAuB,EAC7E,mBAAmB,EAAE,oBAAoB,EACzC,oBAAoB,EAAE,gBAAgB,EACtC,sBAAsB,EAAE,wBAAwB,EAAE,qBAAqB,EACvE,mBAAmB,EAAE,eAAe,GACrC,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEhD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export { default as FormPage } from "./FormPage";
|
|
2
|
-
export { FormPageData, stringWidth } from "./FormPage";
|
|
3
|
-
export { FormPageProvider } from "./context";
|
|
4
|
-
export { default as CustomNode } from "./components/CustomNode";
|
|
5
|
-
export { default as Section } from "./components/Section";
|
|
6
|
-
export { default as SelectSearch } from "./components/SelectSearch";
|
|
7
|
-
export { default as CompanySelect } from "./components/CompanySelect";
|
|
8
|
-
export { default as ExtraDatePicker } from "./components/ExtraDatePicker";
|
|
1
|
+
export { default as FormPage } from "./FormPage";
|
|
2
|
+
export { FormPageData, stringWidth } from "./FormPage";
|
|
3
|
+
export { FormPageProvider } from "./context";
|
|
4
|
+
export { default as CustomNode } from "./components/CustomNode";
|
|
5
|
+
export { default as Section } from "./components/Section";
|
|
6
|
+
export { default as SelectSearch } from "./components/SelectSearch";
|
|
7
|
+
export { default as CompanySelect } from "./components/CompanySelect";
|
|
8
|
+
export { default as ExtraDatePicker } from "./components/ExtraDatePicker";
|
|
9
9
|
export { default as SettingDialog } from "./components/SettingDialog";
|
|
@@ -12,19 +12,19 @@
|
|
|
12
12
|
// // cursor: pointer;
|
|
13
13
|
// display: flex !important;
|
|
14
14
|
// align-items: center;
|
|
15
|
-
img{
|
|
16
|
-
vertical-align:middle;
|
|
15
|
+
img {
|
|
16
|
+
vertical-align: middle;
|
|
17
17
|
}
|
|
18
18
|
span {
|
|
19
19
|
font-family: SourceHanSansCN, SourceHanSansCN;
|
|
20
20
|
font-weight: 400;
|
|
21
21
|
font-size: 14px;
|
|
22
|
-
color: #
|
|
22
|
+
color: #ff7e07;
|
|
23
23
|
margin-left: 4px;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
> .header {
|
|
28
28
|
flex-shrink: 0;
|
|
29
29
|
|
|
30
30
|
.noPaddingRight {
|
|
@@ -32,24 +32,6 @@
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
:global {
|
|
35
|
-
|
|
36
|
-
.next-row {
|
|
37
|
-
|
|
38
|
-
.next-col.next-col-8,
|
|
39
|
-
.next-col.next-col-16 {
|
|
40
|
-
padding-right: 20px;
|
|
41
|
-
box-sizing: border-box;
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.next-col.next-col-6,
|
|
46
|
-
.next-col.next-col-12,
|
|
47
|
-
.next-col.next-col-18 {
|
|
48
|
-
padding-right: 16px;
|
|
49
|
-
box-sizing: border-box;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
35
|
.next-form-item.next-left {
|
|
54
36
|
width: 100%;
|
|
55
37
|
display: flex !important;
|
|
@@ -83,7 +65,7 @@
|
|
|
83
65
|
height: 30px;
|
|
84
66
|
|
|
85
67
|
.next-input-text-field,
|
|
86
|
-
>input {
|
|
68
|
+
> input {
|
|
87
69
|
height: 28px;
|
|
88
70
|
}
|
|
89
71
|
|
|
@@ -107,7 +89,6 @@
|
|
|
107
89
|
width: 100%;
|
|
108
90
|
}
|
|
109
91
|
|
|
110
|
-
|
|
111
92
|
input,
|
|
112
93
|
textarea {
|
|
113
94
|
width: 100%;
|
|
@@ -127,7 +108,6 @@
|
|
|
127
108
|
}
|
|
128
109
|
|
|
129
110
|
.btnCol {
|
|
130
|
-
padding: 0 !important;
|
|
131
111
|
display: flex;
|
|
132
112
|
justify-content: flex-end;
|
|
133
113
|
margin-bottom: 16px;
|
|
@@ -139,9 +119,23 @@
|
|
|
139
119
|
}
|
|
140
120
|
}
|
|
141
121
|
|
|
122
|
+
/* ghost 风格按钮:白底 + 主题橙描边/文字(含 hover/点击),权重一致 */
|
|
123
|
+
.ghostBtn {
|
|
124
|
+
background-color: #fff;
|
|
125
|
+
border-color: #ff7e07 !important;
|
|
126
|
+
color: #ff7e07;
|
|
127
|
+
|
|
128
|
+
&:hover,
|
|
129
|
+
&:focus,
|
|
130
|
+
&:active {
|
|
131
|
+
background-color: #fff;
|
|
132
|
+
border-color: #ff7e07 !important;
|
|
133
|
+
color: #ff7e07;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
142
136
|
}
|
|
143
137
|
|
|
144
|
-
|
|
138
|
+
> .body {
|
|
145
139
|
flex: 1;
|
|
146
140
|
overflow: hidden;
|
|
147
141
|
position: relative;
|
|
@@ -154,11 +148,10 @@
|
|
|
154
148
|
line-height: 38px;
|
|
155
149
|
}
|
|
156
150
|
}
|
|
157
|
-
|
|
158
151
|
}
|
|
159
152
|
}
|
|
160
153
|
|
|
161
|
-
|
|
154
|
+
> .pagination {
|
|
162
155
|
text-align: right;
|
|
163
156
|
flex-shrink: 0;
|
|
164
157
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const parseHiddenKeys: (rawValue: string | undefined) => string[];
|
|
2
|
-
export declare const serializeHiddenKeys: (keys: string[]) => string;
|
|
1
|
+
export declare const parseHiddenKeys: (rawValue: string | undefined) => string[];
|
|
2
|
+
export declare const serializeHiddenKeys: (keys: string[]) => string;
|
|
3
3
|
//# sourceMappingURL=tableKeyMap.d.ts.map
|
package/dist/esm/tableKeyMap.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export var parseHiddenKeys = function parseHiddenKeys(rawValue) {
|
|
2
|
-
if (!rawValue) return [];
|
|
3
|
-
return rawValue.split(',');
|
|
4
|
-
};
|
|
5
|
-
export var serializeHiddenKeys = function serializeHiddenKeys(keys) {
|
|
6
|
-
return keys.join(',');
|
|
1
|
+
export var parseHiddenKeys = function parseHiddenKeys(rawValue) {
|
|
2
|
+
if (!rawValue) return [];
|
|
3
|
+
return rawValue.split(',');
|
|
4
|
+
};
|
|
5
|
+
export var serializeHiddenKeys = function serializeHiddenKeys(keys) {
|
|
6
|
+
return keys.join(',');
|
|
7
7
|
};
|