@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
46 lines (42 loc) • 1.27 kB
JavaScript
"use client";
import { utils_exports } from "../../utils/index.js";
import { useI18n } from "../../providers/i18n-provider/i18n-provider.js";
import { useCallback } from "react";
//#region src/components/progress/use-progress.ts
const useProgress = ({ max = 100, min = 0, value } = {}) => {
const indeterminate = value === null;
const percent = (0, utils_exports.valueToPercent)(value ?? 0, min, max);
const { t } = useI18n("progress");
const getRootProps = useCallback((props) => ({
"aria-label": indeterminate ? t("Loading...") : t("{value} percent", { value: percent }),
"aria-valuemax": max,
"aria-valuemin": min,
"aria-valuenow": value ?? void 0,
"data-indeterminate": (0, utils_exports.dataAttr)(indeterminate),
role: "progressbar",
...props
}), [
max,
min,
percent,
value,
indeterminate,
t
]);
const getTrackProps = useCallback((props) => ({
"data-indeterminate": (0, utils_exports.dataAttr)(indeterminate),
...props
}), [indeterminate]);
return {
percent,
getRangeProps: useCallback((props) => ({
"data-indeterminate": (0, utils_exports.dataAttr)(indeterminate),
...props
}), [indeterminate]),
getRootProps,
getTrackProps
};
};
//#endregion
export { useProgress };
//# sourceMappingURL=use-progress.js.map