@hw-component/form 0.0.5-beta-v8 → 0.0.5-beta-v9
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/Context/FormConfigProvider.js +27 -0
- package/es/Form/Context/index.js +11 -0
- package/es/Form/HFormConnect.js +68 -0
- package/es/Select/components/AllSelect.js +55 -0
- package/es/Select/components/CheckBoxOption.js +16 -0
- package/es/Select/components/DropdownComponent.js +44 -0
- package/es/Select/components/NoFindItem.js +14 -0
- package/es/Select/components/NotFoundContent.js +43 -0
- package/es/Select/defaultConfig.js +32 -0
- package/es/Select/hooks/changeHooks.js +196 -0
- package/es/Select/hooks/norHooks.js +118 -0
- package/es/Select/index.js +149 -0
- package/es/Select/utils.js +37 -0
- package/es/Upload/util.js +18 -0
- package/es/config.js +65 -0
- package/es/hooks/index.js +74 -0
- package/es/index.css +44 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +3 -22
- package/lib/Form/Context/FormConfigProvider.js +28 -0
- package/lib/Form/Context/index.js +14 -0
- package/lib/Form/HFormConnect.js +71 -0
- package/lib/Select/components/AllSelect.js +58 -0
- package/lib/Select/components/CheckBoxOption.js +19 -0
- package/lib/Select/components/DropdownComponent.js +47 -0
- package/lib/Select/components/NoFindItem.js +17 -0
- package/lib/Select/components/NotFoundContent.js +46 -0
- package/lib/Select/defaultConfig.js +34 -0
- package/lib/Select/hooks/changeHooks.js +197 -0
- package/lib/Select/hooks/norHooks.js +120 -0
- package/lib/Select/index.js +152 -0
- package/lib/Select/utils.js +39 -0
- package/lib/Upload/util.js +19 -0
- package/lib/config.js +66 -0
- package/lib/hooks/index.js +77 -0
- package/lib/index.css +44 -0
- package/lib/index.d.ts +3 -1
- package/lib/index.js +3 -22
- package/package.json +1 -1
- package/src/components/index.tsx +4 -3
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.object.keys.js';
|
|
3
|
+
import 'core-js/modules/es.symbol.js';
|
|
4
|
+
import 'core-js/modules/es.array.filter.js';
|
|
5
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
11
|
+
import 'core-js/modules/es.array.map.js';
|
|
12
|
+
import { jsx } from 'react/jsx-runtime';
|
|
13
|
+
import { Select as Select$1 } from 'antd';
|
|
14
|
+
import { useFilterOption, useOptionReq } from './hooks/norHooks.js';
|
|
15
|
+
import { useValueChange } from './hooks/changeHooks.js';
|
|
16
|
+
import { defaultModeConfig, defaultSelectConfig } from './defaultConfig.js';
|
|
17
|
+
import Index$1 from './components/DropdownComponent.js';
|
|
18
|
+
import Index$2 from './components/AllSelect.js';
|
|
19
|
+
import { useMatchConfigProps, useChangeOptions } from '../hooks/index.js';
|
|
20
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
21
|
+
|
|
22
|
+
var _excluded = ["style", "mode", "options", "modeConfig", "value", "onChange", "fieldNames", "request", "manual", "optionLabelProp", "filterProvider", "optionFilterProp", "serviceSearch", "onSearch", "filterOption", "showSearch", "labelInValue", "noMatchItemRender", "allSelect", "addDispatchListener", "addFormat", "dispatch"];
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
var Option = Select$1.Option;
|
|
26
|
+
var Index = function Index(_ref) {
|
|
27
|
+
var _ref$style = _ref.style,
|
|
28
|
+
style = _ref$style === void 0 ? {
|
|
29
|
+
width: "100%"
|
|
30
|
+
} : _ref$style,
|
|
31
|
+
mode = _ref.mode,
|
|
32
|
+
options = _ref.options,
|
|
33
|
+
_ref$modeConfig = _ref.modeConfig,
|
|
34
|
+
modeConfig = _ref$modeConfig === void 0 ? defaultModeConfig : _ref$modeConfig,
|
|
35
|
+
value = _ref.value,
|
|
36
|
+
onChange = _ref.onChange,
|
|
37
|
+
propsFieldNames = _ref.fieldNames,
|
|
38
|
+
request = _ref.request,
|
|
39
|
+
manual = _ref.manual,
|
|
40
|
+
_ref$optionLabelProp = _ref.optionLabelProp,
|
|
41
|
+
optionLabelProp = _ref$optionLabelProp === void 0 ? "label" : _ref$optionLabelProp,
|
|
42
|
+
filterProvider = _ref.filterProvider,
|
|
43
|
+
_ref$optionFilterProp = _ref.optionFilterProp,
|
|
44
|
+
optionFilterProp = _ref$optionFilterProp === void 0 ? "filterLabel" : _ref$optionFilterProp,
|
|
45
|
+
serviceSearch = _ref.serviceSearch,
|
|
46
|
+
propsOnSearch = _ref.onSearch,
|
|
47
|
+
filterOption = _ref.filterOption,
|
|
48
|
+
showSearch = _ref.showSearch,
|
|
49
|
+
labelInValue = _ref.labelInValue,
|
|
50
|
+
_ref$noMatchItemRende = _ref.noMatchItemRender,
|
|
51
|
+
noMatchItemRender = _ref$noMatchItemRende === void 0 ? defaultSelectConfig.noMatchItemRender : _ref$noMatchItemRende,
|
|
52
|
+
allSelect = _ref.allSelect,
|
|
53
|
+
addDispatchListener = _ref.addDispatchListener;
|
|
54
|
+
_ref.addFormat;
|
|
55
|
+
var dispatch = _ref.dispatch,
|
|
56
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
57
|
+
var _ref2 = (modeConfig === null || modeConfig === void 0 ? void 0 : modeConfig[mode || ""]) || {},
|
|
58
|
+
icon = _ref2.icon,
|
|
59
|
+
render = _ref2.render;
|
|
60
|
+
var _useMatchConfigProps = useMatchConfigProps({
|
|
61
|
+
fieldNames: propsFieldNames
|
|
62
|
+
}),
|
|
63
|
+
fieldNames = _useMatchConfigProps.fieldNames;
|
|
64
|
+
var selfFilterOption = useFilterOption({
|
|
65
|
+
filterOption: filterOption,
|
|
66
|
+
serviceSearch: serviceSearch
|
|
67
|
+
});
|
|
68
|
+
var _useOptionReq = useOptionReq({
|
|
69
|
+
options: options,
|
|
70
|
+
manual: manual,
|
|
71
|
+
fieldNames: fieldNames,
|
|
72
|
+
request: request,
|
|
73
|
+
serviceSearch: serviceSearch,
|
|
74
|
+
showSearch: showSearch,
|
|
75
|
+
onSearch: propsOnSearch,
|
|
76
|
+
dispatch: dispatch
|
|
77
|
+
}),
|
|
78
|
+
run = _useOptionReq.run,
|
|
79
|
+
loading = _useOptionReq.loading,
|
|
80
|
+
resultData = _useOptionReq.data,
|
|
81
|
+
error = _useOptionReq.error,
|
|
82
|
+
onSearch = _useOptionReq.onSearch,
|
|
83
|
+
mathShowSearch = _useOptionReq.mathShowSearch,
|
|
84
|
+
reload = _useOptionReq.reload;
|
|
85
|
+
var data = useChangeOptions({
|
|
86
|
+
options: resultData,
|
|
87
|
+
fieldNames: fieldNames
|
|
88
|
+
});
|
|
89
|
+
var _useValueChange = useValueChange({
|
|
90
|
+
labelInValue: labelInValue,
|
|
91
|
+
onChange: onChange,
|
|
92
|
+
value: value,
|
|
93
|
+
options: data,
|
|
94
|
+
mode: mode,
|
|
95
|
+
noMatchItemRender: noMatchItemRender,
|
|
96
|
+
fieldNames: fieldNames
|
|
97
|
+
}),
|
|
98
|
+
val = _useValueChange.val,
|
|
99
|
+
change = _useValueChange.change;
|
|
100
|
+
addDispatchListener === null || addDispatchListener === void 0 || addDispatchListener("reload", reload);
|
|
101
|
+
return jsx(Select$1, _objectSpread(_objectSpread({
|
|
102
|
+
style: style,
|
|
103
|
+
mode: mode,
|
|
104
|
+
loading: loading,
|
|
105
|
+
value: val,
|
|
106
|
+
onSearch: onSearch,
|
|
107
|
+
onChange: change,
|
|
108
|
+
dropdownRender: function dropdownRender(node) {
|
|
109
|
+
return jsx(Index$1, {
|
|
110
|
+
loading: loading,
|
|
111
|
+
reload: run,
|
|
112
|
+
error: error,
|
|
113
|
+
options: data,
|
|
114
|
+
children: jsx(Index$2, {
|
|
115
|
+
allSelect: allSelect,
|
|
116
|
+
options: data,
|
|
117
|
+
mode: mode,
|
|
118
|
+
value: val,
|
|
119
|
+
onChange: change,
|
|
120
|
+
children: node
|
|
121
|
+
})
|
|
122
|
+
});
|
|
123
|
+
},
|
|
124
|
+
optionLabelProp: optionLabelProp,
|
|
125
|
+
menuItemSelectedIcon: icon,
|
|
126
|
+
optionFilterProp: optionFilterProp,
|
|
127
|
+
filterOption: selfFilterOption,
|
|
128
|
+
showSearch: mathShowSearch,
|
|
129
|
+
labelInValue: true
|
|
130
|
+
}, props), {}, {
|
|
131
|
+
children: data === null || data === void 0 ? void 0 : data.map(function (item) {
|
|
132
|
+
var optionValue = item.value,
|
|
133
|
+
label = item.label;
|
|
134
|
+
var result = (filterProvider === null || filterProvider === void 0 ? void 0 : filterProvider(item)) || label;
|
|
135
|
+
var filter = _defineProperty({}, optionFilterProp, result);
|
|
136
|
+
return jsx(Option, _objectSpread(_objectSpread({
|
|
137
|
+
value: optionValue,
|
|
138
|
+
label: label,
|
|
139
|
+
mode: mode
|
|
140
|
+
}, filter), {}, {
|
|
141
|
+
children: render ? render(item, val) : label
|
|
142
|
+
}), optionValue);
|
|
143
|
+
})
|
|
144
|
+
}));
|
|
145
|
+
};
|
|
146
|
+
var Select = HFormConnect(Index);
|
|
147
|
+
|
|
148
|
+
export { Select as default };
|
|
149
|
+
// powered by hdj
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.object.keys.js';
|
|
3
|
+
import 'core-js/modules/es.symbol.js';
|
|
4
|
+
import 'core-js/modules/es.array.filter.js';
|
|
5
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
6
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
11
|
+
import 'core-js/modules/es.array.map.js';
|
|
12
|
+
|
|
13
|
+
var _excluded = ["label", "value"];
|
|
14
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
+
var itemOpMaker = function itemOpMaker(itemOp, fieldNames) {
|
|
17
|
+
var _objectSpread2;
|
|
18
|
+
var label = itemOp.label,
|
|
19
|
+
itemVal = itemOp.value,
|
|
20
|
+
oItemOp = _objectWithoutProperties(itemOp, _excluded);
|
|
21
|
+
var _fieldNames$label = fieldNames.label,
|
|
22
|
+
labelKey = _fieldNames$label === void 0 ? "" : _fieldNames$label,
|
|
23
|
+
_fieldNames$value = fieldNames.value,
|
|
24
|
+
valKey = _fieldNames$value === void 0 ? "" : _fieldNames$value;
|
|
25
|
+
return _objectSpread((_objectSpread2 = {}, _defineProperty(_objectSpread2, labelKey, label), _defineProperty(_objectSpread2, valKey, itemVal), _objectSpread2), oItemOp);
|
|
26
|
+
};
|
|
27
|
+
var itemOpProvider = function itemOpProvider(itemOps, fieldNames) {
|
|
28
|
+
if (Array.isArray(itemOps)) {
|
|
29
|
+
return itemOps.map(function (item) {
|
|
30
|
+
return itemOpMaker(item, fieldNames);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
return itemOpMaker(itemOps, fieldNames);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export { itemOpMaker, itemOpProvider };
|
|
37
|
+
// powered by hdj
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import 'core-js/modules/es.function.name.js';
|
|
3
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
4
|
+
import 'core-js/modules/es.promise.js';
|
|
5
|
+
|
|
6
|
+
var fileToBase64 = function fileToBase64(file) {
|
|
7
|
+
return new Promise(function (resolve) {
|
|
8
|
+
var reader = new FileReader();
|
|
9
|
+
reader.readAsDataURL(file === null || file === void 0 ? void 0 : file.originFileObj);
|
|
10
|
+
reader.onload = function (e) {
|
|
11
|
+
var _e$target;
|
|
12
|
+
resolve((_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.result);
|
|
13
|
+
};
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { fileToBase64 };
|
|
18
|
+
// powered by hdj
|
package/es/config.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _asyncToGenerator from '@babel/runtime-corejs3/helpers/asyncToGenerator';
|
|
3
|
+
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
4
|
+
import moment from 'moment';
|
|
5
|
+
import { fileToBase64 } from './Upload/util.js';
|
|
6
|
+
|
|
7
|
+
var baseConfig = {
|
|
8
|
+
fieldNames: {
|
|
9
|
+
label: "label",
|
|
10
|
+
value: "value"
|
|
11
|
+
},
|
|
12
|
+
valueCheckMap: {
|
|
13
|
+
checked: 1,
|
|
14
|
+
noChecked: 0
|
|
15
|
+
},
|
|
16
|
+
valueSwitchMap: {
|
|
17
|
+
open: 1,
|
|
18
|
+
close: 0
|
|
19
|
+
},
|
|
20
|
+
valueRangePickerValueMap: {
|
|
21
|
+
start: function start(name) {
|
|
22
|
+
return "".concat(name, "StartTime");
|
|
23
|
+
},
|
|
24
|
+
end: function end(name) {
|
|
25
|
+
return "".concat(name, "EndTime");
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
dateRanges: {
|
|
29
|
+
最近三天: [moment().subtract(2, "days").startOf("days"), moment()],
|
|
30
|
+
最近七天: [moment().subtract(6, "days").startOf("days"), moment()],
|
|
31
|
+
最近三十天: [moment().subtract(29, "days").startOf("days"), moment()]
|
|
32
|
+
},
|
|
33
|
+
uploadProps: {
|
|
34
|
+
exFiles: ["JPG", "PNG", "JPEG", "GIF"],
|
|
35
|
+
request: function () {
|
|
36
|
+
var _request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(file) {
|
|
37
|
+
var url;
|
|
38
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
39
|
+
while (1) switch (_context.prev = _context.next) {
|
|
40
|
+
case 0:
|
|
41
|
+
_context.next = 2;
|
|
42
|
+
return fileToBase64(file);
|
|
43
|
+
case 2:
|
|
44
|
+
url = _context.sent;
|
|
45
|
+
return _context.abrupt("return", {
|
|
46
|
+
url: url
|
|
47
|
+
});
|
|
48
|
+
case 4:
|
|
49
|
+
case "end":
|
|
50
|
+
return _context.stop();
|
|
51
|
+
}
|
|
52
|
+
}, _callee);
|
|
53
|
+
}));
|
|
54
|
+
function request(_x) {
|
|
55
|
+
return _request.apply(this, arguments);
|
|
56
|
+
}
|
|
57
|
+
return request;
|
|
58
|
+
}(),
|
|
59
|
+
maxSize: 1024 * 1024 * 1.8
|
|
60
|
+
},
|
|
61
|
+
defaultComponent: {}
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export { baseConfig };
|
|
65
|
+
// powered by hdj
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// welcome to hoo hoo hoo
|
|
2
|
+
import _typeof from '@babel/runtime-corejs3/helpers/typeof';
|
|
3
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
4
|
+
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
5
|
+
import 'core-js/modules/es.array.map.js';
|
|
6
|
+
import 'core-js/modules/es.array.concat.js';
|
|
7
|
+
import 'core-js/modules/es.array.join.js';
|
|
8
|
+
import 'core-js/modules/es.object.keys.js';
|
|
9
|
+
import 'core-js/modules/es.object.to-string.js';
|
|
10
|
+
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
11
|
+
import 'core-js/modules/es.symbol.to-primitive.js';
|
|
12
|
+
import 'core-js/modules/es.date.to-primitive.js';
|
|
13
|
+
import 'core-js/modules/es.symbol.js';
|
|
14
|
+
import 'core-js/modules/es.symbol.description.js';
|
|
15
|
+
import 'core-js/modules/es.number.constructor.js';
|
|
16
|
+
import 'core-js/modules/es.array.filter.js';
|
|
17
|
+
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
18
|
+
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
19
|
+
import { useMemo, useContext } from 'react';
|
|
20
|
+
import { ConfigContext } from 'antd/es/config-provider';
|
|
21
|
+
import { useFormConfigContext } from '../Form/Context/FormConfigProvider.js';
|
|
22
|
+
|
|
23
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
24
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
25
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
26
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
27
|
+
var useChangeOptions = function useChangeOptions(_ref) {
|
|
28
|
+
var options = _ref.options,
|
|
29
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
30
|
+
fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames;
|
|
31
|
+
return useMemo(function () {
|
|
32
|
+
return options === null || options === void 0 ? void 0 : options.map(function (item) {
|
|
33
|
+
var _fieldNames$label = fieldNames.label,
|
|
34
|
+
label = _fieldNames$label === void 0 ? "" : _fieldNames$label,
|
|
35
|
+
_fieldNames$value = fieldNames.value,
|
|
36
|
+
value = _fieldNames$value === void 0 ? "" : _fieldNames$value;
|
|
37
|
+
var relLabel = item[label],
|
|
38
|
+
relVal = item[value],
|
|
39
|
+
oItem = _objectWithoutProperties(item, [label, value].map(_toPropertyKey));
|
|
40
|
+
return _objectSpread(_objectSpread({}, oItem), {}, {
|
|
41
|
+
label: relLabel,
|
|
42
|
+
value: relVal
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}, [options]);
|
|
46
|
+
};
|
|
47
|
+
var useClassName = function useClassName(className) {
|
|
48
|
+
var config = useContext(ConfigContext);
|
|
49
|
+
return useMemo(function () {
|
|
50
|
+
if (Array.isArray(className)) {
|
|
51
|
+
var classNames = className.map(function (item) {
|
|
52
|
+
return "".concat(config.getPrefixCls(), "-").concat(item);
|
|
53
|
+
});
|
|
54
|
+
return classNames.join(" ");
|
|
55
|
+
}
|
|
56
|
+
return "".concat(config.getPrefixCls(), "-").concat(className);
|
|
57
|
+
}, [className]);
|
|
58
|
+
};
|
|
59
|
+
var useMatchConfigProps = function useMatchConfigProps(matchProps) {
|
|
60
|
+
var globalConfig = useFormConfigContext();
|
|
61
|
+
var keys = Object.keys(matchProps);
|
|
62
|
+
var resultMatchProps = {};
|
|
63
|
+
keys.forEach(function (key) {
|
|
64
|
+
if (!matchProps[key]) {
|
|
65
|
+
resultMatchProps[key] = globalConfig[key];
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
resultMatchProps[key] = matchProps[key];
|
|
69
|
+
});
|
|
70
|
+
return resultMatchProps;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export { useChangeOptions, useClassName, useMatchConfigProps };
|
|
74
|
+
// powered by hdj
|
package/es/index.css
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
.ant-hw-all-check-box .ant-select-item-option-active:not( .ant-select-item-option-disabled) {
|
|
2
|
+
background-color: transparent;
|
|
3
|
+
}
|
|
4
|
+
.ant-hw-all-check-box .ant-select-item-option-selected:not( .ant-select-item-option-disabled) {
|
|
5
|
+
background-color: #e6f7ff;
|
|
6
|
+
}
|
|
7
|
+
.ant-hw-all-check-box .ant-select-item-option:not( .ant-select-item-option-selected):hover {
|
|
8
|
+
background-color: #f5f5f5;
|
|
9
|
+
}
|
|
10
|
+
.ant-hw-form-item-colon:after {
|
|
11
|
+
position: relative;
|
|
12
|
+
top: -0.5px;
|
|
13
|
+
margin: 0 0 0 2px;
|
|
14
|
+
content: ":";
|
|
15
|
+
}
|
|
16
|
+
.ant-hw-form-item-required:before {
|
|
17
|
+
display: inline-block;
|
|
18
|
+
margin-right: 4px;
|
|
19
|
+
color: #ff4d4f;
|
|
20
|
+
font-size: 14px;
|
|
21
|
+
font-family: SimSun, sans-serif;
|
|
22
|
+
line-height: 1;
|
|
23
|
+
content: "*";
|
|
24
|
+
}
|
|
25
|
+
.ant-hw-form-base-item {
|
|
26
|
+
display: -webkit-box;
|
|
27
|
+
display: -webkit-flex;
|
|
28
|
+
display: -ms-flexbox;
|
|
29
|
+
display: flex;
|
|
30
|
+
-webkit-box-align: center;
|
|
31
|
+
-webkit-align-items: center;
|
|
32
|
+
-ms-flex-align: center;
|
|
33
|
+
align-items: center;
|
|
34
|
+
min-height: 32px;
|
|
35
|
+
}
|
|
36
|
+
.ant-hw-color-box {
|
|
37
|
+
width: 22px;
|
|
38
|
+
height: 22px;
|
|
39
|
+
border-radius: 4px;
|
|
40
|
+
cursor: pointer;
|
|
41
|
+
}
|
|
42
|
+
.ant-hw-color-input-picker {
|
|
43
|
+
box-shadow: 0 0 0 0 !important;
|
|
44
|
+
}
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
|
@@ -1,26 +1,7 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
-
import
|
|
3
|
-
import _regeneratorRuntime from '@babel/runtime-corejs3/regenerator';
|
|
4
|
-
import 'core-js/modules/es.object.to-string.js';
|
|
5
|
-
import 'core-js/modules/es.promise.js';
|
|
2
|
+
import Select from './Select/index.js';
|
|
6
3
|
|
|
7
|
-
var
|
|
8
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
9
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
10
|
-
while (1) switch (_context.prev = _context.next) {
|
|
11
|
-
case 0:
|
|
12
|
-
_context.next = 2;
|
|
13
|
-
return Promise.resolve("111");
|
|
14
|
-
case 2:
|
|
15
|
-
case "end":
|
|
16
|
-
return _context.stop();
|
|
17
|
-
}
|
|
18
|
-
}, _callee);
|
|
19
|
-
}));
|
|
20
|
-
return function a() {
|
|
21
|
-
return _ref.apply(this, arguments);
|
|
22
|
-
};
|
|
23
|
-
}();
|
|
4
|
+
var HSelect = Select;
|
|
24
5
|
|
|
25
|
-
export {
|
|
6
|
+
export { HSelect };
|
|
26
7
|
// powered by hdj
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('core-js/modules/es.symbol.js');
|
|
4
|
+
require('core-js/modules/es.array.filter.js');
|
|
5
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
6
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
7
|
+
require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
|
|
8
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
9
|
+
require('core-js/modules/es.object.keys.js');
|
|
10
|
+
require('core-js/modules/es.object.to-string.js');
|
|
11
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
var index = require('./index.js');
|
|
14
|
+
var React = require('react');
|
|
15
|
+
var config = require('../../config.js');
|
|
16
|
+
|
|
17
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
18
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
19
|
+
var useFormConfigContext = function useFormConfigContext(key) {
|
|
20
|
+
var defaultProps = React.useContext(index.FormConfigContext);
|
|
21
|
+
if (!key) {
|
|
22
|
+
return Object.keys(defaultProps).length === 0 ? _objectSpread({}, config.baseConfig) : defaultProps;
|
|
23
|
+
}
|
|
24
|
+
return defaultProps[key] || _objectSpread({}, config.baseConfig[key]);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.useFormConfigContext = useFormConfigContext;
|
|
28
|
+
// powered by h
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
5
|
+
var FormContext = /*#__PURE__*/React.createContext({});
|
|
6
|
+
var useFormContext = function useFormContext() {
|
|
7
|
+
return React.useContext(FormContext);
|
|
8
|
+
};
|
|
9
|
+
var FormConfigContext = /*#__PURE__*/React.createContext({});
|
|
10
|
+
|
|
11
|
+
exports.FormConfigContext = FormConfigContext;
|
|
12
|
+
exports.FormContext = FormContext;
|
|
13
|
+
exports.useFormContext = useFormContext;
|
|
14
|
+
// powered by h
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/es.object.keys.js');
|
|
6
|
+
require('core-js/modules/es.symbol.js');
|
|
7
|
+
require('core-js/modules/es.array.filter.js');
|
|
8
|
+
require('core-js/modules/es.object.to-string.js');
|
|
9
|
+
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
10
|
+
require('core-js/modules/web.dom-collections.for-each.js');
|
|
11
|
+
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
12
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
|
+
require('core-js/modules/es.function.name.js');
|
|
14
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
15
|
+
var index = require('./Context/index.js');
|
|
16
|
+
var React = require('react');
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
|
+
var formatMaker = function formatMaker(itemProps, formats) {
|
|
21
|
+
if (!formats) {
|
|
22
|
+
return formats;
|
|
23
|
+
}
|
|
24
|
+
var _inputValue = formats.inputValue,
|
|
25
|
+
_outputValue = formats.outputValue;
|
|
26
|
+
return {
|
|
27
|
+
inputValue: function inputValue(value) {
|
|
28
|
+
return _inputValue(itemProps, value);
|
|
29
|
+
},
|
|
30
|
+
outputValue: function outputValue(value) {
|
|
31
|
+
return _outputValue(itemProps, value);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
var HFormConnect = (function (component) {
|
|
36
|
+
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
37
|
+
var _config$format = config.format,
|
|
38
|
+
format = _config$format === void 0 ? {} : _config$format;
|
|
39
|
+
var Index = function Index(props, ref) {
|
|
40
|
+
var _props$name = props.name,
|
|
41
|
+
name = _props$name === void 0 ? "" : _props$name,
|
|
42
|
+
dispatch = props.dispatch;
|
|
43
|
+
var _useFormContext = index.useFormContext(),
|
|
44
|
+
form = _useFormContext.form,
|
|
45
|
+
_useFormContext$value = _useFormContext.valueType,
|
|
46
|
+
valueType = _useFormContext$value === void 0 ? "float" : _useFormContext$value;
|
|
47
|
+
React.useEffect(function () {
|
|
48
|
+
form === null || form === void 0 || form.addFormat(name, formatMaker(props, format[valueType]));
|
|
49
|
+
}, [valueType, props]);
|
|
50
|
+
var addFormat = function addFormat(aFormat) {
|
|
51
|
+
form === null || form === void 0 || form.addFormat(name, formatMaker(props, aFormat[valueType]));
|
|
52
|
+
};
|
|
53
|
+
var addDispatchListener = function addDispatchListener(key, fn) {
|
|
54
|
+
form === null || form === void 0 || form.addDispatchListener({
|
|
55
|
+
key: key,
|
|
56
|
+
name: name,
|
|
57
|
+
dispatch: dispatch
|
|
58
|
+
}, fn);
|
|
59
|
+
};
|
|
60
|
+
var Component = component;
|
|
61
|
+
return jsxRuntime.jsx(Component, _objectSpread(_objectSpread({}, props), {}, {
|
|
62
|
+
addFormat: addFormat,
|
|
63
|
+
addDispatchListener: addDispatchListener,
|
|
64
|
+
ref: ref
|
|
65
|
+
}));
|
|
66
|
+
};
|
|
67
|
+
return /*#__PURE__*/React.forwardRef(Index);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
exports.default = HFormConnect;
|
|
71
|
+
// powered by h
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('core-js/modules/es.array.concat.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var antd = require('antd');
|
|
8
|
+
var utils = require('../utils.js');
|
|
9
|
+
var index = require('../../hooks/index.js');
|
|
10
|
+
|
|
11
|
+
var useRootClassName = function useRootClassName(checked) {
|
|
12
|
+
var norClassNames = ["select-item", "select-item-option"];
|
|
13
|
+
return checked ? [].concat(norClassNames, ["select-item-option-selected"]) : norClassNames;
|
|
14
|
+
};
|
|
15
|
+
var Index = function Index(_ref) {
|
|
16
|
+
var allSelect = _ref.allSelect,
|
|
17
|
+
mode = _ref.mode,
|
|
18
|
+
onChange = _ref.onChange,
|
|
19
|
+
value = _ref.value,
|
|
20
|
+
serviceSearch = _ref.serviceSearch,
|
|
21
|
+
options = _ref.options,
|
|
22
|
+
_ref$fieldNames = _ref.fieldNames,
|
|
23
|
+
fieldNames = _ref$fieldNames === void 0 ? {} : _ref$fieldNames,
|
|
24
|
+
children = _ref.children;
|
|
25
|
+
var opLen = (options === null || options === void 0 ? void 0 : options.length) || 0;
|
|
26
|
+
var checked = (value === null || value === void 0 ? void 0 : value.length) >= opLen;
|
|
27
|
+
var classNames = useRootClassName(checked);
|
|
28
|
+
var optionsClassName = index.useClassName(classNames);
|
|
29
|
+
var allCheckBox = index.useClassName("hw-all-check-box");
|
|
30
|
+
var change = function change() {
|
|
31
|
+
if (!checked) {
|
|
32
|
+
var subItemOps = utils.itemOpProvider(options, fieldNames);
|
|
33
|
+
onChange === null || onChange === void 0 || onChange(options, subItemOps);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
onChange === null || onChange === void 0 || onChange([], []);
|
|
37
|
+
};
|
|
38
|
+
if (!allSelect || mode !== "multiple" || serviceSearch) {
|
|
39
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
40
|
+
children: children
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
return jsxRuntime.jsxs("div", {
|
|
44
|
+
className: allCheckBox,
|
|
45
|
+
children: [jsxRuntime.jsx("div", {
|
|
46
|
+
className: optionsClassName,
|
|
47
|
+
onClick: change,
|
|
48
|
+
children: jsxRuntime.jsxs(antd.Space, {
|
|
49
|
+
children: [jsxRuntime.jsx(antd.Checkbox, {
|
|
50
|
+
checked: checked
|
|
51
|
+
}), "\u5168\u90E8"]
|
|
52
|
+
})
|
|
53
|
+
}), children]
|
|
54
|
+
});
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.default = Index;
|
|
58
|
+
// powered by h
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var antd = require('antd');
|
|
7
|
+
|
|
8
|
+
var CheckBoxOption = (function (_ref) {
|
|
9
|
+
var label = _ref.label,
|
|
10
|
+
checked = _ref.checked;
|
|
11
|
+
return jsxRuntime.jsxs(antd.Space, {
|
|
12
|
+
children: [jsxRuntime.jsx(antd.Checkbox, {
|
|
13
|
+
checked: checked
|
|
14
|
+
}), label]
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
exports.default = CheckBoxOption;
|
|
19
|
+
// powered by h
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
6
|
+
var antd = require('antd');
|
|
7
|
+
var NotFoundContent = require('./NotFoundContent.js');
|
|
8
|
+
|
|
9
|
+
var Text = antd.Typography.Text;
|
|
10
|
+
var Index = function Index(_ref) {
|
|
11
|
+
var loading = _ref.loading,
|
|
12
|
+
error = _ref.error,
|
|
13
|
+
_ref$options = _ref.options,
|
|
14
|
+
options = _ref$options === void 0 ? [] : _ref$options,
|
|
15
|
+
reload = _ref.reload,
|
|
16
|
+
children = _ref.children;
|
|
17
|
+
var len = options === null || options === void 0 ? void 0 : options.length;
|
|
18
|
+
if (loading && len === 0) {
|
|
19
|
+
return jsxRuntime.jsx(antd.Row, {
|
|
20
|
+
style: {
|
|
21
|
+
height: 125
|
|
22
|
+
},
|
|
23
|
+
justify: "center",
|
|
24
|
+
align: "middle",
|
|
25
|
+
children: jsxRuntime.jsxs(antd.Space, {
|
|
26
|
+
direction: "vertical",
|
|
27
|
+
align: "center",
|
|
28
|
+
children: [jsxRuntime.jsx(antd.Spin, {}), jsxRuntime.jsx(Text, {
|
|
29
|
+
type: "secondary",
|
|
30
|
+
children: "\u62FC\u547D\u52A0\u8F7D\u4E2D..."
|
|
31
|
+
})]
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
if (error && len === 0) {
|
|
36
|
+
return jsxRuntime.jsx(NotFoundContent.default, {
|
|
37
|
+
error: error,
|
|
38
|
+
reload: reload
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return jsxRuntime.jsx(jsxRuntime.Fragment, {
|
|
42
|
+
children: children
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.default = Index;
|
|
47
|
+
// powered by h
|