@dckj-npm/dc-material 0.1.379 → 0.1.381

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.
Files changed (34) hide show
  1. package/build/docs/colorful-button.html +3 -3
  2. package/build/docs/colorful-input.html +3 -3
  3. package/build/docs/custom-form/requirements.html +3 -3
  4. package/build/docs/custom-form.html +3 -3
  5. package/build/docs/index.html +3 -3
  6. package/build/docs/teletext-list.html +3 -3
  7. package/build/docs/{umi.80bcbda5.js → umi.b55ee37b.js} +1 -1
  8. package/build/docs/~demos/colorful-button-demo.html +3 -3
  9. package/build/docs/~demos/colorful-input-demo.html +3 -3
  10. package/build/docs/~demos/teletext-list-demo-1.html +3 -3
  11. package/build/docs/~demos/teletext-list-demo.html +3 -3
  12. package/build/lowcode/assets-daily.json +13 -13
  13. package/build/lowcode/assets-dev.json +2 -2
  14. package/build/lowcode/assets-prod.json +13 -13
  15. package/build/lowcode/meta.design.js +1 -1
  16. package/build/lowcode/meta.js +1 -1
  17. package/build/lowcode/render/default/view.js +1 -1
  18. package/build/lowcode/view.js +1 -1
  19. package/dist/BizComps.js +2 -2
  20. package/dist/BizComps.js.map +1 -1
  21. package/es/components/custom-form/custom-form.d.ts +13 -0
  22. package/es/components/custom-form/custom-form.js +158 -44
  23. package/es/components/custom-form/schema.json +1373 -1373
  24. package/lib/components/custom-form/custom-form.d.ts +13 -0
  25. package/lib/components/custom-form/custom-form.js +157 -43
  26. package/lib/components/custom-form/schema.json +1373 -1373
  27. package/lowcode/custom-form/meta.ts +55 -26
  28. package/lowcode_es/custom-form/meta.js +279 -241
  29. package/lowcode_es/meta.js +1 -1
  30. package/lowcode_lib/custom-form/meta.js +279 -241
  31. package/lowcode_lib/meta.js +1 -1
  32. package/package.json +3 -3
  33. package/es/components/custom-form/CUSTOM_FORM_OPERATION_MANUAL.md +0 -284
  34. package/lib/components/custom-form/CUSTOM_FORM_OPERATION_MANUAL.md +0 -284
@@ -356,7 +356,7 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
356
356
  {
357
357
  title: {
358
358
  label: '动态选项绑定',
359
- tip: '仅在组件类型为「下拉选择」「单选组」「复选组」时生效。\n绑定后优先级高于上方「选项列表」(静态配置)。\n支持绑定页面变量或数据源返回的数组,数组格式为 [{label, value}, ...]。\n常见用法:将套餐列表、城市列表等接口数据直接绑定到选项。',
359
+ tip: '仅在组件类型为「下拉选择」「单选组」「复选组」时生效。\n绑定后优先级高于上方「选项列表」(静态配置)。\n支持绑定页面变量或数据源返回的数组,数组格式为 [{label, value}, ...]。\n常见用法:将套餐列表、城市列表等接口数据直接绑定到选项。\n若接口返回的数据字段名不是 label/value,请配合下方「选项显示字段名」和「选项值字段名」使用。',
360
360
  },
361
361
  name: 'optionsBind',
362
362
  condition: (target: any) => {
@@ -379,6 +379,39 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
379
379
  },
380
380
  },
381
381
  },
382
+ // ── 动态选项字段映射(当数据源字段名不是 label/value 时使用)
383
+ {
384
+ title: {
385
+ label: '选项显示字段名',
386
+ tip: '当「动态选项绑定」的数据源字段名不是 label 时填写。\n例如后端返回 {package_name, id, ...},想用 package_name 做显示文字,则填 "package_name"。\n不填则默认使用 label 字段。',
387
+ },
388
+ name: 'optionsLabelKey',
389
+ condition: (target: any) => {
390
+ const t = target.parent?.getPropValue?.('componentType') || target.parent?.parent?.getPropValue?.('componentType')
391
+ return ['Select','RadioGroup','CheckboxGroup'].includes(t)
392
+ },
393
+ setter: {
394
+ componentName: 'StringSetter',
395
+ isRequired: false,
396
+ initialValue: '',
397
+ },
398
+ },
399
+ {
400
+ title: {
401
+ label: '选项值字段名',
402
+ tip: '当「动态选项绑定」的数据源字段名不是 value 时填写。\n例如后端返回 {package_name, id, ...}:\n· 想用 id 做存储值 → 填 "id"\n· 想用 package_name 做存储值 → 填 "package_name"\n不填则默认使用 value 字段。\n配置后,字段联动规则的「匹配字段名 matchKey」会自动默认使用此字段名,无需重复配置。',
403
+ },
404
+ name: 'optionsValueKey',
405
+ condition: (target: any) => {
406
+ const t = target.parent?.getPropValue?.('componentType') || target.parent?.parent?.getPropValue?.('componentType')
407
+ return ['Select','RadioGroup','CheckboxGroup'].includes(t)
408
+ },
409
+ setter: {
410
+ componentName: 'StringSetter',
411
+ isRequired: false,
412
+ initialValue: '',
413
+ },
414
+ },
382
415
  // ── 布局
383
416
  {
384
417
  title: {
@@ -1051,19 +1084,17 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
1051
1084
  const iv = target.getProps().getPropValue('initialValues')
1052
1085
  if (!iv) return []
1053
1086
  if (Array.isArray(iv)) {
1087
+ // 不过滤 field 为空的行,允许新添加的空行显示出来供用户填写
1088
+ // 仅过滤非对象的元素(防御性兼容旧脏数据)
1054
1089
  return iv
1055
- .map((row: any) => {
1056
- const field = typeof row?.field === 'string' ? row.field.trim() : ''
1057
- if (!field) return null
1058
- const valueType = row?.valueType === 'variable' ? 'variable' : 'fixed'
1059
- return {
1060
- field,
1061
- valueType,
1062
- value: row?.value,
1063
- }
1064
- })
1065
- .filter(Boolean)
1090
+ .filter((row: any) => row && typeof row === 'object')
1091
+ .map((row: any) => ({
1092
+ field: typeof row.field === 'string' ? row.field.trim() : '',
1093
+ valueType: row.valueType === 'variable' ? 'variable' : 'fixed',
1094
+ value: row.value,
1095
+ }))
1066
1096
  }
1097
+ // 对象格式:key 不可能为空字符串,保留原有过滤
1067
1098
  return Object.entries(iv as Record<string, any>).map(([field, value]) => ({
1068
1099
  field: String(field).trim(),
1069
1100
  valueType: 'fixed',
@@ -1072,18 +1103,16 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
1072
1103
  },
1073
1104
  setValue: (target: any, rows: any[]) => {
1074
1105
  if (!Array.isArray(rows)) return
1106
+ // 不过滤 field 为空的行:用户点击"添加一项"时新行 field 为空字符串,
1107
+ // 若此处过滤掉,ArraySetter 重读 getValue 后新行消失,表现为"添加无效"。
1108
+ // 运行时 normalizeInitialValues 已忽略 field 为空的行,不影响实际行为。
1075
1109
  const cleanedRows = rows
1076
- .map((row: any) => {
1077
- const field = typeof row?.field === 'string' ? row.field.trim() : ''
1078
- if (!field) return null
1079
- const valueType = row?.valueType === 'variable' ? 'variable' : 'fixed'
1080
- return {
1081
- field,
1082
- valueType,
1083
- value: row?.value,
1084
- }
1085
- })
1086
- .filter(Boolean)
1110
+ .filter((row: any) => row && typeof row === 'object')
1111
+ .map((row: any) => ({
1112
+ field: typeof row.field === 'string' ? row.field.trim() : '',
1113
+ valueType: row.valueType === 'variable' ? 'variable' : 'fixed',
1114
+ value: row.value,
1115
+ }))
1087
1116
  target.getProps().setPropValue('initialValues', cleanedRows)
1088
1117
  },
1089
1118
  },
@@ -1352,7 +1381,7 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
1352
1381
  {
1353
1382
  title: {
1354
1383
  label: '数据源',
1355
- tip: ' state 中选取一个数组变量作为查找来源。\n\n典型配置:将 package_name 字段的「动态选项绑定」绑定到 state.packages,然后此处同样选择 state.packages。\n\n这样当 package_name 变化时,会在 state.packages 中找到匹配的项,再按「回填映射」将各字段值填入表单。',
1384
+ tip: '⚠️ 必须通过右侧「变量绑定」按钮选择变量,不能直接输入文本(如 "this.state.xxx"),否则运行时会报错。\n\n请选取一个数组变量作为查找来源。\n\n典型配置:\n1. package_name 字段的「动态选项绑定」绑定到 state.packages\n2. 此处也选择同一个 state.packages\n\n数据格式要求(每个对象必须同时包含用于匹配的字段和用于回填的字段):\n state.packages = [\n {value:"A", label:"豪华套餐", price:9800, count:10},\n {value:"B", label:"标准套餐", price:5800, count:8}\n ]\n其中 value/label 供下拉框显示用,price/count 供联动回填用。',
1356
1385
  },
1357
1386
  name: 'dataSource',
1358
1387
  condition: (target: any) =>
@@ -1364,7 +1393,7 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
1364
1393
  {
1365
1394
  title: {
1366
1395
  label: '匹配字段',
1367
- tip: '在数据源的每个对象中,用哪个字段的值与监听字段的当前值进行比对。\n\n下拉框(Select)默认存储选项的 value 字段,此处填 value 即可。\n如果下拉框存储的是 label(名称),则填 label。\n\n示例:state.packages = [{value:"A", label:"豪华套餐", price:9800, count:10}, ...]\n则此处填 value(与 package_name 字段存储的选项 value 对应)。',
1396
+ tip: '在数据源的每个对象中,用哪个字段的值与监听字段的当前值进行比对。\n\n下拉框(Select)默认存储选项的 value 字段,此处填 value 即可。\n如果下拉框存储的是 label(名称),则填 label。\n\n示例:state.packages = [{value:"A", label:"豪华套餐", price:9800, count:10}, ...]\n则此处填 value(与 package_name 字段存储的选项 value 对应)。\n\n注意:匹配字段的值类型需与下拉框存储的值类型一致(如都为字符串,或都为数字)。',
1368
1397
  },
1369
1398
  name: 'matchKey',
1370
1399
  condition: (target: any) =>
@@ -1375,7 +1404,7 @@ const CustomFormMeta: IPublicTypeComponentMetadata = {
1375
1404
  {
1376
1405
  title: {
1377
1406
  label: '回填映射',
1378
- tip: '找到匹配项后,将数据源对象中的哪些字段值填入表单的哪些字段。\n\nJSON 格式:{ "表单字段名": "数据源字段名", ... }\n\n示例(state.packages 中每项有 price 和 count 属性):\n {"package_price":"price","guest_count":"count"}\n\n效果:匹配到套餐后,自动将 price 回填到 package_price 字段,count 回填到 guest_count 字段。',
1407
+ tip: '找到匹配项后,将数据源对象中的哪些字段值填入表单的哪些字段。\n\nJSON 格式:{ "表单字段名": "数据源字段名", ... }\n\n示例(state.packages 中每项有 price 和 count 属性):\n {"package_price":"price","guest_count":"count"}\n\n效果:匹配到套餐后,自动将 price 回填到 package_price 字段,count 回填到 guest_count 字段。\n\n注意:数据源字段名(value 部分)必须是数据源对象中实际存在的属性名。',
1379
1408
  },
1380
1409
  name: 'fillFields',
1381
1410
  condition: (target: any) =>