{"version":3,"file":"progress.vue2.mjs","sources":["../../../components/progress/progress.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { Bubble } from '@/components/bubble'\nimport { Renderer } from '@/components/renderer'\n\nimport { computed } from 'vue'\n\nimport { createStateProp, useNameHelper, useProps } from '@vexip-ui/config'\nimport { callIfFunc, toFixed } from '@vexip-ui/utils'\nimport { progressProps } from './props'\nimport { infoTypes } from './symbol'\n\nimport type { CSSProperties } from 'vue'\n\ndefineOptions({ name: 'Progress' })\n\nconst _props = defineProps(progressProps)\nconst props = useProps('progress', _props, {\n  percentage: {\n    default: 0,\n    validator: value => value >= 0 && value <= 100,\n    static: true\n  },\n  state: createStateProp(),\n  strokeWidth: 8,\n  infoType: {\n    default: 'outside',\n    validator: value => infoTypes.includes(value)\n  },\n  precision: 2,\n  activated: false,\n  strokeColor: {\n    default: null,\n    validator: value => !(Array.isArray(value) && (!value[0] || !value[1]))\n  },\n  slots: () => ({})\n})\n\nconst nh = useNameHelper('progress')\n\nconst className = computed(() => {\n  return [\n    nh.b(),\n    nh.bs('vars'),\n    nh.bm(`info-${props.infoType}`),\n    {\n      [nh.bm('inherit')]: props.inherit,\n      [nh.bm(props.state)]: props.state !== 'default',\n      [nh.bm('activated')]: props.activated\n    }\n  ]\n})\nconst style = computed(() => {\n  return { [nh.cv('percentage')]: props.percentage }\n})\nconst trackStyle = computed(() => {\n  return {\n    height: `${props.strokeWidth}px`,\n    borderRadius: `${props.strokeWidth}px`\n  }\n})\nconst fillerStyle = computed(() => {\n  const style: CSSProperties = {\n    borderRadius: `${props.strokeWidth}px`\n  }\n\n  const strokeColor = callIfFunc(props.strokeColor, props.percentage)\n\n  if (typeof strokeColor === 'string') {\n    style.backgroundColor = strokeColor\n  } else if (Array.isArray(strokeColor)) {\n    style.backgroundImage = `linear-gradient(to right, ${strokeColor[0]} 0%, ${strokeColor[1]} 100%)`\n  }\n\n  return style\n})\nconst useBubble = computed(() => {\n  return props.infoType.includes('bubble')\n})\nconst bubbleType = computed(() => {\n  if (useBubble.value) {\n    return props.infoType.split('-').pop() === 'bottom' ? 'bottom' : 'top'\n  }\n\n  return 'top'\n})\nconst bubbleStyle = computed(() => {\n  if (!useBubble.value) return {}\n\n  const type = bubbleType.value === 'top' ? 'bottom' : 'top'\n\n  return {\n    [type]: `${props.strokeWidth}px`\n  }\n})\nconst percentValue = computed(() => toFixed(props.percentage, props.precision))\n\ndefineExpose({ percentValue })\n</script>\n\n<template>\n  <div\n    :class=\"className\"\n    :style=\"style\"\n    role=\"progressbar\"\n    :aria-valuenow=\"percentValue\"\n    :aria-valuetext=\"`${percentValue}%`\"\n    aria-valuemin=\"0\"\n    aria-valuemax=\"100\"\n  >\n    <div :class=\"nh.be('track')\" :style=\"trackStyle\">\n      <div :class=\"nh.be('filler')\" :style=\"fillerStyle\"></div>\n      <div v-if=\"props.infoType === 'inside'\" :class=\"nh.be('info')\">\n        <slot>\n          <Renderer :renderer=\"props.slots.default\">\n            <span :class=\"nh.be('percentage')\">\n              {{ `${percentValue}%` }}\n            </span>\n          </Renderer>\n        </slot>\n      </div>\n    </div>\n    <div v-if=\"useBubble\" :class=\"nh.be('reference')\">\n      <Bubble\n        inherit\n        :class=\"nh.be('bubble')\"\n        :style=\"bubbleStyle\"\n        :placement=\"bubbleType\"\n        :content-class=\"nh.be('info')\"\n      >\n        <slot>\n          <Renderer :renderer=\"props.slots.default\">\n            <span :class=\"nh.be('percentage')\">\n              {{ `${percentValue}%` }}\n            </span>\n          </Renderer>\n        </slot>\n      </Bubble>\n    </div>\n    <div v-else-if=\"props.infoType === 'outside'\" :class=\"nh.be('info')\">\n      <slot>\n        <Renderer :renderer=\"props.slots.default\">\n          <span :class=\"nh.be('percentage')\">\n            {{ `${percentValue}%` }}\n          </span>\n        </Renderer>\n      </slot>\n    </div>\n  </div>\n</template>\n"],"names":["props","useProps","__props","value","createStateProp","infoTypes","nh","useNameHelper","className","computed","style","trackStyle","fillerStyle","strokeColor","callIfFunc","useBubble","bubbleType","bubble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