tntd 3.0.11 → 3.0.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.
- package/es/form/form.js +1 -0
- package/es/form/form.js.map +1 -1
- package/es/query-form-v3/Field/Checkbox.js +23 -0
- package/es/query-form-v3/Field/Checkbox.js.map +1 -0
- package/es/query-form-v3/Field/Composition/FieldPopover.js +330 -0
- package/es/query-form-v3/Field/Composition/FieldPopover.js.map +1 -0
- package/es/query-form-v3/Field/Composition/FieldPopover.less +35 -0
- package/es/query-form-v3/Field/Composition/Select.js +107 -0
- package/es/query-form-v3/Field/Composition/Select.js.map +1 -0
- package/es/query-form-v3/Field/Composition/index.js +208 -0
- package/es/query-form-v3/Field/Composition/index.js.map +1 -0
- package/es/query-form-v3/Field/Composition/index.less +118 -0
- package/es/query-form-v3/Field/Composition/utils.js +132 -0
- package/es/query-form-v3/Field/Composition/utils.js.map +1 -0
- package/es/query-form-v3/Field/Select.js +59 -0
- package/es/query-form-v3/Field/Select.js.map +1 -0
- package/es/query-form-v3/Field/SelectInput.js +87 -0
- package/es/query-form-v3/Field/SelectInput.js.map +1 -0
- package/es/query-form-v3/Field/fieldsMap.js +28 -0
- package/es/query-form-v3/Field/fieldsMap.js.map +1 -0
- package/es/query-form-v3/Field/index.js +117 -0
- package/es/query-form-v3/Field/index.js.map +1 -0
- package/es/query-form-v3/createActions.js +47 -0
- package/es/query-form-v3/createActions.js.map +1 -0
- package/es/query-form-v3/index.js +175 -0
- package/es/query-form-v3/index.js.map +1 -0
- package/es/query-form-v3/index.less +91 -0
- package/es/query-form-v3/useForm.js +6 -0
- package/es/query-form-v3/useForm.js.map +1 -0
- package/es/table/resizableTable/index.js +8 -5
- package/es/table/resizableTable/index.js.map +1 -1
- package/es/table/table-hoc.js +8 -8
- package/es/table/table-hoc.js.map +1 -1
- package/lib/form/form.d.ts.map +1 -1
- package/lib/form/form.js +1 -0
- package/lib/form/form.js.map +1 -1
- package/lib/query-form-v3/Field/Checkbox.d.ts +8 -0
- package/lib/query-form-v3/Field/Checkbox.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Checkbox.js +28 -0
- package/lib/query-form-v3/Field/Checkbox.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts +19 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.js +370 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/FieldPopover.less +35 -0
- package/lib/query-form-v3/Field/Composition/Select.d.ts +4 -0
- package/lib/query-form-v3/Field/Composition/Select.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/Select.js +131 -0
- package/lib/query-form-v3/Field/Composition/Select.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/index.d.ts +10 -0
- package/lib/query-form-v3/Field/Composition/index.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/index.js +255 -0
- package/lib/query-form-v3/Field/Composition/index.js.map +1 -0
- package/lib/query-form-v3/Field/Composition/index.less +118 -0
- package/lib/query-form-v3/Field/Composition/utils.d.ts +22 -0
- package/lib/query-form-v3/Field/Composition/utils.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Composition/utils.js +147 -0
- package/lib/query-form-v3/Field/Composition/utils.js.map +1 -0
- package/lib/query-form-v3/Field/Select.d.ts +4 -0
- package/lib/query-form-v3/Field/Select.d.ts.map +1 -0
- package/lib/query-form-v3/Field/Select.js +80 -0
- package/lib/query-form-v3/Field/Select.js.map +1 -0
- package/lib/query-form-v3/Field/SelectInput.d.ts +4 -0
- package/lib/query-form-v3/Field/SelectInput.d.ts.map +1 -0
- package/lib/query-form-v3/Field/SelectInput.js +100 -0
- package/lib/query-form-v3/Field/SelectInput.js.map +1 -0
- package/lib/query-form-v3/Field/fieldsMap.d.ts +27 -0
- package/lib/query-form-v3/Field/fieldsMap.d.ts.map +1 -0
- package/lib/query-form-v3/Field/fieldsMap.js +35 -0
- package/lib/query-form-v3/Field/fieldsMap.js.map +1 -0
- package/lib/query-form-v3/Field/index.d.ts +14 -0
- package/lib/query-form-v3/Field/index.d.ts.map +1 -0
- package/lib/query-form-v3/Field/index.js +147 -0
- package/lib/query-form-v3/Field/index.js.map +1 -0
- package/lib/query-form-v3/createActions.d.ts +14 -0
- package/lib/query-form-v3/createActions.d.ts.map +1 -0
- package/lib/query-form-v3/createActions.js +54 -0
- package/lib/query-form-v3/createActions.js.map +1 -0
- package/lib/query-form-v3/index.d.ts +27 -0
- package/lib/query-form-v3/index.d.ts.map +1 -0
- package/lib/query-form-v3/index.js +206 -0
- package/lib/query-form-v3/index.js.map +1 -0
- package/lib/query-form-v3/index.less +91 -0
- package/lib/query-form-v3/useForm.d.ts +13 -0
- package/lib/query-form-v3/useForm.d.ts.map +1 -0
- package/lib/query-form-v3/useForm.js +13 -0
- package/lib/query-form-v3/useForm.js.map +1 -0
- package/lib/table/resizableTable/index.d.ts +1 -1
- package/lib/table/resizableTable/index.d.ts.map +1 -1
- package/lib/table/resizableTable/index.js +8 -5
- package/lib/table/resizableTable/index.js.map +1 -1
- package/lib/table/table-hoc.d.ts +10 -3
- package/lib/table/table-hoc.d.ts.map +1 -1
- package/lib/table/table-hoc.js +8 -11
- package/lib/table/table-hoc.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.formatLabel = formatLabel;
|
|
7
|
+
exports.getLabelByValue = getLabelByValue;
|
|
8
|
+
exports.getLabelFromOptions = getLabelFromOptions;
|
|
9
|
+
exports.highlightSubstring = highlightSubstring;
|
|
10
|
+
exports.parseArrayToObject = parseArrayToObject;
|
|
11
|
+
exports.parseObjectToArray = parseObjectToArray;
|
|
12
|
+
var _flatten2 = _interopRequireDefault(require("lodash/flatten"));
|
|
13
|
+
var _isString2 = _interopRequireDefault(require("lodash/isString"));
|
|
14
|
+
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
|
|
15
|
+
var _react = _interopRequireDefault(require("react"));
|
|
16
|
+
var _moment = _interopRequireDefault(require("moment"));
|
|
17
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
18
|
+
function highlightSubstring(str, substring) {
|
|
19
|
+
var highlighted = "<span class=\"tnt-highlight\">".concat(substring, "</span>");
|
|
20
|
+
return str.replace(new RegExp(substring, 'g'), highlighted);
|
|
21
|
+
}
|
|
22
|
+
function getLabelFromOptions(key, options) {
|
|
23
|
+
var fieldNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {
|
|
24
|
+
label: 'label',
|
|
25
|
+
value: 'value'
|
|
26
|
+
};
|
|
27
|
+
var labelValue = key;
|
|
28
|
+
if (options) {
|
|
29
|
+
var target = options === null || options === void 0 ? void 0 : options.find(function (item) {
|
|
30
|
+
var valueKey = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
|
31
|
+
var itemValue = item instanceof Object ? item[valueKey] : item;
|
|
32
|
+
return itemValue === key;
|
|
33
|
+
});
|
|
34
|
+
labelValue = target instanceof Object ? target === null || target === void 0 ? void 0 : target[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label] : target;
|
|
35
|
+
}
|
|
36
|
+
return labelValue;
|
|
37
|
+
}
|
|
38
|
+
function getLabelByValue(_ref) {
|
|
39
|
+
var value = _ref.value,
|
|
40
|
+
options = _ref.options,
|
|
41
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
42
|
+
fieldNames = _ref$fieldNames === void 0 ? {
|
|
43
|
+
label: 'label',
|
|
44
|
+
value: 'value'
|
|
45
|
+
} : _ref$fieldNames;
|
|
46
|
+
var getLabel = function getLabel(value) {
|
|
47
|
+
var target = options === null || options === void 0 ? void 0 : options.find(function (item) {
|
|
48
|
+
var valueKey = fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value;
|
|
49
|
+
var itemValue = item instanceof Object ? item[valueKey] : item;
|
|
50
|
+
return itemValue === value;
|
|
51
|
+
});
|
|
52
|
+
return target instanceof Object ? target === null || target === void 0 ? void 0 : target[fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.label] : target;
|
|
53
|
+
};
|
|
54
|
+
if ((0, _isArray2["default"])(value)) {
|
|
55
|
+
return value.map(getLabel).join(' | ');
|
|
56
|
+
} else {
|
|
57
|
+
return getLabel(value);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function formatLabel(reactDom) {
|
|
61
|
+
return (0, _flatten2["default"])(_react["default"].Children.map(reactDom.props.children, function (child) {
|
|
62
|
+
if (_react["default"].isValidElement(child)) {
|
|
63
|
+
return formatLabel(child);
|
|
64
|
+
} else if ((0, _isString2["default"])(child)) {
|
|
65
|
+
return child;
|
|
66
|
+
}
|
|
67
|
+
return '';
|
|
68
|
+
})).join('');
|
|
69
|
+
}
|
|
70
|
+
function parseObjectToArray(value, data) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
return (_b = (_a = Object.keys(value)) === null || _a === void 0 ? void 0 : _a.map(function (key) {
|
|
73
|
+
var _a, _b, _c;
|
|
74
|
+
var target = data === null || data === void 0 ? void 0 : data.find(function (item) {
|
|
75
|
+
var _a;
|
|
76
|
+
return ((_a = item.props) === null || _a === void 0 ? void 0 : _a.name) === key;
|
|
77
|
+
});
|
|
78
|
+
if (!target) return null;
|
|
79
|
+
var dataItem = (target === null || target === void 0 ? void 0 : target.props) || {};
|
|
80
|
+
var _ref2 = dataItem || {},
|
|
81
|
+
type = _ref2.type,
|
|
82
|
+
component = _ref2.component,
|
|
83
|
+
setLabel = _ref2.setLabel,
|
|
84
|
+
fieldProps = _ref2.props,
|
|
85
|
+
propsTitle = _ref2.propsTitle,
|
|
86
|
+
title = _ref2.title,
|
|
87
|
+
name = _ref2.name;
|
|
88
|
+
var _propsTitle = propsTitle || title || name;
|
|
89
|
+
var _ref3 = fieldProps || {},
|
|
90
|
+
options = _ref3.options,
|
|
91
|
+
format = _ref3.format;
|
|
92
|
+
var fieldNames = ((_a = dataItem === null || dataItem === void 0 ? void 0 : dataItem.props) === null || _a === void 0 ? void 0 : _a.fieldNames) || {
|
|
93
|
+
label: 'label',
|
|
94
|
+
value: 'value'
|
|
95
|
+
};
|
|
96
|
+
var labelValue = value[key];
|
|
97
|
+
if (!type && component) {
|
|
98
|
+
if (!setLabel) {
|
|
99
|
+
console.error('自定义组件需要传入setLabel()方法');
|
|
100
|
+
}
|
|
101
|
+
} else if (setLabel) {
|
|
102
|
+
// setLabel: 对于自定义组件,无法控制label的显示,可以通过setLabel方法控制
|
|
103
|
+
labelValue = setLabel(labelValue);
|
|
104
|
+
} else if (options) {
|
|
105
|
+
if (type === 'selectInput') {
|
|
106
|
+
var selectKey = (_b = Object.keys(labelValue)) === null || _b === void 0 ? void 0 : _b[0];
|
|
107
|
+
if (!selectKey) {
|
|
108
|
+
// 17. inputSelect组件,初始值{},展示undefined:undefined
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
var inputValue = labelValue[selectKey];
|
|
112
|
+
var selectLabel = (_c = options === null || options === void 0 ? void 0 : options.find(function (v) {
|
|
113
|
+
return v.value === selectKey;
|
|
114
|
+
})) === null || _c === void 0 ? void 0 : _c.label;
|
|
115
|
+
return {
|
|
116
|
+
key: key,
|
|
117
|
+
value: value[key],
|
|
118
|
+
closable: true,
|
|
119
|
+
label: selectLabel + ':' + inputValue
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
labelValue = getLabelByValue({
|
|
123
|
+
value: labelValue,
|
|
124
|
+
options: options,
|
|
125
|
+
fieldNames: fieldNames
|
|
126
|
+
});
|
|
127
|
+
} else if (type === 'dateRange' && format) {
|
|
128
|
+
labelValue = [(0, _moment["default"])(labelValue[0]).format(format), (0, _moment["default"])(labelValue[1]).format(format)].join('~');
|
|
129
|
+
} else if (type === 'date' && format) {
|
|
130
|
+
labelValue = (0, _moment["default"])(labelValue).format(format);
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
key: key,
|
|
134
|
+
value: value[key],
|
|
135
|
+
closable: true,
|
|
136
|
+
label: _propsTitle + ':' + labelValue
|
|
137
|
+
};
|
|
138
|
+
})) === null || _b === void 0 ? void 0 : _b.filter(function (item) {
|
|
139
|
+
return !!item;
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
function parseArrayToObject(value) {
|
|
143
|
+
return value === null || value === void 0 ? void 0 : value.reduce(function (acc, v) {
|
|
144
|
+
acc[v.key] = v.value;
|
|
145
|
+
return acc;
|
|
146
|
+
}, {});
|
|
147
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/query-form-v3/Field/Composition/utils.js"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,mCAAmD;AACnD,oDAA2B;AAE3B,SAAgB,kBAAkB,CAAC,GAAG,EAAE,SAAS;IAC/C,MAAM,WAAW,GAAG,+BAA+B,SAAS,SAAS,CAAA;IACrE,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,WAAW,CAAC,CAAA;AAC7D,CAAC;AAHD,gDAGC;AAED,SAAgB,mBAAmB,CACjC,GAAG,EACH,OAAO,EACP,UAAU,GAAG;IACX,KAAK,EAAE,OAAO;IACd,KAAK,EAAE,OAAO;CACf;IAED,IAAI,UAAU,GAAG,GAAG,CAAA;IACpB,IAAI,OAAO,EAAE;QACX,MAAM,MAAM,GAAG,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACpC,MAAM,QAAQ,GAAG,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,KAAK,CAAA;YAClC,MAAM,SAAS,GAAG,IAAI,YAAY,MAAM,CAAC,CAAC,CAAC,IAA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gBACX,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;gBACpC,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;aACrC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;SACZ;aAAM,IAAI,IAAI,KAAK,MAAM,IAAI,MAAM,EAAE;YACpC,UAAU,GAAG,IAAA,gBAAM,EAAC,UAAU,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;SAC/C;QACD,OAAO;YACL,GAAG;YACH,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC;YACjB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,WAAW,GAAG,GAAG,GAAG,UAAU;SACtC,CAAA;IACH,CAAC,CAAC,0CACA,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAA;AAC9B,CAAC;AA9DD,gDA8DC;AAED,SAAgB,kBAAkB,CAAC,KAAK;IACtC,OAAO,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE;QAC9B,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAA;QACpB,OAAO,GAAG,CAAA;IACZ,CAAC,EAAE,EAAE,CAAC,CAAA;AACR,CAAC;AALD,gDAKC","sourcesContent":["import React from 'react'\nimport { isArray, isString, flatten } from 'lodash'\nimport moment from 'moment'\n\nexport function highlightSubstring(str, substring) {\n const highlighted = `<span class=\"tnt-highlight\">${substring}</span>`\n return str.replace(new RegExp(substring, 'g'), highlighted)\n}\n\nexport function getLabelFromOptions(\n key,\n options,\n fieldNames = {\n label: 'label',\n value: 'value',\n }\n) {\n let labelValue = key\n if (options) {\n const target = options?.find((item) => {\n const valueKey = fieldNames?.value\n const itemValue = item instanceof Object ? item[valueKey] : item\n return itemValue === key\n })\n labelValue = target instanceof Object ? target?.[fieldNames?.label] : target\n }\n return labelValue\n}\n\nexport function getLabelByValue({\n value,\n options,\n fieldNames = {\n label: 'label',\n value: 'value',\n },\n}) {\n const getLabel = (value) => {\n const target = options?.find((item) => {\n const valueKey = fieldNames?.value\n const itemValue = item instanceof Object ? item[valueKey] : item\n return itemValue === value\n })\n return target instanceof Object ? target?.[fieldNames?.label] : target\n }\n if (isArray(value)) {\n return value.map(getLabel).join(' | ')\n } else {\n return getLabel(value)\n }\n}\n\nexport function formatLabel(reactDom) {\n return flatten(\n React.Children.map(reactDom.props.children, (child) => {\n if (React.isValidElement(child)) {\n return formatLabel(child)\n } else if (isString(child)) {\n return child\n }\n return ''\n })\n ).join('')\n}\n\nexport function parseObjectToArray(value, data) {\n return Object.keys(value)\n ?.map((key) => {\n const target = data?.find((item) => item.props?.name === key)\n if (!target) return null\n const dataItem = target?.props || {}\n const {\n type,\n component,\n setLabel,\n props: fieldProps,\n propsTitle,\n title,\n name,\n } = dataItem || {}\n const _propsTitle = propsTitle || title || name\n const { options, format } = fieldProps || {}\n const fieldNames = dataItem?.props?.fieldNames || {\n label: 'label',\n value: 'value',\n }\n let labelValue = value[key]\n if (!type && component) {\n if (!setLabel) {\n console.error('自定义组件需要传入setLabel()方法')\n }\n } else if (setLabel) {\n // setLabel: 对于自定义组件,无法控制label的显示,可以通过setLabel方法控制\n labelValue = setLabel(labelValue)\n } else if (options) {\n if (type === 'selectInput') {\n const selectKey = Object.keys(labelValue)?.[0]\n if (!selectKey) {\n // 17. inputSelect组件,初始值{},展示undefined:undefined\n return false\n }\n const inputValue = labelValue[selectKey]\n const selectLabel = options?.find((v) => v.value === selectKey)?.label\n return {\n key,\n value: value[key],\n closable: true,\n label: selectLabel + ':' + inputValue,\n }\n }\n labelValue = getLabelByValue({ value: labelValue, options, fieldNames })\n } else if (type === 'dateRange' && format) {\n labelValue = [\n moment(labelValue[0]).format(format),\n moment(labelValue[1]).format(format),\n ].join('~')\n } else if (type === 'date' && format) {\n labelValue = moment(labelValue).format(format)\n }\n return {\n key,\n value: value[key],\n closable: true,\n label: _propsTitle + ':' + labelValue,\n }\n })\n ?.filter((item) => !!item)\n}\n\nexport function parseArrayToObject(value) {\n return value?.reduce((acc, v) => {\n acc[v.key] = v.value\n return acc\n }, {})\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.d.ts","sourceRoot":"","sources":["../../../src/query-form-v3/Field/Select.js"],"names":[],"mappings":"AAMe,yDAkDd"}
|
|
@@ -0,0 +1,80 @@
|
|
|
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 _react = _interopRequireWildcard(require("react"));
|
|
9
|
+
var _select = _interopRequireDefault(require("../../select"));
|
|
10
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
+
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); }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
+
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); }
|
|
16
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
17
|
+
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."); }
|
|
18
|
+
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; } }
|
|
19
|
+
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; }
|
|
20
|
+
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; } }
|
|
21
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
22
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
23
|
+
var t = {};
|
|
24
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
25
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
26
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
27
|
+
}
|
|
28
|
+
return t;
|
|
29
|
+
};
|
|
30
|
+
var Option = _select["default"].Option;
|
|
31
|
+
var _default = exports["default"] = function _default(props) {
|
|
32
|
+
var options = props.options,
|
|
33
|
+
params = props.params,
|
|
34
|
+
_props$queryKey = props.queryKey,
|
|
35
|
+
queryKey = _props$queryKey === void 0 ? 'name' : _props$queryKey,
|
|
36
|
+
_props$fieldNames = props.fieldNames,
|
|
37
|
+
fieldNames = _props$fieldNames === void 0 ? {
|
|
38
|
+
label: 'label',
|
|
39
|
+
value: 'value'
|
|
40
|
+
} : _props$fieldNames,
|
|
41
|
+
loadData = props.loadData,
|
|
42
|
+
rest = __rest(props, ["options", "params", "queryKey", "fieldNames", "loadData"]);
|
|
43
|
+
var _useState = (0, _react.useState)(options || []),
|
|
44
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
45
|
+
items = _useState2[0],
|
|
46
|
+
setItems = _useState2[1];
|
|
47
|
+
var _useState3 = (0, _react.useState)(''),
|
|
48
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
49
|
+
query = _useState4[0],
|
|
50
|
+
setQuery = _useState4[1];
|
|
51
|
+
var onSearch = function onSearch(val) {
|
|
52
|
+
setQuery(val);
|
|
53
|
+
};
|
|
54
|
+
if (loadData) {
|
|
55
|
+
(0, _react.useEffect)(function () {
|
|
56
|
+
loadData(Object.assign(_defineProperty({}, queryKey, query), params || {})).then(function (items) {
|
|
57
|
+
setItems(items);
|
|
58
|
+
});
|
|
59
|
+
}, [params, query]);
|
|
60
|
+
}
|
|
61
|
+
(0, _react.useEffect)(function () {
|
|
62
|
+
setItems(options || []);
|
|
63
|
+
}, [options]);
|
|
64
|
+
return _react["default"].createElement(_select["default"], Object.assign({
|
|
65
|
+
allowClear: true,
|
|
66
|
+
showSearch: true,
|
|
67
|
+
optionFilterProp: "children",
|
|
68
|
+
onSearch: onSearch
|
|
69
|
+
}, rest), 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 optionProps = item instanceof Object ? item : {};
|
|
75
|
+
return _react["default"].createElement(Option, Object.assign({}, optionProps, {
|
|
76
|
+
key: value,
|
|
77
|
+
value: value
|
|
78
|
+
}), label);
|
|
79
|
+
}));
|
|
80
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Select.js","sourceRoot":"","sources":["../../../src/query-form-v3/Field/Select.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAElD,0DAAiC;AAEjC,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAA;AAEzB,kBAAe,CAAC,KAAK,EAAE,EAAE;IACvB,MAAM,EACJ,OAAO,EACP,MAAM,EACN,QAAQ,GAAG,MAAM,EACjB,UAAU,GAAG;QACX,KAAK,EAAE,OAAO;QACd,KAAK,EAAE,OAAO;KACf,EACD,QAAQ,KAEN,KAAK,EADJ,IAAI,UACL,KAAK,EAVH,2DAUL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CAAA;QAC5D,MAAM,KAAK,GAAG,IAAI,YAAY,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;QAC5D,MAAM,WAAW,GAAG,IAAI,YAAY,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAA;QAEtD,OAAO,CACL,8BAAC,MAAM,oBAAK,WAAW,IAAE,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,KAC9C,KAAK,CACC,CACV,CAAA;IACH,CAAC,CAAC,CACK,CACV,CAAA;AACH,CAAC,CAAA","sourcesContent":["import React, { useState, useEffect } from 'react'\n\nimport Select from '../../select'\n\nconst { Option } = Select\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 ...rest\n } = props\n const [items, setItems] = useState(options || [])\n const [query, setQuery] = useState('')\n const onSearch = (val) => {\n setQuery(val)\n }\n\n if (loadData) {\n useEffect(() => {\n loadData({\n [queryKey]: query,\n ...(params || {}),\n }).then((items) => {\n setItems(items)\n })\n }, [params, query])\n }\n\n useEffect(() => {\n setItems(options || [])\n }, [options])\n\n return (\n <Select allowClear showSearch optionFilterProp=\"children\" onSearch={onSearch} {...rest}>\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 optionProps = item instanceof Object ? item : {}\n\n return (\n <Option {...optionProps} key={value} value={value}>\n {label}\n </Option>\n )\n })}\n </Select>\n )\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../src/query-form-v3/Field/SelectInput.js"],"names":[],"mappings":"AAQe,yDA+Dd"}
|
|
@@ -0,0 +1,100 @@
|
|
|
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 _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _select = _interopRequireDefault(require("../../select"));
|
|
11
|
+
var _input = _interopRequireDefault(require("../../input"));
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
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; }
|
|
16
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
17
|
+
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); }
|
|
18
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
19
|
+
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."); }
|
|
20
|
+
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; } }
|
|
21
|
+
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; }
|
|
22
|
+
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; } }
|
|
23
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
24
|
+
var __rest = void 0 && (void 0).__rest || function (s, e) {
|
|
25
|
+
var t = {};
|
|
26
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
27
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
28
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
29
|
+
}
|
|
30
|
+
return t;
|
|
31
|
+
};
|
|
32
|
+
var Option = _select["default"].Option;
|
|
33
|
+
var _default = exports["default"] = function _default(props) {
|
|
34
|
+
var _props$options = props.options,
|
|
35
|
+
options = _props$options === void 0 ? [] : _props$options,
|
|
36
|
+
addonBeforeStyle = props.addonBeforeStyle,
|
|
37
|
+
selectProps = props.selectProps,
|
|
38
|
+
form = props.form,
|
|
39
|
+
close = props.close,
|
|
40
|
+
inputProps = __rest(props, ["options", "addonBeforeStyle", "selectProps", "form", "close"]);
|
|
41
|
+
var _useState = (0, _react.useState)(options),
|
|
42
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
43
|
+
items = _useState2[0],
|
|
44
|
+
setItems = _useState2[1];
|
|
45
|
+
var getInitialKey = function getInitialKey() {
|
|
46
|
+
var key = (0, _get2["default"])(options, '0.value');
|
|
47
|
+
if (inputProps.value) {
|
|
48
|
+
key = (0, _get2["default"])(Object.keys(inputProps.value), '0') || key;
|
|
49
|
+
}
|
|
50
|
+
return key;
|
|
51
|
+
};
|
|
52
|
+
var _useState3 = (0, _react.useState)(getInitialKey()),
|
|
53
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
54
|
+
key = _useState4[0],
|
|
55
|
+
setKey = _useState4[1];
|
|
56
|
+
var onKeyChange = function onKeyChange(key) {
|
|
57
|
+
setKey(key);
|
|
58
|
+
props.onChange(_defineProperty({}, key, ''));
|
|
59
|
+
};
|
|
60
|
+
var onChange = function onChange(evt) {
|
|
61
|
+
props.onChange(_defineProperty({}, key, evt.target.value));
|
|
62
|
+
};
|
|
63
|
+
var addonBefore = _react["default"].createElement(_select["default"], Object.assign({
|
|
64
|
+
value: key,
|
|
65
|
+
onChange: onKeyChange,
|
|
66
|
+
style: Object.assign({
|
|
67
|
+
width: '120px'
|
|
68
|
+
}, addonBeforeStyle),
|
|
69
|
+
dropdownMatchSelectWidth: false
|
|
70
|
+
}, selectProps || {}), items.map(function (_ref) {
|
|
71
|
+
var label = _ref.label,
|
|
72
|
+
value = _ref.value;
|
|
73
|
+
return _react["default"].createElement(Option, {
|
|
74
|
+
key: value,
|
|
75
|
+
value: value
|
|
76
|
+
}, label);
|
|
77
|
+
}));
|
|
78
|
+
var getInputValue = function getInputValue() {
|
|
79
|
+
return (0, _get2["default"])(inputProps.value, key);
|
|
80
|
+
};
|
|
81
|
+
(0, _react.useEffect)(function () {
|
|
82
|
+
setItems(options);
|
|
83
|
+
setKey(getInitialKey());
|
|
84
|
+
}, [options, inputProps.value]);
|
|
85
|
+
return _react["default"].createElement(_input["default"].Search, Object.assign({
|
|
86
|
+
addonBefore: addonBefore,
|
|
87
|
+
onPressEnter: function onPressEnter(evt) {
|
|
88
|
+
var _a;
|
|
89
|
+
form.emit('search', _defineProperty(_defineProperty({}, key, (_a = evt === null || evt === void 0 ? void 0 : evt.target) === null || _a === void 0 ? void 0 : _a.value), "current", 1));
|
|
90
|
+
close && close();
|
|
91
|
+
},
|
|
92
|
+
onSearch: function onSearch(value) {
|
|
93
|
+
form.emit('search', _defineProperty(_defineProperty({}, key, value), "current", 1));
|
|
94
|
+
close && close();
|
|
95
|
+
}
|
|
96
|
+
}, inputProps, {
|
|
97
|
+
value: getInputValue(),
|
|
98
|
+
onChange: onChange
|
|
99
|
+
}));
|
|
100
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../src/query-form-v3/Field/SelectInput.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAkD;AAClD,mCAA4B;AAE5B,0DAAiC;AACjC,wDAA+B;AAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,gBAAM,CAAA;AAEzB,kBAAe,CAAC,KAAK,EAAE,EAAE;IACvB,MAAM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CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CAC/B,8BAAC,MAAM,IAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,IAC7B,KAAK,CACC,CACV,CAAC,CACK,CACV,CAAA;IACD,MAAM,aAAa,GAAG,GAAG,EAAE;QACzB,OAAO,IAAA,YAAG,EAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACnC,CAAC,CAAA;IAED,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,QAAQ,CAAC,OAAO,CAAC,CAAA;QACjB,MAAM,CAAC,aAAa,EAAE,CAAC,CAAA;IACzB,CAAC,EAAE,CAAC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAA;IAE/B,OAAO,CACL,8BAAC,eAAK,CAAC,MAAM,kBAAC,WAAW,EAAE,WAAW,EACtC,YAAY,EAAE,CAAC,GAAG,EAAE,EAAE;;YACpB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;YAC9D,KAAK,IAAI,KAAK,EAAE,CAAA;QAClB,CAAC,EACD,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;YAClB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAA;YACjD,KAAK,IAAI,KAAK,EAAE,CAAA;QAClB,CAAC,IACG,UAAU,IAAE,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,QAAQ,IAAM,CACjE,CAAA;AACH,CAAC,CAAA","sourcesContent":["import React, { useState, useEffect } from 'react'\nimport { get } from 'lodash'\n\nimport Select from '../../select'\nimport Input from '../../input'\n\nconst { Option } = Select\n\nexport default (props) => {\n const { options = [], addonBeforeStyle, selectProps, form, close, ...inputProps } = props\n const [items, setItems] = useState(options)\n const getInitialKey = () => {\n let key = get(options, '0.value')\n\n if (inputProps.value) {\n key = get(Object.keys(inputProps.value), '0') || key\n }\n\n return key\n }\n const [key, setKey] = useState(getInitialKey())\n const onKeyChange = (key) => {\n setKey(key)\n props.onChange({\n [key]: '',\n })\n }\n const onChange = (evt) => {\n props.onChange({\n [key]: evt.target.value,\n })\n }\n const addonBefore = (\n <Select\n value={key}\n onChange={onKeyChange}\n style={{\n width: '120px',\n ...addonBeforeStyle,\n }}\n dropdownMatchSelectWidth={false}\n {...(selectProps||{})}\n >\n {items.map(({ label, value }) => (\n <Option key={value} value={value}>\n {label}\n </Option>\n ))}\n </Select>\n )\n const getInputValue = () => {\n return get(inputProps.value, key)\n }\n\n useEffect(() => {\n setItems(options)\n setKey(getInitialKey())\n }, [options, inputProps.value])\n\n return (\n <Input.Search addonBefore={addonBefore} \n onPressEnter={(evt) => {\n form.emit('search', { [key]: evt?.target?.value, current: 1 })\n close && close()\n }}\n onSearch={(value) => {\n form.emit('search', { [key]: value, current: 1 })\n close && close()\n }}\n {...inputProps} value={getInputValue()} onChange={onChange} />\n )\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const defaultFieldWidth: "200px";
|
|
2
|
+
export function getFieldWidth(type: any): any;
|
|
3
|
+
declare namespace _default {
|
|
4
|
+
export const string: import("react").ForwardRefExoticComponent<import("../../input").SearchProps & {
|
|
5
|
+
capitalize?: boolean | undefined;
|
|
6
|
+
} & import("react").RefAttributes<import("antd/lib/input/Search").default>>;
|
|
7
|
+
export const input: import("react").ForwardRefExoticComponent<import("../../input").SearchProps & {
|
|
8
|
+
capitalize?: boolean | undefined;
|
|
9
|
+
} & import("react").RefAttributes<import("antd/lib/input/Search").default>>;
|
|
10
|
+
export const search: import("react").ForwardRefExoticComponent<import("../../input").SearchProps & {
|
|
11
|
+
capitalize?: boolean | undefined;
|
|
12
|
+
} & import("react").RefAttributes<import("antd/lib/input/Search").default>>;
|
|
13
|
+
export { InputNumber as inputNumber };
|
|
14
|
+
export { InputNumber as number };
|
|
15
|
+
export { SelectField as select };
|
|
16
|
+
export { CheckboxField as checkbox };
|
|
17
|
+
export { DatePicker as date };
|
|
18
|
+
export const dateRange: import("react").ClassicComponentClass<import("antd/lib/date-picker/interface").RangePickerProps>;
|
|
19
|
+
export { SelectInput as selectInput };
|
|
20
|
+
}
|
|
21
|
+
export default _default;
|
|
22
|
+
import InputNumber from "../../input-number";
|
|
23
|
+
import SelectField from "./Select";
|
|
24
|
+
import CheckboxField from "./Checkbox";
|
|
25
|
+
import DatePicker from "../../date-picker";
|
|
26
|
+
import SelectInput from "./SelectInput";
|
|
27
|
+
//# sourceMappingURL=fieldsMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldsMap.d.ts","sourceRoot":"","sources":["../../../src/query-form-v3/Field/fieldsMap.js"],"names":[],"mappings":"AAOA,wCAAwC;AAEjC,8CAWN"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getFieldWidth = exports.defaultFieldWidth = exports["default"] = void 0;
|
|
7
|
+
var _Checkbox = _interopRequireDefault(require("./Checkbox"));
|
|
8
|
+
var _Select = _interopRequireDefault(require("./Select"));
|
|
9
|
+
var _SelectInput = _interopRequireDefault(require("./SelectInput"));
|
|
10
|
+
var _datePicker = _interopRequireDefault(require("../../date-picker"));
|
|
11
|
+
var _input = _interopRequireDefault(require("../../input"));
|
|
12
|
+
var _inputNumber = _interopRequireDefault(require("../../input-number"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
14
|
+
var defaultFieldWidth = exports.defaultFieldWidth = '200px';
|
|
15
|
+
var getFieldWidth = exports.getFieldWidth = function getFieldWidth(type) {
|
|
16
|
+
if (type === 'dateRange') {
|
|
17
|
+
return '340px';
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
dateRange: '340px',
|
|
21
|
+
selectInput: '320px'
|
|
22
|
+
}[type] || defaultFieldWidth;
|
|
23
|
+
};
|
|
24
|
+
var _default = exports["default"] = {
|
|
25
|
+
string: _input["default"].Search,
|
|
26
|
+
input: _input["default"].Search,
|
|
27
|
+
search: _input["default"].Search,
|
|
28
|
+
inputNumber: _inputNumber["default"],
|
|
29
|
+
number: _inputNumber["default"],
|
|
30
|
+
select: _Select["default"],
|
|
31
|
+
checkbox: _Checkbox["default"],
|
|
32
|
+
date: _datePicker["default"],
|
|
33
|
+
dateRange: _datePicker["default"].RangePicker,
|
|
34
|
+
selectInput: _SelectInput["default"]
|
|
35
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fieldsMap.js","sourceRoot":"","sources":["../../../src/query-form-v3/Field/fieldsMap.js"],"names":[],"mappings":";;;;;;AAAA,0DAAsC;AACtC,sDAAkC;AAClC,gEAAuC;AACvC,oEAA0C;AAC1C,wDAA+B;AAC/B,sEAA4C;AAE/B,QAAA,iBAAiB,GAAG,OAAO,CAAA;AAEjC,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,EAAE;IACpC,IAAI,IAAI,KAAK,WAAW,EAAE;QACxB,OAAO,OAAO,CAAA;KACf;IAED,OAAO,CACL;QACE,SAAS,EAAE,OAAO;QAClB,WAAW,EAAE,OAAO;KACrB,CAAC,IAAI,CAAC,IAAI,yBAAiB,CAC7B,CAAA;AACH,CAAC,CAAA;AAXY,QAAA,aAAa,iBAWzB;AAED,kBAAe;IACb,MAAM,EAAE,eAAK,CAAC,MAAM;IACpB,KAAK,EAAE,eAAK,CAAC,MAAM;IACnB,MAAM,EAAE,eAAK,CAAC,MAAM;IACpB,WAAW,EAAE,sBAAW;IACxB,MAAM,EAAE,sBAAW;IACnB,MAAM,EAAE,gBAAW;IACnB,QAAQ,EAAE,kBAAa;IACvB,IAAI,EAAE,qBAAU;IAChB,SAAS,EAAE,qBAAU,CAAC,WAAW;IACjC,WAAW,EAAE,qBAAW;CACzB,CAAA","sourcesContent":["import CheckboxField from './Checkbox'\nimport SelectField from './Select'\nimport SelectInput from './SelectInput'\nimport DatePicker from '../../date-picker'\nimport Input from '../../input'\nimport InputNumber from '../../input-number'\n\nexport const defaultFieldWidth = '200px'\n\nexport const getFieldWidth = (type) => {\n if (type === 'dateRange') {\n return '340px'\n }\n\n return (\n {\n dateRange: '340px',\n selectInput: '320px',\n }[type] || defaultFieldWidth\n )\n}\n\nexport default {\n string: Input.Search,\n input: Input.Search,\n search: Input.Search,\n inputNumber: InputNumber,\n number: InputNumber,\n select: SelectField,\n checkbox: CheckboxField,\n date: DatePicker,\n dateRange: DatePicker.RangePicker,\n selectInput: SelectInput,\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default class Field extends React.PureComponent<any, any, any> {
|
|
2
|
+
constructor(props: any);
|
|
3
|
+
state: {
|
|
4
|
+
value: any;
|
|
5
|
+
};
|
|
6
|
+
render(): React.JSX.Element;
|
|
7
|
+
updateValue: (name: any, value: any) => void;
|
|
8
|
+
onChange: (...args: any[]) => void;
|
|
9
|
+
onFormChange: (formData: any) => void;
|
|
10
|
+
componentDidMount(): void;
|
|
11
|
+
componentWillUnmount(): void;
|
|
12
|
+
}
|
|
13
|
+
import React from "react";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/query-form-v3/Field/index.js"],"names":[],"mappings":"AAUA;IACE,wBAMC;IAHC;;MAEC;IAGH,4BAmCC;IAED,6CAKC;IAED,mCAaC;IAED,sCAIC;IAED,0BAKC;IAED,6BAKC;CACF"}
|
|
@@ -0,0 +1,147 @@
|
|
|
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 _react = _interopRequireWildcard(require("react"));
|
|
10
|
+
var _fieldsMap = _interopRequireWildcard(require("./fieldsMap"));
|
|
11
|
+
var _form = _interopRequireDefault(require("../../form"));
|
|
12
|
+
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); }
|
|
13
|
+
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; }
|
|
14
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
15
|
+
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; }
|
|
16
|
+
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
17
|
+
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
18
|
+
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
19
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
20
|
+
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); }
|
|
21
|
+
function _callSuper(t, o, e) { return o = _getPrototypeOf(o), _possibleConstructorReturn(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], _getPrototypeOf(t).constructor) : o.apply(t, e)); }
|
|
22
|
+
function _possibleConstructorReturn(t, e) { if (e && ("object" == _typeof(e) || "function" == typeof e)) return e; if (void 0 !== e) throw new TypeError("Derived constructors may only return object or undefined"); return _assertThisInitialized(t); }
|
|
23
|
+
function _assertThisInitialized(e) { if (void 0 === e) throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); return e; }
|
|
24
|
+
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
|
|
25
|
+
function _getPrototypeOf(t) { return _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function (t) { return t.__proto__ || Object.getPrototypeOf(t); }, _getPrototypeOf(t); }
|
|
26
|
+
function _inherits(t, e) { if ("function" != typeof e && null !== e) throw new TypeError("Super expression must either be null or a function"); t.prototype = Object.create(e && e.prototype, { constructor: { value: t, writable: !0, configurable: !0 } }), Object.defineProperty(t, "prototype", { writable: !1 }), e && _setPrototypeOf(t, e); }
|
|
27
|
+
function _setPrototypeOf(t, e) { return _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function (t, e) { return t.__proto__ = e, t; }, _setPrototypeOf(t, e); }
|
|
28
|
+
var FormItem = _form["default"].Item;
|
|
29
|
+
var isInput = function isInput(type) {
|
|
30
|
+
return ['input', 'string', 'search', 'aloneSearch'].includes(type);
|
|
31
|
+
};
|
|
32
|
+
var Field = exports["default"] = /*#__PURE__*/function (_PureComponent) {
|
|
33
|
+
function Field(props) {
|
|
34
|
+
var _this;
|
|
35
|
+
_classCallCheck(this, Field);
|
|
36
|
+
_this = _callSuper(this, Field, [props]);
|
|
37
|
+
Object.defineProperty(_this, "updateValue", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: function value(name, _value) {
|
|
42
|
+
if (name === _this.props.name) {
|
|
43
|
+
_this.setState({
|
|
44
|
+
value: _value
|
|
45
|
+
});
|
|
46
|
+
_this.props.onChange(name, _value);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(_this, "onChange", {
|
|
51
|
+
enumerable: true,
|
|
52
|
+
configurable: true,
|
|
53
|
+
writable: true,
|
|
54
|
+
value: function value() {
|
|
55
|
+
var _this$props = _this.props,
|
|
56
|
+
name = _this$props.name,
|
|
57
|
+
_this$props$type = _this$props.type,
|
|
58
|
+
type = _this$props$type === void 0 ? 'input' : _this$props$type,
|
|
59
|
+
component = _this$props.component,
|
|
60
|
+
fieldProps = _this$props.props;
|
|
61
|
+
var _ref = fieldProps || {},
|
|
62
|
+
onChange = _ref.onChange;
|
|
63
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
64
|
+
args[_key] = arguments[_key];
|
|
65
|
+
}
|
|
66
|
+
onChange && onChange.apply(void 0, args);
|
|
67
|
+
// Input onChange第一个参数为Event对象,取值特殊处理
|
|
68
|
+
if (!component && isInput(type)) {
|
|
69
|
+
args[0] = (0, _get2["default"])(args[0], 'target.value');
|
|
70
|
+
}
|
|
71
|
+
_this.setState({
|
|
72
|
+
value: args[0]
|
|
73
|
+
});
|
|
74
|
+
_this.props.onChange(name, args[0]);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(_this, "onFormChange", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: function value(formData) {
|
|
82
|
+
_this.setState({
|
|
83
|
+
value: (0, _get2["default"])(formData, _this.props.name)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
_this.state = {
|
|
88
|
+
value: props.initialValue
|
|
89
|
+
};
|
|
90
|
+
return _this;
|
|
91
|
+
}
|
|
92
|
+
_inherits(Field, _PureComponent);
|
|
93
|
+
return _createClass(Field, [{
|
|
94
|
+
key: "render",
|
|
95
|
+
value: function render() {
|
|
96
|
+
var _a;
|
|
97
|
+
var _this$props2 = this.props,
|
|
98
|
+
_this$props2$type = _this$props2.type,
|
|
99
|
+
type = _this$props2$type === void 0 ? 'input' : _this$props2$type,
|
|
100
|
+
title = _this$props2.title,
|
|
101
|
+
name = _this$props2.name,
|
|
102
|
+
_this$props2$isFieldI = _this$props2.isFieldInDrawer,
|
|
103
|
+
isFieldInDrawer = _this$props2$isFieldI === void 0 ? false : _this$props2$isFieldI,
|
|
104
|
+
_this$props2$classNam = _this$props2.className,
|
|
105
|
+
className = _this$props2$classNam === void 0 ? '' : _this$props2$classNam,
|
|
106
|
+
component = _this$props2.component,
|
|
107
|
+
form = _this$props2.form,
|
|
108
|
+
fieldProps = _this$props2.props;
|
|
109
|
+
var value = this.state.value;
|
|
110
|
+
var _Field = component || _fieldsMap["default"][type];
|
|
111
|
+
return _react["default"].createElement(FormItem, {
|
|
112
|
+
label: title,
|
|
113
|
+
className: className
|
|
114
|
+
}, _react["default"].createElement(_Field, Object.assign({
|
|
115
|
+
form: form,
|
|
116
|
+
value: value
|
|
117
|
+
}, isInput(type) ? {
|
|
118
|
+
onPressEnter: function onPressEnter(evt) {
|
|
119
|
+
var _a;
|
|
120
|
+
return form.emit('search', _defineProperty(_defineProperty({}, name, (_a = evt === null || evt === void 0 ? void 0 : evt.target) === null || _a === void 0 ? void 0 : _a.value), "current", 1));
|
|
121
|
+
},
|
|
122
|
+
onSearch: function onSearch(value) {
|
|
123
|
+
return form.emit('search', _defineProperty(_defineProperty({}, name, value), "current", 1));
|
|
124
|
+
}
|
|
125
|
+
} : {}, fieldProps, {
|
|
126
|
+
style: Object.assign(Object.assign({}, fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style), {
|
|
127
|
+
width: isFieldInDrawer ? '100%' : ((_a = fieldProps === null || fieldProps === void 0 ? void 0 : fieldProps.style) === null || _a === void 0 ? void 0 : _a.width) || (0, _fieldsMap.getFieldWidth)(type)
|
|
128
|
+
}),
|
|
129
|
+
onChange: this.onChange
|
|
130
|
+
})));
|
|
131
|
+
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "componentDidMount",
|
|
134
|
+
value: function componentDidMount() {
|
|
135
|
+
var form = this.props.form;
|
|
136
|
+
form.on('setValue', this.updateValue);
|
|
137
|
+
form.on('setValues', this.onFormChange);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "componentWillUnmount",
|
|
141
|
+
value: function componentWillUnmount() {
|
|
142
|
+
var form = this.props.form;
|
|
143
|
+
form.off('setValue', this.updateValue);
|
|
144
|
+
form.off('setValues', this.onFormChange);
|
|
145
|
+
}
|
|
146
|
+
}]);
|
|
147
|
+
}(_react.PureComponent);
|