From 102950021792b1dda4a5109717861e409a9060ec Mon Sep 17 00:00:00 2001 From: Haroen Viaene Date: Mon, 12 Jul 2021 17:28:12 +0200 Subject: [PATCH] feat(props): remove defaults (#1016) * 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 --- src/components/Breadcrumb.vue | 8 +++----- src/components/ClearRefinements.vue | 10 +++------- src/components/CurrentRefinements.vue | 10 +++------- src/components/HierarchicalMenu.vue | 18 +++++++----------- src/components/Highlighter.vue | 20 ++++++++++++++++---- src/components/Hits.vue | 4 +--- src/components/HitsPerPage.vue | 5 +---- src/components/InfiniteHits.vue | 4 +--- src/components/InstantSearch.js | 14 +++++++------- src/components/Menu.vue | 12 ++++-------- src/components/MenuSelect.vue | 4 +--- src/components/NumericMenu.vue | 4 +--- src/components/Pagination.vue | 2 +- src/components/QueryRuleContext.js | 2 +- src/components/QueryRuleCustomData.vue | 2 +- src/components/RangeInput.vue | 2 ++ src/components/RatingMenu.vue | 2 +- src/components/RefinementList.vue | 14 +++++++------- src/components/SortBy.vue | 4 +--- src/components/ToggleRefinement.vue | 2 -- 20 files changed, 62 insertions(+), 81 deletions(-) diff --git a/src/components/Breadcrumb.vue b/src/components/Breadcrumb.vue index 85a3520a3..744741d23 100644 --- a/src/components/Breadcrumb.vue +++ b/src/components/Breadcrumb.vue @@ -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: { diff --git a/src/components/ClearRefinements.vue b/src/components/ClearRefinements.vue index 1704a6fc4..0eb5aacc4 100644 --- a/src/components/ClearRefinements.vue +++ b/src/components/ClearRefinements.vue @@ -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: { diff --git a/src/components/CurrentRefinements.vue b/src/components/CurrentRefinements.vue index b2b27963a..24f5a8672 100644 --- a/src/components/CurrentRefinements.vue +++ b/src/components/CurrentRefinements.vue @@ -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: { diff --git a/src/components/HierarchicalMenu.vue b/src/components/HierarchicalMenu.vue index f3728999a..f06260d35 100644 --- a/src/components/HierarchicalMenu.vue +++ b/src/components/HierarchicalMenu.vue @@ -68,11 +68,11 @@ export default { }, limit: { type: Number, - default: 10, + default: undefined, }, showMoreLimit: { type: Number, - default: 20, + default: undefined, }, showMore: { type: Boolean, @@ -80,27 +80,23 @@ export default { }, 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: { diff --git a/src/components/Highlighter.vue b/src/components/Highlighter.vue index bee0e498e..c7e05a4f1 100644 --- a/src/components/Highlighter.vue +++ b/src/components/Highlighter.vue @@ -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 { diff --git a/src/components/Hits.vue b/src/components/Hits.vue index ba74e14db..296ad86ca 100644 --- a/src/components/Hits.vue +++ b/src/components/Hits.vue @@ -44,9 +44,7 @@ export default { }, transformItems: { type: Function, - default(items) { - return items; - }, + default: undefined, }, }, computed: { diff --git a/src/components/HitsPerPage.vue b/src/components/HitsPerPage.vue index a2595fa1b..bc5d184d7 100644 --- a/src/components/HitsPerPage.vue +++ b/src/components/HitsPerPage.vue @@ -43,13 +43,10 @@ export default { items: { type: Array, required: true, - default: () => [], }, transformItems: { type: Function, - default(items) { - return items; - }, + default: undefined, }, }, data() { diff --git a/src/components/InfiniteHits.vue b/src/components/InfiniteHits.vue index 864ee7f23..81888ed00 100644 --- a/src/components/InfiniteHits.vue +++ b/src/components/InfiniteHits.vue @@ -82,9 +82,7 @@ export default { }, transformItems: { type: Function, - default(items) { - return items; - }, + default: undefined, }, cache: { type: Object, diff --git a/src/components/InstantSearch.js b/src/components/InstantSearch.js index 928f27989..f655cd105 100644 --- a/src/components/InstantSearch.js +++ b/src/components/InstantSearch.js @@ -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' || @@ -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); @@ -61,7 +61,7 @@ export default createInstantSearchComponent({ }, appId: { type: String, - default: null, + default: undefined, validator(value) { if (value) { warn(oldApiWarning); diff --git a/src/components/Menu.vue b/src/components/Menu.vue index 9af476134..2b0288d67 100644 --- a/src/components/Menu.vue +++ b/src/components/Menu.vue @@ -72,11 +72,11 @@ export default { // }, limit: { type: Number, - default: 10, + default: undefined, }, showMoreLimit: { type: Number, - default: 20, + default: undefined, }, showMore: { type: Boolean, @@ -84,15 +84,11 @@ export default { }, sortBy: { type: [Array, Function], - default() { - return ['count:desc', 'name:asc']; - }, + default: undefined, }, transformItems: { type: Function, - default(items) { - return items; - }, + default: undefined, }, }, computed: { diff --git a/src/components/MenuSelect.vue b/src/components/MenuSelect.vue index f8ae88439..6cc9acd20 100644 --- a/src/components/MenuSelect.vue +++ b/src/components/MenuSelect.vue @@ -63,9 +63,7 @@ export default { }, sortBy: { type: [Array, Function], - default() { - return ['name:asc']; - }, + default: undefined, }, transformItems: { type: Function, diff --git a/src/components/NumericMenu.vue b/src/components/NumericMenu.vue index afbb13f73..c5a71abab 100644 --- a/src/components/NumericMenu.vue +++ b/src/components/NumericMenu.vue @@ -59,9 +59,7 @@ export default { }, transformItems: { type: Function, - default(items) { - return items; - }, + default: undefined, }, }, computed: { diff --git a/src/components/Pagination.vue b/src/components/Pagination.vue index c744e9afd..1dcfbaecf 100644 --- a/src/components/Pagination.vue +++ b/src/components/Pagination.vue @@ -182,7 +182,7 @@ export default { props: { padding: { type: Number, - default: 3, + default: undefined, validator(value) { return value > 0; }, diff --git a/src/components/QueryRuleContext.js b/src/components/QueryRuleContext.js index 8f650154d..f93e96413 100644 --- a/src/components/QueryRuleContext.js +++ b/src/components/QueryRuleContext.js @@ -18,7 +18,7 @@ export default { transformRuleContexts: { type: Function, required: false, - default: ruleContexts => ruleContexts, + default: undefined, }, }, computed: { diff --git a/src/components/QueryRuleCustomData.vue b/src/components/QueryRuleCustomData.vue index 6e23856aa..5689e0059 100644 --- a/src/components/QueryRuleCustomData.vue +++ b/src/components/QueryRuleCustomData.vue @@ -36,7 +36,7 @@ export default { transformItems: { type: Function, required: false, - default: items => items, + default: undefined, }, }, computed: { diff --git a/src/components/RangeInput.vue b/src/components/RangeInput.vue index fb209f06f..c4facb66d 100644 --- a/src/components/RangeInput.vue +++ b/src/components/RangeInput.vue @@ -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: { diff --git a/src/components/RatingMenu.vue b/src/components/RatingMenu.vue index 309be50de..06376bc14 100644 --- a/src/components/RatingMenu.vue +++ b/src/components/RatingMenu.vue @@ -99,7 +99,7 @@ export default { }, max: { type: Number, - default: 5, + default: undefined, }, }, computed: { diff --git a/src/components/RefinementList.vue b/src/components/RefinementList.vue index a88c4554f..c40d43ab0 100644 --- a/src/components/RefinementList.vue +++ b/src/components/RefinementList.vue @@ -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', @@ -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() { diff --git a/src/components/SortBy.vue b/src/components/SortBy.vue index b61113e0c..83e76b583 100644 --- a/src/components/SortBy.vue +++ b/src/components/SortBy.vue @@ -48,9 +48,7 @@ export default { }, transformItems: { type: Function, - default(items) { - return items; - }, + default: undefined, }, }, computed: { diff --git a/src/components/ToggleRefinement.vue b/src/components/ToggleRefinement.vue index 2f82f54f4..b9f95a4e6 100644 --- a/src/components/ToggleRefinement.vue +++ b/src/components/ToggleRefinement.vue @@ -63,8 +63,6 @@ export default { off: { type: [String, Number, Boolean, Array], required: false, - // explicit otherwise Vue coerces the default value - // to false because of the `Boolean` prop type default: undefined, }, },