UNPKG

@yamada-ui/rating

Version:

Yamada UI rating component

57 lines (55 loc) 1.58 kB
"use client" import { RatingItem } from "./chunk-G2ZEZHKB.mjs"; import { getRoundedValue } from "./chunk-5OU2JQG4.mjs"; import { useRatingContext } from "./chunk-UAH7LDHT.mjs"; // src/rating-group.tsx import { motion, motionForwardRef } from "@yamada-ui/motion"; import { cx, runIfFunc } from "@yamada-ui/utils"; import { jsx } from "react/jsx-runtime"; var RatingGroup = motionForwardRef( ({ className, color, items, value: groupValue, ...rest }, ref) => { const { decimal, styles, getGroupProps, groupProps } = useRatingContext(); const computedGroupProps = runIfFunc(groupProps, groupValue); const css = { ...styles.group }; return /* @__PURE__ */ jsx( motion.div, { className: cx("ui-rating__group", className), __css: css, ...getGroupProps( { value: groupValue, ...computedGroupProps, ...rest }, ref ), children: Array(items).fill(0).map((_, index) => { const fractionValue = decimal * (groupValue === 1 ? index : index + 1); const value = getRoundedValue( groupValue - 1 + fractionValue, decimal ); return /* @__PURE__ */ jsx( RatingItem, { color, fractionValue, groupValue, value }, `${groupValue}-${fractionValue}` ); }) } ); } ); RatingGroup.displayName = "RatingGroup"; RatingGroup.__ui__ = "RatingGroup"; export { RatingGroup }; //# sourceMappingURL=chunk-LHWQAME3.mjs.map