@revolist/revogrid 4.10.0 → 4.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{column.drag.plugin-7098477f.js → column.drag.plugin-08ca04f4.js} +18 -18
- package/dist/cjs/column.drag.plugin-08ca04f4.js.map +1 -0
- package/dist/cjs/column.service-2670e6e7.js +1286 -0
- package/dist/cjs/column.service-2670e6e7.js.map +1 -0
- package/dist/cjs/{edit.utils-75fa1cab.js → edit.utils-4a790cf8.js} +2 -2
- package/dist/cjs/{edit.utils-75fa1cab.js.map → edit.utils-4a790cf8.js.map} +1 -1
- package/dist/cjs/{header-cell-renderer-aaaad4c8.js → header-cell-renderer-db089f54.js} +2 -2
- package/dist/cjs/{header-cell-renderer-aaaad4c8.js.map → header-cell-renderer-db089f54.js.map} +1 -1
- package/dist/cjs/{column.service-f1d5d924.js → index-91e92bea.js} +452 -1227
- package/dist/cjs/index-91e92bea.js.map +1 -0
- package/dist/cjs/index.cjs.js +20 -20
- package/dist/cjs/{key.utils-8f1105f3.js → key.utils-e65c24e6.js} +2 -2
- package/dist/cjs/{key.utils-8f1105f3.js.map → key.utils-e65c24e6.js.map} +1 -1
- package/dist/cjs/revo-grid.cjs.entry.js +26 -26
- package/dist/cjs/revo-grid.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-attribution_7.cjs.entry.js +11 -11
- package/dist/cjs/revogr-attribution_7.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js +5 -4
- package/dist/cjs/revogr-clipboard_3.cjs.entry.js.map +1 -1
- package/dist/cjs/revogr-data_4.cjs.entry.js +9 -9
- package/dist/cjs/revogr-data_4.cjs.entry.js.map +1 -1
- package/dist/cjs/{row-header-utils-208e4026.js → row-header-utils-dc3d3185.js} +5 -6
- package/dist/cjs/row-header-utils-dc3d3185.js.map +1 -0
- package/dist/cjs/{text-editor-b64a080e.js → text-editor-a32a3993.js} +3 -3
- package/dist/cjs/{text-editor-b64a080e.js.map → text-editor-a32a3993.js.map} +1 -1
- package/dist/cjs/{throttle-3b362440.js → throttle-da92b75d.js} +2 -2
- package/dist/cjs/{throttle-3b362440.js.map → throttle-da92b75d.js.map} +1 -1
- package/dist/collection/components/order/revogr-order-editor.js +4 -2
- package/dist/collection/components/order/revogr-order-editor.js.map +1 -1
- package/dist/collection/components/revoGrid/revo-grid.js.map +1 -1
- package/dist/esm/{column.drag.plugin-813698d2.js → column.drag.plugin-b7bba0da.js} +6 -6
- package/dist/esm/{column.drag.plugin-813698d2.js.map → column.drag.plugin-b7bba0da.js.map} +1 -1
- package/dist/esm/column.service-9b0603f4.js +1249 -0
- package/dist/esm/column.service-9b0603f4.js.map +1 -0
- package/dist/esm/{debounce-72878ced.js → debounce-7b511afc.js} +2 -2
- package/dist/esm/{debounce-72878ced.js.map → debounce-7b511afc.js.map} +1 -1
- package/dist/esm/{edit.utils-cd6a3224.js → edit.utils-abcd0152.js} +2 -2
- package/dist/esm/{edit.utils-cd6a3224.js.map → edit.utils-abcd0152.js.map} +1 -1
- package/dist/esm/{header-cell-renderer-5939221a.js → header-cell-renderer-fce020c3.js} +2 -2
- package/dist/esm/{header-cell-renderer-5939221a.js.map → header-cell-renderer-fce020c3.js.map} +1 -1
- package/dist/esm/{column.service-aa142672.js → index-b1e05212.js} +411 -1187
- package/dist/esm/index-b1e05212.js.map +1 -0
- package/dist/esm/index.js +8 -8
- package/dist/esm/{key.utils-5ff2ec82.js → key.utils-ea9aec31.js} +2 -2
- package/dist/esm/{key.utils-5ff2ec82.js.map → key.utils-ea9aec31.js.map} +1 -1
- package/dist/esm/revo-grid.entry.js +6 -6
- package/dist/esm/revo-grid.entry.js.map +1 -1
- package/dist/esm/revogr-attribution_7.entry.js +7 -7
- package/dist/esm/revogr-clipboard_3.entry.js +6 -5
- package/dist/esm/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/esm/revogr-data_4.entry.js +5 -5
- package/dist/esm/revogr-filter-panel.entry.js +1 -1
- package/dist/esm/{row-header-utils-5511678e.js → row-header-utils-7af8fcbf.js} +2 -3
- package/dist/esm/row-header-utils-7af8fcbf.js.map +1 -0
- package/dist/esm/{text-editor-81767dcb.js → text-editor-fb3f24fe.js} +3 -3
- package/dist/esm/{text-editor-81767dcb.js.map → text-editor-fb3f24fe.js.map} +1 -1
- package/dist/esm/{throttle-4eff5b3c.js → throttle-1f5772ef.js} +3 -3
- package/dist/esm/{throttle-4eff5b3c.js.map → throttle-1f5772ef.js.map} +1 -1
- package/dist/revo-grid/column.drag.plugin-b7bba0da.js +5 -0
- package/dist/revo-grid/{column.drag.plugin-813698d2.js.map → column.drag.plugin-b7bba0da.js.map} +1 -1
- package/dist/revo-grid/column.service-9b0603f4.js +5 -0
- package/dist/revo-grid/column.service-9b0603f4.js.map +1 -0
- package/dist/revo-grid/{debounce-72878ced.js → debounce-7b511afc.js} +2 -2
- package/dist/revo-grid/{edit.utils-cd6a3224.js → edit.utils-abcd0152.js} +2 -2
- package/dist/revo-grid/{header-cell-renderer-5939221a.js → header-cell-renderer-fce020c3.js} +2 -2
- package/dist/revo-grid/index-b1e05212.js +5 -0
- package/dist/revo-grid/index-b1e05212.js.map +1 -0
- package/dist/revo-grid/index.esm.js +1 -1
- package/dist/revo-grid/key.utils-ea9aec31.js +5 -0
- package/dist/revo-grid/{key.utils-5ff2ec82.js.map → key.utils-ea9aec31.js.map} +1 -1
- package/dist/revo-grid/revo-grid.entry.js +1 -1
- package/dist/revo-grid/revo-grid.entry.js.map +1 -1
- package/dist/revo-grid/revogr-attribution_7.entry.js +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js +1 -1
- package/dist/revo-grid/revogr-clipboard_3.entry.js.map +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js +1 -1
- package/dist/revo-grid/revogr-data_4.entry.js.map +1 -1
- package/dist/revo-grid/revogr-filter-panel.entry.js +1 -1
- package/dist/revo-grid/row-header-utils-7af8fcbf.js +5 -0
- package/dist/revo-grid/{row-header-utils-5511678e.js.map → row-header-utils-7af8fcbf.js.map} +1 -1
- package/dist/revo-grid/text-editor-fb3f24fe.js +5 -0
- package/dist/revo-grid/{throttle-4eff5b3c.js → throttle-1f5772ef.js} +2 -2
- package/dist/types/components/order/revogr-order-editor.d.ts +1 -0
- package/dist/types/components/revoGrid/revo-grid.d.ts +1 -5
- package/dist/types/components.d.ts +2 -0
- package/hydrate/index.js +24 -23
- package/hydrate/index.mjs +24 -23
- package/package.json +1 -1
- package/readme.md +10 -12
- package/standalone/column.service.js +1 -1
- package/standalone/data.store.js +21 -2
- package/standalone/data.store.js.map +1 -1
- package/standalone/dimension.helpers.js +1 -1
- package/standalone/revo-grid.js +1 -2
- package/standalone/revo-grid.js.map +1 -1
- package/standalone/revogr-header2.js +1 -1
- package/standalone/revogr-order-editor2.js +2 -0
- package/standalone/revogr-order-editor2.js.map +1 -1
- package/dist/cjs/column.drag.plugin-7098477f.js.map +0 -1
- package/dist/cjs/column.service-f1d5d924.js.map +0 -1
- package/dist/cjs/index-aecb871a.js +0 -510
- package/dist/cjs/index-aecb871a.js.map +0 -1
- package/dist/cjs/row-header-utils-208e4026.js.map +0 -1
- package/dist/esm/column.service-aa142672.js.map +0 -1
- package/dist/esm/index-dbd1c020.js +0 -473
- package/dist/esm/index-dbd1c020.js.map +0 -1
- package/dist/esm/row-header-utils-5511678e.js.map +0 -1
- package/dist/revo-grid/column.drag.plugin-813698d2.js +0 -5
- package/dist/revo-grid/column.service-aa142672.js +0 -5
- package/dist/revo-grid/column.service-aa142672.js.map +0 -1
- package/dist/revo-grid/index-dbd1c020.js +0 -5
- package/dist/revo-grid/index-dbd1c020.js.map +0 -1
- package/dist/revo-grid/key.utils-5ff2ec82.js +0 -5
- package/dist/revo-grid/row-header-utils-5511678e.js +0 -5
- package/dist/revo-grid/text-editor-81767dcb.js +0 -5
- package/standalone/identity.js +0 -26
- package/standalone/identity.js.map +0 -1
- /package/dist/revo-grid/{debounce-72878ced.js.map → debounce-7b511afc.js.map} +0 -0
- /package/dist/revo-grid/{edit.utils-cd6a3224.js.map → edit.utils-abcd0152.js.map} +0 -0
- /package/dist/revo-grid/{header-cell-renderer-5939221a.js.map → header-cell-renderer-fce020c3.js.map} +0 -0
- /package/dist/revo-grid/{text-editor-81767dcb.js.map → text-editor-fb3f24fe.js.map} +0 -0
- /package/dist/revo-grid/{throttle-4eff5b3c.js.map → throttle-1f5772ef.js.map} +0 -0
package/dist/revo-grid/{row-header-utils-5511678e.js.map → row-header-utils-7af8fcbf.js.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["getUpdatedItemsByPosition","pos","items","realCount","virtualSize","dimension","activeItem","getItemByPosition","firstItem","getFirstItem","toUpdate","changedOffsetStart","itemIndex","recombineByOffset","Math","abs","Object","assign","positiveDirection","maxSizeVirtualSize","getMaxVirtualSize","realSize","extra","addMissingItems","length","updateMissingAndRange","getItems","firstItemStart","start","firstItemIndex","origSize","originItemSize","maxSize","maxCount","sizes","end","min","missing","range","splice","existingCollection","lastItem","getLastItem","opt","currentSize","index","size","newSize","getItemSize","push","offset","data","newItems","itemsCount","newRange","undefined","i","newIndex","newEnd","Error","_a","newStart","console","error","_b","isActiveRange","first","last","isActiveRangeOutsideLastItem","s","setItemSizes","vpItems","initialIndex","lastCoordinate","count","item","initialState","ViewportStore","this","lastKnownScroll","value","constructor","type","store","createStore","setViewPortCoordinate","position","force","viewportSize","get","frameOffset","singleOffsetInPx","outsize","maxCoordinate","allItems","setViewport","setOriginalSizes","setStore","LETTER_BLOCK_SIZE","calculateRowHeaderSize","itemsLength","rowHeaderColumn","minWidth","max","toString"],"sources":["src/store/vp/viewport.helpers.ts","src/store/vp/viewport.store.ts","src/utils/row-header-utils.ts"],"sourcesContent":["import {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n ViewportStateItems,\n VirtualPositionItem,\n Range,\n} from '@type';\n\nimport { getItemByPosition } from '../dimension/dimension.helpers';\n\nexport type DimensionDataViewport = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'sizes'\n | 'originItemSize'\n | 'realSize'\n>;\n\nexport type ItemsToUpdate = Pick<ViewportStateItems, 'items' | 'start' | 'end'>;\n/**\n * Update items based on new scroll position\n * If viewport wasn't changed fully simple recombination of positions\n * Otherwise rebuild viewport items\n */\nexport function getUpdatedItemsByPosition<T extends ItemsToUpdate>(\n pos: number, // coordinate\n items: T,\n realCount: number,\n virtualSize: number,\n dimension: DimensionDataViewport,\n): ItemsToUpdate {\n const activeItem: PositionItem = getItemByPosition(dimension, pos);\n const firstItem = getFirstItem(items);\n let toUpdate: ItemsToUpdate | undefined;\n // do simple position recombination if items already present in viewport\n if (firstItem) {\n let changedOffsetStart = activeItem.itemIndex - (firstItem.itemIndex || 0);\n // if item changed\n if (changedOffsetStart) {\n // simple recombination\n toUpdate = recombineByOffset(Math.abs(changedOffsetStart), {\n positiveDirection: changedOffsetStart > -1,\n ...dimension,\n ...items,\n });\n }\n }\n\n const maxSizeVirtualSize = getMaxVirtualSize(\n virtualSize,\n dimension.realSize,\n activeItem,\n );\n // if partial recombination add items if revo-viewport has some space left\n if (toUpdate) {\n const extra = addMissingItems(\n activeItem,\n realCount,\n maxSizeVirtualSize,\n toUpdate,\n dimension,\n );\n if (extra.length) {\n updateMissingAndRange(toUpdate.items, extra, toUpdate);\n }\n }\n\n // new collection if no items after replacement full replacement\n if (!toUpdate) {\n const items = getItems({\n firstItemStart: activeItem.start,\n firstItemIndex: activeItem.itemIndex,\n origSize: dimension.originItemSize,\n maxSize: maxSizeVirtualSize,\n maxCount: realCount,\n sizes: dimension.sizes,\n });\n\n // range now comes from 0 to length - 1\n toUpdate = {\n items,\n start: 0,\n end: items.length - 1,\n };\n }\n return toUpdate;\n}\n\n// virtual size can differ based on scroll position if some big items are present\n// scroll can be in the middle of item and virtual size will be larger\n// so we need to exclude this part from virtual size hence it's already passed\nfunction getMaxVirtualSize(\n virtualSize: number,\n realSize: number,\n activeItem: PositionItem,\n) {\n return Math.min(virtualSize + (activeItem.end - activeItem.start), realSize);\n}\n\nexport function updateMissingAndRange(\n items: VirtualPositionItem[],\n missing: VirtualPositionItem[],\n range: Range,\n) {\n items.splice(range.end + 1, 0, ...missing);\n // update range if start larger after recombination\n if (\n range.start >= range.end &&\n !(range.start === range.end && range.start === 0)\n ) {\n range.start += missing.length;\n }\n range.end += missing.length;\n}\n\n/**\n * If partial replacement\n * this function adds items if viewport has some space left\n */\nexport function addMissingItems<T extends ItemsToUpdate>(\n firstItem: PositionItem,\n realCount: number,\n virtualSize: number,\n existingCollection: T,\n dimension: Pick<DimensionSettingsState, 'sizes' | 'originItemSize'>,\n): VirtualPositionItem[] {\n const lastItem: VirtualPositionItem = getLastItem(existingCollection);\n const items = getItems({\n sizes: dimension.sizes,\n firstItemStart: lastItem.end,\n firstItemIndex: lastItem.itemIndex + 1,\n origSize: dimension.originItemSize,\n maxSize: virtualSize - (lastItem.end - firstItem.start),\n maxCount: realCount,\n });\n return items;\n}\n\n/**\n * Get wiewport items parameters\n * caching position and calculating items count in viewport\n */\nexport function getItems(\n opt: {\n firstItemIndex: number;\n firstItemStart: number;\n origSize: number;\n maxSize: number; // virtual size\n maxCount: number; // real item count, where the last item\n sizes?: ViewSettingSizeProp;\n },\n currentSize = 0,\n) {\n const items: VirtualPositionItem[] = [];\n\n let index = opt.firstItemIndex;\n let size = currentSize;\n\n // max size or max count\n while (size <= opt.maxSize && index < opt.maxCount) {\n const newSize = getItemSize(index, opt.sizes, opt.origSize);\n items.push({\n start: opt.firstItemStart + size,\n end: opt.firstItemStart + size + newSize,\n itemIndex: index,\n size: newSize,\n });\n size += newSize;\n index++;\n }\n return items;\n}\n\n/**\n * Do batch items recombination\n * If items not overlapped with existing viewport returns null\n */\ntype RecombindDimensionData = Pick<\n DimensionSettingsState,\n 'sizes' | 'realSize' | 'originItemSize'\n>;\ntype RecombineOffsetData = {\n positiveDirection: boolean;\n} & ItemsToUpdate &\n RecombindDimensionData;\nexport function recombineByOffset(\n offset: number,\n data: RecombineOffsetData,\n): ItemsToUpdate | undefined {\n const newItems = [...data.items];\n const itemsCount = newItems.length;\n let newRange = {\n start: data.start,\n end: data.end,\n };\n\n // if offset out of revo-viewport, makes sense whole redraw\n if (offset > itemsCount) {\n return undefined;\n }\n\n // is direction of scroll positive\n if (data.positiveDirection) {\n // push item to the end\n let lastItem: VirtualPositionItem = getLastItem(data);\n\n let i = newRange.start;\n const length = i + offset;\n for (; i < length; i++) {\n const newIndex = lastItem.itemIndex + 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // if item overlapped limit break a loop\n if (lastItem.end + size > data.realSize) {\n break;\n }\n\n // new item index to recombine\n let newEnd = i % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newEnd]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newEnd] = lastItem = {\n start: lastItem.end,\n end: lastItem.end + size,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start++;\n newRange.end = newEnd;\n }\n\n // direction is negative\n } else {\n // push item to the start\n let firstItem = getFirstItem(data);\n\n const end = newRange.end;\n for (let i = 0; i < offset; i++) {\n const newIndex = (firstItem?.itemIndex ?? 0) - 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // new item index to recombine\n let newStart = end - i;\n newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newStart]) {\n console.error('incorrect index');\n break;\n }\n\n // do recombination\n const firstItemStart = firstItem?.start ?? 0;\n newItems[newStart] = firstItem = {\n start: firstItemStart - size,\n end: firstItemStart,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start = newStart;\n newRange.end--;\n }\n }\n const range = {\n start:\n (newRange.start < 0 ? itemsCount + newRange.start : newRange.start) %\n itemsCount,\n end:\n (newRange.end < 0 ? itemsCount + newRange.end : newRange.end) %\n itemsCount,\n };\n return {\n items: newItems,\n ...range,\n };\n}\n\nfunction getItemSize(\n index: number,\n sizes?: ViewSettingSizeProp,\n origSize = 0,\n): number {\n if (sizes && sizes[index]) {\n return sizes[index];\n }\n return origSize;\n}\n\n/**\n * Verify if position is in range of the PositionItem, start and end are included\n */\nexport function isActiveRange(\n pos: number,\n realSize: number,\n first?: PositionItem,\n last?: PositionItem,\n): boolean {\n if (!first || !last) {\n return false;\n }\n // if position is in range of first item\n // or position is after first item and last item is the last item in real size\n return (\n (pos >= first.start && pos <= first.end) ||\n (pos > first.end && last.end === realSize)\n );\n}\n\nexport function isActiveRangeOutsideLastItem(\n pos: number,\n virtualSize: number,\n firstItem?: PositionItem,\n lastItem?: PositionItem,\n) {\n // if no first item, means no items in viewport\n if (!firstItem) {\n return false;\n }\n return virtualSize + pos > (lastItem?.end ?? 0);\n}\n\nexport function getFirstItem(\n s: ItemsToUpdate,\n) {\n return s.items[s.start];\n}\n\nexport function getLastItem(s: ItemsToUpdate): VirtualPositionItem {\n return s.items[s.end];\n}\n\n/**\n * Set items sizes from start index to end\n * @param vpItems\n * @param start\n * @param size\n * @param lastCoordinate\n * @returns\n */\nexport function setItemSizes(\n vpItems: VirtualPositionItem[],\n initialIndex: number,\n size: number,\n lastCoordinate: number,\n) {\n const items = [...vpItems];\n const count = items.length;\n\n let pos = lastCoordinate;\n let i = 0;\n let start = initialIndex;\n\n // viewport not inited\n if (!count) {\n return [];\n }\n // loop through array from initial item after recombination\n while (i < count) {\n const item = items[start];\n item.start = pos;\n item.size = size;\n item.end = item.start + size;\n pos = item.end;\n // loop by start index\n start++;\n i++;\n\n // if start index out of array, reset it\n if (start === count) {\n start = 0;\n }\n }\n return items;\n}\n","import {\n DimensionDataViewport,\n addMissingItems,\n getFirstItem,\n getLastItem,\n getUpdatedItemsByPosition,\n isActiveRange,\n setItemSizes,\n updateMissingAndRange,\n isActiveRangeOutsideLastItem,\n ItemsToUpdate,\n} from './viewport.helpers';\nimport { createStore } from '@stencil/store';\nimport { type Observable, setStore } from '../../utils/store.utils';\nimport type {\n VirtualPositionItem,\n ViewportState,\n MultiDimensionType,\n} from '@type';\n\n/**\n * Viewport store\n * Used for virtualization (process of rendering only visible part of data)\n * Redraws viewport based on position and dimension\n */\nfunction initialState(): ViewportState {\n return {\n // virtual item information per rendered item\n items: [],\n // virtual dom item order to render\n start: 0,\n end: 0,\n\n // size of viewport in px\n virtualSize: 0,\n\n // total number of items\n realCount: 0,\n };\n}\n\n/**\n * Viewport store class\n */\nexport class ViewportStore {\n readonly store: Observable<ViewportState>;\n\n // last coordinate for store position restore\n private lastKnownScroll = 0;\n\n get lastCoordinate() {\n return this.lastKnownScroll;\n }\n set lastCoordinate(value: number) {\n this.lastKnownScroll = value;\n }\n constructor(readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n }\n\n /**\n * Render viewport based on coordinate\n * It's the main method for draw\n * Use force if you want to re-render viewport\n */\n setViewPortCoordinate(\n position: number,\n dimension: DimensionDataViewport,\n force = false,\n ) {\n const viewportSize = this.store.get('virtualSize');\n // no visible data to calculate\n if (!viewportSize) {\n return;\n }\n\n const frameOffset = 1;\n const singleOffsetInPx = dimension.originItemSize * frameOffset;\n // add offset to virtual size from both sides\n const outsize = singleOffsetInPx * 2;\n // math virtual size is based on visible area + 2 items outside of visible area\n const virtualSize = viewportSize + outsize;\n\n // expected no scroll if real size less than virtual size, position is 0\n let maxCoordinate = 0;\n // if there is nodes outside of viewport, max coordinate has to be adjusted\n if (dimension.realSize > viewportSize) {\n // max coordinate is real size minus virtual/rendered space\n maxCoordinate = dimension.realSize - viewportSize - singleOffsetInPx;\n }\n\n let pos = position;\n // limit position to max and min coordinates\n if (pos < 0) {\n pos = 0;\n } else if (pos > maxCoordinate) {\n pos = maxCoordinate;\n }\n\n // store last coordinate for further restore on redraw\n this.lastCoordinate = pos;\n\n // actual position is less than first item start based on offset\n pos -= singleOffsetInPx;\n pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;\n\n let allItems: ItemsToUpdate;\n // if force clear all items and start from 0\n if (force) {\n allItems = {\n items: [],\n start: 0,\n end: 0,\n };\n } else {\n allItems = this.getItems();\n }\n\n const firstItem: VirtualPositionItem | undefined = getFirstItem(allItems);\n const lastItem: VirtualPositionItem | undefined = getLastItem(allItems);\n\n let toUpdate: Partial<ViewportState> = {};\n\n // left position changed\n // verify if new position is in range of previously rendered first item\n if (!isActiveRange(pos, dimension.realSize, firstItem, lastItem)) {\n toUpdate = {\n ...toUpdate,\n ...getUpdatedItemsByPosition(\n pos,\n allItems,\n this.store.get('realCount'),\n virtualSize,\n dimension,\n ),\n };\n this.setViewport({ ...toUpdate });\n // verify is render area is outside of last item\n } else if (\n isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)\n ) {\n const items = [...allItems.items];\n // check is any item missing for fulfill content\n const missing = addMissingItems(\n firstItem,\n this.store.get('realCount'),\n virtualSize + pos - firstItem.start,\n allItems,\n {\n sizes: dimension.sizes,\n originItemSize: dimension.originItemSize,\n },\n );\n\n // update missing items\n if (missing.length) {\n const range = {\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n updateMissingAndRange(items, missing, range);\n toUpdate = {\n ...toUpdate,\n items: [...items],\n ...range,\n };\n this.setViewport({ ...toUpdate });\n }\n }\n }\n\n /**\n * Set sizes for existing items\n */\n setOriginalSizes(size: number) {\n const items = this.store.get('items');\n const count = items.length;\n // viewport not inited\n if (!count) {\n return;\n }\n\n setStore(this.store, {\n items: setItemSizes(\n items,\n this.store.get('start'),\n size,\n this.lastCoordinate,\n ),\n });\n }\n\n getItems(): ItemsToUpdate {\n return {\n items: this.store.get('items'),\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n }\n\n setViewport(data: Partial<ViewportState>) {\n // drop items on virtual size change, require a new item set\n // drop items on real size change, require a new item set\n if (typeof data.realCount === 'number' || typeof data.virtualSize === 'number') {\n data = { ...data, items: data.items || [] };\n }\n setStore(this.store, data);\n }\n}\n","import { RowHeaders } from '..';\n\nconst LETTER_BLOCK_SIZE = 10;\nexport const calculateRowHeaderSize = (\n itemsLength: number,\n rowHeaderColumn?: RowHeaders,\n minWidth = 50,\n) => {\n return (\n rowHeaderColumn?.size ||\n Math.max((itemsLength.toString().length + 1) * LETTER_BLOCK_SIZE, minWidth)\n );\n};\n"],"mappings":";;;yGA2BgBA,EACdC,EACAC,EACAC,EACAC,EACAC,GAEA,MAAMC,EAA2BC,EAAkBF,EAAWJ,GAC9D,MAAMO,EAAYC,EAAaP,GAC/B,IAAIQ,EAEJ,GAAIF,EAAW,CACb,IAAIG,EAAqBL,EAAWM,WAAaJ,EAAUI,WAAa,GAExE,GAAID,EAAoB,CAEtBD,EAAWG,EAAkBC,KAAKC,IAAIJ,GAAmBK,OAAAC,OAAAD,OAAAC,OAAA,CACvDC,kBAAmBP,GAAsB,GACtCN,GACAH,G,EAKT,MAAMiB,EAAqBC,EACzBhB,EACAC,EAAUgB,SACVf,GAGF,GAAII,EAAU,CACZ,MAAMY,EAAQC,EACZjB,EACAH,EACAgB,EACAT,EACAL,GAEF,GAAIiB,EAAME,OAAQ,CAChBC,EAAsBf,EAASR,MAAOoB,EAAOZ,E,EAKjD,IAAKA,EAAU,CACb,MAAMR,EAAQwB,EAAS,CACrBC,eAAgBrB,EAAWsB,MAC3BC,eAAgBvB,EAAWM,UAC3BkB,SAAUzB,EAAU0B,eACpBC,QAASb,EACTc,SAAU9B,EACV+B,MAAO7B,EAAU6B,QAInBxB,EAAW,CACTR,QACA0B,MAAO,EACPO,IAAKjC,EAAMsB,OAAS,E,CAGxB,OAAOd,CACT,CAKA,SAASU,EACPhB,EACAiB,EACAf,GAEA,OAAOQ,KAAKsB,IAAIhC,GAAeE,EAAW6B,IAAM7B,EAAWsB,OAAQP,EACrE,C,SAEgBI,EACdvB,EACAmC,EACAC,GAEApC,EAAMqC,OAAOD,EAAMH,IAAM,EAAG,KAAME,GAElC,GACEC,EAAMV,OAASU,EAAMH,OAC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AUoB,MAC9BkE,EACA,CACE5D,MAAO7B,EAAU6B,MACjBH,eAAgB1B,EAAU0B,iBAK9B,GAAIM,EAAQb,OAAQ,CAClB,MAAMc,EAAQ,CACZV,MAAOkD,KAAKK,MAAMM,IAAI,SACtBtD,IAAK2C,KAAKK,MAAMM,IAAI,QAEtBhE,EAAsBvB,EAAOmC,EAASC,GACtC5B,EAAQM,OAAAC,OAAAD,OAAAC,OAAAD,OAAAC,OAAA,GACHP,GAAQ,CACXR,MAAO,IAAIA,KACRoC,GAELwC,KAAKiB,YAAW/E,OAAAC,OAAA,GAAMP,G,GAQ5B,gBAAAsF,CAAiBlD,GACf,MAAM5C,EAAQ4E,KAAKK,MAAMM,IAAI,SAC7B,MAAMf,EAAQxE,EAAMsB,OAEpB,IAAKkD,EAAO,CACV,M,CAGFuB,EAASnB,KAAKK,MAAO,CACnBjF,MAAOoE,EACLpE,EACA4E,KAAKK,MAAMM,IAAI,SACf3C,EACAgC,KAAKL,iB,CAKX,QAAA/C,GACE,MAAO,CACLxB,MAAO4E,KAAKK,MAAMM,IAAI,SACtB7D,MAAOkD,KAAKK,MAAMM,IAAI,SACtBtD,IAAK2C,KAAKK,MAAMM,IAAI,O,CAIxB,WAAAM,CAAY5C,GAGV,UAAWA,EAAKhD,YAAc,iBAAmBgD,EAAK/C,cAAgB,SAAU,CAC9E+C,EAAInC,OAAAC,OAAAD,OAAAC,OAAA,GAAQkC,GAAI,CAAEjD,MAAOiD,EAAKjD,OAAS,I,CAEzC+F,EAASnB,KAAKK,MAAOhC,E,EC5MzB,MAAM+C,EAAoB,G,MACbC,EAAyB,CACpCC,EACAC,EACAC,EAAW,MAGTD,IAAe,MAAfA,SAAe,SAAfA,EAAiBvD,OACjBhC,KAAKyF,KAAKH,EAAYI,WAAWhF,OAAS,GAAK0E,EAAmBI,U","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["getUpdatedItemsByPosition","pos","items","realCount","virtualSize","dimension","activeItem","getItemByPosition","firstItem","getFirstItem","toUpdate","changedOffsetStart","itemIndex","recombineByOffset","Math","abs","Object","assign","positiveDirection","maxSizeVirtualSize","getMaxVirtualSize","realSize","extra","addMissingItems","length","updateMissingAndRange","getItems","firstItemStart","start","firstItemIndex","origSize","originItemSize","maxSize","maxCount","sizes","end","min","missing","range","splice","existingCollection","lastItem","getLastItem","opt","currentSize","index","size","newSize","getItemSize","push","offset","data","newItems","itemsCount","newRange","undefined","i","newIndex","newEnd","Error","_a","newStart","console","error","_b","isActiveRange","first","last","isActiveRangeOutsideLastItem","s","setItemSizes","vpItems","initialIndex","lastCoordinate","count","item","initialState","ViewportStore","this","lastKnownScroll","value","constructor","type","store","createStore","setViewPortCoordinate","position","force","viewportSize","get","frameOffset","singleOffsetInPx","outsize","maxCoordinate","allItems","setViewport","setOriginalSizes","setStore","LETTER_BLOCK_SIZE","calculateRowHeaderSize","itemsLength","rowHeaderColumn","minWidth","max","toString"],"sources":["src/store/vp/viewport.helpers.ts","src/store/vp/viewport.store.ts","src/utils/row-header-utils.ts"],"sourcesContent":["import {\n DimensionSettingsState,\n PositionItem,\n ViewSettingSizeProp,\n ViewportStateItems,\n VirtualPositionItem,\n Range,\n} from '@type';\n\nimport { getItemByPosition } from '../dimension/dimension.helpers';\n\nexport type DimensionDataViewport = Pick<\n DimensionSettingsState,\n | 'indexes'\n | 'positionIndexes'\n | 'positionIndexToItem'\n | 'sizes'\n | 'originItemSize'\n | 'realSize'\n>;\n\nexport type ItemsToUpdate = Pick<ViewportStateItems, 'items' | 'start' | 'end'>;\n/**\n * Update items based on new scroll position\n * If viewport wasn't changed fully simple recombination of positions\n * Otherwise rebuild viewport items\n */\nexport function getUpdatedItemsByPosition<T extends ItemsToUpdate>(\n pos: number, // coordinate\n items: T,\n realCount: number,\n virtualSize: number,\n dimension: DimensionDataViewport,\n): ItemsToUpdate {\n const activeItem: PositionItem = getItemByPosition(dimension, pos);\n const firstItem = getFirstItem(items);\n let toUpdate: ItemsToUpdate | undefined;\n // do simple position recombination if items already present in viewport\n if (firstItem) {\n let changedOffsetStart = activeItem.itemIndex - (firstItem.itemIndex || 0);\n // if item changed\n if (changedOffsetStart) {\n // simple recombination\n toUpdate = recombineByOffset(Math.abs(changedOffsetStart), {\n positiveDirection: changedOffsetStart > -1,\n ...dimension,\n ...items,\n });\n }\n }\n\n const maxSizeVirtualSize = getMaxVirtualSize(\n virtualSize,\n dimension.realSize,\n activeItem,\n );\n // if partial recombination add items if revo-viewport has some space left\n if (toUpdate) {\n const extra = addMissingItems(\n activeItem,\n realCount,\n maxSizeVirtualSize,\n toUpdate,\n dimension,\n );\n if (extra.length) {\n updateMissingAndRange(toUpdate.items, extra, toUpdate);\n }\n }\n\n // new collection if no items after replacement full replacement\n if (!toUpdate) {\n const items = getItems({\n firstItemStart: activeItem.start,\n firstItemIndex: activeItem.itemIndex,\n origSize: dimension.originItemSize,\n maxSize: maxSizeVirtualSize,\n maxCount: realCount,\n sizes: dimension.sizes,\n });\n\n // range now comes from 0 to length - 1\n toUpdate = {\n items,\n start: 0,\n end: items.length - 1,\n };\n }\n return toUpdate;\n}\n\n// virtual size can differ based on scroll position if some big items are present\n// scroll can be in the middle of item and virtual size will be larger\n// so we need to exclude this part from virtual size hence it's already passed\nfunction getMaxVirtualSize(\n virtualSize: number,\n realSize: number,\n activeItem: PositionItem,\n) {\n return Math.min(virtualSize + (activeItem.end - activeItem.start), realSize);\n}\n\nexport function updateMissingAndRange(\n items: VirtualPositionItem[],\n missing: VirtualPositionItem[],\n range: Range,\n) {\n items.splice(range.end + 1, 0, ...missing);\n // update range if start larger after recombination\n if (\n range.start >= range.end &&\n !(range.start === range.end && range.start === 0)\n ) {\n range.start += missing.length;\n }\n range.end += missing.length;\n}\n\n/**\n * If partial replacement\n * this function adds items if viewport has some space left\n */\nexport function addMissingItems<T extends ItemsToUpdate>(\n firstItem: PositionItem,\n realCount: number,\n virtualSize: number,\n existingCollection: T,\n dimension: Pick<DimensionSettingsState, 'sizes' | 'originItemSize'>,\n): VirtualPositionItem[] {\n const lastItem: VirtualPositionItem = getLastItem(existingCollection);\n const items = getItems({\n sizes: dimension.sizes,\n firstItemStart: lastItem.end,\n firstItemIndex: lastItem.itemIndex + 1,\n origSize: dimension.originItemSize,\n maxSize: virtualSize - (lastItem.end - firstItem.start),\n maxCount: realCount,\n });\n return items;\n}\n\n/**\n * Get wiewport items parameters\n * caching position and calculating items count in viewport\n */\nexport function getItems(\n opt: {\n firstItemIndex: number;\n firstItemStart: number;\n origSize: number;\n maxSize: number; // virtual size\n maxCount: number; // real item count, where the last item\n sizes?: ViewSettingSizeProp;\n },\n currentSize = 0,\n) {\n const items: VirtualPositionItem[] = [];\n\n let index = opt.firstItemIndex;\n let size = currentSize;\n\n // max size or max count\n while (size <= opt.maxSize && index < opt.maxCount) {\n const newSize = getItemSize(index, opt.sizes, opt.origSize);\n items.push({\n start: opt.firstItemStart + size,\n end: opt.firstItemStart + size + newSize,\n itemIndex: index,\n size: newSize,\n });\n size += newSize;\n index++;\n }\n return items;\n}\n\n/**\n * Do batch items recombination\n * If items not overlapped with existing viewport returns null\n */\ntype RecombindDimensionData = Pick<\n DimensionSettingsState,\n 'sizes' | 'realSize' | 'originItemSize'\n>;\ntype RecombineOffsetData = {\n positiveDirection: boolean;\n} & ItemsToUpdate &\n RecombindDimensionData;\nexport function recombineByOffset(\n offset: number,\n data: RecombineOffsetData,\n): ItemsToUpdate | undefined {\n const newItems = [...data.items];\n const itemsCount = newItems.length;\n let newRange = {\n start: data.start,\n end: data.end,\n };\n\n // if offset out of revo-viewport, makes sense whole redraw\n if (offset > itemsCount) {\n return undefined;\n }\n\n // is direction of scroll positive\n if (data.positiveDirection) {\n // push item to the end\n let lastItem: VirtualPositionItem = getLastItem(data);\n\n let i = newRange.start;\n const length = i + offset;\n for (; i < length; i++) {\n const newIndex = lastItem.itemIndex + 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // if item overlapped limit break a loop\n if (lastItem.end + size > data.realSize) {\n break;\n }\n\n // new item index to recombine\n let newEnd = i % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newEnd]) {\n throw new Error('incorrect index');\n }\n\n // do recombination\n newItems[newEnd] = lastItem = {\n start: lastItem.end,\n end: lastItem.end + size,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start++;\n newRange.end = newEnd;\n }\n\n // direction is negative\n } else {\n // push item to the start\n let firstItem = getFirstItem(data);\n\n const end = newRange.end;\n for (let i = 0; i < offset; i++) {\n const newIndex = (firstItem?.itemIndex ?? 0) - 1;\n const size = getItemSize(\n newIndex,\n data.sizes,\n data.originItemSize,\n );\n\n // new item index to recombine\n let newStart = end - i;\n newStart = (newStart < 0 ? itemsCount + newStart : newStart) % itemsCount;\n\n // item should always present, we do not create new item, we recombine them\n if (!newItems[newStart]) {\n console.error('incorrect index');\n break;\n }\n\n // do recombination\n const firstItemStart = firstItem?.start ?? 0;\n newItems[newStart] = firstItem = {\n start: firstItemStart - size,\n end: firstItemStart,\n itemIndex: newIndex,\n size: size,\n };\n // update range\n newRange.start = newStart;\n newRange.end--;\n }\n }\n const range = {\n start:\n (newRange.start < 0 ? itemsCount + newRange.start : newRange.start) %\n itemsCount,\n end:\n (newRange.end < 0 ? itemsCount + newRange.end : newRange.end) %\n itemsCount,\n };\n return {\n items: newItems,\n ...range,\n };\n}\n\nfunction getItemSize(\n index: number,\n sizes?: ViewSettingSizeProp,\n origSize = 0,\n): number {\n if (sizes && sizes[index]) {\n return sizes[index];\n }\n return origSize;\n}\n\n/**\n * Verify if position is in range of the PositionItem, start and end are included\n */\nexport function isActiveRange(\n pos: number,\n realSize: number,\n first?: PositionItem,\n last?: PositionItem,\n): boolean {\n if (!first || !last) {\n return false;\n }\n // if position is in range of first item\n // or position is after first item and last item is the last item in real size\n return (\n (pos >= first.start && pos <= first.end) ||\n (pos > first.end && last.end === realSize)\n );\n}\n\nexport function isActiveRangeOutsideLastItem(\n pos: number,\n virtualSize: number,\n firstItem?: PositionItem,\n lastItem?: PositionItem,\n) {\n // if no first item, means no items in viewport\n if (!firstItem) {\n return false;\n }\n return virtualSize + pos > (lastItem?.end ?? 0);\n}\n\nexport function getFirstItem(\n s: ItemsToUpdate,\n) {\n return s.items[s.start];\n}\n\nexport function getLastItem(s: ItemsToUpdate): VirtualPositionItem {\n return s.items[s.end];\n}\n\n/**\n * Set items sizes from start index to end\n * @param vpItems\n * @param start\n * @param size\n * @param lastCoordinate\n * @returns\n */\nexport function setItemSizes(\n vpItems: VirtualPositionItem[],\n initialIndex: number,\n size: number,\n lastCoordinate: number,\n) {\n const items = [...vpItems];\n const count = items.length;\n\n let pos = lastCoordinate;\n let i = 0;\n let start = initialIndex;\n\n // viewport not inited\n if (!count) {\n return [];\n }\n // loop through array from initial item after recombination\n while (i < count) {\n const item = items[start];\n item.start = pos;\n item.size = size;\n item.end = item.start + size;\n pos = item.end;\n // loop by start index\n start++;\n i++;\n\n // if start index out of array, reset it\n if (start === count) {\n start = 0;\n }\n }\n return items;\n}\n","import {\n DimensionDataViewport,\n addMissingItems,\n getFirstItem,\n getLastItem,\n getUpdatedItemsByPosition,\n isActiveRange,\n setItemSizes,\n updateMissingAndRange,\n isActiveRangeOutsideLastItem,\n ItemsToUpdate,\n} from './viewport.helpers';\nimport { createStore } from '@stencil/store';\nimport { type Observable, setStore } from '../../utils/store.utils';\nimport type {\n VirtualPositionItem,\n ViewportState,\n MultiDimensionType,\n} from '@type';\n\n/**\n * Viewport store\n * Used for virtualization (process of rendering only visible part of data)\n * Redraws viewport based on position and dimension\n */\nfunction initialState(): ViewportState {\n return {\n // virtual item information per rendered item\n items: [],\n // virtual dom item order to render\n start: 0,\n end: 0,\n\n // size of viewport in px\n virtualSize: 0,\n\n // total number of items\n realCount: 0,\n };\n}\n\n/**\n * Viewport store class\n */\nexport class ViewportStore {\n readonly store: Observable<ViewportState>;\n\n // last coordinate for store position restore\n private lastKnownScroll = 0;\n\n get lastCoordinate() {\n return this.lastKnownScroll;\n }\n set lastCoordinate(value: number) {\n this.lastKnownScroll = value;\n }\n constructor(readonly type: MultiDimensionType) {\n this.store = createStore(initialState());\n }\n\n /**\n * Render viewport based on coordinate\n * It's the main method for draw\n * Use force if you want to re-render viewport\n */\n setViewPortCoordinate(\n position: number,\n dimension: DimensionDataViewport,\n force = false,\n ) {\n const viewportSize = this.store.get('virtualSize');\n // no visible data to calculate\n if (!viewportSize) {\n return;\n }\n\n const frameOffset = 1;\n const singleOffsetInPx = dimension.originItemSize * frameOffset;\n // add offset to virtual size from both sides\n const outsize = singleOffsetInPx * 2;\n // math virtual size is based on visible area + 2 items outside of visible area\n const virtualSize = viewportSize + outsize;\n\n // expected no scroll if real size less than virtual size, position is 0\n let maxCoordinate = 0;\n // if there is nodes outside of viewport, max coordinate has to be adjusted\n if (dimension.realSize > viewportSize) {\n // max coordinate is real size minus virtual/rendered space\n maxCoordinate = dimension.realSize - viewportSize - singleOffsetInPx;\n }\n\n let pos = position;\n // limit position to max and min coordinates\n if (pos < 0) {\n pos = 0;\n } else if (pos > maxCoordinate) {\n pos = maxCoordinate;\n }\n\n // store last coordinate for further restore on redraw\n this.lastCoordinate = pos;\n\n // actual position is less than first item start based on offset\n pos -= singleOffsetInPx;\n pos = pos < 0 ? 0 : pos < maxCoordinate ? pos : maxCoordinate;\n\n let allItems: ItemsToUpdate;\n // if force clear all items and start from 0\n if (force) {\n allItems = {\n items: [],\n start: 0,\n end: 0,\n };\n } else {\n allItems = this.getItems();\n }\n\n const firstItem: VirtualPositionItem | undefined = getFirstItem(allItems);\n const lastItem: VirtualPositionItem | undefined = getLastItem(allItems);\n\n let toUpdate: Partial<ViewportState> = {};\n\n // left position changed\n // verify if new position is in range of previously rendered first item\n if (!isActiveRange(pos, dimension.realSize, firstItem, lastItem)) {\n toUpdate = {\n ...toUpdate,\n ...getUpdatedItemsByPosition(\n pos,\n allItems,\n this.store.get('realCount'),\n virtualSize,\n dimension,\n ),\n };\n this.setViewport({ ...toUpdate });\n // verify is render area is outside of last item\n } else if (\n isActiveRangeOutsideLastItem(pos, virtualSize, firstItem, lastItem)\n ) {\n const items = [...allItems.items];\n // check is any item missing for fulfill content\n const missing = addMissingItems(\n firstItem,\n this.store.get('realCount'),\n virtualSize + pos - firstItem.start,\n allItems,\n {\n sizes: dimension.sizes,\n originItemSize: dimension.originItemSize,\n },\n );\n\n // update missing items\n if (missing.length) {\n const range = {\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n updateMissingAndRange(items, missing, range);\n toUpdate = {\n ...toUpdate,\n items: [...items],\n ...range,\n };\n this.setViewport({ ...toUpdate });\n }\n }\n }\n\n /**\n * Set sizes for existing items\n */\n setOriginalSizes(size: number) {\n const items = this.store.get('items');\n const count = items.length;\n // viewport not inited\n if (!count) {\n return;\n }\n\n setStore(this.store, {\n items: setItemSizes(\n items,\n this.store.get('start'),\n size,\n this.lastCoordinate,\n ),\n });\n }\n\n getItems(): ItemsToUpdate {\n return {\n items: this.store.get('items'),\n start: this.store.get('start'),\n end: this.store.get('end'),\n };\n }\n\n setViewport(data: Partial<ViewportState>) {\n // drop items on virtual size change, require a new item set\n // drop items on real size change, require a new item set\n if (typeof data.realCount === 'number' || typeof data.virtualSize === 'number') {\n data = { ...data, items: data.items || [] };\n }\n setStore(this.store, data);\n }\n}\n","import { RowHeaders } from '..';\n\nconst LETTER_BLOCK_SIZE = 10;\nexport const calculateRowHeaderSize = (\n itemsLength: number,\n rowHeaderColumn?: RowHeaders,\n minWidth = 50,\n) => {\n return (\n rowHeaderColumn?.size ||\n Math.max((itemsLength.toString().length + 1) * LETTER_BLOCK_SIZE, minWidth)\n );\n};\n"],"mappings":";;;+DA2BgBA,EACdC,EACAC,EACAC,EACAC,EACAC,GAEA,MAAMC,EAA2BC,EAAkBF,EAAWJ,GAC9D,MAAMO,EAAYC,EAAaP,GAC/B,IAAIQ,EAEJ,GAAIF,EAAW,CACb,IAAIG,EAAqBL,EAAWM,WAAaJ,EAAUI,WAAa,GAExE,GAAID,EAAoB,CAEtBD,E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AMf,EAAQxE,EAAMsB,OAEpB,IAAKkD,EAAO,CACV,M,CAGFuB,EAASnB,KAAKK,MAAO,CACnBjF,MAAOoE,EACLpE,EACA4E,KAAKK,MAAMM,IAAI,SACf3C,EACAgC,KAAKL,iB,CAKX,QAAA/C,GACE,MAAO,CACLxB,MAAO4E,KAAKK,MAAMM,IAAI,SACtB7D,MAAOkD,KAAKK,MAAMM,IAAI,SACtBtD,IAAK2C,KAAKK,MAAMM,IAAI,O,CAIxB,WAAAM,CAAY5C,GAGV,UAAWA,EAAKhD,YAAc,iBAAmBgD,EAAK/C,cAAgB,SAAU,CAC9E+C,EAAInC,OAAAC,OAAAD,OAAAC,OAAA,GAAQkC,GAAI,CAAEjD,MAAOiD,EAAKjD,OAAS,I,CAEzC+F,EAASnB,KAAKK,MAAOhC,E,EC5MzB,MAAM+C,EAAoB,G,MACbC,EAAyB,CACpCC,EACAC,EACAC,EAAW,MAGTD,IAAe,MAAfA,SAAe,SAAfA,EAAiBvD,OACjBhC,KAAKyF,KAAKH,EAAYI,WAAWhF,OAAS,GAAK0E,EAAmBI,U","ignoreList":[]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Built by Revolist OU ❤️
|
|
3
|
+
*/
|
|
4
|
+
import{f as i,d as t}from"./key.utils-ea9aec31.js";import{u as e}from"./index-b1e05212.js";class n{constructor(i,t){this.column=i;this.saveCallback=t;this.editInput=null;this.element=null;this.editCell=undefined}async componentDidRender(){var i;if(this.editInput){await e();(i=this.editInput)===null||i===void 0?void 0:i.focus()}}onKeyDown(e){const n=i(e.key);const s=t(e.key);if((s||n)&&e.target&&this.saveCallback&&!e.isComposing){this.beforeDisconnect();this.saveCallback(this.getValue(),s)}}beforeDisconnect(){var i;(i=this.editInput)===null||i===void 0?void 0:i.blur()}getValue(){var i;return(i=this.editInput)===null||i===void 0?void 0:i.value}render(i,t){var e,n;return i("input",{type:"text",enterKeyHint:"enter",value:(n=(e=this.editCell)===null||e===void 0?void 0:e.val)!==null&&n!==void 0?n:"",ref:i=>{this.editInput=i},onKeyDown:i=>this.onKeyDown(i)})}}export{n as T};
|
|
5
|
+
//# sourceMappingURL=text-editor-fb3f24fe.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import{
|
|
5
|
-
//# sourceMappingURL=throttle-
|
|
4
|
+
import{q as t}from"./index-b1e05212.js";import{d as i,i as s}from"./debounce-7b511afc.js";const r={contentSize:0,clientSize:0,virtualSize:0,maxSize:0};const e=-1;function n(t,i,s=0){return t+(s?i-s:0)}class o{constructor(t){this.cfg=t;this.preventArtificialScroll={rgRow:null,rgCol:null};this.previousScroll={rgRow:e,rgCol:e};this.params={rgRow:Object.assign({},r),rgCol:Object.assign({},r)}}setParams(t,i){const s=n(t.contentSize,t.clientSize,t.virtualSize);this.params[i]=Object.assign(Object.assign({},t),{maxSize:s-t.clientSize,virtualContentSize:s})}async setScroll(t){this.cancelScroll(t.dimension);const i=new Promise(((i,s)=>{if(this.cfg.skipAnimationFrame){return i()}const r=window.requestAnimationFrame((()=>{i()}));this.preventArtificialScroll[t.dimension]=s.bind(null,r)}));try{await i;const s=this.getParams(t.dimension);t.coordinate=Math.ceil(t.coordinate);this.previousScroll[t.dimension]=this.wrapCoordinate(t.coordinate,s);this.preventArtificialScroll[t.dimension]=null;this.cfg.applyScroll(Object.assign(Object.assign({},t),{coordinate:s.virtualSize?this.convert(t.coordinate,s,false):t.coordinate}))}catch(t){window.cancelAnimationFrame(t)}}scroll(t,i,s=false,r,n=false){this.cancelScroll(i);if(!s&&this.previousScroll[i]===t){this.previousScroll[i]=e;return}const o=this.getParams(i);this.cfg.runScroll({dimension:i,coordinate:o.virtualSize?this.convert(t,o):t,delta:r,outside:n})}getParams(t){return this.params[t]}wrapCoordinate(t,i){if(t<0){return e}if(typeof i.maxSize==="number"&&t>i.maxSize){return i.maxSize}return t}cancelScroll(t){var i,s;(s=(i=this.preventArtificialScroll)[t])===null||s===void 0?void 0:s.call(i);this.preventArtificialScroll[t]=null}convert(i,s,r=true){var e;const n=s.clientSize;const o=[0,((e=s.virtualContentSize)!==null&&e!==void 0?e:n)-n];const a=[0,s.contentSize-s.virtualSize];if(r){return t(i,o,a)}return t(i,a,o)}}class a{constructor(t=10){this.scrollThrottling=t;this.mouseWheelScrollTimestamp={rgCol:0,rgRow:0};this.lastKnownScrollCoordinate={rgCol:0,rgRow:0}}setCoordinate(t){this.lastKnownScrollCoordinate[t.dimension]=t.coordinate}latestScrollUpdate(t){this.mouseWheelScrollTimestamp[t]=(new Date).getTime()}isReady(t,i){const s=(new Date).getTime()-this.mouseWheelScrollTimestamp[t];return s>this.scrollThrottling&&i!==this.lastKnownScrollCoordinate[t]}}var c="Expected a function";function l(t,r,e){var n=true,o=true;if(typeof t!="function"){throw new TypeError(c)}if(s(e)){n="leading"in e?!!e.leading:n;o="trailing"in e?!!e.trailing:o}return i(t,r,{leading:n,maxWait:r,trailing:o})}export{a as L,o as a,n as g,l as t};
|
|
5
|
+
//# sourceMappingURL=throttle-1f5772ef.js.map
|
|
@@ -524,11 +524,7 @@ export declare class RevoGridComponent {
|
|
|
524
524
|
*/
|
|
525
525
|
mouseupHandle(event: MouseEvent | TouchEvent): Promise<void>;
|
|
526
526
|
/** Drag events */
|
|
527
|
-
onRowDragStarted(e: CustomEvent<
|
|
528
|
-
pos: PositionItem;
|
|
529
|
-
text: string;
|
|
530
|
-
event: MouseEvent;
|
|
531
|
-
}>): void;
|
|
527
|
+
onRowDragStarted(e: CustomEvent<HTMLRevogrOrderEditorElementEventMap['rowdragstartinit']>): void;
|
|
532
528
|
onRowDragEnd(): void;
|
|
533
529
|
onRowOrderChange(e: CustomEvent<HTMLRevogrOrderEditorElementEventMap['roworderchange']>): void;
|
|
534
530
|
onRowDrag({ detail }: CustomEvent<PositionItem>): void;
|
|
@@ -1033,6 +1033,7 @@ declare global {
|
|
|
1033
1033
|
pos: PositionItem;
|
|
1034
1034
|
event: MouseEvent;
|
|
1035
1035
|
rowType: DimensionRows;
|
|
1036
|
+
model: any;
|
|
1036
1037
|
};
|
|
1037
1038
|
"rowdragendinit": { rowType: DimensionRows };
|
|
1038
1039
|
"rowdragmoveinit": PositionItem & { rowType: DimensionRows };
|
|
@@ -1923,6 +1924,7 @@ declare namespace LocalJSX {
|
|
|
1923
1924
|
pos: PositionItem;
|
|
1924
1925
|
event: MouseEvent;
|
|
1925
1926
|
rowType: DimensionRows;
|
|
1927
|
+
model: any;
|
|
1926
1928
|
}>) => void;
|
|
1927
1929
|
/**
|
|
1928
1930
|
* Row dragged, new range ready to be applied
|
package/hydrate/index.js
CHANGED
|
@@ -3299,29 +3299,6 @@ class FilterPanel {
|
|
|
3299
3299
|
}; }
|
|
3300
3300
|
}
|
|
3301
3301
|
|
|
3302
|
-
const MIN_COL_SIZE = 30;
|
|
3303
|
-
const RESIZE_INTERVAL = 40;
|
|
3304
|
-
const DATA_COL = 'data-rgCol';
|
|
3305
|
-
const DATA_ROW = 'data-rgRow';
|
|
3306
|
-
const DISABLED_CLASS = 'disabled';
|
|
3307
|
-
const CELL_CLASS = 'rgCell';
|
|
3308
|
-
const ROW_HEADER_TYPE = 'rowHeaders';
|
|
3309
|
-
const HEADER_CLASS = 'rgHeaderCell';
|
|
3310
|
-
const HEADER_SORTABLE_CLASS = 'sortable';
|
|
3311
|
-
const HEADER_ROW_CLASS = 'header-rgRow';
|
|
3312
|
-
const HEADER_ACTUAL_ROW_CLASS = 'actual-rgRow';
|
|
3313
|
-
const DRAG_ICON_CLASS = 'revo-drag-icon';
|
|
3314
|
-
const DRAGGABLE_CLASS = 'revo-draggable';
|
|
3315
|
-
const FOCUS_CLASS = 'focused-cell';
|
|
3316
|
-
const SELECTION_BORDER_CLASS = 'selection-border-range';
|
|
3317
|
-
const MOBILE_CLASS = 'mobile-handler';
|
|
3318
|
-
const TMP_SELECTION_BG_CLASS = 'temp-bg-range';
|
|
3319
|
-
const CELL_HANDLER_CLASS = 'autofill-handle';
|
|
3320
|
-
const EDIT_INPUT_WR = 'edit-input-wrapper';
|
|
3321
|
-
const DRAGG_TEXT = 'Draggable item';
|
|
3322
|
-
const GRID_INTERNALS = '__rvgr';
|
|
3323
|
-
const ROW_FOCUSED_CLASS = 'focused-rgRow';
|
|
3324
|
-
|
|
3325
3302
|
/**
|
|
3326
3303
|
* Proxy plugin for data source.
|
|
3327
3304
|
* This plugin is used to sort the data source.
|
|
@@ -7903,6 +7880,29 @@ function isRowType(type) {
|
|
|
7903
7880
|
return rowTypes.indexOf(type) > -1;
|
|
7904
7881
|
}
|
|
7905
7882
|
|
|
7883
|
+
const MIN_COL_SIZE = 30;
|
|
7884
|
+
const RESIZE_INTERVAL = 40;
|
|
7885
|
+
const DATA_COL = 'data-rgCol';
|
|
7886
|
+
const DATA_ROW = 'data-rgRow';
|
|
7887
|
+
const DISABLED_CLASS = 'disabled';
|
|
7888
|
+
const CELL_CLASS = 'rgCell';
|
|
7889
|
+
const ROW_HEADER_TYPE = 'rowHeaders';
|
|
7890
|
+
const HEADER_CLASS = 'rgHeaderCell';
|
|
7891
|
+
const HEADER_SORTABLE_CLASS = 'sortable';
|
|
7892
|
+
const HEADER_ROW_CLASS = 'header-rgRow';
|
|
7893
|
+
const HEADER_ACTUAL_ROW_CLASS = 'actual-rgRow';
|
|
7894
|
+
const DRAG_ICON_CLASS = 'revo-drag-icon';
|
|
7895
|
+
const DRAGGABLE_CLASS = 'revo-draggable';
|
|
7896
|
+
const FOCUS_CLASS = 'focused-cell';
|
|
7897
|
+
const SELECTION_BORDER_CLASS = 'selection-border-range';
|
|
7898
|
+
const MOBILE_CLASS = 'mobile-handler';
|
|
7899
|
+
const TMP_SELECTION_BG_CLASS = 'temp-bg-range';
|
|
7900
|
+
const CELL_HANDLER_CLASS = 'autofill-handle';
|
|
7901
|
+
const EDIT_INPUT_WR = 'edit-input-wrapper';
|
|
7902
|
+
const DRAGG_TEXT = 'Draggable item';
|
|
7903
|
+
const GRID_INTERNALS = '__rvgr';
|
|
7904
|
+
const ROW_FOCUSED_CLASS = 'focused-rgRow';
|
|
7905
|
+
|
|
7906
7906
|
class RowOrderService {
|
|
7907
7907
|
constructor(config) {
|
|
7908
7908
|
this.config = config;
|
|
@@ -8013,6 +8013,7 @@ class OrderEditor {
|
|
|
8013
8013
|
pos,
|
|
8014
8014
|
event: e.originalEvent,
|
|
8015
8015
|
rowType: this.rowType,
|
|
8016
|
+
model: getSourceItem(this.dataStore, pos.itemIndex),
|
|
8016
8017
|
});
|
|
8017
8018
|
if (dragStartEvent.defaultPrevented) {
|
|
8018
8019
|
return;
|
package/hydrate/index.mjs
CHANGED
|
@@ -3295,29 +3295,6 @@ class FilterPanel {
|
|
|
3295
3295
|
}; }
|
|
3296
3296
|
}
|
|
3297
3297
|
|
|
3298
|
-
const MIN_COL_SIZE = 30;
|
|
3299
|
-
const RESIZE_INTERVAL = 40;
|
|
3300
|
-
const DATA_COL = 'data-rgCol';
|
|
3301
|
-
const DATA_ROW = 'data-rgRow';
|
|
3302
|
-
const DISABLED_CLASS = 'disabled';
|
|
3303
|
-
const CELL_CLASS = 'rgCell';
|
|
3304
|
-
const ROW_HEADER_TYPE = 'rowHeaders';
|
|
3305
|
-
const HEADER_CLASS = 'rgHeaderCell';
|
|
3306
|
-
const HEADER_SORTABLE_CLASS = 'sortable';
|
|
3307
|
-
const HEADER_ROW_CLASS = 'header-rgRow';
|
|
3308
|
-
const HEADER_ACTUAL_ROW_CLASS = 'actual-rgRow';
|
|
3309
|
-
const DRAG_ICON_CLASS = 'revo-drag-icon';
|
|
3310
|
-
const DRAGGABLE_CLASS = 'revo-draggable';
|
|
3311
|
-
const FOCUS_CLASS = 'focused-cell';
|
|
3312
|
-
const SELECTION_BORDER_CLASS = 'selection-border-range';
|
|
3313
|
-
const MOBILE_CLASS = 'mobile-handler';
|
|
3314
|
-
const TMP_SELECTION_BG_CLASS = 'temp-bg-range';
|
|
3315
|
-
const CELL_HANDLER_CLASS = 'autofill-handle';
|
|
3316
|
-
const EDIT_INPUT_WR = 'edit-input-wrapper';
|
|
3317
|
-
const DRAGG_TEXT = 'Draggable item';
|
|
3318
|
-
const GRID_INTERNALS = '__rvgr';
|
|
3319
|
-
const ROW_FOCUSED_CLASS = 'focused-rgRow';
|
|
3320
|
-
|
|
3321
3298
|
/**
|
|
3322
3299
|
* Proxy plugin for data source.
|
|
3323
3300
|
* This plugin is used to sort the data source.
|
|
@@ -7899,6 +7876,29 @@ function isRowType(type) {
|
|
|
7899
7876
|
return rowTypes.indexOf(type) > -1;
|
|
7900
7877
|
}
|
|
7901
7878
|
|
|
7879
|
+
const MIN_COL_SIZE = 30;
|
|
7880
|
+
const RESIZE_INTERVAL = 40;
|
|
7881
|
+
const DATA_COL = 'data-rgCol';
|
|
7882
|
+
const DATA_ROW = 'data-rgRow';
|
|
7883
|
+
const DISABLED_CLASS = 'disabled';
|
|
7884
|
+
const CELL_CLASS = 'rgCell';
|
|
7885
|
+
const ROW_HEADER_TYPE = 'rowHeaders';
|
|
7886
|
+
const HEADER_CLASS = 'rgHeaderCell';
|
|
7887
|
+
const HEADER_SORTABLE_CLASS = 'sortable';
|
|
7888
|
+
const HEADER_ROW_CLASS = 'header-rgRow';
|
|
7889
|
+
const HEADER_ACTUAL_ROW_CLASS = 'actual-rgRow';
|
|
7890
|
+
const DRAG_ICON_CLASS = 'revo-drag-icon';
|
|
7891
|
+
const DRAGGABLE_CLASS = 'revo-draggable';
|
|
7892
|
+
const FOCUS_CLASS = 'focused-cell';
|
|
7893
|
+
const SELECTION_BORDER_CLASS = 'selection-border-range';
|
|
7894
|
+
const MOBILE_CLASS = 'mobile-handler';
|
|
7895
|
+
const TMP_SELECTION_BG_CLASS = 'temp-bg-range';
|
|
7896
|
+
const CELL_HANDLER_CLASS = 'autofill-handle';
|
|
7897
|
+
const EDIT_INPUT_WR = 'edit-input-wrapper';
|
|
7898
|
+
const DRAGG_TEXT = 'Draggable item';
|
|
7899
|
+
const GRID_INTERNALS = '__rvgr';
|
|
7900
|
+
const ROW_FOCUSED_CLASS = 'focused-rgRow';
|
|
7901
|
+
|
|
7902
7902
|
class RowOrderService {
|
|
7903
7903
|
constructor(config) {
|
|
7904
7904
|
this.config = config;
|
|
@@ -8009,6 +8009,7 @@ class OrderEditor {
|
|
|
8009
8009
|
pos,
|
|
8010
8010
|
event: e.originalEvent,
|
|
8011
8011
|
rowType: this.rowType,
|
|
8012
|
+
model: getSourceItem(this.dataStore, pos.itemIndex),
|
|
8012
8013
|
});
|
|
8013
8014
|
if (dragStartEvent.defaultPrevented) {
|
|
8014
8015
|
return;
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<img src="https://badgen.net/bundlephobia/dependency-count/@revolist/revogrid@latest" alt="Tree shaking"/>
|
|
11
11
|
<img src="https://badgen.net/bundlephobia/tree-shaking/@revolist/revogrid@latest" alt="Tree shaking"/>
|
|
12
12
|
<img src="https://sonarcloud.io/api/project_badges/measure?project=revolist_revogrid&metric=alert_status" alt="Sonar Quality Gate"/>
|
|
13
|
+
<img src="https://sonarcloud.io/api/project_badges/measure?project=revolist_revogrid&metric=alert_status" alt="Sonar Quality Gate"/>
|
|
13
14
|
</p>
|
|
14
15
|
|
|
15
16
|
#
|
|
@@ -53,6 +54,8 @@ Support Millions of cells and thousands of columns easy and efficiently for fast
|
|
|
53
54
|
|
|
54
55
|
- **Formula Support**: Evaluate formulas in cell data.
|
|
55
56
|
|
|
57
|
+
- **Master Detail/Subtables/Forms**: Expand rows to reveal child data.
|
|
58
|
+
|
|
56
59
|
- **Drag and Drop**: Drag and drop in rows and columns.
|
|
57
60
|
|
|
58
61
|
- **Sorting**: Multiple options, customizable per column, with advanced event handling.
|
|
@@ -251,33 +254,28 @@ grid.source = items;
|
|
|
251
254
|
|
|
252
255
|
## Our Sponsors
|
|
253
256
|
|
|
254
|
-
We would like to extend our heartfelt gratitude to our sponsors for their generous support. Their contributions help us maintain and develop RevoGrid
|
|
257
|
+
We would like to extend our heartfelt gratitude to our sponsors for their generous support. Their contributions help us maintain and develop RevoGrid.
|
|
255
258
|
|
|
256
259
|
[](https://altruistiq.com)
|
|
257
260
|
|
|
258
261
|
|
|
259
262
|
### Become a Sponsor
|
|
260
263
|
|
|
261
|
-
If you or your company would like to support the ongoing development of RevoGrid, please consider
|
|
262
|
-
|
|
263
|
-
[](https://opencollective.com/revogrid)
|
|
264
|
+
If you or your company would like to support the ongoing development of RevoGrid, please consider [](https://opencollective.com/revogrid) or use a [Pro version](https://rv-grid.com/pro/). Your support will help us continue to improve the project and provide the best possible tool for the community.
|
|
264
265
|
|
|
265
266
|
Thank you for supporting RevoGrid! 🙏
|
|
266
267
|
|
|
268
|
+
|
|
267
269
|
## Contributing
|
|
268
270
|
|
|
269
|
-
|
|
271
|
+
By getting involved, you'll have the opportunity to enhance your skills, gain valuable experience, and make a significant impact on an innovative project. Your contribution, no matter how big or small, is valuable.
|
|
270
272
|
|
|
271
273
|
### Why Contribute?
|
|
272
274
|
|
|
273
|
-
- **Expand Your Knowledge**: Working on
|
|
274
|
-
- **
|
|
275
|
-
- **Professional Growth**: By contributing, you become part of a network of talented developers. This can lead to mentorship opportunities, collaborations, and professional connections that can benefit your career.
|
|
276
|
-
- **Make a Difference**: Your contributions can help improve RevoGrid, making it more powerful and user-friendly for developers around the world. Your input can shape the future of the project and drive innovation.
|
|
277
|
-
|
|
278
|
-
### Join Us
|
|
275
|
+
- **Expand Your Knowledge**: Working on complex libraries allows you to dive deep into modern web technologies, improve your coding skills, and learn best practices in performance optimization, data handling, and component-based architecture.
|
|
276
|
+
- **Experience**: Contributing to an open-source project like provides you with practical experience that can be a great addition to your portfolio. It demonstrates your ability to work collaboratively, solve complex problems, and contribute to a project's success.
|
|
277
|
+
- **Professional Growth**: By contributing, you become part of a network of talented developers. This can lead to mentorship opportunities, collaborations, and professional connections that can benefit your career.
|
|
279
278
|
|
|
280
|
-
Your contribution, no matter how big or small, is valuable. By working on RevoGrid, you'll be part of an exciting project that's making a difference in the world of data grids. Join us today and let's build something amazing together!
|
|
281
279
|
|
|
282
280
|
## License
|
|
283
281
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { y as keys, q as isArrayLike, x as baseIteratee, l as isArray, j as createStore, i as setStore, n as isIterateeCall, m as toInteger, a as getVisibleSourceItem, b as getSourceItem } from './data.store.js';
|
|
5
5
|
import '@stencil/core/internal/client';
|
|
6
6
|
import { G as GRID_INTERNALS, C as CELL_CLASS, b as DISABLED_CLASS } from './consts.js';
|
|
7
7
|
import './platform.js';
|
package/standalone/data.store.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Built by Revolist OU ❤️
|
|
3
3
|
*/
|
|
4
4
|
import { a as isObject, b as baseGetTag, r as root, S as Symbol, i as isObjectLike, f as freeGlobal, c as isSymbol, t as toNumber } from './toNumber.js';
|
|
5
|
-
import { i as identity } from './identity.js';
|
|
6
5
|
import { getRenderingRef, forceUpdate } from '@stencil/core/internal/client';
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -2460,6 +2459,26 @@ function baseMatchesProperty(path, srcValue) {
|
|
|
2460
2459
|
};
|
|
2461
2460
|
}
|
|
2462
2461
|
|
|
2462
|
+
/**
|
|
2463
|
+
* This method returns the first argument it receives.
|
|
2464
|
+
*
|
|
2465
|
+
* @static
|
|
2466
|
+
* @since 0.1.0
|
|
2467
|
+
* @memberOf _
|
|
2468
|
+
* @category Util
|
|
2469
|
+
* @param {*} value Any value.
|
|
2470
|
+
* @returns {*} Returns `value`.
|
|
2471
|
+
* @example
|
|
2472
|
+
*
|
|
2473
|
+
* var object = { 'a': 1 };
|
|
2474
|
+
*
|
|
2475
|
+
* console.log(_.identity(object) === object);
|
|
2476
|
+
* // => true
|
|
2477
|
+
*/
|
|
2478
|
+
function identity(value) {
|
|
2479
|
+
return value;
|
|
2480
|
+
}
|
|
2481
|
+
|
|
2463
2482
|
/**
|
|
2464
2483
|
* The base implementation of `_.property` without support for deep paths.
|
|
2465
2484
|
*
|
|
@@ -3145,6 +3164,6 @@ function getSourceItemVirtualIndexByProp(store, prop) {
|
|
|
3145
3164
|
return items.indexOf(physicalIndex);
|
|
3146
3165
|
}
|
|
3147
3166
|
|
|
3148
|
-
export { DataStore as D, getVisibleSourceItem as a, getSourceItem as b, getSourcePhysicalIndex as c, setSourceByPhysicalIndex as d, setItems as e, getSourceItemVirtualIndexByProp as f, getPhysical as g, gatherTrimmedItems as h, setStore as i, createStore as j,
|
|
3167
|
+
export { DataStore as D, getVisibleSourceItem as a, getSourceItem as b, getSourcePhysicalIndex as c, setSourceByPhysicalIndex as d, setItems as e, getSourceItemVirtualIndexByProp as f, getPhysical as g, gatherTrimmedItems as h, setStore as i, createStore as j, identity as k, isArray$1 as l, toInteger as m, isIterateeCall as n, baseProperty as o, proxyPlugin as p, isArrayLike as q, getTag$1 as r, setSourceByVirtualIndex as s, trimmedPlugin as t, baseKeys as u, findIndex as v, getNative as w, baseIteratee as x, keys as y };
|
|
3149
3168
|
|
|
3150
3169
|
//# sourceMappingURL=data.store.js.map
|