You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1 lines
4.3 KiB

{"ast":null,"code":"import { ref, onMounted, onBeforeUnmount, watch } from 'vue';\nimport { useResizeObserver } from '@vueuse/core';\nconst useAutoResize = props => {\n const sizer = ref();\n const width$ = ref(0);\n const height$ = ref(0);\n let resizerStopper;\n onMounted(() => {\n resizerStopper = useResizeObserver(sizer, ([entry]) => {\n const {\n width,\n height\n } = entry.contentRect;\n const {\n paddingLeft,\n paddingRight,\n paddingTop,\n paddingBottom\n } = getComputedStyle(entry.target);\n const left = Number.parseInt(paddingLeft) || 0;\n const right = Number.parseInt(paddingRight) || 0;\n const top = Number.parseInt(paddingTop) || 0;\n const bottom = Number.parseInt(paddingBottom) || 0;\n width$.value = width - left - right;\n height$.value = height - top - bottom;\n }).stop;\n });\n onBeforeUnmount(() => {\n resizerStopper == null ? void 0 : resizerStopper();\n });\n watch([width$, height$], ([width, height]) => {\n var _a;\n (_a = props.onResize) == null ? void 0 : _a.call(props, {\n width,\n height\n });\n });\n return {\n sizer,\n width: width$,\n height: height$\n };\n};\nexport { useAutoResize };","map":{"version":3,"names":["useAutoResize","props","sizer","ref","width$","height$","resizerStopper","onMounted","useResizeObserver","entry","width","height","contentRect","paddingLeft","paddingRight","paddingTop","paddingBottom","getComputedStyle","target","left","Number","parseInt","right","top","bottom","value","stop","onBeforeUnmount","watch","_a","onResize","call"],"sources":["../../../../../../../packages/components/table-v2/src/composables/use-auto-resize.ts"],"sourcesContent":["import { onBeforeUnmount, onMounted, ref, watch } from 'vue'\nimport { useResizeObserver } from '@vueuse/core'\n\nimport type { AutoResizerProps } from '../auto-resizer'\n\nconst useAutoResize = (props: AutoResizerProps) => {\n const sizer = ref<HTMLElement>()\n const width$ = ref(0)\n const height$ = ref(0)\n\n let resizerStopper: ReturnType<typeof useResizeObserver>['stop']\n onMounted(() => {\n resizerStopper = useResizeObserver(sizer, ([entry]) => {\n const { width, height } = entry.contentRect\n const { paddingLeft, paddingRight, paddingTop, paddingBottom } =\n getComputedStyle(entry.target)\n\n const left = Number.parseInt(paddingLeft) || 0\n const right = Number.parseInt(paddingRight) || 0\n const top = Number.parseInt(paddingTop) || 0\n const bottom = Number.parseInt(paddingBottom) || 0\n\n width$.value = width - left - right\n height$.value = height - top - bottom\n }).stop\n })\n\n onBeforeUnmount(() => {\n resizerStopper?.()\n })\n\n watch([width$, height$], ([width, height]) => {\n props.onResize?.({\n width,\n height,\n })\n })\n\n return {\n sizer,\n width: width$,\n height: height$,\n }\n}\n\nexport { useAutoResize }\n"],"mappings":";;AAEK,MAACA,aAAa,GAAIC,KAAK,IAAK;EAC/B,MAAMC,KAAK,GAAGC,GAAG,EAAE;EACnB,MAAMC,MAAM,GAAGD,GAAG,CAAC,CAAC,CAAC;EACrB,MAAME,OAAO,GAAGF,GAAG,CAAC,CAAC,CAAC;EACtB,IAAIG,cAAc;EAClBC,SAAS,CAAC,MAAM;IACdD,cAAc,GAAGE,iBAAiB,CAACN,KAAK,EAAE,CAAC,CAACO,KAAK,CAAC,KAAK;MACrD,MAAM;QAAEC,KAAK;QAAEC;MAAM,CAAE,GAAGF,KAAK,CAACG,WAAW;MAC3C,MAAM;QAAEC,WAAW;QAAEC,YAAY;QAAEC,UAAU;QAAEC;MAAa,CAAE,GAAGC,gBAAgB,CAACR,KAAK,CAACS,MAAM,CAAC;MAC/F,MAAMC,IAAI,GAAGC,MAAM,CAACC,QAAQ,CAACR,WAAW,CAAC,IAAI,CAAC;MAC9C,MAAMS,KAAK,GAAGF,MAAM,CAACC,QAAQ,CAACP,YAAY,CAAC,IAAI,CAAC;MAChD,MAAMS,GAAG,GAAGH,MAAM,CAACC,QAAQ,CAACN,UAAU,CAAC,IAAI,CAAC;MAC5C,MAAMS,MAAM,GAAGJ,MAAM,CAACC,QAAQ,CAACL,aAAa,CAAC,IAAI,CAAC;MAClDZ,MAAM,CAACqB,KAAK,GAAGf,KAAK,GAAGS,IAAI,GAAGG,KAAK;MACnCjB,OA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