{"version":3,"file":"use-lifecycle.js","sources":["../../../../../../../packages/components/slider/src/composables/use-lifecycle.ts"],"sourcesContent":["import { nextTick, onMounted, ref } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport type { SliderInitData, SliderProps } from '../slider'\n\nexport const useLifecycle = (\n props: SliderProps,\n initData: SliderInitData,\n resetSize: () => void\n) => {\n const sliderWrapper = ref()\n\n onMounted(async () => {\n if (props.range) {\n if (Array.isArray(props.modelValue)) {\n initData.firstValue = Math.max(props.min, props.modelValue[0])\n initData.secondValue = Math.min(props.max, props.modelValue[1])\n } else {\n initData.firstValue = props.min\n initData.secondValue = props.max\n }\n initData.oldValue = [initData.firstValue, initData.secondValue]\n } else {\n if (\n typeof props.modelValue !== 'number' ||\n Number.isNaN(props.modelValue)\n ) {\n initData.firstValue = props.min\n } else {\n initData.firstValue = Math.min(\n props.max,\n Math.max(props.min, props.modelValue)\n )\n }\n initData.oldValue = initData.firstValue\n }\n\n useEventListener(window, 'resize', resetSize)\n\n await nextTick()\n resetSize()\n })\n\n return {\n sliderWrapper,\n }\n}\n"],"names":["ref","onMounted","useEventListener","nextTick"],"mappings":";;;;;;;AAEY,MAAC,YAAY,GAAG,CAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,KAAK;AAC5D,EAAE,MAAM,aAAa,GAAGA,OAAG,EAAE,CAAC;AAC9B,EAAEC,aAAS,CAAC,YAAY;AACxB,IAAI,IAAI,KAAK,CAAC,KAAK,EAAE;AACrB,MAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;AAC3C,QAAQ,QAAQ,CAAC,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AACvE,QAAQ,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,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