naive-ui 2.30.4 → 2.30.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.
Files changed (75) hide show
  1. package/dist/index.js +293 -75
  2. package/dist/index.prod.js +2 -2
  3. package/es/_internal/scrollbar/src/Scrollbar.js +1 -2
  4. package/es/_internal/selection/src/Selection.js +5 -3
  5. package/es/_utils/dom/index.d.ts +1 -0
  6. package/es/_utils/dom/index.js +1 -0
  7. package/es/_utils/dom/is-document.d.ts +1 -0
  8. package/es/_utils/dom/is-document.js +3 -0
  9. package/es/_utils/index.d.ts +2 -1
  10. package/es/_utils/index.js +2 -1
  11. package/es/_utils/vue/index.d.ts +2 -0
  12. package/es/_utils/vue/index.js +2 -0
  13. package/es/_utils/vue/is-node-v-show-false.d.ts +2 -0
  14. package/es/_utils/vue/is-node-v-show-false.js +6 -0
  15. package/es/{_internal/scrollbar/src/Wrapper.d.ts → _utils/vue/wrapper.d.ts} +0 -0
  16. package/es/{_internal/scrollbar/src/Wrapper.js → _utils/vue/wrapper.js} +0 -0
  17. package/es/back-top/src/BackTop.d.ts +1 -1
  18. package/es/back-top/src/BackTop.js +24 -31
  19. package/es/data-table/src/DataTable.d.ts +5 -2
  20. package/es/data-table/src/DataTable.js +3 -2
  21. package/es/data-table/src/TableParts/Body.d.ts +1 -0
  22. package/es/data-table/src/TableParts/Body.js +4 -3
  23. package/es/data-table/src/TableParts/Cell.d.ts +3 -1
  24. package/es/data-table/src/TableParts/Cell.js +7 -3
  25. package/es/data-table/src/interface.d.ts +2 -1
  26. package/es/data-table/src/use-check.js +11 -3
  27. package/es/grid/src/Grid.js +28 -8
  28. package/es/image/src/Image.d.ts +10 -0
  29. package/es/image/src/Image.js +40 -8
  30. package/es/image/src/utils.d.ts +11 -0
  31. package/es/image/src/utils.js +81 -0
  32. package/es/input/src/styles/input-group-label.cssr.js +2 -0
  33. package/es/space/src/Space.d.ts +26 -0
  34. package/es/space/src/Space.js +53 -43
  35. package/es/tooltip/index.d.ts +1 -1
  36. package/es/version.d.ts +1 -1
  37. package/es/version.js +1 -1
  38. package/lib/_internal/scrollbar/src/Scrollbar.js +2 -3
  39. package/lib/_internal/selection/src/Selection.js +4 -2
  40. package/lib/_utils/dom/index.d.ts +1 -0
  41. package/lib/_utils/dom/index.js +5 -0
  42. package/lib/_utils/dom/is-document.d.ts +1 -0
  43. package/lib/_utils/dom/is-document.js +7 -0
  44. package/lib/_utils/index.d.ts +2 -1
  45. package/lib/_utils/index.js +4 -1
  46. package/lib/_utils/vue/index.d.ts +2 -0
  47. package/lib/_utils/vue/index.js +5 -1
  48. package/lib/_utils/vue/is-node-v-show-false.d.ts +2 -0
  49. package/lib/_utils/vue/is-node-v-show-false.js +10 -0
  50. package/lib/{_internal/scrollbar/src/Wrapper.d.ts → _utils/vue/wrapper.d.ts} +0 -0
  51. package/lib/{_internal/scrollbar/src/Wrapper.js → _utils/vue/wrapper.js} +0 -0
  52. package/lib/back-top/src/BackTop.d.ts +1 -1
  53. package/lib/back-top/src/BackTop.js +23 -30
  54. package/lib/data-table/src/DataTable.d.ts +5 -2
  55. package/lib/data-table/src/DataTable.js +3 -2
  56. package/lib/data-table/src/TableParts/Body.d.ts +1 -0
  57. package/lib/data-table/src/TableParts/Body.js +4 -3
  58. package/lib/data-table/src/TableParts/Cell.d.ts +3 -1
  59. package/lib/data-table/src/TableParts/Cell.js +7 -3
  60. package/lib/data-table/src/interface.d.ts +2 -1
  61. package/lib/data-table/src/use-check.js +11 -3
  62. package/lib/grid/src/Grid.js +26 -6
  63. package/lib/image/src/Image.d.ts +10 -0
  64. package/lib/image/src/Image.js +39 -7
  65. package/lib/image/src/utils.d.ts +11 -0
  66. package/lib/image/src/utils.js +86 -0
  67. package/lib/input/src/styles/input-group-label.cssr.js +2 -0
  68. package/lib/space/src/Space.d.ts +26 -0
  69. package/lib/space/src/Space.js +53 -43
  70. package/lib/tooltip/index.d.ts +1 -1
  71. package/lib/version.d.ts +1 -1
  72. package/lib/version.js +1 -1
  73. package/package.json +1 -1
  74. package/volar.d.ts +0 -1
  75. package/web-types.json +37 -1
@@ -3,9 +3,8 @@ import { on, off } from 'evtd';
3
3
  import { VResizeObserver } from 'vueuc';
4
4
  import { useIsIos } from 'vooks';
5
5
  import { useConfig, useTheme, useThemeClass } from '../../../_mixins';
6
- import { useReactivated } from '../../../_utils';
6
+ import { useReactivated, Wrapper } from '../../../_utils';
7
7
  import { scrollbarLight } from '../styles';
8
- import { Wrapper } from './Wrapper';
9
8
  import style from './styles/index.cssr';
10
9
  const scrollbarProps = Object.assign(Object.assign({}, useTheme.props), { size: {
11
10
  type: Number,
@@ -4,7 +4,7 @@ import { VOverflow } from 'vueuc';
4
4
  import { NPopover } from '../../../popover';
5
5
  import { NTag } from '../../../tag';
6
6
  import { useThemeClass, useTheme } from '../../../_mixins';
7
- import { createKey, getTitleAttribute, render, useOnResize } from '../../../_utils';
7
+ import { createKey, getTitleAttribute, render, useOnResize, Wrapper } from '../../../_utils';
8
8
  import Suffix from '../../suffix';
9
9
  import { internalSelectionLight } from '../styles';
10
10
  import style from './styles/index.cssr';
@@ -426,8 +426,10 @@ export default defineComponent({
426
426
  const maxTagCountResponsive = maxTagCount === 'responsive';
427
427
  const maxTagCountNumeric = typeof maxTagCount === 'number';
428
428
  const useMaxTagCount = maxTagCountResponsive || maxTagCountNumeric;
429
- const suffix = (h(Suffix, { clsPrefix: clsPrefix, loading: this.loading, showArrow: this.showArrow, showClear: this.mergedClearable && this.selected, onClear: this.handleClear }, {
430
- default: () => { var _a, _b; return (_b = (_a = this.$slots).arrow) === null || _b === void 0 ? void 0 : _b.call(_a); }
429
+ const suffix = (h(Wrapper, null, {
430
+ default: () => (h(Suffix, { clsPrefix: clsPrefix, loading: this.loading, showArrow: this.showArrow, showClear: this.mergedClearable && this.selected, onClear: this.handleClear }, {
431
+ default: () => { var _a, _b; return (_b = (_a = this.$slots).arrow) === null || _b === void 0 ? void 0 : _b.call(_a); }
432
+ }))
431
433
  }));
432
434
  let body;
433
435
  if (multiple) {
@@ -0,0 +1 @@
1
+ export { isDocument } from './is-document';
@@ -0,0 +1 @@
1
+ export { isDocument } from './is-document';
@@ -0,0 +1 @@
1
+ export declare function isDocument(node: Node): node is Document;
@@ -0,0 +1,3 @@
1
+ export function isDocument(node) {
2
+ return node.nodeName === '#document';
3
+ }
@@ -1,4 +1,4 @@
1
- export { call, keep, omit, flatten, getSlot, getVNodeChildren, keysOf, render, getFirstSlotVNode, createDataKey, createRefSetter, createInjectionKey, resolveSlot, resolveSlotWithProps, resolveWrappedSlot, isSlotEmpty, mergeEventHandlers } from './vue';
1
+ export { call, keep, omit, flatten, getSlot, getVNodeChildren, keysOf, render, getFirstSlotVNode, createDataKey, createRefSetter, createInjectionKey, resolveSlot, resolveSlotWithProps, resolveWrappedSlot, isSlotEmpty, mergeEventHandlers, isNodeVShowFalse, Wrapper } from './vue';
2
2
  export type { MaybeArray } from './vue';
3
3
  export { warn, warnOnce, throwError, smallerSize, largerSize, getTitleAttribute } from './naive';
4
4
  export type { ExtractPublicPropTypes, ExtractInternalPropTypes, Mutable } from './naive';
@@ -8,3 +8,4 @@ export { isJsdom } from './env/is-jsdom';
8
8
  export { isBrowser } from './env/is-browser';
9
9
  export { eventEffectNotPerformed, markEventEffectPerformed } from './event';
10
10
  export * from './composable';
11
+ export * from './dom';
@@ -1,4 +1,4 @@
1
- export { call, keep, omit, flatten, getSlot, getVNodeChildren, keysOf, render, getFirstSlotVNode, createDataKey, createRefSetter, createInjectionKey, resolveSlot, resolveSlotWithProps, resolveWrappedSlot, isSlotEmpty, mergeEventHandlers } from './vue';
1
+ export { call, keep, omit, flatten, getSlot, getVNodeChildren, keysOf, render, getFirstSlotVNode, createDataKey, createRefSetter, createInjectionKey, resolveSlot, resolveSlotWithProps, resolveWrappedSlot, isSlotEmpty, mergeEventHandlers, isNodeVShowFalse, Wrapper } from './vue';
2
2
  export { warn, warnOnce, throwError, smallerSize, largerSize, getTitleAttribute } from './naive';
3
3
  export { formatLength, color2Class } from './css';
4
4
  export { createKey } from './cssr';
@@ -6,3 +6,4 @@ export { isJsdom } from './env/is-jsdom';
6
6
  export { isBrowser } from './env/is-browser';
7
7
  export { eventEffectNotPerformed, markEventEffectPerformed } from './event';
8
8
  export * from './composable';
9
+ export * from './dom';
@@ -13,3 +13,5 @@ export { createInjectionKey } from './create-injection-key';
13
13
  export { resolveSlot, resolveWrappedSlot, resolveSlotWithProps, isSlotEmpty } from './resolve-slot';
14
14
  export type { MaybeArray } from './call';
15
15
  export { mergeEventHandlers } from './merge-handlers';
16
+ export { isNodeVShowFalse } from './is-node-v-show-false';
17
+ export { Wrapper } from './wrapper';
@@ -12,3 +12,5 @@ export { createRefSetter } from './create-ref-setter';
12
12
  export { createInjectionKey } from './create-injection-key';
13
13
  export { resolveSlot, resolveWrappedSlot, resolveSlotWithProps, isSlotEmpty } from './resolve-slot';
14
14
  export { mergeEventHandlers } from './merge-handlers';
15
+ export { isNodeVShowFalse } from './is-node-v-show-false';
16
+ export { Wrapper } from './wrapper';
@@ -0,0 +1,2 @@
1
+ import { VNode } from 'vue';
2
+ export declare function isNodeVShowFalse(vNode: VNode): boolean;
@@ -0,0 +1,6 @@
1
+ import { vShow } from 'vue';
2
+ export function isNodeVShowFalse(vNode) {
3
+ var _a;
4
+ const showDir = (_a = vNode.dirs) === null || _a === void 0 ? void 0 : _a.find(({ dir }) => dir === vShow);
5
+ return !!(showDir && showDir.value === false);
6
+ }
@@ -159,7 +159,7 @@ declare const _default: import("vue").DefineComponent<{
159
159
  mergedClsPrefix: import("vue").ComputedRef<string>;
160
160
  handleAfterEnter: () => void;
161
161
  handleScroll: () => void;
162
- handleClick: (e: MouseEvent) => void;
162
+ handleClick: () => void;
163
163
  cssVars: import("vue").ComputedRef<{
164
164
  '--n-bezier': string;
165
165
  '--n-border-radius': string;
@@ -4,7 +4,7 @@ import { useIsMounted, useMergedState } from 'vooks';
4
4
  import { getScrollParent, unwrapElement } from 'seemly';
5
5
  import { useConfig, useTheme, useThemeClass } from '../../_mixins';
6
6
  import { NBaseIcon } from '../../_internal';
7
- import { lockHtmlScrollRightCompensationRef, formatLength, resolveSlot, warn, warnOnce } from '../../_utils';
7
+ import { lockHtmlScrollRightCompensationRef, formatLength, resolveSlot, isDocument, warn, warnOnce } from '../../_utils';
8
8
  import { backTopLight } from '../styles';
9
9
  import BackTopIcon from './BackTopIcon';
10
10
  import style from './styles/index.cssr';
@@ -50,15 +50,20 @@ export default defineComponent({
50
50
  }
51
51
  const { mergedClsPrefixRef, inlineThemeDisabled } = useConfig(props);
52
52
  const scrollTopRef = ref(null);
53
- const uncontrolledShowRef = computed(() => {
54
- if (scrollTopRef.value === null)
55
- return false;
56
- return scrollTopRef.value >= props.visibilityHeight;
53
+ const uncontrolledShowRef = ref(false);
54
+ watchEffect(() => {
55
+ const { value: scrollTop } = scrollTopRef;
56
+ if (scrollTop === null) {
57
+ uncontrolledShowRef.value = false;
58
+ return;
59
+ }
60
+ uncontrolledShowRef.value = scrollTop >= props.visibilityHeight;
57
61
  });
58
62
  const DomInfoReadyRef = ref(false);
59
63
  watch(uncontrolledShowRef, (value) => {
64
+ var _a;
60
65
  if (DomInfoReadyRef.value) {
61
- props['onUpdate:show'](value);
66
+ (_a = props['onUpdate:show']) === null || _a === void 0 ? void 0 : _a.call(props, value);
62
67
  }
63
68
  });
64
69
  const controlledShowRef = toRef(props, 'show');
@@ -98,39 +103,27 @@ export default defineComponent({
98
103
  }
99
104
  return;
100
105
  }
101
- scrollElement = scrollEl;
106
+ scrollElement =
107
+ scrollEl === document.documentElement ? document : scrollEl;
102
108
  const { to } = props;
103
109
  const target = typeof to === 'string' ? document.querySelector(to) : to;
104
110
  if (process.env.NODE_ENV !== 'production' && !target) {
105
111
  warn('back-top', 'Target is not found.');
106
112
  }
107
- if (scrollEl) {
108
- scrollEl.addEventListener('scroll', handleScroll);
109
- handleScroll();
110
- }
113
+ scrollElement.addEventListener('scroll', handleScroll);
114
+ handleScroll();
111
115
  }
112
- function handleClick(e) {
113
- if (scrollElement.nodeName === '#document') {
114
- ;
115
- scrollElement.documentElement.scrollTo({
116
- top: 0,
117
- behavior: 'smooth'
118
- });
119
- }
120
- else {
121
- scrollElement.scrollTo({
122
- top: 0,
123
- behavior: 'smooth'
124
- });
125
- }
116
+ function handleClick() {
117
+ ;
118
+ (isDocument(scrollElement)
119
+ ? document.documentElement
120
+ : scrollElement).scrollTo({
121
+ top: 0,
122
+ behavior: 'smooth'
123
+ });
126
124
  }
127
125
  function handleScroll() {
128
- if (scrollElement.nodeName === '#document') {
129
- scrollTopRef.value = scrollElement.documentElement.scrollTop;
130
- }
131
- else {
132
- scrollTopRef.value = scrollElement.scrollTop;
133
- }
126
+ scrollTopRef.value = (isDocument(scrollElement) ? document.documentElement : scrollElement).scrollTop;
134
127
  if (!DomInfoReadyRef.value) {
135
128
  void nextTick(() => {
136
129
  DomInfoReadyRef.value = true;
@@ -1,7 +1,7 @@
1
- import { PropType, ExtractPropTypes } from 'vue';
1
+ import { PropType, ExtractPropTypes, VNodeChild } from 'vue';
2
2
  import type { PaginationProps } from '../../pagination';
3
3
  import type { MaybeArray, ExtractPublicPropTypes } from '../../_utils';
4
- import type { CreateRowClassName, CreateRowKey, OnUpdateCheckedRowKeys, OnUpdateSorter, RowKey, TableColumns, RowData, OnUpdateFilters, OnUpdateExpandedRowKeys, CreateSummary, CreateRowProps, DataTableOnLoad } from './interface';
4
+ import type { CreateRowClassName, CreateRowKey, OnUpdateCheckedRowKeys, OnUpdateSorter, RowKey, TableColumns, RowData, OnUpdateFilters, OnUpdateExpandedRowKeys, CreateSummary, CreateRowProps, DataTableOnLoad, TableBaseColumn } from './interface';
5
5
  export declare const dataTableProps: {
6
6
  readonly pagination: {
7
7
  readonly type: PropType<false | PaginationProps>;
@@ -80,6 +80,7 @@ export declare const dataTableProps: {
80
80
  readonly type: PropType<"first" | "current">;
81
81
  readonly default: "current";
82
82
  };
83
+ readonly renderCell: PropType<(value: any, rowData: object, column: TableBaseColumn) => VNodeChild>;
83
84
  readonly onLoad: PropType<DataTableOnLoad>;
84
85
  readonly 'onUpdate:page': PropType<MaybeArray<(page: number) => void> | undefined>;
85
86
  readonly onUpdatePage: PropType<MaybeArray<(page: number) => void> | undefined>;
@@ -2295,6 +2296,7 @@ declare const _default: import("vue").DefineComponent<{
2295
2296
  readonly type: PropType<"first" | "current">;
2296
2297
  readonly default: "current";
2297
2298
  };
2299
+ readonly renderCell: PropType<(value: any, rowData: object, column: TableBaseColumn<import("./interface").InternalRowData>) => VNodeChild>;
2298
2300
  readonly onLoad: PropType<DataTableOnLoad>;
2299
2301
  readonly 'onUpdate:page': PropType<MaybeArray<(page: number) => void> | undefined>;
2300
2302
  readonly onUpdatePage: PropType<MaybeArray<(page: number) => void> | undefined>;
@@ -5702,6 +5704,7 @@ declare const _default: import("vue").DefineComponent<{
5702
5704
  readonly type: PropType<"first" | "current">;
5703
5705
  readonly default: "current";
5704
5706
  };
5707
+ readonly renderCell: PropType<(value: any, rowData: object, column: TableBaseColumn<import("./interface").InternalRowData>) => VNodeChild>;
5705
5708
  readonly onLoad: PropType<DataTableOnLoad>;
5706
5709
  readonly 'onUpdate:page': PropType<MaybeArray<(page: number) => void> | undefined>;
5707
5710
  readonly onUpdatePage: PropType<MaybeArray<(page: number) => void> | undefined>;
@@ -60,7 +60,7 @@ export const dataTableProps = Object.assign(Object.assign({}, useTheme.props), {
60
60
  }, flexHeight: Boolean, paginationBehaviorOnFilter: {
61
61
  type: String,
62
62
  default: 'current'
63
- }, onLoad: Function, 'onUpdate:page': [Function, Array], onUpdatePage: [Function, Array], 'onUpdate:pageSize': [Function, Array], onUpdatePageSize: [Function, Array], 'onUpdate:sorter': [Function, Array], onUpdateSorter: [Function, Array], 'onUpdate:filters': [Function, Array], onUpdateFilters: [Function, Array], 'onUpdate:checkedRowKeys': [Function, Array], onUpdateCheckedRowKeys: [Function, Array], 'onUpdate:expandedRowKeys': [Function, Array], onUpdateExpandedRowKeys: [Function, Array], onScroll: Function,
63
+ }, renderCell: Function, onLoad: Function, 'onUpdate:page': [Function, Array], onUpdatePage: [Function, Array], 'onUpdate:pageSize': [Function, Array], onUpdatePageSize: [Function, Array], 'onUpdate:sorter': [Function, Array], onUpdateSorter: [Function, Array], 'onUpdate:filters': [Function, Array], onUpdateFilters: [Function, Array], 'onUpdate:checkedRowKeys': [Function, Array], onUpdateCheckedRowKeys: [Function, Array], 'onUpdate:expandedRowKeys': [Function, Array], onUpdateExpandedRowKeys: [Function, Array], onScroll: Function,
64
64
  // deprecated
65
65
  onPageChange: [Function, Array], onPageSizeChange: [Function, Array], onSorterChange: [Function, Array], onFiltersChange: [Function, Array], onCheckedRowKeysChange: [Function, Array] });
66
66
  export default defineComponent({
@@ -204,7 +204,8 @@ export default defineComponent({
204
204
  doUpdateExpandedRowKeys,
205
205
  handleTableHeaderScroll,
206
206
  handleTableBodyScroll,
207
- setHeaderScrollLeft
207
+ setHeaderScrollLeft,
208
+ renderCell: toRef(props, 'renderCell')
208
209
  });
209
210
  const exposedMethods = {
210
211
  filter,
@@ -1213,6 +1213,7 @@ declare const _default: import("vue").DefineComponent<{
1213
1213
  key: RowKey;
1214
1214
  }, checked: boolean, shiftKey: boolean) => void;
1215
1215
  handleUpdateExpanded: (key: RowKey, tmNode: TmNode | null) => void;
1216
+ renderCell: import("vue").Ref<((value: any, rowData: object, column: import("../interface").TableBaseColumn<import("../interface").InternalRowData>) => import("vue").VNodeChild) | undefined>;
1216
1217
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
1217
1218
  onResize: PropType<(e: ResizeObserverEntry) => void>;
1218
1219
  showHeader: BooleanConstructor;
@@ -77,7 +77,7 @@ export default defineComponent({
77
77
  bodyStyle: Object
78
78
  },
79
79
  setup(props) {
80
- const { slots: dataTableSlots, mergedExpandedRowKeysRef, mergedClsPrefixRef, mergedThemeRef, scrollXRef, colsRef, paginatedDataRef, rawPaginatedDataRef, fixedColumnLeftMapRef, fixedColumnRightMapRef, mergedCurrentPageRef, rowClassNameRef, leftActiveFixedColKeyRef, leftActiveFixedChildrenColKeysRef, rightActiveFixedColKeyRef, rightActiveFixedChildrenColKeysRef, renderExpandRef, hoverKeyRef, summaryRef, mergedSortStateRef, virtualScrollRef, componentId, scrollPartRef, mergedTableLayoutRef, childTriggerColIndexRef, indentRef, rowPropsRef, maxHeightRef, stripedRef, loadingRef, onLoadRef, loadingKeySetRef, setHeaderScrollLeft, doUpdateExpandedRowKeys, handleTableBodyScroll, doCheck, doUncheck
80
+ const { slots: dataTableSlots, mergedExpandedRowKeysRef, mergedClsPrefixRef, mergedThemeRef, scrollXRef, colsRef, paginatedDataRef, rawPaginatedDataRef, fixedColumnLeftMapRef, fixedColumnRightMapRef, mergedCurrentPageRef, rowClassNameRef, leftActiveFixedColKeyRef, leftActiveFixedChildrenColKeysRef, rightActiveFixedColKeyRef, rightActiveFixedChildrenColKeysRef, renderExpandRef, hoverKeyRef, summaryRef, mergedSortStateRef, virtualScrollRef, componentId, scrollPartRef, mergedTableLayoutRef, childTriggerColIndexRef, indentRef, rowPropsRef, maxHeightRef, stripedRef, loadingRef, onLoadRef, loadingKeySetRef, setHeaderScrollLeft, doUpdateExpandedRowKeys, handleTableBodyScroll, doCheck, doUncheck, renderCell
81
81
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
82
82
  } = inject(dataTableInjectionKey);
83
83
  const scrollbarInstRef = ref(null);
@@ -308,7 +308,8 @@ export default defineComponent({
308
308
  virtualListContent,
309
309
  handleTableBodyScroll,
310
310
  handleCheckboxUpdateChecked,
311
- handleUpdateExpanded }, exposedMethods);
311
+ handleUpdateExpanded,
312
+ renderCell }, exposedMethods);
312
313
  },
313
314
  render() {
314
315
  const { mergedTheme, scrollX, mergedClsPrefix, virtualScroll, maxHeight, mergedTableLayout, flexHeight, loadingKeySet, onResize, setHeaderScrollLeft } = this;
@@ -511,7 +512,7 @@ export default defineComponent({
511
512
  ]
512
513
  : null,
513
514
  column.type === 'selection' ? (!isSummary ? (h(RenderSafeCheckbox, { key: currentPage, rowKey: rowKey, disabled: rowInfo.tmNode.disabled, onUpdateChecked: (checked, e) => handleCheckboxUpdateChecked(rowInfo.tmNode, checked, e.shiftKey) })) : null) : column.type === 'expand' ? (!isSummary ? (!column.expandable ||
514
- ((_e = column.expandable) === null || _e === void 0 ? void 0 : _e.call(column, rowData)) ? (h(ExpandTrigger, { clsPrefix: mergedClsPrefix, expanded: expanded, onClick: () => handleUpdateExpanded(rowKey, null) })) : null) : null) : (h(Cell, { index: rowIndex, row: rowData, column: column, isSummary: isSummary, mergedTheme: mergedTheme }))));
515
+ ((_e = column.expandable) === null || _e === void 0 ? void 0 : _e.call(column, rowData)) ? (h(ExpandTrigger, { clsPrefix: mergedClsPrefix, expanded: expanded, onClick: () => handleUpdateExpanded(rowKey, null) })) : null) : null) : (h(Cell, { index: rowIndex, row: rowData, column: column, isSummary: isSummary, mergedTheme: mergedTheme, renderCell: this.renderCell }))));
515
516
  })));
516
517
  return row;
517
518
  };
@@ -1,4 +1,4 @@
1
- import { PropType } from 'vue';
1
+ import { PropType, VNodeChild } from 'vue';
2
2
  import { TableBaseColumn, InternalRowData } from '../interface';
3
3
  declare const _default: import("vue").DefineComponent<{
4
4
  row: {
@@ -1149,6 +1149,7 @@ declare const _default: import("vue").DefineComponent<{
1149
1149
  }>;
1150
1150
  required: true;
1151
1151
  };
1152
+ renderCell: PropType<(value: any, rowData: object, column: any) => VNodeChild>;
1152
1153
  }, unknown, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
1153
1154
  row: {
1154
1155
  type: PropType<InternalRowData>;
@@ -2298,6 +2299,7 @@ declare const _default: import("vue").DefineComponent<{
2298
2299
  }>;
2299
2300
  required: true;
2300
2301
  };
2302
+ renderCell: PropType<(value: any, rowData: object, column: any) => VNodeChild>;
2301
2303
  }>>, {
2302
2304
  isSummary: boolean;
2303
2305
  }>;
@@ -20,11 +20,13 @@ export default defineComponent({
20
20
  mergedTheme: {
21
21
  type: Object,
22
22
  required: true
23
- }
23
+ },
24
+ renderCell: Function
24
25
  },
25
26
  render() {
26
- const { isSummary, column: { render, key, ellipsis }, row } = this;
27
+ const { isSummary, column, row, renderCell } = this;
27
28
  let cell;
29
+ const { render, key, ellipsis } = column;
28
30
  if (render && !isSummary) {
29
31
  cell = render(row, this.index);
30
32
  }
@@ -33,7 +35,9 @@ export default defineComponent({
33
35
  cell = row[key].value;
34
36
  }
35
37
  else {
36
- cell = get(row, key);
38
+ cell = renderCell
39
+ ? renderCell(get(row, key), row, column)
40
+ : get(row, key);
37
41
  }
38
42
  }
39
43
  if (ellipsis && typeof ellipsis === 'object') {
@@ -173,6 +173,7 @@ export interface DataTableInjection {
173
173
  handleTableBodyScroll: (e: Event) => void;
174
174
  syncScrollState: (deltaX?: number, deltaY?: number) => void;
175
175
  setHeaderScrollLeft: (scrollLeft: number) => void;
176
+ renderCell: Ref<undefined | ((value: any, rowData: object, column: TableBaseColumn) => VNodeChild)>;
176
177
  }
177
178
  export declare const dataTableInjectionKey: import("vue").InjectionKey<DataTableInjection>;
178
179
  export interface MainTableInjection {
@@ -192,7 +193,7 @@ export declare type RenderFilterMenu = (actions: {
192
193
  hide: () => void;
193
194
  }) => VNodeChild;
194
195
  export declare type OnUpdateExpandedRowKeys = (keys: RowKey[]) => void;
195
- export declare type OnUpdateCheckedRowKeys = (keys: RowKey[]) => void;
196
+ export declare type OnUpdateCheckedRowKeys = (keys: RowKey[], row: InternalRowData[]) => void;
196
197
  export declare type OnUpdateSorter = (sortState: SortState & SortState[] & null) => void;
197
198
  export declare type OnUpdateSorterImpl = (sortState: SortState | SortState[] | null) => void;
198
199
  export declare type OnUpdateFilters = (filterState: FilterState, sourceColumn: TableBaseColumn) => void;
@@ -50,12 +50,20 @@ export function useCheck(props, data) {
50
50
  });
51
51
  function doUpdateCheckedRowKeys(keys) {
52
52
  const { 'onUpdate:checkedRowKeys': _onUpdateCheckedRowKeys, onUpdateCheckedRowKeys, onCheckedRowKeysChange } = props;
53
+ const rows = [];
54
+ const { value: { getNode } } = treeMateRef;
55
+ keys.forEach((key) => {
56
+ var _a;
57
+ const row = (_a = getNode(key)) === null || _a === void 0 ? void 0 : _a.rawNode;
58
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
59
+ rows.push(row);
60
+ });
53
61
  if (_onUpdateCheckedRowKeys)
54
- call(_onUpdateCheckedRowKeys, keys);
62
+ call(_onUpdateCheckedRowKeys, keys, rows);
55
63
  if (onUpdateCheckedRowKeys)
56
- call(onUpdateCheckedRowKeys, keys);
64
+ call(onUpdateCheckedRowKeys, keys, rows);
57
65
  if (onCheckedRowKeysChange)
58
- call(onCheckedRowKeysChange, keys);
66
+ call(onCheckedRowKeysChange, keys, rows);
59
67
  uncontrolledCheckedRowKeysRef.value = keys;
60
68
  }
61
69
  function doCheck(rowKey) {
@@ -1,10 +1,10 @@
1
- import { h, defineComponent, computed, provide, toRef, mergeProps, ref, cloneVNode } from 'vue';
1
+ import { h, defineComponent, computed, provide, toRef, mergeProps, ref, cloneVNode, vShow } from 'vue';
2
2
  import { useBreakpoints, useMemo } from 'vooks';
3
3
  import { VResizeObserver } from 'vueuc';
4
4
  import { pxfy, parseResponsivePropValue, beforeNextFrameOnce } from 'seemly';
5
5
  import { defaultBreakpoints } from '../../config-provider/src/config';
6
6
  import { useConfig } from '../../_mixins';
7
- import { getSlot, flatten } from '../../_utils';
7
+ import { getSlot, flatten, isNodeVShowFalse } from '../../_utils';
8
8
  import { defaultSpan, gridInjectionKey } from './config';
9
9
  const defaultCols = 24;
10
10
  const gridProps = {
@@ -102,7 +102,7 @@ export default defineComponent({
102
102
  },
103
103
  render() {
104
104
  const renderContent = () => {
105
- var _a, _b, _c, _d, _e, _f;
105
+ var _a, _b, _c, _d, _e, _f, _g;
106
106
  this.overflow = false;
107
107
  // render will be called twice when mounted, I can't figure out why
108
108
  // 2 jobs will be pushed into job queues with same id, and then be flushed
@@ -110,11 +110,28 @@ export default defineComponent({
110
110
  const childrenAndRawSpan = [];
111
111
  const { collapsed, collapsedRows, responsiveCols, responsiveQuery } = this;
112
112
  rawChildren.forEach((child) => {
113
- var _a, _b, _c;
113
+ var _a, _b, _c, _d;
114
114
  if (((_a = child === null || child === void 0 ? void 0 : child.type) === null || _a === void 0 ? void 0 : _a.__GRID_ITEM__) !== true)
115
115
  return;
116
+ if (isNodeVShowFalse(child)) {
117
+ const clonedNode = cloneVNode(child);
118
+ if (clonedNode.props) {
119
+ clonedNode.props.privateShow = false;
120
+ }
121
+ else {
122
+ clonedNode.props = { pirvateShow: false };
123
+ }
124
+ childrenAndRawSpan.push({
125
+ child: clonedNode,
126
+ rawChildSpan: 0
127
+ });
128
+ return;
129
+ }
130
+ // We don't want v-show to control display, so we need to stripe it
131
+ // here, nor it may mess child's style
132
+ child.dirs = ((_b = child.dirs) === null || _b === void 0 ? void 0 : _b.filter(({ dir }) => dir !== vShow)) || null;
116
133
  const clonedChild = cloneVNode(child);
117
- const rawChildSpan = Number((_c = parseResponsivePropValue((_b = clonedChild.props) === null || _b === void 0 ? void 0 : _b.span, responsiveQuery)) !== null && _c !== void 0 ? _c : defaultSpan);
134
+ const rawChildSpan = Number((_d = parseResponsivePropValue((_c = clonedChild.props) === null || _c === void 0 ? void 0 : _c.span, responsiveQuery)) !== null && _d !== void 0 ? _d : defaultSpan);
118
135
  if (rawChildSpan === 0)
119
136
  return;
120
137
  childrenAndRawSpan.push({
@@ -131,7 +148,8 @@ export default defineComponent({
131
148
  maybeSuffixNode.props.privateSpan = suffixSpan;
132
149
  maybeSuffixNode.props.privateColStart =
133
150
  responsiveCols + 1 - suffixSpan;
134
- maybeSuffixNode.props.privateShow = true;
151
+ maybeSuffixNode.props.privateShow =
152
+ (_e = maybeSuffixNode.props.privateShow) !== null && _e !== void 0 ? _e : true;
135
153
  }
136
154
  }
137
155
  let spanCounter = 0;
@@ -141,8 +159,9 @@ export default defineComponent({
141
159
  this.overflow = true;
142
160
  }
143
161
  if (!done) {
144
- const childOffset = Number((_f = parseResponsivePropValue((_e = child.props) === null || _e === void 0 ? void 0 : _e.offset, responsiveQuery)) !== null && _f !== void 0 ? _f : 0);
145
- const childSpan = Math.min(rawChildSpan + childOffset, responsiveCols) || 1;
162
+ const childOffset = Number((_g = parseResponsivePropValue((_f = child.props) === null || _f === void 0 ? void 0 : _f.offset, responsiveQuery)) !== null && _g !== void 0 ? _g : 0);
163
+ // it could be 0 sometimes (v-show = false)
164
+ const childSpan = Math.min(rawChildSpan + childOffset, responsiveCols);
146
165
  if (!child.props) {
147
166
  child.props = {
148
167
  privateSpan: childSpan,
@@ -169,6 +188,7 @@ export default defineComponent({
169
188
  }
170
189
  if (done) {
171
190
  if (child.props) {
191
+ // suffix node's privateShow may be true
172
192
  if (child.props.privateShow !== true) {
173
193
  child.props.privateShow = false;
174
194
  }
@@ -1,5 +1,6 @@
1
1
  import { PropType, ImgHTMLAttributes } from 'vue';
2
2
  import type { ExtractPublicPropTypes } from '../../_utils';
3
+ import type { IntersectionObserverOptions } from './utils';
3
4
  export interface ImageInst {
4
5
  click: () => void;
5
6
  }
@@ -99,6 +100,8 @@ declare const imageProps: {
99
100
  alt: StringConstructor;
100
101
  height: PropType<string | number>;
101
102
  imgProps: PropType<ImgHTMLAttributes>;
103
+ lazy: BooleanConstructor;
104
+ intersectionObserverOptions: PropType<IntersectionObserverOptions>;
102
105
  objectFit: {
103
106
  type: PropType<"fill" | "none" | "contain" | "cover" | "scale-down">;
104
107
  default: string;
@@ -209,6 +212,8 @@ declare const _default: import("vue").DefineComponent<{
209
212
  alt: StringConstructor;
210
213
  height: PropType<string | number>;
211
214
  imgProps: PropType<ImgHTMLAttributes>;
215
+ lazy: BooleanConstructor;
216
+ intersectionObserverOptions: PropType<IntersectionObserverOptions>;
212
217
  objectFit: {
213
218
  type: PropType<"fill" | "none" | "contain" | "cover" | "scale-down">;
214
219
  default: string;
@@ -233,6 +238,8 @@ declare const _default: import("vue").DefineComponent<{
233
238
  imageRef: import("vue").Ref<HTMLImageElement | null>;
234
239
  imgProps: import("vue").Ref<ImgHTMLAttributes | undefined>;
235
240
  showError: import("vue").Ref<boolean>;
241
+ shouldStartLoading: import("vue").Ref<boolean>;
242
+ loaded: import("vue").Ref<boolean>;
236
243
  mergedOnError: (e: Event) => void;
237
244
  mergedOnLoad: (e: Event) => void;
238
245
  }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
@@ -331,6 +338,8 @@ declare const _default: import("vue").DefineComponent<{
331
338
  alt: StringConstructor;
332
339
  height: PropType<string | number>;
333
340
  imgProps: PropType<ImgHTMLAttributes>;
341
+ lazy: BooleanConstructor;
342
+ intersectionObserverOptions: PropType<IntersectionObserverOptions>;
334
343
  objectFit: {
335
344
  type: PropType<"fill" | "none" | "contain" | "cover" | "scale-down">;
336
345
  default: string;
@@ -344,6 +353,7 @@ declare const _default: import("vue").DefineComponent<{
344
353
  onError: PropType<(e: Event) => void>;
345
354
  onLoad: PropType<(e: Event) => void>;
346
355
  }>>, {
356
+ lazy: boolean;
347
357
  objectFit: "fill" | "none" | "contain" | "cover" | "scale-down";
348
358
  showToolbar: boolean;
349
359
  showToolbarTooltip: boolean;
@@ -1,9 +1,10 @@
1
- import { defineComponent, h, inject, ref, toRef, watchEffect, onMounted } from 'vue';
1
+ import { defineComponent, h, inject, ref, toRef, watchEffect, onMounted, onBeforeUnmount } from 'vue';
2
2
  import NImagePreview from './ImagePreview';
3
3
  import { imageGroupInjectionKey } from './ImageGroup';
4
4
  import { useConfig } from '../../_mixins';
5
5
  import { imagePreviewSharedProps } from './interface';
6
- const imageProps = Object.assign({ alt: String, height: [String, Number], imgProps: Object, objectFit: {
6
+ import { observeIntersection } from './utils';
7
+ const imageProps = Object.assign({ alt: String, height: [String, Number], imgProps: Object, lazy: Boolean, intersectionObserverOptions: Object, objectFit: {
7
8
  type: String,
8
9
  default: 'fill'
9
10
  }, previewSrc: String, fallbackSrc: String, width: [String, Number], src: String, previewDisabled: Boolean, loadDescription: String, onError: Function, onLoad: Function }, imagePreviewSharedProps);
@@ -37,18 +38,34 @@ export default defineComponent({
37
38
  previewInst.toggleShow();
38
39
  }
39
40
  };
41
+ const shouldStartLoadingRef = ref(!props.lazy);
40
42
  onMounted(() => {
41
43
  var _a;
42
44
  (_a = imageRef.value) === null || _a === void 0 ? void 0 : _a.setAttribute('data-group-id', (imageGroupHandle === null || imageGroupHandle === void 0 ? void 0 : imageGroupHandle.groupId) || '');
43
45
  });
46
+ onMounted(() => {
47
+ let unobserve;
48
+ const stopWatchHandle = watchEffect(() => {
49
+ unobserve === null || unobserve === void 0 ? void 0 : unobserve();
50
+ unobserve = undefined;
51
+ if (props.lazy) {
52
+ unobserve = observeIntersection(imageRef.value, props.intersectionObserverOptions, shouldStartLoadingRef);
53
+ }
54
+ });
55
+ onBeforeUnmount(() => {
56
+ stopWatchHandle();
57
+ unobserve === null || unobserve === void 0 ? void 0 : unobserve();
58
+ });
59
+ });
44
60
  watchEffect(() => {
45
61
  var _a;
46
62
  void props.src;
47
63
  void ((_a = props.imgProps) === null || _a === void 0 ? void 0 : _a.src);
48
64
  showErrorRef.value = false;
49
65
  });
66
+ const loadedRef = ref(false);
50
67
  return Object.assign({ mergedClsPrefix: mergedClsPrefixRef, groupId: imageGroupHandle === null || imageGroupHandle === void 0 ? void 0 : imageGroupHandle.groupId, previewInstRef,
51
- imageRef, imgProps: imgPropsRef, showError: showErrorRef, mergedOnError: (e) => {
68
+ imageRef, imgProps: imgPropsRef, showError: showErrorRef, shouldStartLoading: shouldStartLoadingRef, loaded: loadedRef, mergedOnError: (e) => {
52
69
  showErrorRef.value = true;
53
70
  const { onError, imgProps: { onError: imgPropsOnError } = {} } = props;
54
71
  onError === null || onError === void 0 ? void 0 : onError(e);
@@ -57,18 +74,33 @@ export default defineComponent({
57
74
  const { onLoad, imgProps: { onLoad: imgPropsOnLoad } = {} } = props;
58
75
  onLoad === null || onLoad === void 0 ? void 0 : onLoad(e);
59
76
  imgPropsOnLoad === null || imgPropsOnLoad === void 0 ? void 0 : imgPropsOnLoad(e);
77
+ loadedRef.value = true;
60
78
  } }, exposedMethods);
61
79
  },
62
80
  render() {
63
- const { mergedClsPrefix, imgProps = {}, $attrs } = this;
64
- const imgNode = (h("img", Object.assign({}, imgProps, { class: imgProps.class, ref: "imageRef", width: this.width || imgProps.width, height: this.height || imgProps.height, src: this.showError ? this.fallbackSrc : this.src || imgProps.src, alt: this.alt || imgProps.alt, "aria-label": this.alt || imgProps.alt, onClick: this.click, onError: this.mergedOnError, onLoad: this.mergedOnLoad, style: [imgProps.style || '', { objectFit: this.objectFit }], "data-error": this.showError, "data-preview-src": this.previewSrc || this.src })));
81
+ var _a, _b;
82
+ const { mergedClsPrefix, imgProps = {}, loaded, $attrs } = this;
83
+ const placeholderNode = (_b = (_a = this.$slots).placeholder) === null || _b === void 0 ? void 0 : _b.call(_a);
84
+ const imgNode = (h("img", Object.assign({}, imgProps, { class: imgProps.class, ref: "imageRef", width: this.width || imgProps.width, height: this.height || imgProps.height, src: this.showError
85
+ ? this.fallbackSrc
86
+ : this.shouldStartLoading
87
+ ? this.src || imgProps.src
88
+ : undefined, alt: this.alt || imgProps.alt, "aria-label": this.alt || imgProps.alt, onClick: this.click, onError: this.mergedOnError, onLoad: this.mergedOnLoad, style: [
89
+ imgProps.style || '',
90
+ placeholderNode && !loaded
91
+ ? { height: '0', width: '0', visibility: 'hidden' }
92
+ : '',
93
+ { objectFit: this.objectFit }
94
+ ], "data-error": this.showError, "data-preview-src": this.previewSrc || this.src })));
65
95
  return (h("div", Object.assign({}, $attrs, { role: "none", class: [
66
96
  $attrs.class,
67
97
  `${mergedClsPrefix}-image`,
68
98
  (this.previewDisabled || this.showError) &&
69
99
  `${mergedClsPrefix}-image--preview-disabled`
70
- ] }), this.groupId ? (imgNode) : (h(NImagePreview, { theme: this.theme, themeOverrides: this.themeOverrides, clsPrefix: mergedClsPrefix, ref: "previewInstRef", showToolbar: this.showToolbar, showToolbarTooltip: this.showToolbarTooltip }, {
71
- default: () => imgNode
72
- }))));
100
+ ] }),
101
+ this.groupId ? (imgNode) : (h(NImagePreview, { theme: this.theme, themeOverrides: this.themeOverrides, clsPrefix: mergedClsPrefix, ref: "previewInstRef", showToolbar: this.showToolbar, showToolbarTooltip: this.showToolbarTooltip }, {
102
+ default: () => imgNode
103
+ })),
104
+ !loaded && placeholderNode));
73
105
  }
74
106
  });
@@ -0,0 +1,11 @@
1
+ import { Ref } from 'vue';
2
+ export declare type IntersectionObserverOptions = Omit<IntersectionObserverInit, 'root'> & {
3
+ root?: Element | Document | null | string;
4
+ };
5
+ export declare const resolveOptionsAndHash: (options?: IntersectionObserverOptions | undefined) => {
6
+ hash: string;
7
+ options: Omit<IntersectionObserverInit, "root"> & {
8
+ root: Element | Document;
9
+ };
10
+ };
11
+ export declare const observeIntersection: (el: HTMLImageElement | null, options: IntersectionObserverOptions | undefined, shouldStartLoadingRef: Ref<boolean>) => () => void;