@yamada-ui/react
Version:
React UI components of the Yamada, by the Yamada, for the Yamada built with React and Emotion
48 lines (44 loc) • 1.57 kB
JavaScript
"use client";
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
const require_utils_index = require('../../utils/index.cjs');
const require_i18n_provider = require('../../providers/i18n-provider/i18n-provider.cjs');
let react = require("react");
react = require_rolldown_runtime.__toESM(react);
//#region src/components/progress/use-progress.ts
const useProgress = ({ max = 100, min = 0, value } = {}) => {
const indeterminate = value === null;
const percent = (0, require_utils_index.utils_exports.valueToPercent)(value ?? 0, min, max);
const { t } = require_i18n_provider.useI18n("progress");
const getRootProps = (0, react.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, require_utils_index.utils_exports.dataAttr)(indeterminate),
role: "progressbar",
...props
}), [
max,
min,
percent,
value,
indeterminate,
t
]);
const getTrackProps = (0, react.useCallback)((props) => ({
"data-indeterminate": (0, require_utils_index.utils_exports.dataAttr)(indeterminate),
...props
}), [indeterminate]);
return {
percent,
getRangeProps: (0, react.useCallback)((props) => ({
"data-indeterminate": (0, require_utils_index.utils_exports.dataAttr)(indeterminate),
...props
}), [indeterminate]),
getRootProps,
getTrackProps
};
};
//#endregion
exports.useProgress = useProgress;
//# sourceMappingURL=use-progress.cjs.map