From d0ff48c8f2b0e95f6a1d5d9b99168b795b3cf8aa Mon Sep 17 00:00:00 2001 From: Daybrush Date: Fri, 9 Jul 2021 19:29:23 +0900 Subject: [PATCH] chore(release): Release 1.3.1 --- .gitignore | 2 +- dist/grid.cjs.js | 3053 ++++++++++ dist/grid.cjs.js.map | 1 + dist/grid.esm.js | 3020 ++++++++++ dist/grid.esm.js.map | 1 + dist/grid.js | 5288 +++++++++++++++++ dist/grid.js.map | 1 + dist/grid.min.js | 10 + dist/grid.min.js.map | 1 + package-lock.json | 2 +- package.json | 2 +- .../projects/ngx-grid/package-lock.json | 8 +- .../ngx-grid/projects/ngx-grid/package.json | 4 +- packages/react-grid/package-lock.json | 8 +- packages/react-grid/package.json | 4 +- packages/svelte-grid/package-lock.json | 8 +- packages/svelte-grid/package.json | 4 +- packages/vue-grid/package-lock.json | 8 +- packages/vue-grid/package.json | 4 +- 19 files changed, 11402 insertions(+), 27 deletions(-) create mode 100644 dist/grid.cjs.js create mode 100644 dist/grid.cjs.js.map create mode 100644 dist/grid.esm.js create mode 100644 dist/grid.esm.js.map create mode 100644 dist/grid.js create mode 100644 dist/grid.js.map create mode 100644 dist/grid.min.js create mode 100644 dist/grid.min.js.map diff --git a/.gitignore b/.gitignore index d46e888..1dd4aa5 100644 --- a/.gitignore +++ b/.gitignore @@ -213,4 +213,4 @@ declaration/ packages/*/dist/ test/e2e/log/ test/e2e/screenshots/diff/ -dist/ + diff --git a/dist/grid.cjs.js b/dist/grid.cjs.js new file mode 100644 index 0000000..436c5f9 --- /dev/null +++ b/dist/grid.cjs.js @@ -0,0 +1,3053 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.3.1 +*/ +'use strict'; + +var Component = require('@egjs/component'); +var ImReady = require('@egjs/imready'); +var childrenDiffer = require('@egjs/children-differ'); + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ + +/* global Reflect, Promise */ +var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} +var __assign = function () { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign.apply(this, arguments); +}; +function __decorate(decorators, target, key, desc) { + var c = arguments.length, + r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, + d; + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} +/** @deprecated */ + +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + 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]; + + return r; +} + +var DEFAULT_GRID_OPTIONS = { + horizontal: false, + useTransform: false, + percentage: false, + isEqualSize: false, + isConstantSize: false, + gap: 0, + attributePrefix: "data-grid-", + resizeDebounce: 100, + maxResizeDebounce: 0, + autoResize: true, + preserveUIOnDestroy: false, + defaultDirection: "end", + externalContainerManager: null, + externalItemRenderer: null, + renderOnPropertyChange: true, + useFit: true +}; +var PROPERTY_TYPE; + +(function (PROPERTY_TYPE) { + PROPERTY_TYPE[PROPERTY_TYPE["PROPERTY"] = 1] = "PROPERTY"; + PROPERTY_TYPE[PROPERTY_TYPE["RENDER_PROPERTY"] = 2] = "RENDER_PROPERTY"; +})(PROPERTY_TYPE || (PROPERTY_TYPE = {})); + +var MOUNT_STATE; + +(function (MOUNT_STATE) { + MOUNT_STATE[MOUNT_STATE["UNCHECKED"] = 1] = "UNCHECKED"; + MOUNT_STATE[MOUNT_STATE["UNMOUNTED"] = 2] = "UNMOUNTED"; + MOUNT_STATE[MOUNT_STATE["MOUNTED"] = 3] = "MOUNTED"; +})(MOUNT_STATE || (MOUNT_STATE = {})); + +var UPDATE_STATE; + +(function (UPDATE_STATE) { + UPDATE_STATE[UPDATE_STATE["NEED_UPDATE"] = 1] = "NEED_UPDATE"; + UPDATE_STATE[UPDATE_STATE["WAIT_LOADING"] = 2] = "WAIT_LOADING"; + UPDATE_STATE[UPDATE_STATE["UPDATED"] = 3] = "UPDATED"; +})(UPDATE_STATE || (UPDATE_STATE = {})); + +var GRID_PROPERTY_TYPES = { + gap: PROPERTY_TYPE.RENDER_PROPERTY, + defaultDirection: PROPERTY_TYPE.PROPERTY, + renderOnPropertyChange: PROPERTY_TYPE.PROPERTY, + preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY, + useFit: PROPERTY_TYPE.PROPERTY +}; +var GRID_METHODS = ["syncElements", "updateItems", "getItems", "setItems", "renderItems", "getContainerInlineSize", "getContainerElement"]; +var GRID_EVENTS = ["renderComplete", "contentError"]; +var RECT_NAMES = { + horizontal: { + inlinePos: "top", + contentPos: "left", + inlineSize: "height", + contentSize: "width" + }, + vertical: { + inlinePos: "left", + contentPos: "top", + inlineSize: "width", + contentSize: "height" + } +}; + +var ContainerManager = +/*#__PURE__*/ +function () { + function ContainerManager(container, options) { + this.container = container; + this.options = __assign({ + horizontal: DEFAULT_GRID_OPTIONS.horizontal + }, options); + + this._init(); + } + + var __proto = ContainerManager.prototype; + + __proto.resize = function () { + var container = this.container; + this.setRect({ + width: container.offsetWidth, + height: container.offsetHeight + }); + }; + + __proto.getRect = function () { + return this.rect; + }; + + __proto.setRect = function (rect) { + this.rect = __assign({}, rect); + }; + + __proto.getInlineSize = function () { + return this.rect[this.options.horizontal ? "height" : "width"]; + }; + + __proto.getContentSize = function () { + return this.rect[this.options.horizontal ? "width" : "height"]; + }; + + __proto.getStatus = function () { + return { + rect: __assign({}, this.rect) + }; + }; + + __proto.setStatus = function (status) { + this.rect = __assign({}, status.rect); + this.setContentSize(this.getContentSize()); + }; + + __proto.setContentSize = function (size) { + var sizeName = this.options.horizontal ? "width" : "height"; + this.rect[sizeName] = size; + this.container.style[sizeName] = size + "px"; + }; + + __proto.destroy = function (options) { + if (options === void 0) { + options = {}; + } + + if (!options.preserveUI) { + this.container.style.cssText = this.orgCSSText; + } + }; + + __proto._init = function () { + var container = this.container; + var style = window.getComputedStyle(container); + this.orgCSSText = container.style.cssText; + + if (style.position === "static") { + container.style.position = "relative"; + } + }; + + return ContainerManager; +}(); + +function getKeys(obj) { + return Object.keys(obj); +} +function isString(val) { + return typeof val === "string"; +} +function isObject(val) { + return typeof val === "object"; +} +function isNumber(val) { + return typeof val === "number"; +} +function camelize(str) { + return str.replace(/[\s-_]([a-z])/g, function (all, letter) { + return letter.toUpperCase(); + }); +} +function getDataAttributes(element, attributePrefix) { + var dataAttributes = {}; + var attributes = element.attributes; + var length = attributes.length; + + for (var i = 0; i < length; ++i) { + var attribute = attributes[i]; + var name = attribute.name, + value = attribute.value; + + if (name.indexOf(attributePrefix) === -1) { + continue; + } + + dataAttributes[camelize(name.replace(attributePrefix, ""))] = value; + } + + return dataAttributes; +} +/* Class Decorator */ + +function GetterSetter(component) { + var prototype = component.prototype, + propertyTypes = component.propertyTypes; + + var _loop_1 = function (name) { + var shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY; + var attributes = { + enumerable: true, + configurable: true, + get: function () { + return this.options[name]; + }, + set: function (value) { + var options = this.options; + var prevValue = options[name]; + + if (prevValue === value) { + return; + } + + options[name] = value; + + if (shouldRender && options.renderOnPropertyChange) { + this.scheduleRender(); + } + } + }; + Object.defineProperty(prototype, name, attributes); + }; + + for (var name in propertyTypes) { + _loop_1(name); + } +} +function withMethods(methods) { + return function (prototype, memberName) { + methods.forEach(function (name) { + if (name in prototype) { + return; + } + + prototype[name] = function () { + var _a; + + var args = []; + + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + + var result = (_a = this[memberName])[name].apply(_a, args); // fix `this` type to return your own `class` instance to the instance using the decorator. + + + if (result === this[memberName]) { + return this; + } else { + return result; + } + }; + }); + }; +} +function range(length) { + var arr = []; + + for (var i = 0; i < length; ++i) { + arr.push(i); + } + + return arr; +} +function getRangeCost(value, valueRange) { + return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1; +} +/** + * Decorator that makes the method of grid available in the framework. + * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터. + * @memberof eg.Grid + * @private + * @example + * ```js + * import { withGridMethods } from "@egjs/grid"; + * + * class Grid extends React.Component> { + * @withGridMethods + * private grid: NativeGrid; + * } + * ``` + */ + +var withGridMethods = withMethods(GRID_METHODS); + +var ItemRenderer = +/*#__PURE__*/ +function () { + function ItemRenderer(options) { + this.initialRect = null; + this.sizePercetage = false; + this.posPercetage = false; + this.options = __assign({ + attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix, + useTransform: DEFAULT_GRID_OPTIONS.useTransform, + horizontal: DEFAULT_GRID_OPTIONS.horizontal, + percentage: DEFAULT_GRID_OPTIONS.percentage, + isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize, + isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize + }, options); + + this._init(); + } + + var __proto = ItemRenderer.prototype; + + __proto.resize = function () { + this.initialRect = null; + }; + + __proto.renderItems = function (items) { + var _this = this; + + items.forEach(function (item) { + _this._renderItem(item); + }); + }; + + __proto.getInlineSize = function () { + return this.containerRect[this.options.horizontal ? "height" : "width"]; + }; + + __proto.setContainerRect = function (rect) { + this.containerRect = rect; + }; + + __proto.updateItems = function (items) { + var _this = this; + + items.forEach(function (item) { + _this._updateItem(item); + }); + }; + + __proto.getStatus = function () { + return { + initialRect: this.initialRect + }; + }; + + __proto.setStatus = function (status) { + this.initialRect = status.initialRect; + }; + + __proto._init = function () { + var percentage = this.options.percentage; + var sizePercentage = false; + var posPercentage = false; + + if (percentage === true) { + sizePercentage = true; + posPercentage = true; + } else if (percentage) { + if (percentage.indexOf("position") > -1) { + posPercentage = true; + } + + if (percentage.indexOf("size") > -1) { + sizePercentage = true; + } + } + + this.posPercetage = posPercentage; + this.sizePercetage = sizePercentage; + }; + + __proto._updateItem = function (item) { + var _a = this.options, + isEqualSize = _a.isEqualSize, + isConstantSize = _a.isConstantSize; + var initialRect = this.initialRect; + var orgRect = item.orgRect, + element = item.element; + var isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING; + var hasOrgSize = orgRect && orgRect.width && orgRect.height; + var rect; + + if (isEqualSize && initialRect) { + rect = initialRect; + } else if (isConstantSize && hasOrgSize && !isLoading) { + rect = orgRect; + } else if (!element) { + return; + } else { + rect = { + left: element.offsetLeft, + top: element.offsetTop, + width: element.offsetWidth, + height: element.offsetHeight + }; + } + + if (!item.isFirstUpdate) { + item.orgRect = __assign({}, rect); + } + + item.rect = __assign({}, rect); + + if (item.element) { + item.mountState = MOUNT_STATE.MOUNTED; + } + + if (item.updateState === UPDATE_STATE.NEED_UPDATE) { + item.updateState = UPDATE_STATE.UPDATED; + item.isFirstUpdate = true; + } + + item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {}; + + if (!isLoading) { + this.initialRect = __assign({}, rect); + } + + return rect; + }; + + __proto._renderItem = function (item) { + var element = item.element; + var cssRect = item.cssRect; + + if (!element || !cssRect) { + return; + } + + var _a = this.options, + horizontal = _a.horizontal, + useTransform = _a.useTransform; + var posPercentage = this.posPercetage; + var sizePercentage = this.sizePercetage; + var cssTexts = ["position: absolute;"]; + var _b = RECT_NAMES[horizontal ? "horizontal" : "vertical"], + sizeName = _b.inlineSize, + posName = _b.inlinePos; + var inlineSize = this.getInlineSize(); + var keys = getKeys(cssRect); + + if (useTransform) { + keys = keys.filter(function (key) { + return key !== "top" && key !== "left"; + }); + cssTexts.push("transform: " + ("translate(" + (cssRect.left || 0) + "px, " + (cssRect.top || 0) + "px);")); + } + + cssTexts.push.apply(cssTexts, keys.map(function (name) { + var value = cssRect[name]; + + if (name === sizeName && sizePercentage || name === posName && posPercentage) { + return name + ": " + value / inlineSize * 100 + "%;"; + } + + return name + ": " + value + "px;"; + })); + element.style.cssText += cssTexts.join(""); + }; + + return ItemRenderer; +}(); + +/** + * @memberof Grid + * @implements Grid.GridItem.GridItemStatus + */ + +var GridItem = +/*#__PURE__*/ +function () { + /** + * @constructor + * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향) + * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체. + */ + function GridItem(horizontal, itemStatus) { + if (itemStatus === void 0) { + itemStatus = {}; + } + + var _a; + + this.horizontal = horizontal; + /** + * Grid ready data for rendering + * @ko 렌더링을 하기 위한 grid의 준비 데이타 + * @member Grid.GridItem#gridData + */ + + this.gridData = {}; + var element = itemStatus.element; + + var status = __assign({ + key: "", + orgRect: { + left: 0, + top: 0, + width: 0, + height: 0 + }, + rect: { + left: 0, + top: 0, + width: 0, + height: 0 + }, + cssRect: {}, + attributes: {}, + data: {}, + isFirstUpdate: false, + mountState: MOUNT_STATE.UNCHECKED, + updateState: UPDATE_STATE.NEED_UPDATE, + element: element || null, + orgCSSText: (_a = element === null || element === void 0 ? void 0 : element.style.cssText) !== null && _a !== void 0 ? _a : "" + }, itemStatus); + + for (var name in status) { + this[name] = status[name]; + } + } + + var __proto = GridItem.prototype; + Object.defineProperty(__proto, "orgInlineSize", { + /** + * The size in inline direction before first rendering. "width" if horizontal is false, "height" otherwise. + * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#orgInlineSize + */ + get: function () { + var orgRect = this.orgRect || this.rect; + return this.horizontal ? orgRect.height : orgRect.width; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "orgContentSize", { + /** + * The size in content direction before first rendering. "height" if horizontal is false, "width" otherwise. + * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#orgContentSize + */ + get: function () { + var orgRect = this.orgRect || this.rect; + return this.horizontal ? orgRect.width : orgRect.height; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "inlineSize", { + /** + * The size in inline direction. "width" if horizontal is false, "height" otherwise. + * @ko inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#inlineSize + */ + get: function () { + var rect = this.rect; + return this.horizontal ? rect.height : rect.width; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "contentSize", { + /** + * The size in content direction. "height" if horizontal is false, "width" otherwise. + * @ko content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#contentSize + */ + get: function () { + var rect = this.rect; + return this.horizontal ? rect.width : rect.height; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssInlineSize", { + /** + * The CSS size in inline direction applied to the Grid. "width" if horizontal is false, "height" otherwise. + * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#cssInlineSize + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.height : cssRect.width; + }, + set: function (inlineSize) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "height" : "width"] = inlineSize; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssContentSize", { + /** + * The CSS size in content direction applied to the Grid. "height" if horizontal is false, "width" otherwise. + * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#cssContentSize + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.width : cssRect.height; + }, + set: function (contentSize) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "width" : "height"] = contentSize; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssInlinePos", { + /** + * The CSS pos in inline direction applied to the Grid. "left" if horizontal is false, "top" otherwise. + * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 "left", 아니면 "top". + * @member Grid.GridItem#cssInlinePos + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.top : cssRect.left; + }, + set: function (inlinePos) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "top" : "left"] = inlinePos; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssContentPos", { + /** + * The CSS pos in content direction applied to the Grid. "top" if horizontal is false, "left" otherwise. + * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 "top", 아니면 "left". + * @member Grid.GridItem#cssContentPos + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.left : cssRect.top; + }, + set: function (contentPos) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "left" : "top"] = contentPos; + }, + enumerable: false, + configurable: true + }); + /** + * Set CSS Rect through GridRect. + * @ko GridRect을 통해 CSS Rect를 설정한다. + * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일. + */ + + __proto.setCSSGridRect = function (gridRect) { + var names = RECT_NAMES[this.horizontal ? "horizontal" : "vertical"]; + var rect = {}; + + for (var name in gridRect) { + rect[names[name]] = gridRect[name]; + } + + this.cssRect = rect; + }; + /** + * Returns the status of the item. + * @ko 아이템의 상태를 반환한다. + */ + + + __proto.getStatus = function () { + return { + mountState: this.mountState, + updateState: this.updateState, + attributes: this.attributes, + orgCSSText: this.orgCSSText, + isFirstUpdate: this.isFirstUpdate, + element: null, + key: this.key, + orgRect: this.orgRect, + rect: this.rect, + cssRect: this.cssRect, + data: this.data + }; + }; + + return GridItem; +}(); + +/** + * @extends eg.Component + */ + +var Grid = +/*#__PURE__*/ +function (_super) { + __extends(Grid, _super); + /** + * @param - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param - The option object of the Grid module Grid 모듈의 옵션 객체 + */ + + + function Grid(containerElement, options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.items = []; + _this.outlines = { + start: [], + end: [] + }; + _this._renderTimer = 0; + _this._resizeTimer = 0; + _this._maxResizeDebounceTimer = 0; + + _this._onResize = function () { + clearTimeout(_this._resizeTimer); + clearTimeout(_this._maxResizeDebounceTimer); + _this._maxResizeDebounceTimer = 0; + _this._resizeTimer = 0; + + _this.renderItems({ + useResize: true + }); + }; + + _this._scheduleResize = function () { + var _a = _this.options, + resizeDebounce = _a.resizeDebounce, + maxResizeDebounce = _a.maxResizeDebounce; + + if (!_this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) { + _this._maxResizeDebounceTimer = window.setTimeout(_this._onResize, maxResizeDebounce); + } + + if (_this._resizeTimer) { + clearTimeout(_this._resizeTimer); + _this._resizeTimer = 0; + } + + _this._resizeTimer = window.setTimeout(_this._onResize, resizeDebounce); + }; + + _this.options = __assign(__assign({}, _this.constructor.defaultOptions), options); + _this.containerElement = isString(containerElement) ? document.querySelector(containerElement) : containerElement; + var _a = _this.options, + isEqualSize = _a.isEqualSize, + isConstantSize = _a.isConstantSize, + useTransform = _a.useTransform, + horizontal = _a.horizontal, + percentage = _a.percentage, + externalContainerManager = _a.externalContainerManager, + externalItemRenderer = _a.externalItemRenderer; // TODO: 테스트용 설정 + + _this.containerManager = externalContainerManager || new ContainerManager(_this.containerElement, { + horizontal: horizontal + }); + _this.itemRenderer = externalItemRenderer || new ItemRenderer({ + useTransform: useTransform, + isEqualSize: isEqualSize, + isConstantSize: isConstantSize, + percentage: percentage + }); + + _this._init(); + + return _this; + } + + var __proto = Grid.prototype; + Grid_1 = Grid; + /** + * Return Container Element. + * @ko 컨테이너 엘리먼트를 반환한다. + */ + + __proto.getContainerElement = function () { + return this.containerElement; + }; + /** + * Return items. + * @ko 아이템들을 반환한다. + */ + + + __proto.getItems = function () { + return this.items; + }; + /** + * Returns the children of the container element. + * @ko 컨테이너 엘리먼트의 children을 반환한다. + */ + + + __proto.getChildren = function () { + return [].slice.call(this.containerElement.children); + }; + /** + * Set items. + * @ko 아이템들을 설정한다. + * @param items - The items to set. 설정할 아이템들 + */ + + + __proto.setItems = function (items) { + this.items = items; + return this; + }; + /** + * Gets the container's inline size. ("width" if horizontal is false, otherwise "height") + * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 "width", 아니면 "height") + */ + + + __proto.getContainerInlineSize = function () { + return this.containerManager.getInlineSize(); + }; + /** + * Returns the outlines of the start and end of the Grid. + * @ko Grid의 처음과 끝의 outline을 반환한다. + */ + + + __proto.getOutlines = function () { + return this.outlines; + }; + /** + * Set outlines. + * @ko 아웃라인을 설정한다. + * @param outlines - The outlines to set. 설정할 아웃라인. + */ + + + __proto.setOutlines = function (outlines) { + this.outlines = outlines; + return this; + }; + /** + * When elements change, it synchronizes and renders items. + * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + */ + + + __proto.syncElements = function (options) { + if (options === void 0) { + options = {}; + } + + var items = this.items; + var horizontal = this.options.horizontal; + var elements = this.getChildren(); + + var _a = childrenDiffer.diff(this.items.map(function (item) { + return item.element; + }), elements), + added = _a.added, + maintained = _a.maintained, + changed = _a.changed, + removed = _a.removed; + + var nextItems = []; + maintained.forEach(function (_a) { + var beforeIndex = _a[0], + afterIndex = _a[1]; + nextItems[afterIndex] = items[beforeIndex]; + }); + added.forEach(function (index) { + nextItems[index] = new GridItem(horizontal, { + element: elements[index] + }); + }); + this.setItems(nextItems); + + if (added.length || removed.length || changed.length) { + this.renderItems(options); + } + + return this; + }; + /** + * Update the size of the items and render them. + * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다. + * @param - Items to be updated. 업데이트할 아이템들. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + */ + + + __proto.updateItems = function (items, options) { + if (items === void 0) { + items = this.items; + } + + if (options === void 0) { + options = {}; + } + + items.forEach(function (item) { + item.updateState = UPDATE_STATE.NEED_UPDATE; + }); + this.checkReady(options); + return this; + }; + /** + * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired. + * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + * @example + * import { MasonryGrid } from "@egjs/grid"; + * const grid = new MasonryGrid(); + * + * grid.on("renderComplete", e => { + * console.log(e); + * }); + * grid.renderItems(); + */ + + + __proto.renderItems = function (options) { + if (options === void 0) { + options = {}; + } + + this._clearRenderTimer(); + + if (!this.getItems().length && this.getChildren().length) { + this.syncElements(options); + } else if (options.useResize) { + // Resize container and Update all items + this._resizeContainer(); + + this.updateItems(this.items, options); + } else { + // Update only items that need to be updated. + this.checkReady(options); + } + + return this; + }; + /** + * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method. + * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + */ + + + __proto.getStatus = function () { + return { + outlines: this.outlines, + items: this.items.map(function (item) { + return item.getStatus(); + }), + containerManager: this.containerManager.getStatus(), + itemRenderer: this.itemRenderer.getStatus() + }; + }; + /** + * Set status of the Grid module with the status returned through a call to the getStatus() method. + * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다. + */ + + + __proto.setStatus = function (status) { + var _this = this; + + var horizontal = this.options.horizontal; + var containerManager = this.containerManager; + var prevInlineSize = containerManager.getInlineSize(); + var children = this.getChildren(); + this.itemRenderer.setStatus(status.itemRenderer); + containerManager.setStatus(status.containerManager); + this.outlines = status.outlines; + this.items = status.items.map(function (item, i) { + return new GridItem(horizontal, __assign(__assign({}, item), { + element: children[i] + })); + }); + this.itemRenderer.renderItems(this.items); + + if (prevInlineSize !== containerManager.getInlineSize()) { + this.renderItems({ + useResize: true + }); + } else { + window.setTimeout(function () { + _this._renderComplete({ + mounted: _this.items, + updated: [], + isResize: false + }); + }); + } + + return this; + }; + /** + * Releases the instnace and events and returns the CSS of the container and elements. + * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + * @param Options for destroy. destory()를 위한 옵션 + */ + + + __proto.destroy = function (options) { + var _a; + + if (options === void 0) { + options = {}; + } + + var _b = options.preserveUI, + preserveUI = _b === void 0 ? this.options.preserveUIOnDestroy : _b; + this.containerManager.destroy({ + preserveUI: preserveUI + }); + + if (!preserveUI) { + this.items.forEach(function (_a) { + var element = _a.element, + orgCSSText = _a.orgCSSText; + + if (element) { + element.style.cssText = orgCSSText; + } + }); + } + + window.removeEventListener("resize", this._scheduleResize); + (_a = this._im) === null || _a === void 0 ? void 0 : _a.destroy(); + }; + + __proto.checkReady = function (options) { + var _this = this; + + var _a; + + if (options === void 0) { + options = {}; + } // Grid: renderItems => checkReady => readyItems => applyGrid + + + var items = this.items; + var updated = items.filter(function (item) { + return item.element && item.updateState !== UPDATE_STATE.UPDATED; + }); + var mounted = updated.filter(function (item) { + return item.mountState !== MOUNT_STATE.MOUNTED; + }); + var moreUpdated = []; + (_a = this._im) === null || _a === void 0 ? void 0 : _a.destroy(); + this._im = new ImReady({ + prefix: this.options.attributePrefix + }).on("preReadyElement", function (e) { + updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING; + }).on("preReady", function () { + _this.itemRenderer.updateItems(updated); + + _this.readyItems(mounted, updated, options); + }).on("readyElement", function (e) { + var item = updated[e.index]; + item.updateState = UPDATE_STATE.NEED_UPDATE; // after preReady + + if (e.isPreReadyOver) { + item.element.style.cssText = item.orgCSSText; + + _this.itemRenderer.updateItems([item]); + + _this.readyItems([], [item], options); + } + }).on("error", function (e) { + var item = items[e.index]; + /** + * This event is fired when an error occurs in the content. + * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트. + * @event Grid#contentError + * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트. + * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트. + * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템 + * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라. + * @example + grid.on("contentError", e => { + e.update(); + }); + */ + + _this.trigger("contentError", { + element: e.element, + target: e.target, + item: item, + update: function () { + moreUpdated.push(item); + } + }); + }).on("ready", function () { + if (moreUpdated.length) { + _this.updateItems(moreUpdated); + } + }).check(updated.map(function (item) { + return item.element; + })); + }; + + __proto.scheduleRender = function () { + var _this = this; + + this._clearRenderTimer(); + + this._renderTimer = window.setTimeout(function () { + _this.renderItems(); + }); + }; + + __proto.fitOutlines = function (useFit) { + if (useFit === void 0) { + useFit = this.useFit; + } + + var outlines = this.outlines; + var startOutline = outlines.start; + var endOutline = outlines.end; + var outlineOffset = startOutline.length ? Math.min.apply(Math, startOutline) : 0; // If the outline is less than 0, a fit occurs forcibly. + + if (!useFit && outlineOffset > 0) { + return; + } + + outlines.start = startOutline.map(function (point) { + return point - outlineOffset; + }); + outlines.end = endOutline.map(function (point) { + return point - outlineOffset; + }); + this.items.forEach(function (item) { + var contentPos = item.cssContentPos; + + if (!isNumber(contentPos)) { + return; + } + + item.cssContentPos = contentPos - outlineOffset; + }); + }; + + __proto.readyItems = function (mounted, updated, options) { + var prevOutlines = this.outlines; + var direction = options.direction || this.options.defaultDirection; + var prevOutline = options.outline || prevOutlines[direction === "end" ? "start" : "end"]; + var items = this.items; + var nextOutlines = { + start: __spreadArrays(prevOutline), + end: __spreadArrays(prevOutline) + }; + + if (items.length) { + nextOutlines = this.applyGrid(this.items, direction, prevOutline); + } + + this.setOutlines(nextOutlines); + this.fitOutlines(); + this.itemRenderer.renderItems(this.items); + + this._refreshContainerContentSize(); + + this._renderComplete({ + mounted: mounted, + updated: updated, + isResize: !!options.useResize + }); + }; + + __proto._renderComplete = function (e) { + /** + * This event is fired when the Grid has completed rendering. + * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다. + * @event Grid#renderComplete + * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들 + * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들. + * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부. + * @example + grid.on("renderComplete", e => { + console.log(e.mounted, e.updated, e.useResize); + }); + */ + this.trigger("renderComplete", e); + }; + + __proto._clearRenderTimer = function () { + clearTimeout(this._renderTimer); + this._renderTimer = 0; + }; + + __proto._refreshContainerContentSize = function () { + var _a = this.outlines, + startOutline = _a.start, + endOutline = _a.end; + var gap = this.options.gap; + var endPoint = endOutline.length ? Math.max.apply(Math, endOutline) : 0; + var startPoint = startOutline.length ? Math.max.apply(Math, startOutline) : 0; + var contentSize = Math.max(startPoint, endPoint - gap); + this.containerManager.setContentSize(contentSize); + }; + + __proto._resizeContainer = function () { + this.containerManager.resize(); + this.itemRenderer.setContainerRect(this.containerManager.getRect()); + }; + + __proto._init = function () { + this._resizeContainer(); + + if (this.options.autoResize) { + window.addEventListener("resize", this._scheduleResize); + } + }; + + var Grid_1; + Grid.defaultOptions = DEFAULT_GRID_OPTIONS; + Grid.propertyTypes = GRID_PROPERTY_TYPES; + Grid = Grid_1 = __decorate([GetterSetter], Grid); + return Grid; +}(Component); +/** + * Gap used to create space around items. + * @ko 아이템들 사이의 공간. + * @name Grid#gap + * @type {$ts:Grid.GridOptions["gap"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * gap: 0, + * }); + * + * grid.gap = 5; + */ + +/** + * The default direction value when direction is not set in the render option. + * @ko render옵션에서 direction을 미설정시의 기본 방향값. + * @name Grid#defaultDirection + * @type {$ts:Grid.GridOptions["defaultDirection"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * defaultDirection: "end", + * }); + * + * grid.defaultDirection = "start"; + */ + +/** + * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true) + * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true) + * @name Grid#useFit + * @type {$ts:Grid.GridOptions["useFit"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * useFit: true, + * }); + * + * grid.useFit = false; + +/** + * Whether to preserve the UI of the existing container or item when destroying. + * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부. + * @name Grid#preserveUIOnDestroy + * @type {$ts:Grid.GridOptions["preserveUIOnDestroy"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * preserveUIOnDestroy: false, + * }); + * + * grid.preserveUIOnDestroy = true; + */ + +function getColumnPoint(outline, columnIndex, columnCount, pointCaculationName) { + return Math[pointCaculationName].apply(Math, outline.slice(columnIndex, columnIndex + columnCount)); +} + +function getColumnIndex(outline, columnCount, nearestCalculationName) { + var length = outline.length - columnCount + 1; + var pointCaculationName = nearestCalculationName === "max" ? "min" : "max"; + var indexCaculationName = nearestCalculationName === "max" ? "lastIndexOf" : "indexOf"; + var points = range(length).map(function (index) { + return getColumnPoint(outline, index, columnCount, pointCaculationName); + }); + return points[indexCaculationName](Math[nearestCalculationName].apply(Math, points)); +} +/** + * MasonryGrid 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. + * + * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체 + */ + + +var MasonryGrid = +/*#__PURE__*/ +function (_super) { + __extends(MasonryGrid, _super); + + function MasonryGrid() { + var _this = _super !== null && _super.apply(this, arguments) || this; + + _this._columnSize = 0; + _this._column = 1; + return _this; + } + + var __proto = MasonryGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + this._calculateColumnSize(items); + + this._calculateColumn(items); + + var column = this._column; + var columnSize = this._columnSize; + var _a = this.options, + gap = _a.gap, + align = _a.align, + columnSizeRatio = _a.columnSizeRatio, + columnSizeOption = _a.columnSize; + var outlineLength = outline.length; + var itemsLength = items.length; + + var alignPoses = this._getAlignPoses(); + + var isEndDirection = direction === "end"; + var nearestCalculationName = isEndDirection ? "min" : "max"; + var pointCalculationName = isEndDirection ? "max" : "min"; + var startOutline = [0]; + + if (outlineLength === column) { + startOutline = outline.slice(); + } else { + var point_1 = outlineLength ? Math[nearestCalculationName].apply(Math, outline) : 0; + startOutline = range(column).map(function () { + return point_1; + }); + } + + var endOutline = startOutline.slice(); + var columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0; + var isStretch = align === "stretch"; + + var _loop_1 = function (i) { + var item = items[isEndDirection ? i : itemsLength - 1 - i]; + var columnAttribute = parseInt(item.attributes.column || "1", 10); + var maxColumnAttribute = parseInt(item.attributes.maxColumn || "1", 10); + var inlineSize = item.inlineSize; + var contentSize = item.contentSize; + var columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist))); + var maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute)); + var columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName); + var contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName); + + while (columnCount < maxColumnCount) { + var nextEndColumnIndex = columnIndex + columnCount; + var nextColumnIndex = columnIndex - 1; + + if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) { + break; + } + + if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) { + break; + } + + if (!isEndDirection) { + --columnIndex; + } + + ++columnCount; + } + + columnIndex = Math.max(0, columnIndex); + columnCount = Math.min(column - columnIndex, columnCount); + + if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) { + inlineSize = (columnCount - 1) * columnDist + columnSize; + item.cssInlineSize = inlineSize; + } + + if (columnSizeRatio > 0) { + contentSize = inlineSize / columnSizeRatio; + item.cssContentSize = contentSize; + } + + var inlinePos = alignPoses[columnIndex]; + contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize; + item.cssInlinePos = inlinePos; + item.cssContentPos = contentPos; + var nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos; + range(columnCount).forEach(function (indexOffset) { + endOutline[columnIndex + indexOffset] = nextOutlinePoint; + }); + }; + + for (var i = 0; i < itemsLength; ++i) { + _loop_1(i); + } // if end items, startOutline is low, endOutline is high + // if start items, startOutline is high, endOutline is low + + + return { + start: isEndDirection ? startOutline : endOutline, + end: isEndDirection ? endOutline : startOutline + }; + }; + + __proto._calculateColumnSize = function (items) { + var _a = this.options, + columnSizeOption = _a.columnSize, + gap = _a.gap, + align = _a.align; + + if (align === "stretch") { + var column = this.column; + + if (columnSizeOption) { + column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap))); + } + + this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap; + } else if (columnSizeOption) { + this._columnSize = columnSizeOption; + } else { + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var item = items_1[_i]; + var attributes = item.attributes; + + if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) { + continue; + } + + var inlineSize = item.inlineSize; + this._columnSize = inlineSize; + return inlineSize; + } + + this._columnSize = this._columnSize || 0; + } + + return this._columnSize; + }; + + __proto._calculateColumn = function (items) { + var _a = this.options, + gap = _a.gap, + columnOption = _a.column; + var columnSize = this._columnSize; + var column = 1; + + if (columnOption) { + column = columnOption; + } else if (!columnSize) { + column = 1; + } else { + column = Math.min(items.length, Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap)))); + } + + this._column = column; + return column; + }; + + __proto._getAlignPoses = function () { + var columnSize = this._columnSize; + var column = this._column; + var _a = this.options, + align = _a.align, + gap = _a.gap; + var containerSize = this.getContainerInlineSize(); + var indexes = range(column); + var offset = 0; + var dist = 0; + + if (align === "justify" || align === "stretch") { + var countDist = column - 1; + dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0; + offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2); + } else { + dist = columnSize + gap; + var totalColumnSize = (column - 1) * dist + columnSize; + + if (align === "center") { + offset = (containerSize - totalColumnSize) / 2; + } else if (align === "end") { + offset = containerSize - totalColumnSize; + } + } + + return indexes.map(function (i) { + return offset + i * dist; + }); + }; + + MasonryGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + column: PROPERTY_TYPE.RENDER_PROPERTY, + columnSize: PROPERTY_TYPE.RENDER_PROPERTY, + columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY, + align: PROPERTY_TYPE.RENDER_PROPERTY + }); + MasonryGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + align: "justify", + column: 0, + columnSize: 0, + columnSizeRatio: 0 + }); + MasonryGrid = __decorate([GetterSetter], MasonryGrid); + return MasonryGrid; +}(Grid); +/** + * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. ("start", "center", "end", "justify", "stretch") (default: "justify") + * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. ("start", "center", "end", "justify", "stretch") (default: "justify") + * @name Grid.MasonryGrid#align + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["align"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * align: "start", + * }); + * + * grid.align = "justify"; + */ + +/** + * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. + * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) + * @name Grid.MasonryGrid#column + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["column"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * column: 0, + * }); + * + * grid.column = 4; + */ + +/** + * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) + * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) + * @name Grid.MasonryGrid#columnSize + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSize"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * columnSize: 0, + * }); + * + * grid.columnSize = 200; + */ + +/** + * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) + * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. + * @name Grid.MasonryGrid#columnSizeRatio + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSizeRatio"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * columnSizeRatio: 0, + * }); + * + * grid.columnSizeRatio = 0.5; + */ + +/* eslint-disable */ + +/****************************************************************************** + * Created 2008-08-19. + * + * Dijkstra path-finding functions. Adapted from the Dijkstar Python project. + * + * Copyright (C) 2008 + * Wyatt Baldwin + * All rights reserved + * + * Licensed under the MIT license. + * + * http://www.opensource.org/licenses/mit-license.php + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *****************************************************************************/ +function single_source_shortest_paths(graph, s, d) { + // Predecessor map for each node that has been encountered. + // node ID => predecessor node ID + var predecessors = {}; // Costs of shortest paths from s to all nodes encountered. + // node ID => cost + + var costs = {}; + costs[s] = 0; // Costs of shortest paths from s to all nodes encountered; differs from + // `costs` in that it provides easy access to the node that currently has + // the known shortest path from s. + // XXX: Do we actually need both `costs` and `open`? + + var open = new BinaryHeap(function (x) { + return x.cost; + }); + open.push({ + value: s, + cost: 0 + }); + var closest; + var u; + var cost_of_s_to_u; + var adjacent_nodes; + var cost_of_e; + var cost_of_s_to_u_plus_cost_of_e; + var cost_of_s_to_v; + var first_visit; + + while (open.size()) { + // In the nodes remaining in graph that have a known cost from s, + // find the node, u, that currently has the shortest path from s. + closest = open.pop(); + u = closest.value; + cost_of_s_to_u = closest.cost; // Get nodes adjacent to u... + + adjacent_nodes = graph(u) || {}; // ...and explore the edges that connect u to those nodes, updating + // the cost of the shortest paths to any or all of those nodes as + // necessary. v is the node across the current edge from u. + + for (var v in adjacent_nodes) { + // Get the cost of the edge running from u to v. + cost_of_e = adjacent_nodes[v]; // Cost of s to u plus the cost of u to v across e--this is *a* + // cost from s to v that may or may not be less than the current + // known cost to v. + + cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; // If we haven't visited v yet OR if the current known cost from s to + // v is greater than the new cost we just found (cost of s to u plus + // cost of u to v across e), update v's cost in the cost list and + // update v's predecessor in the predecessor list (it's now u). + + cost_of_s_to_v = costs[v]; + first_visit = typeof costs[v] === "undefined"; + + if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { + costs[v] = cost_of_s_to_u_plus_cost_of_e; + open.push({ + value: v, + cost: cost_of_s_to_u_plus_cost_of_e + }); + predecessors[v] = u; + } + } + } + + if (typeof costs[d] === "undefined") { + var msg = ["Could not find a path from ", s, " to ", d, "."].join(""); + throw new Error(msg); + } + + return predecessors; +} + +function extract_shortest_path_from_predecessor_list(predecessors, d) { + var nodes = []; + var u = d; + + while (u) { + nodes.push(u); + u = predecessors[u]; + } + + nodes.reverse(); + return nodes; +} + +function find_path(graph, s, d) { + var predecessors = single_source_shortest_paths(graph, s, d); + return extract_shortest_path_from_predecessor_list(predecessors, d); +} + +var BinaryHeap = +/*#__PURE__*/ +function () { + function BinaryHeap(scoreFunction) { + this.content = []; + this.scoreFunction = scoreFunction; + } + + var __proto = BinaryHeap.prototype; + + __proto.push = function (element) { + // Add the new element to the end of the array. + this.content.push(element); // Allow it to bubble up. + + this.bubbleUp(this.content.length - 1); + }; + + __proto.pop = function () { + // Store the first element so we can return it later. + var result = this.content[0]; // Get the element at the end of the array. + + var end = this.content.pop(); // If there are any elements left, put the end element at the + // start, and let it sink down. + + if (this.content.length > 0) { + this.content[0] = end; + this.sinkDown(0); + } + + return result; + }; + + __proto.size = function () { + return this.content.length; + }; + + __proto.bubbleUp = function (_n) { + var n = _n; // Fetch the element that has to be moved. + + var element = this.content[n]; // When at 0, an element can not go up any further. + + while (n > 0) { + // Compute the parent element's index, and fetch it. + var parentN = Math.floor((n + 1) / 2) - 1; + var parent = this.content[parentN]; // Swap the elements if the parent is greater. + + if (this.scoreFunction(element) < this.scoreFunction(parent)) { + this.content[parentN] = element; + this.content[n] = parent; // Update 'n' to continue at the new position. + + n = parentN; + } else { + // Found a parent that is less, no need to move it further. + break; + } + } + }; + + __proto.sinkDown = function (n) { + // Look up the target element and its score. + var length = this.content.length; + var element = this.content[n]; + var elemScore = this.scoreFunction(element); + var child1Score; + + while (true) { + // Compute the indices of the child elements. + var child2N = (n + 1) * 2; + var child1N = child2N - 1; // This is used to store the new position of the element, + // if any. + + var swap = null; // If the first child exists (is inside the array)... + + if (child1N < length) { + // Look it up and compute its score. + var child1 = this.content[child1N]; + child1Score = this.scoreFunction(child1); // If the score is less than our element's, we need to swap. + + if (child1Score < elemScore) { + swap = child1N; + } + } // Do the same checks for the other child. + + + if (child2N < length) { + var child2 = this.content[child2N]; + var child2Score = this.scoreFunction(child2); + + if (child2Score < (swap == null ? elemScore : child1Score)) { + swap = child2N; + } + } // If the element needs to be moved, swap it, and continue. + + + if (swap !== null) { + this.content[n] = this.content[swap]; + this.content[swap] = element; + n = swap; + } else { + // Otherwise, we are done. + break; + } + } + }; + + return BinaryHeap; +}(); + +function splitItems(items, path) { + var length = path.length; + var groups = []; + + for (var i = 0; i < length - 1; ++i) { + var path1 = parseInt(path[i], 10); + var path2 = parseInt(path[i + 1], 10); + groups.push(items.slice(path1, path2)); + } + + return groups; +} + +function getExpectedColumnSize(item, rowSize) { + var inlineSize = item.orgInlineSize; + var contentSize = item.orgContentSize; + + if (!inlineSize || !contentSize) { + return 0; + } + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset; +} +/** + * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size. + * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value. + * 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. + * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다. + * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다. + * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체 + */ + + +var JustifiedGrid = +/*#__PURE__*/ +function (_super) { + __extends(JustifiedGrid, _super); + + function JustifiedGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = JustifiedGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var rowRange = this.options.rowRange; + var path = []; + + if (items.length) { + path = rowRange ? this._getRowPath(items) : this._getPath(items); + } + + return this._setStyle(items, path, outline, direction === "end"); + }; + + __proto.readyItems = function (mounted, updated, options) { + var _a = this.options, + attributePrefix = _a.attributePrefix, + horizontal = _a.horizontal; + updated.forEach(function (item) { + var element = item.element; + var attributes = item.attributes; + var gridData = item.gridData; + var inlineOffset = parseFloat(attributes.inlineOffset) || 0; + var contentOffset = parseFloat(attributes.contentOffset) || 0; + + if (element && !("inlineOffset" in attributes) && !("contentOffset" in attributes)) { + var maintainedTarget = element.querySelector("[" + attributePrefix + "maintained-target]"); + + if (maintainedTarget) { + var widthOffset = element.offsetWidth - element.clientWidth + element.scrollWidth - maintainedTarget.clientWidth; + var heightOffset = element.offsetHeight - element.clientHeight + element.scrollHeight - maintainedTarget.clientHeight; + + if (horizontal) { + inlineOffset = heightOffset; + contentOffset = widthOffset; + } else { + inlineOffset = widthOffset; + contentOffset = heightOffset; + } + } + } + + gridData.inlineOffset = inlineOffset; + gridData.contentOffset = contentOffset; + }); + + _super.prototype.readyItems.call(this, mounted, updated, options); + }; + + __proto._getRowPath = function (items) { + var _a; + + var columnRange = this._getColumnRange(); + + var rowRange = this._getRowRange(); + + var pathLink = this._getRowLink(items, { + path: [0], + cost: 0, + length: 0, + currentNode: 0 + }, columnRange, rowRange); + + return (_a = pathLink === null || pathLink === void 0 ? void 0 : pathLink.path.map(function (node) { + return "" + node; + })) !== null && _a !== void 0 ? _a : []; + }; + + __proto._getRowLink = function (items, currentLink, columnRange, rowRange) { + var minColumn = columnRange[0]; + var minRow = rowRange[0], + maxRow = rowRange[1]; + var lastNode = items.length; + var path = currentLink.path, + pathLength = currentLink.length, + cost = currentLink.cost, + currentNode = currentLink.currentNode; // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn. + + if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) { + var rangeCost = getRangeCost(lastNode - currentNode, columnRange); + var lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode)); + return __assign(__assign({}, currentLink), { + length: pathLength + 1, + path: __spreadArrays(path, [lastNode]), + currentNode: lastNode, + cost: cost + lastCost, + isOver: true + }); + } else if (currentNode >= lastNode) { + return __assign(__assign({}, currentLink), { + currentNode: lastNode, + isOver: minRow > pathLength || maxRow < pathLength + }); + } else { + return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange); + } + }; + + __proto._searchRowLink = function (items, currentLink, lastNode, columnRange, rowRange) { + var minColumn = columnRange[0], + maxColumn = columnRange[1]; + var currentNode = currentLink.currentNode, + path = currentLink.path, + pathLength = currentLink.length, + cost = currentLink.cost; + var length = Math.min(lastNode, currentNode + maxColumn); + var links = []; + + for (var nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) { + if (nextNode === currentNode) { + continue; + } + + var nextCost = Math.abs(this._getCost(items, currentNode, nextNode)); + + var nextLink = this._getRowLink(items, { + path: __spreadArrays(path, [nextNode]), + length: pathLength + 1, + cost: cost + nextCost, + currentNode: nextNode + }, columnRange, rowRange); + + if (nextLink) { + links.push(nextLink); + } + } + + links.sort(function (a, b) { + var aIsOver = a.isOver; + var bIsOver = b.isOver; + + if (aIsOver !== bIsOver) { + // If it is over, the cost is high. + return aIsOver ? 1 : -1; + } + + var aRangeCost = getRangeCost(a.length, rowRange); + var bRangeCost = getRangeCost(b.length, rowRange); + return aRangeCost - bRangeCost || a.cost - b.cost; + }); // It returns the lowest cost link. + + return links[0]; + }; + + __proto._getExpectedRowSize = function (items) { + var gap = this.options.gap; + var containerInlineSize = this.getContainerInlineSize() - gap * (items.length - 1); + var ratioSum = 0; + var inlineSum = 0; + items.forEach(function (item) { + var inlineSize = item.orgInlineSize; + var contentSize = item.orgContentSize; + + if (!inlineSize || !contentSize) { + return; + } // sum((expect - offset) * ratio) = container inline size + + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset); + ratioSum += maintainedRatio; + inlineSum += contentOffset * maintainedRatio; + containerInlineSize -= inlineOffset; + }); + return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0; + }; + + __proto._getExpectedInlineSize = function (items, rowSize) { + var gap = this.options.gap; + var size = items.reduce(function (sum, item) { + return sum + getExpectedColumnSize(item, rowSize); + }, 0); + return size ? size + gap * (items.length - 1) : 0; + }; + + __proto._getCost = function (items, i, j) { + var lineItems = items.slice(i, j); + + var rowSize = this._getExpectedRowSize(lineItems); + + var _a = this._getSizeRange(), + minSize = _a[0], + maxSize = _a[1]; + + if (this.isCroppedSize) { + if (minSize <= rowSize && rowSize <= maxSize) { + return 0; + } + + var expectedInlineSize = this._getExpectedInlineSize(lineItems, rowSize < minSize ? minSize : maxSize); + + return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2); + } + + if (isFinite(maxSize)) { + // if this size is not in range, the cost increases sharply. + if (rowSize < minSize) { + return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2); + } else if (rowSize > maxSize) { + return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2); + } + } else if (rowSize < minSize) { + return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2); + } // if this size in range, the cost is row + + + return rowSize - minSize; + }; + + __proto._getPath = function (items) { + var _this = this; + + var lastNode = items.length; + var columnRangeOption = this.options.columnRange; + + var _a = isObject(columnRangeOption) ? columnRangeOption : [columnRangeOption, columnRangeOption], + minColumn = _a[0], + maxColumn = _a[1]; + + var graph = function (nodeKey) { + var results = {}; + var currentNode = parseInt(nodeKey, 10); + + for (var nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) { + if (nextNode - currentNode > maxColumn) { + break; + } + + var cost = _this._getCost(items, currentNode, nextNode); + + if (cost < 0 && nextNode === lastNode) { + cost = 0; + } + + results["" + nextNode] = Math.pow(cost, 2); + } + + return results; + }; // shortest path for items' total height. + + + return find_path(graph, "0", "" + lastNode); + }; + + __proto._setStyle = function (items, path, outline, isEndDirection) { + var _this = this; + + if (outline === void 0) { + outline = []; + } + + var _a = this.options, + gap = _a.gap, + isCroppedSize = _a.isCroppedSize, + displayedRow = _a.displayedRow; + + var sizeRange = this._getSizeRange(); + + var startPoint = outline[0] || 0; + var containerInlineSize = this.getContainerInlineSize(); + var groups = splitItems(items, path); + var contentPos = startPoint; + var displayedSize = 0; + groups.forEach(function (groupItems, rowIndex) { + var length = groupItems.length; + + var rowSize = _this._getExpectedRowSize(groupItems); + + if (isCroppedSize) { + rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1])); + } + + var expectedInlineSize = _this._getExpectedInlineSize(groupItems, rowSize); + + var allGap = gap * (length - 1); + var scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap); + groupItems.forEach(function (item, i) { + var columnSize = getExpectedColumnSize(item, rowSize); + var prevItem = groupItems[i - 1]; + var inlinePos = prevItem ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap : 0; + + if (isCroppedSize) { + columnSize *= scale; + } + + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: columnSize, + contentSize: rowSize + }); + }); + contentPos += gap + rowSize; + + if (displayedRow < 0 || rowIndex < displayedRow) { + displayedSize = contentPos; + } + }); + + if (isEndDirection) { + // previous group's end outline is current group's start outline + return { + start: [startPoint], + end: [displayedSize] + }; + } // always start is lower than end. + // contentPos is endPoinnt + + + var height = contentPos - startPoint; + items.forEach(function (item) { + item.cssContentPos -= height; + }); + return { + start: [startPoint - height], + end: [startPoint] + }; + }; + + __proto._getRowRange = function () { + var rowRange = this.rowRange; + return isObject(rowRange) ? rowRange : [rowRange, rowRange]; + }; + + __proto._getColumnRange = function () { + var columnRange = this.columnRange; + return isObject(columnRange) ? columnRange : [columnRange, columnRange]; + }; + + __proto._getSizeRange = function () { + var sizeRange = this.sizeRange; + return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange]; + }; + + JustifiedGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + columnRange: PROPERTY_TYPE.RENDER_PROPERTY, + rowRange: PROPERTY_TYPE.RENDER_PROPERTY, + sizeRange: PROPERTY_TYPE.RENDER_PROPERTY, + isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY, + displayedRow: PROPERTY_TYPE.RENDER_PROPERTY + }); + JustifiedGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + columnRange: [1, 8], + rowRange: 0, + sizeRange: [0, Infinity], + displayedRow: -1, + isCroppedSize: false + }); + JustifiedGrid = __decorate([GetterSetter], JustifiedGrid); + return JustifiedGrid; +}(Grid); +/** + * The minimum and maximum number of items per line. (default: [1, 8]) + * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) + * @name Grid.JustifiedGrid#columnRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["columnRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * columnRange: [1, 8], + * }); + * + * grid.columnRange = [3, 6]; + */ + +/** + * The minimum and maximum number of rows in a group, 0 is not set. (default: 0) + * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) + * @name Grid.JustifiedGrid#rowRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["rowRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * rowRange: 0, + * }); + * + * grid.rowRange = [3, 4]; + */ + +/** + * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) + * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity]) + * @name Grid.JustifiedGrid#sizeRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["sizeRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * sizeRange: [0, Infinity], + * }); + * + * grid.sizeRange = [200, 800]; + */ + +/** + * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1) + * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1) + * @name Grid.JustifiedGrid#displayedRow + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["displayedRow"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * displayedRow: -1, + * }); + * + * grid.displayedRow = 3; + */ + +/** + * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) + * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false) + * @name Grid.JustifiedGrid#isCroppedSize + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["isCroppedSize"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * sizeRange: [200, 250], + * isCroppedSize: false, + * }); + * + * grid.isCroppedSize = true; + */ + +function getMaxPoint(outline) { + var maxPoint = -Infinity; + outline.forEach(function (point) { + if (isFinite(point)) { + maxPoint = Math.max(maxPoint, point); + } + }); + return isFinite(maxPoint) ? maxPoint : 0; +} + +function getMinPoint(outline) { + var minPoint = Infinity; + outline.forEach(function (point) { + if (isFinite(point)) { + minPoint = Math.min(minPoint, point); + } + }); + return isFinite(minPoint) ? minPoint : 0; +} + +function getOutlinePoint(startOutline, frameOutline, useFrameFill) { + return getMaxPoint(startOutline) + getOutlineDist(startOutline, frameOutline, useFrameFill); +} + +function getOutlineDist(startOutline, endOutline, useFrameFill) { + var length = startOutline.length; + + if (!length) { + return 0; + } + + var minEndPoint = getMinPoint(endOutline); + var maxStartPoint = getMaxPoint(startOutline); + var frameDist = 0; + + if (!useFrameFill) { + return 0; + } + + for (var outlineIndex = 0; outlineIndex < length; ++outlineIndex) { + var startPoint = startOutline[outlineIndex]; + var endPoint = endOutline[outlineIndex]; + + if (!isFinite(startPoint) || !isFinite(endPoint)) { + continue; + } + + var startPos = startPoint - maxStartPoint; + var endPos = endPoint - minEndPoint; // Fill empty block. + + frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos; + } + + return frameDist; +} + +function fillOutlines(startOutline, endOutline, rect) { + var inlinePos = rect.inlinePos, + inlineSize = rect.inlineSize, + contentPos = rect.contentPos, + contentSize = rect.contentSize; + + for (var outlineIndex = inlinePos; outlineIndex < inlinePos + inlineSize; ++outlineIndex) { + startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos); + endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize); + } +} +/** + * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size. + * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체 + */ + + +var FrameGrid = +/*#__PURE__*/ +function (_super) { + __extends(FrameGrid, _super); + + function FrameGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = FrameGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var frame = this._getFrame(); + + var frameInlineSize = frame.inlineSize, + frameContentSize = frame.contentSize, + frameRects = frame.rects; + var _a = this.options, + gap = _a.gap, + useFrameFill = _a.useFrameFill; + + var _b = this.getRectSize(frameInlineSize), + rectInlineSize = _b.inlineSize, + rectContentSize = _b.contentSize; + + var itemsLength = items.length; + + if (!itemsLength || !frameInlineSize || !frameContentSize) { + return { + start: outline, + end: outline + }; + } + + var rectsLength = frameRects.length; + var startOutline = range(frameInlineSize).map(function () { + return Infinity; + }); + var endOutline = range(frameInlineSize).map(function () { + return -Infinity; + }); + var frameOutline = frame.outline.map(function (point) { + return point * (rectContentSize + gap); + }); + + for (var startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) { + // Compare group's startOutline and startOutline of rect + var startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill); + + for (var rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) { + var item = items[startIndex + rectIndex]; + var _c = frameRects[rectIndex], + frameRectContentPos = _c.contentPos, + frameRectInlinePos = _c.inlinePos, + frameRectContentSize = _c.contentSize, + frameRectInlineSize = _c.inlineSize; + var contentPos = startPoint + frameRectContentPos * (rectContentSize + gap); + var inlinePos = frameRectInlinePos * (rectInlineSize + gap); + var contentSize = frameRectContentSize * (rectContentSize + gap) - gap; + var inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap; + fillOutlines(startOutline, endOutline, { + inlinePos: frameRectInlinePos, + inlineSize: frameRectInlineSize, + contentPos: contentPos, + contentSize: contentSize + gap + }); + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: inlineSize, + contentSize: contentSize + }); + } + } + + var isDirectionEnd = direction === "end"; + var gridOutline = outline; + + if (gridOutline.length !== frameInlineSize) { + var point_1 = isDirectionEnd ? Math.max.apply(Math, gridOutline) : Math.min.apply(Math, gridOutline); + gridOutline = range(frameInlineSize).map(function () { + return point_1; + }); + } + + startOutline = startOutline.map(function (point) { + return isFinite(point) ? point : 0; + }); + endOutline = endOutline.map(function (point) { + return isFinite(point) ? point : 0; + }); + var outlineDist = isDirectionEnd ? getOutlineDist(startOutline, gridOutline, useFrameFill) : getOutlineDist(gridOutline, endOutline, useFrameFill); + items.forEach(function (item) { + item.cssContentPos += outlineDist; + }); + return { + start: startOutline.map(function (point) { + return point + outlineDist; + }), + end: endOutline.map(function (point) { + return point + outlineDist; + }) + }; + }; + + __proto.getRectSize = function (frameInlineSize) { + var _a = this.options, + gap = _a.gap, + rectSizeOption = _a.rectSize; + + if (typeof rectSizeOption === "object") { + return rectSizeOption; + } + + var rectSizeValue = rectSizeOption ? rectSizeOption : (this.getContainerInlineSize() + gap) / frameInlineSize - gap; + return { + inlineSize: rectSizeValue, + contentSize: rectSizeValue + }; + }; + + __proto._getFrame = function () { + var frame = this.options.frame; + var frameContentSize = frame.length; + var frameInlineSize = frameContentSize ? frame[0].length : 0; + var rects = []; + var passMap = {}; + var startOutline = range(frameInlineSize).map(function () { + return Infinity; + }); + var endOutline = range(frameInlineSize).map(function () { + return -Infinity; + }); + + for (var y1 = 0; y1 < frameContentSize; ++y1) { + for (var x1 = 0; x1 < frameInlineSize; ++x1) { + var type = frame[y1][x1]; + + if (!type) { + continue; + } + + if (passMap[y1 + "," + x1]) { + continue; + } + + var rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize); + + fillOutlines(startOutline, endOutline, rect); + rects.push(rect); + } + } + + rects.sort(function (a, b) { + return a.type < b.type ? -1 : 1; + }); + return { + rects: rects, + inlineSize: frameInlineSize, + contentSize: frameContentSize, + outline: startOutline + }; + }; + + __proto._findRect = function (passMap, type, y1, x1, frameInlineSize, frameContentSize) { + var frame = this.options.frame; + var contentSize = 1; + var inlineSize = 1; // find rect + + for (var x2 = x1; x2 < frameInlineSize; ++x2) { + if (frame[y1][x2] === type) { + inlineSize = x2 - x1 + 1; + continue; + } + + break; + } + + for (var y2 = y1; y2 < frameContentSize; ++y2) { + if (frame[y2][x1] === type) { + contentSize = y2 - y1 + 1; + continue; + } + + break; + } // pass rect + + + for (var y = y1; y < y1 + contentSize; ++y) { + for (var x = x1; x < x1 + inlineSize; ++x) { + passMap[y + "," + x] = true; + } + } + + var rect = { + type: type, + inlinePos: x1, + contentPos: y1, + inlineSize: inlineSize, + contentSize: contentSize + }; + return rect; + }; + + FrameGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + frame: PROPERTY_TYPE.RENDER_PROPERTY, + useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY, + rectSize: PROPERTY_TYPE.RENDER_PROPERTY + }); + FrameGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + frame: [], + rectSize: 0, + useFrameFill: true + }); + FrameGrid = __decorate([GetterSetter], FrameGrid); + return FrameGrid; +}(Grid); +/** + * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: []) + * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: []) + * @name Grid.FrameGrid#frame + * @type {$ts:Grid.FrameGrid.FrameGridOptions["frame"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * // Item 1 : 2 x 2 + * // Item 2 : 1 x 1 + * // Item 3 : 1 x 2 + * // Item 4 : 1 x 1 + * // Item 5 : 2 x 1 + * const grid = new FrameGrid(container, { + * frame: [ + * [1, 1, 0, 0, 2, 3], + * [1, 1, 0, 4, 5, 5], + * ], + * }); + * + * // Item 1 : 2 x 2 + * // Item 2 : 2 x 2 + * grid.frame = [ + * [1, 1, 0, 0, 2, 2], + * [1, 1, 0, 0, 2, 2], + * ]; + */ + +/** + * Make sure that the frame can be attached after the previous frame. (default: true) + * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true) + * @name Grid.FrameGrid#useFrameFill + * @type {$ts:Grid.FrameGrid.FrameGridOptions["useFrameFill"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * const grid = new FrameGrid(container, { + * useFrameFill: true, + * }); + * + * grid.useFrameFill = false; + */ + +/** + * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) + * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0) + * @name Grid.FrameGrid#rectSize + * @type {$ts:Grid.FrameGrid.FrameGridOptions["rectSize"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * const grid = new FrameGrid(container, { + * rectSize: 0, + * }); + * + * grid.rectSize = { inlineSize: 100, contentSize: 150 }; + */ + +var BoxModel = +/*#__PURE__*/ +function () { + function BoxModel(status) { + var boxStatus = __assign({ + orgInlineSize: 0, + orgContentSize: 0, + inlineSize: 0, + contentSize: 0, + inlinePos: 0, + contentPos: 0, + items: [] + }, status); + + for (var name in boxStatus) { + this[name] = boxStatus[name]; + } + } + + var __proto = BoxModel.prototype; + + __proto.scaleTo = function (inlineSize, contentSize) { + var scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0; + var scaleY = this.contentSize ? contentSize / this.contentSize : 0; + this.items.forEach(function (item) { + if (scaleX !== 0) { + item.inlinePos *= scaleX; + item.inlineSize *= scaleX; + } + + if (scaleY !== 0) { + item.contentPos *= scaleY; + item.contentSize *= scaleY; + } + }); + this.inlineSize = inlineSize; + this.contentSize = contentSize; + }; + + __proto.push = function (item) { + this.items.push(item); + }; + + __proto.getOrgSizeWeight = function () { + return this.orgInlineSize * this.orgContentSize; + }; + + __proto.getSize = function () { + return this.inlineSize * this.contentSize; + }; + + __proto.getOrgRatio = function () { + return this.orgContentSize === 0 ? 0 : this.orgInlineSize / this.orgContentSize; + }; + + __proto.getRatio = function () { + return this.contentSize === 0 ? 0 : this.inlineSize / this.contentSize; + }; + + return BoxModel; +}(); + +function getCost(originLength, length) { + var cost = originLength / length; + + if (cost < 1) { + cost = 1 / cost; + } + + return cost - 1; +} + +function fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection) { + item.contentSize = itemFitSize.contentSize; + item.inlineSize = itemFitSize.inlineSize; + bestFitArea.contentSize = containerFitSize.contentSize; + bestFitArea.inlineSize = containerFitSize.inlineSize; + + if (isContentDirection) { + item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize; + item.inlinePos = bestFitArea.inlinePos; + } else { + item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize; + item.contentPos = bestFitArea.contentPos; + } +} +/** + * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items. + * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion. + * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible. + * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible. + * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다. + * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다. + * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다. + * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체 + */ + + +var PackingGrid = +/*#__PURE__*/ +function (_super) { + __extends(PackingGrid, _super); + + function PackingGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = PackingGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var _this = this; + + var _a = this.options, + aspectRatio = _a.aspectRatio, + gap = _a.gap; + var containerInlineSize = this.getContainerInlineSize(); + var containerContentSize = containerInlineSize / aspectRatio; + var prevOutline = outline.length ? outline : [0]; + var startPoint = direction === "end" ? Math.max.apply(Math, prevOutline) : Math.min.apply(Math, prevOutline) - containerContentSize - gap; + var endPoint = startPoint + containerContentSize + gap; + var container = new BoxModel({}); + items.forEach(function (item) { + var model = new BoxModel({ + inlineSize: item.orgInlineSize, + contentSize: item.orgContentSize, + orgInlineSize: item.orgInlineSize, + orgContentSize: item.orgContentSize + }); + + _this._findBestFitArea(container, model); + + container.push(model); + container.scaleTo(containerInlineSize + gap, containerContentSize + gap); + }); + items.forEach(function (item, i) { + var boxItem = container.items[i]; + var inlineSize = boxItem.inlineSize - gap; + var contentSize = boxItem.contentSize - gap; + var contentPos = startPoint + boxItem.contentPos; + var inlinePos = boxItem.inlinePos; + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: inlineSize, + contentSize: contentSize + }); + }); + return { + start: [startPoint], + end: [endPoint] + }; + }; + + __proto._findBestFitArea = function (container, item) { + if (container.getRatio() === 0) { + // 아이템 최초 삽입시 전체영역 지정 + container.orgInlineSize = item.inlineSize; + container.orgContentSize = item.contentSize; + container.inlineSize = item.inlineSize; + container.contentSize = item.contentSize; + return; + } + + var bestFitArea; + var minCost = Infinity; + var isContentDirection = false; + var itemFitSize = { + inlineSize: 0, + contentSize: 0 + }; + var containerFitSize = { + inlineSize: 0, + contentSize: 0 + }; + + var sizeWeight = this._getWeight("size"); + + var ratioWeight = this._getWeight("ratio"); + + container.items.forEach(function (child) { + var containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight; + var containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight; + var inlineSize = child.inlineSize; + var contentSize = child.contentSize; + + for (var i = 0; i < 2; ++i) { + var itemInlineSize = void 0; + var itemContentSize = void 0; + var containerInlineSize = void 0; + var containerContentSize = void 0; + + if (i === 0) { + // add item to content pos (top, bottom) + itemInlineSize = inlineSize; + itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize)); + containerInlineSize = inlineSize; + containerContentSize = contentSize - itemContentSize; + } else { + // add item to inline pos (left, right) + itemContentSize = contentSize; + itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize)); + containerContentSize = contentSize; + containerInlineSize = inlineSize - itemInlineSize; + } + + var itemSize = itemInlineSize * itemContentSize; + var itemRatio = itemInlineSize / itemContentSize; + var containerSize = containerInlineSize * containerContentSize; + var containerRatio = containerContentSize / containerContentSize; + var cost = getCost(item.getSize(), itemSize) * sizeWeight; + cost += getCost(item.getRatio(), itemRatio) * ratioWeight; + cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost; + cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost; + + if (cost === Math.min(cost, minCost)) { + minCost = cost; + bestFitArea = child; + isContentDirection = i === 0; + itemFitSize.inlineSize = itemInlineSize; + itemFitSize.contentSize = itemContentSize; + containerFitSize.inlineSize = containerInlineSize; + containerFitSize.contentSize = containerContentSize; + } + } + }); + fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection); + }; + + __proto._getWeight = function (type) { + var options = this.options; + var weightPriority = options.weightPriority; + + if (weightPriority === type) { + return 100; + } else if (weightPriority === "custom") { + return options[type + "Weight"]; + } + + return 1; + }; + + PackingGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY, + sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY, + ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY, + weightPriority: PROPERTY_TYPE.RENDER_PROPERTY + }); + PackingGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + aspectRatio: 1, + sizeWeight: 1, + ratioWeight: 1, + weightPriority: "custom" + }); + PackingGrid = __decorate([GetterSetter], PackingGrid); + return PackingGrid; +}(Grid); +/** + * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) + * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1) + * @name Grid.PackingGrid#aspectRatio + * @type {$ts:Grid.PackingGrid.PackingGridOptions["aspectRatio"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * aspectRatio: 1, + * }); + * + * grid.aspectRatio = 1.5; + */ + +/** + * The priority that determines the weight of the item. (default: "custom"), "size" = (sizeWieght: 2, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 2), "custom" = (set sizeWeight, ratioWeight) + * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`. + * @ko 아이템의 가중치를 결정하는 우선수치. (default: "custom"), "size" = (sizeWieght: 2, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 2), "custom" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`. + * @name Grid.PackingGrid#weightPriority + * @type {$ts:Grid.PackingGrid.PackingGridOptions["weightPriority"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * weightPriority: "custom", + * sizeWeight: 1, + * ratioWeight: 1, + * }); + * + * grid.weightPriority = "size"; + * // or + * grid.weightPriority = "ratio"; + */ + +/** + * The size weight when placing items. (default: 1) + * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1) + * @name Grid.PackingGrid#sizeWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["sizeWeight"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * sizeWeight: 1, + * }); + * + * grid.sizeWeight = 10; + */ + +/** + * The weight to keep ratio when placing items. (default: 1) + * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1) + * @name Grid.PackingGrid#ratioWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["ratioWeight"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * ratioWeight: 1, + * }); + * + * grid.ratioWeight = 10; + */ + +/** + * egjs-grid + * Copyright (c) 2021-present NAVER Corp. + * MIT license + */ + +var modules = { + __proto__: null, + 'default': Grid, + GetterSetter: GetterSetter, + withGridMethods: withGridMethods, + withMethods: withMethods, + MasonryGrid: MasonryGrid, + JustifiedGrid: JustifiedGrid, + FrameGrid: FrameGrid, + PackingGrid: PackingGrid, + GridItem: GridItem, + ContainerManager: ContainerManager, + DEFAULT_GRID_OPTIONS: DEFAULT_GRID_OPTIONS, + get PROPERTY_TYPE () { return PROPERTY_TYPE; }, + get MOUNT_STATE () { return MOUNT_STATE; }, + get UPDATE_STATE () { return UPDATE_STATE; }, + GRID_PROPERTY_TYPES: GRID_PROPERTY_TYPES, + GRID_METHODS: GRID_METHODS, + GRID_EVENTS: GRID_EVENTS, + RECT_NAMES: RECT_NAMES +}; + +/** + * egjs-grid + * Copyright (c) 2021-present NAVER Corp. + * MIT license + */ + +for (var name in modules) { + Grid[name] = modules[name]; +} + +module.exports = Grid; +//# sourceMappingURL=grid.cjs.js.map diff --git a/dist/grid.cjs.js.map b/dist/grid.cjs.js.map new file mode 100644 index 0000000..3c0f25d --- /dev/null +++ b/dist/grid.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.cjs.js","sources":["../src/consts.ts","../src/ContainerManager.ts","../src/utils.ts","../src/ItemRenderer.ts","../src/GridItem.ts","../src/Grid.ts","../src/grids/MasonryGrid.ts","../src/grids/lib/dijkstra.ts","../src/grids/JustifiedGrid.ts","../src/grids/FrameGrid.ts","../src/grids/lib/BoxModel.ts","../src/grids/PackingGrid.ts","../src/index.ts","../src/index.umd.ts"],"sourcesContent":["/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { GridOptions } from \"./types\";\n\nexport const DEFAULT_GRID_OPTIONS: Required = {\n horizontal: false,\n useTransform: false,\n percentage: false,\n isEqualSize: false,\n isConstantSize: false,\n gap: 0,\n attributePrefix: \"data-grid-\",\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n autoResize: true,\n preserveUIOnDestroy: false,\n defaultDirection: \"end\",\n externalContainerManager: null,\n externalItemRenderer: null,\n renderOnPropertyChange: true,\n useFit: true,\n};\n\nexport enum PROPERTY_TYPE {\n PROPERTY = 1,\n RENDER_PROPERTY = 2,\n}\nexport enum MOUNT_STATE {\n UNCHECKED = 1,\n UNMOUNTED = 2,\n MOUNTED = 3,\n}\nexport enum UPDATE_STATE {\n NEED_UPDATE = 1,\n WAIT_LOADING = 2,\n UPDATED = 3,\n}\n\nexport const GRID_PROPERTY_TYPES = {\n gap: PROPERTY_TYPE.RENDER_PROPERTY,\n defaultDirection: PROPERTY_TYPE.PROPERTY,\n renderOnPropertyChange: PROPERTY_TYPE.PROPERTY,\n preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY,\n useFit: PROPERTY_TYPE.PROPERTY,\n};\n\nexport const GRID_METHODS = [\n \"syncElements\",\n \"updateItems\",\n \"getItems\",\n \"setItems\",\n \"renderItems\",\n \"getContainerInlineSize\",\n \"getContainerElement\",\n] as const;\n\nexport const GRID_EVENTS = [\n \"renderComplete\",\n \"contentError\",\n] as const;\n\nexport const RECT_NAMES = {\n horizontal: {\n inlinePos: \"top\",\n contentPos: \"left\",\n inlineSize: \"height\",\n contentSize: \"width\",\n },\n vertical: {\n inlinePos: \"left\",\n contentPos: \"top\",\n inlineSize: \"width\",\n contentSize: \"height\",\n },\n} as const;\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DestroyOptions } from \".\";\nimport { DEFAULT_GRID_OPTIONS } from \"./consts\";\nimport { DOMRect } from \"./types\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: DOMRect;\n}\n\nexport class ContainerManager {\n protected options: Required;\n protected rect: DOMRect;\n protected orgCSSText: string;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.offsetWidth,\n height: container.offsetHeight,\n });\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: DOMRect) {\n this.rect = { ...rect };\n }\n public getInlineSize() {\n return this.rect[this.options.horizontal ? \"height\" : \"width\"];\n }\n public getContentSize() {\n return this.rect[this.options.horizontal ? \"width\" : \"height\"]!;\n }\n public getStatus() {\n return {\n rect: { ...this.rect },\n };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.rect = { ...status.rect };\n\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.rect[sizeName] = size;\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n if (!options.preserveUI) {\n this.container.style.cssText = this.orgCSSText;\n }\n }\n private _init() {\n const container = this.container;\n const style = window.getComputedStyle(container);\n\n this.orgCSSText = container.style.cssText;\n\n if (style.position === \"static\") {\n container.style.position = \"relative\";\n }\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\nimport { GRID_METHODS, GRID_PROPERTY_TYPES, PROPERTY_TYPE } from \"./consts\";\n\nexport function getKeys>(obj: T): Array {\n return Object.keys(obj);\n}\n\nexport function isString(val: any): val is string {\n return typeof val === \"string\";\n}\nexport function isObject(val: any): val is object {\n return typeof val === \"object\";\n}\nexport function isNumber(val: any): val is number {\n return typeof val === \"number\";\n}\n\nexport function camelize(str: string) {\n return str.replace(/[\\s-_]([a-z])/g, (all, letter) => letter.toUpperCase());\n}\n\nexport function getDataAttributes(element: HTMLElement, attributePrefix: string) {\n const dataAttributes: Record = {};\n const attributes = element.attributes;\n const length = attributes.length;\n\n for (let i = 0; i < length; ++i) {\n const attribute = attributes[i];\n const { name, value } = attribute;\n if (name.indexOf(attributePrefix) === -1) {\n continue;\n }\n dataAttributes[camelize(name.replace(attributePrefix, \"\"))] = value;\n }\n\n return dataAttributes;\n}\n\n/* Class Decorator */\nexport function GetterSetter(component: {\n prototype: Grid,\n propertyTypes: typeof GRID_PROPERTY_TYPES,\n}) {\n const {\n prototype,\n propertyTypes,\n } = component;\n for (const name in propertyTypes) {\n const shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY;\n const attributes: Record = {\n enumerable: true,\n configurable: true,\n get(this: Grid) {\n return this.options[name];\n },\n set(this: Grid, value: any) {\n const options = this.options;\n const prevValue = options[name];\n\n if (prevValue === value) {\n return;\n }\n options[name] = value;\n\n if (shouldRender && options.renderOnPropertyChange) {\n this.scheduleRender();\n }\n },\n };\n Object.defineProperty(prototype, name, attributes);\n }\n}\n\nexport function withMethods(methods: readonly string[]) {\n return function (prototype: any, memberName: string) {\n methods.forEach((name: string) => {\n if (name in prototype) {\n return;\n }\n prototype[name] = function (...args) {\n const result = this[memberName][name](...args);\n\n // fix `this` type to return your own `class` instance to the instance using the decorator.\n if (result === this[memberName]) {\n return this;\n } else {\n return result;\n }\n };\n });\n };\n}\n\nexport function range(length: number): number[] {\n const arr: number[] = [];\n for (let i = 0; i < length; ++i) {\n arr.push(i);\n }\n return arr;\n}\n\nexport function getRangeCost(value: number, valueRange: number[]) {\n return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1;\n}\n\n/**\n * Decorator that makes the method of grid available in the framework.\n * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터.\n * @memberof eg.Grid\n * @private\n * @example\n * ```js\n * import { withGridMethods } from \"@egjs/grid\";\n *\n * class Grid extends React.Component> {\n * @withGridMethods\n * private grid: NativeGrid;\n * }\n * ```\n */\nexport const withGridMethods = withMethods(GRID_METHODS);\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DEFAULT_GRID_OPTIONS, MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\nimport { GridItem } from \"./GridItem\";\nimport { DOMRect } from \"./types\";\nimport { getDataAttributes, getKeys } from \"./utils\";\n\nexport interface ItemRendererOptions {\n attributePrefix?: string;\n useTransform?: boolean;\n horizontal?: boolean;\n percentage?: Array<\"position\" | \"size\"> | boolean;\n isEqualSize?: boolean;\n isConstantSize?: boolean;\n}\nexport interface ItemRendererStatus {\n initialRect: Required | null;\n}\n\nexport class ItemRenderer {\n protected options: Required;\n protected containerRect: DOMRect;\n protected initialRect: Required | null = null;\n protected sizePercetage = false;\n protected posPercetage = false;\n\n constructor(options: ItemRendererOptions) {\n this.options = {\n attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix,\n useTransform: DEFAULT_GRID_OPTIONS.useTransform,\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n percentage: DEFAULT_GRID_OPTIONS.percentage,\n isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize,\n isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize,\n ...options,\n };\n this._init();\n }\n public resize() {\n this.initialRect = null;\n }\n public renderItems(items: GridItem[]) {\n items.forEach((item) => {\n this._renderItem(item);\n });\n }\n public getInlineSize() {\n return this.containerRect[this.options.horizontal ? \"height\" : \"width\"]!;\n }\n public setContainerRect(rect: DOMRect) {\n this.containerRect = rect;\n }\n public updateItems(items: GridItem[]) {\n items.forEach((item) => {\n this._updateItem(item);\n });\n }\n public getStatus(): ItemRendererStatus {\n return {\n initialRect: this.initialRect,\n };\n }\n public setStatus(status: ItemRendererStatus) {\n this.initialRect = status.initialRect;\n }\n private _init() {\n const { percentage } = this.options;\n\n let sizePercentage = false;\n let posPercentage = false;\n\n if (percentage === true) {\n sizePercentage = true;\n posPercentage = true;\n } else if (percentage) {\n if (percentage.indexOf(\"position\") > -1) {\n posPercentage = true;\n }\n if (percentage.indexOf(\"size\") > -1) {\n sizePercentage = true;\n }\n }\n\n this.posPercetage = posPercentage;\n this.sizePercetage = sizePercentage;\n }\n private _updateItem(item: GridItem) {\n const { isEqualSize, isConstantSize } = this.options;\n const initialRect = this.initialRect;\n const { orgRect, element } = item;\n const isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING;\n const hasOrgSize = orgRect && orgRect.width && orgRect.height;\n let rect: Required;\n\n if (isEqualSize && initialRect) {\n rect = initialRect;\n } else if (isConstantSize && hasOrgSize && !isLoading) {\n rect = orgRect;\n } else if (!element) {\n return;\n } else {\n rect = {\n left: element.offsetLeft,\n top: element.offsetTop,\n width: element.offsetWidth,\n height: element.offsetHeight,\n };\n }\n if (!item.isFirstUpdate) {\n item.orgRect = { ...rect };\n }\n item.rect = { ...rect };\n\n if (item.element) {\n item.mountState = MOUNT_STATE.MOUNTED;\n }\n\n if (item.updateState === UPDATE_STATE.NEED_UPDATE) {\n item.updateState = UPDATE_STATE.UPDATED;\n item.isFirstUpdate = true;\n }\n item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {};\n\n if (!isLoading) {\n this.initialRect = { ...rect };\n }\n\n return rect;\n }\n private _renderItem(item: GridItem) {\n const element = item.element;\n const cssRect = item.cssRect;\n\n if (!element || !cssRect) {\n return;\n }\n\n const {\n horizontal,\n useTransform,\n } = this.options;\n const posPercentage = this.posPercetage;\n const sizePercentage = this.sizePercetage;\n const cssTexts: string[] = [\"position: absolute;\"];\n const {\n inlineSize: sizeName,\n inlinePos: posName,\n } = RECT_NAMES[horizontal ? \"horizontal\": \"vertical\"];\n const inlineSize = this.getInlineSize();\n let keys = getKeys(cssRect);\n\n if (useTransform) {\n keys = keys.filter((key) => key !== \"top\" && key !== \"left\");\n\n cssTexts.push(`transform: `\n + `translate(${cssRect.left || 0}px, ${cssRect.top || 0}px);`\n );\n }\n cssTexts.push(...keys.map((name) => {\n const value = cssRect[name]!;\n\n if (\n (name === sizeName && sizePercentage) ||\n (name === posName && posPercentage)\n ) {\n return `${name}: ${(value / inlineSize) * 100}%;`;\n }\n return `${name}: ${value}px;`;\n }));\n\n element.style.cssText += cssTexts.join(\"\");\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DOMRect, GridRect } from \"./types\";\nimport { MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\n\n/**\n * @typedef\n * @memberof Grid.GridItem\n * @property - The item key. 아이템 키.\n * @property - The element for the item. 아이템에 있는 엘리먼트.\n * @property - State of whether the element has been added to the container. element가 container에 추가되었는지 상태.\n * @property - The update state of the element's rect. element의 rect의 업데이트 상태.\n * @property - Whether the element's rect was updated for the first time. 처음으로 element의 rect를 업데이트 했는지 여부.\n * @property - Attributes set as `data-grid-` of element. element의 `data-grid-`으로 설정된 속성들.\n * @property - cssText of the first style when an element is added to the container. element가 container에 추가됐을 때 처음 style의 cssText.\n * @property - The element's rect before first rendering. 처음 렌더링 하기 전 엘리먼트의 rect.\n * @property - The updated element's rect before rendering. 렌더링 하기 전 업데이트 된 엘리먼트의 rect.\n * @property - The CSS rect of the item to be rendered by being applied to the Grid. Grid에 적용되어 렌더링을 하기 위한 item의 CSS rect\n * @property - Additional data of the item. item의 추가적인 데이터들.\n */\nexport interface GridItemStatus {\n key?: string | number;\n element?: HTMLElement | null;\n mountState?: MOUNT_STATE;\n updateState?: UPDATE_STATE;\n isFirstUpdate?: boolean;\n attributes?: Record;\n orgCSSText?: string;\n orgRect?: Required;\n rect?: Required;\n cssRect?: DOMRect;\n data?: Record;\n}\n\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n /**\n * @constructor\n * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향)\n * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체.\n */\n constructor(\n protected horizontal: boolean,\n itemStatus: Partial = {},\n ) {\n const element = itemStatus.element;\n const status: Required = {\n key: \"\",\n orgRect: { left: 0, top: 0, width: 0, height: 0 },\n rect: { left: 0, top: 0, width: 0, height: 0 },\n cssRect: {},\n attributes: {},\n data: {},\n isFirstUpdate: false,\n mountState: MOUNT_STATE.UNCHECKED,\n updateState: UPDATE_STATE.NEED_UPDATE,\n element: element || null,\n orgCSSText: element?.style.cssText ?? \"\",\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\n /**\n * Grid ready data for rendering\n * @ko 렌더링을 하기 위한 grid의 준비 데이타\n * @member Grid.GridItem#gridData\n */\n public gridData: Record = {};\n /**\n * The size in inline direction before first rendering. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#orgInlineSize\n */\n public get orgInlineSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.height : orgRect.width;\n }\n /**\n * The size in content direction before first rendering. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#orgContentSize\n */\n public get orgContentSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.width : orgRect.height;\n }\n /**\n * The size in inline direction. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#inlineSize\n */\n public get inlineSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.height : rect.width;\n }\n /**\n * The size in content direction. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#contentSize\n */\n public get contentSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.width : rect.height;\n }\n /**\n * The CSS size in inline direction applied to the Grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#cssInlineSize\n */\n public get cssInlineSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.height! : cssRect.width!;\n }\n /**\n * The CSS size in content direction applied to the Grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#cssContentSize\n */\n public get cssContentSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.width! : cssRect.height!;\n }\n /**\n * The CSS pos in inline direction applied to the Grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#cssInlinePos\n */\n public get cssInlinePos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.top! : cssRect.left!;\n }\n /**\n * The CSS pos in content direction applied to the Grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#cssContentPos\n */\n public get cssContentPos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.left! : cssRect.top!;\n }\n public set cssInlinePos(inlinePos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"top\" : \"left\"] = inlinePos;\n }\n public set cssContentPos(contentPos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"left\" : \"top\"] = contentPos;\n }\n public set cssInlineSize(inlineSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"height\" : \"width\"] = inlineSize;\n }\n public set cssContentSize(contentSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"width\" : \"height\"] = contentSize;\n }\n /**\n * Set CSS Rect through GridRect.\n * @ko GridRect을 통해 CSS Rect를 설정한다.\n * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일.\n */\n public setCSSGridRect(gridRect: GridRect) {\n const names = RECT_NAMES[this.horizontal ? \"horizontal\" : \"vertical\"];\n\n const rect: DOMRect = {};\n\n for (const name in gridRect) {\n rect[names[name]] = gridRect[name];\n }\n this.cssRect = rect;\n }\n /**\n * Returns the status of the item.\n * @ko 아이템의 상태를 반환한다.\n */\n public getStatus(): Required {\n return {\n mountState: this.mountState,\n updateState: this.updateState,\n attributes: this.attributes,\n orgCSSText: this.orgCSSText,\n isFirstUpdate: this.isFirstUpdate,\n element: null,\n key: this.key,\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n data: this.data,\n };\n }\n}\n\ninterface GridItem extends Required {\n}\nexport { GridItem };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DEFAULT_GRID_OPTIONS, GRID_PROPERTY_TYPES, MOUNT_STATE, UPDATE_STATE } from \"./consts\";\nimport { ContainerManager } from \"./ContainerManager\";\nimport {\n DestroyOptions, GridEvents, GridOptions,\n GridOutlines, GridStatus, Properties, RenderOptions,\n OnRenderComplete,\n} from \"./types\";\nimport ImReady from \"@egjs/imready\";\nimport { ItemRenderer } from \"./ItemRenderer\";\nimport { GetterSetter, isNumber, isString } from \"./utils\";\nimport { diff } from \"@egjs/children-differ\";\nimport { GridItem } from \"./GridItem\";\n\n/**\n * @extends eg.Component\n */\n@GetterSetter\nabstract class Grid extends Component {\n public static defaultOptions: Required = DEFAULT_GRID_OPTIONS;\n public static propertyTypes = GRID_PROPERTY_TYPES;\n public options: Required;\n protected containerElement: HTMLElement;\n protected containerManager: ContainerManager;\n protected itemRenderer!: ItemRenderer;\n protected items: GridItem[] = [];\n protected outlines: GridOutlines = {\n start: [],\n end: [],\n };\n private _renderTimer = 0;\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _im: ImReady;\n\n /**\n * Apply the CSS rect of items to fit the Grid and calculate the outline.\n * @ko Grid에 맞게 아이템들의 CSS rect를 적용하고 outline을 계산한다.\n * @abstract\n * @method Grid#applyGrid\n * @param {\"start\" | \"end\"} direcion - The direction to apply the Grid. (\"end\": start to end, \"start\": end to start) Grid를 적용할 방향. (\"end\": 시작에서 끝 방향, \"start\": 끝에서 시작 방향)\n * @param {number[]} outline - The start outline to apply the Grid. Grid를 적용할 시작 outline.\n */\n public abstract applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines;\n\n /**\n * @param - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param - The option object of the Grid module Grid 모듈의 옵션 객체\n */\n constructor(containerElement: HTMLElement | string, options: Partial = {}) {\n super();\n\n this.options = {\n ...((this.constructor as typeof Grid)\n .defaultOptions as Required),\n ...options,\n };\n\n this.containerElement = isString(containerElement)\n ? document.querySelector(containerElement)!\n : containerElement;\n\n const {\n isEqualSize,\n isConstantSize,\n useTransform,\n horizontal,\n percentage,\n externalContainerManager,\n externalItemRenderer,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n });\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n });\n\n this._init();\n }\n /**\n * Return Container Element.\n * @ko 컨테이너 엘리먼트를 반환한다.\n */\n public getContainerElement(): HTMLElement {\n return this.containerElement;\n }\n /**\n * Return items.\n * @ko 아이템들을 반환한다.\n */\n public getItems(): GridItem[] {\n return this.items;\n }\n /**\n * Returns the children of the container element.\n * @ko 컨테이너 엘리먼트의 children을 반환한다.\n */\n public getChildren(): HTMLElement[] {\n return [].slice.call(this.containerElement.children);\n }\n /**\n * Set items.\n * @ko 아이템들을 설정한다.\n * @param items - The items to set. 설정할 아이템들\n */\n public setItems(items: GridItem[]): this {\n this.items = items;\n return this;\n }\n /**\n * Gets the container's inline size. (\"width\" if horizontal is false, otherwise \"height\")\n * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 \"width\", 아니면 \"height\")\n */\n public getContainerInlineSize(): number {\n return this.containerManager.getInlineSize()!;\n }\n /**\n * Returns the outlines of the start and end of the Grid.\n * @ko Grid의 처음과 끝의 outline을 반환한다.\n */\n public getOutlines(): GridOutlines {\n return this.outlines;\n }\n /**\n * Set outlines.\n * @ko 아웃라인을 설정한다.\n * @param outlines - The outlines to set. 설정할 아웃라인.\n */\n public setOutlines(outlines: GridOutlines) {\n this.outlines = outlines;\n return this;\n }\n /**\n * When elements change, it synchronizes and renders items.\n * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public syncElements(options: RenderOptions = {}) {\n const items = this.items;\n const horizontal = this.options.horizontal;\n const elements: HTMLElement[] = this.getChildren();\n const { added, maintained, changed, removed } = diff(this.items.map((item) => item.element!), elements);\n\n const nextItems: GridItem[] = [];\n\n maintained.forEach(([beforeIndex, afterIndex]) => {\n nextItems[afterIndex] = items[beforeIndex];\n });\n added.forEach((index) => {\n nextItems[index] = new GridItem(horizontal!, {\n element: elements[index],\n });\n });\n\n this.setItems(nextItems);\n\n if (added.length || removed.length || changed.length) {\n this.renderItems(options);\n }\n return this;\n }\n /**\n * Update the size of the items and render them.\n * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다.\n * @param - Items to be updated. 업데이트할 아이템들.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public updateItems(items: GridItem[] = this.items, options: RenderOptions = {}) {\n items.forEach((item) => {\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n });\n this.checkReady(options);\n return this;\n }\n /**\n * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired.\n * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n * const grid = new MasonryGrid();\n *\n * grid.on(\"renderComplete\", e => {\n * console.log(e);\n * });\n * grid.renderItems();\n */\n public renderItems(options: RenderOptions = {}) {\n this._clearRenderTimer();\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (options.useResize) {\n // Resize container and Update all items\n this._resizeContainer();\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\n }\n return this;\n }\n /**\n * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method.\n * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다.\n */\n public getStatus(): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => item.getStatus()),\n containerManager: this.containerManager.getStatus(),\n itemRenderer: this.itemRenderer.getStatus(),\n };\n }\n /**\n * Set status of the Grid module with the status returned through a call to the getStatus() method.\n * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다.\n */\n public setStatus(status: GridStatus) {\n const horizontal = this.options.horizontal;\n const containerManager = this.containerManager;\n const prevInlineSize = containerManager.getInlineSize();\n const children = this.getChildren();\n\n this.itemRenderer.setStatus(status.itemRenderer);\n containerManager.setStatus(status.containerManager);\n this.outlines = status.outlines;\n this.items = status.items.map((item, i) => new GridItem(horizontal!, {\n ...item,\n element: children[i],\n }));\n\n this.itemRenderer.renderItems(this.items);\n\n if (prevInlineSize !== containerManager.getInlineSize()) {\n this.renderItems({\n useResize: true,\n });\n } else {\n window.setTimeout(() => {\n this._renderComplete({\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Releases the instnace and events and returns the CSS of the container and elements.\n * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.\n * @param Options for destroy. destory()를 위한 옵션\n */\n public destroy(options: DestroyOptions = {}) {\n const {\n preserveUI = this.options.preserveUIOnDestroy,\n } = options;\n this.containerManager.destroy({\n preserveUI,\n });\n\n if (!preserveUI) {\n this.items.forEach(({ element, orgCSSText }) => {\n if (element) {\n element.style.cssText = orgCSSText;\n }\n });\n }\n window.removeEventListener(\"resize\", this._scheduleResize);\n this._im?.destroy();\n }\n protected checkReady(options: RenderOptions = {}) {\n // Grid: renderItems => checkReady => readyItems => applyGrid\n const items = this.items;\n const updated = items.filter((item) => item.element && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n this._im?.destroy();\n this._im = new ImReady({\n prefix: this.options.attributePrefix,\n }).on(\"preReadyElement\", (e) => {\n updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING;\n }).on(\"preReady\", () => {\n this.itemRenderer.updateItems(updated);\n this.readyItems(mounted, updated, options);\n }).on(\"readyElement\", (e) => {\n const item = updated[e.index];\n\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n\n // after preReady\n if (e.isPreReadyOver) {\n item.element!.style.cssText = item.orgCSSText;\n this.itemRenderer.updateItems([item]);\n this.readyItems([], [item], options);\n }\n }).on(\"error\", (e) => {\n const item = items[e.index];\n /**\n * This event is fired when an error occurs in the content.\n * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트.\n * @event Grid#contentError\n * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트.\n * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트.\n * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템\n * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.\n * @example\ngrid.on(\"contentError\", e => {\n e.update();\n});\n */\n this.trigger(\"contentError\", {\n element: e.element,\n target: e.target,\n item,\n update: () => {\n moreUpdated.push(item);\n },\n });\n }).on(\"ready\", () => {\n if (moreUpdated.length) {\n this.updateItems(moreUpdated);\n }\n }).check(updated.map((item) => item.element!));\n }\n\n protected scheduleRender() {\n this._clearRenderTimer();\n this._renderTimer = window.setTimeout(() => {\n this.renderItems();\n });\n }\n protected fitOutlines(useFit = this.useFit) {\n const outlines = this.outlines;\n const startOutline = outlines.start;\n const endOutline = outlines.end;\n const outlineOffset = startOutline.length ? Math.min(...startOutline) : 0;\n\n // If the outline is less than 0, a fit occurs forcibly.\n if (!useFit && outlineOffset > 0) {\n return;\n }\n\n outlines.start = startOutline.map((point) => point - outlineOffset);\n outlines.end = endOutline.map((point) => point - outlineOffset);\n\n this.items.forEach((item) => {\n const contentPos = item.cssContentPos;\n\n if (!isNumber(contentPos)) {\n return;\n }\n item.cssContentPos = contentPos - outlineOffset;\n });\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const prevOutlines = this.outlines;\n const direction = options.direction || this.options.defaultDirection!;\n const prevOutline = options.outline || prevOutlines[direction === \"end\" ? \"start\" : \"end\"];\n const items = this.items;\n let nextOutlines = {\n start: [...prevOutline],\n end: [...prevOutline],\n };\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n this._renderComplete({\n mounted,\n updated,\n isResize: !!options.useResize,\n });\n }\n private _renderComplete(e: OnRenderComplete) {\n /**\n * This event is fired when the Grid has completed rendering.\n * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다.\n * @event Grid#renderComplete\n * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들\n * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들.\n * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.\n * @example\ngrid.on(\"renderComplete\", e => {\nconsole.log(e.mounted, e.updated, e.useResize);\n});\n */\n this.trigger(\"renderComplete\", e);\n }\n private _clearRenderTimer() {\n clearTimeout(this._renderTimer);\n this._renderTimer = 0;\n }\n private _refreshContainerContentSize() {\n const {\n start: startOutline,\n end: endOutline,\n } = this.outlines;\n const gap = this.options.gap!;\n\n const endPoint = endOutline.length ? Math.max(...endOutline) : 0;\n const startPoint = startOutline.length ? Math.max(...startOutline) : 0;\n const contentSize = Math.max(startPoint, endPoint - gap);\n\n this.containerManager.setContentSize(contentSize);\n }\n private _resizeContainer() {\n this.containerManager.resize();\n this.itemRenderer.setContainerRect(this.containerManager.getRect());\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n this.renderItems({\n useResize: true,\n });\n }\n private _scheduleResize = () => {\n const {\n resizeDebounce,\n maxResizeDebounce,\n } = this.options;\n\n\n if (!this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) {\n this._maxResizeDebounceTimer = window.setTimeout(this._onResize, maxResizeDebounce);\n }\n if (this._resizeTimer) {\n clearTimeout(this._resizeTimer);\n this._resizeTimer = 0;\n }\n this._resizeTimer = window.setTimeout(this._onResize, resizeDebounce);\n }\n\n private _init() {\n this._resizeContainer();\n if (this.options.autoResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n }\n}\n\ninterface Grid extends Properties { }\n\nexport default Grid;\n\n/**\n * Gap used to create space around items.\n * @ko 아이템들 사이의 공간.\n * @name Grid#gap\n * @type {$ts:Grid.GridOptions[\"gap\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * gap: 0,\n * });\n *\n * grid.gap = 5;\n */\n\n/**\n * The default direction value when direction is not set in the render option.\n * @ko render옵션에서 direction을 미설정시의 기본 방향값.\n * @name Grid#defaultDirection\n * @type {$ts:Grid.GridOptions[\"defaultDirection\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * defaultDirection: \"end\",\n * });\n *\n * grid.defaultDirection = \"start\";\n */\n\n\n/**\n * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true)\n * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true)\n * @name Grid#useFit\n * @type {$ts:Grid.GridOptions[\"useFit\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * useFit: true,\n * });\n *\n * grid.useFit = false;\n\n/**\n * Whether to preserve the UI of the existing container or item when destroying.\n * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.\n * @name Grid#preserveUIOnDestroy\n * @type {$ts:Grid.GridOptions[\"preserveUIOnDestroy\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * preserveUIOnDestroy: false,\n * });\n *\n * grid.preserveUIOnDestroy = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE, UPDATE_STATE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridAlign } from \"../types\";\nimport { range, GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getColumnPoint(\n outline: number[],\n columnIndex: number,\n columnCount: number,\n pointCaculationName: \"max\" | \"min\",\n) {\n return Math[pointCaculationName](...outline.slice(columnIndex, columnIndex + columnCount));\n}\n\nfunction getColumnIndex(outline: number[], columnCount: number, nearestCalculationName: \"max\" | \"min\") {\n const length = outline.length - columnCount + 1;\n const pointCaculationName = nearestCalculationName === \"max\" ? \"min\" : \"max\";\n const indexCaculationName = nearestCalculationName === \"max\" ? \"lastIndexOf\" : \"indexOf\";\n const points = range(length).map((index) => {\n return getColumnPoint(outline, index, columnCount, pointCaculationName);\n });\n\n return points[indexCaculationName](Math[nearestCalculationName](...points));\n}\n\n/**\n * @typedef\n * @memberof Grid.MasonryGrid\n * @extends Grid.GridOptions\n * @property - The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) \n * @property - The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) \n * @property - The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. \n * @property - Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\") 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n}\n\n/**\n * MasonryGrid 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.\n *\n * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class MasonryGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n column: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSize: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n align: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n align: \"justify\",\n column: 0,\n columnSize: 0,\n columnSizeRatio: 0,\n };\n\n private _columnSize = 0;\n private _column = 1;\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n this._calculateColumnSize(items);\n this._calculateColumn(items);\n\n const column = this._column;\n const columnSize = this._columnSize;\n const {\n gap,\n align,\n columnSizeRatio,\n columnSize: columnSizeOption,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses();\n const isEndDirection = direction === \"end\";\n const nearestCalculationName = isEndDirection ? \"min\" : \"max\";\n const pointCalculationName = isEndDirection ? \"max\" : \"min\";\n let startOutline = [0];\n\n if (outlineLength === column) {\n startOutline = outline.slice();\n } else {\n const point = outlineLength ? Math[nearestCalculationName](...outline) : 0;\n\n startOutline = range(column).map(() => point);\n }\n const endOutline = startOutline.slice();\n const columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0;\n const isStretch = align === \"stretch\";\n\n for (let i = 0; i < itemsLength; ++i) {\n const item = items[isEndDirection ? i : itemsLength - 1 - i];\n const columnAttribute = parseInt(item.attributes.column || \"1\", 10);\n const maxColumnAttribute = parseInt(item.attributes.maxColumn || \"1\", 10);\n let inlineSize = item.inlineSize;\n let contentSize = item.contentSize;\n let columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist)));\n const maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute));\n let columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName);\n let contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName);\n\n while (columnCount < maxColumnCount) {\n const nextEndColumnIndex = columnIndex + columnCount;\n const nextColumnIndex = columnIndex - 1;\n\n if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) {\n break;\n }\n if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) {\n break;\n }\n if (!isEndDirection) {\n --columnIndex;\n }\n ++columnCount;\n }\n\n columnIndex = Math.max(0, columnIndex);\n columnCount = Math.min(column - columnIndex, columnCount);\n\n if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) {\n inlineSize = (columnCount - 1) * columnDist + columnSize;\n item.cssInlineSize = inlineSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = inlineSize / columnSizeRatio;\n item.cssContentSize = contentSize;\n }\n const inlinePos = alignPoses[columnIndex];\n contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize;\n\n item.cssInlinePos = inlinePos;\n item.cssContentPos = contentPos;\n const nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos;\n\n range(columnCount).forEach((indexOffset) => {\n endOutline[columnIndex + indexOffset] = nextOutlinePoint;\n });\n }\n\n // if end items, startOutline is low, endOutline is high\n // if start items, startOutline is high, endOutline is low\n return {\n start: isEndDirection ? startOutline : endOutline,\n end: isEndDirection ? endOutline : startOutline,\n };\n }\n private _calculateColumnSize(items: GridItem[]) {\n const {\n columnSize: columnSizeOption,\n gap,\n align,\n } = this.options;\n\n if (align === \"stretch\") {\n let column = this.column;\n\n if (columnSizeOption) {\n column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap)));\n }\n this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n this._columnSize = columnSizeOption;\n } else {\n for (const item of items) {\n const attributes = item.attributes;\n if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) {\n continue;\n }\n const inlineSize = item.inlineSize;\n\n this._columnSize = inlineSize;\n return inlineSize;\n }\n this._columnSize = this._columnSize || 0;\n }\n return this._columnSize;\n }\n private _calculateColumn(items: GridItem[]) {\n const {\n gap,\n column: columnOption,\n } = this.options;\n const columnSize = this._columnSize;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else if (!columnSize) {\n column = 1;\n } else {\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap))),\n );\n }\n this._column = column;\n return column;\n }\n private _getAlignPoses() {\n const columnSize = this._columnSize;\n const column = this._column;\n const {\n align,\n gap,\n } = this.options;\n const containerSize = this.getContainerInlineSize();\n const indexes = range(column);\n\n let offset = 0;\n let dist = 0;\n\n if (align === \"justify\" || align === \"stretch\") {\n const countDist = column - 1;\n\n dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0;\n offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2);\n } else {\n dist = columnSize + gap;\n const totalColumnSize = (column - 1) * dist + columnSize;\n\n if (align === \"center\") {\n offset = (containerSize - totalColumnSize) / 2;\n } else if (align === \"end\") {\n offset = containerSize - totalColumnSize;\n }\n }\n return indexes.map((i) => {\n return offset + i * dist;\n });\n }\n}\n\nexport interface MasonryGrid extends Properties {\n}\n\n\n/**\n * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * align: \"start\",\n * });\n *\n * grid.align = \"justify\";\n */\n\n\n/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * column: 0,\n * });\n *\n * grid.column = 4;\n */\n\n\n/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0)\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSize: 0,\n * });\n *\n * grid.columnSize = 200;\n */\n\n\n/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0)\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSizeRatio: 0,\n * });\n *\n * grid.columnSizeRatio = 0.5;\n */\n","/* eslint-disable */\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin \n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nfunction single_source_shortest_paths(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\t// Predecessor map for each node that has been encountered.\n\t// node ID => predecessor node ID\n\tconst predecessors: { [key: string]: string } = {};\n\t// Costs of shortest paths from s to all nodes encountered.\n\t// node ID => cost\n\tconst costs: { [key: string]: number } = {};\n\tcosts[s] = 0;\n\n\t// Costs of shortest paths from s to all nodes encountered; differs from\n\t// `costs` in that it provides easy access to the node that currently has\n\t// the known shortest path from s.\n\t// XXX: Do we actually need both `costs` and `open`?\n\tconst open = new BinaryHeap<{ value: string, cost: number }>(x => x.cost);\n\topen.push({ value: s, cost: 0 });\n\n\tlet closest;\n\tlet u;\n\tlet cost_of_s_to_u;\n\tlet adjacent_nodes;\n\tlet cost_of_e;\n\tlet cost_of_s_to_u_plus_cost_of_e;\n\tlet cost_of_s_to_v;\n\tlet first_visit: boolean;\n\n\twhile (open.size()) {\n\t\t// In the nodes remaining in graph that have a known cost from s,\n\t\t// find the node, u, that currently has the shortest path from s.\n\t\tclosest = open.pop();\n\t\tu = closest.value;\n\t\tcost_of_s_to_u = closest.cost;\n\n\t\t// Get nodes adjacent to u...\n\t\tadjacent_nodes = graph(u) || {};\n\n\t\t// ...and explore the edges that connect u to those nodes, updating\n\t\t// the cost of the shortest paths to any or all of those nodes as\n\t\t// necessary. v is the node across the current edge from u.\n\t\tfor (const v in adjacent_nodes) {\n\t\t\t// Get the cost of the edge running from u to v.\n\t\t\tcost_of_e = adjacent_nodes[v];\n\n\t\t\t// Cost of s to u plus the cost of u to v across e--this is *a*\n\t\t\t// cost from s to v that may or may not be less than the current\n\t\t\t// known cost to v.\n\t\t\tcost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n\t\t\t// If we haven't visited v yet OR if the current known cost from s to\n\t\t\t// v is greater than the new cost we just found (cost of s to u plus\n\t\t\t// cost of u to v across e), update v's cost in the cost list and\n\t\t\t// update v's predecessor in the predecessor list (it's now u).\n\t\t\tcost_of_s_to_v = costs[v];\n\t\t\tfirst_visit = (typeof costs[v] === \"undefined\");\n\t\t\tif (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n\t\t\t\tcosts[v] = cost_of_s_to_u_plus_cost_of_e;\n\t\t\t\topen.push({ value: v, cost: cost_of_s_to_u_plus_cost_of_e });\n\t\t\t\tpredecessors[v] = u;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof costs[d] === \"undefined\") {\n\t\tconst msg = [\"Could not find a path from \", s, \" to \", d, \".\"].join(\"\");\n\t\tthrow new Error(msg);\n\t}\n\n\treturn predecessors;\n}\nfunction extract_shortest_path_from_predecessor_list(\n\tpredecessors: { [key: string]: string },\n\td: string,\n) {\n\tconst nodes: string[] = [];\n\tlet u = d;\n\n\twhile (u) {\n\t\tnodes.push(u);\n\t\tu = predecessors[u];\n\t}\n\tnodes.reverse();\n\treturn nodes;\n}\nfunction find_path(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\tconst predecessors = single_source_shortest_paths(graph, s, d);\n\n\treturn extract_shortest_path_from_predecessor_list(predecessors, d);\n}\n\nclass BinaryHeap {\n\tprivate content: T[];\n\tprivate scoreFunction: (x: T) => number;\n\n\tconstructor(scoreFunction: (x: T) => number) {\n\t\tthis.content = [];\n\t\tthis.scoreFunction = scoreFunction;\n\t}\n\tpublic push(element: T) {\n\t\t// Add the new element to the end of the array.\n\t\tthis.content.push(element);\n\t\t// Allow it to bubble up.\n\t\tthis.bubbleUp(this.content.length - 1);\n\t}\n\tpublic pop() {\n\t\t// Store the first element so we can return it later.\n\t\tconst result = this.content[0];\n\t\t// Get the element at the end of the array.\n\t\tconst end = this.content.pop()!;\n\t\t// If there are any elements left, put the end element at the\n\t\t// start, and let it sink down.\n\t\tif (this.content.length > 0) {\n\t\t\tthis.content[0] = end;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic size() {\n\t\treturn this.content.length;\n\t}\n\tpublic bubbleUp(_n: number) {\n\t\tlet n = _n;\n\t\t// Fetch the element that has to be moved.\n\t\tconst element = this.content[n];\n\t\t// When at 0, an element can not go up any further.\n\t\twhile (n > 0) {\n\t\t\t// Compute the parent element's index, and fetch it.\n\t\t\tconst parentN = Math.floor((n + 1) / 2) - 1;\n\t\t\tconst parent = this.content[parentN];\n\n\t\t\t// Swap the elements if the parent is greater.\n\t\t\tif (this.scoreFunction(element) < this.scoreFunction(parent)) {\n\t\t\t\tthis.content[parentN] = element;\n\t\t\t\tthis.content[n] = parent;\n\t\t\t\t// Update 'n' to continue at the new position.\n\t\t\t\tn = parentN;\n\t\t\t} else {\n\t\t\t\t// Found a parent that is less, no need to move it further.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tpublic sinkDown(n: number) {\n\t\t// Look up the target element and its score.\n\t\tconst length = this.content.length;\n\t\tconst element = this.content[n];\n\t\tconst elemScore = this.scoreFunction(element);\n\t\tlet child1Score;\n\n\t\twhile (true) {\n\t\t\t// Compute the indices of the child elements.\n\t\t\tconst child2N = (n + 1) * 2;\n\t\t\tconst child1N = child2N - 1;\n\t\t\t// This is used to store the new position of the element,\n\t\t\t// if any.\n\t\t\tlet swap: number | null = null;\n\t\t\t// If the first child exists (is inside the array)...\n\t\t\tif (child1N < length) {\n\t\t\t\t// Look it up and compute its score.\n\t\t\t\tconst child1 = this.content[child1N];\n\t\t\t\tchild1Score = this.scoreFunction(child1);\n\t\t\t\t// If the score is less than our element's, we need to swap.\n\t\t\t\tif (child1Score < elemScore) {\n\t\t\t\t\tswap = child1N;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Do the same checks for the other child.\n\t\t\tif (child2N < length) {\n\t\t\t\tconst child2 = this.content[child2N];\n\t\t\t\tconst child2Score = this.scoreFunction(child2);\n\n\t\t\t\tif (child2Score < (swap == null ? elemScore : child1Score)) {\n\t\t\t\t\tswap = child2N;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the element needs to be moved, swap it, and continue.\n\t\t\tif (swap !== null) {\n\t\t\t\tthis.content[n] = this.content[swap];\n\t\t\t\tthis.content[swap] = element;\n\t\t\t\tn = swap;\n\t\t\t} else {\n\t\t\t\t// Otherwise, we are done.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport { find_path };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, RenderOptions } from \"../types\";\nimport { getRangeCost, GetterSetter, isObject } from \"../utils\";\nimport { find_path } from \"./lib/dijkstra\";\nimport { GridItem } from \"../GridItem\";\n\n\ninterface Link {\n path: number[];\n cost: number;\n length: number;\n currentNode: number;\n isOver?: boolean;\n}\n\nfunction splitItems(items: GridItem[], path: string[]) {\n const length = path.length;\n const groups: GridItem[][] = [];\n\n for (let i = 0; i < length - 1; ++i) {\n const path1 = parseInt(path[i], 10);\n const path2 = parseInt(path[i + 1], 10);\n\n groups.push(items.slice(path1, path2));\n }\n return groups;\n}\nfunction getExpectedColumnSize(item: GridItem, rowSize: number) {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return 0;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n\n return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset;\n}\n\n/**\n * @typedef\n * @memberof Grid.JustifiedGrid\n * @extends Grid.GridOptions\n * @property - The minimum and maximum number of items per line. (default: [1, 8]) 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) \n * @property - The minimum and maximum number of rows in a group, 0 is not set. (default: 0) 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) \n * @property - The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @property - Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @property - Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) row사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n */\nexport interface JustifiedGridOptions extends GridOptions {\n columnRange?: number | number[];\n rowRange?: number | number[];\n sizeRange?: number | number[];\n displayedRow?: number;\n isCroppedSize?: boolean;\n}\n\n/**\n * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size.\n * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.\n * 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.\n * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.\n * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.\n * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class JustifiedGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n columnRange: PROPERTY_TYPE.RENDER_PROPERTY,\n rowRange: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeRange: PROPERTY_TYPE.RENDER_PROPERTY,\n isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY,\n displayedRow: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n columnRange: [1, 8],\n rowRange: 0,\n sizeRange: [0, Infinity],\n displayedRow: -1,\n isCroppedSize: false,\n };\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const rowRange = this.options.rowRange;\n let path: string[] = [];\n\n if (items.length) {\n path = rowRange ? this._getRowPath(items) : this._getPath(items);\n }\n\n return this._setStyle(items, path, outline, direction === \"end\");\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const {\n attributePrefix,\n horizontal,\n } = this.options;\n\n updated.forEach((item) => {\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || 0;\n\n if (element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)) {\n const maintainedTarget = element.querySelector(`[${attributePrefix}maintained-target]`);\n\n if (maintainedTarget) {\n const widthOffset = element.offsetWidth - element.clientWidth\n + element.scrollWidth - maintainedTarget.clientWidth;\n const heightOffset = element.offsetHeight - element.clientHeight\n + element.scrollHeight - maintainedTarget.clientHeight;\n\n if (horizontal) {\n inlineOffset = heightOffset;\n contentOffset = widthOffset;\n } else {\n inlineOffset = widthOffset;\n contentOffset = heightOffset;\n }\n }\n }\n gridData.inlineOffset = inlineOffset;\n gridData.contentOffset = contentOffset;\n });\n super.readyItems(mounted, updated, options);\n }\n private _getRowPath(items: GridItem[]) {\n const columnRange = this._getColumnRange();\n const rowRange = this._getRowRange();\n\n const pathLink = this._getRowLink(items, {\n path: [0],\n cost: 0,\n length: 0,\n currentNode: 0,\n }, columnRange, rowRange);\n\n return pathLink?.path.map((node) => `${node}`) ?? [];\n }\n private _getRowLink(\n items: GridItem[],\n currentLink: Link,\n columnRange: number[],\n rowRange: number[]\n ): Link {\n const [minColumn] = columnRange;\n const [minRow, maxRow] = rowRange;\n const lastNode = items.length;\n const {\n path,\n length: pathLength,\n cost,\n currentNode,\n } = currentLink;\n\n // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn.\n if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) {\n const rangeCost = getRangeCost(lastNode - currentNode, columnRange);\n const lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode));\n\n return {\n ...currentLink,\n length: pathLength + 1,\n path: [...path, lastNode],\n currentNode: lastNode,\n cost: cost + lastCost,\n isOver: true,\n };\n } else if (currentNode >= lastNode) {\n return {\n ...currentLink,\n currentNode: lastNode,\n isOver: minRow > pathLength || maxRow < pathLength,\n };\n } else {\n return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange);\n }\n\n }\n private _searchRowLink(\n items: GridItem[],\n currentLink: Link,\n lastNode: number,\n columnRange: number[],\n rowRange: number[]\n ) {\n const [minColumn, maxColumn] = columnRange;\n const {\n currentNode,\n path,\n length: pathLength,\n cost,\n } = currentLink;\n const length = Math.min(lastNode, currentNode + maxColumn);\n const links: Link[] = [];\n\n for (let nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) {\n if (nextNode === currentNode) {\n continue;\n }\n const nextCost = Math.abs(this._getCost(items, currentNode, nextNode));\n const nextLink = this._getRowLink(items, {\n path: [...path, nextNode],\n length: pathLength + 1,\n cost: cost + nextCost,\n currentNode: nextNode,\n }, columnRange, rowRange);\n\n if (nextLink) {\n links.push(nextLink);\n }\n }\n links.sort((a, b) => {\n const aIsOver = a.isOver;\n const bIsOver = b.isOver;\n\n if (aIsOver !== bIsOver) {\n // If it is over, the cost is high.\n return aIsOver ? 1 : -1;\n }\n const aRangeCost = getRangeCost(a.length, rowRange);\n const bRangeCost = getRangeCost(b.length, rowRange);\n\n return aRangeCost - bRangeCost || a.cost - b.cost;\n });\n\n // It returns the lowest cost link.\n return links[0];\n }\n private _getExpectedRowSize(items: GridItem[]) {\n const {\n gap,\n } = this.options;\n let containerInlineSize = this.getContainerInlineSize()! - gap * (items.length - 1);\n let ratioSum = 0;\n let inlineSum = 0;\n\n items.forEach((item) => {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return;\n }\n // sum((expect - offset) * ratio) = container inline size\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n ratioSum += maintainedRatio;\n inlineSum += contentOffset * maintainedRatio;\n containerInlineSize -= inlineOffset;\n });\n\n return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0;\n }\n private _getExpectedInlineSize(items: GridItem[], rowSize: number) {\n const {\n gap,\n } = this.options;\n const size = items.reduce((sum, item) => {\n return sum + getExpectedColumnSize(item, rowSize);\n }, 0);\n\n return size ? size + gap * (items.length - 1) : 0;\n }\n private _getCost(\n items: GridItem[],\n i: number,\n j: number,\n ) {\n const lineItems = items.slice(i, j);\n const rowSize = this._getExpectedRowSize(lineItems);\n const [minSize, maxSize] = this._getSizeRange();\n\n if (this.isCroppedSize) {\n if (minSize <= rowSize && rowSize <= maxSize) {\n return 0;\n }\n const expectedInlineSize = this._getExpectedInlineSize(\n lineItems,\n rowSize < minSize ? minSize : maxSize,\n );\n\n return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2);\n }\n\n if (isFinite(maxSize)) {\n // if this size is not in range, the cost increases sharply.\n if (rowSize < minSize) {\n return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2);\n } else if (rowSize > maxSize) {\n return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2);\n }\n } else if (rowSize < minSize) {\n return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2);\n }\n // if this size in range, the cost is row\n return rowSize - minSize;\n }\n private _getPath(items: GridItem[]) {\n const lastNode = items.length;\n const columnRangeOption = this.options.columnRange;\n const [minColumn, maxColumn]: number[] = isObject(columnRangeOption)\n ? columnRangeOption\n : [columnRangeOption, columnRangeOption];\n\n const graph = (nodeKey: string) => {\n const results: { [key: string]: number } = {};\n const currentNode = parseInt(nodeKey, 10);\n\n for (let nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) {\n if (nextNode - currentNode > maxColumn) {\n break;\n }\n let cost = this._getCost(\n items,\n currentNode,\n nextNode,\n );\n\n if (cost < 0 && nextNode === lastNode) {\n cost = 0;\n }\n results[`${nextNode}`] = Math.pow(cost, 2);\n }\n return results;\n };\n // shortest path for items' total height.\n return find_path(graph, \"0\", `${lastNode}`);\n }\n private _setStyle(\n items: GridItem[],\n path: string[],\n outline: number[] = [],\n isEndDirection: boolean,\n ) {\n const {\n gap,\n isCroppedSize,\n displayedRow,\n } = this.options;\n const sizeRange = this._getSizeRange();\n const startPoint = outline[0] || 0;\n const containerInlineSize = this.getContainerInlineSize();\n const groups = splitItems(items, path);\n let contentPos = startPoint;\n let displayedSize = 0;\n\n groups.forEach((groupItems, rowIndex) => {\n const length = groupItems.length;\n let rowSize = this._getExpectedRowSize(groupItems);\n if (isCroppedSize) {\n rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1]));\n }\n const expectedInlineSize = this._getExpectedInlineSize(groupItems, rowSize);\n\n const allGap = gap * (length - 1);\n const scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap);\n\n groupItems.forEach((item, i)=> {\n let columnSize = getExpectedColumnSize(item, rowSize);\n\n const prevItem = groupItems[i - 1];\n const inlinePos = prevItem\n ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap\n : 0;\n\n if (isCroppedSize) {\n columnSize *= scale;\n }\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize: columnSize,\n contentSize: rowSize,\n });\n });\n contentPos += gap + rowSize;\n if (displayedRow < 0 || rowIndex < displayedRow) {\n displayedSize = contentPos;\n }\n });\n\n if (isEndDirection) {\n // previous group's end outline is current group's start outline\n return {\n start: [startPoint],\n end: [displayedSize],\n };\n }\n // always start is lower than end.\n // contentPos is endPoinnt\n const height = contentPos - startPoint;\n\n items.forEach((item) => {\n item.cssContentPos -= height;\n });\n return {\n start: [startPoint - height],\n end: [startPoint], // endPoint - height = startPoint\n };\n }\n private _getRowRange() {\n const rowRange = this.rowRange;\n return isObject(rowRange) ? rowRange : [rowRange, rowRange];\n }\n private _getColumnRange() {\n const columnRange = this.columnRange;\n return isObject(columnRange) ? columnRange : [columnRange, columnRange];\n }\n private _getSizeRange() {\n const sizeRange = this.sizeRange;\n return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange];\n }\n}\n\nexport interface JustifiedGrid extends Properties {\n}\n\n\n/**\n * The minimum and maximum number of items per line. (default: [1, 8])\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8])\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * columnRange: [1, 8],\n * });\n *\n * grid.columnRange = [3, 6];\n */\n\n\n/**\n * The minimum and maximum number of rows in a group, 0 is not set. (default: 0)\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0)\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * rowRange: 0,\n * });\n *\n * grid.rowRange = [3, 4];\n */\n\n/**\n * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity])\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [0, Infinity],\n * });\n *\n * grid.sizeRange = [200, 800];\n */\n\n/**\n * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * displayedRow: -1,\n * });\n *\n * grid.displayedRow = 3;\n */\n\n/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false)\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [200, 250],\n * isCroppedSize: false,\n * });\n *\n * grid.isCroppedSize = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridRect } from \"../types\";\nimport { GetterSetter, range } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getMaxPoint(outline: number[]) {\n let maxPoint = -Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n maxPoint = Math.max(maxPoint, point);\n }\n });\n return isFinite(maxPoint) ? maxPoint : 0;\n}\nfunction getMinPoint(outline: number[]) {\n let minPoint = Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n minPoint = Math.min(minPoint, point);\n }\n });\n return isFinite(minPoint) ? minPoint : 0;\n}\nfunction getOutlinePoint(startOutline: number[], frameOutline: number[], useFrameFill: boolean) {\n return getMaxPoint(startOutline)\n + getOutlineDist(startOutline, frameOutline, useFrameFill);\n}\n\nfunction getOutlineDist(startOutline: number[], endOutline: number[], useFrameFill: boolean) {\n const length = startOutline.length;\n\n if (!length) {\n return 0;\n }\n const minEndPoint = getMinPoint(endOutline);\n const maxStartPoint = getMaxPoint(startOutline);\n let frameDist = 0;\n\n if (!useFrameFill) {\n return 0;\n }\n\n\n for (let outlineIndex = 0; outlineIndex < length; ++outlineIndex) {\n const startPoint = startOutline[outlineIndex];\n const endPoint = endOutline[outlineIndex];\n\n if (!isFinite(startPoint) || !isFinite(endPoint)) {\n continue;\n }\n const startPos = startPoint - maxStartPoint;\n const endPos = endPoint - minEndPoint;\n\n\n // Fill empty block.\n frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos;\n }\n\n return frameDist;\n}\nfunction fillOutlines(startOutline: number[], endOutline: number[], rect: {\n inlinePos: number;\n inlineSize: number;\n contentPos: number;\n contentSize: number;\n}) {\n const {\n inlinePos,\n inlineSize,\n contentPos,\n contentSize,\n } = rect;\n for (\n let outlineIndex = inlinePos;\n outlineIndex < inlinePos + inlineSize;\n ++outlineIndex\n ) {\n startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos);\n endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize);\n }\n}\nexport interface FrameRect extends Required {\n type: any;\n}\n/**\n * @typedef\n * @memberof Grid.FrameGrid\n * @extends Grid.GridOptions\n * @property - The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @property - Make sure that the frame can be attached after the previous frame. (default: true) 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @property - 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n */\nexport interface FrameGridOptions extends GridOptions {\n frame?: number[][];\n useFrameFill?: boolean;\n rectSize?: number | { inlineSize: number, contentSize: number };\n}\n\n/**\n * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size.\n * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class FrameGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n frame: PROPERTY_TYPE.RENDER_PROPERTY,\n useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY,\n rectSize: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n frame: [],\n rectSize: 0,\n useFrameFill: true,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const frame = this._getFrame();\n const {\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n rects: frameRects,\n } = frame;\n const {\n gap,\n useFrameFill,\n } = this.options;\n\n const {\n inlineSize: rectInlineSize,\n contentSize: rectContentSize,\n } = this.getRectSize(frameInlineSize);\n\n\n const itemsLength = items.length;\n\n if (!itemsLength || !frameInlineSize || !frameContentSize) {\n return { start: outline, end: outline };\n }\n const rectsLength = frameRects.length;\n let startOutline = range(frameInlineSize).map(() => Infinity);\n let endOutline = range(frameInlineSize).map(() => -Infinity);\n const frameOutline = frame.outline.map((point) => point * (rectContentSize + gap));\n\n for (let startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) {\n // Compare group's startOutline and startOutline of rect\n const startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill);\n\n for (let rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) {\n const item = items[startIndex + rectIndex];\n const {\n contentPos: frameRectContentPos,\n inlinePos: frameRectInlinePos,\n contentSize: frameRectContentSize,\n inlineSize: frameRectInlineSize,\n } = frameRects[rectIndex];\n const contentPos = startPoint + frameRectContentPos * (rectContentSize + gap);\n const inlinePos = frameRectInlinePos * (rectInlineSize + gap);\n const contentSize = frameRectContentSize * (rectContentSize + gap) - gap;\n const inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap;\n\n fillOutlines(startOutline, endOutline, {\n inlinePos: frameRectInlinePos,\n inlineSize: frameRectInlineSize,\n contentPos: contentPos,\n contentSize: contentSize + gap,\n });\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n }\n }\n const isDirectionEnd = direction === \"end\";\n\n let gridOutline = outline;\n\n if (gridOutline.length !== frameInlineSize) {\n const point = isDirectionEnd ? Math.max(...gridOutline) : Math.min(...gridOutline);\n\n gridOutline = range(frameInlineSize).map(() => point);\n }\n startOutline = startOutline.map((point) => isFinite(point) ? point : 0);\n endOutline = endOutline.map((point) => isFinite(point) ? point : 0);\n const outlineDist = isDirectionEnd\n ? getOutlineDist(startOutline, gridOutline, useFrameFill)\n : getOutlineDist(gridOutline, endOutline, useFrameFill);\n\n items.forEach((item) => {\n item.cssContentPos += outlineDist;\n });\n\n return {\n start: startOutline.map((point) => point + outlineDist),\n end: endOutline.map((point) => point + outlineDist),\n };\n }\n protected getRectSize(frameInlineSize: number) {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption;\n }\n const rectSizeValue = rectSizeOption\n ? rectSizeOption\n : (this.getContainerInlineSize()! + gap) / frameInlineSize - gap;\n\n return { inlineSize: rectSizeValue, contentSize: rectSizeValue };\n }\n private _getFrame() {\n const frame = this.options.frame;\n const frameContentSize = frame.length;\n const frameInlineSize = frameContentSize ? frame[0].length : 0;\n const rects: FrameRect[] = [];\n const passMap: Record = {};\n const startOutline = range(frameInlineSize).map(() => Infinity);\n const endOutline = range(frameInlineSize).map(() => -Infinity);\n\n for (let y1 = 0; y1 < frameContentSize; ++y1) {\n for (let x1 = 0; x1 < frameInlineSize; ++x1) {\n const type = frame[y1][x1];\n\n if (!type) {\n continue;\n }\n if (passMap[`${y1},${x1}`]) {\n continue;\n }\n const rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize);\n\n fillOutlines(startOutline, endOutline, rect);\n rects.push(rect);\n }\n }\n rects.sort((a, b) => (a.type < b.type ? -1 : 1));\n\n\n return {\n rects,\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n outline: startOutline,\n };\n }\n private _findRect(\n passMap: Record,\n type: number,\n y1: number,\n x1: number,\n frameInlineSize: number,\n frameContentSize: number,\n ) {\n const frame = this.options.frame;\n\n let contentSize = 1;\n let inlineSize = 1;\n\n // find rect\n for (let x2 = x1; x2 < frameInlineSize; ++x2) {\n if (frame[y1][x2] === type) {\n inlineSize = x2 - x1 + 1;\n continue;\n }\n break;\n }\n for (let y2 = y1; y2 < frameContentSize; ++y2) {\n if (frame[y2][x1] === type) {\n contentSize = y2 - y1 + 1;\n continue;\n }\n break;\n }\n\n // pass rect\n for (let y = y1; y < y1 + contentSize; ++y) {\n for (let x = x1; x < x1 + inlineSize; ++x) {\n passMap[`${y},${x}`] = true;\n }\n }\n\n const rect: FrameRect = {\n type,\n inlinePos: x1,\n contentPos: y1,\n inlineSize,\n contentSize,\n };\n return rect;\n }\n}\n\nexport interface FrameGrid extends Properties {\n}\n\n\n/**\n * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 1 x 1\n * // Item 3 : 1 x 2\n * // Item 4 : 1 x 1\n * // Item 5 : 2 x 1\n * const grid = new FrameGrid(container, {\n * frame: [\n * [1, 1, 0, 0, 2, 3],\n * [1, 1, 0, 4, 5, 5],\n * ],\n * });\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 2 x 2\n * grid.frame = [\n * [1, 1, 0, 0, 2, 2],\n * [1, 1, 0, 0, 2, 2],\n * ];\n */\n\n/**\n * Make sure that the frame can be attached after the previous frame. (default: true)\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true)\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * useFrameFill: true,\n * });\n *\n * grid.useFrameFill = false;\n */\n\n/**\n * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0)\n * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n * @name Grid.FrameGrid#rectSize\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"rectSize\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * rectSize: 0,\n * });\n *\n * grid.rectSize = { inlineSize: 100, contentSize: 150 };\n */\n","export interface BoxModelStatus {\n orgInlineSize: number;\n orgContentSize: number;\n inlineSize: number;\n contentSize: number;\n inlinePos: number;\n contentPos: number;\n items: BoxModel[];\n}\n\nexport default class BoxModel implements BoxModelStatus {\n public orgInlineSize: number;\n public orgContentSize: number;\n public inlineSize: number;\n public contentSize: number;\n public inlinePos: number;\n public contentPos: number;\n public items: BoxModel[];\n constructor(status: Partial) {\n const boxStatus = {\n orgInlineSize: 0,\n orgContentSize: 0,\n inlineSize: 0,\n contentSize: 0,\n inlinePos: 0,\n contentPos: 0,\n items: [],\n ...status,\n };\n for (const name in boxStatus) {\n this[name] = boxStatus[name];\n }\n }\n public scaleTo(inlineSize: number, contentSize: number) {\n const scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0;\n const scaleY = this.contentSize ? contentSize / this.contentSize : 0;\n\n this.items.forEach((item) => {\n if (scaleX !== 0) {\n item.inlinePos *= scaleX;\n item.inlineSize *= scaleX;\n }\n if (scaleY !== 0) {\n item.contentPos *= scaleY;\n item.contentSize *= scaleY;\n }\n });\n\n this.inlineSize = inlineSize;\n this.contentSize = contentSize;\n }\n public push(item: BoxModel) {\n this.items.push(item);\n }\n public getOrgSizeWeight() {\n return this.orgInlineSize * this.orgContentSize;\n }\n public getSize() {\n return this.inlineSize * this.contentSize;\n }\n public getOrgRatio() {\n return (this.orgContentSize === 0) ? 0 : this.orgInlineSize / this.orgContentSize;\n }\n public getRatio() {\n return (this.contentSize === 0) ? 0 : this.inlineSize / this.contentSize;\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } from \"../types\";\nimport { GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\nimport BoxModel from \"./lib/BoxModel\";\n\n\nfunction getCost(originLength: number, length: number) {\n let cost = originLength / length;\n\n if (cost < 1) {\n cost = 1 / cost;\n }\n\n return cost - 1;\n}\nfunction fitArea(\n item: BoxModel,\n bestFitArea: BoxModel,\n itemFitSize: { inlineSize: number, contentSize: number },\n containerFitSize: { inlineSize: number, contentSize: number },\n isContentDirection: boolean,\n) {\n item.contentSize = itemFitSize.contentSize;\n item.inlineSize = itemFitSize.inlineSize;\n bestFitArea.contentSize = containerFitSize.contentSize;\n bestFitArea.inlineSize = containerFitSize.inlineSize;\n\n if (isContentDirection) {\n item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize;\n item.inlinePos = bestFitArea.inlinePos;\n } else {\n item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize;\n item.contentPos = bestFitArea.contentPos;\n }\n}\n\n\n/**\n * @typedef\n * @memberof Grid.PackingGrid\n * @extends Grid.GridOptions\n * @property - The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @property - The size weight when placing items. (default: 1)아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @property - The weight to keep ratio when placing items. (default: 1)아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @property - The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n */\nexport interface PackingGridOptions extends GridOptions {\n aspectRatio?: number;\n sizeWeight?: number;\n ratioWeight?: number;\n weightPriority?: \"size\" | \"ratio\" | \"custom\";\n}\n\n/**\n * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items.\n * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.\n * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible.\n * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible.\n * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.\n * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.\n * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.\n * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class PackingGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n weightPriority: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n aspectRatio: 1,\n sizeWeight: 1,\n ratioWeight: 1,\n weightPriority: \"custom\",\n };\n\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const { aspectRatio, gap } = this.options;\n const containerInlineSize = this.getContainerInlineSize();\n const containerContentSize = containerInlineSize / aspectRatio;\n const prevOutline = outline.length ? outline : [0];\n const startPoint = direction === \"end\"\n ? Math.max(...prevOutline)\n : Math.min(...prevOutline) - containerContentSize - gap;\n const endPoint = startPoint + containerContentSize + gap;\n const container = new BoxModel({});\n\n items.forEach((item) => {\n const model = new BoxModel({\n inlineSize: item.orgInlineSize,\n contentSize: item.orgContentSize,\n orgInlineSize: item.orgInlineSize,\n orgContentSize: item.orgContentSize,\n });\n\n this._findBestFitArea(container, model);\n container.push(model);\n container.scaleTo(containerInlineSize + gap, containerContentSize + gap);\n });\n items.forEach((item, i) => {\n const boxItem = container.items[i];\n const inlineSize = boxItem.inlineSize - gap;\n const contentSize = boxItem.contentSize - gap;\n const contentPos = startPoint + boxItem.contentPos;\n const inlinePos = boxItem.inlinePos;\n\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n });\n\n return {\n start: [startPoint],\n end: [endPoint],\n };\n }\n private _findBestFitArea(container: BoxModel, item: BoxModel) {\n if (container.getRatio() === 0) { // 아이템 최초 삽입시 전체영역 지정\n container.orgInlineSize = item.inlineSize;\n container.orgContentSize = item.contentSize;\n container.inlineSize = item.inlineSize;\n container.contentSize = item.contentSize;\n return;\n }\n\n let bestFitArea!: BoxModel;\n let minCost = Infinity;\n let isContentDirection = false;\n const itemFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const containerFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const sizeWeight = this._getWeight(\"size\");\n const ratioWeight = this._getWeight(\"ratio\");\n\n container.items.forEach((child) => {\n const containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight;\n const containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight;\n const inlineSize = child.inlineSize;\n const contentSize = child.contentSize;\n for (let i = 0; i < 2; ++i) {\n let itemInlineSize;\n let itemContentSize;\n let containerInlineSize;\n let containerContentSize;\n\n if (i === 0) {\n // add item to content pos (top, bottom)\n itemInlineSize = inlineSize;\n itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize));\n containerInlineSize = inlineSize;\n containerContentSize = contentSize - itemContentSize;\n } else {\n // add item to inline pos (left, right)\n itemContentSize = contentSize;\n itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize));\n containerContentSize = contentSize;\n containerInlineSize = inlineSize - itemInlineSize;\n }\n\n const itemSize = itemInlineSize * itemContentSize;\n const itemRatio = itemInlineSize / itemContentSize;\n const containerSize = containerInlineSize * containerContentSize;\n const containerRatio = containerContentSize / containerContentSize;\n\n let cost = getCost(item.getSize(), itemSize) * sizeWeight;\n cost += getCost(item.getRatio(), itemRatio) * ratioWeight;\n cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost;\n cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost;\n\n if (cost === Math.min(cost, minCost)) {\n minCost = cost;\n bestFitArea = child;\n isContentDirection = (i === 0);\n itemFitSize.inlineSize = itemInlineSize;\n itemFitSize.contentSize = itemContentSize;\n containerFitSize.inlineSize = containerInlineSize;\n containerFitSize.contentSize = containerContentSize;\n }\n }\n });\n\n fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection);\n }\n private _getWeight(type: \"size\" | \"ratio\"): number {\n const options = this.options;\n const weightPriority = options.weightPriority;\n\n if (weightPriority === type) {\n return 100;\n } else if (weightPriority === \"custom\") {\n return options[`${type}Weight`];\n }\n return 1;\n }\n}\n\nexport interface PackingGrid extends Properties {\n}\n\n\n/**\n * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1)\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * aspectRatio: 1,\n * });\n *\n * grid.aspectRatio = 1.5;\n */\n\n/**\n * The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * @ko 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n * @name Grid.PackingGrid#weightPriority\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"weightPriority\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * weightPriority: \"custom\",\n * sizeWeight: 1,\n * ratioWeight: 1,\n * });\n *\n * grid.weightPriority = \"size\";\n * // or\n * grid.weightPriority = \"ratio\";\n */\n\n/**\n * The size weight when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * sizeWeight: 1,\n * });\n *\n * grid.sizeWeight = 10;\n */\n\n\n/**\n * The weight to keep ratio when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * ratioWeight: 1,\n * });\n *\n * grid.ratioWeight = 10;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\n\nexport * from \"./grids/MasonryGrid\";\nexport * from \"./grids/JustifiedGrid\";\nexport * from \"./grids/FrameGrid\";\nexport * from \"./grids/PackingGrid\";\n\nexport * from \"./types\";\nexport * from \"./Grid\";\nexport * from \"./GridItem\";\nexport * from \"./ContainerManager\";\nexport * from \"./consts\";\nexport {\n GetterSetter,\n withGridMethods,\n withMethods,\n} from \"./utils\";\nexport default Grid;\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Grid as any)[name] = (modules as any)[name];\n}\nexport default Grid;\n"],"names":["DEFAULT_GRID_OPTIONS","horizontal","useTransform","percentage","isEqualSize","isConstantSize","gap","attributePrefix","resizeDebounce","maxResizeDebounce","autoResize","preserveUIOnDestroy","defaultDirection","externalContainerManager","externalItemRenderer","renderOnPropertyChange","useFit","PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","GRID_EVENTS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","container","options","_init","setRect","width","offsetWidth","height","offsetHeight","rect","status","setContentSize","getContentSize","size","sizeName","style","preserveUI","cssText","orgCSSText","window","getComputedStyle","position","getKeys","obj","Object","keys","isString","val","isObject","isNumber","camelize","str","replace","all","letter","toUpperCase","getDataAttributes","element","dataAttributes","attributes","length","i","attribute","name","value","indexOf","GetterSetter","component","prototype","propertyTypes","shouldRender","enumerable","configurable","get","set","prevValue","scheduleRender","defineProperty","withMethods","methods","memberName","forEach","_i","args","result","_a","range","arr","push","getRangeCost","valueRange","Math","max","withGridMethods","initialRect","items","item","_this","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","posPercetage","sizePercetage","orgRect","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","cssRect","cssTexts","_b","posName","getInlineSize","filter","key","map","join","itemStatus","data","UNCHECKED","gridRect","names","__extends","containerElement","_super","start","end","clearTimeout","_resizeTimer","_maxResizeDebounceTimer","renderItems","useResize","setTimeout","_onResize","constructor","defaultOptions","document","querySelector","containerManager","ContainerManager","itemRenderer","ItemRenderer","Grid","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","checkReady","_clearRenderTimer","getItems","syncElements","_resizeContainer","updateItems","getStatus","prevInlineSize","setStatus","_renderComplete","mounted","updated","isResize","destroy","removeEventListener","_scheduleResize","_im","moreUpdated","ImReady","prefix","on","e","readyItems","isPreReadyOver","trigger","target","update","check","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","direction","prevOutline","outline","nextOutlines","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","endPoint","startPoint","resize","setContainerRect","getRect","addEventListener","Component","getColumnPoint","columnIndex","columnCount","pointCaculationName","getColumnIndex","nearestCalculationName","indexCaculationName","points","_calculateColumnSize","_calculateColumn","column","_column","columnSize","_columnSize","align","columnSizeRatio","columnSizeOption","outlineLength","itemsLength","alignPoses","_getAlignPoses","isEndDirection","pointCalculationName","point_1","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","nextEndColumnIndex","nextColumnIndex","cssInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","floor","getContainerInlineSize","items_1","columnOption","containerSize","indexes","offset","dist","countDist","totalColumnSize","MasonryGrid","single_source_shortest_paths","graph","s","d","predecessors","costs","open","BinaryHeap","x","cost","closest","u","cost_of_s_to_u","adjacent_nodes","cost_of_e","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","first_visit","pop","v","msg","Error","extract_shortest_path_from_predecessor_list","nodes","reverse","find_path","scoreFunction","content","bubbleUp","sinkDown","_n","n","parentN","parent","elemScore","child1Score","child2N","child1N","swap","child1","child2","child2Score","splitItems","path","groups","path1","path2","getExpectedColumnSize","rowSize","orgInlineSize","orgContentSize","inlineOffset","parseFloat","gridData","contentOffset","rowRange","_getRowPath","_getPath","_setStyle","maintainedTarget","widthOffset","clientWidth","scrollWidth","heightOffset","clientHeight","scrollHeight","columnRange","_getColumnRange","_getRowRange","pathLink","_getRowLink","currentNode","node","currentLink","minColumn","minRow","maxRow","lastNode","pathLength","rangeCost","lastCost","abs","_getCost","isOver","_searchRowLink","links","nextNode","nextCost","nextLink","sort","a","b","aIsOver","bIsOver","aRangeCost","bRangeCost","containerInlineSize","ratioSum","inlineSum","maintainedRatio","reduce","sum","j","lineItems","_getExpectedRowSize","_getSizeRange","minSize","maxSize","isCroppedSize","expectedInlineSize","_getExpectedInlineSize","pow","isFinite","columnRangeOption","nodeKey","results","displayedRow","sizeRange","displayedSize","groupItems","rowIndex","allGap","scale","prevItem","setCSSGridRect","JustifiedGrid","Infinity","getMaxPoint","maxPoint","getMinPoint","minPoint","getOutlinePoint","frameOutline","useFrameFill","getOutlineDist","minEndPoint","maxStartPoint","frameDist","outlineIndex","startPos","endPos","fillOutlines","frame","_getFrame","frameInlineSize","frameContentSize","frameRects","getRectSize","rectInlineSize","rectContentSize","rectsLength","startIndex","rectIndex","_c","frameRectContentPos","frameRectInlinePos","frameRectContentSize","frameRectInlineSize","isDirectionEnd","gridOutline","outlineDist","rectSizeOption","rectSizeValue","rects","passMap","y1","x1","type","_findRect","x2","y2","y","FrameGrid","rectSize","boxStatus","scaleX","scaleY","getCost","originLength","fitArea","bestFitArea","itemFitSize","containerFitSize","isContentDirection","aspectRatio","containerContentSize","BoxModel","model","_findBestFitArea","scaleTo","boxItem","getRatio","minCost","sizeWeight","_getWeight","ratioWeight","child","containerSizeCost","getOrgSizeWeight","getSize","containerRatioCost","getOrgRatio","itemInlineSize","itemContentSize","itemSize","itemRatio","containerRatio","weightPriority","PackingGrid","modules"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOO,IAAMA,oBAAoB,GAA0B;AACzDC,EAAAA,UAAU,EAAE,KAD6C;AAEzDC,EAAAA,YAAY,EAAE,KAF2C;AAGzDC,EAAAA,UAAU,EAAE,KAH6C;AAIzDC,EAAAA,WAAW,EAAE,KAJ4C;AAKzDC,EAAAA,cAAc,EAAE,KALyC;AAMzDC,EAAAA,GAAG,EAAE,CANoD;AAOzDC,EAAAA,eAAe,EAAE,YAPwC;AAQzDC,EAAAA,cAAc,EAAE,GARyC;AASzDC,EAAAA,iBAAiB,EAAE,CATsC;AAUzDC,EAAAA,UAAU,EAAE,IAV6C;AAWzDC,EAAAA,mBAAmB,EAAE,KAXoC;AAYzDC,EAAAA,gBAAgB,EAAE,KAZuC;AAazDC,EAAAA,wBAAwB,EAAE,IAb+B;AAczDC,EAAAA,oBAAoB,EAAE,IAdmC;AAezDC,EAAAA,sBAAsB,EAAE,IAfiC;AAgBzDC,EAAAA,MAAM,EAAE;AAhBiD,CAApD;AAmBP,IAAYC,aAAZ;;AAAA,WAAYA;AACVA,EAAAA,4CAAA,aAAA;AACAA,EAAAA,mDAAA,oBAAA;AACD,CAHD,EAAYA,aAAa,KAAbA,aAAa,KAAA,CAAzB;;AAIA,IAAYC,WAAZ;;AAAA,WAAYA;AACVA,EAAAA,yCAAA,cAAA;AACAA,EAAAA,yCAAA,cAAA;AACAA,EAAAA,uCAAA,YAAA;AACD,CAJD,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;IALJ;AARHC,EAAAA,WAAW,eADvB9Z,eACY8Z,YAAA;AA+Ib,oBAAA;AAAC,EA/IgCvU,KAAjC;AAqJA;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;ACpRA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACAA;;;;;AAKA;AAEA,KAAK,IAAM1F,IAAX,IAAmBka,OAAnB,EAA4B;AACzBxU,EAAAA,IAAY,CAAC1F,IAAD,CAAZ,GAAsBka,OAAe,CAACla,IAAD,CAArC;AACF;;;;"} \ No newline at end of file diff --git a/dist/grid.esm.js b/dist/grid.esm.js new file mode 100644 index 0000000..641942b --- /dev/null +++ b/dist/grid.esm.js @@ -0,0 +1,3020 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.3.1 +*/ +import Component from '@egjs/component'; +import ImReady from '@egjs/imready'; +import { diff } from '@egjs/children-differ'; + +/*! ***************************************************************************** +Copyright (c) Microsoft Corporation. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH +REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, +INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM +LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR +OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR +PERFORMANCE OF THIS SOFTWARE. +***************************************************************************** */ + +/* global Reflect, Promise */ +var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + + return extendStatics(d, b); +}; + +function __extends(d, b) { + if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +} +var __assign = function () { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign.apply(this, arguments); +}; +function __decorate(decorators, target, key, desc) { + var c = arguments.length, + r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, + d; + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; +} +/** @deprecated */ + +function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + 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]; + + return r; +} + +var DEFAULT_GRID_OPTIONS = { + horizontal: false, + useTransform: false, + percentage: false, + isEqualSize: false, + isConstantSize: false, + gap: 0, + attributePrefix: "data-grid-", + resizeDebounce: 100, + maxResizeDebounce: 0, + autoResize: true, + preserveUIOnDestroy: false, + defaultDirection: "end", + externalContainerManager: null, + externalItemRenderer: null, + renderOnPropertyChange: true, + useFit: true +}; +var PROPERTY_TYPE; + +(function (PROPERTY_TYPE) { + PROPERTY_TYPE[PROPERTY_TYPE["PROPERTY"] = 1] = "PROPERTY"; + PROPERTY_TYPE[PROPERTY_TYPE["RENDER_PROPERTY"] = 2] = "RENDER_PROPERTY"; +})(PROPERTY_TYPE || (PROPERTY_TYPE = {})); + +var MOUNT_STATE; + +(function (MOUNT_STATE) { + MOUNT_STATE[MOUNT_STATE["UNCHECKED"] = 1] = "UNCHECKED"; + MOUNT_STATE[MOUNT_STATE["UNMOUNTED"] = 2] = "UNMOUNTED"; + MOUNT_STATE[MOUNT_STATE["MOUNTED"] = 3] = "MOUNTED"; +})(MOUNT_STATE || (MOUNT_STATE = {})); + +var UPDATE_STATE; + +(function (UPDATE_STATE) { + UPDATE_STATE[UPDATE_STATE["NEED_UPDATE"] = 1] = "NEED_UPDATE"; + UPDATE_STATE[UPDATE_STATE["WAIT_LOADING"] = 2] = "WAIT_LOADING"; + UPDATE_STATE[UPDATE_STATE["UPDATED"] = 3] = "UPDATED"; +})(UPDATE_STATE || (UPDATE_STATE = {})); + +var GRID_PROPERTY_TYPES = { + gap: PROPERTY_TYPE.RENDER_PROPERTY, + defaultDirection: PROPERTY_TYPE.PROPERTY, + renderOnPropertyChange: PROPERTY_TYPE.PROPERTY, + preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY, + useFit: PROPERTY_TYPE.PROPERTY +}; +var GRID_METHODS = ["syncElements", "updateItems", "getItems", "setItems", "renderItems", "getContainerInlineSize", "getContainerElement"]; +var GRID_EVENTS = ["renderComplete", "contentError"]; +var RECT_NAMES = { + horizontal: { + inlinePos: "top", + contentPos: "left", + inlineSize: "height", + contentSize: "width" + }, + vertical: { + inlinePos: "left", + contentPos: "top", + inlineSize: "width", + contentSize: "height" + } +}; + +var ContainerManager = +/*#__PURE__*/ +function () { + function ContainerManager(container, options) { + this.container = container; + this.options = __assign({ + horizontal: DEFAULT_GRID_OPTIONS.horizontal + }, options); + + this._init(); + } + + var __proto = ContainerManager.prototype; + + __proto.resize = function () { + var container = this.container; + this.setRect({ + width: container.offsetWidth, + height: container.offsetHeight + }); + }; + + __proto.getRect = function () { + return this.rect; + }; + + __proto.setRect = function (rect) { + this.rect = __assign({}, rect); + }; + + __proto.getInlineSize = function () { + return this.rect[this.options.horizontal ? "height" : "width"]; + }; + + __proto.getContentSize = function () { + return this.rect[this.options.horizontal ? "width" : "height"]; + }; + + __proto.getStatus = function () { + return { + rect: __assign({}, this.rect) + }; + }; + + __proto.setStatus = function (status) { + this.rect = __assign({}, status.rect); + this.setContentSize(this.getContentSize()); + }; + + __proto.setContentSize = function (size) { + var sizeName = this.options.horizontal ? "width" : "height"; + this.rect[sizeName] = size; + this.container.style[sizeName] = size + "px"; + }; + + __proto.destroy = function (options) { + if (options === void 0) { + options = {}; + } + + if (!options.preserveUI) { + this.container.style.cssText = this.orgCSSText; + } + }; + + __proto._init = function () { + var container = this.container; + var style = window.getComputedStyle(container); + this.orgCSSText = container.style.cssText; + + if (style.position === "static") { + container.style.position = "relative"; + } + }; + + return ContainerManager; +}(); + +function getKeys(obj) { + return Object.keys(obj); +} +function isString(val) { + return typeof val === "string"; +} +function isObject(val) { + return typeof val === "object"; +} +function isNumber(val) { + return typeof val === "number"; +} +function camelize(str) { + return str.replace(/[\s-_]([a-z])/g, function (all, letter) { + return letter.toUpperCase(); + }); +} +function getDataAttributes(element, attributePrefix) { + var dataAttributes = {}; + var attributes = element.attributes; + var length = attributes.length; + + for (var i = 0; i < length; ++i) { + var attribute = attributes[i]; + var name = attribute.name, + value = attribute.value; + + if (name.indexOf(attributePrefix) === -1) { + continue; + } + + dataAttributes[camelize(name.replace(attributePrefix, ""))] = value; + } + + return dataAttributes; +} +/* Class Decorator */ + +function GetterSetter(component) { + var prototype = component.prototype, + propertyTypes = component.propertyTypes; + + var _loop_1 = function (name) { + var shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY; + var attributes = { + enumerable: true, + configurable: true, + get: function () { + return this.options[name]; + }, + set: function (value) { + var options = this.options; + var prevValue = options[name]; + + if (prevValue === value) { + return; + } + + options[name] = value; + + if (shouldRender && options.renderOnPropertyChange) { + this.scheduleRender(); + } + } + }; + Object.defineProperty(prototype, name, attributes); + }; + + for (var name in propertyTypes) { + _loop_1(name); + } +} +function withMethods(methods) { + return function (prototype, memberName) { + methods.forEach(function (name) { + if (name in prototype) { + return; + } + + prototype[name] = function () { + var _a; + + var args = []; + + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + + var result = (_a = this[memberName])[name].apply(_a, args); // fix `this` type to return your own `class` instance to the instance using the decorator. + + + if (result === this[memberName]) { + return this; + } else { + return result; + } + }; + }); + }; +} +function range(length) { + var arr = []; + + for (var i = 0; i < length; ++i) { + arr.push(i); + } + + return arr; +} +function getRangeCost(value, valueRange) { + return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1; +} +/** + * Decorator that makes the method of grid available in the framework. + * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터. + * @memberof eg.Grid + * @private + * @example + * ```js + * import { withGridMethods } from "@egjs/grid"; + * + * class Grid extends React.Component> { + * @withGridMethods + * private grid: NativeGrid; + * } + * ``` + */ + +var withGridMethods = withMethods(GRID_METHODS); + +var ItemRenderer = +/*#__PURE__*/ +function () { + function ItemRenderer(options) { + this.initialRect = null; + this.sizePercetage = false; + this.posPercetage = false; + this.options = __assign({ + attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix, + useTransform: DEFAULT_GRID_OPTIONS.useTransform, + horizontal: DEFAULT_GRID_OPTIONS.horizontal, + percentage: DEFAULT_GRID_OPTIONS.percentage, + isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize, + isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize + }, options); + + this._init(); + } + + var __proto = ItemRenderer.prototype; + + __proto.resize = function () { + this.initialRect = null; + }; + + __proto.renderItems = function (items) { + var _this = this; + + items.forEach(function (item) { + _this._renderItem(item); + }); + }; + + __proto.getInlineSize = function () { + return this.containerRect[this.options.horizontal ? "height" : "width"]; + }; + + __proto.setContainerRect = function (rect) { + this.containerRect = rect; + }; + + __proto.updateItems = function (items) { + var _this = this; + + items.forEach(function (item) { + _this._updateItem(item); + }); + }; + + __proto.getStatus = function () { + return { + initialRect: this.initialRect + }; + }; + + __proto.setStatus = function (status) { + this.initialRect = status.initialRect; + }; + + __proto._init = function () { + var percentage = this.options.percentage; + var sizePercentage = false; + var posPercentage = false; + + if (percentage === true) { + sizePercentage = true; + posPercentage = true; + } else if (percentage) { + if (percentage.indexOf("position") > -1) { + posPercentage = true; + } + + if (percentage.indexOf("size") > -1) { + sizePercentage = true; + } + } + + this.posPercetage = posPercentage; + this.sizePercetage = sizePercentage; + }; + + __proto._updateItem = function (item) { + var _a = this.options, + isEqualSize = _a.isEqualSize, + isConstantSize = _a.isConstantSize; + var initialRect = this.initialRect; + var orgRect = item.orgRect, + element = item.element; + var isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING; + var hasOrgSize = orgRect && orgRect.width && orgRect.height; + var rect; + + if (isEqualSize && initialRect) { + rect = initialRect; + } else if (isConstantSize && hasOrgSize && !isLoading) { + rect = orgRect; + } else if (!element) { + return; + } else { + rect = { + left: element.offsetLeft, + top: element.offsetTop, + width: element.offsetWidth, + height: element.offsetHeight + }; + } + + if (!item.isFirstUpdate) { + item.orgRect = __assign({}, rect); + } + + item.rect = __assign({}, rect); + + if (item.element) { + item.mountState = MOUNT_STATE.MOUNTED; + } + + if (item.updateState === UPDATE_STATE.NEED_UPDATE) { + item.updateState = UPDATE_STATE.UPDATED; + item.isFirstUpdate = true; + } + + item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {}; + + if (!isLoading) { + this.initialRect = __assign({}, rect); + } + + return rect; + }; + + __proto._renderItem = function (item) { + var element = item.element; + var cssRect = item.cssRect; + + if (!element || !cssRect) { + return; + } + + var _a = this.options, + horizontal = _a.horizontal, + useTransform = _a.useTransform; + var posPercentage = this.posPercetage; + var sizePercentage = this.sizePercetage; + var cssTexts = ["position: absolute;"]; + var _b = RECT_NAMES[horizontal ? "horizontal" : "vertical"], + sizeName = _b.inlineSize, + posName = _b.inlinePos; + var inlineSize = this.getInlineSize(); + var keys = getKeys(cssRect); + + if (useTransform) { + keys = keys.filter(function (key) { + return key !== "top" && key !== "left"; + }); + cssTexts.push("transform: " + ("translate(" + (cssRect.left || 0) + "px, " + (cssRect.top || 0) + "px);")); + } + + cssTexts.push.apply(cssTexts, keys.map(function (name) { + var value = cssRect[name]; + + if (name === sizeName && sizePercentage || name === posName && posPercentage) { + return name + ": " + value / inlineSize * 100 + "%;"; + } + + return name + ": " + value + "px;"; + })); + element.style.cssText += cssTexts.join(""); + }; + + return ItemRenderer; +}(); + +/** + * @memberof Grid + * @implements Grid.GridItem.GridItemStatus + */ + +var GridItem = +/*#__PURE__*/ +function () { + /** + * @constructor + * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향) + * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체. + */ + function GridItem(horizontal, itemStatus) { + if (itemStatus === void 0) { + itemStatus = {}; + } + + var _a; + + this.horizontal = horizontal; + /** + * Grid ready data for rendering + * @ko 렌더링을 하기 위한 grid의 준비 데이타 + * @member Grid.GridItem#gridData + */ + + this.gridData = {}; + var element = itemStatus.element; + + var status = __assign({ + key: "", + orgRect: { + left: 0, + top: 0, + width: 0, + height: 0 + }, + rect: { + left: 0, + top: 0, + width: 0, + height: 0 + }, + cssRect: {}, + attributes: {}, + data: {}, + isFirstUpdate: false, + mountState: MOUNT_STATE.UNCHECKED, + updateState: UPDATE_STATE.NEED_UPDATE, + element: element || null, + orgCSSText: (_a = element === null || element === void 0 ? void 0 : element.style.cssText) !== null && _a !== void 0 ? _a : "" + }, itemStatus); + + for (var name in status) { + this[name] = status[name]; + } + } + + var __proto = GridItem.prototype; + Object.defineProperty(__proto, "orgInlineSize", { + /** + * The size in inline direction before first rendering. "width" if horizontal is false, "height" otherwise. + * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#orgInlineSize + */ + get: function () { + var orgRect = this.orgRect || this.rect; + return this.horizontal ? orgRect.height : orgRect.width; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "orgContentSize", { + /** + * The size in content direction before first rendering. "height" if horizontal is false, "width" otherwise. + * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#orgContentSize + */ + get: function () { + var orgRect = this.orgRect || this.rect; + return this.horizontal ? orgRect.width : orgRect.height; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "inlineSize", { + /** + * The size in inline direction. "width" if horizontal is false, "height" otherwise. + * @ko inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#inlineSize + */ + get: function () { + var rect = this.rect; + return this.horizontal ? rect.height : rect.width; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "contentSize", { + /** + * The size in content direction. "height" if horizontal is false, "width" otherwise. + * @ko content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#contentSize + */ + get: function () { + var rect = this.rect; + return this.horizontal ? rect.width : rect.height; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssInlineSize", { + /** + * The CSS size in inline direction applied to the Grid. "width" if horizontal is false, "height" otherwise. + * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#cssInlineSize + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.height : cssRect.width; + }, + set: function (inlineSize) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "height" : "width"] = inlineSize; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssContentSize", { + /** + * The CSS size in content direction applied to the Grid. "height" if horizontal is false, "width" otherwise. + * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#cssContentSize + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.width : cssRect.height; + }, + set: function (contentSize) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "width" : "height"] = contentSize; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssInlinePos", { + /** + * The CSS pos in inline direction applied to the Grid. "left" if horizontal is false, "top" otherwise. + * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 "left", 아니면 "top". + * @member Grid.GridItem#cssInlinePos + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.top : cssRect.left; + }, + set: function (inlinePos) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "top" : "left"] = inlinePos; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssContentPos", { + /** + * The CSS pos in content direction applied to the Grid. "top" if horizontal is false, "left" otherwise. + * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 "top", 아니면 "left". + * @member Grid.GridItem#cssContentPos + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.left : cssRect.top; + }, + set: function (contentPos) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "left" : "top"] = contentPos; + }, + enumerable: false, + configurable: true + }); + /** + * Set CSS Rect through GridRect. + * @ko GridRect을 통해 CSS Rect를 설정한다. + * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일. + */ + + __proto.setCSSGridRect = function (gridRect) { + var names = RECT_NAMES[this.horizontal ? "horizontal" : "vertical"]; + var rect = {}; + + for (var name in gridRect) { + rect[names[name]] = gridRect[name]; + } + + this.cssRect = rect; + }; + /** + * Returns the status of the item. + * @ko 아이템의 상태를 반환한다. + */ + + + __proto.getStatus = function () { + return { + mountState: this.mountState, + updateState: this.updateState, + attributes: this.attributes, + orgCSSText: this.orgCSSText, + isFirstUpdate: this.isFirstUpdate, + element: null, + key: this.key, + orgRect: this.orgRect, + rect: this.rect, + cssRect: this.cssRect, + data: this.data + }; + }; + + return GridItem; +}(); + +/** + * @extends eg.Component + */ + +var Grid = +/*#__PURE__*/ +function (_super) { + __extends(Grid, _super); + /** + * @param - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param - The option object of the Grid module Grid 모듈의 옵션 객체 + */ + + + function Grid(containerElement, options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.items = []; + _this.outlines = { + start: [], + end: [] + }; + _this._renderTimer = 0; + _this._resizeTimer = 0; + _this._maxResizeDebounceTimer = 0; + + _this._onResize = function () { + clearTimeout(_this._resizeTimer); + clearTimeout(_this._maxResizeDebounceTimer); + _this._maxResizeDebounceTimer = 0; + _this._resizeTimer = 0; + + _this.renderItems({ + useResize: true + }); + }; + + _this._scheduleResize = function () { + var _a = _this.options, + resizeDebounce = _a.resizeDebounce, + maxResizeDebounce = _a.maxResizeDebounce; + + if (!_this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) { + _this._maxResizeDebounceTimer = window.setTimeout(_this._onResize, maxResizeDebounce); + } + + if (_this._resizeTimer) { + clearTimeout(_this._resizeTimer); + _this._resizeTimer = 0; + } + + _this._resizeTimer = window.setTimeout(_this._onResize, resizeDebounce); + }; + + _this.options = __assign(__assign({}, _this.constructor.defaultOptions), options); + _this.containerElement = isString(containerElement) ? document.querySelector(containerElement) : containerElement; + var _a = _this.options, + isEqualSize = _a.isEqualSize, + isConstantSize = _a.isConstantSize, + useTransform = _a.useTransform, + horizontal = _a.horizontal, + percentage = _a.percentage, + externalContainerManager = _a.externalContainerManager, + externalItemRenderer = _a.externalItemRenderer; // TODO: 테스트용 설정 + + _this.containerManager = externalContainerManager || new ContainerManager(_this.containerElement, { + horizontal: horizontal + }); + _this.itemRenderer = externalItemRenderer || new ItemRenderer({ + useTransform: useTransform, + isEqualSize: isEqualSize, + isConstantSize: isConstantSize, + percentage: percentage + }); + + _this._init(); + + return _this; + } + + var __proto = Grid.prototype; + Grid_1 = Grid; + /** + * Return Container Element. + * @ko 컨테이너 엘리먼트를 반환한다. + */ + + __proto.getContainerElement = function () { + return this.containerElement; + }; + /** + * Return items. + * @ko 아이템들을 반환한다. + */ + + + __proto.getItems = function () { + return this.items; + }; + /** + * Returns the children of the container element. + * @ko 컨테이너 엘리먼트의 children을 반환한다. + */ + + + __proto.getChildren = function () { + return [].slice.call(this.containerElement.children); + }; + /** + * Set items. + * @ko 아이템들을 설정한다. + * @param items - The items to set. 설정할 아이템들 + */ + + + __proto.setItems = function (items) { + this.items = items; + return this; + }; + /** + * Gets the container's inline size. ("width" if horizontal is false, otherwise "height") + * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 "width", 아니면 "height") + */ + + + __proto.getContainerInlineSize = function () { + return this.containerManager.getInlineSize(); + }; + /** + * Returns the outlines of the start and end of the Grid. + * @ko Grid의 처음과 끝의 outline을 반환한다. + */ + + + __proto.getOutlines = function () { + return this.outlines; + }; + /** + * Set outlines. + * @ko 아웃라인을 설정한다. + * @param outlines - The outlines to set. 설정할 아웃라인. + */ + + + __proto.setOutlines = function (outlines) { + this.outlines = outlines; + return this; + }; + /** + * When elements change, it synchronizes and renders items. + * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + */ + + + __proto.syncElements = function (options) { + if (options === void 0) { + options = {}; + } + + var items = this.items; + var horizontal = this.options.horizontal; + var elements = this.getChildren(); + + var _a = diff(this.items.map(function (item) { + return item.element; + }), elements), + added = _a.added, + maintained = _a.maintained, + changed = _a.changed, + removed = _a.removed; + + var nextItems = []; + maintained.forEach(function (_a) { + var beforeIndex = _a[0], + afterIndex = _a[1]; + nextItems[afterIndex] = items[beforeIndex]; + }); + added.forEach(function (index) { + nextItems[index] = new GridItem(horizontal, { + element: elements[index] + }); + }); + this.setItems(nextItems); + + if (added.length || removed.length || changed.length) { + this.renderItems(options); + } + + return this; + }; + /** + * Update the size of the items and render them. + * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다. + * @param - Items to be updated. 업데이트할 아이템들. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + */ + + + __proto.updateItems = function (items, options) { + if (items === void 0) { + items = this.items; + } + + if (options === void 0) { + options = {}; + } + + items.forEach(function (item) { + item.updateState = UPDATE_STATE.NEED_UPDATE; + }); + this.checkReady(options); + return this; + }; + /** + * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired. + * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + * @example + * import { MasonryGrid } from "@egjs/grid"; + * const grid = new MasonryGrid(); + * + * grid.on("renderComplete", e => { + * console.log(e); + * }); + * grid.renderItems(); + */ + + + __proto.renderItems = function (options) { + if (options === void 0) { + options = {}; + } + + this._clearRenderTimer(); + + if (!this.getItems().length && this.getChildren().length) { + this.syncElements(options); + } else if (options.useResize) { + // Resize container and Update all items + this._resizeContainer(); + + this.updateItems(this.items, options); + } else { + // Update only items that need to be updated. + this.checkReady(options); + } + + return this; + }; + /** + * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method. + * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + */ + + + __proto.getStatus = function () { + return { + outlines: this.outlines, + items: this.items.map(function (item) { + return item.getStatus(); + }), + containerManager: this.containerManager.getStatus(), + itemRenderer: this.itemRenderer.getStatus() + }; + }; + /** + * Set status of the Grid module with the status returned through a call to the getStatus() method. + * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다. + */ + + + __proto.setStatus = function (status) { + var _this = this; + + var horizontal = this.options.horizontal; + var containerManager = this.containerManager; + var prevInlineSize = containerManager.getInlineSize(); + var children = this.getChildren(); + this.itemRenderer.setStatus(status.itemRenderer); + containerManager.setStatus(status.containerManager); + this.outlines = status.outlines; + this.items = status.items.map(function (item, i) { + return new GridItem(horizontal, __assign(__assign({}, item), { + element: children[i] + })); + }); + this.itemRenderer.renderItems(this.items); + + if (prevInlineSize !== containerManager.getInlineSize()) { + this.renderItems({ + useResize: true + }); + } else { + window.setTimeout(function () { + _this._renderComplete({ + mounted: _this.items, + updated: [], + isResize: false + }); + }); + } + + return this; + }; + /** + * Releases the instnace and events and returns the CSS of the container and elements. + * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + * @param Options for destroy. destory()를 위한 옵션 + */ + + + __proto.destroy = function (options) { + var _a; + + if (options === void 0) { + options = {}; + } + + var _b = options.preserveUI, + preserveUI = _b === void 0 ? this.options.preserveUIOnDestroy : _b; + this.containerManager.destroy({ + preserveUI: preserveUI + }); + + if (!preserveUI) { + this.items.forEach(function (_a) { + var element = _a.element, + orgCSSText = _a.orgCSSText; + + if (element) { + element.style.cssText = orgCSSText; + } + }); + } + + window.removeEventListener("resize", this._scheduleResize); + (_a = this._im) === null || _a === void 0 ? void 0 : _a.destroy(); + }; + + __proto.checkReady = function (options) { + var _this = this; + + var _a; + + if (options === void 0) { + options = {}; + } // Grid: renderItems => checkReady => readyItems => applyGrid + + + var items = this.items; + var updated = items.filter(function (item) { + return item.element && item.updateState !== UPDATE_STATE.UPDATED; + }); + var mounted = updated.filter(function (item) { + return item.mountState !== MOUNT_STATE.MOUNTED; + }); + var moreUpdated = []; + (_a = this._im) === null || _a === void 0 ? void 0 : _a.destroy(); + this._im = new ImReady({ + prefix: this.options.attributePrefix + }).on("preReadyElement", function (e) { + updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING; + }).on("preReady", function () { + _this.itemRenderer.updateItems(updated); + + _this.readyItems(mounted, updated, options); + }).on("readyElement", function (e) { + var item = updated[e.index]; + item.updateState = UPDATE_STATE.NEED_UPDATE; // after preReady + + if (e.isPreReadyOver) { + item.element.style.cssText = item.orgCSSText; + + _this.itemRenderer.updateItems([item]); + + _this.readyItems([], [item], options); + } + }).on("error", function (e) { + var item = items[e.index]; + /** + * This event is fired when an error occurs in the content. + * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트. + * @event Grid#contentError + * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트. + * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트. + * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템 + * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라. + * @example + grid.on("contentError", e => { + e.update(); + }); + */ + + _this.trigger("contentError", { + element: e.element, + target: e.target, + item: item, + update: function () { + moreUpdated.push(item); + } + }); + }).on("ready", function () { + if (moreUpdated.length) { + _this.updateItems(moreUpdated); + } + }).check(updated.map(function (item) { + return item.element; + })); + }; + + __proto.scheduleRender = function () { + var _this = this; + + this._clearRenderTimer(); + + this._renderTimer = window.setTimeout(function () { + _this.renderItems(); + }); + }; + + __proto.fitOutlines = function (useFit) { + if (useFit === void 0) { + useFit = this.useFit; + } + + var outlines = this.outlines; + var startOutline = outlines.start; + var endOutline = outlines.end; + var outlineOffset = startOutline.length ? Math.min.apply(Math, startOutline) : 0; // If the outline is less than 0, a fit occurs forcibly. + + if (!useFit && outlineOffset > 0) { + return; + } + + outlines.start = startOutline.map(function (point) { + return point - outlineOffset; + }); + outlines.end = endOutline.map(function (point) { + return point - outlineOffset; + }); + this.items.forEach(function (item) { + var contentPos = item.cssContentPos; + + if (!isNumber(contentPos)) { + return; + } + + item.cssContentPos = contentPos - outlineOffset; + }); + }; + + __proto.readyItems = function (mounted, updated, options) { + var prevOutlines = this.outlines; + var direction = options.direction || this.options.defaultDirection; + var prevOutline = options.outline || prevOutlines[direction === "end" ? "start" : "end"]; + var items = this.items; + var nextOutlines = { + start: __spreadArrays(prevOutline), + end: __spreadArrays(prevOutline) + }; + + if (items.length) { + nextOutlines = this.applyGrid(this.items, direction, prevOutline); + } + + this.setOutlines(nextOutlines); + this.fitOutlines(); + this.itemRenderer.renderItems(this.items); + + this._refreshContainerContentSize(); + + this._renderComplete({ + mounted: mounted, + updated: updated, + isResize: !!options.useResize + }); + }; + + __proto._renderComplete = function (e) { + /** + * This event is fired when the Grid has completed rendering. + * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다. + * @event Grid#renderComplete + * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들 + * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들. + * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부. + * @example + grid.on("renderComplete", e => { + console.log(e.mounted, e.updated, e.useResize); + }); + */ + this.trigger("renderComplete", e); + }; + + __proto._clearRenderTimer = function () { + clearTimeout(this._renderTimer); + this._renderTimer = 0; + }; + + __proto._refreshContainerContentSize = function () { + var _a = this.outlines, + startOutline = _a.start, + endOutline = _a.end; + var gap = this.options.gap; + var endPoint = endOutline.length ? Math.max.apply(Math, endOutline) : 0; + var startPoint = startOutline.length ? Math.max.apply(Math, startOutline) : 0; + var contentSize = Math.max(startPoint, endPoint - gap); + this.containerManager.setContentSize(contentSize); + }; + + __proto._resizeContainer = function () { + this.containerManager.resize(); + this.itemRenderer.setContainerRect(this.containerManager.getRect()); + }; + + __proto._init = function () { + this._resizeContainer(); + + if (this.options.autoResize) { + window.addEventListener("resize", this._scheduleResize); + } + }; + + var Grid_1; + Grid.defaultOptions = DEFAULT_GRID_OPTIONS; + Grid.propertyTypes = GRID_PROPERTY_TYPES; + Grid = Grid_1 = __decorate([GetterSetter], Grid); + return Grid; +}(Component); +/** + * Gap used to create space around items. + * @ko 아이템들 사이의 공간. + * @name Grid#gap + * @type {$ts:Grid.GridOptions["gap"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * gap: 0, + * }); + * + * grid.gap = 5; + */ + +/** + * The default direction value when direction is not set in the render option. + * @ko render옵션에서 direction을 미설정시의 기본 방향값. + * @name Grid#defaultDirection + * @type {$ts:Grid.GridOptions["defaultDirection"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * defaultDirection: "end", + * }); + * + * grid.defaultDirection = "start"; + */ + +/** + * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true) + * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true) + * @name Grid#useFit + * @type {$ts:Grid.GridOptions["useFit"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * useFit: true, + * }); + * + * grid.useFit = false; + +/** + * Whether to preserve the UI of the existing container or item when destroying. + * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부. + * @name Grid#preserveUIOnDestroy + * @type {$ts:Grid.GridOptions["preserveUIOnDestroy"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * preserveUIOnDestroy: false, + * }); + * + * grid.preserveUIOnDestroy = true; + */ + +function getColumnPoint(outline, columnIndex, columnCount, pointCaculationName) { + return Math[pointCaculationName].apply(Math, outline.slice(columnIndex, columnIndex + columnCount)); +} + +function getColumnIndex(outline, columnCount, nearestCalculationName) { + var length = outline.length - columnCount + 1; + var pointCaculationName = nearestCalculationName === "max" ? "min" : "max"; + var indexCaculationName = nearestCalculationName === "max" ? "lastIndexOf" : "indexOf"; + var points = range(length).map(function (index) { + return getColumnPoint(outline, index, columnCount, pointCaculationName); + }); + return points[indexCaculationName](Math[nearestCalculationName].apply(Math, points)); +} +/** + * MasonryGrid 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. + * + * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체 + */ + + +var MasonryGrid = +/*#__PURE__*/ +function (_super) { + __extends(MasonryGrid, _super); + + function MasonryGrid() { + var _this = _super !== null && _super.apply(this, arguments) || this; + + _this._columnSize = 0; + _this._column = 1; + return _this; + } + + var __proto = MasonryGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + this._calculateColumnSize(items); + + this._calculateColumn(items); + + var column = this._column; + var columnSize = this._columnSize; + var _a = this.options, + gap = _a.gap, + align = _a.align, + columnSizeRatio = _a.columnSizeRatio, + columnSizeOption = _a.columnSize; + var outlineLength = outline.length; + var itemsLength = items.length; + + var alignPoses = this._getAlignPoses(); + + var isEndDirection = direction === "end"; + var nearestCalculationName = isEndDirection ? "min" : "max"; + var pointCalculationName = isEndDirection ? "max" : "min"; + var startOutline = [0]; + + if (outlineLength === column) { + startOutline = outline.slice(); + } else { + var point_1 = outlineLength ? Math[nearestCalculationName].apply(Math, outline) : 0; + startOutline = range(column).map(function () { + return point_1; + }); + } + + var endOutline = startOutline.slice(); + var columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0; + var isStretch = align === "stretch"; + + var _loop_1 = function (i) { + var item = items[isEndDirection ? i : itemsLength - 1 - i]; + var columnAttribute = parseInt(item.attributes.column || "1", 10); + var maxColumnAttribute = parseInt(item.attributes.maxColumn || "1", 10); + var inlineSize = item.inlineSize; + var contentSize = item.contentSize; + var columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist))); + var maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute)); + var columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName); + var contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName); + + while (columnCount < maxColumnCount) { + var nextEndColumnIndex = columnIndex + columnCount; + var nextColumnIndex = columnIndex - 1; + + if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) { + break; + } + + if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) { + break; + } + + if (!isEndDirection) { + --columnIndex; + } + + ++columnCount; + } + + columnIndex = Math.max(0, columnIndex); + columnCount = Math.min(column - columnIndex, columnCount); + + if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) { + inlineSize = (columnCount - 1) * columnDist + columnSize; + item.cssInlineSize = inlineSize; + } + + if (columnSizeRatio > 0) { + contentSize = inlineSize / columnSizeRatio; + item.cssContentSize = contentSize; + } + + var inlinePos = alignPoses[columnIndex]; + contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize; + item.cssInlinePos = inlinePos; + item.cssContentPos = contentPos; + var nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos; + range(columnCount).forEach(function (indexOffset) { + endOutline[columnIndex + indexOffset] = nextOutlinePoint; + }); + }; + + for (var i = 0; i < itemsLength; ++i) { + _loop_1(i); + } // if end items, startOutline is low, endOutline is high + // if start items, startOutline is high, endOutline is low + + + return { + start: isEndDirection ? startOutline : endOutline, + end: isEndDirection ? endOutline : startOutline + }; + }; + + __proto._calculateColumnSize = function (items) { + var _a = this.options, + columnSizeOption = _a.columnSize, + gap = _a.gap, + align = _a.align; + + if (align === "stretch") { + var column = this.column; + + if (columnSizeOption) { + column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap))); + } + + this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap; + } else if (columnSizeOption) { + this._columnSize = columnSizeOption; + } else { + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var item = items_1[_i]; + var attributes = item.attributes; + + if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) { + continue; + } + + var inlineSize = item.inlineSize; + this._columnSize = inlineSize; + return inlineSize; + } + + this._columnSize = this._columnSize || 0; + } + + return this._columnSize; + }; + + __proto._calculateColumn = function (items) { + var _a = this.options, + gap = _a.gap, + columnOption = _a.column; + var columnSize = this._columnSize; + var column = 1; + + if (columnOption) { + column = columnOption; + } else if (!columnSize) { + column = 1; + } else { + column = Math.min(items.length, Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap)))); + } + + this._column = column; + return column; + }; + + __proto._getAlignPoses = function () { + var columnSize = this._columnSize; + var column = this._column; + var _a = this.options, + align = _a.align, + gap = _a.gap; + var containerSize = this.getContainerInlineSize(); + var indexes = range(column); + var offset = 0; + var dist = 0; + + if (align === "justify" || align === "stretch") { + var countDist = column - 1; + dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0; + offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2); + } else { + dist = columnSize + gap; + var totalColumnSize = (column - 1) * dist + columnSize; + + if (align === "center") { + offset = (containerSize - totalColumnSize) / 2; + } else if (align === "end") { + offset = containerSize - totalColumnSize; + } + } + + return indexes.map(function (i) { + return offset + i * dist; + }); + }; + + MasonryGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + column: PROPERTY_TYPE.RENDER_PROPERTY, + columnSize: PROPERTY_TYPE.RENDER_PROPERTY, + columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY, + align: PROPERTY_TYPE.RENDER_PROPERTY + }); + MasonryGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + align: "justify", + column: 0, + columnSize: 0, + columnSizeRatio: 0 + }); + MasonryGrid = __decorate([GetterSetter], MasonryGrid); + return MasonryGrid; +}(Grid); +/** + * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. ("start", "center", "end", "justify", "stretch") (default: "justify") + * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. ("start", "center", "end", "justify", "stretch") (default: "justify") + * @name Grid.MasonryGrid#align + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["align"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * align: "start", + * }); + * + * grid.align = "justify"; + */ + +/** + * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. + * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) + * @name Grid.MasonryGrid#column + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["column"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * column: 0, + * }); + * + * grid.column = 4; + */ + +/** + * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) + * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) + * @name Grid.MasonryGrid#columnSize + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSize"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * columnSize: 0, + * }); + * + * grid.columnSize = 200; + */ + +/** + * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) + * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. + * @name Grid.MasonryGrid#columnSizeRatio + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSizeRatio"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * columnSizeRatio: 0, + * }); + * + * grid.columnSizeRatio = 0.5; + */ + +/* eslint-disable */ + +/****************************************************************************** + * Created 2008-08-19. + * + * Dijkstra path-finding functions. Adapted from the Dijkstar Python project. + * + * Copyright (C) 2008 + * Wyatt Baldwin + * All rights reserved + * + * Licensed under the MIT license. + * + * http://www.opensource.org/licenses/mit-license.php + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *****************************************************************************/ +function single_source_shortest_paths(graph, s, d) { + // Predecessor map for each node that has been encountered. + // node ID => predecessor node ID + var predecessors = {}; // Costs of shortest paths from s to all nodes encountered. + // node ID => cost + + var costs = {}; + costs[s] = 0; // Costs of shortest paths from s to all nodes encountered; differs from + // `costs` in that it provides easy access to the node that currently has + // the known shortest path from s. + // XXX: Do we actually need both `costs` and `open`? + + var open = new BinaryHeap(function (x) { + return x.cost; + }); + open.push({ + value: s, + cost: 0 + }); + var closest; + var u; + var cost_of_s_to_u; + var adjacent_nodes; + var cost_of_e; + var cost_of_s_to_u_plus_cost_of_e; + var cost_of_s_to_v; + var first_visit; + + while (open.size()) { + // In the nodes remaining in graph that have a known cost from s, + // find the node, u, that currently has the shortest path from s. + closest = open.pop(); + u = closest.value; + cost_of_s_to_u = closest.cost; // Get nodes adjacent to u... + + adjacent_nodes = graph(u) || {}; // ...and explore the edges that connect u to those nodes, updating + // the cost of the shortest paths to any or all of those nodes as + // necessary. v is the node across the current edge from u. + + for (var v in adjacent_nodes) { + // Get the cost of the edge running from u to v. + cost_of_e = adjacent_nodes[v]; // Cost of s to u plus the cost of u to v across e--this is *a* + // cost from s to v that may or may not be less than the current + // known cost to v. + + cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; // If we haven't visited v yet OR if the current known cost from s to + // v is greater than the new cost we just found (cost of s to u plus + // cost of u to v across e), update v's cost in the cost list and + // update v's predecessor in the predecessor list (it's now u). + + cost_of_s_to_v = costs[v]; + first_visit = typeof costs[v] === "undefined"; + + if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { + costs[v] = cost_of_s_to_u_plus_cost_of_e; + open.push({ + value: v, + cost: cost_of_s_to_u_plus_cost_of_e + }); + predecessors[v] = u; + } + } + } + + if (typeof costs[d] === "undefined") { + var msg = ["Could not find a path from ", s, " to ", d, "."].join(""); + throw new Error(msg); + } + + return predecessors; +} + +function extract_shortest_path_from_predecessor_list(predecessors, d) { + var nodes = []; + var u = d; + + while (u) { + nodes.push(u); + u = predecessors[u]; + } + + nodes.reverse(); + return nodes; +} + +function find_path(graph, s, d) { + var predecessors = single_source_shortest_paths(graph, s, d); + return extract_shortest_path_from_predecessor_list(predecessors, d); +} + +var BinaryHeap = +/*#__PURE__*/ +function () { + function BinaryHeap(scoreFunction) { + this.content = []; + this.scoreFunction = scoreFunction; + } + + var __proto = BinaryHeap.prototype; + + __proto.push = function (element) { + // Add the new element to the end of the array. + this.content.push(element); // Allow it to bubble up. + + this.bubbleUp(this.content.length - 1); + }; + + __proto.pop = function () { + // Store the first element so we can return it later. + var result = this.content[0]; // Get the element at the end of the array. + + var end = this.content.pop(); // If there are any elements left, put the end element at the + // start, and let it sink down. + + if (this.content.length > 0) { + this.content[0] = end; + this.sinkDown(0); + } + + return result; + }; + + __proto.size = function () { + return this.content.length; + }; + + __proto.bubbleUp = function (_n) { + var n = _n; // Fetch the element that has to be moved. + + var element = this.content[n]; // When at 0, an element can not go up any further. + + while (n > 0) { + // Compute the parent element's index, and fetch it. + var parentN = Math.floor((n + 1) / 2) - 1; + var parent = this.content[parentN]; // Swap the elements if the parent is greater. + + if (this.scoreFunction(element) < this.scoreFunction(parent)) { + this.content[parentN] = element; + this.content[n] = parent; // Update 'n' to continue at the new position. + + n = parentN; + } else { + // Found a parent that is less, no need to move it further. + break; + } + } + }; + + __proto.sinkDown = function (n) { + // Look up the target element and its score. + var length = this.content.length; + var element = this.content[n]; + var elemScore = this.scoreFunction(element); + var child1Score; + + while (true) { + // Compute the indices of the child elements. + var child2N = (n + 1) * 2; + var child1N = child2N - 1; // This is used to store the new position of the element, + // if any. + + var swap = null; // If the first child exists (is inside the array)... + + if (child1N < length) { + // Look it up and compute its score. + var child1 = this.content[child1N]; + child1Score = this.scoreFunction(child1); // If the score is less than our element's, we need to swap. + + if (child1Score < elemScore) { + swap = child1N; + } + } // Do the same checks for the other child. + + + if (child2N < length) { + var child2 = this.content[child2N]; + var child2Score = this.scoreFunction(child2); + + if (child2Score < (swap == null ? elemScore : child1Score)) { + swap = child2N; + } + } // If the element needs to be moved, swap it, and continue. + + + if (swap !== null) { + this.content[n] = this.content[swap]; + this.content[swap] = element; + n = swap; + } else { + // Otherwise, we are done. + break; + } + } + }; + + return BinaryHeap; +}(); + +function splitItems(items, path) { + var length = path.length; + var groups = []; + + for (var i = 0; i < length - 1; ++i) { + var path1 = parseInt(path[i], 10); + var path2 = parseInt(path[i + 1], 10); + groups.push(items.slice(path1, path2)); + } + + return groups; +} + +function getExpectedColumnSize(item, rowSize) { + var inlineSize = item.orgInlineSize; + var contentSize = item.orgContentSize; + + if (!inlineSize || !contentSize) { + return 0; + } + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset; +} +/** + * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size. + * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value. + * 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. + * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다. + * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다. + * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체 + */ + + +var JustifiedGrid = +/*#__PURE__*/ +function (_super) { + __extends(JustifiedGrid, _super); + + function JustifiedGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = JustifiedGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var rowRange = this.options.rowRange; + var path = []; + + if (items.length) { + path = rowRange ? this._getRowPath(items) : this._getPath(items); + } + + return this._setStyle(items, path, outline, direction === "end"); + }; + + __proto.readyItems = function (mounted, updated, options) { + var _a = this.options, + attributePrefix = _a.attributePrefix, + horizontal = _a.horizontal; + updated.forEach(function (item) { + var element = item.element; + var attributes = item.attributes; + var gridData = item.gridData; + var inlineOffset = parseFloat(attributes.inlineOffset) || 0; + var contentOffset = parseFloat(attributes.contentOffset) || 0; + + if (element && !("inlineOffset" in attributes) && !("contentOffset" in attributes)) { + var maintainedTarget = element.querySelector("[" + attributePrefix + "maintained-target]"); + + if (maintainedTarget) { + var widthOffset = element.offsetWidth - element.clientWidth + element.scrollWidth - maintainedTarget.clientWidth; + var heightOffset = element.offsetHeight - element.clientHeight + element.scrollHeight - maintainedTarget.clientHeight; + + if (horizontal) { + inlineOffset = heightOffset; + contentOffset = widthOffset; + } else { + inlineOffset = widthOffset; + contentOffset = heightOffset; + } + } + } + + gridData.inlineOffset = inlineOffset; + gridData.contentOffset = contentOffset; + }); + + _super.prototype.readyItems.call(this, mounted, updated, options); + }; + + __proto._getRowPath = function (items) { + var _a; + + var columnRange = this._getColumnRange(); + + var rowRange = this._getRowRange(); + + var pathLink = this._getRowLink(items, { + path: [0], + cost: 0, + length: 0, + currentNode: 0 + }, columnRange, rowRange); + + return (_a = pathLink === null || pathLink === void 0 ? void 0 : pathLink.path.map(function (node) { + return "" + node; + })) !== null && _a !== void 0 ? _a : []; + }; + + __proto._getRowLink = function (items, currentLink, columnRange, rowRange) { + var minColumn = columnRange[0]; + var minRow = rowRange[0], + maxRow = rowRange[1]; + var lastNode = items.length; + var path = currentLink.path, + pathLength = currentLink.length, + cost = currentLink.cost, + currentNode = currentLink.currentNode; // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn. + + if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) { + var rangeCost = getRangeCost(lastNode - currentNode, columnRange); + var lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode)); + return __assign(__assign({}, currentLink), { + length: pathLength + 1, + path: __spreadArrays(path, [lastNode]), + currentNode: lastNode, + cost: cost + lastCost, + isOver: true + }); + } else if (currentNode >= lastNode) { + return __assign(__assign({}, currentLink), { + currentNode: lastNode, + isOver: minRow > pathLength || maxRow < pathLength + }); + } else { + return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange); + } + }; + + __proto._searchRowLink = function (items, currentLink, lastNode, columnRange, rowRange) { + var minColumn = columnRange[0], + maxColumn = columnRange[1]; + var currentNode = currentLink.currentNode, + path = currentLink.path, + pathLength = currentLink.length, + cost = currentLink.cost; + var length = Math.min(lastNode, currentNode + maxColumn); + var links = []; + + for (var nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) { + if (nextNode === currentNode) { + continue; + } + + var nextCost = Math.abs(this._getCost(items, currentNode, nextNode)); + + var nextLink = this._getRowLink(items, { + path: __spreadArrays(path, [nextNode]), + length: pathLength + 1, + cost: cost + nextCost, + currentNode: nextNode + }, columnRange, rowRange); + + if (nextLink) { + links.push(nextLink); + } + } + + links.sort(function (a, b) { + var aIsOver = a.isOver; + var bIsOver = b.isOver; + + if (aIsOver !== bIsOver) { + // If it is over, the cost is high. + return aIsOver ? 1 : -1; + } + + var aRangeCost = getRangeCost(a.length, rowRange); + var bRangeCost = getRangeCost(b.length, rowRange); + return aRangeCost - bRangeCost || a.cost - b.cost; + }); // It returns the lowest cost link. + + return links[0]; + }; + + __proto._getExpectedRowSize = function (items) { + var gap = this.options.gap; + var containerInlineSize = this.getContainerInlineSize() - gap * (items.length - 1); + var ratioSum = 0; + var inlineSum = 0; + items.forEach(function (item) { + var inlineSize = item.orgInlineSize; + var contentSize = item.orgContentSize; + + if (!inlineSize || !contentSize) { + return; + } // sum((expect - offset) * ratio) = container inline size + + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset); + ratioSum += maintainedRatio; + inlineSum += contentOffset * maintainedRatio; + containerInlineSize -= inlineOffset; + }); + return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0; + }; + + __proto._getExpectedInlineSize = function (items, rowSize) { + var gap = this.options.gap; + var size = items.reduce(function (sum, item) { + return sum + getExpectedColumnSize(item, rowSize); + }, 0); + return size ? size + gap * (items.length - 1) : 0; + }; + + __proto._getCost = function (items, i, j) { + var lineItems = items.slice(i, j); + + var rowSize = this._getExpectedRowSize(lineItems); + + var _a = this._getSizeRange(), + minSize = _a[0], + maxSize = _a[1]; + + if (this.isCroppedSize) { + if (minSize <= rowSize && rowSize <= maxSize) { + return 0; + } + + var expectedInlineSize = this._getExpectedInlineSize(lineItems, rowSize < minSize ? minSize : maxSize); + + return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2); + } + + if (isFinite(maxSize)) { + // if this size is not in range, the cost increases sharply. + if (rowSize < minSize) { + return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2); + } else if (rowSize > maxSize) { + return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2); + } + } else if (rowSize < minSize) { + return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2); + } // if this size in range, the cost is row + + + return rowSize - minSize; + }; + + __proto._getPath = function (items) { + var _this = this; + + var lastNode = items.length; + var columnRangeOption = this.options.columnRange; + + var _a = isObject(columnRangeOption) ? columnRangeOption : [columnRangeOption, columnRangeOption], + minColumn = _a[0], + maxColumn = _a[1]; + + var graph = function (nodeKey) { + var results = {}; + var currentNode = parseInt(nodeKey, 10); + + for (var nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) { + if (nextNode - currentNode > maxColumn) { + break; + } + + var cost = _this._getCost(items, currentNode, nextNode); + + if (cost < 0 && nextNode === lastNode) { + cost = 0; + } + + results["" + nextNode] = Math.pow(cost, 2); + } + + return results; + }; // shortest path for items' total height. + + + return find_path(graph, "0", "" + lastNode); + }; + + __proto._setStyle = function (items, path, outline, isEndDirection) { + var _this = this; + + if (outline === void 0) { + outline = []; + } + + var _a = this.options, + gap = _a.gap, + isCroppedSize = _a.isCroppedSize, + displayedRow = _a.displayedRow; + + var sizeRange = this._getSizeRange(); + + var startPoint = outline[0] || 0; + var containerInlineSize = this.getContainerInlineSize(); + var groups = splitItems(items, path); + var contentPos = startPoint; + var displayedSize = 0; + groups.forEach(function (groupItems, rowIndex) { + var length = groupItems.length; + + var rowSize = _this._getExpectedRowSize(groupItems); + + if (isCroppedSize) { + rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1])); + } + + var expectedInlineSize = _this._getExpectedInlineSize(groupItems, rowSize); + + var allGap = gap * (length - 1); + var scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap); + groupItems.forEach(function (item, i) { + var columnSize = getExpectedColumnSize(item, rowSize); + var prevItem = groupItems[i - 1]; + var inlinePos = prevItem ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap : 0; + + if (isCroppedSize) { + columnSize *= scale; + } + + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: columnSize, + contentSize: rowSize + }); + }); + contentPos += gap + rowSize; + + if (displayedRow < 0 || rowIndex < displayedRow) { + displayedSize = contentPos; + } + }); + + if (isEndDirection) { + // previous group's end outline is current group's start outline + return { + start: [startPoint], + end: [displayedSize] + }; + } // always start is lower than end. + // contentPos is endPoinnt + + + var height = contentPos - startPoint; + items.forEach(function (item) { + item.cssContentPos -= height; + }); + return { + start: [startPoint - height], + end: [startPoint] + }; + }; + + __proto._getRowRange = function () { + var rowRange = this.rowRange; + return isObject(rowRange) ? rowRange : [rowRange, rowRange]; + }; + + __proto._getColumnRange = function () { + var columnRange = this.columnRange; + return isObject(columnRange) ? columnRange : [columnRange, columnRange]; + }; + + __proto._getSizeRange = function () { + var sizeRange = this.sizeRange; + return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange]; + }; + + JustifiedGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + columnRange: PROPERTY_TYPE.RENDER_PROPERTY, + rowRange: PROPERTY_TYPE.RENDER_PROPERTY, + sizeRange: PROPERTY_TYPE.RENDER_PROPERTY, + isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY, + displayedRow: PROPERTY_TYPE.RENDER_PROPERTY + }); + JustifiedGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + columnRange: [1, 8], + rowRange: 0, + sizeRange: [0, Infinity], + displayedRow: -1, + isCroppedSize: false + }); + JustifiedGrid = __decorate([GetterSetter], JustifiedGrid); + return JustifiedGrid; +}(Grid); +/** + * The minimum and maximum number of items per line. (default: [1, 8]) + * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) + * @name Grid.JustifiedGrid#columnRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["columnRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * columnRange: [1, 8], + * }); + * + * grid.columnRange = [3, 6]; + */ + +/** + * The minimum and maximum number of rows in a group, 0 is not set. (default: 0) + * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) + * @name Grid.JustifiedGrid#rowRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["rowRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * rowRange: 0, + * }); + * + * grid.rowRange = [3, 4]; + */ + +/** + * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) + * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity]) + * @name Grid.JustifiedGrid#sizeRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["sizeRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * sizeRange: [0, Infinity], + * }); + * + * grid.sizeRange = [200, 800]; + */ + +/** + * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1) + * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1) + * @name Grid.JustifiedGrid#displayedRow + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["displayedRow"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * displayedRow: -1, + * }); + * + * grid.displayedRow = 3; + */ + +/** + * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) + * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false) + * @name Grid.JustifiedGrid#isCroppedSize + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["isCroppedSize"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * sizeRange: [200, 250], + * isCroppedSize: false, + * }); + * + * grid.isCroppedSize = true; + */ + +function getMaxPoint(outline) { + var maxPoint = -Infinity; + outline.forEach(function (point) { + if (isFinite(point)) { + maxPoint = Math.max(maxPoint, point); + } + }); + return isFinite(maxPoint) ? maxPoint : 0; +} + +function getMinPoint(outline) { + var minPoint = Infinity; + outline.forEach(function (point) { + if (isFinite(point)) { + minPoint = Math.min(minPoint, point); + } + }); + return isFinite(minPoint) ? minPoint : 0; +} + +function getOutlinePoint(startOutline, frameOutline, useFrameFill) { + return getMaxPoint(startOutline) + getOutlineDist(startOutline, frameOutline, useFrameFill); +} + +function getOutlineDist(startOutline, endOutline, useFrameFill) { + var length = startOutline.length; + + if (!length) { + return 0; + } + + var minEndPoint = getMinPoint(endOutline); + var maxStartPoint = getMaxPoint(startOutline); + var frameDist = 0; + + if (!useFrameFill) { + return 0; + } + + for (var outlineIndex = 0; outlineIndex < length; ++outlineIndex) { + var startPoint = startOutline[outlineIndex]; + var endPoint = endOutline[outlineIndex]; + + if (!isFinite(startPoint) || !isFinite(endPoint)) { + continue; + } + + var startPos = startPoint - maxStartPoint; + var endPos = endPoint - minEndPoint; // Fill empty block. + + frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos; + } + + return frameDist; +} + +function fillOutlines(startOutline, endOutline, rect) { + var inlinePos = rect.inlinePos, + inlineSize = rect.inlineSize, + contentPos = rect.contentPos, + contentSize = rect.contentSize; + + for (var outlineIndex = inlinePos; outlineIndex < inlinePos + inlineSize; ++outlineIndex) { + startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos); + endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize); + } +} +/** + * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size. + * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체 + */ + + +var FrameGrid = +/*#__PURE__*/ +function (_super) { + __extends(FrameGrid, _super); + + function FrameGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = FrameGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var frame = this._getFrame(); + + var frameInlineSize = frame.inlineSize, + frameContentSize = frame.contentSize, + frameRects = frame.rects; + var _a = this.options, + gap = _a.gap, + useFrameFill = _a.useFrameFill; + + var _b = this.getRectSize(frameInlineSize), + rectInlineSize = _b.inlineSize, + rectContentSize = _b.contentSize; + + var itemsLength = items.length; + + if (!itemsLength || !frameInlineSize || !frameContentSize) { + return { + start: outline, + end: outline + }; + } + + var rectsLength = frameRects.length; + var startOutline = range(frameInlineSize).map(function () { + return Infinity; + }); + var endOutline = range(frameInlineSize).map(function () { + return -Infinity; + }); + var frameOutline = frame.outline.map(function (point) { + return point * (rectContentSize + gap); + }); + + for (var startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) { + // Compare group's startOutline and startOutline of rect + var startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill); + + for (var rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) { + var item = items[startIndex + rectIndex]; + var _c = frameRects[rectIndex], + frameRectContentPos = _c.contentPos, + frameRectInlinePos = _c.inlinePos, + frameRectContentSize = _c.contentSize, + frameRectInlineSize = _c.inlineSize; + var contentPos = startPoint + frameRectContentPos * (rectContentSize + gap); + var inlinePos = frameRectInlinePos * (rectInlineSize + gap); + var contentSize = frameRectContentSize * (rectContentSize + gap) - gap; + var inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap; + fillOutlines(startOutline, endOutline, { + inlinePos: frameRectInlinePos, + inlineSize: frameRectInlineSize, + contentPos: contentPos, + contentSize: contentSize + gap + }); + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: inlineSize, + contentSize: contentSize + }); + } + } + + var isDirectionEnd = direction === "end"; + var gridOutline = outline; + + if (gridOutline.length !== frameInlineSize) { + var point_1 = isDirectionEnd ? Math.max.apply(Math, gridOutline) : Math.min.apply(Math, gridOutline); + gridOutline = range(frameInlineSize).map(function () { + return point_1; + }); + } + + startOutline = startOutline.map(function (point) { + return isFinite(point) ? point : 0; + }); + endOutline = endOutline.map(function (point) { + return isFinite(point) ? point : 0; + }); + var outlineDist = isDirectionEnd ? getOutlineDist(startOutline, gridOutline, useFrameFill) : getOutlineDist(gridOutline, endOutline, useFrameFill); + items.forEach(function (item) { + item.cssContentPos += outlineDist; + }); + return { + start: startOutline.map(function (point) { + return point + outlineDist; + }), + end: endOutline.map(function (point) { + return point + outlineDist; + }) + }; + }; + + __proto.getRectSize = function (frameInlineSize) { + var _a = this.options, + gap = _a.gap, + rectSizeOption = _a.rectSize; + + if (typeof rectSizeOption === "object") { + return rectSizeOption; + } + + var rectSizeValue = rectSizeOption ? rectSizeOption : (this.getContainerInlineSize() + gap) / frameInlineSize - gap; + return { + inlineSize: rectSizeValue, + contentSize: rectSizeValue + }; + }; + + __proto._getFrame = function () { + var frame = this.options.frame; + var frameContentSize = frame.length; + var frameInlineSize = frameContentSize ? frame[0].length : 0; + var rects = []; + var passMap = {}; + var startOutline = range(frameInlineSize).map(function () { + return Infinity; + }); + var endOutline = range(frameInlineSize).map(function () { + return -Infinity; + }); + + for (var y1 = 0; y1 < frameContentSize; ++y1) { + for (var x1 = 0; x1 < frameInlineSize; ++x1) { + var type = frame[y1][x1]; + + if (!type) { + continue; + } + + if (passMap[y1 + "," + x1]) { + continue; + } + + var rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize); + + fillOutlines(startOutline, endOutline, rect); + rects.push(rect); + } + } + + rects.sort(function (a, b) { + return a.type < b.type ? -1 : 1; + }); + return { + rects: rects, + inlineSize: frameInlineSize, + contentSize: frameContentSize, + outline: startOutline + }; + }; + + __proto._findRect = function (passMap, type, y1, x1, frameInlineSize, frameContentSize) { + var frame = this.options.frame; + var contentSize = 1; + var inlineSize = 1; // find rect + + for (var x2 = x1; x2 < frameInlineSize; ++x2) { + if (frame[y1][x2] === type) { + inlineSize = x2 - x1 + 1; + continue; + } + + break; + } + + for (var y2 = y1; y2 < frameContentSize; ++y2) { + if (frame[y2][x1] === type) { + contentSize = y2 - y1 + 1; + continue; + } + + break; + } // pass rect + + + for (var y = y1; y < y1 + contentSize; ++y) { + for (var x = x1; x < x1 + inlineSize; ++x) { + passMap[y + "," + x] = true; + } + } + + var rect = { + type: type, + inlinePos: x1, + contentPos: y1, + inlineSize: inlineSize, + contentSize: contentSize + }; + return rect; + }; + + FrameGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + frame: PROPERTY_TYPE.RENDER_PROPERTY, + useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY, + rectSize: PROPERTY_TYPE.RENDER_PROPERTY + }); + FrameGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + frame: [], + rectSize: 0, + useFrameFill: true + }); + FrameGrid = __decorate([GetterSetter], FrameGrid); + return FrameGrid; +}(Grid); +/** + * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: []) + * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: []) + * @name Grid.FrameGrid#frame + * @type {$ts:Grid.FrameGrid.FrameGridOptions["frame"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * // Item 1 : 2 x 2 + * // Item 2 : 1 x 1 + * // Item 3 : 1 x 2 + * // Item 4 : 1 x 1 + * // Item 5 : 2 x 1 + * const grid = new FrameGrid(container, { + * frame: [ + * [1, 1, 0, 0, 2, 3], + * [1, 1, 0, 4, 5, 5], + * ], + * }); + * + * // Item 1 : 2 x 2 + * // Item 2 : 2 x 2 + * grid.frame = [ + * [1, 1, 0, 0, 2, 2], + * [1, 1, 0, 0, 2, 2], + * ]; + */ + +/** + * Make sure that the frame can be attached after the previous frame. (default: true) + * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true) + * @name Grid.FrameGrid#useFrameFill + * @type {$ts:Grid.FrameGrid.FrameGridOptions["useFrameFill"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * const grid = new FrameGrid(container, { + * useFrameFill: true, + * }); + * + * grid.useFrameFill = false; + */ + +/** + * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) + * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0) + * @name Grid.FrameGrid#rectSize + * @type {$ts:Grid.FrameGrid.FrameGridOptions["rectSize"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * const grid = new FrameGrid(container, { + * rectSize: 0, + * }); + * + * grid.rectSize = { inlineSize: 100, contentSize: 150 }; + */ + +var BoxModel = +/*#__PURE__*/ +function () { + function BoxModel(status) { + var boxStatus = __assign({ + orgInlineSize: 0, + orgContentSize: 0, + inlineSize: 0, + contentSize: 0, + inlinePos: 0, + contentPos: 0, + items: [] + }, status); + + for (var name in boxStatus) { + this[name] = boxStatus[name]; + } + } + + var __proto = BoxModel.prototype; + + __proto.scaleTo = function (inlineSize, contentSize) { + var scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0; + var scaleY = this.contentSize ? contentSize / this.contentSize : 0; + this.items.forEach(function (item) { + if (scaleX !== 0) { + item.inlinePos *= scaleX; + item.inlineSize *= scaleX; + } + + if (scaleY !== 0) { + item.contentPos *= scaleY; + item.contentSize *= scaleY; + } + }); + this.inlineSize = inlineSize; + this.contentSize = contentSize; + }; + + __proto.push = function (item) { + this.items.push(item); + }; + + __proto.getOrgSizeWeight = function () { + return this.orgInlineSize * this.orgContentSize; + }; + + __proto.getSize = function () { + return this.inlineSize * this.contentSize; + }; + + __proto.getOrgRatio = function () { + return this.orgContentSize === 0 ? 0 : this.orgInlineSize / this.orgContentSize; + }; + + __proto.getRatio = function () { + return this.contentSize === 0 ? 0 : this.inlineSize / this.contentSize; + }; + + return BoxModel; +}(); + +function getCost(originLength, length) { + var cost = originLength / length; + + if (cost < 1) { + cost = 1 / cost; + } + + return cost - 1; +} + +function fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection) { + item.contentSize = itemFitSize.contentSize; + item.inlineSize = itemFitSize.inlineSize; + bestFitArea.contentSize = containerFitSize.contentSize; + bestFitArea.inlineSize = containerFitSize.inlineSize; + + if (isContentDirection) { + item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize; + item.inlinePos = bestFitArea.inlinePos; + } else { + item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize; + item.contentPos = bestFitArea.contentPos; + } +} +/** + * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items. + * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion. + * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible. + * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible. + * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다. + * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다. + * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다. + * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체 + */ + + +var PackingGrid = +/*#__PURE__*/ +function (_super) { + __extends(PackingGrid, _super); + + function PackingGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = PackingGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var _this = this; + + var _a = this.options, + aspectRatio = _a.aspectRatio, + gap = _a.gap; + var containerInlineSize = this.getContainerInlineSize(); + var containerContentSize = containerInlineSize / aspectRatio; + var prevOutline = outline.length ? outline : [0]; + var startPoint = direction === "end" ? Math.max.apply(Math, prevOutline) : Math.min.apply(Math, prevOutline) - containerContentSize - gap; + var endPoint = startPoint + containerContentSize + gap; + var container = new BoxModel({}); + items.forEach(function (item) { + var model = new BoxModel({ + inlineSize: item.orgInlineSize, + contentSize: item.orgContentSize, + orgInlineSize: item.orgInlineSize, + orgContentSize: item.orgContentSize + }); + + _this._findBestFitArea(container, model); + + container.push(model); + container.scaleTo(containerInlineSize + gap, containerContentSize + gap); + }); + items.forEach(function (item, i) { + var boxItem = container.items[i]; + var inlineSize = boxItem.inlineSize - gap; + var contentSize = boxItem.contentSize - gap; + var contentPos = startPoint + boxItem.contentPos; + var inlinePos = boxItem.inlinePos; + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: inlineSize, + contentSize: contentSize + }); + }); + return { + start: [startPoint], + end: [endPoint] + }; + }; + + __proto._findBestFitArea = function (container, item) { + if (container.getRatio() === 0) { + // 아이템 최초 삽입시 전체영역 지정 + container.orgInlineSize = item.inlineSize; + container.orgContentSize = item.contentSize; + container.inlineSize = item.inlineSize; + container.contentSize = item.contentSize; + return; + } + + var bestFitArea; + var minCost = Infinity; + var isContentDirection = false; + var itemFitSize = { + inlineSize: 0, + contentSize: 0 + }; + var containerFitSize = { + inlineSize: 0, + contentSize: 0 + }; + + var sizeWeight = this._getWeight("size"); + + var ratioWeight = this._getWeight("ratio"); + + container.items.forEach(function (child) { + var containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight; + var containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight; + var inlineSize = child.inlineSize; + var contentSize = child.contentSize; + + for (var i = 0; i < 2; ++i) { + var itemInlineSize = void 0; + var itemContentSize = void 0; + var containerInlineSize = void 0; + var containerContentSize = void 0; + + if (i === 0) { + // add item to content pos (top, bottom) + itemInlineSize = inlineSize; + itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize)); + containerInlineSize = inlineSize; + containerContentSize = contentSize - itemContentSize; + } else { + // add item to inline pos (left, right) + itemContentSize = contentSize; + itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize)); + containerContentSize = contentSize; + containerInlineSize = inlineSize - itemInlineSize; + } + + var itemSize = itemInlineSize * itemContentSize; + var itemRatio = itemInlineSize / itemContentSize; + var containerSize = containerInlineSize * containerContentSize; + var containerRatio = containerContentSize / containerContentSize; + var cost = getCost(item.getSize(), itemSize) * sizeWeight; + cost += getCost(item.getRatio(), itemRatio) * ratioWeight; + cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost; + cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost; + + if (cost === Math.min(cost, minCost)) { + minCost = cost; + bestFitArea = child; + isContentDirection = i === 0; + itemFitSize.inlineSize = itemInlineSize; + itemFitSize.contentSize = itemContentSize; + containerFitSize.inlineSize = containerInlineSize; + containerFitSize.contentSize = containerContentSize; + } + } + }); + fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection); + }; + + __proto._getWeight = function (type) { + var options = this.options; + var weightPriority = options.weightPriority; + + if (weightPriority === type) { + return 100; + } else if (weightPriority === "custom") { + return options[type + "Weight"]; + } + + return 1; + }; + + PackingGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY, + sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY, + ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY, + weightPriority: PROPERTY_TYPE.RENDER_PROPERTY + }); + PackingGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + aspectRatio: 1, + sizeWeight: 1, + ratioWeight: 1, + weightPriority: "custom" + }); + PackingGrid = __decorate([GetterSetter], PackingGrid); + return PackingGrid; +}(Grid); +/** + * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) + * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1) + * @name Grid.PackingGrid#aspectRatio + * @type {$ts:Grid.PackingGrid.PackingGridOptions["aspectRatio"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * aspectRatio: 1, + * }); + * + * grid.aspectRatio = 1.5; + */ + +/** + * The priority that determines the weight of the item. (default: "custom"), "size" = (sizeWieght: 2, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 2), "custom" = (set sizeWeight, ratioWeight) + * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`. + * @ko 아이템의 가중치를 결정하는 우선수치. (default: "custom"), "size" = (sizeWieght: 2, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 2), "custom" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`. + * @name Grid.PackingGrid#weightPriority + * @type {$ts:Grid.PackingGrid.PackingGridOptions["weightPriority"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * weightPriority: "custom", + * sizeWeight: 1, + * ratioWeight: 1, + * }); + * + * grid.weightPriority = "size"; + * // or + * grid.weightPriority = "ratio"; + */ + +/** + * The size weight when placing items. (default: 1) + * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1) + * @name Grid.PackingGrid#sizeWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["sizeWeight"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * sizeWeight: 1, + * }); + * + * grid.sizeWeight = 10; + */ + +/** + * The weight to keep ratio when placing items. (default: 1) + * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1) + * @name Grid.PackingGrid#ratioWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["ratioWeight"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * ratioWeight: 1, + * }); + * + * grid.ratioWeight = 10; + */ + +/** + * egjs-grid + * Copyright (c) 2021-present NAVER Corp. + * MIT license + */ + +export default Grid; +export { ContainerManager, DEFAULT_GRID_OPTIONS, FrameGrid, GRID_EVENTS, GRID_METHODS, GRID_PROPERTY_TYPES, GetterSetter, GridItem, JustifiedGrid, MOUNT_STATE, MasonryGrid, PROPERTY_TYPE, PackingGrid, RECT_NAMES, UPDATE_STATE, withGridMethods, withMethods }; +//# sourceMappingURL=grid.esm.js.map diff --git a/dist/grid.esm.js.map b/dist/grid.esm.js.map new file mode 100644 index 0000000..93b945d --- /dev/null +++ b/dist/grid.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.esm.js","sources":["../src/consts.ts","../src/ContainerManager.ts","../src/utils.ts","../src/ItemRenderer.ts","../src/GridItem.ts","../src/Grid.ts","../src/grids/MasonryGrid.ts","../src/grids/lib/dijkstra.ts","../src/grids/JustifiedGrid.ts","../src/grids/FrameGrid.ts","../src/grids/lib/BoxModel.ts","../src/grids/PackingGrid.ts","../src/index.ts"],"sourcesContent":["/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { GridOptions } from \"./types\";\n\nexport const DEFAULT_GRID_OPTIONS: Required = {\n horizontal: false,\n useTransform: false,\n percentage: false,\n isEqualSize: false,\n isConstantSize: false,\n gap: 0,\n attributePrefix: \"data-grid-\",\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n autoResize: true,\n preserveUIOnDestroy: false,\n defaultDirection: \"end\",\n externalContainerManager: null,\n externalItemRenderer: null,\n renderOnPropertyChange: true,\n useFit: true,\n};\n\nexport enum PROPERTY_TYPE {\n PROPERTY = 1,\n RENDER_PROPERTY = 2,\n}\nexport enum MOUNT_STATE {\n UNCHECKED = 1,\n UNMOUNTED = 2,\n MOUNTED = 3,\n}\nexport enum UPDATE_STATE {\n NEED_UPDATE = 1,\n WAIT_LOADING = 2,\n UPDATED = 3,\n}\n\nexport const GRID_PROPERTY_TYPES = {\n gap: PROPERTY_TYPE.RENDER_PROPERTY,\n defaultDirection: PROPERTY_TYPE.PROPERTY,\n renderOnPropertyChange: PROPERTY_TYPE.PROPERTY,\n preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY,\n useFit: PROPERTY_TYPE.PROPERTY,\n};\n\nexport const GRID_METHODS = [\n \"syncElements\",\n \"updateItems\",\n \"getItems\",\n \"setItems\",\n \"renderItems\",\n \"getContainerInlineSize\",\n \"getContainerElement\",\n] as const;\n\nexport const GRID_EVENTS = [\n \"renderComplete\",\n \"contentError\",\n] as const;\n\nexport const RECT_NAMES = {\n horizontal: {\n inlinePos: \"top\",\n contentPos: \"left\",\n inlineSize: \"height\",\n contentSize: \"width\",\n },\n vertical: {\n inlinePos: \"left\",\n contentPos: \"top\",\n inlineSize: \"width\",\n contentSize: \"height\",\n },\n} as const;\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DestroyOptions } from \".\";\nimport { DEFAULT_GRID_OPTIONS } from \"./consts\";\nimport { DOMRect } from \"./types\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: DOMRect;\n}\n\nexport class ContainerManager {\n protected options: Required;\n protected rect: DOMRect;\n protected orgCSSText: string;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.offsetWidth,\n height: container.offsetHeight,\n });\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: DOMRect) {\n this.rect = { ...rect };\n }\n public getInlineSize() {\n return this.rect[this.options.horizontal ? \"height\" : \"width\"];\n }\n public getContentSize() {\n return this.rect[this.options.horizontal ? \"width\" : \"height\"]!;\n }\n public getStatus() {\n return {\n rect: { ...this.rect },\n };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.rect = { ...status.rect };\n\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.rect[sizeName] = size;\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n if (!options.preserveUI) {\n this.container.style.cssText = this.orgCSSText;\n }\n }\n private _init() {\n const container = this.container;\n const style = window.getComputedStyle(container);\n\n this.orgCSSText = container.style.cssText;\n\n if (style.position === \"static\") {\n container.style.position = \"relative\";\n }\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\nimport { GRID_METHODS, GRID_PROPERTY_TYPES, PROPERTY_TYPE } from \"./consts\";\n\nexport function getKeys>(obj: T): Array {\n return Object.keys(obj);\n}\n\nexport function isString(val: any): val is string {\n return typeof val === \"string\";\n}\nexport function isObject(val: any): val is object {\n return typeof val === \"object\";\n}\nexport function isNumber(val: any): val is number {\n return typeof val === \"number\";\n}\n\nexport function camelize(str: string) {\n return str.replace(/[\\s-_]([a-z])/g, (all, letter) => letter.toUpperCase());\n}\n\nexport function getDataAttributes(element: HTMLElement, attributePrefix: string) {\n const dataAttributes: Record = {};\n const attributes = element.attributes;\n const length = attributes.length;\n\n for (let i = 0; i < length; ++i) {\n const attribute = attributes[i];\n const { name, value } = attribute;\n if (name.indexOf(attributePrefix) === -1) {\n continue;\n }\n dataAttributes[camelize(name.replace(attributePrefix, \"\"))] = value;\n }\n\n return dataAttributes;\n}\n\n/* Class Decorator */\nexport function GetterSetter(component: {\n prototype: Grid,\n propertyTypes: typeof GRID_PROPERTY_TYPES,\n}) {\n const {\n prototype,\n propertyTypes,\n } = component;\n for (const name in propertyTypes) {\n const shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY;\n const attributes: Record = {\n enumerable: true,\n configurable: true,\n get(this: Grid) {\n return this.options[name];\n },\n set(this: Grid, value: any) {\n const options = this.options;\n const prevValue = options[name];\n\n if (prevValue === value) {\n return;\n }\n options[name] = value;\n\n if (shouldRender && options.renderOnPropertyChange) {\n this.scheduleRender();\n }\n },\n };\n Object.defineProperty(prototype, name, attributes);\n }\n}\n\nexport function withMethods(methods: readonly string[]) {\n return function (prototype: any, memberName: string) {\n methods.forEach((name: string) => {\n if (name in prototype) {\n return;\n }\n prototype[name] = function (...args) {\n const result = this[memberName][name](...args);\n\n // fix `this` type to return your own `class` instance to the instance using the decorator.\n if (result === this[memberName]) {\n return this;\n } else {\n return result;\n }\n };\n });\n };\n}\n\nexport function range(length: number): number[] {\n const arr: number[] = [];\n for (let i = 0; i < length; ++i) {\n arr.push(i);\n }\n return arr;\n}\n\nexport function getRangeCost(value: number, valueRange: number[]) {\n return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1;\n}\n\n/**\n * Decorator that makes the method of grid available in the framework.\n * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터.\n * @memberof eg.Grid\n * @private\n * @example\n * ```js\n * import { withGridMethods } from \"@egjs/grid\";\n *\n * class Grid extends React.Component> {\n * @withGridMethods\n * private grid: NativeGrid;\n * }\n * ```\n */\nexport const withGridMethods = withMethods(GRID_METHODS);\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DEFAULT_GRID_OPTIONS, MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\nimport { GridItem } from \"./GridItem\";\nimport { DOMRect } from \"./types\";\nimport { getDataAttributes, getKeys } from \"./utils\";\n\nexport interface ItemRendererOptions {\n attributePrefix?: string;\n useTransform?: boolean;\n horizontal?: boolean;\n percentage?: Array<\"position\" | \"size\"> | boolean;\n isEqualSize?: boolean;\n isConstantSize?: boolean;\n}\nexport interface ItemRendererStatus {\n initialRect: Required | null;\n}\n\nexport class ItemRenderer {\n protected options: Required;\n protected containerRect: DOMRect;\n protected initialRect: Required | null = null;\n protected sizePercetage = false;\n protected posPercetage = false;\n\n constructor(options: ItemRendererOptions) {\n this.options = {\n attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix,\n useTransform: DEFAULT_GRID_OPTIONS.useTransform,\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n percentage: DEFAULT_GRID_OPTIONS.percentage,\n isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize,\n isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize,\n ...options,\n };\n this._init();\n }\n public resize() {\n this.initialRect = null;\n }\n public renderItems(items: GridItem[]) {\n items.forEach((item) => {\n this._renderItem(item);\n });\n }\n public getInlineSize() {\n return this.containerRect[this.options.horizontal ? \"height\" : \"width\"]!;\n }\n public setContainerRect(rect: DOMRect) {\n this.containerRect = rect;\n }\n public updateItems(items: GridItem[]) {\n items.forEach((item) => {\n this._updateItem(item);\n });\n }\n public getStatus(): ItemRendererStatus {\n return {\n initialRect: this.initialRect,\n };\n }\n public setStatus(status: ItemRendererStatus) {\n this.initialRect = status.initialRect;\n }\n private _init() {\n const { percentage } = this.options;\n\n let sizePercentage = false;\n let posPercentage = false;\n\n if (percentage === true) {\n sizePercentage = true;\n posPercentage = true;\n } else if (percentage) {\n if (percentage.indexOf(\"position\") > -1) {\n posPercentage = true;\n }\n if (percentage.indexOf(\"size\") > -1) {\n sizePercentage = true;\n }\n }\n\n this.posPercetage = posPercentage;\n this.sizePercetage = sizePercentage;\n }\n private _updateItem(item: GridItem) {\n const { isEqualSize, isConstantSize } = this.options;\n const initialRect = this.initialRect;\n const { orgRect, element } = item;\n const isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING;\n const hasOrgSize = orgRect && orgRect.width && orgRect.height;\n let rect: Required;\n\n if (isEqualSize && initialRect) {\n rect = initialRect;\n } else if (isConstantSize && hasOrgSize && !isLoading) {\n rect = orgRect;\n } else if (!element) {\n return;\n } else {\n rect = {\n left: element.offsetLeft,\n top: element.offsetTop,\n width: element.offsetWidth,\n height: element.offsetHeight,\n };\n }\n if (!item.isFirstUpdate) {\n item.orgRect = { ...rect };\n }\n item.rect = { ...rect };\n\n if (item.element) {\n item.mountState = MOUNT_STATE.MOUNTED;\n }\n\n if (item.updateState === UPDATE_STATE.NEED_UPDATE) {\n item.updateState = UPDATE_STATE.UPDATED;\n item.isFirstUpdate = true;\n }\n item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {};\n\n if (!isLoading) {\n this.initialRect = { ...rect };\n }\n\n return rect;\n }\n private _renderItem(item: GridItem) {\n const element = item.element;\n const cssRect = item.cssRect;\n\n if (!element || !cssRect) {\n return;\n }\n\n const {\n horizontal,\n useTransform,\n } = this.options;\n const posPercentage = this.posPercetage;\n const sizePercentage = this.sizePercetage;\n const cssTexts: string[] = [\"position: absolute;\"];\n const {\n inlineSize: sizeName,\n inlinePos: posName,\n } = RECT_NAMES[horizontal ? \"horizontal\": \"vertical\"];\n const inlineSize = this.getInlineSize();\n let keys = getKeys(cssRect);\n\n if (useTransform) {\n keys = keys.filter((key) => key !== \"top\" && key !== \"left\");\n\n cssTexts.push(`transform: `\n + `translate(${cssRect.left || 0}px, ${cssRect.top || 0}px);`\n );\n }\n cssTexts.push(...keys.map((name) => {\n const value = cssRect[name]!;\n\n if (\n (name === sizeName && sizePercentage) ||\n (name === posName && posPercentage)\n ) {\n return `${name}: ${(value / inlineSize) * 100}%;`;\n }\n return `${name}: ${value}px;`;\n }));\n\n element.style.cssText += cssTexts.join(\"\");\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DOMRect, GridRect } from \"./types\";\nimport { MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\n\n/**\n * @typedef\n * @memberof Grid.GridItem\n * @property - The item key. 아이템 키.\n * @property - The element for the item. 아이템에 있는 엘리먼트.\n * @property - State of whether the element has been added to the container. element가 container에 추가되었는지 상태.\n * @property - The update state of the element's rect. element의 rect의 업데이트 상태.\n * @property - Whether the element's rect was updated for the first time. 처음으로 element의 rect를 업데이트 했는지 여부.\n * @property - Attributes set as `data-grid-` of element. element의 `data-grid-`으로 설정된 속성들.\n * @property - cssText of the first style when an element is added to the container. element가 container에 추가됐을 때 처음 style의 cssText.\n * @property - The element's rect before first rendering. 처음 렌더링 하기 전 엘리먼트의 rect.\n * @property - The updated element's rect before rendering. 렌더링 하기 전 업데이트 된 엘리먼트의 rect.\n * @property - The CSS rect of the item to be rendered by being applied to the Grid. Grid에 적용되어 렌더링을 하기 위한 item의 CSS rect\n * @property - Additional data of the item. item의 추가적인 데이터들.\n */\nexport interface GridItemStatus {\n key?: string | number;\n element?: HTMLElement | null;\n mountState?: MOUNT_STATE;\n updateState?: UPDATE_STATE;\n isFirstUpdate?: boolean;\n attributes?: Record;\n orgCSSText?: string;\n orgRect?: Required;\n rect?: Required;\n cssRect?: DOMRect;\n data?: Record;\n}\n\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n /**\n * @constructor\n * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향)\n * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체.\n */\n constructor(\n protected horizontal: boolean,\n itemStatus: Partial = {},\n ) {\n const element = itemStatus.element;\n const status: Required = {\n key: \"\",\n orgRect: { left: 0, top: 0, width: 0, height: 0 },\n rect: { left: 0, top: 0, width: 0, height: 0 },\n cssRect: {},\n attributes: {},\n data: {},\n isFirstUpdate: false,\n mountState: MOUNT_STATE.UNCHECKED,\n updateState: UPDATE_STATE.NEED_UPDATE,\n element: element || null,\n orgCSSText: element?.style.cssText ?? \"\",\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\n /**\n * Grid ready data for rendering\n * @ko 렌더링을 하기 위한 grid의 준비 데이타\n * @member Grid.GridItem#gridData\n */\n public gridData: Record = {};\n /**\n * The size in inline direction before first rendering. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#orgInlineSize\n */\n public get orgInlineSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.height : orgRect.width;\n }\n /**\n * The size in content direction before first rendering. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#orgContentSize\n */\n public get orgContentSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.width : orgRect.height;\n }\n /**\n * The size in inline direction. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#inlineSize\n */\n public get inlineSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.height : rect.width;\n }\n /**\n * The size in content direction. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#contentSize\n */\n public get contentSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.width : rect.height;\n }\n /**\n * The CSS size in inline direction applied to the Grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#cssInlineSize\n */\n public get cssInlineSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.height! : cssRect.width!;\n }\n /**\n * The CSS size in content direction applied to the Grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#cssContentSize\n */\n public get cssContentSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.width! : cssRect.height!;\n }\n /**\n * The CSS pos in inline direction applied to the Grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#cssInlinePos\n */\n public get cssInlinePos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.top! : cssRect.left!;\n }\n /**\n * The CSS pos in content direction applied to the Grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#cssContentPos\n */\n public get cssContentPos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.left! : cssRect.top!;\n }\n public set cssInlinePos(inlinePos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"top\" : \"left\"] = inlinePos;\n }\n public set cssContentPos(contentPos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"left\" : \"top\"] = contentPos;\n }\n public set cssInlineSize(inlineSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"height\" : \"width\"] = inlineSize;\n }\n public set cssContentSize(contentSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"width\" : \"height\"] = contentSize;\n }\n /**\n * Set CSS Rect through GridRect.\n * @ko GridRect을 통해 CSS Rect를 설정한다.\n * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일.\n */\n public setCSSGridRect(gridRect: GridRect) {\n const names = RECT_NAMES[this.horizontal ? \"horizontal\" : \"vertical\"];\n\n const rect: DOMRect = {};\n\n for (const name in gridRect) {\n rect[names[name]] = gridRect[name];\n }\n this.cssRect = rect;\n }\n /**\n * Returns the status of the item.\n * @ko 아이템의 상태를 반환한다.\n */\n public getStatus(): Required {\n return {\n mountState: this.mountState,\n updateState: this.updateState,\n attributes: this.attributes,\n orgCSSText: this.orgCSSText,\n isFirstUpdate: this.isFirstUpdate,\n element: null,\n key: this.key,\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n data: this.data,\n };\n }\n}\n\ninterface GridItem extends Required {\n}\nexport { GridItem };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DEFAULT_GRID_OPTIONS, GRID_PROPERTY_TYPES, MOUNT_STATE, UPDATE_STATE } from \"./consts\";\nimport { ContainerManager } from \"./ContainerManager\";\nimport {\n DestroyOptions, GridEvents, GridOptions,\n GridOutlines, GridStatus, Properties, RenderOptions,\n OnRenderComplete,\n} from \"./types\";\nimport ImReady from \"@egjs/imready\";\nimport { ItemRenderer } from \"./ItemRenderer\";\nimport { GetterSetter, isNumber, isString } from \"./utils\";\nimport { diff } from \"@egjs/children-differ\";\nimport { GridItem } from \"./GridItem\";\n\n/**\n * @extends eg.Component\n */\n@GetterSetter\nabstract class Grid extends Component {\n public static defaultOptions: Required = DEFAULT_GRID_OPTIONS;\n public static propertyTypes = GRID_PROPERTY_TYPES;\n public options: Required;\n protected containerElement: HTMLElement;\n protected containerManager: ContainerManager;\n protected itemRenderer!: ItemRenderer;\n protected items: GridItem[] = [];\n protected outlines: GridOutlines = {\n start: [],\n end: [],\n };\n private _renderTimer = 0;\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _im: ImReady;\n\n /**\n * Apply the CSS rect of items to fit the Grid and calculate the outline.\n * @ko Grid에 맞게 아이템들의 CSS rect를 적용하고 outline을 계산한다.\n * @abstract\n * @method Grid#applyGrid\n * @param {\"start\" | \"end\"} direcion - The direction to apply the Grid. (\"end\": start to end, \"start\": end to start) Grid를 적용할 방향. (\"end\": 시작에서 끝 방향, \"start\": 끝에서 시작 방향)\n * @param {number[]} outline - The start outline to apply the Grid. Grid를 적용할 시작 outline.\n */\n public abstract applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines;\n\n /**\n * @param - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param - The option object of the Grid module Grid 모듈의 옵션 객체\n */\n constructor(containerElement: HTMLElement | string, options: Partial = {}) {\n super();\n\n this.options = {\n ...((this.constructor as typeof Grid)\n .defaultOptions as Required),\n ...options,\n };\n\n this.containerElement = isString(containerElement)\n ? document.querySelector(containerElement)!\n : containerElement;\n\n const {\n isEqualSize,\n isConstantSize,\n useTransform,\n horizontal,\n percentage,\n externalContainerManager,\n externalItemRenderer,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n });\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n });\n\n this._init();\n }\n /**\n * Return Container Element.\n * @ko 컨테이너 엘리먼트를 반환한다.\n */\n public getContainerElement(): HTMLElement {\n return this.containerElement;\n }\n /**\n * Return items.\n * @ko 아이템들을 반환한다.\n */\n public getItems(): GridItem[] {\n return this.items;\n }\n /**\n * Returns the children of the container element.\n * @ko 컨테이너 엘리먼트의 children을 반환한다.\n */\n public getChildren(): HTMLElement[] {\n return [].slice.call(this.containerElement.children);\n }\n /**\n * Set items.\n * @ko 아이템들을 설정한다.\n * @param items - The items to set. 설정할 아이템들\n */\n public setItems(items: GridItem[]): this {\n this.items = items;\n return this;\n }\n /**\n * Gets the container's inline size. (\"width\" if horizontal is false, otherwise \"height\")\n * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 \"width\", 아니면 \"height\")\n */\n public getContainerInlineSize(): number {\n return this.containerManager.getInlineSize()!;\n }\n /**\n * Returns the outlines of the start and end of the Grid.\n * @ko Grid의 처음과 끝의 outline을 반환한다.\n */\n public getOutlines(): GridOutlines {\n return this.outlines;\n }\n /**\n * Set outlines.\n * @ko 아웃라인을 설정한다.\n * @param outlines - The outlines to set. 설정할 아웃라인.\n */\n public setOutlines(outlines: GridOutlines) {\n this.outlines = outlines;\n return this;\n }\n /**\n * When elements change, it synchronizes and renders items.\n * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public syncElements(options: RenderOptions = {}) {\n const items = this.items;\n const horizontal = this.options.horizontal;\n const elements: HTMLElement[] = this.getChildren();\n const { added, maintained, changed, removed } = diff(this.items.map((item) => item.element!), elements);\n\n const nextItems: GridItem[] = [];\n\n maintained.forEach(([beforeIndex, afterIndex]) => {\n nextItems[afterIndex] = items[beforeIndex];\n });\n added.forEach((index) => {\n nextItems[index] = new GridItem(horizontal!, {\n element: elements[index],\n });\n });\n\n this.setItems(nextItems);\n\n if (added.length || removed.length || changed.length) {\n this.renderItems(options);\n }\n return this;\n }\n /**\n * Update the size of the items and render them.\n * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다.\n * @param - Items to be updated. 업데이트할 아이템들.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public updateItems(items: GridItem[] = this.items, options: RenderOptions = {}) {\n items.forEach((item) => {\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n });\n this.checkReady(options);\n return this;\n }\n /**\n * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired.\n * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n * const grid = new MasonryGrid();\n *\n * grid.on(\"renderComplete\", e => {\n * console.log(e);\n * });\n * grid.renderItems();\n */\n public renderItems(options: RenderOptions = {}) {\n this._clearRenderTimer();\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (options.useResize) {\n // Resize container and Update all items\n this._resizeContainer();\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\n }\n return this;\n }\n /**\n * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method.\n * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다.\n */\n public getStatus(): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => item.getStatus()),\n containerManager: this.containerManager.getStatus(),\n itemRenderer: this.itemRenderer.getStatus(),\n };\n }\n /**\n * Set status of the Grid module with the status returned through a call to the getStatus() method.\n * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다.\n */\n public setStatus(status: GridStatus) {\n const horizontal = this.options.horizontal;\n const containerManager = this.containerManager;\n const prevInlineSize = containerManager.getInlineSize();\n const children = this.getChildren();\n\n this.itemRenderer.setStatus(status.itemRenderer);\n containerManager.setStatus(status.containerManager);\n this.outlines = status.outlines;\n this.items = status.items.map((item, i) => new GridItem(horizontal!, {\n ...item,\n element: children[i],\n }));\n\n this.itemRenderer.renderItems(this.items);\n\n if (prevInlineSize !== containerManager.getInlineSize()) {\n this.renderItems({\n useResize: true,\n });\n } else {\n window.setTimeout(() => {\n this._renderComplete({\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Releases the instnace and events and returns the CSS of the container and elements.\n * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.\n * @param Options for destroy. destory()를 위한 옵션\n */\n public destroy(options: DestroyOptions = {}) {\n const {\n preserveUI = this.options.preserveUIOnDestroy,\n } = options;\n this.containerManager.destroy({\n preserveUI,\n });\n\n if (!preserveUI) {\n this.items.forEach(({ element, orgCSSText }) => {\n if (element) {\n element.style.cssText = orgCSSText;\n }\n });\n }\n window.removeEventListener(\"resize\", this._scheduleResize);\n this._im?.destroy();\n }\n protected checkReady(options: RenderOptions = {}) {\n // Grid: renderItems => checkReady => readyItems => applyGrid\n const items = this.items;\n const updated = items.filter((item) => item.element && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n this._im?.destroy();\n this._im = new ImReady({\n prefix: this.options.attributePrefix,\n }).on(\"preReadyElement\", (e) => {\n updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING;\n }).on(\"preReady\", () => {\n this.itemRenderer.updateItems(updated);\n this.readyItems(mounted, updated, options);\n }).on(\"readyElement\", (e) => {\n const item = updated[e.index];\n\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n\n // after preReady\n if (e.isPreReadyOver) {\n item.element!.style.cssText = item.orgCSSText;\n this.itemRenderer.updateItems([item]);\n this.readyItems([], [item], options);\n }\n }).on(\"error\", (e) => {\n const item = items[e.index];\n /**\n * This event is fired when an error occurs in the content.\n * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트.\n * @event Grid#contentError\n * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트.\n * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트.\n * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템\n * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.\n * @example\ngrid.on(\"contentError\", e => {\n e.update();\n});\n */\n this.trigger(\"contentError\", {\n element: e.element,\n target: e.target,\n item,\n update: () => {\n moreUpdated.push(item);\n },\n });\n }).on(\"ready\", () => {\n if (moreUpdated.length) {\n this.updateItems(moreUpdated);\n }\n }).check(updated.map((item) => item.element!));\n }\n\n protected scheduleRender() {\n this._clearRenderTimer();\n this._renderTimer = window.setTimeout(() => {\n this.renderItems();\n });\n }\n protected fitOutlines(useFit = this.useFit) {\n const outlines = this.outlines;\n const startOutline = outlines.start;\n const endOutline = outlines.end;\n const outlineOffset = startOutline.length ? Math.min(...startOutline) : 0;\n\n // If the outline is less than 0, a fit occurs forcibly.\n if (!useFit && outlineOffset > 0) {\n return;\n }\n\n outlines.start = startOutline.map((point) => point - outlineOffset);\n outlines.end = endOutline.map((point) => point - outlineOffset);\n\n this.items.forEach((item) => {\n const contentPos = item.cssContentPos;\n\n if (!isNumber(contentPos)) {\n return;\n }\n item.cssContentPos = contentPos - outlineOffset;\n });\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const prevOutlines = this.outlines;\n const direction = options.direction || this.options.defaultDirection!;\n const prevOutline = options.outline || prevOutlines[direction === \"end\" ? \"start\" : \"end\"];\n const items = this.items;\n let nextOutlines = {\n start: [...prevOutline],\n end: [...prevOutline],\n };\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n this._renderComplete({\n mounted,\n updated,\n isResize: !!options.useResize,\n });\n }\n private _renderComplete(e: OnRenderComplete) {\n /**\n * This event is fired when the Grid has completed rendering.\n * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다.\n * @event Grid#renderComplete\n * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들\n * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들.\n * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.\n * @example\ngrid.on(\"renderComplete\", e => {\nconsole.log(e.mounted, e.updated, e.useResize);\n});\n */\n this.trigger(\"renderComplete\", e);\n }\n private _clearRenderTimer() {\n clearTimeout(this._renderTimer);\n this._renderTimer = 0;\n }\n private _refreshContainerContentSize() {\n const {\n start: startOutline,\n end: endOutline,\n } = this.outlines;\n const gap = this.options.gap!;\n\n const endPoint = endOutline.length ? Math.max(...endOutline) : 0;\n const startPoint = startOutline.length ? Math.max(...startOutline) : 0;\n const contentSize = Math.max(startPoint, endPoint - gap);\n\n this.containerManager.setContentSize(contentSize);\n }\n private _resizeContainer() {\n this.containerManager.resize();\n this.itemRenderer.setContainerRect(this.containerManager.getRect());\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n this.renderItems({\n useResize: true,\n });\n }\n private _scheduleResize = () => {\n const {\n resizeDebounce,\n maxResizeDebounce,\n } = this.options;\n\n\n if (!this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) {\n this._maxResizeDebounceTimer = window.setTimeout(this._onResize, maxResizeDebounce);\n }\n if (this._resizeTimer) {\n clearTimeout(this._resizeTimer);\n this._resizeTimer = 0;\n }\n this._resizeTimer = window.setTimeout(this._onResize, resizeDebounce);\n }\n\n private _init() {\n this._resizeContainer();\n if (this.options.autoResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n }\n}\n\ninterface Grid extends Properties { }\n\nexport default Grid;\n\n/**\n * Gap used to create space around items.\n * @ko 아이템들 사이의 공간.\n * @name Grid#gap\n * @type {$ts:Grid.GridOptions[\"gap\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * gap: 0,\n * });\n *\n * grid.gap = 5;\n */\n\n/**\n * The default direction value when direction is not set in the render option.\n * @ko render옵션에서 direction을 미설정시의 기본 방향값.\n * @name Grid#defaultDirection\n * @type {$ts:Grid.GridOptions[\"defaultDirection\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * defaultDirection: \"end\",\n * });\n *\n * grid.defaultDirection = \"start\";\n */\n\n\n/**\n * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true)\n * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true)\n * @name Grid#useFit\n * @type {$ts:Grid.GridOptions[\"useFit\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * useFit: true,\n * });\n *\n * grid.useFit = false;\n\n/**\n * Whether to preserve the UI of the existing container or item when destroying.\n * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.\n * @name Grid#preserveUIOnDestroy\n * @type {$ts:Grid.GridOptions[\"preserveUIOnDestroy\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * preserveUIOnDestroy: false,\n * });\n *\n * grid.preserveUIOnDestroy = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE, UPDATE_STATE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridAlign } from \"../types\";\nimport { range, GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getColumnPoint(\n outline: number[],\n columnIndex: number,\n columnCount: number,\n pointCaculationName: \"max\" | \"min\",\n) {\n return Math[pointCaculationName](...outline.slice(columnIndex, columnIndex + columnCount));\n}\n\nfunction getColumnIndex(outline: number[], columnCount: number, nearestCalculationName: \"max\" | \"min\") {\n const length = outline.length - columnCount + 1;\n const pointCaculationName = nearestCalculationName === \"max\" ? \"min\" : \"max\";\n const indexCaculationName = nearestCalculationName === \"max\" ? \"lastIndexOf\" : \"indexOf\";\n const points = range(length).map((index) => {\n return getColumnPoint(outline, index, columnCount, pointCaculationName);\n });\n\n return points[indexCaculationName](Math[nearestCalculationName](...points));\n}\n\n/**\n * @typedef\n * @memberof Grid.MasonryGrid\n * @extends Grid.GridOptions\n * @property - The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) \n * @property - The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) \n * @property - The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. \n * @property - Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\") 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n}\n\n/**\n * MasonryGrid 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.\n *\n * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class MasonryGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n column: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSize: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n align: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n align: \"justify\",\n column: 0,\n columnSize: 0,\n columnSizeRatio: 0,\n };\n\n private _columnSize = 0;\n private _column = 1;\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n this._calculateColumnSize(items);\n this._calculateColumn(items);\n\n const column = this._column;\n const columnSize = this._columnSize;\n const {\n gap,\n align,\n columnSizeRatio,\n columnSize: columnSizeOption,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses();\n const isEndDirection = direction === \"end\";\n const nearestCalculationName = isEndDirection ? \"min\" : \"max\";\n const pointCalculationName = isEndDirection ? \"max\" : \"min\";\n let startOutline = [0];\n\n if (outlineLength === column) {\n startOutline = outline.slice();\n } else {\n const point = outlineLength ? Math[nearestCalculationName](...outline) : 0;\n\n startOutline = range(column).map(() => point);\n }\n const endOutline = startOutline.slice();\n const columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0;\n const isStretch = align === \"stretch\";\n\n for (let i = 0; i < itemsLength; ++i) {\n const item = items[isEndDirection ? i : itemsLength - 1 - i];\n const columnAttribute = parseInt(item.attributes.column || \"1\", 10);\n const maxColumnAttribute = parseInt(item.attributes.maxColumn || \"1\", 10);\n let inlineSize = item.inlineSize;\n let contentSize = item.contentSize;\n let columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist)));\n const maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute));\n let columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName);\n let contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName);\n\n while (columnCount < maxColumnCount) {\n const nextEndColumnIndex = columnIndex + columnCount;\n const nextColumnIndex = columnIndex - 1;\n\n if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) {\n break;\n }\n if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) {\n break;\n }\n if (!isEndDirection) {\n --columnIndex;\n }\n ++columnCount;\n }\n\n columnIndex = Math.max(0, columnIndex);\n columnCount = Math.min(column - columnIndex, columnCount);\n\n if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) {\n inlineSize = (columnCount - 1) * columnDist + columnSize;\n item.cssInlineSize = inlineSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = inlineSize / columnSizeRatio;\n item.cssContentSize = contentSize;\n }\n const inlinePos = alignPoses[columnIndex];\n contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize;\n\n item.cssInlinePos = inlinePos;\n item.cssContentPos = contentPos;\n const nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos;\n\n range(columnCount).forEach((indexOffset) => {\n endOutline[columnIndex + indexOffset] = nextOutlinePoint;\n });\n }\n\n // if end items, startOutline is low, endOutline is high\n // if start items, startOutline is high, endOutline is low\n return {\n start: isEndDirection ? startOutline : endOutline,\n end: isEndDirection ? endOutline : startOutline,\n };\n }\n private _calculateColumnSize(items: GridItem[]) {\n const {\n columnSize: columnSizeOption,\n gap,\n align,\n } = this.options;\n\n if (align === \"stretch\") {\n let column = this.column;\n\n if (columnSizeOption) {\n column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap)));\n }\n this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n this._columnSize = columnSizeOption;\n } else {\n for (const item of items) {\n const attributes = item.attributes;\n if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) {\n continue;\n }\n const inlineSize = item.inlineSize;\n\n this._columnSize = inlineSize;\n return inlineSize;\n }\n this._columnSize = this._columnSize || 0;\n }\n return this._columnSize;\n }\n private _calculateColumn(items: GridItem[]) {\n const {\n gap,\n column: columnOption,\n } = this.options;\n const columnSize = this._columnSize;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else if (!columnSize) {\n column = 1;\n } else {\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap))),\n );\n }\n this._column = column;\n return column;\n }\n private _getAlignPoses() {\n const columnSize = this._columnSize;\n const column = this._column;\n const {\n align,\n gap,\n } = this.options;\n const containerSize = this.getContainerInlineSize();\n const indexes = range(column);\n\n let offset = 0;\n let dist = 0;\n\n if (align === \"justify\" || align === \"stretch\") {\n const countDist = column - 1;\n\n dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0;\n offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2);\n } else {\n dist = columnSize + gap;\n const totalColumnSize = (column - 1) * dist + columnSize;\n\n if (align === \"center\") {\n offset = (containerSize - totalColumnSize) / 2;\n } else if (align === \"end\") {\n offset = containerSize - totalColumnSize;\n }\n }\n return indexes.map((i) => {\n return offset + i * dist;\n });\n }\n}\n\nexport interface MasonryGrid extends Properties {\n}\n\n\n/**\n * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * align: \"start\",\n * });\n *\n * grid.align = \"justify\";\n */\n\n\n/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * column: 0,\n * });\n *\n * grid.column = 4;\n */\n\n\n/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0)\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSize: 0,\n * });\n *\n * grid.columnSize = 200;\n */\n\n\n/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0)\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSizeRatio: 0,\n * });\n *\n * grid.columnSizeRatio = 0.5;\n */\n","/* eslint-disable */\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin \n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nfunction single_source_shortest_paths(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\t// Predecessor map for each node that has been encountered.\n\t// node ID => predecessor node ID\n\tconst predecessors: { [key: string]: string } = {};\n\t// Costs of shortest paths from s to all nodes encountered.\n\t// node ID => cost\n\tconst costs: { [key: string]: number } = {};\n\tcosts[s] = 0;\n\n\t// Costs of shortest paths from s to all nodes encountered; differs from\n\t// `costs` in that it provides easy access to the node that currently has\n\t// the known shortest path from s.\n\t// XXX: Do we actually need both `costs` and `open`?\n\tconst open = new BinaryHeap<{ value: string, cost: number }>(x => x.cost);\n\topen.push({ value: s, cost: 0 });\n\n\tlet closest;\n\tlet u;\n\tlet cost_of_s_to_u;\n\tlet adjacent_nodes;\n\tlet cost_of_e;\n\tlet cost_of_s_to_u_plus_cost_of_e;\n\tlet cost_of_s_to_v;\n\tlet first_visit: boolean;\n\n\twhile (open.size()) {\n\t\t// In the nodes remaining in graph that have a known cost from s,\n\t\t// find the node, u, that currently has the shortest path from s.\n\t\tclosest = open.pop();\n\t\tu = closest.value;\n\t\tcost_of_s_to_u = closest.cost;\n\n\t\t// Get nodes adjacent to u...\n\t\tadjacent_nodes = graph(u) || {};\n\n\t\t// ...and explore the edges that connect u to those nodes, updating\n\t\t// the cost of the shortest paths to any or all of those nodes as\n\t\t// necessary. v is the node across the current edge from u.\n\t\tfor (const v in adjacent_nodes) {\n\t\t\t// Get the cost of the edge running from u to v.\n\t\t\tcost_of_e = adjacent_nodes[v];\n\n\t\t\t// Cost of s to u plus the cost of u to v across e--this is *a*\n\t\t\t// cost from s to v that may or may not be less than the current\n\t\t\t// known cost to v.\n\t\t\tcost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n\t\t\t// If we haven't visited v yet OR if the current known cost from s to\n\t\t\t// v is greater than the new cost we just found (cost of s to u plus\n\t\t\t// cost of u to v across e), update v's cost in the cost list and\n\t\t\t// update v's predecessor in the predecessor list (it's now u).\n\t\t\tcost_of_s_to_v = costs[v];\n\t\t\tfirst_visit = (typeof costs[v] === \"undefined\");\n\t\t\tif (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n\t\t\t\tcosts[v] = cost_of_s_to_u_plus_cost_of_e;\n\t\t\t\topen.push({ value: v, cost: cost_of_s_to_u_plus_cost_of_e });\n\t\t\t\tpredecessors[v] = u;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof costs[d] === \"undefined\") {\n\t\tconst msg = [\"Could not find a path from \", s, \" to \", d, \".\"].join(\"\");\n\t\tthrow new Error(msg);\n\t}\n\n\treturn predecessors;\n}\nfunction extract_shortest_path_from_predecessor_list(\n\tpredecessors: { [key: string]: string },\n\td: string,\n) {\n\tconst nodes: string[] = [];\n\tlet u = d;\n\n\twhile (u) {\n\t\tnodes.push(u);\n\t\tu = predecessors[u];\n\t}\n\tnodes.reverse();\n\treturn nodes;\n}\nfunction find_path(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\tconst predecessors = single_source_shortest_paths(graph, s, d);\n\n\treturn extract_shortest_path_from_predecessor_list(predecessors, d);\n}\n\nclass BinaryHeap {\n\tprivate content: T[];\n\tprivate scoreFunction: (x: T) => number;\n\n\tconstructor(scoreFunction: (x: T) => number) {\n\t\tthis.content = [];\n\t\tthis.scoreFunction = scoreFunction;\n\t}\n\tpublic push(element: T) {\n\t\t// Add the new element to the end of the array.\n\t\tthis.content.push(element);\n\t\t// Allow it to bubble up.\n\t\tthis.bubbleUp(this.content.length - 1);\n\t}\n\tpublic pop() {\n\t\t// Store the first element so we can return it later.\n\t\tconst result = this.content[0];\n\t\t// Get the element at the end of the array.\n\t\tconst end = this.content.pop()!;\n\t\t// If there are any elements left, put the end element at the\n\t\t// start, and let it sink down.\n\t\tif (this.content.length > 0) {\n\t\t\tthis.content[0] = end;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic size() {\n\t\treturn this.content.length;\n\t}\n\tpublic bubbleUp(_n: number) {\n\t\tlet n = _n;\n\t\t// Fetch the element that has to be moved.\n\t\tconst element = this.content[n];\n\t\t// When at 0, an element can not go up any further.\n\t\twhile (n > 0) {\n\t\t\t// Compute the parent element's index, and fetch it.\n\t\t\tconst parentN = Math.floor((n + 1) / 2) - 1;\n\t\t\tconst parent = this.content[parentN];\n\n\t\t\t// Swap the elements if the parent is greater.\n\t\t\tif (this.scoreFunction(element) < this.scoreFunction(parent)) {\n\t\t\t\tthis.content[parentN] = element;\n\t\t\t\tthis.content[n] = parent;\n\t\t\t\t// Update 'n' to continue at the new position.\n\t\t\t\tn = parentN;\n\t\t\t} else {\n\t\t\t\t// Found a parent that is less, no need to move it further.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tpublic sinkDown(n: number) {\n\t\t// Look up the target element and its score.\n\t\tconst length = this.content.length;\n\t\tconst element = this.content[n];\n\t\tconst elemScore = this.scoreFunction(element);\n\t\tlet child1Score;\n\n\t\twhile (true) {\n\t\t\t// Compute the indices of the child elements.\n\t\t\tconst child2N = (n + 1) * 2;\n\t\t\tconst child1N = child2N - 1;\n\t\t\t// This is used to store the new position of the element,\n\t\t\t// if any.\n\t\t\tlet swap: number | null = null;\n\t\t\t// If the first child exists (is inside the array)...\n\t\t\tif (child1N < length) {\n\t\t\t\t// Look it up and compute its score.\n\t\t\t\tconst child1 = this.content[child1N];\n\t\t\t\tchild1Score = this.scoreFunction(child1);\n\t\t\t\t// If the score is less than our element's, we need to swap.\n\t\t\t\tif (child1Score < elemScore) {\n\t\t\t\t\tswap = child1N;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Do the same checks for the other child.\n\t\t\tif (child2N < length) {\n\t\t\t\tconst child2 = this.content[child2N];\n\t\t\t\tconst child2Score = this.scoreFunction(child2);\n\n\t\t\t\tif (child2Score < (swap == null ? elemScore : child1Score)) {\n\t\t\t\t\tswap = child2N;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the element needs to be moved, swap it, and continue.\n\t\t\tif (swap !== null) {\n\t\t\t\tthis.content[n] = this.content[swap];\n\t\t\t\tthis.content[swap] = element;\n\t\t\t\tn = swap;\n\t\t\t} else {\n\t\t\t\t// Otherwise, we are done.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport { find_path };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, RenderOptions } from \"../types\";\nimport { getRangeCost, GetterSetter, isObject } from \"../utils\";\nimport { find_path } from \"./lib/dijkstra\";\nimport { GridItem } from \"../GridItem\";\n\n\ninterface Link {\n path: number[];\n cost: number;\n length: number;\n currentNode: number;\n isOver?: boolean;\n}\n\nfunction splitItems(items: GridItem[], path: string[]) {\n const length = path.length;\n const groups: GridItem[][] = [];\n\n for (let i = 0; i < length - 1; ++i) {\n const path1 = parseInt(path[i], 10);\n const path2 = parseInt(path[i + 1], 10);\n\n groups.push(items.slice(path1, path2));\n }\n return groups;\n}\nfunction getExpectedColumnSize(item: GridItem, rowSize: number) {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return 0;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n\n return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset;\n}\n\n/**\n * @typedef\n * @memberof Grid.JustifiedGrid\n * @extends Grid.GridOptions\n * @property - The minimum and maximum number of items per line. (default: [1, 8]) 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) \n * @property - The minimum and maximum number of rows in a group, 0 is not set. (default: 0) 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) \n * @property - The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @property - Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @property - Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) row사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n */\nexport interface JustifiedGridOptions extends GridOptions {\n columnRange?: number | number[];\n rowRange?: number | number[];\n sizeRange?: number | number[];\n displayedRow?: number;\n isCroppedSize?: boolean;\n}\n\n/**\n * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size.\n * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.\n * 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.\n * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.\n * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.\n * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class JustifiedGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n columnRange: PROPERTY_TYPE.RENDER_PROPERTY,\n rowRange: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeRange: PROPERTY_TYPE.RENDER_PROPERTY,\n isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY,\n displayedRow: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n columnRange: [1, 8],\n rowRange: 0,\n sizeRange: [0, Infinity],\n displayedRow: -1,\n isCroppedSize: false,\n };\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const rowRange = this.options.rowRange;\n let path: string[] = [];\n\n if (items.length) {\n path = rowRange ? this._getRowPath(items) : this._getPath(items);\n }\n\n return this._setStyle(items, path, outline, direction === \"end\");\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const {\n attributePrefix,\n horizontal,\n } = this.options;\n\n updated.forEach((item) => {\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || 0;\n\n if (element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)) {\n const maintainedTarget = element.querySelector(`[${attributePrefix}maintained-target]`);\n\n if (maintainedTarget) {\n const widthOffset = element.offsetWidth - element.clientWidth\n + element.scrollWidth - maintainedTarget.clientWidth;\n const heightOffset = element.offsetHeight - element.clientHeight\n + element.scrollHeight - maintainedTarget.clientHeight;\n\n if (horizontal) {\n inlineOffset = heightOffset;\n contentOffset = widthOffset;\n } else {\n inlineOffset = widthOffset;\n contentOffset = heightOffset;\n }\n }\n }\n gridData.inlineOffset = inlineOffset;\n gridData.contentOffset = contentOffset;\n });\n super.readyItems(mounted, updated, options);\n }\n private _getRowPath(items: GridItem[]) {\n const columnRange = this._getColumnRange();\n const rowRange = this._getRowRange();\n\n const pathLink = this._getRowLink(items, {\n path: [0],\n cost: 0,\n length: 0,\n currentNode: 0,\n }, columnRange, rowRange);\n\n return pathLink?.path.map((node) => `${node}`) ?? [];\n }\n private _getRowLink(\n items: GridItem[],\n currentLink: Link,\n columnRange: number[],\n rowRange: number[]\n ): Link {\n const [minColumn] = columnRange;\n const [minRow, maxRow] = rowRange;\n const lastNode = items.length;\n const {\n path,\n length: pathLength,\n cost,\n currentNode,\n } = currentLink;\n\n // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn.\n if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) {\n const rangeCost = getRangeCost(lastNode - currentNode, columnRange);\n const lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode));\n\n return {\n ...currentLink,\n length: pathLength + 1,\n path: [...path, lastNode],\n currentNode: lastNode,\n cost: cost + lastCost,\n isOver: true,\n };\n } else if (currentNode >= lastNode) {\n return {\n ...currentLink,\n currentNode: lastNode,\n isOver: minRow > pathLength || maxRow < pathLength,\n };\n } else {\n return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange);\n }\n\n }\n private _searchRowLink(\n items: GridItem[],\n currentLink: Link,\n lastNode: number,\n columnRange: number[],\n rowRange: number[]\n ) {\n const [minColumn, maxColumn] = columnRange;\n const {\n currentNode,\n path,\n length: pathLength,\n cost,\n } = currentLink;\n const length = Math.min(lastNode, currentNode + maxColumn);\n const links: Link[] = [];\n\n for (let nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) {\n if (nextNode === currentNode) {\n continue;\n }\n const nextCost = Math.abs(this._getCost(items, currentNode, nextNode));\n const nextLink = this._getRowLink(items, {\n path: [...path, nextNode],\n length: pathLength + 1,\n cost: cost + nextCost,\n currentNode: nextNode,\n }, columnRange, rowRange);\n\n if (nextLink) {\n links.push(nextLink);\n }\n }\n links.sort((a, b) => {\n const aIsOver = a.isOver;\n const bIsOver = b.isOver;\n\n if (aIsOver !== bIsOver) {\n // If it is over, the cost is high.\n return aIsOver ? 1 : -1;\n }\n const aRangeCost = getRangeCost(a.length, rowRange);\n const bRangeCost = getRangeCost(b.length, rowRange);\n\n return aRangeCost - bRangeCost || a.cost - b.cost;\n });\n\n // It returns the lowest cost link.\n return links[0];\n }\n private _getExpectedRowSize(items: GridItem[]) {\n const {\n gap,\n } = this.options;\n let containerInlineSize = this.getContainerInlineSize()! - gap * (items.length - 1);\n let ratioSum = 0;\n let inlineSum = 0;\n\n items.forEach((item) => {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return;\n }\n // sum((expect - offset) * ratio) = container inline size\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n ratioSum += maintainedRatio;\n inlineSum += contentOffset * maintainedRatio;\n containerInlineSize -= inlineOffset;\n });\n\n return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0;\n }\n private _getExpectedInlineSize(items: GridItem[], rowSize: number) {\n const {\n gap,\n } = this.options;\n const size = items.reduce((sum, item) => {\n return sum + getExpectedColumnSize(item, rowSize);\n }, 0);\n\n return size ? size + gap * (items.length - 1) : 0;\n }\n private _getCost(\n items: GridItem[],\n i: number,\n j: number,\n ) {\n const lineItems = items.slice(i, j);\n const rowSize = this._getExpectedRowSize(lineItems);\n const [minSize, maxSize] = this._getSizeRange();\n\n if (this.isCroppedSize) {\n if (minSize <= rowSize && rowSize <= maxSize) {\n return 0;\n }\n const expectedInlineSize = this._getExpectedInlineSize(\n lineItems,\n rowSize < minSize ? minSize : maxSize,\n );\n\n return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2);\n }\n\n if (isFinite(maxSize)) {\n // if this size is not in range, the cost increases sharply.\n if (rowSize < minSize) {\n return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2);\n } else if (rowSize > maxSize) {\n return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2);\n }\n } else if (rowSize < minSize) {\n return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2);\n }\n // if this size in range, the cost is row\n return rowSize - minSize;\n }\n private _getPath(items: GridItem[]) {\n const lastNode = items.length;\n const columnRangeOption = this.options.columnRange;\n const [minColumn, maxColumn]: number[] = isObject(columnRangeOption)\n ? columnRangeOption\n : [columnRangeOption, columnRangeOption];\n\n const graph = (nodeKey: string) => {\n const results: { [key: string]: number } = {};\n const currentNode = parseInt(nodeKey, 10);\n\n for (let nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) {\n if (nextNode - currentNode > maxColumn) {\n break;\n }\n let cost = this._getCost(\n items,\n currentNode,\n nextNode,\n );\n\n if (cost < 0 && nextNode === lastNode) {\n cost = 0;\n }\n results[`${nextNode}`] = Math.pow(cost, 2);\n }\n return results;\n };\n // shortest path for items' total height.\n return find_path(graph, \"0\", `${lastNode}`);\n }\n private _setStyle(\n items: GridItem[],\n path: string[],\n outline: number[] = [],\n isEndDirection: boolean,\n ) {\n const {\n gap,\n isCroppedSize,\n displayedRow,\n } = this.options;\n const sizeRange = this._getSizeRange();\n const startPoint = outline[0] || 0;\n const containerInlineSize = this.getContainerInlineSize();\n const groups = splitItems(items, path);\n let contentPos = startPoint;\n let displayedSize = 0;\n\n groups.forEach((groupItems, rowIndex) => {\n const length = groupItems.length;\n let rowSize = this._getExpectedRowSize(groupItems);\n if (isCroppedSize) {\n rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1]));\n }\n const expectedInlineSize = this._getExpectedInlineSize(groupItems, rowSize);\n\n const allGap = gap * (length - 1);\n const scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap);\n\n groupItems.forEach((item, i)=> {\n let columnSize = getExpectedColumnSize(item, rowSize);\n\n const prevItem = groupItems[i - 1];\n const inlinePos = prevItem\n ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap\n : 0;\n\n if (isCroppedSize) {\n columnSize *= scale;\n }\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize: columnSize,\n contentSize: rowSize,\n });\n });\n contentPos += gap + rowSize;\n if (displayedRow < 0 || rowIndex < displayedRow) {\n displayedSize = contentPos;\n }\n });\n\n if (isEndDirection) {\n // previous group's end outline is current group's start outline\n return {\n start: [startPoint],\n end: [displayedSize],\n };\n }\n // always start is lower than end.\n // contentPos is endPoinnt\n const height = contentPos - startPoint;\n\n items.forEach((item) => {\n item.cssContentPos -= height;\n });\n return {\n start: [startPoint - height],\n end: [startPoint], // endPoint - height = startPoint\n };\n }\n private _getRowRange() {\n const rowRange = this.rowRange;\n return isObject(rowRange) ? rowRange : [rowRange, rowRange];\n }\n private _getColumnRange() {\n const columnRange = this.columnRange;\n return isObject(columnRange) ? columnRange : [columnRange, columnRange];\n }\n private _getSizeRange() {\n const sizeRange = this.sizeRange;\n return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange];\n }\n}\n\nexport interface JustifiedGrid extends Properties {\n}\n\n\n/**\n * The minimum and maximum number of items per line. (default: [1, 8])\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8])\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * columnRange: [1, 8],\n * });\n *\n * grid.columnRange = [3, 6];\n */\n\n\n/**\n * The minimum and maximum number of rows in a group, 0 is not set. (default: 0)\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0)\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * rowRange: 0,\n * });\n *\n * grid.rowRange = [3, 4];\n */\n\n/**\n * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity])\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [0, Infinity],\n * });\n *\n * grid.sizeRange = [200, 800];\n */\n\n/**\n * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * displayedRow: -1,\n * });\n *\n * grid.displayedRow = 3;\n */\n\n/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false)\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [200, 250],\n * isCroppedSize: false,\n * });\n *\n * grid.isCroppedSize = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridRect } from \"../types\";\nimport { GetterSetter, range } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getMaxPoint(outline: number[]) {\n let maxPoint = -Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n maxPoint = Math.max(maxPoint, point);\n }\n });\n return isFinite(maxPoint) ? maxPoint : 0;\n}\nfunction getMinPoint(outline: number[]) {\n let minPoint = Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n minPoint = Math.min(minPoint, point);\n }\n });\n return isFinite(minPoint) ? minPoint : 0;\n}\nfunction getOutlinePoint(startOutline: number[], frameOutline: number[], useFrameFill: boolean) {\n return getMaxPoint(startOutline)\n + getOutlineDist(startOutline, frameOutline, useFrameFill);\n}\n\nfunction getOutlineDist(startOutline: number[], endOutline: number[], useFrameFill: boolean) {\n const length = startOutline.length;\n\n if (!length) {\n return 0;\n }\n const minEndPoint = getMinPoint(endOutline);\n const maxStartPoint = getMaxPoint(startOutline);\n let frameDist = 0;\n\n if (!useFrameFill) {\n return 0;\n }\n\n\n for (let outlineIndex = 0; outlineIndex < length; ++outlineIndex) {\n const startPoint = startOutline[outlineIndex];\n const endPoint = endOutline[outlineIndex];\n\n if (!isFinite(startPoint) || !isFinite(endPoint)) {\n continue;\n }\n const startPos = startPoint - maxStartPoint;\n const endPos = endPoint - minEndPoint;\n\n\n // Fill empty block.\n frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos;\n }\n\n return frameDist;\n}\nfunction fillOutlines(startOutline: number[], endOutline: number[], rect: {\n inlinePos: number;\n inlineSize: number;\n contentPos: number;\n contentSize: number;\n}) {\n const {\n inlinePos,\n inlineSize,\n contentPos,\n contentSize,\n } = rect;\n for (\n let outlineIndex = inlinePos;\n outlineIndex < inlinePos + inlineSize;\n ++outlineIndex\n ) {\n startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos);\n endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize);\n }\n}\nexport interface FrameRect extends Required {\n type: any;\n}\n/**\n * @typedef\n * @memberof Grid.FrameGrid\n * @extends Grid.GridOptions\n * @property - The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @property - Make sure that the frame can be attached after the previous frame. (default: true) 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @property - 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n */\nexport interface FrameGridOptions extends GridOptions {\n frame?: number[][];\n useFrameFill?: boolean;\n rectSize?: number | { inlineSize: number, contentSize: number };\n}\n\n/**\n * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size.\n * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class FrameGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n frame: PROPERTY_TYPE.RENDER_PROPERTY,\n useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY,\n rectSize: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n frame: [],\n rectSize: 0,\n useFrameFill: true,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const frame = this._getFrame();\n const {\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n rects: frameRects,\n } = frame;\n const {\n gap,\n useFrameFill,\n } = this.options;\n\n const {\n inlineSize: rectInlineSize,\n contentSize: rectContentSize,\n } = this.getRectSize(frameInlineSize);\n\n\n const itemsLength = items.length;\n\n if (!itemsLength || !frameInlineSize || !frameContentSize) {\n return { start: outline, end: outline };\n }\n const rectsLength = frameRects.length;\n let startOutline = range(frameInlineSize).map(() => Infinity);\n let endOutline = range(frameInlineSize).map(() => -Infinity);\n const frameOutline = frame.outline.map((point) => point * (rectContentSize + gap));\n\n for (let startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) {\n // Compare group's startOutline and startOutline of rect\n const startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill);\n\n for (let rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) {\n const item = items[startIndex + rectIndex];\n const {\n contentPos: frameRectContentPos,\n inlinePos: frameRectInlinePos,\n contentSize: frameRectContentSize,\n inlineSize: frameRectInlineSize,\n } = frameRects[rectIndex];\n const contentPos = startPoint + frameRectContentPos * (rectContentSize + gap);\n const inlinePos = frameRectInlinePos * (rectInlineSize + gap);\n const contentSize = frameRectContentSize * (rectContentSize + gap) - gap;\n const inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap;\n\n fillOutlines(startOutline, endOutline, {\n inlinePos: frameRectInlinePos,\n inlineSize: frameRectInlineSize,\n contentPos: contentPos,\n contentSize: contentSize + gap,\n });\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n }\n }\n const isDirectionEnd = direction === \"end\";\n\n let gridOutline = outline;\n\n if (gridOutline.length !== frameInlineSize) {\n const point = isDirectionEnd ? Math.max(...gridOutline) : Math.min(...gridOutline);\n\n gridOutline = range(frameInlineSize).map(() => point);\n }\n startOutline = startOutline.map((point) => isFinite(point) ? point : 0);\n endOutline = endOutline.map((point) => isFinite(point) ? point : 0);\n const outlineDist = isDirectionEnd\n ? getOutlineDist(startOutline, gridOutline, useFrameFill)\n : getOutlineDist(gridOutline, endOutline, useFrameFill);\n\n items.forEach((item) => {\n item.cssContentPos += outlineDist;\n });\n\n return {\n start: startOutline.map((point) => point + outlineDist),\n end: endOutline.map((point) => point + outlineDist),\n };\n }\n protected getRectSize(frameInlineSize: number) {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption;\n }\n const rectSizeValue = rectSizeOption\n ? rectSizeOption\n : (this.getContainerInlineSize()! + gap) / frameInlineSize - gap;\n\n return { inlineSize: rectSizeValue, contentSize: rectSizeValue };\n }\n private _getFrame() {\n const frame = this.options.frame;\n const frameContentSize = frame.length;\n const frameInlineSize = frameContentSize ? frame[0].length : 0;\n const rects: FrameRect[] = [];\n const passMap: Record = {};\n const startOutline = range(frameInlineSize).map(() => Infinity);\n const endOutline = range(frameInlineSize).map(() => -Infinity);\n\n for (let y1 = 0; y1 < frameContentSize; ++y1) {\n for (let x1 = 0; x1 < frameInlineSize; ++x1) {\n const type = frame[y1][x1];\n\n if (!type) {\n continue;\n }\n if (passMap[`${y1},${x1}`]) {\n continue;\n }\n const rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize);\n\n fillOutlines(startOutline, endOutline, rect);\n rects.push(rect);\n }\n }\n rects.sort((a, b) => (a.type < b.type ? -1 : 1));\n\n\n return {\n rects,\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n outline: startOutline,\n };\n }\n private _findRect(\n passMap: Record,\n type: number,\n y1: number,\n x1: number,\n frameInlineSize: number,\n frameContentSize: number,\n ) {\n const frame = this.options.frame;\n\n let contentSize = 1;\n let inlineSize = 1;\n\n // find rect\n for (let x2 = x1; x2 < frameInlineSize; ++x2) {\n if (frame[y1][x2] === type) {\n inlineSize = x2 - x1 + 1;\n continue;\n }\n break;\n }\n for (let y2 = y1; y2 < frameContentSize; ++y2) {\n if (frame[y2][x1] === type) {\n contentSize = y2 - y1 + 1;\n continue;\n }\n break;\n }\n\n // pass rect\n for (let y = y1; y < y1 + contentSize; ++y) {\n for (let x = x1; x < x1 + inlineSize; ++x) {\n passMap[`${y},${x}`] = true;\n }\n }\n\n const rect: FrameRect = {\n type,\n inlinePos: x1,\n contentPos: y1,\n inlineSize,\n contentSize,\n };\n return rect;\n }\n}\n\nexport interface FrameGrid extends Properties {\n}\n\n\n/**\n * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 1 x 1\n * // Item 3 : 1 x 2\n * // Item 4 : 1 x 1\n * // Item 5 : 2 x 1\n * const grid = new FrameGrid(container, {\n * frame: [\n * [1, 1, 0, 0, 2, 3],\n * [1, 1, 0, 4, 5, 5],\n * ],\n * });\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 2 x 2\n * grid.frame = [\n * [1, 1, 0, 0, 2, 2],\n * [1, 1, 0, 0, 2, 2],\n * ];\n */\n\n/**\n * Make sure that the frame can be attached after the previous frame. (default: true)\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true)\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * useFrameFill: true,\n * });\n *\n * grid.useFrameFill = false;\n */\n\n/**\n * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0)\n * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n * @name Grid.FrameGrid#rectSize\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"rectSize\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * rectSize: 0,\n * });\n *\n * grid.rectSize = { inlineSize: 100, contentSize: 150 };\n */\n","export interface BoxModelStatus {\n orgInlineSize: number;\n orgContentSize: number;\n inlineSize: number;\n contentSize: number;\n inlinePos: number;\n contentPos: number;\n items: BoxModel[];\n}\n\nexport default class BoxModel implements BoxModelStatus {\n public orgInlineSize: number;\n public orgContentSize: number;\n public inlineSize: number;\n public contentSize: number;\n public inlinePos: number;\n public contentPos: number;\n public items: BoxModel[];\n constructor(status: Partial) {\n const boxStatus = {\n orgInlineSize: 0,\n orgContentSize: 0,\n inlineSize: 0,\n contentSize: 0,\n inlinePos: 0,\n contentPos: 0,\n items: [],\n ...status,\n };\n for (const name in boxStatus) {\n this[name] = boxStatus[name];\n }\n }\n public scaleTo(inlineSize: number, contentSize: number) {\n const scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0;\n const scaleY = this.contentSize ? contentSize / this.contentSize : 0;\n\n this.items.forEach((item) => {\n if (scaleX !== 0) {\n item.inlinePos *= scaleX;\n item.inlineSize *= scaleX;\n }\n if (scaleY !== 0) {\n item.contentPos *= scaleY;\n item.contentSize *= scaleY;\n }\n });\n\n this.inlineSize = inlineSize;\n this.contentSize = contentSize;\n }\n public push(item: BoxModel) {\n this.items.push(item);\n }\n public getOrgSizeWeight() {\n return this.orgInlineSize * this.orgContentSize;\n }\n public getSize() {\n return this.inlineSize * this.contentSize;\n }\n public getOrgRatio() {\n return (this.orgContentSize === 0) ? 0 : this.orgInlineSize / this.orgContentSize;\n }\n public getRatio() {\n return (this.contentSize === 0) ? 0 : this.inlineSize / this.contentSize;\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } from \"../types\";\nimport { GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\nimport BoxModel from \"./lib/BoxModel\";\n\n\nfunction getCost(originLength: number, length: number) {\n let cost = originLength / length;\n\n if (cost < 1) {\n cost = 1 / cost;\n }\n\n return cost - 1;\n}\nfunction fitArea(\n item: BoxModel,\n bestFitArea: BoxModel,\n itemFitSize: { inlineSize: number, contentSize: number },\n containerFitSize: { inlineSize: number, contentSize: number },\n isContentDirection: boolean,\n) {\n item.contentSize = itemFitSize.contentSize;\n item.inlineSize = itemFitSize.inlineSize;\n bestFitArea.contentSize = containerFitSize.contentSize;\n bestFitArea.inlineSize = containerFitSize.inlineSize;\n\n if (isContentDirection) {\n item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize;\n item.inlinePos = bestFitArea.inlinePos;\n } else {\n item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize;\n item.contentPos = bestFitArea.contentPos;\n }\n}\n\n\n/**\n * @typedef\n * @memberof Grid.PackingGrid\n * @extends Grid.GridOptions\n * @property - The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @property - The size weight when placing items. (default: 1)아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @property - The weight to keep ratio when placing items. (default: 1)아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @property - The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n */\nexport interface PackingGridOptions extends GridOptions {\n aspectRatio?: number;\n sizeWeight?: number;\n ratioWeight?: number;\n weightPriority?: \"size\" | \"ratio\" | \"custom\";\n}\n\n/**\n * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items.\n * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.\n * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible.\n * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible.\n * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.\n * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.\n * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.\n * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class PackingGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n weightPriority: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n aspectRatio: 1,\n sizeWeight: 1,\n ratioWeight: 1,\n weightPriority: \"custom\",\n };\n\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const { aspectRatio, gap } = this.options;\n const containerInlineSize = this.getContainerInlineSize();\n const containerContentSize = containerInlineSize / aspectRatio;\n const prevOutline = outline.length ? outline : [0];\n const startPoint = direction === \"end\"\n ? Math.max(...prevOutline)\n : Math.min(...prevOutline) - containerContentSize - gap;\n const endPoint = startPoint + containerContentSize + gap;\n const container = new BoxModel({});\n\n items.forEach((item) => {\n const model = new BoxModel({\n inlineSize: item.orgInlineSize,\n contentSize: item.orgContentSize,\n orgInlineSize: item.orgInlineSize,\n orgContentSize: item.orgContentSize,\n });\n\n this._findBestFitArea(container, model);\n container.push(model);\n container.scaleTo(containerInlineSize + gap, containerContentSize + gap);\n });\n items.forEach((item, i) => {\n const boxItem = container.items[i];\n const inlineSize = boxItem.inlineSize - gap;\n const contentSize = boxItem.contentSize - gap;\n const contentPos = startPoint + boxItem.contentPos;\n const inlinePos = boxItem.inlinePos;\n\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n });\n\n return {\n start: [startPoint],\n end: [endPoint],\n };\n }\n private _findBestFitArea(container: BoxModel, item: BoxModel) {\n if (container.getRatio() === 0) { // 아이템 최초 삽입시 전체영역 지정\n container.orgInlineSize = item.inlineSize;\n container.orgContentSize = item.contentSize;\n container.inlineSize = item.inlineSize;\n container.contentSize = item.contentSize;\n return;\n }\n\n let bestFitArea!: BoxModel;\n let minCost = Infinity;\n let isContentDirection = false;\n const itemFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const containerFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const sizeWeight = this._getWeight(\"size\");\n const ratioWeight = this._getWeight(\"ratio\");\n\n container.items.forEach((child) => {\n const containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight;\n const containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight;\n const inlineSize = child.inlineSize;\n const contentSize = child.contentSize;\n for (let i = 0; i < 2; ++i) {\n let itemInlineSize;\n let itemContentSize;\n let containerInlineSize;\n let containerContentSize;\n\n if (i === 0) {\n // add item to content pos (top, bottom)\n itemInlineSize = inlineSize;\n itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize));\n containerInlineSize = inlineSize;\n containerContentSize = contentSize - itemContentSize;\n } else {\n // add item to inline pos (left, right)\n itemContentSize = contentSize;\n itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize));\n containerContentSize = contentSize;\n containerInlineSize = inlineSize - itemInlineSize;\n }\n\n const itemSize = itemInlineSize * itemContentSize;\n const itemRatio = itemInlineSize / itemContentSize;\n const containerSize = containerInlineSize * containerContentSize;\n const containerRatio = containerContentSize / containerContentSize;\n\n let cost = getCost(item.getSize(), itemSize) * sizeWeight;\n cost += getCost(item.getRatio(), itemRatio) * ratioWeight;\n cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost;\n cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost;\n\n if (cost === Math.min(cost, minCost)) {\n minCost = cost;\n bestFitArea = child;\n isContentDirection = (i === 0);\n itemFitSize.inlineSize = itemInlineSize;\n itemFitSize.contentSize = itemContentSize;\n containerFitSize.inlineSize = containerInlineSize;\n containerFitSize.contentSize = containerContentSize;\n }\n }\n });\n\n fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection);\n }\n private _getWeight(type: \"size\" | \"ratio\"): number {\n const options = this.options;\n const weightPriority = options.weightPriority;\n\n if (weightPriority === type) {\n return 100;\n } else if (weightPriority === \"custom\") {\n return options[`${type}Weight`];\n }\n return 1;\n }\n}\n\nexport interface PackingGrid extends Properties {\n}\n\n\n/**\n * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1)\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * aspectRatio: 1,\n * });\n *\n * grid.aspectRatio = 1.5;\n */\n\n/**\n * The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * @ko 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n * @name Grid.PackingGrid#weightPriority\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"weightPriority\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * weightPriority: \"custom\",\n * sizeWeight: 1,\n * ratioWeight: 1,\n * });\n *\n * grid.weightPriority = \"size\";\n * // or\n * grid.weightPriority = \"ratio\";\n */\n\n/**\n * The size weight when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * sizeWeight: 1,\n * });\n *\n * grid.sizeWeight = 10;\n */\n\n\n/**\n * The weight to keep ratio when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * ratioWeight: 1,\n * });\n *\n * grid.ratioWeight = 10;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\n\nexport * from \"./grids/MasonryGrid\";\nexport * from \"./grids/JustifiedGrid\";\nexport * from \"./grids/FrameGrid\";\nexport * from \"./grids/PackingGrid\";\n\nexport * from \"./types\";\nexport * from \"./Grid\";\nexport * from \"./GridItem\";\nexport * from \"./ContainerManager\";\nexport * from \"./consts\";\nexport {\n GetterSetter,\n withGridMethods,\n withMethods,\n} from \"./utils\";\nexport default Grid;\n"],"names":["DEFAULT_GRID_OPTIONS","horizontal","useTransform","percentage","isEqualSize","isConstantSize","gap","attributePrefix","resizeDebounce","maxResizeDebounce","autoResize","preserveUIOnDestroy","defaultDirection","externalContainerManager","externalItemRenderer","renderOnPropertyChange","useFit","PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","GRID_EVENTS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","container","options","_init","setRect","width","offsetWidth","height","offsetHeight","rect","status","setContentSize","getContentSize","size","sizeName","style","preserveUI","cssText","orgCSSText","window","getComputedStyle","position","getKeys","obj","Object","keys","isString","val","isObject","isNumber","camelize","str","replace","all","letter","toUpperCase","getDataAttributes","element","dataAttributes","attributes","length","i","attribute","name","value","indexOf","GetterSetter","component","prototype","propertyTypes","shouldRender","enumerable","configurable","get","set","prevValue","scheduleRender","defineProperty","withMethods","methods","memberName","forEach","_i","args","result","_a","range","arr","push","getRangeCost","valueRange","Math","max","withGridMethods","initialRect","items","item","_this","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","posPercetage","sizePercetage","orgRect","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","cssRect","cssTexts","_b","posName","getInlineSize","filter","key","map","join","itemStatus","data","UNCHECKED","gridRect","names","__extends","containerElement","_super","start","end","clearTimeout","_resizeTimer","_maxResizeDebounceTimer","renderItems","useResize","setTimeout","_onResize","constructor","defaultOptions","document","querySelector","containerManager","ContainerManager","itemRenderer","ItemRenderer","Grid","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","checkReady","_clearRenderTimer","getItems","syncElements","_resizeContainer","updateItems","getStatus","prevInlineSize","setStatus","_renderComplete","mounted","updated","isResize","destroy","removeEventListener","_scheduleResize","_im","moreUpdated","ImReady","prefix","on","e","readyItems","isPreReadyOver","trigger","target","update","check","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","direction","prevOutline","outline","nextOutlines","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","endPoint","startPoint","resize","setContainerRect","getRect","addEventListener","Component","getColumnPoint","columnIndex","columnCount","pointCaculationName","getColumnIndex","nearestCalculationName","indexCaculationName","points","_calculateColumnSize","_calculateColumn","column","_column","columnSize","_columnSize","align","columnSizeRatio","columnSizeOption","outlineLength","itemsLength","alignPoses","_getAlignPoses","isEndDirection","pointCalculationName","point_1","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","nextEndColumnIndex","nextColumnIndex","cssInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","floor","getContainerInlineSize","items_1","columnOption","containerSize","indexes","offset","dist","countDist","totalColumnSize","MasonryGrid","single_source_shortest_paths","graph","s","d","predecessors","costs","open","BinaryHeap","x","cost","closest","u","cost_of_s_to_u","adjacent_nodes","cost_of_e","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","first_visit","pop","v","msg","Error","extract_shortest_path_from_predecessor_list","nodes","reverse","find_path","scoreFunction","content","bubbleUp","sinkDown","_n","n","parentN","parent","elemScore","child1Score","child2N","child1N","swap","child1","child2","child2Score","splitItems","path","groups","path1","path2","getExpectedColumnSize","rowSize","orgInlineSize","orgContentSize","inlineOffset","parseFloat","gridData","contentOffset","rowRange","_getRowPath","_getPath","_setStyle","maintainedTarget","widthOffset","clientWidth","scrollWidth","heightOffset","clientHeight","scrollHeight","columnRange","_getColumnRange","_getRowRange","pathLink","_getRowLink","currentNode","node","currentLink","minColumn","minRow","maxRow","lastNode","pathLength","rangeCost","lastCost","abs","_getCost","isOver","_searchRowLink","links","nextNode","nextCost","nextLink","sort","a","b","aIsOver","bIsOver","aRangeCost","bRangeCost","containerInlineSize","ratioSum","inlineSum","maintainedRatio","reduce","sum","j","lineItems","_getExpectedRowSize","_getSizeRange","minSize","maxSize","isCroppedSize","expectedInlineSize","_getExpectedInlineSize","pow","isFinite","columnRangeOption","nodeKey","results","displayedRow","sizeRange","displayedSize","groupItems","rowIndex","allGap","scale","prevItem","setCSSGridRect","JustifiedGrid","Infinity","getMaxPoint","maxPoint","getMinPoint","minPoint","getOutlinePoint","frameOutline","useFrameFill","getOutlineDist","minEndPoint","maxStartPoint","frameDist","outlineIndex","startPos","endPos","fillOutlines","frame","_getFrame","frameInlineSize","frameContentSize","frameRects","getRectSize","rectInlineSize","rectContentSize","rectsLength","startIndex","rectIndex","_c","frameRectContentPos","frameRectInlinePos","frameRectContentSize","frameRectInlineSize","isDirectionEnd","gridOutline","outlineDist","rectSizeOption","rectSizeValue","rects","passMap","y1","x1","type","_findRect","x2","y2","y","FrameGrid","rectSize","boxStatus","scaleX","scaleY","getCost","originLength","fitArea","bestFitArea","itemFitSize","containerFitSize","isContentDirection","aspectRatio","containerContentSize","BoxModel","model","_findBestFitArea","scaleTo","boxItem","getRatio","minCost","sizeWeight","_getWeight","ratioWeight","child","containerSizeCost","getOrgSizeWeight","getSize","containerRatioCost","getOrgRatio","itemInlineSize","itemContentSize","itemSize","itemRatio","containerRatio","weightPriority","PackingGrid"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAOaA,oBAAoB,GAA0B;AACzDC,EAAAA,UAAU,EAAE,KAD6C;AAEzDC,EAAAA,YAAY,EAAE,KAF2C;AAGzDC,EAAAA,UAAU,EAAE,KAH6C;AAIzDC,EAAAA,WAAW,EAAE,KAJ4C;AAKzDC,EAAAA,cAAc,EAAE,KALyC;AAMzDC,EAAAA,GAAG,EAAE,CANoD;AAOzDC,EAAAA,eAAe,EAAE,YAPwC;AAQzDC,EAAAA,cAAc,EAAE,GARyC;AASzDC,EAAAA,iBAAiB,EAAE,CATsC;AAUzDC,EAAAA,UAAU,EAAE,IAV6C;AAWzDC,EAAAA,mBAAmB,EAAE,KAXoC;AAYzDC,EAAAA,gBAAgB,EAAE,KAZuC;AAazDC,EAAAA,wBAAwB,EAAE,IAb+B;AAczDC,EAAAA,oBAAoB,EAAE,IAdmC;AAezDC,EAAAA,sBAAsB,EAAE,IAfiC;AAgBzDC,EAAAA,MAAM,EAAE;AAhBiD;IAmB/CC;;AAAZ,WAAYA;AACVA,EAAAA,4CAAA,aAAA;AACAA,EAAAA,mDAAA,oBAAA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IAAAA,WAAW,EAAE;AACbS,IAAAA,UAAU,EAAE;AACZE,IAAAA,WAAW,EAAE;AACbY,IAAAA,cAAc,EAAE;IALJ;AARHC,EAAAA,WAAW,eADvB9Z,eACY8Z,YAAA;AA+Ib,oBAAA;AAAC,EA/IgCvU,KAAjC;AAqJA;;;;;;;;;;;;;;;AAeA;;;;;;;;;;;;;;;;;;;;AAoBA;;;;;;;;;;;;;;;AAgBA;;;;;;;;;;;;;;;ACpRA;;;;;;;;;"} \ No newline at end of file diff --git a/dist/grid.js b/dist/grid.js new file mode 100644 index 0000000..9f32b0e --- /dev/null +++ b/dist/grid.js @@ -0,0 +1,5288 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.3.1 +*/ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : + typeof define === 'function' && define.amd ? define(factory) : + (global = global || self, global.Grid = factory()); +}(this, (function () { 'use strict'; + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + + return extendStatics(d, b); + }; + + function __extends(d, b) { + if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + var __assign = function () { + __assign = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign.apply(this, arguments); + }; + function __decorate(decorators, target, key, desc) { + var c = arguments.length, + r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, + d; + 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; + return c > 3 && r && Object.defineProperty(target, key, r), r; + } + /** @deprecated */ + + function __spreadArrays() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + 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]; + + return r; + } + + /* + Copyright (c) NAVER Corp. + name: @egjs/component + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-component + version: 3.0.1 + */ + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + function __values(o) { + var s = typeof Symbol === "function" && Symbol.iterator, + m = s && o[s], + i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { + value: o && o[i++], + done: !o + }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + function __read(o, n) { + var m = typeof Symbol === "function" && o[Symbol.iterator]; + if (!m) return o; + var i = m.call(o), + r, + ar = [], + e; + + try { + while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); + } catch (error) { + e = { + error: error + }; + } finally { + try { + if (r && !r.done && (m = i["return"])) m.call(i); + } finally { + if (e) throw e.error; + } + } + + return ar; + } + function __spread() { + for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); + + return ar; + } + + /* + * Copyright (c) 2015 NAVER Corp. + * egjs projects are licensed under the MIT license + */ + var isUndefined = function (value) { + return typeof value === "undefined"; + }; + + /** + * Event class to provide additional properties + * @ko Component에서 추가적인 프로퍼티를 제공하는 이벤트 클래스 + */ + + var ComponentEvent = + /*#__PURE__*/ + function () { + /** + * Create a new instance of ComponentEvent. + * @ko ComponentEvent의 새로운 인스턴스를 생성한다. + * @param eventType The name of the event.이벤트 이름. + * @param props An object that contains additional event properties.추가적인 이벤트 프로퍼티 오브젝트. + */ + function ComponentEvent(eventType, props) { + var e_1, _a; + + this.eventType = eventType; + this._canceled = false; + if (!props) return; + + try { + for (var _b = __values(Object.keys(props)), _c = _b.next(); !_c.done; _c = _b.next()) { + var key = _c.value; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment + + this[key] = props[key]; + } + } catch (e_1_1) { + e_1 = { + error: e_1_1 + }; + } finally { + try { + if (_c && !_c.done && (_a = _b.return)) _a.call(_b); + } finally { + if (e_1) throw e_1.error; + } + } + } + /** + * Stop the event. {@link ComponentEvent#isCanceled} will return `true` after. + * @ko 이벤트를 중단한다. 이후 {@link ComponentEvent#isCanceled}가 `true`를 반환한다. + */ + + + var __proto = ComponentEvent.prototype; + + __proto.stop = function () { + this._canceled = true; + }; + /** + * Returns a boolean value that indicates whether {@link ComponentEvent#stop} is called before. + * @ko {@link ComponentEvent#stop}이 호출되었는지 여부를 반환한다. + * @return {boolean} A boolean value that indicates whether {@link ComponentEvent#stop} is called before.이전에 {@link ComponentEvent#stop}이 불려졌는지 여부를 반환한다. + */ + + + __proto.isCanceled = function () { + return this._canceled; + }; + + return ComponentEvent; + }(); + + /** + * A class used to manage events in a component + * @ko 컴포넌트의 이벤트을 관리할 수 있게 하는 클래스 + */ + + var Component = + /*#__PURE__*/ + function () { + /** + * @support {"ie": "7+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.1+ (except 3.x)"} + */ + function Component() { + this._eventHandler = {}; + } + /** + * Trigger a custom event. + * @ko 커스텀 이벤트를 발생시킨다 + * @param {string | ComponentEvent} event The name of the custom event to be triggered or an instance of the ComponentEvent발생할 커스텀 이벤트의 이름 또는 ComponentEvent의 인스턴스 + * @param {any[]} params Event data to be sent when triggering a custom event 커스텀 이벤트가 발생할 때 전달할 데이터 + * @return An instance of the component itself컴포넌트 자신의 인스턴스 + * @example + * ```ts + * import Component, { ComponentEvent } from "@egjs/component"; + * + * class Some extends Component<{ + * beforeHi: ComponentEvent<{ foo: number; bar: string }>; + * hi: { foo: { a: number; b: boolean } }; + * someEvent: (foo: number, bar: string) => void; + * someOtherEvent: void; // When there's no event argument + * }> { + * some(){ + * if(this.trigger("beforeHi")){ // When event call to stop return false. + * this.trigger("hi");// fire hi event. + * } + * } + * } + * + * const some = new Some(); + * some.on("beforeHi", e => { + * if(condition){ + * e.stop(); // When event call to stop, `hi` event not call. + * } + * // `currentTarget` is component instance. + * console.log(some === e.currentTarget); // true + * + * typeof e.foo; // number + * typeof e.bar; // string + * }); + * some.on("hi", e => { + * typeof e.foo.b; // boolean + * }); + * // If you want to more know event design. You can see article. + * // https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F + * ``` + */ + + + var __proto = Component.prototype; + + __proto.trigger = function (event) { + var params = []; + + for (var _i = 1; _i < arguments.length; _i++) { + params[_i - 1] = arguments[_i]; + } + + var eventName = event instanceof ComponentEvent ? event.eventType : event; + + var handlers = __spread(this._eventHandler[eventName] || []); + + if (handlers.length <= 0) { + return this; + } + + if (event instanceof ComponentEvent) { + event.currentTarget = this; + handlers.forEach(function (handler) { + handler(event); + }); + } else { + handlers.forEach(function (handler) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-call + handler.apply(void 0, __spread(params)); + }); + } + + return this; + }; + /** + * Executed event just one time. + * @ko 이벤트가 한번만 실행된다. + * @param {string} eventName The name of the event to be attached or an event name - event handler mapped object.등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트 + * @param {function} handlerToAttach The handler function of the event to be attached 등록할 이벤트의 핸들러 함수 + * @return An instance of the component itself컴포넌트 자신의 인스턴스 + * @example + * ```ts + * import Component, { ComponentEvent } from "@egjs/component"; + * + * class Some extends Component<{ + * hi: ComponentEvent; + * }> { + * hi() { + * alert("hi"); + * } + * thing() { + * this.once("hi", this.hi); + * } + * } + * + * var some = new Some(); + * some.thing(); + * some.trigger(new ComponentEvent("hi")); + * // fire alert("hi"); + * some.trigger(new ComponentEvent("hi")); + * // Nothing happens + * ``` + */ + + + __proto.once = function (eventName, handlerToAttach) { + var _this = this; + + if (typeof eventName === "object" && isUndefined(handlerToAttach)) { + var eventHash = eventName; + + for (var key in eventHash) { + this.once(key, eventHash[key]); + } + + return this; + } else if (typeof eventName === "string" && typeof handlerToAttach === "function") { + var listener_1 = function () { + var args = []; + + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } // eslint-disable-next-line @typescript-eslint/no-unsafe-call + + + handlerToAttach.apply(void 0, __spread(args)); + + _this.off(eventName, listener_1); + }; + + this.on(eventName, listener_1); + } + + return this; + }; + /** + * Checks whether an event has been attached to a component. + * @ko 컴포넌트에 이벤트가 등록됐는지 확인한다. + * @param {string} eventName The name of the event to be attached 등록 여부를 확인할 이벤트의 이름 + * @return {boolean} Indicates whether the event is attached. 이벤트 등록 여부 + * @example + * ```ts + * import Component from "@egjs/component"; + * + * class Some extends Component<{ + * hi: void; + * }> { + * some() { + * this.hasOn("hi");// check hi event. + * } + * } + * ``` + */ + + + __proto.hasOn = function (eventName) { + return !!this._eventHandler[eventName]; + }; + /** + * Attaches an event to a component. + * @ko 컴포넌트에 이벤트를 등록한다. + * @param {string} eventName The name of the event to be attached or an event name - event handler mapped object.등록할 이벤트의 이름 또는 이벤트 이름-핸들러 오브젝트 + * @param {function} handlerToAttach The handler function of the event to be attached 등록할 이벤트의 핸들러 함수 + * @return An instance of a component itself컴포넌트 자신의 인스턴스 + * @example + * ```ts + * import Component, { ComponentEvent } from "@egjs/component"; + * + * class Some extends Component<{ + * hi: void; + * }> { + * hi() { + * console.log("hi"); + * } + * some() { + * this.on("hi",this.hi); //attach event + * } + * } + * ``` + */ + + + __proto.on = function (eventName, handlerToAttach) { + if (typeof eventName === "object" && isUndefined(handlerToAttach)) { + var eventHash = eventName; + + for (var name in eventHash) { + this.on(name, eventHash[name]); + } + + return this; + } else if (typeof eventName === "string" && typeof handlerToAttach === "function") { + var handlerList = this._eventHandler[eventName]; + + if (isUndefined(handlerList)) { + this._eventHandler[eventName] = []; + handlerList = this._eventHandler[eventName]; + } + + handlerList.push(handlerToAttach); + } + + return this; + }; + /** + * Detaches an event from the component.
If the `eventName` is not given this will detach all event handlers attached.
If the `handlerToDetach` is not given, this will detach all event handlers for `eventName`. + * @ko 컴포넌트에 등록된 이벤트를 해제한다.
`eventName`이 주어지지 않았을 경우 모든 이벤트 핸들러를 제거한다.
`handlerToAttach`가 주어지지 않았을 경우 `eventName`에 해당하는 모든 이벤트 핸들러를 제거한다. + * @param {string?} eventName The name of the event to be detached 해제할 이벤트의 이름 + * @param {function?} handlerToDetach The handler function of the event to be detached 해제할 이벤트의 핸들러 함수 + * @return An instance of a component itself 컴포넌트 자신의 인스턴스 + * @example + * ```ts + * import Component, { ComponentEvent } from "@egjs/component"; + * + * class Some extends Component<{ + * hi: void; + * }> { + * hi() { + * console.log("hi"); + * } + * some() { + * this.off("hi",this.hi); //detach event + * } + * } + * ``` + */ + + + __proto.off = function (eventName, handlerToDetach) { + var e_1, _a; // Detach all event handlers. + + + if (isUndefined(eventName)) { + this._eventHandler = {}; + return this; + } // Detach all handlers for eventname or detach event handlers by object. + + + if (isUndefined(handlerToDetach)) { + if (typeof eventName === "string") { + delete this._eventHandler[eventName]; + return this; + } else { + var eventHash = eventName; + + for (var name in eventHash) { + this.off(name, eventHash[name]); + } + + return this; + } + } // Detach single event handler + + + var handlerList = this._eventHandler[eventName]; + + if (handlerList) { + var idx = 0; + + try { + for (var handlerList_1 = __values(handlerList), handlerList_1_1 = handlerList_1.next(); !handlerList_1_1.done; handlerList_1_1 = handlerList_1.next()) { + var handlerFunction = handlerList_1_1.value; + + if (handlerFunction === handlerToDetach) { + handlerList.splice(idx, 1); + + if (handlerList.length <= 0) { + delete this._eventHandler[eventName]; + } + + break; + } + + idx++; + } + } catch (e_1_1) { + e_1 = { + error: e_1_1 + }; + } finally { + try { + if (handlerList_1_1 && !handlerList_1_1.done && (_a = handlerList_1.return)) _a.call(handlerList_1); + } finally { + if (e_1) throw e_1.error; + } + } + } + + return this; + }; + /** + * Version info string + * @ko 버전정보 문자열 + * @name VERSION + * @static + * @example + * Component.VERSION; // ex) 3.0.0 + * @memberof Component + */ + + + Component.VERSION = "3.0.1"; + return Component; + }(); + + var DEFAULT_GRID_OPTIONS = { + horizontal: false, + useTransform: false, + percentage: false, + isEqualSize: false, + isConstantSize: false, + gap: 0, + attributePrefix: "data-grid-", + resizeDebounce: 100, + maxResizeDebounce: 0, + autoResize: true, + preserveUIOnDestroy: false, + defaultDirection: "end", + externalContainerManager: null, + externalItemRenderer: null, + renderOnPropertyChange: true, + useFit: true + }; + var PROPERTY_TYPE; + + (function (PROPERTY_TYPE) { + PROPERTY_TYPE[PROPERTY_TYPE["PROPERTY"] = 1] = "PROPERTY"; + PROPERTY_TYPE[PROPERTY_TYPE["RENDER_PROPERTY"] = 2] = "RENDER_PROPERTY"; + })(PROPERTY_TYPE || (PROPERTY_TYPE = {})); + + var MOUNT_STATE; + + (function (MOUNT_STATE) { + MOUNT_STATE[MOUNT_STATE["UNCHECKED"] = 1] = "UNCHECKED"; + MOUNT_STATE[MOUNT_STATE["UNMOUNTED"] = 2] = "UNMOUNTED"; + MOUNT_STATE[MOUNT_STATE["MOUNTED"] = 3] = "MOUNTED"; + })(MOUNT_STATE || (MOUNT_STATE = {})); + + var UPDATE_STATE; + + (function (UPDATE_STATE) { + UPDATE_STATE[UPDATE_STATE["NEED_UPDATE"] = 1] = "NEED_UPDATE"; + UPDATE_STATE[UPDATE_STATE["WAIT_LOADING"] = 2] = "WAIT_LOADING"; + UPDATE_STATE[UPDATE_STATE["UPDATED"] = 3] = "UPDATED"; + })(UPDATE_STATE || (UPDATE_STATE = {})); + + var GRID_PROPERTY_TYPES = { + gap: PROPERTY_TYPE.RENDER_PROPERTY, + defaultDirection: PROPERTY_TYPE.PROPERTY, + renderOnPropertyChange: PROPERTY_TYPE.PROPERTY, + preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY, + useFit: PROPERTY_TYPE.PROPERTY + }; + var GRID_METHODS = ["syncElements", "updateItems", "getItems", "setItems", "renderItems", "getContainerInlineSize", "getContainerElement"]; + var GRID_EVENTS = ["renderComplete", "contentError"]; + var RECT_NAMES = { + horizontal: { + inlinePos: "top", + contentPos: "left", + inlineSize: "height", + contentSize: "width" + }, + vertical: { + inlinePos: "left", + contentPos: "top", + inlineSize: "width", + contentSize: "height" + } + }; + + var ContainerManager = + /*#__PURE__*/ + function () { + function ContainerManager(container, options) { + this.container = container; + this.options = __assign({ + horizontal: DEFAULT_GRID_OPTIONS.horizontal + }, options); + + this._init(); + } + + var __proto = ContainerManager.prototype; + + __proto.resize = function () { + var container = this.container; + this.setRect({ + width: container.offsetWidth, + height: container.offsetHeight + }); + }; + + __proto.getRect = function () { + return this.rect; + }; + + __proto.setRect = function (rect) { + this.rect = __assign({}, rect); + }; + + __proto.getInlineSize = function () { + return this.rect[this.options.horizontal ? "height" : "width"]; + }; + + __proto.getContentSize = function () { + return this.rect[this.options.horizontal ? "width" : "height"]; + }; + + __proto.getStatus = function () { + return { + rect: __assign({}, this.rect) + }; + }; + + __proto.setStatus = function (status) { + this.rect = __assign({}, status.rect); + this.setContentSize(this.getContentSize()); + }; + + __proto.setContentSize = function (size) { + var sizeName = this.options.horizontal ? "width" : "height"; + this.rect[sizeName] = size; + this.container.style[sizeName] = size + "px"; + }; + + __proto.destroy = function (options) { + if (options === void 0) { + options = {}; + } + + if (!options.preserveUI) { + this.container.style.cssText = this.orgCSSText; + } + }; + + __proto._init = function () { + var container = this.container; + var style = window.getComputedStyle(container); + this.orgCSSText = container.style.cssText; + + if (style.position === "static") { + container.style.position = "relative"; + } + }; + + return ContainerManager; + }(); + + /* + Copyright (c) NAVER Corp. + name: @egjs/component + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-component + version: 2.2.2 + */ + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + function __values$1(o) { + var s = typeof Symbol === "function" && Symbol.iterator, + m = s && o[s], + i = 0; + if (m) return m.call(o); + if (o && typeof o.length === "number") return { + next: function () { + if (o && i >= o.length) o = void 0; + return { + value: o && o[i++], + done: !o + }; + } + }; + throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); + } + + /* + * Copyright (c) 2015 NAVER Corp. + * egjs projects are licensed under the MIT license + */ + + function isUndefined$1(value) { + return typeof value === "undefined"; + } + /** + * A class used to manage events in a component + * @ko 컴포넌트의 이벤트을 관리할 수 있게 하는 클래스 + * @alias eg.Component + */ + + + var Component$1 = + /*#__PURE__*/ + function () { + /** + * @support {"ie": "7+", "ch" : "latest", "ff" : "latest", "sf" : "latest", "edge" : "latest", "ios" : "7+", "an" : "2.1+ (except 3.x)"} + */ + function Component() { + /** + * @deprecated + * @private + */ + this.options = {}; + this._eventHandler = {}; + } + /** + * Triggers a custom event. + * @ko 커스텀 이벤트를 발생시킨다 + * @param {string} eventName The name of the custom event to be triggered 발생할 커스텀 이벤트의 이름 + * @param {object} customEvent Event data to be sent when triggering a custom event 커스텀 이벤트가 발생할 때 전달할 데이터 + * @param {any[]} restParam Additional parameters when triggering a custom event 커스텀 이벤트가 발생할 때 필요시 추가적으로 전달할 데이터 + * @return Indicates whether the event has occurred. If the stop() method is called by a custom event handler, it will return false and prevent the event from occurring. Ref 이벤트 발생 여부. 커스텀 이벤트 핸들러에서 stop() 메서드를 호출하면 'false'를 반환하고 이벤트 발생을 중단한다. 참고 + * @example + * ``` + * class Some extends eg.Component { + * some(){ + * if(this.trigger("beforeHi")){ // When event call to stop return false. + * this.trigger("hi");// fire hi event. + * } + * } + * } + * + * const some = new Some(); + * some.on("beforeHi", (e) => { + * if(condition){ + * e.stop(); // When event call to stop, `hi` event not call. + * } + * }); + * some.on("hi", (e) => { + * // `currentTarget` is component instance. + * console.log(some === e.currentTarget); // true + * }); + * // If you want to more know event design. You can see article. + * // https://github.com/naver/egjs-component/wiki/How-to-make-Component-event-design%3F + * ``` + */ + + + var __proto = Component.prototype; + + __proto.trigger = function (eventName) { + var _this = this; + + var params = []; + + for (var _i = 1; _i < arguments.length; _i++) { + params[_i - 1] = arguments[_i]; + } + + var handlerList = this._eventHandler[eventName] || []; + var hasHandlerList = handlerList.length > 0; + + if (!hasHandlerList) { + return true; + } + + var customEvent = params[0] || {}; + var restParams = params.slice(1); // If detach method call in handler in first time then handler list calls. + + handlerList = handlerList.concat(); + var isCanceled = false; // This should be done like this to pass previous tests + + customEvent.eventType = eventName; + + customEvent.stop = function () { + isCanceled = true; + }; + + customEvent.currentTarget = this; + var arg = [customEvent]; + + if (restParams.length >= 1) { + arg = arg.concat(restParams); + } + + handlerList.forEach(function (handler) { + handler.apply(_this, arg); + }); + return !isCanceled; + }; + /** + * Executed event just one time. + * @ko 이벤트가 한번만 실행된다. + * @param {string} eventName The name of the event to be attached 등록할 이벤트의 이름 + * @param {function} handlerToAttach The handler function of the event to be attached 등록할 이벤트의 핸들러 함수 + * @return An instance of a component itself컴포넌트 자신의 인스턴스 + * @example + * ``` + * class Some extends eg.Component { + * hi() { + * alert("hi"); + * } + * thing() { + * this.once("hi", this.hi); + * } + * + * var some = new Some(); + * some.thing(); + * some.trigger("hi"); + * // fire alert("hi"); + * some.trigger("hi"); + * // Nothing happens + * ``` + */ + + + __proto.once = function (eventName, handlerToAttach) { + var _this = this; + + if (typeof eventName === "object" && isUndefined$1(handlerToAttach)) { + var eventHash = eventName; + + for (var key in eventHash) { + this.once(key, eventHash[key]); + } + + return this; + } else if (typeof eventName === "string" && typeof handlerToAttach === "function") { + var listener_1 = function () { + var args = []; + + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + + handlerToAttach.apply(_this, args); + + _this.off(eventName, listener_1); + }; + + this.on(eventName, listener_1); + } + + return this; + }; + /** + * Checks whether an event has been attached to a component. + * @ko 컴포넌트에 이벤트가 등록됐는지 확인한다. + * @param {string} eventName The name of the event to be attached 등록 여부를 확인할 이벤트의 이름 + * @return {boolean} Indicates whether the event is attached. 이벤트 등록 여부 + * @example + * ``` + * class Some extends eg.Component { + * some() { + * this.hasOn("hi");// check hi event. + * } + * } + * ``` + */ + + + __proto.hasOn = function (eventName) { + return !!this._eventHandler[eventName]; + }; + /** + * Attaches an event to a component. + * @ko 컴포넌트에 이벤트를 등록한다. + * @param {string} eventName The name of the event to be attached 등록할 이벤트의 이름 + * @param {function} handlerToAttach The handler function of the event to be attached 등록할 이벤트의 핸들러 함수 + * @return An instance of a component itself컴포넌트 자신의 인스턴스 + * @example + * ``` + * class Some extends eg.Component { + * hi() { + * console.log("hi"); + * } + * some() { + * this.on("hi",this.hi); //attach event + * } + * } + * ``` + */ + + + __proto.on = function (eventName, handlerToAttach) { + if (typeof eventName === "object" && isUndefined$1(handlerToAttach)) { + var eventHash = eventName; + + for (var name in eventHash) { + this.on(name, eventHash[name]); + } + + return this; + } else if (typeof eventName === "string" && typeof handlerToAttach === "function") { + var handlerList = this._eventHandler[eventName]; + + if (isUndefined$1(handlerList)) { + this._eventHandler[eventName] = []; + handlerList = this._eventHandler[eventName]; + } + + handlerList.push(handlerToAttach); + } + + return this; + }; + /** + * Detaches an event from the component. + * @ko 컴포넌트에 등록된 이벤트를 해제한다 + * @param {string} eventName The name of the event to be detached 해제할 이벤트의 이름 + * @param {function} handlerToDetach The handler function of the event to be detached 해제할 이벤트의 핸들러 함수 + * @return An instance of a component itself 컴포넌트 자신의 인스턴스 + * @example + * ``` + * class Some extends eg.Component { + * hi() { + * console.log("hi"); + * } + * some() { + * this.off("hi",this.hi); //detach event + * } + * } + * ``` + */ + + + __proto.off = function (eventName, handlerToDetach) { + var e_1, _a; // Detach all event handlers. + + + if (isUndefined$1(eventName)) { + this._eventHandler = {}; + return this; + } // Detach all handlers for eventname or detach event handlers by object. + + + if (isUndefined$1(handlerToDetach)) { + if (typeof eventName === "string") { + delete this._eventHandler[eventName]; + return this; + } else { + var eventHash = eventName; + + for (var name in eventHash) { + this.off(name, eventHash[name]); + } + + return this; + } + } // Detach single event handler + + + var handlerList = this._eventHandler[eventName]; + + if (handlerList) { + var idx = 0; + + try { + for (var handlerList_1 = __values$1(handlerList), handlerList_1_1 = handlerList_1.next(); !handlerList_1_1.done; handlerList_1_1 = handlerList_1.next()) { + var handlerFunction = handlerList_1_1.value; + + if (handlerFunction === handlerToDetach) { + handlerList.splice(idx, 1); + break; + } + + idx++; + } + } catch (e_1_1) { + e_1 = { + error: e_1_1 + }; + } finally { + try { + if (handlerList_1_1 && !handlerList_1_1.done && (_a = handlerList_1.return)) _a.call(handlerList_1); + } finally { + if (e_1) throw e_1.error; + } + } + } + + return this; + }; + /** + * Version info string + * @ko 버전정보 문자열 + * @name VERSION + * @static + * @example + * eg.Component.VERSION; // ex) 2.0.0 + * @memberof eg.Component + */ + + + Component.VERSION = "2.2.2"; + return Component; + }(); + + /* + Copyright (c) 2020-present NAVER Corp. + name: @egjs/imready + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-imready + version: 1.1.3 + */ + + /*! ***************************************************************************** + Copyright (c) Microsoft Corporation. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH + REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, + INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM + LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR + OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR + PERFORMANCE OF THIS SOFTWARE. + ***************************************************************************** */ + + /* global Reflect, Promise */ + var extendStatics$1 = function (d, b) { + extendStatics$1 = Object.setPrototypeOf || { + __proto__: [] + } instanceof Array && function (d, b) { + d.__proto__ = b; + } || function (d, b) { + for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; + }; + + return extendStatics$1(d, b); + }; + + function __extends$1(d, b) { + extendStatics$1(d, b); + + function __() { + this.constructor = d; + } + + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + } + var __assign$1 = function () { + __assign$1 = Object.assign || function __assign(t) { + for (var s, i = 1, n = arguments.length; i < n; i++) { + s = arguments[i]; + + for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; + } + + return t; + }; + + return __assign$1.apply(this, arguments); + }; + function __spreadArrays$1() { + for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; + + 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]; + + return r; + } + + /* + egjs-imready + Copyright (c) 2020-present NAVER Corp. + MIT license + */ + var isWindow = typeof window !== "undefined"; + var ua = isWindow ? window.navigator.userAgent : ""; + var SUPPORT_COMPUTEDSTYLE = isWindow ? !!("getComputedStyle" in window) : false; + var IS_IE = /MSIE|Trident|Windows Phone|Edge/.test(ua); + var SUPPORT_ADDEVENTLISTENER = isWindow ? !!("addEventListener" in document) : false; + var WIDTH = "width"; + var HEIGHT = "height"; + + function getAttribute(el, name) { + return el.getAttribute(name) || ""; + } + function toArray(arr) { + return [].slice.call(arr); + } + function hasSizeAttribute(target, prefix) { + if (prefix === void 0) { + prefix = "data-"; + } + + return !!target.getAttribute(prefix + "width"); + } + function hasLoadingAttribute(target) { + return "loading" in target && target.getAttribute("loading") === "lazy"; + } + function hasSkipAttribute(target, prefix) { + if (prefix === void 0) { + prefix = "data-"; + } + + return !!target.getAttribute(prefix + "skip"); + } + function addEvent(element, type, handler) { + if (SUPPORT_ADDEVENTLISTENER) { + element.addEventListener(type, handler, false); + } else if (element.attachEvent) { + element.attachEvent("on" + type, handler); + } else { + element["on" + type] = handler; + } + } + function removeEvent(element, type, handler) { + if (element.removeEventListener) { + element.removeEventListener(type, handler, false); + } else if (element.detachEvent) { + element.detachEvent("on" + type, handler); + } else { + element["on" + type] = null; + } + } + function innerWidth(el) { + return getSize(el, "Width"); + } + function innerHeight(el) { + return getSize(el, "Height"); + } + function getStyles(el) { + return (SUPPORT_COMPUTEDSTYLE ? window.getComputedStyle(el) : el.currentStyle) || {}; + } + + function getSize(el, name) { + var size = el["client" + name] || el["offset" + name]; + return parseFloat(size || getStyles(el)[name.toLowerCase()]) || 0; + } + + function getContentElements(element, tags, prefix) { + var skipElements = toArray(element.querySelectorAll(__spreadArrays$1(["[" + prefix + "skip] [" + prefix + "width]"], tags.map(function (tag) { + return ["[" + prefix + "skip] " + tag, tag + "[" + prefix + "skip]", "[" + prefix + "width] " + tag].join(", "); + })).join(", "))); + return toArray(element.querySelectorAll("[" + prefix + "width], " + tags.join(", "))).filter(function (el) { + return skipElements.indexOf(el) === -1; + }); + } + + /* + egjs-imready + Copyright (c) 2020-present NAVER Corp. + MIT license + */ + var elements = []; + function addAutoSizer(element, prefix) { + !elements.length && addEvent(window, "resize", resizeAllAutoSizers); + element.__PREFIX__ = prefix; + elements.push(element); + resize(element); + } + function removeAutoSizer(element, prefix) { + var index = elements.indexOf(element); + + if (index < 0) { + return; + } + + var fixed = getAttribute(element, prefix + "fixed"); + delete element.__PREFIX__; + element.style[fixed === HEIGHT ? WIDTH : HEIGHT] = ""; + elements.splice(index, 1); + !elements.length && removeEvent(window, "resize", resizeAllAutoSizers); + } + + function resize(element, prefix) { + if (prefix === void 0) { + prefix = "data-"; + } + + var elementPrefix = element.__PREFIX__ || prefix; + var dataWidth = parseInt(getAttribute(element, "" + elementPrefix + WIDTH), 10) || 0; + var dataHeight = parseInt(getAttribute(element, "" + elementPrefix + HEIGHT), 10) || 0; + var fixed = getAttribute(element, elementPrefix + "fixed"); + + if (fixed === HEIGHT) { + var size = innerHeight(element) || dataHeight; + element.style[WIDTH] = dataWidth / dataHeight * size + "px"; + } else { + var size = innerWidth(element) || dataWidth; + element.style[HEIGHT] = dataHeight / dataWidth * size + "px"; + } + } + + function resizeAllAutoSizers() { + elements.forEach(function (element) { + resize(element); + }); + } + + var Loader = + /*#__PURE__*/ + function (_super) { + __extends$1(Loader, _super); + + function Loader(element, options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.isReady = false; + _this.isPreReady = false; + _this.hasDataSize = false; + _this.hasLoading = false; + _this.isSkip = false; + + _this.onCheck = function (e) { + _this.clear(); + + if (e && e.type === "error") { + _this.onError(_this.element); + } // I'm pre-ready and ready! + + + var withPreReady = !_this.hasDataSize && !_this.hasLoading; + + _this.onReady(withPreReady); + }; + + _this.options = __assign$1({ + prefix: "data-" + }, options); + _this.element = element; + _this.hasDataSize = hasSizeAttribute(element, _this.options.prefix); + _this.hasLoading = hasLoadingAttribute(element); + _this.isSkip = hasSkipAttribute(_this.element); + return _this; + } + + var __proto = Loader.prototype; + + __proto.check = function () { + if (this.isSkip || !this.checkElement()) { + // I'm Ready + this.onAlreadyReady(true); + return false; + } + + if (this.hasDataSize) { + addAutoSizer(this.element, this.options.prefix); + } + + if (this.hasDataSize || this.hasLoading) { + // I'm Pre Ready + this.onAlreadyPreReady(); + } // Wati Pre Ready, Ready + + + return true; + }; + + __proto.addEvents = function () { + var _this = this; + + var element = this.element; + this.constructor.EVENTS.forEach(function (name) { + addEvent(element, name, _this.onCheck); + }); + }; + + __proto.clear = function () { + var _this = this; + + var element = this.element; + this.constructor.EVENTS.forEach(function (name) { + removeEvent(element, name, _this.onCheck); + }); + this.removeAutoSizer(); + }; + + __proto.destroy = function () { + this.clear(); + this.off(); + }; + + __proto.removeAutoSizer = function () { + if (this.hasDataSize) { + // I'm already ready. + var prefix = this.options.prefix; + removeAutoSizer(this.element, prefix); + } + }; + + __proto.onError = function (target) { + this.trigger("error", { + element: this.element, + target: target + }); + }; + + __proto.onPreReady = function () { + if (this.isPreReady) { + return; + } + + this.isPreReady = true; + this.trigger("preReady", { + element: this.element, + hasLoading: this.hasLoading, + isSkip: this.isSkip + }); + }; + + __proto.onReady = function (withPreReady) { + if (this.isReady) { + return; + } + + withPreReady = !this.isPreReady && withPreReady; + + if (withPreReady) { + this.isPreReady = true; + } + + this.removeAutoSizer(); + this.isReady = true; + this.trigger("ready", { + element: this.element, + withPreReady: withPreReady, + hasLoading: this.hasLoading, + isSkip: this.isSkip + }); + }; + + __proto.onAlreadyError = function (target) { + var _this = this; + + setTimeout(function () { + _this.onError(target); + }); + }; + + __proto.onAlreadyPreReady = function () { + var _this = this; + + setTimeout(function () { + _this.onPreReady(); + }); + }; + + __proto.onAlreadyReady = function (withPreReady) { + var _this = this; + + setTimeout(function () { + _this.onReady(withPreReady); + }); + }; + + Loader.EVENTS = []; + return Loader; + }(Component$1); + + var ElementLoader = + /*#__PURE__*/ + function (_super) { + __extends$1(ElementLoader, _super); + + function ElementLoader() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = ElementLoader.prototype; + + __proto.setHasLoading = function (hasLoading) { + this.hasLoading = hasLoading; + }; + + __proto.check = function () { + if (this.isSkip) { + // I'm Ready + this.onAlreadyReady(true); + return false; + } + + if (this.hasDataSize) { + addAutoSizer(this.element, this.options.prefix); + this.onAlreadyPreReady(); + } else { + // has not data size + this.trigger("requestChildren"); + } + + return true; + }; + + __proto.checkElement = function () { + return true; + }; + + __proto.destroy = function () { + this.clear(); + this.trigger("requestDestroy"); + this.off(); + }; + + __proto.onAlreadyPreReady = function () { + // has data size + _super.prototype.onAlreadyPreReady.call(this); + + this.trigger("reqeustReadyChildren"); + }; + + ElementLoader.EVENTS = []; + return ElementLoader; + }(Loader); + + /** + * @alias eg.ImReady + * @extends eg.Component + */ + + var ImReadyManager = + /*#__PURE__*/ + function (_super) { + __extends$1(ImReadyManager, _super); + /** + * @param - ImReady's options + */ + + + function ImReadyManager(options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.readyCount = 0; + _this.preReadyCount = 0; + _this.totalCount = 0; + _this.totalErrorCount = 0; + _this.isPreReadyOver = true; + _this.elementInfos = []; + _this.options = __assign$1({ + loaders: {}, + prefix: "data-" + }, options); + return _this; + } + /** + * Checks whether elements are in the ready state. + * @ko 엘리먼트가 준비 상태인지 체크한다. + * @elements - Elements to check ready status. 준비 상태를 체크할 엘리먼트들. + * @example + * ```html + *
+ * + * + * + *
+ * ``` + * ## Javascript + * ```js + * import ImReady from "@egjs/imready"; + * + * const im = new ImReady(); // umd: eg.ImReady + * im.check(document.querySelectorAll("img")).on({ + * preReadyElement: e => { + * // 1, 3 + * // 2, 3 + * // 3, 3 + * console.log(e.preReadyCount, e.totalCount), + * }, + * }); + * ``` + */ + + + var __proto = ImReadyManager.prototype; + + __proto.check = function (elements) { + var _this = this; + + var prefix = this.options.prefix; + this.clear(); + this.elementInfos = toArray(elements).map(function (element, index) { + var loader = _this.getLoader(element, { + prefix: prefix + }); + + loader.check(); + loader.on("error", function (e) { + _this.onError(index, e.target); + }).on("preReady", function (e) { + var info = _this.elementInfos[index]; + info.hasLoading = e.hasLoading; + info.isSkip = e.isSkip; + + var isPreReady = _this.checkPreReady(index); + + _this.onPreReadyElement(index); + + isPreReady && _this.onPreReady(); + }).on("ready", function (_a) { + var withPreReady = _a.withPreReady, + hasLoading = _a.hasLoading, + isSkip = _a.isSkip; + var info = _this.elementInfos[index]; + info.hasLoading = hasLoading; + info.isSkip = isSkip; + + var isPreReady = withPreReady && _this.checkPreReady(index); + + var isReady = _this.checkReady(index); // Pre-ready and ready occur simultaneously + + + withPreReady && _this.onPreReadyElement(index); + + _this.onReadyElement(index); + + isPreReady && _this.onPreReady(); + isReady && _this.onReady(); + }); + return { + loader: loader, + element: element, + hasLoading: false, + hasError: false, + isPreReady: false, + isReady: false, + isSkip: false + }; + }); + var length = this.elementInfos.length; + this.totalCount = length; + + if (!length) { + setTimeout(function () { + _this.onPreReady(); + + _this.onReady(); + }); + } + + return this; + }; + /** + * Gets the total count of elements to be checked. + * @ko 체크하는 element의 총 개수를 가져온다. + */ + + + __proto.getTotalCount = function () { + return this.totalCount; + }; + /** + * Whether the elements are all pre-ready. (all sizes are known) + * @ko 엘리먼트들이 모두 사전 준비가 됐는지 (사이즈를 전부 알 수 있는지) 여부. + */ + + + __proto.isPreReady = function () { + return this.elementInfos.every(function (info) { + return info.isPreReady; + }); + }; + /** + * Whether the elements are all ready. + * @ko 엘리먼트들이 모두 준비가 됐는지 여부. + */ + + + __proto.isReady = function () { + return this.elementInfos.every(function (info) { + return info.isReady; + }); + }; + /** + * Whether an error has occurred in the elements in the current state. + * @ko 현재 상태에서 엘리먼트들이 에러가 발생했는지 여부. + */ + + + __proto.hasError = function () { + return this.totalErrorCount > 0; + }; + /** + * Clears events of elements being checked. + * @ko 체크 중인 엘리먼트들의 이벤트를 해제 한다. + */ + + + __proto.clear = function () { + this.isPreReadyOver = false; + this.totalCount = 0; + this.preReadyCount = 0; + this.readyCount = 0; + this.totalErrorCount = 0; + this.elementInfos.forEach(function (info) { + if (!info.isReady && info.loader) { + info.loader.destroy(); + } + }); + this.elementInfos = []; + }; + /** + * Destory all events. + * @ko 모든 이벤트를 해제 한다. + */ + + + __proto.destroy = function () { + this.clear(); + this.off(); + }; + + __proto.getLoader = function (element, options) { + var _this = this; + + var tagName = element.tagName.toLowerCase(); + var loaders = this.options.loaders; + var tags = Object.keys(loaders); + + if (loaders[tagName]) { + return new loaders[tagName](element, options); + } + + var loader = new ElementLoader(element, options); + var children = toArray(element.querySelectorAll(tags.join(", "))); + loader.setHasLoading(children.some(function (el) { + return hasLoadingAttribute(el); + })); + var withPreReady = false; + var childrenImReady = this.clone().on("error", function (e) { + loader.onError(e.target); + }).on("ready", function () { + loader.onReady(withPreReady); + }); + loader.on("requestChildren", function () { + // has not data size + var contentElements = getContentElements(element, tags, _this.options.prefix); + childrenImReady.check(contentElements).on("preReady", function (e) { + withPreReady = e.isReady; + + if (!withPreReady) { + loader.onPreReady(); + } + }); + }).on("reqeustReadyChildren", function () { + // has data size + // loader call preReady + // check only video, image elements + childrenImReady.check(children); + }).on("requestDestroy", function () { + childrenImReady.destroy(); + }); + return loader; + }; + + __proto.clone = function () { + return new ImReadyManager(__assign$1({}, this.options)); + }; + + __proto.checkPreReady = function (index) { + this.elementInfos[index].isPreReady = true; + ++this.preReadyCount; + + if (this.preReadyCount < this.totalCount) { + return false; + } + + return true; + }; + + __proto.checkReady = function (index) { + this.elementInfos[index].isReady = true; + ++this.readyCount; + + if (this.readyCount < this.totalCount) { + return false; + } + + return true; + }; + + __proto.onError = function (index, target) { + var info = this.elementInfos[index]; + info.hasError = true; + /** + * An event occurs if the image, video fails to load. + * @ko 이미지, 비디오가 로딩에 실패하면 이벤트가 발생한다. + * @event eg.ImReady#error + * @param {eg.ImReady.OnError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {HTMLElement} [e.element] - The element with error images.오류난 이미지가 있는 엘리먼트 + * @param {number} [e.index] - The item's index with error images. 오류난 이미지가 있는 엘리먼트의 인덱스 + * @param {HTMLElement} [e.target] - Error image target in element 엘리먼트의 오류난 이미지 타겟 + * @param {number} [e.errorCount] - The number of elements with errors 에러가 있는 엘리먼트들의 개수 + * @param {number} [e.totalErrorCount] - The total number of targets with errors 에러가 있는 타겟들의 총 개수 + * @example + * ```html + *
+ * + * + * + *
+ * ``` + * ## Javascript + * ```js + * import ImReady from "@egjs/imready"; + * + * const im = new ImReady(); // umd: eg.ImReady + * im.check([document.querySelector("div")]).on({ + * error: e => { + * //
...
, 0, + * console.log(e.element, e.index, e.target), + * }, + * }); + * ``` + */ + + this.trigger("error", { + element: info.element, + index: index, + target: target, + errorCount: this.getErrorCount(), + totalErrorCount: ++this.totalErrorCount + }); + }; + + __proto.onPreReadyElement = function (index) { + var info = this.elementInfos[index]; + /** + * An event occurs when the element is pre-ready (when the loading attribute is applied or the size is known) + * @ko 해당 엘리먼트가 사전 준비되었을 때(loading 속성이 적용되었거나 사이즈를 알 수 있을 때) 이벤트가 발생한다. + * @event eg.ImReady#preReadyElement + * @param {eg.ImReady.OnPreReadyElement} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {HTMLElement} [e.element] - The pre-ready element.사전 준비된 엘리먼트 + * @param {number} [e.index] - The index of the pre-ready element. 사전 준비된 엘리먼트의 인덱스 + * @param {number} [e.preReadyCount] - Number of elements pre-ready 사전 준비된 엘리먼트들의 개수 + * @param {number} [e.readyCount] - Number of elements ready 준비된 엘리먼트들의 개수 + * @param {number} [e.totalCount] - Total number of elements 엘리먼트들의 총 개수 + * @param {boolean} [e.isPreReady] - Whether all elements are pre-ready 모든 엘리먼트가 사전 준비가 끝났는지 여부 + * @param {boolean} [e.isReady] - Whether all elements are ready 모든 엘리먼트가 준비가 끝났는지 여부 + * @param {boolean} [e.hasLoading] - Whether the loading attribute has been applied loading 속성이 적용되었는지 여부 + * @param {boolean} [e.isSkip] - Whether the check is omitted due to skip attribute skip 속성으로 인하여 체크가 생략됐는지 여부 + * @example + * ```html + *
+ * + * + * + *
+ * ``` + * ## Javascript + * ```js + * import ImReady from "@egjs/imready"; + * + * const im = new ImReady(); // umd: eg.ImReady + * im.check(document.querySelectorAll("img")).on({ + * preReadyElement: e => { + * // 1, 3 + * // 2, 3 + * // 3, 3 + * console.log(e.preReadyCount, e.totalCount), + * }, + * }); + * ``` + */ + + this.trigger("preReadyElement", { + element: info.element, + index: index, + preReadyCount: this.preReadyCount, + readyCount: this.readyCount, + totalCount: this.totalCount, + isPreReady: this.isPreReady(), + isReady: this.isReady(), + hasLoading: info.hasLoading, + isSkip: info.isSkip + }); + }; + + __proto.onPreReady = function () { + this.isPreReadyOver = true; + /** + * An event occurs when all element are pre-ready (When all elements have the loading attribute applied or the size is known) + * @ko 모든 엘리먼트들이 사전 준비된 경우 (모든 엘리먼트들이 loading 속성이 적용되었거나 사이즈를 알 수 있는 경우) 이벤트가 발생한다. + * @event eg.ImReady#preReady + * @param {eg.ImReady.OnPreReady} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {number} [e.readyCount] - Number of elements ready 준비된 엘리먼트들의 개수 + * @param {number} [e.totalCount] - Total number of elements 엘리먼트들의 총 개수 + * @param {boolean} [e.isReady] - Whether all elements are ready 모든 엘리먼트가 준비가 끝났는지 여부 + * @param {boolean} [e.hasLoading] - Whether the loading attribute has been applied loading 속성이 적용되었는지 여부 + * @example + * ```html + *
+ * + * + * + *
+ * ``` + * ## Javascript + * ```js + * import ImReady from "@egjs/imready"; + * + * const im = new ImReady(); // umd: eg.ImReady + * im.check(document.querySelectorAll("img")).on({ + * preReady: e => { + * // 0, 3 + * console.log(e.readyCount, e.totalCount), + * }, + * }); + * ``` + */ + + this.trigger("preReady", { + readyCount: this.readyCount, + totalCount: this.totalCount, + isReady: this.isReady(), + hasLoading: this.hasLoading() + }); + }; + + __proto.onReadyElement = function (index) { + var info = this.elementInfos[index]; + /** + * An event occurs when the element is ready + * @ko 해당 엘리먼트가 준비가 되었을 때 이벤트가 발생한다. + * @event eg.ImReady#readyElement + * @param {eg.ImReady.OnReadyElement} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {HTMLElement} [e.element] - The ready element.준비된 엘리먼트 + * @param {number} [e.index] - The index of the ready element. 준비된 엘리먼트의 인덱스 + * @param {boolean} [e.hasError] - Whether there is an error in the element 해당 엘리먼트에 에러가 있는지 여부 + * @param {number} [e.errorCount] - The number of elements with errors 에러가 있는 엘리먼트들의 개수 + * @param {number} [e.totalErrorCount] - The total number of targets with errors 에러가 있는 타겟들의 총 개수 + * @param {number} [e.preReadyCount] - Number of elements pre-ready 사전 준비된 엘리먼트들의 개수 + * @param {number} [e.readyCount] - Number of elements ready 준비된 엘리먼트들의 개수 + * @param {number} [e.totalCount] - Total number of elements 엘리먼트들의 총 개수 + * @param {boolean} [e.isPreReady] - Whether all elements are pre-ready 모든 엘리먼트가 사전 준비가 끝났는지 여부 + * @param {boolean} [e.isReady] - Whether all elements are ready 모든 엘리먼트가 준비가 끝났는지 여부 + * @param {boolean} [e.hasLoading] - Whether the loading attribute has been applied loading 속성이 적용되었는지 여부 + * @param {boolean} [e.isPreReadyOver] - Whether pre-ready is over 사전 준비가 끝났는지 여부 + * @param {boolean} [e.isSkip] - Whether the check is omitted due to skip attribute skip 속성으로 인하여 체크가 생략됐는지 여부 + * @example + * ```html + *
+ * + * + * + *
+ * ``` + * ## Javascript + * ```js + * import ImReady from "@egjs/imready"; + * + * const im = new ImReady(); // umd: eg.ImReady + * im.check(document.querySelectorAll("img")).on({ + * readyElement: e => { + * // 1, 0, false, 3 + * // 2, 1, false, 3 + * // 3, 2, true, 3 + * console.log(e.readyCount, e.index, e.hasError, e.totalCount), + * }, + * }); + * ``` + */ + + this.trigger("readyElement", { + index: index, + element: info.element, + hasError: info.hasError, + errorCount: this.getErrorCount(), + totalErrorCount: this.totalErrorCount, + preReadyCount: this.preReadyCount, + readyCount: this.readyCount, + totalCount: this.totalCount, + isPreReady: this.isPreReady(), + isReady: this.isReady(), + hasLoading: info.hasLoading, + isPreReadyOver: this.isPreReadyOver, + isSkip: info.isSkip + }); + }; + + __proto.onReady = function () { + /** + * An event occurs when all element are ready + * @ko 모든 엘리먼트들이 준비된 경우 이벤트가 발생한다. + * @event eg.ImReady#ready + * @param {eg.ImReady.OnReady} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {number} [e.errorCount] - The number of elements with errors 에러가 있는 엘리먼트들의 개수 + * @param {number} [e.totalErrorCount] - The total number of targets with errors 에러가 있는 타겟들의 총 개수 + * @param {number} [e.totalCount] - Total number of elements 엘리먼트들의 총 개수 + * @example + * ```html + *
+ * + * + * + *
+ * ``` + * ## Javascript + * ```js + * import ImReady from "@egjs/imready"; + * + * const im = new ImReady(); // umd: eg.ImReady + * im.check(document.querySelectorAll("img")).on({ + * preReady: e => { + * // 0, 3 + * console.log(e.readyCount, e.totalCount), + * }, + * ready: e => { + * // 1, 3 + * console.log(e.errorCount, e.totalCount), + * }, + * }); + * ``` + */ + this.trigger("ready", { + errorCount: this.getErrorCount(), + totalErrorCount: this.totalErrorCount, + totalCount: this.totalCount + }); + }; + + __proto.getErrorCount = function () { + return this.elementInfos.filter(function (info) { + return info.hasError; + }).length; + }; + + __proto.hasLoading = function () { + return this.elementInfos.some(function (info) { + return info.hasLoading; + }); + }; + + return ImReadyManager; + }(Component$1); + + var ImageLoader = + /*#__PURE__*/ + function (_super) { + __extends$1(ImageLoader, _super); + + function ImageLoader() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = ImageLoader.prototype; + + __proto.checkElement = function () { + var element = this.element; + var src = element.getAttribute("src"); + + if (element.complete) { + if (src) { + // complete + if (!element.naturalWidth) { + this.onAlreadyError(element); + } + + return false; + } else { + // Using an external lazy loading module + this.onAlreadyPreReady(); + } + } + + this.addEvents(); + IS_IE && element.setAttribute("src", src); + return true; + }; + + ImageLoader.EVENTS = ["load", "error"]; + return ImageLoader; + }(Loader); + + var VideoLoader = + /*#__PURE__*/ + function (_super) { + __extends$1(VideoLoader, _super); + + function VideoLoader() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = VideoLoader.prototype; + + __proto.checkElement = function () { + var element = this.element; // HAVE_NOTHING: 0, no information whether or not the audio/video is ready + // HAVE_METADATA: 1, HAVE_METADATA - metadata for the audio/video is ready + // HAVE_CURRENT_DATA: 2, data for the current playback position is available, but not enough data to play next frame/millisecond + // HAVE_FUTURE_DATA: 3, data for the current and at least the next frame is available + // HAVE_ENOUGH_DATA: 4, enough data available to start playing + + if (element.readyState >= 1) { + return false; + } + + if (element.error) { + this.onAlreadyError(element); + return false; + } + + this.addEvents(); + return true; + }; + + VideoLoader.EVENTS = ["loadedmetadata", "error"]; + return VideoLoader; + }(Loader); + + var ImReady = + /*#__PURE__*/ + function (_super) { + __extends$1(ImReady, _super); + + function ImReady(options) { + if (options === void 0) { + options = {}; + } + + return _super.call(this, __assign$1({ + loaders: { + img: ImageLoader, + video: VideoLoader + } + }, options)) || this; + } + + return ImReady; + }(ImReadyManager); + + function getKeys(obj) { + return Object.keys(obj); + } + function isString(val) { + return typeof val === "string"; + } + function isObject(val) { + return typeof val === "object"; + } + function isNumber(val) { + return typeof val === "number"; + } + function camelize(str) { + return str.replace(/[\s-_]([a-z])/g, function (all, letter) { + return letter.toUpperCase(); + }); + } + function getDataAttributes(element, attributePrefix) { + var dataAttributes = {}; + var attributes = element.attributes; + var length = attributes.length; + + for (var i = 0; i < length; ++i) { + var attribute = attributes[i]; + var name = attribute.name, + value = attribute.value; + + if (name.indexOf(attributePrefix) === -1) { + continue; + } + + dataAttributes[camelize(name.replace(attributePrefix, ""))] = value; + } + + return dataAttributes; + } + /* Class Decorator */ + + function GetterSetter(component) { + var prototype = component.prototype, + propertyTypes = component.propertyTypes; + + var _loop_1 = function (name) { + var shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY; + var attributes = { + enumerable: true, + configurable: true, + get: function () { + return this.options[name]; + }, + set: function (value) { + var options = this.options; + var prevValue = options[name]; + + if (prevValue === value) { + return; + } + + options[name] = value; + + if (shouldRender && options.renderOnPropertyChange) { + this.scheduleRender(); + } + } + }; + Object.defineProperty(prototype, name, attributes); + }; + + for (var name in propertyTypes) { + _loop_1(name); + } + } + function withMethods(methods) { + return function (prototype, memberName) { + methods.forEach(function (name) { + if (name in prototype) { + return; + } + + prototype[name] = function () { + var _a; + + var args = []; + + for (var _i = 0; _i < arguments.length; _i++) { + args[_i] = arguments[_i]; + } + + var result = (_a = this[memberName])[name].apply(_a, args); // fix `this` type to return your own `class` instance to the instance using the decorator. + + + if (result === this[memberName]) { + return this; + } else { + return result; + } + }; + }); + }; + } + function range(length) { + var arr = []; + + for (var i = 0; i < length; ++i) { + arr.push(i); + } + + return arr; + } + function getRangeCost(value, valueRange) { + return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1; + } + /** + * Decorator that makes the method of grid available in the framework. + * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터. + * @memberof eg.Grid + * @private + * @example + * ```js + * import { withGridMethods } from "@egjs/grid"; + * + * class Grid extends React.Component> { + * @withGridMethods + * private grid: NativeGrid; + * } + * ``` + */ + + var withGridMethods = withMethods(GRID_METHODS); + + var ItemRenderer = + /*#__PURE__*/ + function () { + function ItemRenderer(options) { + this.initialRect = null; + this.sizePercetage = false; + this.posPercetage = false; + this.options = __assign({ + attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix, + useTransform: DEFAULT_GRID_OPTIONS.useTransform, + horizontal: DEFAULT_GRID_OPTIONS.horizontal, + percentage: DEFAULT_GRID_OPTIONS.percentage, + isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize, + isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize + }, options); + + this._init(); + } + + var __proto = ItemRenderer.prototype; + + __proto.resize = function () { + this.initialRect = null; + }; + + __proto.renderItems = function (items) { + var _this = this; + + items.forEach(function (item) { + _this._renderItem(item); + }); + }; + + __proto.getInlineSize = function () { + return this.containerRect[this.options.horizontal ? "height" : "width"]; + }; + + __proto.setContainerRect = function (rect) { + this.containerRect = rect; + }; + + __proto.updateItems = function (items) { + var _this = this; + + items.forEach(function (item) { + _this._updateItem(item); + }); + }; + + __proto.getStatus = function () { + return { + initialRect: this.initialRect + }; + }; + + __proto.setStatus = function (status) { + this.initialRect = status.initialRect; + }; + + __proto._init = function () { + var percentage = this.options.percentage; + var sizePercentage = false; + var posPercentage = false; + + if (percentage === true) { + sizePercentage = true; + posPercentage = true; + } else if (percentage) { + if (percentage.indexOf("position") > -1) { + posPercentage = true; + } + + if (percentage.indexOf("size") > -1) { + sizePercentage = true; + } + } + + this.posPercetage = posPercentage; + this.sizePercetage = sizePercentage; + }; + + __proto._updateItem = function (item) { + var _a = this.options, + isEqualSize = _a.isEqualSize, + isConstantSize = _a.isConstantSize; + var initialRect = this.initialRect; + var orgRect = item.orgRect, + element = item.element; + var isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING; + var hasOrgSize = orgRect && orgRect.width && orgRect.height; + var rect; + + if (isEqualSize && initialRect) { + rect = initialRect; + } else if (isConstantSize && hasOrgSize && !isLoading) { + rect = orgRect; + } else if (!element) { + return; + } else { + rect = { + left: element.offsetLeft, + top: element.offsetTop, + width: element.offsetWidth, + height: element.offsetHeight + }; + } + + if (!item.isFirstUpdate) { + item.orgRect = __assign({}, rect); + } + + item.rect = __assign({}, rect); + + if (item.element) { + item.mountState = MOUNT_STATE.MOUNTED; + } + + if (item.updateState === UPDATE_STATE.NEED_UPDATE) { + item.updateState = UPDATE_STATE.UPDATED; + item.isFirstUpdate = true; + } + + item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {}; + + if (!isLoading) { + this.initialRect = __assign({}, rect); + } + + return rect; + }; + + __proto._renderItem = function (item) { + var element = item.element; + var cssRect = item.cssRect; + + if (!element || !cssRect) { + return; + } + + var _a = this.options, + horizontal = _a.horizontal, + useTransform = _a.useTransform; + var posPercentage = this.posPercetage; + var sizePercentage = this.sizePercetage; + var cssTexts = ["position: absolute;"]; + var _b = RECT_NAMES[horizontal ? "horizontal" : "vertical"], + sizeName = _b.inlineSize, + posName = _b.inlinePos; + var inlineSize = this.getInlineSize(); + var keys = getKeys(cssRect); + + if (useTransform) { + keys = keys.filter(function (key) { + return key !== "top" && key !== "left"; + }); + cssTexts.push("transform: " + ("translate(" + (cssRect.left || 0) + "px, " + (cssRect.top || 0) + "px);")); + } + + cssTexts.push.apply(cssTexts, keys.map(function (name) { + var value = cssRect[name]; + + if (name === sizeName && sizePercentage || name === posName && posPercentage) { + return name + ": " + value / inlineSize * 100 + "%;"; + } + + return name + ": " + value + "px;"; + })); + element.style.cssText += cssTexts.join(""); + }; + + return ItemRenderer; + }(); + + /* + Copyright (c) 2019-present NAVER Corp. + name: @egjs/list-differ + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-list-differ + version: 1.0.0 + */ + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var PolyMap = + /*#__PURE__*/ + function () { + function PolyMap() { + this.keys = []; + this.values = []; + } + + var __proto = PolyMap.prototype; + + __proto.get = function (key) { + return this.values[this.keys.indexOf(key)]; + }; + + __proto.set = function (key, value) { + var keys = this.keys; + var values = this.values; + var prevIndex = keys.indexOf(key); + var index = prevIndex === -1 ? keys.length : prevIndex; + keys[index] = key; + values[index] = value; + }; + + return PolyMap; + }(); + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var HashMap = + /*#__PURE__*/ + function () { + function HashMap() { + this.object = {}; + } + + var __proto = HashMap.prototype; + + __proto.get = function (key) { + return this.object[key]; + }; + + __proto.set = function (key, value) { + this.object[key] = value; + }; + + return HashMap; + }(); + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var SUPPORT_MAP = typeof Map === "function"; + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var Link = + /*#__PURE__*/ + function () { + function Link() {} + + var __proto = Link.prototype; + + __proto.connect = function (prevLink, nextLink) { + this.prev = prevLink; + this.next = nextLink; + prevLink && (prevLink.next = this); + nextLink && (nextLink.prev = this); + }; + + __proto.disconnect = function () { + // In double linked list, diconnect the interconnected relationship. + var prevLink = this.prev; + var nextLink = this.next; + prevLink && (prevLink.next = nextLink); + nextLink && (nextLink.prev = prevLink); + }; + + __proto.getIndex = function () { + var link = this; + var index = -1; + + while (link) { + link = link.prev; + ++index; + } + + return index; + }; + + return Link; + }(); + + /* + egjs-list-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + + function orderChanged(changed, fixed) { + // It is roughly in the order of these examples. + // 4, 6, 0, 2, 1, 3, 5, 7 + var fromLinks = []; // 0, 1, 2, 3, 4, 5, 6, 7 + + var toLinks = []; + changed.forEach(function (_a) { + var from = _a[0], + to = _a[1]; + var link = new Link(); + fromLinks[from] = link; + toLinks[to] = link; + }); // `fromLinks` are connected to each other by double linked list. + + fromLinks.forEach(function (link, i) { + link.connect(fromLinks[i - 1]); + }); + return changed.filter(function (_, i) { + return !fixed[i]; + }).map(function (_a, i) { + var from = _a[0], + to = _a[1]; + + if (from === to) { + return [0, 0]; + } + + var fromLink = fromLinks[from]; + var toLink = toLinks[to - 1]; + var fromIndex = fromLink.getIndex(); // Disconnect the link connected to `fromLink`. + + fromLink.disconnect(); // Connect `fromLink` to the right of `toLink`. + + if (!toLink) { + fromLink.connect(undefined, fromLinks[0]); + } else { + fromLink.connect(toLink, toLink.next); + } + + var toIndex = fromLink.getIndex(); + return [fromIndex, toIndex]; + }); + } + + var Result = + /*#__PURE__*/ + function () { + function Result(prevList, list, added, removed, changed, maintained, changedBeforeAdded, fixed) { + this.prevList = prevList; + this.list = list; + this.added = added; + this.removed = removed; + this.changed = changed; + this.maintained = maintained; + this.changedBeforeAdded = changedBeforeAdded; + this.fixed = fixed; + } + + var __proto = Result.prototype; + Object.defineProperty(__proto, "ordered", { + get: function () { + if (!this.cacheOrdered) { + this.caculateOrdered(); + } + + return this.cacheOrdered; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(__proto, "pureChanged", { + get: function () { + if (!this.cachePureChanged) { + this.caculateOrdered(); + } + + return this.cachePureChanged; + }, + enumerable: true, + configurable: true + }); + + __proto.caculateOrdered = function () { + var ordered = orderChanged(this.changedBeforeAdded, this.fixed); + var changed = this.changed; + var pureChanged = []; + this.cacheOrdered = ordered.filter(function (_a, i) { + var from = _a[0], + to = _a[1]; + var _b = changed[i], + fromBefore = _b[0], + toBefore = _b[1]; + + if (from !== to) { + pureChanged.push([fromBefore, toBefore]); + return true; + } + }); + this.cachePureChanged = pureChanged; + }; + + return Result; + }(); + + /** + * + * @memberof eg.ListDiffer + * @static + * @function + * @param - Previous List 이전 목록 + * @param - List to Update 업데이트 할 목록 + * @param - This callback function returns the key of the item. 아이템의 키를 반환하는 콜백 함수입니다. + * @return - Returns the diff between `prevList` and `list` `prevList`와 `list`의 다른 점을 반환한다. + * @example + * import { diff } from "@egjs/list-differ"; + * // script => eg.ListDiffer.diff + * const result = diff([0, 1, 2, 3, 4, 5], [7, 8, 0, 4, 3, 6, 2, 1], e => e); + * // List before update + * // [1, 2, 3, 4, 5] + * console.log(result.prevList); + * // Updated list + * // [4, 3, 6, 2, 1] + * console.log(result.list); + * // Index array of values added to `list` + * // [0, 1, 5] + * console.log(result.added); + * // Index array of values removed in `prevList` + * // [5] + * console.log(result.removed); + * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list` + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.changed); + * // The subset of `changed` and an array of index pairs that moved data directly. Indicate an array of absolute index pairs of `ordered`.(Formatted by: Array<[index of prevList, index of list]>) + * // [[4, 3], [3, 4], [2, 6]] + * console.log(result.pureChanged); + * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>) + * // [[4, 1], [4, 2], [4, 3]] + * console.log(result.ordered); + * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.maintained); + */ + + function diff(prevList, list, findKeyCallback) { + var mapClass = SUPPORT_MAP ? Map : findKeyCallback ? HashMap : PolyMap; + + var callback = findKeyCallback || function (e) { + return e; + }; + + var added = []; + var removed = []; + var maintained = []; + var prevKeys = prevList.map(callback); + var keys = list.map(callback); + var prevKeyMap = new mapClass(); + var keyMap = new mapClass(); + var changedBeforeAdded = []; + var fixed = []; + var removedMap = {}; + var changed = []; + var addedCount = 0; + var removedCount = 0; // Add prevKeys and keys to the hashmap. + + prevKeys.forEach(function (key, prevListIndex) { + prevKeyMap.set(key, prevListIndex); + }); + keys.forEach(function (key, listIndex) { + keyMap.set(key, listIndex); + }); // Compare `prevKeys` and `keys` and add them to `removed` if they are not in `keys`. + + prevKeys.forEach(function (key, prevListIndex) { + var listIndex = keyMap.get(key); // In prevList, but not in list, it is removed. + + if (typeof listIndex === "undefined") { + ++removedCount; + removed.push(prevListIndex); + } else { + removedMap[listIndex] = removedCount; + } + }); // Compare `prevKeys` and `keys` and add them to `added` if they are not in `prevKeys`. + + keys.forEach(function (key, listIndex) { + var prevListIndex = prevKeyMap.get(key); // In list, but not in prevList, it is added. + + if (typeof prevListIndex === "undefined") { + added.push(listIndex); + ++addedCount; + } else { + maintained.push([prevListIndex, listIndex]); + removedCount = removedMap[listIndex] || 0; + changedBeforeAdded.push([prevListIndex - removedCount, listIndex - addedCount]); + fixed.push(listIndex === prevListIndex); + + if (prevListIndex !== listIndex) { + changed.push([prevListIndex, listIndex]); + } + } + }); // Sort by ascending order of 'to(list's index). + + removed.reverse(); + return new Result(prevList, list, added, removed, changed, maintained, changedBeforeAdded, fixed); + } + + /* + Copyright (c) 2019-present NAVER Corp. + name: @egjs/children-differ + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-children-differ + version: 1.0.1 + */ + + /* + egjs-children-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + var findKeyCallback = typeof Map === "function" ? undefined : function () { + var childrenCount = 0; + return function (el) { + return el.__DIFF_KEY__ || (el.__DIFF_KEY__ = ++childrenCount); + }; + }(); + + /* + egjs-children-differ + Copyright (c) 2019-present NAVER Corp. + MIT license + */ + /** + * + * @memberof eg.ChildrenDiffer + * @static + * @function + * @param - Previous List 이전 목록 + * @param - List to Update 업데이트 할 목록 + * @return - Returns the diff between `prevList` and `list` `prevList`와 `list`의 다른 점을 반환한다. + * @example + * import { diff } from "@egjs/children-differ"; + * // script => eg.ChildrenDiffer.diff + * const result = diff([0, 1, 2, 3, 4, 5], [7, 8, 0, 4, 3, 6, 2, 1]); + * // List before update + * // [1, 2, 3, 4, 5] + * console.log(result.prevList); + * // Updated list + * // [4, 3, 6, 2, 1] + * console.log(result.list); + * // Index array of values added to `list` + * // [0, 1, 5] + * console.log(result.added); + * // Index array of values removed in `prevList` + * // [5] + * console.log(result.removed); + * // An array of index pairs of `prevList` and `list` with different indexes from `prevList` and `list` + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.changed); + * // The subset of `changed` and an array of index pairs that moved data directly. Indicate an array of absolute index pairs of `ordered`.(Formatted by: Array<[index of prevList, index of list]>) + * // [[4, 3], [3, 4], [2, 6]] + * console.log(result.pureChanged); + * // An array of index pairs to be `ordered` that can synchronize `list` before adding data. (Formatted by: Array<[prevIndex, nextIndex]>) + * // [[4, 1], [4, 2], [4, 3]] + * console.log(result.ordered); + * // An array of index pairs of `prevList` and `list` that have not been added/removed so data is preserved + * // [[0, 2], [4, 3], [3, 4], [2, 6], [1, 7]] + * console.log(result.maintained); + */ + + function diff$1(prevList, list) { + return diff(prevList, list, findKeyCallback); + } + + /** + * @memberof Grid + * @implements Grid.GridItem.GridItemStatus + */ + + var GridItem = + /*#__PURE__*/ + function () { + /** + * @constructor + * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향) + * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체. + */ + function GridItem(horizontal, itemStatus) { + if (itemStatus === void 0) { + itemStatus = {}; + } + + var _a; + + this.horizontal = horizontal; + /** + * Grid ready data for rendering + * @ko 렌더링을 하기 위한 grid의 준비 데이타 + * @member Grid.GridItem#gridData + */ + + this.gridData = {}; + var element = itemStatus.element; + + var status = __assign({ + key: "", + orgRect: { + left: 0, + top: 0, + width: 0, + height: 0 + }, + rect: { + left: 0, + top: 0, + width: 0, + height: 0 + }, + cssRect: {}, + attributes: {}, + data: {}, + isFirstUpdate: false, + mountState: MOUNT_STATE.UNCHECKED, + updateState: UPDATE_STATE.NEED_UPDATE, + element: element || null, + orgCSSText: (_a = element === null || element === void 0 ? void 0 : element.style.cssText) !== null && _a !== void 0 ? _a : "" + }, itemStatus); + + for (var name in status) { + this[name] = status[name]; + } + } + + var __proto = GridItem.prototype; + Object.defineProperty(__proto, "orgInlineSize", { + /** + * The size in inline direction before first rendering. "width" if horizontal is false, "height" otherwise. + * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#orgInlineSize + */ + get: function () { + var orgRect = this.orgRect || this.rect; + return this.horizontal ? orgRect.height : orgRect.width; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "orgContentSize", { + /** + * The size in content direction before first rendering. "height" if horizontal is false, "width" otherwise. + * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#orgContentSize + */ + get: function () { + var orgRect = this.orgRect || this.rect; + return this.horizontal ? orgRect.width : orgRect.height; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "inlineSize", { + /** + * The size in inline direction. "width" if horizontal is false, "height" otherwise. + * @ko inline 방향의 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#inlineSize + */ + get: function () { + var rect = this.rect; + return this.horizontal ? rect.height : rect.width; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "contentSize", { + /** + * The size in content direction. "height" if horizontal is false, "width" otherwise. + * @ko content 방향의 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#contentSize + */ + get: function () { + var rect = this.rect; + return this.horizontal ? rect.width : rect.height; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssInlineSize", { + /** + * The CSS size in inline direction applied to the Grid. "width" if horizontal is false, "height" otherwise. + * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#cssInlineSize + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.height : cssRect.width; + }, + set: function (inlineSize) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "height" : "width"] = inlineSize; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssContentSize", { + /** + * The CSS size in content direction applied to the Grid. "height" if horizontal is false, "width" otherwise. + * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#cssContentSize + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.width : cssRect.height; + }, + set: function (contentSize) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "width" : "height"] = contentSize; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssInlinePos", { + /** + * The CSS pos in inline direction applied to the Grid. "left" if horizontal is false, "top" otherwise. + * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 "left", 아니면 "top". + * @member Grid.GridItem#cssInlinePos + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.top : cssRect.left; + }, + set: function (inlinePos) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "top" : "left"] = inlinePos; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "cssContentPos", { + /** + * The CSS pos in content direction applied to the Grid. "top" if horizontal is false, "left" otherwise. + * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 "top", 아니면 "left". + * @member Grid.GridItem#cssContentPos + */ + get: function () { + var cssRect = this.cssRect; + return this.horizontal ? cssRect.left : cssRect.top; + }, + set: function (contentPos) { + var cssRect = this.cssRect; + cssRect[this.horizontal ? "left" : "top"] = contentPos; + }, + enumerable: false, + configurable: true + }); + /** + * Set CSS Rect through GridRect. + * @ko GridRect을 통해 CSS Rect를 설정한다. + * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일. + */ + + __proto.setCSSGridRect = function (gridRect) { + var names = RECT_NAMES[this.horizontal ? "horizontal" : "vertical"]; + var rect = {}; + + for (var name in gridRect) { + rect[names[name]] = gridRect[name]; + } + + this.cssRect = rect; + }; + /** + * Returns the status of the item. + * @ko 아이템의 상태를 반환한다. + */ + + + __proto.getStatus = function () { + return { + mountState: this.mountState, + updateState: this.updateState, + attributes: this.attributes, + orgCSSText: this.orgCSSText, + isFirstUpdate: this.isFirstUpdate, + element: null, + key: this.key, + orgRect: this.orgRect, + rect: this.rect, + cssRect: this.cssRect, + data: this.data + }; + }; + + return GridItem; + }(); + + /** + * @extends eg.Component + */ + + var Grid = + /*#__PURE__*/ + function (_super) { + __extends(Grid, _super); + /** + * @param - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param - The option object of the Grid module Grid 모듈의 옵션 객체 + */ + + + function Grid(containerElement, options) { + if (options === void 0) { + options = {}; + } + + var _this = _super.call(this) || this; + + _this.items = []; + _this.outlines = { + start: [], + end: [] + }; + _this._renderTimer = 0; + _this._resizeTimer = 0; + _this._maxResizeDebounceTimer = 0; + + _this._onResize = function () { + clearTimeout(_this._resizeTimer); + clearTimeout(_this._maxResizeDebounceTimer); + _this._maxResizeDebounceTimer = 0; + _this._resizeTimer = 0; + + _this.renderItems({ + useResize: true + }); + }; + + _this._scheduleResize = function () { + var _a = _this.options, + resizeDebounce = _a.resizeDebounce, + maxResizeDebounce = _a.maxResizeDebounce; + + if (!_this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) { + _this._maxResizeDebounceTimer = window.setTimeout(_this._onResize, maxResizeDebounce); + } + + if (_this._resizeTimer) { + clearTimeout(_this._resizeTimer); + _this._resizeTimer = 0; + } + + _this._resizeTimer = window.setTimeout(_this._onResize, resizeDebounce); + }; + + _this.options = __assign(__assign({}, _this.constructor.defaultOptions), options); + _this.containerElement = isString(containerElement) ? document.querySelector(containerElement) : containerElement; + var _a = _this.options, + isEqualSize = _a.isEqualSize, + isConstantSize = _a.isConstantSize, + useTransform = _a.useTransform, + horizontal = _a.horizontal, + percentage = _a.percentage, + externalContainerManager = _a.externalContainerManager, + externalItemRenderer = _a.externalItemRenderer; // TODO: 테스트용 설정 + + _this.containerManager = externalContainerManager || new ContainerManager(_this.containerElement, { + horizontal: horizontal + }); + _this.itemRenderer = externalItemRenderer || new ItemRenderer({ + useTransform: useTransform, + isEqualSize: isEqualSize, + isConstantSize: isConstantSize, + percentage: percentage + }); + + _this._init(); + + return _this; + } + + var __proto = Grid.prototype; + Grid_1 = Grid; + /** + * Return Container Element. + * @ko 컨테이너 엘리먼트를 반환한다. + */ + + __proto.getContainerElement = function () { + return this.containerElement; + }; + /** + * Return items. + * @ko 아이템들을 반환한다. + */ + + + __proto.getItems = function () { + return this.items; + }; + /** + * Returns the children of the container element. + * @ko 컨테이너 엘리먼트의 children을 반환한다. + */ + + + __proto.getChildren = function () { + return [].slice.call(this.containerElement.children); + }; + /** + * Set items. + * @ko 아이템들을 설정한다. + * @param items - The items to set. 설정할 아이템들 + */ + + + __proto.setItems = function (items) { + this.items = items; + return this; + }; + /** + * Gets the container's inline size. ("width" if horizontal is false, otherwise "height") + * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 "width", 아니면 "height") + */ + + + __proto.getContainerInlineSize = function () { + return this.containerManager.getInlineSize(); + }; + /** + * Returns the outlines of the start and end of the Grid. + * @ko Grid의 처음과 끝의 outline을 반환한다. + */ + + + __proto.getOutlines = function () { + return this.outlines; + }; + /** + * Set outlines. + * @ko 아웃라인을 설정한다. + * @param outlines - The outlines to set. 설정할 아웃라인. + */ + + + __proto.setOutlines = function (outlines) { + this.outlines = outlines; + return this; + }; + /** + * When elements change, it synchronizes and renders items. + * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + */ + + + __proto.syncElements = function (options) { + if (options === void 0) { + options = {}; + } + + var items = this.items; + var horizontal = this.options.horizontal; + var elements = this.getChildren(); + + var _a = diff$1(this.items.map(function (item) { + return item.element; + }), elements), + added = _a.added, + maintained = _a.maintained, + changed = _a.changed, + removed = _a.removed; + + var nextItems = []; + maintained.forEach(function (_a) { + var beforeIndex = _a[0], + afterIndex = _a[1]; + nextItems[afterIndex] = items[beforeIndex]; + }); + added.forEach(function (index) { + nextItems[index] = new GridItem(horizontal, { + element: elements[index] + }); + }); + this.setItems(nextItems); + + if (added.length || removed.length || changed.length) { + this.renderItems(options); + } + + return this; + }; + /** + * Update the size of the items and render them. + * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다. + * @param - Items to be updated. 업데이트할 아이템들. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + */ + + + __proto.updateItems = function (items, options) { + if (items === void 0) { + items = this.items; + } + + if (options === void 0) { + options = {}; + } + + items.forEach(function (item) { + item.updateState = UPDATE_STATE.NEED_UPDATE; + }); + this.checkReady(options); + return this; + }; + /** + * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired. + * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다. + * @param - Options for rendering. 렌더링을 하기 위한 옵션. + * @example + * import { MasonryGrid } from "@egjs/grid"; + * const grid = new MasonryGrid(); + * + * grid.on("renderComplete", e => { + * console.log(e); + * }); + * grid.renderItems(); + */ + + + __proto.renderItems = function (options) { + if (options === void 0) { + options = {}; + } + + this._clearRenderTimer(); + + if (!this.getItems().length && this.getChildren().length) { + this.syncElements(options); + } else if (options.useResize) { + // Resize container and Update all items + this._resizeContainer(); + + this.updateItems(this.items, options); + } else { + // Update only items that need to be updated. + this.checkReady(options); + } + + return this; + }; + /** + * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method. + * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + */ + + + __proto.getStatus = function () { + return { + outlines: this.outlines, + items: this.items.map(function (item) { + return item.getStatus(); + }), + containerManager: this.containerManager.getStatus(), + itemRenderer: this.itemRenderer.getStatus() + }; + }; + /** + * Set status of the Grid module with the status returned through a call to the getStatus() method. + * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다. + */ + + + __proto.setStatus = function (status) { + var _this = this; + + var horizontal = this.options.horizontal; + var containerManager = this.containerManager; + var prevInlineSize = containerManager.getInlineSize(); + var children = this.getChildren(); + this.itemRenderer.setStatus(status.itemRenderer); + containerManager.setStatus(status.containerManager); + this.outlines = status.outlines; + this.items = status.items.map(function (item, i) { + return new GridItem(horizontal, __assign(__assign({}, item), { + element: children[i] + })); + }); + this.itemRenderer.renderItems(this.items); + + if (prevInlineSize !== containerManager.getInlineSize()) { + this.renderItems({ + useResize: true + }); + } else { + window.setTimeout(function () { + _this._renderComplete({ + mounted: _this.items, + updated: [], + isResize: false + }); + }); + } + + return this; + }; + /** + * Releases the instnace and events and returns the CSS of the container and elements. + * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다. + * @param Options for destroy. destory()를 위한 옵션 + */ + + + __proto.destroy = function (options) { + var _a; + + if (options === void 0) { + options = {}; + } + + var _b = options.preserveUI, + preserveUI = _b === void 0 ? this.options.preserveUIOnDestroy : _b; + this.containerManager.destroy({ + preserveUI: preserveUI + }); + + if (!preserveUI) { + this.items.forEach(function (_a) { + var element = _a.element, + orgCSSText = _a.orgCSSText; + + if (element) { + element.style.cssText = orgCSSText; + } + }); + } + + window.removeEventListener("resize", this._scheduleResize); + (_a = this._im) === null || _a === void 0 ? void 0 : _a.destroy(); + }; + + __proto.checkReady = function (options) { + var _this = this; + + var _a; + + if (options === void 0) { + options = {}; + } // Grid: renderItems => checkReady => readyItems => applyGrid + + + var items = this.items; + var updated = items.filter(function (item) { + return item.element && item.updateState !== UPDATE_STATE.UPDATED; + }); + var mounted = updated.filter(function (item) { + return item.mountState !== MOUNT_STATE.MOUNTED; + }); + var moreUpdated = []; + (_a = this._im) === null || _a === void 0 ? void 0 : _a.destroy(); + this._im = new ImReady({ + prefix: this.options.attributePrefix + }).on("preReadyElement", function (e) { + updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING; + }).on("preReady", function () { + _this.itemRenderer.updateItems(updated); + + _this.readyItems(mounted, updated, options); + }).on("readyElement", function (e) { + var item = updated[e.index]; + item.updateState = UPDATE_STATE.NEED_UPDATE; // after preReady + + if (e.isPreReadyOver) { + item.element.style.cssText = item.orgCSSText; + + _this.itemRenderer.updateItems([item]); + + _this.readyItems([], [item], options); + } + }).on("error", function (e) { + var item = items[e.index]; + /** + * This event is fired when an error occurs in the content. + * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트. + * @event Grid#contentError + * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트. + * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트. + * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템 + * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라. + * @example + grid.on("contentError", e => { + e.update(); + }); + */ + + _this.trigger("contentError", { + element: e.element, + target: e.target, + item: item, + update: function () { + moreUpdated.push(item); + } + }); + }).on("ready", function () { + if (moreUpdated.length) { + _this.updateItems(moreUpdated); + } + }).check(updated.map(function (item) { + return item.element; + })); + }; + + __proto.scheduleRender = function () { + var _this = this; + + this._clearRenderTimer(); + + this._renderTimer = window.setTimeout(function () { + _this.renderItems(); + }); + }; + + __proto.fitOutlines = function (useFit) { + if (useFit === void 0) { + useFit = this.useFit; + } + + var outlines = this.outlines; + var startOutline = outlines.start; + var endOutline = outlines.end; + var outlineOffset = startOutline.length ? Math.min.apply(Math, startOutline) : 0; // If the outline is less than 0, a fit occurs forcibly. + + if (!useFit && outlineOffset > 0) { + return; + } + + outlines.start = startOutline.map(function (point) { + return point - outlineOffset; + }); + outlines.end = endOutline.map(function (point) { + return point - outlineOffset; + }); + this.items.forEach(function (item) { + var contentPos = item.cssContentPos; + + if (!isNumber(contentPos)) { + return; + } + + item.cssContentPos = contentPos - outlineOffset; + }); + }; + + __proto.readyItems = function (mounted, updated, options) { + var prevOutlines = this.outlines; + var direction = options.direction || this.options.defaultDirection; + var prevOutline = options.outline || prevOutlines[direction === "end" ? "start" : "end"]; + var items = this.items; + var nextOutlines = { + start: __spreadArrays(prevOutline), + end: __spreadArrays(prevOutline) + }; + + if (items.length) { + nextOutlines = this.applyGrid(this.items, direction, prevOutline); + } + + this.setOutlines(nextOutlines); + this.fitOutlines(); + this.itemRenderer.renderItems(this.items); + + this._refreshContainerContentSize(); + + this._renderComplete({ + mounted: mounted, + updated: updated, + isResize: !!options.useResize + }); + }; + + __proto._renderComplete = function (e) { + /** + * This event is fired when the Grid has completed rendering. + * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다. + * @event Grid#renderComplete + * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체 + * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들 + * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들. + * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부. + * @example + grid.on("renderComplete", e => { + console.log(e.mounted, e.updated, e.useResize); + }); + */ + this.trigger("renderComplete", e); + }; + + __proto._clearRenderTimer = function () { + clearTimeout(this._renderTimer); + this._renderTimer = 0; + }; + + __proto._refreshContainerContentSize = function () { + var _a = this.outlines, + startOutline = _a.start, + endOutline = _a.end; + var gap = this.options.gap; + var endPoint = endOutline.length ? Math.max.apply(Math, endOutline) : 0; + var startPoint = startOutline.length ? Math.max.apply(Math, startOutline) : 0; + var contentSize = Math.max(startPoint, endPoint - gap); + this.containerManager.setContentSize(contentSize); + }; + + __proto._resizeContainer = function () { + this.containerManager.resize(); + this.itemRenderer.setContainerRect(this.containerManager.getRect()); + }; + + __proto._init = function () { + this._resizeContainer(); + + if (this.options.autoResize) { + window.addEventListener("resize", this._scheduleResize); + } + }; + + var Grid_1; + Grid.defaultOptions = DEFAULT_GRID_OPTIONS; + Grid.propertyTypes = GRID_PROPERTY_TYPES; + Grid = Grid_1 = __decorate([GetterSetter], Grid); + return Grid; + }(Component); + /** + * Gap used to create space around items. + * @ko 아이템들 사이의 공간. + * @name Grid#gap + * @type {$ts:Grid.GridOptions["gap"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * gap: 0, + * }); + * + * grid.gap = 5; + */ + + /** + * The default direction value when direction is not set in the render option. + * @ko render옵션에서 direction을 미설정시의 기본 방향값. + * @name Grid#defaultDirection + * @type {$ts:Grid.GridOptions["defaultDirection"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * defaultDirection: "end", + * }); + * + * grid.defaultDirection = "start"; + */ + + /** + * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true) + * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true) + * @name Grid#useFit + * @type {$ts:Grid.GridOptions["useFit"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * useFit: true, + * }); + * + * grid.useFit = false; + + /** + * Whether to preserve the UI of the existing container or item when destroying. + * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부. + * @name Grid#preserveUIOnDestroy + * @type {$ts:Grid.GridOptions["preserveUIOnDestroy"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * preserveUIOnDestroy: false, + * }); + * + * grid.preserveUIOnDestroy = true; + */ + + function getColumnPoint(outline, columnIndex, columnCount, pointCaculationName) { + return Math[pointCaculationName].apply(Math, outline.slice(columnIndex, columnIndex + columnCount)); + } + + function getColumnIndex(outline, columnCount, nearestCalculationName) { + var length = outline.length - columnCount + 1; + var pointCaculationName = nearestCalculationName === "max" ? "min" : "max"; + var indexCaculationName = nearestCalculationName === "max" ? "lastIndexOf" : "indexOf"; + var points = range(length).map(function (index) { + return getColumnPoint(outline, index, columnCount, pointCaculationName); + }); + return points[indexCaculationName](Math[nearestCalculationName].apply(Math, points)); + } + /** + * MasonryGrid 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. + * + * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체 + */ + + + var MasonryGrid = + /*#__PURE__*/ + function (_super) { + __extends(MasonryGrid, _super); + + function MasonryGrid() { + var _this = _super !== null && _super.apply(this, arguments) || this; + + _this._columnSize = 0; + _this._column = 1; + return _this; + } + + var __proto = MasonryGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + this._calculateColumnSize(items); + + this._calculateColumn(items); + + var column = this._column; + var columnSize = this._columnSize; + var _a = this.options, + gap = _a.gap, + align = _a.align, + columnSizeRatio = _a.columnSizeRatio, + columnSizeOption = _a.columnSize; + var outlineLength = outline.length; + var itemsLength = items.length; + + var alignPoses = this._getAlignPoses(); + + var isEndDirection = direction === "end"; + var nearestCalculationName = isEndDirection ? "min" : "max"; + var pointCalculationName = isEndDirection ? "max" : "min"; + var startOutline = [0]; + + if (outlineLength === column) { + startOutline = outline.slice(); + } else { + var point_1 = outlineLength ? Math[nearestCalculationName].apply(Math, outline) : 0; + startOutline = range(column).map(function () { + return point_1; + }); + } + + var endOutline = startOutline.slice(); + var columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0; + var isStretch = align === "stretch"; + + var _loop_1 = function (i) { + var item = items[isEndDirection ? i : itemsLength - 1 - i]; + var columnAttribute = parseInt(item.attributes.column || "1", 10); + var maxColumnAttribute = parseInt(item.attributes.maxColumn || "1", 10); + var inlineSize = item.inlineSize; + var contentSize = item.contentSize; + var columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist))); + var maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute)); + var columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName); + var contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName); + + while (columnCount < maxColumnCount) { + var nextEndColumnIndex = columnIndex + columnCount; + var nextColumnIndex = columnIndex - 1; + + if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) { + break; + } + + if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) { + break; + } + + if (!isEndDirection) { + --columnIndex; + } + + ++columnCount; + } + + columnIndex = Math.max(0, columnIndex); + columnCount = Math.min(column - columnIndex, columnCount); + + if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) { + inlineSize = (columnCount - 1) * columnDist + columnSize; + item.cssInlineSize = inlineSize; + } + + if (columnSizeRatio > 0) { + contentSize = inlineSize / columnSizeRatio; + item.cssContentSize = contentSize; + } + + var inlinePos = alignPoses[columnIndex]; + contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize; + item.cssInlinePos = inlinePos; + item.cssContentPos = contentPos; + var nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos; + range(columnCount).forEach(function (indexOffset) { + endOutline[columnIndex + indexOffset] = nextOutlinePoint; + }); + }; + + for (var i = 0; i < itemsLength; ++i) { + _loop_1(i); + } // if end items, startOutline is low, endOutline is high + // if start items, startOutline is high, endOutline is low + + + return { + start: isEndDirection ? startOutline : endOutline, + end: isEndDirection ? endOutline : startOutline + }; + }; + + __proto._calculateColumnSize = function (items) { + var _a = this.options, + columnSizeOption = _a.columnSize, + gap = _a.gap, + align = _a.align; + + if (align === "stretch") { + var column = this.column; + + if (columnSizeOption) { + column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap))); + } + + this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap; + } else if (columnSizeOption) { + this._columnSize = columnSizeOption; + } else { + for (var _i = 0, items_1 = items; _i < items_1.length; _i++) { + var item = items_1[_i]; + var attributes = item.attributes; + + if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) { + continue; + } + + var inlineSize = item.inlineSize; + this._columnSize = inlineSize; + return inlineSize; + } + + this._columnSize = this._columnSize || 0; + } + + return this._columnSize; + }; + + __proto._calculateColumn = function (items) { + var _a = this.options, + gap = _a.gap, + columnOption = _a.column; + var columnSize = this._columnSize; + var column = 1; + + if (columnOption) { + column = columnOption; + } else if (!columnSize) { + column = 1; + } else { + column = Math.min(items.length, Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap)))); + } + + this._column = column; + return column; + }; + + __proto._getAlignPoses = function () { + var columnSize = this._columnSize; + var column = this._column; + var _a = this.options, + align = _a.align, + gap = _a.gap; + var containerSize = this.getContainerInlineSize(); + var indexes = range(column); + var offset = 0; + var dist = 0; + + if (align === "justify" || align === "stretch") { + var countDist = column - 1; + dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0; + offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2); + } else { + dist = columnSize + gap; + var totalColumnSize = (column - 1) * dist + columnSize; + + if (align === "center") { + offset = (containerSize - totalColumnSize) / 2; + } else if (align === "end") { + offset = containerSize - totalColumnSize; + } + } + + return indexes.map(function (i) { + return offset + i * dist; + }); + }; + + MasonryGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + column: PROPERTY_TYPE.RENDER_PROPERTY, + columnSize: PROPERTY_TYPE.RENDER_PROPERTY, + columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY, + align: PROPERTY_TYPE.RENDER_PROPERTY + }); + MasonryGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + align: "justify", + column: 0, + columnSize: 0, + columnSizeRatio: 0 + }); + MasonryGrid = __decorate([GetterSetter], MasonryGrid); + return MasonryGrid; + }(Grid); + /** + * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. ("start", "center", "end", "justify", "stretch") (default: "justify") + * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. ("start", "center", "end", "justify", "stretch") (default: "justify") + * @name Grid.MasonryGrid#align + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["align"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * align: "start", + * }); + * + * grid.align = "justify"; + */ + + /** + * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. + * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) + * @name Grid.MasonryGrid#column + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["column"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * column: 0, + * }); + * + * grid.column = 4; + */ + + /** + * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) + * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) + * @name Grid.MasonryGrid#columnSize + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSize"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * columnSize: 0, + * }); + * + * grid.columnSize = 200; + */ + + /** + * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) + * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. + * @name Grid.MasonryGrid#columnSizeRatio + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSizeRatio"]} + * @example + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * columnSizeRatio: 0, + * }); + * + * grid.columnSizeRatio = 0.5; + */ + + /* eslint-disable */ + + /****************************************************************************** + * Created 2008-08-19. + * + * Dijkstra path-finding functions. Adapted from the Dijkstar Python project. + * + * Copyright (C) 2008 + * Wyatt Baldwin + * All rights reserved + * + * Licensed under the MIT license. + * + * http://www.opensource.org/licenses/mit-license.php + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + *****************************************************************************/ + function single_source_shortest_paths(graph, s, d) { + // Predecessor map for each node that has been encountered. + // node ID => predecessor node ID + var predecessors = {}; // Costs of shortest paths from s to all nodes encountered. + // node ID => cost + + var costs = {}; + costs[s] = 0; // Costs of shortest paths from s to all nodes encountered; differs from + // `costs` in that it provides easy access to the node that currently has + // the known shortest path from s. + // XXX: Do we actually need both `costs` and `open`? + + var open = new BinaryHeap(function (x) { + return x.cost; + }); + open.push({ + value: s, + cost: 0 + }); + var closest; + var u; + var cost_of_s_to_u; + var adjacent_nodes; + var cost_of_e; + var cost_of_s_to_u_plus_cost_of_e; + var cost_of_s_to_v; + var first_visit; + + while (open.size()) { + // In the nodes remaining in graph that have a known cost from s, + // find the node, u, that currently has the shortest path from s. + closest = open.pop(); + u = closest.value; + cost_of_s_to_u = closest.cost; // Get nodes adjacent to u... + + adjacent_nodes = graph(u) || {}; // ...and explore the edges that connect u to those nodes, updating + // the cost of the shortest paths to any or all of those nodes as + // necessary. v is the node across the current edge from u. + + for (var v in adjacent_nodes) { + // Get the cost of the edge running from u to v. + cost_of_e = adjacent_nodes[v]; // Cost of s to u plus the cost of u to v across e--this is *a* + // cost from s to v that may or may not be less than the current + // known cost to v. + + cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e; // If we haven't visited v yet OR if the current known cost from s to + // v is greater than the new cost we just found (cost of s to u plus + // cost of u to v across e), update v's cost in the cost list and + // update v's predecessor in the predecessor list (it's now u). + + cost_of_s_to_v = costs[v]; + first_visit = typeof costs[v] === "undefined"; + + if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) { + costs[v] = cost_of_s_to_u_plus_cost_of_e; + open.push({ + value: v, + cost: cost_of_s_to_u_plus_cost_of_e + }); + predecessors[v] = u; + } + } + } + + if (typeof costs[d] === "undefined") { + var msg = ["Could not find a path from ", s, " to ", d, "."].join(""); + throw new Error(msg); + } + + return predecessors; + } + + function extract_shortest_path_from_predecessor_list(predecessors, d) { + var nodes = []; + var u = d; + + while (u) { + nodes.push(u); + u = predecessors[u]; + } + + nodes.reverse(); + return nodes; + } + + function find_path(graph, s, d) { + var predecessors = single_source_shortest_paths(graph, s, d); + return extract_shortest_path_from_predecessor_list(predecessors, d); + } + + var BinaryHeap = + /*#__PURE__*/ + function () { + function BinaryHeap(scoreFunction) { + this.content = []; + this.scoreFunction = scoreFunction; + } + + var __proto = BinaryHeap.prototype; + + __proto.push = function (element) { + // Add the new element to the end of the array. + this.content.push(element); // Allow it to bubble up. + + this.bubbleUp(this.content.length - 1); + }; + + __proto.pop = function () { + // Store the first element so we can return it later. + var result = this.content[0]; // Get the element at the end of the array. + + var end = this.content.pop(); // If there are any elements left, put the end element at the + // start, and let it sink down. + + if (this.content.length > 0) { + this.content[0] = end; + this.sinkDown(0); + } + + return result; + }; + + __proto.size = function () { + return this.content.length; + }; + + __proto.bubbleUp = function (_n) { + var n = _n; // Fetch the element that has to be moved. + + var element = this.content[n]; // When at 0, an element can not go up any further. + + while (n > 0) { + // Compute the parent element's index, and fetch it. + var parentN = Math.floor((n + 1) / 2) - 1; + var parent = this.content[parentN]; // Swap the elements if the parent is greater. + + if (this.scoreFunction(element) < this.scoreFunction(parent)) { + this.content[parentN] = element; + this.content[n] = parent; // Update 'n' to continue at the new position. + + n = parentN; + } else { + // Found a parent that is less, no need to move it further. + break; + } + } + }; + + __proto.sinkDown = function (n) { + // Look up the target element and its score. + var length = this.content.length; + var element = this.content[n]; + var elemScore = this.scoreFunction(element); + var child1Score; + + while (true) { + // Compute the indices of the child elements. + var child2N = (n + 1) * 2; + var child1N = child2N - 1; // This is used to store the new position of the element, + // if any. + + var swap = null; // If the first child exists (is inside the array)... + + if (child1N < length) { + // Look it up and compute its score. + var child1 = this.content[child1N]; + child1Score = this.scoreFunction(child1); // If the score is less than our element's, we need to swap. + + if (child1Score < elemScore) { + swap = child1N; + } + } // Do the same checks for the other child. + + + if (child2N < length) { + var child2 = this.content[child2N]; + var child2Score = this.scoreFunction(child2); + + if (child2Score < (swap == null ? elemScore : child1Score)) { + swap = child2N; + } + } // If the element needs to be moved, swap it, and continue. + + + if (swap !== null) { + this.content[n] = this.content[swap]; + this.content[swap] = element; + n = swap; + } else { + // Otherwise, we are done. + break; + } + } + }; + + return BinaryHeap; + }(); + + function splitItems(items, path) { + var length = path.length; + var groups = []; + + for (var i = 0; i < length - 1; ++i) { + var path1 = parseInt(path[i], 10); + var path2 = parseInt(path[i + 1], 10); + groups.push(items.slice(path1, path2)); + } + + return groups; + } + + function getExpectedColumnSize(item, rowSize) { + var inlineSize = item.orgInlineSize; + var contentSize = item.orgContentSize; + + if (!inlineSize || !contentSize) { + return 0; + } + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset; + } + /** + * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size. + * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value. + * 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. + * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다. + * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다. + * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체 + */ + + + var JustifiedGrid = + /*#__PURE__*/ + function (_super) { + __extends(JustifiedGrid, _super); + + function JustifiedGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = JustifiedGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var rowRange = this.options.rowRange; + var path = []; + + if (items.length) { + path = rowRange ? this._getRowPath(items) : this._getPath(items); + } + + return this._setStyle(items, path, outline, direction === "end"); + }; + + __proto.readyItems = function (mounted, updated, options) { + var _a = this.options, + attributePrefix = _a.attributePrefix, + horizontal = _a.horizontal; + updated.forEach(function (item) { + var element = item.element; + var attributes = item.attributes; + var gridData = item.gridData; + var inlineOffset = parseFloat(attributes.inlineOffset) || 0; + var contentOffset = parseFloat(attributes.contentOffset) || 0; + + if (element && !("inlineOffset" in attributes) && !("contentOffset" in attributes)) { + var maintainedTarget = element.querySelector("[" + attributePrefix + "maintained-target]"); + + if (maintainedTarget) { + var widthOffset = element.offsetWidth - element.clientWidth + element.scrollWidth - maintainedTarget.clientWidth; + var heightOffset = element.offsetHeight - element.clientHeight + element.scrollHeight - maintainedTarget.clientHeight; + + if (horizontal) { + inlineOffset = heightOffset; + contentOffset = widthOffset; + } else { + inlineOffset = widthOffset; + contentOffset = heightOffset; + } + } + } + + gridData.inlineOffset = inlineOffset; + gridData.contentOffset = contentOffset; + }); + + _super.prototype.readyItems.call(this, mounted, updated, options); + }; + + __proto._getRowPath = function (items) { + var _a; + + var columnRange = this._getColumnRange(); + + var rowRange = this._getRowRange(); + + var pathLink = this._getRowLink(items, { + path: [0], + cost: 0, + length: 0, + currentNode: 0 + }, columnRange, rowRange); + + return (_a = pathLink === null || pathLink === void 0 ? void 0 : pathLink.path.map(function (node) { + return "" + node; + })) !== null && _a !== void 0 ? _a : []; + }; + + __proto._getRowLink = function (items, currentLink, columnRange, rowRange) { + var minColumn = columnRange[0]; + var minRow = rowRange[0], + maxRow = rowRange[1]; + var lastNode = items.length; + var path = currentLink.path, + pathLength = currentLink.length, + cost = currentLink.cost, + currentNode = currentLink.currentNode; // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn. + + if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) { + var rangeCost = getRangeCost(lastNode - currentNode, columnRange); + var lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode)); + return __assign(__assign({}, currentLink), { + length: pathLength + 1, + path: __spreadArrays(path, [lastNode]), + currentNode: lastNode, + cost: cost + lastCost, + isOver: true + }); + } else if (currentNode >= lastNode) { + return __assign(__assign({}, currentLink), { + currentNode: lastNode, + isOver: minRow > pathLength || maxRow < pathLength + }); + } else { + return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange); + } + }; + + __proto._searchRowLink = function (items, currentLink, lastNode, columnRange, rowRange) { + var minColumn = columnRange[0], + maxColumn = columnRange[1]; + var currentNode = currentLink.currentNode, + path = currentLink.path, + pathLength = currentLink.length, + cost = currentLink.cost; + var length = Math.min(lastNode, currentNode + maxColumn); + var links = []; + + for (var nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) { + if (nextNode === currentNode) { + continue; + } + + var nextCost = Math.abs(this._getCost(items, currentNode, nextNode)); + + var nextLink = this._getRowLink(items, { + path: __spreadArrays(path, [nextNode]), + length: pathLength + 1, + cost: cost + nextCost, + currentNode: nextNode + }, columnRange, rowRange); + + if (nextLink) { + links.push(nextLink); + } + } + + links.sort(function (a, b) { + var aIsOver = a.isOver; + var bIsOver = b.isOver; + + if (aIsOver !== bIsOver) { + // If it is over, the cost is high. + return aIsOver ? 1 : -1; + } + + var aRangeCost = getRangeCost(a.length, rowRange); + var bRangeCost = getRangeCost(b.length, rowRange); + return aRangeCost - bRangeCost || a.cost - b.cost; + }); // It returns the lowest cost link. + + return links[0]; + }; + + __proto._getExpectedRowSize = function (items) { + var gap = this.options.gap; + var containerInlineSize = this.getContainerInlineSize() - gap * (items.length - 1); + var ratioSum = 0; + var inlineSum = 0; + items.forEach(function (item) { + var inlineSize = item.orgInlineSize; + var contentSize = item.orgContentSize; + + if (!inlineSize || !contentSize) { + return; + } // sum((expect - offset) * ratio) = container inline size + + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset); + ratioSum += maintainedRatio; + inlineSum += contentOffset * maintainedRatio; + containerInlineSize -= inlineOffset; + }); + return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0; + }; + + __proto._getExpectedInlineSize = function (items, rowSize) { + var gap = this.options.gap; + var size = items.reduce(function (sum, item) { + return sum + getExpectedColumnSize(item, rowSize); + }, 0); + return size ? size + gap * (items.length - 1) : 0; + }; + + __proto._getCost = function (items, i, j) { + var lineItems = items.slice(i, j); + + var rowSize = this._getExpectedRowSize(lineItems); + + var _a = this._getSizeRange(), + minSize = _a[0], + maxSize = _a[1]; + + if (this.isCroppedSize) { + if (minSize <= rowSize && rowSize <= maxSize) { + return 0; + } + + var expectedInlineSize = this._getExpectedInlineSize(lineItems, rowSize < minSize ? minSize : maxSize); + + return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2); + } + + if (isFinite(maxSize)) { + // if this size is not in range, the cost increases sharply. + if (rowSize < minSize) { + return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2); + } else if (rowSize > maxSize) { + return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2); + } + } else if (rowSize < minSize) { + return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2); + } // if this size in range, the cost is row + + + return rowSize - minSize; + }; + + __proto._getPath = function (items) { + var _this = this; + + var lastNode = items.length; + var columnRangeOption = this.options.columnRange; + + var _a = isObject(columnRangeOption) ? columnRangeOption : [columnRangeOption, columnRangeOption], + minColumn = _a[0], + maxColumn = _a[1]; + + var graph = function (nodeKey) { + var results = {}; + var currentNode = parseInt(nodeKey, 10); + + for (var nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) { + if (nextNode - currentNode > maxColumn) { + break; + } + + var cost = _this._getCost(items, currentNode, nextNode); + + if (cost < 0 && nextNode === lastNode) { + cost = 0; + } + + results["" + nextNode] = Math.pow(cost, 2); + } + + return results; + }; // shortest path for items' total height. + + + return find_path(graph, "0", "" + lastNode); + }; + + __proto._setStyle = function (items, path, outline, isEndDirection) { + var _this = this; + + if (outline === void 0) { + outline = []; + } + + var _a = this.options, + gap = _a.gap, + isCroppedSize = _a.isCroppedSize, + displayedRow = _a.displayedRow; + + var sizeRange = this._getSizeRange(); + + var startPoint = outline[0] || 0; + var containerInlineSize = this.getContainerInlineSize(); + var groups = splitItems(items, path); + var contentPos = startPoint; + var displayedSize = 0; + groups.forEach(function (groupItems, rowIndex) { + var length = groupItems.length; + + var rowSize = _this._getExpectedRowSize(groupItems); + + if (isCroppedSize) { + rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1])); + } + + var expectedInlineSize = _this._getExpectedInlineSize(groupItems, rowSize); + + var allGap = gap * (length - 1); + var scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap); + groupItems.forEach(function (item, i) { + var columnSize = getExpectedColumnSize(item, rowSize); + var prevItem = groupItems[i - 1]; + var inlinePos = prevItem ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap : 0; + + if (isCroppedSize) { + columnSize *= scale; + } + + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: columnSize, + contentSize: rowSize + }); + }); + contentPos += gap + rowSize; + + if (displayedRow < 0 || rowIndex < displayedRow) { + displayedSize = contentPos; + } + }); + + if (isEndDirection) { + // previous group's end outline is current group's start outline + return { + start: [startPoint], + end: [displayedSize] + }; + } // always start is lower than end. + // contentPos is endPoinnt + + + var height = contentPos - startPoint; + items.forEach(function (item) { + item.cssContentPos -= height; + }); + return { + start: [startPoint - height], + end: [startPoint] + }; + }; + + __proto._getRowRange = function () { + var rowRange = this.rowRange; + return isObject(rowRange) ? rowRange : [rowRange, rowRange]; + }; + + __proto._getColumnRange = function () { + var columnRange = this.columnRange; + return isObject(columnRange) ? columnRange : [columnRange, columnRange]; + }; + + __proto._getSizeRange = function () { + var sizeRange = this.sizeRange; + return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange]; + }; + + JustifiedGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + columnRange: PROPERTY_TYPE.RENDER_PROPERTY, + rowRange: PROPERTY_TYPE.RENDER_PROPERTY, + sizeRange: PROPERTY_TYPE.RENDER_PROPERTY, + isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY, + displayedRow: PROPERTY_TYPE.RENDER_PROPERTY + }); + JustifiedGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + columnRange: [1, 8], + rowRange: 0, + sizeRange: [0, Infinity], + displayedRow: -1, + isCroppedSize: false + }); + JustifiedGrid = __decorate([GetterSetter], JustifiedGrid); + return JustifiedGrid; + }(Grid); + /** + * The minimum and maximum number of items per line. (default: [1, 8]) + * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) + * @name Grid.JustifiedGrid#columnRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["columnRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * columnRange: [1, 8], + * }); + * + * grid.columnRange = [3, 6]; + */ + + /** + * The minimum and maximum number of rows in a group, 0 is not set. (default: 0) + * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) + * @name Grid.JustifiedGrid#rowRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["rowRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * rowRange: 0, + * }); + * + * grid.rowRange = [3, 4]; + */ + + /** + * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) + * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity]) + * @name Grid.JustifiedGrid#sizeRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["sizeRange"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * sizeRange: [0, Infinity], + * }); + * + * grid.sizeRange = [200, 800]; + */ + + /** + * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1) + * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1) + * @name Grid.JustifiedGrid#displayedRow + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["displayedRow"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * displayedRow: -1, + * }); + * + * grid.displayedRow = 3; + */ + + /** + * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) + * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false) + * @name Grid.JustifiedGrid#isCroppedSize + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["isCroppedSize"]} + * @example + * import { JustifiedGrid } from "@egjs/grid"; + * + * const grid = new JustifiedGrid(container, { + * sizeRange: [200, 250], + * isCroppedSize: false, + * }); + * + * grid.isCroppedSize = true; + */ + + function getMaxPoint(outline) { + var maxPoint = -Infinity; + outline.forEach(function (point) { + if (isFinite(point)) { + maxPoint = Math.max(maxPoint, point); + } + }); + return isFinite(maxPoint) ? maxPoint : 0; + } + + function getMinPoint(outline) { + var minPoint = Infinity; + outline.forEach(function (point) { + if (isFinite(point)) { + minPoint = Math.min(minPoint, point); + } + }); + return isFinite(minPoint) ? minPoint : 0; + } + + function getOutlinePoint(startOutline, frameOutline, useFrameFill) { + return getMaxPoint(startOutline) + getOutlineDist(startOutline, frameOutline, useFrameFill); + } + + function getOutlineDist(startOutline, endOutline, useFrameFill) { + var length = startOutline.length; + + if (!length) { + return 0; + } + + var minEndPoint = getMinPoint(endOutline); + var maxStartPoint = getMaxPoint(startOutline); + var frameDist = 0; + + if (!useFrameFill) { + return 0; + } + + for (var outlineIndex = 0; outlineIndex < length; ++outlineIndex) { + var startPoint = startOutline[outlineIndex]; + var endPoint = endOutline[outlineIndex]; + + if (!isFinite(startPoint) || !isFinite(endPoint)) { + continue; + } + + var startPos = startPoint - maxStartPoint; + var endPos = endPoint - minEndPoint; // Fill empty block. + + frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos; + } + + return frameDist; + } + + function fillOutlines(startOutline, endOutline, rect) { + var inlinePos = rect.inlinePos, + inlineSize = rect.inlineSize, + contentPos = rect.contentPos, + contentSize = rect.contentSize; + + for (var outlineIndex = inlinePos; outlineIndex < inlinePos + inlineSize; ++outlineIndex) { + startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos); + endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize); + } + } + /** + * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size. + * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체 + */ + + + var FrameGrid = + /*#__PURE__*/ + function (_super) { + __extends(FrameGrid, _super); + + function FrameGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = FrameGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var frame = this._getFrame(); + + var frameInlineSize = frame.inlineSize, + frameContentSize = frame.contentSize, + frameRects = frame.rects; + var _a = this.options, + gap = _a.gap, + useFrameFill = _a.useFrameFill; + + var _b = this.getRectSize(frameInlineSize), + rectInlineSize = _b.inlineSize, + rectContentSize = _b.contentSize; + + var itemsLength = items.length; + + if (!itemsLength || !frameInlineSize || !frameContentSize) { + return { + start: outline, + end: outline + }; + } + + var rectsLength = frameRects.length; + var startOutline = range(frameInlineSize).map(function () { + return Infinity; + }); + var endOutline = range(frameInlineSize).map(function () { + return -Infinity; + }); + var frameOutline = frame.outline.map(function (point) { + return point * (rectContentSize + gap); + }); + + for (var startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) { + // Compare group's startOutline and startOutline of rect + var startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill); + + for (var rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) { + var item = items[startIndex + rectIndex]; + var _c = frameRects[rectIndex], + frameRectContentPos = _c.contentPos, + frameRectInlinePos = _c.inlinePos, + frameRectContentSize = _c.contentSize, + frameRectInlineSize = _c.inlineSize; + var contentPos = startPoint + frameRectContentPos * (rectContentSize + gap); + var inlinePos = frameRectInlinePos * (rectInlineSize + gap); + var contentSize = frameRectContentSize * (rectContentSize + gap) - gap; + var inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap; + fillOutlines(startOutline, endOutline, { + inlinePos: frameRectInlinePos, + inlineSize: frameRectInlineSize, + contentPos: contentPos, + contentSize: contentSize + gap + }); + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: inlineSize, + contentSize: contentSize + }); + } + } + + var isDirectionEnd = direction === "end"; + var gridOutline = outline; + + if (gridOutline.length !== frameInlineSize) { + var point_1 = isDirectionEnd ? Math.max.apply(Math, gridOutline) : Math.min.apply(Math, gridOutline); + gridOutline = range(frameInlineSize).map(function () { + return point_1; + }); + } + + startOutline = startOutline.map(function (point) { + return isFinite(point) ? point : 0; + }); + endOutline = endOutline.map(function (point) { + return isFinite(point) ? point : 0; + }); + var outlineDist = isDirectionEnd ? getOutlineDist(startOutline, gridOutline, useFrameFill) : getOutlineDist(gridOutline, endOutline, useFrameFill); + items.forEach(function (item) { + item.cssContentPos += outlineDist; + }); + return { + start: startOutline.map(function (point) { + return point + outlineDist; + }), + end: endOutline.map(function (point) { + return point + outlineDist; + }) + }; + }; + + __proto.getRectSize = function (frameInlineSize) { + var _a = this.options, + gap = _a.gap, + rectSizeOption = _a.rectSize; + + if (typeof rectSizeOption === "object") { + return rectSizeOption; + } + + var rectSizeValue = rectSizeOption ? rectSizeOption : (this.getContainerInlineSize() + gap) / frameInlineSize - gap; + return { + inlineSize: rectSizeValue, + contentSize: rectSizeValue + }; + }; + + __proto._getFrame = function () { + var frame = this.options.frame; + var frameContentSize = frame.length; + var frameInlineSize = frameContentSize ? frame[0].length : 0; + var rects = []; + var passMap = {}; + var startOutline = range(frameInlineSize).map(function () { + return Infinity; + }); + var endOutline = range(frameInlineSize).map(function () { + return -Infinity; + }); + + for (var y1 = 0; y1 < frameContentSize; ++y1) { + for (var x1 = 0; x1 < frameInlineSize; ++x1) { + var type = frame[y1][x1]; + + if (!type) { + continue; + } + + if (passMap[y1 + "," + x1]) { + continue; + } + + var rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize); + + fillOutlines(startOutline, endOutline, rect); + rects.push(rect); + } + } + + rects.sort(function (a, b) { + return a.type < b.type ? -1 : 1; + }); + return { + rects: rects, + inlineSize: frameInlineSize, + contentSize: frameContentSize, + outline: startOutline + }; + }; + + __proto._findRect = function (passMap, type, y1, x1, frameInlineSize, frameContentSize) { + var frame = this.options.frame; + var contentSize = 1; + var inlineSize = 1; // find rect + + for (var x2 = x1; x2 < frameInlineSize; ++x2) { + if (frame[y1][x2] === type) { + inlineSize = x2 - x1 + 1; + continue; + } + + break; + } + + for (var y2 = y1; y2 < frameContentSize; ++y2) { + if (frame[y2][x1] === type) { + contentSize = y2 - y1 + 1; + continue; + } + + break; + } // pass rect + + + for (var y = y1; y < y1 + contentSize; ++y) { + for (var x = x1; x < x1 + inlineSize; ++x) { + passMap[y + "," + x] = true; + } + } + + var rect = { + type: type, + inlinePos: x1, + contentPos: y1, + inlineSize: inlineSize, + contentSize: contentSize + }; + return rect; + }; + + FrameGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + frame: PROPERTY_TYPE.RENDER_PROPERTY, + useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY, + rectSize: PROPERTY_TYPE.RENDER_PROPERTY + }); + FrameGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + frame: [], + rectSize: 0, + useFrameFill: true + }); + FrameGrid = __decorate([GetterSetter], FrameGrid); + return FrameGrid; + }(Grid); + /** + * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: []) + * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: []) + * @name Grid.FrameGrid#frame + * @type {$ts:Grid.FrameGrid.FrameGridOptions["frame"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * // Item 1 : 2 x 2 + * // Item 2 : 1 x 1 + * // Item 3 : 1 x 2 + * // Item 4 : 1 x 1 + * // Item 5 : 2 x 1 + * const grid = new FrameGrid(container, { + * frame: [ + * [1, 1, 0, 0, 2, 3], + * [1, 1, 0, 4, 5, 5], + * ], + * }); + * + * // Item 1 : 2 x 2 + * // Item 2 : 2 x 2 + * grid.frame = [ + * [1, 1, 0, 0, 2, 2], + * [1, 1, 0, 0, 2, 2], + * ]; + */ + + /** + * Make sure that the frame can be attached after the previous frame. (default: true) + * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true) + * @name Grid.FrameGrid#useFrameFill + * @type {$ts:Grid.FrameGrid.FrameGridOptions["useFrameFill"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * const grid = new FrameGrid(container, { + * useFrameFill: true, + * }); + * + * grid.useFrameFill = false; + */ + + /** + * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) + * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0) + * @name Grid.FrameGrid#rectSize + * @type {$ts:Grid.FrameGrid.FrameGridOptions["rectSize"]} + * @example + * import { FrameGrid } from "@egjs/grid"; + * + * const grid = new FrameGrid(container, { + * rectSize: 0, + * }); + * + * grid.rectSize = { inlineSize: 100, contentSize: 150 }; + */ + + var BoxModel = + /*#__PURE__*/ + function () { + function BoxModel(status) { + var boxStatus = __assign({ + orgInlineSize: 0, + orgContentSize: 0, + inlineSize: 0, + contentSize: 0, + inlinePos: 0, + contentPos: 0, + items: [] + }, status); + + for (var name in boxStatus) { + this[name] = boxStatus[name]; + } + } + + var __proto = BoxModel.prototype; + + __proto.scaleTo = function (inlineSize, contentSize) { + var scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0; + var scaleY = this.contentSize ? contentSize / this.contentSize : 0; + this.items.forEach(function (item) { + if (scaleX !== 0) { + item.inlinePos *= scaleX; + item.inlineSize *= scaleX; + } + + if (scaleY !== 0) { + item.contentPos *= scaleY; + item.contentSize *= scaleY; + } + }); + this.inlineSize = inlineSize; + this.contentSize = contentSize; + }; + + __proto.push = function (item) { + this.items.push(item); + }; + + __proto.getOrgSizeWeight = function () { + return this.orgInlineSize * this.orgContentSize; + }; + + __proto.getSize = function () { + return this.inlineSize * this.contentSize; + }; + + __proto.getOrgRatio = function () { + return this.orgContentSize === 0 ? 0 : this.orgInlineSize / this.orgContentSize; + }; + + __proto.getRatio = function () { + return this.contentSize === 0 ? 0 : this.inlineSize / this.contentSize; + }; + + return BoxModel; + }(); + + function getCost(originLength, length) { + var cost = originLength / length; + + if (cost < 1) { + cost = 1 / cost; + } + + return cost - 1; + } + + function fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection) { + item.contentSize = itemFitSize.contentSize; + item.inlineSize = itemFitSize.inlineSize; + bestFitArea.contentSize = containerFitSize.contentSize; + bestFitArea.inlineSize = containerFitSize.inlineSize; + + if (isContentDirection) { + item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize; + item.inlinePos = bestFitArea.inlinePos; + } else { + item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize; + item.contentPos = bestFitArea.contentPos; + } + } + /** + * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items. + * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion. + * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible. + * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible. + * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다. + * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다. + * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다. + * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다. + * @memberof Grid + * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트 + * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체 + */ + + + var PackingGrid = + /*#__PURE__*/ + function (_super) { + __extends(PackingGrid, _super); + + function PackingGrid() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = PackingGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var _this = this; + + var _a = this.options, + aspectRatio = _a.aspectRatio, + gap = _a.gap; + var containerInlineSize = this.getContainerInlineSize(); + var containerContentSize = containerInlineSize / aspectRatio; + var prevOutline = outline.length ? outline : [0]; + var startPoint = direction === "end" ? Math.max.apply(Math, prevOutline) : Math.min.apply(Math, prevOutline) - containerContentSize - gap; + var endPoint = startPoint + containerContentSize + gap; + var container = new BoxModel({}); + items.forEach(function (item) { + var model = new BoxModel({ + inlineSize: item.orgInlineSize, + contentSize: item.orgContentSize, + orgInlineSize: item.orgInlineSize, + orgContentSize: item.orgContentSize + }); + + _this._findBestFitArea(container, model); + + container.push(model); + container.scaleTo(containerInlineSize + gap, containerContentSize + gap); + }); + items.forEach(function (item, i) { + var boxItem = container.items[i]; + var inlineSize = boxItem.inlineSize - gap; + var contentSize = boxItem.contentSize - gap; + var contentPos = startPoint + boxItem.contentPos; + var inlinePos = boxItem.inlinePos; + item.setCSSGridRect({ + inlinePos: inlinePos, + contentPos: contentPos, + inlineSize: inlineSize, + contentSize: contentSize + }); + }); + return { + start: [startPoint], + end: [endPoint] + }; + }; + + __proto._findBestFitArea = function (container, item) { + if (container.getRatio() === 0) { + // 아이템 최초 삽입시 전체영역 지정 + container.orgInlineSize = item.inlineSize; + container.orgContentSize = item.contentSize; + container.inlineSize = item.inlineSize; + container.contentSize = item.contentSize; + return; + } + + var bestFitArea; + var minCost = Infinity; + var isContentDirection = false; + var itemFitSize = { + inlineSize: 0, + contentSize: 0 + }; + var containerFitSize = { + inlineSize: 0, + contentSize: 0 + }; + + var sizeWeight = this._getWeight("size"); + + var ratioWeight = this._getWeight("ratio"); + + container.items.forEach(function (child) { + var containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight; + var containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight; + var inlineSize = child.inlineSize; + var contentSize = child.contentSize; + + for (var i = 0; i < 2; ++i) { + var itemInlineSize = void 0; + var itemContentSize = void 0; + var containerInlineSize = void 0; + var containerContentSize = void 0; + + if (i === 0) { + // add item to content pos (top, bottom) + itemInlineSize = inlineSize; + itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize)); + containerInlineSize = inlineSize; + containerContentSize = contentSize - itemContentSize; + } else { + // add item to inline pos (left, right) + itemContentSize = contentSize; + itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize)); + containerContentSize = contentSize; + containerInlineSize = inlineSize - itemInlineSize; + } + + var itemSize = itemInlineSize * itemContentSize; + var itemRatio = itemInlineSize / itemContentSize; + var containerSize = containerInlineSize * containerContentSize; + var containerRatio = containerContentSize / containerContentSize; + var cost = getCost(item.getSize(), itemSize) * sizeWeight; + cost += getCost(item.getRatio(), itemRatio) * ratioWeight; + cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost; + cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost; + + if (cost === Math.min(cost, minCost)) { + minCost = cost; + bestFitArea = child; + isContentDirection = i === 0; + itemFitSize.inlineSize = itemInlineSize; + itemFitSize.contentSize = itemContentSize; + containerFitSize.inlineSize = containerInlineSize; + containerFitSize.contentSize = containerContentSize; + } + } + }); + fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection); + }; + + __proto._getWeight = function (type) { + var options = this.options; + var weightPriority = options.weightPriority; + + if (weightPriority === type) { + return 100; + } else if (weightPriority === "custom") { + return options[type + "Weight"]; + } + + return 1; + }; + + PackingGrid.propertyTypes = __assign(__assign({}, Grid.propertyTypes), { + aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY, + sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY, + ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY, + weightPriority: PROPERTY_TYPE.RENDER_PROPERTY + }); + PackingGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + aspectRatio: 1, + sizeWeight: 1, + ratioWeight: 1, + weightPriority: "custom" + }); + PackingGrid = __decorate([GetterSetter], PackingGrid); + return PackingGrid; + }(Grid); + /** + * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) + * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1) + * @name Grid.PackingGrid#aspectRatio + * @type {$ts:Grid.PackingGrid.PackingGridOptions["aspectRatio"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * aspectRatio: 1, + * }); + * + * grid.aspectRatio = 1.5; + */ + + /** + * The priority that determines the weight of the item. (default: "custom"), "size" = (sizeWieght: 2, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 2), "custom" = (set sizeWeight, ratioWeight) + * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`. + * @ko 아이템의 가중치를 결정하는 우선수치. (default: "custom"), "size" = (sizeWieght: 2, ratioWeight: 1), "ratio" = (sizeWeight: 1, ratioWeight; 2), "custom" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`. + * @name Grid.PackingGrid#weightPriority + * @type {$ts:Grid.PackingGrid.PackingGridOptions["weightPriority"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * weightPriority: "custom", + * sizeWeight: 1, + * ratioWeight: 1, + * }); + * + * grid.weightPriority = "size"; + * // or + * grid.weightPriority = "ratio"; + */ + + /** + * The size weight when placing items. (default: 1) + * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1) + * @name Grid.PackingGrid#sizeWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["sizeWeight"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * sizeWeight: 1, + * }); + * + * grid.sizeWeight = 10; + */ + + /** + * The weight to keep ratio when placing items. (default: 1) + * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1) + * @name Grid.PackingGrid#ratioWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["ratioWeight"]} + * @example + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * ratioWeight: 1, + * }); + * + * grid.ratioWeight = 10; + */ + + /** + * egjs-grid + * Copyright (c) 2021-present NAVER Corp. + * MIT license + */ + + var modules = { + __proto__: null, + 'default': Grid, + GetterSetter: GetterSetter, + withGridMethods: withGridMethods, + withMethods: withMethods, + MasonryGrid: MasonryGrid, + JustifiedGrid: JustifiedGrid, + FrameGrid: FrameGrid, + PackingGrid: PackingGrid, + GridItem: GridItem, + ContainerManager: ContainerManager, + DEFAULT_GRID_OPTIONS: DEFAULT_GRID_OPTIONS, + get PROPERTY_TYPE () { return PROPERTY_TYPE; }, + get MOUNT_STATE () { return MOUNT_STATE; }, + get UPDATE_STATE () { return UPDATE_STATE; }, + GRID_PROPERTY_TYPES: GRID_PROPERTY_TYPES, + GRID_METHODS: GRID_METHODS, + GRID_EVENTS: GRID_EVENTS, + RECT_NAMES: RECT_NAMES + }; + + /** + * egjs-grid + * Copyright (c) 2021-present NAVER Corp. + * MIT license + */ + + for (var name in modules) { + Grid[name] = modules[name]; + } + + return Grid; + +}))); +//# sourceMappingURL=grid.js.map diff --git a/dist/grid.js.map b/dist/grid.js.map new file mode 100644 index 0000000..d8e0a49 --- /dev/null +++ b/dist/grid.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.js","sources":["../src/consts.ts","../src/ContainerManager.ts","../src/utils.ts","../src/ItemRenderer.ts","../src/GridItem.ts","../src/Grid.ts","../src/grids/MasonryGrid.ts","../src/grids/lib/dijkstra.ts","../src/grids/JustifiedGrid.ts","../src/grids/FrameGrid.ts","../src/grids/lib/BoxModel.ts","../src/grids/PackingGrid.ts","../src/index.ts","../src/index.umd.ts"],"sourcesContent":["/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { GridOptions } from \"./types\";\n\nexport const DEFAULT_GRID_OPTIONS: Required = {\n horizontal: false,\n useTransform: false,\n percentage: false,\n isEqualSize: false,\n isConstantSize: false,\n gap: 0,\n attributePrefix: \"data-grid-\",\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n autoResize: true,\n preserveUIOnDestroy: false,\n defaultDirection: \"end\",\n externalContainerManager: null,\n externalItemRenderer: null,\n renderOnPropertyChange: true,\n useFit: true,\n};\n\nexport enum PROPERTY_TYPE {\n PROPERTY = 1,\n RENDER_PROPERTY = 2,\n}\nexport enum MOUNT_STATE {\n UNCHECKED = 1,\n UNMOUNTED = 2,\n MOUNTED = 3,\n}\nexport enum UPDATE_STATE {\n NEED_UPDATE = 1,\n WAIT_LOADING = 2,\n UPDATED = 3,\n}\n\nexport const GRID_PROPERTY_TYPES = {\n gap: PROPERTY_TYPE.RENDER_PROPERTY,\n defaultDirection: PROPERTY_TYPE.PROPERTY,\n renderOnPropertyChange: PROPERTY_TYPE.PROPERTY,\n preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY,\n useFit: PROPERTY_TYPE.PROPERTY,\n};\n\nexport const GRID_METHODS = [\n \"syncElements\",\n \"updateItems\",\n \"getItems\",\n \"setItems\",\n \"renderItems\",\n \"getContainerInlineSize\",\n \"getContainerElement\",\n] as const;\n\nexport const GRID_EVENTS = [\n \"renderComplete\",\n \"contentError\",\n] as const;\n\nexport const RECT_NAMES = {\n horizontal: {\n inlinePos: \"top\",\n contentPos: \"left\",\n inlineSize: \"height\",\n contentSize: \"width\",\n },\n vertical: {\n inlinePos: \"left\",\n contentPos: \"top\",\n inlineSize: \"width\",\n contentSize: \"height\",\n },\n} as const;\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DestroyOptions } from \".\";\nimport { DEFAULT_GRID_OPTIONS } from \"./consts\";\nimport { DOMRect } from \"./types\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: DOMRect;\n}\n\nexport class ContainerManager {\n protected options: Required;\n protected rect: DOMRect;\n protected orgCSSText: string;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.offsetWidth,\n height: container.offsetHeight,\n });\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: DOMRect) {\n this.rect = { ...rect };\n }\n public getInlineSize() {\n return this.rect[this.options.horizontal ? \"height\" : \"width\"];\n }\n public getContentSize() {\n return this.rect[this.options.horizontal ? \"width\" : \"height\"]!;\n }\n public getStatus() {\n return {\n rect: { ...this.rect },\n };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.rect = { ...status.rect };\n\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.rect[sizeName] = size;\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n if (!options.preserveUI) {\n this.container.style.cssText = this.orgCSSText;\n }\n }\n private _init() {\n const container = this.container;\n const style = window.getComputedStyle(container);\n\n this.orgCSSText = container.style.cssText;\n\n if (style.position === \"static\") {\n container.style.position = \"relative\";\n }\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\nimport { GRID_METHODS, GRID_PROPERTY_TYPES, PROPERTY_TYPE } from \"./consts\";\n\nexport function getKeys>(obj: T): Array {\n return Object.keys(obj);\n}\n\nexport function isString(val: any): val is string {\n return typeof val === \"string\";\n}\nexport function isObject(val: any): val is object {\n return typeof val === \"object\";\n}\nexport function isNumber(val: any): val is number {\n return typeof val === \"number\";\n}\n\nexport function camelize(str: string) {\n return str.replace(/[\\s-_]([a-z])/g, (all, letter) => letter.toUpperCase());\n}\n\nexport function getDataAttributes(element: HTMLElement, attributePrefix: string) {\n const dataAttributes: Record = {};\n const attributes = element.attributes;\n const length = attributes.length;\n\n for (let i = 0; i < length; ++i) {\n const attribute = attributes[i];\n const { name, value } = attribute;\n if (name.indexOf(attributePrefix) === -1) {\n continue;\n }\n dataAttributes[camelize(name.replace(attributePrefix, \"\"))] = value;\n }\n\n return dataAttributes;\n}\n\n/* Class Decorator */\nexport function GetterSetter(component: {\n prototype: Grid,\n propertyTypes: typeof GRID_PROPERTY_TYPES,\n}) {\n const {\n prototype,\n propertyTypes,\n } = component;\n for (const name in propertyTypes) {\n const shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY;\n const attributes: Record = {\n enumerable: true,\n configurable: true,\n get(this: Grid) {\n return this.options[name];\n },\n set(this: Grid, value: any) {\n const options = this.options;\n const prevValue = options[name];\n\n if (prevValue === value) {\n return;\n }\n options[name] = value;\n\n if (shouldRender && options.renderOnPropertyChange) {\n this.scheduleRender();\n }\n },\n };\n Object.defineProperty(prototype, name, attributes);\n }\n}\n\nexport function withMethods(methods: readonly string[]) {\n return function (prototype: any, memberName: string) {\n methods.forEach((name: string) => {\n if (name in prototype) {\n return;\n }\n prototype[name] = function (...args) {\n const result = this[memberName][name](...args);\n\n // fix `this` type to return your own `class` instance to the instance using the decorator.\n if (result === this[memberName]) {\n return this;\n } else {\n return result;\n }\n };\n });\n };\n}\n\nexport function range(length: number): number[] {\n const arr: number[] = [];\n for (let i = 0; i < length; ++i) {\n arr.push(i);\n }\n return arr;\n}\n\nexport function getRangeCost(value: number, valueRange: number[]) {\n return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1;\n}\n\n/**\n * Decorator that makes the method of grid available in the framework.\n * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터.\n * @memberof eg.Grid\n * @private\n * @example\n * ```js\n * import { withGridMethods } from \"@egjs/grid\";\n *\n * class Grid extends React.Component> {\n * @withGridMethods\n * private grid: NativeGrid;\n * }\n * ```\n */\nexport const withGridMethods = withMethods(GRID_METHODS);\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DEFAULT_GRID_OPTIONS, MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\nimport { GridItem } from \"./GridItem\";\nimport { DOMRect } from \"./types\";\nimport { getDataAttributes, getKeys } from \"./utils\";\n\nexport interface ItemRendererOptions {\n attributePrefix?: string;\n useTransform?: boolean;\n horizontal?: boolean;\n percentage?: Array<\"position\" | \"size\"> | boolean;\n isEqualSize?: boolean;\n isConstantSize?: boolean;\n}\nexport interface ItemRendererStatus {\n initialRect: Required | null;\n}\n\nexport class ItemRenderer {\n protected options: Required;\n protected containerRect: DOMRect;\n protected initialRect: Required | null = null;\n protected sizePercetage = false;\n protected posPercetage = false;\n\n constructor(options: ItemRendererOptions) {\n this.options = {\n attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix,\n useTransform: DEFAULT_GRID_OPTIONS.useTransform,\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n percentage: DEFAULT_GRID_OPTIONS.percentage,\n isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize,\n isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize,\n ...options,\n };\n this._init();\n }\n public resize() {\n this.initialRect = null;\n }\n public renderItems(items: GridItem[]) {\n items.forEach((item) => {\n this._renderItem(item);\n });\n }\n public getInlineSize() {\n return this.containerRect[this.options.horizontal ? \"height\" : \"width\"]!;\n }\n public setContainerRect(rect: DOMRect) {\n this.containerRect = rect;\n }\n public updateItems(items: GridItem[]) {\n items.forEach((item) => {\n this._updateItem(item);\n });\n }\n public getStatus(): ItemRendererStatus {\n return {\n initialRect: this.initialRect,\n };\n }\n public setStatus(status: ItemRendererStatus) {\n this.initialRect = status.initialRect;\n }\n private _init() {\n const { percentage } = this.options;\n\n let sizePercentage = false;\n let posPercentage = false;\n\n if (percentage === true) {\n sizePercentage = true;\n posPercentage = true;\n } else if (percentage) {\n if (percentage.indexOf(\"position\") > -1) {\n posPercentage = true;\n }\n if (percentage.indexOf(\"size\") > -1) {\n sizePercentage = true;\n }\n }\n\n this.posPercetage = posPercentage;\n this.sizePercetage = sizePercentage;\n }\n private _updateItem(item: GridItem) {\n const { isEqualSize, isConstantSize } = this.options;\n const initialRect = this.initialRect;\n const { orgRect, element } = item;\n const isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING;\n const hasOrgSize = orgRect && orgRect.width && orgRect.height;\n let rect: Required;\n\n if (isEqualSize && initialRect) {\n rect = initialRect;\n } else if (isConstantSize && hasOrgSize && !isLoading) {\n rect = orgRect;\n } else if (!element) {\n return;\n } else {\n rect = {\n left: element.offsetLeft,\n top: element.offsetTop,\n width: element.offsetWidth,\n height: element.offsetHeight,\n };\n }\n if (!item.isFirstUpdate) {\n item.orgRect = { ...rect };\n }\n item.rect = { ...rect };\n\n if (item.element) {\n item.mountState = MOUNT_STATE.MOUNTED;\n }\n\n if (item.updateState === UPDATE_STATE.NEED_UPDATE) {\n item.updateState = UPDATE_STATE.UPDATED;\n item.isFirstUpdate = true;\n }\n item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {};\n\n if (!isLoading) {\n this.initialRect = { ...rect };\n }\n\n return rect;\n }\n private _renderItem(item: GridItem) {\n const element = item.element;\n const cssRect = item.cssRect;\n\n if (!element || !cssRect) {\n return;\n }\n\n const {\n horizontal,\n useTransform,\n } = this.options;\n const posPercentage = this.posPercetage;\n const sizePercentage = this.sizePercetage;\n const cssTexts: string[] = [\"position: absolute;\"];\n const {\n inlineSize: sizeName,\n inlinePos: posName,\n } = RECT_NAMES[horizontal ? \"horizontal\": \"vertical\"];\n const inlineSize = this.getInlineSize();\n let keys = getKeys(cssRect);\n\n if (useTransform) {\n keys = keys.filter((key) => key !== \"top\" && key !== \"left\");\n\n cssTexts.push(`transform: `\n + `translate(${cssRect.left || 0}px, ${cssRect.top || 0}px);`\n );\n }\n cssTexts.push(...keys.map((name) => {\n const value = cssRect[name]!;\n\n if (\n (name === sizeName && sizePercentage) ||\n (name === posName && posPercentage)\n ) {\n return `${name}: ${(value / inlineSize) * 100}%;`;\n }\n return `${name}: ${value}px;`;\n }));\n\n element.style.cssText += cssTexts.join(\"\");\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DOMRect, GridRect } from \"./types\";\nimport { MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\n\n/**\n * @typedef\n * @memberof Grid.GridItem\n * @property - The item key. 아이템 키.\n * @property - The element for the item. 아이템에 있는 엘리먼트.\n * @property - State of whether the element has been added to the container. element가 container에 추가되었는지 상태.\n * @property - The update state of the element's rect. element의 rect의 업데이트 상태.\n * @property - Whether the element's rect was updated for the first time. 처음으로 element의 rect를 업데이트 했는지 여부.\n * @property - Attributes set as `data-grid-` of element. element의 `data-grid-`으로 설정된 속성들.\n * @property - cssText of the first style when an element is added to the container. element가 container에 추가됐을 때 처음 style의 cssText.\n * @property - The element's rect before first rendering. 처음 렌더링 하기 전 엘리먼트의 rect.\n * @property - The updated element's rect before rendering. 렌더링 하기 전 업데이트 된 엘리먼트의 rect.\n * @property - The CSS rect of the item to be rendered by being applied to the Grid. Grid에 적용되어 렌더링을 하기 위한 item의 CSS rect\n * @property - Additional data of the item. item의 추가적인 데이터들.\n */\nexport interface GridItemStatus {\n key?: string | number;\n element?: HTMLElement | null;\n mountState?: MOUNT_STATE;\n updateState?: UPDATE_STATE;\n isFirstUpdate?: boolean;\n attributes?: Record;\n orgCSSText?: string;\n orgRect?: Required;\n rect?: Required;\n cssRect?: DOMRect;\n data?: Record;\n}\n\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n /**\n * @constructor\n * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향)\n * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체.\n */\n constructor(\n protected horizontal: boolean,\n itemStatus: Partial = {},\n ) {\n const element = itemStatus.element;\n const status: Required = {\n key: \"\",\n orgRect: { left: 0, top: 0, width: 0, height: 0 },\n rect: { left: 0, top: 0, width: 0, height: 0 },\n cssRect: {},\n attributes: {},\n data: {},\n isFirstUpdate: false,\n mountState: MOUNT_STATE.UNCHECKED,\n updateState: UPDATE_STATE.NEED_UPDATE,\n element: element || null,\n orgCSSText: element?.style.cssText ?? \"\",\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\n /**\n * Grid ready data for rendering\n * @ko 렌더링을 하기 위한 grid의 준비 데이타\n * @member Grid.GridItem#gridData\n */\n public gridData: Record = {};\n /**\n * The size in inline direction before first rendering. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#orgInlineSize\n */\n public get orgInlineSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.height : orgRect.width;\n }\n /**\n * The size in content direction before first rendering. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#orgContentSize\n */\n public get orgContentSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.width : orgRect.height;\n }\n /**\n * The size in inline direction. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#inlineSize\n */\n public get inlineSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.height : rect.width;\n }\n /**\n * The size in content direction. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#contentSize\n */\n public get contentSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.width : rect.height;\n }\n /**\n * The CSS size in inline direction applied to the Grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#cssInlineSize\n */\n public get cssInlineSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.height! : cssRect.width!;\n }\n /**\n * The CSS size in content direction applied to the Grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#cssContentSize\n */\n public get cssContentSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.width! : cssRect.height!;\n }\n /**\n * The CSS pos in inline direction applied to the Grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#cssInlinePos\n */\n public get cssInlinePos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.top! : cssRect.left!;\n }\n /**\n * The CSS pos in content direction applied to the Grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#cssContentPos\n */\n public get cssContentPos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.left! : cssRect.top!;\n }\n public set cssInlinePos(inlinePos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"top\" : \"left\"] = inlinePos;\n }\n public set cssContentPos(contentPos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"left\" : \"top\"] = contentPos;\n }\n public set cssInlineSize(inlineSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"height\" : \"width\"] = inlineSize;\n }\n public set cssContentSize(contentSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"width\" : \"height\"] = contentSize;\n }\n /**\n * Set CSS Rect through GridRect.\n * @ko GridRect을 통해 CSS Rect를 설정한다.\n * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일.\n */\n public setCSSGridRect(gridRect: GridRect) {\n const names = RECT_NAMES[this.horizontal ? \"horizontal\" : \"vertical\"];\n\n const rect: DOMRect = {};\n\n for (const name in gridRect) {\n rect[names[name]] = gridRect[name];\n }\n this.cssRect = rect;\n }\n /**\n * Returns the status of the item.\n * @ko 아이템의 상태를 반환한다.\n */\n public getStatus(): Required {\n return {\n mountState: this.mountState,\n updateState: this.updateState,\n attributes: this.attributes,\n orgCSSText: this.orgCSSText,\n isFirstUpdate: this.isFirstUpdate,\n element: null,\n key: this.key,\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n data: this.data,\n };\n }\n}\n\ninterface GridItem extends Required {\n}\nexport { GridItem };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DEFAULT_GRID_OPTIONS, GRID_PROPERTY_TYPES, MOUNT_STATE, UPDATE_STATE } from \"./consts\";\nimport { ContainerManager } from \"./ContainerManager\";\nimport {\n DestroyOptions, GridEvents, GridOptions,\n GridOutlines, GridStatus, Properties, RenderOptions,\n OnRenderComplete,\n} from \"./types\";\nimport ImReady from \"@egjs/imready\";\nimport { ItemRenderer } from \"./ItemRenderer\";\nimport { GetterSetter, isNumber, isString } from \"./utils\";\nimport { diff } from \"@egjs/children-differ\";\nimport { GridItem } from \"./GridItem\";\n\n/**\n * @extends eg.Component\n */\n@GetterSetter\nabstract class Grid extends Component {\n public static defaultOptions: Required = DEFAULT_GRID_OPTIONS;\n public static propertyTypes = GRID_PROPERTY_TYPES;\n public options: Required;\n protected containerElement: HTMLElement;\n protected containerManager: ContainerManager;\n protected itemRenderer!: ItemRenderer;\n protected items: GridItem[] = [];\n protected outlines: GridOutlines = {\n start: [],\n end: [],\n };\n private _renderTimer = 0;\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _im: ImReady;\n\n /**\n * Apply the CSS rect of items to fit the Grid and calculate the outline.\n * @ko Grid에 맞게 아이템들의 CSS rect를 적용하고 outline을 계산한다.\n * @abstract\n * @method Grid#applyGrid\n * @param {\"start\" | \"end\"} direcion - The direction to apply the Grid. (\"end\": start to end, \"start\": end to start) Grid를 적용할 방향. (\"end\": 시작에서 끝 방향, \"start\": 끝에서 시작 방향)\n * @param {number[]} outline - The start outline to apply the Grid. Grid를 적용할 시작 outline.\n */\n public abstract applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines;\n\n /**\n * @param - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param - The option object of the Grid module Grid 모듈의 옵션 객체\n */\n constructor(containerElement: HTMLElement | string, options: Partial = {}) {\n super();\n\n this.options = {\n ...((this.constructor as typeof Grid)\n .defaultOptions as Required),\n ...options,\n };\n\n this.containerElement = isString(containerElement)\n ? document.querySelector(containerElement)!\n : containerElement;\n\n const {\n isEqualSize,\n isConstantSize,\n useTransform,\n horizontal,\n percentage,\n externalContainerManager,\n externalItemRenderer,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n });\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n });\n\n this._init();\n }\n /**\n * Return Container Element.\n * @ko 컨테이너 엘리먼트를 반환한다.\n */\n public getContainerElement(): HTMLElement {\n return this.containerElement;\n }\n /**\n * Return items.\n * @ko 아이템들을 반환한다.\n */\n public getItems(): GridItem[] {\n return this.items;\n }\n /**\n * Returns the children of the container element.\n * @ko 컨테이너 엘리먼트의 children을 반환한다.\n */\n public getChildren(): HTMLElement[] {\n return [].slice.call(this.containerElement.children);\n }\n /**\n * Set items.\n * @ko 아이템들을 설정한다.\n * @param items - The items to set. 설정할 아이템들\n */\n public setItems(items: GridItem[]): this {\n this.items = items;\n return this;\n }\n /**\n * Gets the container's inline size. (\"width\" if horizontal is false, otherwise \"height\")\n * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 \"width\", 아니면 \"height\")\n */\n public getContainerInlineSize(): number {\n return this.containerManager.getInlineSize()!;\n }\n /**\n * Returns the outlines of the start and end of the Grid.\n * @ko Grid의 처음과 끝의 outline을 반환한다.\n */\n public getOutlines(): GridOutlines {\n return this.outlines;\n }\n /**\n * Set outlines.\n * @ko 아웃라인을 설정한다.\n * @param outlines - The outlines to set. 설정할 아웃라인.\n */\n public setOutlines(outlines: GridOutlines) {\n this.outlines = outlines;\n return this;\n }\n /**\n * When elements change, it synchronizes and renders items.\n * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public syncElements(options: RenderOptions = {}) {\n const items = this.items;\n const horizontal = this.options.horizontal;\n const elements: HTMLElement[] = this.getChildren();\n const { added, maintained, changed, removed } = diff(this.items.map((item) => item.element!), elements);\n\n const nextItems: GridItem[] = [];\n\n maintained.forEach(([beforeIndex, afterIndex]) => {\n nextItems[afterIndex] = items[beforeIndex];\n });\n added.forEach((index) => {\n nextItems[index] = new GridItem(horizontal!, {\n element: elements[index],\n });\n });\n\n this.setItems(nextItems);\n\n if (added.length || removed.length || changed.length) {\n this.renderItems(options);\n }\n return this;\n }\n /**\n * Update the size of the items and render them.\n * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다.\n * @param - Items to be updated. 업데이트할 아이템들.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public updateItems(items: GridItem[] = this.items, options: RenderOptions = {}) {\n items.forEach((item) => {\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n });\n this.checkReady(options);\n return this;\n }\n /**\n * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired.\n * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n * const grid = new MasonryGrid();\n *\n * grid.on(\"renderComplete\", e => {\n * console.log(e);\n * });\n * grid.renderItems();\n */\n public renderItems(options: RenderOptions = {}) {\n this._clearRenderTimer();\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (options.useResize) {\n // Resize container and Update all items\n this._resizeContainer();\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\n }\n return this;\n }\n /**\n * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method.\n * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다.\n */\n public getStatus(): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => item.getStatus()),\n containerManager: this.containerManager.getStatus(),\n itemRenderer: this.itemRenderer.getStatus(),\n };\n }\n /**\n * Set status of the Grid module with the status returned through a call to the getStatus() method.\n * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다.\n */\n public setStatus(status: GridStatus) {\n const horizontal = this.options.horizontal;\n const containerManager = this.containerManager;\n const prevInlineSize = containerManager.getInlineSize();\n const children = this.getChildren();\n\n this.itemRenderer.setStatus(status.itemRenderer);\n containerManager.setStatus(status.containerManager);\n this.outlines = status.outlines;\n this.items = status.items.map((item, i) => new GridItem(horizontal!, {\n ...item,\n element: children[i],\n }));\n\n this.itemRenderer.renderItems(this.items);\n\n if (prevInlineSize !== containerManager.getInlineSize()) {\n this.renderItems({\n useResize: true,\n });\n } else {\n window.setTimeout(() => {\n this._renderComplete({\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Releases the instnace and events and returns the CSS of the container and elements.\n * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.\n * @param Options for destroy. destory()를 위한 옵션\n */\n public destroy(options: DestroyOptions = {}) {\n const {\n preserveUI = this.options.preserveUIOnDestroy,\n } = options;\n this.containerManager.destroy({\n preserveUI,\n });\n\n if (!preserveUI) {\n this.items.forEach(({ element, orgCSSText }) => {\n if (element) {\n element.style.cssText = orgCSSText;\n }\n });\n }\n window.removeEventListener(\"resize\", this._scheduleResize);\n this._im?.destroy();\n }\n protected checkReady(options: RenderOptions = {}) {\n // Grid: renderItems => checkReady => readyItems => applyGrid\n const items = this.items;\n const updated = items.filter((item) => item.element && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n this._im?.destroy();\n this._im = new ImReady({\n prefix: this.options.attributePrefix,\n }).on(\"preReadyElement\", (e) => {\n updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING;\n }).on(\"preReady\", () => {\n this.itemRenderer.updateItems(updated);\n this.readyItems(mounted, updated, options);\n }).on(\"readyElement\", (e) => {\n const item = updated[e.index];\n\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n\n // after preReady\n if (e.isPreReadyOver) {\n item.element!.style.cssText = item.orgCSSText;\n this.itemRenderer.updateItems([item]);\n this.readyItems([], [item], options);\n }\n }).on(\"error\", (e) => {\n const item = items[e.index];\n /**\n * This event is fired when an error occurs in the content.\n * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트.\n * @event Grid#contentError\n * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트.\n * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트.\n * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템\n * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.\n * @example\ngrid.on(\"contentError\", e => {\n e.update();\n});\n */\n this.trigger(\"contentError\", {\n element: e.element,\n target: e.target,\n item,\n update: () => {\n moreUpdated.push(item);\n },\n });\n }).on(\"ready\", () => {\n if (moreUpdated.length) {\n this.updateItems(moreUpdated);\n }\n }).check(updated.map((item) => item.element!));\n }\n\n protected scheduleRender() {\n this._clearRenderTimer();\n this._renderTimer = window.setTimeout(() => {\n this.renderItems();\n });\n }\n protected fitOutlines(useFit = this.useFit) {\n const outlines = this.outlines;\n const startOutline = outlines.start;\n const endOutline = outlines.end;\n const outlineOffset = startOutline.length ? Math.min(...startOutline) : 0;\n\n // If the outline is less than 0, a fit occurs forcibly.\n if (!useFit && outlineOffset > 0) {\n return;\n }\n\n outlines.start = startOutline.map((point) => point - outlineOffset);\n outlines.end = endOutline.map((point) => point - outlineOffset);\n\n this.items.forEach((item) => {\n const contentPos = item.cssContentPos;\n\n if (!isNumber(contentPos)) {\n return;\n }\n item.cssContentPos = contentPos - outlineOffset;\n });\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const prevOutlines = this.outlines;\n const direction = options.direction || this.options.defaultDirection!;\n const prevOutline = options.outline || prevOutlines[direction === \"end\" ? \"start\" : \"end\"];\n const items = this.items;\n let nextOutlines = {\n start: [...prevOutline],\n end: [...prevOutline],\n };\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n this._renderComplete({\n mounted,\n updated,\n isResize: !!options.useResize,\n });\n }\n private _renderComplete(e: OnRenderComplete) {\n /**\n * This event is fired when the Grid has completed rendering.\n * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다.\n * @event Grid#renderComplete\n * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들\n * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들.\n * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.\n * @example\ngrid.on(\"renderComplete\", e => {\nconsole.log(e.mounted, e.updated, e.useResize);\n});\n */\n this.trigger(\"renderComplete\", e);\n }\n private _clearRenderTimer() {\n clearTimeout(this._renderTimer);\n this._renderTimer = 0;\n }\n private _refreshContainerContentSize() {\n const {\n start: startOutline,\n end: endOutline,\n } = this.outlines;\n const gap = this.options.gap!;\n\n const endPoint = endOutline.length ? Math.max(...endOutline) : 0;\n const startPoint = startOutline.length ? Math.max(...startOutline) : 0;\n const contentSize = Math.max(startPoint, endPoint - gap);\n\n this.containerManager.setContentSize(contentSize);\n }\n private _resizeContainer() {\n this.containerManager.resize();\n this.itemRenderer.setContainerRect(this.containerManager.getRect());\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n this.renderItems({\n useResize: true,\n });\n }\n private _scheduleResize = () => {\n const {\n resizeDebounce,\n maxResizeDebounce,\n } = this.options;\n\n\n if (!this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) {\n this._maxResizeDebounceTimer = window.setTimeout(this._onResize, maxResizeDebounce);\n }\n if (this._resizeTimer) {\n clearTimeout(this._resizeTimer);\n this._resizeTimer = 0;\n }\n this._resizeTimer = window.setTimeout(this._onResize, resizeDebounce);\n }\n\n private _init() {\n this._resizeContainer();\n if (this.options.autoResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n }\n}\n\ninterface Grid extends Properties { }\n\nexport default Grid;\n\n/**\n * Gap used to create space around items.\n * @ko 아이템들 사이의 공간.\n * @name Grid#gap\n * @type {$ts:Grid.GridOptions[\"gap\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * gap: 0,\n * });\n *\n * grid.gap = 5;\n */\n\n/**\n * The default direction value when direction is not set in the render option.\n * @ko render옵션에서 direction을 미설정시의 기본 방향값.\n * @name Grid#defaultDirection\n * @type {$ts:Grid.GridOptions[\"defaultDirection\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * defaultDirection: \"end\",\n * });\n *\n * grid.defaultDirection = \"start\";\n */\n\n\n/**\n * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true)\n * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true)\n * @name Grid#useFit\n * @type {$ts:Grid.GridOptions[\"useFit\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * useFit: true,\n * });\n *\n * grid.useFit = false;\n\n/**\n * Whether to preserve the UI of the existing container or item when destroying.\n * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.\n * @name Grid#preserveUIOnDestroy\n * @type {$ts:Grid.GridOptions[\"preserveUIOnDestroy\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * preserveUIOnDestroy: false,\n * });\n *\n * grid.preserveUIOnDestroy = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE, UPDATE_STATE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridAlign } from \"../types\";\nimport { range, GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getColumnPoint(\n outline: number[],\n columnIndex: number,\n columnCount: number,\n pointCaculationName: \"max\" | \"min\",\n) {\n return Math[pointCaculationName](...outline.slice(columnIndex, columnIndex + columnCount));\n}\n\nfunction getColumnIndex(outline: number[], columnCount: number, nearestCalculationName: \"max\" | \"min\") {\n const length = outline.length - columnCount + 1;\n const pointCaculationName = nearestCalculationName === \"max\" ? \"min\" : \"max\";\n const indexCaculationName = nearestCalculationName === \"max\" ? \"lastIndexOf\" : \"indexOf\";\n const points = range(length).map((index) => {\n return getColumnPoint(outline, index, columnCount, pointCaculationName);\n });\n\n return points[indexCaculationName](Math[nearestCalculationName](...points));\n}\n\n/**\n * @typedef\n * @memberof Grid.MasonryGrid\n * @extends Grid.GridOptions\n * @property - The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) \n * @property - The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) \n * @property - The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. \n * @property - Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\") 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n}\n\n/**\n * MasonryGrid 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.\n *\n * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class MasonryGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n column: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSize: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n align: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n align: \"justify\",\n column: 0,\n columnSize: 0,\n columnSizeRatio: 0,\n };\n\n private _columnSize = 0;\n private _column = 1;\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n this._calculateColumnSize(items);\n this._calculateColumn(items);\n\n const column = this._column;\n const columnSize = this._columnSize;\n const {\n gap,\n align,\n columnSizeRatio,\n columnSize: columnSizeOption,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses();\n const isEndDirection = direction === \"end\";\n const nearestCalculationName = isEndDirection ? \"min\" : \"max\";\n const pointCalculationName = isEndDirection ? \"max\" : \"min\";\n let startOutline = [0];\n\n if (outlineLength === column) {\n startOutline = outline.slice();\n } else {\n const point = outlineLength ? Math[nearestCalculationName](...outline) : 0;\n\n startOutline = range(column).map(() => point);\n }\n const endOutline = startOutline.slice();\n const columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0;\n const isStretch = align === \"stretch\";\n\n for (let i = 0; i < itemsLength; ++i) {\n const item = items[isEndDirection ? i : itemsLength - 1 - i];\n const columnAttribute = parseInt(item.attributes.column || \"1\", 10);\n const maxColumnAttribute = parseInt(item.attributes.maxColumn || \"1\", 10);\n let inlineSize = item.inlineSize;\n let contentSize = item.contentSize;\n let columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist)));\n const maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute));\n let columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName);\n let contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName);\n\n while (columnCount < maxColumnCount) {\n const nextEndColumnIndex = columnIndex + columnCount;\n const nextColumnIndex = columnIndex - 1;\n\n if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) {\n break;\n }\n if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) {\n break;\n }\n if (!isEndDirection) {\n --columnIndex;\n }\n ++columnCount;\n }\n\n columnIndex = Math.max(0, columnIndex);\n columnCount = Math.min(column - columnIndex, columnCount);\n\n if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) {\n inlineSize = (columnCount - 1) * columnDist + columnSize;\n item.cssInlineSize = inlineSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = inlineSize / columnSizeRatio;\n item.cssContentSize = contentSize;\n }\n const inlinePos = alignPoses[columnIndex];\n contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize;\n\n item.cssInlinePos = inlinePos;\n item.cssContentPos = contentPos;\n const nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos;\n\n range(columnCount).forEach((indexOffset) => {\n endOutline[columnIndex + indexOffset] = nextOutlinePoint;\n });\n }\n\n // if end items, startOutline is low, endOutline is high\n // if start items, startOutline is high, endOutline is low\n return {\n start: isEndDirection ? startOutline : endOutline,\n end: isEndDirection ? endOutline : startOutline,\n };\n }\n private _calculateColumnSize(items: GridItem[]) {\n const {\n columnSize: columnSizeOption,\n gap,\n align,\n } = this.options;\n\n if (align === \"stretch\") {\n let column = this.column;\n\n if (columnSizeOption) {\n column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap)));\n }\n this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n this._columnSize = columnSizeOption;\n } else {\n for (const item of items) {\n const attributes = item.attributes;\n if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) {\n continue;\n }\n const inlineSize = item.inlineSize;\n\n this._columnSize = inlineSize;\n return inlineSize;\n }\n this._columnSize = this._columnSize || 0;\n }\n return this._columnSize;\n }\n private _calculateColumn(items: GridItem[]) {\n const {\n gap,\n column: columnOption,\n } = this.options;\n const columnSize = this._columnSize;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else if (!columnSize) {\n column = 1;\n } else {\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap))),\n );\n }\n this._column = column;\n return column;\n }\n private _getAlignPoses() {\n const columnSize = this._columnSize;\n const column = this._column;\n const {\n align,\n gap,\n } = this.options;\n const containerSize = this.getContainerInlineSize();\n const indexes = range(column);\n\n let offset = 0;\n let dist = 0;\n\n if (align === \"justify\" || align === \"stretch\") {\n const countDist = column - 1;\n\n dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0;\n offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2);\n } else {\n dist = columnSize + gap;\n const totalColumnSize = (column - 1) * dist + columnSize;\n\n if (align === \"center\") {\n offset = (containerSize - totalColumnSize) / 2;\n } else if (align === \"end\") {\n offset = containerSize - totalColumnSize;\n }\n }\n return indexes.map((i) => {\n return offset + i * dist;\n });\n }\n}\n\nexport interface MasonryGrid extends Properties {\n}\n\n\n/**\n * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * align: \"start\",\n * });\n *\n * grid.align = \"justify\";\n */\n\n\n/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * column: 0,\n * });\n *\n * grid.column = 4;\n */\n\n\n/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0)\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSize: 0,\n * });\n *\n * grid.columnSize = 200;\n */\n\n\n/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0)\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSizeRatio: 0,\n * });\n *\n * grid.columnSizeRatio = 0.5;\n */\n","/* eslint-disable */\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin \n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nfunction single_source_shortest_paths(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\t// Predecessor map for each node that has been encountered.\n\t// node ID => predecessor node ID\n\tconst predecessors: { [key: string]: string } = {};\n\t// Costs of shortest paths from s to all nodes encountered.\n\t// node ID => cost\n\tconst costs: { [key: string]: number } = {};\n\tcosts[s] = 0;\n\n\t// Costs of shortest paths from s to all nodes encountered; differs from\n\t// `costs` in that it provides easy access to the node that currently has\n\t// the known shortest path from s.\n\t// XXX: Do we actually need both `costs` and `open`?\n\tconst open = new BinaryHeap<{ value: string, cost: number }>(x => x.cost);\n\topen.push({ value: s, cost: 0 });\n\n\tlet closest;\n\tlet u;\n\tlet cost_of_s_to_u;\n\tlet adjacent_nodes;\n\tlet cost_of_e;\n\tlet cost_of_s_to_u_plus_cost_of_e;\n\tlet cost_of_s_to_v;\n\tlet first_visit: boolean;\n\n\twhile (open.size()) {\n\t\t// In the nodes remaining in graph that have a known cost from s,\n\t\t// find the node, u, that currently has the shortest path from s.\n\t\tclosest = open.pop();\n\t\tu = closest.value;\n\t\tcost_of_s_to_u = closest.cost;\n\n\t\t// Get nodes adjacent to u...\n\t\tadjacent_nodes = graph(u) || {};\n\n\t\t// ...and explore the edges that connect u to those nodes, updating\n\t\t// the cost of the shortest paths to any or all of those nodes as\n\t\t// necessary. v is the node across the current edge from u.\n\t\tfor (const v in adjacent_nodes) {\n\t\t\t// Get the cost of the edge running from u to v.\n\t\t\tcost_of_e = adjacent_nodes[v];\n\n\t\t\t// Cost of s to u plus the cost of u to v across e--this is *a*\n\t\t\t// cost from s to v that may or may not be less than the current\n\t\t\t// known cost to v.\n\t\t\tcost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n\t\t\t// If we haven't visited v yet OR if the current known cost from s to\n\t\t\t// v is greater than the new cost we just found (cost of s to u plus\n\t\t\t// cost of u to v across e), update v's cost in the cost list and\n\t\t\t// update v's predecessor in the predecessor list (it's now u).\n\t\t\tcost_of_s_to_v = costs[v];\n\t\t\tfirst_visit = (typeof costs[v] === \"undefined\");\n\t\t\tif (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n\t\t\t\tcosts[v] = cost_of_s_to_u_plus_cost_of_e;\n\t\t\t\topen.push({ value: v, cost: cost_of_s_to_u_plus_cost_of_e });\n\t\t\t\tpredecessors[v] = u;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof costs[d] === \"undefined\") {\n\t\tconst msg = [\"Could not find a path from \", s, \" to \", d, \".\"].join(\"\");\n\t\tthrow new Error(msg);\n\t}\n\n\treturn predecessors;\n}\nfunction extract_shortest_path_from_predecessor_list(\n\tpredecessors: { [key: string]: string },\n\td: string,\n) {\n\tconst nodes: string[] = [];\n\tlet u = d;\n\n\twhile (u) {\n\t\tnodes.push(u);\n\t\tu = predecessors[u];\n\t}\n\tnodes.reverse();\n\treturn nodes;\n}\nfunction find_path(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\tconst predecessors = single_source_shortest_paths(graph, s, d);\n\n\treturn extract_shortest_path_from_predecessor_list(predecessors, d);\n}\n\nclass BinaryHeap {\n\tprivate content: T[];\n\tprivate scoreFunction: (x: T) => number;\n\n\tconstructor(scoreFunction: (x: T) => number) {\n\t\tthis.content = [];\n\t\tthis.scoreFunction = scoreFunction;\n\t}\n\tpublic push(element: T) {\n\t\t// Add the new element to the end of the array.\n\t\tthis.content.push(element);\n\t\t// Allow it to bubble up.\n\t\tthis.bubbleUp(this.content.length - 1);\n\t}\n\tpublic pop() {\n\t\t// Store the first element so we can return it later.\n\t\tconst result = this.content[0];\n\t\t// Get the element at the end of the array.\n\t\tconst end = this.content.pop()!;\n\t\t// If there are any elements left, put the end element at the\n\t\t// start, and let it sink down.\n\t\tif (this.content.length > 0) {\n\t\t\tthis.content[0] = end;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic size() {\n\t\treturn this.content.length;\n\t}\n\tpublic bubbleUp(_n: number) {\n\t\tlet n = _n;\n\t\t// Fetch the element that has to be moved.\n\t\tconst element = this.content[n];\n\t\t// When at 0, an element can not go up any further.\n\t\twhile (n > 0) {\n\t\t\t// Compute the parent element's index, and fetch it.\n\t\t\tconst parentN = Math.floor((n + 1) / 2) - 1;\n\t\t\tconst parent = this.content[parentN];\n\n\t\t\t// Swap the elements if the parent is greater.\n\t\t\tif (this.scoreFunction(element) < this.scoreFunction(parent)) {\n\t\t\t\tthis.content[parentN] = element;\n\t\t\t\tthis.content[n] = parent;\n\t\t\t\t// Update 'n' to continue at the new position.\n\t\t\t\tn = parentN;\n\t\t\t} else {\n\t\t\t\t// Found a parent that is less, no need to move it further.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tpublic sinkDown(n: number) {\n\t\t// Look up the target element and its score.\n\t\tconst length = this.content.length;\n\t\tconst element = this.content[n];\n\t\tconst elemScore = this.scoreFunction(element);\n\t\tlet child1Score;\n\n\t\twhile (true) {\n\t\t\t// Compute the indices of the child elements.\n\t\t\tconst child2N = (n + 1) * 2;\n\t\t\tconst child1N = child2N - 1;\n\t\t\t// This is used to store the new position of the element,\n\t\t\t// if any.\n\t\t\tlet swap: number | null = null;\n\t\t\t// If the first child exists (is inside the array)...\n\t\t\tif (child1N < length) {\n\t\t\t\t// Look it up and compute its score.\n\t\t\t\tconst child1 = this.content[child1N];\n\t\t\t\tchild1Score = this.scoreFunction(child1);\n\t\t\t\t// If the score is less than our element's, we need to swap.\n\t\t\t\tif (child1Score < elemScore) {\n\t\t\t\t\tswap = child1N;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Do the same checks for the other child.\n\t\t\tif (child2N < length) {\n\t\t\t\tconst child2 = this.content[child2N];\n\t\t\t\tconst child2Score = this.scoreFunction(child2);\n\n\t\t\t\tif (child2Score < (swap == null ? elemScore : child1Score)) {\n\t\t\t\t\tswap = child2N;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the element needs to be moved, swap it, and continue.\n\t\t\tif (swap !== null) {\n\t\t\t\tthis.content[n] = this.content[swap];\n\t\t\t\tthis.content[swap] = element;\n\t\t\t\tn = swap;\n\t\t\t} else {\n\t\t\t\t// Otherwise, we are done.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport { find_path };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, RenderOptions } from \"../types\";\nimport { getRangeCost, GetterSetter, isObject } from \"../utils\";\nimport { find_path } from \"./lib/dijkstra\";\nimport { GridItem } from \"../GridItem\";\n\n\ninterface Link {\n path: number[];\n cost: number;\n length: number;\n currentNode: number;\n isOver?: boolean;\n}\n\nfunction splitItems(items: GridItem[], path: string[]) {\n const length = path.length;\n const groups: GridItem[][] = [];\n\n for (let i = 0; i < length - 1; ++i) {\n const path1 = parseInt(path[i], 10);\n const path2 = parseInt(path[i + 1], 10);\n\n groups.push(items.slice(path1, path2));\n }\n return groups;\n}\nfunction getExpectedColumnSize(item: GridItem, rowSize: number) {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return 0;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n\n return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset;\n}\n\n/**\n * @typedef\n * @memberof Grid.JustifiedGrid\n * @extends Grid.GridOptions\n * @property - The minimum and maximum number of items per line. (default: [1, 8]) 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) \n * @property - The minimum and maximum number of rows in a group, 0 is not set. (default: 0) 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) \n * @property - The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @property - Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @property - Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) row사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n */\nexport interface JustifiedGridOptions extends GridOptions {\n columnRange?: number | number[];\n rowRange?: number | number[];\n sizeRange?: number | number[];\n displayedRow?: number;\n isCroppedSize?: boolean;\n}\n\n/**\n * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size.\n * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.\n * 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.\n * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.\n * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.\n * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class JustifiedGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n columnRange: PROPERTY_TYPE.RENDER_PROPERTY,\n rowRange: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeRange: PROPERTY_TYPE.RENDER_PROPERTY,\n isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY,\n displayedRow: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n columnRange: [1, 8],\n rowRange: 0,\n sizeRange: [0, Infinity],\n displayedRow: -1,\n isCroppedSize: false,\n };\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const rowRange = this.options.rowRange;\n let path: string[] = [];\n\n if (items.length) {\n path = rowRange ? this._getRowPath(items) : this._getPath(items);\n }\n\n return this._setStyle(items, path, outline, direction === \"end\");\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const {\n attributePrefix,\n horizontal,\n } = this.options;\n\n updated.forEach((item) => {\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || 0;\n\n if (element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)) {\n const maintainedTarget = element.querySelector(`[${attributePrefix}maintained-target]`);\n\n if (maintainedTarget) {\n const widthOffset = element.offsetWidth - element.clientWidth\n + element.scrollWidth - maintainedTarget.clientWidth;\n const heightOffset = element.offsetHeight - element.clientHeight\n + element.scrollHeight - maintainedTarget.clientHeight;\n\n if (horizontal) {\n inlineOffset = heightOffset;\n contentOffset = widthOffset;\n } else {\n inlineOffset = widthOffset;\n contentOffset = heightOffset;\n }\n }\n }\n gridData.inlineOffset = inlineOffset;\n gridData.contentOffset = contentOffset;\n });\n super.readyItems(mounted, updated, options);\n }\n private _getRowPath(items: GridItem[]) {\n const columnRange = this._getColumnRange();\n const rowRange = this._getRowRange();\n\n const pathLink = this._getRowLink(items, {\n path: [0],\n cost: 0,\n length: 0,\n currentNode: 0,\n }, columnRange, rowRange);\n\n return pathLink?.path.map((node) => `${node}`) ?? [];\n }\n private _getRowLink(\n items: GridItem[],\n currentLink: Link,\n columnRange: number[],\n rowRange: number[]\n ): Link {\n const [minColumn] = columnRange;\n const [minRow, maxRow] = rowRange;\n const lastNode = items.length;\n const {\n path,\n length: pathLength,\n cost,\n currentNode,\n } = currentLink;\n\n // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn.\n if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) {\n const rangeCost = getRangeCost(lastNode - currentNode, columnRange);\n const lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode));\n\n return {\n ...currentLink,\n length: pathLength + 1,\n path: [...path, lastNode],\n currentNode: lastNode,\n cost: cost + lastCost,\n isOver: true,\n };\n } else if (currentNode >= lastNode) {\n return {\n ...currentLink,\n currentNode: lastNode,\n isOver: minRow > pathLength || maxRow < pathLength,\n };\n } else {\n return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange);\n }\n\n }\n private _searchRowLink(\n items: GridItem[],\n currentLink: Link,\n lastNode: number,\n columnRange: number[],\n rowRange: number[]\n ) {\n const [minColumn, maxColumn] = columnRange;\n const {\n currentNode,\n path,\n length: pathLength,\n cost,\n } = currentLink;\n const length = Math.min(lastNode, currentNode + maxColumn);\n const links: Link[] = [];\n\n for (let nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) {\n if (nextNode === currentNode) {\n continue;\n }\n const nextCost = Math.abs(this._getCost(items, currentNode, nextNode));\n const nextLink = this._getRowLink(items, {\n path: [...path, nextNode],\n length: pathLength + 1,\n cost: cost + nextCost,\n currentNode: nextNode,\n }, columnRange, rowRange);\n\n if (nextLink) {\n links.push(nextLink);\n }\n }\n links.sort((a, b) => {\n const aIsOver = a.isOver;\n const bIsOver = b.isOver;\n\n if (aIsOver !== bIsOver) {\n // If it is over, the cost is high.\n return aIsOver ? 1 : -1;\n }\n const aRangeCost = getRangeCost(a.length, rowRange);\n const bRangeCost = getRangeCost(b.length, rowRange);\n\n return aRangeCost - bRangeCost || a.cost - b.cost;\n });\n\n // It returns the lowest cost link.\n return links[0];\n }\n private _getExpectedRowSize(items: GridItem[]) {\n const {\n gap,\n } = this.options;\n let containerInlineSize = this.getContainerInlineSize()! - gap * (items.length - 1);\n let ratioSum = 0;\n let inlineSum = 0;\n\n items.forEach((item) => {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return;\n }\n // sum((expect - offset) * ratio) = container inline size\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n ratioSum += maintainedRatio;\n inlineSum += contentOffset * maintainedRatio;\n containerInlineSize -= inlineOffset;\n });\n\n return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0;\n }\n private _getExpectedInlineSize(items: GridItem[], rowSize: number) {\n const {\n gap,\n } = this.options;\n const size = items.reduce((sum, item) => {\n return sum + getExpectedColumnSize(item, rowSize);\n }, 0);\n\n return size ? size + gap * (items.length - 1) : 0;\n }\n private _getCost(\n items: GridItem[],\n i: number,\n j: number,\n ) {\n const lineItems = items.slice(i, j);\n const rowSize = this._getExpectedRowSize(lineItems);\n const [minSize, maxSize] = this._getSizeRange();\n\n if (this.isCroppedSize) {\n if (minSize <= rowSize && rowSize <= maxSize) {\n return 0;\n }\n const expectedInlineSize = this._getExpectedInlineSize(\n lineItems,\n rowSize < minSize ? minSize : maxSize,\n );\n\n return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2);\n }\n\n if (isFinite(maxSize)) {\n // if this size is not in range, the cost increases sharply.\n if (rowSize < minSize) {\n return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2);\n } else if (rowSize > maxSize) {\n return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2);\n }\n } else if (rowSize < minSize) {\n return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2);\n }\n // if this size in range, the cost is row\n return rowSize - minSize;\n }\n private _getPath(items: GridItem[]) {\n const lastNode = items.length;\n const columnRangeOption = this.options.columnRange;\n const [minColumn, maxColumn]: number[] = isObject(columnRangeOption)\n ? columnRangeOption\n : [columnRangeOption, columnRangeOption];\n\n const graph = (nodeKey: string) => {\n const results: { [key: string]: number } = {};\n const currentNode = parseInt(nodeKey, 10);\n\n for (let nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) {\n if (nextNode - currentNode > maxColumn) {\n break;\n }\n let cost = this._getCost(\n items,\n currentNode,\n nextNode,\n );\n\n if (cost < 0 && nextNode === lastNode) {\n cost = 0;\n }\n results[`${nextNode}`] = Math.pow(cost, 2);\n }\n return results;\n };\n // shortest path for items' total height.\n return find_path(graph, \"0\", `${lastNode}`);\n }\n private _setStyle(\n items: GridItem[],\n path: string[],\n outline: number[] = [],\n isEndDirection: boolean,\n ) {\n const {\n gap,\n isCroppedSize,\n displayedRow,\n } = this.options;\n const sizeRange = this._getSizeRange();\n const startPoint = outline[0] || 0;\n const containerInlineSize = this.getContainerInlineSize();\n const groups = splitItems(items, path);\n let contentPos = startPoint;\n let displayedSize = 0;\n\n groups.forEach((groupItems, rowIndex) => {\n const length = groupItems.length;\n let rowSize = this._getExpectedRowSize(groupItems);\n if (isCroppedSize) {\n rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1]));\n }\n const expectedInlineSize = this._getExpectedInlineSize(groupItems, rowSize);\n\n const allGap = gap * (length - 1);\n const scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap);\n\n groupItems.forEach((item, i)=> {\n let columnSize = getExpectedColumnSize(item, rowSize);\n\n const prevItem = groupItems[i - 1];\n const inlinePos = prevItem\n ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap\n : 0;\n\n if (isCroppedSize) {\n columnSize *= scale;\n }\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize: columnSize,\n contentSize: rowSize,\n });\n });\n contentPos += gap + rowSize;\n if (displayedRow < 0 || rowIndex < displayedRow) {\n displayedSize = contentPos;\n }\n });\n\n if (isEndDirection) {\n // previous group's end outline is current group's start outline\n return {\n start: [startPoint],\n end: [displayedSize],\n };\n }\n // always start is lower than end.\n // contentPos is endPoinnt\n const height = contentPos - startPoint;\n\n items.forEach((item) => {\n item.cssContentPos -= height;\n });\n return {\n start: [startPoint - height],\n end: [startPoint], // endPoint - height = startPoint\n };\n }\n private _getRowRange() {\n const rowRange = this.rowRange;\n return isObject(rowRange) ? rowRange : [rowRange, rowRange];\n }\n private _getColumnRange() {\n const columnRange = this.columnRange;\n return isObject(columnRange) ? columnRange : [columnRange, columnRange];\n }\n private _getSizeRange() {\n const sizeRange = this.sizeRange;\n return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange];\n }\n}\n\nexport interface JustifiedGrid extends Properties {\n}\n\n\n/**\n * The minimum and maximum number of items per line. (default: [1, 8])\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8])\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * columnRange: [1, 8],\n * });\n *\n * grid.columnRange = [3, 6];\n */\n\n\n/**\n * The minimum and maximum number of rows in a group, 0 is not set. (default: 0)\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0)\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * rowRange: 0,\n * });\n *\n * grid.rowRange = [3, 4];\n */\n\n/**\n * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity])\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [0, Infinity],\n * });\n *\n * grid.sizeRange = [200, 800];\n */\n\n/**\n * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * displayedRow: -1,\n * });\n *\n * grid.displayedRow = 3;\n */\n\n/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false)\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [200, 250],\n * isCroppedSize: false,\n * });\n *\n * grid.isCroppedSize = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridRect } from \"../types\";\nimport { GetterSetter, range } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getMaxPoint(outline: number[]) {\n let maxPoint = -Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n maxPoint = Math.max(maxPoint, point);\n }\n });\n return isFinite(maxPoint) ? maxPoint : 0;\n}\nfunction getMinPoint(outline: number[]) {\n let minPoint = Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n minPoint = Math.min(minPoint, point);\n }\n });\n return isFinite(minPoint) ? minPoint : 0;\n}\nfunction getOutlinePoint(startOutline: number[], frameOutline: number[], useFrameFill: boolean) {\n return getMaxPoint(startOutline)\n + getOutlineDist(startOutline, frameOutline, useFrameFill);\n}\n\nfunction getOutlineDist(startOutline: number[], endOutline: number[], useFrameFill: boolean) {\n const length = startOutline.length;\n\n if (!length) {\n return 0;\n }\n const minEndPoint = getMinPoint(endOutline);\n const maxStartPoint = getMaxPoint(startOutline);\n let frameDist = 0;\n\n if (!useFrameFill) {\n return 0;\n }\n\n\n for (let outlineIndex = 0; outlineIndex < length; ++outlineIndex) {\n const startPoint = startOutline[outlineIndex];\n const endPoint = endOutline[outlineIndex];\n\n if (!isFinite(startPoint) || !isFinite(endPoint)) {\n continue;\n }\n const startPos = startPoint - maxStartPoint;\n const endPos = endPoint - minEndPoint;\n\n\n // Fill empty block.\n frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos;\n }\n\n return frameDist;\n}\nfunction fillOutlines(startOutline: number[], endOutline: number[], rect: {\n inlinePos: number;\n inlineSize: number;\n contentPos: number;\n contentSize: number;\n}) {\n const {\n inlinePos,\n inlineSize,\n contentPos,\n contentSize,\n } = rect;\n for (\n let outlineIndex = inlinePos;\n outlineIndex < inlinePos + inlineSize;\n ++outlineIndex\n ) {\n startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos);\n endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize);\n }\n}\nexport interface FrameRect extends Required {\n type: any;\n}\n/**\n * @typedef\n * @memberof Grid.FrameGrid\n * @extends Grid.GridOptions\n * @property - The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @property - Make sure that the frame can be attached after the previous frame. (default: true) 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @property - 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n */\nexport interface FrameGridOptions extends GridOptions {\n frame?: number[][];\n useFrameFill?: boolean;\n rectSize?: number | { inlineSize: number, contentSize: number };\n}\n\n/**\n * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size.\n * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class FrameGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n frame: PROPERTY_TYPE.RENDER_PROPERTY,\n useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY,\n rectSize: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n frame: [],\n rectSize: 0,\n useFrameFill: true,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const frame = this._getFrame();\n const {\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n rects: frameRects,\n } = frame;\n const {\n gap,\n useFrameFill,\n } = this.options;\n\n const {\n inlineSize: rectInlineSize,\n contentSize: rectContentSize,\n } = this.getRectSize(frameInlineSize);\n\n\n const itemsLength = items.length;\n\n if (!itemsLength || !frameInlineSize || !frameContentSize) {\n return { start: outline, end: outline };\n }\n const rectsLength = frameRects.length;\n let startOutline = range(frameInlineSize).map(() => Infinity);\n let endOutline = range(frameInlineSize).map(() => -Infinity);\n const frameOutline = frame.outline.map((point) => point * (rectContentSize + gap));\n\n for (let startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) {\n // Compare group's startOutline and startOutline of rect\n const startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill);\n\n for (let rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) {\n const item = items[startIndex + rectIndex];\n const {\n contentPos: frameRectContentPos,\n inlinePos: frameRectInlinePos,\n contentSize: frameRectContentSize,\n inlineSize: frameRectInlineSize,\n } = frameRects[rectIndex];\n const contentPos = startPoint + frameRectContentPos * (rectContentSize + gap);\n const inlinePos = frameRectInlinePos * (rectInlineSize + gap);\n const contentSize = frameRectContentSize * (rectContentSize + gap) - gap;\n const inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap;\n\n fillOutlines(startOutline, endOutline, {\n inlinePos: frameRectInlinePos,\n inlineSize: frameRectInlineSize,\n contentPos: contentPos,\n contentSize: contentSize + gap,\n });\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n }\n }\n const isDirectionEnd = direction === \"end\";\n\n let gridOutline = outline;\n\n if (gridOutline.length !== frameInlineSize) {\n const point = isDirectionEnd ? Math.max(...gridOutline) : Math.min(...gridOutline);\n\n gridOutline = range(frameInlineSize).map(() => point);\n }\n startOutline = startOutline.map((point) => isFinite(point) ? point : 0);\n endOutline = endOutline.map((point) => isFinite(point) ? point : 0);\n const outlineDist = isDirectionEnd\n ? getOutlineDist(startOutline, gridOutline, useFrameFill)\n : getOutlineDist(gridOutline, endOutline, useFrameFill);\n\n items.forEach((item) => {\n item.cssContentPos += outlineDist;\n });\n\n return {\n start: startOutline.map((point) => point + outlineDist),\n end: endOutline.map((point) => point + outlineDist),\n };\n }\n protected getRectSize(frameInlineSize: number) {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption;\n }\n const rectSizeValue = rectSizeOption\n ? rectSizeOption\n : (this.getContainerInlineSize()! + gap) / frameInlineSize - gap;\n\n return { inlineSize: rectSizeValue, contentSize: rectSizeValue };\n }\n private _getFrame() {\n const frame = this.options.frame;\n const frameContentSize = frame.length;\n const frameInlineSize = frameContentSize ? frame[0].length : 0;\n const rects: FrameRect[] = [];\n const passMap: Record = {};\n const startOutline = range(frameInlineSize).map(() => Infinity);\n const endOutline = range(frameInlineSize).map(() => -Infinity);\n\n for (let y1 = 0; y1 < frameContentSize; ++y1) {\n for (let x1 = 0; x1 < frameInlineSize; ++x1) {\n const type = frame[y1][x1];\n\n if (!type) {\n continue;\n }\n if (passMap[`${y1},${x1}`]) {\n continue;\n }\n const rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize);\n\n fillOutlines(startOutline, endOutline, rect);\n rects.push(rect);\n }\n }\n rects.sort((a, b) => (a.type < b.type ? -1 : 1));\n\n\n return {\n rects,\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n outline: startOutline,\n };\n }\n private _findRect(\n passMap: Record,\n type: number,\n y1: number,\n x1: number,\n frameInlineSize: number,\n frameContentSize: number,\n ) {\n const frame = this.options.frame;\n\n let contentSize = 1;\n let inlineSize = 1;\n\n // find rect\n for (let x2 = x1; x2 < frameInlineSize; ++x2) {\n if (frame[y1][x2] === type) {\n inlineSize = x2 - x1 + 1;\n continue;\n }\n break;\n }\n for (let y2 = y1; y2 < frameContentSize; ++y2) {\n if (frame[y2][x1] === type) {\n contentSize = y2 - y1 + 1;\n continue;\n }\n break;\n }\n\n // pass rect\n for (let y = y1; y < y1 + contentSize; ++y) {\n for (let x = x1; x < x1 + inlineSize; ++x) {\n passMap[`${y},${x}`] = true;\n }\n }\n\n const rect: FrameRect = {\n type,\n inlinePos: x1,\n contentPos: y1,\n inlineSize,\n contentSize,\n };\n return rect;\n }\n}\n\nexport interface FrameGrid extends Properties {\n}\n\n\n/**\n * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 1 x 1\n * // Item 3 : 1 x 2\n * // Item 4 : 1 x 1\n * // Item 5 : 2 x 1\n * const grid = new FrameGrid(container, {\n * frame: [\n * [1, 1, 0, 0, 2, 3],\n * [1, 1, 0, 4, 5, 5],\n * ],\n * });\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 2 x 2\n * grid.frame = [\n * [1, 1, 0, 0, 2, 2],\n * [1, 1, 0, 0, 2, 2],\n * ];\n */\n\n/**\n * Make sure that the frame can be attached after the previous frame. (default: true)\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true)\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * useFrameFill: true,\n * });\n *\n * grid.useFrameFill = false;\n */\n\n/**\n * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0)\n * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n * @name Grid.FrameGrid#rectSize\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"rectSize\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * rectSize: 0,\n * });\n *\n * grid.rectSize = { inlineSize: 100, contentSize: 150 };\n */\n","export interface BoxModelStatus {\n orgInlineSize: number;\n orgContentSize: number;\n inlineSize: number;\n contentSize: number;\n inlinePos: number;\n contentPos: number;\n items: BoxModel[];\n}\n\nexport default class BoxModel implements BoxModelStatus {\n public orgInlineSize: number;\n public orgContentSize: number;\n public inlineSize: number;\n public contentSize: number;\n public inlinePos: number;\n public contentPos: number;\n public items: BoxModel[];\n constructor(status: Partial) {\n const boxStatus = {\n orgInlineSize: 0,\n orgContentSize: 0,\n inlineSize: 0,\n contentSize: 0,\n inlinePos: 0,\n contentPos: 0,\n items: [],\n ...status,\n };\n for (const name in boxStatus) {\n this[name] = boxStatus[name];\n }\n }\n public scaleTo(inlineSize: number, contentSize: number) {\n const scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0;\n const scaleY = this.contentSize ? contentSize / this.contentSize : 0;\n\n this.items.forEach((item) => {\n if (scaleX !== 0) {\n item.inlinePos *= scaleX;\n item.inlineSize *= scaleX;\n }\n if (scaleY !== 0) {\n item.contentPos *= scaleY;\n item.contentSize *= scaleY;\n }\n });\n\n this.inlineSize = inlineSize;\n this.contentSize = contentSize;\n }\n public push(item: BoxModel) {\n this.items.push(item);\n }\n public getOrgSizeWeight() {\n return this.orgInlineSize * this.orgContentSize;\n }\n public getSize() {\n return this.inlineSize * this.contentSize;\n }\n public getOrgRatio() {\n return (this.orgContentSize === 0) ? 0 : this.orgInlineSize / this.orgContentSize;\n }\n public getRatio() {\n return (this.contentSize === 0) ? 0 : this.inlineSize / this.contentSize;\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } from \"../types\";\nimport { GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\nimport BoxModel from \"./lib/BoxModel\";\n\n\nfunction getCost(originLength: number, length: number) {\n let cost = originLength / length;\n\n if (cost < 1) {\n cost = 1 / cost;\n }\n\n return cost - 1;\n}\nfunction fitArea(\n item: BoxModel,\n bestFitArea: BoxModel,\n itemFitSize: { inlineSize: number, contentSize: number },\n containerFitSize: { inlineSize: number, contentSize: number },\n isContentDirection: boolean,\n) {\n item.contentSize = itemFitSize.contentSize;\n item.inlineSize = itemFitSize.inlineSize;\n bestFitArea.contentSize = containerFitSize.contentSize;\n bestFitArea.inlineSize = containerFitSize.inlineSize;\n\n if (isContentDirection) {\n item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize;\n item.inlinePos = bestFitArea.inlinePos;\n } else {\n item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize;\n item.contentPos = bestFitArea.contentPos;\n }\n}\n\n\n/**\n * @typedef\n * @memberof Grid.PackingGrid\n * @extends Grid.GridOptions\n * @property - The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @property - The size weight when placing items. (default: 1)아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @property - The weight to keep ratio when placing items. (default: 1)아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @property - The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n */\nexport interface PackingGridOptions extends GridOptions {\n aspectRatio?: number;\n sizeWeight?: number;\n ratioWeight?: number;\n weightPriority?: \"size\" | \"ratio\" | \"custom\";\n}\n\n/**\n * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items.\n * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.\n * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible.\n * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible.\n * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.\n * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.\n * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.\n * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class PackingGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n weightPriority: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n aspectRatio: 1,\n sizeWeight: 1,\n ratioWeight: 1,\n weightPriority: \"custom\",\n };\n\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const { aspectRatio, gap } = this.options;\n const containerInlineSize = this.getContainerInlineSize();\n const containerContentSize = containerInlineSize / aspectRatio;\n const prevOutline = outline.length ? outline : [0];\n const startPoint = direction === \"end\"\n ? Math.max(...prevOutline)\n : Math.min(...prevOutline) - containerContentSize - gap;\n const endPoint = startPoint + containerContentSize + gap;\n const container = new BoxModel({});\n\n items.forEach((item) => {\n const model = new BoxModel({\n inlineSize: item.orgInlineSize,\n contentSize: item.orgContentSize,\n orgInlineSize: item.orgInlineSize,\n orgContentSize: item.orgContentSize,\n });\n\n this._findBestFitArea(container, model);\n container.push(model);\n container.scaleTo(containerInlineSize + gap, containerContentSize + gap);\n });\n items.forEach((item, i) => {\n const boxItem = container.items[i];\n const inlineSize = boxItem.inlineSize - gap;\n const contentSize = boxItem.contentSize - gap;\n const contentPos = startPoint + boxItem.contentPos;\n const inlinePos = boxItem.inlinePos;\n\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n });\n\n return {\n start: [startPoint],\n end: [endPoint],\n };\n }\n private _findBestFitArea(container: BoxModel, item: BoxModel) {\n if (container.getRatio() === 0) { // 아이템 최초 삽입시 전체영역 지정\n container.orgInlineSize = item.inlineSize;\n container.orgContentSize = item.contentSize;\n container.inlineSize = item.inlineSize;\n container.contentSize = item.contentSize;\n return;\n }\n\n let bestFitArea!: BoxModel;\n let minCost = Infinity;\n let isContentDirection = false;\n const itemFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const containerFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const sizeWeight = this._getWeight(\"size\");\n const ratioWeight = this._getWeight(\"ratio\");\n\n container.items.forEach((child) => {\n const containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight;\n const containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight;\n const inlineSize = child.inlineSize;\n const contentSize = child.contentSize;\n for (let i = 0; i < 2; ++i) {\n let itemInlineSize;\n let itemContentSize;\n let containerInlineSize;\n let containerContentSize;\n\n if (i === 0) {\n // add item to content pos (top, bottom)\n itemInlineSize = inlineSize;\n itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize));\n containerInlineSize = inlineSize;\n containerContentSize = contentSize - itemContentSize;\n } else {\n // add item to inline pos (left, right)\n itemContentSize = contentSize;\n itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize));\n containerContentSize = contentSize;\n containerInlineSize = inlineSize - itemInlineSize;\n }\n\n const itemSize = itemInlineSize * itemContentSize;\n const itemRatio = itemInlineSize / itemContentSize;\n const containerSize = containerInlineSize * containerContentSize;\n const containerRatio = containerContentSize / containerContentSize;\n\n let cost = getCost(item.getSize(), itemSize) * sizeWeight;\n cost += getCost(item.getRatio(), itemRatio) * ratioWeight;\n cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost;\n cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost;\n\n if (cost === Math.min(cost, minCost)) {\n minCost = cost;\n bestFitArea = child;\n isContentDirection = (i === 0);\n itemFitSize.inlineSize = itemInlineSize;\n itemFitSize.contentSize = itemContentSize;\n containerFitSize.inlineSize = containerInlineSize;\n containerFitSize.contentSize = containerContentSize;\n }\n }\n });\n\n fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection);\n }\n private _getWeight(type: \"size\" | \"ratio\"): number {\n const options = this.options;\n const weightPriority = options.weightPriority;\n\n if (weightPriority === type) {\n return 100;\n } else if (weightPriority === \"custom\") {\n return options[`${type}Weight`];\n }\n return 1;\n }\n}\n\nexport interface PackingGrid extends Properties {\n}\n\n\n/**\n * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1)\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * aspectRatio: 1,\n * });\n *\n * grid.aspectRatio = 1.5;\n */\n\n/**\n * The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * @ko 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n * @name Grid.PackingGrid#weightPriority\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"weightPriority\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * weightPriority: \"custom\",\n * sizeWeight: 1,\n * ratioWeight: 1,\n * });\n *\n * grid.weightPriority = \"size\";\n * // or\n * grid.weightPriority = \"ratio\";\n */\n\n/**\n * The size weight when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * sizeWeight: 1,\n * });\n *\n * grid.sizeWeight = 10;\n */\n\n\n/**\n * The weight to keep ratio when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * ratioWeight: 1,\n * });\n *\n * grid.ratioWeight = 10;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\n\nexport * from \"./grids/MasonryGrid\";\nexport * from \"./grids/JustifiedGrid\";\nexport * from \"./grids/FrameGrid\";\nexport * from \"./grids/PackingGrid\";\n\nexport * from \"./types\";\nexport * from \"./Grid\";\nexport * from \"./GridItem\";\nexport * from \"./ContainerManager\";\nexport * from \"./consts\";\nexport {\n GetterSetter,\n withGridMethods,\n withMethods,\n} from \"./utils\";\nexport default Grid;\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Grid as any)[name] = (modules as any)[name];\n}\nexport default Grid;\n"],"names":["DEFAULT_GRID_OPTIONS","horizontal","useTransform","percentage","isEqualSize","isConstantSize","gap","attributePrefix","resizeDebounce","maxResizeDebounce","autoResize","preserveUIOnDestroy","defaultDirection","externalContainerManager","externalItemRenderer","renderOnPropertyChange","useFit","PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","GRID_EVENTS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","container","options","_init","setRect","width","offsetWidth","height","offsetHeight","rect","status","setContentSize","getContentSize","size","sizeName","style","preserveUI","cssText","orgCSSText","window","getComputedStyle","position","getKeys","obj","Object","keys","isString","val","isObject","isNumber","camelize","str","replace","all","letter","toUpperCase","getDataAttributes","element","dataAttributes","attributes","length","i","attribute","name","value","indexOf","GetterSetter","component","prototype","propertyTypes","shouldRender","enumerable","configurable","get","set","prevValue","scheduleRender","defineProperty","withMethods","methods","memberName","forEach","_i","args","result","_a","range","arr","push","getRangeCost","valueRange","Math","max","withGridMethods","initialRect","items","item","_this","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","posPercetage","sizePercetage","orgRect","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","cssRect","cssTexts","_b","posName","getInlineSize","filter","key","map","join","itemStatus","data","UNCHECKED","gridRect","names","__extends","containerElement","_super","start","end","clearTimeout","_resizeTimer","_maxResizeDebounceTimer","renderItems","useResize","setTimeout","_onResize","constructor","defaultOptions","document","querySelector","containerManager","ContainerManager","itemRenderer","ItemRenderer","Grid","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","checkReady","_clearRenderTimer","getItems","syncElements","_resizeContainer","updateItems","getStatus","prevInlineSize","setStatus","_renderComplete","mounted","updated","isResize","destroy","removeEventListener","_scheduleResize","_im","moreUpdated","ImReady","prefix","on","e","readyItems","isPreReadyOver","trigger","target","update","check","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","direction","prevOutline","outline","nextOutlines","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","endPoint","startPoint","resize","setContainerRect","getRect","addEventListener","Component","getColumnPoint","columnIndex","columnCount","pointCaculationName","getColumnIndex","nearestCalculationName","indexCaculationName","points","_calculateColumnSize","_calculateColumn","column","_column","columnSize","_columnSize","align","columnSizeRatio","columnSizeOption","outlineLength","itemsLength","alignPoses","_getAlignPoses","isEndDirection","pointCalculationName","point_1","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","nextEndColumnIndex","nextColumnIndex","cssInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","floor","getContainerInlineSize","items_1","columnOption","containerSize","indexes","offset","dist","countDist","totalColumnSize","MasonryGrid","single_source_shortest_paths","graph","s","d","predecessors","costs","open","BinaryHeap","x","cost","closest","u","cost_of_s_to_u","adjacent_nodes","cost_of_e","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","first_visit","pop","v","msg","Error","extract_shortest_path_from_predecessor_list","nodes","reverse","find_path","scoreFunction","content","bubbleUp","sinkDown","_n","n","parentN","parent","elemScore","child1Score","child2N","child1N","swap","child1","child2","child2Score","splitItems","path","groups","path1","path2","getExpectedColumnSize","rowSize","orgInlineSize","orgContentSize","inlineOffset","parseFloat","gridData","contentOffset","rowRange","_getRowPath","_getPath","_setStyle","maintainedTarget","widthOffset","clientWidth","scrollWidth","heightOffset","clientHeight","scrollHeight","columnRange","_getColumnRange","_getRowRange","pathLink","_getRowLink","currentNode","node","currentLink","minColumn","minRow","maxRow","lastNode","pathLength","rangeCost","lastCost","abs","_getCost","isOver","_searchRowLink","links","nextNode","nextCost","nextLink","sort","a","b","aIsOver","bIsOver","aRangeCost","bRangeCost","containerInlineSize","ratioSum","inlineSum","maintainedRatio","reduce","sum","j","lineItems","_getExpectedRowSize","_getSizeRange","minSize","maxSize","isCroppedSize","expectedInlineSize","_getExpectedInlineSize","pow","isFinite","columnRangeOption","nodeKey","results","displayedRow","sizeRange","displayedSize","groupItems","rowIndex","allGap","scale","prevItem","setCSSGridRect","JustifiedGrid","Infinity","getMaxPoint","maxPoint","getMinPoint","minPoint","getOutlinePoint","frameOutline","useFrameFill","getOutlineDist","minEndPoint","maxStartPoint","frameDist","outlineIndex","startPos","endPos","fillOutlines","frame","_getFrame","frameInlineSize","frameContentSize","frameRects","getRectSize","rectInlineSize","rectContentSize","rectsLength","startIndex","rectIndex","_c","frameRectContentPos","frameRectInlinePos","frameRectContentSize","frameRectInlineSize","isDirectionEnd","gridOutline","outlineDist","rectSizeOption","rectSizeValue","rects","passMap","y1","x1","type","_findRect","x2","y2","y","FrameGrid","rectSize","boxStatus","scaleX","scaleY","getCost","originLength","fitArea","bestFitArea","itemFitSize","containerFitSize","isContentDirection","aspectRatio","containerContentSize","BoxModel","model","_findBestFitArea","scaleTo","boxItem","getRatio","minCost","sizeWeight","_getWeight","ratioWeight","child","containerSizeCost","getOrgSizeWeight","getSize","containerRatioCost","getOrgRatio","itemInlineSize","itemContentSize","itemSize","itemRatio","containerRatio","weightPriority","PackingGrid","modules"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;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,eADvB9Z,eACY8Z,YAAA;IA+Ib,oBAAA;IAAC,EA/IgCvU,KAAjC;IAqJA;;;;;;;;;;;;;;;IAeA;;;;;;;;;;;;;;;;;;;;IAoBA;;;;;;;;;;;;;;;IAgBA;;;;;;;;;;;;;;;ICpRA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ICAA;;;;;AAKA;IAEA,KAAK,IAAM1F,IAAX,IAAmBka,OAAnB,EAA4B;IACzBxU,EAAAA,IAAY,CAAC1F,IAAD,CAAZ,GAAsBka,OAAe,CAACla,IAAD,CAArC;IACF;;;;;;;;"} \ No newline at end of file diff --git a/dist/grid.min.js b/dist/grid.min.js new file mode 100644 index 0000000..d7edb86 --- /dev/null +++ b/dist/grid.min.js @@ -0,0 +1,10 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.3.1 +*/ +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).Grid=e()}(this,function(){"use strict";var i=function(t,e){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function o(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}i(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var f=function(){return(f=Object.assign||function(t){for(var e,n=1,i=arguments.length;n=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function a(){for(var t=[],e=0;e=t.length?void 0:t)&&t[i++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(s),c=u.next();!c.done;c=u.next()){if(c.value===e){s.splice(a,1);break}a++}}catch(t){n={error:t}}finally{try{c&&!c.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}}return this},t.VERSION="2.2.2",t}(),S=function(t,e){return(S=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function z(t,e){function n(){this.constructor=t}S(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var E=function(){return(E=Object.assign||function(t){for(var e,n=1,i=arguments.length;nd))break;if(!C&&(g<0||I[g]) = {\n horizontal: false,\n useTransform: false,\n percentage: false,\n isEqualSize: false,\n isConstantSize: false,\n gap: 0,\n attributePrefix: \"data-grid-\",\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n autoResize: true,\n preserveUIOnDestroy: false,\n defaultDirection: \"end\",\n externalContainerManager: null,\n externalItemRenderer: null,\n renderOnPropertyChange: true,\n useFit: true,\n};\n\nexport enum PROPERTY_TYPE {\n PROPERTY = 1,\n RENDER_PROPERTY = 2,\n}\nexport enum MOUNT_STATE {\n UNCHECKED = 1,\n UNMOUNTED = 2,\n MOUNTED = 3,\n}\nexport enum UPDATE_STATE {\n NEED_UPDATE = 1,\n WAIT_LOADING = 2,\n UPDATED = 3,\n}\n\nexport const GRID_PROPERTY_TYPES = {\n gap: PROPERTY_TYPE.RENDER_PROPERTY,\n defaultDirection: PROPERTY_TYPE.PROPERTY,\n renderOnPropertyChange: PROPERTY_TYPE.PROPERTY,\n preserveUIOnDestroy: PROPERTY_TYPE.PROPERTY,\n useFit: PROPERTY_TYPE.PROPERTY,\n};\n\nexport const GRID_METHODS = [\n \"syncElements\",\n \"updateItems\",\n \"getItems\",\n \"setItems\",\n \"renderItems\",\n \"getContainerInlineSize\",\n \"getContainerElement\",\n] as const;\n\nexport const GRID_EVENTS = [\n \"renderComplete\",\n \"contentError\",\n] as const;\n\nexport const RECT_NAMES = {\n horizontal: {\n inlinePos: \"top\",\n contentPos: \"left\",\n inlineSize: \"height\",\n contentSize: \"width\",\n },\n vertical: {\n inlinePos: \"left\",\n contentPos: \"top\",\n inlineSize: \"width\",\n contentSize: \"height\",\n },\n} as const;\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DestroyOptions } from \".\";\nimport { DEFAULT_GRID_OPTIONS } from \"./consts\";\nimport { DOMRect } from \"./types\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: DOMRect;\n}\n\nexport class ContainerManager {\n protected options: Required;\n protected rect: DOMRect;\n protected orgCSSText: string;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.offsetWidth,\n height: container.offsetHeight,\n });\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: DOMRect) {\n this.rect = { ...rect };\n }\n public getInlineSize() {\n return this.rect[this.options.horizontal ? \"height\" : \"width\"];\n }\n public getContentSize() {\n return this.rect[this.options.horizontal ? \"width\" : \"height\"]!;\n }\n public getStatus() {\n return {\n rect: { ...this.rect },\n };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.rect = { ...status.rect };\n\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.rect[sizeName] = size;\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n if (!options.preserveUI) {\n this.container.style.cssText = this.orgCSSText;\n }\n }\n private _init() {\n const container = this.container;\n const style = window.getComputedStyle(container);\n\n this.orgCSSText = container.style.cssText;\n\n if (style.position === \"static\") {\n container.style.position = \"relative\";\n }\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"./Grid\";\nimport { GRID_METHODS, GRID_PROPERTY_TYPES, PROPERTY_TYPE } from \"./consts\";\n\nexport function getKeys>(obj: T): Array {\n return Object.keys(obj);\n}\n\nexport function isString(val: any): val is string {\n return typeof val === \"string\";\n}\nexport function isObject(val: any): val is object {\n return typeof val === \"object\";\n}\nexport function isNumber(val: any): val is number {\n return typeof val === \"number\";\n}\n\nexport function camelize(str: string) {\n return str.replace(/[\\s-_]([a-z])/g, (all, letter) => letter.toUpperCase());\n}\n\nexport function getDataAttributes(element: HTMLElement, attributePrefix: string) {\n const dataAttributes: Record = {};\n const attributes = element.attributes;\n const length = attributes.length;\n\n for (let i = 0; i < length; ++i) {\n const attribute = attributes[i];\n const { name, value } = attribute;\n if (name.indexOf(attributePrefix) === -1) {\n continue;\n }\n dataAttributes[camelize(name.replace(attributePrefix, \"\"))] = value;\n }\n\n return dataAttributes;\n}\n\n/* Class Decorator */\nexport function GetterSetter(component: {\n prototype: Grid,\n propertyTypes: typeof GRID_PROPERTY_TYPES,\n}) {\n const {\n prototype,\n propertyTypes,\n } = component;\n for (const name in propertyTypes) {\n const shouldRender = propertyTypes[name] === PROPERTY_TYPE.RENDER_PROPERTY;\n const attributes: Record = {\n enumerable: true,\n configurable: true,\n get(this: Grid) {\n return this.options[name];\n },\n set(this: Grid, value: any) {\n const options = this.options;\n const prevValue = options[name];\n\n if (prevValue === value) {\n return;\n }\n options[name] = value;\n\n if (shouldRender && options.renderOnPropertyChange) {\n this.scheduleRender();\n }\n },\n };\n Object.defineProperty(prototype, name, attributes);\n }\n}\n\nexport function withMethods(methods: readonly string[]) {\n return function (prototype: any, memberName: string) {\n methods.forEach((name: string) => {\n if (name in prototype) {\n return;\n }\n prototype[name] = function (...args) {\n const result = this[memberName][name](...args);\n\n // fix `this` type to return your own `class` instance to the instance using the decorator.\n if (result === this[memberName]) {\n return this;\n } else {\n return result;\n }\n };\n });\n };\n}\n\nexport function range(length: number): number[] {\n const arr: number[] = [];\n for (let i = 0; i < length; ++i) {\n arr.push(i);\n }\n return arr;\n}\n\nexport function getRangeCost(value: number, valueRange: number[]) {\n return Math.max(value - valueRange[1], valueRange[0] - value, 0) + 1;\n}\n\n/**\n * Decorator that makes the method of grid available in the framework.\n * @ko 프레임워크에서 그리드의 메소드를 사용할 수 있게 하는 데코레이터.\n * @memberof eg.Grid\n * @private\n * @example\n * ```js\n * import { withGridMethods } from \"@egjs/grid\";\n *\n * class Grid extends React.Component> {\n * @withGridMethods\n * private grid: NativeGrid;\n * }\n * ```\n */\nexport const withGridMethods = withMethods(GRID_METHODS);\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DEFAULT_GRID_OPTIONS, MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\nimport { GridItem } from \"./GridItem\";\nimport { DOMRect } from \"./types\";\nimport { getDataAttributes, getKeys } from \"./utils\";\n\nexport interface ItemRendererOptions {\n attributePrefix?: string;\n useTransform?: boolean;\n horizontal?: boolean;\n percentage?: Array<\"position\" | \"size\"> | boolean;\n isEqualSize?: boolean;\n isConstantSize?: boolean;\n}\nexport interface ItemRendererStatus {\n initialRect: Required | null;\n}\n\nexport class ItemRenderer {\n protected options: Required;\n protected containerRect: DOMRect;\n protected initialRect: Required | null = null;\n protected sizePercetage = false;\n protected posPercetage = false;\n\n constructor(options: ItemRendererOptions) {\n this.options = {\n attributePrefix: DEFAULT_GRID_OPTIONS.attributePrefix,\n useTransform: DEFAULT_GRID_OPTIONS.useTransform,\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n percentage: DEFAULT_GRID_OPTIONS.percentage,\n isEqualSize: DEFAULT_GRID_OPTIONS.isEqualSize,\n isConstantSize: DEFAULT_GRID_OPTIONS.isConstantSize,\n ...options,\n };\n this._init();\n }\n public resize() {\n this.initialRect = null;\n }\n public renderItems(items: GridItem[]) {\n items.forEach((item) => {\n this._renderItem(item);\n });\n }\n public getInlineSize() {\n return this.containerRect[this.options.horizontal ? \"height\" : \"width\"]!;\n }\n public setContainerRect(rect: DOMRect) {\n this.containerRect = rect;\n }\n public updateItems(items: GridItem[]) {\n items.forEach((item) => {\n this._updateItem(item);\n });\n }\n public getStatus(): ItemRendererStatus {\n return {\n initialRect: this.initialRect,\n };\n }\n public setStatus(status: ItemRendererStatus) {\n this.initialRect = status.initialRect;\n }\n private _init() {\n const { percentage } = this.options;\n\n let sizePercentage = false;\n let posPercentage = false;\n\n if (percentage === true) {\n sizePercentage = true;\n posPercentage = true;\n } else if (percentage) {\n if (percentage.indexOf(\"position\") > -1) {\n posPercentage = true;\n }\n if (percentage.indexOf(\"size\") > -1) {\n sizePercentage = true;\n }\n }\n\n this.posPercetage = posPercentage;\n this.sizePercetage = sizePercentage;\n }\n private _updateItem(item: GridItem) {\n const { isEqualSize, isConstantSize } = this.options;\n const initialRect = this.initialRect;\n const { orgRect, element } = item;\n const isLoading = item.updateState === UPDATE_STATE.WAIT_LOADING;\n const hasOrgSize = orgRect && orgRect.width && orgRect.height;\n let rect: Required;\n\n if (isEqualSize && initialRect) {\n rect = initialRect;\n } else if (isConstantSize && hasOrgSize && !isLoading) {\n rect = orgRect;\n } else if (!element) {\n return;\n } else {\n rect = {\n left: element.offsetLeft,\n top: element.offsetTop,\n width: element.offsetWidth,\n height: element.offsetHeight,\n };\n }\n if (!item.isFirstUpdate) {\n item.orgRect = { ...rect };\n }\n item.rect = { ...rect };\n\n if (item.element) {\n item.mountState = MOUNT_STATE.MOUNTED;\n }\n\n if (item.updateState === UPDATE_STATE.NEED_UPDATE) {\n item.updateState = UPDATE_STATE.UPDATED;\n item.isFirstUpdate = true;\n }\n item.attributes = element ? getDataAttributes(element, this.options.attributePrefix) : {};\n\n if (!isLoading) {\n this.initialRect = { ...rect };\n }\n\n return rect;\n }\n private _renderItem(item: GridItem) {\n const element = item.element;\n const cssRect = item.cssRect;\n\n if (!element || !cssRect) {\n return;\n }\n\n const {\n horizontal,\n useTransform,\n } = this.options;\n const posPercentage = this.posPercetage;\n const sizePercentage = this.sizePercetage;\n const cssTexts: string[] = [\"position: absolute;\"];\n const {\n inlineSize: sizeName,\n inlinePos: posName,\n } = RECT_NAMES[horizontal ? \"horizontal\": \"vertical\"];\n const inlineSize = this.getInlineSize();\n let keys = getKeys(cssRect);\n\n if (useTransform) {\n keys = keys.filter((key) => key !== \"top\" && key !== \"left\");\n\n cssTexts.push(`transform: `\n + `translate(${cssRect.left || 0}px, ${cssRect.top || 0}px);`\n );\n }\n cssTexts.push(...keys.map((name) => {\n const value = cssRect[name]!;\n\n if (\n (name === sizeName && sizePercentage) ||\n (name === posName && posPercentage)\n ) {\n return `${name}: ${(value / inlineSize) * 100}%;`;\n }\n return `${name}: ${value}px;`;\n }));\n\n element.style.cssText += cssTexts.join(\"\");\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport { DOMRect, GridRect } from \"./types\";\nimport { MOUNT_STATE, RECT_NAMES, UPDATE_STATE } from \"./consts\";\n\n/**\n * @typedef\n * @memberof Grid.GridItem\n * @property - The item key. 아이템 키.\n * @property - The element for the item. 아이템에 있는 엘리먼트.\n * @property - State of whether the element has been added to the container. element가 container에 추가되었는지 상태.\n * @property - The update state of the element's rect. element의 rect의 업데이트 상태.\n * @property - Whether the element's rect was updated for the first time. 처음으로 element의 rect를 업데이트 했는지 여부.\n * @property - Attributes set as `data-grid-` of element. element의 `data-grid-`으로 설정된 속성들.\n * @property - cssText of the first style when an element is added to the container. element가 container에 추가됐을 때 처음 style의 cssText.\n * @property - The element's rect before first rendering. 처음 렌더링 하기 전 엘리먼트의 rect.\n * @property - The updated element's rect before rendering. 렌더링 하기 전 업데이트 된 엘리먼트의 rect.\n * @property - The CSS rect of the item to be rendered by being applied to the Grid. Grid에 적용되어 렌더링을 하기 위한 item의 CSS rect\n * @property - Additional data of the item. item의 추가적인 데이터들.\n */\nexport interface GridItemStatus {\n key?: string | number;\n element?: HTMLElement | null;\n mountState?: MOUNT_STATE;\n updateState?: UPDATE_STATE;\n isFirstUpdate?: boolean;\n attributes?: Record;\n orgCSSText?: string;\n orgRect?: Required;\n rect?: Required;\n cssRect?: DOMRect;\n data?: Record;\n}\n\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n /**\n * @constructor\n * @param horizontal - Direction of the scroll movement. (true: horizontal, false: vertical) 스크롤 이동 방향. (true: 가로방향, false: 세로방향)\n * @param itemStatus - Default status object of GridItem module. GridItem 모듈의 기본 status 객체.\n */\n constructor(\n protected horizontal: boolean,\n itemStatus: Partial = {},\n ) {\n const element = itemStatus.element;\n const status: Required = {\n key: \"\",\n orgRect: { left: 0, top: 0, width: 0, height: 0 },\n rect: { left: 0, top: 0, width: 0, height: 0 },\n cssRect: {},\n attributes: {},\n data: {},\n isFirstUpdate: false,\n mountState: MOUNT_STATE.UNCHECKED,\n updateState: UPDATE_STATE.NEED_UPDATE,\n element: element || null,\n orgCSSText: element?.style.cssText ?? \"\",\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\n /**\n * Grid ready data for rendering\n * @ko 렌더링을 하기 위한 grid의 준비 데이타\n * @member Grid.GridItem#gridData\n */\n public gridData: Record = {};\n /**\n * The size in inline direction before first rendering. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko 첫 렌더링 되기 전의 inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#orgInlineSize\n */\n public get orgInlineSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.height : orgRect.width;\n }\n /**\n * The size in content direction before first rendering. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko 첫 렌더링 되기 전의 content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#orgContentSize\n */\n public get orgContentSize() {\n const orgRect = (this.orgRect || this.rect);\n\n return this.horizontal ? orgRect.width : orgRect.height;\n }\n /**\n * The size in inline direction. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko inline 방향의 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#inlineSize\n */\n public get inlineSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.height : rect.width;\n }\n /**\n * The size in content direction. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko content 방향의 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#contentSize\n */\n public get contentSize() {\n const rect = this.rect;\n\n return this.horizontal ? rect.width : rect.height;\n }\n /**\n * The CSS size in inline direction applied to the Grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#cssInlineSize\n */\n public get cssInlineSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.height! : cssRect.width!;\n }\n /**\n * The CSS size in content direction applied to the Grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#cssContentSize\n */\n public get cssContentSize() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.width! : cssRect.height!;\n }\n /**\n * The CSS pos in inline direction applied to the Grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 inline 방향의 CSS 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#cssInlinePos\n */\n public get cssInlinePos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.top! : cssRect.left!;\n }\n /**\n * The CSS pos in content direction applied to the Grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 CSS 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#cssContentPos\n */\n public get cssContentPos() {\n const cssRect = this.cssRect;\n\n return this.horizontal ? cssRect.left! : cssRect.top!;\n }\n public set cssInlinePos(inlinePos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"top\" : \"left\"] = inlinePos;\n }\n public set cssContentPos(contentPos: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"left\" : \"top\"] = contentPos;\n }\n public set cssInlineSize(inlineSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"height\" : \"width\"] = inlineSize;\n }\n public set cssContentSize(contentSize: number) {\n const cssRect = this.cssRect;\n\n cssRect[this.horizontal ? \"width\" : \"height\"] = contentSize;\n }\n /**\n * Set CSS Rect through GridRect.\n * @ko GridRect을 통해 CSS Rect를 설정한다.\n * @param - The style for setting CSS rect. CSS rect를 설정하기 위한 스타일.\n */\n public setCSSGridRect(gridRect: GridRect) {\n const names = RECT_NAMES[this.horizontal ? \"horizontal\" : \"vertical\"];\n\n const rect: DOMRect = {};\n\n for (const name in gridRect) {\n rect[names[name]] = gridRect[name];\n }\n this.cssRect = rect;\n }\n /**\n * Returns the status of the item.\n * @ko 아이템의 상태를 반환한다.\n */\n public getStatus(): Required {\n return {\n mountState: this.mountState,\n updateState: this.updateState,\n attributes: this.attributes,\n orgCSSText: this.orgCSSText,\n isFirstUpdate: this.isFirstUpdate,\n element: null,\n key: this.key,\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n data: this.data,\n };\n }\n}\n\ninterface GridItem extends Required {\n}\nexport { GridItem };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DEFAULT_GRID_OPTIONS, GRID_PROPERTY_TYPES, MOUNT_STATE, UPDATE_STATE } from \"./consts\";\nimport { ContainerManager } from \"./ContainerManager\";\nimport {\n DestroyOptions, GridEvents, GridOptions,\n GridOutlines, GridStatus, Properties, RenderOptions,\n OnRenderComplete,\n} from \"./types\";\nimport ImReady from \"@egjs/imready\";\nimport { ItemRenderer } from \"./ItemRenderer\";\nimport { GetterSetter, isNumber, isString } from \"./utils\";\nimport { diff } from \"@egjs/children-differ\";\nimport { GridItem } from \"./GridItem\";\n\n/**\n * @extends eg.Component\n */\n@GetterSetter\nabstract class Grid extends Component {\n public static defaultOptions: Required = DEFAULT_GRID_OPTIONS;\n public static propertyTypes = GRID_PROPERTY_TYPES;\n public options: Required;\n protected containerElement: HTMLElement;\n protected containerManager: ContainerManager;\n protected itemRenderer!: ItemRenderer;\n protected items: GridItem[] = [];\n protected outlines: GridOutlines = {\n start: [],\n end: [],\n };\n private _renderTimer = 0;\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _im: ImReady;\n\n /**\n * Apply the CSS rect of items to fit the Grid and calculate the outline.\n * @ko Grid에 맞게 아이템들의 CSS rect를 적용하고 outline을 계산한다.\n * @abstract\n * @method Grid#applyGrid\n * @param {\"start\" | \"end\"} direcion - The direction to apply the Grid. (\"end\": start to end, \"start\": end to start) Grid를 적용할 방향. (\"end\": 시작에서 끝 방향, \"start\": 끝에서 시작 방향)\n * @param {number[]} outline - The start outline to apply the Grid. Grid를 적용할 시작 outline.\n */\n public abstract applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines;\n\n /**\n * @param - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param - The option object of the Grid module Grid 모듈의 옵션 객체\n */\n constructor(containerElement: HTMLElement | string, options: Partial = {}) {\n super();\n\n this.options = {\n ...((this.constructor as typeof Grid)\n .defaultOptions as Required),\n ...options,\n };\n\n this.containerElement = isString(containerElement)\n ? document.querySelector(containerElement)!\n : containerElement;\n\n const {\n isEqualSize,\n isConstantSize,\n useTransform,\n horizontal,\n percentage,\n externalContainerManager,\n externalItemRenderer,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n });\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n });\n\n this._init();\n }\n /**\n * Return Container Element.\n * @ko 컨테이너 엘리먼트를 반환한다.\n */\n public getContainerElement(): HTMLElement {\n return this.containerElement;\n }\n /**\n * Return items.\n * @ko 아이템들을 반환한다.\n */\n public getItems(): GridItem[] {\n return this.items;\n }\n /**\n * Returns the children of the container element.\n * @ko 컨테이너 엘리먼트의 children을 반환한다.\n */\n public getChildren(): HTMLElement[] {\n return [].slice.call(this.containerElement.children);\n }\n /**\n * Set items.\n * @ko 아이템들을 설정한다.\n * @param items - The items to set. 설정할 아이템들\n */\n public setItems(items: GridItem[]): this {\n this.items = items;\n return this;\n }\n /**\n * Gets the container's inline size. (\"width\" if horizontal is false, otherwise \"height\")\n * @ko container의 inline 사이즈를 가져온다. (horizontal이 false면 \"width\", 아니면 \"height\")\n */\n public getContainerInlineSize(): number {\n return this.containerManager.getInlineSize()!;\n }\n /**\n * Returns the outlines of the start and end of the Grid.\n * @ko Grid의 처음과 끝의 outline을 반환한다.\n */\n public getOutlines(): GridOutlines {\n return this.outlines;\n }\n /**\n * Set outlines.\n * @ko 아웃라인을 설정한다.\n * @param outlines - The outlines to set. 설정할 아웃라인.\n */\n public setOutlines(outlines: GridOutlines) {\n this.outlines = outlines;\n return this;\n }\n /**\n * When elements change, it synchronizes and renders items.\n * @ko elements가 바뀐 경우 동기화를 하고 렌더링을 한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public syncElements(options: RenderOptions = {}) {\n const items = this.items;\n const horizontal = this.options.horizontal;\n const elements: HTMLElement[] = this.getChildren();\n const { added, maintained, changed, removed } = diff(this.items.map((item) => item.element!), elements);\n\n const nextItems: GridItem[] = [];\n\n maintained.forEach(([beforeIndex, afterIndex]) => {\n nextItems[afterIndex] = items[beforeIndex];\n });\n added.forEach((index) => {\n nextItems[index] = new GridItem(horizontal!, {\n element: elements[index],\n });\n });\n\n this.setItems(nextItems);\n\n if (added.length || removed.length || changed.length) {\n this.renderItems(options);\n }\n return this;\n }\n /**\n * Update the size of the items and render them.\n * @ko 아이템들의 사이즈를 업데이트하고 렌더링을 한다.\n * @param - Items to be updated. 업데이트할 아이템들.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n */\n public updateItems(items: GridItem[] = this.items, options: RenderOptions = {}) {\n items.forEach((item) => {\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n });\n this.checkReady(options);\n return this;\n }\n /**\n * Rearrange items to fit the grid and render them. When rearrange is complete, the `renderComplete` event is fired.\n * @ko grid에 맞게 아이템을 재배치하고 렌더링을 한다. 배치가 완료되면 `renderComplete` 이벤트가 발생한다.\n * @param - Options for rendering. 렌더링을 하기 위한 옵션.\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n * const grid = new MasonryGrid();\n *\n * grid.on(\"renderComplete\", e => {\n * console.log(e);\n * });\n * grid.renderItems();\n */\n public renderItems(options: RenderOptions = {}) {\n this._clearRenderTimer();\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (options.useResize) {\n // Resize container and Update all items\n this._resizeContainer();\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\n }\n return this;\n }\n /**\n * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method.\n * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다.\n */\n public getStatus(): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => item.getStatus()),\n containerManager: this.containerManager.getStatus(),\n itemRenderer: this.itemRenderer.getStatus(),\n };\n }\n /**\n * Set status of the Grid module with the status returned through a call to the getStatus() method.\n * @ko getStatus() 메서드에 대한 호출을 통해 반환된 상태로 Grid 모듈의 상태를 설정한다.\n */\n public setStatus(status: GridStatus) {\n const horizontal = this.options.horizontal;\n const containerManager = this.containerManager;\n const prevInlineSize = containerManager.getInlineSize();\n const children = this.getChildren();\n\n this.itemRenderer.setStatus(status.itemRenderer);\n containerManager.setStatus(status.containerManager);\n this.outlines = status.outlines;\n this.items = status.items.map((item, i) => new GridItem(horizontal!, {\n ...item,\n element: children[i],\n }));\n\n this.itemRenderer.renderItems(this.items);\n\n if (prevInlineSize !== containerManager.getInlineSize()) {\n this.renderItems({\n useResize: true,\n });\n } else {\n window.setTimeout(() => {\n this._renderComplete({\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Releases the instnace and events and returns the CSS of the container and elements.\n * @ko 인스턴스와 이벤트를 해제하고 컨테이너와 엘리먼트들의 CSS를 되돌린다.\n * @param Options for destroy. destory()를 위한 옵션\n */\n public destroy(options: DestroyOptions = {}) {\n const {\n preserveUI = this.options.preserveUIOnDestroy,\n } = options;\n this.containerManager.destroy({\n preserveUI,\n });\n\n if (!preserveUI) {\n this.items.forEach(({ element, orgCSSText }) => {\n if (element) {\n element.style.cssText = orgCSSText;\n }\n });\n }\n window.removeEventListener(\"resize\", this._scheduleResize);\n this._im?.destroy();\n }\n protected checkReady(options: RenderOptions = {}) {\n // Grid: renderItems => checkReady => readyItems => applyGrid\n const items = this.items;\n const updated = items.filter((item) => item.element && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n this._im?.destroy();\n this._im = new ImReady({\n prefix: this.options.attributePrefix,\n }).on(\"preReadyElement\", (e) => {\n updated[e.index].updateState = UPDATE_STATE.WAIT_LOADING;\n }).on(\"preReady\", () => {\n this.itemRenderer.updateItems(updated);\n this.readyItems(mounted, updated, options);\n }).on(\"readyElement\", (e) => {\n const item = updated[e.index];\n\n item.updateState = UPDATE_STATE.NEED_UPDATE;\n\n // after preReady\n if (e.isPreReadyOver) {\n item.element!.style.cssText = item.orgCSSText;\n this.itemRenderer.updateItems([item]);\n this.readyItems([], [item], options);\n }\n }).on(\"error\", (e) => {\n const item = items[e.index];\n /**\n * This event is fired when an error occurs in the content.\n * @ko 콘텐츠 로드에 에러가 날 때 발생하는 이벤트.\n * @event Grid#contentError\n * @param {Grid.OnContentError} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {HTMLElement} [e.element] - The item's element.아이템의 엘리먼트.\n * @param {HTMLElement} [e.target] - The content element with error.에러난 발생한 콘텐츠 엘리먼트.\n * @param {Grid.GridItem} [e.item] - The item with error content.에러난 콘텐츠를 가지고 있는 아이템\n * @param {function} [e.update] - If you have fixed the error and want to recheck it, call update(). If you remove an element, call the syncElements() method.에러를 해결했고 재검사하고 싶으면 update()를 호출해라. 만약 엘리먼트를 삭제한 경우 syncElements() 메서드를 호출해라.\n * @example\ngrid.on(\"contentError\", e => {\n e.update();\n});\n */\n this.trigger(\"contentError\", {\n element: e.element,\n target: e.target,\n item,\n update: () => {\n moreUpdated.push(item);\n },\n });\n }).on(\"ready\", () => {\n if (moreUpdated.length) {\n this.updateItems(moreUpdated);\n }\n }).check(updated.map((item) => item.element!));\n }\n\n protected scheduleRender() {\n this._clearRenderTimer();\n this._renderTimer = window.setTimeout(() => {\n this.renderItems();\n });\n }\n protected fitOutlines(useFit = this.useFit) {\n const outlines = this.outlines;\n const startOutline = outlines.start;\n const endOutline = outlines.end;\n const outlineOffset = startOutline.length ? Math.min(...startOutline) : 0;\n\n // If the outline is less than 0, a fit occurs forcibly.\n if (!useFit && outlineOffset > 0) {\n return;\n }\n\n outlines.start = startOutline.map((point) => point - outlineOffset);\n outlines.end = endOutline.map((point) => point - outlineOffset);\n\n this.items.forEach((item) => {\n const contentPos = item.cssContentPos;\n\n if (!isNumber(contentPos)) {\n return;\n }\n item.cssContentPos = contentPos - outlineOffset;\n });\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const prevOutlines = this.outlines;\n const direction = options.direction || this.options.defaultDirection!;\n const prevOutline = options.outline || prevOutlines[direction === \"end\" ? \"start\" : \"end\"];\n const items = this.items;\n let nextOutlines = {\n start: [...prevOutline],\n end: [...prevOutline],\n };\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n this._renderComplete({\n mounted,\n updated,\n isResize: !!options.useResize,\n });\n }\n private _renderComplete(e: OnRenderComplete) {\n /**\n * This event is fired when the Grid has completed rendering.\n * @ko Grid가 렌더링이 완료됐을 때 발생하는 이벤트이다.\n * @event Grid#renderComplete\n * @param {Grid.OnRenderComplete} e - The object of data to be sent to an event 이벤트에 전달되는 데이터 객체\n * @param {function} [e.mounted] - The items rendered for the first time 처음 렌더링한 아이템들\n * @param {function} [e.updated] - The items updated in size.사이즈 업데이트한 아이템들.\n * @param {function} [e.useResize] - Whether rendering was done using the resize event or the useResize option. resize 이벤트 또는 useResize 옵션을 사용하여 렌더링를 했는지 여부.\n * @example\ngrid.on(\"renderComplete\", e => {\nconsole.log(e.mounted, e.updated, e.useResize);\n});\n */\n this.trigger(\"renderComplete\", e);\n }\n private _clearRenderTimer() {\n clearTimeout(this._renderTimer);\n this._renderTimer = 0;\n }\n private _refreshContainerContentSize() {\n const {\n start: startOutline,\n end: endOutline,\n } = this.outlines;\n const gap = this.options.gap!;\n\n const endPoint = endOutline.length ? Math.max(...endOutline) : 0;\n const startPoint = startOutline.length ? Math.max(...startOutline) : 0;\n const contentSize = Math.max(startPoint, endPoint - gap);\n\n this.containerManager.setContentSize(contentSize);\n }\n private _resizeContainer() {\n this.containerManager.resize();\n this.itemRenderer.setContainerRect(this.containerManager.getRect());\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n this.renderItems({\n useResize: true,\n });\n }\n private _scheduleResize = () => {\n const {\n resizeDebounce,\n maxResizeDebounce,\n } = this.options;\n\n\n if (!this._maxResizeDebounceTimer && maxResizeDebounce >= resizeDebounce) {\n this._maxResizeDebounceTimer = window.setTimeout(this._onResize, maxResizeDebounce);\n }\n if (this._resizeTimer) {\n clearTimeout(this._resizeTimer);\n this._resizeTimer = 0;\n }\n this._resizeTimer = window.setTimeout(this._onResize, resizeDebounce);\n }\n\n private _init() {\n this._resizeContainer();\n if (this.options.autoResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n }\n}\n\ninterface Grid extends Properties { }\n\nexport default Grid;\n\n/**\n * Gap used to create space around items.\n * @ko 아이템들 사이의 공간.\n * @name Grid#gap\n * @type {$ts:Grid.GridOptions[\"gap\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * gap: 0,\n * });\n *\n * grid.gap = 5;\n */\n\n/**\n * The default direction value when direction is not set in the render option.\n * @ko render옵션에서 direction을 미설정시의 기본 방향값.\n * @name Grid#defaultDirection\n * @type {$ts:Grid.GridOptions[\"defaultDirection\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * defaultDirection: \"end\",\n * });\n *\n * grid.defaultDirection = \"start\";\n */\n\n\n/**\n * Whether to move the outline to 0 when the top is empty when rendering. However, if it overflows above the top, the outline is forced to 0. (default: true)\n * @ko 렌더링시 상단이 비어있을 때 아웃라인을 0으로 이동시킬지 여부. 하지만 상단보다 넘치는 경우 아웃라인을 0으로 강제 이동한다. (default: true)\n * @name Grid#useFit\n * @type {$ts:Grid.GridOptions[\"useFit\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * useFit: true,\n * });\n *\n * grid.useFit = false;\n\n/**\n * Whether to preserve the UI of the existing container or item when destroying.\n * @ko destroy 시 기존 컨테이너, 아이템의 UI를 보존할지 여부.\n * @name Grid#preserveUIOnDestroy\n * @type {$ts:Grid.GridOptions[\"preserveUIOnDestroy\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * preserveUIOnDestroy: false,\n * });\n *\n * grid.preserveUIOnDestroy = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE, UPDATE_STATE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridAlign } from \"../types\";\nimport { range, GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getColumnPoint(\n outline: number[],\n columnIndex: number,\n columnCount: number,\n pointCaculationName: \"max\" | \"min\",\n) {\n return Math[pointCaculationName](...outline.slice(columnIndex, columnIndex + columnCount));\n}\n\nfunction getColumnIndex(outline: number[], columnCount: number, nearestCalculationName: \"max\" | \"min\") {\n const length = outline.length - columnCount + 1;\n const pointCaculationName = nearestCalculationName === \"max\" ? \"min\" : \"max\";\n const indexCaculationName = nearestCalculationName === \"max\" ? \"lastIndexOf\" : \"indexOf\";\n const points = range(length).map((index) => {\n return getColumnPoint(outline, index, columnCount, pointCaculationName);\n });\n\n return points[indexCaculationName](Math[nearestCalculationName](...points));\n}\n\n/**\n * @typedef\n * @memberof Grid.MasonryGrid\n * @extends Grid.GridOptions\n * @property - The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0) \n * @property - The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0) \n * @property - The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0) 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. \n * @property - Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\") 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n}\n\n/**\n * MasonryGrid 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.\n *\n * @ko MasonryGrid는 벽돌을 쌓아 올린 모양처럼 동일한 너비를 가진 아이템를 쌓는 레이아웃이다. 모든 이미지의 너비를 동일한 크기로 조정하고, 가장 높이가 낮은 열을 찾아 새로운 이미지를 삽입한다. 따라서 배치된 아이템 사이에 빈 공간이 생기지는 않지만 배치된 레이아웃의 아래쪽은 울퉁불퉁해진다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.MasonryGrid.MasonryGridOptions} options - The option object of the MasonryGrid module MasonryGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class MasonryGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n column: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSize: PROPERTY_TYPE.RENDER_PROPERTY,\n columnSizeRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n align: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n align: \"justify\",\n column: 0,\n columnSize: 0,\n columnSizeRatio: 0,\n };\n\n private _columnSize = 0;\n private _column = 1;\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n this._calculateColumnSize(items);\n this._calculateColumn(items);\n\n const column = this._column;\n const columnSize = this._columnSize;\n const {\n gap,\n align,\n columnSizeRatio,\n columnSize: columnSizeOption,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses();\n const isEndDirection = direction === \"end\";\n const nearestCalculationName = isEndDirection ? \"min\" : \"max\";\n const pointCalculationName = isEndDirection ? \"max\" : \"min\";\n let startOutline = [0];\n\n if (outlineLength === column) {\n startOutline = outline.slice();\n } else {\n const point = outlineLength ? Math[nearestCalculationName](...outline) : 0;\n\n startOutline = range(column).map(() => point);\n }\n const endOutline = startOutline.slice();\n const columnDist = column > 1 ? alignPoses[1] - alignPoses[0] : 0;\n const isStretch = align === \"stretch\";\n\n for (let i = 0; i < itemsLength; ++i) {\n const item = items[isEndDirection ? i : itemsLength - 1 - i];\n const columnAttribute = parseInt(item.attributes.column || \"1\", 10);\n const maxColumnAttribute = parseInt(item.attributes.maxColumn || \"1\", 10);\n let inlineSize = item.inlineSize;\n let contentSize = item.contentSize;\n let columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((inlineSize + gap) / columnDist)));\n const maxColumnCount = Math.min(column, Math.max(columnCount, maxColumnAttribute));\n let columnIndex = getColumnIndex(endOutline, columnCount, nearestCalculationName);\n let contentPos = getColumnPoint(endOutline, columnIndex, columnCount, pointCalculationName);\n\n while (columnCount < maxColumnCount) {\n const nextEndColumnIndex = columnIndex + columnCount;\n const nextColumnIndex = columnIndex - 1;\n\n if (isEndDirection && (nextEndColumnIndex >= column || endOutline[nextEndColumnIndex] > contentPos)) {\n break;\n }\n if (!isEndDirection && (nextColumnIndex < 0 || endOutline[nextColumnIndex]) < contentPos) {\n break;\n }\n if (!isEndDirection) {\n --columnIndex;\n }\n ++columnCount;\n }\n\n columnIndex = Math.max(0, columnIndex);\n columnCount = Math.min(column - columnIndex, columnCount);\n\n if (columnAttribute > 0 && (columnCount > 1 || isStretch || columnSizeOption)) {\n inlineSize = (columnCount - 1) * columnDist + columnSize;\n item.cssInlineSize = inlineSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = inlineSize / columnSizeRatio;\n item.cssContentSize = contentSize;\n }\n const inlinePos = alignPoses[columnIndex];\n contentPos = isEndDirection ? contentPos : contentPos - gap - contentSize;\n\n item.cssInlinePos = inlinePos;\n item.cssContentPos = contentPos;\n const nextOutlinePoint = isEndDirection ? contentPos + contentSize + gap : contentPos;\n\n range(columnCount).forEach((indexOffset) => {\n endOutline[columnIndex + indexOffset] = nextOutlinePoint;\n });\n }\n\n // if end items, startOutline is low, endOutline is high\n // if start items, startOutline is high, endOutline is low\n return {\n start: isEndDirection ? startOutline : endOutline,\n end: isEndDirection ? endOutline : startOutline,\n };\n }\n private _calculateColumnSize(items: GridItem[]) {\n const {\n columnSize: columnSizeOption,\n gap,\n align,\n } = this.options;\n\n if (align === \"stretch\") {\n let column = this.column;\n\n if (columnSizeOption) {\n column = Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSizeOption + gap)));\n }\n this._columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n this._columnSize = columnSizeOption;\n } else {\n for (const item of items) {\n const attributes = item.attributes;\n if (item.updateState !== UPDATE_STATE.UPDATED || !item.rect || attributes.column || attributes.maxColumnCount) {\n continue;\n }\n const inlineSize = item.inlineSize;\n\n this._columnSize = inlineSize;\n return inlineSize;\n }\n this._columnSize = this._columnSize || 0;\n }\n return this._columnSize;\n }\n private _calculateColumn(items: GridItem[]) {\n const {\n gap,\n column: columnOption,\n } = this.options;\n const columnSize = this._columnSize;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else if (!columnSize) {\n column = 1;\n } else {\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize + gap))),\n );\n }\n this._column = column;\n return column;\n }\n private _getAlignPoses() {\n const columnSize = this._columnSize;\n const column = this._column;\n const {\n align,\n gap,\n } = this.options;\n const containerSize = this.getContainerInlineSize();\n const indexes = range(column);\n\n let offset = 0;\n let dist = 0;\n\n if (align === \"justify\" || align === \"stretch\") {\n const countDist = column - 1;\n\n dist = countDist ? Math.max((containerSize - columnSize) / countDist, columnSize + gap) : 0;\n offset = Math.min(0, containerSize / 2 - (countDist * dist + columnSize) / 2);\n } else {\n dist = columnSize + gap;\n const totalColumnSize = (column - 1) * dist + columnSize;\n\n if (align === \"center\") {\n offset = (containerSize - totalColumnSize) / 2;\n } else if (align === \"end\") {\n offset = containerSize - totalColumnSize;\n }\n }\n return indexes.map((i) => {\n return offset + i * dist;\n });\n }\n}\n\nexport interface MasonryGrid extends Properties {\n}\n\n\n/**\n * Align of the position of the items. If you want to use `stretch`, be sure to set `column` or `columnSize` option. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\") (default: \"justify\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * align: \"start\",\n * });\n *\n * grid.align = \"justify\";\n */\n\n\n/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * column: 0,\n * });\n *\n * grid.column = 4;\n */\n\n\n/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. (default: 0)\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. (default: 0)\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSize: 0,\n * });\n *\n * grid.columnSize = 200;\n */\n\n\n/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set. (default: 0)\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @example\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * columnSizeRatio: 0,\n * });\n *\n * grid.columnSizeRatio = 0.5;\n */\n","/* eslint-disable */\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin \n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nfunction single_source_shortest_paths(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\t// Predecessor map for each node that has been encountered.\n\t// node ID => predecessor node ID\n\tconst predecessors: { [key: string]: string } = {};\n\t// Costs of shortest paths from s to all nodes encountered.\n\t// node ID => cost\n\tconst costs: { [key: string]: number } = {};\n\tcosts[s] = 0;\n\n\t// Costs of shortest paths from s to all nodes encountered; differs from\n\t// `costs` in that it provides easy access to the node that currently has\n\t// the known shortest path from s.\n\t// XXX: Do we actually need both `costs` and `open`?\n\tconst open = new BinaryHeap<{ value: string, cost: number }>(x => x.cost);\n\topen.push({ value: s, cost: 0 });\n\n\tlet closest;\n\tlet u;\n\tlet cost_of_s_to_u;\n\tlet adjacent_nodes;\n\tlet cost_of_e;\n\tlet cost_of_s_to_u_plus_cost_of_e;\n\tlet cost_of_s_to_v;\n\tlet first_visit: boolean;\n\n\twhile (open.size()) {\n\t\t// In the nodes remaining in graph that have a known cost from s,\n\t\t// find the node, u, that currently has the shortest path from s.\n\t\tclosest = open.pop();\n\t\tu = closest.value;\n\t\tcost_of_s_to_u = closest.cost;\n\n\t\t// Get nodes adjacent to u...\n\t\tadjacent_nodes = graph(u) || {};\n\n\t\t// ...and explore the edges that connect u to those nodes, updating\n\t\t// the cost of the shortest paths to any or all of those nodes as\n\t\t// necessary. v is the node across the current edge from u.\n\t\tfor (const v in adjacent_nodes) {\n\t\t\t// Get the cost of the edge running from u to v.\n\t\t\tcost_of_e = adjacent_nodes[v];\n\n\t\t\t// Cost of s to u plus the cost of u to v across e--this is *a*\n\t\t\t// cost from s to v that may or may not be less than the current\n\t\t\t// known cost to v.\n\t\t\tcost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n\t\t\t// If we haven't visited v yet OR if the current known cost from s to\n\t\t\t// v is greater than the new cost we just found (cost of s to u plus\n\t\t\t// cost of u to v across e), update v's cost in the cost list and\n\t\t\t// update v's predecessor in the predecessor list (it's now u).\n\t\t\tcost_of_s_to_v = costs[v];\n\t\t\tfirst_visit = (typeof costs[v] === \"undefined\");\n\t\t\tif (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n\t\t\t\tcosts[v] = cost_of_s_to_u_plus_cost_of_e;\n\t\t\t\topen.push({ value: v, cost: cost_of_s_to_u_plus_cost_of_e });\n\t\t\t\tpredecessors[v] = u;\n\t\t\t}\n\t\t}\n\t}\n\n\tif (typeof costs[d] === \"undefined\") {\n\t\tconst msg = [\"Could not find a path from \", s, \" to \", d, \".\"].join(\"\");\n\t\tthrow new Error(msg);\n\t}\n\n\treturn predecessors;\n}\nfunction extract_shortest_path_from_predecessor_list(\n\tpredecessors: { [key: string]: string },\n\td: string,\n) {\n\tconst nodes: string[] = [];\n\tlet u = d;\n\n\twhile (u) {\n\t\tnodes.push(u);\n\t\tu = predecessors[u];\n\t}\n\tnodes.reverse();\n\treturn nodes;\n}\nfunction find_path(\n\tgraph: (x: string) => ({ [key: string]: number }),\n\ts: string,\n\td: string,\n) {\n\tconst predecessors = single_source_shortest_paths(graph, s, d);\n\n\treturn extract_shortest_path_from_predecessor_list(predecessors, d);\n}\n\nclass BinaryHeap {\n\tprivate content: T[];\n\tprivate scoreFunction: (x: T) => number;\n\n\tconstructor(scoreFunction: (x: T) => number) {\n\t\tthis.content = [];\n\t\tthis.scoreFunction = scoreFunction;\n\t}\n\tpublic push(element: T) {\n\t\t// Add the new element to the end of the array.\n\t\tthis.content.push(element);\n\t\t// Allow it to bubble up.\n\t\tthis.bubbleUp(this.content.length - 1);\n\t}\n\tpublic pop() {\n\t\t// Store the first element so we can return it later.\n\t\tconst result = this.content[0];\n\t\t// Get the element at the end of the array.\n\t\tconst end = this.content.pop()!;\n\t\t// If there are any elements left, put the end element at the\n\t\t// start, and let it sink down.\n\t\tif (this.content.length > 0) {\n\t\t\tthis.content[0] = end;\n\t\t\tthis.sinkDown(0);\n\t\t}\n\t\treturn result;\n\t}\n\tpublic size() {\n\t\treturn this.content.length;\n\t}\n\tpublic bubbleUp(_n: number) {\n\t\tlet n = _n;\n\t\t// Fetch the element that has to be moved.\n\t\tconst element = this.content[n];\n\t\t// When at 0, an element can not go up any further.\n\t\twhile (n > 0) {\n\t\t\t// Compute the parent element's index, and fetch it.\n\t\t\tconst parentN = Math.floor((n + 1) / 2) - 1;\n\t\t\tconst parent = this.content[parentN];\n\n\t\t\t// Swap the elements if the parent is greater.\n\t\t\tif (this.scoreFunction(element) < this.scoreFunction(parent)) {\n\t\t\t\tthis.content[parentN] = element;\n\t\t\t\tthis.content[n] = parent;\n\t\t\t\t// Update 'n' to continue at the new position.\n\t\t\t\tn = parentN;\n\t\t\t} else {\n\t\t\t\t// Found a parent that is less, no need to move it further.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n\tpublic sinkDown(n: number) {\n\t\t// Look up the target element and its score.\n\t\tconst length = this.content.length;\n\t\tconst element = this.content[n];\n\t\tconst elemScore = this.scoreFunction(element);\n\t\tlet child1Score;\n\n\t\twhile (true) {\n\t\t\t// Compute the indices of the child elements.\n\t\t\tconst child2N = (n + 1) * 2;\n\t\t\tconst child1N = child2N - 1;\n\t\t\t// This is used to store the new position of the element,\n\t\t\t// if any.\n\t\t\tlet swap: number | null = null;\n\t\t\t// If the first child exists (is inside the array)...\n\t\t\tif (child1N < length) {\n\t\t\t\t// Look it up and compute its score.\n\t\t\t\tconst child1 = this.content[child1N];\n\t\t\t\tchild1Score = this.scoreFunction(child1);\n\t\t\t\t// If the score is less than our element's, we need to swap.\n\t\t\t\tif (child1Score < elemScore) {\n\t\t\t\t\tswap = child1N;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// Do the same checks for the other child.\n\t\t\tif (child2N < length) {\n\t\t\t\tconst child2 = this.content[child2N];\n\t\t\t\tconst child2Score = this.scoreFunction(child2);\n\n\t\t\t\tif (child2Score < (swap == null ? elemScore : child1Score)) {\n\t\t\t\t\tswap = child2N;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// If the element needs to be moved, swap it, and continue.\n\t\t\tif (swap !== null) {\n\t\t\t\tthis.content[n] = this.content[swap];\n\t\t\t\tthis.content[swap] = element;\n\t\t\t\tn = swap;\n\t\t\t} else {\n\t\t\t\t// Otherwise, we are done.\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t}\n}\n\nexport { find_path };\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, RenderOptions } from \"../types\";\nimport { getRangeCost, GetterSetter, isObject } from \"../utils\";\nimport { find_path } from \"./lib/dijkstra\";\nimport { GridItem } from \"../GridItem\";\n\n\ninterface Link {\n path: number[];\n cost: number;\n length: number;\n currentNode: number;\n isOver?: boolean;\n}\n\nfunction splitItems(items: GridItem[], path: string[]) {\n const length = path.length;\n const groups: GridItem[][] = [];\n\n for (let i = 0; i < length - 1; ++i) {\n const path1 = parseInt(path[i], 10);\n const path2 = parseInt(path[i + 1], 10);\n\n groups.push(items.slice(path1, path2));\n }\n return groups;\n}\nfunction getExpectedColumnSize(item: GridItem, rowSize: number) {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return 0;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n\n return (inlineSize - inlineOffset) / (contentSize - contentOffset) * (rowSize - contentOffset) + inlineOffset;\n}\n\n/**\n * @typedef\n * @memberof Grid.JustifiedGrid\n * @extends Grid.GridOptions\n * @property - The minimum and maximum number of items per line. (default: [1, 8]) 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8]) \n * @property - The minimum and maximum number of rows in a group, 0 is not set. (default: 0) 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0) \n * @property - The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity]) 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @property - Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @property - Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false) row사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n */\nexport interface JustifiedGridOptions extends GridOptions {\n columnRange?: number | number[];\n rowRange?: number | number[];\n sizeRange?: number | number[];\n displayedRow?: number;\n isCroppedSize?: boolean;\n}\n\n/**\n * 'justified' is a printing term with the meaning that 'it fits in one row wide'. JustifiedGrid is a grid that the item is filled up on the basis of a line given a size.\n * If 'data-grid-inline-offset' or 'data-grid-content-offset' are set for item element, the ratio is maintained except for the offset value.\n * 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.\n * @ko 'justified'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. JustifiedGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템가 가득 차도록 배치하는 Grid다.\n * 아이템 엘리먼트에 'data-grid-inline-offset' 또는 'data-grid-content-offset'를 설정하면 offset 값을 제외하고 비율을 유지한다.\n * 비율을 유지하고 싶은 엘리먼트에 'data-grid-maintained-target'을 설정한다면 해당 엘리먼트의 비율을 유지하면서 아이템이 렌더링이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.JustifiedGrid.JustifiedGridOptions} options - The option object of the JustifiedGrid module JustifiedGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class JustifiedGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n columnRange: PROPERTY_TYPE.RENDER_PROPERTY,\n rowRange: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeRange: PROPERTY_TYPE.RENDER_PROPERTY,\n isCroppedSize: PROPERTY_TYPE.RENDER_PROPERTY,\n displayedRow: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n columnRange: [1, 8],\n rowRange: 0,\n sizeRange: [0, Infinity],\n displayedRow: -1,\n isCroppedSize: false,\n };\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const rowRange = this.options.rowRange;\n let path: string[] = [];\n\n if (items.length) {\n path = rowRange ? this._getRowPath(items) : this._getPath(items);\n }\n\n return this._setStyle(items, path, outline, direction === \"end\");\n }\n protected readyItems(mounted: GridItem[], updated: GridItem[], options: RenderOptions) {\n const {\n attributePrefix,\n horizontal,\n } = this.options;\n\n updated.forEach((item) => {\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || 0;\n\n if (element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)) {\n const maintainedTarget = element.querySelector(`[${attributePrefix}maintained-target]`);\n\n if (maintainedTarget) {\n const widthOffset = element.offsetWidth - element.clientWidth\n + element.scrollWidth - maintainedTarget.clientWidth;\n const heightOffset = element.offsetHeight - element.clientHeight\n + element.scrollHeight - maintainedTarget.clientHeight;\n\n if (horizontal) {\n inlineOffset = heightOffset;\n contentOffset = widthOffset;\n } else {\n inlineOffset = widthOffset;\n contentOffset = heightOffset;\n }\n }\n }\n gridData.inlineOffset = inlineOffset;\n gridData.contentOffset = contentOffset;\n });\n super.readyItems(mounted, updated, options);\n }\n private _getRowPath(items: GridItem[]) {\n const columnRange = this._getColumnRange();\n const rowRange = this._getRowRange();\n\n const pathLink = this._getRowLink(items, {\n path: [0],\n cost: 0,\n length: 0,\n currentNode: 0,\n }, columnRange, rowRange);\n\n return pathLink?.path.map((node) => `${node}`) ?? [];\n }\n private _getRowLink(\n items: GridItem[],\n currentLink: Link,\n columnRange: number[],\n rowRange: number[]\n ): Link {\n const [minColumn] = columnRange;\n const [minRow, maxRow] = rowRange;\n const lastNode = items.length;\n const {\n path,\n length: pathLength,\n cost,\n currentNode,\n } = currentLink;\n\n // not reached lastNode but path is exceed or the number of remaining nodes is less than minColumn.\n if (currentNode < lastNode && (maxRow <= pathLength || currentNode + minColumn > lastNode)) {\n const rangeCost = getRangeCost(lastNode - currentNode, columnRange);\n const lastCost = rangeCost * Math.abs(this._getCost(items, currentNode, lastNode));\n\n return {\n ...currentLink,\n length: pathLength + 1,\n path: [...path, lastNode],\n currentNode: lastNode,\n cost: cost + lastCost,\n isOver: true,\n };\n } else if (currentNode >= lastNode) {\n return {\n ...currentLink,\n currentNode: lastNode,\n isOver: minRow > pathLength || maxRow < pathLength,\n };\n } else {\n return this._searchRowLink(items, currentLink, lastNode, columnRange, rowRange);\n }\n\n }\n private _searchRowLink(\n items: GridItem[],\n currentLink: Link,\n lastNode: number,\n columnRange: number[],\n rowRange: number[]\n ) {\n const [minColumn, maxColumn] = columnRange;\n const {\n currentNode,\n path,\n length: pathLength,\n cost,\n } = currentLink;\n const length = Math.min(lastNode, currentNode + maxColumn);\n const links: Link[] = [];\n\n for (let nextNode = currentNode + minColumn; nextNode <= length; ++nextNode) {\n if (nextNode === currentNode) {\n continue;\n }\n const nextCost = Math.abs(this._getCost(items, currentNode, nextNode));\n const nextLink = this._getRowLink(items, {\n path: [...path, nextNode],\n length: pathLength + 1,\n cost: cost + nextCost,\n currentNode: nextNode,\n }, columnRange, rowRange);\n\n if (nextLink) {\n links.push(nextLink);\n }\n }\n links.sort((a, b) => {\n const aIsOver = a.isOver;\n const bIsOver = b.isOver;\n\n if (aIsOver !== bIsOver) {\n // If it is over, the cost is high.\n return aIsOver ? 1 : -1;\n }\n const aRangeCost = getRangeCost(a.length, rowRange);\n const bRangeCost = getRangeCost(b.length, rowRange);\n\n return aRangeCost - bRangeCost || a.cost - b.cost;\n });\n\n // It returns the lowest cost link.\n return links[0];\n }\n private _getExpectedRowSize(items: GridItem[]) {\n const {\n gap,\n } = this.options;\n let containerInlineSize = this.getContainerInlineSize()! - gap * (items.length - 1);\n let ratioSum = 0;\n let inlineSum = 0;\n\n items.forEach((item) => {\n const inlineSize = item.orgInlineSize;\n const contentSize = item.orgContentSize;\n\n if (!inlineSize || !contentSize) {\n return;\n }\n // sum((expect - offset) * ratio) = container inline size\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const maintainedRatio = (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n ratioSum += maintainedRatio;\n inlineSum += contentOffset * maintainedRatio;\n containerInlineSize -= inlineOffset;\n });\n\n return ratioSum ? (containerInlineSize + inlineSum) / ratioSum : 0;\n }\n private _getExpectedInlineSize(items: GridItem[], rowSize: number) {\n const {\n gap,\n } = this.options;\n const size = items.reduce((sum, item) => {\n return sum + getExpectedColumnSize(item, rowSize);\n }, 0);\n\n return size ? size + gap * (items.length - 1) : 0;\n }\n private _getCost(\n items: GridItem[],\n i: number,\n j: number,\n ) {\n const lineItems = items.slice(i, j);\n const rowSize = this._getExpectedRowSize(lineItems);\n const [minSize, maxSize] = this._getSizeRange();\n\n if (this.isCroppedSize) {\n if (minSize <= rowSize && rowSize <= maxSize) {\n return 0;\n }\n const expectedInlineSize = this._getExpectedInlineSize(\n lineItems,\n rowSize < minSize ? minSize : maxSize,\n );\n\n return Math.pow(expectedInlineSize - this.getContainerInlineSize(), 2);\n }\n\n if (isFinite(maxSize)) {\n // if this size is not in range, the cost increases sharply.\n if (rowSize < minSize) {\n return Math.pow(rowSize - minSize, 2) + Math.pow(maxSize, 2);\n } else if (rowSize > maxSize) {\n return Math.pow(rowSize - maxSize, 2) + Math.pow(maxSize, 2);\n }\n } else if (rowSize < minSize) {\n return Math.max(Math.pow(minSize, 2), Math.pow(rowSize, 2)) + Math.pow(maxSize, 2);\n }\n // if this size in range, the cost is row\n return rowSize - minSize;\n }\n private _getPath(items: GridItem[]) {\n const lastNode = items.length;\n const columnRangeOption = this.options.columnRange;\n const [minColumn, maxColumn]: number[] = isObject(columnRangeOption)\n ? columnRangeOption\n : [columnRangeOption, columnRangeOption];\n\n const graph = (nodeKey: string) => {\n const results: { [key: string]: number } = {};\n const currentNode = parseInt(nodeKey, 10);\n\n for (let nextNode = Math.min(currentNode + minColumn, lastNode); nextNode <= lastNode; ++nextNode) {\n if (nextNode - currentNode > maxColumn) {\n break;\n }\n let cost = this._getCost(\n items,\n currentNode,\n nextNode,\n );\n\n if (cost < 0 && nextNode === lastNode) {\n cost = 0;\n }\n results[`${nextNode}`] = Math.pow(cost, 2);\n }\n return results;\n };\n // shortest path for items' total height.\n return find_path(graph, \"0\", `${lastNode}`);\n }\n private _setStyle(\n items: GridItem[],\n path: string[],\n outline: number[] = [],\n isEndDirection: boolean,\n ) {\n const {\n gap,\n isCroppedSize,\n displayedRow,\n } = this.options;\n const sizeRange = this._getSizeRange();\n const startPoint = outline[0] || 0;\n const containerInlineSize = this.getContainerInlineSize();\n const groups = splitItems(items, path);\n let contentPos = startPoint;\n let displayedSize = 0;\n\n groups.forEach((groupItems, rowIndex) => {\n const length = groupItems.length;\n let rowSize = this._getExpectedRowSize(groupItems);\n if (isCroppedSize) {\n rowSize = Math.max(sizeRange[0], Math.min(rowSize, sizeRange[1]));\n }\n const expectedInlineSize = this._getExpectedInlineSize(groupItems, rowSize);\n\n const allGap = gap * (length - 1);\n const scale = (containerInlineSize - allGap) / (expectedInlineSize - allGap);\n\n groupItems.forEach((item, i)=> {\n let columnSize = getExpectedColumnSize(item, rowSize);\n\n const prevItem = groupItems[i - 1];\n const inlinePos = prevItem\n ? prevItem.cssInlinePos + prevItem.cssInlineSize + gap\n : 0;\n\n if (isCroppedSize) {\n columnSize *= scale;\n }\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize: columnSize,\n contentSize: rowSize,\n });\n });\n contentPos += gap + rowSize;\n if (displayedRow < 0 || rowIndex < displayedRow) {\n displayedSize = contentPos;\n }\n });\n\n if (isEndDirection) {\n // previous group's end outline is current group's start outline\n return {\n start: [startPoint],\n end: [displayedSize],\n };\n }\n // always start is lower than end.\n // contentPos is endPoinnt\n const height = contentPos - startPoint;\n\n items.forEach((item) => {\n item.cssContentPos -= height;\n });\n return {\n start: [startPoint - height],\n end: [startPoint], // endPoint - height = startPoint\n };\n }\n private _getRowRange() {\n const rowRange = this.rowRange;\n return isObject(rowRange) ? rowRange : [rowRange, rowRange];\n }\n private _getColumnRange() {\n const columnRange = this.columnRange;\n return isObject(columnRange) ? columnRange : [columnRange, columnRange];\n }\n private _getSizeRange() {\n const sizeRange = this.sizeRange;\n return isObject(sizeRange) ? sizeRange : [sizeRange, sizeRange];\n }\n}\n\nexport interface JustifiedGrid extends Properties {\n}\n\n\n/**\n * The minimum and maximum number of items per line. (default: [1, 8])\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. (default: [1, 8])\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * columnRange: [1, 8],\n * });\n *\n * grid.columnRange = [3, 6];\n */\n\n\n/**\n * The minimum and maximum number of rows in a group, 0 is not set. (default: 0)\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. (default: 0)\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * rowRange: 0,\n * });\n *\n * grid.rowRange = [3, 4];\n */\n\n/**\n * The minimum and maximum size by which the item is adjusted. If it is not calculated, it may deviate from the minimum and maximum sizes. (default: [0, Infinity])\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. (default: [0, Infinity])\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [0, Infinity],\n * });\n *\n * grid.sizeRange = [200, 800];\n */\n\n/**\n * Maximum number of rows to be counted for container size. You can hide it on the screen by setting overflow: hidden. -1 is not set. (default: -1)\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. (default: -1)\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * displayedRow: -1,\n * });\n *\n * grid.displayedRow = 3;\n */\n\n/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken. (default: false)\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. (default: false)\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @example\n * import { JustifiedGrid } from \"@egjs/grid\";\n *\n * const grid = new JustifiedGrid(container, {\n * sizeRange: [200, 250],\n * isCroppedSize: false,\n * });\n *\n * grid.isCroppedSize = true;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines, GridRect } from \"../types\";\nimport { GetterSetter, range } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\n\n\nfunction getMaxPoint(outline: number[]) {\n let maxPoint = -Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n maxPoint = Math.max(maxPoint, point);\n }\n });\n return isFinite(maxPoint) ? maxPoint : 0;\n}\nfunction getMinPoint(outline: number[]) {\n let minPoint = Infinity;\n\n outline.forEach((point) => {\n if (isFinite(point)) {\n minPoint = Math.min(minPoint, point);\n }\n });\n return isFinite(minPoint) ? minPoint : 0;\n}\nfunction getOutlinePoint(startOutline: number[], frameOutline: number[], useFrameFill: boolean) {\n return getMaxPoint(startOutline)\n + getOutlineDist(startOutline, frameOutline, useFrameFill);\n}\n\nfunction getOutlineDist(startOutline: number[], endOutline: number[], useFrameFill: boolean) {\n const length = startOutline.length;\n\n if (!length) {\n return 0;\n }\n const minEndPoint = getMinPoint(endOutline);\n const maxStartPoint = getMaxPoint(startOutline);\n let frameDist = 0;\n\n if (!useFrameFill) {\n return 0;\n }\n\n\n for (let outlineIndex = 0; outlineIndex < length; ++outlineIndex) {\n const startPoint = startOutline[outlineIndex];\n const endPoint = endOutline[outlineIndex];\n\n if (!isFinite(startPoint) || !isFinite(endPoint)) {\n continue;\n }\n const startPos = startPoint - maxStartPoint;\n const endPos = endPoint - minEndPoint;\n\n\n // Fill empty block.\n frameDist = outlineIndex ? Math.max(frameDist, frameDist + startPos - endPos) : startPos - endPos;\n }\n\n return frameDist;\n}\nfunction fillOutlines(startOutline: number[], endOutline: number[], rect: {\n inlinePos: number;\n inlineSize: number;\n contentPos: number;\n contentSize: number;\n}) {\n const {\n inlinePos,\n inlineSize,\n contentPos,\n contentSize,\n } = rect;\n for (\n let outlineIndex = inlinePos;\n outlineIndex < inlinePos + inlineSize;\n ++outlineIndex\n ) {\n startOutline[outlineIndex] = Math.min(startOutline[outlineIndex], contentPos);\n endOutline[outlineIndex] = Math.max(endOutline[outlineIndex], contentPos + contentSize);\n }\n}\nexport interface FrameRect extends Required {\n type: any;\n}\n/**\n * @typedef\n * @memberof Grid.FrameGrid\n * @extends Grid.GridOptions\n * @property - The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @property - Make sure that the frame can be attached after the previous frame. (default: true) 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @property - 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0) 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n */\nexport interface FrameGridOptions extends GridOptions {\n frame?: number[][];\n useFrameFill?: boolean;\n rectSize?: number | { inlineSize: number, contentSize: number };\n}\n\n/**\n * 'Frame' is a printing term with the meaning that 'it fits in one row wide'. FrameGrid is a grid that the item is filled up on the basis of a line given a size.\n * @ko 'Frame'는 '1행의 너비에 맞게 꼭 들어찬'이라는 의미를 가진 인쇄 용어다. FrameGrid는 용어의 의미대로 너비가 주어진 사이즈를 기준으로 아이템이 가득 차도록 배치하는 Grid다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.FrameGrid.FrameGridOptions} options - The option object of the FrameGrid module FrameGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class FrameGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n frame: PROPERTY_TYPE.RENDER_PROPERTY,\n useFrameFill: PROPERTY_TYPE.RENDER_PROPERTY,\n rectSize: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n frame: [],\n rectSize: 0,\n useFrameFill: true,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const frame = this._getFrame();\n const {\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n rects: frameRects,\n } = frame;\n const {\n gap,\n useFrameFill,\n } = this.options;\n\n const {\n inlineSize: rectInlineSize,\n contentSize: rectContentSize,\n } = this.getRectSize(frameInlineSize);\n\n\n const itemsLength = items.length;\n\n if (!itemsLength || !frameInlineSize || !frameContentSize) {\n return { start: outline, end: outline };\n }\n const rectsLength = frameRects.length;\n let startOutline = range(frameInlineSize).map(() => Infinity);\n let endOutline = range(frameInlineSize).map(() => -Infinity);\n const frameOutline = frame.outline.map((point) => point * (rectContentSize + gap));\n\n for (let startIndex = 0; startIndex < itemsLength; startIndex += rectsLength) {\n // Compare group's startOutline and startOutline of rect\n const startPoint = getOutlinePoint(endOutline, frameOutline, useFrameFill);\n\n for (let rectIndex = 0; rectIndex < rectsLength && startIndex + rectIndex < itemsLength; ++rectIndex) {\n const item = items[startIndex + rectIndex];\n const {\n contentPos: frameRectContentPos,\n inlinePos: frameRectInlinePos,\n contentSize: frameRectContentSize,\n inlineSize: frameRectInlineSize,\n } = frameRects[rectIndex];\n const contentPos = startPoint + frameRectContentPos * (rectContentSize + gap);\n const inlinePos = frameRectInlinePos * (rectInlineSize + gap);\n const contentSize = frameRectContentSize * (rectContentSize + gap) - gap;\n const inlineSize = frameRectInlineSize * (rectInlineSize + gap) - gap;\n\n fillOutlines(startOutline, endOutline, {\n inlinePos: frameRectInlinePos,\n inlineSize: frameRectInlineSize,\n contentPos: contentPos,\n contentSize: contentSize + gap,\n });\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n }\n }\n const isDirectionEnd = direction === \"end\";\n\n let gridOutline = outline;\n\n if (gridOutline.length !== frameInlineSize) {\n const point = isDirectionEnd ? Math.max(...gridOutline) : Math.min(...gridOutline);\n\n gridOutline = range(frameInlineSize).map(() => point);\n }\n startOutline = startOutline.map((point) => isFinite(point) ? point : 0);\n endOutline = endOutline.map((point) => isFinite(point) ? point : 0);\n const outlineDist = isDirectionEnd\n ? getOutlineDist(startOutline, gridOutline, useFrameFill)\n : getOutlineDist(gridOutline, endOutline, useFrameFill);\n\n items.forEach((item) => {\n item.cssContentPos += outlineDist;\n });\n\n return {\n start: startOutline.map((point) => point + outlineDist),\n end: endOutline.map((point) => point + outlineDist),\n };\n }\n protected getRectSize(frameInlineSize: number) {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption;\n }\n const rectSizeValue = rectSizeOption\n ? rectSizeOption\n : (this.getContainerInlineSize()! + gap) / frameInlineSize - gap;\n\n return { inlineSize: rectSizeValue, contentSize: rectSizeValue };\n }\n private _getFrame() {\n const frame = this.options.frame;\n const frameContentSize = frame.length;\n const frameInlineSize = frameContentSize ? frame[0].length : 0;\n const rects: FrameRect[] = [];\n const passMap: Record = {};\n const startOutline = range(frameInlineSize).map(() => Infinity);\n const endOutline = range(frameInlineSize).map(() => -Infinity);\n\n for (let y1 = 0; y1 < frameContentSize; ++y1) {\n for (let x1 = 0; x1 < frameInlineSize; ++x1) {\n const type = frame[y1][x1];\n\n if (!type) {\n continue;\n }\n if (passMap[`${y1},${x1}`]) {\n continue;\n }\n const rect = this._findRect(passMap, type, y1, x1, frameInlineSize, frameContentSize);\n\n fillOutlines(startOutline, endOutline, rect);\n rects.push(rect);\n }\n }\n rects.sort((a, b) => (a.type < b.type ? -1 : 1));\n\n\n return {\n rects,\n inlineSize: frameInlineSize,\n contentSize: frameContentSize,\n outline: startOutline,\n };\n }\n private _findRect(\n passMap: Record,\n type: number,\n y1: number,\n x1: number,\n frameInlineSize: number,\n frameContentSize: number,\n ) {\n const frame = this.options.frame;\n\n let contentSize = 1;\n let inlineSize = 1;\n\n // find rect\n for (let x2 = x1; x2 < frameInlineSize; ++x2) {\n if (frame[y1][x2] === type) {\n inlineSize = x2 - x1 + 1;\n continue;\n }\n break;\n }\n for (let y2 = y1; y2 < frameContentSize; ++y2) {\n if (frame[y2][x1] === type) {\n contentSize = y2 - y1 + 1;\n continue;\n }\n break;\n }\n\n // pass rect\n for (let y = y1; y < y1 + contentSize; ++y) {\n for (let x = x1; x < x1 + inlineSize; ++x) {\n passMap[`${y},${x}`] = true;\n }\n }\n\n const rect: FrameRect = {\n type,\n inlinePos: x1,\n contentPos: y1,\n inlineSize,\n contentSize,\n };\n return rect;\n }\n}\n\nexport interface FrameGrid extends Properties {\n}\n\n\n/**\n * The shape of the grid. You can set the shape and order of items with a 2d array ([contentPos][inlinePos]). You can place items as many times as you fill the array with numbers, and zeros and spaces are empty spaces. The order of the items is arranged in ascending order of the numeric values that fill the array. (default: [])\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. (default: [])\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 1 x 1\n * // Item 3 : 1 x 2\n * // Item 4 : 1 x 1\n * // Item 5 : 2 x 1\n * const grid = new FrameGrid(container, {\n * frame: [\n * [1, 1, 0, 0, 2, 3],\n * [1, 1, 0, 4, 5, 5],\n * ],\n * });\n *\n * // Item 1 : 2 x 2\n * // Item 2 : 2 x 2\n * grid.frame = [\n * [1, 1, 0, 0, 2, 2],\n * [1, 1, 0, 0, 2, 2],\n * ];\n */\n\n/**\n * Make sure that the frame can be attached after the previous frame. (default: true)\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. (default: true)\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * useFrameFill: true,\n * });\n *\n * grid.useFrameFill = false;\n */\n\n/**\n * 1x1 rect size. If it is 0, it is determined by the number of columns in the frame. (default: 0)\n * @ko 1x1 직사각형 크기. 0이면 frame의 column의 개수에 의해 결정된다. (default: 0)\n * @name Grid.FrameGrid#rectSize\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"rectSize\"]}\n * @example\n * import { FrameGrid } from \"@egjs/grid\";\n *\n * const grid = new FrameGrid(container, {\n * rectSize: 0,\n * });\n *\n * grid.rectSize = { inlineSize: 100, contentSize: 150 };\n */\n","export interface BoxModelStatus {\n orgInlineSize: number;\n orgContentSize: number;\n inlineSize: number;\n contentSize: number;\n inlinePos: number;\n contentPos: number;\n items: BoxModel[];\n}\n\nexport default class BoxModel implements BoxModelStatus {\n public orgInlineSize: number;\n public orgContentSize: number;\n public inlineSize: number;\n public contentSize: number;\n public inlinePos: number;\n public contentPos: number;\n public items: BoxModel[];\n constructor(status: Partial) {\n const boxStatus = {\n orgInlineSize: 0,\n orgContentSize: 0,\n inlineSize: 0,\n contentSize: 0,\n inlinePos: 0,\n contentPos: 0,\n items: [],\n ...status,\n };\n for (const name in boxStatus) {\n this[name] = boxStatus[name];\n }\n }\n public scaleTo(inlineSize: number, contentSize: number) {\n const scaleX = this.inlineSize ? inlineSize / this.inlineSize : 0;\n const scaleY = this.contentSize ? contentSize / this.contentSize : 0;\n\n this.items.forEach((item) => {\n if (scaleX !== 0) {\n item.inlinePos *= scaleX;\n item.inlineSize *= scaleX;\n }\n if (scaleY !== 0) {\n item.contentPos *= scaleY;\n item.contentSize *= scaleY;\n }\n });\n\n this.inlineSize = inlineSize;\n this.contentSize = contentSize;\n }\n public push(item: BoxModel) {\n this.items.push(item);\n }\n public getOrgSizeWeight() {\n return this.orgInlineSize * this.orgContentSize;\n }\n public getSize() {\n return this.inlineSize * this.contentSize;\n }\n public getOrgRatio() {\n return (this.orgContentSize === 0) ? 0 : this.orgInlineSize / this.orgContentSize;\n }\n public getRatio() {\n return (this.contentSize === 0) ? 0 : this.inlineSize / this.contentSize;\n }\n}\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid from \"../Grid\";\nimport { PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } from \"../types\";\nimport { GetterSetter } from \"../utils\";\nimport { GridItem } from \"../GridItem\";\nimport BoxModel from \"./lib/BoxModel\";\n\n\nfunction getCost(originLength: number, length: number) {\n let cost = originLength / length;\n\n if (cost < 1) {\n cost = 1 / cost;\n }\n\n return cost - 1;\n}\nfunction fitArea(\n item: BoxModel,\n bestFitArea: BoxModel,\n itemFitSize: { inlineSize: number, contentSize: number },\n containerFitSize: { inlineSize: number, contentSize: number },\n isContentDirection: boolean,\n) {\n item.contentSize = itemFitSize.contentSize;\n item.inlineSize = itemFitSize.inlineSize;\n bestFitArea.contentSize = containerFitSize.contentSize;\n bestFitArea.inlineSize = containerFitSize.inlineSize;\n\n if (isContentDirection) {\n item.contentPos = bestFitArea.contentPos + bestFitArea.contentSize;\n item.inlinePos = bestFitArea.inlinePos;\n } else {\n item.inlinePos = bestFitArea.inlinePos + bestFitArea.inlineSize;\n item.contentPos = bestFitArea.contentPos;\n }\n}\n\n\n/**\n * @typedef\n * @memberof Grid.PackingGrid\n * @extends Grid.GridOptions\n * @property - The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1) 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @property - The size weight when placing items. (default: 1)아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @property - The weight to keep ratio when placing items. (default: 1)아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @property - The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 100, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 100), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n */\nexport interface PackingGridOptions extends GridOptions {\n aspectRatio?: number;\n sizeWeight?: number;\n ratioWeight?: number;\n weightPriority?: \"size\" | \"ratio\" | \"custom\";\n}\n\n/**\n * The PackingGrid is a grid that shows the important items bigger without sacrificing the weight of the items.\n * Rows and columns are separated so that items are dynamically placed within the horizontal and vertical space rather than arranged in an orderly fashion.\n * If `sizeWeight` is higher than `ratioWeight`, the size of items is preserved as much as possible.\n * Conversely, if `ratioWeight` is higher than `sizeWeight`, the ratio of items is preserved as much as possible.\n * @ko PackingGrid는 아이템의 본래 크기에 따른 비중을 해치지 않으면서 중요한 카드는 더 크게 보여 주는 레이아웃이다.\n * 행과 열이 구분돼 아이템을 정돈되게 배치하는 대신 가로세로 일정 공간 내에서 동적으로 아이템을 배치한다.\n * `sizeWeight`가 `ratioWeight`보다 높으면 아이템들의 size가 최대한 보존이 된다.\n * 반대로 `ratioWeight`가 `sizeWeight`보다 높으면 아이템들의 비율이 최대한 보존이 된다.\n * @memberof Grid\n * @param {HTMLElement | string} container - A base element for a module 모듈을 적용할 기준 엘리먼트\n * @param {Grid.PackingGrid.PackingGridOptions} options - The option object of the PackingGrid module PackingGrid 모듈의 옵션 객체\n */\n@GetterSetter\nexport class PackingGrid extends Grid {\n public static propertyTypes = {\n ...Grid.propertyTypes,\n aspectRatio: PROPERTY_TYPE.RENDER_PROPERTY,\n sizeWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n ratioWeight: PROPERTY_TYPE.RENDER_PROPERTY,\n weightPriority: PROPERTY_TYPE.RENDER_PROPERTY,\n };\n public static defaultOptions: Required = {\n ...Grid.defaultOptions,\n aspectRatio: 1,\n sizeWeight: 1,\n ratioWeight: 1,\n weightPriority: \"custom\",\n };\n\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const { aspectRatio, gap } = this.options;\n const containerInlineSize = this.getContainerInlineSize();\n const containerContentSize = containerInlineSize / aspectRatio;\n const prevOutline = outline.length ? outline : [0];\n const startPoint = direction === \"end\"\n ? Math.max(...prevOutline)\n : Math.min(...prevOutline) - containerContentSize - gap;\n const endPoint = startPoint + containerContentSize + gap;\n const container = new BoxModel({});\n\n items.forEach((item) => {\n const model = new BoxModel({\n inlineSize: item.orgInlineSize,\n contentSize: item.orgContentSize,\n orgInlineSize: item.orgInlineSize,\n orgContentSize: item.orgContentSize,\n });\n\n this._findBestFitArea(container, model);\n container.push(model);\n container.scaleTo(containerInlineSize + gap, containerContentSize + gap);\n });\n items.forEach((item, i) => {\n const boxItem = container.items[i];\n const inlineSize = boxItem.inlineSize - gap;\n const contentSize = boxItem.contentSize - gap;\n const contentPos = startPoint + boxItem.contentPos;\n const inlinePos = boxItem.inlinePos;\n\n item.setCSSGridRect({\n inlinePos,\n contentPos,\n inlineSize,\n contentSize,\n });\n });\n\n return {\n start: [startPoint],\n end: [endPoint],\n };\n }\n private _findBestFitArea(container: BoxModel, item: BoxModel) {\n if (container.getRatio() === 0) { // 아이템 최초 삽입시 전체영역 지정\n container.orgInlineSize = item.inlineSize;\n container.orgContentSize = item.contentSize;\n container.inlineSize = item.inlineSize;\n container.contentSize = item.contentSize;\n return;\n }\n\n let bestFitArea!: BoxModel;\n let minCost = Infinity;\n let isContentDirection = false;\n const itemFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const containerFitSize = {\n inlineSize: 0,\n contentSize: 0,\n };\n const sizeWeight = this._getWeight(\"size\");\n const ratioWeight = this._getWeight(\"ratio\");\n\n container.items.forEach((child) => {\n const containerSizeCost = getCost(child.getOrgSizeWeight(), child.getSize()) * sizeWeight;\n const containerRatioCost = getCost(child.getOrgRatio(), child.getRatio()) * ratioWeight;\n const inlineSize = child.inlineSize;\n const contentSize = child.contentSize;\n for (let i = 0; i < 2; ++i) {\n let itemInlineSize;\n let itemContentSize;\n let containerInlineSize;\n let containerContentSize;\n\n if (i === 0) {\n // add item to content pos (top, bottom)\n itemInlineSize = inlineSize;\n itemContentSize = contentSize * (item.contentSize / (child.orgContentSize + item.contentSize));\n containerInlineSize = inlineSize;\n containerContentSize = contentSize - itemContentSize;\n } else {\n // add item to inline pos (left, right)\n itemContentSize = contentSize;\n itemInlineSize = inlineSize * (item.inlineSize / (child.orgInlineSize + item.inlineSize));\n containerContentSize = contentSize;\n containerInlineSize = inlineSize - itemInlineSize;\n }\n\n const itemSize = itemInlineSize * itemContentSize;\n const itemRatio = itemInlineSize / itemContentSize;\n const containerSize = containerInlineSize * containerContentSize;\n const containerRatio = containerContentSize / containerContentSize;\n\n let cost = getCost(item.getSize(), itemSize) * sizeWeight;\n cost += getCost(item.getRatio(), itemRatio) * ratioWeight;\n cost += getCost(child.getOrgSizeWeight(), containerSize) * sizeWeight - containerSizeCost;\n cost += getCost(child.getOrgRatio(), containerRatio) * ratioWeight - containerRatioCost;\n\n if (cost === Math.min(cost, minCost)) {\n minCost = cost;\n bestFitArea = child;\n isContentDirection = (i === 0);\n itemFitSize.inlineSize = itemInlineSize;\n itemFitSize.contentSize = itemContentSize;\n containerFitSize.inlineSize = containerInlineSize;\n containerFitSize.contentSize = containerContentSize;\n }\n }\n });\n\n fitArea(item, bestFitArea, itemFitSize, containerFitSize, isContentDirection);\n }\n private _getWeight(type: \"size\" | \"ratio\"): number {\n const options = this.options;\n const weightPriority = options.weightPriority;\n\n if (weightPriority === type) {\n return 100;\n } else if (weightPriority === \"custom\") {\n return options[`${type}Weight`];\n }\n return 1;\n }\n}\n\nexport interface PackingGrid extends Properties {\n}\n\n\n/**\n * The aspect ratio (inlineSize / contentSize) of the container with items. (default: 1)\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). (default: 1)\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * aspectRatio: 1,\n * });\n *\n * grid.aspectRatio = 1.5;\n */\n\n/**\n * The priority that determines the weight of the item. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight)\n * item's weight = item's ratio(inlineSize / contentSize) change * `ratioWeight` + size(inlineSize * contentSize) change * `sizeWeight`.\n * @ko 아이템의 가중치를 결정하는 우선수치. (default: \"custom\"), \"size\" = (sizeWieght: 2, ratioWeight: 1), \"ratio\" = (sizeWeight: 1, ratioWeight; 2), \"custom\" = (set sizeWeight, ratioWeight). 아이템의 가중치 = ratio(inlineSize / contentSize)의 변화량 * `ratioWeight` + size(inlineSize * contentSize)의 변화량 * `sizeWeight`.\n * @name Grid.PackingGrid#weightPriority\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"weightPriority\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * weightPriority: \"custom\",\n * sizeWeight: 1,\n * ratioWeight: 1,\n * });\n *\n * grid.weightPriority = \"size\";\n * // or\n * grid.weightPriority = \"ratio\";\n */\n\n/**\n * The size weight when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 사이즈 가중치. (default: 1)\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * sizeWeight: 1,\n * });\n *\n * grid.sizeWeight = 10;\n */\n\n\n/**\n * The weight to keep ratio when placing items. (default: 1)\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. (default: 1)\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @example\n * import { PackingGrid } from \"@egjs/grid\";\n *\n * const grid = new PackingGrid(container, {\n * ratioWeight: 1,\n * });\n *\n * grid.ratioWeight = 10;\n */\n","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Grid, * as modules from \"./index\";\n\nfor (const name in modules) {\n (Grid as any)[name] = (modules as any)[name];\n}\nexport default Grid;\n"],"names":["PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","DEFAULT_GRID_OPTIONS","horizontal","useTransform","percentage","isEqualSize","isConstantSize","gap","attributePrefix","resizeDebounce","maxResizeDebounce","autoResize","preserveUIOnDestroy","defaultDirection","externalContainerManager","externalItemRenderer","renderOnPropertyChange","useFit","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","container","options","_init","this","setRect","width","offsetWidth","height","offsetHeight","rect","status","setContentSize","getContentSize","size","sizeName","style","preserveUI","cssText","orgCSSText","window","getComputedStyle","position","isObject","val","GetterSetter","component","name","prototype","propertyTypes","shouldRender","Object","defineProperty","enumerable","configurable","get","set","value","scheduleRender","withMethods","methods","memberName","forEach","_i","args","result","_a","range","length","arr","i","push","getRangeCost","valueRange","Math","max","withGridMethods","initialRect","items","item","_this","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","indexOf","posPercetage","sizePercetage","orgRect","element","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","attributes","dataAttributes","attribute","replace","all","letter","toUpperCase","getDataAttributes","cssTexts","posName","obj","cssRect","_b","getInlineSize","keys","filter","key","map","join","itemStatus","data","UNCHECKED","gridRect","names","containerElement","_super","start","end","clearTimeout","_resizeTimer","_maxResizeDebounceTimer","renderItems","useResize","setTimeout","_onResize","constructor","defaultOptions","document","querySelector","containerManager","ContainerManager","itemRenderer","ItemRenderer","__extends","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","checkReady","_clearRenderTimer","getItems","syncElements","_resizeContainer","updateItems","getStatus","prevInlineSize","setStatus","_renderComplete","mounted","updated","isResize","destroy","removeEventListener","_scheduleResize","_im","moreUpdated","ImReady","prefix","on","e","readyItems","isPreReadyOver","trigger","target","update","check","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","direction","prevOutline","outline","nextOutlines","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","endPoint","startPoint","resize","setContainerRect","getRect","addEventListener","Grid","Component","getColumnPoint","columnIndex","columnCount","pointCaculationName","_calculateColumnSize","_calculateColumn","point_1","column","_column","columnSize","_columnSize","align","columnSizeRatio","columnSizeOption","outlineLength","itemsLength","alignPoses","_getAlignPoses","isEndDirection","nearestCalculationName","pointCalculationName","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","indexCaculationName","points","nextEndColumnIndex","nextColumnIndex","cssInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","floor","getContainerInlineSize","items_1","columnOption","containerSize","indexes","offset","dist","countDist","totalColumnSize","MasonryGrid","find_path","graph","s","d","predecessors","nodes","u","reverse","extract_shortest_path_from_predecessor_list","costs","closest","cost_of_s_to_u","adjacent_nodes","cost_of_s_to_u_plus_cost_of_e","cost_of_s_to_v","open","BinaryHeap","x","cost","v","pop","msg","Error","single_source_shortest_paths","scoreFunction","content","bubbleUp","sinkDown","_n","n","parentN","parent","elemScore","child1Score","child2N","child1N","swap","child1","child2","getExpectedColumnSize","rowSize","orgInlineSize","orgContentSize","inlineOffset","parseFloat","gridData","contentOffset","rowRange","path","_getRowPath","_getPath","_setStyle","maintainedTarget","widthOffset","clientWidth","scrollWidth","heightOffset","clientHeight","scrollHeight","columnRange","_getColumnRange","_getRowRange","pathLink","_getRowLink","currentNode","node","currentLink","minColumn","minRow","maxRow","lastNode","pathLength","lastCost","abs","_getCost","isOver","_searchRowLink","nextLink","links","nextNode","nextCost","sort","a","b","aIsOver","containerInlineSize","ratioSum","inlineSum","maintainedRatio","reduce","sum","j","lineItems","_getExpectedRowSize","_getSizeRange","minSize","maxSize","isCroppedSize","expectedInlineSize","_getExpectedInlineSize","pow","isFinite","columnRangeOption","nodeKey","results","displayedRow","sizeRange","groups","path1","path2","splitItems","displayedSize","groupItems","rowIndex","allGap","scale","prevItem","setCSSGridRect","JustifiedGrid","Infinity","getMaxPoint","maxPoint","getOutlineDist","useFrameFill","minPoint","minEndPoint","maxStartPoint","frameDist","outlineIndex","startPos","endPos","fillOutlines","frame","_getFrame","frameInlineSize","frameContentSize","frameRects","getRectSize","rectInlineSize","rectContentSize","frameOutline","rectsLength","startIndex","rectIndex","_c","frameRectContentPos","frameRectInlinePos","frameRectContentSize","frameRectInlineSize","isDirectionEnd","gridOutline","outlineDist","rectSizeOption","rectSizeValue","rects","passMap","y1","x1","type","_findRect","x2","y2","y","FrameGrid","rectSize","boxStatus","scaleX","scaleY","getCost","originLength","aspectRatio","containerContentSize","BoxModel","model","_findBestFitArea","scaleTo","boxItem","getRatio","bestFitArea","itemFitSize","containerFitSize","isContentDirection","minCost","sizeWeight","_getWeight","ratioWeight","child","containerSizeCost","getOrgSizeWeight","getSize","containerRatioCost","getOrgRatio","itemInlineSize","itemContentSize","itemSize","itemRatio","containerRatio","weightPriority","PackingGrid","modules"],"mappings":";;;;;;;;wgEA0BYA,EAIAC,EAKAC,oyDA5BCC,EAA8C,CACzDC,YAAY,EACZC,cAAc,EACdC,YAAY,EACZC,aAAa,EACbC,gBAAgB,EAChBC,IAAK,EACLC,gBAAiB,aACjBC,eAAgB,IAChBC,kBAAmB,EACnBC,YAAY,EACZC,qBAAqB,EACrBC,iBAAkB,MAClBC,yBAA0B,KAC1BC,qBAAsB,KACtBC,wBAAwB,EACxBC,QAAQ,IAGEnB,EAAAA,EAAAA,gCAEVA,0CAEUC,EAAAA,EAAAA,kCAEVA,6BACAA,0BAEUC,EAAAA,EAAAA,sCAEVA,mCACAA,yBAGK,IAAMkB,EAAsB,CACjCX,IAAKT,EAAcqB,gBACnBN,iBAAkBf,EAAcsB,SAChCJ,uBAAwBlB,EAAcsB,SACtCR,oBAAqBd,EAAcsB,SACnCH,OAAQnB,EAAcsB,UAGXC,EAAe,CAC1B,eACA,cACA,WACA,WACA,cACA,yBACA,uBAQWC,EAAa,CACxBpB,WAAY,CACVqB,UAAW,MACXC,WAAY,OACZC,WAAY,SACZC,YAAa,SAEfC,SAAU,CACRJ,UAAW,OACXC,WAAY,MACZC,WAAY,QACZC,YAAa,mCCrDOE,EAAwBC,kBAAxBD,OACfC,WACH3B,WAAYD,EAAqBC,YAC9B2B,Q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ACYma,IAAoBzP,kMXjBN,CACzB,iBACA,8BYtDF,IAAWxK,MAAQka,GAChB1P,GAAaxK,IAASka,GAAgBla"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 65d015b..07c4405 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@egjs/grid", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 764c23d..7fe9012 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/grid", - "version": "1.3.0-snapshot", + "version": "1.3.1", "description": "A component that can arrange items according to the type of grids", "main": "dist/grid.cjs.js", "module": "dist/grid.esm.js", diff --git a/packages/ngx-grid/projects/ngx-grid/package-lock.json b/packages/ngx-grid/projects/ngx-grid/package-lock.json index 84e37d6..8bf4e21 100644 --- a/packages/ngx-grid/projects/ngx-grid/package-lock.json +++ b/packages/ngx-grid/projects/ngx-grid/package-lock.json @@ -1,6 +1,6 @@ { "name": "@egjs/ngx-grid", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -18,9 +18,9 @@ "integrity": "sha512-Hus9GMXOVfHBzyumyeRL1TkN60LhGen+e9FpqXqbS9jA9hDYEE1AH3ulahbBGhRdMs4uXYl3hRnB5kGZRb9n7Q==" }, "@egjs/grid": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.0.tgz", - "integrity": "sha512-Mhq+d2mErG3j7kIzPLR5p9qVID1VenFpaj8ijTibc8DNdjSb5TJG2AugyjeaO8wvaRC9v0Z/lAb0RMoETbCCgg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.1.tgz", + "integrity": "sha512-AAZgGBt0tbDD/ctRITKFvlUo6kx5p/p7nCakAgHGOkEJJJOKDmiuHV/2VKyr32508yy605OQHOljeonnWermNA==", "requires": { "@egjs/children-differ": "^1.0.1", "@egjs/component": "^3.0.0", diff --git a/packages/ngx-grid/projects/ngx-grid/package.json b/packages/ngx-grid/projects/ngx-grid/package.json index 75d1c66..e33976c 100644 --- a/packages/ngx-grid/projects/ngx-grid/package.json +++ b/packages/ngx-grid/projects/ngx-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/ngx-grid", - "version": "1.3.0", + "version": "1.3.1", "description": "An Angular component that can arrange items according to the type of grids", "author": { "name": "NAVER Corp." @@ -30,7 +30,7 @@ "@angular/core": ">=8.0.0" }, "dependencies": { - "@egjs/grid": "~1.3.0", + "@egjs/grid": "~1.3.1", "tslib": "^2.0.0" } } diff --git a/packages/react-grid/package-lock.json b/packages/react-grid/package-lock.json index ae23b29..0578b59 100644 --- a/packages/react-grid/package-lock.json +++ b/packages/react-grid/package-lock.json @@ -1,6 +1,6 @@ { "name": "@egjs/react-grid", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1455,9 +1455,9 @@ "integrity": "sha512-Hus9GMXOVfHBzyumyeRL1TkN60LhGen+e9FpqXqbS9jA9hDYEE1AH3ulahbBGhRdMs4uXYl3hRnB5kGZRb9n7Q==" }, "@egjs/grid": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.0.tgz", - "integrity": "sha512-Mhq+d2mErG3j7kIzPLR5p9qVID1VenFpaj8ijTibc8DNdjSb5TJG2AugyjeaO8wvaRC9v0Z/lAb0RMoETbCCgg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.1.tgz", + "integrity": "sha512-AAZgGBt0tbDD/ctRITKFvlUo6kx5p/p7nCakAgHGOkEJJJOKDmiuHV/2VKyr32508yy605OQHOljeonnWermNA==", "requires": { "@egjs/children-differ": "^1.0.1", "@egjs/component": "^3.0.0", diff --git a/packages/react-grid/package.json b/packages/react-grid/package.json index 57e91f6..87c803c 100644 --- a/packages/react-grid/package.json +++ b/packages/react-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/react-grid", - "version": "1.3.0", + "version": "1.3.1", "description": "A React component that can arrange items according to the type of grids", "types": "declaration/index.d.ts", "main": "dist/grid.cjs.js", @@ -36,7 +36,7 @@ "layout" ], "dependencies": { - "@egjs/grid": "~1.3.0" + "@egjs/grid": "~1.3.1" }, "devDependencies": { "@codeceptjs/configure": "^0.6.2", diff --git a/packages/svelte-grid/package-lock.json b/packages/svelte-grid/package-lock.json index a5a954e..68dc7c0 100644 --- a/packages/svelte-grid/package-lock.json +++ b/packages/svelte-grid/package-lock.json @@ -1,6 +1,6 @@ { "name": "@egjs/svelte-grid", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1292,9 +1292,9 @@ "integrity": "sha512-Hus9GMXOVfHBzyumyeRL1TkN60LhGen+e9FpqXqbS9jA9hDYEE1AH3ulahbBGhRdMs4uXYl3hRnB5kGZRb9n7Q==" }, "@egjs/grid": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.0.tgz", - "integrity": "sha512-Mhq+d2mErG3j7kIzPLR5p9qVID1VenFpaj8ijTibc8DNdjSb5TJG2AugyjeaO8wvaRC9v0Z/lAb0RMoETbCCgg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.1.tgz", + "integrity": "sha512-AAZgGBt0tbDD/ctRITKFvlUo6kx5p/p7nCakAgHGOkEJJJOKDmiuHV/2VKyr32508yy605OQHOljeonnWermNA==", "requires": { "@egjs/children-differ": "^1.0.1", "@egjs/component": "^3.0.0", diff --git a/packages/svelte-grid/package.json b/packages/svelte-grid/package.json index 9bea125..35bf291 100644 --- a/packages/svelte-grid/package.json +++ b/packages/svelte-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/svelte-grid", - "version": "1.3.0", + "version": "1.3.1", "description": "A Svelte component that can arrange items according to the type of grids", "sideEffects": false, "types": "src/index.d.ts", @@ -68,6 +68,6 @@ "typescript": "^4.0.0" }, "dependencies": { - "@egjs/grid": "~1.3.0" + "@egjs/grid": "~1.3.1" } } diff --git a/packages/vue-grid/package-lock.json b/packages/vue-grid/package-lock.json index bf29592..3b969e8 100644 --- a/packages/vue-grid/package-lock.json +++ b/packages/vue-grid/package-lock.json @@ -1,6 +1,6 @@ { "name": "@egjs/vue-grid", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1347,9 +1347,9 @@ "integrity": "sha512-Hus9GMXOVfHBzyumyeRL1TkN60LhGen+e9FpqXqbS9jA9hDYEE1AH3ulahbBGhRdMs4uXYl3hRnB5kGZRb9n7Q==" }, "@egjs/grid": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.0.tgz", - "integrity": "sha512-Mhq+d2mErG3j7kIzPLR5p9qVID1VenFpaj8ijTibc8DNdjSb5TJG2AugyjeaO8wvaRC9v0Z/lAb0RMoETbCCgg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.3.1.tgz", + "integrity": "sha512-AAZgGBt0tbDD/ctRITKFvlUo6kx5p/p7nCakAgHGOkEJJJOKDmiuHV/2VKyr32508yy605OQHOljeonnWermNA==", "requires": { "@egjs/children-differ": "^1.0.1", "@egjs/component": "^3.0.0", diff --git a/packages/vue-grid/package.json b/packages/vue-grid/package.json index c815281..7916650 100644 --- a/packages/vue-grid/package.json +++ b/packages/vue-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/vue-grid", - "version": "1.3.0", + "version": "1.3.1", "description": "A Vue component that can arrange items according to the type of grids", "sideEffects": false, "types": "declaration/index.d.ts", @@ -42,7 +42,7 @@ "layout" ], "dependencies": { - "@egjs/grid": "~1.3.0" + "@egjs/grid": "~1.3.1" }, "devDependencies": { "@babel/core": "^7.12.10",