This commit is contained in:
Rizky 2024-04-03 19:55:39 +07:00
parent c49a88b79a
commit 38ddf4b909
1 changed files with 12 additions and 3 deletions

View File

@ -12,6 +12,7 @@ import { Popover } from "../../../../../utils/ui/popover";
type MetaOption = { type MetaOption = {
label: string; label: string;
value: any; value: any;
checked?: boolean;
options?: MetaOption[]; options?: MetaOption[];
reload?: string[]; reload?: string[];
}; };
@ -38,7 +39,7 @@ export const EdPropInstanceOptions: FC<{
checkbox: { checkbox: {
width: 0, width: 0,
}, },
options: [] as MetaOption[] options: [] as MetaOption[],
}); });
const p = useGlobal(EDGlobal, "EDITOR"); const p = useGlobal(EDGlobal, "EDITOR");
@ -80,14 +81,14 @@ export const EdPropInstanceOptions: FC<{
const res = new Function( const res = new Function(
...Object.keys(arg), ...Object.keys(arg),
'local', "local",
` `
const resOpt = ${cprop.meta.optionsBuilt || cprop.meta.options}; const resOpt = ${cprop.meta.optionsBuilt || cprop.meta.options};
if (typeof resOpt === 'function') local.metaFn = resOpt; if (typeof resOpt === 'function') local.metaFn = resOpt;
else local.options = resOpt;` else local.options = resOpt;`
); );
res(...Object.values(arg),local); res(...Object.values(arg), local);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
@ -326,11 +327,19 @@ const SingleCheckbox = ({
} }
}); });
useEffect(() => {
if (item.checked && !val.find((e) => e === item.value)) {
val.push(item.value);
onChange(val, item);
}
}, []);
return ( return (
<div <div
className={cx( className={cx(
"flex pl-1 text-xs cursor-pointer select-none space-x-1 items-center", "flex pl-1 text-xs cursor-pointer select-none space-x-1 items-center",
idx === 0 && !depth ? "" : "border-t", idx === 0 && !depth ? "" : "border-t",
item.checked && "opacity-50",
depth && depth &&
css` css`
padding-left: ${depth * 20}px; padding-left: ${depth * 20}px;