123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- import { createVNode as _createVNode } from "vue";
- // Styles
- import "./VProgressLinear.css";
- // Composables
- import { useBackgroundColor, useTextColor } from "../../composables/color.mjs";
- import { makeComponentProps } from "../../composables/component.mjs";
- import { useIntersectionObserver } from "../../composables/intersectionObserver.mjs";
- import { useRtl } from "../../composables/locale.mjs";
- import { makeLocationProps, useLocation } from "../../composables/location.mjs";
- import { useProxiedModel } from "../../composables/proxiedModel.mjs";
- import { makeRoundedProps, useRounded } from "../../composables/rounded.mjs";
- import { makeTagProps } from "../../composables/tag.mjs";
- import { makeThemeProps, provideTheme } from "../../composables/theme.mjs"; // Utilities
- import { computed, Transition } from 'vue';
- import { clamp, convertToUnit, genericComponent, IN_BROWSER, propsFactory, useRender } from "../../util/index.mjs";
- export const makeVProgressLinearProps = propsFactory({
- absolute: Boolean,
- active: {
- type: Boolean,
- default: true
- },
- bgColor: String,
- bgOpacity: [Number, String],
- bufferValue: {
- type: [Number, String],
- default: 0
- },
- bufferColor: String,
- bufferOpacity: [Number, String],
- clickable: Boolean,
- color: String,
- height: {
- type: [Number, String],
- default: 4
- },
- indeterminate: Boolean,
- max: {
- type: [Number, String],
- default: 100
- },
- modelValue: {
- type: [Number, String],
- default: 0
- },
- opacity: [Number, String],
- reverse: Boolean,
- stream: Boolean,
- striped: Boolean,
- roundedBar: Boolean,
- ...makeComponentProps(),
- ...makeLocationProps({
- location: 'top'
- }),
- ...makeRoundedProps(),
- ...makeTagProps(),
- ...makeThemeProps()
- }, 'VProgressLinear');
- export const VProgressLinear = genericComponent()({
- name: 'VProgressLinear',
- props: makeVProgressLinearProps(),
- emits: {
- 'update:modelValue': value => true
- },
- setup(props, _ref) {
- let {
- slots
- } = _ref;
- const progress = useProxiedModel(props, 'modelValue');
- const {
- isRtl,
- rtlClasses
- } = useRtl();
- const {
- themeClasses
- } = provideTheme(props);
- const {
- locationStyles
- } = useLocation(props);
- const {
- textColorClasses,
- textColorStyles
- } = useTextColor(props, 'color');
- const {
- backgroundColorClasses,
- backgroundColorStyles
- } = useBackgroundColor(computed(() => props.bgColor || props.color));
- const {
- backgroundColorClasses: bufferColorClasses,
- backgroundColorStyles: bufferColorStyles
- } = useBackgroundColor(computed(() => props.bufferColor || props.bgColor || props.color));
- const {
- backgroundColorClasses: barColorClasses,
- backgroundColorStyles: barColorStyles
- } = useBackgroundColor(props, 'color');
- const {
- roundedClasses
- } = useRounded(props);
- const {
- intersectionRef,
- isIntersecting
- } = useIntersectionObserver();
- const max = computed(() => parseFloat(props.max));
- const height = computed(() => parseFloat(props.height));
- const normalizedBuffer = computed(() => clamp(parseFloat(props.bufferValue) / max.value * 100, 0, 100));
- const normalizedValue = computed(() => clamp(parseFloat(progress.value) / max.value * 100, 0, 100));
- const isReversed = computed(() => isRtl.value !== props.reverse);
- const transition = computed(() => props.indeterminate ? 'fade-transition' : 'slide-x-transition');
- const isForcedColorsModeActive = IN_BROWSER && window.matchMedia?.('(forced-colors: active)').matches;
- function handleClick(e) {
- if (!intersectionRef.value) return;
- const {
- left,
- right,
- width
- } = intersectionRef.value.getBoundingClientRect();
- const value = isReversed.value ? width - e.clientX + (right - width) : e.clientX - left;
- progress.value = Math.round(value / width * max.value);
- }
- useRender(() => _createVNode(props.tag, {
- "ref": intersectionRef,
- "class": ['v-progress-linear', {
- 'v-progress-linear--absolute': props.absolute,
- 'v-progress-linear--active': props.active && isIntersecting.value,
- 'v-progress-linear--reverse': isReversed.value,
- 'v-progress-linear--rounded': props.rounded,
- 'v-progress-linear--rounded-bar': props.roundedBar,
- 'v-progress-linear--striped': props.striped
- }, roundedClasses.value, themeClasses.value, rtlClasses.value, props.class],
- "style": [{
- bottom: props.location === 'bottom' ? 0 : undefined,
- top: props.location === 'top' ? 0 : undefined,
- height: props.active ? convertToUnit(height.value) : 0,
- '--v-progress-linear-height': convertToUnit(height.value),
- ...(props.absolute ? locationStyles.value : {})
- }, props.style],
- "role": "progressbar",
- "aria-hidden": props.active ? 'false' : 'true',
- "aria-valuemin": "0",
- "aria-valuemax": props.max,
- "aria-valuenow": props.indeterminate ? undefined : normalizedValue.value,
- "onClick": props.clickable && handleClick
- }, {
- default: () => [props.stream && _createVNode("div", {
- "key": "stream",
- "class": ['v-progress-linear__stream', textColorClasses.value],
- "style": {
- ...textColorStyles.value,
- [isReversed.value ? 'left' : 'right']: convertToUnit(-height.value),
- borderTop: `${convertToUnit(height.value / 2)} dotted`,
- opacity: parseFloat(props.bufferOpacity),
- top: `calc(50% - ${convertToUnit(height.value / 4)})`,
- width: convertToUnit(100 - normalizedBuffer.value, '%'),
- '--v-progress-linear-stream-to': convertToUnit(height.value * (isReversed.value ? 1 : -1))
- }
- }, null), _createVNode("div", {
- "class": ['v-progress-linear__background', !isForcedColorsModeActive ? backgroundColorClasses.value : undefined],
- "style": [backgroundColorStyles.value, {
- opacity: parseFloat(props.bgOpacity),
- width: props.stream ? 0 : undefined
- }]
- }, null), _createVNode("div", {
- "class": ['v-progress-linear__buffer', !isForcedColorsModeActive ? bufferColorClasses.value : undefined],
- "style": [bufferColorStyles.value, {
- opacity: parseFloat(props.bufferOpacity),
- width: convertToUnit(normalizedBuffer.value, '%')
- }]
- }, null), _createVNode(Transition, {
- "name": transition.value
- }, {
- default: () => [!props.indeterminate ? _createVNode("div", {
- "class": ['v-progress-linear__determinate', !isForcedColorsModeActive ? barColorClasses.value : undefined],
- "style": [barColorStyles.value, {
- width: convertToUnit(normalizedValue.value, '%')
- }]
- }, null) : _createVNode("div", {
- "class": "v-progress-linear__indeterminate"
- }, [['long', 'short'].map(bar => _createVNode("div", {
- "key": bar,
- "class": ['v-progress-linear__indeterminate', bar, !isForcedColorsModeActive ? barColorClasses.value : undefined],
- "style": barColorStyles.value
- }, null))])]
- }), slots.default && _createVNode("div", {
- "class": "v-progress-linear__content"
- }, [slots.default({
- value: normalizedValue.value,
- buffer: normalizedBuffer.value
- })])]
- }));
- return {};
- }
- });
- //# sourceMappingURL=VProgressLinear.mjs.map
|