🌐 AI搜索 & 代理 主页
Skip to content

Commit ede5fe4

Browse files
authored
Merge branch 'dev' into b-form-tags-limit-prop
2 parents 7af585d + f847dae commit ede5fe4

File tree

6 files changed

+39
-28
lines changed

6 files changed

+39
-28
lines changed

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@
140140
"execa": "^4.0.3",
141141
"highlight.js": "^9.18.2",
142142
"html-loader": "^1.3.0",
143-
"husky": "^4.2.5",
143+
"husky": "^4.3.0",
144144
"improved-yarn-audit": "^2.3.1",
145145
"jest": "^26.4.2",
146146
"lint-staged": "^10.3.0",
@@ -153,7 +153,7 @@
153153
"prettier": "1.14.3",
154154
"regenerator-runtime": "^0.13.7",
155155
"require-context": "^1.1.0",
156-
"rollup": "^2.26.10",
156+
"rollup": "^2.26.11",
157157
"rollup-plugin-babel": "^4.4.0",
158158
"rollup-plugin-commonjs": "^10.1.0",
159159
"rollup-plugin-node-resolve": "^5.2.0",

src/components/table/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ The following field properties are recognized:
242242
| `class` | String or Array | Class name (or array of class names) to add to `<th>` **and** `<td>` in the column. |
243243
| `formatter` | String or Function | A formatter callback function or name of a method in your component, can be used instead of (or in conjunction with) scoped field slots. The formatter will be called with the syntax `formatter(value, key, item)`. Refer to [Custom Data Rendering](#custom-data-rendering) for more details. |
244244
| `sortable` | Boolean | Enable sorting on this column. Refer to the [Sorting](#sorting) Section for more details. |
245+
| `sortKey` | String | <span class="badge badge-secondary">v2.17.0+</span> Set the value of `sortBy` for the column in the emitted context when `no-local-sorting` is `true`. |
245246
| `sortDirection` | String | Set the initial sort direction on this column when it becomes sorted. Refer to the [Change initial sort direction](#change-initial-sort-direction) Section for more details. |
246247
| `sortByFormatted` | Boolean or Function | Sort the column by the result of the field's `formatter` callback function when set to `true`. Default is `false`. Boolean has no effect if the field does not have a `formatter`. Optionally accepts a formatter function _reference_ to format the value for sorting purposes only. Refer to the [Sorting](#sorting) Section for more details. |
247248
| `filterByFormatted` | Boolean or Function | Filter the column by the result of the field's `formatter` callback function when set to `true`. Default is `false`. Boolean has no effect if the field does not have a `formatter`. Optionally accepts a formatter function _reference_ to format the value for filtering purposes only. Refer to the [Filtering](#filtering) section for more details. |
@@ -2048,7 +2049,7 @@ function toString(value) {
20482049
### Disable local sorting
20492050

20502051
If you want to handle sorting entirely in your app, you can disable the local sorting in `<b-table>`
2051-
by setting the prop `no-local-sorting` to true, while still maintaining the sortable header
2052+
by setting the prop `no-local-sorting` to `true`, while still maintaining the sortable header
20522053
functionality (via `sort-changed` or `context-changed` events as well as syncable props).
20532054

20542055
You can use the syncable props `sort-by.sync` and `sort-desc.sync` to detect changes in sorting
@@ -2059,7 +2060,7 @@ with a single argument containing the context object of `<b-table>`. See the
20592060
[Detection of sorting change](#detection-of-sorting-change) section below for details about the
20602061
sort-changed event and the context object.
20612062

2062-
When `no-local-sorting` is true, the `sort-compare` prop has no effect.
2063+
When `no-local-sorting` is `true`, the `sort-compare` prop has no effect.
20632064

20642065
### Change initial sort direction
20652066

src/components/table/helpers/mixin-sorting.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,13 @@ export default {
209209
}
210210
}
211211
if (field.sortable) {
212-
if (key === this.localSortBy) {
212+
const sortKey = !this.localSorting && field.sortKey ? field.sortKey : key
213+
if (this.localSortBy === sortKey) {
213214
// Change sorting direction on current column
214215
this.localSortDesc = !this.localSortDesc
215216
} else {
216217
// Start sorting this column ascending
217-
this.localSortBy = key
218+
this.localSortBy = sortKey
218219
// this.localSortDesc = false
219220
toggleLocalSortDesc()
220221
}

src/components/table/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export declare class BTable extends BvComponent {
2424
fields?: BvTableFieldArray
2525
primaryKey?: string
2626
sortBy?: string | null
27+
sortKey?: string
2728
sortDesc?: boolean
2829
sortDirection?: BvTableSortDirection
2930
sortCompare?: BvTableSortCompareCallback

src/components/table/table-sorting.spec.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,25 @@ describe('table > sorting', () => {
4141
wrapper.destroy()
4242
})
4343

44+
it('should emit `field.sortKey` if specified and no local sorting', async () => {
45+
const wrapper = mount(BTable, {
46+
propsData: {
47+
fields: [...testFields, { key: 'd', label: 'D', sortable: true, sortKey: 'non-local' }],
48+
items: testItems,
49+
noLocalSorting: true
50+
}
51+
})
52+
53+
expect(wrapper).toBeDefined()
54+
55+
await wrapper
56+
.findAll('thead > tr > th')
57+
.at(3)
58+
.trigger('keydown.enter')
59+
expect(wrapper.emitted('sort-changed').length).toBe(1)
60+
expect(wrapper.emitted('sort-changed')[0][0].sortBy).toEqual('non-local')
61+
})
62+
4463
it('should sort column descending when sortBy set and sortDesc changed, with proper attributes', async () => {
4564
const wrapper = mount(BTable, {
4665
propsData: {

yarn.lock

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4396,17 +4396,6 @@ cosmiconfig@^5.0.0:
43964396
js-yaml "^3.13.1"
43974397
parse-json "^4.0.0"
43984398

4399-
cosmiconfig@^6.0.0:
4400-
version "6.0.0"
4401-
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-6.0.0.tgz#da4fee853c52f6b1e6935f41c1a2fc50bd4a9982"
4402-
integrity sha512-xb3ZL6+L8b9JLLCx3ZdoZy4+2ECphCMo2PwqgP1tlfVq6M6YReyzBJtvWWtbDSpNr9hn96pkCiZqUcFEc+54Qg==
4403-
dependencies:
4404-
"@types/parse-json" "^4.0.0"
4405-
import-fresh "^3.1.0"
4406-
parse-json "^5.0.0"
4407-
path-type "^4.0.0"
4408-
yaml "^1.7.2"
4409-
44104399
cosmiconfig@^7.0.0:
44114400
version "7.0.0"
44124401
resolved "https://registry.yarnpkg.com/cosmiconfig/-/cosmiconfig-7.0.0.tgz#ef9b44d773959cae63ddecd122de23853b60f8d3"
@@ -7162,15 +7151,15 @@ humps@^2.0.1:
71627151
resolved "https://registry.yarnpkg.com/humps/-/humps-2.0.1.tgz#dd02ea6081bd0568dc5d073184463957ba9ef9aa"
71637152
integrity sha1-3QLqYIG9BWjcXQcxhEY5V7qe+ao=
71647153

7165-
husky@^4.2.5:
7166-
version "4.2.5"
7167-
resolved "https://registry.yarnpkg.com/husky/-/husky-4.2.5.tgz#2b4f7622673a71579f901d9885ed448394b5fa36"
7168-
integrity sha512-SYZ95AjKcX7goYVZtVZF2i6XiZcHknw50iXvY7b0MiGoj5RwdgRQNEHdb+gPDPCXKlzwrybjFjkL6FOj8uRhZQ==
7154+
husky@^4.3.0:
7155+
version "4.3.0"
7156+
resolved "https://registry.yarnpkg.com/husky/-/husky-4.3.0.tgz#0b2ec1d66424e9219d359e26a51c58ec5278f0de"
7157+
integrity sha512-tTMeLCLqSBqnflBZnlVDhpaIMucSGaYyX6855jM4AguGeWCeSzNdb1mfyWduTZ3pe3SJVvVWGL0jO1iKZVPfTA==
71697158
dependencies:
71707159
chalk "^4.0.0"
71717160
ci-info "^2.0.0"
71727161
compare-versions "^3.6.0"
7173-
cosmiconfig "^6.0.0"
7162+
cosmiconfig "^7.0.0"
71747163
find-versions "^3.2.0"
71757164
opencollective-postinstall "^2.0.2"
71767165
pkg-dir "^4.2.0"
@@ -7239,7 +7228,7 @@ import-fresh@^2.0.0:
72397228
caller-path "^2.0.0"
72407229
resolve-from "^3.0.0"
72417230

7242-
import-fresh@^3.0.0, import-fresh@^3.1.0, import-fresh@^3.2.1:
7231+
import-fresh@^3.0.0, import-fresh@^3.2.1:
72437232
version "3.2.1"
72447233
resolved "https://registry.yarnpkg.com/import-fresh/-/import-fresh-3.2.1.tgz#633ff618506e793af5ac91bf48b72677e15cbe66"
72457234
integrity sha512-6e1q1cnWP2RXD9/keSkxHScg508CdXqXWgWBaETNhyuBFz+kUZlKboh+ISK+bU++DmbHimVBrOz/zzPe0sZ3sQ==
@@ -12099,10 +12088,10 @@ rollup-pluginutils@^2.8.1:
1209912088
dependencies:
1210012089
estree-walker "^0.6.1"
1210112090

12102-
rollup@^2.26.10:
12103-
version "2.26.10"
12104-
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.26.10.tgz#0ffe0390d35f07af850382f22f1b8525c7f57f07"
12105-
integrity sha512-dUnjCWOA0h9qNX6qtcHidyatz8FAFZxVxt1dbcGtKdlJkpSxGK3G9+DLCYvtZr9v94D129ij9zUhG+xbRoqepw==
12091+
rollup@^2.26.11:
12092+
version "2.26.11"
12093+
resolved "https://registry.yarnpkg.com/rollup/-/rollup-2.26.11.tgz#4fc31de9c7b83d50916fc8395f8c3d24730cdaae"
12094+
integrity sha512-xyfxxhsE6hW57xhfL1I+ixH8l2bdoIMaAecdQiWF3N7IgJEMu99JG+daBiSZQjnBpzFxa0/xZm+3pbCdAQehHw==
1210612095
optionalDependencies:
1210712096
fsevents "~2.1.2"
1210812097

@@ -14610,7 +14599,7 @@ yallist@^4.0.0:
1461014599
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
1461114600
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
1461214601

14613-
yaml@^1.10.0, yaml@^1.7.2:
14602+
yaml@^1.10.0:
1461414603
version "1.10.0"
1461514604
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e"
1461614605
integrity sha512-yr2icI4glYaNG+KWONODapy2/jDdMSDnrONSjblABjD9B4Z5LgiircSt8m8sRZFNi08kG9Sm0uSHtEmP3zaEGg==

0 commit comments

Comments
 (0)