@kne/form-creator 0.1.29 → 0.1.30

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.
@@ -10266,6 +10266,41 @@ const renderFieldsContent = (fields, data, formatMessage, column, {
10266
10266
  });
10267
10267
  };
10268
10268
  const renderBlockList = (blocks, data, ctx) => (blocks || []).map(block => renderBlock(block, data, ctx)).filter(Boolean);
10269
+
10270
+ /** 列表项标题:优先 itemTitle,其次首个带标题的 itemBlock(与填写态 List 常见结构对齐),避免只显示「第 N 项」 */
10271
+ const resolveListItemTitle = (block, item, index, formatMessage) => {
10272
+ if (typeof block.itemTitle === 'function') {
10273
+ try {
10274
+ const title = block.itemTitle({
10275
+ index,
10276
+ data: item
10277
+ });
10278
+ if (title != null && title !== '') {
10279
+ return {
10280
+ title,
10281
+ titleFromItemBlockId: null
10282
+ };
10283
+ }
10284
+ } catch (e) {
10285
+ // ignore bad itemTitle
10286
+ }
10287
+ }
10288
+ const head = (block.itemBlocks || []).find(child => child && (child.title || child.label));
10289
+ if (head) {
10290
+ return {
10291
+ title: head.title || head.label,
10292
+ titleFromItemBlockId: head.id
10293
+ };
10294
+ }
10295
+ return {
10296
+ title: formatMessage({
10297
+ id: 'schemaContentItemIndex'
10298
+ }, {
10299
+ index: index + 1
10300
+ }),
10301
+ titleFromItemBlockId: null
10302
+ };
10303
+ };
10269
10304
  const renderBlock = (block, data, ctx) => {
10270
10305
  const {
10271
10306
  formatMessage,
@@ -10315,15 +10350,21 @@ const renderBlock = (block, data, ctx) => {
10315
10350
  const items = name ? getByPath(data, name) : null;
10316
10351
  const rows = Array.isArray(items) ? items : [];
10317
10352
  return /*#__PURE__*/jsx(InfoPage.Part, _extends({}, partProps, {
10318
- children: rows.length ? rows.map((item, index) => /*#__PURE__*/jsxs(InfoPage.Part, {
10319
- title: formatMessage({
10320
- id: 'schemaContentItemIndex'
10321
- }, {
10322
- index: index + 1
10323
- }),
10324
- bordered: false,
10325
- children: [renderFieldsContent(block.list, item || {}, formatMessage, 2), supportsItemBlocks(block.kind) ? renderBlockList(block.itemBlocks, item || {}, nextCtx) : null]
10326
- }, `${block.id}-${index}`)) : formatMessage({
10353
+ children: rows.length ? rows.map((item, index) => {
10354
+ const {
10355
+ title: itemTitle,
10356
+ titleFromItemBlockId
10357
+ } = resolveListItemTitle(block, item || {}, index, formatMessage);
10358
+ const itemBlocks = supportsItemBlocks(block.kind) && titleFromItemBlockId ? (block.itemBlocks || []).map(child => child && child.id === titleFromItemBlockId ? _extends({}, child, {
10359
+ title: undefined,
10360
+ label: undefined
10361
+ }) : child) : block.itemBlocks;
10362
+ return /*#__PURE__*/jsxs(InfoPage.Part, {
10363
+ title: itemTitle,
10364
+ bordered: false,
10365
+ children: [renderFieldsContent(block.list, item || {}, formatMessage, 2), supportsItemBlocks(block.kind) ? renderBlockList(itemBlocks, item || {}, nextCtx) : null]
10366
+ }, `${block.id}-${index}`);
10367
+ }) : formatMessage({
10327
10368
  id: 'schemaContentEmptyValue'
10328
10369
  })
10329
10370
  }));