This commit is contained in:
faisolavolut 2024-06-18 14:28:28 +07:00
parent 634adaeef8
commit d571700f32
1 changed files with 89 additions and 6 deletions

View File

@ -295,12 +295,95 @@ export const EdPropInstanceOptions: FC<{
`
)}
>
<CheckboxLayer
value={local.options}
render={local.render}
evalue={evalue}
onChange={onChange}
/>
<div className={cx("flex flex-col bg-white")}>
{Array.isArray(local.options) &&
local.options.map((item, idx) => {
const val: any[] = Array.isArray(evalue)
? evalue
: [];
const found = val.find((e) => {
if (!item.options) {
return e === item.value;
} else {
if (
typeof e === "object" &&
e.value === item.value
) {
return true;
}
return false;
}
});
return (
<Fragment key={idx}>
<SingleCheckbox
item={item}
idx={idx}
val={val}
depth={0}
onChange={(val) => {
onChange(JSON.stringify(val), item);
local.render();
}}
/>
{item.options &&
found &&
item.options.map((child, idx) => {
const sub_found = found.checked.find(
(e: any) => {
if (!item.options) {
return e === child.value;
} else {
if (
typeof e === "object" &&
e.value === child.value
) {
return true;
}
return false;
}
}
);
return (
<Fragment key={idx}>
<SingleCheckbox
key={idx}
item={child}
idx={idx}
depth={1}
val={found.checked}
onChange={(newval) => {
onChange(JSON.stringify(val), child);
local.render();
}}
/>
{child.options &&
sub_found &&
child.options.map((item, sidx) => {
return (
<SingleCheckbox
item={item}
idx={idx}
key={sidx}
depth={2}
val={sub_found.checked}
onChange={(newval) => {
onChange(
JSON.stringify(val),
item
);
local.render();
}}
/>
);
})}
</Fragment>
);
})}
</Fragment>
);
})}
</div>
</div>
}
asChild