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;AAEA,mBAAO,KAAK,cAAL,CAAoB,KAApB,EAA2B;AAChC,6BAAa;AADmB,aAA3B,EAEJ,QAFI,CAAP;AAGD,SA9IM;AA+IP,qBA/IO,2BA+IM;AACX,mBAAO,KAAK,cAAL,CAAoB,8BAApB,EAAuC,CAAC,KAAK,kBAAL,EAAD,CAAvC,CAAP;AACD;AAjJM,KAhEF;AAoNP,UApNO,kBAoNC,CApND,EAoNE;AACP,YAAM,WAAW,CAAC,KAAK,OAAL,EAAD,CAAjB;AAEA,YAAI,KAAK,UAAT,EAAqB,SAAS,IAAT,CAAc,KAAK,aAAL,EAAd,EAArB,KACK,SAAS,IAAT,CAAc,KAAK,kBAAL,EAAd;AAEL,eAAO,EAAE,KAAF,EAAS;AACd,yBAAa,iBADC;AAEd,mBAAO;AACL,yCAAyB,CAAC,KAAK,WAD1B;AAEL,0CAA0B,KAAK,WAF1B;AAGL,6CAA6B,KAAK,UAH7B;AAIL,6CAA6B,KAAK,QAAL,CAAc,UAAd,CAAyB,KAAK,GAA9B;AAJxB;AAFO,SAAT,EAQJ,QARI,CAAP;AASD;AAnOM,CAHM,C","sourcesContent":["// Components\nimport { VExpandTransition } from '../transitions'\nimport { VIcon } from '../VIcon'\nimport VTreeview from './VTreeview'\nimport VTreeviewNode from './VTreeviewNode'\n\n// Mixins\nimport { inject as RegistrableInject } from '../../mixins/registrable'\n\n// Utils\nimport mixins from '../../util/mixins'\nimport { getObjectValueByPath } from '../../util/helpers'\nimport { PropValidator } from 'vue/types/options'\n\n// Types\nimport Vue, { VNode } from 'vue'\n\ntype VTreeViewInstance = InstanceType\n\ninterface options extends Vue {\n treeview: VTreeViewInstance\n}\n\nexport const VTreeviewNodeProps = {\n activatable: Boolean,\n activeClass: {\n type: String,\n default: 'v-treeview-node--active'\n },\n selectable: Boolean,\n selectedColor: {\n type: String,\n default: 'accent'\n },\n indeterminateIcon: {\n type: String,\n default: '$vuetify.icons.checkboxIndeterminate'\n },\n onIcon: {\n type: String,\n default: '$vuetify.icons.checkboxOn'\n },\n offIcon: {\n type: String,\n default: '$vuetify.icons.checkboxOff'\n },\n expandIcon: {\n type: String,\n default: '$vuetify.icons.subgroup'\n },\n loadingIcon: {\n type: String,\n default: '$vuetify.icons.loading'\n },\n itemKey: {\n type: String,\n default: 'id'\n },\n itemText: {\n type: String,\n default: 'name'\n },\n itemChildren: {\n type: String,\n default: 'children'\n },\n loadChildren: Function as PropValidator<(item: any) => Promise>,\n openOnClick: Boolean,\n transition: Boolean\n}\n\nexport default mixins(\n RegistrableInject('treeview')\n /* @vue/component */\n).extend({\n name: 'v-treeview-node',\n\n inject: {\n treeview: {\n default: null\n }\n },\n\n props: {\n item: {\n type: Object,\n default: () => null\n },\n ...VTreeviewNodeProps\n },\n\n data: () => ({\n isOpen: false, // Node is open/expanded\n isSelected: false, // Node is selected (checkbox)\n isIndeterminate: false, // Node has at least one selected child\n isActive: false, // Node is selected (row)\n isLoading: false,\n hasLoaded: false\n }),\n\n computed: {\n key (): string {\n return getObjectValueByPath(this.item, this.itemKey)\n },\n children (): any[] | null {\n return getObjectValueByPath(this.item, this.itemChildren)\n },\n text (): string {\n return getObjectValueByPath(this.item, this.itemText)\n },\n scopedProps (): object {\n return {\n item: this.item,\n leaf: !this.children,\n selected: this.isSelected,\n indeterminate: this.isIndeterminate,\n active: this.isActive,\n open: this.isOpen\n }\n },\n computedIcon (): string {\n if (this.isIndeterminate) return this.indeterminateIcon\n else if (this.isSelected) return this.onIcon\n else return this.offIcon\n },\n hasChildren (): boolean {\n return !!this.children && (!!this.children.length || !!this.loadChildren)\n }\n },\n\n created () {\n this.treeview.register(this)\n },\n\n beforeDestroy () {\n this.treeview.unregister(this)\n },\n\n methods: {\n checkChildren (): Promise {\n return new Promise(resolve => {\n // TODO: Potential issue with always trying\n // to load children if response is empty?\n if (!this.children || this.children.length || !this.loadChildren || this.hasLoaded) return resolve()\n\n this.isLoading = true\n resolve(this.loadChildren(this.item))\n }).then(() => {\n this.isLoading = false\n this.hasLoaded = true\n })\n },\n open () {\n this.isOpen = !this.isOpen\n this.treeview.updateOpen(this.key, this.isOpen)\n this.treeview.emitOpen()\n },\n genLabel () {\n const children = []\n\n if (this.$scopedSlots.label) children.push(this.$scopedSlots.label(this.scopedProps))\n else children.push(this.text)\n\n return this.$createElement('div', {\n slot: 'label',\n staticClass: 'v-treeview-node__label'\n }, children)\n },\n genContent () {\n const children = [\n this.$scopedSlots.prepend && this.$scopedSlots.prepend(this.scopedProps),\n this.genLabel(),\n this.$scopedSlots.append && this.$scopedSlots.append(this.scopedProps)\n ]\n\n return this.$createElement('div', {\n staticClass: 'v-treeview-node__content'\n }, children)\n },\n genToggle () {\n return this.$createElement(VIcon, {\n staticClass: 'v-treeview-node__toggle',\n class: {\n 'v-treeview-node__toggle--open': this.isOpen,\n 'v-treeview-node__toggle--loading': this.isLoading\n },\n slot: 'prepend',\n on: {\n click: (e: MouseEvent) => {\n e.stopPropagation()\n\n if (this.isLoading) return\n\n this.checkChildren().then(() => this.open())\n }\n }\n }, [this.isLoading ? this.loadingIcon : this.expandIcon])\n },\n genCheckbox () {\n return this.$createElement(VIcon, {\n staticClass: 'v-treeview-node__checkbox',\n props: {\n color: this.isSelected ? this.selectedColor : undefined\n },\n on: {\n click: (e: MouseEvent) => {\n e.stopPropagation()\n\n if (this.isLoading) return\n\n this.checkChildren().then(() => {\n // We nextTick here so that items watch in VTreeview has a chance to run first\n this.$nextTick(() => {\n this.isSelected = !this.isSelected\n this.isIndeterminate = false\n\n this.treeview.updateSelected(this.key, this.isSelected)\n this.treeview.emitSelected()\n })\n })\n }\n }\n }, [this.computedIcon])\n },\n genNode (): VNode {\n const children = [this.genContent()]\n\n if (this.selectable) children.unshift(this.genCheckbox())\n if (this.hasChildren) children.unshift(this.genToggle())\n\n return this.$createElement('div', {\n staticClass: 'v-treeview-node__root',\n class: {\n [this.activeClass]: this.isActive\n },\n on: {\n click: () => {\n if (this.openOnClick && this.children) {\n this.open()\n } else if (this.activatable) {\n this.isActive = !this.isActive\n this.treeview.updateActive(this.key, this.isActive)\n this.treeview.emitActive()\n }\n }\n }\n }, children)\n },\n genChild (item: any): VNode {\n return this.$createElement(VTreeviewNode, {\n key: getObjectValueByPath(item, this.itemKey),\n props: {\n activatable: this.activatable,\n activeClass: this.activeClass,\n item,\n selectable: this.selectable,\n selectedColor: this.selectedColor,\n expandIcon: this.expandIcon,\n indeterminateIcon: this.indeterminateIcon,\n offIcon: this.offIcon,\n onIcon: this.onIcon,\n loadingIcon: this.loadingIcon,\n itemKey: this.itemKey,\n itemText: this.itemText,\n itemChildren: this.itemChildren,\n loadChildren: this.loadChildren,\n transition: this.transition,\n openOnClick: this.openOnClick\n },\n scopedSlots: this.$scopedSlots\n })\n },\n genChildrenWrapper (): any {\n if (!this.isOpen || !this.children) return null\n\n const children = [this.children.map(this.genChild)]\n\n return this.$createElement('div', {\n staticClass: 'v-treeview-node__children'\n }, children)\n },\n genTransition () {\n return this.$createElement(VExpandTransition, [this.genChildrenWrapper()])\n }\n },\n\n render (h): VNode {\n const children = [this.genNode()]\n\n if (this.transition) children.push(this.genTransition())\n else children.push(this.genChildrenWrapper())\n\n return h('div', {\n staticClass: 'v-treeview-node',\n class: {\n 'v-treeview-node--leaf': !this.hasChildren,\n 'v-treeview-node--click': this.openOnClick,\n 'v-treeview-node--selected': this.isSelected,\n 'v-treeview-node--excluded': this.treeview.isExcluded(this.key)\n }\n }, children)\n }\n})\n"],"sourceRoot":""}