tntd 3.0.26-beta.1 → 3.0.27
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/CHANGELOG.json +1034 -0
- package/CHANGELOG.md +605 -0
- package/es/checkbox/checkbox-group.js +5 -0
- package/es/checkbox/checkbox-group.js.map +1 -0
- package/es/index.js +0 -1
- package/es/index.js.map +1 -1
- package/es/query-form/Field/Checkbox.js +1 -1
- package/es/query-form/Field/Checkbox.js.map +1 -1
- package/es/query-form/Field/SelectInput.js +4 -22
- package/es/query-form/Field/SelectInput.js.map +1 -1
- package/es/query-form/Field/fieldsMap.js +2 -2
- package/es/query-form/Field/fieldsMap.js.map +1 -1
- package/es/query-form/Field/index.js +0 -1
- package/es/query-form/Field/index.js.map +1 -1
- package/es/query-form/index.js +335 -163
- package/es/query-form/index.js.map +1 -1
- package/es/query-form/index.less +60 -29
- package/es/query-list-scene/List.js +1 -14
- package/es/query-list-scene/List.js.map +1 -1
- package/es/query-list-scene/QueryForm.js +9 -22
- package/es/query-list-scene/QueryForm.js.map +1 -1
- package/es/query-list-scene/index.js +1 -2
- package/es/query-list-scene/index.js.map +1 -1
- package/es/radio/radio-group.js +5 -0
- package/es/radio/radio-group.js.map +1 -0
- package/es/steps/stepStyle/small.less +5 -0
- package/es/tntd-select/index.js.map +1 -1
- package/es/tntd-virtual-tree/index.js +3 -2
- package/es/tntd-virtual-tree/index.js.map +1 -1
- package/es/tntd-virtual-tree-select/index.js +4 -2
- package/es/tntd-virtual-tree-select/index.js.map +1 -1
- package/es/upload/svg/UploadSVG.js +37 -0
- package/es/upload/svg/UploadSVG.js.map +1 -0
- package/es/upload/upload.less +108 -0
- package/es/utils/index.js +1 -0
- package/es/utils/index.js.map +1 -1
- package/lib/checkbox/checkbox-group.d.ts +8 -0
- package/lib/checkbox/checkbox-group.d.ts.map +1 -0
- package/lib/checkbox/checkbox-group.js +12 -0
- package/lib/checkbox/checkbox-group.js.map +1 -0
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -7
- package/lib/index.js.map +1 -1
- package/lib/query-form/Field/Checkbox.js +1 -1
- package/lib/query-form/Field/Checkbox.js.map +1 -1
- package/lib/query-form/Field/SelectInput.d.ts.map +1 -1
- package/lib/query-form/Field/SelectInput.js +3 -15
- package/lib/query-form/Field/SelectInput.js.map +1 -1
- package/lib/query-form/Field/fieldsMap.d.ts +3 -6
- package/lib/query-form/Field/fieldsMap.js +2 -2
- package/lib/query-form/Field/fieldsMap.js.map +1 -1
- package/lib/query-form/Field/index.d.ts.map +1 -1
- package/lib/query-form/Field/index.js +0 -1
- package/lib/query-form/Field/index.js.map +1 -1
- package/lib/query-form/index.d.ts +27 -18
- package/lib/query-form/index.d.ts.map +1 -1
- package/lib/query-form/index.js +360 -183
- package/lib/query-form/index.js.map +1 -1
- package/lib/query-form/index.less +60 -29
- package/lib/query-list-scene/List.d.ts.map +1 -1
- package/lib/query-list-scene/List.js +1 -15
- package/lib/query-list-scene/List.js.map +1 -1
- package/lib/query-list-scene/QueryForm.d.ts +3 -4
- package/lib/query-list-scene/QueryForm.d.ts.map +1 -1
- package/lib/query-list-scene/QueryForm.js +10 -23
- package/lib/query-list-scene/QueryForm.js.map +1 -1
- package/lib/query-list-scene/index.d.ts.map +1 -1
- package/lib/query-list-scene/index.js +1 -2
- package/lib/query-list-scene/index.js.map +1 -1
- package/lib/radio/radio-group.d.ts +8 -0
- package/lib/radio/radio-group.d.ts.map +1 -0
- package/lib/radio/radio-group.js +12 -0
- package/lib/radio/radio-group.js.map +1 -0
- package/lib/steps/stepStyle/small.less +5 -0
- package/lib/tntd-select/index.d.ts.map +1 -1
- package/lib/tntd-select/index.js.map +1 -1
- package/lib/tntd-virtual-tree/index.d.ts +2 -1
- package/lib/tntd-virtual-tree/index.d.ts.map +1 -1
- package/lib/tntd-virtual-tree/index.js +5 -3
- package/lib/tntd-virtual-tree/index.js.map +1 -1
- package/lib/tntd-virtual-tree-select/index.d.ts +2 -1
- package/lib/tntd-virtual-tree-select/index.d.ts.map +1 -1
- package/lib/tntd-virtual-tree-select/index.js +6 -3
- package/lib/tntd-virtual-tree-select/index.js.map +1 -1
- package/lib/{query-form-v3/Field/Composition/Select.d.ts → upload/svg/UploadSVG.d.ts} +1 -1
- package/lib/upload/svg/UploadSVG.d.ts.map +1 -0
- package/lib/upload/svg/UploadSVG.js +44 -0
- package/lib/upload/svg/UploadSVG.js.map +1 -0
- package/lib/upload/upload.less +108 -0
- package/lib/utils/index.d.ts.map +1 -1
- package/lib/utils/index.js +12 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +2 -3
- package/es/query-form/Field/Composition/FieldPopover.js +0 -304
- package/es/query-form/Field/Composition/FieldPopover.js.map +0 -1
- package/es/query-form/Field/Composition/FieldPopover.less +0 -35
- package/es/query-form/Field/Composition/Select.js +0 -122
- package/es/query-form/Field/Composition/Select.js.map +0 -1
- package/es/query-form/Field/Composition/ValueTag.js +0 -121
- package/es/query-form/Field/Composition/ValueTag.js.map +0 -1
- package/es/query-form/Field/Composition/index.js +0 -233
- package/es/query-form/Field/Composition/index.js.map +0 -1
- package/es/query-form/Field/Composition/index.less +0 -118
- package/es/query-form/Field/Composition/utils.js +0 -154
- package/es/query-form/Field/Composition/utils.js.map +0 -1
- package/es/query-form-v2/index.less +0 -133
- package/es/scroll-bar/Bar.js +0 -56
- package/es/scroll-bar/Bar.js.map +0 -1
- package/es/scroll-bar/Context.js +0 -6
- package/es/scroll-bar/Context.js.map +0 -1
- package/es/scroll-bar/ScrollBar.js +0 -86
- package/es/scroll-bar/ScrollBar.js.map +0 -1
- package/es/scroll-bar/Thumb.js +0 -105
- package/es/scroll-bar/Thumb.js.map +0 -1
- package/es/scroll-bar/index.js +0 -3
- package/es/scroll-bar/index.js.map +0 -1
- package/es/scroll-bar/scrollBar.less +0 -59
- package/es/scroll-bar/util.js +0 -31
- package/es/scroll-bar/util.js.map +0 -1
- package/lib/query-form/Field/Composition/FieldPopover.d.ts +0 -19
- package/lib/query-form/Field/Composition/FieldPopover.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/FieldPopover.js +0 -338
- package/lib/query-form/Field/Composition/FieldPopover.js.map +0 -1
- package/lib/query-form/Field/Composition/FieldPopover.less +0 -35
- package/lib/query-form/Field/Composition/Select.d.ts +0 -4
- package/lib/query-form/Field/Composition/Select.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/Select.js +0 -146
- package/lib/query-form/Field/Composition/Select.js.map +0 -1
- package/lib/query-form/Field/Composition/ValueTag.d.ts +0 -12
- package/lib/query-form/Field/Composition/ValueTag.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/ValueTag.js +0 -150
- package/lib/query-form/Field/Composition/ValueTag.js.map +0 -1
- package/lib/query-form/Field/Composition/index.d.ts +0 -12
- package/lib/query-form/Field/Composition/index.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/index.js +0 -277
- package/lib/query-form/Field/Composition/index.js.map +0 -1
- package/lib/query-form/Field/Composition/index.less +0 -118
- package/lib/query-form/Field/Composition/utils.d.ts +0 -22
- package/lib/query-form/Field/Composition/utils.d.ts.map +0 -1
- package/lib/query-form/Field/Composition/utils.js +0 -168
- package/lib/query-form/Field/Composition/utils.js.map +0 -1
- package/lib/query-form-v2/Field/Checkbox.d.ts +0 -8
- package/lib/query-form-v2/Field/Checkbox.d.ts.map +0 -1
- package/lib/query-form-v2/Field/Checkbox.js +0 -28
- package/lib/query-form-v2/Field/Checkbox.js.map +0 -1
- package/lib/query-form-v2/Field/Select.d.ts +0 -4
- package/lib/query-form-v2/Field/Select.d.ts.map +0 -1
- package/lib/query-form-v2/Field/Select.js +0 -80
- package/lib/query-form-v2/Field/Select.js.map +0 -1
- package/lib/query-form-v2/Field/SelectInput.d.ts +0 -4
- package/lib/query-form-v2/Field/SelectInput.d.ts.map +0 -1
- package/lib/query-form-v2/Field/SelectInput.js +0 -88
- package/lib/query-form-v2/Field/SelectInput.js.map +0 -1
- package/lib/query-form-v2/Field/fieldsMap.d.ts +0 -24
- package/lib/query-form-v2/Field/fieldsMap.d.ts.map +0 -1
- package/lib/query-form-v2/Field/fieldsMap.js +0 -35
- package/lib/query-form-v2/Field/fieldsMap.js.map +0 -1
- package/lib/query-form-v2/Field/index.d.ts +0 -14
- package/lib/query-form-v2/Field/index.d.ts.map +0 -1
- package/lib/query-form-v2/Field/index.js +0 -146
- package/lib/query-form-v2/Field/index.js.map +0 -1
- package/lib/query-form-v2/createActions.d.ts +0 -14
- package/lib/query-form-v2/createActions.d.ts.map +0 -1
- package/lib/query-form-v2/createActions.js +0 -54
- package/lib/query-form-v2/createActions.js.map +0 -1
- package/lib/query-form-v2/index.d.ts +0 -39
- package/lib/query-form-v2/index.d.ts.map +0 -1
- package/lib/query-form-v2/index.js +0 -391
- package/lib/query-form-v2/index.js.map +0 -1
- package/lib/query-form-v2/index.less +0 -133
- package/lib/query-form-v2/useForm.d.ts +0 -13
- package/lib/query-form-v2/useForm.d.ts.map +0 -1
- package/lib/query-form-v2/useForm.js +0 -13
- package/lib/query-form-v2/useForm.js.map +0 -1
- package/lib/query-form-v3/Field/Checkbox.d.ts +0 -8
- package/lib/query-form-v3/Field/Checkbox.d.ts.map +0 -1
- package/lib/query-form-v3/Field/Checkbox.js +0 -28
- package/lib/query-form-v3/Field/Checkbox.js.map +0 -1
- package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts +0 -19
- package/lib/query-form-v3/Field/Composition/FieldPopover.d.ts.map +0 -1
- package/lib/query-form-v3/Field/Composition/FieldPopover.js +0 -381
- package/lib/query-form-v3/Field/Composition/FieldPopover.js.map +0 -1
- package/lib/query-form-v3/Field/Composition/FieldPopover.less +0 -35
- package/lib/query-form-v3/Field/Composition/Select.d.ts.map +0 -1
- package/lib/query-form-v3/Field/Composition/Select.js +0 -131
- package/lib/query-form-v3/Field/Composition/Select.js.map +0 -1
- package/lib/query-form-v3/Field/Composition/index.d.ts +0 -10
- package/lib/query-form-v3/Field/Composition/index.d.ts.map +0 -1
- package/lib/query-form-v3/Field/Composition/index.js +0 -255
- package/lib/query-form-v3/Field/Composition/index.js.map +0 -1
- package/lib/query-form-v3/Field/Composition/index.less +0 -118
- package/lib/query-form-v3/Field/Composition/utils.d.ts +0 -22
- package/lib/query-form-v3/Field/Composition/utils.d.ts.map +0 -1
- package/lib/query-form-v3/Field/Composition/utils.js +0 -147
- package/lib/query-form-v3/Field/Composition/utils.js.map +0 -1
- package/lib/query-form-v3/Field/Select.d.ts +0 -4
- package/lib/query-form-v3/Field/Select.d.ts.map +0 -1
- package/lib/query-form-v3/Field/Select.js +0 -80
- package/lib/query-form-v3/Field/Select.js.map +0 -1
- package/lib/query-form-v3/Field/SelectInput.d.ts +0 -4
- package/lib/query-form-v3/Field/SelectInput.d.ts.map +0 -1
- package/lib/query-form-v3/Field/SelectInput.js +0 -100
- package/lib/query-form-v3/Field/SelectInput.js.map +0 -1
- package/lib/query-form-v3/Field/fieldsMap.d.ts +0 -27
- package/lib/query-form-v3/Field/fieldsMap.d.ts.map +0 -1
- package/lib/query-form-v3/Field/fieldsMap.js +0 -35
- package/lib/query-form-v3/Field/fieldsMap.js.map +0 -1
- package/lib/query-form-v3/Field/index.d.ts +0 -14
- package/lib/query-form-v3/Field/index.d.ts.map +0 -1
- package/lib/query-form-v3/Field/index.js +0 -147
- package/lib/query-form-v3/Field/index.js.map +0 -1
- package/lib/query-form-v3/createActions.d.ts +0 -14
- package/lib/query-form-v3/createActions.d.ts.map +0 -1
- package/lib/query-form-v3/createActions.js +0 -54
- package/lib/query-form-v3/createActions.js.map +0 -1
- package/lib/query-form-v3/index.d.ts +0 -27
- package/lib/query-form-v3/index.d.ts.map +0 -1
- package/lib/query-form-v3/index.js +0 -206
- package/lib/query-form-v3/index.js.map +0 -1
- package/lib/query-form-v3/index.less +0 -91
- package/lib/query-form-v3/useForm.d.ts +0 -13
- package/lib/query-form-v3/useForm.d.ts.map +0 -1
- package/lib/query-form-v3/useForm.js +0 -13
- package/lib/query-form-v3/useForm.js.map +0 -1
- package/lib/scroll-bar/Bar.d.ts +0 -4
- package/lib/scroll-bar/Bar.d.ts.map +0 -1
- package/lib/scroll-bar/Bar.js +0 -91
- package/lib/scroll-bar/Bar.js.map +0 -1
- package/lib/scroll-bar/Context.d.ts +0 -7
- package/lib/scroll-bar/Context.d.ts.map +0 -1
- package/lib/scroll-bar/Context.js +0 -13
- package/lib/scroll-bar/Context.js.map +0 -1
- package/lib/scroll-bar/ScrollBar.d.ts +0 -4
- package/lib/scroll-bar/ScrollBar.d.ts.map +0 -1
- package/lib/scroll-bar/ScrollBar.js +0 -97
- package/lib/scroll-bar/ScrollBar.js.map +0 -1
- package/lib/scroll-bar/Thumb.d.ts +0 -3
- package/lib/scroll-bar/Thumb.d.ts.map +0 -1
- package/lib/scroll-bar/Thumb.js +0 -125
- package/lib/scroll-bar/Thumb.js.map +0 -1
- package/lib/scroll-bar/index.d.ts +0 -3
- package/lib/scroll-bar/index.d.ts.map +0 -1
- package/lib/scroll-bar/index.js +0 -10
- package/lib/scroll-bar/index.js.map +0 -1
- package/lib/scroll-bar/scrollBar.less +0 -59
- package/lib/scroll-bar/util.d.ts +0 -40
- package/lib/scroll-bar/util.d.ts.map +0 -1
- package/lib/scroll-bar/util.js +0 -39
- package/lib/scroll-bar/util.js.map +0 -1
|
@@ -17,11 +17,9 @@ export default (props => {
|
|
|
17
17
|
const {
|
|
18
18
|
options = [],
|
|
19
19
|
addonBeforeStyle,
|
|
20
|
-
selectProps
|
|
21
|
-
form,
|
|
22
|
-
close
|
|
20
|
+
selectProps
|
|
23
21
|
} = props,
|
|
24
|
-
inputProps = __rest(props, ["options", "addonBeforeStyle", "selectProps"
|
|
22
|
+
inputProps = __rest(props, ["options", "addonBeforeStyle", "selectProps"]);
|
|
25
23
|
const [items, setItems] = useState(options);
|
|
26
24
|
const getInitialKey = () => {
|
|
27
25
|
let key = _get(options, '0.value');
|
|
@@ -63,25 +61,9 @@ export default (props => {
|
|
|
63
61
|
setItems(options);
|
|
64
62
|
setKey(getInitialKey());
|
|
65
63
|
}, [options, inputProps.value]);
|
|
66
|
-
return React.createElement(Input
|
|
67
|
-
addonBefore: addonBefore,
|
|
68
|
-
onPressEnter: evt => {
|
|
69
|
-
var _a;
|
|
70
|
-
form.emit('search', {
|
|
71
|
-
[key]: (_a = evt === null || evt === void 0 ? void 0 : evt.target) === null || _a === void 0 ? void 0 : _a.value,
|
|
72
|
-
current: 1
|
|
73
|
-
});
|
|
74
|
-
close && close();
|
|
75
|
-
},
|
|
76
|
-
onSearch: value => {
|
|
77
|
-
form.emit('search', {
|
|
78
|
-
[key]: value,
|
|
79
|
-
current: 1
|
|
80
|
-
});
|
|
81
|
-
close && close();
|
|
82
|
-
}
|
|
83
|
-
}, inputProps, {
|
|
64
|
+
return React.createElement(Input, Object.assign({}, inputProps, {
|
|
84
65
|
value: getInputValue(),
|
|
66
|
+
addonBefore: addonBefore,
|
|
85
67
|
onChange: onChange
|
|
86
68
|
}));
|
|
87
69
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../src/query-form/Field/SelectInput.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"SelectInput.js","sourceRoot":"","sources":["../../../src/query-form/Field/SelectInput.js"],"names":[],"mappings":";;;;;;;;;;;AAAA,OAAO,KAAK,EAAE,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAE5B,OAAO,MAAM,MAAM,cAAc,CAAA;AACjC,OAAO,KAAK,MAAM,aAAa,CAAA;AAE/B,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;AAEzB,eAAe,CAAC,K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KAAK,EAAE,EAAE,EAAE,CAAC,CAC/B,oBAAC,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,GAAG,CAAC,UAAU,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IACnC,CAAC,CAAA;IAED,SAAS,CAAC,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,oBAAC,KAAK,oBAAK,UAAU,IAAE,KAAK,EAAE,aAAa,EAAE,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,IAAI,CAChG,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,...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 {...inputProps} value={getInputValue()} addonBefore={addonBefore} onChange={onChange} />\n )\n}\n"]}
|
|
@@ -15,8 +15,8 @@ export const getFieldWidth = type => {
|
|
|
15
15
|
}[type] || defaultFieldWidth;
|
|
16
16
|
};
|
|
17
17
|
export default {
|
|
18
|
-
string: Input
|
|
19
|
-
input: Input
|
|
18
|
+
string: Input,
|
|
19
|
+
input: Input,
|
|
20
20
|
search: Input.Search,
|
|
21
21
|
inputNumber: InputNumber,
|
|
22
22
|
number: InputNumber,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fieldsMap.js","sourceRoot":"","sources":["../../../src/query-form/Field/fieldsMap.js"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,YAAY,CAAA;AACtC,OAAO,WAAW,MAAM,UAAU,CAAA;AAClC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,UAAU,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,MAAM,aAAa,CAAA;AAC/B,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAExC,MAAM,CAAC,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,iBAAiB,CAC7B,CAAA;AACH,CAAC,CAAA;AAED,eAAe;IACb,MAAM,EAAE,KAAK
|
|
1
|
+
{"version":3,"file":"fieldsMap.js","sourceRoot":"","sources":["../../../src/query-form/Field/fieldsMap.js"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,YAAY,CAAA;AACtC,OAAO,WAAW,MAAM,UAAU,CAAA;AAClC,OAAO,WAAW,MAAM,eAAe,CAAA;AACvC,OAAO,UAAU,MAAM,mBAAmB,CAAA;AAC1C,OAAO,KAAK,MAAM,aAAa,CAAA;AAC/B,OAAO,WAAW,MAAM,oBAAoB,CAAA;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAA;AAExC,MAAM,CAAC,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,iBAAiB,CAC7B,CAAA;AACH,CAAC,CAAA;AAED,eAAe;IACb,MAAM,EAAE,KAAK;IACb,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE,KAAK,CAAC,MAAM;IACpB,WAAW,EAAE,WAAW;IACxB,MAAM,EAAE,WAAW;IACnB,MAAM,EAAE,WAAW;IACnB,QAAQ,EAAE,aAAa;IACvB,IAAI,EAAE,UAAU;IAChB,SAAS,EAAE,UAAU,CAAC,WAAW;IACjC,WAAW,EAAE,WAAW;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,\n input: Input,\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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/query-form/Field/index.js"],"names":[],"mappings":"AA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EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QACrC,IAAI,CAAC,EAAE,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IACzC,CAAC;IAED,oBAAoB;QAClB,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAE3B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAA;QACtC,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,IAAI,CAAC,YAAY,CAAC,CAAA;IAC1C,CAAC;CACF","sourcesContent":["import React, { PureComponent } from 'react'\nimport { get } from 'lodash'\nimport fieldsMap, { getFieldWidth } from './fieldsMap'\n\nimport Form from '../../form'\n\nconst FormItem = Form.Item\n\nconst isInput = (type) => ['input', 'string', 'search', 'aloneSearch'].includes(type)\n\nexport default class Field extends PureComponent {\n constructor(props) {\n super(props)\n\n this.state = {\n value: props.initialValue,\n }\n }\n\n render () {\n const {\n type = 'input',\n title,\n name,\n isFieldInDrawer = false,\n className = '',\n component,\n form,\n props: fieldProps,\n } = this.props\n const { value } = this.state\n const Field = component || fieldsMap[type]\n\n return (\n <FormItem label={title} className={className}>\n <Field\n value={value}\n {...(isInput(type)\n ? {\n onPressEnter: (evt) =>\n form.emit('search', { [name]: evt?.target?.value, current: 1 }),\n onSearch: (value) => form.emit('search', { [name]: value, current: 1 })\n }\n : {})}\n {...fieldProps}\n style={{\n ...fieldProps?.style,\n width: isFieldInDrawer ? '100%' : fieldProps?.style?.width || getFieldWidth(type),\n }}\n onChange={this.onChange}\n />\n </FormItem>\n )\n }\n\n updateValue = (name, value) => {\n if (name === this.props.name) {\n this.setState({ value })\n this.props.onChange(name, value)\n }\n }\n\n onChange = (...args) => {\n const { name, type = 'input', component, props: fieldProps } = this.props\n const { onChange } = fieldProps || {}\n\n onChange && onChange(...args)\n\n // Input onChange第一个参数为Event对象,取值特殊处理\n if (!component && isInput(type)) {\n args[0] = get(args[0], 'target.value')\n }\n\n this.setState({ value: args[0] })\n this.props.onChange(name, args[0])\n }\n\n onFormChange = (formData) => {\n this.setState({\n value: get(formData, this.props.name),\n })\n }\n\n componentDidMount () {\n const { form } = this.props\n\n form.on('setValue', this.updateValue)\n form.on('setValues', this.onFormChange)\n }\n\n componentWillUnmount () {\n const { form } = this.props\n\n form.off('setValue', this.updateValue)\n form.off('setValues', this.onFormChange)\n }\n}\n"]}
|
package/es/query-form/index.js
CHANGED
|
@@ -1,181 +1,353 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import Button from '../button';
|
|
5
|
-
import Form from '../form';
|
|
6
|
-
import { getLanguage, getText } from '../prev-locale';
|
|
1
|
+
import _debounce from "lodash/debounce";
|
|
2
|
+
import classnames from 'classnames';
|
|
3
|
+
import React, { createRef } from 'react';
|
|
7
4
|
import createActions from './createActions';
|
|
8
5
|
import Field from './Field';
|
|
9
6
|
import useForm from './useForm';
|
|
7
|
+
import Badge from '../badge';
|
|
8
|
+
import Button from '../button';
|
|
9
|
+
import Drawer from '../drawer';
|
|
10
|
+
import Form from '../form';
|
|
11
|
+
import { getLanguage, getText } from '../prev-locale';
|
|
12
|
+
import Icon from '../tntd-icon';
|
|
10
13
|
import './index.less';
|
|
11
14
|
const clsPrefix = 'tnt-queryform';
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
compositionShowReset = true,
|
|
30
|
-
inline
|
|
31
|
-
}) {
|
|
32
|
-
const [initialValues, setInitialValues] = useState(_initialValues || {});
|
|
33
|
-
const formRef = useRef(form || createActions());
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const _search = (params = {}) => {
|
|
36
|
-
onSearch(Object.assign(Object.assign({}, formRef.current.getValues()), params));
|
|
37
|
-
};
|
|
38
|
-
formRef.current.setData('initialValues', initialValues);
|
|
39
|
-
formRef.current.setData('values', initialValues);
|
|
40
|
-
formRef.current.on('search', _search);
|
|
41
|
-
return () => {
|
|
42
|
-
formRef.current.off('search', _search);
|
|
43
|
-
};
|
|
44
|
-
}, []);
|
|
45
|
-
const _getText = key => {
|
|
46
|
-
return getText(key, language || getLanguage());
|
|
47
|
-
};
|
|
48
|
-
const _onSearch = () => {
|
|
49
|
-
onSearch === null || onSearch === void 0 ? void 0 : onSearch(formRef.current.getValues());
|
|
50
|
-
};
|
|
51
|
-
const _onReset = () => {
|
|
52
|
-
formRef.current.setValues(Object.assign({}, initialValues));
|
|
53
|
-
onReset === null || onReset === void 0 ? void 0 : onReset(initialValues);
|
|
54
|
-
setInitialValues(Object.assign({}, initialValues));
|
|
55
|
-
};
|
|
56
|
-
const _onFieldChange = (name, value, ...rest) => {
|
|
57
|
-
const values = formRef.current.getValues();
|
|
58
|
-
const newValues = Object.assign(Object.assign({}, values), {
|
|
59
|
-
[name]: value
|
|
60
|
-
});
|
|
61
|
-
const changedInfo = {
|
|
62
|
-
name,
|
|
63
|
-
value,
|
|
64
|
-
preValue: values === null || values === void 0 ? void 0 : values[name]
|
|
65
|
-
};
|
|
66
|
-
formRef.current.setData('values', newValues);
|
|
67
|
-
onChange && onChange(newValues, changedInfo, ...rest);
|
|
68
|
-
};
|
|
69
|
-
const _onCompositionFieldChange = (value, deleteKeys, needSearch) => {
|
|
70
|
-
var _a;
|
|
71
|
-
const values = formRef.current.getValues();
|
|
72
|
-
const newValues = Object.assign(Object.assign({}, values), value);
|
|
73
|
-
if (deleteKeys === null || deleteKeys === void 0 ? void 0 : deleteKeys.length) {
|
|
74
|
-
deleteKeys === null || deleteKeys === void 0 ? void 0 : deleteKeys.forEach(key => {
|
|
75
|
-
if ((values === null || values === void 0 ? void 0 : values[key]) || (values === null || values === void 0 ? void 0 : values[key]) === 0 || (values === null || values === void 0 ? void 0 : values[key]) === false) {
|
|
76
|
-
delete newValues[key];
|
|
15
|
+
class QueryForm extends React.PureComponent {
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
18
|
+
Object.defineProperty(this, "onWindowResize", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
configurable: true,
|
|
21
|
+
writable: true,
|
|
22
|
+
value: _debounce(() => {
|
|
23
|
+
const {
|
|
24
|
+
current
|
|
25
|
+
} = this.fieldsRef;
|
|
26
|
+
if (current) {
|
|
27
|
+
setTimeout(() => {
|
|
28
|
+
this.setState({
|
|
29
|
+
showMore: this.isFieldsWidthOverflow()
|
|
30
|
+
});
|
|
31
|
+
}, 25);
|
|
77
32
|
}
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
33
|
+
}, 50)
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(this, "search", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
configurable: true,
|
|
38
|
+
writable: true,
|
|
39
|
+
value: params => {
|
|
40
|
+
this.props.onSearch(Object.assign(Object.assign({}, this.form.getValues()), params));
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(this, "onSearch", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
configurable: true,
|
|
46
|
+
writable: true,
|
|
47
|
+
value: () => {
|
|
48
|
+
var _a, _b;
|
|
49
|
+
(_b = (_a = this.props).onSearch) === null || _b === void 0 ? void 0 : _b.call(_a, this.form.getValues());
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(this, "onReset", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: () => {
|
|
57
|
+
const {
|
|
58
|
+
initialValues,
|
|
59
|
+
onReset
|
|
60
|
+
} = this.props;
|
|
61
|
+
this.form.setValues(Object.assign({}, initialValues));
|
|
62
|
+
this.updateDrawerFieldsValueCount();
|
|
63
|
+
onReset === null || onReset === void 0 ? void 0 : onReset(initialValues);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
Object.defineProperty(this, "onToggleExpand", {
|
|
67
|
+
enumerable: true,
|
|
68
|
+
configurable: true,
|
|
69
|
+
writable: true,
|
|
70
|
+
value: () => {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
this.setState({
|
|
73
|
+
expanded: !this.state.expanded
|
|
74
|
+
});
|
|
75
|
+
(_b = (_a = this.props).onToggleExpand) === null || _b === void 0 ? void 0 : _b.call(_a, !this.state.expanded);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
Object.defineProperty(this, "onShowDrawer", {
|
|
79
|
+
enumerable: true,
|
|
80
|
+
configurable: true,
|
|
81
|
+
writable: true,
|
|
82
|
+
value: () => {
|
|
83
|
+
this.setState({
|
|
84
|
+
drawerVisible: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(this, "onFieldChange", {
|
|
89
|
+
enumerable: true,
|
|
90
|
+
configurable: true,
|
|
91
|
+
writable: true,
|
|
92
|
+
value: (name, value, ...rest) => {
|
|
93
|
+
const values = this.form.getValues();
|
|
94
|
+
const newValues = Object.assign(Object.assign({}, values), {
|
|
95
|
+
[name]: value
|
|
96
|
+
});
|
|
97
|
+
const changedInfo = {
|
|
98
|
+
name,
|
|
99
|
+
value,
|
|
100
|
+
preValue: values === null || values === void 0 ? void 0 : values[name]
|
|
101
|
+
};
|
|
102
|
+
const {
|
|
103
|
+
onChange
|
|
104
|
+
} = this.props;
|
|
105
|
+
this.form.setData('values', newValues);
|
|
106
|
+
onChange && onChange(newValues, changedInfo, ...rest);
|
|
107
|
+
this.updateDrawerFieldsValueCount(newValues);
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
Object.defineProperty(this, "updateDrawerFieldsValueCount", {
|
|
111
|
+
enumerable: true,
|
|
112
|
+
configurable: true,
|
|
113
|
+
writable: true,
|
|
114
|
+
value: () => {
|
|
115
|
+
const values = this.form.getValues();
|
|
116
|
+
const {
|
|
117
|
+
showFieldCount,
|
|
118
|
+
children
|
|
119
|
+
} = this.props;
|
|
120
|
+
if (showFieldCount) {
|
|
121
|
+
const drawerFieldsValueCount = children.reduce((acc, cur, index) => {
|
|
122
|
+
var _a;
|
|
123
|
+
if (index >= showFieldCount && (values === null || values === void 0 ? void 0 : values[(_a = cur === null || cur === void 0 ? void 0 : cur.props) === null || _a === void 0 ? void 0 : _a.name])) {
|
|
124
|
+
acc++;
|
|
125
|
+
}
|
|
126
|
+
return acc;
|
|
127
|
+
}, 0);
|
|
128
|
+
if (drawerFieldsValueCount !== this.state.drawerFieldsValueCount) {
|
|
129
|
+
this.setState({
|
|
130
|
+
drawerFieldsValueCount
|
|
131
|
+
});
|
|
132
|
+
}
|
|
90
133
|
}
|
|
91
|
-
});
|
|
92
|
-
if (needSearch && !hasOnChange) {
|
|
93
|
-
formRef.current.emit('search', newValues);
|
|
94
134
|
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
} else if (((_b = child.props) === null || _b === void 0 ? void 0 : _b.isGroup) === false) {
|
|
111
|
-
outFields.push(child);
|
|
135
|
+
});
|
|
136
|
+
Object.defineProperty(this, "addResizeListener", {
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true,
|
|
139
|
+
writable: true,
|
|
140
|
+
value: () => {
|
|
141
|
+
if ('ResizeObserver' in window) {
|
|
142
|
+
const {
|
|
143
|
+
current
|
|
144
|
+
} = this.fieldsRef;
|
|
145
|
+
if (current) {
|
|
146
|
+
const observer = new ResizeObserver(this.onWindowResize);
|
|
147
|
+
observer.observe(current);
|
|
148
|
+
return () => observer.disconnect();
|
|
149
|
+
}
|
|
112
150
|
} else {
|
|
113
|
-
|
|
151
|
+
window.addEventListener('resize', this.onWindowResize);
|
|
152
|
+
return () => window.removeEventListener('resize', this.onWindowResize);
|
|
114
153
|
}
|
|
115
|
-
otherFields.push(child);
|
|
116
154
|
}
|
|
117
155
|
});
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
156
|
+
const {
|
|
157
|
+
form,
|
|
158
|
+
initialValues,
|
|
159
|
+
showExpand = true,
|
|
160
|
+
renderActions,
|
|
161
|
+
defaultExpanded
|
|
162
|
+
} = props;
|
|
163
|
+
this.state = {
|
|
164
|
+
showMore: false,
|
|
165
|
+
expanded: defaultExpanded || !showExpand || renderActions ? true : false,
|
|
166
|
+
drawerVisible: false,
|
|
167
|
+
drawerFieldsValueCount: 0
|
|
168
|
+
};
|
|
169
|
+
this.fieldsRef = createRef();
|
|
170
|
+
this.formBoxRef = createRef();
|
|
171
|
+
this.form = form || createActions();
|
|
172
|
+
this.form.setData('initialValues', initialValues);
|
|
173
|
+
this.form.setData('values', Object.assign({}, initialValues));
|
|
174
|
+
}
|
|
175
|
+
render() {
|
|
176
|
+
const {
|
|
177
|
+
children,
|
|
178
|
+
className = '',
|
|
179
|
+
initialValues = {},
|
|
180
|
+
renderActions,
|
|
181
|
+
showSearch = true,
|
|
182
|
+
showReset = true,
|
|
183
|
+
showFieldCount,
|
|
184
|
+
drawerProps = {},
|
|
185
|
+
size
|
|
186
|
+
} = this.props;
|
|
187
|
+
const extraActions = this.props.extraActions;
|
|
188
|
+
const {
|
|
189
|
+
expanded,
|
|
190
|
+
showMore,
|
|
191
|
+
drawerVisible,
|
|
192
|
+
drawerFieldsValueCount
|
|
193
|
+
} = this.state;
|
|
194
|
+
const renderFormActions = renderActions || (() => React.createElement(React.Fragment, null, showFieldCount && React.createElement(Badge, {
|
|
195
|
+
count: drawerFieldsValueCount
|
|
196
|
+
}, React.createElement(Button, {
|
|
197
|
+
onClick: this.onShowDrawer
|
|
198
|
+
}, React.createElement(Icon, {
|
|
199
|
+
type: "filter"
|
|
200
|
+
}), this.getText('moreFiltering'))), showSearch && React.createElement(Button, {
|
|
201
|
+
type: "primary",
|
|
202
|
+
onClick: this.onSearch
|
|
203
|
+
}, this.getText('search')), showReset && React.createElement(Button, {
|
|
204
|
+
onClick: this.onReset
|
|
205
|
+
}, this.getText('reset')), showMore && !showFieldCount && React.createElement(Button, {
|
|
206
|
+
className: "expand-link",
|
|
207
|
+
type: "link",
|
|
208
|
+
onClick: this.onToggleExpand
|
|
209
|
+
}, this.getText(expanded ? 'collapse' : 'expand')), React.Children.map(children, child => {
|
|
210
|
+
var _a;
|
|
211
|
+
return child && ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.align) === 'right' && React.cloneElement(child);
|
|
212
|
+
})));
|
|
213
|
+
return React.createElement("div", {
|
|
214
|
+
ref: this.formBoxRef,
|
|
215
|
+
className: classnames(clsPrefix, {
|
|
216
|
+
[className]: className
|
|
217
|
+
})
|
|
218
|
+
}, React.createElement(Form, {
|
|
219
|
+
layout: "inline",
|
|
220
|
+
className: classnames({
|
|
221
|
+
expanded: !showMore || expanded,
|
|
222
|
+
showMore
|
|
223
|
+
})
|
|
224
|
+
}, React.createElement("div", {
|
|
225
|
+
ref: this.fieldsRef
|
|
226
|
+
}, React.Children.map(children, (child, index) => {
|
|
227
|
+
var _a, _b;
|
|
228
|
+
return child && ((_a = child === null || child === void 0 ? void 0 : child.props) === null || _a === void 0 ? void 0 : _a.align) !== 'right' && (!showFieldCount || showFieldCount > index) && React.cloneElement(child, {
|
|
229
|
+
form: this.form,
|
|
230
|
+
initialValue: initialValues === null || initialValues === void 0 ? void 0 : initialValues[(_b = child.props) === null || _b === void 0 ? void 0 : _b.name],
|
|
231
|
+
onChange: this.onFieldChange
|
|
232
|
+
});
|
|
233
|
+
})), React.createElement("div", {
|
|
234
|
+
className: `${clsPrefix}-actions`
|
|
235
|
+
}, renderFormActions()), showFieldCount && React.createElement(Drawer, Object.assign({
|
|
236
|
+
title: this.getText('moreFiltering'),
|
|
237
|
+
visible: drawerVisible,
|
|
238
|
+
onClose: () => this.setState({
|
|
239
|
+
drawerVisible: false
|
|
240
|
+
}),
|
|
241
|
+
width: 300,
|
|
242
|
+
size: size,
|
|
243
|
+
getContainer: false
|
|
244
|
+
}, drawerProps, {
|
|
245
|
+
className: classnames(`${clsPrefix}-drawer`, {
|
|
246
|
+
'large-size': size === 'large',
|
|
247
|
+
[className]: className
|
|
248
|
+
})
|
|
249
|
+
}), React.Children.map(children, (child, index) => child && index >= showFieldCount && React.cloneElement(child, {
|
|
250
|
+
form: this.form,
|
|
251
|
+
isFieldInDrawer: true,
|
|
252
|
+
initialValue: initialValues === null || initialValues === void 0 ? void 0 : initialValues[child.props.name],
|
|
253
|
+
onChange: this.onFieldChange,
|
|
254
|
+
onSearch: this.onSearch
|
|
255
|
+
})), React.createElement(Button, {
|
|
256
|
+
type: "primary",
|
|
257
|
+
onClick: this.onSearch
|
|
258
|
+
}, this.getText('search')), React.createElement(Button, {
|
|
259
|
+
onClick: this.onReset
|
|
260
|
+
}, this.getText('reset')))), extraActions && React.createElement("div", {
|
|
261
|
+
className: `${clsPrefix}-extra`
|
|
262
|
+
}, extraActions));
|
|
263
|
+
}
|
|
264
|
+
getText(key) {
|
|
265
|
+
return getText(key, this.props.language || getLanguage());
|
|
266
|
+
}
|
|
267
|
+
isFieldsWidthOverflow() {
|
|
268
|
+
const {
|
|
269
|
+
current
|
|
270
|
+
} = this.fieldsRef;
|
|
271
|
+
if (current) {
|
|
272
|
+
return parseFloat(window.getComputedStyle(current).width, 10) < [].reduce.call(current.children, (acc, cur) => {
|
|
273
|
+
const {
|
|
274
|
+
margin,
|
|
275
|
+
width
|
|
276
|
+
} = window.getComputedStyle(cur);
|
|
277
|
+
const marginArray = margin.split(' ').map(str => parseFloat(str, 10));
|
|
278
|
+
acc += parseFloat(width, 10) + marginArray[1];
|
|
279
|
+
return acc;
|
|
280
|
+
}, 0);
|
|
281
|
+
}
|
|
282
|
+
return false;
|
|
283
|
+
}
|
|
284
|
+
updateFieldHeight() {
|
|
285
|
+
var _a, _b, _c;
|
|
286
|
+
const {
|
|
287
|
+
formBoxRef,
|
|
288
|
+
fieldsRef
|
|
289
|
+
} = this;
|
|
290
|
+
const getFieldHeight = () => {
|
|
291
|
+
var _a;
|
|
292
|
+
const {
|
|
293
|
+
current
|
|
294
|
+
} = fieldsRef;
|
|
295
|
+
let height = '32px';
|
|
296
|
+
if (current && ((_a = current.children) === null || _a === void 0 ? void 0 : _a[0])) {
|
|
297
|
+
height = window.getComputedStyle(current.children[0]).height;
|
|
128
298
|
}
|
|
299
|
+
return height;
|
|
300
|
+
};
|
|
301
|
+
const queryFormActionsDom = (_a = formBoxRef === null || formBoxRef === void 0 ? void 0 : formBoxRef.current) === null || _a === void 0 ? void 0 : _a.querySelector(`.${clsPrefix}-actions`);
|
|
302
|
+
const queryFormExtraDom = (_b = formBoxRef === null || formBoxRef === void 0 ? void 0 : formBoxRef.current) === null || _b === void 0 ? void 0 : _b.querySelector(`.${clsPrefix}-extra`);
|
|
303
|
+
const formItemsDomList = (_c = fieldsRef === null || fieldsRef === void 0 ? void 0 : fieldsRef.current) === null || _c === void 0 ? void 0 : _c.querySelectorAll('.ant-form-item-control');
|
|
304
|
+
const fieldHeight = getFieldHeight();
|
|
305
|
+
fieldsRef.current.style.height = fieldHeight;
|
|
306
|
+
[queryFormActionsDom, queryFormExtraDom].forEach(item => {
|
|
307
|
+
item && Object.assign(item.style, {
|
|
308
|
+
height: fieldHeight,
|
|
309
|
+
lineHeight: fieldHeight
|
|
310
|
+
});
|
|
311
|
+
});
|
|
312
|
+
[].forEach.call(formItemsDomList, item => {
|
|
313
|
+
item.style.lineHeight = fieldHeight;
|
|
314
|
+
});
|
|
315
|
+
}
|
|
316
|
+
componentDidMount() {
|
|
317
|
+
const {
|
|
318
|
+
current
|
|
319
|
+
} = this.fieldsRef;
|
|
320
|
+
const {
|
|
321
|
+
showFieldCount,
|
|
322
|
+
showExpand = true
|
|
323
|
+
} = this.props;
|
|
324
|
+
this.updateFieldHeight();
|
|
325
|
+
this.form.on('search', this.search);
|
|
326
|
+
// 未设置第一行显示数量且禁止了展开操作 或 自定义了操作区域,则不需要处理展开计算逻辑
|
|
327
|
+
// || renderActions
|
|
328
|
+
if (!showFieldCount && !showExpand) {
|
|
329
|
+
return;
|
|
129
330
|
}
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
className: `${clsPrefix}-top-body`
|
|
145
|
-
}, hasOutField ? outFields.map((child, i) => {
|
|
331
|
+
if (!showFieldCount) {
|
|
332
|
+
if (current && this.isFieldsWidthOverflow()) {
|
|
333
|
+
this.setState({
|
|
334
|
+
showMore: true
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
this.removeResizeListener = this.addResizeListener();
|
|
338
|
+
} else {
|
|
339
|
+
this.updateDrawerFieldsValueCount();
|
|
340
|
+
this.form.on('setValues', this.updateDrawerFieldsValueCount);
|
|
341
|
+
this.form.on('setValue', this.updateDrawerFieldsValueCount);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
componentWillUnmount() {
|
|
146
345
|
var _a;
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
});
|
|
153
|
-
}) : isGroupMode ? React.createElement(Composition, {
|
|
154
|
-
clsPrefix: clsPrefix,
|
|
155
|
-
fieldItems: groupFields,
|
|
156
|
-
initialValues: compositionInitValues,
|
|
157
|
-
_onReset: _onReset,
|
|
158
|
-
onChange: _onCompositionFieldChange,
|
|
159
|
-
form: formRef.current,
|
|
160
|
-
compositionShowReset: compositionShowReset
|
|
161
|
-
}) : null, renderActions ? renderActions() : React.createElement(React.Fragment, null, showSearch && React.createElement(Button, {
|
|
162
|
-
type: "primary",
|
|
163
|
-
onClick: _onSearch
|
|
164
|
-
}, _getText('search')), showReset && React.createElement(Button, {
|
|
165
|
-
onClick: _onReset
|
|
166
|
-
}, _getText('reset')))), showExtra && React.createElement("div", {
|
|
167
|
-
className: `${clsPrefix}-extra`
|
|
168
|
-
}, rightChildren, extraActions)), isGroupMode && hasOutField && React.createElement("div", {
|
|
169
|
-
className: `${clsPrefix}-bottom`
|
|
170
|
-
}, React.createElement(Composition, {
|
|
171
|
-
clsPrefix: clsPrefix,
|
|
172
|
-
fieldItems: groupFields,
|
|
173
|
-
initialValues: compositionInitValues,
|
|
174
|
-
_onReset: _onReset,
|
|
175
|
-
onChange: _onCompositionFieldChange,
|
|
176
|
-
form: formRef.current,
|
|
177
|
-
compositionShowReset: compositionShowReset
|
|
178
|
-
}))));
|
|
346
|
+
(_a = this.removeResizeListener) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
347
|
+
this.form.off('setValues', this.updateDrawerFieldsValueCount);
|
|
348
|
+
this.form.off('setValue', this.updateDrawerFieldsValueCount);
|
|
349
|
+
this.form.off('search', this.search);
|
|
350
|
+
}
|
|
179
351
|
}
|
|
180
352
|
QueryForm.Field = Field;
|
|
181
353
|
QueryForm.useForm = useForm;
|