{"version":3,"sources":["webpack:///./src/components/AppTable.vue","webpack:///./src/utils/filters.ts","webpack:///./src/components/AppTable.vue?9bfa","webpack:///./src/components/AppTable.vue?1046","webpack:///./src/components/AppTable.vue?98c0"],"names":["render","_vm","this","_c","_self","_setup","_setupProxy","VDataTable","_g","_b","ref","attrs","headers","props","items","scopedSlots","_u","key","fn","_headers","_items","model","value","inlineFilters","callback","$$v","expression","proxy","_l","slots","_","slot","slotData","_t","$attrs","$listeners","staticRenderFns","filterColumn","filter","dataType","undefined","Array","isArray","length","filterText","String","toLowerCase","normalize","replace","isOperation","test","includes","substring","Number","filterDate","map","f","temp","Date","setHours","getTime","max","Math","min","filterSelect","filterBool","Boolean","__name","__props","refs","$refs","$scopedSlots","h","dataTypes","reduce","t","getProp","obj","a","split","i","n","k","filteredItems","imp","Object","entries","every","val","scrollToRow","index","table","dataTable","$el","querySelector","row","rows","scrollIntoView","trigger","deep","debounce","immediate","__sfc","component"],"mappings":"wIAAA,IAAIA,EAAS,WAAkB,IAAIC,EAAIC,KAAKC,EAAGF,EAAIG,MAAMD,GAAGE,EAAOJ,EAAIG,MAAME,YAAY,OAAOH,EAAGE,EAAOE,WAAWN,EAAIO,GAAGP,EAAIQ,GAAG,CAACC,IAAI,YAAYC,MAAM,CAAC,QAAUV,EAAIW,QAAQ,MAAQP,EAAOQ,MAAMC,MAAM,qBAAqB,GAAG,sBAAsB,IAAIC,YAAYd,EAAIe,GAAG,CAAC,CAACC,IAAI,QAAQC,GAAG,WAAW,MAAO,CAACf,EAAG,gBAAgB,CAACQ,MAAM,CAAC,QAAUN,EAAOc,SAAS,MAAQd,EAAOe,QAAQC,MAAM,CAACC,MAAOjB,EAAOkB,cAAeC,SAAS,SAAUC,GAAMpB,EAAOkB,cAAcE,GAAKC,WAAW,qBAAqBC,OAAM,GAAM1B,EAAI2B,GAAIvB,EAAOwB,OAAO,SAASC,EAAEC,GAAM,MAAO,CAACd,IAAIc,EAAKb,GAAG,SAASc,GAAU,MAAO,CA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M,EAAEtE,EAAKuE,KACxCnD,EAAauC,EAAQQ,EAAKnE,GAAMuE,EAAKf,EAAUnD,MAAML,OAapE,SAASwE,EAAYC,GACnB,MAAMC,EAAQtB,EAAKuB,UAAUC,IAAIC,cAAc,SACzCC,EAAMJ,EAAMK,KAAKN,GACnBK,GACFA,EAAIE,gBAAe,GAgCvB,OA3CA,4BAAe,CAAC1E,EAAeH,GAAS+D,EAAce,QAAS,CAC7DC,MAAM,EACNC,SAAU,IACVC,WAAW,IAwCN,CAAEC,OAAO,EAAKzF,QAAOwD,OAAMxC,QAAON,gBAAeH,SAAQD,WAAUsD,YAAWG,UAASO,gBAAeM,cAAalF,aAAA,SC5G8J,I,YCOpRgG,EAAY,eACd,EACAvG,EACAoC,GACA,EACA,KACA,KACA,MAIa,aAAAmE,E","file":"js/chunk-2d221b96.4103d153.js","sourcesContent":["var render = function render(){var _vm=this,_c=_vm._self._c,_setup=_vm._self._setupProxy;return _c(_setup.VDataTable,_vm._g(_vm._b({ref:\"dataTable\",attrs:{\"headers\":_vm.headers,\"items\":_setup.props.items,\"disable-pagination\":\"\",\"hide-default-footer\":\"\"},scopedSlots:_vm._u([{key:\"thead\",fn:function(){return [_c('table-filters',{attrs:{\"headers\":_setup._headers,\"items\":_setup._items},model:{value:(_setup.inlineFilters),callback:function ($$v) {_setup.inlineFilters=$$v},expression:\"inlineFilters\"}})]},proxy:true},_vm._l((_setup.slots),function(_,slot){return {key:slot,fn:function(slotData){return [_vm._t(slot,null,null,slotData)]}}})],null,true)},'v-data-table',_vm.$attrs,false),_vm.$listeners))\n}\nvar staticRenderFns = []\n\nexport { render, staticRenderFns }","export function parseDate( value, opciones : Intl.DateTimeFormatOptions ) {\n if (!value) return ''\n const date = new Date(value)\n return date.toLocaleString(['es-ES'], {\n month: 'short',\n day: '2-digit',\n year: 'numeric',\n ...opciones\n // hour: '2-digit',\n // minute: '2-digit',\n })\n}\n\ntype ValueType = string | boolean | null | number\ntype FilterType = string | ValueType[] | boolean\n\nexport function filterColumn(value : ValueType, filter : FilterType, dataType = \"text\") : Boolean {\n if (\n filter === \"\" ||\n filter === null ||\n filter === undefined ||\n (Array.isArray(filter) && filter.length == 0)\n )\n return true;\n if (filter === \"-\") return value === null;\n if (value === \"\" || value === null || value === undefined) return false;\n\n const filterText = (filter : string, value : ValueType) => {\n value = String(value)\n .toLowerCase()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\");\n filter = String(filter)\n .toLowerCase()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\");\n const isOperation = /=|<|>|!/.test(filter[0]);\n if (isOperation) {\n switch (filter[0]) {\n case \"!\":\n return !value.includes(filter.substring(1));\n case \"=\":\n return value == filter.substring(1);\n case \">\":\n return Number(value) >= Number(filter.substring(1));\n case \"<\":\n return Number(value) <= Number(filter.substring(1));\n default:\n return false;\n }\n } else {\n return value.includes(filter);\n }\n };\n const filterDate = (filter : string[], value : ValueType) => {\n filter = filter.map((f) => {\n let temp = new Date(f);\n temp.setHours(0, 0, 0, 0);\n return temp.getTime();\n });\n value = new Date(value).getTime();\n let max = Math.max(...filter);\n let min = Math.min(...filter);\n return max >= value && value >= min;\n };\n const filterSelect = (filter : ValueType[], value : ValueType) => {\n if (filter.length > 1) return filter.includes(value);\n else return filterText(\"=\" + filter[0], value);\n };\n const filterBool = (filter : boolean, value : ValueType) => filter == Boolean(value);\n\n switch (dataType) {\n case \"select\":\n return filterSelect(filter, value);\n case \"date\":\n return filterDate(filter, value);\n case \"bool\":\n return filterBool(filter, value);\n case \"text\":\n default:\n return filterText(filter, value);\n }\n};","import { defineComponent as _defineComponent } from 'vue'\nimport { computedWithControl, watchDebounced } from '@vueuse/core';\nimport { ref, computed, getCurrentInstance, watch } from 'vue'\nimport { VDataTable } from \"vuetify/lib/components/VDataTable\";\nimport { filterColumn } from \"@/utils/filters\";\n\n\nexport default /*#__PURE__*/_defineComponent({\n __name: 'AppTable',\n props: [\"headers\", \"items\"],\n setup(__props) {\n\nconst props = __props;\n\n\n\n// const start = ref(0)\n// const itemsPerPage = 40\n// const end = ref( itemsPerPage )\n\n// const display = computed(() => props.items.slice(start.value, end.value))\n\nconst refs = getCurrentInstance()?.proxy.$refs\nconst slots = { ...getCurrentInstance()?.proxy.$scopedSlots, ...getCurrentInstance()?.proxy.$scopedSlots }\n\nconst inlineFilters = ref({});\n\nconst _items = computed(() => props.items);\nconst _headers = computed(() =>\n props.headers.map((h) => ({ dataType: \"text\", ...h }))\n);\n\nconst dataTypes = computed(() =>\n _headers.value.reduce((t, h) => {\n t[h.key] = h.dataType || \"text\";\n return t;\n }, {})\n);\n\nfunction getProp(obj: Object, key: string) {\n key = key.replace(/\\[(\\w+)\\]/g, '.$1'); // convert indexes to properties\n key = key.replace(/^\\./, ''); // strip a leading dot\n var a = key.split('.');\n for (var i = 0, n = a.length; i < n; ++i) {\n var k = a[i];\n if (k in obj) {\n obj = obj[k];\n } else {\n return;\n }\n }\n return obj;\n}\n\nconst filteredItems = computedWithControl(\n () => { },\n () => {\n return _items.value.filter((imp) =>\n Object.entries(inlineFilters.value).every(([key, val]) => {\n return filterColumn(getProp(imp, key), val, dataTypes.value[key]);\n })\n );\n }\n);\n\nwatchDebounced([inlineFilters, _items], filteredItems.trigger, {\n deep: true,\n debounce: 200,\n immediate: true,\n});\n\n\nfunction scrollToRow(index) {\n const table = refs.dataTable.$el.querySelector(\"table\");\n const row = table.rows[index];\n if (row) {\n row.scrollIntoView(true);\n }\n}\n\n// function loadMore(entries, observer, isIntersecting) {\n// if (isIntersecting) {\n// const indexesLeft = props.items.length - end.value;\n// if (indexesLeft < itemsPerPage) {\n// // start.value = end.value + indexesLeft - itemsPerPage;\n// end.value = props.items.length;\n// } else {\n// // start.value += itemsPerPage;\n// end.value += itemsPerPage;\n// }\n// // scrollToRow( 23 );\n// }\n// }\n\n// function loadLess(entries, observer, isIntersecting) {\n// if (isIntersecting) {\n// if (start.value < itemsPerPage) {\n// start.value = 0;\n// end.value = itemsPerPage;\n// } else {\n// // start.value -= itemsPerPage;\n// end.value -= itemsPerPage;\n// }\n// // scrollToRow( 5 );\n// }\n// }\n\n\nreturn { __sfc: true,props, refs, slots, inlineFilters, _items, _headers, dataTypes, getProp, filteredItems, scrollToRow, VDataTable }\n}\n\n})","import mod from \"-!../../node_modules/ts-loader/index.js??ref--15!../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../node_modules/@vue/cli-service/node_modules/vue-loader/lib/index.js??vue-loader-options!./AppTable.vue?vue&type=script&setup=true&lang=ts\"; export default mod; export * from \"-!../../node_modules/ts-loader/index.js??ref--15!../../node_modules/cache-loader/dist/cjs.js??ref--1-0!../../node_modules/@vue/cli-service/node_modules/vue-loader/lib/index.js??vue-loader-options!./AppTable.vue?vue&type=script&setup=true&lang=ts\"","import { render, staticRenderFns } from \"./AppTable.vue?vue&type=template&id=72460044\"\nimport script from \"./AppTable.vue?vue&type=script&setup=true&lang=ts\"\nexport * from \"./AppTable.vue?vue&type=script&setup=true&lang=ts\"\n\n\n/* normalize component */\nimport normalizer from \"!../../node_modules/@vue/cli-service/node_modules/vue-loader/lib/runtime/componentNormalizer.js\"\nvar component = normalizer(\n script,\n render,\n staticRenderFns,\n false,\n null,\n null,\n null\n \n)\n\nexport default component.exports"],"sourceRoot":""}