@appbaseio/reactivesearch-vue 2.0.0-alpha.4 → 3.0.0-alpha.1

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.
Files changed (109) hide show
  1. package/README.md +9 -9
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js +21316 -29369
  3. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +5 -19
  5. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  6. package/dist/cjs/Button-ad042719.js +59 -0
  7. package/dist/cjs/Card-f5ab024a.js +27 -0
  8. package/dist/cjs/{ComponentWrapper-ad3dad02.js → ComponentWrapper-611cf7f9.js} +44 -58
  9. package/dist/cjs/Container-29f049b2.js +12 -0
  10. package/dist/cjs/DropDown-dc184468.js +700 -0
  11. package/dist/cjs/DynamicRangeSlider.js +106 -157
  12. package/dist/cjs/Flex-d5675ea6.js +48 -0
  13. package/dist/cjs/FormControlList-fadd792f.js +42 -0
  14. package/dist/cjs/Input-088dfcb4.js +74 -0
  15. package/dist/cjs/ListItem-d57d648d.js +42 -0
  16. package/dist/cjs/MultiDropdownList.js +124 -240
  17. package/dist/cjs/MultiList.js +124 -262
  18. package/dist/cjs/MultiRange.js +87 -133
  19. package/dist/cjs/{Pagination-71e85fa9.js → Pagination-b5ddc906.js} +70 -83
  20. package/dist/cjs/PreferencesConsumer-22d1b49f.js +73 -0
  21. package/dist/cjs/RangeInput.js +163 -171
  22. package/dist/cjs/RangeSlider.js +81 -109
  23. package/dist/cjs/ReactiveBase.js +139 -156
  24. package/dist/cjs/ReactiveComponent-a6108189.js +2184 -0
  25. package/dist/cjs/ReactiveComponent.js +46 -340
  26. package/dist/cjs/ReactiveGoogleMap.js +451 -660
  27. package/dist/cjs/ReactiveList.js +180 -305
  28. package/dist/cjs/ResultCard.js +36 -36
  29. package/dist/cjs/ResultList.js +48 -56
  30. package/dist/cjs/SelectedFilters.js +62 -69
  31. package/dist/cjs/SingleDropdownList.js +117 -177
  32. package/dist/cjs/SingleList.js +122 -206
  33. package/dist/cjs/SingleRange.js +78 -105
  34. package/dist/cjs/StateProvider.js +35 -38
  35. package/dist/cjs/Title-8802a218.js +12 -0
  36. package/dist/cjs/ToggleButton.js +72 -119
  37. package/dist/cjs/{_rollupPluginBabelHelpers-c705cbe6.js → _rollupPluginBabelHelpers-f8b843f8.js} +0 -15
  38. package/dist/cjs/{index-6a167fe0.js → index-d8d8f291.js} +38 -108
  39. package/dist/cjs/index.js +44 -41
  40. package/dist/cjs/initReactivesearch.js +63 -150
  41. package/dist/cjs/install.js +47 -43
  42. package/dist/cjs/ssr-6c8a72e1.js +66 -0
  43. package/dist/cjs/{utils-d6a52588.js → utils-83fd01e9.js} +7 -16
  44. package/dist/cjs/version.js +1 -1
  45. package/dist/cjs/{vueTypes-727b7c63.js → vueTypes-1bf00978.js} +8 -19
  46. package/dist/es/Button-474510e3.js +53 -0
  47. package/dist/es/{Card-450683f1.js → Card-38cbe652.js} +3 -3
  48. package/dist/es/{ComponentWrapper-424e86fd.js → ComponentWrapper-3dfe6931.js} +44 -58
  49. package/dist/es/{Container-ba826e96.js → Container-d00219f7.js} +2 -2
  50. package/dist/es/DropDown-029ffd42.js +690 -0
  51. package/dist/es/DynamicRangeSlider.js +106 -157
  52. package/dist/es/Flex-a08e22d7.js +46 -0
  53. package/dist/es/FormControlList-fe6eaee4.js +38 -0
  54. package/dist/es/Input-ad474a55.js +69 -0
  55. package/dist/es/{ListItem-cad14c5e.js → ListItem-16756c02.js} +7 -8
  56. package/dist/es/MultiDropdownList.js +124 -240
  57. package/dist/es/MultiList.js +124 -262
  58. package/dist/es/MultiRange.js +87 -133
  59. package/dist/es/{Pagination-784bf143.js → Pagination-72bd1d9e.js} +70 -83
  60. package/dist/es/PreferencesConsumer-24e88f3b.js +71 -0
  61. package/dist/es/RangeInput.js +163 -170
  62. package/dist/es/RangeSlider.js +81 -109
  63. package/dist/es/ReactiveBase.js +138 -154
  64. package/dist/es/ReactiveComponent-0a97eb1e.js +2178 -0
  65. package/dist/es/ReactiveComponent.js +42 -337
  66. package/dist/es/ReactiveGoogleMap.js +446 -654
  67. package/dist/es/ReactiveList.js +178 -302
  68. package/dist/es/ResultCard.js +36 -36
  69. package/dist/es/ResultList.js +48 -56
  70. package/dist/es/SelectedFilters.js +62 -69
  71. package/dist/es/SingleDropdownList.js +117 -177
  72. package/dist/es/SingleList.js +122 -206
  73. package/dist/es/SingleRange.js +78 -105
  74. package/dist/es/StateProvider.js +36 -39
  75. package/dist/es/{Title-3342664a.js → Title-863dfa42.js} +2 -2
  76. package/dist/es/ToggleButton.js +72 -119
  77. package/dist/es/{_rollupPluginBabelHelpers-76660dab.js → _rollupPluginBabelHelpers-ded08042.js} +0 -15
  78. package/dist/es/{index-7788a843.js → index-4520a598.js} +39 -107
  79. package/dist/es/index.js +30 -32
  80. package/dist/es/initReactivesearch.js +63 -150
  81. package/dist/es/install.js +49 -41
  82. package/dist/es/{ssr-b2c0b401.js → ssr-584c278d.js} +37 -8
  83. package/dist/es/{utils-9e68acee.js → utils-9e5a16a1.js} +7 -16
  84. package/dist/es/version.js +1 -1
  85. package/dist/es/{vueTypes-b8146772.js → vueTypes-f1923c72.js} +8 -19
  86. package/package.json +10 -9
  87. package/dist/cjs/Button-446f819e.js +0 -68
  88. package/dist/cjs/CancelSvg-9f258f4f.js +0 -449
  89. package/dist/cjs/Card-642547a8.js +0 -30
  90. package/dist/cjs/Container-daf30918.js +0 -15
  91. package/dist/cjs/DataSearch-aa04dc6e.js +0 -2352
  92. package/dist/cjs/DataSearch.js +0 -30
  93. package/dist/cjs/DropDown-c479bbb0.js +0 -328
  94. package/dist/cjs/Flex-aa517a13.js +0 -52
  95. package/dist/cjs/FormControlList-c195a592.js +0 -47
  96. package/dist/cjs/Input-e6603a7e.js +0 -79
  97. package/dist/cjs/ListItem-8c9e0d68.js +0 -46
  98. package/dist/cjs/Title-1de7d0f4.js +0 -15
  99. package/dist/cjs/install-b97dbac4.js +0 -1409
  100. package/dist/cjs/ssr-3027b848.js +0 -39
  101. package/dist/es/Button-d8bc15ea.js +0 -59
  102. package/dist/es/CancelSvg-4cfae5fd.js +0 -440
  103. package/dist/es/DataSearch-b86a6675.js +0 -2337
  104. package/dist/es/DataSearch.js +0 -22
  105. package/dist/es/DropDown-05a644a5.js +0 -322
  106. package/dist/es/Flex-1f0795c3.js +0 -47
  107. package/dist/es/FormControlList-c22d64f6.js +0 -40
  108. package/dist/es/Input-7a2a9fac.js +0 -71
  109. package/dist/es/install-ac8a1edb.js +0 -1402
@@ -1,26 +1,31 @@
1
1
  import { Actions, helper } from '@appbaseio/reactivecore';
2
- import { a as _extends, b as _objectWithoutPropertiesLoose, c as _toPropertyKey } from './_rollupPluginBabelHelpers-76660dab.js';
3
- import VueTypes from 'vue-types';
4
2
  import { componentTypes } from '@appbaseio/reactivecore/lib/utils/constants';
5
- import 'emotion';
3
+ import _transformOn from '@vue/babel-helper-vue-transform-on';
4
+ import { a as _extends, b as _objectWithoutPropertiesLoose, c as _toPropertyKey } from './_rollupPluginBabelHelpers-ded08042.js';
5
+ import { createVNode, mergeProps, isVNode } from 'vue';
6
+ import VueTypes from 'vue-types';
6
7
  import '@appbaseio/vue-emotion';
7
8
  import 'polished';
8
- import { t as types } from './vueTypes-b8146772.js';
9
+ import { t as types } from './vueTypes-f1923c72.js';
9
10
  import '@appbaseio/reactivecore/lib/utils/transform';
10
11
  import 'redux';
11
- import { q as parseValueArray, f as updateCustomQuery, i as isQueryIdentical, c as connect } from './index-7788a843.js';
12
- import { C as ComponentWrapper } from './ComponentWrapper-424e86fd.js';
13
- import { T as Title } from './Title-3342664a.js';
14
- import { C as Container } from './Container-ba826e96.js';
15
- import { U as UL, C as Checkbox } from './FormControlList-c22d64f6.js';
16
-
12
+ import { n as parseValueArray, j as updateCustomQuery, i as isQueryIdentical, c as connect } from './index-4520a598.js';
13
+ import { C as ComponentWrapper } from './ComponentWrapper-3dfe6931.js';
14
+ import { P as PreferencesConsumer } from './PreferencesConsumer-24e88f3b.js';
15
+ import { T as Title } from './Title-863dfa42.js';
16
+ import { C as Container } from './Container-d00219f7.js';
17
+ import { U as UL, C as Checkbox } from './FormControlList-fe6eaee4.js';
18
+
19
+ function _isSlot(s) {
20
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
21
+ }
17
22
  var updateQuery = Actions.updateQuery,
18
- setQueryOptions = Actions.setQueryOptions,
19
- setCustomQuery = Actions.setCustomQuery;
23
+ setQueryOptions = Actions.setQueryOptions,
24
+ setCustomQuery = Actions.setCustomQuery;
20
25
  var isEqual = helper.isEqual,
21
- checkValueChange = helper.checkValueChange,
22
- getClassName = helper.getClassName,
23
- getOptionsFromQuery = helper.getOptionsFromQuery;
26
+ checkValueChange = helper.checkValueChange,
27
+ getClassName = helper.getClassName,
28
+ getOptionsFromQuery = helper.getOptionsFromQuery;
24
29
  var MultiRange = {
25
30
  name: 'MultiRange',
26
31
  data: function data() {
@@ -55,7 +60,6 @@ var MultiRange = {
55
60
  methods: {
56
61
  handleClick: function handleClick(e) {
57
62
  var value = this.$props.value;
58
-
59
63
  if (value === undefined) {
60
64
  this.selectItem(e.target.value);
61
65
  } else {
@@ -65,22 +69,17 @@ var MultiRange = {
65
69
  },
66
70
  selectItem: function selectItem(item, isDefaultValue, props, reset) {
67
71
  var _this = this;
68
-
69
72
  if (isDefaultValue === void 0) {
70
73
  isDefaultValue = false;
71
74
  }
72
-
73
75
  if (props === void 0) {
74
76
  props = this.$props;
75
77
  }
76
-
77
78
  if (reset === void 0) {
78
79
  reset = false;
79
80
  }
80
-
81
81
  var currentValue = this.currentValue,
82
- selectedValues = this.selectedValues;
83
-
82
+ selectedValues = this.selectedValues;
84
83
  if (!item) {
85
84
  currentValue = [];
86
85
  selectedValues = {};
@@ -90,7 +89,6 @@ var MultiRange = {
90
89
  currentValue.forEach(function (value) {
91
90
  values[[value.label]] = true;
92
91
  });
93
-
94
92
  if (reset) {
95
93
  selectedValues = values;
96
94
  } else {
@@ -100,48 +98,37 @@ var MultiRange = {
100
98
  currentValue = currentValue.filter(function (value) {
101
99
  return value.label !== item;
102
100
  });
103
-
104
101
  var _selectedValues = selectedValues,
105
- del = _selectedValues[item],
106
- selected = _objectWithoutPropertiesLoose(_selectedValues, [item].map(_toPropertyKey));
107
-
102
+ del = _selectedValues[item],
103
+ selected = _objectWithoutPropertiesLoose(_selectedValues, [item].map(_toPropertyKey));
108
104
  selectedValues = selected;
109
105
  } else {
110
106
  var _extends2;
111
-
112
107
  var currentItems = props.data.filter(function (value) {
113
108
  return item.indexOf(value.label) !== -1;
114
109
  });
115
110
  currentValue = [].concat(currentValue, currentItems);
116
111
  selectedValues = _extends({}, selectedValues, (_extends2 = {}, _extends2[typeof item === 'object' ? item.label : item] = true, _extends2));
117
112
  }
118
-
119
113
  var performUpdate = function performUpdate() {
120
114
  _this.currentValue = currentValue;
121
115
  _this.selectedValues = selectedValues;
122
-
123
116
  _this.updateQueryHandler(currentValue, props);
124
-
125
117
  _this.$emit('valueChange', Object.keys(selectedValues));
126
-
127
118
  _this.$emit('value-change', Object.keys(selectedValues));
128
119
  };
129
-
130
120
  checkValueChange(props.componentId, currentValue, props.beforeValueChange, performUpdate);
131
121
  },
132
122
  updateQueryHandler: function updateQueryHandler(value, props) {
133
123
  var customQuery = props.customQuery;
134
124
  var query = MultiRange.defaultQuery(value, props);
135
-
136
125
  if (customQuery) {
137
126
  var _ref = customQuery(value, props) || {};
138
-
139
127
  query = _ref.query;
140
128
  var customQueryOptions = getOptionsFromQuery(customQuery(value, props));
141
129
  updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.currentValue);
142
130
  this.setQueryOptions(props.componentId, customQueryOptions, false);
143
131
  }
144
-
145
132
  this.updateQuery({
146
133
  componentId: props.componentId,
147
134
  query: query,
@@ -167,7 +154,13 @@ var MultiRange = {
167
154
  },
168
155
  selectedValue: function selectedValue(newVal) {
169
156
  if (!isEqual(this.$data.currentValue, newVal)) {
170
- this.selectItem(newVal, true, undefined, true);
157
+ var processSelectedValues = newVal ? newVal.map(function (item) {
158
+ if (typeof item === 'object' && 'label' in item) {
159
+ return item.label;
160
+ }
161
+ return item;
162
+ }) : null;
163
+ this.selectItem(processSelectedValues, true, undefined, true);
171
164
  }
172
165
  },
173
166
  customQuery: function customQuery(newVal, oldVal) {
@@ -177,11 +170,7 @@ var MultiRange = {
177
170
  }
178
171
  },
179
172
  created: function created() {
180
- if (!this.enableAppbase && this.$props.index) {
181
- console.warn('Warning(ReactiveSearch): In order to use the `index` prop, the `enableAppbase` prop must be set to true in `ReactiveBase`.');
182
- } // Set custom query in store
183
-
184
-
173
+ // Set custom query in store
185
174
  updateCustomQuery(this.componentId, this.setCustomQuery, this.$props, this.currentValue);
186
175
  },
187
176
  beforeMount: function beforeMount() {
@@ -194,118 +183,83 @@ var MultiRange = {
194
183
  }
195
184
  },
196
185
  render: function render() {
186
+ var _slot;
197
187
  var _this2 = this;
198
-
199
- var h = arguments[0];
200
- return h(Container, {
188
+ return createVNode(Container, {
201
189
  "class": this.$props.className
202
- }, [this.$props.title && h(Title, {
203
- "class": getClassName(this.$props.innerClass, 'title')
204
- }, [this.$props.title]), h(UL, {
205
- "class": getClassName(this.$props.innerClass, 'list')
206
- }, [this.$props.data.map(function (item) {
207
- var selected = !!_this2.$data.currentValue && _this2.$data.currentValue.label === item.label;
208
- return h("li", {
209
- "key": item.label,
210
- "class": "" + (selected ? 'active' : '')
211
- }, [h(Checkbox, {
212
- "class": getClassName(_this2.$props.innerClass, 'checkbox'),
213
- "attrs": {
214
- "id": _this2.$props.componentId + "-" + item.label,
215
- "name": _this2.$props.componentId,
216
- "value": item.label,
217
- "type": "Checkbox",
218
- "show": _this2.$props.showCheckbox
219
- },
220
- "domProps": _extends({}, {
221
- checked: _this2.selectedValues[item.label]
222
- }),
223
- "on": _extends({}, {
224
- click: _this2.handleClick
225
- })
226
- }), h("label", {
227
- "class": getClassName(_this2.$props.innerClass, 'label'),
228
- "attrs": {
229
- "for": _this2.$props.componentId + "-" + item.label
230
- }
231
- }, [item.label])]);
232
- })])]);
190
+ }, {
191
+ "default": function _default() {
192
+ return [_this2.$props.title && createVNode(Title, {
193
+ "class": getClassName(_this2.$props.innerClass, 'title')
194
+ }, {
195
+ "default": function _default() {
196
+ return [_this2.$props.title];
197
+ }
198
+ }), createVNode(UL, {
199
+ "class": getClassName(_this2.$props.innerClass, 'list')
200
+ }, _isSlot(_slot = _this2.$props.data.map(function (item) {
201
+ var selected = !!_this2.$data.currentValue && _this2.$data.currentValue.label === item.label;
202
+ return createVNode("li", {
203
+ "key": item.label,
204
+ "class": "" + (selected ? 'active' : '')
205
+ }, [createVNode(Checkbox, mergeProps(_transformOn({
206
+ click: _this2.handleClick
207
+ }), {
208
+ "class": getClassName(_this2.$props.innerClass, 'checkbox'),
209
+ "id": _this2.$props.componentId + "-" + item.label,
210
+ "name": _this2.$props.componentId,
211
+ "value": item.label,
212
+ "type": "Checkbox",
213
+ "show": _this2.$props.showCheckbox,
214
+ "checked": _this2.selectedValues[item.label]
215
+ }), null), createVNode("label", {
216
+ "class": getClassName(_this2.$props.innerClass, 'label'),
217
+ "for": _this2.$props.componentId + "-" + item.label
218
+ }, [item.label])]);
219
+ })) ? _slot : {
220
+ "default": function _default() {
221
+ return [_slot];
222
+ }
223
+ })];
224
+ }
225
+ });
233
226
  }
234
227
  };
235
-
236
228
  MultiRange.parseValue = function (value, props) {
237
229
  return value ? props.data.filter(function (item) {
238
230
  return value.includes(item.label);
239
231
  }) : null;
240
232
  };
241
-
242
- MultiRange.defaultQuery = function (values, props) {
243
- var generateRangeQuery = function generateRangeQuery(dataField, items) {
244
- if (items.length > 0) {
245
- return items.map(function (value) {
246
- var _range;
247
-
248
- return {
249
- range: (_range = {}, _range[dataField] = {
250
- gte: value.start,
251
- lte: value.end,
252
- boost: 2.0
253
- }, _range)
254
- };
255
- });
233
+ MultiRange.defaultQuery = function (value, props) {
234
+ return {
235
+ query: {
236
+ queryFormat: props.queryFormat,
237
+ dataField: props.dataField,
238
+ value: value,
239
+ showMissing: props.showMissing
256
240
  }
257
-
258
- return null;
259
241
  };
260
-
261
- var query = null;
262
-
263
- if (values && values.length) {
264
- query = {
265
- bool: {
266
- should: generateRangeQuery(props.dataField, values),
267
- minimum_should_match: 1,
268
- boost: 1.0
269
- }
270
- };
271
- }
272
-
273
- if (query && props.nestedField) {
274
- return {
275
- query: {
276
- nested: {
277
- path: props.nestedField,
278
- query: query
279
- }
280
- }
281
- };
282
- }
283
-
284
- return query;
285
242
  };
286
-
287
243
  var mapStateToProps = function mapStateToProps(state, props) {
288
244
  return {
289
245
  selectedValue: state.selectedValues[props.componentId] && state.selectedValues[props.componentId].value || null,
290
- componentProps: state.props[props.componentId],
291
- enableAppbase: state.config.enableAppbase
246
+ componentProps: state.props[props.componentId]
292
247
  };
293
248
  };
294
-
295
249
  var mapDispatchtoProps = {
296
250
  updateQuery: updateQuery,
297
251
  setQueryOptions: setQueryOptions,
298
252
  setCustomQuery: setCustomQuery
299
253
  };
300
- var RangeConnected = ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(MultiRange), {
254
+ var RangeConnected = PreferencesConsumer(ComponentWrapper(connect(mapStateToProps, mapDispatchtoProps)(MultiRange), {
301
255
  componentType: componentTypes.multiRange
302
- });
303
-
304
- MultiRange.install = function (Vue) {
305
- Vue.component(MultiRange.name, RangeConnected);
306
- }; // Add componentType for SSR
307
-
308
-
309
- MultiRange.componentType = componentTypes.multiRange;
256
+ }));
257
+ RangeConnected.name = MultiRange.name;
258
+ RangeConnected.install = function (Vue) {
259
+ Vue.component(RangeConnected.name, RangeConnected);
260
+ };
261
+ // Add componentType for SSR
262
+ RangeConnected.componentType = componentTypes.multiRange;
310
263
 
311
- export default MultiRange;
264
+ export default RangeConnected;
265
+ export { RangeConnected };
@@ -1,17 +1,20 @@
1
1
  import { helper } from '@appbaseio/reactivecore';
2
+ import _transformOn from '@vue/babel-helper-vue-transform-on';
3
+ import { createVNode, mergeProps, createTextVNode, isVNode } from 'vue';
2
4
  import VueTypes from 'vue-types';
3
- import { p as pagination, B as Button } from './Button-d8bc15ea.js';
4
- import { t as types } from './vueTypes-b8146772.js';
5
+ import { p as pagination, B as Button } from './Button-474510e3.js';
6
+ import { t as types } from './vueTypes-f1923c72.js';
5
7
 
8
+ function _isSlot(s) {
9
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
10
+ }
6
11
  var getClassName = helper.getClassName,
7
- handleA11yAction = helper.handleA11yAction;
8
-
12
+ handleA11yAction = helper.handleA11yAction;
9
13
  function getStartPage(totalPages, currentPage, showEndPage) {
10
14
  var midValue = parseInt(totalPages / 2, 10);
11
15
  var start = currentPage - (showEndPage ? Math.ceil(midValue / 2) - 1 : midValue);
12
16
  return start > 1 ? start : 2;
13
17
  }
14
-
15
18
  var Pagination = {
16
19
  name: 'Pagination',
17
20
  functional: true,
@@ -25,151 +28,135 @@ var Pagination = {
25
28
  prevLabel: types.string,
26
29
  nextLabel: types.string
27
30
  },
28
- render: function render(createElement, context) {
29
- var h = arguments[0];
30
- var props = context.props;
31
-
31
+ render: function render(context) {
32
+ var props = context.$props;
32
33
  var onPrevPage = function onPrevPage() {
33
34
  if (props.currentPage) {
34
35
  props.setPage(props.currentPage - 1);
35
36
  }
36
37
  };
37
-
38
38
  var onNextPage = function onNextPage() {
39
39
  if (props.currentPage < props.totalPages - 1) {
40
40
  props.setPage(props.currentPage + 1);
41
41
  }
42
42
  };
43
-
44
43
  if (!props.totalPages) {
45
44
  return null;
46
45
  }
47
-
48
46
  var innerClassName = getClassName(props.innerClass, 'button');
49
47
  var primary = props.currentPage === 0;
50
48
  var className = innerClassName || primary ? innerClassName + " " + (primary ? 'active' : '') : '';
51
-
52
49
  var buildPaginationDOM = function buildPaginationDOM(position) {
53
50
  var pages = props.pages,
54
- currentPage = props.currentPage,
55
- totalPages = props.totalPages,
56
- setPage = props.setPage,
57
- showEndPage = props.showEndPage;
51
+ currentPage = props.currentPage,
52
+ totalPages = props.totalPages,
53
+ setPage = props.setPage,
54
+ showEndPage = props.showEndPage;
58
55
  var start = position === 'start' ? getStartPage(pages, currentPage, showEndPage) : Math.max(2, Math.ceil(totalPages - (pages - 1) / 2 + 1));
59
56
  var paginationButtons = [];
60
57
  var endPage = start;
61
-
62
58
  if (start <= totalPages) {
63
59
  var totalPagesToShow = pages < totalPages ? start + (pages - 1) : totalPages + 1;
64
-
65
60
  if (showEndPage) {
66
61
  totalPagesToShow = position === 'start' ? start + (Math.ceil(pages / 2) - pages % 2) : totalPages + 1;
67
62
  }
68
-
69
63
  if (currentPage > totalPages - pages + 2) {
70
64
  start = Math.max(2, totalPages - pages + 2);
71
65
  totalPagesToShow = start + pages;
72
66
  }
73
-
74
67
  var _loop = function _loop(i) {
75
68
  var activeButton = currentPage === i - 1;
76
69
  var classNameBtn = innerClassName || activeButton ? innerClassName + " " + (activeButton ? 'active' : '') : '';
77
- var pageBtn = h(Button, {
70
+ var pageBtn = createVNode(Button, {
78
71
  "class": classNameBtn,
79
- "attrs": {
80
- "primary": activeButton,
81
- "tabIndex": "0",
82
- "alt": "page-" + i
83
- },
84
- "on": {
85
- "keyPress": function keyPress(event) {
86
- return handleA11yAction(event, function () {
87
- return setPage(i - 1);
88
- });
89
- },
90
- "click": function click() {
72
+ "primary": activeButton,
73
+ "tabIndex": "0",
74
+ "onKeyPress": function onKeyPress(event) {
75
+ return handleA11yAction(event, function () {
91
76
  return setPage(i - 1);
92
- }
77
+ });
78
+ },
79
+ "alt": "page-" + i,
80
+ "onClick": function onClick() {
81
+ return setPage(i - 1);
93
82
  }
94
- }, [i]);
95
-
83
+ }, _isSlot(i) ? i : {
84
+ "default": function _default() {
85
+ return [i];
86
+ }
87
+ });
96
88
  if (i <= totalPages + 1) {
97
89
  paginationButtons.push(pageBtn);
98
-
99
90
  if (i === Math.min(totalPages + 1, totalPagesToShow) - 1) {
100
91
  endPage = i;
101
92
  }
102
93
  }
103
94
  };
104
-
105
95
  for (var i = start; i < Math.min(totalPages + 1, totalPagesToShow); i += 1) {
106
96
  _loop(i);
107
97
  }
108
98
  }
109
-
110
99
  return [paginationButtons, start, endPage];
111
100
  };
112
-
113
101
  var buildIntermediatePaginationDom = function buildIntermediatePaginationDom() {
114
102
  var showEndPage = props.showEndPage,
115
- currentPage = props.currentPage,
116
- totalPages = props.totalPages,
117
- pages = props.pages;
103
+ currentPage = props.currentPage,
104
+ totalPages = props.totalPages,
105
+ pages = props.pages;
118
106
  if (!showEndPage) return buildPaginationDOM('start')[0];
119
-
120
107
  if (currentPage <= totalPages - pages + 2 || totalPages < pages) {
121
108
  return buildPaginationDOM('start')[0];
122
109
  }
123
-
124
110
  return null;
125
111
  };
126
-
127
- return h("div", {
112
+ return createVNode("div", {
128
113
  "class": pagination + " " + getClassName(props.innerClass, 'pagination')
129
- }, [h(Button, {
114
+ }, [createVNode(Button, mergeProps(_transformOn({
115
+ click: onPrevPage,
116
+ 'key-press': function keyPress(event) {
117
+ return handleA11yAction(event, onPrevPage);
118
+ }
119
+ }), {
130
120
  "class": getClassName(props.innerClass, 'button') || '',
131
- "attrs": {
132
- "disabled": props.currentPage === 0,
133
- "tabIndex": "0"
134
- },
135
- "on": {
136
- "keyPress": function keyPress(event) {
137
- return handleA11yAction(event, onPrevPage);
138
- },
139
- "click": onPrevPage
121
+ "disabled": props.currentPage === 0,
122
+ "tabIndex": "0"
123
+ }), {
124
+ "default": function _default() {
125
+ return [props.prevLabel || 'Prev'];
140
126
  }
141
- }, [props.prevLabel || 'Prev']), h(Button, {
127
+ }), createVNode(Button, mergeProps(_transformOn({
128
+ click: function click() {
129
+ return props.setPage(0);
130
+ }
131
+ }), {
142
132
  "class": className,
143
- "attrs": {
144
- "primary": primary,
145
- "tabIndex": "0"
146
- },
147
- "on": {
148
- "keyPress": function keyPress(event) {
149
- return handleA11yAction(event, function () {
150
- return props.setPage(0);
151
- });
152
- },
153
- "click": function click() {
133
+ "primary": primary,
134
+ "onKeyPress": function onKeyPress(event) {
135
+ return handleA11yAction(event, function () {
154
136
  return props.setPage(0);
155
- }
137
+ });
138
+ },
139
+ "tabIndex": "0"
140
+ }), {
141
+ "default": function _default() {
142
+ return [createTextVNode("1")];
143
+ }
144
+ }), props.showEndPage && props.currentPage >= Math.floor(props.pages / 2) + !!(props.pages % 2) && buildPaginationDOM('start')[1] !== 2 ? createVNode("span", null, [createTextVNode("...")]) : null, buildIntermediatePaginationDom(), props.showEndPage && props.pages > 2 && props.currentPage <= props.totalPages - Math.ceil(props.pages * 0.75) && buildPaginationDOM('start')[2] !== buildPaginationDOM('end')[1] - 1 ? createVNode("span", null, [createTextVNode("...")]) : null, props.showEndPage && props.totalPages >= props.pages && buildPaginationDOM('end')[0], createVNode(Button, mergeProps(_transformOn({
145
+ click: onNextPage,
146
+ 'key-press': function keyPress(event) {
147
+ return handleA11yAction(event, onNextPage);
156
148
  }
157
- }, ["1"]), props.showEndPage && props.currentPage >= Math.floor(props.pages / 2) + !!(props.pages % 2) && buildPaginationDOM('start')[1] !== 2 ? h("span", ["..."]) : null, buildIntermediatePaginationDom(), props.showEndPage && props.pages > 2 && props.currentPage <= props.totalPages - Math.ceil(props.pages * 0.75) && buildPaginationDOM('start')[2] !== buildPaginationDOM('end')[1] - 1 ? h("span", ["..."]) : null, props.showEndPage && props.totalPages >= props.pages && buildPaginationDOM('end')[0], h(Button, {
149
+ }), {
158
150
  "class": getClassName(props.innerClass, 'button') || '',
159
- "attrs": {
160
- "disabled": props.currentPage >= props.totalPages - 1,
161
- "tabIndex": "0"
162
- },
163
- "on": {
164
- "keyPress": function keyPress(event) {
165
- return handleA11yAction(event, onNextPage);
166
- },
167
- "click": onNextPage
151
+ "disabled": props.currentPage >= props.totalPages - 1,
152
+ "tabIndex": "0"
153
+ }), {
154
+ "default": function _default() {
155
+ return [props.nextLabel || 'Next'];
168
156
  }
169
- }, [props.nextLabel || 'Next'])]);
157
+ })]);
170
158
  }
171
159
  };
172
-
173
160
  Pagination.install = function (Vue) {
174
161
  Vue.component(Pagination.name, Pagination);
175
162
  };
@@ -0,0 +1,71 @@
1
+ import { a as _extends } from './_rollupPluginBabelHelpers-ded08042.js';
2
+ import { h } from 'vue';
3
+ import { b as getCamelCase } from './index-4520a598.js';
4
+
5
+ var deepValue = function deepValue(o, p) {
6
+ return p.split('.').reduce(function (a, v) {
7
+ return a ? a[v] : null;
8
+ }, o);
9
+ };
10
+ /**
11
+ * PreferencesConsumer reads the preferences from SearchPreferencesContext
12
+ * and set the props from preferences to the component
13
+ *
14
+ */
15
+ var PreferencesConsumer = function PreferencesConsumer(component) {
16
+ return {
17
+ name: 'PreferencesConsumer',
18
+ inject: {
19
+ $searchPreferences: {
20
+ "default": null
21
+ }
22
+ },
23
+ render: function render() {
24
+ var _this = this;
25
+ var userProps = Object.keys(this.$attrs).reduce(function (result, key) {
26
+ var _extends2;
27
+ return _extends({}, result, (_extends2 = {}, _extends2[getCamelCase(key)] = _this.$attrs[key], _extends2));
28
+ }, {});
29
+ var context = this.$searchPreferences;
30
+ if (!userProps || !userProps.componentId) {
31
+ throw Error('ReactiveSearch: componentId is required');
32
+ }
33
+ var componentId = userProps.componentId;
34
+ var preferencesPath = userProps.preferencesPath;
35
+ var preferences;
36
+ if (context) {
37
+ if (preferencesPath) {
38
+ // read preferences from path
39
+ preferences = deepValue(context, preferencesPath);
40
+ } else {
41
+ preferences = deepValue(context, ['componentSettings', componentId].join('.'));
42
+ // read preferences from componentSettings
43
+ }
44
+ }
45
+ // Retrieve component specific preferences
46
+ var componentProps = userProps;
47
+ if (preferences) {
48
+ if (preferences.rsConfig) {
49
+ componentProps = _extends({}, preferences.rsConfig, componentProps);
50
+ } else {
51
+ componentProps = _extends({}, preferences, componentProps);
52
+ }
53
+ if (preferences.enabled !== undefined && !preferences.enabled) {
54
+ return null;
55
+ }
56
+ }
57
+ // Parse component props
58
+ Object.keys(componentProps).forEach(function (p) {
59
+ if (typeof componentProps[p] === 'string') {
60
+ if (['defaultQuery', 'customQuery', 'setOption'].includes(p)) {
61
+ // eslint-disable-next-line
62
+ componentProps[p] = eval(componentProps[p]);
63
+ }
64
+ }
65
+ });
66
+ return h(component, componentProps, this.$slots);
67
+ }
68
+ };
69
+ };
70
+
71
+ export { PreferencesConsumer as P };