mirror of
https://github.com/Choices-js/Choices.git
synced 2024-05-23 16:02:21 +02:00
Rename sortFields to searchFields for clarity
This commit is contained in:
parent
7ec1e5310c
commit
99a1eb5e3a
19
README.md
19
README.md
|
@ -69,12 +69,12 @@ Or include Choices directly:
|
||||||
search: true,
|
search: true,
|
||||||
searchChoices: true,
|
searchChoices: true,
|
||||||
searchFloor: 1,
|
searchFloor: 1,
|
||||||
|
searchFields: ['label', 'value'],
|
||||||
position: 'auto',
|
position: 'auto',
|
||||||
resetScrollPosition: true,
|
resetScrollPosition: true,
|
||||||
regexFilter: null,
|
regexFilter: null,
|
||||||
shouldSort: true,
|
shouldSort: true,
|
||||||
sortFilter: () => {...},
|
sortFilter: () => {...},
|
||||||
sortFields: ['label', 'value'],
|
|
||||||
placeholder: true,
|
placeholder: true,
|
||||||
placeholderValue: null,
|
placeholderValue: null,
|
||||||
prependValue: null,
|
prependValue: null,
|
||||||
|
@ -251,7 +251,15 @@ Pass an array of objects:
|
||||||
|
|
||||||
**Input types affected:** `select-one`
|
**Input types affected:** `select-one`
|
||||||
|
|
||||||
**Usage:** Whether the plugin should filter the choices by input or not. If `false` the search event will be emited.
|
**Usage:** Whether the plugin should filter the choices by input or not. If `false`, the search event will still emit.
|
||||||
|
|
||||||
|
|
||||||
|
### searchFields
|
||||||
|
**Type:** `Array/String` **Default:** `['label', 'value']`
|
||||||
|
|
||||||
|
**Input types affected:**`select-one`, `select-multiple`
|
||||||
|
|
||||||
|
**Usage:** Specify which fields should be used when a user is searching.
|
||||||
|
|
||||||
### searchFloor
|
### searchFloor
|
||||||
**Type:** `Number` **Default:** `1`
|
**Type:** `Number` **Default:** `1`
|
||||||
|
@ -306,13 +314,6 @@ const example = new Choices(element, {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
### sortFields
|
|
||||||
**Type:** `Array/String` **Default:** `['label', 'value']`
|
|
||||||
|
|
||||||
**Input types affected:**`select-one`, `select-multiple`
|
|
||||||
|
|
||||||
**Usage:** Specify which fields should be used for sorting when a user is searching. If a user is not searching and sorting is enabled, only the choice's label will be sorted.
|
|
||||||
|
|
||||||
### placeholder
|
### placeholder
|
||||||
**Type:** `Boolean` **Default:** `true`
|
**Type:** `Boolean` **Default:** `true`
|
||||||
|
|
||||||
|
|
4
assets/scripts/dist/choices.js
vendored
4
assets/scripts/dist/choices.js
vendored
|
@ -131,7 +131,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
regexFilter: null,
|
regexFilter: null,
|
||||||
shouldSort: true,
|
shouldSort: true,
|
||||||
sortFilter: _utils.sortByAlpha,
|
sortFilter: _utils.sortByAlpha,
|
||||||
sortFields: ['label', 'value'],
|
searchFields: ['label', 'value'],
|
||||||
placeholder: true,
|
placeholder: true,
|
||||||
placeholderValue: null,
|
placeholderValue: null,
|
||||||
prependValue: null,
|
prependValue: null,
|
||||||
|
@ -1409,7 +1409,7 @@ return /******/ (function(modules) { // webpackBootstrap
|
||||||
if (newValue.length >= 1 && newValue !== currentValue + ' ') {
|
if (newValue.length >= 1 && newValue !== currentValue + ' ') {
|
||||||
var haystack = this.store.getChoicesFilteredBySelectable();
|
var haystack = this.store.getChoicesFilteredBySelectable();
|
||||||
var needle = newValue;
|
var needle = newValue;
|
||||||
var keys = (0, _utils.isType)('Array', this.config.sortFields) ? this.config.sortFields : [this.config.sortFields];
|
var keys = (0, _utils.isType)('Array', this.config.searchFields) ? this.config.searchFields : [this.config.searchFields];
|
||||||
var options = Object.assign(this.config.fuseOptions, { keys: keys });
|
var options = Object.assign(this.config.fuseOptions, { keys: keys });
|
||||||
var fuse = new _fuse2.default(haystack, options);
|
var fuse = new _fuse2.default(haystack, options);
|
||||||
var results = fuse.search(needle);
|
var results = fuse.search(needle);
|
||||||
|
|
2
assets/scripts/dist/choices.js.map
vendored
2
assets/scripts/dist/choices.js.map
vendored
File diff suppressed because one or more lines are too long
2
assets/scripts/dist/choices.min.js
vendored
2
assets/scripts/dist/choices.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -62,12 +62,12 @@ class Choices {
|
||||||
search: true,
|
search: true,
|
||||||
searchChoices: true,
|
searchChoices: true,
|
||||||
searchFloor: 1,
|
searchFloor: 1,
|
||||||
|
searchFields: ['label', 'value'],
|
||||||
position: 'auto',
|
position: 'auto',
|
||||||
resetScrollPosition: true,
|
resetScrollPosition: true,
|
||||||
regexFilter: null,
|
regexFilter: null,
|
||||||
shouldSort: true,
|
shouldSort: true,
|
||||||
sortFilter: sortByAlpha,
|
sortFilter: sortByAlpha,
|
||||||
sortFields: ['label', 'value'],
|
|
||||||
placeholder: true,
|
placeholder: true,
|
||||||
placeholderValue: null,
|
placeholderValue: null,
|
||||||
prependValue: null,
|
prependValue: null,
|
||||||
|
@ -1199,7 +1199,7 @@ class Choices {
|
||||||
if (newValue.length >= 1 && newValue !== `${currentValue} `) {
|
if (newValue.length >= 1 && newValue !== `${currentValue} `) {
|
||||||
const haystack = this.store.getChoicesFilteredBySelectable();
|
const haystack = this.store.getChoicesFilteredBySelectable();
|
||||||
const needle = newValue;
|
const needle = newValue;
|
||||||
const keys = isType('Array', this.config.sortFields) ? this.config.sortFields : [this.config.sortFields];
|
const keys = isType('Array', this.config.searchFields) ? this.config.searchFields : [this.config.searchFields];
|
||||||
const options = Object.assign(this.config.fuseOptions, { keys });
|
const options = Object.assign(this.config.fuseOptions, { keys });
|
||||||
const fuse = new Fuse(haystack, options);
|
const fuse = new Fuse(haystack, options);
|
||||||
const results = fuse.search(needle);
|
const results = fuse.search(needle);
|
||||||
|
|
|
@ -76,10 +76,10 @@ describe('Choices', () => {
|
||||||
expect(this.choices.config.paste).toEqual(jasmine.any(Boolean));
|
expect(this.choices.config.paste).toEqual(jasmine.any(Boolean));
|
||||||
expect(this.choices.config.search).toEqual(jasmine.any(Boolean));
|
expect(this.choices.config.search).toEqual(jasmine.any(Boolean));
|
||||||
expect(this.choices.config.searchFloor).toEqual(jasmine.any(Number));
|
expect(this.choices.config.searchFloor).toEqual(jasmine.any(Number));
|
||||||
|
expect(this.choices.config.searchFields).toEqual(jasmine.any(Array) || jasmine.any(String));
|
||||||
expect(this.choices.config.position).toEqual(jasmine.any(String));
|
expect(this.choices.config.position).toEqual(jasmine.any(String));
|
||||||
expect(this.choices.config.regexFilter).toEqual(null);
|
expect(this.choices.config.regexFilter).toEqual(null);
|
||||||
expect(this.choices.config.sortFilter).toEqual(jasmine.any(Function));
|
expect(this.choices.config.sortFilter).toEqual(jasmine.any(Function));
|
||||||
expect(this.choices.config.sortFields).toEqual(jasmine.any(Array) || jasmine.any(String));
|
|
||||||
expect(this.choices.config.shouldSort).toEqual(jasmine.any(Boolean));
|
expect(this.choices.config.shouldSort).toEqual(jasmine.any(Boolean));
|
||||||
expect(this.choices.config.placeholder).toEqual(jasmine.any(Boolean));
|
expect(this.choices.config.placeholder).toEqual(jasmine.any(Boolean));
|
||||||
expect(this.choices.config.placeholderValue).toEqual(null);
|
expect(this.choices.config.placeholderValue).toEqual(null);
|
||||||
|
|
Loading…
Reference in a new issue