{"version":3,"file":"line.vue.mjs","sources":["../../../../../../packages/components/progress/src/line.vue"],"sourcesContent":["<script lang=\"ts\">\n  import type { PropType, StyleValue } from 'vue'\n  import { computed, defineComponent } from 'vue'\n  import { getNamespace } from '../../../utils/global-config'\n  import { addUnit } from '../../../shared/utils'\n  import { isFunction, isString } from '../../../utils/is'\n  import type { ProgressStatus, ProgressSize } from './type'\n\n  const DEFAULT_STROKE_WIDTH = {\n    small: 6,\n    normal: 8,\n    large: 10\n  }\n\n  export default defineComponent({\n    name: 'ProgressLine',\n    props: {\n      percent: {\n        type: Number,\n        default: 0\n      },\n      animation: {\n        type: Boolean,\n        default: false\n      },\n      size: {\n        type: String as PropType<ProgressSize>,\n        default: 'normal'\n      },\n      strokeWidth: {\n        type: Number,\n        default: 0\n      },\n      width: {\n        type: [Number, String],\n        default: '100%'\n      },\n      color: {\n        type: [String, Function],\n        default: undefined\n      },\n      // eslint-disable-next-line vue/require-default-prop\n      trackColor: String,\n      formatText: {\n        type: Function,\n        default: undefined\n      },\n      status: {\n        type: String as PropType<ProgressStatus>,\n        default: 'primary'\n      },\n      showText: Boolean\n    },\n    setup(props) {\n      const ns = getNamespace('progress-line')\n\n      const cls = computed(() => {\n        return [ns]\n      })\n\n      const computedStrokeWidth = computed(() => {\n        if (props.strokeWidth) {\n          return props.strokeWidth\n        }\n        return DEFAULT_STROKE_WIDTH[props.size]\n      })\n\n      const trackStyle = computed(() => {\n        const style: StyleValue = {\n          width: addUnit(props.width),\n          height: addUnit(computedStrokeWidth.value),\n          backgroundColor: props.trackColor\n        }\n        return style\n      })\n\n      const getBarColor = (): string => {\n        if (isString(props.color)) {\n          return props.color\n        }\n        if (isFunction(props.color)) {\n          return props.color(props.percent) as string\n        }\n\n        if (props.status) {\n          return `var(--bn-${props.status})`\n        }\n\n        return ''\n      }\n\n      const barStyle = computed(() => {\n        const barBgColor = getBarColor()\n        const style: StyleValue = {\n          width: `${props.percent}%`,\n          background: barBgColor\n        }\n        return style\n      })\n\n      const bufferStyle = computed(() => {\n        const style: StyleValue = {}\n        if (props.animation) {\n          style.width = `${props.percent}%`\n        }\n        return style\n      })\n\n      const text = computed(() => {\n        if (isFunction(props.formatText)) {\n          return props.formatText(props.percent)\n        }\n        return props.percent + '%'\n      })\n\n      return {\n        ns,\n        cls,\n        text,\n        trackStyle,\n        barStyle,\n        bufferStyle\n      }\n    }\n  })\n</script>\n\n<template>\n  <div :class=\"cls\" aria-valuemin=\"0\" aria-valuemax=\"100\" :aria-valuenow=\"percent\">\n    <div :class=\"[`${ns}__track`]\" :style=\"trackStyle\">\n      <div\n        :class=\"[\n          `${ns}__buffer`,\n          {\n            'is-animation': animation\n          }\n        ]\"\n        :style=\"bufferStyle\"\n      ></div>\n      <div :class=\"[`${ns}__bar`]\" :style=\"barStyle\"></div>\n    </div>\n\n    <div v-if=\"showText\" :class=\"[`${ns}__text`]\">\n      <slot name=\"text\" :percent=\"percent\">\n        {{ text }}\n      </slot>\n    </div>\n  </div>\n</template>\n"],"names":["cls","_openBlock","_createElementBlock","_normalizeClass","percent","trackStyle","_normalizeStyle","ns","barStyle","showText"],"mappings":";;;;;AAgIa,SAAA,YAAA,IAAEA,EAAAA,MAAAA,EAAG,MAAA,EAAA,MAAA,EAAA,OAAA,QAAA,EAAA;AAAE,EAAA,OAAAC,SAAA,EAAiB,EAAAC,kBAAA,CAAA,KAAA,EAAA;AAAA,IAAC,KAAA,EAAmBC,cAAA,CAAA,IAAA,CAAA,GAAA,CAAA;AAAA,IAAE,eAAeC,EAAAA,GAAAA;AAAAA,IAAAA,eAAAA,EAAAA,KAAAA;AAAAA,IACtE,iBAWM,IAAA,CAAA,OAAA;AAAA,GAAA,EAAA;AAAA;MAX+B,KAAA;AAAA,MAAEC;AAAAA,QAAAA,OAAAA,cAAAA,CAAAA,CAAAA,CAAAA,EAAAA,IAAAA,CAAAA,WAAAA,CAAAA,CAAAA;AAAAA,QACrC,KAAA,EAQOC,cAAA,CAAA,IAAA,CAAA,UAAA,CAAA;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