oa-componentbook 1.0.1-stage.350 → 1.0.1-stage.352
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.
|
@@ -64,12 +64,23 @@ function FormWidget(props) {
|
|
|
64
64
|
const getFieldRules = item => {
|
|
65
65
|
return dynamicRules[item === null || item === void 0 ? void 0 : item.name] || (item === null || item === void 0 ? void 0 : item.rules) || [];
|
|
66
66
|
};
|
|
67
|
+
const getInputRules = (itemData, item) => {
|
|
68
|
+
var _ref;
|
|
69
|
+
if (itemData !== null && itemData !== void 0 && itemData.customRules) {
|
|
70
|
+
for (const key in itemData === null || itemData === void 0 ? void 0 : itemData.customRules) {
|
|
71
|
+
if (item[key]) {
|
|
72
|
+
var _itemData$customRules;
|
|
73
|
+
return itemData === null || itemData === void 0 || (_itemData$customRules = itemData.customRules[key]) === null || _itemData$customRules === void 0 ? void 0 : _itemData$customRules.map(r => (r === null || r === void 0 ? void 0 : r.checkValidator) && (r === null || r === void 0 ? void 0 : r.rule));
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return (_ref = itemData || item) === null || _ref === void 0 || (_ref = _ref.rules) === null || _ref === void 0 ? void 0 : _ref.map(r => (r === null || r === void 0 ? void 0 : r.checkValidator) && (r === null || r === void 0 ? void 0 : r.rule));
|
|
78
|
+
};
|
|
67
79
|
const handleDynamicRuleUpdate = (fieldName, value, dynamicRulesConfig) => {
|
|
68
80
|
if (!dynamicRulesConfig) return;
|
|
69
|
-
|
|
70
|
-
Object.entries(dynamicRulesConfig).forEach(_ref => {
|
|
81
|
+
Object.entries(dynamicRulesConfig).forEach(_ref2 => {
|
|
71
82
|
var _config$conditions;
|
|
72
|
-
let [targetField, config] =
|
|
83
|
+
let [targetField, config] = _ref2;
|
|
73
84
|
const condition = (_config$conditions = config.conditions) === null || _config$conditions === void 0 ? void 0 : _config$conditions.find(c => c.type === "equals" ? value == c.value : c.type == "not_equals" ? value != c.value : c.type == "includes" ? value === null || value === void 0 ? void 0 : value.includes(c.value) : c.validator ? c.validator(value) : false);
|
|
74
85
|
const newRules = condition ? condition.rules : config.defaultRules || [];
|
|
75
86
|
setDynamicRules(prev => _objectSpread(_objectSpread({}, prev), {}, {
|
|
@@ -151,8 +162,8 @@ function FormWidget(props) {
|
|
|
151
162
|
},
|
|
152
163
|
showSearch: (_item$showSearch = item === null || item === void 0 ? void 0 : item.showSearch) !== null && _item$showSearch !== void 0 ? _item$showSearch : false,
|
|
153
164
|
filterOption: (input, option) => {
|
|
154
|
-
var _toLowerCase,
|
|
155
|
-
return (_toLowerCase = (
|
|
165
|
+
var _toLowerCase, _ref3, _option$label$props$t, _option$label, _input$toLowerCase;
|
|
166
|
+
return (_toLowerCase = (_ref3 = (_option$label$props$t = option === null || option === void 0 || (_option$label = option.label) === null || _option$label === void 0 || (_option$label = _option$label.props) === null || _option$label === void 0 ? void 0 : _option$label.title) !== null && _option$label$props$t !== void 0 ? _option$label$props$t : "").toLowerCase) === null || _toLowerCase === void 0 || (_toLowerCase = _toLowerCase.call(_ref3)) === null || _toLowerCase === void 0 ? void 0 : _toLowerCase.includes(input === null || input === void 0 || (_input$toLowerCase = input.toLowerCase) === null || _input$toLowerCase === void 0 ? void 0 : _input$toLowerCase.call(input));
|
|
156
167
|
}
|
|
157
168
|
}, item.optionLabelProp && {
|
|
158
169
|
optionLabelProp: (_item$optionLabelProp = item === null || item === void 0 ? void 0 : item.optionLabelProp) !== null && _item$optionLabelProp !== void 0 ? _item$optionLabelProp : ""
|
|
@@ -185,7 +196,7 @@ function FormWidget(props) {
|
|
|
185
196
|
return /*#__PURE__*/_react.default.createElement(_antd.Form.Item, {
|
|
186
197
|
name: "".concat(item === null || item === void 0 ? void 0 : item.name).concat(index ? index : ""),
|
|
187
198
|
label: renderLabelWithTooltip(item === null || item === void 0 ? void 0 : item.label, item === null || item === void 0 ? void 0 : item.tooltip),
|
|
188
|
-
rules:
|
|
199
|
+
rules: getInputRules(itemData, item),
|
|
189
200
|
extra: item === null || item === void 0 ? void 0 : item.helpText,
|
|
190
201
|
initialValue: item === null || item === void 0 ? void 0 : item.value
|
|
191
202
|
}, /*#__PURE__*/_react.default.createElement(_CustomInput.default, _extends({}, item === null || item === void 0 ? void 0 : item.props, {
|