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