@canvas-components/list-table 0.2.4 → 0.2.5

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/index.d.cts CHANGED
@@ -411,7 +411,7 @@ type ListTableFormRules<RecordType = Record<string, unknown>> = ListTableFormRul
411
411
  * 单元格内容片段样式。
412
412
  */
413
413
  interface ListTableContentStyle {
414
- display?: "block" | "inline-block";
414
+ display?: "none" | "block" | "inline-block";
415
415
  textAlign?: CanvasTextAlign;
416
416
  fontSize?: number;
417
417
  fontWeight?: string;
@@ -430,6 +430,8 @@ interface ListTableContentStyle {
430
430
  */
431
431
  interface ListTableBaseCellContent<RecordType = any> {
432
432
  key?: string;
433
+ /** 是否展示内容,默认展示。 */
434
+ visible?: boolean;
433
435
  style?: ListTableContentStyle;
434
436
  cursor?: string;
435
437
  onClick?: (context: ListTableCellContentClickContext<RecordType>) => void;
package/dist/index.d.ts CHANGED
@@ -411,7 +411,7 @@ type ListTableFormRules<RecordType = Record<string, unknown>> = ListTableFormRul
411
411
  * 单元格内容片段样式。
412
412
  */
413
413
  interface ListTableContentStyle {
414
- display?: "block" | "inline-block";
414
+ display?: "none" | "block" | "inline-block";
415
415
  textAlign?: CanvasTextAlign;
416
416
  fontSize?: number;
417
417
  fontWeight?: string;
@@ -430,6 +430,8 @@ interface ListTableContentStyle {
430
430
  */
431
431
  interface ListTableBaseCellContent<RecordType = any> {
432
432
  key?: string;
433
+ /** 是否展示内容,默认展示。 */
434
+ visible?: boolean;
433
435
  style?: ListTableContentStyle;
434
436
  cursor?: string;
435
437
  onClick?: (context: ListTableCellContentClickContext<RecordType>) => void;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { stringifyDataIndex, getValueByDataIndex, clamp, copyTextSync, copyText, exportTableToXlsx, formatPreciseNumber, addPreciseNumbers, comparePreciseNumbers, dividePreciseNumber, roundPreciseNumber, parseNumberValue, formatNumberValue, formatPercentValue, formatScientificValue, formatChineseNumber, parseChineseNumber, normalizeDecimalPlaces, exportTableToTxt, exportTableToCsv, downloadJsonFile, mapRowsToExportRecords, copyJson, copyRows, isDateTimeFormatPattern, formatDateTimeValue, formatCustomNumberPattern, isSameDataIndex, isPointInRect as isPointInRect$1 } from '@canvas-components/utils';
1
+ import { stringifyDataIndex, getValueByDataIndex, clamp, copyTextSync, copyText, exportTableToXlsx, formatPreciseNumber, addPreciseNumbers, comparePreciseNumbers, dividePreciseNumber, roundPreciseNumber, parseNumberValue, formatNumberValue, formatPercentValue, formatScientificValue, formatChineseNumber, parseChineseNumber, exportTableToTxt, exportTableToCsv, downloadJsonFile, mapRowsToExportRecords, copyJson, copyRows, isDateTimeFormatPattern, normalizeDecimalPlaces, formatDateTimeValue, formatCustomNumberPattern, isSameDataIndex, isPointInRect as isPointInRect$1 } from '@canvas-components/utils';
2
2
  import { drawBarcodeToCanvas } from '@canvas-components/barcode';
3
3
  import { drawCanvasChartToCanvas, getCanvasChartRenderer, resolveCanvasChartTooltipText } from '@canvas-components/chart';
4
4
  import { drawQrCodeToCanvas } from '@canvas-components/qrcode';
@@ -5872,6 +5872,9 @@ function drawBodyTextContent(params) {
5872
5872
  searchMatch,
5873
5873
  fragmentKey = `content:${contentIndex}`
5874
5874
  } = params;
5875
+ if (params.content.visible === false || params.content.style?.display === "none") {
5876
+ return void 0;
5877
+ }
5875
5878
  ctx.save();
5876
5879
  ctx.globalAlpha *= resolveContentOpacity(content);
5877
5880
  applyTextContentStyle(
@@ -5983,6 +5986,9 @@ function drawBodyTextContent(params) {
5983
5986
  return width;
5984
5987
  }
5985
5988
  function measureTextContentWidth(ctx, content, theme) {
5989
+ if (content.visible === false || content.style?.display === "none") {
5990
+ return 0;
5991
+ }
5986
5992
  applyTextContentStyle(ctx, content, theme.textColor, theme);
5987
5993
  const intrinsicWidth = Math.max(
5988
5994
  ctx.measureText(content.text).width + resolveContentTextIndent(content),
@@ -6173,6 +6179,11 @@ var CONTENT_HORIZONTAL_PADDING = 12;
6173
6179
  var CONTENT_GAP = 8;
6174
6180
  var CONTENT_VERTICAL_PADDING = 6;
6175
6181
  function resolveBodyCellContents(params) {
6182
+ return resolveRawBodyCellContents(params).filter(
6183
+ (content) => content.visible !== false && content.style?.display !== "none"
6184
+ );
6185
+ }
6186
+ function resolveRawBodyCellContents(params) {
6176
6187
  const { record, rowIndex, column } = params;
6177
6188
  const value = getValueByDataIndex(record, column.dataIndex);
6178
6189
  const rendered = column.render?.(value, record, rowIndex, column);
@@ -6317,7 +6328,9 @@ function normalizeCellContents(contents) {
6317
6328
  return [normalizeCellContentItem(contents)];
6318
6329
  }
6319
6330
  function normalizeDrawableCellContents(contents) {
6320
- return contents.map(normalizeCellContentItem);
6331
+ return contents.filter(
6332
+ (content) => content.visible !== false && content.style?.display !== "none"
6333
+ ).map(normalizeCellContentItem);
6321
6334
  }
6322
6335
  function normalizeCellContentItem(content) {
6323
6336
  if (content.type !== "money") {
@@ -6327,6 +6340,7 @@ function normalizeCellContentItem(content) {
6327
6340
  type: "text",
6328
6341
  text: formatMoneyValue(content.value, content),
6329
6342
  key: content.key,
6343
+ visible: content.visible,
6330
6344
  style: content.style,
6331
6345
  cursor: content.cursor,
6332
6346
  onClick: content.onClick,