fix(variants): normalize variant axes options and support custom tags in VariantAxesSelector
This commit is contained in:
@@ -90,7 +90,24 @@ export const VariantAxesSelector: React.FC<VariantAxesSelectorProps> = ({
|
||||
|
||||
<div className="p-5 space-y-6">
|
||||
{axes.map(axis => {
|
||||
const options = axis.optionsList || [];
|
||||
let options: any[] = [];
|
||||
if (Array.isArray(axis.optionsList) && axis.optionsList.length > 0) {
|
||||
options = axis.optionsList;
|
||||
} else {
|
||||
const rawOpts = (axis as any).options || (axis as any).attributeOptions || (axis as any).values || [];
|
||||
if (Array.isArray(rawOpts)) {
|
||||
options = rawOpts.map((o: any, idx: number) => {
|
||||
if (typeof o === 'string') {
|
||||
return { id: `${axis.code}-${idx}`, code: o, label: o };
|
||||
}
|
||||
return {
|
||||
id: o.id || `${axis.code}-${idx}`,
|
||||
code: o.code || o.value || String(o.label || ''),
|
||||
label: o.label || o.value || o.name || o.code
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
const selected = selectedValues[axis.code] || [];
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user