All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.lib.labs.VTreeview.VTreeview.mjs.map Maven / Gradle / Ivy

{"version":3,"file":"VTreeview.mjs","names":["makeVTreeviewChildrenProps","VTreeviewChildren","makeVListProps","useListItems","VList","provideDefaults","makeFilterProps","useFilter","useProxiedModel","computed","provide","ref","toRef","genericComponent","omit","propsFactory","useRender","VTreeviewSymbol","flatten","items","flat","arguments","length","undefined","item","push","children","makeVTreeviewProps","openAll","Boolean","search","String","filterKeys","collapseIcon","expandIcon","slim","VTreeview","name","props","emits","val","value","setup","_ref","slots","activeColor","baseColor","color","activated","selected","vListRef","opened","flatItems","filteredItems","visibleIds","Set","flatMap","getPath","getChildren","id","path","parent","unshift","parents","get","arr","queue","slice","child","shift","ids","i","concat","VTreeviewGroup","VTreeviewItem","activeClass","density","disabled","lines","variant","listProps","filterProps","treeviewChildrenProps","_createVNode","_mergeProps","class","style","$event","default","open"],"sources":["../../../src/labs/VTreeview/VTreeview.tsx"],"sourcesContent":["// Components\nimport { makeVTreeviewChildrenProps, VTreeviewChildren } from './VTreeviewChildren'\nimport { makeVListProps, useListItems, VList } from '@/components/VList/VList'\n\n// Composables\nimport { provideDefaults } from '@/composables/defaults'\nimport { makeFilterProps, useFilter } from '@/composables/filter'\nimport { useProxiedModel } from '@/composables/proxiedModel'\n\n// Utilities\nimport { computed, provide, ref, toRef } from 'vue'\nimport { genericComponent, omit, propsFactory, useRender } from '@/util'\n\n// Types\nimport { VTreeviewSymbol } from './shared'\nimport type { VListChildrenSlots } from '@/components/VList/VListChildren'\nimport type { ListItem } from '@/composables/list-items'\nimport type { GenericProps } from '@/util'\n\nfunction flatten (items: ListItem[], flat: ListItem[] = []) {\n  for (const item of items) {\n    flat.push(item)\n    if (item.children) flatten(item.children, flat)\n  }\n  return flat\n}\n\nexport const makeVTreeviewProps = propsFactory({\n  openAll: Boolean,\n  search: String,\n\n  ...makeFilterProps({ filterKeys: ['title'] }),\n  ...makeVTreeviewChildrenProps(),\n  ...omit(makeVListProps({\n    collapseIcon: '$treeviewCollapse',\n    expandIcon: '$treeviewExpand',\n    slim: true,\n  }), ['nav']),\n}, 'VTreeview')\n\nexport const VTreeview = genericComponent(\n  props: {\n    items?: T[]\n  },\n  slots: VListChildrenSlots\n) => GenericProps>()({\n  name: 'VTreeview',\n\n  props: makeVTreeviewProps(),\n\n  emits: {\n    'update:opened': (val: unknown) => true,\n    'update:activated': (val: unknown) => true,\n    'update:selected': (val: unknown) => true,\n    'click:open': (value: { id: unknown, value: boolean, path: unknown[] }) => true,\n    'click:select': (value: { id: unknown, value: boolean, path: unknown[] }) => true,\n  },\n\n  setup (props, { slots }) {\n    const { items } = useListItems(props)\n    const activeColor = toRef(props, 'activeColor')\n    const baseColor = toRef(props, 'baseColor')\n    const color = toRef(props, 'color')\n    const activated = useProxiedModel(props, 'activated')\n    const selected = useProxiedModel(props, 'selected')\n\n    const vListRef = ref()\n\n    const opened = computed(() => props.openAll ? openAll(items.value) : props.opened)\n    const flatItems = computed(() => flatten(items.value))\n    const search = toRef(props, 'search')\n    const { filteredItems } = useFilter(props, flatItems, search)\n    const visibleIds = computed(() => {\n      if (!search.value) {\n        return null\n      }\n      return new Set(filteredItems.value.flatMap(item => {\n        return [...getPath(item.props.value), ...getChildren(item.props.value)]\n      }))\n    })\n\n    function getPath (id: unknown) {\n      const path: unknown[] = []\n      let parent: unknown = id\n      while (parent != null) {\n        path.unshift(parent)\n        parent = vListRef.value?.parents.get(parent)\n      }\n      return path\n    }\n\n    function getChildren (id: unknown) {\n      const arr: unknown[] = []\n      const queue = ((vListRef.value?.children.get(id) ?? []).slice())\n      while (queue.length) {\n        const child = queue.shift()\n        if (!child) continue\n        arr.push(child)\n        queue.push(...((vListRef.value?.children.get(child) ?? []).slice()))\n      }\n      return arr\n    }\n\n    function openAll (item: any) {\n      let ids: number[] = []\n\n      for (const i of item) {\n        if (!i.children) continue\n\n        ids.push(i.value)\n\n        if (i.children) {\n          ids = ids.concat(openAll(i.children))\n        }\n      }\n\n      return ids\n    }\n\n    provide(VTreeviewSymbol, { visibleIds })\n\n    provideDefaults({\n      VTreeviewGroup: {\n        activeColor,\n        baseColor,\n        color,\n        collapseIcon: toRef(props, 'collapseIcon'),\n        expandIcon: toRef(props, 'expandIcon'),\n      },\n      VTreeviewItem: {\n        activeClass: toRef(props, 'activeClass'),\n        activeColor,\n        baseColor,\n        color,\n        density: toRef(props, 'density'),\n        disabled: toRef(props, 'disabled'),\n        lines: toRef(props, 'lines'),\n        variant: toRef(props, 'variant'),\n      },\n    })\n\n    useRender(() => {\n      const listProps = VList.filterProps(props)\n\n      const treeviewChildrenProps = VTreeviewChildren.filterProps(props)\n\n      return (\n        \n          \n        \n      )\n    })\n\n    return {\n      open,\n    }\n  },\n})\n\nexport type VTreeview = InstanceType\n"],"mappings":";AAAA;AAAA,SACSA,0BAA0B,EAAEC,iBAAiB;AAAA,SAC7CC,cAAc,EAAEC,YAAY,EAAEC,KAAK,4CAE5C;AAAA,SACSC,eAAe;AAAA,SACfC,eAAe,EAAEC,SAAS;AAAA,SAC1BC,eAAe,8CAExB;AACA,SAASC,QAAQ,EAAEC,OAAO,EAAEC,GAAG,EAAEC,KAAK,QAAQ,KAAK;AAAA,SAC1CC,gBAAgB,EAAEC,IAAI,EAAEC,YAAY,EAAEC,SAAS,gCAExD;AAAA,SACSC,eAAe;AAKxB,SAASC,OAAOA,CAAEC,KAAiB,EAAyB;EAAA,IAAvBC,IAAgB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,EAAE;EACxD,KAAK,MAAMG,IAAI,IAAIL,KAAK,EAAE;IACxBC,IAAI,CAACK,IAAI,CAACD,IAAI,CAAC;IACf,IAAIA,IAAI,CAACE,QAAQ,EAAER,OAAO,CAACM,IAAI,CAACE,QAAQ,EAAEN,IAAI,CAAC;EACjD;EACA,OAAOA,IAAI;AACb;AAEA,OAAO,MAAMO,kBAAkB,GAAGZ,YAAY,CAAC;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