Skip to content
This repository has been archived by the owner on Dec 30, 2022. It is now read-only.

Commit

Permalink
feat(props): remove defaults (#1016)
Browse files Browse the repository at this point in the history
* feat(props): remove defaults

for facetOrdering, we need to let InstantSearch.js decide the real default value of props. At the same time I removed all other defaults to avoid differences

* redo defaults that change tests
  • Loading branch information
Haroenv authored Jul 12, 2021
1 parent 3a5b6bf commit 1029500
Show file tree
Hide file tree
Showing 20 changed files with 62 additions and 81 deletions.
8 changes: 3 additions & 5 deletions src/components/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -69,17 +69,15 @@ export default {
},
separator: {
type: String,
default: ' > ',
default: undefined,
},
rootPath: {
type: String,
default: null,
default: undefined,
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
10 changes: 3 additions & 7 deletions src/components/ClearRefinements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,17 @@ export default {
createSuitMixin({ name: 'ClearRefinements' }),
],
props: {
// explicitly no default, since included and excluded are incompatible
// eslint-disable-next-line vue/require-default-prop
excludedAttributes: {
type: Array,
default: undefined,
},
// explicitly no default, since included and excluded are incompatible
// eslint-disable-next-line vue/require-default-prop
includedAttributes: {
type: Array,
default: undefined,
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
10 changes: 3 additions & 7 deletions src/components/CurrentRefinements.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,17 @@ export default {
}),
],
props: {
// no default because included and excluded are incompatible
// eslint-disable-next-line vue/require-default-prop
includedAttributes: {
type: Array,
default: undefined,
},
// no default because included and excluded are incompatible
// eslint-disable-next-line vue/require-default-prop
excludedAttributes: {
type: Array,
default: undefined,
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
18 changes: 7 additions & 11 deletions src/components/HierarchicalMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,35 @@ export default {
},
limit: {
type: Number,
default: 10,
default: undefined,
},
showMoreLimit: {
type: Number,
default: 20,
default: undefined,
},
showMore: {
type: Boolean,
default: false,
},
sortBy: {
type: [Array, Function],
default() {
return ['name:asc'];
},
default: undefined,
},
separator: {
type: String,
default: ' > ',
default: undefined,
},
rootPath: {
type: String,
default: null,
default: undefined,
},
showParentLevel: {
type: Boolean,
default: true,
default: undefined,
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
20 changes: 16 additions & 4 deletions src/components/Highlighter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,22 @@ export default {
type: String,
default: 'mark',
},
suit: { type: Function, required: true },
highlightProperty: { type: String, required: true },
preTag: { type: String, required: true },
postTag: { type: String, required: true },
suit: {
type: Function,
required: true,
},
highlightProperty: {
type: String,
required: true,
},
preTag: {
type: String,
required: true,
},
postTag: {
type: String,
required: true,
},
},
data() {
return {
Expand Down
4 changes: 1 addition & 3 deletions src/components/Hits.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ export default {
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
5 changes: 1 addition & 4 deletions src/components/HitsPerPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,10 @@ export default {
items: {
type: Array,
required: true,
default: () => [],
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
data() {
Expand Down
4 changes: 1 addition & 3 deletions src/components/InfiniteHits.vue
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,7 @@ export default {
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
cache: {
type: Object,
Expand Down
14 changes: 7 additions & 7 deletions src/components/InstantSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ export default createInstantSearchComponent({
},
insightsClient: {
type: Function,
required: false,
default: undefined,
},
indexName: {
type: String,
required: true,
},
routing: {
default: null,
default: undefined,
validator(value) {
if (
typeof value === 'boolean' ||
Expand All @@ -39,19 +39,19 @@ export default createInstantSearchComponent({
},
stalledSearchDelay: {
type: Number,
default: 200,
default: undefined,
},
searchFunction: {
type: Function,
default: null,
default: undefined,
},
initialUiState: {
type: Object,
required: false,
default: undefined,
},
apiKey: {
type: String,
default: null,
default: undefined,
validator(value) {
if (value) {
warn(oldApiWarning);
Expand All @@ -61,7 +61,7 @@ export default createInstantSearchComponent({
},
appId: {
type: String,
default: null,
default: undefined,
validator(value) {
if (value) {
warn(oldApiWarning);
Expand Down
12 changes: 4 additions & 8 deletions src/components/Menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,27 +72,23 @@ export default {
// },
limit: {
type: Number,
default: 10,
default: undefined,
},
showMoreLimit: {
type: Number,
default: 20,
default: undefined,
},
showMore: {
type: Boolean,
default: false,
},
sortBy: {
type: [Array, Function],
default() {
return ['count:desc', 'name:asc'];
},
default: undefined,
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
4 changes: 1 addition & 3 deletions src/components/MenuSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ export default {
},
sortBy: {
type: [Array, Function],
default() {
return ['name:asc'];
},
default: undefined,
},
transformItems: {
type: Function,
Expand Down
4 changes: 1 addition & 3 deletions src/components/NumericMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,7 @@ export default {
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/Pagination.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export default {
props: {
padding: {
type: Number,
default: 3,
default: undefined,
validator(value) {
return value > 0;
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/QueryRuleContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default {
transformRuleContexts: {
type: Function,
required: false,
default: ruleContexts => ruleContexts,
default: undefined,
},
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/QueryRuleCustomData.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default {
transformItems: {
type: Function,
required: false,
default: items => items,
default: undefined,
},
},
computed: {
Expand Down
2 changes: 2 additions & 0 deletions src/components/RangeInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,13 @@ export default {
min: {
type: Number,
required: false,
// @major: remove this default
default: -Infinity,
},
max: {
type: Number,
required: false,
// @major: remove this default
default: Infinity,
},
precision: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/RatingMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export default {
},
max: {
type: Number,
default: 5,
default: undefined,
},
},
computed: {
Expand Down
14 changes: 7 additions & 7 deletions src/components/RefinementList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ export default {
},
searchable: {
type: Boolean,
default: false,
default: undefined,
},
searchablePlaceholder: {
default: 'Search here…',
type: String,
required: false,
default: 'Search here…',
},
operator: {
default: 'or',
Expand All @@ -138,28 +138,28 @@ export default {
},
limit: {
type: Number,
default: 10,
required: false,
default: undefined,
},
showMoreLimit: {
type: Number,
default: 20,
required: false,
default: undefined,
},
showMore: {
type: Boolean,
default: false,
required: false,
default: false,
},
sortBy: {
type: [Array, Function],
default: () => ['isRefined', 'count:desc', 'name:asc'],
required: false,
default: undefined,
},
transformItems: {
type: Function,
default: items => items,
required: false,
default: undefined,
},
},
data() {
Expand Down
4 changes: 1 addition & 3 deletions src/components/SortBy.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ export default {
},
transformItems: {
type: Function,
default(items) {
return items;
},
default: undefined,
},
},
computed: {
Expand Down
Loading

0 comments on commit 1029500

Please sign in to comment.