@teamix/pro 1.2.11 → 1.2.12

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 (42) hide show
  1. package/dist/212.js +1 -1
  2. package/dist/pro.css +1 -1
  3. package/dist/pro.js +1382 -644
  4. package/dist/pro.min.css +1 -1
  5. package/dist/pro.min.js +1 -1
  6. package/es/actions/index.scss +14 -0
  7. package/es/form/Filter/index.d.ts +2 -5
  8. package/es/form/Filter/index.js +3 -44
  9. package/es/form/Filter/index.scss +71 -0
  10. package/es/form/Filter/index2.d.ts +8 -0
  11. package/es/form/Filter/index2.js +318 -0
  12. package/es/form/ProForm/index.scss +1 -19
  13. package/es/form/ProForm/useFormDisplayValues.d.ts +3 -5
  14. package/es/form/ProForm/useFormDisplayValues.js +44 -38
  15. package/es/form/index.d.ts +2 -1
  16. package/es/form/index.js +3 -2
  17. package/es/form/typing.d.ts +3 -0
  18. package/es/index.d.ts +1 -1
  19. package/es/index.js +1 -1
  20. package/es/table/components/Filter/index.js +8 -6
  21. package/es/table/components/Filter/index.scss +7 -3
  22. package/es/table/components/Layout/index.js +10 -1
  23. package/es/table/index.js +2 -3
  24. package/lib/actions/index.scss +14 -0
  25. package/lib/form/Filter/index.d.ts +2 -5
  26. package/lib/form/Filter/index.js +4 -45
  27. package/lib/form/Filter/index.scss +71 -0
  28. package/lib/form/Filter/index2.d.ts +8 -0
  29. package/lib/form/Filter/index2.js +342 -0
  30. package/lib/form/ProForm/index.scss +1 -19
  31. package/lib/form/ProForm/useFormDisplayValues.d.ts +3 -5
  32. package/lib/form/ProForm/useFormDisplayValues.js +51 -44
  33. package/lib/form/index.d.ts +2 -1
  34. package/lib/form/index.js +5 -3
  35. package/lib/form/typing.d.ts +3 -0
  36. package/lib/index.d.ts +1 -1
  37. package/lib/index.js +1 -1
  38. package/lib/table/components/Filter/index.js +8 -6
  39. package/lib/table/components/Filter/index.scss +7 -3
  40. package/lib/table/components/Layout/index.js +10 -1
  41. package/lib/table/index.js +1 -2
  42. package/package.json +4 -4
@@ -0,0 +1,342 @@
1
+ "use strict";
2
+
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.QueryFilter = void 0;
9
+
10
+ var _react = _interopRequireWildcard(require("react"));
11
+
12
+ var _classnames = _interopRequireDefault(require("classnames"));
13
+
14
+ var _components = require("@alicloudfe/components");
15
+
16
+ var _icon = _interopRequireDefault(require("@teamix/icon"));
17
+
18
+ var _core = require("@formily/core");
19
+
20
+ var _utils = require("@teamix/utils");
21
+
22
+ var _ProForm = _interopRequireDefault(require("../ProForm"));
23
+
24
+ var _useFormDisplayValues = require("../ProForm/useFormDisplayValues");
25
+
26
+ var _utils2 = require("../utils");
27
+
28
+ require("./index.scss");
29
+
30
+ var _excluded = ["schema", "triggerType", "onFilter"];
31
+
32
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
33
+
34
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
35
+
36
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
37
+
38
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
39
+
40
+ 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."); }
41
+
42
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
43
+
44
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
+
46
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
47
+
48
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
49
+
50
+ 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); }
51
+
52
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
53
+
54
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
55
+
56
+ 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; }
57
+
58
+ 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; }
59
+
60
+ 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; }
61
+
62
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
63
+
64
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
65
+
66
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
67
+
68
+ var getEventProps = function getEventProps(triggerType, onFilter) {
69
+ var keydownEvent = {
70
+ onSubmit: onFilter
71
+ };
72
+ var changeEvent = {
73
+ onChange: onFilter
74
+ };
75
+ var eventMap = {
76
+ keydown: keydownEvent,
77
+ change: _objectSpread(_objectSpread({}, keydownEvent), changeEvent),
78
+ submit: keydownEvent
79
+ };
80
+ return eventMap[triggerType];
81
+ };
82
+
83
+ var schemaTemp = [{
84
+ name: 'taskName',
85
+ title: '实例名称',
86
+ component: 'Input',
87
+ required: true,
88
+ props: {
89
+ style: {
90
+ width: 180
91
+ },
92
+ placeholder: '请输入'
93
+ }
94
+ }];
95
+ /**
96
+ * 简单筛选
97
+ */
98
+
99
+ var SimpleFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
100
+ var schema = props.schema,
101
+ triggerType = props.triggerType,
102
+ onFilter = props.onFilter,
103
+ otherProps = _objectWithoutProperties(props, _excluded);
104
+
105
+ var prefixCls = (0, _utils.usePrefixCls)('', {
106
+ prefix: 'teamix-pro-form-filter-simple'
107
+ });
108
+ var simpleSchema = (0, _react.useMemo)(function () {
109
+ return [{
110
+ component: 'FormFlex',
111
+ props: {
112
+ size: 8
113
+ },
114
+ children: [].concat(_toConsumableArray(schema), [{
115
+ type: 'void',
116
+ decorator: null,
117
+ component: 'Submit',
118
+ props: {
119
+ style: _objectSpread({}, triggerType === 'submit' ? {} : {
120
+ display: 'none'
121
+ })
122
+ }
123
+ }])
124
+ }];
125
+ }, []);
126
+ var eventProps = getEventProps(triggerType, onFilter);
127
+ return /*#__PURE__*/_react.default.createElement(_ProForm.default, _objectSpread(_objectSpread(_objectSpread({
128
+ feedbackLayout: "popover",
129
+ breakpoints: [],
130
+ inset: true
131
+ }, otherProps), eventProps), {}, {
132
+ className: (0, _classnames.default)(prefixCls, props.className),
133
+ schema: simpleSchema
134
+ }));
135
+ });
136
+ SimpleFilter.defaultProps = {
137
+ triggerType: 'change'
138
+ };
139
+ /**
140
+ * 高级筛选
141
+ */
142
+
143
+ var AdvancedFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
144
+ var form = (0, _react.useMemo)(function () {
145
+ return (props === null || props === void 0 ? void 0 : props.form) || (0, _core.createForm)();
146
+ }, []);
147
+ var schema = props.schema,
148
+ triggerType = props.triggerType,
149
+ onFilter = props.onFilter,
150
+ onReset = props.onReset,
151
+ layout = props.layout,
152
+ labelAlign = props.labelAlign,
153
+ wrapperAlign = props.wrapperAlign,
154
+ labelCol = props.labelCol,
155
+ wrapperCol = props.wrapperCol;
156
+ var prefixCls = (0, _utils.usePrefixCls)('', {
157
+ prefix: 'teamix-pro-form-filter-advanced'
158
+ });
159
+ var gridSchema = (0, _react.useMemo)(function () {
160
+ return [{
161
+ name: 'FormGrid',
162
+ component: 'FormGrid',
163
+ props: {
164
+ breakpoints: [480, 720, 990, 1200, Infinity],
165
+ maxColumns: [1, 2, 3, 3, 4],
166
+ columnGap: 16,
167
+ rowGap: 12
168
+ },
169
+ children: [].concat(_toConsumableArray(schema), [{
170
+ component: 'FormGrid.GridColumn',
171
+ props: {
172
+ gridSpan: -1
173
+ },
174
+ children: [{
175
+ component: 'FormButtonGroup',
176
+ props: {
177
+ align: 'right'
178
+ },
179
+ children: [{
180
+ component: 'Reset',
181
+ props: {
182
+ onResetValidateSuccess: onReset,
183
+ style: _objectSpread({}, triggerType === 'submit' ? {} : {
184
+ marginRight: -16
185
+ }),
186
+ children: (0, _utils.getMessage)('reset')
187
+ }
188
+ }, {
189
+ component: 'Submit',
190
+ props: {
191
+ style: _objectSpread({}, triggerType === 'submit' ? {
192
+ marginRight: -8
193
+ } : {
194
+ display: 'none'
195
+ }),
196
+ children: (0, _utils.getMessage)('search')
197
+ }
198
+ }]
199
+ }]
200
+ }])
201
+ }];
202
+ }, []);
203
+ var getTeamixLayout = (0, _react.useMemo)(function () {
204
+ return {
205
+ breakpoints: [990],
206
+ layout: (0, _utils2.mergeArrayValue)(['vertical'], layout),
207
+ labelAlign: (0, _utils2.mergeArrayValue)(['left'], labelAlign),
208
+ wrapperAlign: (0, _utils2.mergeArrayValue)(['left'], wrapperAlign),
209
+ labelCol: (0, _utils2.mergeArrayValue)([24], labelCol),
210
+ wrapperCol: (0, _utils2.mergeArrayValue)([24], wrapperCol)
211
+ };
212
+ }, [layout, labelAlign, wrapperAlign, labelCol, wrapperCol]);
213
+ var eventProps = getEventProps(triggerType, onFilter);
214
+ return /*#__PURE__*/_react.default.createElement(_ProForm.default, _objectSpread(_objectSpread(_objectSpread(_objectSpread({
215
+ feedbackLayout: "popover"
216
+ }, props), eventProps), getTeamixLayout), {}, {
217
+ form: form,
218
+ className: (0, _classnames.default)(prefixCls, props.className),
219
+ schema: gridSchema,
220
+ onSubmit: onFilter
221
+ }));
222
+ });
223
+ AdvancedFilter.defaultProps = {
224
+ triggerType: 'change',
225
+ layout: 'horizontal',
226
+ labelAlign: 'right',
227
+ labelCol: 6,
228
+ wrapperCol: 18
229
+ };
230
+ /**
231
+ * 查询筛选
232
+ */
233
+
234
+ var QueryFilter = /*#__PURE__*/(0, _react.memo)(function (props) {
235
+ var _useState = (0, _react.useState)(true),
236
+ _useState2 = _slicedToArray(_useState, 2),
237
+ advancedFilterVisible = _useState2[0],
238
+ setAdvancedFilterVisible = _useState2[1];
239
+
240
+ var _useState3 = (0, _react.useState)([]),
241
+ _useState4 = _slicedToArray(_useState3, 2),
242
+ tagDataSource = _useState4[0],
243
+ setTagDataSource = _useState4[1]; // const [values, setValues] = useState<any>();
244
+
245
+
246
+ var form = (0, _react.useMemo)(function () {
247
+ return (props === null || props === void 0 ? void 0 : props.form) || (0, _core.createForm)({
248
+ validateFirst: true
249
+ });
250
+ }, []);
251
+ var schema = props.schema,
252
+ addonAfter = props.addonAfter,
253
+ addonBefore = props.addonBefore;
254
+ var prefixCls = (0, _utils.usePrefixCls)('', {
255
+ prefix: 'teamix-pro-form-query-filter'
256
+ }); // 展开收起高级筛选
257
+
258
+ var toggleAdvancedFilter = (0, _react.useCallback)(function () {
259
+ setAdvancedFilterVisible(function (visible) {
260
+ return !visible;
261
+ });
262
+ }, []); // 获取标签数据
263
+
264
+ var getTagDataSource = (0, _react.useCallback)(function (form) {
265
+ var displayValues = (0, _useFormDisplayValues.getFormDisplayValues)(form);
266
+ return Object.entries(displayValues).map(function (_ref) {
267
+ var _data$displayValue;
268
+
269
+ var _ref2 = _slicedToArray(_ref, 2),
270
+ key = _ref2[0],
271
+ data = _ref2[1];
272
+
273
+ return {
274
+ key: key,
275
+ label: data.title,
276
+ value: (_data$displayValue = data.displayValue) !== null && _data$displayValue !== void 0 ? _data$displayValue : data.value
277
+ };
278
+ }); // .filter((item) => isValid(item.value));
279
+ }, []); // 表单值变化
280
+
281
+ var onFormValueChange = (0, _react.useCallback)(function (values) {
282
+ setTagDataSource(getTagDataSource(form));
283
+ }, []);
284
+ console.log(tagDataSource); // useEffect(() => {
285
+ // console.log(form.values);
286
+ // }, [form.values]);
287
+
288
+ return /*#__PURE__*/_react.default.createElement("div", {
289
+ className: (0, _classnames.default)(prefixCls, props.className)
290
+ }, /*#__PURE__*/_react.default.createElement("div", {
291
+ className: "".concat(prefixCls, "-inline")
292
+ }, /*#__PURE__*/_react.default.createElement("div", {
293
+ className: "".concat(prefixCls, "-left")
294
+ }, addonBefore ? /*#__PURE__*/_react.default.createElement("div", {
295
+ className: "".concat(prefixCls, "-addonBefore")
296
+ }, addonBefore) : null, /*#__PURE__*/_react.default.createElement("div", {
297
+ className: "".concat(prefixCls, "-simple")
298
+ }, /*#__PURE__*/_react.default.createElement(SimpleFilter, {
299
+ schema: schemaTemp
300
+ })), /*#__PURE__*/_react.default.createElement("div", {
301
+ className: "".concat(prefixCls, "-toggle")
302
+ }, /*#__PURE__*/_react.default.createElement(_components.Badge, {
303
+ count: tagDataSource.length,
304
+ style: _objectSpread({
305
+ backgroundColor: 'var(--color-brand1-6, #0064c8)',
306
+ color: 'var(--color-white, #fff)'
307
+ }, advancedFilterVisible ? {
308
+ display: 'none'
309
+ } : {})
310
+ }, /*#__PURE__*/_react.default.createElement(_components.Button, {
311
+ onClick: toggleAdvancedFilter
312
+ }, advancedFilterVisible ? /*#__PURE__*/_react.default.createElement(_icon.default, {
313
+ type: "up-line"
314
+ }) : /*#__PURE__*/_react.default.createElement(_icon.default, {
315
+ type: "filter-line"
316
+ }), (0, _utils.getMessage)('advancedFilter'))))), addonAfter ? /*#__PURE__*/_react.default.createElement("div", {
317
+ className: "".concat(prefixCls, "-addonAfter")
318
+ }, addonAfter) : null), /*#__PURE__*/_react.default.createElement("div", {
319
+ className: "".concat(prefixCls, "-panel")
320
+ }, /*#__PURE__*/_react.default.createElement("div", {
321
+ className: (0, _classnames.default)("".concat(prefixCls, "-tag"), !advancedFilterVisible ? "".concat(prefixCls, "-tag-hidden") : '')
322
+ }, /*#__PURE__*/_react.default.createElement(_components.Tag.Group, null, tagDataSource.map(function (_ref3) {
323
+ var key = _ref3.key,
324
+ label = _ref3.label,
325
+ value = _ref3.value;
326
+ return /*#__PURE__*/_react.default.createElement(_components.Tag.Closeable, {
327
+ key: key,
328
+ afterClose: console.log
329
+ }, /*#__PURE__*/_react.default.createElement("span", {
330
+ className: "".concat(prefixCls, "-tag-title")
331
+ }, label), /*#__PURE__*/_react.default.createElement("span", {
332
+ className: "".concat(prefixCls, "-tag-content")
333
+ }, value));
334
+ }))), /*#__PURE__*/_react.default.createElement("div", {
335
+ className: (0, _classnames.default)("".concat(prefixCls, "-advanced"), !advancedFilterVisible ? "".concat(prefixCls, "-advanced-hidden") : '')
336
+ }, /*#__PURE__*/_react.default.createElement(AdvancedFilter, _objectSpread(_objectSpread({
337
+ form: form
338
+ }, props), {}, {
339
+ onFilter: onFormValueChange
340
+ })))));
341
+ });
342
+ exports.QueryFilter = QueryFilter;
@@ -230,14 +230,12 @@
230
230
  }
231
231
  }
232
232
 
233
- // 筛选和抽屉按钮
234
- .#{$teamix-pro-form}-filter-advanced,
233
+ // 抽屉按钮
235
234
  .#{$css-prefix}drawer-footer {
236
235
  .#{$css-prefix}formily-button-group {
237
236
  margin-top: 0;
238
237
  }
239
238
  }
240
-
241
239
  .#{$teamix-pro-form}-button-affix-auto.#{$css-prefix}affix,
242
240
  .#{$teamix-pro-form}-button-affix-always.#{$css-prefix}affix {
243
241
  left: 0;
@@ -259,22 +257,6 @@
259
257
  }
260
258
  }
261
259
 
262
- // 高级筛选
263
- .#{$teamix-pro-form}-filter-advanced,
264
- .#{$teamix-pro-form}-filter-simple {
265
- .#{$form-item-cls}-feedback-layout-popover {
266
- margin-bottom: 0;
267
- }
268
- .#{$css-prefix}date-picker2-input {
269
- .#{$css-prefix}input {
270
- width: inherit;
271
- input {
272
- width: inherit;
273
- }
274
- }
275
- }
276
- }
277
-
278
260
  // ArrayItems
279
261
  .#{$css-prefix}formily-array-items {
280
262
  .#{$css-prefix}formily-grid-layout {
@@ -1,6 +1,4 @@
1
- /**
2
- * 获取表单值的可显示值
3
- * @returns 如果某字段有dataSource,则返回value对应label
4
- */
1
+ import type { Form } from '@formily/core';
5
2
  declare const useFormDisplayValues: () => any;
6
- export default useFormDisplayValues;
3
+ declare const getFormDisplayValues: (form: Form) => any;
4
+ export { useFormDisplayValues, getFormDisplayValues };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.useFormDisplayValues = exports.getFormDisplayValues = void 0;
7
7
 
8
8
  var _react = require("@formily/react");
9
9
 
@@ -24,51 +24,58 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
24
24
  /**
25
25
  * 获取表单值的可显示值
26
26
  * @returns 如果某字段有dataSource,则返回value对应label
27
+ * @example const example = {
28
+ a: [
29
+ [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
30
+ { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
31
+ ],
32
+ };
33
+ console.log(getDisplayValues(example));
27
34
  */
35
+ var getDisplayValues = function getDisplayValues(form, values) {
36
+ var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
37
+ var displayValues; // 判断值的类型,递归获取每个值在该结构中的完整路径
38
+
39
+ if ((0, _utils.isPlainObj)(values)) {
40
+ displayValues = {};
41
+ Object.entries(values).forEach(function (_ref) {
42
+ var _ref2 = _slicedToArray(_ref, 2),
43
+ key = _ref2[0],
44
+ value = _ref2[1];
45
+
46
+ var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
47
+ displayValues[key] = getDisplayValues(form, value, path);
48
+ });
49
+ } else if ((0, _utils.isArr)(values)) {
50
+ displayValues = []; // todo 如果对象或数组的值不再是对象或数组,并且找不到路径,判断为非复合组件,直接返回原始值
51
+
52
+ values.map(function (value, index) {
53
+ var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
54
+ displayValues[index] = getDisplayValues(form, value, path);
55
+ });
56
+ } else {
57
+ // 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
58
+ var address = form.indexes[prefix];
59
+ var field = form.query(address).take();
60
+ displayValues = {
61
+ title: field === null || field === void 0 ? void 0 : field.title,
62
+ value: values,
63
+ displayValue: (0, _utils.getValueByValue)(field === null || field === void 0 ? void 0 : field.dataSource, values)
64
+ };
65
+ }
66
+
67
+ return displayValues;
68
+ };
69
+
28
70
  var useFormDisplayValues = function useFormDisplayValues() {
29
71
  var form = (0, _react.useForm)();
30
- var values = form.values; // 判断值的类型,递归获取每个值在该结构中的完整路径
31
-
32
- var getDisplayValues = function getDisplayValues(values) {
33
- var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
34
- var displayValues;
35
-
36
- if ((0, _utils.isPlainObj)(values)) {
37
- displayValues = {};
38
- Object.entries(values).forEach(function (_ref) {
39
- var _ref2 = _slicedToArray(_ref, 2),
40
- key = _ref2[0],
41
- value = _ref2[1];
42
-
43
- var path = prefix ? "".concat(prefix, ".").concat(key) : "".concat(key);
44
- displayValues[key] = getDisplayValues(value, path);
45
- });
46
- } else if ((0, _utils.isArr)(values)) {
47
- displayValues = [];
48
- values.map(function (value, index) {
49
- var path = prefix ? "".concat(prefix, ".").concat(index) : "".concat(index);
50
- displayValues[index] = getDisplayValues(value, path);
51
- });
52
- } else {
53
- // 通过值的完整路径获取字段address(从form实例的indexes中),然后获取该字段的value在该字段dataSource中对应的label
54
- var address = form.indexes[prefix];
55
- var field = form.query(address).take();
56
- displayValues = (0, _utils.getValueByValue)(field === null || field === void 0 ? void 0 : field.dataSource, values) || values;
57
- }
58
-
59
- return displayValues;
60
- }; // 测试样例
61
- // const example = {
62
- // a: [
63
- // [{ b: 'a.0.0.b', c: 'a.0.0.c' }, { d: 'a.0.1.d' }],
64
- // { e: [{ f: { g: [{ h: 'a.1.e.0.f.g.0.h' }] } }, 'a.1.e.1'] },
65
- // ],
66
- // };
67
- // console.log(getDisplayValues(example));
68
-
69
-
70
- return getDisplayValues(values);
72
+ return getDisplayValues(form, form.values);
73
+ };
74
+
75
+ exports.useFormDisplayValues = useFormDisplayValues;
76
+
77
+ var getFormDisplayValues = function getFormDisplayValues(form) {
78
+ return getDisplayValues(form, form.values);
71
79
  };
72
80
 
73
- var _default = useFormDisplayValues;
74
- exports.default = _default;
81
+ exports.getFormDisplayValues = getFormDisplayValues;
@@ -108,7 +108,8 @@ export { createForm, FormConsumer, FormDialog, FormDrawer, FormStep, FormTab, Fo
108
108
  /**
109
109
  * 导出 Filter 组件
110
110
  */
111
- import { AdvancedFilter, SimpleFilter, QueryFilter } from './Filter';
111
+ import { AdvancedFilter, SimpleFilter } from './Filter';
112
+ import { QueryFilter } from './Filter/index2';
112
113
  export { AdvancedFilter, SimpleFilter, QueryFilter };
113
114
  /**
114
115
  * 导出 ProForm 组件,支持快速搭建表单
package/lib/form/index.js CHANGED
@@ -71,7 +71,7 @@ Object.defineProperty(exports, "FormTab", {
71
71
  Object.defineProperty(exports, "QueryFilter", {
72
72
  enumerable: true,
73
73
  get: function get() {
74
- return _Filter.QueryFilter;
74
+ return _index.QueryFilter;
75
75
  }
76
76
  });
77
77
  Object.defineProperty(exports, "SimpleFilter", {
@@ -146,12 +146,14 @@ exports.formilyTeamix = _formilyTeamix;
146
146
 
147
147
  var originalFormilyReact = _interopRequireWildcard(require("@formily/react"));
148
148
 
149
- var _useFormDisplayValues = _interopRequireDefault(require("./ProForm/useFormDisplayValues"));
149
+ var _useFormDisplayValues = require("./ProForm/useFormDisplayValues");
150
150
 
151
151
  var _useFieldRequest = _interopRequireDefault(require("./ProForm/useFieldRequest"));
152
152
 
153
153
  var _Filter = require("./Filter");
154
154
 
155
+ var _index = require("./Filter/index2");
156
+
155
157
  var _ProForm = _interopRequireDefault(require("./ProForm"));
156
158
 
157
159
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -168,7 +170,7 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
168
170
 
169
171
  var formilyReact = _objectSpread(_objectSpread({}, originalFormilyReact), {}, {
170
172
  useFieldRequest: _useFieldRequest.default,
171
- useFormDisplayValues: _useFormDisplayValues.default
173
+ useFormDisplayValues: _useFormDisplayValues.useFormDisplayValues
172
174
  });
173
175
 
174
176
  exports.formilyReact = formilyReact;
@@ -2,6 +2,7 @@ import type { ReactNode } from 'react';
2
2
  import type { IFormFeedback, Form as FormType, FieldPatternTypes } from '@formily/core';
3
3
  import type { IFormLayoutProps } from '@teamix/formily';
4
4
  import { CommonRequestConfig } from '@teamix/utils';
5
+ import React from 'react';
5
6
  interface AnyObject {
6
7
  [propName: string]: any;
7
8
  }
@@ -64,6 +65,8 @@ export interface ProFormProps extends IFormLayoutProps {
64
65
  onSubmitFailed?: (feedbacks: IFormFeedback[]) => void;
65
66
  }
66
67
  export interface QueryFilterProps extends ProFormProps {
68
+ addonBefore?: ReactNode;
69
+ addonAfter?: ReactNode;
67
70
  onFilter?: (values: any) => void;
68
71
  onReset?: (payload?: any) => void;
69
72
  }
package/lib/index.d.ts CHANGED
@@ -21,5 +21,5 @@ export * from './page-container';
21
21
  export * from './page-header';
22
22
  export * from './skeleton';
23
23
  export * from './table';
24
- declare const version = "1.2.10";
24
+ declare const version = "1.2.11";
25
25
  export { version, ProAction, ProCard, ProField, ProForm, ProInfo, ProPageContainer, ProPageHeader, ProSkeleton, ProTable, hooks, nocode, templates, utils, };
package/lib/index.js CHANGED
@@ -253,5 +253,5 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
253
253
  _icon.default.setConfig(_utils.default.getTeamixIconConfig());
254
254
 
255
255
  // export * from './sidebar';
256
- var version = '1.2.10';
256
+ var version = '1.2.11';
257
257
  exports.version = version;
@@ -191,7 +191,7 @@ var Filter = function Filter(props) {
191
191
  btn: true
192
192
  }),
193
193
  onClick: function onClick() {
194
- var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge5, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current5, _actionRef$current5$s, _actionRef$current6, _actionRef$current6$r, _actionRef$current7, _actionRef$current7$r;
194
+ var _actionRef$current2, _actionRef$current2$f, _actionRef$current$ge5, _actionRef$current3, _actionRef$current3$g, _actionRef$current3$g2, _actionRef$current4, _actionRef$current5, _actionRef$current5$s, _actionRef$current6, _actionRef$current6$r, _actionRef$current7, _actionRef$current7$r, _actionRef$current8, _actionRef$current8$c;
195
195
 
196
196
  (_actionRef$current2 = actionRef.current) === null || _actionRef$current2 === void 0 ? void 0 : (_actionRef$current2$f = _actionRef$current2.filterDataSource) === null || _actionRef$current2$f === void 0 ? void 0 : _actionRef$current2$f.call(_actionRef$current2, column.dataIndex); // 先获取此列的param
197
197
 
@@ -234,7 +234,9 @@ var Filter = function Filter(props) {
234
234
  }))); // 发送请求
235
235
 
236
236
  (_actionRef$current6 = actionRef.current) === null || _actionRef$current6 === void 0 ? void 0 : (_actionRef$current6$r = _actionRef$current6.request) === null || _actionRef$current6$r === void 0 ? void 0 : _actionRef$current6$r.call(_actionRef$current6, _objectSpread(_objectSpread({}, params), {}, _defineProperty({}, targetPageKey, 1)));
237
- (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.resetPage) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7);
237
+ (_actionRef$current7 = actionRef.current) === null || _actionRef$current7 === void 0 ? void 0 : (_actionRef$current7$r = _actionRef$current7.resetPage) === null || _actionRef$current7$r === void 0 ? void 0 : _actionRef$current7$r.call(_actionRef$current7); // 清空表格选择
238
+
239
+ (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$c = _actionRef$current8.clearRowSelection) === null || _actionRef$current8$c === void 0 ? void 0 : _actionRef$current8$c.call(_actionRef$current8);
238
240
  setVisible(false);
239
241
  }
240
242
  }, (0, _utils.getMessage)('ok')), /*#__PURE__*/_react.default.createElement(_components.Button, {
@@ -244,15 +246,15 @@ var Filter = function Filter(props) {
244
246
  btn: true
245
247
  }),
246
248
  onClick: function onClick() {
247
- var _actionRef$current$ge6, _actionRef$current8, _actionRef$current8$g, _actionRef$current8$g2, _actionRef$current9, _actionRef$current9$s, _actionRef$current10, _actionRef$current10$;
249
+ var _actionRef$current$ge6, _actionRef$current9, _actionRef$current9$g, _actionRef$current9$g2, _actionRef$current10, _actionRef$current10$, _actionRef$current11, _actionRef$current11$;
248
250
 
249
251
  setSelected([]);
250
- var rules = (_actionRef$current$ge6 = (_actionRef$current8 = actionRef.current) === null || _actionRef$current8 === void 0 ? void 0 : (_actionRef$current8$g = _actionRef$current8.getState) === null || _actionRef$current8$g === void 0 ? void 0 : (_actionRef$current8$g2 = _actionRef$current8$g.call(_actionRef$current8)) === null || _actionRef$current8$g2 === void 0 ? void 0 : _actionRef$current8$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
251
- (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$s = _actionRef$current9.setFilterRules) === null || _actionRef$current9$s === void 0 ? void 0 : _actionRef$current9$s.call(_actionRef$current9, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
252
+ var rules = (_actionRef$current$ge6 = (_actionRef$current9 = actionRef.current) === null || _actionRef$current9 === void 0 ? void 0 : (_actionRef$current9$g = _actionRef$current9.getState) === null || _actionRef$current9$g === void 0 ? void 0 : (_actionRef$current9$g2 = _actionRef$current9$g.call(_actionRef$current9)) === null || _actionRef$current9$g2 === void 0 ? void 0 : _actionRef$current9$g2.filterRules) !== null && _actionRef$current$ge6 !== void 0 ? _actionRef$current$ge6 : {};
253
+ (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.setFilterRules) === null || _actionRef$current10$ === void 0 ? void 0 : _actionRef$current10$.call(_actionRef$current10, _objectSpread(_objectSpread({}, rules), {}, _defineProperty({}, column.dataIndex, {
252
254
  rules: [],
253
255
  params: ''
254
256
  })));
255
- (_actionRef$current10 = actionRef.current) === null || _actionRef$current10 === void 0 ? void 0 : (_actionRef$current10$ = _actionRef$current10.filterDataSource) === null || _actionRef$current10$ === void 0 ? void 0 : _actionRef$current10$.call(_actionRef$current10, column.dataIndex); // setVisible(!visible);
257
+ (_actionRef$current11 = actionRef.current) === null || _actionRef$current11 === void 0 ? void 0 : (_actionRef$current11$ = _actionRef$current11.filterDataSource) === null || _actionRef$current11$ === void 0 ? void 0 : _actionRef$current11$.call(_actionRef$current11, column.dataIndex); // setVisible(!visible);
256
258
  }
257
259
  }, (0, _utils.getMessage)('reset'))))));
258
260
  };
@@ -12,12 +12,16 @@
12
12
  }
13
13
  .teamix-pro-table-toolbar-filter-btn-box {
14
14
  display: flex;
15
- justify-content: space-around;
15
+ justify-content: center;
16
16
  margin-top: 10px;
17
17
  padding-bottom: 5px;
18
+ padding-left: 4px;
19
+ padding-right: 4px;
18
20
  }
19
21
  .teamix-pro-table-toolbar-filter-btn.teamix-pro-table-toolbar-filter-btn {
20
- width: 48px !important;
21
- min-width: unset !important;
22
+ min-width: 48px !important;
23
+ &:first-child {
24
+ margin-right: 8px;
25
+ }
22
26
  }
23
27
  }
@@ -92,7 +92,16 @@ var Layout = function Layout(props) {
92
92
  var _mainAction$actions;
93
93
 
94
94
  if (_typeof(mainAction) === 'object' && (mainAction === null || mainAction === void 0 ? void 0 : (_mainAction$actions = mainAction.actions) === null || _mainAction$actions === void 0 ? void 0 : _mainAction$actions.length) > 0) {
95
- // 默认 context
95
+ // 判断 actions 是否 visible 都为 false,是的话也不渲染
96
+ var isEmptyActions = mainAction === null || mainAction === void 0 ? void 0 : mainAction.actions.every(function (action) {
97
+ return (action === null || action === void 0 ? void 0 : action.visible) === false;
98
+ });
99
+
100
+ if (isEmptyActions) {
101
+ return;
102
+ } // 默认 context
103
+
104
+
96
105
  var defaultContext = {
97
106
  action: actionRef.current,
98
107
  rowSelection: rowSelection