@ftjs/antd 3.0.0 → 3.1.1
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/dist/form/index.d.ts +1 -0
- package/dist/index.js +11 -6
- package/package.json +1 -1
package/dist/form/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -237,22 +237,26 @@ const cascader = defineFormItem((props) => {
|
|
|
237
237
|
const locale = useLocale();
|
|
238
238
|
return () => {
|
|
239
239
|
const _props = unrefs(props.column.props);
|
|
240
|
+
const fieldNames = (_props == null ? void 0 : _props.fieldNames) || {};
|
|
241
|
+
const labelKey = fieldNames.label || "label";
|
|
242
|
+
const valueKey = fieldNames.value || "value";
|
|
243
|
+
const childrenKey = fieldNames.children || "children";
|
|
240
244
|
const placeholder = locale.value.placeholder.select(formItemProps.value.label);
|
|
241
245
|
const getTextFromOptions = (options, value, level = 0) => {
|
|
242
246
|
if (!options || !value || level >= value.length) return void 0;
|
|
243
247
|
const currentValue = value[level];
|
|
244
|
-
const currentOption = options.find((option) => option
|
|
248
|
+
const currentOption = options.find((option) => option[valueKey] === currentValue);
|
|
245
249
|
if (!currentOption) return void 0;
|
|
246
250
|
if (level === value.length - 1) {
|
|
247
|
-
return currentOption
|
|
251
|
+
return currentOption[labelKey];
|
|
248
252
|
}
|
|
249
|
-
if (currentOption
|
|
250
|
-
const childText = getTextFromOptions(currentOption
|
|
253
|
+
if (currentOption[childrenKey] && currentOption[childrenKey].length > 0) {
|
|
254
|
+
const childText = getTextFromOptions(currentOption[childrenKey], value, level + 1);
|
|
251
255
|
if (childText) {
|
|
252
|
-
return `${currentOption
|
|
256
|
+
return `${currentOption[labelKey]} / ${childText}`;
|
|
253
257
|
}
|
|
254
258
|
}
|
|
255
|
-
return currentOption
|
|
259
|
+
return currentOption[labelKey];
|
|
256
260
|
};
|
|
257
261
|
const isViewText = computed(() => {
|
|
258
262
|
if (props.isView && valueComputed.value) {
|
|
@@ -1279,5 +1283,6 @@ export {
|
|
|
1279
1283
|
isComponentTuple,
|
|
1280
1284
|
registerEdit,
|
|
1281
1285
|
registerForm,
|
|
1286
|
+
useFormItemProps,
|
|
1282
1287
|
useRules
|
|
1283
1288
|
};
|