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..bef929c --- /dev/null +++ b/dist/grid.cjs.js @@ -0,0 +1,3539 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.9.0 +*/ +'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; +} +function __spreadArray(to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; + + return to; +} + +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, + outlineLength: 0, + outlineSize: 0, + useRoundedSize: true, + useResizeObserver: false +}; +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, + outlineSize: PROPERTY_TYPE.RENDER_PROPERTY, + outlineLength: PROPERTY_TYPE.RENDER_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" + } +}; + +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 descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {}; + + var getter = descriptor.get || function get() { + return this.options[name]; + }; + + var setter = descriptor.set || function set(value) { + var options = this.options; + var prevValue = options[name]; + + if (prevValue === value) { + return; + } + + options[name] = value; + + if (shouldRender && options.renderOnPropertyChange) { + this.scheduleRender(); + } + }; + + var attributes = { + enumerable: true, + configurable: true, + get: getter, + set: setter + }; + 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 ResizeWatcher = +/*#__PURE__*/ +function () { + function ResizeWatcher(container, options) { + var _this = this; + + if (options === void 0) { + options = {}; + } + + this._resizeTimer = 0; + this._maxResizeDebounceTimer = 0; + this.rect = { + width: 0, + height: 0 + }; + + this._onResize = function () { + clearTimeout(_this._resizeTimer); + clearTimeout(_this._maxResizeDebounceTimer); + _this._maxResizeDebounceTimer = 0; + _this._resizeTimer = 0; + var watchDirection = _this._options.watchDirection; + var prevRect = _this.rect; + + _this.resize(); + + var rect = _this.rect; + var isWatchWidth = watchDirection === "box" || watchDirection === "width"; + var isWatchHeight = watchDirection === "box" || watchDirection === "height"; + var isResize = !watchDirection || isWatchWidth && prevRect.width !== rect.width || isWatchHeight && prevRect.height !== rect.height; + + if (isResize) { + _this._emitter.trigger("resize"); + } + }; + + 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({ + resizeDebounce: 100, + maxResizeDebounce: 0, + useResizeObserver: false, + useWindowResize: true, + watchDirection: false, + rectBox: "content-box" + }, options); + this.container = isString(container) ? document.querySelector(container) : container; + + this._init(); + } + + var __proto = ResizeWatcher.prototype; + + __proto.getRect = function () { + return this.rect; + }; + + __proto.setRect = function (rect) { + this.rect = __assign({}, rect); + }; + + __proto.resize = function () { + var container = this.container; + this.setRect(this._options.rectBox === "border-box" ? { + width: container.offsetWidth, + height: container.offsetHeight + } : { + width: container.clientWidth, + height: container.clientHeight + }); + }; + + __proto.listen = function (callback) { + this._emitter.on("resize", callback); + + return this; + }; + + __proto.destroy = function () { + var _a; + + (_a = this._observer) === null || _a === void 0 ? void 0 : _a.disconnect(); + + if (this._options.useWindowResize) { + window.removeEventListener("reisze", this._onResize); + } + }; + + __proto._init = function () { + var container = this.container; + var options = this._options; + this._emitter = new Component(); + + if (options.useResizeObserver && !!window.ResizeObserver) { + this._observer = new window.ResizeObserver(this._scheduleResize); + + this._observer.observe(container, { + box: options.rectBox + }); + } + + if (options.useWindowResize) { + window.addEventListener("resize", this._scheduleResize); + } + + this.resize(); + }; + + return ResizeWatcher; +}(); + +var ContainerManager = +/*#__PURE__*/ +function (_super) { + __extends(ContainerManager, _super); + + function ContainerManager(container, options) { + var _this = _super.call(this) || this; + + _this.container = container; + + _this._onResize = function () { + _this.trigger("resize"); + }; + + _this.options = __assign({ + horizontal: DEFAULT_GRID_OPTIONS.horizontal, + autoResize: DEFAULT_GRID_OPTIONS.autoResize, + resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce, + maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce, + useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver + }, options); + + _this._init(); + + return _this; + } + + var __proto = ContainerManager.prototype; + + __proto.resize = function () { + var container = this.container; + this.setRect({ + width: container.clientWidth, + height: container.clientHeight + }); + }; + + __proto.getRect = function () { + return this._watcher.getRect(); + }; + + __proto.setRect = function (rect) { + this._watcher.setRect(rect); + }; + + __proto.getInlineSize = function () { + return this.getRect()[this._names.inlineSize]; + }; + + __proto.getContentSize = function () { + return this.getRect()[this._names.contentSize]; + }; + + __proto.getStatus = function () { + return { + rect: this._watcher.getRect() + }; + }; + + __proto.setStatus = function (status) { + this.setRect(status.rect); + this.setContentSize(this.getContentSize()); + }; + + __proto.setContentSize = function (size) { + var _a; + + var sizeName = this.options.horizontal ? "width" : "height"; + this.setRect(__assign(__assign({}, this.getRect()), (_a = {}, _a[sizeName] = size, _a))); + this.container.style[sizeName] = size + "px"; + }; + + __proto.destroy = function (options) { + if (options === void 0) { + options = {}; + } + + this._watcher.destroy(); + + 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"; + } + + var options = this.options; + this._watcher = new ResizeWatcher(container, { + useWindowResize: options.autoResize, + useResizeObserver: options.useResizeObserver, + resizeDebounce: options.resizeDebounce, + maxResizeDebounce: options.maxResizeDebounce, + watchDirection: options.useResizeObserver ? this._names.inlineSize : false + }).listen(this._onResize); + }; + + Object.defineProperty(__proto, "_names", { + get: function () { + return RECT_NAMES[this.options.horizontal ? "horizontal" : "vertical"]; + }, + enumerable: false, + configurable: true + }); + return ContainerManager; +}(Component); + +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, + useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize + }, 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, + useRoundedSize = _a.useRoundedSize; + 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: 0, + height: 0 + }; + + if (useRoundedSize) { + rect.width = element.offsetWidth; + rect.height = element.offsetHeight; + } else { + var clientRect = element.getBoundingClientRect(); + rect.width = clientRect.width; + rect.height = clientRect.height; + } + } + + if (!item.isFirstUpdate || !hasOrgSize) { + 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; + this.isUpdate = false; + this.hasTransition = false; + this.transitionDuration = ""; + 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 : "", + gridData: {} + }, 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 name = this._names.inlineSize; + return this.orgRect[name] || this.rect[name]; + }, + 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 name = this._names.contentSize; + return this.orgRect[name] || this.rect[name]; + }, + 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 () { + return this.rect[this._names.inlineSize]; + }, + 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 () { + return this.rect[this._names.contentSize]; + }, + 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 () { + return this.cssRect[this._names.inlineSize]; + }, + set: function (inlineSize) { + this.cssRect[this._names.inlineSize] = 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 () { + return this.cssRect[this._names.contentSize]; + }, + set: function (contentSize) { + this.cssRect[this._names.contentSize] = 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 () { + return this.cssRect[this._names.inlinePos]; + }, + set: function (inlinePos) { + this.cssRect[this._names.inlinePos] = 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 () { + return this.cssRect[this._names.contentPos]; + }, + set: function (contentPos) { + this.cssRect[this._names.contentPos] = contentPos; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedInlineSize", { + /** + * Calculated size in the direction of the inline applied to the grid. "width" if horizontal is false, "height" otherwise. + * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#computedInlineSize + */ + get: function () { + var name = this._names.inlineSize; + return this.cssRect[name] || this.rect[name] || this.orgRect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedContentSize", { + /** + * Calculated size in the direction of the content applied to the grid. "height" if horizontal is false, "width" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#computedContentSize + */ + get: function () { + var name = this._names.contentSize; + return this.cssRect[name] || this.rect[name] || this.orgRect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedInlinePos", { + /** + * Calculated position in the direction of the inline applied to the grid. "left" if horizontal is false, "top" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 "left", 아니면 "top". + * @member Grid.GridItem#computedInlinePos + */ + get: function () { + var _a; + + var name = this._names.inlinePos; + return (_a = this.cssRect[name]) !== null && _a !== void 0 ? _a : this.rect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedContentPos", { + /** + * Calculated position in the direction of the content applied to the grid. "top" if horizontal is false, "left" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 "top", 아니면 "left". + * @member Grid.GridItem#computedContentPos + */ + get: function () { + var _a; + + var name = this._names.contentPos; + return (_a = this.cssRect[name]) !== null && _a !== void 0 ? _a : this.rect[name]; + }, + 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, + gridData: this.gridData, + data: this.data + }; + }; + /** + * Returns minimized status of the item. + * @ko 아이템의 간소화된 상태를 반환한다. + */ + + + __proto.getMinimizedStatus = function () { + var status = { + orgRect: this.orgRect, + rect: this.rect, + cssRect: this.cssRect, + attributes: this.attributes, + gridData: this.gridData + }; + + var _a = this, + key = _a.key, + mountState = _a.mountState, + updateState = _a.updateState, + isFirstUpdate = _a.isFirstUpdate, + orgCSSText = _a.orgCSSText; + + if (typeof key !== "undefined") { + status.key = key; + } + + if (mountState !== MOUNT_STATE.UNCHECKED) { + status.mountState = mountState; + } + + if (updateState !== UPDATE_STATE.NEED_UPDATE) { + status.updateState = updateState; + } + + if (isFirstUpdate) { + status.isFirstUpdate = true; + } + + if (orgCSSText) { + status.orgCSSText = orgCSSText; + } + + return status; + }; + + Object.defineProperty(__proto, "_names", { + get: function () { + return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical; + }, + enumerable: false, + configurable: true + }); + 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._onResize = function () { + _this._renderItems({ + useResize: true + }, true); + }; + + _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, + resizeDebounce = _a.resizeDebounce, + maxResizeDebounce = _a.maxResizeDebounce, + autoResize = _a.autoResize, + useRoundedSize = _a.useRoundedSize, + useResizeObserver = _a.useResizeObserver; // TODO: 테스트용 설정 + + _this.containerManager = externalContainerManager || new ContainerManager(_this.containerElement, { + horizontal: horizontal, + resizeDebounce: resizeDebounce, + maxResizeDebounce: maxResizeDebounce, + autoResize: autoResize, + useResizeObserver: useResizeObserver + }).on("resize", _this._onResize); + _this.itemRenderer = externalItemRenderer || new ItemRenderer({ + useTransform: useTransform, + isEqualSize: isEqualSize, + isConstantSize: isConstantSize, + percentage: percentage, + useRoundedSize: useRoundedSize + }); + + _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 = {}; + } + + var useOrgResize = options.useOrgResize; + items.forEach(function (item) { + if (useOrgResize) { + var orgRect = item.orgRect; + orgRect.width = 0; + orgRect.height = 0; + } + + 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 + * ```js + * 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._renderItems(options); + + return this; + }; + /** + * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method. + * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false) + */ + + + __proto.getStatus = function (minimize) { + return { + outlines: this.outlines, + items: this.items.map(function (item) { + return minimize ? item.getMinimizedStatus() : 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({ + direction: _this.defaultDirection, + mounted: _this.items, + updated: [], + isResize: false + }); + }); + } + + return this; + }; + /** + * Get the inline size corresponding to outline. + * @ko outline에 해당하는 inline 사이즈를 구한다. + * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + + + __proto.getComputedOutlineSize = function (items) { + if (items === void 0) { + items = this.items; + } + + return this.options.outlineSize || this.getContainerInlineSize(); + }; + /** + * Get the length corresponding to outline. + * @ko outline에 해당하는 length를 가져온다. + * @param items - Items to get outline length. outline length를 구하기 위한 아이템들. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + + + __proto.getComputedOutlineLength = function (items) { + if (items === void 0) { + items = this.items; + } + + return this.options.outlineLength || 1; + }; + /** + * 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; + } + }); + } + + (_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) { + var _a; + + return ((_a = item.element) === null || _a === void 0 ? void 0 : _a.parentNode) && item.updateState !== UPDATE_STATE.UPDATED; + }); + var mounted = updated.filter(function (item) { + return item.mountState !== MOUNT_STATE.MOUNTED; + }); + var moreUpdated = []; + mounted.filter(function (item) { + if (item.hasTransition) { + return true; + } else { + var element = item.element; + var transitionDuration = parseFloat(getComputedStyle(element).transitionDuration); + + if (transitionDuration > 0) { + item.hasTransition = true; + item.transitionDuration = element.style.transitionDuration; + return true; + } + } + + return false; + }).forEach(function (item) { + item.element.style.transitionDuration = "0s"; + }); + (_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 () { + // reset org size + updated.forEach(function (item) { + var hasOrgSize = item.orgRect.width && item.orgRect.height; + var hasCSSSize = item.cssRect.width || item.cssRect.height; + + if (!hasOrgSize && hasCSSSize) { + item.element.style.cssText = item.orgCSSText; + } + }); + + _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 이벤트에 전달되는 데이터 객체 + * @example + * ```js + * 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: __spreadArray([], prevOutline), + end: __spreadArray([], prevOutline) + }; + updated.forEach(function (item) { + item.isUpdate = true; + }); + + if (items.length) { + nextOutlines = this.applyGrid(this.items, direction, prevOutline); + } + + updated.forEach(function (item) { + item.isUpdate = false; + }); + this.setOutlines(nextOutlines); + this.fitOutlines(); + this.itemRenderer.renderItems(this.items); + + this._refreshContainerContentSize(); + + var transitionMounted = mounted.filter(function (item) { + return item.hasTransition; + }); + + if (transitionMounted.length) { + this.containerManager.resize(); + transitionMounted.forEach(function (item) { + var element = item.element; + element.style.transitionDuration = item.transitionDuration; + }); + } + + this._renderComplete({ + direction: direction, + 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 이벤트에 전달되는 데이터 객체 + * @example + * ```js + * 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(); + }; + + __proto._renderItems = function (options, isTrusted) { + if (options === void 0) { + options = {}; + } + + this._clearRenderTimer(); + + var isResize = options.useResize || options.useOrgResize; + + if (isResize && !isTrusted) { + // Resize container + // isTrusted has already been resized internally. + this._resizeContainer(); + } + + if (!this.getItems().length && this.getChildren().length) { + this.syncElements(options); + } else if (isResize) { + // Update all items + this.updateItems(this.items, options); + } else { + // Update only items that need to be updated. + this.checkReady(options); + } + }; + + 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"]} + * @default 0 + * @example + * ```js + * 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"]} + * @default "end" + * @example + * ```js + * 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"]} + * @default true + * @example + * ```js + * 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"]} + * @default false + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * preserveUIOnDestroy: false, + * }); + * + * grid.preserveUIOnDestroy = true; + * ``` + */ + +/** + * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid. + * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다. + * @name Grid#outlineLength + * @type {$ts:Grid.GridOptions["outlineLength"]} + * @default 0 + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * outlineLength: 0, + * outlineSize: 0, + * }); + * + * grid.outlineLength = 3; + * ``` + */ + +/** + * The size of the outline. If the outline size is 0, it is calculated according to the grid type. + * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. + * @name Grid#outlineSize + * @type {$ts:Grid.GridOptions["outlineSize"]} + * @default 0 + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * outlineLength: 0, + * outlineSize: 0, + * }); + * + * grid.outlineSize = 300; + * ``` + */ + +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() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = MasonryGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var columnSize = this.getComputedOutlineSize(items); + var column = this.getComputedOutlineLength(items); + var _a = this.options, + gap = _a.gap, + align = _a.align, + columnSizeRatio = _a.columnSizeRatio; + var outlineLength = outline.length; + var itemsLength = items.length; + + var alignPoses = this._getAlignPoses(column, columnSize); + + 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[pointCalculationName].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 contentSize = item.contentSize; + var columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((item.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); // stretch mode or data-grid-column > "1" + + if (columnAttribute > 0 && columnCount > 1 || isStretch) { + item.cssInlineSize = (columnCount - 1) * columnDist + columnSize; + } + + if (columnSizeRatio > 0) { + contentSize = item.computedInlineSize / 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.getComputedOutlineSize = function (items) { + if (items === void 0) { + items = this.items; + } + + var _a = this.options, + gap = _a.gap, + align = _a.align; + var columnSizeOption = this.columnSize || this.outlineSize; + var column = this.column || this.outlineLength || 1; + var columnSize = 0; + + if (align === "stretch") { + columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap; + } else if (columnSizeOption) { + columnSize = columnSizeOption; + } else if (items.length) { + var checkedItem = items[0]; + + 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.inlineSize || attributes.column || attributes.maxColumnCount) { + continue; + } + + checkedItem = item; + break; + } + + var inlineSize = checkedItem.inlineSize || 0; + columnSize = inlineSize; + } else { + columnSize = this.getContainerInlineSize(); + } + + return columnSize || 0; + }; + + __proto.getComputedOutlineLength = function (items) { + if (items === void 0) { + items = this.items; + } + + var gap = this.gap; + var columnOption = this.column || this.outlineLength; + var columnCalculationThreshold = this.columnCalculationThreshold; + var column = 1; + + if (columnOption) { + column = columnOption; + } else { + var columnSize = this.getComputedOutlineSize(items); + column = Math.min(items.length, Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize - columnCalculationThreshold + gap)))); + } + + return column; + }; + + __proto._getAlignPoses = function (column, columnSize) { + 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, + columnCalculationThreshold: PROPERTY_TYPE.RENDER_PROPERTY + }); + MasonryGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + align: "justify", + column: 0, + columnSize: 0, + columnSizeRatio: 0, + columnCalculationThreshold: 0.5 + }); + 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") + * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. ("start", "center", "end", "justify", "stretch") + * @name Grid.MasonryGrid#align + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["align"]} + * @default "justify" + * @example + * ```js + * 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. Can be used instead of outlineLength. + * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다. + * @name Grid.MasonryGrid#column + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["column"]} + * @default 0 + * @example + * ```js + * 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. Can be used instead of outlineSize. + * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다. + * @name Grid.MasonryGrid#columnSize + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSize"]} + * @default 0 + * @example + * ```js + * 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. + * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. + * @name Grid.MasonryGrid#columnSizeRatio + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSizeRatio"]} + * @default 0 + * @example + * ```js + * 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 rowSize; + } + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset); + return ratio * (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 _a = this.options, + attributePrefix = _a.attributePrefix, + horizontal = _a.horizontal; + items.forEach(function (item) { + if (!item.isUpdate) { + return; + } + + var element = item.element; + var attributes = item.attributes; + var gridData = item.gridData; + var inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0; + var contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0; + + if (element && !("inlineOffset" in attributes) && !("contentOffset" in attributes) && item.mountState === MOUNT_STATE.MOUNTED) { + 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; + }); + 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._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: __spreadArray(__spreadArray([], 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: __spreadArray(__spreadArray([], 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) { + ratioSum += 1; + return; + } // sum((expect - offset) * ratio) = container inline size + + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var maintainedRatio = contentSize <= contentOffset ? 1 : (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] // endPoint - height = startPoint + + }; + }; + + __proto.getComputedOutlineLength = function () { + return 1; + }; + + __proto.getComputedOutlineSize = function () { + return this.getContainerInlineSize(); + }; + + __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. + * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. + * @name Grid.JustifiedGrid#columnRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["columnRange"]} + * @default [1, 8] + * @example + * ```js + * 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. + * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. + * @name Grid.JustifiedGrid#rowRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["rowRange"]} + * @default 0 + * @example + * ```js + * 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. + * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. + * @name Grid.JustifiedGrid#sizeRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["sizeRange"]} + * @default [0, Infinity] + * @example + * ```js + * 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. + * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. + * @name Grid.JustifiedGrid#displayedRow + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["displayedRow"]} + * @default -1 + * @example + * ```js + * 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. + * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. + * @name Grid.JustifiedGrid#isCroppedSize + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["isCroppedSize"]} + * @default false + * @example + * ```js + * 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.length ? outline : [0]; + + 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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill) : getOutlinePoint(endOutline, gridOutline, 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.getComputedOutlineLength = function () { + var frame = this.options.frame; + return frame.length ? frame[0].length : 0; + }; + + __proto.getComputedOutlineSize = function () { + var _a = this.options, + gap = _a.gap, + rectSizeOption = _a.rectSize; + + if (typeof rectSizeOption === "object") { + return rectSizeOption.inlineSize; + } + + return rectSizeOption || (this.getContainerInlineSize() + gap) / this.getComputedOutlineLength() - gap; + }; + + __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. + * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. + * @name Grid.FrameGrid#frame + * @type {$ts:Grid.FrameGrid.FrameGridOptions["frame"]} + * @default [] + * @example + * ```js + * 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. + * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. + * @name Grid.FrameGrid#useFrameFill + * @type {$ts:Grid.FrameGrid.FrameGridOptions["useFrameFill"]} + * @default true + * @example + * ```js + * 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 + * ```js + * 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.getComputedOutlineLength = function () { + return 1; + }; + + __proto.getComputedOutlineSize = function () { + return this.getContainerInlineSize(); + }; + + __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. + * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). + * @name Grid.PackingGrid#aspectRatio + * @type {$ts:Grid.PackingGrid.PackingGridOptions["aspectRatio"]} + * @default 1 + * @example + * ```js + * 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. "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 아이템의 가중치를 결정하는 우선수치. "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"]} + * @default "custom" + * @example + * ```js + * 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. + * @ko 아이템들을 배치하는데 사이즈 가중치. + * @name Grid.PackingGrid#sizeWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["sizeWeight"]} + * @default 1 + * @example + * ```js + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * sizeWeight: 1, + * }); + * + * grid.sizeWeight = 10; + * ``` + */ + +/** + * The weight to keep ratio when placing items. + * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. + * @name Grid.PackingGrid#ratioWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["ratioWeight"]} + * @default 1 + * @example + * ```js + * 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, + ItemRenderer: ItemRenderer, + GridItem: GridItem, + ContainerManager: ContainerManager, + ResizeWatcher: ResizeWatcher, + 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..d9bd164 --- /dev/null +++ b/dist/grid.cjs.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.cjs.js","sources":["../src/consts.ts","../src/utils.ts","../src/ResizeWatcher.ts","../src/ContainerManager.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 outlineLength: 0,\n outlineSize: 0,\n useRoundedSize: true,\n useResizeObserver: false,\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 outlineSize: PROPERTY_TYPE.RENDER_PROPERTY,\n outlineLength: PROPERTY_TYPE.RENDER_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 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\n const descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {};\n\n const getter = descriptor.get || function get(this: Grid) {\n return this.options[name];\n };\n const setter = descriptor.set || function 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 const attributes: Record = {\n enumerable: true,\n configurable: true,\n get: getter,\n set: setter,\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","import Component from \"@egjs/component\";\nimport { SizeRect } from \"./types\";\nimport { isString } from \"./utils\";\n\nexport interface ResizeWatherOptions {\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n useWindowResize?: boolean;\n watchDirection?: \"width\" | \"height\" | \"box\" | false;\n rectBox?: \"border-box\" | \"content-box\";\n}\n\nexport class ResizeWatcher {\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _emitter: Component<{ resize: void }>;\n private _observer: ResizeObserver | null;\n protected container: HTMLElement;\n protected rect: SizeRect = { width: 0, height: 0 };\n private _options!: Required;\n\n constructor(container: HTMLElement | string, options: ResizeWatherOptions = {}) {\n this._options = {\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n useResizeObserver: false,\n useWindowResize: true,\n watchDirection: false,\n rectBox: \"content-box\",\n ...options,\n };\n\n this.container = isString(container) ? document.querySelector(container)! : container;\n this._init();\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: SizeRect) {\n this.rect = { ...rect };\n }\n public resize() {\n const container = this.container;\n\n this.setRect(this._options.rectBox === \"border-box\" ? {\n width: container.offsetWidth,\n height: container.offsetHeight,\n } : {\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public listen(callback: () => void) {\n this._emitter.on(\"resize\", callback);\n return this;\n }\n public destroy() {\n this._observer?.disconnect();\n if (this._options.useWindowResize) {\n window.removeEventListener(\"reisze\", this._onResize);\n }\n }\n private _init() {\n const container = this.container;\n const options = this._options;\n\n this._emitter = new Component();\n if (options.useResizeObserver && !!window.ResizeObserver) {\n this._observer = new window.ResizeObserver(this._scheduleResize);\n this._observer.observe(container, {\n box: options.rectBox,\n });\n }\n if (options.useWindowResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n this.resize();\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n\n const watchDirection = this._options.watchDirection;\n const prevRect = this.rect;\n this.resize();\n const rect = this.rect;\n const isWatchWidth = watchDirection === \"box\" || watchDirection === \"width\";\n const isWatchHeight = watchDirection === \"box\" || watchDirection === \"height\";\n const isResize = !watchDirection\n || (isWatchWidth && prevRect.width !== rect.width)\n || (isWatchHeight && prevRect.height !== rect.height);\n\n if (isResize) {\n this._emitter.trigger(\"resize\");\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","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DestroyOptions, SizeRect } from \"./types\";\nimport { ResizeWatcher } from \"./ResizeWatcher\";\nimport { DEFAULT_GRID_OPTIONS, RECT_NAMES } from \"./consts\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n autoResize?: boolean;\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: SizeRect;\n}\nexport interface ContainerManagerEvents {\n resize: void;\n}\nexport class ContainerManager extends Component {\n protected options: Required;\n protected orgCSSText: string;\n private _watcher: ResizeWatcher;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n super();\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n autoResize: DEFAULT_GRID_OPTIONS.autoResize,\n resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce,\n maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce,\n useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public getRect() {\n return this._watcher.getRect();\n }\n public setRect(rect: SizeRect) {\n this._watcher.setRect(rect);\n }\n public getInlineSize() {\n return this.getRect()[this._names.inlineSize];\n }\n public getContentSize() {\n return this.getRect()[this._names.contentSize];\n }\n public getStatus() {\n return { rect: this._watcher.getRect() };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.setRect(status.rect);\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.setRect({\n ...this.getRect(),\n [sizeName]: size,\n });\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n this._watcher.destroy();\n\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 const options = this.options;\n\n this._watcher = new ResizeWatcher(container, {\n useWindowResize: options.autoResize,\n useResizeObserver: options.useResizeObserver,\n resizeDebounce: options.resizeDebounce,\n maxResizeDebounce: options.maxResizeDebounce,\n watchDirection: options.useResizeObserver ? this._names.inlineSize : false,\n }).listen(this._onResize);\n }\n private _onResize = () => {\n this.trigger(\"resize\");\n }\n private get _names() {\n return RECT_NAMES[this.options.horizontal ? \"horizontal\" : \"vertical\"];\n }\n}\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 useRoundedSize?: 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 useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize,\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, useRoundedSize } = 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: 0,\n height: 0,\n };\n if (useRoundedSize) {\n rect.width = element.offsetWidth;\n rect.height = element.offsetHeight;\n } else {\n const clientRect = element.getBoundingClientRect();\n\n rect.width = clientRect.width;\n rect.height = clientRect.height;\n }\n }\n if (!item.isFirstUpdate || !hasOrgSize) {\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 * @property - Grid ready data for rendering. 렌더링을 하기 위한 grid의 준비 데이터.\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 gridData?: Record;\n}\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n public isUpdate = false;\n public hasTransition = false;\n public transitionDuration = \"\";\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 gridData: {},\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\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 name = this._names.inlineSize;\n\n return this.orgRect[name] || this.rect[name];\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 name = this._names.contentSize;\n\n return this.orgRect[name] || this.rect[name];\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 return this.rect[this._names.inlineSize];\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 return this.rect[this._names.contentSize];\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 return this.cssRect[this._names.inlineSize];\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 return this.cssRect[this._names.contentSize];\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 return this.cssRect[this._names.inlinePos];\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 return this.cssRect[this._names.contentPos];\n }\n public set cssInlinePos(inlinePos: number | undefined) {\n this.cssRect[this._names.inlinePos] = inlinePos;\n }\n public set cssContentPos(contentPos: number | undefined) {\n this.cssRect[this._names.contentPos] = contentPos;\n }\n public set cssInlineSize(inlineSize: number | undefined) {\n this.cssRect[this._names.inlineSize] = inlineSize;\n }\n public set cssContentSize(contentSize: number | undefined) {\n this.cssRect[this._names.contentSize] = contentSize;\n }\n /**\n * Calculated size in the direction of the inline applied to the grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#computedInlineSize\n */\n public get computedInlineSize() {\n const name = this._names.inlineSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated size in the direction of the content applied to the grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#computedContentSize\n */\n public get computedContentSize() {\n const name = this._names.contentSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated position in the direction of the inline applied to the grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#computedInlinePos\n */\n public get computedInlinePos() {\n const name = this._names.inlinePos;\n\n return this.cssRect[name] ?? this.rect[name];\n }\n /**\n * Calculated position in the direction of the content applied to the grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#computedContentPos\n */\n public get computedContentPos() {\n const name = this._names.contentPos;\n\n return this.cssRect[name] ?? this.rect[name];\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 gridData: this.gridData,\n data: this.data,\n };\n }\n /**\n * Returns minimized status of the item.\n * @ko 아이템의 간소화된 상태를 반환한다.\n */\n public getMinimizedStatus(): Partial {\n const status: Partial = {\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n attributes: this.attributes,\n gridData: this.gridData,\n };\n\n const {\n key,\n mountState,\n updateState,\n isFirstUpdate,\n orgCSSText,\n } = this;\n if (typeof key !== \"undefined\") {\n status.key = key;\n }\n if (mountState !== MOUNT_STATE.UNCHECKED) {\n status.mountState = mountState;\n }\n if (updateState !== UPDATE_STATE.NEED_UPDATE) {\n status.updateState = updateState;\n }\n if (isFirstUpdate) {\n status.isFirstUpdate = true;\n }\n if (orgCSSText) {\n status.orgCSSText = orgCSSText;\n }\n return status;\n }\n private get _names() {\n return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical;\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 _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 resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useRoundedSize,\n useResizeObserver,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useResizeObserver,\n }).on(\"resize\", this._onResize);\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n useRoundedSize,\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;\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 const useOrgResize = options.useOrgResize;\n\n items.forEach((item) => {\n if (useOrgResize) {\n const orgRect = item.orgRect;\n\n orgRect.width = 0;\n orgRect.height = 0;\n }\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 * ```js\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 */\n public renderItems(options: RenderOptions = {}) {\n this._renderItems(options);\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 * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false)\n */\n public getStatus(minimize?: boolean): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => minimize ? item.getMinimizedStatus() : 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 direction: this.defaultDirection,\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Get the inline size corresponding to outline.\n * @ko outline에 해당하는 inline 사이즈를 구한다.\n * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineSize(items: GridItem[] = this.items) {\n return this.options.outlineSize! || this.getContainerInlineSize();\n }\n /**\n * Get the length corresponding to outline.\n * @ko outline에 해당하는 length를 가져온다.\n * @param items - Items to get outline length. outline length를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineLength(items: GridItem[] = this.items): number {\n return this.options.outlineLength! || 1;\n }\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\n this._im?.destroy();\n }\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?.parentNode && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n mounted.filter((item) => {\n if (item.hasTransition) {\n return true;\n } else {\n const element = item.element!;\n const transitionDuration = parseFloat(getComputedStyle(element).transitionDuration);\n\n if (transitionDuration > 0) {\n item.hasTransition = true;\n item.transitionDuration = element.style.transitionDuration;\n return true;\n }\n }\n return false;\n }).forEach((item) => {\n item.element!.style.transitionDuration = \"0s\";\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 // reset org size\n updated.forEach((item) => {\n const hasOrgSize = item.orgRect.width && item.orgRect.height;\n const hasCSSSize = item.cssRect.width || item.cssRect.height;\n\n if (!hasOrgSize && hasCSSSize) {\n item.element!.style.cssText = item.orgCSSText;\n }\n });\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 * @example\n * ```js\n * grid.on(\"contentError\", e => {\n * e.update();\n * });\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\n updated.forEach((item) => {\n item.isUpdate = true;\n });\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n updated.forEach((item) => {\n item.isUpdate = false;\n });\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n\n const transitionMounted = mounted.filter((item) => item.hasTransition);\n\n if (transitionMounted.length) {\n this.containerManager.resize();\n transitionMounted.forEach((item) => {\n const element = item.element!;\n\n element.style.transitionDuration = item.transitionDuration;\n });\n }\n this._renderComplete({\n direction,\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 * @example\n * ```js\n * grid.on(\"renderComplete\", e => {\n * console.log(e.mounted, e.updated, e.useResize);\n * });\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 this._renderItems({\n useResize: true,\n }, true);\n }\n private _init() {\n this._resizeContainer();\n }\n private _renderItems(options: RenderOptions = {}, isTrusted?: boolean) {\n this._clearRenderTimer();\n\n const isResize = options.useResize || options.useOrgResize;\n\n\n if (isResize && !isTrusted) {\n // Resize container\n // isTrusted has already been resized internally.\n this._resizeContainer();\n }\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (isResize) {\n // Update all items\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\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 * @default 0\n * @example\n * ```js\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/**\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 * @default \"end\"\n * @example\n * ```js\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/**\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 * @default true\n * @example\n * ```js\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\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 * @default false\n * @example\n * ```js\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\n\n/**\n * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.\n * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineLength\n * @type {$ts:Grid.GridOptions[\"outlineLength\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineLength = 3;\n * ```\n */\n\n\n/**\n * The size of the outline. If the outline size is 0, it is calculated according to the grid type.\n * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineSize\n * @type {$ts:Grid.GridOptions[\"outlineSize\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineSize = 300;\n * ```\n */\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. Can be used instead of outlineLength. (default: 0)열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.(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. Can be used instead of outlineSize. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.(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 * @property - Difference Threshold for Counting Columns. Since offsetSize is calculated by rounding, the number of columns may not be accurate. (default: 1) 칼럼 개수를 계산하기 위한 차이 임계값. offset 사이즈는 반올림으로 게산하기 때문에 정확하지 않을 수 있다. (default: 1)\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n columnCalculationThreshold?: number;\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 * @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 columnCalculationThreshold: 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 columnCalculationThreshold: 0.5,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const columnSize = this.getComputedOutlineSize(items);\n const column = this.getComputedOutlineLength(items);\n\n const {\n gap,\n align,\n columnSizeRatio,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses(column, columnSize);\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[pointCalculationName](...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 contentSize = item.contentSize;\n let columnCount = Math.min(\n column,\n columnAttribute || Math.max(1, Math.ceil((item.inlineSize + gap) / columnDist)),\n );\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 // stretch mode or data-grid-column > \"1\"\n if ((columnAttribute > 0 && columnCount > 1) || isStretch) {\n item.cssInlineSize = (columnCount - 1) * columnDist + columnSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = item.computedInlineSize / 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 public getComputedOutlineSize(items = this.items) {\n const {\n gap,\n align,\n } = this.options;\n const columnSizeOption = this.columnSize || this.outlineSize;\n const column = this.column || this.outlineLength || 1;\n\n let columnSize = 0;\n\n if (align === \"stretch\") {\n columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n columnSize = columnSizeOption;\n } else if (items.length) {\n let checkedItem = items[0];\n\n for (const item of items) {\n const attributes = item.attributes;\n if (\n item.updateState !== UPDATE_STATE.UPDATED\n || !item.inlineSize\n || attributes.column\n || attributes.maxColumnCount\n ) {\n continue;\n }\n checkedItem = item;\n break;\n }\n const inlineSize = checkedItem.inlineSize || 0;\n\n columnSize = inlineSize;\n } else {\n columnSize = this.getContainerInlineSize();\n }\n return columnSize || 0;\n }\n public getComputedOutlineLength(items = this.items) {\n const gap = this.gap;\n const columnOption = this.column || this.outlineLength;\n const columnCalculationThreshold = this.columnCalculationThreshold;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else {\n const columnSize = this.getComputedOutlineSize(items);\n\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap)\n / (columnSize - columnCalculationThreshold + gap))),\n );\n }\n return column;\n }\n private _getAlignPoses(column: number, columnSize: number) {\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\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @default \"justify\"\n * @example\n * ```js\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/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. Can be used instead of outlineLength.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. Can be used instead of outlineSize.\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set.\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @default 0\n * @example\n * ```js\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 */\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 { MOUNT_STATE, PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } 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 rowSize;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n return ratio * (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 {\n attributePrefix,\n horizontal,\n } = this.options;\n\n items.forEach((item) => {\n if (!item.isUpdate) {\n return;\n }\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0;\n\n if (\n element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)\n && item.mountState === MOUNT_STATE.MOUNTED\n ) {\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 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 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 ratioSum += 1;\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 = contentSize <= contentOffset ? 1\n : (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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수.\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @default [1, 8]\n * @example\n * ```js\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/**\n * The minimum and maximum number of rows in a group, 0 is not set.\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다.\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @default 0\n * @example\n * ```js\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/**\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.\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다.\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @default [0, Infinity]\n * @example\n * ```js\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/**\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.\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다.\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @default -1\n * @example\n * ```js\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/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken.\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다.\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @default false\n * @example\n * ```js\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","/**\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.length ? outline : [0];\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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill)\n : getOutlinePoint(endOutline, gridOutline, 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 public getComputedOutlineLength() {\n const frame = this.options.frame;\n\n return frame.length ? frame[0].length : 0;\n }\n public getComputedOutlineSize() {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption.inlineSize;\n }\n return rectSizeOption || ((this.getContainerInlineSize()! + gap) / this.getComputedOutlineLength() - gap);\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.\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다.\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @default []\n * @example\n * ```js\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/**\n * Make sure that the frame can be attached after the previous frame.\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @default true\n * @example\n * ```js\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/**\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 * ```js\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 */\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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize).\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The priority that determines the weight of the item. \"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 아이템의 가중치를 결정하는 우선수치. \"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 * @default \"custom\"\n * @example\n * ```js\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/**\n * The size weight when placing items.\n * @ko 아이템들을 배치하는데 사이즈 가중치.\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The weight to keep ratio when placing items.\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치.\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @default 1\n * @example\n * ```js\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","/**\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\";\nexport * from \"./ItemRenderer\";\nexport * from \"./types\";\nexport * from \"./Grid\";\nexport * from \"./GridItem\";\nexport * from \"./ContainerManager\";\nexport * from \"./ResizeWatcher\";\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","outlineLength","outlineSize","useRoundedSize","useResizeObserver","PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","GRID_EVENTS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","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","descriptor","getOwnPropertyDescriptor","getter","get","options","setter","set","prevValue","scheduleRender","enumerable","configurable","defineProperty","withMethods","methods","memberName","forEach","_i","args","result","_a","range","arr","push","getRangeCost","valueRange","Math","max","withGridMethods","container","width","height","clearTimeout","_this","_resizeTimer","_maxResizeDebounceTimer","watchDirection","_options","prevRect","rect","resize","isWatchWidth","isWatchHeight","isResize","_emitter","trigger","window","setTimeout","_onResize","useWindowResize","rectBox","document","querySelector","_init","setRect","offsetWidth","offsetHeight","clientWidth","clientHeight","callback","on","_observer","disconnect","removeEventListener","Component","ResizeObserver","_scheduleResize","observe","box","addEventListener","__extends","_super","_watcher","getRect","_names","status","setContentSize","getContentSize","size","sizeName","style","destroy","preserveUI","cssText","orgCSSText","getComputedStyle","position","ResizeWatcher","listen","initialRect","items","item","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","posPercetage","sizePercetage","orgRect","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","clientRect","getBoundingClientRect","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","cssRect","cssTexts","_b","posName","getInlineSize","filter","key","map","join","itemStatus","data","UNCHECKED","gridData","gridRect","names","containerElement","start","end","_renderItems","useResize","constructor","defaultOptions","containerManager","ContainerManager","itemRenderer","ItemRenderer","Grid","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","renderItems","useOrgResize","checkReady","minimize","getMinimizedStatus","getStatus","prevInlineSize","setStatus","_renderComplete","direction","mounted","updated","getContainerInlineSize","_im","parentNode","moreUpdated","hasTransition","transitionDuration","parseFloat","ImReady","prefix","e","hasCSSSize","updateItems","readyItems","isPreReadyOver","target","update","check","_clearRenderTimer","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","prevOutline","outline","nextOutlines","isUpdate","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","transitionMounted","endPoint","startPoint","setContainerRect","_resizeContainer","isTrusted","getItems","syncElements","getColumnPoint","columnIndex","columnCount","pointCaculationName","getColumnIndex","nearestCalculationName","indexCaculationName","points","columnSize","getComputedOutlineSize","column","getComputedOutlineLength","align","columnSizeRatio","itemsLength","alignPoses","_getAlignPoses","isEndDirection","pointCalculationName","point_1","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","nextEndColumnIndex","nextColumnIndex","cssInlineSize","computedInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","columnSizeOption","checkedItem","items_1","columnOption","columnCalculationThreshold","floor","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","contentOffset","ratio","maintainedTarget","widthOffset","scrollWidth","heightOffset","scrollHeight","rowRange","_getRowPath","_getPath","_setStyle","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,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id.esm.js new file mode 100644 index 0000000..58e0e92 --- /dev/null +++ b/dist/grid.esm.js @@ -0,0 +1,3504 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.9.0 +*/ +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; +} +function __spreadArray(to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; + + return to; +} + +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, + outlineLength: 0, + outlineSize: 0, + useRoundedSize: true, + useResizeObserver: false +}; +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, + outlineSize: PROPERTY_TYPE.RENDER_PROPERTY, + outlineLength: PROPERTY_TYPE.RENDER_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" + } +}; + +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 descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {}; + + var getter = descriptor.get || function get() { + return this.options[name]; + }; + + var setter = descriptor.set || function set(value) { + var options = this.options; + var prevValue = options[name]; + + if (prevValue === value) { + return; + } + + options[name] = value; + + if (shouldRender && options.renderOnPropertyChange) { + this.scheduleRender(); + } + }; + + var attributes = { + enumerable: true, + configurable: true, + get: getter, + set: setter + }; + 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 ResizeWatcher = +/*#__PURE__*/ +function () { + function ResizeWatcher(container, options) { + var _this = this; + + if (options === void 0) { + options = {}; + } + + this._resizeTimer = 0; + this._maxResizeDebounceTimer = 0; + this.rect = { + width: 0, + height: 0 + }; + + this._onResize = function () { + clearTimeout(_this._resizeTimer); + clearTimeout(_this._maxResizeDebounceTimer); + _this._maxResizeDebounceTimer = 0; + _this._resizeTimer = 0; + var watchDirection = _this._options.watchDirection; + var prevRect = _this.rect; + + _this.resize(); + + var rect = _this.rect; + var isWatchWidth = watchDirection === "box" || watchDirection === "width"; + var isWatchHeight = watchDirection === "box" || watchDirection === "height"; + var isResize = !watchDirection || isWatchWidth && prevRect.width !== rect.width || isWatchHeight && prevRect.height !== rect.height; + + if (isResize) { + _this._emitter.trigger("resize"); + } + }; + + 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({ + resizeDebounce: 100, + maxResizeDebounce: 0, + useResizeObserver: false, + useWindowResize: true, + watchDirection: false, + rectBox: "content-box" + }, options); + this.container = isString(container) ? document.querySelector(container) : container; + + this._init(); + } + + var __proto = ResizeWatcher.prototype; + + __proto.getRect = function () { + return this.rect; + }; + + __proto.setRect = function (rect) { + this.rect = __assign({}, rect); + }; + + __proto.resize = function () { + var container = this.container; + this.setRect(this._options.rectBox === "border-box" ? { + width: container.offsetWidth, + height: container.offsetHeight + } : { + width: container.clientWidth, + height: container.clientHeight + }); + }; + + __proto.listen = function (callback) { + this._emitter.on("resize", callback); + + return this; + }; + + __proto.destroy = function () { + var _a; + + (_a = this._observer) === null || _a === void 0 ? void 0 : _a.disconnect(); + + if (this._options.useWindowResize) { + window.removeEventListener("reisze", this._onResize); + } + }; + + __proto._init = function () { + var container = this.container; + var options = this._options; + this._emitter = new Component(); + + if (options.useResizeObserver && !!window.ResizeObserver) { + this._observer = new window.ResizeObserver(this._scheduleResize); + + this._observer.observe(container, { + box: options.rectBox + }); + } + + if (options.useWindowResize) { + window.addEventListener("resize", this._scheduleResize); + } + + this.resize(); + }; + + return ResizeWatcher; +}(); + +var ContainerManager = +/*#__PURE__*/ +function (_super) { + __extends(ContainerManager, _super); + + function ContainerManager(container, options) { + var _this = _super.call(this) || this; + + _this.container = container; + + _this._onResize = function () { + _this.trigger("resize"); + }; + + _this.options = __assign({ + horizontal: DEFAULT_GRID_OPTIONS.horizontal, + autoResize: DEFAULT_GRID_OPTIONS.autoResize, + resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce, + maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce, + useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver + }, options); + + _this._init(); + + return _this; + } + + var __proto = ContainerManager.prototype; + + __proto.resize = function () { + var container = this.container; + this.setRect({ + width: container.clientWidth, + height: container.clientHeight + }); + }; + + __proto.getRect = function () { + return this._watcher.getRect(); + }; + + __proto.setRect = function (rect) { + this._watcher.setRect(rect); + }; + + __proto.getInlineSize = function () { + return this.getRect()[this._names.inlineSize]; + }; + + __proto.getContentSize = function () { + return this.getRect()[this._names.contentSize]; + }; + + __proto.getStatus = function () { + return { + rect: this._watcher.getRect() + }; + }; + + __proto.setStatus = function (status) { + this.setRect(status.rect); + this.setContentSize(this.getContentSize()); + }; + + __proto.setContentSize = function (size) { + var _a; + + var sizeName = this.options.horizontal ? "width" : "height"; + this.setRect(__assign(__assign({}, this.getRect()), (_a = {}, _a[sizeName] = size, _a))); + this.container.style[sizeName] = size + "px"; + }; + + __proto.destroy = function (options) { + if (options === void 0) { + options = {}; + } + + this._watcher.destroy(); + + 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"; + } + + var options = this.options; + this._watcher = new ResizeWatcher(container, { + useWindowResize: options.autoResize, + useResizeObserver: options.useResizeObserver, + resizeDebounce: options.resizeDebounce, + maxResizeDebounce: options.maxResizeDebounce, + watchDirection: options.useResizeObserver ? this._names.inlineSize : false + }).listen(this._onResize); + }; + + Object.defineProperty(__proto, "_names", { + get: function () { + return RECT_NAMES[this.options.horizontal ? "horizontal" : "vertical"]; + }, + enumerable: false, + configurable: true + }); + return ContainerManager; +}(Component); + +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, + useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize + }, 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, + useRoundedSize = _a.useRoundedSize; + 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: 0, + height: 0 + }; + + if (useRoundedSize) { + rect.width = element.offsetWidth; + rect.height = element.offsetHeight; + } else { + var clientRect = element.getBoundingClientRect(); + rect.width = clientRect.width; + rect.height = clientRect.height; + } + } + + if (!item.isFirstUpdate || !hasOrgSize) { + 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; + this.isUpdate = false; + this.hasTransition = false; + this.transitionDuration = ""; + 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 : "", + gridData: {} + }, 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 name = this._names.inlineSize; + return this.orgRect[name] || this.rect[name]; + }, + 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 name = this._names.contentSize; + return this.orgRect[name] || this.rect[name]; + }, + 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 () { + return this.rect[this._names.inlineSize]; + }, + 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 () { + return this.rect[this._names.contentSize]; + }, + 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 () { + return this.cssRect[this._names.inlineSize]; + }, + set: function (inlineSize) { + this.cssRect[this._names.inlineSize] = 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 () { + return this.cssRect[this._names.contentSize]; + }, + set: function (contentSize) { + this.cssRect[this._names.contentSize] = 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 () { + return this.cssRect[this._names.inlinePos]; + }, + set: function (inlinePos) { + this.cssRect[this._names.inlinePos] = 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 () { + return this.cssRect[this._names.contentPos]; + }, + set: function (contentPos) { + this.cssRect[this._names.contentPos] = contentPos; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedInlineSize", { + /** + * Calculated size in the direction of the inline applied to the grid. "width" if horizontal is false, "height" otherwise. + * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#computedInlineSize + */ + get: function () { + var name = this._names.inlineSize; + return this.cssRect[name] || this.rect[name] || this.orgRect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedContentSize", { + /** + * Calculated size in the direction of the content applied to the grid. "height" if horizontal is false, "width" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#computedContentSize + */ + get: function () { + var name = this._names.contentSize; + return this.cssRect[name] || this.rect[name] || this.orgRect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedInlinePos", { + /** + * Calculated position in the direction of the inline applied to the grid. "left" if horizontal is false, "top" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 "left", 아니면 "top". + * @member Grid.GridItem#computedInlinePos + */ + get: function () { + var _a; + + var name = this._names.inlinePos; + return (_a = this.cssRect[name]) !== null && _a !== void 0 ? _a : this.rect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedContentPos", { + /** + * Calculated position in the direction of the content applied to the grid. "top" if horizontal is false, "left" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 "top", 아니면 "left". + * @member Grid.GridItem#computedContentPos + */ + get: function () { + var _a; + + var name = this._names.contentPos; + return (_a = this.cssRect[name]) !== null && _a !== void 0 ? _a : this.rect[name]; + }, + 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, + gridData: this.gridData, + data: this.data + }; + }; + /** + * Returns minimized status of the item. + * @ko 아이템의 간소화된 상태를 반환한다. + */ + + + __proto.getMinimizedStatus = function () { + var status = { + orgRect: this.orgRect, + rect: this.rect, + cssRect: this.cssRect, + attributes: this.attributes, + gridData: this.gridData + }; + + var _a = this, + key = _a.key, + mountState = _a.mountState, + updateState = _a.updateState, + isFirstUpdate = _a.isFirstUpdate, + orgCSSText = _a.orgCSSText; + + if (typeof key !== "undefined") { + status.key = key; + } + + if (mountState !== MOUNT_STATE.UNCHECKED) { + status.mountState = mountState; + } + + if (updateState !== UPDATE_STATE.NEED_UPDATE) { + status.updateState = updateState; + } + + if (isFirstUpdate) { + status.isFirstUpdate = true; + } + + if (orgCSSText) { + status.orgCSSText = orgCSSText; + } + + return status; + }; + + Object.defineProperty(__proto, "_names", { + get: function () { + return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical; + }, + enumerable: false, + configurable: true + }); + 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._onResize = function () { + _this._renderItems({ + useResize: true + }, true); + }; + + _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, + resizeDebounce = _a.resizeDebounce, + maxResizeDebounce = _a.maxResizeDebounce, + autoResize = _a.autoResize, + useRoundedSize = _a.useRoundedSize, + useResizeObserver = _a.useResizeObserver; // TODO: 테스트용 설정 + + _this.containerManager = externalContainerManager || new ContainerManager(_this.containerElement, { + horizontal: horizontal, + resizeDebounce: resizeDebounce, + maxResizeDebounce: maxResizeDebounce, + autoResize: autoResize, + useResizeObserver: useResizeObserver + }).on("resize", _this._onResize); + _this.itemRenderer = externalItemRenderer || new ItemRenderer({ + useTransform: useTransform, + isEqualSize: isEqualSize, + isConstantSize: isConstantSize, + percentage: percentage, + useRoundedSize: useRoundedSize + }); + + _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 = {}; + } + + var useOrgResize = options.useOrgResize; + items.forEach(function (item) { + if (useOrgResize) { + var orgRect = item.orgRect; + orgRect.width = 0; + orgRect.height = 0; + } + + 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 + * ```js + * 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._renderItems(options); + + return this; + }; + /** + * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method. + * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false) + */ + + + __proto.getStatus = function (minimize) { + return { + outlines: this.outlines, + items: this.items.map(function (item) { + return minimize ? item.getMinimizedStatus() : 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({ + direction: _this.defaultDirection, + mounted: _this.items, + updated: [], + isResize: false + }); + }); + } + + return this; + }; + /** + * Get the inline size corresponding to outline. + * @ko outline에 해당하는 inline 사이즈를 구한다. + * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + + + __proto.getComputedOutlineSize = function (items) { + if (items === void 0) { + items = this.items; + } + + return this.options.outlineSize || this.getContainerInlineSize(); + }; + /** + * Get the length corresponding to outline. + * @ko outline에 해당하는 length를 가져온다. + * @param items - Items to get outline length. outline length를 구하기 위한 아이템들. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + + + __proto.getComputedOutlineLength = function (items) { + if (items === void 0) { + items = this.items; + } + + return this.options.outlineLength || 1; + }; + /** + * 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; + } + }); + } + + (_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) { + var _a; + + return ((_a = item.element) === null || _a === void 0 ? void 0 : _a.parentNode) && item.updateState !== UPDATE_STATE.UPDATED; + }); + var mounted = updated.filter(function (item) { + return item.mountState !== MOUNT_STATE.MOUNTED; + }); + var moreUpdated = []; + mounted.filter(function (item) { + if (item.hasTransition) { + return true; + } else { + var element = item.element; + var transitionDuration = parseFloat(getComputedStyle(element).transitionDuration); + + if (transitionDuration > 0) { + item.hasTransition = true; + item.transitionDuration = element.style.transitionDuration; + return true; + } + } + + return false; + }).forEach(function (item) { + item.element.style.transitionDuration = "0s"; + }); + (_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 () { + // reset org size + updated.forEach(function (item) { + var hasOrgSize = item.orgRect.width && item.orgRect.height; + var hasCSSSize = item.cssRect.width || item.cssRect.height; + + if (!hasOrgSize && hasCSSSize) { + item.element.style.cssText = item.orgCSSText; + } + }); + + _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 이벤트에 전달되는 데이터 객체 + * @example + * ```js + * 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: __spreadArray([], prevOutline), + end: __spreadArray([], prevOutline) + }; + updated.forEach(function (item) { + item.isUpdate = true; + }); + + if (items.length) { + nextOutlines = this.applyGrid(this.items, direction, prevOutline); + } + + updated.forEach(function (item) { + item.isUpdate = false; + }); + this.setOutlines(nextOutlines); + this.fitOutlines(); + this.itemRenderer.renderItems(this.items); + + this._refreshContainerContentSize(); + + var transitionMounted = mounted.filter(function (item) { + return item.hasTransition; + }); + + if (transitionMounted.length) { + this.containerManager.resize(); + transitionMounted.forEach(function (item) { + var element = item.element; + element.style.transitionDuration = item.transitionDuration; + }); + } + + this._renderComplete({ + direction: direction, + 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 이벤트에 전달되는 데이터 객체 + * @example + * ```js + * 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(); + }; + + __proto._renderItems = function (options, isTrusted) { + if (options === void 0) { + options = {}; + } + + this._clearRenderTimer(); + + var isResize = options.useResize || options.useOrgResize; + + if (isResize && !isTrusted) { + // Resize container + // isTrusted has already been resized internally. + this._resizeContainer(); + } + + if (!this.getItems().length && this.getChildren().length) { + this.syncElements(options); + } else if (isResize) { + // Update all items + this.updateItems(this.items, options); + } else { + // Update only items that need to be updated. + this.checkReady(options); + } + }; + + 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"]} + * @default 0 + * @example + * ```js + * 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"]} + * @default "end" + * @example + * ```js + * 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"]} + * @default true + * @example + * ```js + * 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"]} + * @default false + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * preserveUIOnDestroy: false, + * }); + * + * grid.preserveUIOnDestroy = true; + * ``` + */ + +/** + * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid. + * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다. + * @name Grid#outlineLength + * @type {$ts:Grid.GridOptions["outlineLength"]} + * @default 0 + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * outlineLength: 0, + * outlineSize: 0, + * }); + * + * grid.outlineLength = 3; + * ``` + */ + +/** + * The size of the outline. If the outline size is 0, it is calculated according to the grid type. + * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. + * @name Grid#outlineSize + * @type {$ts:Grid.GridOptions["outlineSize"]} + * @default 0 + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * outlineLength: 0, + * outlineSize: 0, + * }); + * + * grid.outlineSize = 300; + * ``` + */ + +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() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = MasonryGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var columnSize = this.getComputedOutlineSize(items); + var column = this.getComputedOutlineLength(items); + var _a = this.options, + gap = _a.gap, + align = _a.align, + columnSizeRatio = _a.columnSizeRatio; + var outlineLength = outline.length; + var itemsLength = items.length; + + var alignPoses = this._getAlignPoses(column, columnSize); + + 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[pointCalculationName].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 contentSize = item.contentSize; + var columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((item.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); // stretch mode or data-grid-column > "1" + + if (columnAttribute > 0 && columnCount > 1 || isStretch) { + item.cssInlineSize = (columnCount - 1) * columnDist + columnSize; + } + + if (columnSizeRatio > 0) { + contentSize = item.computedInlineSize / 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.getComputedOutlineSize = function (items) { + if (items === void 0) { + items = this.items; + } + + var _a = this.options, + gap = _a.gap, + align = _a.align; + var columnSizeOption = this.columnSize || this.outlineSize; + var column = this.column || this.outlineLength || 1; + var columnSize = 0; + + if (align === "stretch") { + columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap; + } else if (columnSizeOption) { + columnSize = columnSizeOption; + } else if (items.length) { + var checkedItem = items[0]; + + 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.inlineSize || attributes.column || attributes.maxColumnCount) { + continue; + } + + checkedItem = item; + break; + } + + var inlineSize = checkedItem.inlineSize || 0; + columnSize = inlineSize; + } else { + columnSize = this.getContainerInlineSize(); + } + + return columnSize || 0; + }; + + __proto.getComputedOutlineLength = function (items) { + if (items === void 0) { + items = this.items; + } + + var gap = this.gap; + var columnOption = this.column || this.outlineLength; + var columnCalculationThreshold = this.columnCalculationThreshold; + var column = 1; + + if (columnOption) { + column = columnOption; + } else { + var columnSize = this.getComputedOutlineSize(items); + column = Math.min(items.length, Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize - columnCalculationThreshold + gap)))); + } + + return column; + }; + + __proto._getAlignPoses = function (column, columnSize) { + 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, + columnCalculationThreshold: PROPERTY_TYPE.RENDER_PROPERTY + }); + MasonryGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + align: "justify", + column: 0, + columnSize: 0, + columnSizeRatio: 0, + columnCalculationThreshold: 0.5 + }); + 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") + * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. ("start", "center", "end", "justify", "stretch") + * @name Grid.MasonryGrid#align + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["align"]} + * @default "justify" + * @example + * ```js + * 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. Can be used instead of outlineLength. + * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다. + * @name Grid.MasonryGrid#column + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["column"]} + * @default 0 + * @example + * ```js + * 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. Can be used instead of outlineSize. + * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다. + * @name Grid.MasonryGrid#columnSize + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSize"]} + * @default 0 + * @example + * ```js + * 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. + * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. + * @name Grid.MasonryGrid#columnSizeRatio + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSizeRatio"]} + * @default 0 + * @example + * ```js + * 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 rowSize; + } + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset); + return ratio * (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 _a = this.options, + attributePrefix = _a.attributePrefix, + horizontal = _a.horizontal; + items.forEach(function (item) { + if (!item.isUpdate) { + return; + } + + var element = item.element; + var attributes = item.attributes; + var gridData = item.gridData; + var inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0; + var contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0; + + if (element && !("inlineOffset" in attributes) && !("contentOffset" in attributes) && item.mountState === MOUNT_STATE.MOUNTED) { + 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; + }); + 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._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: __spreadArray(__spreadArray([], 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: __spreadArray(__spreadArray([], 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) { + ratioSum += 1; + return; + } // sum((expect - offset) * ratio) = container inline size + + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var maintainedRatio = contentSize <= contentOffset ? 1 : (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] // endPoint - height = startPoint + + }; + }; + + __proto.getComputedOutlineLength = function () { + return 1; + }; + + __proto.getComputedOutlineSize = function () { + return this.getContainerInlineSize(); + }; + + __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. + * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. + * @name Grid.JustifiedGrid#columnRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["columnRange"]} + * @default [1, 8] + * @example + * ```js + * 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. + * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. + * @name Grid.JustifiedGrid#rowRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["rowRange"]} + * @default 0 + * @example + * ```js + * 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. + * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. + * @name Grid.JustifiedGrid#sizeRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["sizeRange"]} + * @default [0, Infinity] + * @example + * ```js + * 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. + * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. + * @name Grid.JustifiedGrid#displayedRow + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["displayedRow"]} + * @default -1 + * @example + * ```js + * 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. + * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. + * @name Grid.JustifiedGrid#isCroppedSize + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["isCroppedSize"]} + * @default false + * @example + * ```js + * 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.length ? outline : [0]; + + 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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill) : getOutlinePoint(endOutline, gridOutline, 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.getComputedOutlineLength = function () { + var frame = this.options.frame; + return frame.length ? frame[0].length : 0; + }; + + __proto.getComputedOutlineSize = function () { + var _a = this.options, + gap = _a.gap, + rectSizeOption = _a.rectSize; + + if (typeof rectSizeOption === "object") { + return rectSizeOption.inlineSize; + } + + return rectSizeOption || (this.getContainerInlineSize() + gap) / this.getComputedOutlineLength() - gap; + }; + + __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. + * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. + * @name Grid.FrameGrid#frame + * @type {$ts:Grid.FrameGrid.FrameGridOptions["frame"]} + * @default [] + * @example + * ```js + * 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. + * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. + * @name Grid.FrameGrid#useFrameFill + * @type {$ts:Grid.FrameGrid.FrameGridOptions["useFrameFill"]} + * @default true + * @example + * ```js + * 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 + * ```js + * 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.getComputedOutlineLength = function () { + return 1; + }; + + __proto.getComputedOutlineSize = function () { + return this.getContainerInlineSize(); + }; + + __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. + * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). + * @name Grid.PackingGrid#aspectRatio + * @type {$ts:Grid.PackingGrid.PackingGridOptions["aspectRatio"]} + * @default 1 + * @example + * ```js + * 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. "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 아이템의 가중치를 결정하는 우선수치. "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"]} + * @default "custom" + * @example + * ```js + * 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. + * @ko 아이템들을 배치하는데 사이즈 가중치. + * @name Grid.PackingGrid#sizeWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["sizeWeight"]} + * @default 1 + * @example + * ```js + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * sizeWeight: 1, + * }); + * + * grid.sizeWeight = 10; + * ``` + */ + +/** + * The weight to keep ratio when placing items. + * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. + * @name Grid.PackingGrid#ratioWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["ratioWeight"]} + * @default 1 + * @example + * ```js + * 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, ItemRenderer, JustifiedGrid, MOUNT_STATE, MasonryGrid, PROPERTY_TYPE, PackingGrid, RECT_NAMES, ResizeWatcher, 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..bf48fd8 --- /dev/null +++ b/dist/grid.esm.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.esm.js","sources":["../src/consts.ts","../src/utils.ts","../src/ResizeWatcher.ts","../src/ContainerManager.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 outlineLength: 0,\n outlineSize: 0,\n useRoundedSize: true,\n useResizeObserver: false,\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 outlineSize: PROPERTY_TYPE.RENDER_PROPERTY,\n outlineLength: PROPERTY_TYPE.RENDER_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 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\n const descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {};\n\n const getter = descriptor.get || function get(this: Grid) {\n return this.options[name];\n };\n const setter = descriptor.set || function 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 const attributes: Record = {\n enumerable: true,\n configurable: true,\n get: getter,\n set: setter,\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","import Component from \"@egjs/component\";\nimport { SizeRect } from \"./types\";\nimport { isString } from \"./utils\";\n\nexport interface ResizeWatherOptions {\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n useWindowResize?: boolean;\n watchDirection?: \"width\" | \"height\" | \"box\" | false;\n rectBox?: \"border-box\" | \"content-box\";\n}\n\nexport class ResizeWatcher {\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _emitter: Component<{ resize: void }>;\n private _observer: ResizeObserver | null;\n protected container: HTMLElement;\n protected rect: SizeRect = { width: 0, height: 0 };\n private _options!: Required;\n\n constructor(container: HTMLElement | string, options: ResizeWatherOptions = {}) {\n this._options = {\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n useResizeObserver: false,\n useWindowResize: true,\n watchDirection: false,\n rectBox: \"content-box\",\n ...options,\n };\n\n this.container = isString(container) ? document.querySelector(container)! : container;\n this._init();\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: SizeRect) {\n this.rect = { ...rect };\n }\n public resize() {\n const container = this.container;\n\n this.setRect(this._options.rectBox === \"border-box\" ? {\n width: container.offsetWidth,\n height: container.offsetHeight,\n } : {\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public listen(callback: () => void) {\n this._emitter.on(\"resize\", callback);\n return this;\n }\n public destroy() {\n this._observer?.disconnect();\n if (this._options.useWindowResize) {\n window.removeEventListener(\"reisze\", this._onResize);\n }\n }\n private _init() {\n const container = this.container;\n const options = this._options;\n\n this._emitter = new Component();\n if (options.useResizeObserver && !!window.ResizeObserver) {\n this._observer = new window.ResizeObserver(this._scheduleResize);\n this._observer.observe(container, {\n box: options.rectBox,\n });\n }\n if (options.useWindowResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n this.resize();\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n\n const watchDirection = this._options.watchDirection;\n const prevRect = this.rect;\n this.resize();\n const rect = this.rect;\n const isWatchWidth = watchDirection === \"box\" || watchDirection === \"width\";\n const isWatchHeight = watchDirection === \"box\" || watchDirection === \"height\";\n const isResize = !watchDirection\n || (isWatchWidth && prevRect.width !== rect.width)\n || (isWatchHeight && prevRect.height !== rect.height);\n\n if (isResize) {\n this._emitter.trigger(\"resize\");\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","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DestroyOptions, SizeRect } from \"./types\";\nimport { ResizeWatcher } from \"./ResizeWatcher\";\nimport { DEFAULT_GRID_OPTIONS, RECT_NAMES } from \"./consts\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n autoResize?: boolean;\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: SizeRect;\n}\nexport interface ContainerManagerEvents {\n resize: void;\n}\nexport class ContainerManager extends Component {\n protected options: Required;\n protected orgCSSText: string;\n private _watcher: ResizeWatcher;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n super();\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n autoResize: DEFAULT_GRID_OPTIONS.autoResize,\n resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce,\n maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce,\n useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public getRect() {\n return this._watcher.getRect();\n }\n public setRect(rect: SizeRect) {\n this._watcher.setRect(rect);\n }\n public getInlineSize() {\n return this.getRect()[this._names.inlineSize];\n }\n public getContentSize() {\n return this.getRect()[this._names.contentSize];\n }\n public getStatus() {\n return { rect: this._watcher.getRect() };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.setRect(status.rect);\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.setRect({\n ...this.getRect(),\n [sizeName]: size,\n });\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n this._watcher.destroy();\n\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 const options = this.options;\n\n this._watcher = new ResizeWatcher(container, {\n useWindowResize: options.autoResize,\n useResizeObserver: options.useResizeObserver,\n resizeDebounce: options.resizeDebounce,\n maxResizeDebounce: options.maxResizeDebounce,\n watchDirection: options.useResizeObserver ? this._names.inlineSize : false,\n }).listen(this._onResize);\n }\n private _onResize = () => {\n this.trigger(\"resize\");\n }\n private get _names() {\n return RECT_NAMES[this.options.horizontal ? \"horizontal\" : \"vertical\"];\n }\n}\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 useRoundedSize?: 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 useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize,\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, useRoundedSize } = 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: 0,\n height: 0,\n };\n if (useRoundedSize) {\n rect.width = element.offsetWidth;\n rect.height = element.offsetHeight;\n } else {\n const clientRect = element.getBoundingClientRect();\n\n rect.width = clientRect.width;\n rect.height = clientRect.height;\n }\n }\n if (!item.isFirstUpdate || !hasOrgSize) {\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 * @property - Grid ready data for rendering. 렌더링을 하기 위한 grid의 준비 데이터.\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 gridData?: Record;\n}\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n public isUpdate = false;\n public hasTransition = false;\n public transitionDuration = \"\";\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 gridData: {},\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\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 name = this._names.inlineSize;\n\n return this.orgRect[name] || this.rect[name];\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 name = this._names.contentSize;\n\n return this.orgRect[name] || this.rect[name];\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 return this.rect[this._names.inlineSize];\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 return this.rect[this._names.contentSize];\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 return this.cssRect[this._names.inlineSize];\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 return this.cssRect[this._names.contentSize];\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 return this.cssRect[this._names.inlinePos];\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 return this.cssRect[this._names.contentPos];\n }\n public set cssInlinePos(inlinePos: number | undefined) {\n this.cssRect[this._names.inlinePos] = inlinePos;\n }\n public set cssContentPos(contentPos: number | undefined) {\n this.cssRect[this._names.contentPos] = contentPos;\n }\n public set cssInlineSize(inlineSize: number | undefined) {\n this.cssRect[this._names.inlineSize] = inlineSize;\n }\n public set cssContentSize(contentSize: number | undefined) {\n this.cssRect[this._names.contentSize] = contentSize;\n }\n /**\n * Calculated size in the direction of the inline applied to the grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#computedInlineSize\n */\n public get computedInlineSize() {\n const name = this._names.inlineSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated size in the direction of the content applied to the grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#computedContentSize\n */\n public get computedContentSize() {\n const name = this._names.contentSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated position in the direction of the inline applied to the grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#computedInlinePos\n */\n public get computedInlinePos() {\n const name = this._names.inlinePos;\n\n return this.cssRect[name] ?? this.rect[name];\n }\n /**\n * Calculated position in the direction of the content applied to the grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#computedContentPos\n */\n public get computedContentPos() {\n const name = this._names.contentPos;\n\n return this.cssRect[name] ?? this.rect[name];\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 gridData: this.gridData,\n data: this.data,\n };\n }\n /**\n * Returns minimized status of the item.\n * @ko 아이템의 간소화된 상태를 반환한다.\n */\n public getMinimizedStatus(): Partial {\n const status: Partial = {\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n attributes: this.attributes,\n gridData: this.gridData,\n };\n\n const {\n key,\n mountState,\n updateState,\n isFirstUpdate,\n orgCSSText,\n } = this;\n if (typeof key !== \"undefined\") {\n status.key = key;\n }\n if (mountState !== MOUNT_STATE.UNCHECKED) {\n status.mountState = mountState;\n }\n if (updateState !== UPDATE_STATE.NEED_UPDATE) {\n status.updateState = updateState;\n }\n if (isFirstUpdate) {\n status.isFirstUpdate = true;\n }\n if (orgCSSText) {\n status.orgCSSText = orgCSSText;\n }\n return status;\n }\n private get _names() {\n return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical;\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 _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 resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useRoundedSize,\n useResizeObserver,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useResizeObserver,\n }).on(\"resize\", this._onResize);\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n useRoundedSize,\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;\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 const useOrgResize = options.useOrgResize;\n\n items.forEach((item) => {\n if (useOrgResize) {\n const orgRect = item.orgRect;\n\n orgRect.width = 0;\n orgRect.height = 0;\n }\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 * ```js\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 */\n public renderItems(options: RenderOptions = {}) {\n this._renderItems(options);\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 * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false)\n */\n public getStatus(minimize?: boolean): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => minimize ? item.getMinimizedStatus() : 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 direction: this.defaultDirection,\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Get the inline size corresponding to outline.\n * @ko outline에 해당하는 inline 사이즈를 구한다.\n * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineSize(items: GridItem[] = this.items) {\n return this.options.outlineSize! || this.getContainerInlineSize();\n }\n /**\n * Get the length corresponding to outline.\n * @ko outline에 해당하는 length를 가져온다.\n * @param items - Items to get outline length. outline length를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineLength(items: GridItem[] = this.items): number {\n return this.options.outlineLength! || 1;\n }\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\n this._im?.destroy();\n }\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?.parentNode && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n mounted.filter((item) => {\n if (item.hasTransition) {\n return true;\n } else {\n const element = item.element!;\n const transitionDuration = parseFloat(getComputedStyle(element).transitionDuration);\n\n if (transitionDuration > 0) {\n item.hasTransition = true;\n item.transitionDuration = element.style.transitionDuration;\n return true;\n }\n }\n return false;\n }).forEach((item) => {\n item.element!.style.transitionDuration = \"0s\";\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 // reset org size\n updated.forEach((item) => {\n const hasOrgSize = item.orgRect.width && item.orgRect.height;\n const hasCSSSize = item.cssRect.width || item.cssRect.height;\n\n if (!hasOrgSize && hasCSSSize) {\n item.element!.style.cssText = item.orgCSSText;\n }\n });\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 * @example\n * ```js\n * grid.on(\"contentError\", e => {\n * e.update();\n * });\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\n updated.forEach((item) => {\n item.isUpdate = true;\n });\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n updated.forEach((item) => {\n item.isUpdate = false;\n });\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n\n const transitionMounted = mounted.filter((item) => item.hasTransition);\n\n if (transitionMounted.length) {\n this.containerManager.resize();\n transitionMounted.forEach((item) => {\n const element = item.element!;\n\n element.style.transitionDuration = item.transitionDuration;\n });\n }\n this._renderComplete({\n direction,\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 * @example\n * ```js\n * grid.on(\"renderComplete\", e => {\n * console.log(e.mounted, e.updated, e.useResize);\n * });\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 this._renderItems({\n useResize: true,\n }, true);\n }\n private _init() {\n this._resizeContainer();\n }\n private _renderItems(options: RenderOptions = {}, isTrusted?: boolean) {\n this._clearRenderTimer();\n\n const isResize = options.useResize || options.useOrgResize;\n\n\n if (isResize && !isTrusted) {\n // Resize container\n // isTrusted has already been resized internally.\n this._resizeContainer();\n }\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (isResize) {\n // Update all items\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\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 * @default 0\n * @example\n * ```js\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/**\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 * @default \"end\"\n * @example\n * ```js\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/**\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 * @default true\n * @example\n * ```js\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\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 * @default false\n * @example\n * ```js\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\n\n/**\n * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.\n * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineLength\n * @type {$ts:Grid.GridOptions[\"outlineLength\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineLength = 3;\n * ```\n */\n\n\n/**\n * The size of the outline. If the outline size is 0, it is calculated according to the grid type.\n * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineSize\n * @type {$ts:Grid.GridOptions[\"outlineSize\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineSize = 300;\n * ```\n */\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. Can be used instead of outlineLength. (default: 0)열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.(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. Can be used instead of outlineSize. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.(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 * @property - Difference Threshold for Counting Columns. Since offsetSize is calculated by rounding, the number of columns may not be accurate. (default: 1) 칼럼 개수를 계산하기 위한 차이 임계값. offset 사이즈는 반올림으로 게산하기 때문에 정확하지 않을 수 있다. (default: 1)\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n columnCalculationThreshold?: number;\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 * @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 columnCalculationThreshold: 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 columnCalculationThreshold: 0.5,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const columnSize = this.getComputedOutlineSize(items);\n const column = this.getComputedOutlineLength(items);\n\n const {\n gap,\n align,\n columnSizeRatio,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses(column, columnSize);\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[pointCalculationName](...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 contentSize = item.contentSize;\n let columnCount = Math.min(\n column,\n columnAttribute || Math.max(1, Math.ceil((item.inlineSize + gap) / columnDist)),\n );\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 // stretch mode or data-grid-column > \"1\"\n if ((columnAttribute > 0 && columnCount > 1) || isStretch) {\n item.cssInlineSize = (columnCount - 1) * columnDist + columnSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = item.computedInlineSize / 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 public getComputedOutlineSize(items = this.items) {\n const {\n gap,\n align,\n } = this.options;\n const columnSizeOption = this.columnSize || this.outlineSize;\n const column = this.column || this.outlineLength || 1;\n\n let columnSize = 0;\n\n if (align === \"stretch\") {\n columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n columnSize = columnSizeOption;\n } else if (items.length) {\n let checkedItem = items[0];\n\n for (const item of items) {\n const attributes = item.attributes;\n if (\n item.updateState !== UPDATE_STATE.UPDATED\n || !item.inlineSize\n || attributes.column\n || attributes.maxColumnCount\n ) {\n continue;\n }\n checkedItem = item;\n break;\n }\n const inlineSize = checkedItem.inlineSize || 0;\n\n columnSize = inlineSize;\n } else {\n columnSize = this.getContainerInlineSize();\n }\n return columnSize || 0;\n }\n public getComputedOutlineLength(items = this.items) {\n const gap = this.gap;\n const columnOption = this.column || this.outlineLength;\n const columnCalculationThreshold = this.columnCalculationThreshold;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else {\n const columnSize = this.getComputedOutlineSize(items);\n\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap)\n / (columnSize - columnCalculationThreshold + gap))),\n );\n }\n return column;\n }\n private _getAlignPoses(column: number, columnSize: number) {\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\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @default \"justify\"\n * @example\n * ```js\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/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. Can be used instead of outlineLength.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. Can be used instead of outlineSize.\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set.\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @default 0\n * @example\n * ```js\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 */\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 { MOUNT_STATE, PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } 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 rowSize;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n return ratio * (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 {\n attributePrefix,\n horizontal,\n } = this.options;\n\n items.forEach((item) => {\n if (!item.isUpdate) {\n return;\n }\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0;\n\n if (\n element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)\n && item.mountState === MOUNT_STATE.MOUNTED\n ) {\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 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 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 ratioSum += 1;\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 = contentSize <= contentOffset ? 1\n : (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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수.\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @default [1, 8]\n * @example\n * ```js\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/**\n * The minimum and maximum number of rows in a group, 0 is not set.\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다.\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @default 0\n * @example\n * ```js\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/**\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.\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다.\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @default [0, Infinity]\n * @example\n * ```js\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/**\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.\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다.\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @default -1\n * @example\n * ```js\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/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken.\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다.\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @default false\n * @example\n * ```js\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","/**\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.length ? outline : [0];\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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill)\n : getOutlinePoint(endOutline, gridOutline, 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 public getComputedOutlineLength() {\n const frame = this.options.frame;\n\n return frame.length ? frame[0].length : 0;\n }\n public getComputedOutlineSize() {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption.inlineSize;\n }\n return rectSizeOption || ((this.getContainerInlineSize()! + gap) / this.getComputedOutlineLength() - gap);\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.\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다.\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @default []\n * @example\n * ```js\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/**\n * Make sure that the frame can be attached after the previous frame.\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @default true\n * @example\n * ```js\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/**\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 * ```js\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 */\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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize).\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The priority that determines the weight of the item. \"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 아이템의 가중치를 결정하는 우선수치. \"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 * @default \"custom\"\n * @example\n * ```js\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/**\n * The size weight when placing items.\n * @ko 아이템들을 배치하는데 사이즈 가중치.\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The weight to keep ratio when placing items.\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치.\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @default 1\n * @example\n * ```js\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","/**\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\";\nexport * from \"./ItemRenderer\";\nexport * from \"./types\";\nexport * from \"./Grid\";\nexport * from \"./GridItem\";\nexport * from \"./ContainerManager\";\nexport * from \"./ResizeWatcher\";\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","outlineLength","outlineSize","useRoundedSize","useResizeObserver","PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","GRID_EVENTS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","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","descriptor","getOwnPropertyDescriptor","getter","get","options","setter","set","prevValue","scheduleRender","enumerable","configurable","defineProperty","withMethods","methods","memberName","forEach","_i","args","result","_a","range","arr","push","getRangeCost","valueRange","Math","max","withGridMethods","container","width","height","clearTimeout","_this","_resizeTimer","_maxResizeDebounceTimer","watchDirection","_options","prevRect","rect","resize","isWatchWidth","isWatchHeight","isResize","_emitter","trigger","window","setTimeout","_onResize","useWindowResize","rectBox","document","querySelector","_init","setRect","offsetWidth","offsetHeight","clientWidth","clientHeight","callback","on","_observer","disconnect","removeEventListener","Component","ResizeObserver","_scheduleResize","observe","box","addEventListener","__extends","_super","_watcher","getRect","_names","status","setContentSize","getContentSize","size","sizeName","style","destroy","preserveUI","cssText","orgCSSText","getComputedStyle","position","ResizeWatcher","listen","initialRect","items","item","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","posPercetage","sizePercetage","orgRect","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","clientRect","getBoundingClientRect","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","cssRect","cssTexts","_b","posName","getInlineSize","filter","key","map","join","itemStatus","data","UNCHECKED","gridData","gridRect","names","containerElement","start","end","_renderItems","useResize","constructor","defaultOptions","containerManager","ContainerManager","itemRenderer","ItemRenderer","Grid","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","renderItems","useOrgResize","checkReady","minimize","getMinimizedStatus","getStatus","prevInlineSize","setStatus","_renderComplete","direction","mounted","updated","getContainerInlineSize","_im","parentNode","moreUpdated","hasTransition","transitionDuration","parseFloat","ImReady","prefix","e","hasCSSSize","updateItems","readyItems","isPreReadyOver","target","update","check","_clearRenderTimer","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","prevOutline","outline","nextOutlines","isUpdate","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","transitionMounted","endPoint","startPoint","setContainerRect","_resizeContainer","isTrusted","getItems","syncElements","getColumnPoint","columnIndex","columnCount","pointCaculationName","getColumnIndex","nearestCalculationName","indexCaculationName","points","columnSize","getComputedOutlineSize","column","getComputedOutlineLength","align","columnSizeRatio","itemsLength","alignPoses","_getAlignPoses","isEndDirection","pointCalculationName","point_1","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","nextEndColumnIndex","nextColumnIndex","cssInlineSize","computedInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","columnSizeOption","checkedItem","items_1","columnOption","columnCalculationThreshold","floor","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","contentOffset","ratio","maintainedTarget","widthOffset","scrollWidth","heightOffset","scrollHeight","rowRange","_getRowPath","_getPath","_setStyle","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":";;;;;;;;;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YAAA;AAqJb,oBAAA;AAAC,EArJgCtU,KAAjC;AA2JA;;;;;;;;;;;;;;;;;;AAkBA;;;;;;;;;;;;;;;;;;;;;;;AAuBA;;;;;;;;;;;;;;;;;;AAmBA;;;;;;;;;;;;;;;;;;ACnSA;;;;;;;;;"} \ No newline at end of file diff --git a/dist/grid.js b/dist/grid.js new file mode 100644 index 0000000..a103a1f --- /dev/null +++ b/dist/grid.js @@ -0,0 +1,5407 @@ +/* +Copyright (c) 2021-present NAVER Corp. +name: @egjs/grid +license: MIT +author: NAVER Corp. +repository: https://github.com/naver/egjs-grid +version: 1.9.0 +*/ +(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; + } + function __spreadArray(to, from) { + for (var i = 0, il = from.length, j = to.length; i < il; i++, j++) to[j] = from[i]; + + return to; + } + + /* + 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; + }(); + + /* + * Copyright (c) 2015 NAVER Corp. + * egjs projects are licensed under the MIT license + */ + + var ComponentEvent$1 = ComponentEvent; + + 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, + outlineLength: 0, + outlineSize: 0, + useRoundedSize: true, + useResizeObserver: false + }; + 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, + outlineSize: PROPERTY_TYPE.RENDER_PROPERTY, + outlineLength: PROPERTY_TYPE.RENDER_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" + } + }; + + 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 descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {}; + + var getter = descriptor.get || function get() { + return this.options[name]; + }; + + var setter = descriptor.set || function set(value) { + var options = this.options; + var prevValue = options[name]; + + if (prevValue === value) { + return; + } + + options[name] = value; + + if (shouldRender && options.renderOnPropertyChange) { + this.scheduleRender(); + } + }; + + var attributes = { + enumerable: true, + configurable: true, + get: getter, + set: setter + }; + 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 ResizeWatcher = + /*#__PURE__*/ + function () { + function ResizeWatcher(container, options) { + var _this = this; + + if (options === void 0) { + options = {}; + } + + this._resizeTimer = 0; + this._maxResizeDebounceTimer = 0; + this.rect = { + width: 0, + height: 0 + }; + + this._onResize = function () { + clearTimeout(_this._resizeTimer); + clearTimeout(_this._maxResizeDebounceTimer); + _this._maxResizeDebounceTimer = 0; + _this._resizeTimer = 0; + var watchDirection = _this._options.watchDirection; + var prevRect = _this.rect; + + _this.resize(); + + var rect = _this.rect; + var isWatchWidth = watchDirection === "box" || watchDirection === "width"; + var isWatchHeight = watchDirection === "box" || watchDirection === "height"; + var isResize = !watchDirection || isWatchWidth && prevRect.width !== rect.width || isWatchHeight && prevRect.height !== rect.height; + + if (isResize) { + _this._emitter.trigger("resize"); + } + }; + + 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({ + resizeDebounce: 100, + maxResizeDebounce: 0, + useResizeObserver: false, + useWindowResize: true, + watchDirection: false, + rectBox: "content-box" + }, options); + this.container = isString(container) ? document.querySelector(container) : container; + + this._init(); + } + + var __proto = ResizeWatcher.prototype; + + __proto.getRect = function () { + return this.rect; + }; + + __proto.setRect = function (rect) { + this.rect = __assign({}, rect); + }; + + __proto.resize = function () { + var container = this.container; + this.setRect(this._options.rectBox === "border-box" ? { + width: container.offsetWidth, + height: container.offsetHeight + } : { + width: container.clientWidth, + height: container.clientHeight + }); + }; + + __proto.listen = function (callback) { + this._emitter.on("resize", callback); + + return this; + }; + + __proto.destroy = function () { + var _a; + + (_a = this._observer) === null || _a === void 0 ? void 0 : _a.disconnect(); + + if (this._options.useWindowResize) { + window.removeEventListener("reisze", this._onResize); + } + }; + + __proto._init = function () { + var container = this.container; + var options = this._options; + this._emitter = new Component(); + + if (options.useResizeObserver && !!window.ResizeObserver) { + this._observer = new window.ResizeObserver(this._scheduleResize); + + this._observer.observe(container, { + box: options.rectBox + }); + } + + if (options.useWindowResize) { + window.addEventListener("resize", this._scheduleResize); + } + + this.resize(); + }; + + return ResizeWatcher; + }(); + + var ContainerManager = + /*#__PURE__*/ + function (_super) { + __extends(ContainerManager, _super); + + function ContainerManager(container, options) { + var _this = _super.call(this) || this; + + _this.container = container; + + _this._onResize = function () { + _this.trigger("resize"); + }; + + _this.options = __assign({ + horizontal: DEFAULT_GRID_OPTIONS.horizontal, + autoResize: DEFAULT_GRID_OPTIONS.autoResize, + resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce, + maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce, + useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver + }, options); + + _this._init(); + + return _this; + } + + var __proto = ContainerManager.prototype; + + __proto.resize = function () { + var container = this.container; + this.setRect({ + width: container.clientWidth, + height: container.clientHeight + }); + }; + + __proto.getRect = function () { + return this._watcher.getRect(); + }; + + __proto.setRect = function (rect) { + this._watcher.setRect(rect); + }; + + __proto.getInlineSize = function () { + return this.getRect()[this._names.inlineSize]; + }; + + __proto.getContentSize = function () { + return this.getRect()[this._names.contentSize]; + }; + + __proto.getStatus = function () { + return { + rect: this._watcher.getRect() + }; + }; + + __proto.setStatus = function (status) { + this.setRect(status.rect); + this.setContentSize(this.getContentSize()); + }; + + __proto.setContentSize = function (size) { + var _a; + + var sizeName = this.options.horizontal ? "width" : "height"; + this.setRect(__assign(__assign({}, this.getRect()), (_a = {}, _a[sizeName] = size, _a))); + this.container.style[sizeName] = size + "px"; + }; + + __proto.destroy = function (options) { + if (options === void 0) { + options = {}; + } + + this._watcher.destroy(); + + 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"; + } + + var options = this.options; + this._watcher = new ResizeWatcher(container, { + useWindowResize: options.autoResize, + useResizeObserver: options.useResizeObserver, + resizeDebounce: options.resizeDebounce, + maxResizeDebounce: options.maxResizeDebounce, + watchDirection: options.useResizeObserver ? this._names.inlineSize : false + }).listen(this._onResize); + }; + + Object.defineProperty(__proto, "_names", { + get: function () { + return RECT_NAMES[this.options.horizontal ? "horizontal" : "vertical"]; + }, + enumerable: false, + configurable: true + }); + return ContainerManager; + }(Component); + + /* + Copyright (c) 2020-present NAVER Corp. + name: @egjs/imready + license: MIT + author: NAVER Corp. + repository: https://github.com/naver/egjs-imready + version: 1.3.0 + */ + + /*! ***************************************************************************** + 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() { + 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, prefix) { + if (prefix === void 0) { + prefix = "data-"; + } + + return "loading" in target && target.getAttribute("loading") === "lazy" || !!target.getAttribute(prefix + "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(["[" + 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); + } + + if (_this.hasLoading && _this.checkElement()) { + // I'm not ready + return; + } // 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; + var prefix = _this.options.prefix; + _this.hasDataSize = hasSizeAttribute(element, prefix); + _this.isSkip = hasSkipAttribute(element, prefix); + _this.hasLoading = hasLoadingAttribute(element, prefix); + 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); + + 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 prefix = options.prefix; + 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, prefix); + })); + 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 이벤트에 전달되는 데이터 객체 + * @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(new ComponentEvent$1("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 이벤트에 전달되는 데이터 객체 + * @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(new ComponentEvent$1("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 이벤트에 전달되는 데이터 객체 + * @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(new ComponentEvent$1("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 이벤트에 전달되는 데이터 객체 + * @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(new ComponentEvent$1("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 이벤트에 전달되는 데이터 객체 + * @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(new ComponentEvent$1("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); + + 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); + + 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, + useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize + }, 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, + useRoundedSize = _a.useRoundedSize; + 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: 0, + height: 0 + }; + + if (useRoundedSize) { + rect.width = element.offsetWidth; + rect.height = element.offsetHeight; + } else { + var clientRect = element.getBoundingClientRect(); + rect.width = clientRect.width; + rect.height = clientRect.height; + } + } + + if (!item.isFirstUpdate || !hasOrgSize) { + 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; + this.isUpdate = false; + this.hasTransition = false; + this.transitionDuration = ""; + 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 : "", + gridData: {} + }, 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 name = this._names.inlineSize; + return this.orgRect[name] || this.rect[name]; + }, + 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 name = this._names.contentSize; + return this.orgRect[name] || this.rect[name]; + }, + 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 () { + return this.rect[this._names.inlineSize]; + }, + 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 () { + return this.rect[this._names.contentSize]; + }, + 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 () { + return this.cssRect[this._names.inlineSize]; + }, + set: function (inlineSize) { + this.cssRect[this._names.inlineSize] = 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 () { + return this.cssRect[this._names.contentSize]; + }, + set: function (contentSize) { + this.cssRect[this._names.contentSize] = 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 () { + return this.cssRect[this._names.inlinePos]; + }, + set: function (inlinePos) { + this.cssRect[this._names.inlinePos] = 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 () { + return this.cssRect[this._names.contentPos]; + }, + set: function (contentPos) { + this.cssRect[this._names.contentPos] = contentPos; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedInlineSize", { + /** + * Calculated size in the direction of the inline applied to the grid. "width" if horizontal is false, "height" otherwise. + * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 "width", 아니면 "height". + * @member Grid.GridItem#computedInlineSize + */ + get: function () { + var name = this._names.inlineSize; + return this.cssRect[name] || this.rect[name] || this.orgRect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedContentSize", { + /** + * Calculated size in the direction of the content applied to the grid. "height" if horizontal is false, "width" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 "height", 아니면 "width". + * @member Grid.GridItem#computedContentSize + */ + get: function () { + var name = this._names.contentSize; + return this.cssRect[name] || this.rect[name] || this.orgRect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedInlinePos", { + /** + * Calculated position in the direction of the inline applied to the grid. "left" if horizontal is false, "top" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 "left", 아니면 "top". + * @member Grid.GridItem#computedInlinePos + */ + get: function () { + var _a; + + var name = this._names.inlinePos; + return (_a = this.cssRect[name]) !== null && _a !== void 0 ? _a : this.rect[name]; + }, + enumerable: false, + configurable: true + }); + Object.defineProperty(__proto, "computedContentPos", { + /** + * Calculated position in the direction of the content applied to the grid. "top" if horizontal is false, "left" otherwise. + * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 "top", 아니면 "left". + * @member Grid.GridItem#computedContentPos + */ + get: function () { + var _a; + + var name = this._names.contentPos; + return (_a = this.cssRect[name]) !== null && _a !== void 0 ? _a : this.rect[name]; + }, + 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, + gridData: this.gridData, + data: this.data + }; + }; + /** + * Returns minimized status of the item. + * @ko 아이템의 간소화된 상태를 반환한다. + */ + + + __proto.getMinimizedStatus = function () { + var status = { + orgRect: this.orgRect, + rect: this.rect, + cssRect: this.cssRect, + attributes: this.attributes, + gridData: this.gridData + }; + + var _a = this, + key = _a.key, + mountState = _a.mountState, + updateState = _a.updateState, + isFirstUpdate = _a.isFirstUpdate, + orgCSSText = _a.orgCSSText; + + if (typeof key !== "undefined") { + status.key = key; + } + + if (mountState !== MOUNT_STATE.UNCHECKED) { + status.mountState = mountState; + } + + if (updateState !== UPDATE_STATE.NEED_UPDATE) { + status.updateState = updateState; + } + + if (isFirstUpdate) { + status.isFirstUpdate = true; + } + + if (orgCSSText) { + status.orgCSSText = orgCSSText; + } + + return status; + }; + + Object.defineProperty(__proto, "_names", { + get: function () { + return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical; + }, + enumerable: false, + configurable: true + }); + 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._onResize = function () { + _this._renderItems({ + useResize: true + }, true); + }; + + _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, + resizeDebounce = _a.resizeDebounce, + maxResizeDebounce = _a.maxResizeDebounce, + autoResize = _a.autoResize, + useRoundedSize = _a.useRoundedSize, + useResizeObserver = _a.useResizeObserver; // TODO: 테스트용 설정 + + _this.containerManager = externalContainerManager || new ContainerManager(_this.containerElement, { + horizontal: horizontal, + resizeDebounce: resizeDebounce, + maxResizeDebounce: maxResizeDebounce, + autoResize: autoResize, + useResizeObserver: useResizeObserver + }).on("resize", _this._onResize); + _this.itemRenderer = externalItemRenderer || new ItemRenderer({ + useTransform: useTransform, + isEqualSize: isEqualSize, + isConstantSize: isConstantSize, + percentage: percentage, + useRoundedSize: useRoundedSize + }); + + _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 = {}; + } + + var useOrgResize = options.useOrgResize; + items.forEach(function (item) { + if (useOrgResize) { + var orgRect = item.orgRect; + orgRect.width = 0; + orgRect.height = 0; + } + + 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 + * ```js + * 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._renderItems(options); + + return this; + }; + /** + * Returns current status such as item's position, size. The returned status can be restored with the setStatus() method. + * @ko 아이템의 위치, 사이즈 등 현재 상태를 반환한다. 반환한 상태는 setStatus() 메서드로 복원할 수 있다. + * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false) + */ + + + __proto.getStatus = function (minimize) { + return { + outlines: this.outlines, + items: this.items.map(function (item) { + return minimize ? item.getMinimizedStatus() : 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({ + direction: _this.defaultDirection, + mounted: _this.items, + updated: [], + isResize: false + }); + }); + } + + return this; + }; + /** + * Get the inline size corresponding to outline. + * @ko outline에 해당하는 inline 사이즈를 구한다. + * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + + + __proto.getComputedOutlineSize = function (items) { + if (items === void 0) { + items = this.items; + } + + return this.options.outlineSize || this.getContainerInlineSize(); + }; + /** + * Get the length corresponding to outline. + * @ko outline에 해당하는 length를 가져온다. + * @param items - Items to get outline length. outline length를 구하기 위한 아이템들. + */ + // eslint-disable-next-line @typescript-eslint/no-unused-vars + + + __proto.getComputedOutlineLength = function (items) { + if (items === void 0) { + items = this.items; + } + + return this.options.outlineLength || 1; + }; + /** + * 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; + } + }); + } + + (_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) { + var _a; + + return ((_a = item.element) === null || _a === void 0 ? void 0 : _a.parentNode) && item.updateState !== UPDATE_STATE.UPDATED; + }); + var mounted = updated.filter(function (item) { + return item.mountState !== MOUNT_STATE.MOUNTED; + }); + var moreUpdated = []; + mounted.filter(function (item) { + if (item.hasTransition) { + return true; + } else { + var element = item.element; + var transitionDuration = parseFloat(getComputedStyle(element).transitionDuration); + + if (transitionDuration > 0) { + item.hasTransition = true; + item.transitionDuration = element.style.transitionDuration; + return true; + } + } + + return false; + }).forEach(function (item) { + item.element.style.transitionDuration = "0s"; + }); + (_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 () { + // reset org size + updated.forEach(function (item) { + var hasOrgSize = item.orgRect.width && item.orgRect.height; + var hasCSSSize = item.cssRect.width || item.cssRect.height; + + if (!hasOrgSize && hasCSSSize) { + item.element.style.cssText = item.orgCSSText; + } + }); + + _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 이벤트에 전달되는 데이터 객체 + * @example + * ```js + * 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: __spreadArray([], prevOutline), + end: __spreadArray([], prevOutline) + }; + updated.forEach(function (item) { + item.isUpdate = true; + }); + + if (items.length) { + nextOutlines = this.applyGrid(this.items, direction, prevOutline); + } + + updated.forEach(function (item) { + item.isUpdate = false; + }); + this.setOutlines(nextOutlines); + this.fitOutlines(); + this.itemRenderer.renderItems(this.items); + + this._refreshContainerContentSize(); + + var transitionMounted = mounted.filter(function (item) { + return item.hasTransition; + }); + + if (transitionMounted.length) { + this.containerManager.resize(); + transitionMounted.forEach(function (item) { + var element = item.element; + element.style.transitionDuration = item.transitionDuration; + }); + } + + this._renderComplete({ + direction: direction, + 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 이벤트에 전달되는 데이터 객체 + * @example + * ```js + * 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(); + }; + + __proto._renderItems = function (options, isTrusted) { + if (options === void 0) { + options = {}; + } + + this._clearRenderTimer(); + + var isResize = options.useResize || options.useOrgResize; + + if (isResize && !isTrusted) { + // Resize container + // isTrusted has already been resized internally. + this._resizeContainer(); + } + + if (!this.getItems().length && this.getChildren().length) { + this.syncElements(options); + } else if (isResize) { + // Update all items + this.updateItems(this.items, options); + } else { + // Update only items that need to be updated. + this.checkReady(options); + } + }; + + 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"]} + * @default 0 + * @example + * ```js + * 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"]} + * @default "end" + * @example + * ```js + * 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"]} + * @default true + * @example + * ```js + * 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"]} + * @default false + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * preserveUIOnDestroy: false, + * }); + * + * grid.preserveUIOnDestroy = true; + * ``` + */ + + /** + * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid. + * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다. + * @name Grid#outlineLength + * @type {$ts:Grid.GridOptions["outlineLength"]} + * @default 0 + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * outlineLength: 0, + * outlineSize: 0, + * }); + * + * grid.outlineLength = 3; + * ``` + */ + + /** + * The size of the outline. If the outline size is 0, it is calculated according to the grid type. + * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다. + * @name Grid#outlineSize + * @type {$ts:Grid.GridOptions["outlineSize"]} + * @default 0 + * @example + * ```js + * import { MasonryGrid } from "@egjs/grid"; + * + * const grid = new MasonryGrid(container, { + * outlineLength: 0, + * outlineSize: 0, + * }); + * + * grid.outlineSize = 300; + * ``` + */ + + 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() { + return _super !== null && _super.apply(this, arguments) || this; + } + + var __proto = MasonryGrid.prototype; + + __proto.applyGrid = function (items, direction, outline) { + var columnSize = this.getComputedOutlineSize(items); + var column = this.getComputedOutlineLength(items); + var _a = this.options, + gap = _a.gap, + align = _a.align, + columnSizeRatio = _a.columnSizeRatio; + var outlineLength = outline.length; + var itemsLength = items.length; + + var alignPoses = this._getAlignPoses(column, columnSize); + + 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[pointCalculationName].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 contentSize = item.contentSize; + var columnCount = Math.min(column, columnAttribute || Math.max(1, Math.ceil((item.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); // stretch mode or data-grid-column > "1" + + if (columnAttribute > 0 && columnCount > 1 || isStretch) { + item.cssInlineSize = (columnCount - 1) * columnDist + columnSize; + } + + if (columnSizeRatio > 0) { + contentSize = item.computedInlineSize / 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.getComputedOutlineSize = function (items) { + if (items === void 0) { + items = this.items; + } + + var _a = this.options, + gap = _a.gap, + align = _a.align; + var columnSizeOption = this.columnSize || this.outlineSize; + var column = this.column || this.outlineLength || 1; + var columnSize = 0; + + if (align === "stretch") { + columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap; + } else if (columnSizeOption) { + columnSize = columnSizeOption; + } else if (items.length) { + var checkedItem = items[0]; + + 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.inlineSize || attributes.column || attributes.maxColumnCount) { + continue; + } + + checkedItem = item; + break; + } + + var inlineSize = checkedItem.inlineSize || 0; + columnSize = inlineSize; + } else { + columnSize = this.getContainerInlineSize(); + } + + return columnSize || 0; + }; + + __proto.getComputedOutlineLength = function (items) { + if (items === void 0) { + items = this.items; + } + + var gap = this.gap; + var columnOption = this.column || this.outlineLength; + var columnCalculationThreshold = this.columnCalculationThreshold; + var column = 1; + + if (columnOption) { + column = columnOption; + } else { + var columnSize = this.getComputedOutlineSize(items); + column = Math.min(items.length, Math.max(1, Math.floor((this.getContainerInlineSize() + gap) / (columnSize - columnCalculationThreshold + gap)))); + } + + return column; + }; + + __proto._getAlignPoses = function (column, columnSize) { + 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, + columnCalculationThreshold: PROPERTY_TYPE.RENDER_PROPERTY + }); + MasonryGrid.defaultOptions = __assign(__assign({}, Grid.defaultOptions), { + align: "justify", + column: 0, + columnSize: 0, + columnSizeRatio: 0, + columnCalculationThreshold: 0.5 + }); + 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") + * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. ("start", "center", "end", "justify", "stretch") + * @name Grid.MasonryGrid#align + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["align"]} + * @default "justify" + * @example + * ```js + * 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. Can be used instead of outlineLength. + * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다. + * @name Grid.MasonryGrid#column + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["column"]} + * @default 0 + * @example + * ```js + * 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. Can be used instead of outlineSize. + * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다. + * @name Grid.MasonryGrid#columnSize + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSize"]} + * @default 0 + * @example + * ```js + * 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. + * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다. + * @name Grid.MasonryGrid#columnSizeRatio + * @type {$ts:Grid.MasonryGrid.MasonryGridOptions["columnSizeRatio"]} + * @default 0 + * @example + * ```js + * 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 rowSize; + } + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset); + return ratio * (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 _a = this.options, + attributePrefix = _a.attributePrefix, + horizontal = _a.horizontal; + items.forEach(function (item) { + if (!item.isUpdate) { + return; + } + + var element = item.element; + var attributes = item.attributes; + var gridData = item.gridData; + var inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0; + var contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0; + + if (element && !("inlineOffset" in attributes) && !("contentOffset" in attributes) && item.mountState === MOUNT_STATE.MOUNTED) { + 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; + }); + 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._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: __spreadArray(__spreadArray([], 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: __spreadArray(__spreadArray([], 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) { + ratioSum += 1; + return; + } // sum((expect - offset) * ratio) = container inline size + + + var inlineOffset = parseFloat(item.gridData.inlineOffset) || 0; + var contentOffset = parseFloat(item.gridData.contentOffset) || 0; + var maintainedRatio = contentSize <= contentOffset ? 1 : (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] // endPoint - height = startPoint + + }; + }; + + __proto.getComputedOutlineLength = function () { + return 1; + }; + + __proto.getComputedOutlineSize = function () { + return this.getContainerInlineSize(); + }; + + __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. + * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수. + * @name Grid.JustifiedGrid#columnRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["columnRange"]} + * @default [1, 8] + * @example + * ```js + * 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. + * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다. + * @name Grid.JustifiedGrid#rowRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["rowRange"]} + * @default 0 + * @example + * ```js + * 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. + * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다. + * @name Grid.JustifiedGrid#sizeRange + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["sizeRange"]} + * @default [0, Infinity] + * @example + * ```js + * 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. + * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다. + * @name Grid.JustifiedGrid#displayedRow + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["displayedRow"]} + * @default -1 + * @example + * ```js + * 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. + * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다. + * @name Grid.JustifiedGrid#isCroppedSize + * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions["isCroppedSize"]} + * @default false + * @example + * ```js + * 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.length ? outline : [0]; + + 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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill) : getOutlinePoint(endOutline, gridOutline, 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.getComputedOutlineLength = function () { + var frame = this.options.frame; + return frame.length ? frame[0].length : 0; + }; + + __proto.getComputedOutlineSize = function () { + var _a = this.options, + gap = _a.gap, + rectSizeOption = _a.rectSize; + + if (typeof rectSizeOption === "object") { + return rectSizeOption.inlineSize; + } + + return rectSizeOption || (this.getContainerInlineSize() + gap) / this.getComputedOutlineLength() - gap; + }; + + __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. + * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다. + * @name Grid.FrameGrid#frame + * @type {$ts:Grid.FrameGrid.FrameGridOptions["frame"]} + * @default [] + * @example + * ```js + * 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. + * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다. + * @name Grid.FrameGrid#useFrameFill + * @type {$ts:Grid.FrameGrid.FrameGridOptions["useFrameFill"]} + * @default true + * @example + * ```js + * 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 + * ```js + * 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.getComputedOutlineLength = function () { + return 1; + }; + + __proto.getComputedOutlineSize = function () { + return this.getContainerInlineSize(); + }; + + __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. + * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize). + * @name Grid.PackingGrid#aspectRatio + * @type {$ts:Grid.PackingGrid.PackingGridOptions["aspectRatio"]} + * @default 1 + * @example + * ```js + * 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. "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 아이템의 가중치를 결정하는 우선수치. "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"]} + * @default "custom" + * @example + * ```js + * 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. + * @ko 아이템들을 배치하는데 사이즈 가중치. + * @name Grid.PackingGrid#sizeWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["sizeWeight"]} + * @default 1 + * @example + * ```js + * import { PackingGrid } from "@egjs/grid"; + * + * const grid = new PackingGrid(container, { + * sizeWeight: 1, + * }); + * + * grid.sizeWeight = 10; + * ``` + */ + + /** + * The weight to keep ratio when placing items. + * @ko 아이템들을 배치하는데 비율을 유지하는 가중치. + * @name Grid.PackingGrid#ratioWeight + * @type {$ts:Grid.PackingGrid.PackingGridOptions["ratioWeight"]} + * @default 1 + * @example + * ```js + * 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, + ItemRenderer: ItemRenderer, + GridItem: GridItem, + ContainerManager: ContainerManager, + ResizeWatcher: ResizeWatcher, + 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..99c61f2 --- /dev/null +++ b/dist/grid.js.map @@ -0,0 +1 @@ +{"version":3,"file":"grid.js","sources":["../src/consts.ts","../src/utils.ts","../src/ResizeWatcher.ts","../src/ContainerManager.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 outlineLength: 0,\n outlineSize: 0,\n useRoundedSize: true,\n useResizeObserver: false,\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 outlineSize: PROPERTY_TYPE.RENDER_PROPERTY,\n outlineLength: PROPERTY_TYPE.RENDER_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 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\n const descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {};\n\n const getter = descriptor.get || function get(this: Grid) {\n return this.options[name];\n };\n const setter = descriptor.set || function 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 const attributes: Record = {\n enumerable: true,\n configurable: true,\n get: getter,\n set: setter,\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","import Component from \"@egjs/component\";\nimport { SizeRect } from \"./types\";\nimport { isString } from \"./utils\";\n\nexport interface ResizeWatherOptions {\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n useWindowResize?: boolean;\n watchDirection?: \"width\" | \"height\" | \"box\" | false;\n rectBox?: \"border-box\" | \"content-box\";\n}\n\nexport class ResizeWatcher {\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _emitter: Component<{ resize: void }>;\n private _observer: ResizeObserver | null;\n protected container: HTMLElement;\n protected rect: SizeRect = { width: 0, height: 0 };\n private _options!: Required;\n\n constructor(container: HTMLElement | string, options: ResizeWatherOptions = {}) {\n this._options = {\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n useResizeObserver: false,\n useWindowResize: true,\n watchDirection: false,\n rectBox: \"content-box\",\n ...options,\n };\n\n this.container = isString(container) ? document.querySelector(container)! : container;\n this._init();\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: SizeRect) {\n this.rect = { ...rect };\n }\n public resize() {\n const container = this.container;\n\n this.setRect(this._options.rectBox === \"border-box\" ? {\n width: container.offsetWidth,\n height: container.offsetHeight,\n } : {\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public listen(callback: () => void) {\n this._emitter.on(\"resize\", callback);\n return this;\n }\n public destroy() {\n this._observer?.disconnect();\n if (this._options.useWindowResize) {\n window.removeEventListener(\"reisze\", this._onResize);\n }\n }\n private _init() {\n const container = this.container;\n const options = this._options;\n\n this._emitter = new Component();\n if (options.useResizeObserver && !!window.ResizeObserver) {\n this._observer = new window.ResizeObserver(this._scheduleResize);\n this._observer.observe(container, {\n box: options.rectBox,\n });\n }\n if (options.useWindowResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n this.resize();\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n\n const watchDirection = this._options.watchDirection;\n const prevRect = this.rect;\n this.resize();\n const rect = this.rect;\n const isWatchWidth = watchDirection === \"box\" || watchDirection === \"width\";\n const isWatchHeight = watchDirection === \"box\" || watchDirection === \"height\";\n const isResize = !watchDirection\n || (isWatchWidth && prevRect.width !== rect.width)\n || (isWatchHeight && prevRect.height !== rect.height);\n\n if (isResize) {\n this._emitter.trigger(\"resize\");\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","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DestroyOptions, SizeRect } from \"./types\";\nimport { ResizeWatcher } from \"./ResizeWatcher\";\nimport { DEFAULT_GRID_OPTIONS, RECT_NAMES } from \"./consts\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n autoResize?: boolean;\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: SizeRect;\n}\nexport interface ContainerManagerEvents {\n resize: void;\n}\nexport class ContainerManager extends Component {\n protected options: Required;\n protected orgCSSText: string;\n private _watcher: ResizeWatcher;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n super();\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n autoResize: DEFAULT_GRID_OPTIONS.autoResize,\n resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce,\n maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce,\n useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public getRect() {\n return this._watcher.getRect();\n }\n public setRect(rect: SizeRect) {\n this._watcher.setRect(rect);\n }\n public getInlineSize() {\n return this.getRect()[this._names.inlineSize];\n }\n public getContentSize() {\n return this.getRect()[this._names.contentSize];\n }\n public getStatus() {\n return { rect: this._watcher.getRect() };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.setRect(status.rect);\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.setRect({\n ...this.getRect(),\n [sizeName]: size,\n });\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n this._watcher.destroy();\n\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 const options = this.options;\n\n this._watcher = new ResizeWatcher(container, {\n useWindowResize: options.autoResize,\n useResizeObserver: options.useResizeObserver,\n resizeDebounce: options.resizeDebounce,\n maxResizeDebounce: options.maxResizeDebounce,\n watchDirection: options.useResizeObserver ? this._names.inlineSize : false,\n }).listen(this._onResize);\n }\n private _onResize = () => {\n this.trigger(\"resize\");\n }\n private get _names() {\n return RECT_NAMES[this.options.horizontal ? \"horizontal\" : \"vertical\"];\n }\n}\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 useRoundedSize?: 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 useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize,\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, useRoundedSize } = 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: 0,\n height: 0,\n };\n if (useRoundedSize) {\n rect.width = element.offsetWidth;\n rect.height = element.offsetHeight;\n } else {\n const clientRect = element.getBoundingClientRect();\n\n rect.width = clientRect.width;\n rect.height = clientRect.height;\n }\n }\n if (!item.isFirstUpdate || !hasOrgSize) {\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 * @property - Grid ready data for rendering. 렌더링을 하기 위한 grid의 준비 데이터.\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 gridData?: Record;\n}\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n public isUpdate = false;\n public hasTransition = false;\n public transitionDuration = \"\";\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 gridData: {},\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\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 name = this._names.inlineSize;\n\n return this.orgRect[name] || this.rect[name];\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 name = this._names.contentSize;\n\n return this.orgRect[name] || this.rect[name];\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 return this.rect[this._names.inlineSize];\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 return this.rect[this._names.contentSize];\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 return this.cssRect[this._names.inlineSize];\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 return this.cssRect[this._names.contentSize];\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 return this.cssRect[this._names.inlinePos];\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 return this.cssRect[this._names.contentPos];\n }\n public set cssInlinePos(inlinePos: number | undefined) {\n this.cssRect[this._names.inlinePos] = inlinePos;\n }\n public set cssContentPos(contentPos: number | undefined) {\n this.cssRect[this._names.contentPos] = contentPos;\n }\n public set cssInlineSize(inlineSize: number | undefined) {\n this.cssRect[this._names.inlineSize] = inlineSize;\n }\n public set cssContentSize(contentSize: number | undefined) {\n this.cssRect[this._names.contentSize] = contentSize;\n }\n /**\n * Calculated size in the direction of the inline applied to the grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#computedInlineSize\n */\n public get computedInlineSize() {\n const name = this._names.inlineSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated size in the direction of the content applied to the grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#computedContentSize\n */\n public get computedContentSize() {\n const name = this._names.contentSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated position in the direction of the inline applied to the grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#computedInlinePos\n */\n public get computedInlinePos() {\n const name = this._names.inlinePos;\n\n return this.cssRect[name] ?? this.rect[name];\n }\n /**\n * Calculated position in the direction of the content applied to the grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#computedContentPos\n */\n public get computedContentPos() {\n const name = this._names.contentPos;\n\n return this.cssRect[name] ?? this.rect[name];\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 gridData: this.gridData,\n data: this.data,\n };\n }\n /**\n * Returns minimized status of the item.\n * @ko 아이템의 간소화된 상태를 반환한다.\n */\n public getMinimizedStatus(): Partial {\n const status: Partial = {\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n attributes: this.attributes,\n gridData: this.gridData,\n };\n\n const {\n key,\n mountState,\n updateState,\n isFirstUpdate,\n orgCSSText,\n } = this;\n if (typeof key !== \"undefined\") {\n status.key = key;\n }\n if (mountState !== MOUNT_STATE.UNCHECKED) {\n status.mountState = mountState;\n }\n if (updateState !== UPDATE_STATE.NEED_UPDATE) {\n status.updateState = updateState;\n }\n if (isFirstUpdate) {\n status.isFirstUpdate = true;\n }\n if (orgCSSText) {\n status.orgCSSText = orgCSSText;\n }\n return status;\n }\n private get _names() {\n return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical;\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 _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 resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useRoundedSize,\n useResizeObserver,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useResizeObserver,\n }).on(\"resize\", this._onResize);\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n useRoundedSize,\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;\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 const useOrgResize = options.useOrgResize;\n\n items.forEach((item) => {\n if (useOrgResize) {\n const orgRect = item.orgRect;\n\n orgRect.width = 0;\n orgRect.height = 0;\n }\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 * ```js\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 */\n public renderItems(options: RenderOptions = {}) {\n this._renderItems(options);\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 * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false)\n */\n public getStatus(minimize?: boolean): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => minimize ? item.getMinimizedStatus() : 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 direction: this.defaultDirection,\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Get the inline size corresponding to outline.\n * @ko outline에 해당하는 inline 사이즈를 구한다.\n * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineSize(items: GridItem[] = this.items) {\n return this.options.outlineSize! || this.getContainerInlineSize();\n }\n /**\n * Get the length corresponding to outline.\n * @ko outline에 해당하는 length를 가져온다.\n * @param items - Items to get outline length. outline length를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineLength(items: GridItem[] = this.items): number {\n return this.options.outlineLength! || 1;\n }\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\n this._im?.destroy();\n }\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?.parentNode && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n mounted.filter((item) => {\n if (item.hasTransition) {\n return true;\n } else {\n const element = item.element!;\n const transitionDuration = parseFloat(getComputedStyle(element).transitionDuration);\n\n if (transitionDuration > 0) {\n item.hasTransition = true;\n item.transitionDuration = element.style.transitionDuration;\n return true;\n }\n }\n return false;\n }).forEach((item) => {\n item.element!.style.transitionDuration = \"0s\";\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 // reset org size\n updated.forEach((item) => {\n const hasOrgSize = item.orgRect.width && item.orgRect.height;\n const hasCSSSize = item.cssRect.width || item.cssRect.height;\n\n if (!hasOrgSize && hasCSSSize) {\n item.element!.style.cssText = item.orgCSSText;\n }\n });\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 * @example\n * ```js\n * grid.on(\"contentError\", e => {\n * e.update();\n * });\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\n updated.forEach((item) => {\n item.isUpdate = true;\n });\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n updated.forEach((item) => {\n item.isUpdate = false;\n });\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n\n const transitionMounted = mounted.filter((item) => item.hasTransition);\n\n if (transitionMounted.length) {\n this.containerManager.resize();\n transitionMounted.forEach((item) => {\n const element = item.element!;\n\n element.style.transitionDuration = item.transitionDuration;\n });\n }\n this._renderComplete({\n direction,\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 * @example\n * ```js\n * grid.on(\"renderComplete\", e => {\n * console.log(e.mounted, e.updated, e.useResize);\n * });\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 this._renderItems({\n useResize: true,\n }, true);\n }\n private _init() {\n this._resizeContainer();\n }\n private _renderItems(options: RenderOptions = {}, isTrusted?: boolean) {\n this._clearRenderTimer();\n\n const isResize = options.useResize || options.useOrgResize;\n\n\n if (isResize && !isTrusted) {\n // Resize container\n // isTrusted has already been resized internally.\n this._resizeContainer();\n }\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (isResize) {\n // Update all items\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\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 * @default 0\n * @example\n * ```js\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/**\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 * @default \"end\"\n * @example\n * ```js\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/**\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 * @default true\n * @example\n * ```js\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\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 * @default false\n * @example\n * ```js\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\n\n/**\n * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.\n * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineLength\n * @type {$ts:Grid.GridOptions[\"outlineLength\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineLength = 3;\n * ```\n */\n\n\n/**\n * The size of the outline. If the outline size is 0, it is calculated according to the grid type.\n * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineSize\n * @type {$ts:Grid.GridOptions[\"outlineSize\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineSize = 300;\n * ```\n */\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. Can be used instead of outlineLength. (default: 0)열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.(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. Can be used instead of outlineSize. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.(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 * @property - Difference Threshold for Counting Columns. Since offsetSize is calculated by rounding, the number of columns may not be accurate. (default: 1) 칼럼 개수를 계산하기 위한 차이 임계값. offset 사이즈는 반올림으로 게산하기 때문에 정확하지 않을 수 있다. (default: 1)\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n columnCalculationThreshold?: number;\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 * @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 columnCalculationThreshold: 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 columnCalculationThreshold: 0.5,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const columnSize = this.getComputedOutlineSize(items);\n const column = this.getComputedOutlineLength(items);\n\n const {\n gap,\n align,\n columnSizeRatio,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses(column, columnSize);\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[pointCalculationName](...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 contentSize = item.contentSize;\n let columnCount = Math.min(\n column,\n columnAttribute || Math.max(1, Math.ceil((item.inlineSize + gap) / columnDist)),\n );\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 // stretch mode or data-grid-column > \"1\"\n if ((columnAttribute > 0 && columnCount > 1) || isStretch) {\n item.cssInlineSize = (columnCount - 1) * columnDist + columnSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = item.computedInlineSize / 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 public getComputedOutlineSize(items = this.items) {\n const {\n gap,\n align,\n } = this.options;\n const columnSizeOption = this.columnSize || this.outlineSize;\n const column = this.column || this.outlineLength || 1;\n\n let columnSize = 0;\n\n if (align === \"stretch\") {\n columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n columnSize = columnSizeOption;\n } else if (items.length) {\n let checkedItem = items[0];\n\n for (const item of items) {\n const attributes = item.attributes;\n if (\n item.updateState !== UPDATE_STATE.UPDATED\n || !item.inlineSize\n || attributes.column\n || attributes.maxColumnCount\n ) {\n continue;\n }\n checkedItem = item;\n break;\n }\n const inlineSize = checkedItem.inlineSize || 0;\n\n columnSize = inlineSize;\n } else {\n columnSize = this.getContainerInlineSize();\n }\n return columnSize || 0;\n }\n public getComputedOutlineLength(items = this.items) {\n const gap = this.gap;\n const columnOption = this.column || this.outlineLength;\n const columnCalculationThreshold = this.columnCalculationThreshold;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else {\n const columnSize = this.getComputedOutlineSize(items);\n\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap)\n / (columnSize - columnCalculationThreshold + gap))),\n );\n }\n return column;\n }\n private _getAlignPoses(column: number, columnSize: number) {\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\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @default \"justify\"\n * @example\n * ```js\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/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. Can be used instead of outlineLength.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. Can be used instead of outlineSize.\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set.\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @default 0\n * @example\n * ```js\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 */\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 { MOUNT_STATE, PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } 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 rowSize;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n return ratio * (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 {\n attributePrefix,\n horizontal,\n } = this.options;\n\n items.forEach((item) => {\n if (!item.isUpdate) {\n return;\n }\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0;\n\n if (\n element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)\n && item.mountState === MOUNT_STATE.MOUNTED\n ) {\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 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 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 ratioSum += 1;\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 = contentSize <= contentOffset ? 1\n : (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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수.\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @default [1, 8]\n * @example\n * ```js\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/**\n * The minimum and maximum number of rows in a group, 0 is not set.\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다.\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @default 0\n * @example\n * ```js\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/**\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.\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다.\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @default [0, Infinity]\n * @example\n * ```js\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/**\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.\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다.\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @default -1\n * @example\n * ```js\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/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken.\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다.\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @default false\n * @example\n * ```js\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","/**\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.length ? outline : [0];\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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill)\n : getOutlinePoint(endOutline, gridOutline, 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 public getComputedOutlineLength() {\n const frame = this.options.frame;\n\n return frame.length ? frame[0].length : 0;\n }\n public getComputedOutlineSize() {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption.inlineSize;\n }\n return rectSizeOption || ((this.getContainerInlineSize()! + gap) / this.getComputedOutlineLength() - gap);\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.\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다.\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @default []\n * @example\n * ```js\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/**\n * Make sure that the frame can be attached after the previous frame.\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @default true\n * @example\n * ```js\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/**\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 * ```js\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 */\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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize).\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The priority that determines the weight of the item. \"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 아이템의 가중치를 결정하는 우선수치. \"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 * @default \"custom\"\n * @example\n * ```js\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/**\n * The size weight when placing items.\n * @ko 아이템들을 배치하는데 사이즈 가중치.\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The weight to keep ratio when placing items.\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치.\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @default 1\n * @example\n * ```js\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","/**\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\";\nexport * from \"./ItemRenderer\";\nexport * from \"./types\";\nexport * from \"./Grid\";\nexport * from \"./GridItem\";\nexport * from \"./ContainerManager\";\nexport * from \"./ResizeWatcher\";\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","outlineLength","outlineSize","useRoundedSize","useResizeObserver","PROPERTY_TYPE","MOUNT_STATE","UPDATE_STATE","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","GRID_EVENTS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","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","descriptor","getOwnPropertyDescriptor","getter","get","options","setter","set","prevValue","scheduleRender","enumerable","configurable","defineProperty","withMethods","methods","memberName","forEach","_i","args","result","_a","range","arr","push","getRangeCost","valueRange","Math","max","withGridMethods","container","width","height","clearTimeout","_this","_resizeTimer","_maxResizeDebounceTimer","watchDirection","_options","prevRect","rect","resize","isWatchWidth","isWatchHeight","isResize","_emitter","trigger","window","setTimeout","_onResize","useWindowResize","rectBox","document","querySelector","_init","setRect","offsetWidth","offsetHeight","clientWidth","clientHeight","callback","on","_observer","disconnect","removeEventListener","Component","ResizeObserver","_scheduleResize","observe","box","addEventListener","__extends","_super","_watcher","getRect","_names","status","setContentSize","getContentSize","size","sizeName","style","destroy","preserveUI","cssText","orgCSSText","getComputedStyle","position","ResizeWatcher","listen","initialRect","items","item","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","posPercetage","sizePercetage","orgRect","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","clientRect","getBoundingClientRect","isFirstUpdate","mountState","MOUNTED","NEED_UPDATE","UPDATED","cssRect","cssTexts","_b","posName","getInlineSize","filter","key","map","join","itemStatus","data","UNCHECKED","gridData","gridRect","names","containerElement","start","end","_renderItems","useResize","constructor","defaultOptions","containerManager","ContainerManager","itemRenderer","ItemRenderer","Grid","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","renderItems","useOrgResize","checkReady","minimize","getMinimizedStatus","getStatus","prevInlineSize","setStatus","_renderComplete","direction","mounted","updated","getContainerInlineSize","_im","parentNode","moreUpdated","hasTransition","transitionDuration","parseFloat","ImReady","prefix","e","hasCSSSize","updateItems","readyItems","isPreReadyOver","target","update","check","_clearRenderTimer","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","prevOutline","outline","nextOutlines","isUpdate","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","transitionMounted","endPoint","startPoint","setContainerRect","_resizeContainer","isTrusted","getItems","syncElements","getColumnPoint","columnIndex","columnCount","pointCaculationName","getColumnIndex","nearestCalculationName","indexCaculationName","points","columnSize","getComputedOutlineSize","column","getComputedOutlineLength","align","columnSizeRatio","itemsLength","alignPoses","_getAlignPoses","isEndDirection","pointCalculationName","point_1","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","nextEndColumnIndex","nextColumnIndex","cssInlineSize","computedInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","columnSizeOption","checkedItem","items_1","columnOption","columnCalculationThreshold","floor","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","contentOffset","ratio","maintainedTarget","widthOffset","scrollWidth","heightOffset","scrollHeight","rowRange","_getRowPath","_getPath","_setStyle","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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AA,GAAR,UAAmB+P,IAAnB;IACE,QAAMra,OAAO,GAAG,KAAKA,OAArB;IACA,QAAM6c,cAAc,GAAG7c,OAAO,CAAC6c,cAA/B;;IAEA,QAAIA,cAAc,KAAKxC,IAAvB,EAA6B;IAC3B,aAAO,GAAP;IACD,KAFD,MAEO,IAAIwC,cAAc,KAAK,QAAvB,EAAiC;IACtC,aAAO7c,OAAO,CAAIqa,IAAI,WAAR,CAAd;IACD;;IACD,WAAO,CAAP;IACD,GAVO;;IAzIMyC,EAAAA,yBAAA,yBACTtU,IAAI,CAAC9I;IACR4b,IAAAA,WAAW,EAAEre,aAAa,CAACI;IAC3B0e,IAAAA,UAAU,EAAE9e,aAAa,CAACI;IAC1B4e,IAAAA,WAAW,EAAEhf,aAAa,CAACI;IAC3Bwf,IAAAA,cAAc,EAAE5f,aAAa,CAACI;QALlB;IAOAyf,EAAAA,0BAAA,yBACTtU,IAAI,CAACL;IACRmT,IAAAA,WAAW,EAAE;IACbS,IAAAA,UAAU,EAAE;IACZE,IAAAA,WAAW,EAAE;IACbY,IAAAA,cAAc,EAAE;QALJ;IARHC,EAAAA,WAAW,eADvBvd,eACYud,YAAA;IAqJb,oBAAA;IAAC,EArJgCtU,KAAjC;IA2JA;;;;;;;;;;;;;;;;;;IAkBA;;;;;;;;;;;;;;;;;;;;;;;IAuBA;;;;;;;;;;;;;;;;;;IAmBA;;;;;;;;;;;;;;;;;;ICnSA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ICAA;;;;;AAKA;IAEA,KAAK,IAAMpJ,IAAX,IAAmB2d,OAAnB,EAA4B;IACzBvU,EAAAA,IAAY,CAACpJ,IAAD,CAAZ,GAAsB2d,OAAe,CAAC3d,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..e4fb936 --- /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.9.0 +*/ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).Grid=t()}(this,function(){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var p=function(){return(p=Object.assign||function(e){for(var t,n=1,i=arguments.length;n=e.length?void 0:e)&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function s(){for(var e=[],t=0;tf))break;if(!_&&(p<0||O[p]) = {\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 outlineLength: 0,\n outlineSize: 0,\n useRoundedSize: true,\n useResizeObserver: false,\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 outlineSize: PROPERTY_TYPE.RENDER_PROPERTY,\n outlineLength: PROPERTY_TYPE.RENDER_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 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\n const descriptor = Object.getOwnPropertyDescriptor(prototype, name) || {};\n\n const getter = descriptor.get || function get(this: Grid) {\n return this.options[name];\n };\n const setter = descriptor.set || function 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 const attributes: Record = {\n enumerable: true,\n configurable: true,\n get: getter,\n set: setter,\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","import Component from \"@egjs/component\";\nimport { SizeRect } from \"./types\";\nimport { isString } from \"./utils\";\n\nexport interface ResizeWatherOptions {\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n useWindowResize?: boolean;\n watchDirection?: \"width\" | \"height\" | \"box\" | false;\n rectBox?: \"border-box\" | \"content-box\";\n}\n\nexport class ResizeWatcher {\n private _resizeTimer = 0;\n private _maxResizeDebounceTimer = 0;\n private _emitter: Component<{ resize: void }>;\n private _observer: ResizeObserver | null;\n protected container: HTMLElement;\n protected rect: SizeRect = { width: 0, height: 0 };\n private _options!: Required;\n\n constructor(container: HTMLElement | string, options: ResizeWatherOptions = {}) {\n this._options = {\n resizeDebounce: 100,\n maxResizeDebounce: 0,\n useResizeObserver: false,\n useWindowResize: true,\n watchDirection: false,\n rectBox: \"content-box\",\n ...options,\n };\n\n this.container = isString(container) ? document.querySelector(container)! : container;\n this._init();\n }\n public getRect() {\n return this.rect;\n }\n public setRect(rect: SizeRect) {\n this.rect = { ...rect };\n }\n public resize() {\n const container = this.container;\n\n this.setRect(this._options.rectBox === \"border-box\" ? {\n width: container.offsetWidth,\n height: container.offsetHeight,\n } : {\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public listen(callback: () => void) {\n this._emitter.on(\"resize\", callback);\n return this;\n }\n public destroy() {\n this._observer?.disconnect();\n if (this._options.useWindowResize) {\n window.removeEventListener(\"reisze\", this._onResize);\n }\n }\n private _init() {\n const container = this.container;\n const options = this._options;\n\n this._emitter = new Component();\n if (options.useResizeObserver && !!window.ResizeObserver) {\n this._observer = new window.ResizeObserver(this._scheduleResize);\n this._observer.observe(container, {\n box: options.rectBox,\n });\n }\n if (options.useWindowResize) {\n window.addEventListener(\"resize\", this._scheduleResize);\n }\n this.resize();\n }\n private _onResize = () => {\n clearTimeout(this._resizeTimer);\n clearTimeout(this._maxResizeDebounceTimer);\n\n this._maxResizeDebounceTimer = 0;\n this._resizeTimer = 0;\n\n const watchDirection = this._options.watchDirection;\n const prevRect = this.rect;\n this.resize();\n const rect = this.rect;\n const isWatchWidth = watchDirection === \"box\" || watchDirection === \"width\";\n const isWatchHeight = watchDirection === \"box\" || watchDirection === \"height\";\n const isResize = !watchDirection\n || (isWatchWidth && prevRect.width !== rect.width)\n || (isWatchHeight && prevRect.height !== rect.height);\n\n if (isResize) {\n this._emitter.trigger(\"resize\");\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","/**\n * egjs-grid\n * Copyright (c) 2021-present NAVER Corp.\n * MIT license\n */\nimport Component from \"@egjs/component\";\nimport { DestroyOptions, SizeRect } from \"./types\";\nimport { ResizeWatcher } from \"./ResizeWatcher\";\nimport { DEFAULT_GRID_OPTIONS, RECT_NAMES } from \"./consts\";\n\nexport interface ContainerManagerOptions {\n horizontal?: boolean;\n autoResize?: boolean;\n resizeDebounce?: number;\n maxResizeDebounce?: number;\n useResizeObserver?: boolean;\n}\n\nexport interface ContainerManagerStatus {\n rect: SizeRect;\n}\nexport interface ContainerManagerEvents {\n resize: void;\n}\nexport class ContainerManager extends Component {\n protected options: Required;\n protected orgCSSText: string;\n private _watcher: ResizeWatcher;\n\n constructor(protected container: HTMLElement, options: ContainerManagerOptions) {\n super();\n this.options = {\n horizontal: DEFAULT_GRID_OPTIONS.horizontal,\n autoResize: DEFAULT_GRID_OPTIONS.autoResize,\n resizeDebounce: DEFAULT_GRID_OPTIONS.resizeDebounce,\n maxResizeDebounce: DEFAULT_GRID_OPTIONS.maxResizeDebounce,\n useResizeObserver: DEFAULT_GRID_OPTIONS.useResizeObserver,\n ...options,\n };\n\n this._init();\n }\n public resize() {\n const container = this.container;\n\n this.setRect({\n width: container.clientWidth,\n height: container.clientHeight,\n });\n }\n public getRect() {\n return this._watcher.getRect();\n }\n public setRect(rect: SizeRect) {\n this._watcher.setRect(rect);\n }\n public getInlineSize() {\n return this.getRect()[this._names.inlineSize];\n }\n public getContentSize() {\n return this.getRect()[this._names.contentSize];\n }\n public getStatus() {\n return { rect: this._watcher.getRect() };\n }\n public setStatus(status: ContainerManagerStatus) {\n this.setRect(status.rect);\n this.setContentSize(this.getContentSize());\n }\n public setContentSize(size: number) {\n const sizeName = this.options.horizontal ? \"width\" : \"height\";\n this.setRect({\n ...this.getRect(),\n [sizeName]: size,\n });\n this.container.style[sizeName] = `${size}px`;\n }\n public destroy(options: DestroyOptions = {}) {\n this._watcher.destroy();\n\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 const options = this.options;\n\n this._watcher = new ResizeWatcher(container, {\n useWindowResize: options.autoResize,\n useResizeObserver: options.useResizeObserver,\n resizeDebounce: options.resizeDebounce,\n maxResizeDebounce: options.maxResizeDebounce,\n watchDirection: options.useResizeObserver ? this._names.inlineSize : false,\n }).listen(this._onResize);\n }\n private _onResize = () => {\n this.trigger(\"resize\");\n }\n private get _names() {\n return RECT_NAMES[this.options.horizontal ? \"horizontal\" : \"vertical\"];\n }\n}\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 useRoundedSize?: 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 useRoundedSize: DEFAULT_GRID_OPTIONS.useRoundedSize,\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, useRoundedSize } = 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: 0,\n height: 0,\n };\n if (useRoundedSize) {\n rect.width = element.offsetWidth;\n rect.height = element.offsetHeight;\n } else {\n const clientRect = element.getBoundingClientRect();\n\n rect.width = clientRect.width;\n rect.height = clientRect.height;\n }\n }\n if (!item.isFirstUpdate || !hasOrgSize) {\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 * @property - Grid ready data for rendering. 렌더링을 하기 위한 grid의 준비 데이터.\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 gridData?: Record;\n}\n\n/**\n * @memberof Grid\n * @implements Grid.GridItem.GridItemStatus\n */\nclass GridItem {\n public isUpdate = false;\n public hasTransition = false;\n public transitionDuration = \"\";\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 gridData: {},\n ...itemStatus,\n };\n\n for (const name in status) {\n this[name] = status[name];\n }\n }\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 name = this._names.inlineSize;\n\n return this.orgRect[name] || this.rect[name];\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 name = this._names.contentSize;\n\n return this.orgRect[name] || this.rect[name];\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 return this.rect[this._names.inlineSize];\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 return this.rect[this._names.contentSize];\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 return this.cssRect[this._names.inlineSize];\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 return this.cssRect[this._names.contentSize];\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 return this.cssRect[this._names.inlinePos];\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 return this.cssRect[this._names.contentPos];\n }\n public set cssInlinePos(inlinePos: number | undefined) {\n this.cssRect[this._names.inlinePos] = inlinePos;\n }\n public set cssContentPos(contentPos: number | undefined) {\n this.cssRect[this._names.contentPos] = contentPos;\n }\n public set cssInlineSize(inlineSize: number | undefined) {\n this.cssRect[this._names.inlineSize] = inlineSize;\n }\n public set cssContentSize(contentSize: number | undefined) {\n this.cssRect[this._names.contentSize] = contentSize;\n }\n /**\n * Calculated size in the direction of the inline applied to the grid. \"width\" if horizontal is false, \"height\" otherwise.\n * @ko Grid에 적용된 inline 방향의 계산된 사이즈. horizontal이 false면 \"width\", 아니면 \"height\".\n * @member Grid.GridItem#computedInlineSize\n */\n public get computedInlineSize() {\n const name = this._names.inlineSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated size in the direction of the content applied to the grid. \"height\" if horizontal is false, \"width\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 사이즈. horizontal이 false면 \"height\", 아니면 \"width\".\n * @member Grid.GridItem#computedContentSize\n */\n public get computedContentSize() {\n const name = this._names.contentSize;\n\n return this.cssRect[name] || this.rect[name] || this.orgRect[name];\n }\n /**\n * Calculated position in the direction of the inline applied to the grid. \"left\" if horizontal is false, \"top\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"left\", 아니면 \"top\".\n * @member Grid.GridItem#computedInlinePos\n */\n public get computedInlinePos() {\n const name = this._names.inlinePos;\n\n return this.cssRect[name] ?? this.rect[name];\n }\n /**\n * Calculated position in the direction of the content applied to the grid. \"top\" if horizontal is false, \"left\" otherwise.\n * @ko Grid에 적용된 content 방향의 계산된 포지션. horizontal이 false면 \"top\", 아니면 \"left\".\n * @member Grid.GridItem#computedContentPos\n */\n public get computedContentPos() {\n const name = this._names.contentPos;\n\n return this.cssRect[name] ?? this.rect[name];\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 gridData: this.gridData,\n data: this.data,\n };\n }\n /**\n * Returns minimized status of the item.\n * @ko 아이템의 간소화된 상태를 반환한다.\n */\n public getMinimizedStatus(): Partial {\n const status: Partial = {\n orgRect: this.orgRect,\n rect: this.rect,\n cssRect: this.cssRect,\n attributes: this.attributes,\n gridData: this.gridData,\n };\n\n const {\n key,\n mountState,\n updateState,\n isFirstUpdate,\n orgCSSText,\n } = this;\n if (typeof key !== \"undefined\") {\n status.key = key;\n }\n if (mountState !== MOUNT_STATE.UNCHECKED) {\n status.mountState = mountState;\n }\n if (updateState !== UPDATE_STATE.NEED_UPDATE) {\n status.updateState = updateState;\n }\n if (isFirstUpdate) {\n status.isFirstUpdate = true;\n }\n if (orgCSSText) {\n status.orgCSSText = orgCSSText;\n }\n return status;\n }\n private get _names() {\n return this.horizontal ? RECT_NAMES.horizontal : RECT_NAMES.vertical;\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 _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 resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useRoundedSize,\n useResizeObserver,\n } = this.options;\n\n // TODO: 테스트용 설정\n this.containerManager = externalContainerManager!\n || new ContainerManager(this.containerElement, {\n horizontal,\n resizeDebounce,\n maxResizeDebounce,\n autoResize,\n useResizeObserver,\n }).on(\"resize\", this._onResize);\n this.itemRenderer = externalItemRenderer!\n || new ItemRenderer({\n useTransform,\n isEqualSize,\n isConstantSize,\n percentage,\n useRoundedSize,\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;\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 const useOrgResize = options.useOrgResize;\n\n items.forEach((item) => {\n if (useOrgResize) {\n const orgRect = item.orgRect;\n\n orgRect.width = 0;\n orgRect.height = 0;\n }\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 * ```js\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 */\n public renderItems(options: RenderOptions = {}) {\n this._renderItems(options);\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 * @param - Whether to minimize the status of the item. (default: false) item의 status를 최소화할지 여부. (default: false)\n */\n public getStatus(minimize?: boolean): GridStatus {\n return {\n outlines: this.outlines,\n items: this.items.map((item) => minimize ? item.getMinimizedStatus() : 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 direction: this.defaultDirection,\n mounted: this.items,\n updated: [],\n isResize: false,\n });\n });\n }\n return this;\n }\n /**\n * Get the inline size corresponding to outline.\n * @ko outline에 해당하는 inline 사이즈를 구한다.\n * @param items - Items to get outline size. outline 사이즈를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineSize(items: GridItem[] = this.items) {\n return this.options.outlineSize! || this.getContainerInlineSize();\n }\n /**\n * Get the length corresponding to outline.\n * @ko outline에 해당하는 length를 가져온다.\n * @param items - Items to get outline length. outline length를 구하기 위한 아이템들.\n */\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n public getComputedOutlineLength(items: GridItem[] = this.items): number {\n return this.options.outlineLength! || 1;\n }\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\n this._im?.destroy();\n }\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?.parentNode && item.updateState !== UPDATE_STATE.UPDATED);\n const mounted: GridItem[] = updated.filter((item) => item.mountState !== MOUNT_STATE.MOUNTED);\n const moreUpdated: GridItem[] = [];\n\n mounted.filter((item) => {\n if (item.hasTransition) {\n return true;\n } else {\n const element = item.element!;\n const transitionDuration = parseFloat(getComputedStyle(element).transitionDuration);\n\n if (transitionDuration > 0) {\n item.hasTransition = true;\n item.transitionDuration = element.style.transitionDuration;\n return true;\n }\n }\n return false;\n }).forEach((item) => {\n item.element!.style.transitionDuration = \"0s\";\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 // reset org size\n updated.forEach((item) => {\n const hasOrgSize = item.orgRect.width && item.orgRect.height;\n const hasCSSSize = item.cssRect.width || item.cssRect.height;\n\n if (!hasOrgSize && hasCSSSize) {\n item.element!.style.cssText = item.orgCSSText;\n }\n });\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 * @example\n * ```js\n * grid.on(\"contentError\", e => {\n * e.update();\n * });\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\n updated.forEach((item) => {\n item.isUpdate = true;\n });\n if (items.length) {\n nextOutlines = this.applyGrid(this.items, direction, prevOutline);\n }\n updated.forEach((item) => {\n item.isUpdate = false;\n });\n this.setOutlines(nextOutlines);\n this.fitOutlines();\n this.itemRenderer.renderItems(this.items);\n this._refreshContainerContentSize();\n\n const transitionMounted = mounted.filter((item) => item.hasTransition);\n\n if (transitionMounted.length) {\n this.containerManager.resize();\n transitionMounted.forEach((item) => {\n const element = item.element!;\n\n element.style.transitionDuration = item.transitionDuration;\n });\n }\n this._renderComplete({\n direction,\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 * @example\n * ```js\n * grid.on(\"renderComplete\", e => {\n * console.log(e.mounted, e.updated, e.useResize);\n * });\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 this._renderItems({\n useResize: true,\n }, true);\n }\n private _init() {\n this._resizeContainer();\n }\n private _renderItems(options: RenderOptions = {}, isTrusted?: boolean) {\n this._clearRenderTimer();\n\n const isResize = options.useResize || options.useOrgResize;\n\n\n if (isResize && !isTrusted) {\n // Resize container\n // isTrusted has already been resized internally.\n this._resizeContainer();\n }\n\n if (!this.getItems().length && this.getChildren().length) {\n this.syncElements(options);\n } else if (isResize) {\n // Update all items\n this.updateItems(this.items, options);\n } else {\n // Update only items that need to be updated.\n this.checkReady(options);\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 * @default 0\n * @example\n * ```js\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/**\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 * @default \"end\"\n * @example\n * ```js\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/**\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 * @default true\n * @example\n * ```js\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\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 * @default false\n * @example\n * ```js\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\n\n/**\n * The number of outlines. If the number of outlines is 0, it is calculated according to the type of grid.\n * @ko outline의 개수. 아웃라인의 개수가 0이라면 grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineLength\n * @type {$ts:Grid.GridOptions[\"outlineLength\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineLength = 3;\n * ```\n */\n\n\n/**\n * The size of the outline. If the outline size is 0, it is calculated according to the grid type.\n * @ko outline의 사이즈. 만약 outline의 사이즈가 0이면, grid의 종류에 따라 계산이 된다.\n * @name Grid#outlineSize\n * @type {$ts:Grid.GridOptions[\"outlineSize\"]}\n * @default 0\n * @example\n * ```js\n * import { MasonryGrid } from \"@egjs/grid\";\n *\n * const grid = new MasonryGrid(container, {\n * outlineLength: 0,\n * outlineSize: 0,\n * });\n *\n * grid.outlineSize = 300;\n * ```\n */\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. Can be used instead of outlineLength. (default: 0)열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.(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. Can be used instead of outlineSize. (default: 0) 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.(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 * @property - Difference Threshold for Counting Columns. Since offsetSize is calculated by rounding, the number of columns may not be accurate. (default: 1) 칼럼 개수를 계산하기 위한 차이 임계값. offset 사이즈는 반올림으로 게산하기 때문에 정확하지 않을 수 있다. (default: 1)\n */\nexport interface MasonryGridOptions extends GridOptions {\n column?: number;\n columnSize?: number;\n columnSizeRatio?: number;\n align?: GridAlign;\n columnCalculationThreshold?: number;\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 * @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 columnCalculationThreshold: 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 columnCalculationThreshold: 0.5,\n };\n\n public applyGrid(items: GridItem[], direction: \"start\" | \"end\", outline: number[]): GridOutlines {\n const columnSize = this.getComputedOutlineSize(items);\n const column = this.getComputedOutlineLength(items);\n\n const {\n gap,\n align,\n columnSizeRatio,\n } = this.options;\n const outlineLength = outline.length;\n const itemsLength = items.length;\n const alignPoses = this._getAlignPoses(column, columnSize);\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[pointCalculationName](...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 contentSize = item.contentSize;\n let columnCount = Math.min(\n column,\n columnAttribute || Math.max(1, Math.ceil((item.inlineSize + gap) / columnDist)),\n );\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 // stretch mode or data-grid-column > \"1\"\n if ((columnAttribute > 0 && columnCount > 1) || isStretch) {\n item.cssInlineSize = (columnCount - 1) * columnDist + columnSize;\n }\n if (columnSizeRatio > 0) {\n contentSize = item.computedInlineSize / 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 public getComputedOutlineSize(items = this.items) {\n const {\n gap,\n align,\n } = this.options;\n const columnSizeOption = this.columnSize || this.outlineSize;\n const column = this.column || this.outlineLength || 1;\n\n let columnSize = 0;\n\n if (align === \"stretch\") {\n columnSize = (this.getContainerInlineSize() + gap) / (column || 1) - gap;\n } else if (columnSizeOption) {\n columnSize = columnSizeOption;\n } else if (items.length) {\n let checkedItem = items[0];\n\n for (const item of items) {\n const attributes = item.attributes;\n if (\n item.updateState !== UPDATE_STATE.UPDATED\n || !item.inlineSize\n || attributes.column\n || attributes.maxColumnCount\n ) {\n continue;\n }\n checkedItem = item;\n break;\n }\n const inlineSize = checkedItem.inlineSize || 0;\n\n columnSize = inlineSize;\n } else {\n columnSize = this.getContainerInlineSize();\n }\n return columnSize || 0;\n }\n public getComputedOutlineLength(items = this.items) {\n const gap = this.gap;\n const columnOption = this.column || this.outlineLength;\n const columnCalculationThreshold = this.columnCalculationThreshold;\n let column = 1;\n\n if (columnOption) {\n column = columnOption;\n } else {\n const columnSize = this.getComputedOutlineSize(items);\n\n column = Math.min(\n items.length,\n Math.max(1, Math.floor((this.getContainerInlineSize() + gap)\n / (columnSize - columnCalculationThreshold + gap))),\n );\n }\n return column;\n }\n private _getAlignPoses(column: number, columnSize: number) {\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\")\n * @ko 아이템들의 위치의 정렬. `stretch`를 사용하고 싶다면 `column` 또는 `columnSize` 옵션을 설정해라. (\"start\", \"center\", \"end\", \"justify\", \"stretch\")\n * @name Grid.MasonryGrid#align\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"align\"]}\n * @default \"justify\"\n * @example\n * ```js\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/**\n * The number of columns. If the number of columns is 0, it is automatically calculated according to the size of the container. Can be used instead of outlineLength.\n * @ko 열의 개수. 열의 개수가 0이라면, 컨테이너의 사이즈에 의해 계산이 된다. outlineLength 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#column\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"column\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size of the columns. If it is 0, it is calculated as the size of the first item in items. Can be used instead of outlineSize.\n * @ko 열의 사이즈. 만약 열의 사이즈가 0이면, 아이템들의 첫번째 아이템의 사이즈로 계산이 된다. outlineSize 대신 사용할 수 있다.\n * @name Grid.MasonryGrid#columnSize\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSize\"]}\n * @default 0\n * @example\n * ```js\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/**\n * The size ratio(inlineSize / contentSize) of the columns. 0 is not set.\n * @ko 열의 사이즈 비율(inlineSize / contentSize). 0은 미설정이다.\n * @name Grid.MasonryGrid#columnSizeRatio\n * @type {$ts:Grid.MasonryGrid.MasonryGridOptions[\"columnSizeRatio\"]}\n * @default 0\n * @example\n * ```js\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 */\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 { MOUNT_STATE, PROPERTY_TYPE } from \"../consts\";\nimport { GridOptions, Properties, GridOutlines } 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 rowSize;\n }\n const inlineOffset = parseFloat(item.gridData.inlineOffset) || 0;\n const contentOffset = parseFloat(item.gridData.contentOffset) || 0;\n const ratio = contentSize <= contentOffset ? 1 : (inlineSize - inlineOffset) / (contentSize - contentOffset);\n\n return ratio * (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 {\n attributePrefix,\n horizontal,\n } = this.options;\n\n items.forEach((item) => {\n if (!item.isUpdate) {\n return;\n }\n const element = item.element;\n const attributes = item.attributes;\n const gridData = item.gridData;\n let inlineOffset = parseFloat(attributes.inlineOffset) || gridData.inlineOffset || 0;\n let contentOffset = parseFloat(attributes.contentOffset) || gridData.contentOffset | 0;\n\n if (\n element && !(\"inlineOffset\" in attributes) && !(\"contentOffset\" in attributes)\n && item.mountState === MOUNT_STATE.MOUNTED\n ) {\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 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 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 ratioSum += 1;\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 = contentSize <= contentOffset ? 1\n : (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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 한 줄에 들어가는 아이템의 최소, 최대 개수.\n * @name Grid.JustifiedGrid#columnRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"columnRange\"]}\n * @default [1, 8]\n * @example\n * ```js\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/**\n * The minimum and maximum number of rows in a group, 0 is not set.\n * @ko 한 그룹에 들어가는 행의 최소, 최대 개수, 0은 미설정이다.\n * @name Grid.JustifiedGrid#rowRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"rowRange\"]}\n * @default 0\n * @example\n * ```js\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/**\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.\n * @ko 아이템이 조정되는 최소, 최대 사이즈. 계산이 되지 않는 경우 최소, 최대 사이즈를 벗어날 수 있다.\n * @name Grid.JustifiedGrid#sizeRange\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"sizeRange\"]}\n * @default [0, Infinity]\n * @example\n * ```js\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/**\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.\n * @ko - 컨테이너 크기에 계산될 최대 row 개수. overflow: hidden을 설정하면 화면에 가릴 수 있다. -1은 미설정이다.\n * @name Grid.JustifiedGrid#displayedRow\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"displayedRow\"]}\n * @default -1\n * @example\n * ```js\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/**\n * Whether to crop when the row size is out of sizeRange. If set to true, this ratio can be broken.\n * @ko - row 사이즈가 sizeRange에 벗어나면 크롭할지 여부. true로 설정하면 비율이 깨질 수 있다.\n * @name Grid.JustifiedGrid#isCroppedSize\n * @type {$ts:Grid.JustifiedGrid.JustifiedGridOptions[\"isCroppedSize\"]}\n * @default false\n * @example\n * ```js\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","/**\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.length ? outline : [0];\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 ? getOutlinePoint(gridOutline, startOutline, useFrameFill)\n : getOutlinePoint(endOutline, gridOutline, 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 public getComputedOutlineLength() {\n const frame = this.options.frame;\n\n return frame.length ? frame[0].length : 0;\n }\n public getComputedOutlineSize() {\n const {\n gap,\n rectSize: rectSizeOption,\n } = this.options;\n\n if (typeof rectSizeOption === \"object\") {\n return rectSizeOption.inlineSize;\n }\n return rectSizeOption || ((this.getContainerInlineSize()! + gap) / this.getComputedOutlineLength() - gap);\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.\n * @ko Grid의 모양. 2d 배열([contentPos][inlinePos])로 아이템의 모양과 순서를 설정할 수 있다. 숫자로 배열을 채운만큼 아이템을 배치할 수 있으며 0과 공백은 빈 공간이다. 아이템들의 순서는 배열을 채운 숫자값의 오름차순대로 배치가 된다.\n * @name Grid.FrameGrid#frame\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"frame\"]}\n * @default []\n * @example\n * ```js\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/**\n * Make sure that the frame can be attached after the previous frame.\n * @ko 다음 프레임이 전 프레임에 이어 붙일 수 있는지 있는지 확인한다.\n * @name Grid.FrameGrid#useFrameFill\n * @type {$ts:Grid.FrameGrid.FrameGridOptions[\"useFrameFill\"]}\n * @default true\n * @example\n * ```js\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/**\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 * ```js\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 */\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 public getComputedOutlineLength() {\n return 1;\n }\n public getComputedOutlineSize() {\n return this.getContainerInlineSize();\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.\n * @ko 아이템들을 가진 컨테이너의 종횡비(inlineSize / contentSize).\n * @name Grid.PackingGrid#aspectRatio\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"aspectRatio\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The priority that determines the weight of the item. \"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 아이템의 가중치를 결정하는 우선수치. \"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 * @default \"custom\"\n * @example\n * ```js\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/**\n * The size weight when placing items.\n * @ko 아이템들을 배치하는데 사이즈 가중치.\n * @name Grid.PackingGrid#sizeWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"sizeWeight\"]}\n * @default 1\n * @example\n * ```js\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/**\n * The weight to keep ratio when placing items.\n * @ko 아이템들을 배치하는데 비율을 유지하는 가중치.\n * @name Grid.PackingGrid#ratioWeight\n * @type {$ts:Grid.PackingGrid.PackingGridOptions[\"ratioWeight\"]}\n * @default 1\n * @example\n * ```js\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","/**\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","outlineLength","outlineSize","useRoundedSize","useResizeObserver","GRID_PROPERTY_TYPES","RENDER_PROPERTY","PROPERTY","GRID_METHODS","RECT_NAMES","inlinePos","contentPos","inlineSize","contentSize","vertical","isString","val","isObject","GetterSetter","component","name","prototype","propertyTypes","shouldRender","descriptor","Object","getOwnPropertyDescriptor","defineProperty","enumerable","configurable","get","this","options","set","value","scheduleRender","withMethods","methods","memberName","forEach","_i","args","result","_a","range","length","arr","i","push","getRangeCost","valueRange","Math","max","withGridMethods","container","width","height","clearTimeout","_this","_resizeTimer","_maxResizeDebounceTimer","watchDirection","_options","prevRect","rect","resize","_emitter","trigger","window","setTimeout","_onResize","useWindowResize","rectBox","document","querySelector","_init","setRect","offsetWidth","offsetHeight","clientWidth","clientHeight","callback","on","_observer","disconnect","removeEventListener","Component","ResizeObserver","_scheduleResize","observe","box","addEventListener","_super","__extends","_watcher","getRect","_names","status","setContentSize","getContentSize","size","sizeName","style","destroy","preserveUI","cssText","orgCSSText","getComputedStyle","position","ResizeWatcher","listen","initialRect","items","item","_renderItem","containerRect","_updateItem","sizePercentage","posPercentage","indexOf","posPercetage","sizePercetage","orgRect","element","isLoading","updateState","WAIT_LOADING","hasOrgSize","left","offsetLeft","top","offsetTop","clientRect","getBoundingClientRect","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","gridData","gridRect","names","containerElement","start","end","_renderItems","useResize","constructor","defaultOptions","containerManager","ContainerManager","itemRenderer","ItemRenderer","slice","call","children","outlines","elements","getChildren","diff","added","maintained","changed","removed","nextItems","beforeIndex","afterIndex","index","GridItem","setItems","renderItems","useOrgResize","checkReady","minimize","getMinimizedStatus","getStatus","prevInlineSize","setStatus","_renderComplete","direction","mounted","updated","isResize","getContainerInlineSize","_im","parentNode","moreUpdated","hasTransition","parseFloat","transitionDuration","ImReady","prefix","e","hasCSSSize","updateItems","readyItems","isPreReadyOver","target","update","check","_clearRenderTimer","_renderTimer","startOutline","endOutline","outlineOffset","min","point","cssContentPos","prevOutlines","prevOutline","outline","nextOutlines","isUpdate","applyGrid","setOutlines","fitOutlines","_refreshContainerContentSize","transitionMounted","endPoint","startPoint","setContainerRect","_resizeContainer","isTrusted","getItems","syncElements","Grid","getColumnPoint","columnIndex","columnCount","pointCaculationName","point_1","columnSize","getComputedOutlineSize","column","getComputedOutlineLength","align","columnSizeRatio","itemsLength","alignPoses","_getAlignPoses","isEndDirection","nearestCalculationName","pointCalculationName","columnDist","isStretch","columnAttribute","parseInt","maxColumnAttribute","maxColumn","ceil","maxColumnCount","indexCaculationName","points","nextEndColumnIndex","nextColumnIndex","cssInlineSize","computedInlineSize","cssContentSize","cssInlinePos","nextOutlinePoint","indexOffset","columnSizeOption","checkedItem","items_1","columnOption","columnCalculationThreshold","floor","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","contentOffset","heightOffset","maintainedTarget","widthOffset","scrollWidth","scrollHeight","rowRange","path","_getRowPath","_getPath","_setStyle","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","getOutlinePoint","frameOutline","useFrameFill","minEndPoint","minPoint","getMinPoint","maxStartPoint","frameDist","outlineIndex","startPos","endPos","getOutlineDist","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","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":";;;;;;;;k6DA8BYA,EAIAC,EAKAC,wyDAhCCC,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,EAC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ud,WAAYhf,EAAcyB,gBAC1Byd,YAAalf,EAAcyB,gBAC3Bqe,eAAgB9f,EAAcyB,kBAElBse,wBACTrP,GAAK7E,iBACRsS,YAAa,EACba,WAAY,EACZE,YAAa,EACbY,eAAgB,cAdnBzd,GACY0d,IAAoBrP,iOZXN,CACzB,iBACA,8Ba5DF,IAAWnO,MAAQyd,GAChBtP,GAAanO,IAASyd,GAAgBzd"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3609f5a..ceacfa2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@egjs/grid", - "version": "1.8.0-snapshot", + "version": "1.9.0", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 0aaef1a..6c47e86 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/grid", - "version": "1.8.0-snapshot", + "version": "1.9.0", "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 7d6bd67..150d718 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.8.0", + "version": "1.9.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -18,9 +18,9 @@ "integrity": "sha512-Mze3mwEE19+dERrimg0JVLtpOHG4AC+LOuKqvF4qGZjn0k23ZbNI7b/gy1LFR63LigC2b8k70aDjy8xoT+WNPA==" }, "@egjs/grid": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.8.0.tgz", - "integrity": "sha512-kV3kJorMWgSfAagdaI/dhrb5SCG44WV5YWYg6QRutMUN+7JQ5tHiTDqaev+IHjq1NL9vMkCs9wjb5Uw+PfPuqQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.9.0.tgz", + "integrity": "sha512-LduXcibZObqqfsgaR5vGx4FXCSMMy585WDaVVh6Mxlg07oVXier6BL2C0Vl9qmDGe5B1eISMChFWScEHBZtQIA==", "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 27b56b4..d09b542 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.8.0", + "version": "1.9.0", "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.8.0", + "@egjs/grid": "~1.9.0", "tslib": "^2.0.0" } } diff --git a/packages/ngx-grid/projects/ngx-grid/src/lib/ngx-grid.component.ts b/packages/ngx-grid/projects/ngx-grid/src/lib/ngx-grid.component.ts index 2f1fb62..f854564 100644 --- a/packages/ngx-grid/projects/ngx-grid/src/lib/ngx-grid.component.ts +++ b/packages/ngx-grid/projects/ngx-grid/src/lib/ngx-grid.component.ts @@ -46,6 +46,7 @@ export class NgxGridComponent @Input() outlineLength!: Required['outlineLength']; @Input() outlineSize!: Required['outlineSize']; @Input() useRoundedSize!: Required['useRoundedSize']; + @Input() useResizeObserver!: Required['useResizeObserver']; @Output() renderComplete!: EventEmitter; @Output() contentError!: EventEmitter; diff --git a/packages/react-grid/package-lock.json b/packages/react-grid/package-lock.json index 4ec1804..8bf8449 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.8.0", + "version": "1.9.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1455,9 +1455,9 @@ "integrity": "sha512-Mze3mwEE19+dERrimg0JVLtpOHG4AC+LOuKqvF4qGZjn0k23ZbNI7b/gy1LFR63LigC2b8k70aDjy8xoT+WNPA==" }, "@egjs/grid": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.8.0.tgz", - "integrity": "sha512-kV3kJorMWgSfAagdaI/dhrb5SCG44WV5YWYg6QRutMUN+7JQ5tHiTDqaev+IHjq1NL9vMkCs9wjb5Uw+PfPuqQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.9.0.tgz", + "integrity": "sha512-LduXcibZObqqfsgaR5vGx4FXCSMMy585WDaVVh6Mxlg07oVXier6BL2C0Vl9qmDGe5B1eISMChFWScEHBZtQIA==", "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 69f33a4..48b37d5 100644 --- a/packages/react-grid/package.json +++ b/packages/react-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/react-grid", - "version": "1.8.0", + "version": "1.9.0", "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.8.0" + "@egjs/grid": "~1.9.0" }, "devDependencies": { "@codeceptjs/configure": "^0.6.2", diff --git a/packages/svelte-grid/package-lock.json b/packages/svelte-grid/package-lock.json index b05edd5..f254432 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.8.0", + "version": "1.9.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1292,9 +1292,9 @@ "integrity": "sha512-Mze3mwEE19+dERrimg0JVLtpOHG4AC+LOuKqvF4qGZjn0k23ZbNI7b/gy1LFR63LigC2b8k70aDjy8xoT+WNPA==" }, "@egjs/grid": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.8.0.tgz", - "integrity": "sha512-kV3kJorMWgSfAagdaI/dhrb5SCG44WV5YWYg6QRutMUN+7JQ5tHiTDqaev+IHjq1NL9vMkCs9wjb5Uw+PfPuqQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.9.0.tgz", + "integrity": "sha512-LduXcibZObqqfsgaR5vGx4FXCSMMy585WDaVVh6Mxlg07oVXier6BL2C0Vl9qmDGe5B1eISMChFWScEHBZtQIA==", "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 8b958d5..48905ba 100644 --- a/packages/svelte-grid/package.json +++ b/packages/svelte-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/svelte-grid", - "version": "1.8.0", + "version": "1.9.0", "description": "A Svelte component that can arrange items according to the type of grids", "sideEffects": false, "svelte": "src/index.js", @@ -69,6 +69,6 @@ "typescript": "^4.0.0" }, "dependencies": { - "@egjs/grid": "~1.8.0" + "@egjs/grid": "~1.9.0" } } diff --git a/packages/vue-grid/package-lock.json b/packages/vue-grid/package-lock.json index ee18374..dbc59bf 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.8.0", + "version": "1.9.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1347,9 +1347,9 @@ "integrity": "sha512-Mze3mwEE19+dERrimg0JVLtpOHG4AC+LOuKqvF4qGZjn0k23ZbNI7b/gy1LFR63LigC2b8k70aDjy8xoT+WNPA==" }, "@egjs/grid": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.8.0.tgz", - "integrity": "sha512-kV3kJorMWgSfAagdaI/dhrb5SCG44WV5YWYg6QRutMUN+7JQ5tHiTDqaev+IHjq1NL9vMkCs9wjb5Uw+PfPuqQ==", + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@egjs/grid/-/grid-1.9.0.tgz", + "integrity": "sha512-LduXcibZObqqfsgaR5vGx4FXCSMMy585WDaVVh6Mxlg07oVXier6BL2C0Vl9qmDGe5B1eISMChFWScEHBZtQIA==", "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 bf07faf..ec3ab47 100644 --- a/packages/vue-grid/package.json +++ b/packages/vue-grid/package.json @@ -1,6 +1,6 @@ { "name": "@egjs/vue-grid", - "version": "1.8.0", + "version": "1.9.0", "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.8.0" + "@egjs/grid": "~1.9.0" }, "devDependencies": { "@babel/core": "^7.12.10",