UNPKG

109 kBJavaScriptView Raw
1/*
2Copyright (c) NAVER Corp.
3name: @egjs/infinitegrid
4license: MIT
5author: NAVER Corp.
6repository: https://github.com/naver/egjs-infinitegrid
7version: 4.6.0
8*/
9'use strict';
10
11var Component = require('@egjs/component');
12var Grid = require('@egjs/grid');
13var listDiffer = require('@egjs/list-differ');
14
15/*! *****************************************************************************
16Copyright (c) Microsoft Corporation.
17
18Permission to use, copy, modify, and/or distribute this software for any
19purpose with or without fee is hereby granted.
20
21THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
22REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
23AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
25LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27PERFORMANCE OF THIS SOFTWARE.
28***************************************************************************** */
29
30/* global Reflect, Promise */
31var extendStatics = function (d, b) {
32 extendStatics = Object.setPrototypeOf || {
33 __proto__: []
34 } instanceof Array && function (d, b) {
35 d.__proto__ = b;
36 } || function (d, b) {
37 for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p];
38 };
39
40 return extendStatics(d, b);
41};
42
43function __extends(d, b) {
44 if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
45 extendStatics(d, b);
46
47 function __() {
48 this.constructor = d;
49 }
50
51 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
52}
53var __assign = function () {
54 __assign = Object.assign || function __assign(t) {
55 for (var s, i = 1, n = arguments.length; i < n; i++) {
56 s = arguments[i];
57
58 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
59 }
60
61 return t;
62 };
63
64 return __assign.apply(this, arguments);
65};
66function __rest(s, e) {
67 var t = {};
68
69 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
70
71 if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
72 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
73 }
74 return t;
75}
76function __decorate(decorators, target, key, desc) {
77 var c = arguments.length,
78 r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
79 d;
80 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
81 return c > 3 && r && Object.defineProperty(target, key, r), r;
82}
83/** @deprecated */
84
85function __spreadArrays() {
86 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
87
88 for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j];
89
90 return r;
91}
92
93var ua = typeof window !== "undefined" ? window.navigator.userAgent : "";
94var IS_IOS = /iPhone|iPad/.test(ua);
95var CONTAINER_CLASS_NAME = "infinitegrid-container";
96var IGNORE_PROPERITES_MAP = {
97 renderOnPropertyChange: true,
98 useFit: true,
99 autoResize: true
100};
101var INFINITEGRID_PROPERTY_TYPES = __assign({}, Grid.GRID_PROPERTY_TYPES);
102var DIRECTION = {
103 START: "start",
104 END: "end",
105 NONE: ""
106};
107var INFINITEGRID_EVENTS = {
108 CHANGE_SCROLL: "changeScroll",
109 REQUEST_APPEND: "requestAppend",
110 REQUEST_PREPEND: "requestPrepend",
111 RENDER_COMPLETE: "renderComplete",
112 CONTENT_ERROR: "contentError"
113}; // type?: ITEM_TYPE;
114// groupKey?: string | number;
115// key?: string | number;
116// element?: HTMLElement | null;
117// html?: string;
118// data?: Record<string, any>;
119
120var ITEM_INFO_PROPERTIES = {
121 type: true,
122 groupKey: true,
123 key: true,
124 element: true,
125 html: true,
126 data: true
127};
128var INFINITEGRID_METHODS = ["insertByGroupIndex", "updateItems", "getItems", "getVisibleItems", "getGroups", "getVisibleGroups", "renderItems", "getContainerElement", "getScrollContainerElement", "getWrapperElement", "setStatus", "getStatus", "removePlaceholders", "prependPlaceholders", "appendPlaceholders", "getStartCursor", "getEndCursor", "setCursors"];
129var GROUP_TYPE;
130
131(function (GROUP_TYPE) {
132 GROUP_TYPE[GROUP_TYPE["NORMAL"] = 0] = "NORMAL";
133 GROUP_TYPE[GROUP_TYPE["VIRTUAL"] = 1] = "VIRTUAL";
134 GROUP_TYPE[GROUP_TYPE["LOADING"] = 2] = "LOADING";
135})(GROUP_TYPE || (GROUP_TYPE = {}));
136
137var ITEM_TYPE;
138
139(function (ITEM_TYPE) {
140 ITEM_TYPE[ITEM_TYPE["NORMAL"] = 0] = "NORMAL";
141 ITEM_TYPE[ITEM_TYPE["VIRTUAL"] = 1] = "VIRTUAL";
142 ITEM_TYPE[ITEM_TYPE["LOADING"] = 2] = "LOADING";
143})(ITEM_TYPE || (ITEM_TYPE = {}));
144
145var STATUS_TYPE;
146
147(function (STATUS_TYPE) {
148 // does not remove anything.
149 STATUS_TYPE[STATUS_TYPE["NOT_REMOVE"] = 0] = "NOT_REMOVE"; // Minimize information on invisible items
150
151 STATUS_TYPE[STATUS_TYPE["MINIMIZE_INVISIBLE_ITEMS"] = 1] = "MINIMIZE_INVISIBLE_ITEMS"; // Minimize information on invisible groups
152
153 STATUS_TYPE[STATUS_TYPE["MINIMIZE_INVISIBLE_GROUPS"] = 2] = "MINIMIZE_INVISIBLE_GROUPS"; // remove invisible groups
154
155 STATUS_TYPE[STATUS_TYPE["REMOVE_INVISIBLE_GROUPS"] = 3] = "REMOVE_INVISIBLE_GROUPS";
156})(STATUS_TYPE || (STATUS_TYPE = {}));
157
158var INVISIBLE_POS = -9999;
159
160/**
161 * @extends Grid.GridItem
162 */
163
164var InfiniteGridItem =
165/*#__PURE__*/
166function (_super) {
167 __extends(InfiniteGridItem, _super);
168
169 function InfiniteGridItem(horizontal, itemStatus) {
170 var _this = _super.call(this, horizontal, __assign({
171 html: "",
172 type: ITEM_TYPE.NORMAL,
173 cssRect: {
174 top: INVISIBLE_POS,
175 left: INVISIBLE_POS
176 }
177 }, itemStatus)) || this;
178
179 if (_this.type === ITEM_TYPE.VIRTUAL) {
180 if (_this.rect.width || _this.rect.height) {
181 _this.mountState = Grid.MOUNT_STATE.UNMOUNTED;
182 }
183
184 var orgRect = _this.orgRect;
185 var rect = _this.rect;
186 var cssRect = _this.cssRect;
187
188 if (cssRect.width) {
189 rect.width = cssRect.width;
190 } else if (orgRect.width) {
191 rect.width = orgRect.width;
192 }
193
194 if (cssRect.height) {
195 rect.height = cssRect.height;
196 } else if (orgRect.height) {
197 rect.height = orgRect.height;
198 }
199 }
200
201 return _this;
202 }
203
204 var __proto = InfiniteGridItem.prototype;
205
206 __proto.getVirtualStatus = function () {
207 return {
208 type: ITEM_TYPE.VIRTUAL,
209 groupKey: this.groupKey,
210 key: this.key,
211 orgRect: this.orgRect,
212 rect: this.rect,
213 cssRect: this.cssRect,
214 attributes: this.attributes
215 };
216 };
217
218 __proto.getMinimizedStatus = function () {
219 var status = __assign(__assign({}, _super.prototype.getMinimizedStatus.call(this)), {
220 type: ITEM_TYPE.NORMAL,
221 groupKey: this.groupKey
222 });
223
224 if (this.html) {
225 status.html = this.html;
226 }
227
228 return status;
229 };
230
231 return InfiniteGridItem;
232}(Grid.GridItem);
233
234var LOADING_GROUP_KEY = "__INFINITEGRID__LOADING_GRID";
235var LOADING_ITEM_KEY = "__INFINITEGRID__LOADING_ITEM";
236
237var LoadingGrid =
238/*#__PURE__*/
239function (_super) {
240 __extends(LoadingGrid, _super);
241
242 function LoadingGrid() {
243 var _this = _super !== null && _super.apply(this, arguments) || this;
244
245 _this.type = "";
246 return _this;
247 }
248
249 var __proto = LoadingGrid.prototype;
250
251 __proto.getLoadingItem = function () {
252 return this.items[0] || null;
253 };
254
255 __proto.setLoadingItem = function (item) {
256 if (item) {
257 var loadingItem = this.getLoadingItem();
258
259 if (!loadingItem) {
260 this.items = [new InfiniteGridItem(this.options.horizontal, __assign(__assign({}, item), {
261 type: ITEM_TYPE.LOADING,
262 key: LOADING_ITEM_KEY
263 }))];
264 } else {
265 for (var name in item) {
266 loadingItem[name] = item[name];
267 }
268 }
269 } else {
270 this.items = [];
271 }
272 };
273
274 __proto.applyGrid = function (items, direction, outline) {
275 if (!items.length) {
276 return {
277 start: outline,
278 end: outline
279 };
280 }
281
282 var nextOutline = outline.length ? __spreadArrays(outline) : [0];
283 var item = items[0];
284 var offset = item.contentSize + this.gap;
285 item.cssInlinePos = this.getContainerInlineSize() / 2 - item.inlineSize / 2;
286
287 if (direction === "end") {
288 var maxPos = Math.max.apply(Math, nextOutline);
289 item.cssContentPos = maxPos;
290 return {
291 start: nextOutline,
292 end: nextOutline.map(function (pos) {
293 return pos + offset;
294 })
295 };
296 } else {
297 var minPos = Math.min.apply(Math, nextOutline);
298 item.cssContentPos = minPos - offset;
299 return {
300 start: nextOutline.map(function (pos) {
301 return pos - offset;
302 }),
303 end: nextOutline
304 };
305 }
306 };
307
308 return LoadingGrid;
309}(Grid);
310
311function isWindow(el) {
312 return el === window;
313}
314function isNumber(val) {
315 return typeof val === "number";
316}
317function isString(val) {
318 return typeof val === "string";
319}
320function isObject(val) {
321 return typeof val === "object";
322}
323function flat(arr) {
324 return arr.reduce(function (prev, cur) {
325 return __spreadArrays(prev, cur);
326 }, []);
327}
328function splitOptions(options) {
329 var gridOptions = options.gridOptions,
330 otherOptions = __rest(options, ["gridOptions"]);
331
332 return __assign(__assign({}, splitGridOptions(gridOptions)), otherOptions);
333}
334function splitGridOptions(options) {
335 var nextOptions = {};
336 var gridOptions = {};
337 var defaultOptions = Grid.defaultOptions;
338
339 for (var name in options) {
340 var value = options[name];
341
342 if (!(name in IGNORE_PROPERITES_MAP)) {
343 gridOptions[name] = value;
344 }
345
346 if (name in defaultOptions) {
347 nextOptions[name] = value;
348 }
349 }
350
351 return __assign(__assign({}, nextOptions), {
352 gridOptions: gridOptions
353 });
354}
355function categorize(items) {
356 var groups = [];
357 var groupKeys = {};
358 var registeredGroupKeys = {};
359 items.filter(function (item) {
360 return item.groupKey != null;
361 }).forEach(function (_a) {
362 var groupKey = _a.groupKey;
363 registeredGroupKeys[groupKey] = true;
364 });
365 var generatedGroupKey;
366 var isContinuousGroupKey = false;
367 items.forEach(function (item) {
368 if (item.groupKey != null) {
369 isContinuousGroupKey = false;
370 } else {
371 if (!isContinuousGroupKey) {
372 generatedGroupKey = makeKey(registeredGroupKeys);
373 isContinuousGroupKey = true;
374 registeredGroupKeys[generatedGroupKey] = true;
375 }
376
377 item.groupKey = generatedGroupKey;
378 }
379
380 var groupKey = item.groupKey;
381 var group = groupKeys[groupKey];
382
383 if (!group) {
384 group = {
385 groupKey: groupKey,
386 items: []
387 };
388 groupKeys[groupKey] = group;
389 groups.push(group);
390 }
391
392 group.items.push(item);
393 });
394 return groups;
395}
396function getNextCursors(prevKeys, nextKeys, prevStartCursor, prevEndCursor) {
397 var result = listDiffer.diff(prevKeys, nextKeys, function (key) {
398 return key;
399 });
400 var nextStartCursor = -1;
401 var nextEndCursor = -1; // sync cursors
402
403 result.maintained.forEach(function (_a) {
404 var prevIndex = _a[0],
405 nextIndex = _a[1];
406
407 if (prevStartCursor <= prevIndex && prevIndex <= prevEndCursor) {
408 if (nextStartCursor === -1) {
409 nextStartCursor = nextIndex;
410 nextEndCursor = nextIndex;
411 } else {
412 nextStartCursor = Math.min(nextStartCursor, nextIndex);
413 nextEndCursor = Math.max(nextEndCursor, nextIndex);
414 }
415 }
416 });
417 return {
418 startCursor: nextStartCursor,
419 endCursor: nextEndCursor
420 };
421}
422function splitVirtualGroups(groups, direction, nextGroups) {
423 var virtualGroups = [];
424
425 if (direction === "start") {
426 var index = findIndex(groups, function (group) {
427 return group.type === GROUP_TYPE.NORMAL;
428 });
429
430 if (index === -1) {
431 return [];
432 } // Get the virtual group maintained in the group from the next group.
433
434
435 var endMaintainedIndex = findIndex(groups, function (group) {
436 return findIndex(nextGroups, function (nextGroup) {
437 return nextGroup.groupKey === group.groupKey;
438 }) >= 0;
439 });
440 var endIndex = endMaintainedIndex >= 0 ? Math.min(index, endMaintainedIndex) : index;
441 virtualGroups = groups.slice(0, endIndex);
442 } else {
443 var index = findLastIndex(groups, function (group) {
444 return group.type === GROUP_TYPE.NORMAL;
445 });
446
447 if (index === -1) {
448 return [];
449 }
450
451 var startMaintainedIndex = findLastIndex(groups, function (group) {
452 return findIndex(nextGroups, function (nextGroup) {
453 return nextGroup.groupKey === group.groupKey;
454 }) >= 0;
455 });
456 var startIndex = startMaintainedIndex >= 0 ? Math.max(index, startMaintainedIndex) : index;
457 virtualGroups = groups.slice(startIndex + 1);
458 }
459
460 return virtualGroups;
461}
462function getFirstRenderingItems(nextItems, horizontal) {
463 var groups = categorize(nextItems);
464
465 if (!groups[0]) {
466 return [];
467 }
468
469 return groups[0].items.map(function (item) {
470 return new InfiniteGridItem(horizontal, __assign({}, item));
471 });
472}
473function getRenderingItemsByStatus(groupManagerStatus, nextItems, usePlaceholder, horizontal) {
474 var prevGroups = groupManagerStatus.groups;
475 var groups = categorize(nextItems);
476 var startVirtualGroups = splitVirtualGroups(prevGroups, "start", groups);
477 var endVirtualGroups = splitVirtualGroups(prevGroups, "end", groups);
478
479 var nextGroups = __spreadArrays(startVirtualGroups, groups, endVirtualGroups);
480
481 var _a = getNextCursors(prevGroups.map(function (group) {
482 return group.groupKey;
483 }), nextGroups.map(function (group) {
484 return group.groupKey;
485 }), groupManagerStatus.cursors[0], groupManagerStatus.cursors[1]),
486 startCursor = _a.startCursor,
487 endCursor = _a.endCursor;
488
489 var nextVisibleItems = flat(nextGroups.slice(startCursor, endCursor + 1).map(function (group) {
490 return group.items.map(function (item) {
491 return new InfiniteGridItem(horizontal, __assign({}, item));
492 });
493 }));
494
495 if (!usePlaceholder) {
496 nextVisibleItems = nextVisibleItems.filter(function (item) {
497 return item.type !== ITEM_TYPE.VIRTUAL;
498 });
499 }
500
501 return nextVisibleItems;
502}
503function mountRenderingItems(items, options) {
504 var grid = options.grid,
505 usePlaceholder = options.usePlaceholder,
506 useLoading = options.useLoading,
507 useFirstRender = options.useFirstRender,
508 status = options.status;
509
510 if (!grid) {
511 return;
512 }
513
514 if (usePlaceholder) {
515 grid.setPlaceholder({});
516 }
517
518 if (useLoading) {
519 grid.setLoading({});
520 }
521
522 if (status) {
523 grid.setStatus(status, true);
524 }
525
526 grid.syncItems(items);
527
528 if (useFirstRender && !status && grid.getGroups().length) {
529 grid.setCursors(0, 0, true);
530 }
531}
532function getRenderingItems(items, options) {
533 var status = options.status,
534 usePlaceholder = options.usePlaceholder,
535 useLoading = options.useLoading,
536 horizontal = options.horizontal,
537 useFirstRender = options.useFirstRender,
538 grid = options.grid;
539 var visibleItems = [];
540
541 if (grid) {
542 grid.setPlaceholder(usePlaceholder ? {} : null);
543 grid.setLoading(useLoading ? {} : null);
544 grid.syncItems(items);
545 visibleItems = grid.getRenderingItems();
546 } else if (status) {
547 visibleItems = getRenderingItemsByStatus(status.groupManager, items, !!usePlaceholder, !!horizontal);
548 } else if (useFirstRender) {
549 visibleItems = getFirstRenderingItems(items, !!horizontal);
550 }
551
552 return visibleItems;
553}
554/* Class Decorator */
555
556function InfiniteGridGetterSetter(component) {
557 var prototype = component.prototype,
558 propertyTypes = component.propertyTypes;
559
560 var _loop_1 = function (name) {
561 var attributes = {
562 enumerable: true,
563 configurable: true,
564 get: function () {
565 var options = this.groupManager.options;
566
567 if (name in options) {
568 return options[name];
569 } else {
570 return options.gridOptions[name];
571 }
572 },
573 set: function (value) {
574 var _a;
575
576 var prevValue = this.groupManager[name];
577
578 if (prevValue === value) {
579 return;
580 }
581
582 this.groupManager.gridOptions = (_a = {}, _a[name] = value, _a);
583 }
584 };
585 Object.defineProperty(prototype, name, attributes);
586 };
587
588 for (var name in propertyTypes) {
589 _loop_1(name);
590 }
591}
592function makeKey(registeredKeys) {
593 var index = 0; // eslint-disable-next-line no-constant-condition
594
595 while (true) {
596 var key = "infinitegrid_" + index++;
597
598 if (!(key in registeredKeys)) {
599 return key;
600 }
601 }
602}
603function convertHTMLtoElement(html) {
604 var dummy = document.createElement("div");
605 dummy.innerHTML = html;
606 return toArray(dummy.children);
607}
608function convertInsertedItems(items, groupKey) {
609 var insertedItems;
610
611 if (isString(items)) {
612 insertedItems = convertHTMLtoElement(items);
613 } else {
614 insertedItems = items;
615 }
616
617 return insertedItems.map(function (item) {
618 var element;
619 var html = "";
620 var key;
621
622 if (isString(item)) {
623 html = item;
624 } else if ("parentNode" in item) {
625 element = item;
626 html = item.outerHTML;
627 } else {
628 return __assign({
629 groupKey: groupKey
630 }, item);
631 }
632
633 return {
634 key: key,
635 groupKey: groupKey,
636 html: html,
637 element: element
638 };
639 });
640}
641function toArray(nodes) {
642 var array = [];
643
644 if (nodes) {
645 var length = nodes.length;
646
647 for (var i = 0; i < length; i++) {
648 array.push(nodes[i]);
649 }
650 }
651
652 return array;
653}
654function findIndex(arr, callback) {
655 var length = arr.length;
656
657 for (var i = 0; i < length; ++i) {
658 if (callback(arr[i], i)) {
659 return i;
660 }
661 }
662
663 return -1;
664}
665function findLastIndex(arr, callback) {
666 var length = arr.length;
667
668 for (var i = length - 1; i >= 0; --i) {
669 if (callback(arr[i], i)) {
670 return i;
671 }
672 }
673
674 return -1;
675}
676function getItemInfo(info) {
677 var nextInfo = {};
678
679 for (var name in info) {
680 if (name in ITEM_INFO_PROPERTIES) {
681 nextInfo[name] = info[name];
682 }
683 }
684
685 return nextInfo;
686}
687function setPlaceholder(item, info) {
688 for (var name in info) {
689 var value = info[name];
690
691 if (isObject(value)) {
692 item[name] = __assign(__assign({}, item[name]), value);
693 } else {
694 item[name] = info[name];
695 }
696 }
697}
698function isFlatOutline(start, end) {
699 return start.length === end.length && start.every(function (pos, i) {
700 return end[i] === pos;
701 });
702}
703function range(length) {
704 var arr = [];
705
706 for (var i = 0; i < length; ++i) {
707 arr.push(i);
708 }
709
710 return arr;
711}
712function flatGroups(groups) {
713 return flat(groups.map(function (_a) {
714 var grid = _a.grid;
715 return grid.getItems();
716 }));
717}
718function filterVirtuals(items, includePlaceholders) {
719 if (includePlaceholders) {
720 return items;
721 } else {
722 return items.filter(function (item) {
723 return item.type !== ITEM_TYPE.VIRTUAL;
724 });
725 }
726}
727/**
728 * Decorator that makes the method of InfiniteGrid available in the framework.
729 * @ko 프레임워크에서 InfiniteGrid의 메소드를 사용할 수 있게 하는 데코레이터.
730 * @private
731 * @example
732 * ```js
733 * import { withInfiniteGridMethods } from "@egjs/infinitegrid";
734 *
735 * class Grid extends React.Component<Partial<InfiniteGridProps & InfiniteGridOptions>> {
736 * &#64;withInfiniteGridMethods
737 * private grid: NativeGrid;
738 * }
739 * ```
740 */
741
742var withInfiniteGridMethods = Grid.withMethods(INFINITEGRID_METHODS);
743
744var GroupManager =
745/*#__PURE__*/
746function (_super) {
747 __extends(GroupManager, _super);
748
749 function GroupManager(container, options) {
750 var _this = _super.call(this, container, splitOptions(options)) || this;
751
752 _this.groupItems = [];
753 _this.groups = [];
754 _this.itemKeys = {};
755 _this.groupKeys = {};
756 _this.startCursor = 0;
757 _this.endCursor = 0;
758 _this._placeholder = null;
759 _this._loadingGrid = new LoadingGrid(container, {
760 externalContainerManager: _this.containerManager,
761 useFit: false,
762 autoResize: false,
763 renderOnPropertyChange: false,
764 gap: _this.gap
765 });
766 _this._mainGrid = _this._makeGrid();
767 return _this;
768 }
769
770 var __proto = GroupManager.prototype;
771 Object.defineProperty(__proto, "gridOptions", {
772 set: function (options) {
773 var _a = splitGridOptions(options),
774 gridOptions = _a.gridOptions,
775 otherOptions = __rest(_a, ["gridOptions"]);
776
777 var shouldRender = this._checkShouldRender(options);
778
779 this.options.gridOptions = __assign(__assign({}, this.options.gridOptions), gridOptions);
780
781 __spreadArrays([this._mainGrid], this.groups.map(function (_a) {
782 var grid = _a.grid;
783 return grid;
784 })).forEach(function (grid) {
785 for (var name in options) {
786 grid[name] = options[name];
787 }
788 });
789
790 for (var name in otherOptions) {
791 this[name] = otherOptions[name];
792 }
793
794 this._loadingGrid.gap = this.gap;
795
796 if (shouldRender) {
797 this.scheduleRender();
798 }
799 },
800 enumerable: false,
801 configurable: true
802 });
803
804 __proto.getItemByKey = function (key) {
805 return this.itemKeys[key] || null;
806 };
807
808 __proto.getGroupItems = function (includePlaceholders) {
809 return filterVirtuals(this.groupItems, includePlaceholders);
810 };
811
812 __proto.getVisibleItems = function (includePlaceholders) {
813 return filterVirtuals(this.items, includePlaceholders);
814 };
815
816 __proto.getRenderingItems = function () {
817 if (this.hasPlaceholder()) {
818 return this.items;
819 } else {
820 return this.items.filter(function (item) {
821 return item.type !== ITEM_TYPE.VIRTUAL;
822 });
823 }
824 };
825
826 __proto.getGroups = function (includePlaceholders) {
827 return filterVirtuals(this.groups, includePlaceholders);
828 };
829
830 __proto.hasVisibleVirtualGroups = function () {
831 return this.getVisibleGroups(true).some(function (group) {
832 return group.type === GROUP_TYPE.VIRTUAL;
833 });
834 };
835
836 __proto.hasPlaceholder = function () {
837 return !!this._placeholder;
838 };
839
840 __proto.hasLoadingItem = function () {
841 return !!this._getLoadingItem();
842 };
843
844 __proto.updateItems = function (items, options) {
845 if (items === void 0) {
846 items = this.groupItems;
847 }
848
849 return _super.prototype.updateItems.call(this, items, options);
850 };
851
852 __proto.setPlaceholder = function (placeholder) {
853 this._placeholder = placeholder;
854
855 this._updatePlaceholder();
856 };
857
858 __proto.getLoadingType = function () {
859 return this._loadingGrid.type;
860 };
861
862 __proto.startLoading = function (type) {
863 this._loadingGrid.type = type;
864 this.items = this._getRenderingItems();
865 return true;
866 };
867
868 __proto.endLoading = function () {
869 var prevType = this._loadingGrid.type;
870 this._loadingGrid.type = "";
871 this.items = this._getRenderingItems();
872 return !!prevType;
873 };
874
875 __proto.setLoading = function (loading) {
876 this._loadingGrid.setLoadingItem(loading);
877
878 this.items = this._getRenderingItems();
879 };
880
881 __proto.getVisibleGroups = function (includePlaceholders) {
882 var groups = this.groups.slice(this.startCursor, this.endCursor + 1);
883 return filterVirtuals(groups, includePlaceholders);
884 };
885
886 __proto.getComputedOutlineLength = function (items) {
887 if (items === void 0) {
888 items = this.items;
889 }
890
891 return this._mainGrid.getComputedOutlineLength(items);
892 };
893
894 __proto.getComputedOutlineSize = function (items) {
895 if (items === void 0) {
896 items = this.items;
897 }
898
899 return this._mainGrid.getComputedOutlineSize(items);
900 };
901
902 __proto.applyGrid = function (items, direction, outline) {
903 var _this = this;
904
905 var renderingGroups = this.groups.slice();
906
907 if (!renderingGroups.length) {
908 return {
909 start: [],
910 end: []
911 };
912 }
913
914 var loadingGrid = this._loadingGrid;
915
916 if (loadingGrid.getLoadingItem()) {
917 if (loadingGrid.type === "start") {
918 renderingGroups.unshift(this._getLoadingGroup());
919 } else if (loadingGrid.type === "end") {
920 renderingGroups.push(this._getLoadingGroup());
921 }
922 }
923
924 var groups = renderingGroups.slice();
925 var nextOutline = outline;
926
927 if (direction === "start") {
928 groups.reverse();
929 }
930
931 var groupItems = this.groupItems;
932 var outlineLength = this.getComputedOutlineLength(groupItems);
933 var outlineSize = this.getComputedOutlineSize(groupItems);
934 groups.forEach(function (group) {
935 var grid = group.grid;
936 var gridItems = grid.getItems();
937 var isVirtual = group.type === GROUP_TYPE.VIRTUAL && !gridItems[0];
938 var appliedItems = gridItems.filter(function (item) {
939 return item.mountState !== Grid.MOUNT_STATE.UNCHECKED && item.rect.width;
940 });
941 var gridOutlines;
942 grid.outlineLength = outlineLength;
943 grid.outlineSize = outlineSize;
944
945 if (isVirtual) {
946 gridOutlines = _this._applyVirtualGrid(grid, direction, nextOutline);
947 } else if (appliedItems.length) {
948 gridOutlines = grid.applyGrid(appliedItems, direction, nextOutline);
949 } else {
950 gridOutlines = {
951 start: __spreadArrays(nextOutline),
952 end: __spreadArrays(nextOutline)
953 };
954 }
955
956 grid.setOutlines(gridOutlines);
957 nextOutline = gridOutlines[direction];
958 });
959 return {
960 start: renderingGroups[0].grid.getOutlines().start,
961 end: renderingGroups[renderingGroups.length - 1].grid.getOutlines().end
962 };
963 };
964
965 __proto.syncItems = function (nextItemInfos) {
966 var _this = this;
967
968 var prevItemKeys = this.itemKeys;
969 this.itemKeys = {};
970
971 var nextItems = this._syncItemInfos(nextItemInfos.map(function (info) {
972 return getItemInfo(info);
973 }), prevItemKeys);
974
975 var prevGroupKeys = this.groupKeys;
976 var nextManagerGroups = categorize(nextItems);
977
978 var startVirtualGroups = this._splitVirtualGroups("start", nextManagerGroups);
979
980 var endVirtualGroups = this._splitVirtualGroups("end", nextManagerGroups);
981
982 nextManagerGroups = __spreadArrays(startVirtualGroups, this._mergeVirtualGroups(nextManagerGroups), endVirtualGroups);
983 var nextGroups = nextManagerGroups.map(function (_a) {
984 var _b, _c;
985
986 var groupKey = _a.groupKey,
987 items = _a.items;
988 var isVirtual = !items[0] || items[0].type === ITEM_TYPE.VIRTUAL;
989 var grid = (_c = (_b = prevGroupKeys[groupKey]) === null || _b === void 0 ? void 0 : _b.grid) !== null && _c !== void 0 ? _c : _this._makeGrid();
990 var gridItems = isVirtual ? items : items.filter(function (_a) {
991 var type = _a.type;
992 return type === ITEM_TYPE.NORMAL;
993 });
994 grid.setItems(gridItems);
995 return {
996 type: isVirtual ? GROUP_TYPE.VIRTUAL : GROUP_TYPE.NORMAL,
997 groupKey: groupKey,
998 grid: grid,
999 items: gridItems,
1000 renderItems: items
1001 };
1002 });
1003
1004 this._registerGroups(nextGroups);
1005 };
1006
1007 __proto.renderItems = function (options) {
1008 if (options === void 0) {
1009 options = {};
1010 }
1011
1012 if (options.useResize) {
1013 this.groupItems.forEach(function (item) {
1014 item.updateState = Grid.UPDATE_STATE.NEED_UPDATE;
1015 });
1016
1017 var loadingItem = this._getLoadingItem();
1018
1019 if (loadingItem) {
1020 loadingItem.updateState = Grid.UPDATE_STATE.NEED_UPDATE;
1021 }
1022 }
1023
1024 return _super.prototype.renderItems.call(this, options);
1025 };
1026
1027 __proto.setCursors = function (startCursor, endCursor) {
1028 this.startCursor = startCursor;
1029 this.endCursor = endCursor;
1030 this.items = this._getRenderingItems();
1031 };
1032
1033 __proto.getStartCursor = function () {
1034 return this.startCursor;
1035 };
1036
1037 __proto.getEndCursor = function () {
1038 return this.endCursor;
1039 };
1040
1041 __proto.getGroupStatus = function (type, includePlaceholders) {
1042 var orgStartCursor = this.startCursor;
1043 var orgEndCursor = this.endCursor;
1044 var orgGroups = this.groups;
1045 var startGroup = orgGroups[orgStartCursor];
1046 var endGroup = orgGroups[orgEndCursor];
1047 var startCursor = orgStartCursor;
1048 var endCursor = orgEndCursor;
1049 var isMinimizeItems = type === STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS;
1050 var isMinimizeGroups = type === STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS;
1051 var groups;
1052
1053 if (type === STATUS_TYPE.REMOVE_INVISIBLE_GROUPS) {
1054 groups = this.getVisibleGroups(includePlaceholders);
1055 endCursor = groups.length - 1;
1056 startCursor = 0;
1057 } else {
1058 groups = this.getGroups(includePlaceholders);
1059
1060 if (!includePlaceholders) {
1061 startCursor = -1;
1062 endCursor = -1;
1063
1064 for (var orgIndex = orgStartCursor; orgIndex <= orgEndCursor; ++orgIndex) {
1065 var orgGroup = orgGroups[orgIndex];
1066
1067 if (orgGroup && orgGroup.type !== GROUP_TYPE.VIRTUAL) {
1068 startCursor = groups.indexOf(orgGroup);
1069 break;
1070 }
1071 }
1072
1073 for (var orgIndex = orgEndCursor; orgIndex >= orgStartCursor; --orgIndex) {
1074 var orgGroup = orgGroups[orgIndex];
1075
1076 if (orgGroup && orgGroup.type !== GROUP_TYPE.VIRTUAL) {
1077 endCursor = groups.lastIndexOf(orgGroup);
1078 break;
1079 }
1080 }
1081 }
1082 }
1083
1084 var groupStatus = groups.map(function (_a, i) {
1085 var grid = _a.grid,
1086 groupKey = _a.groupKey;
1087 var isOutsideCursor = i < startCursor || endCursor < i;
1088 var isVirtualItems = isMinimizeItems && isOutsideCursor;
1089 var isVirtualGroup = isMinimizeGroups && isOutsideCursor;
1090 var gridItems = grid.getItems();
1091 var items = isVirtualGroup ? [] : gridItems.map(function (item) {
1092 return isVirtualItems ? item.getVirtualStatus() : item.getMinimizedStatus();
1093 });
1094 return {
1095 type: isVirtualGroup || isVirtualItems ? GROUP_TYPE.VIRTUAL : GROUP_TYPE.NORMAL,
1096 groupKey: groupKey,
1097 outlines: grid.getOutlines(),
1098 items: items
1099 };
1100 });
1101 var totalItems = this.getGroupItems();
1102 var itemStartCursor = totalItems.indexOf(startGroup === null || startGroup === void 0 ? void 0 : startGroup.items[0]);
1103 var itemEndCursor = totalItems.indexOf(endGroup === null || endGroup === void 0 ? void 0 : endGroup.items.slice().reverse()[0]);
1104 return {
1105 cursors: [startCursor, endCursor],
1106 orgCursors: [orgStartCursor, orgEndCursor],
1107 itemCursors: [itemStartCursor, itemEndCursor],
1108 startGroupKey: startGroup === null || startGroup === void 0 ? void 0 : startGroup.groupKey,
1109 endGroupKey: endGroup === null || endGroup === void 0 ? void 0 : endGroup.groupKey,
1110 groups: groupStatus,
1111 outlines: this.outlines
1112 };
1113 };
1114
1115 __proto.fitOutlines = function (useFit) {
1116 if (useFit === void 0) {
1117 useFit = this.useFit;
1118 }
1119
1120 var groups = this.groups;
1121 var firstGroup = groups[0];
1122
1123 if (!firstGroup) {
1124 return;
1125 }
1126
1127 var outlines = firstGroup.grid.getOutlines();
1128 var startOutline = outlines.start;
1129 var outlineOffset = startOutline.length ? Math.min.apply(Math, startOutline) : 0; // If the outline is less than 0, a fit occurs forcibly.
1130
1131 if (!useFit && outlineOffset > 0) {
1132 return;
1133 }
1134
1135 groups.forEach(function (_a) {
1136 var grid = _a.grid;
1137
1138 var _b = grid.getOutlines(),
1139 start = _b.start,
1140 end = _b.end;
1141
1142 grid.setOutlines({
1143 start: start.map(function (point) {
1144 return point - outlineOffset;
1145 }),
1146 end: end.map(function (point) {
1147 return point - outlineOffset;
1148 })
1149 });
1150 });
1151 this.groupItems.forEach(function (item) {
1152 var contentPos = item.cssContentPos;
1153
1154 if (!isNumber(contentPos)) {
1155 return;
1156 }
1157
1158 item.cssContentPos = contentPos - outlineOffset;
1159 });
1160 };
1161
1162 __proto.setGroupStatus = function (status) {
1163 var _this = this;
1164
1165 this.itemKeys = {};
1166 this.groupItems = [];
1167 this.items = [];
1168 var prevGroupKeys = this.groupKeys;
1169 var nextGroups = status.groups.map(function (_a) {
1170 var _b, _c;
1171
1172 var type = _a.type,
1173 groupKey = _a.groupKey,
1174 items = _a.items,
1175 outlines = _a.outlines;
1176
1177 var nextItems = _this._syncItemInfos(items);
1178
1179 var grid = (_c = (_b = prevGroupKeys[groupKey]) === null || _b === void 0 ? void 0 : _b.grid) !== null && _c !== void 0 ? _c : _this._makeGrid();
1180 grid.setOutlines(outlines);
1181 grid.setItems(nextItems);
1182 return {
1183 type: type,
1184 groupKey: groupKey,
1185 grid: grid,
1186 items: nextItems,
1187 renderItems: nextItems
1188 };
1189 });
1190 this.setOutlines(status.outlines);
1191
1192 this._registerGroups(nextGroups);
1193
1194 this._updatePlaceholder();
1195
1196 this.setCursors(status.cursors[0], status.cursors[1]);
1197 };
1198
1199 __proto.appendPlaceholders = function (items, groupKey) {
1200 return this.insertPlaceholders("end", items, groupKey);
1201 };
1202
1203 __proto.prependPlaceholders = function (items, groupKey) {
1204 return this.insertPlaceholders("start", items, groupKey);
1205 };
1206
1207 __proto.removePlaceholders = function (type) {
1208 var groups = this.groups;
1209 var length = groups.length;
1210
1211 if (type === "start") {
1212 var index = findIndex(groups, function (group) {
1213 return group.type === GROUP_TYPE.NORMAL;
1214 });
1215 groups.splice(0, index);
1216 } else if (type === "end") {
1217 var index = findLastIndex(groups, function (group) {
1218 return group.type === GROUP_TYPE.NORMAL;
1219 });
1220 groups.splice(index + 1, length - index - 1);
1221 } else {
1222 var groupKey_1 = type.groupKey;
1223 var index = findIndex(groups, function (group) {
1224 return group.groupKey === groupKey_1;
1225 });
1226
1227 if (index > -1) {
1228 groups.splice(index, 1);
1229 }
1230 }
1231
1232 this.syncItems(flatGroups(this.getGroups()));
1233 };
1234
1235 __proto.insertPlaceholders = function (direction, items, groupKey) {
1236 var _a, _b;
1237
1238 if (groupKey === void 0) {
1239 groupKey = makeKey(this.groupKeys);
1240 }
1241
1242 var infos = [];
1243
1244 if (isNumber(items)) {
1245 infos = range(items).map(function () {
1246 return {
1247 type: ITEM_TYPE.VIRTUAL,
1248 groupKey: groupKey
1249 };
1250 });
1251 } else if (Array.isArray(items)) {
1252 infos = items.map(function (status) {
1253 return __assign(__assign({
1254 groupKey: groupKey
1255 }, status), {
1256 type: ITEM_TYPE.VIRTUAL
1257 });
1258 });
1259 }
1260
1261 var grid = this._makeGrid();
1262
1263 var nextItems = this._syncItemInfos(infos, this.itemKeys);
1264
1265 this._updatePlaceholder(nextItems);
1266
1267 grid.setItems(nextItems);
1268 var group = {
1269 type: GROUP_TYPE.VIRTUAL,
1270 groupKey: groupKey,
1271 grid: grid,
1272 items: nextItems,
1273 renderItems: nextItems
1274 };
1275 this.groupKeys[groupKey] = group;
1276
1277 if (direction === "end") {
1278 this.groups.push(group);
1279
1280 (_a = this.groupItems).push.apply(_a, nextItems);
1281 } else {
1282 this.groups.splice(0, 0, group);
1283
1284 (_b = this.groupItems).splice.apply(_b, __spreadArrays([0, 0], nextItems));
1285
1286 if (this.startCursor > -1) {
1287 ++this.startCursor;
1288 ++this.endCursor;
1289 }
1290 }
1291
1292 return {
1293 group: group,
1294 items: nextItems
1295 };
1296 };
1297
1298 __proto.shouldRerenderItems = function () {
1299 var isRerender = false;
1300 this.getVisibleGroups().forEach(function (group) {
1301 var items = group.items;
1302
1303 if (items.length === group.renderItems.length || items.every(function (item) {
1304 return item.mountState === Grid.MOUNT_STATE.UNCHECKED;
1305 })) {
1306 return;
1307 }
1308
1309 isRerender = true;
1310 group.renderItems = __spreadArrays(items);
1311 });
1312
1313 if (isRerender) {
1314 this.items = this._getRenderingItems();
1315 }
1316
1317 return isRerender;
1318 };
1319
1320 __proto._getGroupItems = function () {
1321 return flatGroups(this.getGroups(true));
1322 };
1323
1324 __proto._getRenderingItems = function () {
1325 var items = flat(this.getVisibleGroups(true).map(function (item) {
1326 return item.renderItems;
1327 }));
1328 var loadingGrid = this._loadingGrid;
1329 var loadingItem = loadingGrid.getLoadingItem();
1330
1331 if (loadingItem) {
1332 if (loadingGrid.type === "end") {
1333 items.push(loadingItem);
1334 } else if (loadingGrid.type === "start") {
1335 items.unshift(loadingItem);
1336 }
1337 }
1338
1339 return items;
1340 };
1341
1342 __proto._checkShouldRender = function (options) {
1343 var GridConstructor = this.options.gridConstructor;
1344 var prevOptions = this.gridOptions;
1345 var propertyTypes = GridConstructor.propertyTypes;
1346
1347 for (var name in prevOptions) {
1348 if (!(name in options) && propertyTypes[name] === Grid.PROPERTY_TYPE.RENDER_PROPERTY) {
1349 return true;
1350 }
1351 }
1352
1353 for (var name in options) {
1354 if (prevOptions[name] !== options[name] && propertyTypes[name] === Grid.PROPERTY_TYPE.RENDER_PROPERTY) {
1355 return true;
1356 }
1357 }
1358
1359 return false;
1360 };
1361
1362 __proto._applyVirtualGrid = function (grid, direction, outline) {
1363 var startOutline = outline.length ? __spreadArrays(outline) : [0];
1364 var prevOutlines = grid.getOutlines();
1365 var prevOutline = prevOutlines[direction === "end" ? "start" : "end"];
1366
1367 if (prevOutline.length !== startOutline.length || prevOutline.some(function (value, i) {
1368 return value !== startOutline[i];
1369 })) {
1370 return {
1371 start: __spreadArrays(startOutline),
1372 end: __spreadArrays(startOutline)
1373 };
1374 }
1375
1376 return prevOutlines;
1377 };
1378
1379 __proto._syncItemInfos = function (nextItemInfos, prevItemKeys) {
1380 if (prevItemKeys === void 0) {
1381 prevItemKeys = {};
1382 }
1383
1384 var horizontal = this.options.horizontal;
1385 var nextItemKeys = this.itemKeys;
1386 nextItemInfos.filter(function (info) {
1387 return info.key != null;
1388 }).forEach(function (info) {
1389 var key = info.key;
1390 var prevItem = prevItemKeys[key];
1391
1392 if (!prevItem) {
1393 nextItemKeys[key] = new InfiniteGridItem(horizontal, __assign({}, info));
1394 } else if (prevItem.type === ITEM_TYPE.VIRTUAL && info.type !== ITEM_TYPE.VIRTUAL) {
1395 nextItemKeys[key] = new InfiniteGridItem(horizontal, __assign({
1396 orgRect: prevItem.orgRect,
1397 rect: prevItem.rect
1398 }, info));
1399 } else {
1400 if (info.data) {
1401 prevItem.data = info.data;
1402 }
1403
1404 nextItemKeys[key] = prevItem;
1405 }
1406 });
1407 var nextItems = nextItemInfos.map(function (info) {
1408 var key = info.key;
1409
1410 if (info.key == null) {
1411 key = makeKey(nextItemKeys);
1412 }
1413
1414 var item = nextItemKeys[key];
1415
1416 if (!item) {
1417 var prevItem = prevItemKeys[key];
1418
1419 if (prevItem) {
1420 item = prevItem;
1421
1422 if (info.data) {
1423 item.data = info.data;
1424 }
1425 } else {
1426 item = new InfiniteGridItem(horizontal, __assign(__assign({}, info), {
1427 key: key
1428 }));
1429 }
1430
1431 nextItemKeys[key] = item;
1432 }
1433
1434 return item;
1435 });
1436 return nextItems;
1437 };
1438
1439 __proto._registerGroups = function (groups) {
1440 var nextGroupKeys = {};
1441 groups.forEach(function (group) {
1442 nextGroupKeys[group.groupKey] = group;
1443 });
1444 this.groups = groups;
1445 this.groupKeys = nextGroupKeys;
1446 this.groupItems = this._getGroupItems();
1447 };
1448
1449 __proto._splitVirtualGroups = function (direction, nextGroups) {
1450 var groups = splitVirtualGroups(this.groups, direction, nextGroups);
1451 var itemKeys = this.itemKeys;
1452 groups.forEach(function (_a) {
1453 var renderItems = _a.renderItems;
1454 renderItems.forEach(function (item) {
1455 itemKeys[item.key] = item;
1456 });
1457 });
1458 return groups;
1459 };
1460
1461 __proto._mergeVirtualGroups = function (groups) {
1462 var itemKeys = this.itemKeys;
1463 var groupKeys = this.groupKeys;
1464 groups.forEach(function (group) {
1465 var prevGroup = groupKeys[group.groupKey];
1466
1467 if (!prevGroup) {
1468 return;
1469 }
1470
1471 var items = group.items;
1472
1473 if (items.every(function (item) {
1474 return item.mountState === Grid.MOUNT_STATE.UNCHECKED;
1475 })) {
1476 prevGroup.renderItems.forEach(function (item) {
1477 if (item.type === ITEM_TYPE.VIRTUAL && !itemKeys[item.key]) {
1478 items.push(item);
1479 itemKeys[item.key] = item;
1480 }
1481 });
1482 }
1483 });
1484 return groups;
1485 };
1486
1487 __proto._updatePlaceholder = function (items) {
1488 if (items === void 0) {
1489 items = this.groupItems;
1490 }
1491
1492 var placeholder = this._placeholder;
1493
1494 if (!placeholder) {
1495 return;
1496 }
1497
1498 items.filter(function (item) {
1499 return item.type === ITEM_TYPE.VIRTUAL;
1500 }).forEach(function (item) {
1501 setPlaceholder(item, placeholder);
1502 });
1503 };
1504
1505 __proto._makeGrid = function () {
1506 var GridConstructor = this.options.gridConstructor;
1507 var gridOptions = this.gridOptions;
1508 var container = this.containerElement;
1509 return new GridConstructor(container, __assign(__assign({}, gridOptions), {
1510 useFit: false,
1511 autoResize: false,
1512 useResizeObserver: false,
1513 observeChildren: false,
1514 renderOnPropertyChange: false,
1515 externalContainerManager: this.containerManager,
1516 externalItemRenderer: this.itemRenderer
1517 }));
1518 };
1519
1520 __proto._getLoadingGroup = function () {
1521 var loadingGrid = this._loadingGrid;
1522 var items = loadingGrid.getItems();
1523 return {
1524 groupKey: LOADING_GROUP_KEY,
1525 type: GROUP_TYPE.NORMAL,
1526 grid: loadingGrid,
1527 items: items,
1528 renderItems: items
1529 };
1530 };
1531
1532 __proto._getLoadingItem = function () {
1533 return this._loadingGrid.getLoadingItem();
1534 };
1535
1536 GroupManager.defaultOptions = __assign(__assign({}, Grid.defaultOptions), {
1537 gridConstructor: null,
1538 gridOptions: {}
1539 });
1540 GroupManager.propertyTypes = __assign(__assign({}, Grid.propertyTypes), {
1541 gridConstructor: Grid.PROPERTY_TYPE.PROPERTY,
1542 gridOptions: Grid.PROPERTY_TYPE.PROPERTY
1543 });
1544 GroupManager = __decorate([Grid.GetterSetter], GroupManager);
1545 return GroupManager;
1546}(Grid);
1547
1548var Infinite =
1549/*#__PURE__*/
1550function (_super) {
1551 __extends(Infinite, _super);
1552
1553 function Infinite(options) {
1554 var _this = _super.call(this) || this;
1555
1556 _this.startCursor = -1;
1557 _this.endCursor = -1;
1558 _this.size = 0;
1559 _this.items = [];
1560 _this.itemKeys = {};
1561 _this.options = __assign({
1562 threshold: 0,
1563 useRecycle: true,
1564 defaultDirection: "end"
1565 }, options);
1566 return _this;
1567 }
1568
1569 var __proto = Infinite.prototype;
1570
1571 __proto.scroll = function (scrollPos) {
1572 var _a, _b;
1573
1574 var prevStartCursor = this.startCursor;
1575 var prevEndCursor = this.endCursor;
1576 var items = this.items;
1577 var length = items.length;
1578 var size = this.size;
1579 var _c = this.options,
1580 defaultDirection = _c.defaultDirection,
1581 threshold = _c.threshold,
1582 useRecycle = _c.useRecycle;
1583 var isDirectionEnd = defaultDirection === "end";
1584
1585 if (!length) {
1586 this.trigger(isDirectionEnd ? "requestAppend" : "requestPrepend", {
1587 key: undefined,
1588 isVirtual: false
1589 });
1590 return;
1591 } else if (prevStartCursor === -1 || prevEndCursor === -1) {
1592 var nextCursor = isDirectionEnd ? 0 : length - 1;
1593 this.trigger("change", {
1594 prevStartCursor: prevStartCursor,
1595 prevEndCursor: prevEndCursor,
1596 nextStartCursor: nextCursor,
1597 nextEndCursor: nextCursor
1598 });
1599 return;
1600 }
1601
1602 var endScrollPos = scrollPos + size;
1603 var startEdgePos = Math.max.apply(Math, items[prevStartCursor].startOutline);
1604 var endEdgePos = Math.min.apply(Math, items[prevEndCursor].endOutline);
1605 var visibles = items.map(function (item) {
1606 var startOutline = item.startOutline,
1607 endOutline = item.endOutline;
1608
1609 if (!startOutline.length || !endOutline.length) {
1610 return false;
1611 }
1612
1613 var startPos = Math.min.apply(Math, startOutline);
1614 var endPos = Math.max.apply(Math, endOutline);
1615
1616 if (startPos - threshold <= endScrollPos && scrollPos <= endPos + threshold) {
1617 return true;
1618 }
1619
1620 return false;
1621 });
1622 var hasStartItems = 0 < prevStartCursor;
1623 var hasEndItems = prevEndCursor < length - 1;
1624 var isStart = scrollPos <= startEdgePos + threshold;
1625 var isEnd = endScrollPos >= endEdgePos - threshold;
1626 var nextStartCursor = visibles.indexOf(true);
1627 var nextEndCursor = visibles.lastIndexOf(true);
1628
1629 if (nextStartCursor === -1) {
1630 nextStartCursor = prevStartCursor;
1631 nextEndCursor = prevEndCursor;
1632 }
1633
1634 if (!useRecycle) {
1635 nextStartCursor = Math.min(nextStartCursor, prevStartCursor);
1636 nextEndCursor = Math.max(nextEndCursor, prevEndCursor);
1637 }
1638
1639 if (nextStartCursor === prevStartCursor && hasStartItems && isStart) {
1640 nextStartCursor -= 1;
1641 }
1642
1643 if (nextEndCursor === prevEndCursor && hasEndItems && isEnd) {
1644 nextEndCursor += 1;
1645 }
1646
1647 var nextVisibleItems = items.slice(nextStartCursor, nextEndCursor + 1); // It must contain no virtual items.
1648
1649 if (nextVisibleItems.every(function (item) {
1650 return item.isVirtual === true;
1651 })) {
1652 // The real item can be in either the start or end direction.
1653 var hasRealItem = false;
1654
1655 for (var i = nextStartCursor - 1; i >= 0; --i) {
1656 if (!items[i].isVirtual) {
1657 nextStartCursor = i;
1658 hasRealItem = true;
1659 break;
1660 }
1661 }
1662
1663 if (!hasRealItem) {
1664 for (var i = nextEndCursor + 1; i < length; ++i) {
1665 if (!items[i].isVirtual) {
1666 nextEndCursor = i;
1667 hasRealItem = true;
1668 break;
1669 }
1670 }
1671 }
1672
1673 if (hasRealItem) {
1674 nextVisibleItems = items.slice(nextStartCursor, nextEndCursor + 1);
1675 }
1676 }
1677
1678 var hasVirtualItems = nextVisibleItems.some(function (item) {
1679 return item.isVirtual === true;
1680 });
1681
1682 if (prevStartCursor !== nextStartCursor || prevEndCursor !== nextEndCursor) {
1683 this.trigger("change", {
1684 prevStartCursor: prevStartCursor,
1685 prevEndCursor: prevEndCursor,
1686 nextStartCursor: nextStartCursor,
1687 nextEndCursor: nextEndCursor
1688 });
1689
1690 if (!hasVirtualItems) {
1691 return;
1692 }
1693 } // If a virtual item is included, a requestPrepend (or requestAppend) event is triggered.
1694
1695
1696 if (hasVirtualItems) {
1697 var isStartVirtual = (_a = nextVisibleItems[0]) === null || _a === void 0 ? void 0 : _a.isVirtual;
1698 var isEndVirtual = (_b = nextVisibleItems[nextVisibleItems.length - 1]) === null || _b === void 0 ? void 0 : _b.isVirtual;
1699
1700 if ((!isDirectionEnd || !isEnd) && isStartVirtual) {
1701 var realItemIndex = findIndex(nextVisibleItems, function (item) {
1702 return !item.isVirtual;
1703 });
1704 var endVirtualItemIndex = (realItemIndex === -1 ? nextVisibleItems.length : realItemIndex) - 1;
1705
1706 if (nextVisibleItems[endVirtualItemIndex]) {
1707 this.trigger("requestPrepend", {
1708 key: nextVisibleItems[realItemIndex].key,
1709 nextKey: nextVisibleItems[endVirtualItemIndex].key,
1710 nextKeys: nextVisibleItems.slice(0, endVirtualItemIndex + 1).map(function (item) {
1711 return item.key;
1712 }),
1713 isVirtual: true
1714 });
1715 }
1716 } else if ((isDirectionEnd || !isStart) && isEndVirtual) {
1717 var realItemIndex = findLastIndex(nextVisibleItems, function (item) {
1718 return !item.isVirtual;
1719 });
1720 var startVirtualItemIndex = realItemIndex + 1;
1721
1722 if (nextVisibleItems[startVirtualItemIndex]) {
1723 this.trigger("requestAppend", {
1724 key: nextVisibleItems[realItemIndex].key,
1725 nextKey: nextVisibleItems[startVirtualItemIndex].key,
1726 nextKeys: nextVisibleItems.slice(startVirtualItemIndex).map(function (item) {
1727 return item.key;
1728 }),
1729 isVirtual: true
1730 });
1731 }
1732 }
1733 } else if (!this._requestVirtualItems()) {
1734 if ((!isDirectionEnd || !isEnd) && isStart) {
1735 this.trigger("requestPrepend", {
1736 key: items[prevStartCursor].key,
1737 isVirtual: false
1738 });
1739 } else if ((isDirectionEnd || !isStart) && isEnd) {
1740 this.trigger("requestAppend", {
1741 key: items[prevEndCursor].key,
1742 isVirtual: false
1743 });
1744 }
1745 }
1746 };
1747 /**
1748 * Call the requestAppend or requestPrepend event to fill the virtual items.
1749 * @ko virtual item을 채우기 위해 requestAppend 또는 requestPrepend 이벤트를 호출합니다.
1750 * @return - Whether the event is called. <ko>이벤트를 호출했는지 여부.</ko>
1751 */
1752
1753
1754 __proto._requestVirtualItems = function () {
1755 var isDirectionEnd = this.options.defaultDirection === "end";
1756 var items = this.items;
1757 var totalVisibleItems = this.getVisibleItems();
1758 var visibleItems = totalVisibleItems.filter(function (item) {
1759 return !item.isVirtual;
1760 });
1761 var totalVisibleLength = totalVisibleItems.length;
1762 var visibleLength = visibleItems.length;
1763 var startCursor = this.getStartCursor();
1764 var endCursor = this.getEndCursor();
1765
1766 if (visibleLength === totalVisibleLength) {
1767 return false;
1768 } else if (visibleLength) {
1769 var startKey_1 = visibleItems[0].key;
1770 var endKey_1 = visibleItems[visibleLength - 1].key;
1771 var startIndex = findIndex(items, function (item) {
1772 return item.key === startKey_1;
1773 }) - 1;
1774 var endIndex = findIndex(items, function (item) {
1775 return item.key === endKey_1;
1776 }) + 1;
1777 var isEnd = endIndex <= endCursor;
1778 var isStart = startIndex >= startCursor; // Fill the placeholder with the original item.
1779
1780 if ((isDirectionEnd || !isStart) && isEnd) {
1781 this.trigger("requestAppend", {
1782 key: endKey_1,
1783 nextKey: items[endIndex].key,
1784 isVirtual: true
1785 });
1786 return true;
1787 } else if ((!isDirectionEnd || !isEnd) && isStart) {
1788 this.trigger("requestPrepend", {
1789 key: startKey_1,
1790 nextKey: items[startIndex].key,
1791 isVirtual: true
1792 });
1793 return true;
1794 }
1795 } else if (totalVisibleLength) {
1796 var lastItem = totalVisibleItems[totalVisibleLength - 1];
1797
1798 if (isDirectionEnd) {
1799 this.trigger("requestAppend", {
1800 nextKey: totalVisibleItems[0].key,
1801 isVirtual: true
1802 });
1803 } else {
1804 this.trigger("requestPrepend", {
1805 nextKey: lastItem.key,
1806 isVirtual: true
1807 });
1808 }
1809
1810 return true;
1811 }
1812
1813 return false;
1814 };
1815
1816 __proto.setCursors = function (startCursor, endCursor) {
1817 this.startCursor = startCursor;
1818 this.endCursor = endCursor;
1819 };
1820
1821 __proto.setSize = function (size) {
1822 this.size = size;
1823 };
1824
1825 __proto.getStartCursor = function () {
1826 return this.startCursor;
1827 };
1828
1829 __proto.getEndCursor = function () {
1830 return this.endCursor;
1831 };
1832
1833 __proto.isLoading = function (direction) {
1834 var startCursor = this.startCursor;
1835 var endCursor = this.endCursor;
1836 var items = this.items;
1837 var firstItem = items[startCursor];
1838 var lastItem = items[endCursor];
1839 var length = items.length;
1840
1841 if (direction === DIRECTION.END && endCursor > -1 && endCursor < length - 1 && !lastItem.isVirtual && !isFlatOutline(lastItem.startOutline, lastItem.endOutline)) {
1842 return false;
1843 }
1844
1845 if (direction === DIRECTION.START && startCursor > 0 && !firstItem.isVirtual && !isFlatOutline(firstItem.startOutline, firstItem.endOutline)) {
1846 return false;
1847 }
1848
1849 return true;
1850 };
1851
1852 __proto.setItems = function (nextItems) {
1853 this.items = nextItems;
1854 var itemKeys = {};
1855 nextItems.forEach(function (item) {
1856 itemKeys[item.key] = item;
1857 });
1858 this.itemKeys = itemKeys;
1859 };
1860
1861 __proto.syncItems = function (nextItems) {
1862 var prevItems = this.items;
1863 var prevStartCursor = this.startCursor;
1864 var prevEndCursor = this.endCursor;
1865
1866 var _a = getNextCursors(this.items.map(function (item) {
1867 return item.key;
1868 }), nextItems.map(function (item) {
1869 return item.key;
1870 }), prevStartCursor, prevEndCursor),
1871 nextStartCursor = _a.startCursor,
1872 nextEndCursor = _a.endCursor; // sync items between cursors
1873
1874
1875 var isChange = nextEndCursor - nextStartCursor !== prevEndCursor - prevStartCursor || prevStartCursor === -1 || nextStartCursor === -1;
1876
1877 if (!isChange) {
1878 var prevVisibleItems = prevItems.slice(prevStartCursor, prevEndCursor + 1);
1879 var nextVisibleItems = nextItems.slice(nextStartCursor, nextEndCursor + 1);
1880 var visibleResult = listDiffer.diff(prevVisibleItems, nextVisibleItems, function (item) {
1881 return item.key;
1882 });
1883 isChange = visibleResult.added.length > 0 || visibleResult.removed.length > 0 || visibleResult.changed.length > 0;
1884 }
1885
1886 this.setItems(nextItems);
1887 this.setCursors(nextStartCursor, nextEndCursor);
1888 return isChange;
1889 };
1890
1891 __proto.getItems = function () {
1892 return this.items;
1893 };
1894
1895 __proto.getVisibleItems = function () {
1896 var startCursor = this.startCursor;
1897 var endCursor = this.endCursor;
1898
1899 if (startCursor === -1) {
1900 return [];
1901 }
1902
1903 return this.items.slice(startCursor, endCursor + 1);
1904 };
1905
1906 __proto.getItemByKey = function (key) {
1907 return this.itemKeys[key];
1908 };
1909
1910 __proto.getRenderedVisibleItems = function () {
1911 var items = this.getVisibleItems();
1912 var rendered = items.map(function (_a) {
1913 var startOutline = _a.startOutline,
1914 endOutline = _a.endOutline;
1915 var length = startOutline.length;
1916
1917 if (length === 0 || length !== endOutline.length) {
1918 return false;
1919 }
1920
1921 return startOutline.some(function (pos, i) {
1922 return endOutline[i] !== pos;
1923 });
1924 });
1925 var startIndex = rendered.indexOf(true);
1926 var endIndex = rendered.lastIndexOf(true);
1927 return endIndex === -1 ? [] : items.slice(startIndex, endIndex + 1);
1928 };
1929
1930 __proto.destroy = function () {
1931 this.off();
1932 this.startCursor = -1;
1933 this.endCursor = -1;
1934 this.items = [];
1935 this.size = 0;
1936 };
1937
1938 return Infinite;
1939}(Component);
1940
1941var Renderer =
1942/*#__PURE__*/
1943function (_super) {
1944 __extends(Renderer, _super);
1945
1946 function Renderer() {
1947 var _this = _super !== null && _super.apply(this, arguments) || this;
1948
1949 _this.items = [];
1950 _this.container = null;
1951 _this.rendererKey = 0;
1952 _this._updateTimer = 0;
1953 _this._state = {};
1954 _this._isItemChanged = false;
1955 return _this;
1956 }
1957
1958 var __proto = Renderer.prototype;
1959
1960 __proto.updateKey = function () {
1961 this.rendererKey = Date.now();
1962 };
1963
1964 __proto.getItems = function () {
1965 return this.items;
1966 };
1967
1968 __proto.setContainer = function (container) {
1969 this.container = container;
1970 };
1971
1972 __proto.render = function (nextItems, state) {
1973 return this.syncItems(nextItems, state);
1974 };
1975
1976 __proto.update = function (state) {
1977 var _this = this;
1978
1979 if (state === void 0) {
1980 state = {};
1981 }
1982
1983 this._state = __assign(__assign({}, this._state), state);
1984 this.trigger("update", {
1985 state: state
1986 });
1987 clearTimeout(this._updateTimer);
1988 this._updateTimer = window.setTimeout(function () {
1989 _this.trigger("requestUpdate", {
1990 state: state
1991 });
1992 });
1993 };
1994
1995 __proto.updated = function (nextElements) {
1996 var _a, _b;
1997
1998 if (nextElements === void 0) {
1999 nextElements = (_b = (_a = this.container) === null || _a === void 0 ? void 0 : _a.children) !== null && _b !== void 0 ? _b : [];
2000 }
2001
2002 var diffResult = this._diffResult;
2003 var isChanged = !!(diffResult.added.length || diffResult.removed.length || diffResult.changed.length);
2004 var state = this._state;
2005 var isItemChanged = this._isItemChanged;
2006 var nextItems = diffResult.list;
2007 this._isItemChanged = false;
2008 this._state = {};
2009 this.items = nextItems;
2010 nextItems.forEach(function (item, i) {
2011 item.element = nextElements[i];
2012 });
2013 this.trigger("updated", {
2014 items: nextItems,
2015 elements: toArray(nextElements),
2016 diffResult: this._diffResult,
2017 state: state,
2018 isItemChanged: isItemChanged,
2019 isChanged: isChanged
2020 });
2021 return isChanged;
2022 };
2023
2024 __proto.syncItems = function (items, state) {
2025 if (state === void 0) {
2026 state = {};
2027 }
2028
2029 var rendererKey = this.rendererKey;
2030 var prevItems = this.items;
2031 var nextItems = items.map(function (item) {
2032 return __assign(__assign({}, item), {
2033 renderKey: rendererKey + "_" + item.key
2034 });
2035 });
2036 var result = listDiffer.diff(prevItems, nextItems, function (item) {
2037 return item.renderKey;
2038 });
2039 this._isItemChanged = !!result.added.length || !!result.removed.length || !!result.changed.length;
2040 this._state = __assign(__assign({}, this._state), state);
2041 this._diffResult = result;
2042 return result;
2043 };
2044
2045 __proto.destroy = function () {
2046 this.off();
2047 };
2048
2049 return Renderer;
2050}(Component);
2051
2052var VanillaRenderer =
2053/*#__PURE__*/
2054function (_super) {
2055 __extends(VanillaRenderer, _super);
2056
2057 function VanillaRenderer() {
2058 return _super !== null && _super.apply(this, arguments) || this;
2059 }
2060
2061 var __proto = VanillaRenderer.prototype;
2062
2063 __proto.render = function (nextItems, state) {
2064 var container = this.container;
2065
2066 var result = _super.prototype.render.call(this, nextItems, state);
2067
2068 var prevList = result.prevList,
2069 removed = result.removed,
2070 ordered = result.ordered,
2071 added = result.added,
2072 list = result.list;
2073
2074 var diffList = __spreadArrays(prevList);
2075
2076 removed.forEach(function (index) {
2077 diffList.splice(index, 1);
2078 container.removeChild(prevList[index].element);
2079 });
2080 ordered.forEach(function (_a) {
2081 var _b, _c;
2082
2083 var prevIndex = _a[0],
2084 nextIndex = _a[1];
2085 var item = diffList.splice(prevIndex, 1)[0];
2086 diffList.splice(nextIndex, 0, item);
2087 container.insertBefore(item.element, (_c = (_b = diffList[nextIndex + 1]) === null || _b === void 0 ? void 0 : _b.element) !== null && _c !== void 0 ? _c : null);
2088 });
2089 added.forEach(function (index) {
2090 var _a, _b;
2091
2092 var item = list[index];
2093 diffList.splice(index, 0, item);
2094 container.insertBefore(item.element, (_b = (_a = diffList[index + 1]) === null || _a === void 0 ? void 0 : _a.element) !== null && _b !== void 0 ? _b : null);
2095 });
2096 this.updated(container.children);
2097 return result;
2098 };
2099
2100 return VanillaRenderer;
2101}(Renderer);
2102
2103var VanillaGridRenderer =
2104/*#__PURE__*/
2105function (_super) {
2106 __extends(VanillaGridRenderer, _super);
2107
2108 function VanillaGridRenderer() {
2109 return _super !== null && _super.apply(this, arguments) || this;
2110 }
2111
2112 var __proto = VanillaGridRenderer.prototype;
2113
2114 __proto.syncItems = function (nextItems) {
2115 var result = _super.prototype.syncItems.call(this, nextItems);
2116
2117 var added = result.added,
2118 list = result.list;
2119 added.forEach(function (index) {
2120 var orgItem = nextItems[index].orgItem;
2121
2122 if (orgItem.html && !orgItem.element) {
2123 orgItem.element = convertHTMLtoElement(orgItem.html)[0];
2124 }
2125
2126 list[index].element = orgItem.element;
2127 });
2128 return result;
2129 };
2130
2131 return VanillaGridRenderer;
2132}(VanillaRenderer);
2133
2134var ScrollManager =
2135/*#__PURE__*/
2136function (_super) {
2137 __extends(ScrollManager, _super);
2138
2139 function ScrollManager(wrapper, options) {
2140 var _this = _super.call(this) || this;
2141
2142 _this.wrapper = wrapper;
2143 _this.prevScrollPos = null;
2144 _this.scrollOffset = 0;
2145 _this.contentSize = 0;
2146 _this._isScrollIssue = IS_IOS;
2147
2148 _this._onCheck = function () {
2149 var prevScrollPos = _this.getScrollPos();
2150
2151 var nextScrollPos = _this.getOrgScrollPos();
2152
2153 _this.setScrollPos(nextScrollPos);
2154
2155 if (prevScrollPos === null || _this._isScrollIssue && nextScrollPos === 0 || prevScrollPos === nextScrollPos) {
2156 nextScrollPos && (_this._isScrollIssue = false);
2157 return;
2158 }
2159
2160 _this._isScrollIssue = false;
2161
2162 _this.trigger(new Component.ComponentEvent("scroll", {
2163 direction: prevScrollPos < nextScrollPos ? "end" : "start",
2164 scrollPos: nextScrollPos,
2165 relativeScrollPos: _this.getRelativeScrollPos()
2166 }));
2167 };
2168
2169 _this.options = __assign({
2170 container: false,
2171 containerTag: "div",
2172 horizontal: false
2173 }, options);
2174
2175 _this._init();
2176
2177 return _this;
2178 }
2179
2180 var __proto = ScrollManager.prototype;
2181
2182 __proto.getWrapper = function () {
2183 return this.wrapper;
2184 };
2185
2186 __proto.getContainer = function () {
2187 return this.container;
2188 };
2189
2190 __proto.getScrollContainer = function () {
2191 return this.scrollContainer;
2192 };
2193
2194 __proto.getScrollOffset = function () {
2195 return this.scrollOffset;
2196 };
2197
2198 __proto.getContentSize = function () {
2199 return this.contentSize;
2200 };
2201
2202 __proto.getRelativeScrollPos = function () {
2203 return (this.prevScrollPos || 0) - this.scrollOffset;
2204 };
2205
2206 __proto.getScrollPos = function () {
2207 return this.prevScrollPos;
2208 };
2209
2210 __proto.setScrollPos = function (pos) {
2211 this.prevScrollPos = pos;
2212 };
2213
2214 __proto.getOrgScrollPos = function () {
2215 var eventTarget = this.eventTarget;
2216 var horizontal = this.options.horizontal;
2217 var prop = "scroll" + (horizontal ? "Left" : "Top");
2218
2219 if (isWindow(eventTarget)) {
2220 return window[horizontal ? "pageXOffset" : "pageYOffset"] || document.documentElement[prop] || document.body[prop];
2221 } else {
2222 return eventTarget[prop];
2223 }
2224 };
2225
2226 __proto.setStatus = function (status) {
2227 this.contentSize = status.contentSize;
2228 this.scrollOffset = status.scrollOffset;
2229 this.prevScrollPos = status.prevScrollPos;
2230 this.scrollTo(this.prevScrollPos);
2231 };
2232
2233 __proto.getStatus = function () {
2234 return {
2235 contentSize: this.contentSize,
2236 scrollOffset: this.scrollOffset,
2237 prevScrollPos: this.prevScrollPos
2238 };
2239 };
2240
2241 __proto.scrollTo = function (pos) {
2242 var eventTarget = this.eventTarget;
2243 var horizontal = this.options.horizontal;
2244
2245 var _a = horizontal ? [pos, 0] : [0, pos],
2246 x = _a[0],
2247 y = _a[1];
2248
2249 if (isWindow(eventTarget)) {
2250 eventTarget.scroll(x, y);
2251 } else {
2252 eventTarget.scrollLeft = x;
2253 eventTarget.scrollTop = y;
2254 }
2255 };
2256
2257 __proto.scrollBy = function (pos) {
2258 if (!pos) {
2259 return;
2260 }
2261
2262 var eventTarget = this.eventTarget;
2263 var horizontal = this.options.horizontal;
2264
2265 var _a = horizontal ? [pos, 0] : [0, pos],
2266 x = _a[0],
2267 y = _a[1];
2268
2269 this.prevScrollPos += pos;
2270
2271 if (isWindow(eventTarget)) {
2272 eventTarget.scrollBy(x, y);
2273 } else {
2274 eventTarget.scrollLeft += x;
2275 eventTarget.scrollTop += y;
2276 }
2277 };
2278
2279 __proto.resize = function () {
2280 var scrollContainer = this.scrollContainer;
2281 var horizontal = this.options.horizontal;
2282 var isBody = scrollContainer === document.body;
2283 var scrollContainerRect = isBody ? {
2284 top: 0,
2285 left: 0
2286 } : scrollContainer.getBoundingClientRect();
2287 var containerRect = this.container.getBoundingClientRect();
2288 this.scrollOffset = (this.prevScrollPos || 0) + (horizontal ? containerRect.left - scrollContainerRect.left : containerRect.top - scrollContainerRect.top);
2289
2290 if (isBody) {
2291 this.contentSize = horizontal ? window.innerWidth : window.innerHeight;
2292 } else {
2293 this.contentSize = horizontal ? scrollContainer.offsetWidth : scrollContainer.offsetHeight;
2294 }
2295 };
2296
2297 __proto.destroy = function () {
2298 var container = this.container;
2299 this.eventTarget.removeEventListener("scroll", this._onCheck);
2300
2301 if (this._isCreateElement) {
2302 var scrollContainer = this.scrollContainer;
2303 var fragment_1 = document.createDocumentFragment();
2304 var childNodes = toArray(container.childNodes);
2305 scrollContainer.removeChild(container);
2306 childNodes.forEach(function (childNode) {
2307 fragment_1.appendChild(childNode);
2308 });
2309 scrollContainer.appendChild(fragment_1);
2310 } else if (this.options.container) {
2311 container.style.cssText = this._orgCSSText;
2312 }
2313 };
2314
2315 __proto._init = function () {
2316 var _a;
2317
2318 var _b = this.options,
2319 containerOption = _b.container,
2320 containerTag = _b.containerTag,
2321 horizontal = _b.horizontal;
2322 var wrapper = this.wrapper;
2323 var scrollContainer = wrapper;
2324 var container = wrapper;
2325 var containerCSSText = "";
2326
2327 if (!containerOption) {
2328 scrollContainer = document.body;
2329 containerCSSText = container.style.cssText;
2330 } else {
2331 if (containerOption instanceof HTMLElement) {
2332 // Container that already exists
2333 container = containerOption;
2334 } else if (containerOption === true) {
2335 // Create Container
2336 container = document.createElement(containerTag);
2337 container.style.position = "relative";
2338 container.className = CONTAINER_CLASS_NAME;
2339 var childNodes = toArray(scrollContainer.childNodes);
2340 childNodes.forEach(function (childNode) {
2341 container.appendChild(childNode);
2342 });
2343 scrollContainer.appendChild(container);
2344 this._isCreateElement = true;
2345 } else {
2346 // Find Container by Selector
2347 container = scrollContainer.querySelector(containerOption);
2348 }
2349
2350 containerCSSText = container.style.cssText;
2351 var style = scrollContainer.style;
2352 _a = horizontal ? ["scroll", "hidden"] : ["hidden", "scroll"], style.overflowX = _a[0], style.overflowY = _a[1];
2353
2354 if (horizontal) {
2355 container.style.height = "100%";
2356 }
2357 }
2358
2359 var eventTarget = scrollContainer === document.body ? window : scrollContainer;
2360 eventTarget.addEventListener("scroll", this._onCheck);
2361 this._orgCSSText = containerCSSText;
2362 this.container = container;
2363 this.scrollContainer = scrollContainer;
2364 this.eventTarget = eventTarget;
2365 this.resize();
2366 this.setScrollPos(this.getOrgScrollPos());
2367 };
2368
2369 return ScrollManager;
2370}(Component);
2371
2372/**
2373 * A module used to arrange items including content infinitely according to layout type. With this module, you can implement various layouts composed of different items whose sizes vary. It guarantees performance by maintaining the number of DOMs the module is handling under any circumstance
2374 * @ko 콘텐츠가 있는 아이템을 레이아웃 타입에 따라 무한으로 배치하는 모듈. 다양한 크기의 아이템을 다양한 레이아웃으로 배치할 수 있다. 아이템의 개수가 계속 늘어나도 모듈이 처리하는 DOM의 개수를 일정하게 유지해 최적의 성능을 보장한다
2375 * @extends Component
2376 * @support {"ie": "9+(with polyfill)", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "4.X+"}
2377 * @example
2378```html
2379<ul id="grid">
2380 <li class="card">
2381 <div>test1</div>
2382 </li>
2383 <li class="card">
2384 <div>test2</div>
2385 </li>
2386 <li class="card">
2387 <div>test3</div>
2388 </li>
2389 <li class="card">
2390 <div>test4</div>
2391 </li>
2392 <li class="card">
2393 <div>test5</div>
2394 </li>
2395 <li class="card">
2396 <div>test6</div>
2397 </li>
2398</ul>
2399<script>
2400import { MasonryInfiniteGrid } from "@egjs/infinitegrid";
2401var some = new MasonryInfiniteGrid("#grid").on("renderComplete", function(e) {
2402 // ...
2403});
2404// If you already have items in the container, call "layout" method.
2405some.renderItems();
2406</script>
2407```
2408 */
2409
2410var InfiniteGrid =
2411/*#__PURE__*/
2412function (_super) {
2413 __extends(InfiniteGrid, _super);
2414 /**
2415 * @param - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
2416 * @param - The option object of the InfiniteGrid module <ko>eg.InfiniteGrid 모듈의 옵션 객체</ko>
2417 */
2418
2419
2420 function InfiniteGrid(wrapper, options) {
2421 var _this = _super.call(this) || this;
2422
2423 _this._waitType = "";
2424
2425 _this._onScroll = function (_a) {
2426 var direction = _a.direction,
2427 scrollPos = _a.scrollPos,
2428 relativeScrollPos = _a.relativeScrollPos;
2429
2430 _this._scroll();
2431 /**
2432 * This event is fired when scrolling.
2433 * @ko 스크롤하면 발생하는 이벤트이다.
2434 * @event InfiniteGrid#changeScroll
2435 * @param {InfiniteGrid.OnChangeScroll} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2436 */
2437
2438
2439 _this.trigger(new Component.ComponentEvent(INFINITEGRID_EVENTS.CHANGE_SCROLL, {
2440 direction: direction,
2441 scrollPos: scrollPos,
2442 relativeScrollPos: relativeScrollPos
2443 }));
2444 };
2445
2446 _this._onChange = function (e) {
2447 _this.setCursors(e.nextStartCursor, e.nextEndCursor);
2448 };
2449
2450 _this._onRendererUpdated = function (e) {
2451 if (!e.isChanged) {
2452 _this._checkEndLoading();
2453
2454 _this._scroll();
2455
2456 return;
2457 }
2458
2459 var renderedItems = e.items;
2460 var _a = e.diffResult,
2461 added = _a.added,
2462 removed = _a.removed,
2463 prevList = _a.prevList,
2464 list = _a.list;
2465 removed.forEach(function (index) {
2466 var orgItem = prevList[index].orgItem;
2467
2468 if (orgItem.mountState !== Grid.MOUNT_STATE.UNCHECKED) {
2469 orgItem.mountState = Grid.MOUNT_STATE.UNMOUNTED;
2470 }
2471 });
2472 renderedItems.forEach(function (item) {
2473 // set grid element
2474 var gridItem = item.orgItem;
2475 gridItem.element = item.element;
2476 });
2477 var horizontal = _this.options.horizontal;
2478 var addedItems = added.map(function (index) {
2479 var gridItem = list[index].orgItem;
2480 var element = gridItem.element;
2481
2482 if (gridItem.type === ITEM_TYPE.VIRTUAL) {
2483 var cssRect = __assign({}, gridItem.cssRect);
2484
2485 var rect = gridItem.rect;
2486
2487 if (!cssRect.width && rect.width) {
2488 cssRect.width = rect.width;
2489 }
2490
2491 if (!cssRect.height && rect.height) {
2492 cssRect.height = rect.height;
2493 } // virtual item
2494
2495
2496 return new Grid.GridItem(horizontal, {
2497 element: element,
2498 cssRect: cssRect
2499 });
2500 }
2501
2502 return gridItem;
2503 });
2504 var containerManager = _this.containerManager;
2505
2506 if (_this.options.observeChildren) {
2507 containerManager.observeChildren(added.map(function (index) {
2508 return list[index].element;
2509 }));
2510 containerManager.unobserveChildren(removed.map(function (index) {
2511 return prevList[index].element;
2512 }));
2513 }
2514
2515 var _b = e.state,
2516 isRestore = _b.isRestore,
2517 isResize = _b.isResize;
2518
2519 _this.itemRenderer.renderItems(addedItems);
2520
2521 if (isRestore) {
2522 _this._onRenderComplete({
2523 mounted: added.map(function (index) {
2524 return list[index].orgItem;
2525 }),
2526 updated: [],
2527 isResize: false,
2528 direction: _this.defaultDirection
2529 });
2530 }
2531
2532 if (!isRestore || isResize || e.isItemChanged) {
2533 _this.groupManager.renderItems();
2534 }
2535 };
2536
2537 _this._onResize = function (e) {
2538 if (e.isResizeContainer) {
2539 _this._renderItems({
2540 useResize: true
2541 }, true);
2542 } else {
2543 var updatedItems = Grid.getUpdatedItems(_this.getVisibleItems(), e.childEntries);
2544
2545 if (updatedItems.length > 0) {
2546 _this.updateItems(updatedItems);
2547 }
2548 }
2549 };
2550
2551 _this._onRequestAppend = function (e) {
2552 /**
2553 * The event is fired when scrolling reaches the end or when data for a virtual group is required.
2554 * @ko 스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다.
2555 * @event InfiniteGrid#requestAppend
2556 * @param {InfiniteGrid.OnRequestAppend} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2557 */
2558 _this._onRequestInsert(DIRECTION.END, INFINITEGRID_EVENTS.REQUEST_APPEND, e);
2559 };
2560
2561 _this._onRequestPrepend = function (e) {
2562 /**
2563 * The event is fired when scrolling reaches the start or when data for a virtual group is required.
2564 * @ko 스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다.
2565 * @event InfiniteGrid#requestPrepend
2566 * @param {InfiniteGrid.OnRequestPrepend} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2567 */
2568 _this._onRequestInsert(DIRECTION.START, INFINITEGRID_EVENTS.REQUEST_PREPEND, e);
2569 };
2570
2571 _this._onContentError = function (_a) {
2572 var element = _a.element,
2573 target = _a.target,
2574 item = _a.item,
2575 update = _a.update;
2576 /**
2577 * The event is fired when scrolling reaches the start or when data for a virtual group is required.
2578 * @ko 스크롤이 끝에 도달하거나 virtual 그룹에 대한 데이터가 필요한 경우 이벤트가 발생한다.
2579 * @event InfiniteGrid#contentError
2580 * @param {InfiniteGrid.OnContentError} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2581 */
2582
2583 _this.trigger(new Component.ComponentEvent(INFINITEGRID_EVENTS.CONTENT_ERROR, {
2584 element: element,
2585 target: target,
2586 item: item,
2587 update: update,
2588 remove: function () {
2589 _this.removeByKey(item.key);
2590 }
2591 }));
2592 };
2593
2594 _this._onRenderComplete = function (_a) {
2595 var isResize = _a.isResize,
2596 mounted = _a.mounted,
2597 updated = _a.updated,
2598 direction = _a.direction;
2599 var infinite = _this.infinite;
2600 var prevRenderedGroups = infinite.getRenderedVisibleItems();
2601 var length = prevRenderedGroups.length;
2602 var isDirectionEnd = direction === DIRECTION.END;
2603
2604 _this._syncInfinite();
2605
2606 if (length) {
2607 var prevStandardGroup = prevRenderedGroups[isDirectionEnd ? 0 : length - 1];
2608 var nextStandardGroup = infinite.getItemByKey(prevStandardGroup.key);
2609 var offset = isDirectionEnd ? Math.min.apply(Math, nextStandardGroup.startOutline) - Math.min.apply(Math, prevStandardGroup.startOutline) : Math.max.apply(Math, nextStandardGroup.endOutline) - Math.max.apply(Math, prevStandardGroup.endOutline);
2610
2611 _this.scrollManager.scrollBy(offset);
2612 }
2613 /**
2614 * This event is fired when the InfiniteGrid has completed rendering.
2615 * @ko InfiniteGrid가 렌더링이 완료됐을 때 이벤트가 발생한다.
2616 * @event InfiniteGrid#renderComplete
2617 * @param {InfiniteGrid.OnRenderComplete} e - The object of data to be sent to an event <ko>이벤트에 전달되는 데이터 객체</ko>
2618 */
2619
2620
2621 _this.trigger(new Component.ComponentEvent(INFINITEGRID_EVENTS.RENDER_COMPLETE, {
2622 isResize: isResize,
2623 direction: direction,
2624 mounted: mounted.filter(function (item) {
2625 return item.type !== ITEM_TYPE.LOADING;
2626 }),
2627 updated: updated.filter(function (item) {
2628 return item.type !== ITEM_TYPE.LOADING;
2629 }),
2630 startCursor: _this.getStartCursor(),
2631 endCursor: _this.getEndCursor(),
2632 items: _this.getVisibleItems(true),
2633 groups: _this.getVisibleGroups(true)
2634 }));
2635
2636 if (_this.groupManager.shouldRerenderItems()) {
2637 _this._update();
2638 } else {
2639 _this._checkEndLoading();
2640
2641 _this._scroll();
2642 }
2643 };
2644
2645 _this.options = __assign(__assign(__assign({}, _this.constructor.defaultOptions), {
2646 renderer: new VanillaGridRenderer().on("requestUpdate", function () {
2647 return _this._render();
2648 })
2649 }), options);
2650
2651 var _a = _this.options,
2652 gridConstructor = _a.gridConstructor,
2653 containerTag = _a.containerTag,
2654 container = _a.container,
2655 renderer = _a.renderer,
2656 threshold = _a.threshold,
2657 useRecycle = _a.useRecycle,
2658 gridOptions = __rest(_a, ["gridConstructor", "containerTag", "container", "renderer", "threshold", "useRecycle"]); // options.container === false, wrapper = container, scrollContainer = document.body
2659 // options.container === true, wrapper = scrollContainer, container = wrapper's child
2660 // options.container === string,
2661
2662
2663 var horizontal = gridOptions.horizontal,
2664 attributePrefix = gridOptions.attributePrefix,
2665 useTransform = gridOptions.useTransform,
2666 percentage = gridOptions.percentage,
2667 isConstantSize = gridOptions.isConstantSize,
2668 isEqualSize = gridOptions.isEqualSize,
2669 autoResize = gridOptions.autoResize,
2670 useResizeObserver = gridOptions.useResizeObserver,
2671 resizeDebounce = gridOptions.resizeDebounce,
2672 maxResizeDebounce = gridOptions.maxResizeDebounce,
2673 defaultDirection = gridOptions.defaultDirection;
2674 var wrapperElement = isString(wrapper) ? document.querySelector(wrapper) : wrapper;
2675 var scrollManager = new ScrollManager(wrapperElement, {
2676 container: container,
2677 containerTag: containerTag,
2678 horizontal: horizontal
2679 }).on({
2680 scroll: _this._onScroll
2681 });
2682 var containerElement = scrollManager.getContainer();
2683 var containerManager = new Grid.ContainerManager(containerElement, {
2684 horizontal: horizontal,
2685 autoResize: autoResize,
2686 resizeDebounce: resizeDebounce,
2687 maxResizeDebounce: maxResizeDebounce,
2688 useResizeObserver: useResizeObserver
2689 }).on("resize", _this._onResize);
2690 var itemRenderer = new Grid.ItemRenderer({
2691 attributePrefix: attributePrefix,
2692 horizontal: horizontal,
2693 useTransform: useTransform,
2694 percentage: percentage,
2695 isEqualSize: isEqualSize,
2696 isConstantSize: isConstantSize
2697 });
2698 var infinite = new Infinite({
2699 defaultDirection: defaultDirection,
2700 useRecycle: useRecycle,
2701 threshold: threshold
2702 }).on({
2703 "change": _this._onChange,
2704 "requestAppend": _this._onRequestAppend,
2705 "requestPrepend": _this._onRequestPrepend
2706 });
2707 infinite.setSize(scrollManager.getContentSize());
2708 var groupManager = new GroupManager(containerElement, {
2709 gridConstructor: gridConstructor,
2710 externalItemRenderer: itemRenderer,
2711 externalContainerManager: containerManager,
2712 gridOptions: gridOptions
2713 });
2714 groupManager.on({
2715 "renderComplete": _this._onRenderComplete,
2716 "contentError": _this._onContentError
2717 });
2718 renderer.setContainer(containerElement);
2719 renderer.on("updated", _this._onRendererUpdated);
2720 _this.itemRenderer = itemRenderer;
2721 _this.groupManager = groupManager;
2722 _this.wrapperElement = wrapperElement;
2723 _this.scrollManager = scrollManager;
2724 _this.containerManager = containerManager;
2725 _this.infinite = infinite;
2726
2727 _this.containerManager.resize();
2728
2729 return _this;
2730 }
2731
2732 var __proto = InfiniteGrid.prototype;
2733 InfiniteGrid_1 = InfiniteGrid;
2734 /**
2735 * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired.
2736 * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다.
2737 * @param - Options for rendering. <ko>렌더링을 하기 위한 옵션.</ko>
2738 * @example
2739 * ```ts
2740 * import { MasonryInfiniteGrid } from "@egjs/infinitegrid";
2741 * const grid = new MasonryInfiniteGrid();
2742 *
2743 * grid.on("renderComplete", e => {
2744 * console.log(e);
2745 * });
2746 * grid.renderItems();
2747 * ```
2748 */
2749
2750 __proto.renderItems = function (options) {
2751 if (options === void 0) {
2752 options = {};
2753 }
2754
2755 this._renderItems(options);
2756
2757 return this;
2758 };
2759 /**
2760 * Returns the wrapper element specified by the user.
2761 * @ko 컨테이너 엘리먼트를 반환한다.
2762 */
2763
2764
2765 __proto.getWrapperElement = function () {
2766 return this.scrollManager.getWrapper();
2767 };
2768 /**
2769 * Returns the container element corresponding to the scroll area.
2770 * @ko 스크롤 영역에 해당하는 컨테이너 엘리먼트를 반환한다.
2771 */
2772
2773
2774 __proto.getScrollContainerElement = function () {
2775 return this.scrollManager.getScrollContainer();
2776 };
2777 /**
2778 * Returns the container element containing item elements.
2779 * @ko 아이템 엘리먼트들을 담긴 컨테이너 엘리먼트를 반환한다.
2780 */
2781
2782
2783 __proto.getContainerElement = function () {
2784 return this.scrollManager.getContainer();
2785 };
2786 /**
2787 * When items change, it synchronizes and renders items.
2788 * @ko items가 바뀐 경우 동기화를 하고 렌더링을 한다.
2789 * @param - Options for rendering. <ko>렌더링을 하기 위한 옵션.</ko>
2790 */
2791
2792
2793 __proto.syncItems = function (items) {
2794 this.groupManager.syncItems(items);
2795
2796 this._syncGroups();
2797
2798 return this;
2799 };
2800 /**
2801 * Change the currently visible groups.
2802 * @ko 현재 보이는 그룹들을 바꾼다.
2803 * @param - first index of visible groups. <ko>보이는 그룹의 첫번째 index.</ko>
2804 * @param - last index of visible groups. <ko>보이는 그룹의 마지막 index.</ko>
2805 * @param - Whether the first rendering has already been done. <ko>첫 렌더링이 이미 되어있는지 여부.</ko>
2806 */
2807
2808
2809 __proto.setCursors = function (startCursor, endCursor, useFirstRender) {
2810 this.groupManager.setCursors(startCursor, endCursor);
2811 this.infinite.setCursors(startCursor, endCursor);
2812
2813 if (useFirstRender) {
2814 this._syncItems();
2815 } else {
2816 this._update();
2817
2818 this._checkEndLoading();
2819 }
2820
2821 return this;
2822 };
2823 /**
2824 * Returns the first index of visible groups.
2825 * @ko 보이는 그룹들의 첫번째 index를 반환한다.
2826 */
2827
2828
2829 __proto.getStartCursor = function () {
2830 return this.infinite.getStartCursor();
2831 };
2832 /**
2833 * Returns the last index of visible groups.
2834 * @ko 보이는 그룹들의 마지막 index를 반환한다.
2835 */
2836
2837
2838 __proto.getEndCursor = function () {
2839 return this.infinite.getEndCursor();
2840 };
2841 /**
2842 * Add items at the bottom(right) of the grid.
2843 * @ko 아이템들을 grid 아래(오른쪽)에 추가한다.
2844 * @param - items to be added <ko>추가할 아이템들</ko>
2845 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2846 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2847 * @example
2848 * ```js
2849 * ig.append(`<div class="item">test1</div><div class="item">test2</div>`);
2850 * ig.append([`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2851 * ig.append([HTMLElement1, HTMLElement2]);
2852 * ```
2853 */
2854
2855
2856 __proto.append = function (items, groupKey) {
2857 return this.insert(-1, items, groupKey);
2858 };
2859 /**
2860 * Add items at the top(left) of the grid.
2861 * @ko 아이템들을 grid 위(왼쪽)에 추가한다.
2862 * @param - items to be added <ko>추가할 아이템들</ko>
2863 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2864 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2865 * @example
2866 * ```ts
2867 * ig.prepend(`<div class="item">test1</div><div class="item">test2</div>`);
2868 * ig.prepend([`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2869 * ig.prepend([HTMLElement1, HTMLElement2]);
2870 * ```
2871 */
2872
2873
2874 __proto.prepend = function (items, groupKey) {
2875 return this.insert(0, items, groupKey);
2876 };
2877 /**
2878 * Add items to a specific index.
2879 * @ko 아이템들을 특정 index에 추가한다.
2880 * @param - index to add <ko>추가하기 위한 index</ko>
2881 * @param - items to be added <ko>추가할 아이템들</ko>
2882 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2883 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2884 * @example
2885 * ```ts
2886 * ig.insert(2, `<div class="item">test1</div><div class="item">test2</div>`);
2887 * ig.insert(3, [`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2888 * ig.insert(4, [HTMLElement1, HTMLElement2]);
2889 * ```
2890 */
2891
2892
2893 __proto.insert = function (index, items, groupKey) {
2894 var nextItemInfos = this.groupManager.getGroupItems();
2895 var itemInfos = convertInsertedItems(items, groupKey);
2896
2897 if (index === -1) {
2898 nextItemInfos.push.apply(nextItemInfos, itemInfos);
2899 } else {
2900 nextItemInfos.splice.apply(nextItemInfos, __spreadArrays([index, 0], itemInfos));
2901 }
2902
2903 return this.syncItems(nextItemInfos);
2904 };
2905 /**
2906 * Add items based on group index.
2907 * @ko group의 index 기준으로 item들을 추가한다.
2908 * @param - group index to add <ko>추가하기 위한 group의 index</ko>
2909 * @param - items to be added <ko>추가할 아이템들</ko>
2910 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2911 * @return - An instance of a module itself<ko>모듈 자신의 인스턴스</ko>
2912 * @example
2913 * ```ts
2914 * ig.insertByGroupIndex(2, `<div class="item">test1</div><div class="item">test2</div>`);
2915 * ig.insertByGroupIndex(3, [`<div class="item">test1</div>`, `<div class="item">test2</div>`]);
2916 * ig.insertByGroupIndex(4, [HTMLElement1, HTMLElement2]);
2917 * ```
2918 */
2919
2920
2921 __proto.insertByGroupIndex = function (groupIndex, items, groupKey) {
2922 var nextGroupInfos = this.groupManager.getGroups();
2923 var rightGroup = nextGroupInfos[groupIndex];
2924
2925 if (!rightGroup) {
2926 return this.append(items, groupKey);
2927 }
2928
2929 var nextItemInfos = this.groupManager.getGroupItems();
2930 var rightGroupKey = rightGroup.groupKey;
2931 var rightItemIndex = findIndex(nextItemInfos, function (item) {
2932 return item.groupKey === rightGroupKey;
2933 });
2934 return this.insert(rightItemIndex, items, groupKey);
2935 };
2936 /**
2937 * Returns the current state of a module such as location information. You can use the setStatus() method to restore the information returned through a call to this method.
2938 * @ko 아이템의 위치 정보 등 모듈의 현재 상태 정보를 반환한다. 이 메서드가 반환한 정보를 저장해 두었다가 setStatus() 메서드로 복원할 수 있다
2939 * @param - STATUS_TYPE.NOT_REMOVE = Get all information about items. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = Get information on visible items only. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = Compress invisible items. You can replace it with a placeholder. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = Compress invisible groups. <ko> STATUS_TYPE.NOT_REMOVE = 모든 아이템들의 정보를 가져온다. STATUS_TYPE.REMOVE_INVISIBLE_ITEMS = 보이는 아이템들의 정보만 가져온다. STATUS_TYPE.MINIMIZE_INVISIBLE_ITEMS = 안보이는 아이템들을 압축한다. placeholder로 대체가 가능하다. STATUS_TYPE.MINIMIZE_INVISIBLE_GROUPS = 안보이는 그룹을 압축한다.</ko>
2940 * @param - Whether to include items corresponding to placeholders. <ko>placeholder에 해당하는 아이템들을 포함할지 여부.</ko>
2941 */
2942
2943
2944 __proto.getStatus = function (type, includePlaceholders) {
2945 return {
2946 containerManager: this.containerManager.getStatus(),
2947 itemRenderer: this.itemRenderer.getStatus(),
2948 groupManager: this.groupManager.getGroupStatus(type, includePlaceholders),
2949 scrollManager: this.scrollManager.getStatus()
2950 };
2951 };
2952 /**
2953 * You can set placeholders to restore status or wait for items to be added.
2954 * @ko status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다.
2955 * @param - The placeholder status. <ko>placeholder의 status</ko>
2956 */
2957
2958
2959 __proto.setPlaceholder = function (info) {
2960 this.groupManager.setPlaceholder(info);
2961 return this;
2962 };
2963 /**
2964 * You can set placeholders to restore status or wait for items to be added.
2965 * @ko status 복구 또는 아이템 추가 대기를 위한 placeholder를 설정할 수 있다.
2966 * @param - The placeholder status. <ko>placeholder의 status</ko>
2967 */
2968
2969
2970 __proto.setLoading = function (info) {
2971 this.groupManager.setLoading(info);
2972 return this;
2973 };
2974 /**
2975 * Add the placeholder at the end.
2976 * @ko placeholder들을 마지막에 추가한다.
2977 * @param - Items that correspond to placeholders. If it is a number, it duplicates the number of copies. <ko>placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.</ko>
2978 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
2979 */
2980
2981
2982 __proto.appendPlaceholders = function (items, groupKey) {
2983 var _this = this;
2984
2985 var result = this.groupManager.appendPlaceholders(items, groupKey);
2986
2987 this._syncGroups(true);
2988
2989 return __assign(__assign({}, result), {
2990 remove: function () {
2991 _this.removePlaceholders({
2992 groupKey: result.group.groupKey
2993 });
2994 }
2995 });
2996 };
2997 /**
2998 * Add the placeholder at the start.
2999 * @ko placeholder들을 처음에 추가한다.
3000 * @param - Items that correspond to placeholders. If it is a number, it duplicates the number of copies. <ko>placeholder에 해당하는 아이템들. 숫자면 갯수만큼 복제를 한다.</ko>
3001 * @param - The group key to be configured in items. It is automatically generated by default. <ko>추가할 아이템에 설정할 그룹 키. 생략하면 값이 자동으로 생성된다.</ko>
3002 */
3003
3004
3005 __proto.prependPlaceholders = function (items, groupKey) {
3006 var _this = this;
3007
3008 var result = this.groupManager.prependPlaceholders(items, groupKey);
3009
3010 this._syncGroups(true);
3011
3012 return __assign(__assign({}, result), {
3013 remove: function () {
3014 _this.removePlaceholders({
3015 groupKey: result.group.groupKey
3016 });
3017 }
3018 });
3019 };
3020 /**
3021 * Remove placeholders
3022 * @ko placeholder들을 삭제한다.
3023 * @param type - Remove the placeholders corresponding to the groupkey. When "start" or "end", remove all placeholders in that direction. <ko>groupkey에 해당하는 placeholder들을 삭제한다. "start" 또는 "end" 일 때 해당 방향의 모든 placeholder들을 삭제한다.</ko>
3024 */
3025
3026
3027 __proto.removePlaceholders = function (type) {
3028 this.groupManager.removePlaceholders(type);
3029
3030 this._syncGroups(true);
3031 };
3032 /**
3033 * Sets the status of the InfiniteGrid module with the information returned through a call to the getStatus() method.
3034 * @ko getStatus() 메서드가 저장한 정보로 InfiniteGrid 모듈의 상태를 설정한다.
3035 * @param - status object of the InfiniteGrid module. <ko>InfiniteGrid 모듈의 status 객체.</ko>
3036 * @param - Whether the first rendering has already been done. <ko>첫 렌더링이 이미 되어있는지 여부.</ko>
3037 */
3038
3039
3040 __proto.setStatus = function (status, useFirstRender) {
3041 this.itemRenderer.setStatus(status.itemRenderer);
3042 this.containerManager.setStatus(status.containerManager);
3043 this.scrollManager.setStatus(status.scrollManager);
3044 var groupManager = this.groupManager;
3045 var prevInlineSize = this.containerManager.getInlineSize();
3046 groupManager.setGroupStatus(status.groupManager);
3047
3048 this._syncInfinite();
3049
3050 this.infinite.setCursors(groupManager.getStartCursor(), groupManager.getEndCursor());
3051
3052 this._getRenderer().updateKey();
3053
3054 var state = {
3055 isResize: this.containerManager.getInlineSize() !== prevInlineSize,
3056 isRestore: true
3057 };
3058
3059 if (useFirstRender) {
3060 this._syncItems(state);
3061 } else {
3062 this._update(state);
3063 }
3064
3065 return this;
3066 };
3067 /**
3068 * Removes the group corresponding to index.
3069 * @ko index에 해당하는 그룹을 제거 한다.
3070 */
3071
3072
3073 __proto.removeGroupByIndex = function (index) {
3074 var nextGroups = this.getGroups();
3075 return this.removeGroupByKey(nextGroups[index].groupKey);
3076 };
3077 /**
3078 * Removes the group corresponding to key.
3079 * @ko key에 해당하는 그룹을 제거 한다.
3080 */
3081
3082
3083 __proto.removeGroupByKey = function (key) {
3084 var nextItemInfos = this.getItems();
3085 var firstIndex = findIndex(nextItemInfos, function (item) {
3086 return item.groupKey === key;
3087 });
3088 var lastIndex = findLastIndex(nextItemInfos, function (item) {
3089 return item.groupKey === key;
3090 });
3091
3092 if (firstIndex === -1) {
3093 return this;
3094 }
3095
3096 nextItemInfos.splice(firstIndex, lastIndex - firstIndex + 1);
3097 return this.syncItems(nextItemInfos);
3098 };
3099 /**
3100 * Removes the item corresponding to index.
3101 * @ko index에 해당하는 아이템을 제거 한다.
3102 */
3103
3104
3105 __proto.removeByIndex = function (index) {
3106 var nextItemInfos = this.getItems(true);
3107 nextItemInfos.splice(index, 1);
3108 return this.syncItems(nextItemInfos);
3109 };
3110 /**
3111 * Removes the item corresponding to key.
3112 * @ko key에 해당하는 아이템을 제거 한다.
3113 */
3114
3115
3116 __proto.removeByKey = function (key) {
3117 var nextItemInfos = this.getItems(true);
3118 var index = findIndex(nextItemInfos, function (item) {
3119 return item.key === key;
3120 });
3121 return this.removeByIndex(index);
3122 };
3123 /**
3124 * Update the size of the items and render them.
3125 * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다.
3126 * @param - Items to be updated. <ko>업데이트할 아이템들.</ko>
3127 * @param - Options for rendering. <ko>렌더링을 하기 위한 옵션.</ko>
3128 */
3129
3130
3131 __proto.updateItems = function (items, options) {
3132 if (options === void 0) {
3133 options = {};
3134 }
3135
3136 this.groupManager.updateItems(items, options);
3137 return this;
3138 };
3139 /**
3140 * Return all items of InfiniteGrid.
3141 * @ko InfiniteGrid의 모든 아이템들을 반환한다.
3142 * @param - Whether to include items corresponding to placeholders. <ko>placeholder에 해당하는 아이템들을 포함할지 여부.</ko>
3143 */
3144
3145
3146 __proto.getItems = function (includePlaceholders) {
3147 return this.groupManager.getGroupItems(includePlaceholders);
3148 };
3149 /**
3150 * Return visible items of InfiniteGrid.
3151 * @ko InfiniteGrid의 보이는 아이템들을 반환한다.
3152 * @param - Whether to include items corresponding to placeholders. <ko>placeholder에 해당하는 아이템들을 포함할지 여부.</ko>
3153 */
3154
3155
3156 __proto.getVisibleItems = function (includePlaceholders) {
3157 return this.groupManager.getVisibleItems(includePlaceholders);
3158 };
3159 /**
3160 * Return rendering items of InfiniteGrid.
3161 * @ko InfiniteGrid의 렌더링 아이템들을 반환한다.
3162 */
3163
3164
3165 __proto.getRenderingItems = function () {
3166 return this.groupManager.getRenderingItems();
3167 };
3168 /**
3169 * Return all groups of InfiniteGrid.
3170 * @ko InfiniteGrid의 모든 그룹들을 반환한다.
3171 * @param - Whether to include groups corresponding to placeholders. <ko>placeholder에 해당하는 그룹들을 포함할지 여부.</ko>
3172 */
3173
3174
3175 __proto.getGroups = function (includePlaceholders) {
3176 return this.groupManager.getGroups(includePlaceholders);
3177 };
3178 /**
3179 * Return visible groups of InfiniteGrid.
3180 * @ko InfiniteGrid의 보이는 그룹들을 반환한다.
3181 * @param - Whether to include groups corresponding to placeholders. <ko>placeholder에 해당하는 그룹들을 포함할지 여부.</ko>
3182 */
3183
3184
3185 __proto.getVisibleGroups = function (includePlaceholders) {
3186 return this.groupManager.getVisibleGroups(includePlaceholders);
3187 };
3188 /**
3189 * Set to wait to request data.
3190 * @ko 데이터를 요청하기 위해 대기 상태로 설정한다.
3191 * @param direction - direction in which data will be added. <ko>데이터를 추가하기 위한 방향.</ko>
3192 */
3193
3194
3195 __proto.wait = function (direction) {
3196 if (direction === void 0) {
3197 direction = DIRECTION.END;
3198 }
3199
3200 this._waitType = direction;
3201
3202 this._checkStartLoading(direction);
3203 };
3204 /**
3205 * When the data request is complete, it is set to ready state.
3206 * @ko 데이터 요청이 끝났다면 준비 상태로 설정한다.
3207 */
3208
3209
3210 __proto.ready = function () {
3211 this._waitType = "";
3212 };
3213 /**
3214 * Returns whether it is set to wait to request data.
3215 * @ko 데이터를 요청하기 위해 대기 상태로 설정되어 있는지 여부를 반환한다.
3216 */
3217
3218
3219 __proto.isWait = function () {
3220 return !!this._waitType;
3221 };
3222 /**
3223 * Releases the instnace and events and returns the CSS of the container and elements.
3224 * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.
3225 */
3226
3227
3228 __proto.destroy = function () {
3229 this.off();
3230
3231 this._getRenderer().destroy();
3232
3233 this.containerManager.destroy();
3234 this.groupManager.destroy();
3235 this.scrollManager.destroy();
3236 this.infinite.destroy();
3237 };
3238
3239 __proto._getRenderer = function () {
3240 return this.options.renderer;
3241 };
3242
3243 __proto._getRendererItems = function () {
3244 return this.getRenderingItems().map(function (item) {
3245 return {
3246 element: item.element,
3247 key: item.type + "_" + item.key,
3248 orgItem: item
3249 };
3250 });
3251 };
3252
3253 __proto._syncItems = function (state) {
3254 this._getRenderer().syncItems(this._getRendererItems(), state);
3255 };
3256
3257 __proto._render = function (state) {
3258 this._getRenderer().render(this._getRendererItems(), state);
3259 };
3260
3261 __proto._update = function (state) {
3262 if (state === void 0) {
3263 state = {};
3264 }
3265
3266 this._getRenderer().update(state);
3267 };
3268
3269 __proto._resizeScroll = function () {
3270 var scrollManager = this.scrollManager;
3271 scrollManager.resize();
3272 this.infinite.setSize(scrollManager.getContentSize());
3273 };
3274
3275 __proto._syncGroups = function (isUpdate) {
3276 var infinite = this.infinite;
3277 var scrollManager = this.scrollManager;
3278
3279 if (!scrollManager.getContentSize()) {
3280 this._resizeScroll();
3281 }
3282
3283 this._syncInfinite();
3284
3285 this.groupManager.setCursors(infinite.getStartCursor(), infinite.getEndCursor());
3286
3287 if (isUpdate) {
3288 this._update();
3289 } else {
3290 this._render();
3291 }
3292 };
3293
3294 __proto._syncInfinite = function () {
3295 this.infinite.syncItems(this.getGroups(true).map(function (_a) {
3296 var groupKey = _a.groupKey,
3297 grid = _a.grid,
3298 type = _a.type;
3299 var outlines = grid.getOutlines();
3300 return {
3301 key: groupKey,
3302 isVirtual: type === GROUP_TYPE.VIRTUAL,
3303 startOutline: outlines.start,
3304 endOutline: outlines.end
3305 };
3306 }));
3307 };
3308
3309 __proto._scroll = function () {
3310 this.infinite.scroll(this.scrollManager.getRelativeScrollPos());
3311 };
3312
3313 __proto._onRequestInsert = function (direction, eventType, e) {
3314 var _this = this;
3315
3316 if (this._waitType) {
3317 this._checkStartLoading(this._waitType);
3318
3319 return;
3320 }
3321
3322 this.trigger(new Component.ComponentEvent(eventType, {
3323 groupKey: e.key,
3324 nextGroupKey: e.nextKey,
3325 nextGroupKeys: e.nextKeys || [],
3326 isVirtual: e.isVirtual,
3327 wait: function () {
3328 _this.wait(direction);
3329 },
3330 ready: function () {
3331 _this.ready();
3332 }
3333 }));
3334 };
3335
3336 __proto._renderItems = function (options, isTrusted) {
3337 if (options === void 0) {
3338 options = {};
3339 }
3340
3341 if (!isTrusted && options.useResize) {
3342 this.containerManager.resize();
3343 }
3344
3345 this._resizeScroll();
3346
3347 if (!this.getRenderingItems().length) {
3348 var children = toArray(this.getContainerElement().children);
3349
3350 if (children.length > 0) {
3351 // no items, but has children
3352 this.groupManager.syncItems(convertInsertedItems(children));
3353
3354 this._syncInfinite();
3355
3356 this.setCursors(0, 0, true);
3357
3358 this._getRenderer().updated();
3359 } else {
3360 this.infinite.scroll(0);
3361 }
3362
3363 return this;
3364 }
3365
3366 if (!this.getVisibleGroups(true).length) {
3367 this.setCursors(0, 0);
3368 } else {
3369 this.groupManager.renderItems(options);
3370 }
3371
3372 return this;
3373 };
3374
3375 __proto._checkStartLoading = function (direction) {
3376 var groupManager = this.groupManager;
3377 var infinite = this.infinite;
3378
3379 if (!groupManager.getLoadingType() && infinite.isLoading(direction) && groupManager.startLoading(direction) && groupManager.hasLoadingItem()) {
3380 this._update();
3381 }
3382 };
3383
3384 __proto._checkEndLoading = function () {
3385 var groupManager = this.groupManager;
3386 var loadingType = this.groupManager.getLoadingType();
3387
3388 if (loadingType && (!this._waitType || !this.infinite.isLoading(loadingType)) && groupManager.endLoading() && groupManager.hasLoadingItem()) {
3389 this._update();
3390 }
3391 };
3392
3393 var InfiniteGrid_1;
3394 InfiniteGrid.defaultOptions = __assign(__assign({}, Grid.DEFAULT_GRID_OPTIONS), {
3395 container: false,
3396 containerTag: "div",
3397 renderer: null,
3398 threshold: 100,
3399 useRecycle: true
3400 });
3401 InfiniteGrid.propertyTypes = INFINITEGRID_PROPERTY_TYPES;
3402 InfiniteGrid = InfiniteGrid_1 = __decorate([InfiniteGridGetterSetter], InfiniteGrid);
3403 return InfiniteGrid;
3404}(Component);
3405
3406/**
3407 * MasonryInfiniteGrid is a grid that stacks items with the same width as a stack of bricks. Adjust the width of all images to the same size, find the lowest height column, and insert a new item.
3408 * @ko MasonryInfiniteGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템을 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.
3409 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3410 * @param {MasonryInfiniteGridOptions} options - The option object of the MasonryInfiniteGrid module <ko>MasonryInfiniteGrid 모듈의 옵션 객체</ko>
3411 */
3412
3413var MasonryInfiniteGrid =
3414/*#__PURE__*/
3415function (_super) {
3416 __extends(MasonryInfiniteGrid, _super);
3417
3418 function MasonryInfiniteGrid() {
3419 return _super !== null && _super.apply(this, arguments) || this;
3420 }
3421
3422 MasonryInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), Grid.MasonryGrid.propertyTypes);
3423 MasonryInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), Grid.MasonryGrid.defaultOptions), {
3424 gridConstructor: Grid.MasonryGrid
3425 });
3426 MasonryInfiniteGrid = __decorate([InfiniteGridGetterSetter], MasonryInfiniteGrid);
3427 return MasonryInfiniteGrid;
3428}(InfiniteGrid);
3429
3430/**
3431 * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedInfiniteGrid is a grid that the item is filled up on the basis of a line given a size.
3432 * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.
3433 * If 'data-grid-maintained-target' is set for an element whose ratio is to be maintained, the item is rendered while maintaining the ratio of the element.
3434 * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedInfiniteGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.
3435 * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.
3436 * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다.
3437 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3438 * @param {JustifiedInfiniteGridOptions} options - The option object of the JustifiedInfiniteGrid module <ko>JustifiedInfiniteGrid 모듈의 옵션 객체</ko>
3439 */
3440
3441var JustifiedInfiniteGrid =
3442/*#__PURE__*/
3443function (_super) {
3444 __extends(JustifiedInfiniteGrid, _super);
3445
3446 function JustifiedInfiniteGrid() {
3447 return _super !== null && _super.apply(this, arguments) || this;
3448 }
3449
3450 JustifiedInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), Grid.JustifiedGrid.propertyTypes);
3451 JustifiedInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), Grid.JustifiedGrid.defaultOptions), {
3452 gridConstructor: Grid.JustifiedGrid
3453 });
3454 JustifiedInfiniteGrid = __decorate([InfiniteGridGetterSetter], JustifiedInfiniteGrid);
3455 return JustifiedInfiniteGrid;
3456}(InfiniteGrid);
3457
3458/**
3459 * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameInfiniteGrid is a grid that the item is filled up on the basis of a line given a size.
3460 * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameInfiniteGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다.
3461 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3462 * @param {FrameInfiniteGridOptions} options - The option object of the FrameInfiniteGrid module <ko>FrameGrid 모듈의 옵션 객체</ko>
3463 */
3464
3465var FrameInfiniteGrid =
3466/*#__PURE__*/
3467function (_super) {
3468 __extends(FrameInfiniteGrid, _super);
3469
3470 function FrameInfiniteGrid() {
3471 return _super !== null && _super.apply(this, arguments) || this;
3472 }
3473
3474 FrameInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), Grid.FrameGrid.propertyTypes);
3475 FrameInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), Grid.FrameGrid.defaultOptions), {
3476 gridConstructor: Grid.FrameGrid
3477 });
3478 FrameInfiniteGrid = __decorate([InfiniteGridGetterSetter], FrameInfiniteGrid);
3479 return FrameInfiniteGrid;
3480}(InfiniteGrid);
3481
3482/**
3483 * The PackingInfiniteGrid is a grid that shows the important items bigger without sacrificing the weight of the items.
3484 * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.
3485 * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible.
3486 * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible.
3487 * @ko PackingInfiniteGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.
3488 * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.
3489 * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.
3490 * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다.
3491 * @param {HTMLElement | string} container - A base element for a module <ko>모듈을 적용할 기준 엘리먼트</ko>
3492 * @param {PackingInfiniteGridOptions} options - The option object of the PackingInfiniteGrid module <ko>PackingInfiniteGrid 모듈의 옵션 객체</ko>
3493 */
3494
3495var PackingInfiniteGrid =
3496/*#__PURE__*/
3497function (_super) {
3498 __extends(PackingInfiniteGrid, _super);
3499
3500 function PackingInfiniteGrid() {
3501 return _super !== null && _super.apply(this, arguments) || this;
3502 }
3503
3504 PackingInfiniteGrid.propertyTypes = __assign(__assign({}, InfiniteGrid.propertyTypes), Grid.PackingGrid.propertyTypes);
3505 PackingInfiniteGrid.defaultOptions = __assign(__assign(__assign({}, InfiniteGrid.defaultOptions), Grid.PackingGrid.defaultOptions), {
3506 gridConstructor: Grid.PackingGrid
3507 });
3508 PackingInfiniteGrid = __decorate([InfiniteGridGetterSetter], PackingInfiniteGrid);
3509 return PackingInfiniteGrid;
3510}(InfiniteGrid);
3511
3512
3513
3514var modules = {
3515 __proto__: null,
3516 'default': InfiniteGrid,
3517 withInfiniteGridMethods: withInfiniteGridMethods,
3518 getRenderingItems: getRenderingItems,
3519 mountRenderingItems: mountRenderingItems,
3520 InfiniteGridItem: InfiniteGridItem,
3521 MasonryInfiniteGrid: MasonryInfiniteGrid,
3522 JustifiedInfiniteGrid: JustifiedInfiniteGrid,
3523 FrameInfiniteGrid: FrameInfiniteGrid,
3524 PackingInfiniteGrid: PackingInfiniteGrid,
3525 Renderer: Renderer,
3526 IS_IOS: IS_IOS,
3527 CONTAINER_CLASS_NAME: CONTAINER_CLASS_NAME,
3528 IGNORE_PROPERITES_MAP: IGNORE_PROPERITES_MAP,
3529 INFINITEGRID_PROPERTY_TYPES: INFINITEGRID_PROPERTY_TYPES,
3530 DIRECTION: DIRECTION,
3531 INFINITEGRID_EVENTS: INFINITEGRID_EVENTS,
3532 ITEM_INFO_PROPERTIES: ITEM_INFO_PROPERTIES,
3533 INFINITEGRID_METHODS: INFINITEGRID_METHODS,
3534 get GROUP_TYPE () { return GROUP_TYPE; },
3535 get ITEM_TYPE () { return ITEM_TYPE; },
3536 get STATUS_TYPE () { return STATUS_TYPE; },
3537 INVISIBLE_POS: INVISIBLE_POS
3538};
3539
3540for (var name in modules) {
3541 InfiniteGrid[name] = modules[name];
3542}
3543
3544module.exports = InfiniteGrid;
3545//# sourceMappingURL=infinitegrid.cjs.js.map