@nokecy/qc-ui 0.4.8 → 0.5.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.
Files changed (92) hide show
  1. package/dist/esm/ag-grid-plus/_utils/boolSelect.js +49 -0
  2. package/dist/esm/ag-grid-plus/ag-grid-theme-builder.css +404 -0
  3. package/dist/esm/ag-grid-plus/ag-gridPlus.js +472 -0
  4. package/dist/esm/ag-grid-plus/context/gridContext.js +6 -0
  5. package/dist/esm/ag-grid-plus/gridManager/index.js +35 -0
  6. package/dist/esm/ag-grid-plus/index.js +10 -0
  7. package/dist/esm/ag-grid-plus/index.less +7 -0
  8. package/dist/esm/ag-grid-plus/interface.js +9 -0
  9. package/dist/esm/ag-grid-plus/queryForm/index.js +175 -0
  10. package/dist/esm/ag-grid-plus/queryForm/index.less +48 -0
  11. package/dist/esm/ag-grid-plus/queryForm/queryForm.js +84 -0
  12. package/dist/esm/ag-grid-plus/setting/index.js +198 -0
  13. package/dist/esm/ag-grid-plus/settingItem/index.js +15 -0
  14. package/dist/esm/ag-grid-plus/toolBar/index.js +171 -0
  15. package/dist/esm/ag-grid-plus/utils.js +137 -0
  16. package/dist/esm/array-table/arrayAddBtn.js +56 -0
  17. package/dist/esm/array-table/arrayBase.js +217 -0
  18. package/dist/esm/array-table/index.js +145 -0
  19. package/dist/esm/array-table/interface.js +1 -0
  20. package/dist/esm/array-table/preview.js +49 -0
  21. package/dist/esm/array-table/utils.js +124 -0
  22. package/dist/esm/array-table-index/index.js +10 -0
  23. package/dist/esm/dashboard/dashboard/components/index.js +2 -0
  24. package/dist/esm/dashboard/dashboard/components/modal/index.js +15 -0
  25. package/dist/esm/dashboard/dashboard/components/toolbar/index.js +22 -0
  26. package/dist/esm/dashboard/dashboard/components/toolbar/style/index.js +1 -0
  27. package/dist/esm/dashboard/dashboard/components/toolbar/style/index.less +49 -0
  28. package/dist/esm/dashboard/dashboard/index.js +525 -0
  29. package/dist/esm/dashboard/dashboard/index.less +173 -0
  30. package/dist/esm/dashboard/dashboard/service.js +86 -0
  31. package/dist/esm/dashboard/dashboard/utils.js +89 -0
  32. package/dist/esm/dashboard/index.js +3 -0
  33. package/dist/esm/dashboard/utils.js +125 -0
  34. package/dist/esm/dashboard/widget/index.js +47 -0
  35. package/dist/esm/dashboard/widget/index.less +7 -0
  36. package/dist/esm/dashboard/widget/selector/index.js +234 -0
  37. package/dist/esm/dashboard/widget/selector/index.less +172 -0
  38. package/dist/esm/dashboard/widget/utils.js +89 -0
  39. package/dist/esm/dialogSelect/index.js +70 -0
  40. package/dist/esm/dialogSelect/interface.js +0 -0
  41. package/dist/esm/dialogSelect/selectModal.js +138 -0
  42. package/dist/esm/editable/index.js +241 -0
  43. package/dist/esm/editable/style.js +46 -0
  44. package/dist/esm/extensible-grid/index.js +22 -0
  45. package/dist/esm/extensible-grid/interface.js +1 -0
  46. package/dist/esm/formDesigner/FormDesigner.js +222 -0
  47. package/dist/esm/formDesigner/ProCard/index.js +21 -0
  48. package/dist/esm/formDesigner/arrayTable/arrayTableSchema.js +106 -0
  49. package/dist/esm/formDesigner/arrayTable/index.js +1 -0
  50. package/dist/esm/formDesigner/arrayTable/preview.js +390 -0
  51. package/dist/esm/formDesigner/arrayTable/styles.less +3 -0
  52. package/dist/esm/formDesigner/index.js +2 -0
  53. package/dist/esm/formDesigner/index.less +3 -0
  54. package/dist/esm/formDesigner/preWidgets/arrayTableIndex/index.js +1 -0
  55. package/dist/esm/formDesigner/preWidgets/arrayTableIndex/preview.js +40 -0
  56. package/dist/esm/formDesigner/preWidgets/card/index.js +1 -0
  57. package/dist/esm/formDesigner/preWidgets/card/preview.js +38 -0
  58. package/dist/esm/formDesigner/preWidgets/index.js +12 -0
  59. package/dist/esm/formDesigner/preWidgets/preDefineProperty1/index.js +1 -0
  60. package/dist/esm/formDesigner/preWidgets/preDefineProperty1/preview.js +44 -0
  61. package/dist/esm/formDesigner/preWidgets/preDefineProperty10/index.js +1 -0
  62. package/dist/esm/formDesigner/preWidgets/preDefineProperty10/preview.js +43 -0
  63. package/dist/esm/formDesigner/preWidgets/preDefineProperty2/index.js +1 -0
  64. package/dist/esm/formDesigner/preWidgets/preDefineProperty2/preview.js +43 -0
  65. package/dist/esm/formDesigner/preWidgets/preDefineProperty3/index.js +1 -0
  66. package/dist/esm/formDesigner/preWidgets/preDefineProperty3/preview.js +43 -0
  67. package/dist/esm/formDesigner/preWidgets/preDefineProperty4/index.js +1 -0
  68. package/dist/esm/formDesigner/preWidgets/preDefineProperty4/preview.js +43 -0
  69. package/dist/esm/formDesigner/preWidgets/preDefineProperty5/index.js +1 -0
  70. package/dist/esm/formDesigner/preWidgets/preDefineProperty5/preview.js +43 -0
  71. package/dist/esm/formDesigner/preWidgets/preDefineProperty6/index.js +1 -0
  72. package/dist/esm/formDesigner/preWidgets/preDefineProperty6/preview.js +43 -0
  73. package/dist/esm/formDesigner/preWidgets/preDefineProperty7/index.js +1 -0
  74. package/dist/esm/formDesigner/preWidgets/preDefineProperty7/preview.js +43 -0
  75. package/dist/esm/formDesigner/preWidgets/preDefineProperty8/index.js +1 -0
  76. package/dist/esm/formDesigner/preWidgets/preDefineProperty8/preview.js +43 -0
  77. package/dist/esm/formDesigner/preWidgets/preDefineProperty9/index.js +1 -0
  78. package/dist/esm/formDesigner/preWidgets/preDefineProperty9/preview.js +43 -0
  79. package/dist/esm/formDesigner/preWidgets/utils.js +219 -0
  80. package/dist/esm/formDesigner/widgets/ActionsWidget.js +29 -0
  81. package/dist/esm/formDesigner/widgets/LogoWidget.js +24 -0
  82. package/dist/esm/formDesigner/widgets/PreviewWidget.js +33 -0
  83. package/dist/esm/formDesigner/widgets/SchemaEditorWidget.js +17 -0
  84. package/dist/esm/formDesigner/widgets/index.js +4 -0
  85. package/dist/esm/formPro/context/formProContext.js +5 -0
  86. package/dist/esm/formPro/formLayoutPro.js +41 -0
  87. package/dist/esm/formPro/index.js +2 -0
  88. package/dist/esm/index.js +12 -0
  89. package/dist/esm/type.d.ts +1 -0
  90. package/dist/umd/qc-ui.min.css +1 -0
  91. package/dist/umd/qc-ui.min.js +1 -0
  92. package/package.json +1 -1
@@ -0,0 +1,175 @@
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
+ import { DatePicker, FormButtonGroup, FormGrid, FormItem, Form, Input, Submit } from '@formily/antd-v5';
14
+ import { createForm } from '@formily/core';
15
+ import { onFieldInit } from '@formily/core';
16
+ import { createSchemaField } from '@formily/react';
17
+ import { Button } from 'antd';
18
+ import classNames from 'classnames';
19
+ import React, { useEffect, useMemo, useState } from 'react';
20
+ import QueryForm from "./queryForm";
21
+ import BoolSelect from "../_utils/boolSelect";
22
+ import "./index.less";
23
+ var FormRender = function FormRender(props) {
24
+ var className = props.className,
25
+ gridApi = props.gridApi,
26
+ colDefs = props.colDefs,
27
+ columnStates = props.columnStates,
28
+ onQuery = props.onQuery;
29
+ var _useState = useState({
30
+ type: 'object',
31
+ properties: {}
32
+ }),
33
+ _useState2 = _slicedToArray(_useState, 2),
34
+ schema = _useState2[0],
35
+ setSchema = _useState2[1];
36
+ var form = useMemo(function () {
37
+ return createForm({
38
+ effects: function effects() {
39
+ return [onFieldInit('queryForm', function (field) {
40
+ field.query('queryForm').take(function (node) {
41
+ node.setComponentProps({
42
+ onReset: onReset
43
+ });
44
+ });
45
+ })];
46
+ }
47
+ });
48
+ }, []);
49
+ var SchemaField = useMemo(function () {
50
+ return createSchemaField({
51
+ components: {
52
+ QueryForm: QueryForm,
53
+ Input: Input,
54
+ DatePicker: DatePicker,
55
+ FormItem: FormItem,
56
+ FormGrid: FormGrid,
57
+ FormButtonGroup: FormButtonGroup,
58
+ Submit: Submit,
59
+ Button: Button,
60
+ BoolSelect: BoolSelect
61
+ }
62
+ });
63
+ }, [schema]);
64
+ var onSubmit = function onSubmit() {
65
+ onQuery && onQuery(form.values);
66
+ };
67
+ var onReset = function onReset() {
68
+ form.reset();
69
+ onQuery({});
70
+ };
71
+ var getComponent = function getComponent(colDef) {
72
+ var component = colDef.searchComponent ? colDef.searchComponent : undefined;
73
+ if (component) {
74
+ return component;
75
+ } else {
76
+ switch (colDef.filter) {
77
+ case "agDateColumnFilter":
78
+ component = "DatePicker.RangePicker";
79
+ break;
80
+ case "boolFilter":
81
+ component = "BoolSelect";
82
+ break;
83
+ }
84
+ switch (colDef.type) {
85
+ case "dateTimeColumn":
86
+ case "dateColumn":
87
+ component = "DatePicker.RangePicker";
88
+ break;
89
+ case "boolColumn":
90
+ component = "BoolSelect";
91
+ break;
92
+ }
93
+ return component ? component : "Input";
94
+ }
95
+ };
96
+ var getSchema = function getSchema(reset) {
97
+ var _columns, _columns2;
98
+ var rootSchema = {
99
+ type: 'object',
100
+ properties: {}
101
+ };
102
+ if (!columnStates) {
103
+ return rootSchema;
104
+ }
105
+ var gridSchema = {
106
+ type: 'void',
107
+ "name": 'queryForm',
108
+ "x-component": 'QueryForm',
109
+ properties: {}
110
+ };
111
+ var columns = colDefs === null || colDefs === void 0 ? void 0 : colDefs.map(function (colDef) {
112
+ var state = columnStates.find(function (x) {
113
+ return x.colId == colDef.field;
114
+ });
115
+ var columnDefs = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(colDef.field);
116
+ return _objectSpread(_objectSpread(_objectSpread({}, colDef), columnDefs), state);
117
+ });
118
+ columns = columns ? (_columns = columns) === null || _columns === void 0 ? void 0 : _columns.filter(function (i) {
119
+ return (i === null || i === void 0 ? void 0 : i.visible) != false && !(i !== null && i !== void 0 && i.hide) && !(i !== null && i !== void 0 && i.hideInSearch) || (i === null || i === void 0 ? void 0 : i.hideInTable);
120
+ }) : [];
121
+ columns.map(function (col) {
122
+ var _colDef$queryField;
123
+ var colDef = col;
124
+ var name = (_colDef$queryField = colDef.queryField) !== null && _colDef$queryField !== void 0 ? _colDef$queryField : colDef.field;
125
+ var headerName = colDef.headerName;
126
+ //表单自定义组件
127
+ var component = getComponent(colDef);
128
+ if (colDef.filter != false) {
129
+ var _colDef$searchCompone, _colDef$searchCompone2;
130
+ var filedSchema = {
131
+ type: 'string',
132
+ title: headerName,
133
+ required: (colDef === null || colDef === void 0 || (_colDef$searchCompone = colDef.searchComponentProps) === null || _colDef$searchCompone === void 0 ? void 0 : _colDef$searchCompone.required) || false,
134
+ default: colDef === null || colDef === void 0 || (_colDef$searchCompone2 = colDef.searchComponentProps) === null || _colDef$searchCompone2 === void 0 ? void 0 : _colDef$searchCompone2.default,
135
+ "x-component": component,
136
+ "x-component-props": _objectSpread({
137
+ placeholder: "\u8BF7\u8F93\u5165".concat(headerName),
138
+ allowClear: true,
139
+ style: {
140
+ maxWidth: 200
141
+ }
142
+ }, colDef === null || colDef === void 0 ? void 0 : colDef.searchComponentProps),
143
+ "x-decorator": 'FormItem',
144
+ "x-decorator-props": {
145
+ wrapperWrap: true
146
+ }
147
+ };
148
+ ///@ts-ignore
149
+ gridSchema.properties[name] = filedSchema;
150
+ }
151
+ });
152
+ ///@ts-ignore
153
+ rootSchema.properties["queryForm"] = gridSchema;
154
+ if (!((_columns2 = columns) !== null && _columns2 !== void 0 && _columns2.length)) {
155
+ ///@ts-ignore
156
+ delete rootSchema.properties["queryForm"];
157
+ }
158
+ return rootSchema;
159
+ };
160
+ useEffect(function () {
161
+ var new_schema = getSchema(onReset);
162
+ setSchema(new_schema);
163
+ }, [JSON.stringify(columnStates)]);
164
+ return /*#__PURE__*/React.createElement("div", {
165
+ className: classNames(className, "ag-grid-table-search ag-grid-table-search-query-filter")
166
+ }, /*#__PURE__*/React.createElement(Form, {
167
+ form: form,
168
+ labelWidth: 100,
169
+ feedbackLayout: "none",
170
+ onAutoSubmit: onSubmit
171
+ }, /*#__PURE__*/React.createElement(SchemaField, {
172
+ schema: schema
173
+ })));
174
+ };
175
+ export default FormRender;
@@ -0,0 +1,48 @@
1
+
2
+ @pro-table-search-prefix-cls: ~'ag-grid-table-search';
3
+
4
+ @pro-table-form-prefix-cls: ~'ag-grid-table-form';
5
+
6
+ .@{pro-table-search-prefix-cls} {
7
+ margin-bottom: 8px;
8
+ padding: 8px;
9
+ // padding-bottom: 0;
10
+ background-color: #fff;
11
+
12
+ &.@{pro-table-form-prefix-cls} {
13
+ margin: 0;
14
+ padding: 0 16px;
15
+ overflow: unset;
16
+ }
17
+
18
+ &-light {
19
+ margin-bottom: 0;
20
+ padding: 16px 0;
21
+ }
22
+
23
+ &-form-option {
24
+ .ant-form-item {
25
+ margin: 0;
26
+ }
27
+
28
+ .ant-form-item-label {
29
+ opacity: 0;
30
+ }
31
+
32
+ .ant-form-item-control-input {
33
+ justify-content: flex-start;
34
+ }
35
+ }
36
+ }
37
+
38
+ @media (max-width: 575px) {
39
+ .@{pro-table-search-prefix-cls} {
40
+ height: auto !important;
41
+ padding-bottom: 24px;
42
+
43
+ .ant-form-item-label {
44
+ min-width: 80px;
45
+ text-align: left;
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,84 @@
1
+ import React, { useMemo, Fragment } from 'react';
2
+ import { FormGrid, Submit, FormButtonGroup } from '@formily/antd-v5';
3
+ import { DownOutlined } from '@ant-design/icons';
4
+ import { Button } from 'antd';
5
+ import { observer } from '@formily/react';
6
+ var useCollapseGrid = function useCollapseGrid(maxRows) {
7
+ var grid = useMemo(function () {
8
+ return FormGrid.createFormGrid({
9
+ maxColumns: 5,
10
+ maxWidth: 240,
11
+ maxRows: maxRows,
12
+ shouldVisible: function shouldVisible(node, grid) {
13
+ if (node.index === grid.childSize - 1) return true;
14
+ if (grid.maxRows === Infinity) return true;
15
+ return node.shadowRow < maxRows + 1 && node.index < grid.maxColumns - 1;
16
+ }
17
+ });
18
+ }, []);
19
+ var expanded = grid.maxRows === Infinity;
20
+ var realRows = grid.shadowRows;
21
+ var computeRows = grid.fullnessLastColumn ? grid.shadowRows - 1 : grid.shadowRows;
22
+ var toggle = function toggle() {
23
+ if (grid.maxRows === Infinity) {
24
+ grid.maxRows = maxRows;
25
+ } else {
26
+ grid.maxRows = Infinity;
27
+ }
28
+ };
29
+ var takeType = function takeType() {
30
+ if (realRows < maxRows + 1) return 'incomplete-wrap';
31
+ if (computeRows > maxRows) return 'collapsible';
32
+ return 'complete-wrap';
33
+ };
34
+ return {
35
+ grid: grid,
36
+ expanded: expanded,
37
+ toggle: toggle,
38
+ type: takeType()
39
+ };
40
+ };
41
+ var QueryForm = observer(function (props) {
42
+ var onReset = props.onReset;
43
+ var _useCollapseGrid = useCollapseGrid(1),
44
+ grid = _useCollapseGrid.grid,
45
+ expanded = _useCollapseGrid.expanded,
46
+ toggle = _useCollapseGrid.toggle,
47
+ type = _useCollapseGrid.type;
48
+ var renderActions = function renderActions() {
49
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Submit, null, "\u67E5\u8BE2"), /*#__PURE__*/React.createElement(Button, {
50
+ onClick: onReset
51
+ }, "\u91CD\u7F6E"));
52
+ };
53
+ var renderExpanded = function renderExpanded() {
54
+ return /*#__PURE__*/React.createElement("a", {
55
+ onClick: function onClick(e) {
56
+ e.preventDefault();
57
+ toggle();
58
+ }
59
+ }, /*#__PURE__*/React.createElement(React.Fragment, null, expanded ? '收起' : '展开', /*#__PURE__*/React.createElement(DownOutlined, {
60
+ style: {
61
+ marginLeft: '0.5em',
62
+ transition: '0.3s all',
63
+ transform: "rotate(".concat(expanded ? 0 : 0.5, "turn)")
64
+ }
65
+ })));
66
+ };
67
+ var renderButtonGroup = function renderButtonGroup() {
68
+ return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(FormButtonGroup, {
69
+ align: "right"
70
+ }, renderActions(), type === 'collapsible' ? renderExpanded() : null));
71
+ };
72
+ return /*#__PURE__*/React.createElement(FormGrid, {
73
+ grid: grid,
74
+ colWrap: true,
75
+ strictAutoFit: true
76
+ }, props.children, /*#__PURE__*/React.createElement(FormGrid.GridColumn, {
77
+ gridSpan: -1,
78
+ style: {
79
+ display: 'flex',
80
+ justifyContent: 'right'
81
+ }
82
+ }, renderButtonGroup()));
83
+ });
84
+ export default QueryForm;
@@ -0,0 +1,198 @@
1
+ import _uniqueId from "lodash/uniqueId";
2
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
3
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
4
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
5
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
6
+ 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; }
7
+ 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; }
8
+ 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; }
9
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
10
+ 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); }
11
+ import { ArrayTable, FormDialog, FormGrid, FormItem, FormLayout, FormTab, Input, Select, Space, NumberPicker, Switch } from '@formily/antd-v5';
12
+ import { createSchemaField } from '@formily/react';
13
+ import { onFormInit } from '@formily/core';
14
+ import React, { useMemo } from "react";
15
+ import { SettingOutlined } from '@ant-design/icons';
16
+ import { jsx as _jsx } from "react/jsx-runtime";
17
+ import { jsxs as _jsxs } from "react/jsx-runtime";
18
+ var Setting = function Setting(props) {
19
+ var gridKey = props.gridKey,
20
+ gridApi = props.gridApi,
21
+ onSaveColumnState = props.onSaveColumnState;
22
+ var SchemaField = useMemo(function () {
23
+ return createSchemaField({
24
+ components: {
25
+ FormTab: FormTab,
26
+ FormItem: FormItem,
27
+ FormGrid: FormGrid,
28
+ Space: Space,
29
+ Input: Input,
30
+ Select: Select,
31
+ ArrayTable: ArrayTable,
32
+ NumberPicker: NumberPicker,
33
+ Switch: Switch
34
+ }
35
+ });
36
+ }, []);
37
+ var formProps = {
38
+ effects: function effects() {
39
+ onFormInit(function (form) {
40
+ form.setInitialValuesIn('items', getColumnData());
41
+ });
42
+ }
43
+ };
44
+ var getColumnData = function getColumnData() {
45
+ var columnStates = gridApi.getColumnState();
46
+ var columnRowData = [];
47
+ var columns = columnStates.map(function (columnState) {
48
+ var colDef = gridApi === null || gridApi === void 0 ? void 0 : gridApi.getColumnDef(columnState.colId);
49
+ columnRowData.push(_objectSpread({
50
+ field: colDef.field,
51
+ headerName: colDef.headerName,
52
+ width: columnState.width,
53
+ hide: columnState.hide
54
+ }, columnState));
55
+ });
56
+ return columnRowData;
57
+ };
58
+ var portalId = "workProcedure".concat(_uniqueId());
59
+ if (!gridKey) {
60
+ return null;
61
+ }
62
+ return /*#__PURE__*/_jsx(FormDialog.Portal, {
63
+ id: portalId,
64
+ children: /*#__PURE__*/_jsx("div", {
65
+ style: {
66
+ margin: "0 4px",
67
+ color: "#000",
68
+ fontSize: 16,
69
+ cursor: "pointer"
70
+ },
71
+ onClick: /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
72
+ var formDialog;
73
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
74
+ while (1) switch (_context.prev = _context.next) {
75
+ case 0:
76
+ formDialog = FormDialog({
77
+ title: "个性化设置",
78
+ width: 960
79
+ }, portalId, function () {
80
+ return /*#__PURE__*/_jsx(FormLayout, {
81
+ children: /*#__PURE__*/_jsx(SchemaField, {
82
+ children: /*#__PURE__*/_jsx(SchemaField.Void, {
83
+ "x-component": "FormGrid",
84
+ "x-component-props": {
85
+ maxColumns: [1, 3],
86
+ strictAutoFit: true
87
+ },
88
+ children: /*#__PURE__*/_jsx(SchemaField.Array, {
89
+ name: "items",
90
+ title: "",
91
+ "x-component": "ArrayTable",
92
+ "x-validator": [{
93
+ message: ""
94
+ }],
95
+ "x-decorator": "FormItem",
96
+ "x-decorator-props": {
97
+ gridSpan: 3
98
+ },
99
+ children: /*#__PURE__*/_jsxs(SchemaField.Object, {
100
+ children: [/*#__PURE__*/_jsx(SchemaField.Void, {
101
+ "x-component": "ArrayTable.Column",
102
+ "x-component-props": {
103
+ width: 100,
104
+ title: "列名"
105
+ },
106
+ children: /*#__PURE__*/_jsx(SchemaField.String, {
107
+ name: "headerName",
108
+ "x-decorator": "FormItem",
109
+ "x-component": "Input",
110
+ "x-read-pretty": true
111
+ })
112
+ }), /*#__PURE__*/_jsx(SchemaField.Void, {
113
+ "x-component": "ArrayTable.Column",
114
+ "x-component-props": {
115
+ width: 100,
116
+ title: "宽度"
117
+ },
118
+ children: /*#__PURE__*/_jsx(SchemaField.String, {
119
+ name: "width",
120
+ "x-decorator": "FormItem",
121
+ "x-component": "NumberPicker"
122
+ })
123
+ }), /*#__PURE__*/_jsx(SchemaField.Void, {
124
+ "x-component": "ArrayTable.Column",
125
+ "x-component-props": {
126
+ width: 100,
127
+ title: "占满"
128
+ },
129
+ children: /*#__PURE__*/_jsx(SchemaField.String, {
130
+ name: "flex",
131
+ "x-decorator": "FormItem",
132
+ "x-component": "Select",
133
+ enum: [{
134
+ value: 1,
135
+ label: "占满"
136
+ }, {
137
+ value: 0,
138
+ label: "不占满"
139
+ }]
140
+ })
141
+ }), /*#__PURE__*/_jsx(SchemaField.Void, {
142
+ "x-component": "ArrayTable.Column",
143
+ "x-component-props": {
144
+ width: 100,
145
+ title: '固定位置'
146
+ },
147
+ children: /*#__PURE__*/_jsx(SchemaField.String, {
148
+ name: "pinned",
149
+ "x-decorator": "FormItem",
150
+ "x-component": "Select",
151
+ enum: [{
152
+ value: "left",
153
+ label: "左固定"
154
+ }, {
155
+ value: "right",
156
+ label: "右固定"
157
+ }, {
158
+ value: undefined,
159
+ label: "不固定"
160
+ }]
161
+ })
162
+ }), /*#__PURE__*/_jsx(SchemaField.Void, {
163
+ "x-component": "ArrayTable.Column",
164
+ "x-component-props": {
165
+ title: '隐藏'
166
+ },
167
+ children: /*#__PURE__*/_jsx(SchemaField.String, {
168
+ name: "hide",
169
+ "x-decorator": "FormItem",
170
+ "x-component": "Switch"
171
+ })
172
+ })]
173
+ })
174
+ })
175
+ })
176
+ })
177
+ });
178
+ });
179
+ formDialog.forConfirm(function (payload, next) {
180
+ var values = payload.values;
181
+ var falg = gridApi.applyColumnState({
182
+ state: values.items,
183
+ applyOrder: true
184
+ });
185
+ onSaveColumnState && onSaveColumnState(values.items);
186
+ next(payload);
187
+ }).open(formProps);
188
+ case 2:
189
+ case "end":
190
+ return _context.stop();
191
+ }
192
+ }, _callee);
193
+ })),
194
+ children: /*#__PURE__*/_jsx(SettingOutlined, {})
195
+ })
196
+ });
197
+ };
198
+ export default Setting;
@@ -0,0 +1,15 @@
1
+ import React from 'react';
2
+ var SettingItem = function SettingItem(props) {
3
+ var onClick = props.onClick,
4
+ icon = props.icon;
5
+ return /*#__PURE__*/React.createElement("div", {
6
+ style: {
7
+ margin: "0 4px",
8
+ color: "#000",
9
+ fontSize: 16,
10
+ cursor: "pointer"
11
+ },
12
+ onClick: onClick
13
+ }, icon);
14
+ };
15
+ export default SettingItem;