tntd 3.0.34-beta.3 → 3.0.34-beta.5

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 (118) hide show
  1. package/es/form/style/index.less +5 -5
  2. package/es/query-form/Field/Composition/index.js +25 -2
  3. package/es/query-form/Field/Composition/index.js.map +1 -1
  4. package/es/query-form/index.js +16 -15
  5. package/es/query-form/index.js.map +1 -1
  6. package/es/query-list-scene/QueryForm.js +9 -14
  7. package/es/query-list-scene/QueryForm.js.map +1 -1
  8. package/lib/form/style/index.less +5 -5
  9. package/lib/query-form/Field/Composition/index.js +29 -5
  10. package/lib/query-form/Field/Composition/index.js.map +1 -1
  11. package/lib/query-form/index.d.ts +1 -28
  12. package/lib/query-form/index.d.ts.map +1 -1
  13. package/lib/query-form/index.js +16 -13
  14. package/lib/query-form/index.js.map +1 -1
  15. package/lib/query-form-v2/Field/Checkbox.d.ts +8 -0
  16. package/lib/query-form-v2/Field/Checkbox.d.ts.map +1 -0
  17. package/lib/query-form-v2/Field/Checkbox.js +28 -0
  18. package/lib/query-form-v2/Field/Checkbox.js.map +1 -0
  19. package/lib/query-form-v2/Field/Select.d.ts +4 -0
  20. package/lib/query-form-v2/Field/Select.d.ts.map +1 -0
  21. package/lib/query-form-v2/Field/Select.js +80 -0
  22. package/lib/query-form-v2/Field/Select.js.map +1 -0
  23. package/lib/query-form-v2/Field/SelectInput.d.ts +4 -0
  24. package/lib/query-form-v2/Field/SelectInput.d.ts.map +1 -0
  25. package/lib/query-form-v2/Field/SelectInput.js +88 -0
  26. package/lib/query-form-v2/Field/SelectInput.js.map +1 -0
  27. package/lib/query-form-v2/Field/fieldsMap.d.ts +24 -0
  28. package/lib/query-form-v2/Field/fieldsMap.d.ts.map +1 -0
  29. package/lib/query-form-v2/Field/fieldsMap.js +35 -0
  30. package/lib/query-form-v2/Field/fieldsMap.js.map +1 -0
  31. package/lib/query-form-v2/Field/index.d.ts +14 -0
  32. package/lib/query-form-v2/Field/index.d.ts.map +1 -0
  33. package/lib/query-form-v2/Field/index.js +146 -0
  34. package/lib/query-form-v2/Field/index.js.map +1 -0
  35. package/lib/query-form-v2/createActions.d.ts +14 -0
  36. package/lib/query-form-v2/createActions.d.ts.map +1 -0
  37. package/lib/query-form-v2/createActions.js +54 -0
  38. package/lib/query-form-v2/createActions.js.map +1 -0
  39. package/lib/query-form-v2/index.d.ts +39 -0
  40. package/lib/query-form-v2/index.d.ts.map +1 -0
  41. package/lib/query-form-v2/index.js +391 -0
  42. package/lib/query-form-v2/index.js.map +1 -0
  43. package/lib/query-form-v2/useForm.d.ts +13 -0
  44. package/lib/query-form-v2/useForm.d.ts.map +1 -0
  45. package/lib/query-form-v2/useForm.js +13 -0
  46. package/lib/query-form-v2/useForm.js.map +1 -0
  47. package/lib/query-form-v3/Field/Checkbox.d.ts +8 -0
  48. package/lib/query-form-v3/Field/Checkbox.d.ts.map +1 -0
  49. package/lib/query-form-v3/Field/Checkbox.js +28 -0
  50. package/lib/query-form-v3/Field/Checkbox.js.map +1 -0
  51. package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts +19 -0
  52. package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts.map +1 -0
  53. package/lib/query-form-v3/Field/Composition/FieldPopover.js +381 -0
  54. package/lib/query-form-v3/Field/Composition/FieldPopover.js.map +1 -0
  55. package/lib/query-form-v3/Field/Composition/FieldPopover.less +35 -0
  56. package/lib/query-form-v3/Field/Composition/Select.d.ts +4 -0
  57. package/lib/query-form-v3/Field/Composition/Select.d.ts.map +1 -0
  58. package/lib/query-form-v3/Field/Composition/Select.js +131 -0
  59. package/lib/query-form-v3/Field/Composition/Select.js.map +1 -0
  60. package/lib/query-form-v3/Field/Composition/index.d.ts +10 -0
  61. package/lib/query-form-v3/Field/Composition/index.d.ts.map +1 -0
  62. package/lib/query-form-v3/Field/Composition/index.js +255 -0
  63. package/lib/query-form-v3/Field/Composition/index.js.map +1 -0
  64. package/lib/query-form-v3/Field/Composition/index.less +118 -0
  65. package/lib/query-form-v3/Field/Composition/utils.d.ts +22 -0
  66. package/lib/query-form-v3/Field/Composition/utils.d.ts.map +1 -0
  67. package/lib/query-form-v3/Field/Composition/utils.js +147 -0
  68. package/lib/query-form-v3/Field/Composition/utils.js.map +1 -0
  69. package/lib/query-form-v3/Field/Select.d.ts +4 -0
  70. package/lib/query-form-v3/Field/Select.d.ts.map +1 -0
  71. package/lib/query-form-v3/Field/Select.js +80 -0
  72. package/lib/query-form-v3/Field/Select.js.map +1 -0
  73. package/lib/query-form-v3/Field/SelectInput.d.ts +4 -0
  74. package/lib/query-form-v3/Field/SelectInput.d.ts.map +1 -0
  75. package/lib/query-form-v3/Field/SelectInput.js +100 -0
  76. package/lib/query-form-v3/Field/SelectInput.js.map +1 -0
  77. package/lib/query-form-v3/Field/fieldsMap.d.ts +27 -0
  78. package/lib/query-form-v3/Field/fieldsMap.d.ts.map +1 -0
  79. package/lib/query-form-v3/Field/fieldsMap.js +35 -0
  80. package/lib/query-form-v3/Field/fieldsMap.js.map +1 -0
  81. package/lib/query-form-v3/Field/index.d.ts +14 -0
  82. package/lib/query-form-v3/Field/index.d.ts.map +1 -0
  83. package/lib/query-form-v3/Field/index.js +147 -0
  84. package/lib/query-form-v3/Field/index.js.map +1 -0
  85. package/lib/query-form-v3/createActions.d.ts +14 -0
  86. package/lib/query-form-v3/createActions.d.ts.map +1 -0
  87. package/lib/query-form-v3/createActions.js +54 -0
  88. package/lib/query-form-v3/createActions.js.map +1 -0
  89. package/lib/query-form-v3/index.d.ts +27 -0
  90. package/lib/query-form-v3/index.d.ts.map +1 -0
  91. package/lib/query-form-v3/index.js +206 -0
  92. package/lib/query-form-v3/index.js.map +1 -0
  93. package/lib/query-form-v3/index.less +91 -0
  94. package/lib/query-form-v3/useForm.d.ts +13 -0
  95. package/lib/query-form-v3/useForm.d.ts.map +1 -0
  96. package/lib/query-form-v3/useForm.js +13 -0
  97. package/lib/query-form-v3/useForm.js.map +1 -0
  98. package/lib/query-list-scene/QueryForm.d.ts +1 -2
  99. package/lib/query-list-scene/QueryForm.d.ts.map +1 -1
  100. package/lib/query-list-scene/QueryForm.js +9 -14
  101. package/lib/query-list-scene/QueryForm.js.map +1 -1
  102. package/package.json +2 -2
  103. package/CHANGELOG.json +0 -1034
  104. package/CHANGELOG.md +0 -605
  105. package/es/checkbox/checkbox-group.js +0 -5
  106. package/es/checkbox/checkbox-group.js.map +0 -1
  107. package/es/radio/radio-group.js +0 -5
  108. package/es/radio/radio-group.js.map +0 -1
  109. package/es/steps/stepStyle/small.less +0 -5
  110. package/lib/checkbox/checkbox-group.d.ts +0 -8
  111. package/lib/checkbox/checkbox-group.d.ts.map +0 -1
  112. package/lib/checkbox/checkbox-group.js +0 -12
  113. package/lib/checkbox/checkbox-group.js.map +0 -1
  114. package/lib/radio/radio-group.d.ts +0 -8
  115. package/lib/radio/radio-group.d.ts.map +0 -1
  116. package/lib/radio/radio-group.js +0 -12
  117. package/lib/radio/radio-group.js.map +0 -1
  118. package/lib/steps/stepStyle/small.less +0 -5
@@ -0,0 +1,381 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _get2 = _interopRequireDefault(require("lodash/get"));
9
+ var _find2 = _interopRequireDefault(require("lodash/find"));
10
+ var _filter2 = _interopRequireDefault(require("lodash/filter"));
11
+ var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
12
+ var _react = _interopRequireWildcard(require("react"));
13
+ var _tntd = require("tntd");
14
+ var _popover = _interopRequireDefault(require("../../../popover"));
15
+ var _Select = _interopRequireDefault(require("./Select"));
16
+ var _utils = require("./utils");
17
+ var _fieldsMap = _interopRequireDefault(require("../fieldsMap"));
18
+ require("./FieldPopover.less");
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
22
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
23
+ 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."); }
24
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
25
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
26
+ 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; } }
27
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
28
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
29
+ var t = {};
30
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
31
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
32
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
33
+ }
34
+ return t;
35
+ };
36
+ var isInput = function isInput(type) {
37
+ return ['input', 'string', 'search', 'number', 'inputNumber'].includes(type);
38
+ };
39
+ var FieldPopover = function FieldPopover(_a, ref) {
40
+ var visible = _a.visible,
41
+ setVisible = _a.setVisible,
42
+ searchText = _a.searchText,
43
+ children = _a.children,
44
+ value = _a.value,
45
+ regex = _a.regex,
46
+ fieldItems = _a.fieldItems,
47
+ propItem = _a.propItem,
48
+ setFieldItem = _a.setFieldItem,
49
+ onChange = _a.onChange,
50
+ form = _a.form,
51
+ locale = _a.locale,
52
+ clsPrefix = _a.clsPrefix,
53
+ props = __rest(_a, ["visible", "setVisible", "searchText", "children", "value", "regex", "fieldItems", "propItem", "setFieldItem", "onChange", "form", "locale", "clsPrefix"]);
54
+ var _useState = (0, _react.useState)(undefined),
55
+ _useState2 = _slicedToArray(_useState, 2),
56
+ searchTarget = _useState2[0],
57
+ setSearchTarget = _useState2[1];
58
+ var _useState3 = (0, _react.useState)(false),
59
+ _useState4 = _slicedToArray(_useState3, 2),
60
+ popoverContent = _useState4[0],
61
+ setPopoverContent = _useState4[1];
62
+ var onPropsClick = function onPropsClick(props) {
63
+ var _ref = props || {},
64
+ _ref$type = _ref.type,
65
+ type = _ref$type === void 0 ? 'input' : _ref$type,
66
+ component = _ref.component;
67
+ var copyValue = (0, _cloneDeep2["default"])(value);
68
+ if (!(copyValue === null || copyValue === void 0 ? void 0 : copyValue.find(function (v) {
69
+ return v.key === props.name;
70
+ }))) {
71
+ copyValue.push({
72
+ key: props.name,
73
+ value: type === 'array' ? [] : undefined,
74
+ closable: true,
75
+ label: (props.propsTitle || props.title || props.name) + ':'
76
+ });
77
+ }
78
+ setFieldItem(props);
79
+ if (isInput(type) && !component) {
80
+ var target = copyValue.find(function (v) {
81
+ return v.key === props.name;
82
+ });
83
+ onChange(target, true);
84
+ close();
85
+ return;
86
+ }
87
+ setVisible(true);
88
+ setPopoverContent(true);
89
+ onChange(copyValue);
90
+ };
91
+ (0, _react.useImperativeHandle)(ref, function () {
92
+ return {
93
+ onPropsClick: onPropsClick
94
+ };
95
+ });
96
+ var onSelectChange = function onSelectChange(v, isMultiple) {
97
+ var _a, _b, _c, _d, _e, _f;
98
+ var propObj = (v === null || v === void 0 ? void 0 : v.propItem) || propItem || {};
99
+ var fieldProps = propObj.props; // 直接搜索拿v.xx的值
100
+ var copyValue = (0, _cloneDeep2["default"])(value || []);
101
+ var index;
102
+ if (v === null || v === void 0 ? void 0 : v.propItem) {
103
+ // 模糊搜索
104
+ var _index = copyValue.findIndex(function (vv) {
105
+ var _a;
106
+ return vv.key === ((_a = v.propItem) === null || _a === void 0 ? void 0 : _a.name);
107
+ });
108
+ if (_index > -1) {
109
+ index = _index;
110
+ } else {
111
+ copyValue.push({
112
+ key: (_a = v.propItem) === null || _a === void 0 ? void 0 : _a.name,
113
+ value: isMultiple ? [] : ''
114
+ });
115
+ index = copyValue.length - 1;
116
+ }
117
+ setFieldItem(v.propItem);
118
+ } else {
119
+ // 选择值
120
+ index = copyValue.findIndex(function (v) {
121
+ return v.key === (propItem === null || propItem === void 0 ? void 0 : propItem.name);
122
+ });
123
+ }
124
+ if (isMultiple) {
125
+ if (!((_c = (_b = copyValue[index]) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.length)) {
126
+ copyValue[index].value = [v === null || v === void 0 ? void 0 : v.value];
127
+ } else {
128
+ if (((_d = copyValue[index].value) === null || _d === void 0 ? void 0 : _d.indexOf(v.value)) > -1) {
129
+ copyValue[index].value = copyValue[index].value.filter(function (val) {
130
+ return val !== v.value;
131
+ });
132
+ } else {
133
+ copyValue[index].value.push(v.value);
134
+ }
135
+ }
136
+ // 如果是模糊搜索-展开多选项
137
+ if (v === null || v === void 0 ? void 0 : v.propItem) {
138
+ setFieldItem(v === null || v === void 0 ? void 0 : v.propItem);
139
+ setVisible(true);
140
+ setPopoverContent(true);
141
+ }
142
+ } else {
143
+ copyValue[index].value = v === null || v === void 0 ? void 0 : v.value;
144
+ close();
145
+ }
146
+ var labelPrefix = "".concat(propObj.propsTitle || propObj.title || propObj.name, ": ");
147
+ if (propObj.setLabel) {
148
+ copyValue[index].label = labelPrefix + propObj.setLabel(copyValue[index].value);
149
+ } else {
150
+ copyValue[index].label = labelPrefix + (0, _utils.getLabelByValue)({
151
+ value: copyValue[index].value,
152
+ options: ((_e = propObj.props) === null || _e === void 0 ? void 0 : _e.options) || v.options,
153
+ fieldNames: ((_f = propObj.props) === null || _f === void 0 ? void 0 : _f.fieldNames) || {
154
+ label: 'label',
155
+ value: 'value'
156
+ }
157
+ });
158
+ }
159
+ copyValue[index].closable = true;
160
+ onChange(copyValue, false, true);
161
+ (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.onChange) && fieldProps.onChange(copyValue[index].value);
162
+ };
163
+ var onFieldChange = function onFieldChange() {
164
+ var _a, _b;
165
+ var _ref2 = propItem || {},
166
+ type = _ref2.type,
167
+ component = _ref2.component,
168
+ fieldProps = _ref2.props,
169
+ setLabel = _ref2.setLabel,
170
+ propsTitle = _ref2.propsTitle,
171
+ title = _ref2.title,
172
+ name = _ref2.name;
173
+ var _ref3 = fieldProps || {},
174
+ options = _ref3.options;
175
+ var copyValue = (0, _cloneDeep2["default"])(value);
176
+ var index = copyValue.findIndex(function (v) {
177
+ return v.key === (propItem === null || propItem === void 0 ? void 0 : propItem.name);
178
+ });
179
+ copyValue[index].value = arguments.length <= 0 ? undefined : arguments[0];
180
+ var labelPrefix = "".concat(propsTitle || title || name, ": ");
181
+ if (setLabel) {
182
+ // setLabel: 对于自定义组件,无法控制label的显示,可以通过setLabel方法控制
183
+ copyValue[index].label = labelPrefix + setLabel(arguments.length <= 0 ? undefined : arguments[0]);
184
+ } else if (type === 'date') {
185
+ copyValue[index].label = labelPrefix + (arguments.length <= 1 ? undefined : arguments[1]);
186
+ close();
187
+ } else if (type === 'dateRange') {
188
+ copyValue[index].label = labelPrefix + ((_a = arguments.length <= 1 ? undefined : arguments[1]) === null || _a === void 0 ? void 0 : _a.join('~'));
189
+ if ((_b = arguments.length <= 1 ? undefined : arguments[1]) === null || _b === void 0 ? void 0 : _b[1]) {
190
+ close();
191
+ }
192
+ } else if (type === 'selectInput') {
193
+ var key = (0, _get2["default"])(Object.keys(arguments.length <= 0 ? undefined : arguments[0]), '0');
194
+ var val = (0, _get2["default"])(arguments.length <= 0 ? undefined : arguments[0], key);
195
+ var label = (0, _utils.getLabelFromOptions)(key, options);
196
+ copyValue[index].label = "".concat(label, ": ").concat(val);
197
+ } else if (type === 'checkbox') {
198
+ copyValue[index].label = labelPrefix + ((arguments.length <= 0 ? undefined : arguments[0]) ? locale.yes : locale.no);
199
+ close();
200
+ } else if (!type && component) {
201
+ copyValue[index].label = labelPrefix + ((arguments.length <= 1 ? undefined : arguments[1]) || (arguments.length <= 0 ? undefined : arguments[0]));
202
+ close();
203
+ }
204
+ copyValue[index].closable = true;
205
+ // onChange(copyValue, false, true)
206
+ onChange(copyValue, false, (arguments.length <= 0 ? undefined : arguments[0]) !== undefined);
207
+ (fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.onChange) && fieldProps.onChange(copyValue[index].value);
208
+ };
209
+ var close = function close() {
210
+ setVisible(false);
211
+ setTimeout(function () {
212
+ setFieldItem();
213
+ setPopoverContent(false);
214
+ }, 1);
215
+ };
216
+ var handleVisibleChange = function handleVisibleChange() {
217
+ if (!visible && !regex.test(searchText)) {
218
+ setVisible(true);
219
+ } else {
220
+ close();
221
+ }
222
+ };
223
+ (0, _react.useEffect)(function () {
224
+ var bool1 = false,
225
+ bool2 = false;
226
+ if (searchText && !propItem) {
227
+ fieldItems === null || fieldItems === void 0 ? void 0 : fieldItems.forEach(function (v) {
228
+ var _ref4 = v.props || {},
229
+ name = _ref4.name,
230
+ propsTitle = _ref4.propsTitle,
231
+ title = _ref4.title,
232
+ type = _ref4.type,
233
+ props = _ref4.props;
234
+ var _propsTitle = propsTitle || title || name;
235
+ if ((_propsTitle === null || _propsTitle === void 0 ? void 0 : _propsTitle.indexOf(searchText)) > -1) {
236
+ bool1 = true;
237
+ }
238
+ var sOptions = type !== 'select' ? [] : (props === null || props === void 0 ? void 0 : props.options) || [];
239
+ var fieldNames = props === null || props === void 0 ? void 0 : props.fieldNames;
240
+ var target = sOptions === null || sOptions === void 0 ? void 0 : sOptions.find(function (item) {
241
+ var labelKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label';
242
+ var label = item instanceof Object ? item[labelKey] : item + '';
243
+ return (_react["default"].isValidElement(label) ? (0, _utils.formatLabel)(label) : label).indexOf(searchText) > -1;
244
+ });
245
+ if (target) {
246
+ bool2 = true;
247
+ }
248
+ });
249
+ setSearchTarget(!bool2 && !bool1 ? null : {
250
+ propsTitle: bool1,
251
+ propsValue: bool2
252
+ });
253
+ } else {
254
+ setSearchTarget(undefined);
255
+ }
256
+ }, [fieldItems, searchText, propItem]);
257
+ var renderFirstOptions = function renderFirstOptions() {
258
+ var firstItems = searchText ? (0, _filter2["default"])(fieldItems, function (v) {
259
+ var _ref5 = v.props || {},
260
+ name = _ref5.name,
261
+ propsTitle = _ref5.propsTitle,
262
+ title = _ref5.title;
263
+ var _propsTitle = propsTitle || title || name;
264
+ return (_propsTitle === null || _propsTitle === void 0 ? void 0 : _propsTitle.indexOf(searchText)) > -1;
265
+ }) : fieldItems;
266
+ var secondItems = searchText ? (0, _filter2["default"])(fieldItems, function (v) {
267
+ var _ref6 = v.props || {},
268
+ type = _ref6.type,
269
+ props = _ref6.props;
270
+ var options = props.options,
271
+ loadData = props.loadData,
272
+ fieldNames = props.fieldNames;
273
+ return type === 'select' && !loadData && !!(0, _find2["default"])(options, function (item) {
274
+ var labelKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label';
275
+ var label = item instanceof Object ? item[labelKey] : item + '';
276
+ var isReactDom = _react["default"].isValidElement(label);
277
+ var _label = isReactDom ? (0, _utils.formatLabel)(label) : label;
278
+ return (_label === null || _label === void 0 ? void 0 : _label.indexOf(searchText)) > -1;
279
+ });
280
+ }) : [];
281
+ return _react["default"].createElement("div", null, firstItems.length > 0 && _react["default"].createElement(_react["default"].Fragment, null, (!searchText || (searchTarget === null || searchTarget === void 0 ? void 0 : searchTarget.propsTitle)) && _react["default"].createElement("label", null, locale.propTitle), _react["default"].createElement("ul", {
282
+ className: "ant-select-dropdown-menu"
283
+ }, firstItems.map(function (v) {
284
+ var _ref7 = v.props || {},
285
+ name = _ref7.name,
286
+ propsTitle = _ref7.propsTitle,
287
+ title = _ref7.title,
288
+ type = _ref7.type,
289
+ props = _ref7.props;
290
+ var _propsTitle = propsTitle || title || name;
291
+ return _react["default"].createElement("li", {
292
+ className: "ant-select-dropdown-menu-item",
293
+ key: name,
294
+ value: name,
295
+ onMouseDown: function onMouseDown(e) {
296
+ return e.preventDefault();
297
+ },
298
+ onClick: function onClick() {
299
+ onPropsClick(v.props);
300
+ }
301
+ }, searchText ? _react["default"].createElement("span", {
302
+ dangerouslySetInnerHTML: {
303
+ __html: (0, _utils.highlightSubstring)(_propsTitle, searchText)
304
+ }
305
+ }) : _propsTitle);
306
+ }))), secondItems.length > 0 && _react["default"].createElement("div", null, (searchTarget === null || searchTarget === void 0 ? void 0 : searchTarget.propsValue) && _react["default"].createElement("label", null, locale.propValue), fieldItems === null || fieldItems === void 0 ? void 0 : fieldItems.map(function (v) {
307
+ var _ref8 = v.props || {},
308
+ name = _ref8.name,
309
+ type = _ref8.type,
310
+ props = _ref8.props;
311
+ var target = value === null || value === void 0 ? void 0 : value.find(function (v) {
312
+ return v.key === name;
313
+ });
314
+ if (type === 'select') {
315
+ // && props?.options?.length > 0
316
+ return _react["default"].createElement(_Select["default"], Object.assign({
317
+ key: name
318
+ }, props, {
319
+ searchText: searchText,
320
+ propItem: v.props,
321
+ onChange: onSelectChange,
322
+ value: target === null || target === void 0 ? void 0 : target.value
323
+ }));
324
+ }
325
+ return;
326
+ })), !firstItems.length && !secondItems.length && _react["default"].createElement(_tntd.Empty, {
327
+ size: "mini"
328
+ }));
329
+ };
330
+ var renderSecondOptions = function renderSecondOptions() {
331
+ var _a;
332
+ var _ref9 = propItem || {},
333
+ name = _ref9.name,
334
+ propsTitle = _ref9.propsTitle,
335
+ title = _ref9.title,
336
+ type = _ref9.type,
337
+ className = _ref9.className,
338
+ component = _ref9.component,
339
+ fieldProps = _ref9.props;
340
+ var target = value === null || value === void 0 ? void 0 : value.find(function (v) {
341
+ return v.key === name;
342
+ });
343
+ var Field = component || _fieldsMap["default"][type] || function () {
344
+ return null;
345
+ };
346
+ return _react["default"].createElement("div", {
347
+ onClick: function onClick(e) {
348
+ return e.stopPropagation();
349
+ },
350
+ className: className
351
+ }, _react["default"].createElement("label", null, propsTitle || title || name), type === 'select' ? _react["default"].createElement(_Select["default"], Object.assign({}, fieldProps, {
352
+ searchText: searchText,
353
+ propItem: propItem,
354
+ onChange: onSelectChange,
355
+ value: target === null || target === void 0 ? void 0 : target.value
356
+ })) : _react["default"].createElement("div", {
357
+ className: "".concat(clsPrefix, "-field-popover-content"),
358
+ onClick: function onClick(e) {
359
+ return e.stopPropagation();
360
+ }
361
+ }, _react["default"].createElement(Field, Object.assign({
362
+ form: form,
363
+ value: target === null || target === void 0 ? void 0 : target.value
364
+ }, fieldProps, {
365
+ style: Object.assign(Object.assign({}, fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style), {
366
+ width: ((_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style) === null || _a === void 0 ? void 0 : _a.width) || '250px'
367
+ }),
368
+ close: close,
369
+ onChange: onFieldChange
370
+ }))));
371
+ };
372
+ return _react["default"].createElement(_popover["default"], Object.assign({
373
+ trigger: "click",
374
+ visible: visible,
375
+ placement: "bottom",
376
+ overlayClassName: "".concat(clsPrefix, "-field-popover"),
377
+ content: !popoverContent ? renderFirstOptions() : renderSecondOptions(),
378
+ onVisibleChange: handleVisibleChange
379
+ }, props), children);
380
+ };
381
+ var _default = exports["default"] = (0, _react.forwardRef)(FieldPopover);
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FieldPopover.js","sourceRoot":"","sources":["../../../../src/query-form-v3/Field/Composition/FieldPopover.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAmF;AACnF,mCAAqD;AACrD,+BAA6B;AAC7B,+DAAsC;AACtC,sDAAgC;AAChC,mCAA+F;AAC/F,6DAAuD;AACvD,+BAA4B;AAE5B,MAAM,OAAO,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;AAE/F,MAAM,YAAY,GAAG,CACnB,EAeC,EACD,GAAG,EACH,EAAE;QAjBF,EACE,OAAO,EACP,UAAU,EACV,UAAU,EACV,QAAQ,EACR,KAAK,EACL,KAAK,EACL,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,IAAI,EACJ,MAAM,EACN,SAAS,OAEV,EADI,KAAK,cAdV,0JAeC,CADS;IAIV,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,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AC,CAAA;IAED,OAAO,CACL,8BAAC,iBAAO,kBACN,OAAO,EAAC,OAAO,EACf,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,QAAQ,EAClB,gBAAgB,EAAE,GAAG,SAAS,gBAAgB,EAC9C,OAAO,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC,mBAAmB,EAAE,EACvE,eAAe,EAAE,mBAAmB,IAChC,KAAK,GAER,QAAQ,CACD,CACX,CAAA;AACH,CAAC,CAAA;AACD,kBAAe,IAAA,kBAAU,EAAC,YAAY,CAAC,CAAA","sourcesContent":["import React, { useEffect, useState, forwardRef, useImperativeHandle } from 'react'\nimport { cloneDeep, filter, find, get } from 'lodash'\nimport { Empty } from 'tntd';\nimport Popover from '../../../popover'\nimport SelectOpt from './Select'\nimport { highlightSubstring, getLabelFromOptions, getLabelByValue, formatLabel } from './utils'\nimport fieldsMap, { getFieldWidth } from '../fieldsMap'\nimport './FieldPopover.less'\n\nconst isInput = (type) => ['input', 'string', 'search', 'number', 'inputNumber'].includes(type)\n\nconst FieldPopover = (\n {\n visible,\n setVisible,\n searchText,\n children,\n value,\n regex,\n fieldItems,\n propItem,\n setFieldItem,\n onChange,\n form,\n locale,\n clsPrefix,\n ...props\n },\n ref\n) => {\n const [searchTarget, setSearchTarget] = useState(undefined)\n const [popoverContent, setPopoverContent] = useState(false)\n\n const onPropsClick = (props) => {\n const { type = 'input', component } = props || {}\n const copyValue = cloneDeep(value)\n if (!copyValue?.find((v) => v.key === props.name)) {\n copyValue.push({\n key: props.name,\n value: type === 'array' ? [] : undefined,\n closable: true,\n label: (props.propsTitle || props.title || props.name) + ':',\n })\n }\n setFieldItem(props)\n if (isInput(type) && !component) {\n const target = copyValue.find((v) => v.key === props.name)\n onChange(target, true)\n close()\n return\n }\n setVisible(true)\n setPopoverContent(true)\n onChange(copyValue)\n }\n\n useImperativeHandle(ref, () => ({\n onPropsClick,\n }))\n\n const onSelectChange = (v, isMultiple) => {\n const propObj = v?.propItem || propItem || {}\n const { props: fieldProps } = propObj // 直接搜索拿v.xx的值\n const copyValue = cloneDeep(value || [])\n let index\n if (v?.propItem) {\n // 模糊搜索\n const _index = copyValue.findIndex((vv) => vv.key === v.propItem?.name)\n if (_index > -1) {\n index = _index\n } else {\n copyValue.push({\n key: v.propItem?.name,\n value: isMultiple ? [] : '',\n })\n index = copyValue.length - 1\n }\n setFieldItem(v.propItem)\n } else {\n // 选择值\n index = copyValue.findIndex((v) => v.key === propItem?.name)\n }\n\n if (isMultiple) {\n if (!copyValue[index]?.value?.length) {\n copyValue[index].value = [v?.value]\n } else {\n if (copyValue[index].value?.indexOf(v.value) > -1) {\n copyValue[index].value = copyValue[index].value.filter((val) => val !== v.value)\n } else {\n copyValue[index].value.push(v.value)\n }\n }\n // 如果是模糊搜索-展开多选项\n if (v?.propItem) {\n setFieldItem(v?.propItem)\n setVisible(true)\n setPopoverContent(true)\n }\n } else {\n copyValue[index].value = v?.value\n close()\n }\n\n const labelPrefix = `${propObj.propsTitle || propObj.title || propObj.name}: `\n if (propObj.setLabel) {\n copyValue[index].label = labelPrefix + propObj.setLabel(copyValue[index].value)\n } else {\n copyValue[index].label =\n labelPrefix +\n getLabelByValue({\n value: copyValue[index].value,\n options: propObj.props?.options || v.options,\n fieldNames: propObj.props?.fieldNames || {\n label: 'label',\n value: 'value',\n },\n })\n }\n copyValue[index].closable = true\n onChange(copyValue, false, true)\n fieldProps?.onChange && fieldProps.onChange(copyValue[index].value)\n }\n\n const onFieldChange = (...args) => {\n const { type, component, props: fieldProps, setLabel, propsTitle, title, name } = propItem || {}\n const { options } = fieldProps || {}\n const copyValue = cloneDeep(value)\n const index = copyValue.findIndex((v) => v.key === propItem?.name)\n copyValue[index].value = args[0]\n const labelPrefix = `${propsTitle || title || name}: `\n if (setLabel) {\n // setLabel: 对于自定义组件,无法控制label的显示,可以通过setLabel方法控制\n copyValue[index].label = labelPrefix + setLabel(args[0])\n } else if (type === 'date') {\n copyValue[index].label = labelPrefix + args[1]\n close()\n } else if (type === 'dateRange') {\n copyValue[index].label = labelPrefix + args[1]?.join('~')\n if (args[1]?.[1]) {\n close()\n }\n } else if (type === 'selectInput') {\n const key = get(Object.keys(args[0]), '0')\n const val = get(args[0], key)\n const label = getLabelFromOptions(key, options)\n copyValue[index].label = `${label}: ${val}`\n } else if (type === 'checkbox') {\n copyValue[index].label = labelPrefix + (args[0] ? locale.yes : locale.no)\n close()\n } else if (!type && component) {\n copyValue[index].label = labelPrefix + (args[1] || args[0])\n close()\n }\n copyValue[index].closable = true\n // onChange(copyValue, false, true)\n onChange(copyValue, false, args[0] !== undefined)\n fieldProps?.onChange && fieldProps.onChange(copyValue[index].value)\n }\n\n const close = () => {\n setVisible(false)\n setTimeout(() => {\n setFieldItem()\n setPopoverContent(false)\n }, 1)\n }\n const handleVisibleChange = () => {\n if (!visible && !regex.test(searchText)) {\n setVisible(true)\n } else {\n close()\n }\n }\n\n useEffect(() => {\n let bool1 = false,\n bool2 = false\n\n if (searchText && !propItem) {\n fieldItems?.forEach((v) => {\n const { name, propsTitle, title, type, props } = v.props || {}\n const _propsTitle = propsTitle || title || name\n if (_propsTitle?.indexOf(searchText) > -1) {\n bool1 = true\n }\n const sOptions = type !== 'select' ? [] : props?.options || []\n const fieldNames = props?.fieldNames\n const target = sOptions?.find((item) => {\n const labelKey = fieldNames?.label || 'label'\n const label = item instanceof Object ? item[labelKey] : item + ''\n return (React.isValidElement(label) ? formatLabel(label) : label).indexOf(searchText) > -1\n })\n if (target) {\n bool2 = true\n }\n })\n setSearchTarget(!bool2 && !bool1 ? null : { propsTitle: bool1, propsValue: bool2 })\n } else {\n setSearchTarget(undefined)\n }\n }, [fieldItems, searchText, propItem])\n\n const renderFirstOptions = () => {\n const firstItems = searchText ? filter(fieldItems, v => {\n const { name, propsTitle, title, } = v.props || {}\n const _propsTitle = propsTitle || title || name\n return _propsTitle?.indexOf(searchText) > -1\n }) : fieldItems\n const secondItems = searchText ? filter(fieldItems, v => {\n const { type, props } = v.props || {}\n const { options, loadData, fieldNames } = props;\n return type === 'select' && !loadData && !!find(options, (item) => {\n const labelKey = fieldNames?.label || 'label'\n const label = item instanceof Object ? item[labelKey] : item + ''\n const isReactDom = React.isValidElement(label)\n const _label = isReactDom ? formatLabel(label) : label\n return _label?.indexOf(searchText) > -1\n })\n }) : []\n return (\n <div>\n {firstItems.length > 0 && <>\n {(!searchText || searchTarget?.propsTitle) && <label>{locale.propTitle}</label>}\n <ul className=\"ant-select-dropdown-menu\">\n {firstItems.map((v) => {\n const { name, propsTitle, title, type, props } = v.props || {}\n const _propsTitle = propsTitle || title || name\n return (\n <li\n className=\"ant-select-dropdown-menu-item\"\n key={name}\n value={name}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n onPropsClick(v.props)\n }}\n >\n {searchText ? <span\n dangerouslySetInnerHTML={{\n __html: highlightSubstring(_propsTitle, searchText),\n }}\n /> : _propsTitle}\n </li>\n )\n })}\n </ul>\n </>}\n\n {/* 可以对下拉框值筛选 */}\n {secondItems.length > 0 && <div>\n {searchTarget?.propsValue && <label>{locale.propValue}</label>}\n {fieldItems?.map((v) => {\n const { name, type, props } = v.props || {}\n const target = value?.find((v) => v.key === name)\n if (type === 'select') {\n // && props?.options?.length > 0\n return (\n <SelectOpt\n key={name}\n {...props}\n searchText={searchText}\n propItem={v.props}\n onChange={onSelectChange}\n value={target?.value}\n />\n )\n }\n return\n })}\n </div>}\n\n {(!firstItems.length && !secondItems.length) && <Empty size=\"mini\" />}\n </div>\n )\n }\n\n const renderSecondOptions = () => {\n const {\n name,\n propsTitle,\n title,\n type,\n className,\n component,\n props: fieldProps,\n } = propItem || {}\n const target = value?.find((v) => v.key === name)\n const Field = component || fieldsMap[type] || (() => null)\n return (\n <div onClick={(e) => e.stopPropagation()} className={className}>\n <label>{propsTitle || title || name}</label>\n {type === 'select' ? (\n <SelectOpt\n {...fieldProps}\n searchText={searchText}\n propItem={propItem}\n onChange={onSelectChange}\n value={target?.value}\n />\n ) : (\n <div\n className={`${clsPrefix}-field-popover-content`}\n onClick={(e) => e.stopPropagation()}\n >\n <Field\n form={form}\n value={target?.value}\n {...fieldProps}\n style={{\n ...fieldProps?.style,\n width: fieldProps?.style?.width || '250px',\n }}\n close={close}\n onChange={onFieldChange}\n />\n </div>\n )}\n </div>\n )\n }\n\n return (\n <Popover\n trigger=\"click\"\n visible={visible}\n placement=\"bottom\"\n overlayClassName={`${clsPrefix}-field-popover`}\n content={!popoverContent ? renderFirstOptions() : renderSecondOptions()}\n onVisibleChange={handleVisibleChange}\n {...props}\n >\n {children}\n </Popover>\n )\n}\nexport default forwardRef(FieldPopover)\n"]}
@@ -0,0 +1,35 @@
1
+ .tnt-queryform-field-popover {
2
+ min-width: 280px;
3
+ .ant-popover-inner-content {
4
+ padding: @padding-sm 0;
5
+ }
6
+ .ant-calendar-picker {
7
+ margin: @margin-xxs 0;
8
+ }
9
+ label {
10
+ color: tint(@text-color, 50%);
11
+ margin-bottom: @margin-xs;
12
+ display: block;
13
+ padding: 0 @padding-sm;
14
+ }
15
+ .ant-select-dropdown-menu {
16
+ &-item {
17
+ padding: @padding-xxs @padding-sm;
18
+ &:hover {
19
+ background-color: @bg-color-quaternary;
20
+ }
21
+ }
22
+ }
23
+ &-content {
24
+ padding: @padding-xxs @padding-sm;
25
+ }
26
+ .ant-select-selected-icon {
27
+ position: absolute;
28
+ right: @margin-base;
29
+ top: @margin-xs;
30
+ color: @blue-6;
31
+ }
32
+ .tnt-highlight {
33
+ color: @blue-6;
34
+ }
35
+ }
@@ -0,0 +1,4 @@
1
+ declare function _default(props: any): React.JSX.Element;
2
+ export default _default;
3
+ import React from "react";
4
+ //# sourceMappingURL=Select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../../src/query-form-v3/Field/Composition/Select.js"],"names":[],"mappings":"AAMe,yDA4Gd"}
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ 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); }
4
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports["default"] = void 0;
8
+ var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
9
+ var _react = _interopRequireWildcard(require("react"));
10
+ var _classnames = _interopRequireDefault(require("classnames"));
11
+ var _icon = _interopRequireDefault(require("../../../icon"));
12
+ var _utils = require("./utils");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
18
+ 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); }
19
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
20
+ 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."); }
21
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
22
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
23
+ 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; } }
24
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
25
+ var __rest = void 0 && (void 0).__rest || function (s, e) {
26
+ var t = {};
27
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
28
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
29
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
30
+ }
31
+ return t;
32
+ };
33
+ var _default = exports["default"] = function _default(props) {
34
+ var options = props.options,
35
+ params = props.params,
36
+ _props$queryKey = props.queryKey,
37
+ queryKey = _props$queryKey === void 0 ? 'name' : _props$queryKey,
38
+ _props$fieldNames = props.fieldNames,
39
+ fieldNames = _props$fieldNames === void 0 ? {
40
+ label: 'label',
41
+ value: 'value'
42
+ } : _props$fieldNames,
43
+ loadData = props.loadData,
44
+ onChange = props.onChange,
45
+ _value = props.value,
46
+ mode = props.mode,
47
+ propItem = props.propItem,
48
+ searchText = props.searchText,
49
+ rest = __rest(props, ["options", "params", "queryKey", "fieldNames", "loadData", "onChange", "value", "mode", "propItem", "searchText"]);
50
+ var _useState = (0, _react.useState)(options || []),
51
+ _useState2 = _slicedToArray(_useState, 2),
52
+ items = _useState2[0],
53
+ setItems = _useState2[1];
54
+ (0, _react.useEffect)(function () {
55
+ if (loadData) {
56
+ loadData(Object.assign(_defineProperty({}, queryKey, searchText), params || {})).then(function (items) {
57
+ setItems(items);
58
+ });
59
+ }
60
+ }, [params, searchText]);
61
+ (0, _react.useEffect)(function () {
62
+ setItems(options || []);
63
+ }, [options]);
64
+ var onValueChange = function onValueChange(item) {
65
+ onChange(item, mode === 'multiple' || mode === 'tags');
66
+ };
67
+ return _react["default"].createElement("ul", {
68
+ className: "ant-select-dropdown-menu"
69
+ }, items.map(function (item) {
70
+ var labelKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label) || 'label';
71
+ var valueKey = (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || 'value';
72
+ var value = item instanceof Object ? item[valueKey] : item;
73
+ var label = item instanceof Object ? item[labelKey] : item + '';
74
+ var disabled = item instanceof Object ? item['disabled'] : false;
75
+ var isSelected = (0, _isArray2["default"])(_value) ? (_value === null || _value === void 0 ? void 0 : _value.indexOf(value)) > -1 : value === _value;
76
+ if (searchText) {
77
+ var isReactDom = _react["default"].isValidElement(label);
78
+ var _label = isReactDom ? (0, _utils.formatLabel)(label) : label;
79
+ if ((_label === null || _label === void 0 ? void 0 : _label.indexOf(searchText)) > -1) {
80
+ return _react["default"].createElement("li", {
81
+ className: (0, _classnames["default"])({
82
+ 'ant-select-dropdown-menu-item': true,
83
+ 'ant-select-dropdown-menu-item-selected': isSelected,
84
+ 'ant-select-dropdown-menu-item-disabled': disabled
85
+ }),
86
+ key: value,
87
+ value: value,
88
+ onMouseDown: function onMouseDown(e) {
89
+ return e.preventDefault();
90
+ },
91
+ onClick: function onClick() {
92
+ !disabled && onValueChange({
93
+ value: value,
94
+ propItem: propItem,
95
+ options: items
96
+ });
97
+ }
98
+ }, _react["default"].createElement("span", null, (propItem === null || propItem === void 0 ? void 0 : propItem.propsTitle) || (propItem === null || propItem === void 0 ? void 0 : propItem.name), ": "), isReactDom ? _react["default"].createElement("span", null, label) : _react["default"].createElement("span", {
99
+ dangerouslySetInnerHTML: {
100
+ __html: (0, _utils.highlightSubstring)(label, searchText)
101
+ }
102
+ }), isSelected && _react["default"].createElement(_icon["default"], {
103
+ type: "check",
104
+ className: "ant-select-selected-icon"
105
+ }));
106
+ }
107
+ return null;
108
+ }
109
+ return _react["default"].createElement("li", {
110
+ className: (0, _classnames["default"])({
111
+ 'ant-select-dropdown-menu-item': true,
112
+ 'ant-select-dropdown-menu-item-selected': isSelected,
113
+ 'ant-select-dropdown-menu-item-disabled': disabled
114
+ }),
115
+ key: value,
116
+ value: value,
117
+ onMouseDown: function onMouseDown(e) {
118
+ return e.preventDefault();
119
+ },
120
+ onClick: function onClick() {
121
+ !disabled && onValueChange({
122
+ value: value,
123
+ options: items
124
+ });
125
+ }
126
+ }, label, isSelected && _react["default"].createElement(_icon["default"], {
127
+ type: "check",
128
+ className: "ant-select-selected-icon"
129
+ }));
130
+ }));
131
+ };
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../../src/query-form-v3/Field/Composition/Select.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,mCAAgC;AAChC,4DA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nimport classNames from 'classnames'\nimport Icon from '../../../icon'\nimport { highlightSubstring, formatLabel } from './utils'\n\nexport default (props) => {\n const {\n options,\n params,\n queryKey = 'name',\n fieldNames = {\n label: 'label',\n value: 'value',\n },\n loadData,\n onChange,\n value: _value,\n mode,\n propItem,\n searchText,\n ...rest\n } = props\n const [items, setItems] = useState(options || [])\n\n useEffect(() => {\n if (loadData) {\n loadData({\n [queryKey]: searchText,\n ...(params || {}),\n }).then((items) => {\n setItems(items)\n })\n }\n }, [params, searchText])\n\n useEffect(() => {\n setItems(options || [])\n }, [options])\n\n const onValueChange = (item) => {\n onChange(item, mode === 'multiple' || mode === 'tags')\n }\n\n return (\n <ul className=\"ant-select-dropdown-menu\">\n {items.map((item) => {\n const labelKey = fieldNames?.label || 'label'\n const valueKey = fieldNames?.value || 'value'\n const value = item instanceof Object ? item[valueKey] : item\n const label = item instanceof Object ? item[labelKey] : item + ''\n const disabled = item instanceof Object ? item['disabled'] : false\n\n const isSelected = isArray(_value) ? _value?.indexOf(value) > -1 : value === _value\n if (searchText) {\n const isReactDom = React.isValidElement(label)\n const _label = isReactDom ? formatLabel(label) : label\n if (_label?.indexOf(searchText) > -1) {\n return (\n <li\n className={classNames({\n 'ant-select-dropdown-menu-item': true,\n 'ant-select-dropdown-menu-item-selected': isSelected,\n 'ant-select-dropdown-menu-item-disabled': disabled,\n })}\n key={value}\n value={value}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n !disabled &&\n onValueChange({\n value,\n propItem,\n options: items,\n })\n }}\n >\n <span>{propItem?.propsTitle || propItem?.name}: </span>\n {isReactDom ? (\n <span>{label}</span>\n ) : (\n <span\n dangerouslySetInnerHTML={{\n __html: highlightSubstring(label, searchText),\n }}\n ></span>\n )}\n {isSelected && <Icon type=\"check\" className=\"ant-select-selected-icon\" />}\n </li>\n )\n }\n return null\n }\n return (\n <li\n className={classNames({\n 'ant-select-dropdown-menu-item': true,\n 'ant-select-dropdown-menu-item-selected': isSelected,\n 'ant-select-dropdown-menu-item-disabled': disabled,\n })}\n key={value}\n value={value}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => {\n !disabled && onValueChange({ value, options: items })\n }}\n >\n {label}\n {isSelected && <Icon type=\"check\" className=\"ant-select-selected-icon\" />}\n </li>\n )\n })}\n </ul>\n )\n}\n"]}
@@ -0,0 +1,10 @@
1
+ declare var _default: React.ForwardRefExoticComponent<{
2
+ fieldItems: any;
3
+ initialValues: any;
4
+ onChange: any;
5
+ form: any;
6
+ clsPrefix: any;
7
+ } & React.RefAttributes<any>>;
8
+ export default _default;
9
+ import React from "react";
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/query-form-v3/Field/Composition/index.js"],"names":[],"mappings":""}