@tager/admin-banners 0.3.5 → 1.0.0

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 (75) hide show
  1. package/dist/constants/paths.d.ts +5 -10
  2. package/dist/constants/routes.d.ts +4 -4
  3. package/dist/dev/App.vue.d.ts +5 -0
  4. package/dist/dev/config.d.ts +2 -0
  5. package/dist/dev/env.d.ts +1 -0
  6. package/dist/dev/main.d.ts +3 -0
  7. package/dist/hooks/index.d.ts +2 -2
  8. package/dist/hooks/useFetchBanner.d.ts +7 -8
  9. package/dist/hooks/useFetchBanners.d.ts +3 -6
  10. package/dist/hooks/useFetchZoneFields.d.ts +7 -0
  11. package/dist/hooks/useFetchZones.d.ts +3 -6
  12. package/dist/index.mjs +993 -0
  13. package/dist/locales/apply.d.ts +1 -0
  14. package/dist/locales/en.d.ts +41 -40
  15. package/dist/locales/ru.d.ts +2 -3
  16. package/dist/main.d.ts +3 -4
  17. package/dist/services/requests.d.ts +25 -24
  18. package/dist/style.css +1 -0
  19. package/dist/typings/banners.d.ts +47 -40
  20. package/dist/typings/common.d.ts +1 -1
  21. package/dist/typings/model.d.ts +104 -104
  22. package/dist/typings/zones.d.ts +9 -5
  23. package/dist/utils/common.d.ts +2 -2
  24. package/dist/utils/paths.d.ts +5 -0
  25. package/dist/views/Banners/BannerForm/BannerForm.helpers.d.ts +5 -5
  26. package/dist/views/Banners/BannerForm/BannerForm.vue.d.ts +2694 -81
  27. package/dist/views/Banners/BannerForm/index.d.ts +1 -1
  28. package/dist/views/Banners/BannerList/BannerList.helpers.d.ts +6 -6
  29. package/dist/views/Banners/BannerList/BannerList.vue.d.ts +25 -55
  30. package/dist/views/Banners/BannerList/hooks/index.d.ts +1 -1
  31. package/dist/views/Banners/BannerList/hooks/useAdvancedSearch.d.ts +23 -21
  32. package/dist/views/Banners/BannerList/index.d.ts +1 -1
  33. package/dist/views/Zones/ZoneList/ZoneList.helpers.d.ts +5 -5
  34. package/dist/views/Zones/ZoneList/ZoneList.vue.d.ts +11 -28
  35. package/dist/views/Zones/ZoneList/index.d.ts +1 -1
  36. package/package.json +51 -49
  37. package/src/constants/paths.ts +1 -15
  38. package/src/constants/routes.ts +7 -7
  39. package/src/dev/App.vue +46 -0
  40. package/src/dev/config.ts +23 -0
  41. package/src/dev/env.ts +17 -0
  42. package/src/dev/main.ts +47 -0
  43. package/src/hooks/useFetchBanner.ts +3 -6
  44. package/src/hooks/useFetchBanners.ts +2 -5
  45. package/src/hooks/useFetchZoneFields.ts +39 -0
  46. package/src/hooks/useFetchZones.ts +2 -5
  47. package/src/locales/apply.ts +9 -0
  48. package/src/locales/en.ts +2 -1
  49. package/src/locales/ru.ts +40 -41
  50. package/src/main.ts +3 -8
  51. package/src/services/requests.ts +7 -1
  52. package/src/typings/banners.ts +14 -2
  53. package/src/typings/zones.ts +6 -0
  54. package/src/utils/paths.ts +15 -0
  55. package/src/views/Banners/BannerForm/BannerForm.helpers.ts +10 -0
  56. package/src/views/Banners/BannerForm/BannerForm.vue +168 -83
  57. package/src/views/Banners/BannerList/BannerList.helpers.ts +11 -4
  58. package/src/views/Banners/BannerList/BannerList.vue +60 -47
  59. package/src/views/Banners/BannerList/hooks/useAdvancedSearch.ts +14 -14
  60. package/src/views/Zones/ZoneList/ZoneList.helpers.ts +1 -1
  61. package/src/views/Zones/ZoneList/ZoneList.vue +18 -19
  62. package/CHANGELOG.md +0 -13
  63. package/dist/constants/menu.d.ts +0 -5
  64. package/dist/dev.d.ts +0 -1
  65. package/dist/index.esm.js +0 -3621
  66. package/dist/index.umd.js +0 -3640
  67. package/dist/router/index.d.ts +0 -4
  68. package/src/constants/menu.ts +0 -26
  69. package/src/dev.ts +0 -34
  70. package/src/router/index.ts +0 -38
  71. package/src/typings/sfc.d.ts +0 -12
  72. package/src/typings/shims-tsx.d.ts +0 -13
  73. package/src/typings/shims-vue.d.ts +0 -11
  74. package/src/views/App.vue +0 -22
  75. package/src/views/Home.vue +0 -37
package/dist/index.esm.js DELETED
@@ -1,3621 +0,0 @@
1
- import { request, useResource, useResourceDelete, createId, convertRequestErrorToMap, i18n } from '@tager/admin-services';
2
- import { defineComponent, onMounted, computed, ref, watch } from '@vue/composition-api';
3
- import { useDataTable, getFilterParamAsStringArray, getFilterParamAsString, getFilterParams, useTranslation, FormFooter } from '@tager/admin-ui';
4
- import { compile } from 'path-to-regexp';
5
-
6
- const EN = {
7
- home: 'Home',
8
- zone: 'Banner zone',
9
- zones: 'Banner zones',
10
- banners: 'Banners',
11
- bannerForm: 'Banner Form',
12
- createBanner: 'Create Banner',
13
- updateBanner: 'Update Banner',
14
- link: 'Link',
15
- image: 'Image',
16
- openNewTab: 'Open new tab',
17
- period: 'Period',
18
- from: 'From',
19
- to: 'To',
20
- disabled: 'Disabled',
21
- comment: 'Comment',
22
- status: 'Status',
23
- bannerZoneIsDeleted: 'Banner zone is deleted',
24
- newTab: 'New Tab',
25
- yes: 'Yes',
26
- no: 'No',
27
- edit: 'Edit',
28
- remove: 'Remove',
29
- actions: 'actions',
30
- date: 'Date',
31
- name: 'Name',
32
- success: 'Success',
33
- error: 'Error',
34
- statuses: {
35
- waiting: 'Waiting',
36
- archived: 'Archived',
37
- active: 'Active',
38
- disabled: 'Disabled',
39
- },
40
- bannerWasSuccessfullyCreated: 'Banner was successfully created',
41
- bannerWasSuccessfullyUpdated: 'Banner was successfully updated',
42
- bannerCreationWasFailed: 'Banner creation was failed',
43
- bannerUpdateWasFailed: 'Banner update was failed',
44
- };
45
-
46
- const RU = {
47
- home: 'Главная',
48
- zone: 'Баннерная зона',
49
- zones: 'Баннерные зоны',
50
- banners: 'Баннеры',
51
- bannerForm: 'Форма баннера',
52
- createBanner: 'Добавить баннер',
53
- updateBanner: 'Редактировать баннер',
54
- link: 'Ссылка',
55
- image: 'Картинка',
56
- openNewTab: 'Открывать в новой вкладке',
57
- period: 'Срок действия',
58
- from: 'От',
59
- to: 'До',
60
- disabled: 'Выключен',
61
- comment: 'Комментарий',
62
- status: 'Статус',
63
- bannerZoneIsDeleted: 'Баннерная зона удалена',
64
- newTab: 'Новая вкладка',
65
- yes: 'Да',
66
- no: 'Нет',
67
- edit: 'Редактировать',
68
- remove: 'Удалить',
69
- actions: 'Действия',
70
- date: 'Дата',
71
- name: 'Название',
72
- success: 'Успех',
73
- error: 'Ошибка',
74
- statuses: {
75
- waiting: 'В ожидании',
76
- archived: 'Архивный',
77
- active: 'Активный',
78
- disabled: 'Отключен',
79
- },
80
- bannerWasSuccessfullyCreated: 'Баннер успешно создан',
81
- bannerWasSuccessfullyUpdated: 'Баннер успешно обновлен',
82
- bannerCreationWasFailed: 'Не удалось создать баннер',
83
- bannerUpdateWasFailed: 'Не удалось обновить баннер',
84
- };
85
-
86
- /** Zones **/
87
- function getZones(params) {
88
- return request.get({ path: '/admin/adv/zones', params });
89
- }
90
- /** Banners **/
91
- function getBanners(params) {
92
- return request.get({ path: '/admin/adv', params });
93
- }
94
- function getBanner(bannerId) {
95
- return request.get({ path: `/admin/adv/${bannerId}` });
96
- }
97
- function createBanner(payload) {
98
- return request.post({ path: '/admin/adv', body: payload });
99
- }
100
- function updateBanner(bannerId, payload) {
101
- return request.put({
102
- path: `/admin/adv/${bannerId}`,
103
- body: payload,
104
- });
105
- }
106
- function deleteBanner(bannerId) {
107
- return request.delete({ path: `/admin/adv/${bannerId}` });
108
- }
109
- function getBannerCount() {
110
- return request.get({ path: '/admin/adv/count' });
111
- }
112
-
113
- const BANNERS_ROUTE_PATHS = {
114
- ZONE_LIST: '/banners/zones',
115
- BANNER_LIST: '/banners',
116
- BANNER_FORM: '/banners/:bannerId',
117
- };
118
- function getBannersZoneListUrl() {
119
- return BANNERS_ROUTE_PATHS.ZONE_LIST;
120
- }
121
- function getBannersBannerListUrl() {
122
- return BANNERS_ROUTE_PATHS.BANNER_LIST;
123
- }
124
- function getBannersBannerFormUrl(params) {
125
- return compile(BANNERS_ROUTE_PATHS.BANNER_FORM)(params);
126
- }
127
-
128
- function getColumnDefs(t) {
129
- return [
130
- {
131
- id: 0,
132
- name: 'ID',
133
- field: 'id',
134
- style: { width: '50px', textAlign: 'center' },
135
- headStyle: { width: '50px', textAlign: 'center' },
136
- },
137
- {
138
- id: 1,
139
- name: t('banners:name'),
140
- field: 'name',
141
- type: 'name',
142
- },
143
- {
144
- id: 2,
145
- name: t('banners:banners'),
146
- field: 'bannersCount',
147
- style: { whiteSpace: 'nowrap', width: '130px' },
148
- },
149
- ];
150
- }
151
- function getLinkToBannersByZone(zoneId) {
152
- return `${getBannersBannerListUrl()}?filter[zone]=${zoneId}`;
153
- }
154
-
155
- var script = defineComponent({
156
- name: 'ZoneList',
157
- setup(props, context) {
158
- const { fetchEntityList: fetchZones, isLoading: isZonesLoading, rowData, errorMessage, handleChange, } = useDataTable({
159
- fetchEntityList: getZones,
160
- initialValue: [],
161
- context,
162
- resourceName: 'Banner Zones',
163
- });
164
- onMounted(() => {
165
- fetchZones();
166
- });
167
- const columnDefs = computed(() => getColumnDefs(context.root.$t));
168
- return {
169
- columnDefs,
170
- isRowDataLoading: isZonesLoading,
171
- rowData,
172
- errorMessage,
173
- handleChange,
174
- getLinkToBannersByZone,
175
- };
176
- },
177
- });
178
-
179
- function normalizeComponent(template, style, script, scopeId, isFunctionalTemplate, moduleIdentifier /* server only */, shadowMode, createInjector, createInjectorSSR, createInjectorShadow) {
180
- if (typeof shadowMode !== 'boolean') {
181
- createInjectorSSR = createInjector;
182
- createInjector = shadowMode;
183
- shadowMode = false;
184
- }
185
- // Vue.extend constructor export interop.
186
- const options = typeof script === 'function' ? script.options : script;
187
- // render functions
188
- if (template && template.render) {
189
- options.render = template.render;
190
- options.staticRenderFns = template.staticRenderFns;
191
- options._compiled = true;
192
- // functional template
193
- if (isFunctionalTemplate) {
194
- options.functional = true;
195
- }
196
- }
197
- // scopedId
198
- if (scopeId) {
199
- options._scopeId = scopeId;
200
- }
201
- let hook;
202
- if (moduleIdentifier) {
203
- // server build
204
- hook = function (context) {
205
- // 2.3 injection
206
- context =
207
- context || // cached call
208
- (this.$vnode && this.$vnode.ssrContext) || // stateful
209
- (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext); // functional
210
- // 2.2 with runInNewContext: true
211
- if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
212
- context = __VUE_SSR_CONTEXT__;
213
- }
214
- // inject component styles
215
- if (style) {
216
- style.call(this, createInjectorSSR(context));
217
- }
218
- // register component module identifier for async chunk inference
219
- if (context && context._registeredComponents) {
220
- context._registeredComponents.add(moduleIdentifier);
221
- }
222
- };
223
- // used by ssr in case component is cached and beforeCreate
224
- // never gets called
225
- options._ssrRegister = hook;
226
- }
227
- else if (style) {
228
- hook = shadowMode
229
- ? function (context) {
230
- style.call(this, createInjectorShadow(context, this.$root.$options.shadowRoot));
231
- }
232
- : function (context) {
233
- style.call(this, createInjector(context));
234
- };
235
- }
236
- if (hook) {
237
- if (options.functional) {
238
- // register for functional component in vue file
239
- const originalRender = options.render;
240
- options.render = function renderWithStyleInjection(h, context) {
241
- hook.call(context);
242
- return originalRender(h, context);
243
- };
244
- }
245
- else {
246
- // inject component registration as beforeCreate hook
247
- const existing = options.beforeCreate;
248
- options.beforeCreate = existing ? [].concat(existing, hook) : [hook];
249
- }
250
- }
251
- return script;
252
- }
253
-
254
- /* script */
255
- const __vue_script__ = script;
256
-
257
- /* template */
258
- var __vue_render__ = function () {
259
- var _vm = this;
260
- var _h = _vm.$createElement;
261
- var _c = _vm._self._c || _h;
262
- return _c("page", {
263
- attrs: { title: _vm.$t("banners:zones") },
264
- scopedSlots: _vm._u([
265
- {
266
- key: "content",
267
- fn: function () {
268
- return [
269
- _c("data-table", {
270
- attrs: {
271
- "column-defs": _vm.columnDefs,
272
- "row-data": _vm.rowData,
273
- loading: _vm.isRowDataLoading,
274
- "error-message": _vm.errorMessage,
275
- "data-table": "banners-zones",
276
- "use-search": false,
277
- "use-pagination": false,
278
- },
279
- on: { change: _vm.handleChange },
280
- scopedSlots: _vm._u([
281
- {
282
- key: "cell(banners-count)",
283
- fn: function (ref) {
284
- var row = ref.row;
285
- return [
286
- _c(
287
- "count-button",
288
- {
289
- attrs: {
290
- href: _vm.getLinkToBannersByZone(row.id),
291
- variant: "outline-secondary",
292
- count: row.bannersCount,
293
- },
294
- },
295
- [
296
- _vm._v(
297
- "\n " +
298
- _vm._s(_vm.$t("banners:banners")) +
299
- "\n "
300
- ),
301
- ]
302
- ),
303
- ]
304
- },
305
- },
306
- ]),
307
- }),
308
- ]
309
- },
310
- proxy: true,
311
- },
312
- ]),
313
- })
314
- };
315
- var __vue_staticRenderFns__ = [];
316
- __vue_render__._withStripped = true;
317
-
318
- /* style */
319
- const __vue_inject_styles__ = undefined;
320
- /* scoped */
321
- const __vue_scope_id__ = undefined;
322
- /* module identifier */
323
- const __vue_module_identifier__ = undefined;
324
- /* functional template */
325
- const __vue_is_functional_template__ = false;
326
- /* style inject */
327
-
328
- /* style inject SSR */
329
-
330
- /* style inject shadow dom */
331
-
332
-
333
-
334
- const __vue_component__ = /*#__PURE__*/normalizeComponent(
335
- { render: __vue_render__, staticRenderFns: __vue_staticRenderFns__ },
336
- __vue_inject_styles__,
337
- __vue_script__,
338
- __vue_scope_id__,
339
- __vue_is_functional_template__,
340
- __vue_module_identifier__,
341
- false,
342
- undefined,
343
- undefined,
344
- undefined
345
- );
346
-
347
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
348
-
349
- function createCommonjsModule(fn, basedir, module) {
350
- return module = {
351
- path: basedir,
352
- exports: {},
353
- require: function (path, base) {
354
- return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
355
- }
356
- }, fn(module, module.exports), module.exports;
357
- }
358
-
359
- function commonjsRequire () {
360
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
361
- }
362
-
363
- var lodash_isequal = createCommonjsModule(function (module, exports) {
364
- /**
365
- * Lodash (Custom Build) <https://lodash.com/>
366
- * Build: `lodash modularize exports="npm" -o ./`
367
- * Copyright JS Foundation and other contributors <https://js.foundation/>
368
- * Released under MIT license <https://lodash.com/license>
369
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
370
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
371
- */
372
-
373
- /** Used as the size to enable large array optimizations. */
374
- var LARGE_ARRAY_SIZE = 200;
375
-
376
- /** Used to stand-in for `undefined` hash values. */
377
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
378
-
379
- /** Used to compose bitmasks for value comparisons. */
380
- var COMPARE_PARTIAL_FLAG = 1,
381
- COMPARE_UNORDERED_FLAG = 2;
382
-
383
- /** Used as references for various `Number` constants. */
384
- var MAX_SAFE_INTEGER = 9007199254740991;
385
-
386
- /** `Object#toString` result references. */
387
- var argsTag = '[object Arguments]',
388
- arrayTag = '[object Array]',
389
- asyncTag = '[object AsyncFunction]',
390
- boolTag = '[object Boolean]',
391
- dateTag = '[object Date]',
392
- errorTag = '[object Error]',
393
- funcTag = '[object Function]',
394
- genTag = '[object GeneratorFunction]',
395
- mapTag = '[object Map]',
396
- numberTag = '[object Number]',
397
- nullTag = '[object Null]',
398
- objectTag = '[object Object]',
399
- promiseTag = '[object Promise]',
400
- proxyTag = '[object Proxy]',
401
- regexpTag = '[object RegExp]',
402
- setTag = '[object Set]',
403
- stringTag = '[object String]',
404
- symbolTag = '[object Symbol]',
405
- undefinedTag = '[object Undefined]',
406
- weakMapTag = '[object WeakMap]';
407
-
408
- var arrayBufferTag = '[object ArrayBuffer]',
409
- dataViewTag = '[object DataView]',
410
- float32Tag = '[object Float32Array]',
411
- float64Tag = '[object Float64Array]',
412
- int8Tag = '[object Int8Array]',
413
- int16Tag = '[object Int16Array]',
414
- int32Tag = '[object Int32Array]',
415
- uint8Tag = '[object Uint8Array]',
416
- uint8ClampedTag = '[object Uint8ClampedArray]',
417
- uint16Tag = '[object Uint16Array]',
418
- uint32Tag = '[object Uint32Array]';
419
-
420
- /**
421
- * Used to match `RegExp`
422
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
423
- */
424
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
425
-
426
- /** Used to detect host constructors (Safari). */
427
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
428
-
429
- /** Used to detect unsigned integer values. */
430
- var reIsUint = /^(?:0|[1-9]\d*)$/;
431
-
432
- /** Used to identify `toStringTag` values of typed arrays. */
433
- var typedArrayTags = {};
434
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
435
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
436
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
437
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
438
- typedArrayTags[uint32Tag] = true;
439
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
440
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
441
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
442
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
443
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
444
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
445
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
446
- typedArrayTags[weakMapTag] = false;
447
-
448
- /** Detect free variable `global` from Node.js. */
449
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
450
-
451
- /** Detect free variable `self`. */
452
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
453
-
454
- /** Used as a reference to the global object. */
455
- var root = freeGlobal || freeSelf || Function('return this')();
456
-
457
- /** Detect free variable `exports`. */
458
- var freeExports = exports && !exports.nodeType && exports;
459
-
460
- /** Detect free variable `module`. */
461
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
462
-
463
- /** Detect the popular CommonJS extension `module.exports`. */
464
- var moduleExports = freeModule && freeModule.exports === freeExports;
465
-
466
- /** Detect free variable `process` from Node.js. */
467
- var freeProcess = moduleExports && freeGlobal.process;
468
-
469
- /** Used to access faster Node.js helpers. */
470
- var nodeUtil = (function() {
471
- try {
472
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
473
- } catch (e) {}
474
- }());
475
-
476
- /* Node.js helper references. */
477
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
478
-
479
- /**
480
- * A specialized version of `_.filter` for arrays without support for
481
- * iteratee shorthands.
482
- *
483
- * @private
484
- * @param {Array} [array] The array to iterate over.
485
- * @param {Function} predicate The function invoked per iteration.
486
- * @returns {Array} Returns the new filtered array.
487
- */
488
- function arrayFilter(array, predicate) {
489
- var index = -1,
490
- length = array == null ? 0 : array.length,
491
- resIndex = 0,
492
- result = [];
493
-
494
- while (++index < length) {
495
- var value = array[index];
496
- if (predicate(value, index, array)) {
497
- result[resIndex++] = value;
498
- }
499
- }
500
- return result;
501
- }
502
-
503
- /**
504
- * Appends the elements of `values` to `array`.
505
- *
506
- * @private
507
- * @param {Array} array The array to modify.
508
- * @param {Array} values The values to append.
509
- * @returns {Array} Returns `array`.
510
- */
511
- function arrayPush(array, values) {
512
- var index = -1,
513
- length = values.length,
514
- offset = array.length;
515
-
516
- while (++index < length) {
517
- array[offset + index] = values[index];
518
- }
519
- return array;
520
- }
521
-
522
- /**
523
- * A specialized version of `_.some` for arrays without support for iteratee
524
- * shorthands.
525
- *
526
- * @private
527
- * @param {Array} [array] The array to iterate over.
528
- * @param {Function} predicate The function invoked per iteration.
529
- * @returns {boolean} Returns `true` if any element passes the predicate check,
530
- * else `false`.
531
- */
532
- function arraySome(array, predicate) {
533
- var index = -1,
534
- length = array == null ? 0 : array.length;
535
-
536
- while (++index < length) {
537
- if (predicate(array[index], index, array)) {
538
- return true;
539
- }
540
- }
541
- return false;
542
- }
543
-
544
- /**
545
- * The base implementation of `_.times` without support for iteratee shorthands
546
- * or max array length checks.
547
- *
548
- * @private
549
- * @param {number} n The number of times to invoke `iteratee`.
550
- * @param {Function} iteratee The function invoked per iteration.
551
- * @returns {Array} Returns the array of results.
552
- */
553
- function baseTimes(n, iteratee) {
554
- var index = -1,
555
- result = Array(n);
556
-
557
- while (++index < n) {
558
- result[index] = iteratee(index);
559
- }
560
- return result;
561
- }
562
-
563
- /**
564
- * The base implementation of `_.unary` without support for storing metadata.
565
- *
566
- * @private
567
- * @param {Function} func The function to cap arguments for.
568
- * @returns {Function} Returns the new capped function.
569
- */
570
- function baseUnary(func) {
571
- return function(value) {
572
- return func(value);
573
- };
574
- }
575
-
576
- /**
577
- * Checks if a `cache` value for `key` exists.
578
- *
579
- * @private
580
- * @param {Object} cache The cache to query.
581
- * @param {string} key The key of the entry to check.
582
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
583
- */
584
- function cacheHas(cache, key) {
585
- return cache.has(key);
586
- }
587
-
588
- /**
589
- * Gets the value at `key` of `object`.
590
- *
591
- * @private
592
- * @param {Object} [object] The object to query.
593
- * @param {string} key The key of the property to get.
594
- * @returns {*} Returns the property value.
595
- */
596
- function getValue(object, key) {
597
- return object == null ? undefined : object[key];
598
- }
599
-
600
- /**
601
- * Converts `map` to its key-value pairs.
602
- *
603
- * @private
604
- * @param {Object} map The map to convert.
605
- * @returns {Array} Returns the key-value pairs.
606
- */
607
- function mapToArray(map) {
608
- var index = -1,
609
- result = Array(map.size);
610
-
611
- map.forEach(function(value, key) {
612
- result[++index] = [key, value];
613
- });
614
- return result;
615
- }
616
-
617
- /**
618
- * Creates a unary function that invokes `func` with its argument transformed.
619
- *
620
- * @private
621
- * @param {Function} func The function to wrap.
622
- * @param {Function} transform The argument transform.
623
- * @returns {Function} Returns the new function.
624
- */
625
- function overArg(func, transform) {
626
- return function(arg) {
627
- return func(transform(arg));
628
- };
629
- }
630
-
631
- /**
632
- * Converts `set` to an array of its values.
633
- *
634
- * @private
635
- * @param {Object} set The set to convert.
636
- * @returns {Array} Returns the values.
637
- */
638
- function setToArray(set) {
639
- var index = -1,
640
- result = Array(set.size);
641
-
642
- set.forEach(function(value) {
643
- result[++index] = value;
644
- });
645
- return result;
646
- }
647
-
648
- /** Used for built-in method references. */
649
- var arrayProto = Array.prototype,
650
- funcProto = Function.prototype,
651
- objectProto = Object.prototype;
652
-
653
- /** Used to detect overreaching core-js shims. */
654
- var coreJsData = root['__core-js_shared__'];
655
-
656
- /** Used to resolve the decompiled source of functions. */
657
- var funcToString = funcProto.toString;
658
-
659
- /** Used to check objects for own properties. */
660
- var hasOwnProperty = objectProto.hasOwnProperty;
661
-
662
- /** Used to detect methods masquerading as native. */
663
- var maskSrcKey = (function() {
664
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
665
- return uid ? ('Symbol(src)_1.' + uid) : '';
666
- }());
667
-
668
- /**
669
- * Used to resolve the
670
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
671
- * of values.
672
- */
673
- var nativeObjectToString = objectProto.toString;
674
-
675
- /** Used to detect if a method is native. */
676
- var reIsNative = RegExp('^' +
677
- funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
678
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
679
- );
680
-
681
- /** Built-in value references. */
682
- var Buffer = moduleExports ? root.Buffer : undefined,
683
- Symbol = root.Symbol,
684
- Uint8Array = root.Uint8Array,
685
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
686
- splice = arrayProto.splice,
687
- symToStringTag = Symbol ? Symbol.toStringTag : undefined;
688
-
689
- /* Built-in method references for those with the same name as other `lodash` methods. */
690
- var nativeGetSymbols = Object.getOwnPropertySymbols,
691
- nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
692
- nativeKeys = overArg(Object.keys, Object);
693
-
694
- /* Built-in method references that are verified to be native. */
695
- var DataView = getNative(root, 'DataView'),
696
- Map = getNative(root, 'Map'),
697
- Promise = getNative(root, 'Promise'),
698
- Set = getNative(root, 'Set'),
699
- WeakMap = getNative(root, 'WeakMap'),
700
- nativeCreate = getNative(Object, 'create');
701
-
702
- /** Used to detect maps, sets, and weakmaps. */
703
- var dataViewCtorString = toSource(DataView),
704
- mapCtorString = toSource(Map),
705
- promiseCtorString = toSource(Promise),
706
- setCtorString = toSource(Set),
707
- weakMapCtorString = toSource(WeakMap);
708
-
709
- /** Used to convert symbols to primitives and strings. */
710
- var symbolProto = Symbol ? Symbol.prototype : undefined,
711
- symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
712
-
713
- /**
714
- * Creates a hash object.
715
- *
716
- * @private
717
- * @constructor
718
- * @param {Array} [entries] The key-value pairs to cache.
719
- */
720
- function Hash(entries) {
721
- var index = -1,
722
- length = entries == null ? 0 : entries.length;
723
-
724
- this.clear();
725
- while (++index < length) {
726
- var entry = entries[index];
727
- this.set(entry[0], entry[1]);
728
- }
729
- }
730
-
731
- /**
732
- * Removes all key-value entries from the hash.
733
- *
734
- * @private
735
- * @name clear
736
- * @memberOf Hash
737
- */
738
- function hashClear() {
739
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
740
- this.size = 0;
741
- }
742
-
743
- /**
744
- * Removes `key` and its value from the hash.
745
- *
746
- * @private
747
- * @name delete
748
- * @memberOf Hash
749
- * @param {Object} hash The hash to modify.
750
- * @param {string} key The key of the value to remove.
751
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
752
- */
753
- function hashDelete(key) {
754
- var result = this.has(key) && delete this.__data__[key];
755
- this.size -= result ? 1 : 0;
756
- return result;
757
- }
758
-
759
- /**
760
- * Gets the hash value for `key`.
761
- *
762
- * @private
763
- * @name get
764
- * @memberOf Hash
765
- * @param {string} key The key of the value to get.
766
- * @returns {*} Returns the entry value.
767
- */
768
- function hashGet(key) {
769
- var data = this.__data__;
770
- if (nativeCreate) {
771
- var result = data[key];
772
- return result === HASH_UNDEFINED ? undefined : result;
773
- }
774
- return hasOwnProperty.call(data, key) ? data[key] : undefined;
775
- }
776
-
777
- /**
778
- * Checks if a hash value for `key` exists.
779
- *
780
- * @private
781
- * @name has
782
- * @memberOf Hash
783
- * @param {string} key The key of the entry to check.
784
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
785
- */
786
- function hashHas(key) {
787
- var data = this.__data__;
788
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
789
- }
790
-
791
- /**
792
- * Sets the hash `key` to `value`.
793
- *
794
- * @private
795
- * @name set
796
- * @memberOf Hash
797
- * @param {string} key The key of the value to set.
798
- * @param {*} value The value to set.
799
- * @returns {Object} Returns the hash instance.
800
- */
801
- function hashSet(key, value) {
802
- var data = this.__data__;
803
- this.size += this.has(key) ? 0 : 1;
804
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
805
- return this;
806
- }
807
-
808
- // Add methods to `Hash`.
809
- Hash.prototype.clear = hashClear;
810
- Hash.prototype['delete'] = hashDelete;
811
- Hash.prototype.get = hashGet;
812
- Hash.prototype.has = hashHas;
813
- Hash.prototype.set = hashSet;
814
-
815
- /**
816
- * Creates an list cache object.
817
- *
818
- * @private
819
- * @constructor
820
- * @param {Array} [entries] The key-value pairs to cache.
821
- */
822
- function ListCache(entries) {
823
- var index = -1,
824
- length = entries == null ? 0 : entries.length;
825
-
826
- this.clear();
827
- while (++index < length) {
828
- var entry = entries[index];
829
- this.set(entry[0], entry[1]);
830
- }
831
- }
832
-
833
- /**
834
- * Removes all key-value entries from the list cache.
835
- *
836
- * @private
837
- * @name clear
838
- * @memberOf ListCache
839
- */
840
- function listCacheClear() {
841
- this.__data__ = [];
842
- this.size = 0;
843
- }
844
-
845
- /**
846
- * Removes `key` and its value from the list cache.
847
- *
848
- * @private
849
- * @name delete
850
- * @memberOf ListCache
851
- * @param {string} key The key of the value to remove.
852
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
853
- */
854
- function listCacheDelete(key) {
855
- var data = this.__data__,
856
- index = assocIndexOf(data, key);
857
-
858
- if (index < 0) {
859
- return false;
860
- }
861
- var lastIndex = data.length - 1;
862
- if (index == lastIndex) {
863
- data.pop();
864
- } else {
865
- splice.call(data, index, 1);
866
- }
867
- --this.size;
868
- return true;
869
- }
870
-
871
- /**
872
- * Gets the list cache value for `key`.
873
- *
874
- * @private
875
- * @name get
876
- * @memberOf ListCache
877
- * @param {string} key The key of the value to get.
878
- * @returns {*} Returns the entry value.
879
- */
880
- function listCacheGet(key) {
881
- var data = this.__data__,
882
- index = assocIndexOf(data, key);
883
-
884
- return index < 0 ? undefined : data[index][1];
885
- }
886
-
887
- /**
888
- * Checks if a list cache value for `key` exists.
889
- *
890
- * @private
891
- * @name has
892
- * @memberOf ListCache
893
- * @param {string} key The key of the entry to check.
894
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
895
- */
896
- function listCacheHas(key) {
897
- return assocIndexOf(this.__data__, key) > -1;
898
- }
899
-
900
- /**
901
- * Sets the list cache `key` to `value`.
902
- *
903
- * @private
904
- * @name set
905
- * @memberOf ListCache
906
- * @param {string} key The key of the value to set.
907
- * @param {*} value The value to set.
908
- * @returns {Object} Returns the list cache instance.
909
- */
910
- function listCacheSet(key, value) {
911
- var data = this.__data__,
912
- index = assocIndexOf(data, key);
913
-
914
- if (index < 0) {
915
- ++this.size;
916
- data.push([key, value]);
917
- } else {
918
- data[index][1] = value;
919
- }
920
- return this;
921
- }
922
-
923
- // Add methods to `ListCache`.
924
- ListCache.prototype.clear = listCacheClear;
925
- ListCache.prototype['delete'] = listCacheDelete;
926
- ListCache.prototype.get = listCacheGet;
927
- ListCache.prototype.has = listCacheHas;
928
- ListCache.prototype.set = listCacheSet;
929
-
930
- /**
931
- * Creates a map cache object to store key-value pairs.
932
- *
933
- * @private
934
- * @constructor
935
- * @param {Array} [entries] The key-value pairs to cache.
936
- */
937
- function MapCache(entries) {
938
- var index = -1,
939
- length = entries == null ? 0 : entries.length;
940
-
941
- this.clear();
942
- while (++index < length) {
943
- var entry = entries[index];
944
- this.set(entry[0], entry[1]);
945
- }
946
- }
947
-
948
- /**
949
- * Removes all key-value entries from the map.
950
- *
951
- * @private
952
- * @name clear
953
- * @memberOf MapCache
954
- */
955
- function mapCacheClear() {
956
- this.size = 0;
957
- this.__data__ = {
958
- 'hash': new Hash,
959
- 'map': new (Map || ListCache),
960
- 'string': new Hash
961
- };
962
- }
963
-
964
- /**
965
- * Removes `key` and its value from the map.
966
- *
967
- * @private
968
- * @name delete
969
- * @memberOf MapCache
970
- * @param {string} key The key of the value to remove.
971
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
972
- */
973
- function mapCacheDelete(key) {
974
- var result = getMapData(this, key)['delete'](key);
975
- this.size -= result ? 1 : 0;
976
- return result;
977
- }
978
-
979
- /**
980
- * Gets the map value for `key`.
981
- *
982
- * @private
983
- * @name get
984
- * @memberOf MapCache
985
- * @param {string} key The key of the value to get.
986
- * @returns {*} Returns the entry value.
987
- */
988
- function mapCacheGet(key) {
989
- return getMapData(this, key).get(key);
990
- }
991
-
992
- /**
993
- * Checks if a map value for `key` exists.
994
- *
995
- * @private
996
- * @name has
997
- * @memberOf MapCache
998
- * @param {string} key The key of the entry to check.
999
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1000
- */
1001
- function mapCacheHas(key) {
1002
- return getMapData(this, key).has(key);
1003
- }
1004
-
1005
- /**
1006
- * Sets the map `key` to `value`.
1007
- *
1008
- * @private
1009
- * @name set
1010
- * @memberOf MapCache
1011
- * @param {string} key The key of the value to set.
1012
- * @param {*} value The value to set.
1013
- * @returns {Object} Returns the map cache instance.
1014
- */
1015
- function mapCacheSet(key, value) {
1016
- var data = getMapData(this, key),
1017
- size = data.size;
1018
-
1019
- data.set(key, value);
1020
- this.size += data.size == size ? 0 : 1;
1021
- return this;
1022
- }
1023
-
1024
- // Add methods to `MapCache`.
1025
- MapCache.prototype.clear = mapCacheClear;
1026
- MapCache.prototype['delete'] = mapCacheDelete;
1027
- MapCache.prototype.get = mapCacheGet;
1028
- MapCache.prototype.has = mapCacheHas;
1029
- MapCache.prototype.set = mapCacheSet;
1030
-
1031
- /**
1032
- *
1033
- * Creates an array cache object to store unique values.
1034
- *
1035
- * @private
1036
- * @constructor
1037
- * @param {Array} [values] The values to cache.
1038
- */
1039
- function SetCache(values) {
1040
- var index = -1,
1041
- length = values == null ? 0 : values.length;
1042
-
1043
- this.__data__ = new MapCache;
1044
- while (++index < length) {
1045
- this.add(values[index]);
1046
- }
1047
- }
1048
-
1049
- /**
1050
- * Adds `value` to the array cache.
1051
- *
1052
- * @private
1053
- * @name add
1054
- * @memberOf SetCache
1055
- * @alias push
1056
- * @param {*} value The value to cache.
1057
- * @returns {Object} Returns the cache instance.
1058
- */
1059
- function setCacheAdd(value) {
1060
- this.__data__.set(value, HASH_UNDEFINED);
1061
- return this;
1062
- }
1063
-
1064
- /**
1065
- * Checks if `value` is in the array cache.
1066
- *
1067
- * @private
1068
- * @name has
1069
- * @memberOf SetCache
1070
- * @param {*} value The value to search for.
1071
- * @returns {number} Returns `true` if `value` is found, else `false`.
1072
- */
1073
- function setCacheHas(value) {
1074
- return this.__data__.has(value);
1075
- }
1076
-
1077
- // Add methods to `SetCache`.
1078
- SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
1079
- SetCache.prototype.has = setCacheHas;
1080
-
1081
- /**
1082
- * Creates a stack cache object to store key-value pairs.
1083
- *
1084
- * @private
1085
- * @constructor
1086
- * @param {Array} [entries] The key-value pairs to cache.
1087
- */
1088
- function Stack(entries) {
1089
- var data = this.__data__ = new ListCache(entries);
1090
- this.size = data.size;
1091
- }
1092
-
1093
- /**
1094
- * Removes all key-value entries from the stack.
1095
- *
1096
- * @private
1097
- * @name clear
1098
- * @memberOf Stack
1099
- */
1100
- function stackClear() {
1101
- this.__data__ = new ListCache;
1102
- this.size = 0;
1103
- }
1104
-
1105
- /**
1106
- * Removes `key` and its value from the stack.
1107
- *
1108
- * @private
1109
- * @name delete
1110
- * @memberOf Stack
1111
- * @param {string} key The key of the value to remove.
1112
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1113
- */
1114
- function stackDelete(key) {
1115
- var data = this.__data__,
1116
- result = data['delete'](key);
1117
-
1118
- this.size = data.size;
1119
- return result;
1120
- }
1121
-
1122
- /**
1123
- * Gets the stack value for `key`.
1124
- *
1125
- * @private
1126
- * @name get
1127
- * @memberOf Stack
1128
- * @param {string} key The key of the value to get.
1129
- * @returns {*} Returns the entry value.
1130
- */
1131
- function stackGet(key) {
1132
- return this.__data__.get(key);
1133
- }
1134
-
1135
- /**
1136
- * Checks if a stack value for `key` exists.
1137
- *
1138
- * @private
1139
- * @name has
1140
- * @memberOf Stack
1141
- * @param {string} key The key of the entry to check.
1142
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1143
- */
1144
- function stackHas(key) {
1145
- return this.__data__.has(key);
1146
- }
1147
-
1148
- /**
1149
- * Sets the stack `key` to `value`.
1150
- *
1151
- * @private
1152
- * @name set
1153
- * @memberOf Stack
1154
- * @param {string} key The key of the value to set.
1155
- * @param {*} value The value to set.
1156
- * @returns {Object} Returns the stack cache instance.
1157
- */
1158
- function stackSet(key, value) {
1159
- var data = this.__data__;
1160
- if (data instanceof ListCache) {
1161
- var pairs = data.__data__;
1162
- if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1163
- pairs.push([key, value]);
1164
- this.size = ++data.size;
1165
- return this;
1166
- }
1167
- data = this.__data__ = new MapCache(pairs);
1168
- }
1169
- data.set(key, value);
1170
- this.size = data.size;
1171
- return this;
1172
- }
1173
-
1174
- // Add methods to `Stack`.
1175
- Stack.prototype.clear = stackClear;
1176
- Stack.prototype['delete'] = stackDelete;
1177
- Stack.prototype.get = stackGet;
1178
- Stack.prototype.has = stackHas;
1179
- Stack.prototype.set = stackSet;
1180
-
1181
- /**
1182
- * Creates an array of the enumerable property names of the array-like `value`.
1183
- *
1184
- * @private
1185
- * @param {*} value The value to query.
1186
- * @param {boolean} inherited Specify returning inherited property names.
1187
- * @returns {Array} Returns the array of property names.
1188
- */
1189
- function arrayLikeKeys(value, inherited) {
1190
- var isArr = isArray(value),
1191
- isArg = !isArr && isArguments(value),
1192
- isBuff = !isArr && !isArg && isBuffer(value),
1193
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1194
- skipIndexes = isArr || isArg || isBuff || isType,
1195
- result = skipIndexes ? baseTimes(value.length, String) : [],
1196
- length = result.length;
1197
-
1198
- for (var key in value) {
1199
- if ((inherited || hasOwnProperty.call(value, key)) &&
1200
- !(skipIndexes && (
1201
- // Safari 9 has enumerable `arguments.length` in strict mode.
1202
- key == 'length' ||
1203
- // Node.js 0.10 has enumerable non-index properties on buffers.
1204
- (isBuff && (key == 'offset' || key == 'parent')) ||
1205
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
1206
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1207
- // Skip index properties.
1208
- isIndex(key, length)
1209
- ))) {
1210
- result.push(key);
1211
- }
1212
- }
1213
- return result;
1214
- }
1215
-
1216
- /**
1217
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1218
- *
1219
- * @private
1220
- * @param {Array} array The array to inspect.
1221
- * @param {*} key The key to search for.
1222
- * @returns {number} Returns the index of the matched value, else `-1`.
1223
- */
1224
- function assocIndexOf(array, key) {
1225
- var length = array.length;
1226
- while (length--) {
1227
- if (eq(array[length][0], key)) {
1228
- return length;
1229
- }
1230
- }
1231
- return -1;
1232
- }
1233
-
1234
- /**
1235
- * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
1236
- * `keysFunc` and `symbolsFunc` to get the enumerable property names and
1237
- * symbols of `object`.
1238
- *
1239
- * @private
1240
- * @param {Object} object The object to query.
1241
- * @param {Function} keysFunc The function to get the keys of `object`.
1242
- * @param {Function} symbolsFunc The function to get the symbols of `object`.
1243
- * @returns {Array} Returns the array of property names and symbols.
1244
- */
1245
- function baseGetAllKeys(object, keysFunc, symbolsFunc) {
1246
- var result = keysFunc(object);
1247
- return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
1248
- }
1249
-
1250
- /**
1251
- * The base implementation of `getTag` without fallbacks for buggy environments.
1252
- *
1253
- * @private
1254
- * @param {*} value The value to query.
1255
- * @returns {string} Returns the `toStringTag`.
1256
- */
1257
- function baseGetTag(value) {
1258
- if (value == null) {
1259
- return value === undefined ? undefinedTag : nullTag;
1260
- }
1261
- return (symToStringTag && symToStringTag in Object(value))
1262
- ? getRawTag(value)
1263
- : objectToString(value);
1264
- }
1265
-
1266
- /**
1267
- * The base implementation of `_.isArguments`.
1268
- *
1269
- * @private
1270
- * @param {*} value The value to check.
1271
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1272
- */
1273
- function baseIsArguments(value) {
1274
- return isObjectLike(value) && baseGetTag(value) == argsTag;
1275
- }
1276
-
1277
- /**
1278
- * The base implementation of `_.isEqual` which supports partial comparisons
1279
- * and tracks traversed objects.
1280
- *
1281
- * @private
1282
- * @param {*} value The value to compare.
1283
- * @param {*} other The other value to compare.
1284
- * @param {boolean} bitmask The bitmask flags.
1285
- * 1 - Unordered comparison
1286
- * 2 - Partial comparison
1287
- * @param {Function} [customizer] The function to customize comparisons.
1288
- * @param {Object} [stack] Tracks traversed `value` and `other` objects.
1289
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1290
- */
1291
- function baseIsEqual(value, other, bitmask, customizer, stack) {
1292
- if (value === other) {
1293
- return true;
1294
- }
1295
- if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
1296
- return value !== value && other !== other;
1297
- }
1298
- return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
1299
- }
1300
-
1301
- /**
1302
- * A specialized version of `baseIsEqual` for arrays and objects which performs
1303
- * deep comparisons and tracks traversed objects enabling objects with circular
1304
- * references to be compared.
1305
- *
1306
- * @private
1307
- * @param {Object} object The object to compare.
1308
- * @param {Object} other The other object to compare.
1309
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1310
- * @param {Function} customizer The function to customize comparisons.
1311
- * @param {Function} equalFunc The function to determine equivalents of values.
1312
- * @param {Object} [stack] Tracks traversed `object` and `other` objects.
1313
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1314
- */
1315
- function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
1316
- var objIsArr = isArray(object),
1317
- othIsArr = isArray(other),
1318
- objTag = objIsArr ? arrayTag : getTag(object),
1319
- othTag = othIsArr ? arrayTag : getTag(other);
1320
-
1321
- objTag = objTag == argsTag ? objectTag : objTag;
1322
- othTag = othTag == argsTag ? objectTag : othTag;
1323
-
1324
- var objIsObj = objTag == objectTag,
1325
- othIsObj = othTag == objectTag,
1326
- isSameTag = objTag == othTag;
1327
-
1328
- if (isSameTag && isBuffer(object)) {
1329
- if (!isBuffer(other)) {
1330
- return false;
1331
- }
1332
- objIsArr = true;
1333
- objIsObj = false;
1334
- }
1335
- if (isSameTag && !objIsObj) {
1336
- stack || (stack = new Stack);
1337
- return (objIsArr || isTypedArray(object))
1338
- ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
1339
- : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
1340
- }
1341
- if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
1342
- var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
1343
- othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
1344
-
1345
- if (objIsWrapped || othIsWrapped) {
1346
- var objUnwrapped = objIsWrapped ? object.value() : object,
1347
- othUnwrapped = othIsWrapped ? other.value() : other;
1348
-
1349
- stack || (stack = new Stack);
1350
- return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1351
- }
1352
- }
1353
- if (!isSameTag) {
1354
- return false;
1355
- }
1356
- stack || (stack = new Stack);
1357
- return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1358
- }
1359
-
1360
- /**
1361
- * The base implementation of `_.isNative` without bad shim checks.
1362
- *
1363
- * @private
1364
- * @param {*} value The value to check.
1365
- * @returns {boolean} Returns `true` if `value` is a native function,
1366
- * else `false`.
1367
- */
1368
- function baseIsNative(value) {
1369
- if (!isObject(value) || isMasked(value)) {
1370
- return false;
1371
- }
1372
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1373
- return pattern.test(toSource(value));
1374
- }
1375
-
1376
- /**
1377
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
1378
- *
1379
- * @private
1380
- * @param {*} value The value to check.
1381
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1382
- */
1383
- function baseIsTypedArray(value) {
1384
- return isObjectLike(value) &&
1385
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1386
- }
1387
-
1388
- /**
1389
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1390
- *
1391
- * @private
1392
- * @param {Object} object The object to query.
1393
- * @returns {Array} Returns the array of property names.
1394
- */
1395
- function baseKeys(object) {
1396
- if (!isPrototype(object)) {
1397
- return nativeKeys(object);
1398
- }
1399
- var result = [];
1400
- for (var key in Object(object)) {
1401
- if (hasOwnProperty.call(object, key) && key != 'constructor') {
1402
- result.push(key);
1403
- }
1404
- }
1405
- return result;
1406
- }
1407
-
1408
- /**
1409
- * A specialized version of `baseIsEqualDeep` for arrays with support for
1410
- * partial deep comparisons.
1411
- *
1412
- * @private
1413
- * @param {Array} array The array to compare.
1414
- * @param {Array} other The other array to compare.
1415
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1416
- * @param {Function} customizer The function to customize comparisons.
1417
- * @param {Function} equalFunc The function to determine equivalents of values.
1418
- * @param {Object} stack Tracks traversed `array` and `other` objects.
1419
- * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1420
- */
1421
- function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1422
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1423
- arrLength = array.length,
1424
- othLength = other.length;
1425
-
1426
- if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1427
- return false;
1428
- }
1429
- // Assume cyclic values are equal.
1430
- var stacked = stack.get(array);
1431
- if (stacked && stack.get(other)) {
1432
- return stacked == other;
1433
- }
1434
- var index = -1,
1435
- result = true,
1436
- seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
1437
-
1438
- stack.set(array, other);
1439
- stack.set(other, array);
1440
-
1441
- // Ignore non-index properties.
1442
- while (++index < arrLength) {
1443
- var arrValue = array[index],
1444
- othValue = other[index];
1445
-
1446
- if (customizer) {
1447
- var compared = isPartial
1448
- ? customizer(othValue, arrValue, index, other, array, stack)
1449
- : customizer(arrValue, othValue, index, array, other, stack);
1450
- }
1451
- if (compared !== undefined) {
1452
- if (compared) {
1453
- continue;
1454
- }
1455
- result = false;
1456
- break;
1457
- }
1458
- // Recursively compare arrays (susceptible to call stack limits).
1459
- if (seen) {
1460
- if (!arraySome(other, function(othValue, othIndex) {
1461
- if (!cacheHas(seen, othIndex) &&
1462
- (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1463
- return seen.push(othIndex);
1464
- }
1465
- })) {
1466
- result = false;
1467
- break;
1468
- }
1469
- } else if (!(
1470
- arrValue === othValue ||
1471
- equalFunc(arrValue, othValue, bitmask, customizer, stack)
1472
- )) {
1473
- result = false;
1474
- break;
1475
- }
1476
- }
1477
- stack['delete'](array);
1478
- stack['delete'](other);
1479
- return result;
1480
- }
1481
-
1482
- /**
1483
- * A specialized version of `baseIsEqualDeep` for comparing objects of
1484
- * the same `toStringTag`.
1485
- *
1486
- * **Note:** This function only supports comparing values with tags of
1487
- * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1488
- *
1489
- * @private
1490
- * @param {Object} object The object to compare.
1491
- * @param {Object} other The other object to compare.
1492
- * @param {string} tag The `toStringTag` of the objects to compare.
1493
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1494
- * @param {Function} customizer The function to customize comparisons.
1495
- * @param {Function} equalFunc The function to determine equivalents of values.
1496
- * @param {Object} stack Tracks traversed `object` and `other` objects.
1497
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1498
- */
1499
- function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1500
- switch (tag) {
1501
- case dataViewTag:
1502
- if ((object.byteLength != other.byteLength) ||
1503
- (object.byteOffset != other.byteOffset)) {
1504
- return false;
1505
- }
1506
- object = object.buffer;
1507
- other = other.buffer;
1508
-
1509
- case arrayBufferTag:
1510
- if ((object.byteLength != other.byteLength) ||
1511
- !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1512
- return false;
1513
- }
1514
- return true;
1515
-
1516
- case boolTag:
1517
- case dateTag:
1518
- case numberTag:
1519
- // Coerce booleans to `1` or `0` and dates to milliseconds.
1520
- // Invalid dates are coerced to `NaN`.
1521
- return eq(+object, +other);
1522
-
1523
- case errorTag:
1524
- return object.name == other.name && object.message == other.message;
1525
-
1526
- case regexpTag:
1527
- case stringTag:
1528
- // Coerce regexes to strings and treat strings, primitives and objects,
1529
- // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1530
- // for more details.
1531
- return object == (other + '');
1532
-
1533
- case mapTag:
1534
- var convert = mapToArray;
1535
-
1536
- case setTag:
1537
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
1538
- convert || (convert = setToArray);
1539
-
1540
- if (object.size != other.size && !isPartial) {
1541
- return false;
1542
- }
1543
- // Assume cyclic values are equal.
1544
- var stacked = stack.get(object);
1545
- if (stacked) {
1546
- return stacked == other;
1547
- }
1548
- bitmask |= COMPARE_UNORDERED_FLAG;
1549
-
1550
- // Recursively compare objects (susceptible to call stack limits).
1551
- stack.set(object, other);
1552
- var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
1553
- stack['delete'](object);
1554
- return result;
1555
-
1556
- case symbolTag:
1557
- if (symbolValueOf) {
1558
- return symbolValueOf.call(object) == symbolValueOf.call(other);
1559
- }
1560
- }
1561
- return false;
1562
- }
1563
-
1564
- /**
1565
- * A specialized version of `baseIsEqualDeep` for objects with support for
1566
- * partial deep comparisons.
1567
- *
1568
- * @private
1569
- * @param {Object} object The object to compare.
1570
- * @param {Object} other The other object to compare.
1571
- * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1572
- * @param {Function} customizer The function to customize comparisons.
1573
- * @param {Function} equalFunc The function to determine equivalents of values.
1574
- * @param {Object} stack Tracks traversed `object` and `other` objects.
1575
- * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1576
- */
1577
- function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1578
- var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1579
- objProps = getAllKeys(object),
1580
- objLength = objProps.length,
1581
- othProps = getAllKeys(other),
1582
- othLength = othProps.length;
1583
-
1584
- if (objLength != othLength && !isPartial) {
1585
- return false;
1586
- }
1587
- var index = objLength;
1588
- while (index--) {
1589
- var key = objProps[index];
1590
- if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1591
- return false;
1592
- }
1593
- }
1594
- // Assume cyclic values are equal.
1595
- var stacked = stack.get(object);
1596
- if (stacked && stack.get(other)) {
1597
- return stacked == other;
1598
- }
1599
- var result = true;
1600
- stack.set(object, other);
1601
- stack.set(other, object);
1602
-
1603
- var skipCtor = isPartial;
1604
- while (++index < objLength) {
1605
- key = objProps[index];
1606
- var objValue = object[key],
1607
- othValue = other[key];
1608
-
1609
- if (customizer) {
1610
- var compared = isPartial
1611
- ? customizer(othValue, objValue, key, other, object, stack)
1612
- : customizer(objValue, othValue, key, object, other, stack);
1613
- }
1614
- // Recursively compare objects (susceptible to call stack limits).
1615
- if (!(compared === undefined
1616
- ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1617
- : compared
1618
- )) {
1619
- result = false;
1620
- break;
1621
- }
1622
- skipCtor || (skipCtor = key == 'constructor');
1623
- }
1624
- if (result && !skipCtor) {
1625
- var objCtor = object.constructor,
1626
- othCtor = other.constructor;
1627
-
1628
- // Non `Object` object instances with different constructors are not equal.
1629
- if (objCtor != othCtor &&
1630
- ('constructor' in object && 'constructor' in other) &&
1631
- !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1632
- typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1633
- result = false;
1634
- }
1635
- }
1636
- stack['delete'](object);
1637
- stack['delete'](other);
1638
- return result;
1639
- }
1640
-
1641
- /**
1642
- * Creates an array of own enumerable property names and symbols of `object`.
1643
- *
1644
- * @private
1645
- * @param {Object} object The object to query.
1646
- * @returns {Array} Returns the array of property names and symbols.
1647
- */
1648
- function getAllKeys(object) {
1649
- return baseGetAllKeys(object, keys, getSymbols);
1650
- }
1651
-
1652
- /**
1653
- * Gets the data for `map`.
1654
- *
1655
- * @private
1656
- * @param {Object} map The map to query.
1657
- * @param {string} key The reference key.
1658
- * @returns {*} Returns the map data.
1659
- */
1660
- function getMapData(map, key) {
1661
- var data = map.__data__;
1662
- return isKeyable(key)
1663
- ? data[typeof key == 'string' ? 'string' : 'hash']
1664
- : data.map;
1665
- }
1666
-
1667
- /**
1668
- * Gets the native function at `key` of `object`.
1669
- *
1670
- * @private
1671
- * @param {Object} object The object to query.
1672
- * @param {string} key The key of the method to get.
1673
- * @returns {*} Returns the function if it's native, else `undefined`.
1674
- */
1675
- function getNative(object, key) {
1676
- var value = getValue(object, key);
1677
- return baseIsNative(value) ? value : undefined;
1678
- }
1679
-
1680
- /**
1681
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1682
- *
1683
- * @private
1684
- * @param {*} value The value to query.
1685
- * @returns {string} Returns the raw `toStringTag`.
1686
- */
1687
- function getRawTag(value) {
1688
- var isOwn = hasOwnProperty.call(value, symToStringTag),
1689
- tag = value[symToStringTag];
1690
-
1691
- try {
1692
- value[symToStringTag] = undefined;
1693
- var unmasked = true;
1694
- } catch (e) {}
1695
-
1696
- var result = nativeObjectToString.call(value);
1697
- if (unmasked) {
1698
- if (isOwn) {
1699
- value[symToStringTag] = tag;
1700
- } else {
1701
- delete value[symToStringTag];
1702
- }
1703
- }
1704
- return result;
1705
- }
1706
-
1707
- /**
1708
- * Creates an array of the own enumerable symbols of `object`.
1709
- *
1710
- * @private
1711
- * @param {Object} object The object to query.
1712
- * @returns {Array} Returns the array of symbols.
1713
- */
1714
- var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1715
- if (object == null) {
1716
- return [];
1717
- }
1718
- object = Object(object);
1719
- return arrayFilter(nativeGetSymbols(object), function(symbol) {
1720
- return propertyIsEnumerable.call(object, symbol);
1721
- });
1722
- };
1723
-
1724
- /**
1725
- * Gets the `toStringTag` of `value`.
1726
- *
1727
- * @private
1728
- * @param {*} value The value to query.
1729
- * @returns {string} Returns the `toStringTag`.
1730
- */
1731
- var getTag = baseGetTag;
1732
-
1733
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1734
- if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1735
- (Map && getTag(new Map) != mapTag) ||
1736
- (Promise && getTag(Promise.resolve()) != promiseTag) ||
1737
- (Set && getTag(new Set) != setTag) ||
1738
- (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1739
- getTag = function(value) {
1740
- var result = baseGetTag(value),
1741
- Ctor = result == objectTag ? value.constructor : undefined,
1742
- ctorString = Ctor ? toSource(Ctor) : '';
1743
-
1744
- if (ctorString) {
1745
- switch (ctorString) {
1746
- case dataViewCtorString: return dataViewTag;
1747
- case mapCtorString: return mapTag;
1748
- case promiseCtorString: return promiseTag;
1749
- case setCtorString: return setTag;
1750
- case weakMapCtorString: return weakMapTag;
1751
- }
1752
- }
1753
- return result;
1754
- };
1755
- }
1756
-
1757
- /**
1758
- * Checks if `value` is a valid array-like index.
1759
- *
1760
- * @private
1761
- * @param {*} value The value to check.
1762
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1763
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1764
- */
1765
- function isIndex(value, length) {
1766
- length = length == null ? MAX_SAFE_INTEGER : length;
1767
- return !!length &&
1768
- (typeof value == 'number' || reIsUint.test(value)) &&
1769
- (value > -1 && value % 1 == 0 && value < length);
1770
- }
1771
-
1772
- /**
1773
- * Checks if `value` is suitable for use as unique object key.
1774
- *
1775
- * @private
1776
- * @param {*} value The value to check.
1777
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1778
- */
1779
- function isKeyable(value) {
1780
- var type = typeof value;
1781
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1782
- ? (value !== '__proto__')
1783
- : (value === null);
1784
- }
1785
-
1786
- /**
1787
- * Checks if `func` has its source masked.
1788
- *
1789
- * @private
1790
- * @param {Function} func The function to check.
1791
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1792
- */
1793
- function isMasked(func) {
1794
- return !!maskSrcKey && (maskSrcKey in func);
1795
- }
1796
-
1797
- /**
1798
- * Checks if `value` is likely a prototype object.
1799
- *
1800
- * @private
1801
- * @param {*} value The value to check.
1802
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1803
- */
1804
- function isPrototype(value) {
1805
- var Ctor = value && value.constructor,
1806
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1807
-
1808
- return value === proto;
1809
- }
1810
-
1811
- /**
1812
- * Converts `value` to a string using `Object.prototype.toString`.
1813
- *
1814
- * @private
1815
- * @param {*} value The value to convert.
1816
- * @returns {string} Returns the converted string.
1817
- */
1818
- function objectToString(value) {
1819
- return nativeObjectToString.call(value);
1820
- }
1821
-
1822
- /**
1823
- * Converts `func` to its source code.
1824
- *
1825
- * @private
1826
- * @param {Function} func The function to convert.
1827
- * @returns {string} Returns the source code.
1828
- */
1829
- function toSource(func) {
1830
- if (func != null) {
1831
- try {
1832
- return funcToString.call(func);
1833
- } catch (e) {}
1834
- try {
1835
- return (func + '');
1836
- } catch (e) {}
1837
- }
1838
- return '';
1839
- }
1840
-
1841
- /**
1842
- * Performs a
1843
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1844
- * comparison between two values to determine if they are equivalent.
1845
- *
1846
- * @static
1847
- * @memberOf _
1848
- * @since 4.0.0
1849
- * @category Lang
1850
- * @param {*} value The value to compare.
1851
- * @param {*} other The other value to compare.
1852
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1853
- * @example
1854
- *
1855
- * var object = { 'a': 1 };
1856
- * var other = { 'a': 1 };
1857
- *
1858
- * _.eq(object, object);
1859
- * // => true
1860
- *
1861
- * _.eq(object, other);
1862
- * // => false
1863
- *
1864
- * _.eq('a', 'a');
1865
- * // => true
1866
- *
1867
- * _.eq('a', Object('a'));
1868
- * // => false
1869
- *
1870
- * _.eq(NaN, NaN);
1871
- * // => true
1872
- */
1873
- function eq(value, other) {
1874
- return value === other || (value !== value && other !== other);
1875
- }
1876
-
1877
- /**
1878
- * Checks if `value` is likely an `arguments` object.
1879
- *
1880
- * @static
1881
- * @memberOf _
1882
- * @since 0.1.0
1883
- * @category Lang
1884
- * @param {*} value The value to check.
1885
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1886
- * else `false`.
1887
- * @example
1888
- *
1889
- * _.isArguments(function() { return arguments; }());
1890
- * // => true
1891
- *
1892
- * _.isArguments([1, 2, 3]);
1893
- * // => false
1894
- */
1895
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1896
- return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
1897
- !propertyIsEnumerable.call(value, 'callee');
1898
- };
1899
-
1900
- /**
1901
- * Checks if `value` is classified as an `Array` object.
1902
- *
1903
- * @static
1904
- * @memberOf _
1905
- * @since 0.1.0
1906
- * @category Lang
1907
- * @param {*} value The value to check.
1908
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1909
- * @example
1910
- *
1911
- * _.isArray([1, 2, 3]);
1912
- * // => true
1913
- *
1914
- * _.isArray(document.body.children);
1915
- * // => false
1916
- *
1917
- * _.isArray('abc');
1918
- * // => false
1919
- *
1920
- * _.isArray(_.noop);
1921
- * // => false
1922
- */
1923
- var isArray = Array.isArray;
1924
-
1925
- /**
1926
- * Checks if `value` is array-like. A value is considered array-like if it's
1927
- * not a function and has a `value.length` that's an integer greater than or
1928
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1929
- *
1930
- * @static
1931
- * @memberOf _
1932
- * @since 4.0.0
1933
- * @category Lang
1934
- * @param {*} value The value to check.
1935
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1936
- * @example
1937
- *
1938
- * _.isArrayLike([1, 2, 3]);
1939
- * // => true
1940
- *
1941
- * _.isArrayLike(document.body.children);
1942
- * // => true
1943
- *
1944
- * _.isArrayLike('abc');
1945
- * // => true
1946
- *
1947
- * _.isArrayLike(_.noop);
1948
- * // => false
1949
- */
1950
- function isArrayLike(value) {
1951
- return value != null && isLength(value.length) && !isFunction(value);
1952
- }
1953
-
1954
- /**
1955
- * Checks if `value` is a buffer.
1956
- *
1957
- * @static
1958
- * @memberOf _
1959
- * @since 4.3.0
1960
- * @category Lang
1961
- * @param {*} value The value to check.
1962
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1963
- * @example
1964
- *
1965
- * _.isBuffer(new Buffer(2));
1966
- * // => true
1967
- *
1968
- * _.isBuffer(new Uint8Array(2));
1969
- * // => false
1970
- */
1971
- var isBuffer = nativeIsBuffer || stubFalse;
1972
-
1973
- /**
1974
- * Performs a deep comparison between two values to determine if they are
1975
- * equivalent.
1976
- *
1977
- * **Note:** This method supports comparing arrays, array buffers, booleans,
1978
- * date objects, error objects, maps, numbers, `Object` objects, regexes,
1979
- * sets, strings, symbols, and typed arrays. `Object` objects are compared
1980
- * by their own, not inherited, enumerable properties. Functions and DOM
1981
- * nodes are compared by strict equality, i.e. `===`.
1982
- *
1983
- * @static
1984
- * @memberOf _
1985
- * @since 0.1.0
1986
- * @category Lang
1987
- * @param {*} value The value to compare.
1988
- * @param {*} other The other value to compare.
1989
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1990
- * @example
1991
- *
1992
- * var object = { 'a': 1 };
1993
- * var other = { 'a': 1 };
1994
- *
1995
- * _.isEqual(object, other);
1996
- * // => true
1997
- *
1998
- * object === other;
1999
- * // => false
2000
- */
2001
- function isEqual(value, other) {
2002
- return baseIsEqual(value, other);
2003
- }
2004
-
2005
- /**
2006
- * Checks if `value` is classified as a `Function` object.
2007
- *
2008
- * @static
2009
- * @memberOf _
2010
- * @since 0.1.0
2011
- * @category Lang
2012
- * @param {*} value The value to check.
2013
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2014
- * @example
2015
- *
2016
- * _.isFunction(_);
2017
- * // => true
2018
- *
2019
- * _.isFunction(/abc/);
2020
- * // => false
2021
- */
2022
- function isFunction(value) {
2023
- if (!isObject(value)) {
2024
- return false;
2025
- }
2026
- // The use of `Object#toString` avoids issues with the `typeof` operator
2027
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
2028
- var tag = baseGetTag(value);
2029
- return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
2030
- }
2031
-
2032
- /**
2033
- * Checks if `value` is a valid array-like length.
2034
- *
2035
- * **Note:** This method is loosely based on
2036
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2037
- *
2038
- * @static
2039
- * @memberOf _
2040
- * @since 4.0.0
2041
- * @category Lang
2042
- * @param {*} value The value to check.
2043
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2044
- * @example
2045
- *
2046
- * _.isLength(3);
2047
- * // => true
2048
- *
2049
- * _.isLength(Number.MIN_VALUE);
2050
- * // => false
2051
- *
2052
- * _.isLength(Infinity);
2053
- * // => false
2054
- *
2055
- * _.isLength('3');
2056
- * // => false
2057
- */
2058
- function isLength(value) {
2059
- return typeof value == 'number' &&
2060
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2061
- }
2062
-
2063
- /**
2064
- * Checks if `value` is the
2065
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2066
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2067
- *
2068
- * @static
2069
- * @memberOf _
2070
- * @since 0.1.0
2071
- * @category Lang
2072
- * @param {*} value The value to check.
2073
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2074
- * @example
2075
- *
2076
- * _.isObject({});
2077
- * // => true
2078
- *
2079
- * _.isObject([1, 2, 3]);
2080
- * // => true
2081
- *
2082
- * _.isObject(_.noop);
2083
- * // => true
2084
- *
2085
- * _.isObject(null);
2086
- * // => false
2087
- */
2088
- function isObject(value) {
2089
- var type = typeof value;
2090
- return value != null && (type == 'object' || type == 'function');
2091
- }
2092
-
2093
- /**
2094
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2095
- * and has a `typeof` result of "object".
2096
- *
2097
- * @static
2098
- * @memberOf _
2099
- * @since 4.0.0
2100
- * @category Lang
2101
- * @param {*} value The value to check.
2102
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2103
- * @example
2104
- *
2105
- * _.isObjectLike({});
2106
- * // => true
2107
- *
2108
- * _.isObjectLike([1, 2, 3]);
2109
- * // => true
2110
- *
2111
- * _.isObjectLike(_.noop);
2112
- * // => false
2113
- *
2114
- * _.isObjectLike(null);
2115
- * // => false
2116
- */
2117
- function isObjectLike(value) {
2118
- return value != null && typeof value == 'object';
2119
- }
2120
-
2121
- /**
2122
- * Checks if `value` is classified as a typed array.
2123
- *
2124
- * @static
2125
- * @memberOf _
2126
- * @since 3.0.0
2127
- * @category Lang
2128
- * @param {*} value The value to check.
2129
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
2130
- * @example
2131
- *
2132
- * _.isTypedArray(new Uint8Array);
2133
- * // => true
2134
- *
2135
- * _.isTypedArray([]);
2136
- * // => false
2137
- */
2138
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
2139
-
2140
- /**
2141
- * Creates an array of the own enumerable property names of `object`.
2142
- *
2143
- * **Note:** Non-object values are coerced to objects. See the
2144
- * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
2145
- * for more details.
2146
- *
2147
- * @static
2148
- * @since 0.1.0
2149
- * @memberOf _
2150
- * @category Object
2151
- * @param {Object} object The object to query.
2152
- * @returns {Array} Returns the array of property names.
2153
- * @example
2154
- *
2155
- * function Foo() {
2156
- * this.a = 1;
2157
- * this.b = 2;
2158
- * }
2159
- *
2160
- * Foo.prototype.c = 3;
2161
- *
2162
- * _.keys(new Foo);
2163
- * // => ['a', 'b'] (iteration order is not guaranteed)
2164
- *
2165
- * _.keys('hi');
2166
- * // => ['0', '1']
2167
- */
2168
- function keys(object) {
2169
- return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
2170
- }
2171
-
2172
- /**
2173
- * This method returns a new empty array.
2174
- *
2175
- * @static
2176
- * @memberOf _
2177
- * @since 4.13.0
2178
- * @category Util
2179
- * @returns {Array} Returns the new empty array.
2180
- * @example
2181
- *
2182
- * var arrays = _.times(2, _.stubArray);
2183
- *
2184
- * console.log(arrays);
2185
- * // => [[], []]
2186
- *
2187
- * console.log(arrays[0] === arrays[1]);
2188
- * // => false
2189
- */
2190
- function stubArray() {
2191
- return [];
2192
- }
2193
-
2194
- /**
2195
- * This method returns `false`.
2196
- *
2197
- * @static
2198
- * @memberOf _
2199
- * @since 4.13.0
2200
- * @category Util
2201
- * @returns {boolean} Returns `false`.
2202
- * @example
2203
- *
2204
- * _.times(2, _.stubFalse);
2205
- * // => [false, false]
2206
- */
2207
- function stubFalse() {
2208
- return false;
2209
- }
2210
-
2211
- module.exports = isEqual;
2212
- });
2213
-
2214
- /**
2215
- * lodash (Custom Build) <https://lodash.com/>
2216
- * Build: `lodash modularize exports="npm" -o ./`
2217
- * Copyright jQuery Foundation and other contributors <https://jquery.org/>
2218
- * Released under MIT license <https://lodash.com/license>
2219
- * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2220
- * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2221
- */
2222
-
2223
- /** Used as references for various `Number` constants. */
2224
- var INFINITY = 1 / 0,
2225
- MAX_SAFE_INTEGER = 9007199254740991;
2226
-
2227
- /** `Object#toString` result references. */
2228
- var argsTag = '[object Arguments]',
2229
- funcTag = '[object Function]',
2230
- genTag = '[object GeneratorFunction]',
2231
- symbolTag = '[object Symbol]';
2232
-
2233
- /** Detect free variable `global` from Node.js. */
2234
- var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
2235
-
2236
- /** Detect free variable `self`. */
2237
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
2238
-
2239
- /** Used as a reference to the global object. */
2240
- var root = freeGlobal || freeSelf || Function('return this')();
2241
-
2242
- /**
2243
- * A faster alternative to `Function#apply`, this function invokes `func`
2244
- * with the `this` binding of `thisArg` and the arguments of `args`.
2245
- *
2246
- * @private
2247
- * @param {Function} func The function to invoke.
2248
- * @param {*} thisArg The `this` binding of `func`.
2249
- * @param {Array} args The arguments to invoke `func` with.
2250
- * @returns {*} Returns the result of `func`.
2251
- */
2252
- function apply(func, thisArg, args) {
2253
- switch (args.length) {
2254
- case 0: return func.call(thisArg);
2255
- case 1: return func.call(thisArg, args[0]);
2256
- case 2: return func.call(thisArg, args[0], args[1]);
2257
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
2258
- }
2259
- return func.apply(thisArg, args);
2260
- }
2261
-
2262
- /**
2263
- * A specialized version of `_.map` for arrays without support for iteratee
2264
- * shorthands.
2265
- *
2266
- * @private
2267
- * @param {Array} [array] The array to iterate over.
2268
- * @param {Function} iteratee The function invoked per iteration.
2269
- * @returns {Array} Returns the new mapped array.
2270
- */
2271
- function arrayMap(array, iteratee) {
2272
- var index = -1,
2273
- length = array ? array.length : 0,
2274
- result = Array(length);
2275
-
2276
- while (++index < length) {
2277
- result[index] = iteratee(array[index], index, array);
2278
- }
2279
- return result;
2280
- }
2281
-
2282
- /**
2283
- * Appends the elements of `values` to `array`.
2284
- *
2285
- * @private
2286
- * @param {Array} array The array to modify.
2287
- * @param {Array} values The values to append.
2288
- * @returns {Array} Returns `array`.
2289
- */
2290
- function arrayPush(array, values) {
2291
- var index = -1,
2292
- length = values.length,
2293
- offset = array.length;
2294
-
2295
- while (++index < length) {
2296
- array[offset + index] = values[index];
2297
- }
2298
- return array;
2299
- }
2300
-
2301
- /** Used for built-in method references. */
2302
- var objectProto = Object.prototype;
2303
-
2304
- /** Used to check objects for own properties. */
2305
- var hasOwnProperty = objectProto.hasOwnProperty;
2306
-
2307
- /**
2308
- * Used to resolve the
2309
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
2310
- * of values.
2311
- */
2312
- var objectToString = objectProto.toString;
2313
-
2314
- /** Built-in value references. */
2315
- var Symbol = root.Symbol,
2316
- propertyIsEnumerable = objectProto.propertyIsEnumerable,
2317
- spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;
2318
-
2319
- /* Built-in method references for those with the same name as other `lodash` methods. */
2320
- var nativeMax = Math.max;
2321
-
2322
- /**
2323
- * The base implementation of `_.flatten` with support for restricting flattening.
2324
- *
2325
- * @private
2326
- * @param {Array} array The array to flatten.
2327
- * @param {number} depth The maximum recursion depth.
2328
- * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
2329
- * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
2330
- * @param {Array} [result=[]] The initial result value.
2331
- * @returns {Array} Returns the new flattened array.
2332
- */
2333
- function baseFlatten(array, depth, predicate, isStrict, result) {
2334
- var index = -1,
2335
- length = array.length;
2336
-
2337
- predicate || (predicate = isFlattenable);
2338
- result || (result = []);
2339
-
2340
- while (++index < length) {
2341
- var value = array[index];
2342
- if (depth > 0 && predicate(value)) {
2343
- if (depth > 1) {
2344
- // Recursively flatten arrays (susceptible to call stack limits).
2345
- baseFlatten(value, depth - 1, predicate, isStrict, result);
2346
- } else {
2347
- arrayPush(result, value);
2348
- }
2349
- } else if (!isStrict) {
2350
- result[result.length] = value;
2351
- }
2352
- }
2353
- return result;
2354
- }
2355
-
2356
- /**
2357
- * The base implementation of `_.pick` without support for individual
2358
- * property identifiers.
2359
- *
2360
- * @private
2361
- * @param {Object} object The source object.
2362
- * @param {string[]} props The property identifiers to pick.
2363
- * @returns {Object} Returns the new object.
2364
- */
2365
- function basePick(object, props) {
2366
- object = Object(object);
2367
- return basePickBy(object, props, function(value, key) {
2368
- return key in object;
2369
- });
2370
- }
2371
-
2372
- /**
2373
- * The base implementation of `_.pickBy` without support for iteratee shorthands.
2374
- *
2375
- * @private
2376
- * @param {Object} object The source object.
2377
- * @param {string[]} props The property identifiers to pick from.
2378
- * @param {Function} predicate The function invoked per property.
2379
- * @returns {Object} Returns the new object.
2380
- */
2381
- function basePickBy(object, props, predicate) {
2382
- var index = -1,
2383
- length = props.length,
2384
- result = {};
2385
-
2386
- while (++index < length) {
2387
- var key = props[index],
2388
- value = object[key];
2389
-
2390
- if (predicate(value, key)) {
2391
- result[key] = value;
2392
- }
2393
- }
2394
- return result;
2395
- }
2396
-
2397
- /**
2398
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
2399
- *
2400
- * @private
2401
- * @param {Function} func The function to apply a rest parameter to.
2402
- * @param {number} [start=func.length-1] The start position of the rest parameter.
2403
- * @returns {Function} Returns the new function.
2404
- */
2405
- function baseRest(func, start) {
2406
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
2407
- return function() {
2408
- var args = arguments,
2409
- index = -1,
2410
- length = nativeMax(args.length - start, 0),
2411
- array = Array(length);
2412
-
2413
- while (++index < length) {
2414
- array[index] = args[start + index];
2415
- }
2416
- index = -1;
2417
- var otherArgs = Array(start + 1);
2418
- while (++index < start) {
2419
- otherArgs[index] = args[index];
2420
- }
2421
- otherArgs[start] = array;
2422
- return apply(func, this, otherArgs);
2423
- };
2424
- }
2425
-
2426
- /**
2427
- * Checks if `value` is a flattenable `arguments` object or array.
2428
- *
2429
- * @private
2430
- * @param {*} value The value to check.
2431
- * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
2432
- */
2433
- function isFlattenable(value) {
2434
- return isArray(value) || isArguments(value) ||
2435
- !!(spreadableSymbol && value && value[spreadableSymbol]);
2436
- }
2437
-
2438
- /**
2439
- * Converts `value` to a string key if it's not a string or symbol.
2440
- *
2441
- * @private
2442
- * @param {*} value The value to inspect.
2443
- * @returns {string|symbol} Returns the key.
2444
- */
2445
- function toKey(value) {
2446
- if (typeof value == 'string' || isSymbol(value)) {
2447
- return value;
2448
- }
2449
- var result = (value + '');
2450
- return (result == '0' && (1 / value) == -INFINITY) ? '-0' : result;
2451
- }
2452
-
2453
- /**
2454
- * Checks if `value` is likely an `arguments` object.
2455
- *
2456
- * @static
2457
- * @memberOf _
2458
- * @since 0.1.0
2459
- * @category Lang
2460
- * @param {*} value The value to check.
2461
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
2462
- * else `false`.
2463
- * @example
2464
- *
2465
- * _.isArguments(function() { return arguments; }());
2466
- * // => true
2467
- *
2468
- * _.isArguments([1, 2, 3]);
2469
- * // => false
2470
- */
2471
- function isArguments(value) {
2472
- // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
2473
- return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
2474
- (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
2475
- }
2476
-
2477
- /**
2478
- * Checks if `value` is classified as an `Array` object.
2479
- *
2480
- * @static
2481
- * @memberOf _
2482
- * @since 0.1.0
2483
- * @category Lang
2484
- * @param {*} value The value to check.
2485
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
2486
- * @example
2487
- *
2488
- * _.isArray([1, 2, 3]);
2489
- * // => true
2490
- *
2491
- * _.isArray(document.body.children);
2492
- * // => false
2493
- *
2494
- * _.isArray('abc');
2495
- * // => false
2496
- *
2497
- * _.isArray(_.noop);
2498
- * // => false
2499
- */
2500
- var isArray = Array.isArray;
2501
-
2502
- /**
2503
- * Checks if `value` is array-like. A value is considered array-like if it's
2504
- * not a function and has a `value.length` that's an integer greater than or
2505
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
2506
- *
2507
- * @static
2508
- * @memberOf _
2509
- * @since 4.0.0
2510
- * @category Lang
2511
- * @param {*} value The value to check.
2512
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
2513
- * @example
2514
- *
2515
- * _.isArrayLike([1, 2, 3]);
2516
- * // => true
2517
- *
2518
- * _.isArrayLike(document.body.children);
2519
- * // => true
2520
- *
2521
- * _.isArrayLike('abc');
2522
- * // => true
2523
- *
2524
- * _.isArrayLike(_.noop);
2525
- * // => false
2526
- */
2527
- function isArrayLike(value) {
2528
- return value != null && isLength(value.length) && !isFunction(value);
2529
- }
2530
-
2531
- /**
2532
- * This method is like `_.isArrayLike` except that it also checks if `value`
2533
- * is an object.
2534
- *
2535
- * @static
2536
- * @memberOf _
2537
- * @since 4.0.0
2538
- * @category Lang
2539
- * @param {*} value The value to check.
2540
- * @returns {boolean} Returns `true` if `value` is an array-like object,
2541
- * else `false`.
2542
- * @example
2543
- *
2544
- * _.isArrayLikeObject([1, 2, 3]);
2545
- * // => true
2546
- *
2547
- * _.isArrayLikeObject(document.body.children);
2548
- * // => true
2549
- *
2550
- * _.isArrayLikeObject('abc');
2551
- * // => false
2552
- *
2553
- * _.isArrayLikeObject(_.noop);
2554
- * // => false
2555
- */
2556
- function isArrayLikeObject(value) {
2557
- return isObjectLike(value) && isArrayLike(value);
2558
- }
2559
-
2560
- /**
2561
- * Checks if `value` is classified as a `Function` object.
2562
- *
2563
- * @static
2564
- * @memberOf _
2565
- * @since 0.1.0
2566
- * @category Lang
2567
- * @param {*} value The value to check.
2568
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
2569
- * @example
2570
- *
2571
- * _.isFunction(_);
2572
- * // => true
2573
- *
2574
- * _.isFunction(/abc/);
2575
- * // => false
2576
- */
2577
- function isFunction(value) {
2578
- // The use of `Object#toString` avoids issues with the `typeof` operator
2579
- // in Safari 8-9 which returns 'object' for typed array and other constructors.
2580
- var tag = isObject(value) ? objectToString.call(value) : '';
2581
- return tag == funcTag || tag == genTag;
2582
- }
2583
-
2584
- /**
2585
- * Checks if `value` is a valid array-like length.
2586
- *
2587
- * **Note:** This method is loosely based on
2588
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
2589
- *
2590
- * @static
2591
- * @memberOf _
2592
- * @since 4.0.0
2593
- * @category Lang
2594
- * @param {*} value The value to check.
2595
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
2596
- * @example
2597
- *
2598
- * _.isLength(3);
2599
- * // => true
2600
- *
2601
- * _.isLength(Number.MIN_VALUE);
2602
- * // => false
2603
- *
2604
- * _.isLength(Infinity);
2605
- * // => false
2606
- *
2607
- * _.isLength('3');
2608
- * // => false
2609
- */
2610
- function isLength(value) {
2611
- return typeof value == 'number' &&
2612
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
2613
- }
2614
-
2615
- /**
2616
- * Checks if `value` is the
2617
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
2618
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
2619
- *
2620
- * @static
2621
- * @memberOf _
2622
- * @since 0.1.0
2623
- * @category Lang
2624
- * @param {*} value The value to check.
2625
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
2626
- * @example
2627
- *
2628
- * _.isObject({});
2629
- * // => true
2630
- *
2631
- * _.isObject([1, 2, 3]);
2632
- * // => true
2633
- *
2634
- * _.isObject(_.noop);
2635
- * // => true
2636
- *
2637
- * _.isObject(null);
2638
- * // => false
2639
- */
2640
- function isObject(value) {
2641
- var type = typeof value;
2642
- return !!value && (type == 'object' || type == 'function');
2643
- }
2644
-
2645
- /**
2646
- * Checks if `value` is object-like. A value is object-like if it's not `null`
2647
- * and has a `typeof` result of "object".
2648
- *
2649
- * @static
2650
- * @memberOf _
2651
- * @since 4.0.0
2652
- * @category Lang
2653
- * @param {*} value The value to check.
2654
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
2655
- * @example
2656
- *
2657
- * _.isObjectLike({});
2658
- * // => true
2659
- *
2660
- * _.isObjectLike([1, 2, 3]);
2661
- * // => true
2662
- *
2663
- * _.isObjectLike(_.noop);
2664
- * // => false
2665
- *
2666
- * _.isObjectLike(null);
2667
- * // => false
2668
- */
2669
- function isObjectLike(value) {
2670
- return !!value && typeof value == 'object';
2671
- }
2672
-
2673
- /**
2674
- * Checks if `value` is classified as a `Symbol` primitive or object.
2675
- *
2676
- * @static
2677
- * @memberOf _
2678
- * @since 4.0.0
2679
- * @category Lang
2680
- * @param {*} value The value to check.
2681
- * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
2682
- * @example
2683
- *
2684
- * _.isSymbol(Symbol.iterator);
2685
- * // => true
2686
- *
2687
- * _.isSymbol('abc');
2688
- * // => false
2689
- */
2690
- function isSymbol(value) {
2691
- return typeof value == 'symbol' ||
2692
- (isObjectLike(value) && objectToString.call(value) == symbolTag);
2693
- }
2694
-
2695
- /**
2696
- * Creates an object composed of the picked `object` properties.
2697
- *
2698
- * @static
2699
- * @since 0.1.0
2700
- * @memberOf _
2701
- * @category Object
2702
- * @param {Object} object The source object.
2703
- * @param {...(string|string[])} [props] The property identifiers to pick.
2704
- * @returns {Object} Returns the new object.
2705
- * @example
2706
- *
2707
- * var object = { 'a': 1, 'b': '2', 'c': 3 };
2708
- *
2709
- * _.pick(object, ['a', 'c']);
2710
- * // => { 'a': 1, 'c': 3 }
2711
- */
2712
- var pick = baseRest(function(object, props) {
2713
- return object == null ? {} : basePick(object, arrayMap(baseFlatten(props, 1), toKey));
2714
- });
2715
-
2716
- var lodash_pick = pick;
2717
-
2718
- function useFetchZones(params) {
2719
- const [fetchZones, resource] = useResource({
2720
- fetchResource: getZones,
2721
- initialValue: [],
2722
- context: params.context,
2723
- resourceName: 'Banner zones',
2724
- });
2725
- onMounted(() => {
2726
- fetchZones();
2727
- });
2728
- return resource;
2729
- }
2730
-
2731
- var Status;
2732
- (function (Status) {
2733
- Status["Waiting"] = "WAITING";
2734
- Status["Archived"] = "ARCHIVED";
2735
- Status["Active"] = "ACTIVE";
2736
- Status["Disabled"] = "DISABLED";
2737
- })(Status || (Status = {}));
2738
-
2739
- function getStatus(type, t) {
2740
- switch (type) {
2741
- case Status.Waiting:
2742
- return t('banners:statuses.waiting');
2743
- case Status.Archived:
2744
- return t('banners:statuses.archived');
2745
- case Status.Active:
2746
- return t('banners:statuses.active');
2747
- case Status.Disabled:
2748
- return t('banners:statuses.disabled');
2749
- default:
2750
- return '';
2751
- }
2752
- }
2753
- function getColumnDefs$1(zoneList, t) {
2754
- return [
2755
- {
2756
- id: 0,
2757
- name: '#',
2758
- field: 'id',
2759
- format: ({ rowIndex }) => String(rowIndex + 1),
2760
- style: { width: '50px', textAlign: 'center' },
2761
- headStyle: { width: '50px', textAlign: 'center' },
2762
- },
2763
- {
2764
- id: 1,
2765
- name: t('banners:zone'),
2766
- field: 'bannerZone',
2767
- format: ({ row }) => {
2768
- const foundBannerZone = zoneList.find((zone) => zone.id === row.bannerZone);
2769
- return foundBannerZone
2770
- ? foundBannerZone.name
2771
- : t('banners:bannerZoneIsDeleted');
2772
- },
2773
- },
2774
- {
2775
- id: 2,
2776
- name: t('banners:status'),
2777
- field: 'status',
2778
- format: ({ row }) => getStatus(row.status, t),
2779
- style: { width: '120px' },
2780
- headStyle: { width: '120px' },
2781
- },
2782
- {
2783
- id: 3,
2784
- name: t('banners:period'),
2785
- field: 'dateStart',
2786
- format: ({ row }) => `${row.dateStart ? `${t('banners:from')} ${row.dateStart}` : ''} ${row.dateEnd ? `${t('banners:to')} ${row.dateEnd}` : ''}`,
2787
- },
2788
- {
2789
- id: 4,
2790
- name: t('banners:image'),
2791
- field: 'image',
2792
- type: 'image',
2793
- },
2794
- {
2795
- id: 5,
2796
- name: t('banners:link'),
2797
- field: 'link',
2798
- type: 'name',
2799
- format: ({ row }) => {
2800
- var _a, _b;
2801
- return ({
2802
- adminLink: {
2803
- url: (_a = row.link) !== null && _a !== void 0 ? _a : '',
2804
- text: (_b = row.link) !== null && _b !== void 0 ? _b : '',
2805
- },
2806
- paramList: [
2807
- {
2808
- name: t('banners:newTab'),
2809
- value: row.openNewTab ? t('banners:yes') : t('banners:no'),
2810
- },
2811
- ],
2812
- });
2813
- },
2814
- options: {
2815
- shouldOpenNewTab: true,
2816
- },
2817
- },
2818
- {
2819
- id: 6,
2820
- name: t('banners:comment'),
2821
- field: 'comment',
2822
- },
2823
- {
2824
- id: 7,
2825
- name: t('banners:actions'),
2826
- field: 'actions',
2827
- style: { whiteSpace: 'nowrap', width: '100px' },
2828
- headStyle: { whiteSpace: 'nowrap', width: '100px' },
2829
- },
2830
- ];
2831
- }
2832
-
2833
- var FilterTypes;
2834
- (function (FilterTypes) {
2835
- FilterTypes["Zone"] = "zone";
2836
- FilterTypes["Date"] = "date";
2837
- FilterTypes["Status"] = "status";
2838
- })(FilterTypes || (FilterTypes = {}));
2839
- function useAdvancedSearch({ context, t, zoneList }) {
2840
- /** Zone **/
2841
- const zonesOptionList = computed(() => zoneList.value.map(({ id, name }) => ({
2842
- value: id,
2843
- label: name,
2844
- })));
2845
- const initialZoneFilter = computed(() => {
2846
- const queryValue = getFilterParamAsStringArray(context.root.$route.query, FilterTypes.Zone);
2847
- return zonesOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
2848
- });
2849
- const zoneFilter = ref(initialZoneFilter.value);
2850
- watch(initialZoneFilter, () => {
2851
- zoneFilter.value = initialZoneFilter.value;
2852
- });
2853
- /** Date **/
2854
- const initialDateFilter = computed(() => { var _a; return (_a = getFilterParamAsString(context.root.$route.query, FilterTypes.Date)) !== null && _a !== void 0 ? _a : ''; });
2855
- const dateFilter = ref(initialDateFilter.value);
2856
- watch(initialDateFilter, () => {
2857
- dateFilter.value = initialDateFilter.value;
2858
- });
2859
- /** Status **/
2860
- const statusesOptionList = computed(() => Object.entries(Status).map(([_, value]) => ({
2861
- value: value,
2862
- label: getStatus(value, t),
2863
- })));
2864
- const initialStatusFilter = computed(() => {
2865
- const queryValue = getFilterParamAsStringArray(context.root.$route.query, FilterTypes.Status);
2866
- return statusesOptionList.value.filter(({ value }) => queryValue.some((selected) => selected === value));
2867
- });
2868
- const statusFilter = ref(initialStatusFilter.value);
2869
- watch(initialStatusFilter, () => {
2870
- statusFilter.value = initialStatusFilter.value;
2871
- });
2872
- /** Params **/
2873
- const filterParams = computed(() => getFilterParams({
2874
- [FilterTypes.Zone]: zoneFilter.value.map(({ value }) => value),
2875
- [FilterTypes.Date]: dateFilter.value || [],
2876
- [FilterTypes.Status]: statusFilter.value.map(({ value }) => value),
2877
- }));
2878
- /** Tag removal handler **/
2879
- const tagRemovalHandler = (event) => {
2880
- if (event.name === FilterTypes.Zone) {
2881
- zoneFilter.value = zoneFilter.value.filter(({ value }) => value !== event.value);
2882
- }
2883
- if (event.name === FilterTypes.Date) {
2884
- dateFilter.value = '';
2885
- }
2886
- if (event.name === FilterTypes.Status) {
2887
- statusFilter.value = statusFilter.value.filter(({ value }) => value !== event.value);
2888
- }
2889
- };
2890
- /** Tags **/
2891
- const tags = computed(() => []);
2892
- return {
2893
- zoneFilter,
2894
- zonesOptionList,
2895
- dateFilter,
2896
- statusFilter,
2897
- statusesOptionList,
2898
- filterParams,
2899
- tags,
2900
- tagRemovalHandler,
2901
- };
2902
- }
2903
-
2904
- var script$1 = defineComponent({
2905
- name: 'BannerList',
2906
- setup(props, context) {
2907
- const { t } = useTranslation(context);
2908
- const { loading: isZonesLoading, data: zoneList } = useFetchZones({
2909
- context,
2910
- });
2911
- const { zoneFilter, zonesOptionList, dateFilter, statusFilter, statusesOptionList, filterParams, tags, tagRemovalHandler, } = useAdvancedSearch({
2912
- context,
2913
- t,
2914
- zoneList,
2915
- });
2916
- const { fetchEntityList: fetchBanners, isLoading: isBannersLoading, rowData, errorMessage, handleChange, searchQuery, pageNumber, pageCount, pageSize, } = useDataTable({
2917
- fetchEntityList: (params) => getBanners(Object.assign({ query: params.searchQuery, pageNumber: params.pageNumber, pageSize: params.pageSize }, filterParams.value)),
2918
- initialValue: [],
2919
- context,
2920
- resourceName: 'Banners',
2921
- });
2922
- watch(filterParams, () => {
2923
- if (isZonesLoading.value) {
2924
- return;
2925
- }
2926
- const newQuery = Object.assign(Object.assign({}, lodash_pick(context.root.$route.query, ['query', 'pageNumber'])), filterParams.value);
2927
- if (!lodash_isequal(context.root.$route.query, newQuery)) {
2928
- context.root.$router.replace({ query: newQuery });
2929
- fetchBanners();
2930
- }
2931
- });
2932
- const { isDeleting, handleResourceDelete } = useResourceDelete({
2933
- deleteResource: deleteBanner,
2934
- resourceName: 'Banner',
2935
- onSuccess: fetchBanners,
2936
- context,
2937
- });
2938
- const isBusy = (bannerId) => {
2939
- return isDeleting(bannerId) || isBannersLoading.value;
2940
- };
2941
- const columnDefs = computed(() => getColumnDefs$1(zoneList.value, context.root.$t));
2942
- const isRowDataLoading = computed(() => isBannersLoading.value || isZonesLoading.value);
2943
- return {
2944
- columnDefs,
2945
- isRowDataLoading,
2946
- rowData,
2947
- errorMessage,
2948
- handleChange,
2949
- getBannersBannerFormUrl,
2950
- searchQuery,
2951
- pageNumber,
2952
- pageCount,
2953
- pageSize,
2954
- isBusy,
2955
- handleResourceDelete,
2956
- // Advanced search
2957
- zoneFilter,
2958
- zonesOptionList,
2959
- dateFilter,
2960
- statusFilter,
2961
- statusesOptionList,
2962
- tags,
2963
- tagRemovalHandler,
2964
- };
2965
- },
2966
- });
2967
-
2968
- const isOldIE = typeof navigator !== 'undefined' &&
2969
- /msie [6-9]\\b/.test(navigator.userAgent.toLowerCase());
2970
- function createInjector(context) {
2971
- return (id, style) => addStyle(id, style);
2972
- }
2973
- let HEAD;
2974
- const styles = {};
2975
- function addStyle(id, css) {
2976
- const group = isOldIE ? css.media || 'default' : id;
2977
- const style = styles[group] || (styles[group] = { ids: new Set(), styles: [] });
2978
- if (!style.ids.has(id)) {
2979
- style.ids.add(id);
2980
- let code = css.source;
2981
- if (css.map) {
2982
- // https://developer.chrome.com/devtools/docs/javascript-debugging
2983
- // this makes source maps inside style tags work properly in Chrome
2984
- code += '\n/*# sourceURL=' + css.map.sources[0] + ' */';
2985
- // http://stackoverflow.com/a/26603875
2986
- code +=
2987
- '\n/*# sourceMappingURL=data:application/json;base64,' +
2988
- btoa(unescape(encodeURIComponent(JSON.stringify(css.map)))) +
2989
- ' */';
2990
- }
2991
- if (!style.element) {
2992
- style.element = document.createElement('style');
2993
- style.element.type = 'text/css';
2994
- if (css.media)
2995
- style.element.setAttribute('media', css.media);
2996
- if (HEAD === undefined) {
2997
- HEAD = document.head || document.getElementsByTagName('head')[0];
2998
- }
2999
- HEAD.appendChild(style.element);
3000
- }
3001
- if ('styleSheet' in style.element) {
3002
- style.styles.push(code);
3003
- style.element.styleSheet.cssText = style.styles
3004
- .filter(Boolean)
3005
- .join('\n');
3006
- }
3007
- else {
3008
- const index = style.ids.size - 1;
3009
- const textNode = document.createTextNode(code);
3010
- const nodes = style.element.childNodes;
3011
- if (nodes[index])
3012
- style.element.removeChild(nodes[index]);
3013
- if (nodes.length)
3014
- style.element.insertBefore(textNode, nodes[index]);
3015
- else
3016
- style.element.appendChild(textNode);
3017
- }
3018
- }
3019
- }
3020
-
3021
- /* script */
3022
- const __vue_script__$1 = script$1;
3023
-
3024
- /* template */
3025
- var __vue_render__$1 = function () {
3026
- var _vm = this;
3027
- var _h = _vm.$createElement;
3028
- var _c = _vm._self._c || _h;
3029
- return _c("page", {
3030
- attrs: {
3031
- title: _vm.$t("banners:banners"),
3032
- "header-buttons": [
3033
- {
3034
- text: _vm.$t("banners:createBanner"),
3035
- href: _vm.getBannersBannerFormUrl({ bannerId: "create" }),
3036
- },
3037
- ],
3038
- },
3039
- scopedSlots: _vm._u([
3040
- {
3041
- key: "content",
3042
- fn: function () {
3043
- return [
3044
- _c("data-table", {
3045
- attrs: {
3046
- "column-defs": _vm.columnDefs,
3047
- "row-data": _vm.rowData,
3048
- loading: _vm.isRowDataLoading,
3049
- "error-message": _vm.errorMessage,
3050
- "data-table": "banners",
3051
- "use-search": true,
3052
- "use-pagination": true,
3053
- "search-query": _vm.searchQuery,
3054
- pagination: {
3055
- pageNumber: _vm.pageNumber,
3056
- pageCount: _vm.pageCount,
3057
- pageSize: _vm.pageSize,
3058
- disabled: _vm.isRowDataLoading,
3059
- },
3060
- },
3061
- on: { change: _vm.handleChange },
3062
- scopedSlots: _vm._u([
3063
- {
3064
- key: "filters",
3065
- fn: function () {
3066
- return [
3067
- _c(
3068
- "advanced-search",
3069
- {
3070
- attrs: { tags: _vm.tags },
3071
- on: { "click:tag": _vm.tagRemovalHandler },
3072
- },
3073
- [
3074
- _c(
3075
- "div",
3076
- { staticClass: "filters" },
3077
- [
3078
- _c("form-field-multi-select", {
3079
- staticClass: "filter",
3080
- attrs: {
3081
- options: _vm.zonesOptionList,
3082
- name: "zoneFilter",
3083
- searchable: true,
3084
- label: _vm.$t("banners:zone"),
3085
- },
3086
- model: {
3087
- value: _vm.zoneFilter,
3088
- callback: function ($$v) {
3089
- _vm.zoneFilter = $$v;
3090
- },
3091
- expression: "zoneFilter",
3092
- },
3093
- }),
3094
- _vm._v(" "),
3095
- _c("form-field", {
3096
- staticClass: "filter",
3097
- attrs: {
3098
- label: _vm.$t("banners:date"),
3099
- name: "dateFilter",
3100
- type: "date",
3101
- },
3102
- model: {
3103
- value: _vm.dateFilter,
3104
- callback: function ($$v) {
3105
- _vm.dateFilter = $$v;
3106
- },
3107
- expression: "dateFilter",
3108
- },
3109
- }),
3110
- _vm._v(" "),
3111
- _c("form-field-multi-select", {
3112
- staticClass: "filter",
3113
- attrs: {
3114
- options: _vm.statusesOptionList,
3115
- name: "statusFilter",
3116
- searchable: true,
3117
- label: _vm.$t("banners:status"),
3118
- },
3119
- model: {
3120
- value: _vm.statusFilter,
3121
- callback: function ($$v) {
3122
- _vm.statusFilter = $$v;
3123
- },
3124
- expression: "statusFilter",
3125
- },
3126
- }),
3127
- ],
3128
- 1
3129
- ),
3130
- ]
3131
- ),
3132
- ]
3133
- },
3134
- proxy: true,
3135
- },
3136
- {
3137
- key: "cell(actions)",
3138
- fn: function (ref) {
3139
- var row = ref.row;
3140
- return [
3141
- _c(
3142
- "base-button",
3143
- {
3144
- attrs: {
3145
- variant: "icon",
3146
- title: _vm.$t("banners:edit"),
3147
- disabled: _vm.isBusy(row.id),
3148
- href: _vm.getBannersBannerFormUrl({
3149
- bannerId: row.id,
3150
- }),
3151
- },
3152
- },
3153
- [_c("svg-icon", { attrs: { name: "edit" } })],
3154
- 1
3155
- ),
3156
- _vm._v(" "),
3157
- _c(
3158
- "base-button",
3159
- {
3160
- attrs: {
3161
- variant: "icon",
3162
- title: _vm.$t("banners:remove"),
3163
- disabled: _vm.isBusy(row.id),
3164
- },
3165
- on: {
3166
- click: function ($event) {
3167
- return _vm.handleResourceDelete(row.id)
3168
- },
3169
- },
3170
- },
3171
- [_c("svg-icon", { attrs: { name: "delete" } })],
3172
- 1
3173
- ),
3174
- ]
3175
- },
3176
- },
3177
- ]),
3178
- }),
3179
- ]
3180
- },
3181
- proxy: true,
3182
- },
3183
- ]),
3184
- })
3185
- };
3186
- var __vue_staticRenderFns__$1 = [];
3187
- __vue_render__$1._withStripped = true;
3188
-
3189
- /* style */
3190
- const __vue_inject_styles__$1 = function (inject) {
3191
- if (!inject) return
3192
- inject("data-v-23927d9c_0", { source: ".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerList/BannerList.vue","BannerList.vue"],"names":[],"mappings":"AA0NA;EACA,aAAA;EACA,eAAA;ACzNA;AD2NA;EACA,gBAAA;ACzNA;AD4NA;EACA,oBAAA;EACA,UAAA;EACA,SAAA;AC1NA;;AAEA,yCAAyC","file":"BannerList.vue","sourcesContent":["<template>\n <page\n :title=\"$t('banners:banners')\"\n :header-buttons=\"[\n {\n text: $t('banners:createBanner'),\n href: getBannersBannerFormUrl({ bannerId: 'create' }),\n },\n ]\"\n >\n <template v-slot:content>\n <data-table\n :column-defs=\"columnDefs\"\n :row-data=\"rowData\"\n :loading=\"isRowDataLoading\"\n :error-message=\"errorMessage\"\n data-table=\"banners\"\n :use-search=\"true\"\n :use-pagination=\"true\"\n :search-query=\"searchQuery\"\n :pagination=\"{\n pageNumber,\n pageCount,\n pageSize,\n disabled: isRowDataLoading,\n }\"\n @change=\"handleChange\"\n >\n <template v-slot:filters>\n <advanced-search :tags=\"tags\" @click:tag=\"tagRemovalHandler\">\n <div class=\"filters\">\n <form-field-multi-select\n v-model=\"zoneFilter\"\n :options=\"zonesOptionList\"\n name=\"zoneFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:zone')\"\n class=\"filter\"\n />\n\n <form-field\n v-model=\"dateFilter\"\n :label=\"$t('banners:date')\"\n name=\"dateFilter\"\n type=\"date\"\n class=\"filter\"\n />\n\n <form-field-multi-select\n v-model=\"statusFilter\"\n :options=\"statusesOptionList\"\n name=\"statusFilter\"\n :searchable=\"true\"\n :label=\"$t('banners:status')\"\n class=\"filter\"\n />\n </div>\n </advanced-search>\n </template>\n\n <template v-slot:cell(actions)=\"{ row }\">\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:edit')\"\n :disabled=\"isBusy(row.id)\"\n :href=\"getBannersBannerFormUrl({ bannerId: row.id })\"\n >\n <svg-icon name=\"edit\" />\n </base-button>\n\n <base-button\n variant=\"icon\"\n :title=\"$t('banners:remove')\"\n :disabled=\"isBusy(row.id)\"\n @click=\"handleResourceDelete(row.id)\"\n >\n <svg-icon name=\"delete\" />\n </base-button>\n </template>\n </data-table>\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n SetupContext,\n watch,\n} from '@vue/composition-api';\nimport isEqual from 'lodash.isequal';\nimport pick from 'lodash.pick';\n\nimport {\n ColumnDefinition,\n useDataTable,\n useTranslation,\n} from '@tager/admin-ui';\nimport { useResourceDelete } from '@tager/admin-services';\n\nimport { deleteBanner, getBanners } from '../../../services/requests';\nimport { Banner } from '../../../typings/banners';\nimport { getBannersBannerFormUrl } from '../../../constants/paths';\nimport { useFetchZones } from '../../../hooks';\n\nimport { getColumnDefs } from './BannerList.helpers';\nimport { useAdvancedSearch } from './hooks';\n\nexport default defineComponent({\n name: 'BannerList',\n setup(props, context: SetupContext) {\n const { t } = useTranslation(context);\n const { loading: isZonesLoading, data: zoneList } = useFetchZones({\n context,\n });\n\n const {\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n filterParams,\n tags,\n tagRemovalHandler,\n } = useAdvancedSearch({\n context,\n t,\n zoneList,\n });\n\n const {\n fetchEntityList: fetchBanners,\n isLoading: isBannersLoading,\n rowData,\n errorMessage,\n handleChange,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n } = useDataTable<Banner>({\n fetchEntityList: (params) =>\n getBanners({\n query: params.searchQuery,\n pageNumber: params.pageNumber,\n pageSize: params.pageSize,\n ...filterParams.value,\n }),\n initialValue: [],\n context,\n resourceName: 'Banners',\n });\n\n watch(filterParams, () => {\n if (isZonesLoading.value) {\n return;\n }\n\n const newQuery = {\n ...pick(context.root.$route.query, ['query', 'pageNumber']),\n ...filterParams.value,\n };\n\n if (!isEqual(context.root.$route.query, newQuery)) {\n context.root.$router.replace({ query: newQuery });\n fetchBanners();\n }\n });\n\n const { isDeleting, handleResourceDelete } = useResourceDelete({\n deleteResource: deleteBanner,\n resourceName: 'Banner',\n onSuccess: fetchBanners,\n context,\n });\n\n const isBusy = (bannerId: number): boolean => {\n return isDeleting(bannerId) || isBannersLoading.value;\n };\n\n const columnDefs = computed<ColumnDefinition<Banner>[]>(() =>\n getColumnDefs(zoneList.value, context.root.$t)\n );\n\n const isRowDataLoading = computed<boolean>(\n () => isBannersLoading.value || isZonesLoading.value\n );\n\n return {\n columnDefs,\n isRowDataLoading,\n rowData,\n errorMessage,\n handleChange,\n getBannersBannerFormUrl,\n searchQuery,\n pageNumber,\n pageCount,\n pageSize,\n isBusy,\n handleResourceDelete,\n\n // Advanced search\n zoneFilter,\n zonesOptionList,\n dateFilter,\n statusFilter,\n statusesOptionList,\n tags,\n tagRemovalHandler,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.filters {\n display: flex;\n margin: 0 -10px;\n\n &:not(:first-child) {\n margin-top: 10px;\n }\n\n .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n }\n}\n</style>\n",".filters {\n display: flex;\n margin: 0 -10px;\n}\n.filters:not(:first-child) {\n margin-top: 10px;\n}\n.filters .filter {\n padding: 10px 10px 0;\n width: 50%;\n margin: 0;\n}\n\n/*# sourceMappingURL=BannerList.vue.map */"]}, media: undefined });
3193
-
3194
- };
3195
- /* scoped */
3196
- const __vue_scope_id__$1 = undefined;
3197
- /* module identifier */
3198
- const __vue_module_identifier__$1 = undefined;
3199
- /* functional template */
3200
- const __vue_is_functional_template__$1 = false;
3201
- /* style inject SSR */
3202
-
3203
- /* style inject shadow dom */
3204
-
3205
-
3206
-
3207
- const __vue_component__$1 = /*#__PURE__*/normalizeComponent(
3208
- { render: __vue_render__$1, staticRenderFns: __vue_staticRenderFns__$1 },
3209
- __vue_inject_styles__$1,
3210
- __vue_script__$1,
3211
- __vue_scope_id__$1,
3212
- __vue_is_functional_template__$1,
3213
- __vue_module_identifier__$1,
3214
- false,
3215
- createInjector,
3216
- undefined,
3217
- undefined
3218
- );
3219
-
3220
- function useFetchBanner({ context, bannerId, isCreation, }) {
3221
- const [fetchBanner, resource] = useResource({
3222
- fetchResource: () => getBanner(bannerId.value),
3223
- initialValue: null,
3224
- context,
3225
- resourceName: 'Banner',
3226
- });
3227
- onMounted(() => {
3228
- if (isCreation.value) {
3229
- return;
3230
- }
3231
- fetchBanner();
3232
- });
3233
- watch(bannerId, () => {
3234
- if (isCreation.value) {
3235
- return;
3236
- }
3237
- fetchBanner();
3238
- });
3239
- return resource;
3240
- }
3241
-
3242
- function convertBannerToFormValues(banner, zonesOptionList) {
3243
- var _a, _b, _c, _d, _e, _f;
3244
- const foundZone = zonesOptionList.find(({ value }) => value === (banner === null || banner === void 0 ? void 0 : banner.bannerZone));
3245
- return {
3246
- link: (_a = banner === null || banner === void 0 ? void 0 : banner.link) !== null && _a !== void 0 ? _a : '',
3247
- image: (banner === null || banner === void 0 ? void 0 : banner.image) ? { id: createId(), file: banner.image } : null,
3248
- bannerZone: foundZone !== null && foundZone !== void 0 ? foundZone : null,
3249
- openNewTab: (_b = banner === null || banner === void 0 ? void 0 : banner.openNewTab) !== null && _b !== void 0 ? _b : false,
3250
- dateStart: (_c = banner === null || banner === void 0 ? void 0 : banner.dateStart) !== null && _c !== void 0 ? _c : '',
3251
- dateEnd: (_d = banner === null || banner === void 0 ? void 0 : banner.dateEnd) !== null && _d !== void 0 ? _d : '',
3252
- disabled: (_e = banner === null || banner === void 0 ? void 0 : banner.disabled) !== null && _e !== void 0 ? _e : false,
3253
- comment: (_f = banner === null || banner === void 0 ? void 0 : banner.comment) !== null && _f !== void 0 ? _f : '',
3254
- };
3255
- }
3256
- function convertBannerFormValuesToPayload(values) {
3257
- var _a, _b, _c, _d;
3258
- return Object.assign(Object.assign({}, values), { image: (_b = (_a = values.image) === null || _a === void 0 ? void 0 : _a.file.id) !== null && _b !== void 0 ? _b : null, bannerZone: (_d = (_c = values.bannerZone) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : '' });
3259
- }
3260
-
3261
- var script$2 = defineComponent({
3262
- name: 'BannerForm',
3263
- components: { FormFooter },
3264
- setup(props, context) {
3265
- const bannerId = computed(() => context.root.$route.params.bannerId);
3266
- const isCreation = computed(() => bannerId.value === 'create');
3267
- /** Zones **/
3268
- const { data: zones, loading: isZonesLoading } = useFetchZones({ context });
3269
- const zonesOptionList = computed(() => zones.value.map((zone) => ({
3270
- value: zone.id,
3271
- label: zone.name,
3272
- })));
3273
- /** Banner **/
3274
- const { data: banner, loading: isBannerLoading } = useFetchBanner({
3275
- context,
3276
- bannerId,
3277
- isCreation,
3278
- });
3279
- /** Form State **/
3280
- const isSubmitting = ref(false);
3281
- const values = ref(convertBannerToFormValues(banner.value, zonesOptionList.value));
3282
- const errors = ref({});
3283
- watch([banner, zones], () => {
3284
- values.value = convertBannerToFormValues(banner.value, zonesOptionList.value);
3285
- });
3286
- const submitForm = (event) => {
3287
- isSubmitting.value = true;
3288
- const body = convertBannerFormValuesToPayload(values.value);
3289
- const requestPromise = isCreation.value
3290
- ? createBanner(body)
3291
- : updateBanner(bannerId.value, body);
3292
- requestPromise
3293
- .then(({ data }) => {
3294
- errors.value = {};
3295
- if (event.type === 'create') {
3296
- context.root.$router.push(getBannersBannerFormUrl({ bannerId: String(data.id) }));
3297
- }
3298
- if (event.type === 'create_exit' || event.type === 'save_exit') {
3299
- context.root.$router.push(getBannersBannerListUrl());
3300
- }
3301
- if (event.type === 'create_create-another') {
3302
- values.value = convertBannerToFormValues(null, zonesOptionList.value);
3303
- }
3304
- context.root.$toast({
3305
- variant: 'success',
3306
- title: context.root.$t('banners:success'),
3307
- body: isCreation.value
3308
- ? context.root.$t('banners:bannerWasSuccessfullyCreated')
3309
- : context.root.$t('banners:bannerWasSuccessfullyUpdated'),
3310
- });
3311
- })
3312
- .catch((error) => {
3313
- console.error(error);
3314
- errors.value = convertRequestErrorToMap(error);
3315
- context.root.$toast({
3316
- variant: 'danger',
3317
- title: context.root.$t('banners:error'),
3318
- body: isCreation.value
3319
- ? context.root.$t('banners:bannerCreationWasFailed')
3320
- : context.root.$t('banners:bannerUpdateWasFailed'),
3321
- });
3322
- })
3323
- .finally(() => {
3324
- isSubmitting.value = false;
3325
- });
3326
- };
3327
- const isContentLoading = computed(() => isBannerLoading.value || isZonesLoading.value);
3328
- return {
3329
- isCreation,
3330
- isContentLoading,
3331
- isSubmitting,
3332
- values,
3333
- errors,
3334
- submitForm,
3335
- bannerListUrl: getBannersBannerListUrl(),
3336
- zonesOptionList,
3337
- };
3338
- },
3339
- });
3340
-
3341
- /* script */
3342
- const __vue_script__$2 = script$2;
3343
-
3344
- /* template */
3345
- var __vue_render__$2 = function () {
3346
- var _vm = this;
3347
- var _h = _vm.$createElement;
3348
- var _c = _vm._self._c || _h;
3349
- return _c("page", {
3350
- attrs: {
3351
- title: _vm.isCreation
3352
- ? _vm.$t("banners:createBanner")
3353
- : _vm.$t("banners:updateBanner"),
3354
- "is-content-loading": _vm.isContentLoading,
3355
- },
3356
- scopedSlots: _vm._u([
3357
- {
3358
- key: "content",
3359
- fn: function () {
3360
- return [
3361
- _c(
3362
- "form",
3363
- {
3364
- attrs: { novalidate: "" },
3365
- on: {
3366
- submit: function ($event) {
3367
- $event.preventDefault();
3368
- return _vm.submitForm($event)
3369
- },
3370
- },
3371
- },
3372
- [
3373
- _c("form-field-select", {
3374
- attrs: {
3375
- name: "bannerZone",
3376
- label: _vm.$t("banners:zone"),
3377
- options: _vm.zonesOptionList,
3378
- error: _vm.errors.bannerZone,
3379
- },
3380
- model: {
3381
- value: _vm.values.bannerZone,
3382
- callback: function ($$v) {
3383
- _vm.$set(_vm.values, "bannerZone", $$v);
3384
- },
3385
- expression: "values.bannerZone",
3386
- },
3387
- }),
3388
- _vm._v(" "),
3389
- _c("form-field-file-input", {
3390
- attrs: {
3391
- name: "image",
3392
- "file-type": "image",
3393
- label: _vm.$t("banners:image"),
3394
- error: _vm.errors.file,
3395
- },
3396
- model: {
3397
- value: _vm.values.image,
3398
- callback: function ($$v) {
3399
- _vm.$set(_vm.values, "image", $$v);
3400
- },
3401
- expression: "values.image",
3402
- },
3403
- }),
3404
- _vm._v(" "),
3405
- _c("form-field", {
3406
- attrs: {
3407
- name: "link",
3408
- label: _vm.$t("banners:link"),
3409
- error: _vm.errors.name,
3410
- },
3411
- model: {
3412
- value: _vm.values.link,
3413
- callback: function ($$v) {
3414
- _vm.$set(_vm.values, "link", $$v);
3415
- },
3416
- expression: "values.link",
3417
- },
3418
- }),
3419
- _vm._v(" "),
3420
- _c("form-field-checkbox", {
3421
- attrs: {
3422
- name: "openNewTab",
3423
- label: _vm.$t("banners:openNewTab"),
3424
- error: _vm.errors.openNewTab,
3425
- },
3426
- model: {
3427
- value: _vm.values.openNewTab,
3428
- callback: function ($$v) {
3429
- _vm.$set(_vm.values, "openNewTab", $$v);
3430
- },
3431
- expression: "values.openNewTab",
3432
- },
3433
- }),
3434
- _vm._v(" "),
3435
- _c("input-label", [_vm._v(_vm._s(_vm.$t("banners:period")))]),
3436
- _vm._v(" "),
3437
- _c(
3438
- "div",
3439
- { staticClass: "date" },
3440
- [
3441
- _c("form-field", {
3442
- attrs: {
3443
- label: _vm.$t("banners:from"),
3444
- name: "dateStart",
3445
- type: "date",
3446
- max: _vm.values.dateEnd,
3447
- },
3448
- model: {
3449
- value: _vm.values.dateStart,
3450
- callback: function ($$v) {
3451
- _vm.$set(_vm.values, "dateStart", $$v);
3452
- },
3453
- expression: "values.dateStart",
3454
- },
3455
- }),
3456
- _vm._v(" "),
3457
- _c("form-field", {
3458
- attrs: {
3459
- label: _vm.$t("banners:to"),
3460
- name: "dateEnd",
3461
- type: "date",
3462
- min: _vm.values.dateStart,
3463
- },
3464
- model: {
3465
- value: _vm.values.dateEnd,
3466
- callback: function ($$v) {
3467
- _vm.$set(_vm.values, "dateEnd", $$v);
3468
- },
3469
- expression: "values.dateEnd",
3470
- },
3471
- }),
3472
- ],
3473
- 1
3474
- ),
3475
- _vm._v(" "),
3476
- _c("form-field-checkbox", {
3477
- attrs: {
3478
- name: "disabled",
3479
- label: _vm.$t("banners:disabled"),
3480
- error: _vm.errors.disabled,
3481
- },
3482
- model: {
3483
- value: _vm.values.disabled,
3484
- callback: function ($$v) {
3485
- _vm.$set(_vm.values, "disabled", $$v);
3486
- },
3487
- expression: "values.disabled",
3488
- },
3489
- }),
3490
- _vm._v(" "),
3491
- _c("form-field", {
3492
- attrs: {
3493
- name: "comment",
3494
- type: "textarea",
3495
- label: _vm.$t("banners:comment"),
3496
- error: _vm.errors.comment,
3497
- },
3498
- model: {
3499
- value: _vm.values.comment,
3500
- callback: function ($$v) {
3501
- _vm.$set(_vm.values, "comment", $$v);
3502
- },
3503
- expression: "values.comment",
3504
- },
3505
- }),
3506
- ],
3507
- 1
3508
- ),
3509
- ]
3510
- },
3511
- proxy: true,
3512
- },
3513
- {
3514
- key: "footer",
3515
- fn: function () {
3516
- return [
3517
- _c("FormFooter", {
3518
- attrs: {
3519
- "back-href": _vm.bannerListUrl,
3520
- "on-submit": _vm.submitForm,
3521
- "is-submitting": _vm.isSubmitting,
3522
- "is-creation": _vm.isCreation,
3523
- "can-create-another": _vm.isCreation,
3524
- },
3525
- }),
3526
- ]
3527
- },
3528
- proxy: true,
3529
- },
3530
- ]),
3531
- })
3532
- };
3533
- var __vue_staticRenderFns__$2 = [];
3534
- __vue_render__$2._withStripped = true;
3535
-
3536
- /* style */
3537
- const __vue_inject_styles__$2 = function (inject) {
3538
- if (!inject) return
3539
- inject("data-v-60ad1218_0", { source: ".date {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=BannerForm.vue.map */", map: {"version":3,"sources":["/home/runner/work/tager-admin-banners/tager-admin-banners/src/views/Banners/BannerForm/BannerForm.vue","BannerForm.vue"],"names":[],"mappings":"AAsOA;EACA,aAAA;EACA,qCAAA;EACA,gBAAA;ACrOA;;AAEA,yCAAyC","file":"BannerForm.vue","sourcesContent":["<template>\n <page\n :title=\"\n isCreation ? $t('banners:createBanner') : $t('banners:updateBanner')\n \"\n :is-content-loading=\"isContentLoading\"\n >\n <template v-slot:content>\n <form novalidate @submit.prevent=\"submitForm\">\n <form-field-select\n v-model=\"values.bannerZone\"\n name=\"bannerZone\"\n :label=\"$t('banners:zone')\"\n :options=\"zonesOptionList\"\n :error=\"errors.bannerZone\"\n />\n\n <form-field-file-input\n v-model=\"values.image\"\n name=\"image\"\n file-type=\"image\"\n :label=\"$t('banners:image')\"\n :error=\"errors.file\"\n />\n\n <form-field\n v-model=\"values.link\"\n name=\"link\"\n :label=\"$t('banners:link')\"\n :error=\"errors.name\"\n />\n\n <form-field-checkbox\n v-model=\"values.openNewTab\"\n name=\"openNewTab\"\n :label=\"$t('banners:openNewTab')\"\n :error=\"errors.openNewTab\"\n />\n\n <input-label>{{ $t('banners:period') }}</input-label>\n\n <div class=\"date\">\n <form-field\n v-model=\"values.dateStart\"\n :label=\"$t('banners:from')\"\n name=\"dateStart\"\n type=\"date\"\n :max=\"values.dateEnd\"\n />\n\n <form-field\n v-model=\"values.dateEnd\"\n :label=\"$t('banners:to')\"\n name=\"dateEnd\"\n type=\"date\"\n :min=\"values.dateStart\"\n />\n </div>\n\n <form-field-checkbox\n v-model=\"values.disabled\"\n name=\"disabled\"\n :label=\"$t('banners:disabled')\"\n :error=\"errors.disabled\"\n />\n\n <form-field\n v-model=\"values.comment\"\n name=\"comment\"\n type=\"textarea\"\n :label=\"$t('banners:comment')\"\n :error=\"errors.comment\"\n />\n </form>\n </template>\n\n <template v-slot:footer>\n <FormFooter\n :back-href=\"bannerListUrl\"\n :on-submit=\"submitForm\"\n :is-submitting=\"isSubmitting\"\n :is-creation=\"isCreation\"\n :can-create-another=\"isCreation\"\n />\n </template>\n </page>\n</template>\n\n<script lang=\"ts\">\nimport {\n computed,\n defineComponent,\n ref,\n SetupContext,\n watch,\n} from '@vue/composition-api';\n\nimport { FormFooter, OptionType, TagerFormSubmitEvent } from '@tager/admin-ui';\nimport { convertRequestErrorToMap } from '@tager/admin-services';\n\nimport { useFetchZones } from '../../../hooks';\nimport { BannerFormValues } from '../../../typings/banners';\nimport { useFetchBanner } from '../../../hooks/useFetchBanner';\nimport {\n getBannersBannerFormUrl,\n getBannersBannerListUrl,\n} from '../../../constants/paths';\nimport { createBanner, updateBanner } from '../../../services/requests';\n\nimport {\n convertBannerFormValuesToPayload,\n convertBannerToFormValues,\n} from './BannerForm.helpers';\n\nexport default defineComponent({\n name: 'BannerForm',\n components: { FormFooter },\n setup(props, context: SetupContext) {\n const bannerId = computed<string>(\n () => context.root.$route.params.bannerId\n );\n const isCreation = computed<boolean>(() => bannerId.value === 'create');\n\n /** Zones **/\n\n const { data: zones, loading: isZonesLoading } = useFetchZones({ context });\n\n const zonesOptionList = computed<OptionType[]>(() =>\n zones.value.map<OptionType>((zone) => ({\n value: zone.id,\n label: zone.name,\n }))\n );\n\n /** Banner **/\n\n const { data: banner, loading: isBannerLoading } = useFetchBanner({\n context,\n bannerId,\n isCreation,\n });\n\n /** Form State **/\n\n const isSubmitting = ref<boolean>(false);\n const values = ref<BannerFormValues>(\n convertBannerToFormValues(banner.value, zonesOptionList.value)\n );\n const errors = ref<Record<string, string>>({});\n\n watch([banner, zones], () => {\n values.value = convertBannerToFormValues(\n banner.value,\n zonesOptionList.value\n );\n });\n\n const submitForm = (event: TagerFormSubmitEvent) => {\n isSubmitting.value = true;\n\n const body = convertBannerFormValuesToPayload(values.value);\n\n const requestPromise = isCreation.value\n ? createBanner(body)\n : updateBanner(bannerId.value, body);\n\n requestPromise\n .then(({ data }) => {\n errors.value = {};\n\n if (event.type === 'create') {\n context.root.$router.push(\n getBannersBannerFormUrl({ bannerId: String(data.id) })\n );\n }\n\n if (event.type === 'create_exit' || event.type === 'save_exit') {\n context.root.$router.push(getBannersBannerListUrl());\n }\n\n if (event.type === 'create_create-another') {\n values.value = convertBannerToFormValues(\n null,\n zonesOptionList.value\n );\n }\n\n context.root.$toast({\n variant: 'success',\n title: context.root.$t('banners:success'),\n body: isCreation.value\n ? context.root.$t('banners:bannerWasSuccessfullyCreated')\n : context.root.$t('banners:bannerWasSuccessfullyUpdated'),\n });\n })\n .catch((error) => {\n console.error(error);\n errors.value = convertRequestErrorToMap(error);\n context.root.$toast({\n variant: 'danger',\n title: context.root.$t('banners:error'),\n body: isCreation.value\n ? context.root.$t('banners:bannerCreationWasFailed')\n : context.root.$t('banners:bannerUpdateWasFailed'),\n });\n })\n .finally(() => {\n isSubmitting.value = false;\n });\n };\n\n const isContentLoading = computed<boolean>(\n () => isBannerLoading.value || isZonesLoading.value\n );\n\n return {\n isCreation,\n isContentLoading,\n isSubmitting,\n values,\n errors,\n submitForm,\n bannerListUrl: getBannersBannerListUrl(),\n zonesOptionList,\n };\n },\n});\n</script>\n\n<style lang=\"scss\">\n.date {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n</style>\n",".date {\n display: grid;\n grid-template-columns: repeat(2, 1fr);\n column-gap: 10px;\n}\n\n/*# sourceMappingURL=BannerForm.vue.map */"]}, media: undefined });
3540
-
3541
- };
3542
- /* scoped */
3543
- const __vue_scope_id__$2 = undefined;
3544
- /* module identifier */
3545
- const __vue_module_identifier__$2 = undefined;
3546
- /* functional template */
3547
- const __vue_is_functional_template__$2 = false;
3548
- /* style inject SSR */
3549
-
3550
- /* style inject shadow dom */
3551
-
3552
-
3553
-
3554
- const __vue_component__$2 = /*#__PURE__*/normalizeComponent(
3555
- { render: __vue_render__$2, staticRenderFns: __vue_staticRenderFns__$2 },
3556
- __vue_inject_styles__$2,
3557
- __vue_script__$2,
3558
- __vue_scope_id__$2,
3559
- __vue_is_functional_template__$2,
3560
- __vue_module_identifier__$2,
3561
- false,
3562
- createInjector,
3563
- undefined,
3564
- undefined
3565
- );
3566
-
3567
- const BANNERS_ZONE_LIST_ROUTE = {
3568
- path: BANNERS_ROUTE_PATHS.ZONE_LIST,
3569
- component: __vue_component__,
3570
- name: 'Zones',
3571
- meta: {
3572
- getBreadcrumbs: (route, t) => [
3573
- { url: '/', text: t('banners:home') },
3574
- { url: BANNERS_ROUTE_PATHS.ZONE_LIST, text: t('banners:zones') },
3575
- ],
3576
- },
3577
- };
3578
- const BANNERS_BANNER_LIST_ROUTE = {
3579
- path: BANNERS_ROUTE_PATHS.BANNER_LIST,
3580
- component: __vue_component__$1,
3581
- name: 'Banners',
3582
- meta: {
3583
- getBreadcrumbs: (route, t) => [
3584
- { url: '/', text: t('banners:home') },
3585
- { url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t('banners:banners') },
3586
- ],
3587
- },
3588
- };
3589
- const BANNERS_BANNER_FORM_ROUTE = {
3590
- path: BANNERS_ROUTE_PATHS.BANNER_FORM,
3591
- component: __vue_component__$2,
3592
- name: 'Banner Form',
3593
- meta: {
3594
- getBreadcrumbs: (route, t) => [
3595
- { url: '/', text: t('banners:home') },
3596
- { url: BANNERS_ROUTE_PATHS.BANNER_LIST, text: t('banners:banners') },
3597
- { url: route.path, text: t('banners:bannerForm') },
3598
- ],
3599
- },
3600
- };
3601
-
3602
- function getBannersMenuItem(params) {
3603
- return {
3604
- id: 'banners',
3605
- text: params.t('banners:banners'),
3606
- icon: 'viewList',
3607
- children: [
3608
- { text: params.t('banners:zones'), url: getBannersZoneListUrl() },
3609
- { text: params.t('banners:banners'), url: getBannersBannerListUrl() },
3610
- {
3611
- text: params.t('banners:createBanner'),
3612
- url: getBannersBannerFormUrl({ bannerId: 'create' }),
3613
- },
3614
- ],
3615
- };
3616
- }
3617
-
3618
- i18n.addTranslations('en', 'banners', EN);
3619
- i18n.addTranslations('ru', 'banners', RU);
3620
-
3621
- export { BANNERS_BANNER_FORM_ROUTE, BANNERS_BANNER_LIST_ROUTE, BANNERS_ROUTE_PATHS, BANNERS_ZONE_LIST_ROUTE, createBanner, deleteBanner, getBanner, getBannerCount, getBanners, getBannersBannerFormUrl, getBannersBannerListUrl, getBannersMenuItem, getBannersZoneListUrl, getZones, updateBanner };