@appbaseio/reactivesearch-vue 3.0.0-rc.5.alpha.2 → 3.0.0-rc.5.alpha.4

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 (62) hide show
  1. package/dist/@appbaseio/reactivesearch-vue.umd.js +35189 -36246
  2. package/dist/@appbaseio/reactivesearch-vue.umd.js.map +1 -1
  3. package/dist/@appbaseio/reactivesearch-vue.umd.min.js +32 -32
  4. package/dist/@appbaseio/reactivesearch-vue.umd.min.js.map +1 -1
  5. package/dist/cjs/{DropDown-b16418e9.js → CancelSvg-ab0f8b23.js} +0 -290
  6. package/dist/cjs/DropDown-e7125b72.js +299 -0
  7. package/dist/cjs/MultiDropdownList.js +2 -1
  8. package/dist/cjs/{install-7cdf6798.js → SearchBox.js} +21 -867
  9. package/dist/cjs/SingleDropdownList.js +2 -1
  10. package/dist/cjs/index.js +7 -5
  11. package/dist/cjs/install-3c4520bf.js +874 -0
  12. package/dist/cjs/install.js +4 -2
  13. package/dist/cjs/version.js +1 -1
  14. package/dist/es/{Button-a376dd9b.js → Button-fd869491.js} +1 -1
  15. package/dist/es/CancelSvg-e7ae49e9.js +401 -0
  16. package/dist/es/{Card-56bd984e.js → Card-54b9e7a0.js} +2 -2
  17. package/dist/es/{ComponentWrapper-b43a546e.js → ComponentWrapper-8a3c388d.js} +4 -3
  18. package/dist/es/{Container-6c21a1e6.js → Container-d00219f7.js} +1 -1
  19. package/dist/es/DropDown-13afb4d2.js +295 -0
  20. package/dist/es/DynamicRangeSlider.js +7 -6
  21. package/dist/es/{Flex-651f2422.js → Flex-25792bc3.js} +1 -1
  22. package/dist/es/{FormControlList-be0456b0.js → FormControlList-fe6eaee4.js} +1 -1
  23. package/dist/es/{Input-3126d7b6.js → Input-f7499ef8.js} +1 -1
  24. package/dist/es/{ListItem-a25ed63a.js → ListItem-e3c6acf4.js} +2 -2
  25. package/dist/es/MultiDropdownList.js +15 -12
  26. package/dist/es/MultiList.js +12 -10
  27. package/dist/es/MultiRange.js +10 -9
  28. package/dist/es/{Pagination-874e01df.js → Pagination-c2745bec.js} +2 -2
  29. package/dist/es/{PreferencesConsumer-9a3b0bac.js → PreferencesConsumer-b058d14e.js} +2 -2
  30. package/dist/es/RangeInput.js +12 -11
  31. package/dist/es/RangeSlider.js +9 -8
  32. package/dist/es/ReactiveBase.js +17 -5508
  33. package/dist/es/ReactiveComponent.js +6 -5
  34. package/dist/es/ReactiveGoogleMap.js +10 -9
  35. package/dist/es/ReactiveList.js +14 -13
  36. package/dist/es/ResultCard.js +3 -3
  37. package/dist/es/ResultList.js +3 -3
  38. package/dist/es/SearchBox.js +1847 -0
  39. package/dist/es/SelectedFilters.js +7 -6
  40. package/dist/es/SingleDropdownList.js +15 -12
  41. package/dist/es/SingleList.js +12 -10
  42. package/dist/es/SingleRange.js +10 -9
  43. package/dist/es/StateProvider.js +4 -3
  44. package/dist/es/{Title-4b7614be.js → Title-863dfa42.js} +1 -1
  45. package/dist/es/ToggleButton.js +9 -8
  46. package/dist/es/_rollupPluginBabelHelpers-ded08042.js +61 -0
  47. package/dist/es/{index-b2212b15.js → index-882489e1.js} +3 -67
  48. package/dist/es/index.js +31 -22
  49. package/dist/es/initReactivesearch.js +3 -2291
  50. package/dist/es/install-ff8b0750.js +868 -0
  51. package/dist/es/install.js +28 -21
  52. package/dist/es/{ssr-26e0b4af.js → ssr-c630ccb9.js} +1 -1
  53. package/dist/es/utils-d7dd4f4e.js +60 -0
  54. package/dist/es/version.js +1 -1
  55. package/package.json +2 -2
  56. package/dist/es/DropDown-59c3fbc7.js +0 -690
  57. package/dist/es/_rollupPluginBabelHelpers-dac426db.js +0 -423
  58. package/dist/es/helper-39773859.js +0 -558
  59. package/dist/es/index-b9203a60.js +0 -10
  60. package/dist/es/install-d7f59dee.js +0 -4008
  61. package/dist/es/transform-e41c9e5c.js +0 -412
  62. package/dist/es/utils-782d91c4.js +0 -1315
@@ -1,2294 +1,6 @@
1
- import { e as _asyncToGenerator, f as _regeneratorRuntime, g as _createForOfIteratorHelperLoose, _ as _extends } from './_rollupPluginBabelHelpers-dac426db.js';
2
- import { ssrUtils, initDirectivesForSSR, createVNode, ssrContextKey, createApp, warn, Fragment, Static, Comment, Text, mergeProps, createSSRApp } from 'vue';
3
-
4
- var _PatchFlagNames, _slotFlagsText;
5
- /**
6
- * Make a map and return a function for checking if a key
7
- * is in that map.
8
- * IMPORTANT: all calls of this function must be prefixed with
9
- * \/\*#\_\_PURE\_\_\*\/
10
- * So that rollup can tree-shake them if necessary.
11
- */
12
- function makeMap(str, expectsLowerCase) {
13
- var map = Object.create(null);
14
- var list = str.split(',');
15
- for (var i = 0; i < list.length; i++) {
16
- map[list[i]] = true;
17
- }
18
- return expectsLowerCase ? function (val) {
19
- return !!map[val.toLowerCase()];
20
- } : function (val) {
21
- return !!map[val];
22
- };
23
- }
24
-
25
- /**
26
- * dev only flag -> name mapping
27
- */
28
- var PatchFlagNames = (_PatchFlagNames = {}, _PatchFlagNames[1 /* PatchFlags.TEXT */] = "TEXT", _PatchFlagNames[2 /* PatchFlags.CLASS */] = "CLASS", _PatchFlagNames[4 /* PatchFlags.STYLE */] = "STYLE", _PatchFlagNames[8 /* PatchFlags.PROPS */] = "PROPS", _PatchFlagNames[16 /* PatchFlags.FULL_PROPS */] = "FULL_PROPS", _PatchFlagNames[32 /* PatchFlags.HYDRATE_EVENTS */] = "HYDRATE_EVENTS", _PatchFlagNames[64 /* PatchFlags.STABLE_FRAGMENT */] = "STABLE_FRAGMENT", _PatchFlagNames[128 /* PatchFlags.KEYED_FRAGMENT */] = "KEYED_FRAGMENT", _PatchFlagNames[256 /* PatchFlags.UNKEYED_FRAGMENT */] = "UNKEYED_FRAGMENT", _PatchFlagNames[512 /* PatchFlags.NEED_PATCH */] = "NEED_PATCH", _PatchFlagNames[1024 /* PatchFlags.DYNAMIC_SLOTS */] = "DYNAMIC_SLOTS", _PatchFlagNames[2048 /* PatchFlags.DEV_ROOT_FRAGMENT */] = "DEV_ROOT_FRAGMENT", _PatchFlagNames[-1 /* PatchFlags.HOISTED */] = "HOISTED", _PatchFlagNames[-2 /* PatchFlags.BAIL */] = "BAIL", _PatchFlagNames);
29
-
30
- /**
31
- * Dev only
32
- */
33
- var slotFlagsText = (_slotFlagsText = {}, _slotFlagsText[1 /* SlotFlags.STABLE */] = 'STABLE', _slotFlagsText[2 /* SlotFlags.DYNAMIC */] = 'DYNAMIC', _slotFlagsText[3 /* SlotFlags.FORWARDED */] = 'FORWARDED', _slotFlagsText);
34
- function normalizeStyle(value) {
35
- if (isArray(value)) {
36
- var res = {};
37
- for (var i = 0; i < value.length; i++) {
38
- var item = value[i];
39
- var normalized = isString(item) ? parseStringStyle(item) : normalizeStyle(item);
40
- if (normalized) {
41
- for (var key in normalized) {
42
- res[key] = normalized[key];
43
- }
44
- }
45
- }
46
- return res;
47
- } else if (isString(value)) {
48
- return value;
49
- } else if (isObject(value)) {
50
- return value;
51
- }
52
- }
53
- var listDelimiterRE = /;(?![^(]*\))/g;
54
- var propertyDelimiterRE = /:([^]+)/;
55
- var styleCommentRE = /\/\*[\s\S]*?\*\//g;
56
- function parseStringStyle(cssText) {
57
- var ret = {};
58
- cssText.replace(styleCommentRE, '').split(listDelimiterRE).forEach(function (item) {
59
- if (item) {
60
- var tmp = item.split(propertyDelimiterRE);
61
- tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
62
- }
63
- });
64
- return ret;
65
- }
66
- function stringifyStyle(styles) {
67
- var ret = '';
68
- if (!styles || isString(styles)) {
69
- return ret;
70
- }
71
- for (var key in styles) {
72
- var value = styles[key];
73
- var normalizedKey = key.startsWith("--") ? key : hyphenate(key);
74
- if (isString(value) || typeof value === 'number') {
75
- // only render valid values
76
- ret += normalizedKey + ":" + value + ";";
77
- }
78
- }
79
- return ret;
80
- }
81
- function normalizeClass(value) {
82
- var res = '';
83
- if (isString(value)) {
84
- res = value;
85
- } else if (isArray(value)) {
86
- for (var i = 0; i < value.length; i++) {
87
- var normalized = normalizeClass(value[i]);
88
- if (normalized) {
89
- res += normalized + ' ';
90
- }
91
- }
92
- } else if (isObject(value)) {
93
- for (var name in value) {
94
- if (value[name]) {
95
- res += name + ' ';
96
- }
97
- }
98
- }
99
- return res.trim();
100
- }
101
- // https://developer.mozilla.org/en-US/docs/Web/SVG/Element
102
- var SVG_TAGS = 'svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,' + 'defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,' + 'feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,' + 'feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,' + 'feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,' + 'fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,' + 'foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,' + 'mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,' + 'polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,' + 'text,textPath,title,tspan,unknown,use,view';
103
- var VOID_TAGS = 'area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr';
104
- /**
105
- * Compiler only.
106
- * Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag.
107
- */
108
- var isSVGTag = /*#__PURE__*/makeMap(SVG_TAGS);
109
- /**
110
- * Compiler only.
111
- * Do NOT use in runtime code paths unless behind `(process.env.NODE_ENV !== 'production')` flag.
112
- */
113
- var isVoidTag = /*#__PURE__*/makeMap(VOID_TAGS);
114
-
115
- /**
116
- * On the client we only need to offer special cases for boolean attributes that
117
- * have different names from their corresponding dom properties:
118
- * - itemscope -> N/A
119
- * - allowfullscreen -> allowFullscreen
120
- * - formnovalidate -> formNoValidate
121
- * - ismap -> isMap
122
- * - nomodule -> noModule
123
- * - novalidate -> noValidate
124
- * - readonly -> readOnly
125
- */
126
- var specialBooleanAttrs = "itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly";
127
- /**
128
- * The full list is needed during SSR to produce the correct initial markup.
129
- */
130
- var isBooleanAttr = /*#__PURE__*/makeMap(specialBooleanAttrs + ",async,autofocus,autoplay,controls,default,defer,disabled,hidden," + "loop,open,required,reversed,scoped,seamless," + "checked,muted,multiple,selected");
131
- /**
132
- * Boolean attributes should be included if the value is truthy or ''.
133
- * e.g. `<select multiple>` compiles to `{ multiple: '' }`
134
- */
135
- function includeBooleanAttr(value) {
136
- return !!value || value === '';
137
- }
138
- var unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
139
- var attrValidationCache = {};
140
- function isSSRSafeAttrName(name) {
141
- if (attrValidationCache.hasOwnProperty(name)) {
142
- return attrValidationCache[name];
143
- }
144
- var isUnsafe = unsafeAttrCharRE.test(name);
145
- if (isUnsafe) {
146
- console.error("unsafe attribute name: " + name);
147
- }
148
- return attrValidationCache[name] = !isUnsafe;
149
- }
150
- var propsToAttrMap = {
151
- acceptCharset: 'accept-charset',
152
- className: 'class',
153
- htmlFor: 'for',
154
- httpEquiv: 'http-equiv'
155
- };
156
- var escapeRE = /["'&<>]/;
157
- function escapeHtml(string) {
158
- var str = '' + string;
159
- var match = escapeRE.exec(str);
160
- if (!match) {
161
- return str;
162
- }
163
- var html = '';
164
- var escaped;
165
- var index;
166
- var lastIndex = 0;
167
- for (index = match.index; index < str.length; index++) {
168
- switch (str.charCodeAt(index)) {
169
- case 34:
170
- // "
171
- escaped = '&quot;';
172
- break;
173
- case 38:
174
- // &
175
- escaped = '&amp;';
176
- break;
177
- case 39:
178
- // '
179
- escaped = '&#39;';
180
- break;
181
- case 60:
182
- // <
183
- escaped = '&lt;';
184
- break;
185
- case 62:
186
- // >
187
- escaped = '&gt;';
188
- break;
189
- default:
190
- continue;
191
- }
192
- if (lastIndex !== index) {
193
- html += str.slice(lastIndex, index);
194
- }
195
- lastIndex = index + 1;
196
- html += escaped;
197
- }
198
- return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
199
- }
200
- // https://www.w3.org/TR/html52/syntax.html#comments
201
- var commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
202
- function escapeHtmlComment(src) {
203
- return src.replace(commentStripRE, '');
204
- }
205
- var EMPTY_OBJ = process.env.NODE_ENV !== 'production' ? Object.freeze({}) : {};
206
- var EMPTY_ARR = process.env.NODE_ENV !== 'production' ? Object.freeze([]) : [];
207
- var NOOP = function NOOP() {};
208
- var onRE = /^on[^a-z]/;
209
- var isOn = function isOn(key) {
210
- return onRE.test(key);
211
- };
212
- var isArray = Array.isArray;
213
- var isFunction = function isFunction(val) {
214
- return typeof val === 'function';
215
- };
216
- var isString = function isString(val) {
217
- return typeof val === 'string';
218
- };
219
- var isObject = function isObject(val) {
220
- return val !== null && typeof val === 'object';
221
- };
222
- var isPromise = function isPromise(val) {
223
- return isObject(val) && isFunction(val.then) && isFunction(val["catch"]);
224
- };
225
- var cacheStringFunction = function cacheStringFunction(fn) {
226
- var cache = Object.create(null);
227
- return function (str) {
228
- var hit = cache[str];
229
- return hit || (cache[str] = fn(str));
230
- };
231
- };
232
- var hyphenateRE = /\B([A-Z])/g;
233
- /**
234
- * @private
235
- */
236
- var hyphenate = cacheStringFunction(function (str) {
237
- return str.replace(hyphenateRE, '-$1').toLowerCase();
238
- });
239
-
240
- var _ErrorTypeStrings;
241
-
242
- // leading comma for empty string ""
243
- var shouldIgnoreProp = makeMap(",key,ref,innerHTML,textContent,ref_key,ref_for");
244
- function ssrRenderAttrs(props, tag) {
245
- var ret = '';
246
- for (var key in props) {
247
- if (shouldIgnoreProp(key) || isOn(key) || tag === 'textarea' && key === 'value') {
248
- continue;
249
- }
250
- var value = props[key];
251
- if (key === 'class') {
252
- ret += " class=\"" + ssrRenderClass(value) + "\"";
253
- } else if (key === 'style') {
254
- ret += " style=\"" + ssrRenderStyle(value) + "\"";
255
- } else {
256
- ret += ssrRenderDynamicAttr(key, value, tag);
257
- }
258
- }
259
- return ret;
260
- }
261
- // render an attr with dynamic (unknown) key.
262
- function ssrRenderDynamicAttr(key, value, tag) {
263
- if (!isRenderableValue(value)) {
264
- return "";
265
- }
266
- var attrKey = tag && (tag.indexOf('-') > 0 || isSVGTag(tag)) ? key // preserve raw name on custom elements and svg
267
- : propsToAttrMap[key] || key.toLowerCase();
268
- if (isBooleanAttr(attrKey)) {
269
- return includeBooleanAttr(value) ? " " + attrKey : "";
270
- } else if (isSSRSafeAttrName(attrKey)) {
271
- return value === '' ? " " + attrKey : " " + attrKey + "=\"" + escapeHtml(value) + "\"";
272
- } else {
273
- console.warn("[@vue/server-renderer] Skipped rendering unsafe attribute name: " + attrKey);
274
- return "";
275
- }
276
- }
277
- function isRenderableValue(value) {
278
- if (value == null) {
279
- return false;
280
- }
281
- var type = typeof value;
282
- return type === 'string' || type === 'number' || type === 'boolean';
283
- }
284
- function ssrRenderClass(raw) {
285
- return escapeHtml(normalizeClass(raw));
286
- }
287
- function ssrRenderStyle(raw) {
288
- if (!raw) {
289
- return '';
290
- }
291
- if (isString(raw)) {
292
- return escapeHtml(raw);
293
- }
294
- var styles = normalizeStyle(raw);
295
- return escapeHtml(stringifyStyle(styles));
296
- }
297
- function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
298
- parentPush('<!--teleport start-->');
299
- var context = parentComponent.appContext.provides[ssrContextKey];
300
- var teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
301
- var targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
302
- // record current index of the target buffer to handle nested teleports
303
- // since the parent needs to be rendered before the child
304
- var bufferIndex = targetBuffer.length;
305
- var teleportContent;
306
- if (disabled) {
307
- contentRenderFn(parentPush);
308
- teleportContent = "<!--teleport anchor-->";
309
- } else {
310
- var _createBuffer = createBuffer(),
311
- getBuffer = _createBuffer.getBuffer,
312
- push = _createBuffer.push;
313
- contentRenderFn(push);
314
- push("<!--teleport anchor-->");
315
- teleportContent = getBuffer();
316
- }
317
- targetBuffer.splice(bufferIndex, 0, teleportContent);
318
- parentPush('<!--teleport end-->');
319
- }
320
- Symbol(process.env.NODE_ENV !== 'production' ? 'iterate' : '');
321
- Symbol(process.env.NODE_ENV !== 'production' ? 'Map key iterate' : '');
322
- var ErrorTypeStrings = (_ErrorTypeStrings = {}, _ErrorTypeStrings["sp" /* LifecycleHooks.SERVER_PREFETCH */] = 'serverPrefetch hook', _ErrorTypeStrings["bc" /* LifecycleHooks.BEFORE_CREATE */] = 'beforeCreate hook', _ErrorTypeStrings["c" /* LifecycleHooks.CREATED */] = 'created hook', _ErrorTypeStrings["bm" /* LifecycleHooks.BEFORE_MOUNT */] = 'beforeMount hook', _ErrorTypeStrings["m" /* LifecycleHooks.MOUNTED */] = 'mounted hook', _ErrorTypeStrings["bu" /* LifecycleHooks.BEFORE_UPDATE */] = 'beforeUpdate hook', _ErrorTypeStrings["u" /* LifecycleHooks.UPDATED */] = 'updated', _ErrorTypeStrings["bum" /* LifecycleHooks.BEFORE_UNMOUNT */] = 'beforeUnmount hook', _ErrorTypeStrings["um" /* LifecycleHooks.UNMOUNTED */] = 'unmounted hook', _ErrorTypeStrings["a" /* LifecycleHooks.ACTIVATED */] = 'activated hook', _ErrorTypeStrings["da" /* LifecycleHooks.DEACTIVATED */] = 'deactivated hook', _ErrorTypeStrings["ec" /* LifecycleHooks.ERROR_CAPTURED */] = 'errorCaptured hook', _ErrorTypeStrings["rtc" /* LifecycleHooks.RENDER_TRACKED */] = 'renderTracked hook', _ErrorTypeStrings["rtg" /* LifecycleHooks.RENDER_TRIGGERED */] = 'renderTriggered hook', _ErrorTypeStrings[0 /* ErrorCodes.SETUP_FUNCTION */] = 'setup function', _ErrorTypeStrings[1 /* ErrorCodes.RENDER_FUNCTION */] = 'render function', _ErrorTypeStrings[2 /* ErrorCodes.WATCH_GETTER */] = 'watcher getter', _ErrorTypeStrings[3 /* ErrorCodes.WATCH_CALLBACK */] = 'watcher callback', _ErrorTypeStrings[4 /* ErrorCodes.WATCH_CLEANUP */] = 'watcher cleanup function', _ErrorTypeStrings[5 /* ErrorCodes.NATIVE_EVENT_HANDLER */] = 'native event handler', _ErrorTypeStrings[6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */] = 'component event handler', _ErrorTypeStrings[7 /* ErrorCodes.VNODE_HOOK */] = 'vnode hook', _ErrorTypeStrings[8 /* ErrorCodes.DIRECTIVE_HOOK */] = 'directive hook', _ErrorTypeStrings[9 /* ErrorCodes.TRANSITION_HOOK */] = 'transition hook', _ErrorTypeStrings[10 /* ErrorCodes.APP_ERROR_HANDLER */] = 'app errorHandler', _ErrorTypeStrings[11 /* ErrorCodes.APP_WARN_HANDLER */] = 'app warnHandler', _ErrorTypeStrings[12 /* ErrorCodes.FUNCTION_REF */] = 'ref function', _ErrorTypeStrings[13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */] = 'async component loader', _ErrorTypeStrings[14 /* ErrorCodes.SCHEDULER */] = 'scheduler flush. This is likely a Vue internals bug. ' + 'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core', _ErrorTypeStrings);
323
- function ssrCompile(template, instance) {
324
- // TODO: this branch should now work in ESM builds, enable it in a minor
325
- {
326
- throw new Error("On-the-fly template compilation is not supported in the ESM build of " + "@vue/server-renderer. All templates must be pre-compiled into " + "render functions.");
327
- }
328
- }
329
- var createComponentInstance = ssrUtils.createComponentInstance,
330
- setCurrentRenderingInstance = ssrUtils.setCurrentRenderingInstance,
331
- setupComponent = ssrUtils.setupComponent,
332
- renderComponentRoot = ssrUtils.renderComponentRoot,
333
- normalizeVNode = ssrUtils.normalizeVNode;
334
- // Each component has a buffer array.
335
- // A buffer array can contain one of the following:
336
- // - plain string
337
- // - A resolved buffer (recursive arrays of strings that can be unrolled
338
- // synchronously)
339
- // - An async buffer (a Promise that resolves to a resolved buffer)
340
- function createBuffer() {
341
- var appendable = false;
342
- var buffer = [];
343
- return {
344
- getBuffer: function getBuffer() {
345
- // Return static buffer and await on items during unroll stage
346
- return buffer;
347
- },
348
- push: function push(item) {
349
- var isStringItem = isString(item);
350
- if (appendable && isStringItem) {
351
- buffer[buffer.length - 1] += item;
352
- } else {
353
- buffer.push(item);
354
- }
355
- appendable = isStringItem;
356
- if (isPromise(item) || isArray(item) && item.hasAsync) {
357
- // promise, or child buffer with async, mark as async.
358
- // this allows skipping unnecessary await ticks during unroll stage
359
- buffer.hasAsync = true;
360
- }
361
- }
362
- };
363
- }
364
- function renderComponentVNode(vnode, parentComponent, slotScopeId) {
365
- if (parentComponent === void 0) {
366
- parentComponent = null;
367
- }
368
- var instance = createComponentInstance(vnode, parentComponent, null);
369
- var res = setupComponent(instance, true /* isSSR */);
370
- var hasAsyncSetup = isPromise(res);
371
- var prefetches = instance.sp; /* LifecycleHooks.SERVER_PREFETCH */
372
- if (hasAsyncSetup || prefetches) {
373
- var p = hasAsyncSetup ? res : Promise.resolve();
374
- if (prefetches) {
375
- p = p.then(function () {
376
- return Promise.all(prefetches.map(function (prefetch) {
377
- return prefetch.call(instance.proxy);
378
- }));
379
- })
380
- // Note: error display is already done by the wrapped lifecycle hook function.
381
- ["catch"](function () {});
382
- }
383
- return p.then(function () {
384
- return renderComponentSubTree(instance, slotScopeId);
385
- });
386
- } else {
387
- return renderComponentSubTree(instance, slotScopeId);
388
- }
389
- }
390
- function renderComponentSubTree(instance, slotScopeId) {
391
- var comp = instance.type;
392
- var _createBuffer2 = createBuffer(),
393
- getBuffer = _createBuffer2.getBuffer,
394
- push = _createBuffer2.push;
395
- if (isFunction(comp)) {
396
- var root = renderComponentRoot(instance);
397
- // #5817 scope ID attrs not falling through if functional component doesn't
398
- // have props
399
- if (!comp.props) {
400
- for (var key in instance.attrs) {
401
- if (key.startsWith("data-v-")) {
402
- (root.props || (root.props = {}))[key] = "";
403
- }
404
- }
405
- }
406
- renderVNode(push, instance.subTree = root, instance, slotScopeId);
407
- } else {
408
- if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) {
409
- comp.ssrRender = ssrCompile(comp.template);
410
- }
411
- // perf: enable caching of computed getters during render
412
- // since there cannot be state mutations during render.
413
- for (var _iterator = _createForOfIteratorHelperLoose(instance.scope.effects), _step; !(_step = _iterator()).done;) {
414
- var e = _step.value;
415
- if (e.computed) e.computed._cacheable = true;
416
- }
417
- var ssrRender = instance.ssrRender || comp.ssrRender;
418
- if (ssrRender) {
419
- // optimized
420
- // resolve fallthrough attrs
421
- var attrs = instance.inheritAttrs !== false ? instance.attrs : undefined;
422
- var hasCloned = false;
423
- var cur = instance;
424
- while (true) {
425
- var scopeId = cur.vnode.scopeId;
426
- if (scopeId) {
427
- if (!hasCloned) {
428
- attrs = _extends({}, attrs);
429
- hasCloned = true;
430
- }
431
- attrs[scopeId] = '';
432
- }
433
- var parent = cur.parent;
434
- if (parent && parent.subTree && parent.subTree === cur.vnode) {
435
- // parent is a non-SSR compiled component and is rendering this
436
- // component as root. inherit its scopeId if present.
437
- cur = parent;
438
- } else {
439
- break;
440
- }
441
- }
442
- if (slotScopeId) {
443
- if (!hasCloned) attrs = _extends({}, attrs);
444
- attrs[slotScopeId.trim()] = '';
445
- }
446
- // set current rendering instance for asset resolution
447
- var prev = setCurrentRenderingInstance(instance);
448
- try {
449
- ssrRender(instance.proxy, push, instance, attrs,
450
- // compiler-optimized bindings
451
- instance.props, instance.setupState, instance.data, instance.ctx);
452
- } finally {
453
- setCurrentRenderingInstance(prev);
454
- }
455
- } else if (instance.render && instance.render !== NOOP) {
456
- renderVNode(push, instance.subTree = renderComponentRoot(instance), instance, slotScopeId);
457
- } else {
458
- var componentName = comp.name || comp.__file || "<Anonymous>";
459
- warn("Component " + componentName + " is missing template or render function.");
460
- push("<!---->");
461
- }
462
- }
463
- return getBuffer();
464
- }
465
- function renderVNode(push, vnode, parentComponent, slotScopeId) {
466
- var type = vnode.type,
467
- shapeFlag = vnode.shapeFlag,
468
- children = vnode.children;
469
- switch (type) {
470
- case Text:
471
- push(escapeHtml(children));
472
- break;
473
- case Comment:
474
- push(children ? "<!--" + escapeHtmlComment(children) + "-->" : "<!---->");
475
- break;
476
- case Static:
477
- push(children);
478
- break;
479
- case Fragment:
480
- if (vnode.slotScopeIds) {
481
- slotScopeId = (slotScopeId ? slotScopeId + ' ' : '') + vnode.slotScopeIds.join(' ');
482
- }
483
- push("<!--[-->"); // open
484
- renderVNodeChildren(push, children, parentComponent, slotScopeId);
485
- push("<!--]-->"); // close
486
- break;
487
- default:
488
- if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
489
- renderElementVNode(push, vnode, parentComponent, slotScopeId);
490
- } else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
491
- push(renderComponentVNode(vnode, parentComponent, slotScopeId));
492
- } else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
493
- renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
494
- } else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
495
- renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
496
- } else {
497
- warn('[@vue/server-renderer] Invalid VNode type:', type, "(" + typeof type + ")");
498
- }
499
- }
500
- }
501
- function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
502
- for (var i = 0; i < children.length; i++) {
503
- renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
504
- }
505
- }
506
- function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
507
- var tag = vnode.type;
508
- var props = vnode.props,
509
- children = vnode.children,
510
- shapeFlag = vnode.shapeFlag,
511
- scopeId = vnode.scopeId,
512
- dirs = vnode.dirs;
513
- var openTag = "<" + tag;
514
- if (dirs) {
515
- props = applySSRDirectives(vnode, props, dirs);
516
- }
517
- if (props) {
518
- openTag += ssrRenderAttrs(props, tag);
519
- }
520
- if (scopeId) {
521
- openTag += " " + scopeId;
522
- }
523
- // inherit parent chain scope id if this is the root node
524
- var curParent = parentComponent;
525
- var curVnode = vnode;
526
- while (curParent && curVnode === curParent.subTree) {
527
- curVnode = curParent.vnode;
528
- if (curVnode.scopeId) {
529
- openTag += " " + curVnode.scopeId;
530
- }
531
- curParent = curParent.parent;
532
- }
533
- if (slotScopeId) {
534
- openTag += " " + slotScopeId;
535
- }
536
- push(openTag + ">");
537
- if (!isVoidTag(tag)) {
538
- var hasChildrenOverride = false;
539
- if (props) {
540
- if (props.innerHTML) {
541
- hasChildrenOverride = true;
542
- push(props.innerHTML);
543
- } else if (props.textContent) {
544
- hasChildrenOverride = true;
545
- push(escapeHtml(props.textContent));
546
- } else if (tag === 'textarea' && props.value) {
547
- hasChildrenOverride = true;
548
- push(escapeHtml(props.value));
549
- }
550
- }
551
- if (!hasChildrenOverride) {
552
- if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
553
- push(escapeHtml(children));
554
- } else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
555
- renderVNodeChildren(push, children, parentComponent, slotScopeId);
556
- }
557
- }
558
- push("</" + tag + ">");
559
- }
560
- }
561
- function applySSRDirectives(vnode, rawProps, dirs) {
562
- var toMerge = [];
563
- for (var i = 0; i < dirs.length; i++) {
564
- var binding = dirs[i];
565
- var getSSRProps = binding.dir.getSSRProps;
566
- if (getSSRProps) {
567
- var props = getSSRProps(binding, vnode);
568
- if (props) toMerge.push(props);
569
- }
570
- }
571
- return mergeProps.apply(void 0, [rawProps || {}].concat(toMerge));
572
- }
573
- function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
574
- var target = vnode.props && vnode.props.to;
575
- var disabled = vnode.props && vnode.props.disabled;
576
- if (!target) {
577
- if (!disabled) {
578
- warn("[@vue/server-renderer] Teleport is missing target prop.");
579
- }
580
- return [];
581
- }
582
- if (!isString(target)) {
583
- warn("[@vue/server-renderer] Teleport target must be a query selector string.");
584
- return [];
585
- }
586
- ssrRenderTeleport(push, function (push) {
587
- renderVNodeChildren(push, vnode.children, parentComponent, slotScopeId);
588
- }, target, disabled || disabled === '', parentComponent);
589
- }
590
- var isVNode$1 = ssrUtils.isVNode;
591
- function unrollBuffer$1(_x3) {
592
- return _unrollBuffer$.apply(this, arguments);
593
- }
594
- function _unrollBuffer$() {
595
- _unrollBuffer$ = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buffer) {
596
- var ret, i, item;
597
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
598
- while (1) switch (_context3.prev = _context3.next) {
599
- case 0:
600
- if (!buffer.hasAsync) {
601
- _context3.next = 23;
602
- break;
603
- }
604
- ret = '';
605
- i = 0;
606
- case 3:
607
- if (!(i < buffer.length)) {
608
- _context3.next = 20;
609
- break;
610
- }
611
- item = buffer[i];
612
- if (!isPromise(item)) {
613
- _context3.next = 9;
614
- break;
615
- }
616
- _context3.next = 8;
617
- return item;
618
- case 8:
619
- item = _context3.sent;
620
- case 9:
621
- if (!isString(item)) {
622
- _context3.next = 13;
623
- break;
624
- }
625
- ret += item;
626
- _context3.next = 17;
627
- break;
628
- case 13:
629
- _context3.t0 = ret;
630
- _context3.next = 16;
631
- return unrollBuffer$1(item);
632
- case 16:
633
- ret = _context3.t0 += _context3.sent;
634
- case 17:
635
- i++;
636
- _context3.next = 3;
637
- break;
638
- case 20:
639
- return _context3.abrupt("return", ret);
640
- case 23:
641
- return _context3.abrupt("return", unrollBufferSync$1(buffer));
642
- case 24:
643
- case "end":
644
- return _context3.stop();
645
- }
646
- }, _callee3);
647
- }));
648
- return _unrollBuffer$.apply(this, arguments);
649
- }
650
- function unrollBufferSync$1(buffer) {
651
- var ret = '';
652
- for (var i = 0; i < buffer.length; i++) {
653
- var item = buffer[i];
654
- if (isString(item)) {
655
- ret += item;
656
- } else {
657
- // since this is a sync buffer, child buffers are never promises
658
- ret += unrollBufferSync$1(item);
659
- }
660
- }
661
- return ret;
662
- }
663
- function renderToString(_x4, _x5) {
664
- return _renderToString.apply(this, arguments);
665
- }
666
- function _renderToString() {
667
- _renderToString = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(input, context) {
668
- var vnode, buffer, result, _iterator3, _step3, unwatch;
669
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
670
- while (1) switch (_context4.prev = _context4.next) {
671
- case 0:
672
- if (context === void 0) {
673
- context = {};
674
- }
675
- if (!isVNode$1(input)) {
676
- _context4.next = 3;
677
- break;
678
- }
679
- return _context4.abrupt("return", renderToString(createApp({
680
- render: function render() {
681
- return input;
682
- }
683
- }), context));
684
- case 3:
685
- // rendering an app
686
- vnode = createVNode(input._component, input._props);
687
- vnode.appContext = input._context;
688
- // provide the ssr context to the tree
689
- input.provide(ssrContextKey, context);
690
- _context4.next = 8;
691
- return renderComponentVNode(vnode);
692
- case 8:
693
- buffer = _context4.sent;
694
- _context4.next = 11;
695
- return unrollBuffer$1(buffer);
696
- case 11:
697
- result = _context4.sent;
698
- _context4.next = 14;
699
- return resolveTeleports(context);
700
- case 14:
701
- if (context.__watcherHandles) {
702
- for (_iterator3 = _createForOfIteratorHelperLoose(context.__watcherHandles); !(_step3 = _iterator3()).done;) {
703
- unwatch = _step3.value;
704
- unwatch();
705
- }
706
- }
707
- return _context4.abrupt("return", result);
708
- case 16:
709
- case "end":
710
- return _context4.stop();
711
- }
712
- }, _callee4);
713
- }));
714
- return _renderToString.apply(this, arguments);
715
- }
716
- function resolveTeleports(_x6) {
717
- return _resolveTeleports.apply(this, arguments);
718
- }
719
- function _resolveTeleports() {
720
- _resolveTeleports = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(context) {
721
- var key;
722
- return _regeneratorRuntime().wrap(function _callee5$(_context5) {
723
- while (1) switch (_context5.prev = _context5.next) {
724
- case 0:
725
- if (!context.__teleportBuffers) {
726
- _context5.next = 14;
727
- break;
728
- }
729
- context.teleports = context.teleports || {};
730
- _context5.t0 = _regeneratorRuntime().keys(context.__teleportBuffers);
731
- case 3:
732
- if ((_context5.t1 = _context5.t0()).done) {
733
- _context5.next = 14;
734
- break;
735
- }
736
- key = _context5.t1.value;
737
- _context5.t2 = unrollBuffer$1;
738
- _context5.next = 8;
739
- return Promise.all([context.__teleportBuffers[key]]);
740
- case 8:
741
- _context5.t3 = _context5.sent;
742
- _context5.next = 11;
743
- return (0, _context5.t2)(_context5.t3);
744
- case 11:
745
- context.teleports[key] = _context5.sent;
746
- _context5.next = 3;
747
- break;
748
- case 14:
749
- case "end":
750
- return _context5.stop();
751
- }
752
- }, _callee5);
753
- }));
754
- return _resolveTeleports.apply(this, arguments);
755
- }
756
- var isVNode = ssrUtils.isVNode;
757
- initDirectivesForSSR();
758
-
759
- function _arrayLikeToArray(arr, len) {
760
- if (len == null || len > arr.length) len = arr.length;
761
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
762
- return arr2;
763
- }
764
- function _arrayWithoutHoles(arr) {
765
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
766
- }
767
- function _iterableToArray(iter) {
768
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
769
- }
770
- function _unsupportedIterableToArray(o, minLen) {
771
- if (!o) return;
772
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
773
- var n = Object.prototype.toString.call(o).slice(8, -1);
774
- if (n === "Object" && o.constructor) n = o.constructor.name;
775
- if (n === "Map" || n === "Set") return Array.from(o);
776
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
777
- }
778
- function _nonIterableSpread() {
779
- throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
780
- }
781
- function _toConsumableArray(arr) {
782
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
783
- }
784
- function _objectWithoutPropertiesLoose(source, excluded) {
785
- if (source == null) return {};
786
- var target = {};
787
- var sourceKeys = Object.keys(source);
788
- var key, i;
789
- for (i = 0; i < sourceKeys.length; i++) {
790
- key = sourceKeys[i];
791
- if (excluded.indexOf(key) >= 0) continue;
792
- target[key] = source[key];
793
- }
794
- return target;
795
- }
796
- function _objectWithoutProperties(source, excluded) {
797
- if (source == null) return {};
798
- var target = _objectWithoutPropertiesLoose(source, excluded);
799
- var key, i;
800
- if (Object.getOwnPropertySymbols) {
801
- var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
802
- for (i = 0; i < sourceSymbolKeys.length; i++) {
803
- key = sourceSymbolKeys[i];
804
- if (excluded.indexOf(key) >= 0) continue;
805
- if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
806
- target[key] = source[key];
807
- }
808
- }
809
- return target;
810
- }
811
- function _typeof(obj) {
812
- "@babel/helpers - typeof";
813
-
814
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
815
- return typeof obj;
816
- } : function (obj) {
817
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
818
- }, _typeof(obj);
819
- }
820
- function _toPrimitive$1(input, hint) {
821
- if (_typeof(input) !== "object" || input === null) return input;
822
- var prim = input[Symbol.toPrimitive];
823
- if (prim !== undefined) {
824
- var res = prim.call(input, hint || "default");
825
- if (_typeof(res) !== "object") return res;
826
- throw new TypeError("@@toPrimitive must return a primitive value.");
827
- }
828
- return (hint === "string" ? String : Number)(input);
829
- }
830
- function _toPropertyKey$1(arg) {
831
- var key = _toPrimitive$1(arg, "string");
832
- return _typeof(key) === "symbol" ? key : String(key);
833
- }
834
- function _defineProperty(obj, key, value) {
835
- key = _toPropertyKey$1(key);
836
- if (key in obj) {
837
- Object.defineProperty(obj, key, {
838
- value: value,
839
- enumerable: true,
840
- configurable: true,
841
- writable: true
842
- });
843
- } else {
844
- obj[key] = value;
845
- }
846
- return obj;
847
- }
848
- var componentTypes = {
849
- reactiveList: 'REACTIVELIST',
850
- // search components
851
- dataSearch: 'DATASEARCH',
852
- categorySearch: 'CATEGORYSEARCH',
853
- searchBox: 'SEARCHBOX',
854
- // list components
855
- singleList: 'SINGLELIST',
856
- multiList: 'MULTILIST',
857
- singleDataList: 'SINGLEDATALIST',
858
- tabDataList: 'TABDATALIST',
859
- singleDropdownList: 'SINGLEDROPDOWNLIST',
860
- multiDataList: 'MULTIDATALIST',
861
- multiDropdownList: 'MULTIDROPDOWNLIST',
862
- singleDropdownRange: 'SINGLEDROPDOWNRANGE',
863
- treeList: 'TREELIST',
864
- // basic components
865
- numberBox: 'NUMBERBOX',
866
- tagCloud: 'TAGCLOUD',
867
- toggleButton: 'TOGGLEBUTTON',
868
- reactiveComponent: 'REACTIVECOMPONENT',
869
- // range components
870
- datePicker: 'DATEPICKER',
871
- dateRange: 'DATERANGE',
872
- dynamicRangeSlider: 'DYNAMICRANGESLIDER',
873
- multiDropdownRange: 'MULTIDROPDOWNRANGE',
874
- singleRange: 'SINGLERANGE',
875
- multiRange: 'MULTIRANGE',
876
- rangeSlider: 'RANGESLIDER',
877
- ratingsFilter: 'RATINGSFILTER',
878
- rangeInput: 'RANGEINPUT',
879
- // map components
880
- geoDistanceDropdown: 'GEO_DISTANCE_DROPDOWN',
881
- geoDistanceSlider: 'GEO_DISTANCE_SLIDER',
882
- reactiveMap: 'REACTIVE_MAP',
883
- // chart components
884
- reactiveChart: 'REACTIVE_CHART'
885
- };
886
- var queryTypes = {
887
- search: 'search',
888
- term: 'term',
889
- range: 'range',
890
- geo: 'geo',
891
- suggestion: 'suggestion'
892
- };
893
- var REMOVE_COMPONENT = 'REMOVE_COMPONENT';
894
- var PATCH_VALUE = 'PATCH_VALUE';
895
- var CLEAR_VALUES = 'CLEAR_VALUES';
896
- var SET_VALUE = 'SET_VALUE';
897
- var SET_VALUES = 'SET_VALUES';
898
- var RESET_TO_DEFAULT = 'RESET_TO_DEFAULT';
899
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
900
- function getDefaultExportFromCjs(x) {
901
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
902
- }
903
- var dayjs_min = {
904
- exports: {}
905
- };
906
- (function (module, exports) {
907
- !function (t, e) {
908
- module.exports = e();
909
- }(commonjsGlobal, function () {
910
- var t = 1e3,
911
- e = 6e4,
912
- n = 36e5,
913
- r = "millisecond",
914
- i = "second",
915
- s = "minute",
916
- u = "hour",
917
- a = "day",
918
- o = "week",
919
- f = "month",
920
- h = "quarter",
921
- c = "year",
922
- d = "date",
923
- l = "Invalid Date",
924
- $ = /^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,
925
- y = /\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,
926
- M = {
927
- name: "en",
928
- weekdays: "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),
929
- months: "January_February_March_April_May_June_July_August_September_October_November_December".split("_"),
930
- ordinal: function ordinal(t) {
931
- var e = ["th", "st", "nd", "rd"],
932
- n = t % 100;
933
- return "[" + t + (e[(n - 20) % 10] || e[n] || e[0]) + "]";
934
- }
935
- },
936
- m = function m(t, e, n) {
937
- var r = String(t);
938
- return !r || r.length >= e ? t : "" + Array(e + 1 - r.length).join(n) + t;
939
- },
940
- v = {
941
- s: m,
942
- z: function z(t) {
943
- var e = -t.utcOffset(),
944
- n = Math.abs(e),
945
- r = Math.floor(n / 60),
946
- i = n % 60;
947
- return (e <= 0 ? "+" : "-") + m(r, 2, "0") + ":" + m(i, 2, "0");
948
- },
949
- m: function t(e, n) {
950
- if (e.date() < n.date()) return -t(n, e);
951
- var r = 12 * (n.year() - e.year()) + (n.month() - e.month()),
952
- i = e.clone().add(r, f),
953
- s = n - i < 0,
954
- u = e.clone().add(r + (s ? -1 : 1), f);
955
- return +(-(r + (n - i) / (s ? i - u : u - i)) || 0);
956
- },
957
- a: function a(t) {
958
- return t < 0 ? Math.ceil(t) || 0 : Math.floor(t);
959
- },
960
- p: function p(t) {
961
- return {
962
- M: f,
963
- y: c,
964
- w: o,
965
- d: a,
966
- D: d,
967
- h: u,
968
- m: s,
969
- s: i,
970
- ms: r,
971
- Q: h
972
- }[t] || String(t || "").toLowerCase().replace(/s$/, "");
973
- },
974
- u: function u(t) {
975
- return void 0 === t;
976
- }
977
- },
978
- g = "en",
979
- D = {};
980
- D[g] = M;
981
- var p = function p(t) {
982
- return t instanceof _;
983
- },
984
- S = function t(e, n, r) {
985
- var i;
986
- if (!e) return g;
987
- if ("string" == typeof e) {
988
- var s = e.toLowerCase();
989
- D[s] && (i = s), n && (D[s] = n, i = s);
990
- var u = e.split("-");
991
- if (!i && u.length > 1) return t(u[0]);
992
- } else {
993
- var a = e.name;
994
- D[a] = e, i = a;
995
- }
996
- return !r && i && (g = i), i || !r && g;
997
- },
998
- w = function w(t, e) {
999
- if (p(t)) return t.clone();
1000
- var n = "object" == _typeof(e) ? e : {};
1001
- return n.date = t, n.args = arguments, new _(n);
1002
- },
1003
- O = v;
1004
- O.l = S, O.i = p, O.w = function (t, e) {
1005
- return w(t, {
1006
- locale: e.$L,
1007
- utc: e.$u,
1008
- x: e.$x,
1009
- $offset: e.$offset
1010
- });
1011
- };
1012
- var _ = function () {
1013
- function M(t) {
1014
- this.$L = S(t.locale, null, !0), this.parse(t);
1015
- }
1016
- var m = M.prototype;
1017
- return m.parse = function (t) {
1018
- this.$d = function (t) {
1019
- var e = t.date,
1020
- n = t.utc;
1021
- if (null === e) return new Date(NaN);
1022
- if (O.u(e)) return new Date();
1023
- if (e instanceof Date) return new Date(e);
1024
- if ("string" == typeof e && !/Z$/i.test(e)) {
1025
- var r = e.match($);
1026
- if (r) {
1027
- var i = r[2] - 1 || 0,
1028
- s = (r[7] || "0").substring(0, 3);
1029
- return n ? new Date(Date.UTC(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s)) : new Date(r[1], i, r[3] || 1, r[4] || 0, r[5] || 0, r[6] || 0, s);
1030
- }
1031
- }
1032
- return new Date(e);
1033
- }(t), this.$x = t.x || {}, this.init();
1034
- }, m.init = function () {
1035
- var t = this.$d;
1036
- this.$y = t.getFullYear(), this.$M = t.getMonth(), this.$D = t.getDate(), this.$W = t.getDay(), this.$H = t.getHours(), this.$m = t.getMinutes(), this.$s = t.getSeconds(), this.$ms = t.getMilliseconds();
1037
- }, m.$utils = function () {
1038
- return O;
1039
- }, m.isValid = function () {
1040
- return !(this.$d.toString() === l);
1041
- }, m.isSame = function (t, e) {
1042
- var n = w(t);
1043
- return this.startOf(e) <= n && n <= this.endOf(e);
1044
- }, m.isAfter = function (t, e) {
1045
- return w(t) < this.startOf(e);
1046
- }, m.isBefore = function (t, e) {
1047
- return this.endOf(e) < w(t);
1048
- }, m.$g = function (t, e, n) {
1049
- return O.u(t) ? this[e] : this.set(n, t);
1050
- }, m.unix = function () {
1051
- return Math.floor(this.valueOf() / 1e3);
1052
- }, m.valueOf = function () {
1053
- return this.$d.getTime();
1054
- }, m.startOf = function (t, e) {
1055
- var n = this,
1056
- r = !!O.u(e) || e,
1057
- h = O.p(t),
1058
- l = function l(t, e) {
1059
- var i = O.w(n.$u ? Date.UTC(n.$y, e, t) : new Date(n.$y, e, t), n);
1060
- return r ? i : i.endOf(a);
1061
- },
1062
- $ = function $(t, e) {
1063
- return O.w(n.toDate()[t].apply(n.toDate("s"), (r ? [0, 0, 0, 0] : [23, 59, 59, 999]).slice(e)), n);
1064
- },
1065
- y = this.$W,
1066
- M = this.$M,
1067
- m = this.$D,
1068
- v = "set" + (this.$u ? "UTC" : "");
1069
- switch (h) {
1070
- case c:
1071
- return r ? l(1, 0) : l(31, 11);
1072
- case f:
1073
- return r ? l(1, M) : l(0, M + 1);
1074
- case o:
1075
- var g = this.$locale().weekStart || 0,
1076
- D = (y < g ? y + 7 : y) - g;
1077
- return l(r ? m - D : m + (6 - D), M);
1078
- case a:
1079
- case d:
1080
- return $(v + "Hours", 0);
1081
- case u:
1082
- return $(v + "Minutes", 1);
1083
- case s:
1084
- return $(v + "Seconds", 2);
1085
- case i:
1086
- return $(v + "Milliseconds", 3);
1087
- default:
1088
- return this.clone();
1089
- }
1090
- }, m.endOf = function (t) {
1091
- return this.startOf(t, !1);
1092
- }, m.$set = function (t, e) {
1093
- var n,
1094
- o = O.p(t),
1095
- h = "set" + (this.$u ? "UTC" : ""),
1096
- l = (n = {}, n[a] = h + "Date", n[d] = h + "Date", n[f] = h + "Month", n[c] = h + "FullYear", n[u] = h + "Hours", n[s] = h + "Minutes", n[i] = h + "Seconds", n[r] = h + "Milliseconds", n)[o],
1097
- $ = o === a ? this.$D + (e - this.$W) : e;
1098
- if (o === f || o === c) {
1099
- var y = this.clone().set(d, 1);
1100
- y.$d[l]($), y.init(), this.$d = y.set(d, Math.min(this.$D, y.daysInMonth())).$d;
1101
- } else l && this.$d[l]($);
1102
- return this.init(), this;
1103
- }, m.set = function (t, e) {
1104
- return this.clone().$set(t, e);
1105
- }, m.get = function (t) {
1106
- return this[O.p(t)]();
1107
- }, m.add = function (r, h) {
1108
- var d,
1109
- l = this;
1110
- r = Number(r);
1111
- var $ = O.p(h),
1112
- y = function y(t) {
1113
- var e = w(l);
1114
- return O.w(e.date(e.date() + Math.round(t * r)), l);
1115
- };
1116
- if ($ === f) return this.set(f, this.$M + r);
1117
- if ($ === c) return this.set(c, this.$y + r);
1118
- if ($ === a) return y(1);
1119
- if ($ === o) return y(7);
1120
- var M = (d = {}, d[s] = e, d[u] = n, d[i] = t, d)[$] || 1,
1121
- m = this.$d.getTime() + r * M;
1122
- return O.w(m, this);
1123
- }, m.subtract = function (t, e) {
1124
- return this.add(-1 * t, e);
1125
- }, m.format = function (t) {
1126
- var e = this,
1127
- n = this.$locale();
1128
- if (!this.isValid()) return n.invalidDate || l;
1129
- var r = t || "YYYY-MM-DDTHH:mm:ssZ",
1130
- i = O.z(this),
1131
- s = this.$H,
1132
- u = this.$m,
1133
- a = this.$M,
1134
- o = n.weekdays,
1135
- f = n.months,
1136
- h = function h(t, n, i, s) {
1137
- return t && (t[n] || t(e, r)) || i[n].slice(0, s);
1138
- },
1139
- c = function c(t) {
1140
- return O.s(s % 12 || 12, t, "0");
1141
- },
1142
- d = n.meridiem || function (t, e, n) {
1143
- var r = t < 12 ? "AM" : "PM";
1144
- return n ? r.toLowerCase() : r;
1145
- },
1146
- $ = {
1147
- YY: String(this.$y).slice(-2),
1148
- YYYY: this.$y,
1149
- M: a + 1,
1150
- MM: O.s(a + 1, 2, "0"),
1151
- MMM: h(n.monthsShort, a, f, 3),
1152
- MMMM: h(f, a),
1153
- D: this.$D,
1154
- DD: O.s(this.$D, 2, "0"),
1155
- d: String(this.$W),
1156
- dd: h(n.weekdaysMin, this.$W, o, 2),
1157
- ddd: h(n.weekdaysShort, this.$W, o, 3),
1158
- dddd: o[this.$W],
1159
- H: String(s),
1160
- HH: O.s(s, 2, "0"),
1161
- h: c(1),
1162
- hh: c(2),
1163
- a: d(s, u, !0),
1164
- A: d(s, u, !1),
1165
- m: String(u),
1166
- mm: O.s(u, 2, "0"),
1167
- s: String(this.$s),
1168
- ss: O.s(this.$s, 2, "0"),
1169
- SSS: O.s(this.$ms, 3, "0"),
1170
- Z: i
1171
- };
1172
- return r.replace(y, function (t, e) {
1173
- return e || $[t] || i.replace(":", "");
1174
- });
1175
- }, m.utcOffset = function () {
1176
- return 15 * -Math.round(this.$d.getTimezoneOffset() / 15);
1177
- }, m.diff = function (r, d, l) {
1178
- var $,
1179
- y = O.p(d),
1180
- M = w(r),
1181
- m = (M.utcOffset() - this.utcOffset()) * e,
1182
- v = this - M,
1183
- g = O.m(this, M);
1184
- return g = ($ = {}, $[c] = g / 12, $[f] = g, $[h] = g / 3, $[o] = (v - m) / 6048e5, $[a] = (v - m) / 864e5, $[u] = v / n, $[s] = v / e, $[i] = v / t, $)[y] || v, l ? g : O.a(g);
1185
- }, m.daysInMonth = function () {
1186
- return this.endOf(f).$D;
1187
- }, m.$locale = function () {
1188
- return D[this.$L];
1189
- }, m.locale = function (t, e) {
1190
- if (!t) return this.$L;
1191
- var n = this.clone(),
1192
- r = S(t, e, !0);
1193
- return r && (n.$L = r), n;
1194
- }, m.clone = function () {
1195
- return O.w(this.$d, this);
1196
- }, m.toDate = function () {
1197
- return new Date(this.valueOf());
1198
- }, m.toJSON = function () {
1199
- return this.isValid() ? this.toISOString() : null;
1200
- }, m.toISOString = function () {
1201
- return this.$d.toISOString();
1202
- }, m.toString = function () {
1203
- return this.$d.toUTCString();
1204
- }, M;
1205
- }(),
1206
- T = _.prototype;
1207
- return w.prototype = T, [["$ms", r], ["$s", i], ["$m", s], ["$H", u], ["$W", a], ["$M", f], ["$y", c], ["$D", d]].forEach(function (t) {
1208
- T[t[1]] = function (e) {
1209
- return this.$g(e, t[0], t[1]);
1210
- };
1211
- }), w.extend = function (t, e) {
1212
- return t.$i || (t(e, _, w), t.$i = !0), w;
1213
- }, w.locale = S, w.isDayjs = p, w.unix = function (t) {
1214
- return w(1e3 * t);
1215
- }, w.en = D[g], w.Ls = D, w.p = {}, w;
1216
- });
1217
- })(dayjs_min);
1218
- var dayjs_minExports = dayjs_min.exports;
1219
- var dayjs = /*@__PURE__*/getDefaultExportFromCjs(dayjs_minExports);
1220
- var dateFormats = {
1221
- date: 'YYYY-MM-DD',
1222
- basic_date: 'YYYYMMDD',
1223
- basic_date_time: 'YYYYMMDD[T]HHmmss.SSSZ',
1224
- basic_date_time_no_millis: 'YYYYMMDD[T]HHmmssZ',
1225
- date_time_no_millis: 'YYYY-MM-DD[T]HH:mm:ssZ',
1226
- basic_time: 'HHmmss.SSSZ',
1227
- basic_time_no_millis: 'HHmmssZ',
1228
- epoch_millis: 'epoch_millis',
1229
- epoch_second: 'epoch_second'
1230
- };
1231
- var _componentTypeToDefau;
1232
- function ownKeys$3(object, enumerableOnly) {
1233
- var keys = Object.keys(object);
1234
- if (Object.getOwnPropertySymbols) {
1235
- var symbols = Object.getOwnPropertySymbols(object);
1236
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1237
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1238
- })), keys.push.apply(keys, symbols);
1239
- }
1240
- return keys;
1241
- }
1242
- function _objectSpread$3(target) {
1243
- for (var i = 1; i < arguments.length; i++) {
1244
- var source = null != arguments[i] ? arguments[i] : {};
1245
- i % 2 ? ownKeys$3(Object(source), !0).forEach(function (key) {
1246
- _defineProperty(target, key, source[key]);
1247
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$3(Object(source)).forEach(function (key) {
1248
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1249
- });
1250
- }
1251
- return target;
1252
- }
1253
- function getOperation(conjunction) {
1254
- if (conjunction === 'and') {
1255
- return 'must';
1256
- }
1257
- if (conjunction === 'or') {
1258
- return 'should';
1259
- }
1260
- return 'must_not';
1261
- }
1262
- function createBoolQuery(operation, query) {
1263
- var resultQuery = null;
1264
- if (Array.isArray(query) && query.length || !Array.isArray(query) && query) {
1265
- resultQuery = {
1266
- bool: _defineProperty({}, operation, query)
1267
- };
1268
- }
1269
- if (operation === 'should' && resultQuery) {
1270
- resultQuery = {
1271
- bool: _objectSpread$3(_objectSpread$3({}, resultQuery.bool), {}, {
1272
- minimum_should_match: 1
1273
- })
1274
- };
1275
- }
1276
- return resultQuery;
1277
- }
1278
- function getQuery(react, queryList) {
1279
- var query = [];
1280
- Object.keys(react).forEach(function (conjunction) {
1281
- if (Array.isArray(react[conjunction])) {
1282
- var operation = getOperation(conjunction);
1283
- var queryArr = react[conjunction].map(function (comp) {
1284
- if (typeof comp !== 'string') {
1285
- // in this case, we have { <conjunction>: <> } objects inside the array
1286
- return getQuery(comp, queryList);
1287
- } else if (comp in queryList) {
1288
- if (queryList[comp] && Object.keys(queryList[comp]).length) {
1289
- return queryList[comp];
1290
- }
1291
- }
1292
- return null;
1293
- }).filter(function (item) {
1294
- return !!item;
1295
- });
1296
- var boolQuery = createBoolQuery(operation, queryArr);
1297
- if (boolQuery && Object.keys(boolQuery).length) {
1298
- query = [].concat(_toConsumableArray(query), [boolQuery]);
1299
- }
1300
- } else if (typeof react[conjunction] === 'string') {
1301
- var _operation = getOperation(conjunction);
1302
- var _boolQuery = createBoolQuery(_operation, queryList[react[conjunction]]);
1303
- if (_boolQuery && Object.keys(_boolQuery).length) {
1304
- query = [].concat(_toConsumableArray(query), [_boolQuery]);
1305
- }
1306
- } else if (_typeof(react[conjunction]) === 'object' && react[conjunction] !== null) {
1307
- var _boolQuery2 = getQuery(react[conjunction], queryList);
1308
- if (_boolQuery2 && Object.keys(_boolQuery2).length) {
1309
- query = [].concat(_toConsumableArray(query), [_boolQuery2]);
1310
- }
1311
- }
1312
- });
1313
- if (Array.isArray(query) && query.length) {
1314
- return {
1315
- bool: {
1316
- must: query
1317
- }
1318
- };
1319
- }
1320
- if (query && Object.keys(query).length) {
1321
- return query;
1322
- }
1323
- return null;
1324
- }
1325
- function getExternalQueryOptions(react, options, component) {
1326
- var queryOptions = {};
1327
- Object.keys(react).forEach(function (conjunction) {
1328
- if (Array.isArray(react[conjunction])) {
1329
- react[conjunction].forEach(function (comp) {
1330
- if (options[comp]) {
1331
- queryOptions = _objectSpread$3(_objectSpread$3({}, queryOptions), options[comp]);
1332
- }
1333
- });
1334
- } else if (typeof react[conjunction] === 'string') {
1335
- if (options[react[conjunction]]) {
1336
- queryOptions = _objectSpread$3(_objectSpread$3({}, queryOptions), options[react[conjunction]]);
1337
- }
1338
- } else if (_typeof(react[conjunction]) === 'object' && react[conjunction] !== null && !Array.isArray(react[conjunction])) {
1339
- queryOptions = _objectSpread$3(_objectSpread$3({}, queryOptions), getExternalQueryOptions(react[conjunction], options));
1340
- }
1341
- });
1342
- if (options[component]) {
1343
- queryOptions = _objectSpread$3(_objectSpread$3({}, queryOptions), options[component]);
1344
- }
1345
- return queryOptions;
1346
- }
1347
- function buildQuery(component, dependencyTree, queryList, queryOptions) {
1348
- var queryObj = null;
1349
- var options = null;
1350
- if (component in dependencyTree) {
1351
- queryObj = getQuery(dependencyTree[component], queryList);
1352
- options = getExternalQueryOptions(dependencyTree[component], queryOptions, component);
1353
- }
1354
- return {
1355
- queryObj: queryObj,
1356
- options: options
1357
- };
1358
- }
1359
- function formatDate(date, props) {
1360
- if (props.parseDate) {
1361
- // We would be passing an instance of dayjs instead of xdate below. Users need to know.
1362
- return props.parseDate(date, props);
1363
- }
1364
- switch (props.queryFormat) {
1365
- case 'epoch_millis':
1366
- return date.valueOf();
1367
- case 'epoch_second':
1368
- return Math.floor(date.valueOf() / 1000);
1369
- default:
1370
- {
1371
- if (dateFormats[props.queryFormat]) {
1372
- return date.format(dateFormats[props.queryFormat]);
1373
- }
1374
- return date.valueOf();
1375
- }
1376
- }
1377
- }
1378
- _componentTypeToDefau = {}, _defineProperty(_componentTypeToDefau, componentTypes.singleList, ''), _defineProperty(_componentTypeToDefau, componentTypes.multiList, []), _defineProperty(_componentTypeToDefau, componentTypes.singleDataList, ''), _defineProperty(_componentTypeToDefau, componentTypes.singleDropdownList, ''), _defineProperty(_componentTypeToDefau, componentTypes.multiDataList, []), _defineProperty(_componentTypeToDefau, componentTypes.multiDropdownList, []), _defineProperty(_componentTypeToDefau, componentTypes.tagCloud, ''), _defineProperty(_componentTypeToDefau, componentTypes.toggleButton, ''), _defineProperty(_componentTypeToDefau, componentTypes.singleDropdownRange, ''), _defineProperty(_componentTypeToDefau, componentTypes.multiDropdownRange, []), _defineProperty(_componentTypeToDefau, componentTypes.singleRange, ''), _defineProperty(_componentTypeToDefau, componentTypes.multiRange, []), _componentTypeToDefau;
1379
-
1380
- /* isValidDateRangeQueryFormat() checks if the queryFormat is one of the dateFormats
1381
- accepted by the elasticsearch or not. */
1382
- function isValidDateRangeQueryFormat(queryFormat) {
1383
- return Object.keys(dateFormats).includes(queryFormat);
1384
- }
1385
- var _componentToTypeMap;
1386
- function ownKeys$2(object, enumerableOnly) {
1387
- var keys = Object.keys(object);
1388
- if (Object.getOwnPropertySymbols) {
1389
- var symbols = Object.getOwnPropertySymbols(object);
1390
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1391
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1392
- })), keys.push.apply(keys, symbols);
1393
- }
1394
- return keys;
1395
- }
1396
- function _objectSpread$2(target) {
1397
- for (var i = 1; i < arguments.length; i++) {
1398
- var source = null != arguments[i] ? arguments[i] : {};
1399
- i % 2 ? ownKeys$2(Object(source), !0).forEach(function (key) {
1400
- _defineProperty(target, key, source[key]);
1401
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$2(Object(source)).forEach(function (key) {
1402
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1403
- });
1404
- }
1405
- return target;
1406
- }
1407
- var componentToTypeMap = (_componentToTypeMap = {}, _defineProperty(_componentToTypeMap, componentTypes.reactiveList, queryTypes.search), _defineProperty(_componentToTypeMap, componentTypes.dataSearch, queryTypes.search), _defineProperty(_componentToTypeMap, componentTypes.categorySearch, queryTypes.search), _defineProperty(_componentToTypeMap, componentTypes.searchBox, queryTypes.suggestion), _defineProperty(_componentToTypeMap, componentTypes.singleList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.multiList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.singleDataList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.singleDropdownList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.multiDataList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.multiDropdownList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.tagCloud, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.toggleButton, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.reactiveChart, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.treeList, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.numberBox, queryTypes.term), _defineProperty(_componentToTypeMap, componentTypes.datePicker, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.dateRange, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.dynamicRangeSlider, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.singleDropdownRange, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.multiDropdownRange, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.singleRange, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.multiRange, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.rangeSlider, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.ratingsFilter, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.rangeInput, queryTypes.range), _defineProperty(_componentToTypeMap, componentTypes.geoDistanceDropdown, queryTypes.geo), _defineProperty(_componentToTypeMap, componentTypes.geoDistanceSlider, queryTypes.geo), _defineProperty(_componentToTypeMap, componentTypes.reactiveMap, queryTypes.geo), _componentToTypeMap);
1408
- var multiRangeComponents = [componentTypes.multiRange, componentTypes.multiDropdownRange];
1409
- var dateRangeComponents = [componentTypes.dateRange, componentTypes.datePicker];
1410
- var searchComponents = [componentTypes.categorySearch, componentTypes.dataSearch, componentTypes.searchBox];
1411
- var listComponentsWithPagination = [componentTypes.singleList, componentTypes.multiList, componentTypes.singleDropdownList, componentTypes.multiDropdownList];
1412
- var getNormalizedField = function getNormalizedField(field) {
1413
- if (field && !Array.isArray(field)) {
1414
- return [field];
1415
- }
1416
- return field;
1417
- };
1418
- var isInternalComponent = function isInternalComponent() {
1419
- var componentID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1420
- return componentID.endsWith('__internal');
1421
- };
1422
- var getInternalComponentID = function getInternalComponentID() {
1423
- var componentID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1424
- return "".concat(componentID, "__internal");
1425
- };
1426
- var getHistogramComponentID = function getHistogramComponentID() {
1427
- var componentID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1428
- return "".concat(componentID, "__histogram__internal");
1429
- };
1430
- var isDRSRangeComponent = function isDRSRangeComponent() {
1431
- var componentID = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1432
- return componentID.endsWith('__range__internal');
1433
- };
1434
- var isSearchComponent = function isSearchComponent() {
1435
- var componentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1436
- return searchComponents.includes(componentType);
1437
- };
1438
- var isComponentUsesLabelAsValue = function isComponentUsesLabelAsValue() {
1439
- var componentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1440
- return componentType === componentTypes.multiDataList || componentType === componentTypes.singleDataList || componentType === componentTypes.tabDataList;
1441
- };
1442
- var hasPaginationSupport = function hasPaginationSupport() {
1443
- var componentType = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
1444
- return listComponentsWithPagination.includes(componentType);
1445
- };
1446
- var getRSQuery = function getRSQuery(componentId, props) {
1447
- var execute = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
1448
- if (props && componentId) {
1449
- var queryType = props.type ? props.type : componentToTypeMap[props.componentType];
1450
- // dataField is a required field for components other than search
1451
- // TODO: Revisit this logic based on the Appbase version
1452
- // dataField is no longer a required field in RS API
1453
- if (!isSearchComponent(props.componentType) && !props.dataField) {
1454
- return null;
1455
- }
1456
- var endpoint;
1457
- if (props.endpoint instanceof Object) {
1458
- endpoint = props.endpoint;
1459
- }
1460
- return _objectSpread$2(_objectSpread$2({
1461
- id: componentId,
1462
- type: queryType || queryTypes.search,
1463
- dataField: getNormalizedField(props.dataField),
1464
- execute: execute,
1465
- react: props.react,
1466
- highlight: props.highlight,
1467
- highlightField: getNormalizedField(props.highlightField),
1468
- fuzziness: props.fuzziness,
1469
- searchOperators: props.searchOperators,
1470
- includeFields: props.includeFields,
1471
- excludeFields: props.excludeFields,
1472
- size: props.size,
1473
- aggregationSize: props.aggregationSize,
1474
- from: props.from || undefined,
1475
- // Need to maintain for RL
1476
- queryFormat: props.queryFormat,
1477
- sortBy: props.sortBy,
1478
- fieldWeights: getNormalizedField(props.fieldWeights),
1479
- includeNullValues: props.includeNullValues,
1480
- aggregationField: props.aggregationField || undefined,
1481
- categoryField: props.categoryField || undefined,
1482
- missingLabel: props.missingLabel || undefined,
1483
- showMissing: props.showMissing,
1484
- nestedField: props.nestedField || undefined,
1485
- interval: props.interval,
1486
- highlightConfig: props.customHighlight || props.highlightConfig,
1487
- customQuery: props.customQuery,
1488
- defaultQuery: props.defaultQuery,
1489
- value: props.value,
1490
- categoryValue: props.categoryValue || undefined,
1491
- after: props.after || undefined,
1492
- aggregations: props.aggregations || undefined,
1493
- enableSynonyms: props.enableSynonyms,
1494
- selectAllLabel: props.selectAllLabel,
1495
- pagination: props.pagination,
1496
- queryString: props.queryString,
1497
- distinctField: props.distinctField,
1498
- distinctFieldConfig: props.distinctFieldConfig,
1499
- index: props.index
1500
- }, queryType === queryTypes.suggestion ? _objectSpread$2({
1501
- enablePopularSuggestions: props.enablePopularSuggestions,
1502
- enableEndpointSuggestions: props.enableEndpointSuggestions,
1503
- enableRecentSuggestions: props.enableRecentSuggestions,
1504
- popularSuggestionsConfig: props.popularSuggestionsConfig,
1505
- recentSuggestionsConfig: props.recentSuggestionsConfig,
1506
- applyStopwords: props.applyStopwords,
1507
- customStopwords: props.customStopwords,
1508
- enablePredictiveSuggestions: props.enablePredictiveSuggestions,
1509
- featuredSuggestionsConfig: props.featuredSuggestionsConfig,
1510
- indexSuggestionsConfig: props.indexSuggestionsConfig,
1511
- enableFeaturedSuggestions: props.enableFeaturedSuggestions,
1512
- enableIndexSuggestions: props.enableIndexSuggestions
1513
- }, props.searchboxId ? {
1514
- searchboxId: props.searchboxId
1515
- } : {}) : {}), {}, {
1516
- calendarInterval: props.calendarInterval,
1517
- endpoint: endpoint,
1518
- range: props.range
1519
- });
1520
- }
1521
- return null;
1522
- };
1523
- var extractPropsFromState = function extractPropsFromState(store, component, customOptions) {
1524
- var componentProps = store.props[component];
1525
- if (!componentProps) {
1526
- return null;
1527
- }
1528
- var queryType = componentProps.type ? componentProps.type : componentToTypeMap[componentProps.componentType];
1529
- var calcValues = store.selectedValues[component];
1530
- var value = calcValues !== undefined && calcValues !== null ? calcValues.value : undefined;
1531
- var queryFormat = componentProps.queryFormat;
1532
- // calendarInterval only supported when using date types
1533
- var calendarInterval;
1534
- var interval = componentProps.interval;
1535
- var type = queryType;
1536
- var dataField = componentProps.dataField;
1537
- var aggregations = componentProps.aggregations;
1538
- var pagination; // pagination for `term` type of queries
1539
- var from = componentProps.from; // offset for RL
1540
- var range; // applicable for range components supporting histogram
1541
-
1542
- // For term queries i.e list component `dataField` will be treated as aggregationField
1543
- if (queryType === queryTypes.term) {
1544
- // Only apply pagination prop for the components which supports it otherwise it can break the UI
1545
- if (componentProps.showLoadMore && hasPaginationSupport(componentProps.componentType)) {
1546
- pagination = true;
1547
- }
1548
- // Extract values from components that are type of objects
1549
- // This code handles the controlled behavior in list components for e.g ToggleButton
1550
- if (value != null && _typeof(value) === 'object' && value.value) {
1551
- value = value.value;
1552
- } else if (Array.isArray(value)) {
1553
- var parsedValue = [];
1554
- value.forEach(function (val) {
1555
- if (val != null && _typeof(val) === 'object' && val.value) {
1556
- parsedValue.push(val.value);
1557
- } else {
1558
- parsedValue.push(val);
1559
- }
1560
- });
1561
- value = parsedValue;
1562
- }
1563
- }
1564
- if (queryType === queryTypes.range) {
1565
- if (Array.isArray(value)) {
1566
- if (multiRangeComponents.includes(componentProps.componentType)) {
1567
- value = value.map(function (_ref) {
1568
- var start = _ref.start,
1569
- end = _ref.end;
1570
- return {
1571
- start: start,
1572
- end: end
1573
- };
1574
- });
1575
- } else {
1576
- value = {
1577
- start: value[0],
1578
- end: value[1]
1579
- };
1580
- }
1581
- } else if (componentProps.showHistogram) {
1582
- var internalComponentID = getInternalComponentID(component);
1583
- var internalComponentValue = store.internalValues[internalComponentID];
1584
- if (!internalComponentValue) {
1585
- // Handle dynamic range slider
1586
- var histogramComponentID = getHistogramComponentID(component);
1587
- internalComponentValue = store.internalValues[histogramComponentID];
1588
- }
1589
- if (internalComponentValue && Array.isArray(internalComponentValue.value)) {
1590
- value = {
1591
- start: internalComponentValue.value[0],
1592
- end: internalComponentValue.value[1]
1593
- };
1594
- }
1595
- }
1596
- if (isDRSRangeComponent(component)) {
1597
- aggregations = ['min', 'max'];
1598
- } else if (componentProps.showHistogram) {
1599
- aggregations = ['histogram'];
1600
- }
1601
-
1602
- // handle number box, number box query changes based on the `queryFormat` value
1603
- if (componentProps.componentType === componentTypes.dynamicRangeSlider || componentProps.componentType === componentTypes.rangeSlider) {
1604
- calendarInterval = Object.keys(dateFormats).includes(queryFormat) ? componentProps.calendarInterval : undefined;
1605
-
1606
- // Set value
1607
- if (value) {
1608
- if (isValidDateRangeQueryFormat(componentProps.queryFormat)) {
1609
- // check if date types are dealt with
1610
- value = {
1611
- start: formatDate(dayjs(new Date(value.start)), componentProps),
1612
- end: formatDate(dayjs(new Date(value.end)), componentProps)
1613
- };
1614
- } else {
1615
- value = {
1616
- start: parseFloat(value.start),
1617
- end: parseFloat(value.end)
1618
- };
1619
- }
1620
- }
1621
- var rangeValue;
1622
- if (componentProps.componentType === componentTypes.dynamicRangeSlider) {
1623
- rangeValue = store.aggregations["".concat(component, "__range__internal")];
1624
- if (componentProps.nestedField) {
1625
- rangeValue = rangeValue && store.aggregations["".concat(component, "__range__internal")][componentProps.nestedField].min ? {
1626
- start: store.aggregations["".concat(component, "__range__internal")][componentProps.nestedField].min.value,
1627
- end: store.aggregations["".concat(component, "__range__internal")][componentProps.nestedField].max.value
1628
- } // prettier-ignore
1629
- : null;
1630
- } else {
1631
- rangeValue = rangeValue && store.aggregations["".concat(component, "__range__internal")].min && store.aggregations["".concat(component, "__range__internal")].min.value ? {
1632
- start: store.aggregations["".concat(component, "__range__internal")].min.value,
1633
- end: store.aggregations["".concat(component, "__range__internal")].max.value
1634
- } // prettier-ignore
1635
- : null;
1636
- }
1637
- } else {
1638
- rangeValue = componentProps.range;
1639
- }
1640
- if (rangeValue) {
1641
- if (isValidDateRangeQueryFormat(componentProps.queryFormat)) {
1642
- // check if date types are dealt with
1643
- range = {
1644
- start: formatDate(dayjs(rangeValue.start), componentProps),
1645
- end: formatDate(dayjs(rangeValue.end), componentProps)
1646
- };
1647
- } else {
1648
- range = {
1649
- start: parseFloat(rangeValue.start),
1650
- end: parseFloat(rangeValue.end)
1651
- };
1652
- }
1653
- }
1654
- }
1655
-
1656
- // handle date components
1657
- if (dateRangeComponents.includes(componentProps.componentType)) {
1658
- // Set value
1659
- if (value) {
1660
- if (isValidDateRangeQueryFormat(componentProps.queryFormat)) {
1661
- if (typeof value === 'string') {
1662
- value = {
1663
- // value would be an ISO Date string
1664
- start: formatDate(dayjs(value).subtract(24, 'hour'), componentProps),
1665
- end: formatDate(dayjs(value), componentProps)
1666
- };
1667
- } else if (Array.isArray(value)) {
1668
- value = value.map(function (val) {
1669
- return {
1670
- // value would be one of ISO Date string, number, native date
1671
- start: formatDate(dayjs(val).subtract(24, 'hour'), componentProps),
1672
- end: formatDate(dayjs(val), componentProps)
1673
- };
1674
- });
1675
- } else {
1676
- value = {
1677
- start: formatDate(dayjs(value.start).subtract(24, 'hour'), componentProps),
1678
- end: formatDate(dayjs(value.end), componentProps)
1679
- };
1680
- }
1681
- }
1682
- }
1683
- }
1684
- }
1685
- if (queryType === queryTypes.geo) {
1686
- // override the value extracted from selectedValues reducer
1687
- value = undefined;
1688
- var geoCalcValues = store.selectedValues[component] || store.internalValues[component] || store.internalValues[getInternalComponentID(component)];
1689
- if (geoCalcValues && geoCalcValues.meta) {
1690
- if (geoCalcValues.meta.distance && geoCalcValues.meta.coordinates) {
1691
- value = {
1692
- distance: geoCalcValues.meta.distance,
1693
- location: geoCalcValues.meta.coordinates
1694
- };
1695
- if (componentProps.unit) {
1696
- value.unit = componentProps.unit;
1697
- }
1698
- }
1699
- if (geoCalcValues.meta.mapBoxBounds && geoCalcValues.meta.mapBoxBounds.top_left && geoCalcValues.meta.mapBoxBounds.bottom_right) {
1700
- value = {
1701
- // Note: format will be reverse of what we're using now
1702
- geoBoundingBox: {
1703
- topLeft: "".concat(geoCalcValues.meta.mapBoxBounds.top_left[1], ", ").concat(geoCalcValues.meta.mapBoxBounds.top_left[0]),
1704
- bottomRight: "".concat(geoCalcValues.meta.mapBoxBounds.bottom_right[1], ", ").concat(geoCalcValues.meta.mapBoxBounds.bottom_right[0])
1705
- }
1706
- };
1707
- }
1708
- }
1709
- }
1710
- // handle number box, number box query changes based on the `queryFormat` value
1711
- if (componentProps.componentType === componentTypes.numberBox) {
1712
- if (queryFormat === 'exact') {
1713
- type = 'term';
1714
- } else {
1715
- type = 'range';
1716
- if (queryFormat === 'lte') {
1717
- value = {
1718
- end: value,
1719
- boost: 2.0
1720
- };
1721
- } else {
1722
- value = {
1723
- start: value,
1724
- boost: 2.0
1725
- };
1726
- }
1727
- }
1728
- // Remove query format
1729
- queryFormat = 'or';
1730
- }
1731
- // Fake dataField for ReactiveComponent
1732
- // TODO: Remove it after some time. The `dataField` is no longer required
1733
- if (componentProps.componentType === componentTypes.reactiveComponent) {
1734
- // Set the type to `term`
1735
- type = 'term';
1736
- dataField = 'reactive_component_field';
1737
- // Don't set value property for ReactiveComponent
1738
- // since it is driven by `defaultQuery` and `customQuery`
1739
- value = undefined;
1740
- }
1741
- // Assign default value as an empty string for search components so search relevancy can work
1742
- if (isSearchComponent(componentProps.componentType) && !value) {
1743
- value = '';
1744
- }
1745
-
1746
- // Handle components which uses label instead of value as the selected value
1747
- if (isComponentUsesLabelAsValue(componentProps.componentType)) {
1748
- var data = componentProps.data,
1749
- selectAllLabel = componentProps.selectAllLabel;
1750
- var absValue = [];
1751
- if (value && Array.isArray(value)) {
1752
- absValue = value;
1753
- } else if (value && typeof value === 'string') {
1754
- absValue = [value];
1755
- }
1756
- var normalizedValue = [];
1757
- if (absValue.length) {
1758
- if (data && Array.isArray(data)) {
1759
- absValue.forEach(function (val) {
1760
- var dataItem = data.find(function (o) {
1761
- return o.label === val;
1762
- });
1763
- if (dataItem && dataItem.value) {
1764
- normalizedValue.push(dataItem.value);
1765
- }
1766
- });
1767
- }
1768
- }
1769
- if (selectAllLabel && absValue.length && absValue.includes(selectAllLabel)) {
1770
- normalizedValue = absValue;
1771
- }
1772
- if (normalizedValue.length) {
1773
- value = normalizedValue;
1774
- } else {
1775
- value = undefined;
1776
- }
1777
- }
1778
- if (componentProps.componentType === componentTypes.reactiveList) {
1779
- // We set selected page as the value in the redux store for RL.
1780
- // It's complex to change this logic in the component so changed it here.
1781
- if (value > 0) {
1782
- from = (value - 1) * (componentProps.size || 10);
1783
- }
1784
- value = undefined;
1785
- }
1786
- var queryValue = value || undefined;
1787
- if (componentProps.componentType === componentTypes.searchBox) {
1788
- if (Array.isArray(queryValue)) {
1789
- queryValue = undefined;
1790
- }
1791
- }
1792
- var endpoint;
1793
- if (componentProps.endpoint instanceof Object) {
1794
- endpoint = _objectSpread$2(_objectSpread$2({}, endpoint || {}), componentProps.endpoint);
1795
- }
1796
- return _objectSpread$2(_objectSpread$2({}, componentProps), {}, {
1797
- endpoint: endpoint,
1798
- calendarInterval: calendarInterval,
1799
- dataField: dataField,
1800
- queryFormat: queryFormat,
1801
- type: type,
1802
- aggregations: aggregations,
1803
- interval: interval,
1804
- react: store.dependencyTree ? store.dependencyTree[component] : undefined,
1805
- customQuery: store.customQueries ? store.customQueries[component] : undefined,
1806
- defaultQuery: store.defaultQueries ? store.defaultQueries[component] : undefined,
1807
- customHighlight: store.customHighlightOptions ? store.customHighlightOptions[component] : undefined,
1808
- categoryValue: store.internalValues[component] ? store.internalValues[component].category : undefined,
1809
- value: queryValue,
1810
- pagination: pagination,
1811
- from: from,
1812
- range: range
1813
- }, customOptions);
1814
- };
1815
- function flatReactProp(reactProp, componentID) {
1816
- var flattenReact = [];
1817
- var flatReact = function flatReact(react) {
1818
- if (react && Object.keys(react)) {
1819
- Object.keys(react).forEach(function (r) {
1820
- if (react[r]) {
1821
- if (typeof react[r] === 'string') {
1822
- flattenReact = [].concat(_toConsumableArray(flattenReact), [react[r]]);
1823
- } else if (Array.isArray(react[r])) {
1824
- flattenReact = [].concat(_toConsumableArray(flattenReact), _toConsumableArray(react[r]));
1825
- } else if (_typeof(react[r]) === 'object') {
1826
- flatReact(react[r]);
1827
- }
1828
- }
1829
- });
1830
- }
1831
- };
1832
- flatReact(reactProp);
1833
- // Remove cyclic dependencies
1834
- flattenReact = flattenReact.filter(function (react) {
1835
- return react !== componentID;
1836
- });
1837
- return flattenReact;
1838
- }
1839
- var getDependentQueries = function getDependentQueries(store, componentID) {
1840
- var orderOfQueries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
1841
- var finalQuery = {};
1842
- var react = flatReactProp(store.dependencyTree[componentID], componentID);
1843
- react.forEach(function (componentObject) {
1844
- var component = componentObject;
1845
- var customQuery = store.customQueries[component];
1846
- if (!isInternalComponent(component)) {
1847
- var calcValues = store.selectedValues[component] || store.internalValues[component];
1848
- // Only include queries for that component that has `customQuery` or `value` defined
1849
- if ((calcValues && calcValues.value || customQuery) && !finalQuery[component]) {
1850
- var execute = false;
1851
- if (Array.isArray(orderOfQueries) && orderOfQueries.includes(component)) {
1852
- execute = true;
1853
- }
1854
- var componentProps = store.props[component];
1855
- // build query
1856
- var dependentQuery = getRSQuery(component, extractPropsFromState(store, component, _objectSpread$2({}, componentProps && _objectSpread$2(_objectSpread$2({}, componentProps.componentType === componentTypes.searchBox ? _objectSpread$2(_objectSpread$2(_objectSpread$2({}, execute === false ? {
1857
- type: queryTypes.search
1858
- } : {}), calcValues.category ? {
1859
- categoryValue: calcValues.category
1860
- } : {
1861
- categoryValue: undefined
1862
- }), calcValues.value ? {
1863
- value: calcValues.value
1864
- } : {}) : {}), componentProps.componentType === componentTypes.categorySearch ? _objectSpread$2({}, calcValues.category ? {
1865
- categoryValue: calcValues.category
1866
- } : {
1867
- categoryValue: undefined
1868
- }) : {}))), execute);
1869
- if (dependentQuery) {
1870
- finalQuery[component] = dependentQuery;
1871
- }
1872
- }
1873
- }
1874
- });
1875
- return finalQuery;
1876
- };
1877
- var handleTransformResponse = function handleTransformResponse() {
1878
- var res = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1879
- var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1880
- var component = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
1881
- if (config.transformResponse && typeof config.transformResponse === 'function') {
1882
- return config.transformResponse(res, component);
1883
- }
1884
- return new Promise(function (resolve) {
1885
- return resolve(res);
1886
- });
1887
- };
1888
- var isPropertyDefined = function isPropertyDefined(property) {
1889
- return property !== undefined && property !== null;
1890
- };
1891
- var _excluded$1 = ["value"];
1892
- function _toPropertyKey(arg) {
1893
- var key = _toPrimitive(arg, "string");
1894
- return _typeof(key) === "symbol" ? key : String(key);
1895
- }
1896
- function _toPrimitive(input, hint) {
1897
- if (_typeof(input) !== "object" || input === null) return input;
1898
- var prim = input[Symbol.toPrimitive];
1899
- if (prim !== undefined) {
1900
- var res = prim.call(input, hint || "default");
1901
- if (_typeof(res) !== "object") return res;
1902
- throw new TypeError("@@toPrimitive must return a primitive value.");
1903
- }
1904
- return (hint === "string" ? String : Number)(input);
1905
- }
1906
- function ownKeys$1(object, enumerableOnly) {
1907
- var keys = Object.keys(object);
1908
- if (Object.getOwnPropertySymbols) {
1909
- var symbols = Object.getOwnPropertySymbols(object);
1910
- enumerableOnly && (symbols = symbols.filter(function (sym) {
1911
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
1912
- })), keys.push.apply(keys, symbols);
1913
- }
1914
- return keys;
1915
- }
1916
- function _objectSpread$1(target) {
1917
- for (var i = 1; i < arguments.length; i++) {
1918
- var source = null != arguments[i] ? arguments[i] : {};
1919
- i % 2 ? ownKeys$1(Object(source), !0).forEach(function (key) {
1920
- _defineProperty(target, key, source[key]);
1921
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys$1(Object(source)).forEach(function (key) {
1922
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
1923
- });
1924
- }
1925
- return target;
1926
- }
1927
- function valueReducer() {
1928
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1929
- var action = arguments.length > 1 ? arguments[1] : undefined;
1930
- switch (action.type) {
1931
- case SET_VALUE:
1932
- {
1933
- var newState = {};
1934
- Object.keys(action.componentsToReset || {}).forEach(function (id) {
1935
- newState[id] = _objectSpread$1(_objectSpread$1({}, state[id]), {}, {
1936
- value: action.componentsToReset[id]
1937
- });
1938
- });
1939
- return _objectSpread$1(_objectSpread$1(_objectSpread$1({}, state), newState), {}, _defineProperty({}, action.component, {
1940
- value: action.value,
1941
- label: action.label || action.component,
1942
- showFilter: action.showFilter,
1943
- URLParams: action.URLParams,
1944
- componentType: action.componentType,
1945
- category: action.category,
1946
- meta: action.meta,
1947
- reference: action.reference
1948
- }));
1949
- }
1950
- case SET_VALUES:
1951
- {
1952
- var componentKeys = action.componentsValues ? Object.keys(action.componentsValues) : [];
1953
- if (componentKeys.length) {
1954
- var _newState = {};
1955
- componentKeys.forEach(function (component) {
1956
- var _action$componentsVal = action.componentsValues[component],
1957
- value = _action$componentsVal.value,
1958
- rest = _objectWithoutProperties(_action$componentsVal, _excluded$1);
1959
- _newState[component] = _objectSpread$1(_objectSpread$1({}, state[component]), {}, {
1960
- value: value
1961
- }, rest);
1962
- });
1963
- return _objectSpread$1(_objectSpread$1({}, state), _newState);
1964
- }
1965
- return state;
1966
- }
1967
- case PATCH_VALUE:
1968
- return _objectSpread$1(_objectSpread$1({}, state), {}, _defineProperty({}, action.component, _objectSpread$1(_objectSpread$1({}, state[action.component]), action.payload)));
1969
- case CLEAR_VALUES:
1970
- {
1971
- var nextState = {};
1972
- if (action.resetValues) {
1973
- Object.keys(action.resetValues).forEach(function (componentId) {
1974
- nextState[componentId] = _objectSpread$1(_objectSpread$1({}, state[componentId]), {}, {
1975
- value: action.resetValues[componentId]
1976
- });
1977
- });
1978
- }
1979
- // clearAllBlacklistComponents has more priority over reset values
1980
- if (Array.isArray(action.clearAllBlacklistComponents)) {
1981
- Object.keys(state).forEach(function (componentId) {
1982
- if (action.clearAllBlacklistComponents.includes(componentId)) {
1983
- nextState[componentId] = state[componentId];
1984
- }
1985
- });
1986
- }
1987
- return nextState;
1988
- }
1989
- case REMOVE_COMPONENT:
1990
- {
1991
- var _action$component = action.component;
1992
- state[_action$component];
1993
- var obj = _objectWithoutProperties(state, [_action$component].map(_toPropertyKey));
1994
- return obj;
1995
- }
1996
- case RESET_TO_DEFAULT:
1997
- return _objectSpread$1(_objectSpread$1({}, state), action.defaultValues);
1998
- default:
1999
- return state;
2000
- }
2001
- }
2002
- var _excluded = ["value"];
2003
- function ownKeys(object, enumerableOnly) {
2004
- var keys = Object.keys(object);
2005
- if (Object.getOwnPropertySymbols) {
2006
- var symbols = Object.getOwnPropertySymbols(object);
2007
- enumerableOnly && (symbols = symbols.filter(function (sym) {
2008
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
2009
- })), keys.push.apply(keys, symbols);
2010
- }
2011
- return keys;
2012
- }
2013
- function _objectSpread(target) {
2014
- for (var i = 1; i < arguments.length; i++) {
2015
- var source = null != arguments[i] ? arguments[i] : {};
2016
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
2017
- _defineProperty(target, key, source[key]);
2018
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
2019
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
2020
- });
2021
- }
2022
- return target;
2023
- }
2024
- function getValue(state, id, defaultValue) {
2025
- if (state && state[id]) {
2026
- try {
2027
- // parsing for next.js - since it uses extra set of quotes to wrap params
2028
- var parsedValue = JSON.parse(state[id]);
2029
- return _objectSpread(_objectSpread({}, _typeof(parsedValue) === 'object' && parsedValue.value ? _objectSpread({
2030
- value: parsedValue.value
2031
- }, parsedValue.category ? {
2032
- category: parsedValue.category
2033
- } : {}) : {
2034
- value: parsedValue
2035
- }), {}, {
2036
- reference: 'URL'
2037
- });
2038
- } catch (error) {
2039
- // using react-dom-server for ssr
2040
- return {
2041
- value: state[id],
2042
- reference: 'URL'
2043
- };
2044
- }
2045
- }
2046
- return {
2047
- value: defaultValue,
2048
- reference: 'DEFAULT'
2049
- };
2050
- }
2051
-
2052
- // parse query string
2053
- // ref: https://stackoverflow.com/a/13896633/10822996
2054
- function parseQuery(str) {
2055
- if (str instanceof Object) {
2056
- return str;
2057
- }
2058
- if (typeof str !== 'string' || str.length === 0) return {};
2059
- var s;
2060
- if (str.split('/?')[1]) {
2061
- s = str.split('/?')[1].split('&');
2062
- }
2063
- if (str.split('?')[1]) {
2064
- s = str.split('?')[1].split('&');
2065
- }
2066
- if (!s) return {};
2067
- var sLength = s.length;
2068
- var bit;
2069
- var query = {};
2070
- var first;
2071
- var second;
2072
- for (var i = 0; i < sLength; i += 1) {
2073
- bit = s[i].split('=');
2074
- first = decodeURIComponent(bit[0]);
2075
- // eslint-disable-next-line no-continue
2076
- if (first.length === 0) continue;
2077
- second = decodeURIComponent(bit[1]);
2078
- if (typeof query[first] === 'undefined') query[first] = second;else if (query[first] instanceof Array) query[first].push(second);else query[first] = [query[first], second];
2079
- }
2080
- return query;
2081
- }
2082
- var getServerResults = function getServerResults() {
2083
- var storeReference = null;
2084
- return function (App) {
2085
- var queryString = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
2086
- var ssrRenderFunc = arguments.length > 2 ? arguments[2] : undefined;
2087
- try {
2088
- // parse the query String to respect url params in SSR
2089
- var parsedQueryString = parseQuery(queryString);
2090
- if (!storeReference) {
2091
- var newSelectedValues = {};
2092
- // callback function to collect SearchBase context
2093
- var contextCollector = function contextCollector(params) {
2094
- if (params.ctx) {
2095
- // store collected
2096
- storeReference = params.ctx;
2097
-
2098
- // collect selected values from the URL query string
2099
- Object.keys(parsedQueryString).forEach(function (componentId) {
2100
- var _getValue = getValue(parsedQueryString, componentId, null),
2101
- value = _getValue.value,
2102
- reference = _getValue.reference;
2103
- if (value) {
2104
- newSelectedValues = valueReducer(newSelectedValues, {
2105
- type: 'PATCH_VALUE',
2106
- component: componentId,
2107
- payload: {
2108
- value: value,
2109
- reference: reference
2110
- }
2111
- });
2112
- }
2113
- });
2114
- }
2115
- return {
2116
- // send back to ReactiveBase to hydrate the store with values from queryParams(if present)
2117
- selectedValues: newSelectedValues
2118
- };
2119
- };
2120
-
2121
- // render the app server-side to collect context and build initial state
2122
- // for hydration on client side
2123
- // in case of React, ssrRenderFunc === renderToString || renderToStaticMarkup
2124
- // in case of Vue, ssrRenderFunc === renderToString (import { renderToString } from 'vue/server-renderer')
2125
- var output = ssrRenderFunc(App({
2126
- contextCollector: contextCollector
2127
- }));
2128
- var promiseFunc;
2129
- if (!output.then) {
2130
- promiseFunc = Promise.resolve(promiseFunc);
2131
- } else {
2132
- promiseFunc = output;
2133
- }
2134
- return promiseFunc.then(function () {
2135
- if (storeReference) {
2136
- var extractedState = storeReference.getState();
2137
- var components = extractedState.components,
2138
- config = extractedState.config,
2139
- appbaseRef = extractedState.appbaseRef,
2140
- queryOptions = extractedState.queryOptions,
2141
- internalValues = extractedState.internalValues,
2142
- props = extractedState.props,
2143
- queryList = extractedState.queryList,
2144
- dependencyTree = extractedState.dependencyTree;
2145
- var queryLog = extractedState.queryLog;
2146
- var finalQuery = [];
2147
- var appbaseQuery = {}; // Use object to prevent duplicate query added by react prop
2148
- var orderOfQueries = [];
2149
- var hits = {};
2150
- var aggregations = {};
2151
- var state = _objectSpread({}, extractedState);
2152
-
2153
- // Generate finalQuery for search
2154
- components.filter(function (t) {
2155
- return !t.endsWith('__internal');
2156
- }).forEach(function (componentId) {
2157
- // eslint-disable-next-line
2158
- var _buildQuery = buildQuery(componentId, dependencyTree, queryList, queryOptions),
2159
- queryObj = _buildQuery.queryObj,
2160
- options = _buildQuery.options;
2161
- if (!queryObj && !options) {
2162
- return;
2163
- }
2164
- var query = getRSQuery(componentId, extractPropsFromState(state, componentId, queryOptions && queryOptions[componentId] ? {
2165
- from: queryOptions[componentId].from
2166
- } : null));
2167
-
2168
- // check if query or options are valid - non-empty
2169
- if (query && !!Object.keys(query).length) {
2170
- var currentQuery = query;
2171
- var dependentQueries = getDependentQueries(state, componentId, orderOfQueries);
2172
- var queryToLog = _objectSpread(_objectSpread({}, _defineProperty({}, componentId, currentQuery)), Object.keys(dependentQueries).reduce(function (acc, q) {
2173
- return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, q, _objectSpread(_objectSpread({}, dependentQueries[q]), {}, {
2174
- execute: false
2175
- }, dependentQueries[q].type === queryTypes.suggestion ? {
2176
- type: 'search'
2177
- } : {})));
2178
- }, {}));
2179
- if ([queryTypes.range, queryTypes.term].includes(componentToTypeMap[props[componentId].componentType])) {
2180
- // Avoid logging `value` for term type of components
2181
- // eslint-disable-next-line
2182
- var value = currentQuery.value,
2183
- rest = _objectWithoutProperties(currentQuery, _excluded);
2184
- queryToLog = _objectSpread(_objectSpread({}, _defineProperty({}, componentId, rest)), Object.keys(dependentQueries).reduce(function (acc, q) {
2185
- return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, q, _objectSpread(_objectSpread({}, dependentQueries[q]), {}, {
2186
- execute: false
2187
- }, dependentQueries[q].type === queryTypes.suggestion ? {
2188
- type: 'search'
2189
- } : {})));
2190
- }, {}));
2191
- }
2192
- // if (!compareQueries(queryToLog, currentQuery, false)) {
2193
- orderOfQueries = [].concat(_toConsumableArray(orderOfQueries), [componentId]);
2194
- queryLog = _objectSpread(_objectSpread({}, queryLog), {}, _defineProperty({}, componentId, queryToLog));
2195
- // }
2196
-
2197
- if (query) {
2198
- // Apply dependent queries
2199
- var dependentQueriesToAppend = getDependentQueries(state, componentId, orderOfQueries);
2200
- appbaseQuery = _objectSpread(_objectSpread({}, appbaseQuery), _defineProperty({}, componentId, query));
2201
- Object.keys(dependentQueriesToAppend).forEach(function (cId) {
2202
- if (appbaseQuery[cId]) {
2203
- appbaseQuery[cId + Math.random()] = dependentQueriesToAppend[cId];
2204
- } else {
2205
- appbaseQuery[cId] = dependentQueriesToAppend[cId];
2206
- }
2207
- });
2208
- }
2209
- }
2210
- });
2211
- var handleRSResponse = function handleRSResponse(res) {
2212
- var promotedResults = {};
2213
- var rawData = {};
2214
- var customData = {};
2215
- var allPromises = orderOfQueries.map(function (component) {
2216
- return new Promise(function (responseResolve, responseReject) {
2217
- handleTransformResponse(res[component], config, component).then(function (response) {
2218
- if (response) {
2219
- if (response.promoted) {
2220
- promotedResults[component] = response.promoted.map(function (promoted) {
2221
- return _objectSpread(_objectSpread({}, promoted.doc), {}, {
2222
- _position: promoted.position
2223
- });
2224
- });
2225
- }
2226
- rawData[component] = response;
2227
- // Update custom data
2228
- if (response.customData) {
2229
- customData[component] = response.customData;
2230
- }
2231
- if (response.aggregations) {
2232
- aggregations = _objectSpread(_objectSpread({}, aggregations), {}, _defineProperty({}, component, response.aggregations));
2233
- }
2234
- var hitsObj = response.hits || {};
2235
- hits = _objectSpread(_objectSpread({}, hits), {}, _defineProperty({}, component, {
2236
- hits: hitsObj.hits,
2237
- total: _typeof(hitsObj.total) === 'object' ? hitsObj.total.value : hitsObj.total,
2238
- time: response.took
2239
- }));
2240
- responseResolve();
2241
- }
2242
- })["catch"](function (err) {
2243
- responseReject(err);
2244
- });
2245
- });
2246
- });
2247
- return Promise.all(allPromises).then(function () {
2248
- state = {
2249
- queryList: queryList,
2250
- queryOptions: queryOptions,
2251
- selectedValues: newSelectedValues,
2252
- internalValues: internalValues,
2253
- queryLog: queryLog,
2254
- hits: hits,
2255
- aggregations: aggregations,
2256
- promotedResults: promotedResults,
2257
- customData: customData,
2258
- rawData: rawData,
2259
- dependencyTree: dependencyTree
2260
- };
2261
- return Promise.resolve(JSON.parse(JSON.stringify(state)));
2262
- });
2263
- };
2264
- if (Object.keys(appbaseQuery).length) {
2265
- finalQuery = Object.values(appbaseQuery);
2266
- // Call RS API
2267
- var rsAPISettings = {};
2268
- if (config.analyticsConfig) {
2269
- rsAPISettings.recordAnalytics = isPropertyDefined(config.analyticsConfig.recordAnalytics) ? config.analyticsConfig.recordAnalytics : undefined;
2270
- rsAPISettings.userId = isPropertyDefined(config.analyticsConfig.userId) ? config.analyticsConfig.userId : undefined;
2271
- rsAPISettings.enableQueryRules = isPropertyDefined(config.analyticsConfig.enableQueryRules) ? config.analyticsConfig.enableQueryRules : undefined;
2272
- rsAPISettings.customEvents = isPropertyDefined(config.analyticsConfig.customEvents) ? config.analyticsConfig.customEvents : undefined;
2273
- }
2274
- return appbaseRef.reactiveSearchv3(finalQuery, rsAPISettings).then(function (res) {
2275
- return handleRSResponse(res);
2276
- })["catch"](function (err) {
2277
- return Promise.reject(err);
2278
- });
2279
- }
2280
- throw new Error('Could not compute server-side initial state of the app!');
2281
- } else {
2282
- return null;
2283
- }
2284
- })["catch"](Promise.reject);
2285
- }
2286
- return null;
2287
- } catch (error) {
2288
- return Promise.reject(error);
2289
- }
2290
- };
2291
- };
1
+ import { createSSRApp } from 'vue';
2
+ import { renderToString } from 'vue/server-renderer';
3
+ import { getServerResults } from '@appbaseio/reactivecore/lib/utils/server';
2292
4
 
2293
5
  function getServerState(App, queryString) {
2294
6
  var renderFunction = renderToString;