n20-common-lib 2.22.39 → 2.22.40

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "2.22.39",
3
+ "version": "2.22.40",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -145,6 +145,47 @@ import empty from '../Empty'
145
145
  import tableSetSize from '../TableSetSize/index.vue'
146
146
  import { $lc } from '../../utils/i18n/index.js'
147
147
  import XEUtils from 'xe-utils'
148
+
149
+ /** 将 Element 表格风格的 show-overflow-tooltip 转为 vxe-column 的 show-overflow */
150
+ function hasOverflowTooltipKey(item) {
151
+ return (
152
+ Object.prototype.hasOwnProperty.call(item, 'showOverflowTooltip') ||
153
+ Object.prototype.hasOwnProperty.call(item, 'show-overflow-tooltip')
154
+ )
155
+ }
156
+
157
+ function applyTooltipToShowOverflow(item) {
158
+ const explicitOverflow =
159
+ item.showOverflow !== undefined ? item.showOverflow : item['show-overflow']
160
+ const hasTooltipKey = hasOverflowTooltipKey(item)
161
+ if (!hasTooltipKey && explicitOverflow === undefined) {
162
+ return item
163
+ }
164
+ const out = { ...item }
165
+ if (hasTooltipKey) {
166
+ delete out['show-overflow-tooltip']
167
+ delete out.showOverflowTooltip
168
+ }
169
+ if (explicitOverflow !== undefined) {
170
+ out['show-overflow'] = explicitOverflow
171
+ } else if (hasTooltipKey) {
172
+ const tooltipVal = item.showOverflowTooltip ?? item['show-overflow-tooltip']
173
+ // 与 n20 Table(ux-table)overflowF 一致:无 tooltip 时用 ellipsis,仅省略无浮层
174
+ out['show-overflow'] = tooltipVal ? 'tooltip' : 'ellipsis'
175
+ }
176
+ return out
177
+ }
178
+
179
+ function mapColumnOverflowForVxe(item) {
180
+ if (!item) return item
181
+ if (item.children && item.children.length) {
182
+ const children = item.children.map(mapColumnOverflowForVxe)
183
+ const childChanged = children.some((c, i) => c !== item.children[i])
184
+ if (!childChanged) return item
185
+ return { ...item, children }
186
+ }
187
+ return applyTooltipToShowOverflow(item)
188
+ }
148
189
  const renderer = {
149
190
  name: 'renderer',
150
191
  props: {
@@ -244,11 +285,8 @@ export default {
244
285
  },
245
286
  computed: {
246
287
  _columns() {
247
- if (this.isAutoWidth) {
248
- return this.calcColumnWidth(this.columns)
249
- } else {
250
- return this.columns
251
- }
288
+ const raw = this.isAutoWidth ? this.calcColumnWidth(this.columns) : this.columns
289
+ return raw.map(mapColumnOverflowForVxe)
252
290
  }
253
291
  },
254
292
  watch: {