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AAzD,CAAf;AACA,UAAM,QAAQ,GAAG,KAAK,eAAL,CAAqB,SAArB,CAA+B,MAA/B,CAAsC,KAAK,eAAL,CAAqB,QAA3D,CAAjB;AACA,aAAO,KAAK,UAAL,CAAgB,KAAhB,EAAuB,MAAvB,EAA+B,QAA/B,EAAyC,KAAK,MAA9C,CAAP;AACD,KAzEM;AA0EP,IAAA,aA1EO,yBA0EQ,KA1ER,EA0EoB;AACzB;AACA;AACA,UAAI,KAAK,CAAC,MAAN,GAAe,KAAK,SAAxB,EAAmC,KAAK,eAAL,CAAqB,IAArB,GAA4B,CAA5B;AAEnC,aAAO,KAAK,CAAC,KAAN,CAAY,KAAK,SAAjB,EAA4B,KAAK,QAAjC,CAAP;AACD;AAhFM,GAxOe;AA2TxB,EAAA,MA3TwB,oBA2TlB;AACJ,WAAO,KAAK,YAAL,CAAkB,OAAlB,IAA6B,KAAK,YAAL,CAAkB,OAAlB,CAA0B,KAAK,WAA/B,CAApC;AACD;AA7TuB,CAAX,C","sourcesContent":["// Helpers\nimport { wrapInArray, sortItems, deepEqual, groupByProperty, searchItems } from '../../util/helpers'\nimport Vue, { VNode, PropType } from 'vue'\n\nexport interface DataOptions {\n page: number\n itemsPerPage: number\n sortBy: string[]\n sortDesc: boolean[]\n groupBy: string[]\n groupDesc: boolean[]\n multiSort: boolean\n mustSort: boolean\n}\n\nexport interface DataPagination {\n page: number\n itemsPerPage: number\n pageStart: number\n pageStop: number\n pageCount: number\n itemsLength: number\n}\n\nexport interface DataProps {\n items: any[]\n pagination: DataPagination\n options: DataOptions\n updateOptions: (obj: any) => void\n sort: (value: string) => void\n group: (value: string) => void\n groupedItems: Record<string, any[]> | null\n}\n\nexport default Vue.extend({\n name: 'v-data',\n\n inheritAttrs: false,\n\n props: {\n items: {\n type: Array as PropType<any[]>,\n default: () => [],\n },\n options: {\n type: Object,\n default: () => ({}),\n },\n sortBy: {\n type: [String, Array] as PropType<string | string[]>,\n default: () => [],\n },\n sortDesc: {\n type: [Boolean, Array] as PropType<boolean | boolean[]>,\n default: () => [],\n },\n customSort: {\n type: Function as any as PropType<typeof sortItems>,\n default: sortItems,\n },\n mustSort: Boolean,\n multiSort: Boolean,\n page: {\n type: Number,\n default: 1,\n },\n itemsPerPage: {\n type: Number,\n default: 10,\n },\n groupBy: {\n type: [String, Array] as PropType<string | string[]>,\n default: () => [],\n },\n groupDesc: {\n type: [Boolean, Array] as PropType<boolean | boolean[]>,\n default: () => [],\n },\n locale: {\n type: String,\n default: 'en-US',\n },\n disableSort: Boolean,\n disablePagination: Boolean,\n disableFiltering: Boolean,\n search: String,\n customFilter: {\n type: Function as any as PropType<typeof searchItems>,\n default: searchItems,\n },\n serverItemsLength: {\n type: Number,\n default: -1,\n },\n },\n\n data () {\n return {\n internalOptions: {\n page: this.page,\n itemsPerPage: this.itemsPerPage,\n sortBy: wrapInArray(this.sortBy),\n sortDesc: wrapInArray(this.sortDesc),\n groupBy: wrapInArray(this.groupBy),\n groupDesc: wrapInArray(this.groupDesc),\n mustSort: this.mustSort,\n multiSort: this.multiSort,\n } as DataOptions,\n }\n },\n\n computed: {\n itemsLength (): number {\n return this.serverItemsLength >= 0 ? this.serverItemsLength : this.filteredItems.length\n },\n pageCount (): number {\n return this.internalOptions.itemsPerPage === -1\n ? 1\n : Math.ceil(this.itemsLength / this.internalOptions.itemsPerPage) // TODO: can't use items.length here\n },\n pageStart (): number {\n if (this.internalOptions.itemsPerPage === -1 || !this.items.length) return 0\n\n return (this.internalOptions.page - 1) * this.internalOptions.itemsPerPage\n },\n pageStop (): number {\n if (this.internalOptions.itemsPerPage === -1) return this.itemsLength\n if (!this.items.length) return 0\n\n return Math.min(this.itemsLength, this.internalOptions.page * this.internalOptions.itemsPerPage)\n },\n isGrouped (): boolean {\n return !!this.internalOptions.groupBy.length\n },\n pagination (): DataPagination {\n return {\n page: this.internalOptions.page,\n itemsPerPage: this.internalOptions.itemsPerPage,\n pageStart: this.pageStart,\n pageStop: this.pageStop,\n pageCount: this.pageCount,\n itemsLength: this.itemsLength,\n }\n },\n filteredItems (): any[] {\n let items = this.items.slice()\n\n if (!this.disableFiltering && this.serverItemsLength <= 0) {\n items = this.customFilter(items, this.search)\n }\n\n return items\n },\n computedItems (): any[] {\n let items = this.filteredItems.slice()\n\n if (!this.disableSort && this.serverItemsLength <= 0) {\n items = this.sortItems(items)\n }\n\n if (!this.disablePagination && this.serverItemsLength <= 0) {\n items = this.paginateItems(items)\n }\n\n return items\n },\n groupedItems (): Record<string, any[]> | null {\n return this.isGrouped ? groupByProperty(this.computedItems, this.internalOptions.groupBy[0]) : null\n },\n scopedProps (): DataProps {\n const props = {\n sort: this.sort,\n sortArray: this.sortArray,\n group: this.group,\n items: this.computedItems,\n options: this.internalOptions,\n updateOptions: this.updateOptions,\n pagination: this.pagination,\n groupedItems: this.groupedItems,\n }\n\n return props\n },\n },\n\n watch: {\n options: {\n handler (options: DataOptions, old: DataOptions) {\n if (deepEqual(options, old)) return\n\n this.updateOptions(options)\n },\n deep: true,\n immediate: true,\n },\n internalOptions: {\n handler (options: DataOptions, old: DataOptions) {\n if (deepEqual(options, old)) return\n this.$emit('update:options', options)\n this.$emit('pagination', this.pagination)\n },\n deep: true,\n immediate: true,\n },\n page (page: number) {\n this.updateOptions({ page })\n },\n 'internalOptions.page' (page: number) {\n this.$emit('update:page', page)\n },\n itemsPerPage (itemsPerPage: number) {\n this.updateOptions({ itemsPerPage })\n },\n 'internalOptions.itemsPerPage' (itemsPerPage: number) {\n this.$emit('update:items-per-page', itemsPerPage)\n },\n sortBy (sortBy: string | string[]) {\n this.updateOptions({ sortBy: wrapInArray(sortBy) })\n },\n 'internalOptions.sortBy' (sortBy: string[], old: string[]) {\n !deepEqual(sortBy, old) && this.$emit('update:sort-by', Array.isArray(this.sortBy) ? sortBy : sortBy[0])\n },\n sortDesc (sortDesc: boolean | boolean[]) {\n this.updateOptions({ sortDesc: wrapInArray(sortDesc) })\n },\n 'internalOptions.sortDesc' (sortDesc: boolean[], old: boolean[]) {\n !deepEqual(sortDesc, old) && this.$emit('update:sort-desc', Array.isArray(this.sortDesc) ? sortDesc : sortDesc[0])\n },\n groupBy (groupBy: string | string[]) {\n this.updateOptions({ groupBy: wrapInArray(groupBy) })\n },\n 'internalOptions.groupBy' (groupBy: string[], old: string[]) {\n !deepEqual(groupBy, old) && this.$emit('update:group-by', Array.isArray(this.groupBy) ? groupBy : groupBy[0])\n },\n groupDesc (groupDesc: boolean | boolean[]) {\n this.updateOptions({ groupDesc: wrapInArray(groupDesc) })\n },\n 'internalOptions.groupDesc' (groupDesc: boolean[], old: boolean[]) {\n !deepEqual(groupDesc, old) && this.$emit('update:group-desc', Array.isArray(this.groupDesc) ? groupDesc : groupDesc[0])\n },\n multiSort (multiSort: boolean) {\n this.updateOptions({ multiSort })\n },\n 'internalOptions.multiSort' (multiSort: boolean) {\n this.$emit('update:multi-sort', multiSort)\n },\n mustSort (mustSort: boolean) {\n this.updateOptions({ mustSort })\n },\n 'internalOptions.mustSort' (mustSort: boolean) {\n this.$emit('update:must-sort', mustSort)\n },\n pageCount: {\n handler (pageCount: number) {\n this.$emit('page-count', pageCount)\n },\n immediate: true,\n },\n computedItems: {\n handler (computedItems: any[]) {\n this.$emit('current-items', computedItems)\n },\n immediate: true,\n },\n },\n\n methods: {\n toggle (key: string, oldBy: string[], oldDesc: boolean[], page: number, mustSort: boolean, multiSort: boolean) {\n let by = oldBy.slice()\n let desc = oldDesc.slice()\n const byIndex = by.findIndex((k: string) => k === key)\n\n if (byIndex < 0) {\n if (!multiSort) {\n by = []\n desc = []\n }\n\n by.push(key)\n desc.push(false)\n } else if (byIndex >= 0 && !desc[byIndex]) {\n desc[byIndex] = true\n } else if (!mustSort) {\n by.splice(byIndex, 1)\n desc.splice(byIndex, 1)\n } else {\n desc[byIndex] = false\n }\n\n // Reset page to 1 if sortBy or sortDesc have changed\n if (!deepEqual(by, oldBy) || !deepEqual(desc, oldDesc)) {\n page = 1\n }\n\n return { by, desc, page }\n },\n group (key: string): void {\n const { by: groupBy, desc: groupDesc, page } = this.toggle(\n key,\n this.internalOptions.groupBy,\n this.internalOptions.groupDesc,\n this.internalOptions.page,\n true,\n false\n )\n this.updateOptions({ groupBy, groupDesc, page })\n },\n sort (key: string | string[]): void {\n if (Array.isArray(key)) return this.sortArray(key)\n\n const { by: sortBy, desc: sortDesc, page } = this.toggle(\n key,\n this.internalOptions.sortBy,\n this.internalOptions.sortDesc,\n this.internalOptions.page,\n this.mustSort,\n this.multiSort\n )\n this.updateOptions({ sortBy, sortDesc, page })\n },\n sortArray (sortBy: string[]) {\n const sortDesc = sortBy.map(s => {\n const i = this.internalOptions.sortBy.findIndex((k: string) => k === s)\n return i > -1 ? this.internalOptions.sortDesc[i] : false\n })\n\n this.updateOptions({ sortBy, sortDesc })\n },\n updateOptions (options: any) {\n this.internalOptions = {\n ...this.internalOptions,\n ...options,\n page: Math.max(1, Math.min(options.page || this.internalOptions.page, this.pageCount)),\n }\n },\n sortItems (items: any[]) {\n const sortBy = this.internalOptions.groupBy.concat(this.internalOptions.sortBy)\n const sortDesc = this.internalOptions.groupDesc.concat(this.internalOptions.sortDesc)\n return this.customSort(items, sortBy, sortDesc, this.locale)\n },\n paginateItems (items: any[]) {\n // Make sure we don't try to display non-existant page if items suddenly change\n // TODO: Could possibly move this to pageStart/pageStop?\n if (items.length < this.pageStart) this.internalOptions.page = 1\n\n return items.slice(this.pageStart, this.pageStop)\n },\n },\n\n render (): VNode {\n return this.$scopedSlots.default && this.$scopedSlots.default(this.scopedProps) as any\n },\n})\n"],"sourceRoot":"","file":"VData.js"} |