iglooform 2.5.40 → 2.5.41
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/button/style/index.less +79 -51
- package/es/checkbox/index.d.ts +1 -0
- package/es/checkbox/index.js +5 -2
- package/es/declaration/index.js +21 -1
- package/es/form/element/index.js +25 -3
- package/es/free-form/element/index.js +2 -2
- package/es/radio/index.d.ts +1 -0
- package/es/radio/index.js +5 -2
- package/es/radio/radio-group-with-other.js +19 -3
- package/es/select/attached-select.d.ts +1 -0
- package/es/select/attached-select.js +14 -38
- package/es/select/style/index.less +7 -2
- package/es/types.d.ts +1 -0
- package/es/utils/form-utils.js +2 -2
- package/es/utils/option-utils.d.ts +1 -0
- package/es/utils/option-utils.js +14 -1
- package/lib/button/style/index.less +79 -51
- package/lib/checkbox/index.d.ts +1 -0
- package/lib/checkbox/index.js +4 -1
- package/lib/declaration/index.js +21 -1
- package/lib/form/element/index.js +25 -3
- package/lib/free-form/element/index.js +2 -2
- package/lib/radio/index.d.ts +1 -0
- package/lib/radio/index.js +4 -1
- package/lib/radio/radio-group-with-other.js +18 -2
- package/lib/select/attached-select.d.ts +1 -0
- package/lib/select/attached-select.js +13 -37
- package/lib/select/style/index.less +7 -2
- package/lib/types.d.ts +1 -0
- package/lib/utils/form-utils.js +2 -2
- package/lib/utils/option-utils.d.ts +1 -0
- package/lib/utils/option-utils.js +16 -1
- package/package.json +1 -1
- package/yarn-error.log +13769 -0
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
@btn-hover-color: @purple-medium;
|
|
4
4
|
@btn-hover-bg: @purple-medium;
|
|
5
5
|
|
|
6
|
+
@btn-green-color: #108043;
|
|
7
|
+
@btn-red-color: #de3618;
|
|
8
|
+
@btn-yellow-color: #cf8909;
|
|
9
|
+
|
|
6
10
|
.ant-btn {
|
|
7
11
|
padding: 0 16px;
|
|
8
12
|
text-shadow: none;
|
|
@@ -66,6 +70,81 @@
|
|
|
66
70
|
background-color: @primary-color;
|
|
67
71
|
}
|
|
68
72
|
}
|
|
73
|
+
|
|
74
|
+
&.green {
|
|
75
|
+
background: @btn-green-color;
|
|
76
|
+
border-color: @btn-green-color;
|
|
77
|
+
--antd-wave-shadow-color: @btn-green-color;
|
|
78
|
+
|
|
79
|
+
&:hover,
|
|
80
|
+
&:active,
|
|
81
|
+
&:focus {
|
|
82
|
+
background: @btn-green-color;
|
|
83
|
+
opacity: 0.9;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
&[disabled] {
|
|
87
|
+
background: @btn-green-color;
|
|
88
|
+
opacity: 0.3;
|
|
89
|
+
|
|
90
|
+
&:hover,
|
|
91
|
+
&:active,
|
|
92
|
+
&:focus {
|
|
93
|
+
border-color: @btn-green-color;
|
|
94
|
+
background: @btn-green-color;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
&.yellow {
|
|
100
|
+
background: @btn-yellow-color;
|
|
101
|
+
border-color: @btn-yellow-color;
|
|
102
|
+
--antd-wave-shadow-color: @btn-yellow-color;
|
|
103
|
+
|
|
104
|
+
&:hover,
|
|
105
|
+
&:active,
|
|
106
|
+
&:focus {
|
|
107
|
+
background: @btn-yellow-color;
|
|
108
|
+
opacity: 0.9;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
&[disabled] {
|
|
112
|
+
background: @btn-yellow-color;
|
|
113
|
+
opacity: 0.3;
|
|
114
|
+
|
|
115
|
+
&:hover,
|
|
116
|
+
&:active,
|
|
117
|
+
&:focus {
|
|
118
|
+
border-color: @btn-yellow-color;
|
|
119
|
+
background: @btn-yellow-color;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
&.red {
|
|
125
|
+
background: @btn-red-color;
|
|
126
|
+
border-color: @btn-red-color;
|
|
127
|
+
--antd-wave-shadow-color: @btn-red-color;
|
|
128
|
+
|
|
129
|
+
&:hover,
|
|
130
|
+
&:active,
|
|
131
|
+
&:focus {
|
|
132
|
+
background: @btn-red-color;
|
|
133
|
+
opacity: 0.9;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
&[disabled] {
|
|
137
|
+
background: @btn-red-color;
|
|
138
|
+
opacity: 0.3;
|
|
139
|
+
|
|
140
|
+
&:hover,
|
|
141
|
+
&:active,
|
|
142
|
+
&:focus {
|
|
143
|
+
border-color: @btn-red-color;
|
|
144
|
+
background: @btn-red-color;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
69
148
|
}
|
|
70
149
|
|
|
71
150
|
.ant-btn-link {
|
|
@@ -139,54 +218,3 @@
|
|
|
139
218
|
.ant-btn-icon-only {
|
|
140
219
|
width: auto;
|
|
141
220
|
}
|
|
142
|
-
|
|
143
|
-
.green {
|
|
144
|
-
background: #108043;
|
|
145
|
-
border: 0px;
|
|
146
|
-
|
|
147
|
-
&:hover,
|
|
148
|
-
&:active,
|
|
149
|
-
&:focus {
|
|
150
|
-
background: #108043;
|
|
151
|
-
opacity: 0.9;
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
.yellow {
|
|
156
|
-
background: #cf8909;
|
|
157
|
-
border: 0px;
|
|
158
|
-
|
|
159
|
-
&:hover,
|
|
160
|
-
&:active,
|
|
161
|
-
&:focus {
|
|
162
|
-
background: #cf8909;
|
|
163
|
-
opacity: 0.9;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
.red {
|
|
168
|
-
background: #de3618;
|
|
169
|
-
border: 0px;
|
|
170
|
-
|
|
171
|
-
&:hover,
|
|
172
|
-
&:active,
|
|
173
|
-
&:focus {
|
|
174
|
-
background: #de3618;
|
|
175
|
-
opacity: 0.9;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
button[class~='red'] {
|
|
180
|
-
border-color: #de3618 !important;
|
|
181
|
-
--antd-wave-shadow-color: #de3618 !important;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
button[class~='yellow'] {
|
|
185
|
-
border-color: #cf8909 !important;
|
|
186
|
-
--antd-wave-shadow-color: #cf8909 !important;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
button[class~='green'] {
|
|
190
|
-
border-color: #108043 !important;
|
|
191
|
-
--antd-wave-shadow-color: #108043 !important;
|
|
192
|
-
}
|
package/lib/checkbox/index.d.ts
CHANGED
package/lib/checkbox/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var _empty = _interopRequireDefault(require("../radio/style/empty.svg"));
|
|
|
37
37
|
|
|
38
38
|
require("./style/index.less");
|
|
39
39
|
|
|
40
|
-
var _excluded = ["className", "options", "value", "clearWhenOptionsUpdated"],
|
|
40
|
+
var _excluded = ["className", "options", "value", "clearWhenOptionsUpdated", "preview"],
|
|
41
41
|
_excluded2 = ["label", "value", "extraInfo"];
|
|
42
42
|
|
|
43
43
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -87,6 +87,7 @@ var InnerCheckboxGroup = function InnerCheckboxGroup(_ref) {
|
|
|
87
87
|
value = _ref.value,
|
|
88
88
|
_ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
|
|
89
89
|
clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
|
|
90
|
+
preview = _ref.preview,
|
|
90
91
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
91
92
|
|
|
92
93
|
var _useState = (0, _react.useState)(value),
|
|
@@ -124,6 +125,7 @@ var InnerCheckboxGroup = function InnerCheckboxGroup(_ref) {
|
|
|
124
125
|
originOptions.current = options;
|
|
125
126
|
}
|
|
126
127
|
}, [options]);
|
|
128
|
+
if (preview) return (0, _optionUtils.previewSelectedOptions)(options, value);
|
|
127
129
|
return (0, _jsxRuntime.jsxs)(_checkbox.default.Group, _objectSpread(_objectSpread({}, (0, _omit.default)(rest, _formMethods.default)), {}, {
|
|
128
130
|
className: (0, _classnames.default)('igloo-checkbox-group', className),
|
|
129
131
|
value: value,
|
|
@@ -181,6 +183,7 @@ var InnerCheckboxGroup = function InnerCheckboxGroup(_ref) {
|
|
|
181
183
|
|
|
182
184
|
var CheckboxGroup = (0, _optionUtils.optionsHOC)(InnerCheckboxGroup);
|
|
183
185
|
exports.CheckboxGroup = CheckboxGroup;
|
|
186
|
+
CheckboxGroup.isPreviewSupport = true;
|
|
184
187
|
|
|
185
188
|
CheckboxGroup.formItemPropsHandler = function () {
|
|
186
189
|
return {};
|
package/lib/declaration/index.js
CHANGED
|
@@ -73,13 +73,33 @@ var Declaration = function Declaration(_ref) {
|
|
|
73
73
|
};
|
|
74
74
|
|
|
75
75
|
Declaration.formItemPropsHandler = function (config) {
|
|
76
|
+
var rules = []; // 用户没有明确指明 `required: false`时,需要加上验证
|
|
77
|
+
|
|
78
|
+
if (config.required !== false) {
|
|
79
|
+
var _config$requiredMessa;
|
|
80
|
+
|
|
81
|
+
var requiredMessage = (_config$requiredMessa = config.requiredMessage) !== null && _config$requiredMessa !== void 0 ? _config$requiredMessa : 'Please check the declaration to proceed.';
|
|
82
|
+
rules.push({
|
|
83
|
+
validator: function validator(_, value) {
|
|
84
|
+
return new Promise(function (resolve, reject) {
|
|
85
|
+
if (!value) {
|
|
86
|
+
return reject(new Error(requiredMessage));
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return resolve('ok');
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
76
95
|
return {
|
|
77
96
|
getValueFromEvent: function getValueFromEvent(e) {
|
|
78
97
|
return e.target.checked;
|
|
79
98
|
},
|
|
80
99
|
valuePropName: 'checked',
|
|
81
100
|
fullRow: true,
|
|
82
|
-
|
|
101
|
+
required: false,
|
|
102
|
+
rules: rules
|
|
83
103
|
};
|
|
84
104
|
};
|
|
85
105
|
|
|
@@ -190,7 +190,7 @@ var Element = function Element(_ref) {
|
|
|
190
190
|
previewFormater = _calcFormItemProps.previewFormater;
|
|
191
191
|
|
|
192
192
|
(0, _react.useEffect)(function () {
|
|
193
|
-
if (
|
|
193
|
+
if (formItemProps.name === undefined || preview || !formItemProps.copiedValue.copied) return;
|
|
194
194
|
var originalValue = form === null || form === void 0 ? void 0 : form.getFieldValue(formItemProps.name);
|
|
195
195
|
var value = formItemProps.copiedValue.value;
|
|
196
196
|
|
|
@@ -205,7 +205,7 @@ var Element = function Element(_ref) {
|
|
|
205
205
|
}]);
|
|
206
206
|
}, [formItemProps.copiedValue.value]);
|
|
207
207
|
(0, _react.useEffect)(function () {
|
|
208
|
-
if (
|
|
208
|
+
if (formItemProps.name === undefined || preview || !formItemProps.selectedValue.selected) return;
|
|
209
209
|
form && form.setFields([{
|
|
210
210
|
name: formItemProps.name,
|
|
211
211
|
value: formItemProps.selectedValue.value,
|
|
@@ -242,6 +242,28 @@ var Element = function Element(_ref) {
|
|
|
242
242
|
return form;
|
|
243
243
|
};
|
|
244
244
|
|
|
245
|
+
var renderPreviewValue = function renderPreviewValue() {
|
|
246
|
+
if (previewFormater) return previewFormater(value, form);
|
|
247
|
+
|
|
248
|
+
if (Component === null || Component === void 0 ? void 0 : Component.isPreviewSupport) {
|
|
249
|
+
var extra = {
|
|
250
|
+
value: value,
|
|
251
|
+
preview: true
|
|
252
|
+
};
|
|
253
|
+
return (0, _jsxRuntime.jsx)(Component, _objectSpread(_objectSpread({}, elementProps), {}, {
|
|
254
|
+
disabled: elementProps.disabled || disabled,
|
|
255
|
+
containerRef: ref,
|
|
256
|
+
setFieldError: setFieldError,
|
|
257
|
+
setFieldValue: setFieldValue,
|
|
258
|
+
setShowStepButton: setShowStepButton,
|
|
259
|
+
getFormInstance: getFormInstance,
|
|
260
|
+
validateField: validateField
|
|
261
|
+
}, extra));
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
return _typeof(value) === 'object' ? JSON.stringify(value) : value;
|
|
265
|
+
};
|
|
266
|
+
|
|
245
267
|
var value = form === null || form === void 0 ? void 0 : form.getFieldValue(formItemProps.name);
|
|
246
268
|
var error = form === null || form === void 0 ? void 0 : form.getFieldError(formItemProps.name);
|
|
247
269
|
(0, _react.useEffect)(function () {
|
|
@@ -352,7 +374,7 @@ var Element = function Element(_ref) {
|
|
|
352
374
|
children: [error && !!error.length && (0, _jsxRuntime.jsx)(_iglooicon.AlertFilled, {
|
|
353
375
|
className: "igloo-element-preview-value-icon"
|
|
354
376
|
}), (0, _jsxRuntime.jsx)("div", {
|
|
355
|
-
children:
|
|
377
|
+
children: renderPreviewValue()
|
|
356
378
|
})]
|
|
357
379
|
})]
|
|
358
380
|
})
|
|
@@ -181,7 +181,7 @@ var Element = function Element(props) {
|
|
|
181
181
|
elementProps = _calcFormItemProps.elementProps;
|
|
182
182
|
|
|
183
183
|
(0, _react.useEffect)(function () {
|
|
184
|
-
if (
|
|
184
|
+
if (formItemProps.name === undefined || preview || !formItemProps.copiedValue.copied) return;
|
|
185
185
|
var originalValue = form === null || form === void 0 ? void 0 : form.getFieldValue(formItemProps.name);
|
|
186
186
|
var value = formItemProps.copiedValue.value;
|
|
187
187
|
|
|
@@ -196,7 +196,7 @@ var Element = function Element(props) {
|
|
|
196
196
|
}]);
|
|
197
197
|
}, [formItemProps.copiedValue.value]);
|
|
198
198
|
(0, _react.useEffect)(function () {
|
|
199
|
-
if (
|
|
199
|
+
if (formItemProps.name === undefined || preview || !formItemProps.selectedValue.selected) return;
|
|
200
200
|
form && form.setFields([{
|
|
201
201
|
name: formItemProps.name,
|
|
202
202
|
value: formItemProps.selectedValue.value,
|
package/lib/radio/index.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export interface IProps extends IglooComponentProps, Omit<RadioGroupProps, 'opti
|
|
|
15
15
|
className?: string;
|
|
16
16
|
radioType?: string;
|
|
17
17
|
options: Option[];
|
|
18
|
+
preview?: boolean;
|
|
18
19
|
}
|
|
19
20
|
export declare const InnerRadioGroup: FC<IProps>;
|
|
20
21
|
export declare const RadioGroup: FC<import("../utils/option-utils").HOCProps & IProps>;
|
package/lib/radio/index.js
CHANGED
|
@@ -46,7 +46,7 @@ var _optionUtils = require("../utils/option-utils");
|
|
|
46
46
|
|
|
47
47
|
var _radioGroupWithOther = _interopRequireDefault(require("./radio-group-with-other"));
|
|
48
48
|
|
|
49
|
-
var _excluded = ["className", "options", "radioType", "value", "clearWhenOptionsUpdated"],
|
|
49
|
+
var _excluded = ["className", "options", "radioType", "value", "clearWhenOptionsUpdated", "preview"],
|
|
50
50
|
_excluded2 = ["label", "value", "extraInfo"];
|
|
51
51
|
|
|
52
52
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -89,6 +89,7 @@ var InnerRadioGroup = function InnerRadioGroup(_ref) {
|
|
|
89
89
|
value = _ref.value,
|
|
90
90
|
_ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
|
|
91
91
|
clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
|
|
92
|
+
preview = _ref.preview,
|
|
92
93
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
93
94
|
|
|
94
95
|
var _useState = (0, _react.useState)(value),
|
|
@@ -126,6 +127,7 @@ var InnerRadioGroup = function InnerRadioGroup(_ref) {
|
|
|
126
127
|
originOptions.current = options;
|
|
127
128
|
}
|
|
128
129
|
}, [options]);
|
|
130
|
+
if (preview) return (0, _optionUtils.previewSelectedOptions)(options, value);
|
|
129
131
|
return (0, _jsxRuntime.jsxs)(_radio.default.Group, _objectSpread(_objectSpread({}, (0, _omit.default)(rest, _formMethods.default)), {}, {
|
|
130
132
|
className: (0, _classnames.default)('igloo-radio-group', className),
|
|
131
133
|
value: value,
|
|
@@ -204,6 +206,7 @@ var InnerRadioGroup = function InnerRadioGroup(_ref) {
|
|
|
204
206
|
exports.InnerRadioGroup = InnerRadioGroup;
|
|
205
207
|
var RadioGroup = (0, _optionUtils.optionsHOC)(InnerRadioGroup);
|
|
206
208
|
exports.RadioGroup = RadioGroup;
|
|
209
|
+
RadioGroup.isPreviewSupport = true;
|
|
207
210
|
|
|
208
211
|
RadioGroup.formItemPropsHandler = function () {
|
|
209
212
|
return {};
|
|
@@ -99,6 +99,7 @@ var InnerRadioGroupWithOther = function InnerRadioGroupWithOther(_ref) {
|
|
|
99
99
|
}, [options]);
|
|
100
100
|
|
|
101
101
|
var handleChange = function handleChange(e) {
|
|
102
|
+
enableOther(true);
|
|
102
103
|
onChange && onChange(e);
|
|
103
104
|
};
|
|
104
105
|
|
|
@@ -110,10 +111,23 @@ var InnerRadioGroupWithOther = function InnerRadioGroupWithOther(_ref) {
|
|
|
110
111
|
var _useContext = (0, _react.useContext)(_locale.LocaleContext),
|
|
111
112
|
formatMessage = _useContext.formatMessage;
|
|
112
113
|
|
|
114
|
+
var otherValue = (0, _react.useMemo)(function () {
|
|
115
|
+
return value === otherKey ? '' : value;
|
|
116
|
+
}, [value]);
|
|
117
|
+
var optionValueList = (0, _react.useMemo)(function () {
|
|
118
|
+
return options.map(function (e) {
|
|
119
|
+
return e.value;
|
|
120
|
+
});
|
|
121
|
+
}, [options]);
|
|
122
|
+
var radioGroupValue = (0, _react.useMemo)(function () {
|
|
123
|
+
if (otherEnabled) return otherKey;
|
|
124
|
+
if (optionValueList.includes(value) || value === undefined) return value;
|
|
125
|
+
return otherKey;
|
|
126
|
+
}, [options, otherEnabled, value]);
|
|
113
127
|
return (0, _jsxRuntime.jsx)("div", {
|
|
114
128
|
className: "igloo-reason-selector",
|
|
115
129
|
children: (0, _jsxRuntime.jsx)(_index.RadioGroup, _objectSpread({
|
|
116
|
-
value:
|
|
130
|
+
value: radioGroupValue,
|
|
117
131
|
onChange: handleRadioChange,
|
|
118
132
|
options: [].concat(_toConsumableArray(options), [{
|
|
119
133
|
label: otherOptionLabel || formatMessage({
|
|
@@ -122,7 +136,8 @@ var InnerRadioGroupWithOther = function InnerRadioGroupWithOther(_ref) {
|
|
|
122
136
|
value: otherKey,
|
|
123
137
|
extraInfo: {
|
|
124
138
|
content: (0, _jsxRuntime.jsx)(_input.TextArea, {
|
|
125
|
-
onChange: handleChange
|
|
139
|
+
onChange: handleChange,
|
|
140
|
+
value: otherValue
|
|
126
141
|
}),
|
|
127
142
|
shownTrigger: 'checked'
|
|
128
143
|
}
|
|
@@ -132,5 +147,6 @@ var InnerRadioGroupWithOther = function InnerRadioGroupWithOther(_ref) {
|
|
|
132
147
|
};
|
|
133
148
|
|
|
134
149
|
var RadioGroupWithOther = (0, _optionUtils.optionsHOC)(InnerRadioGroupWithOther);
|
|
150
|
+
RadioGroupWithOther.isPreviewSupport = true;
|
|
135
151
|
var _default = RadioGroupWithOther;
|
|
136
152
|
exports.default = _default;
|
|
@@ -5,6 +5,7 @@ import { ComponentProps } from '../utils/option-utils';
|
|
|
5
5
|
export declare const Option: import("rc-select/lib/Option").OptionFC, OptGroup: import("rc-select/lib/OptGroup").OptionGroupFC;
|
|
6
6
|
declare type Props = SelectProps<SelectValue> & IglooComponentProps & {
|
|
7
7
|
multiple?: boolean;
|
|
8
|
+
preview?: boolean;
|
|
8
9
|
} & ComponentProps;
|
|
9
10
|
declare type OptionType = typeof Option;
|
|
10
11
|
declare type OptGroupType = typeof OptGroup;
|
|
@@ -33,7 +33,8 @@ require("./style");
|
|
|
33
33
|
|
|
34
34
|
var _optionUtils = require("../utils/option-utils");
|
|
35
35
|
|
|
36
|
-
var _excluded = ["value", "className", "placeholder", "onDropdownVisibleChange", "showSearch", "filterOption", "optionFilterProp", "multiple", "options", "clearWhenOptionsUpdated"]
|
|
36
|
+
var _excluded = ["value", "className", "placeholder", "onDropdownVisibleChange", "showSearch", "filterOption", "optionFilterProp", "multiple", "options", "clearWhenOptionsUpdated", "preview"],
|
|
37
|
+
_excluded2 = ["label", "value"];
|
|
37
38
|
|
|
38
39
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
39
40
|
|
|
@@ -86,6 +87,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
86
87
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
87
88
|
_ref$clearWhenOptions = _ref.clearWhenOptionsUpdated,
|
|
88
89
|
clearWhenOptionsUpdated = _ref$clearWhenOptions === void 0 ? false : _ref$clearWhenOptions,
|
|
90
|
+
preview = _ref.preview,
|
|
89
91
|
rest = _objectWithoutProperties(_ref, _excluded);
|
|
90
92
|
|
|
91
93
|
var _useContext = (0, _react.useContext)(_localeContext.default),
|
|
@@ -193,6 +195,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
193
195
|
setSelectedOptions(options);
|
|
194
196
|
};
|
|
195
197
|
|
|
198
|
+
if (preview) return (0, _optionUtils.previewSelectedOptions)(options, valueProp);
|
|
196
199
|
return (0, _jsxRuntime.jsx)("div", {
|
|
197
200
|
className: (0, _classnames.default)('igloo-attached-select-containter', className),
|
|
198
201
|
children: (0, _jsxRuntime.jsx)(_select.default, _objectSpread(_objectSpread({
|
|
@@ -298,13 +301,16 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
298
301
|
dropdownMatchSelectWidth: true,
|
|
299
302
|
children: displayOptions.map(function (_ref10) {
|
|
300
303
|
var label = _ref10.label,
|
|
301
|
-
value = _ref10.value
|
|
302
|
-
|
|
304
|
+
value = _ref10.value,
|
|
305
|
+
rest = _objectWithoutProperties(_ref10, _excluded2);
|
|
306
|
+
|
|
307
|
+
return (0, _jsxRuntime.jsxs)(Option, _objectSpread(_objectSpread({
|
|
303
308
|
value: value,
|
|
304
309
|
label: label,
|
|
305
310
|
style: {
|
|
306
311
|
position: 'relative'
|
|
307
|
-
}
|
|
312
|
+
}
|
|
313
|
+
}, rest), {}, {
|
|
308
314
|
children: [multiple ? (0, _jsxRuntime.jsxs)("div", {
|
|
309
315
|
children: [(0, _jsxRuntime.jsx)(_checkbox.default, {
|
|
310
316
|
checked: Array.isArray(selected) && selected.includes(value),
|
|
@@ -322,7 +328,7 @@ var IglooSelect = function IglooSelect(_ref) {
|
|
|
322
328
|
left: 0
|
|
323
329
|
}
|
|
324
330
|
})]
|
|
325
|
-
}, value);
|
|
331
|
+
}), value);
|
|
326
332
|
})
|
|
327
333
|
}))
|
|
328
334
|
});
|
|
@@ -332,39 +338,9 @@ var AttachedSelect = Object.assign((0, _optionUtils.optionsHOC)(IglooSelect), {
|
|
|
332
338
|
Option: Option,
|
|
333
339
|
OptGroup: OptGroup
|
|
334
340
|
});
|
|
341
|
+
AttachedSelect.isPreviewSupport = true;
|
|
335
342
|
|
|
336
|
-
AttachedSelect.formItemPropsHandler = function (
|
|
337
|
-
var options = config.options,
|
|
338
|
-
multiple = config.multiple;
|
|
339
|
-
|
|
340
|
-
var previewFormateForSingleValue = function previewFormateForSingleValue(value) {
|
|
341
|
-
return options === null || options === void 0 ? void 0 : options.reduce(function (displayLabel, option) {
|
|
342
|
-
if (option.value === value) {
|
|
343
|
-
displayLabel = option.label;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
return displayLabel;
|
|
347
|
-
}, value);
|
|
348
|
-
}; // 多选
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
var previewFormateForMultipleValue = function previewFormateForMultipleValue(value) {
|
|
352
|
-
var replaceLabel = value.reduce(function (strArr, selectedValue, index) {
|
|
353
|
-
var matched = options === null || options === void 0 ? void 0 : options.filter(function (originOption) {
|
|
354
|
-
return originOption.value === selectedValue;
|
|
355
|
-
});
|
|
356
|
-
if (matched && matched[0]) strArr[index] = matched[0].label;
|
|
357
|
-
return strArr;
|
|
358
|
-
}, value);
|
|
359
|
-
return replaceLabel.join(',');
|
|
360
|
-
};
|
|
361
|
-
|
|
362
|
-
if (options === null || options === void 0 ? void 0 : options.length) {
|
|
363
|
-
return {
|
|
364
|
-
previewFormater: multiple ? previewFormateForMultipleValue : previewFormateForSingleValue
|
|
365
|
-
};
|
|
366
|
-
}
|
|
367
|
-
|
|
343
|
+
AttachedSelect.formItemPropsHandler = function () {
|
|
368
344
|
return {};
|
|
369
345
|
};
|
|
370
346
|
|
|
@@ -30,7 +30,10 @@
|
|
|
30
30
|
|
|
31
31
|
.ant-select-item-option {
|
|
32
32
|
padding: 12px 16px;
|
|
33
|
-
|
|
33
|
+
|
|
34
|
+
&:not(.ant-select-item-option-disabled) {
|
|
35
|
+
color: #212121;
|
|
36
|
+
}
|
|
34
37
|
|
|
35
38
|
.ant-select-item-option-content {
|
|
36
39
|
line-height: 24px;
|
|
@@ -259,7 +262,9 @@
|
|
|
259
262
|
|
|
260
263
|
.ant-select-item {
|
|
261
264
|
padding: 8px 16px;
|
|
262
|
-
|
|
265
|
+
&:not(.ant-select-item-option-disabled) {
|
|
266
|
+
color: #212121;
|
|
267
|
+
}
|
|
263
268
|
}
|
|
264
269
|
}
|
|
265
270
|
}
|
package/lib/types.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ export interface FormItemConfig extends FormItemExtraConfig {
|
|
|
125
125
|
export declare type FormItemPropsHandler = (config: FormItemConfig) => FormItemConfig;
|
|
126
126
|
interface IglooFC<P = {}> extends React.FunctionComponent<P> {
|
|
127
127
|
formItemPropsHandler?: FormItemPropsHandler;
|
|
128
|
+
isPreviewSupport?: boolean;
|
|
128
129
|
}
|
|
129
130
|
export interface Form extends React.ForwardRefExoticComponent<FormBasicConfig & React.RefAttributes<any>> {
|
|
130
131
|
useForm: () => FormInstance;
|
package/lib/utils/form-utils.js
CHANGED
|
@@ -210,8 +210,8 @@ var calcFormItemProps = function calcFormItemProps(config, extraProps, form, par
|
|
|
210
210
|
className = extraProps.className,
|
|
211
211
|
extraRest = _objectWithoutProperties(extraProps, _excluded2);
|
|
212
212
|
|
|
213
|
-
var rules = calcRequired(required, form, requiredAsserts) ? [{
|
|
214
|
-
required:
|
|
213
|
+
var rules = calcRequired(required || extraRequired, form, requiredAsserts) ? [{
|
|
214
|
+
required: type !== 'Declaration',
|
|
215
215
|
message: requiredMessage || extraRequiredMessage
|
|
216
216
|
}].concat(_toConsumableArray(propsRules)) : _toConsumableArray(propsRules);
|
|
217
217
|
|
|
@@ -23,4 +23,5 @@ export interface ComponentProps extends IglooComponentProps {
|
|
|
23
23
|
clearWhenOptionsUpdated?: boolean;
|
|
24
24
|
}
|
|
25
25
|
export declare function optionsHOC<T>(Component: FC<T>): FC<HOCProps & T>;
|
|
26
|
+
export declare function previewSelectedOptions(options: Options, value: any): any;
|
|
26
27
|
export {};
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.compareSelected = exports.compareOptions = void 0;
|
|
7
7
|
exports.optionsHOC = optionsHOC;
|
|
8
|
+
exports.previewSelectedOptions = previewSelectedOptions;
|
|
8
9
|
|
|
9
10
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
11
|
|
|
@@ -68,7 +69,7 @@ var compareOptions = function compareOptions(newOptions, oldOptions) {
|
|
|
68
69
|
var newOption = oldOptions[i];
|
|
69
70
|
var originOption = newOptions[i];
|
|
70
71
|
|
|
71
|
-
if (newOption.label !== originOption.label || newOption.value !== originOption.value) {
|
|
72
|
+
if (newOption.label !== originOption.label || newOption.value !== originOption.value || newOption.extraInfo !== originOption.extraInfo) {
|
|
72
73
|
return true;
|
|
73
74
|
}
|
|
74
75
|
}
|
|
@@ -277,4 +278,18 @@ function optionsHOC(Component) {
|
|
|
277
278
|
optionsUpdating: updating
|
|
278
279
|
})) : null;
|
|
279
280
|
};
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function previewSelectedOptions(options, value) {
|
|
284
|
+
var _value = [value].flat();
|
|
285
|
+
|
|
286
|
+
var replaceLabel = _value.reduce(function (strArr, selectedValue, index) {
|
|
287
|
+
var matched = options === null || options === void 0 ? void 0 : options.filter(function (originOption) {
|
|
288
|
+
return originOption.value === selectedValue;
|
|
289
|
+
});
|
|
290
|
+
if (matched && matched[0]) strArr[index] = matched[0].label;
|
|
291
|
+
return strArr;
|
|
292
|
+
}, _value);
|
|
293
|
+
|
|
294
|
+
return replaceLabel.join(',');
|
|
280
295
|
}
|