{"version":3,"file":"use-lifecycle.mjs","names":[],"sources":["../../../../../../../packages/components/slider/src/composables/use-lifecycle.ts"],"sourcesContent":["import { nextTick, onMounted, ref } from 'vue'\nimport { useEventListener } from '@vueuse/core'\nimport { isArray, isNumber } from '@element-plus/utils'\n\nimport type { SliderInitData, SliderProps } from '../slider'\n\nexport const useLifecycle = (\n  props: SliderProps,\n  initData: SliderInitData,\n  resetSize: () => void\n) => {\n  const sliderWrapper = ref<HTMLElement>()\n\n  onMounted(async () => {\n    if (props.range) {\n      if (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 (!isNumber(props.modelValue) || Number.isNaN(props.modelValue)) {\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"],"mappings":";;;;AAMA,MAAa,gBACX,OACA,UACA,cACG;CACH,MAAM,gBAAgB,KAAkB;CAExC,UAAU,YAAY;EACpB,IAAI,MAAM,OAAO;GACf,IAAI,QAAQ,MAAM,WAAW,EAAE;IAC7B,SAAS,aAAa,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,GAAG;IAC9D,SAAS,cAAc,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,GAAG;UAC1D;IACL,SAAS,aAAa,MAAM;IAC5B,SAAS,cAAc,MAAM;;GAE/B,SAAS,WAAW,CAAC,SAAS,YAAY,SAAS,YAAY;SAC1D;GACL,IAAI,CAAC,SAAS,MAAM,WAAW,IAAI,OAAO,MAAM,MAAM,WAAW,EAC/D,SAAS,aAAa,MAAM;QAE5B,SAAS,aAAa,KAAK,IACzB,MAAM,KACN,KAAK,IAAI,MAAM,KAAK,MAAM,WAAW,CACtC;GAEH,SAAS,WAAW,SAAS;;EAG/B,iBAAiB,QAAQ,UAAU,UAAU;EAE7C,MAAM,UAAU;EAChB,WAAW;GACX;CAEF,OAAO,EACL,eACD"}