@react-vant-next/campaign
Version:
React Mobile UI Components based on Vant UI - Next Generation
30 lines (27 loc) • 1.14 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { createNamespace } from '@react-vant-next/utils';
import cls from 'clsx';
import { useMemo } from 'react';
const [bem] = createNamespace("sku-row");
const SkuRowPropItem = (props) => {
var _a;
const choosed = useMemo(() => {
const { selectedProp, skuKeyStr, skuValue } = props;
if (selectedProp && selectedProp[skuKeyStr]) {
return selectedProp[skuKeyStr].includes(skuValue.id);
}
return false;
}, [
JSON.stringify(props.selectedProp),
JSON.stringify(props.skuValue),
props.skuKeyStr,
]);
const onSelect = () => {
props.onSkuPropSelected(Object.assign(Object.assign({}, props.skuValue), { skuKeyStr: props.skuKeyStr, multiple: props.multiple }));
};
return (jsx("span", { className: cls(bem("item", {
active: choosed,
})), onClick: onSelect, children: jsx("span", { className: cls(bem("item-name")), children: (_a = props.skuValue) === null || _a === void 0 ? void 0 : _a.name }) }));
};
export { SkuRowPropItem as default };
//# sourceMappingURL=SkuRowPropItem.js.map