wip fix
This commit is contained in:
parent
583924cece
commit
d148e20d2c
|
|
@ -38,11 +38,10 @@ export const EdPropInstanceOptions: FC<{
|
||||||
checkbox: {
|
checkbox: {
|
||||||
width: 0,
|
width: 0,
|
||||||
},
|
},
|
||||||
|
options: [] as MetaOption[]
|
||||||
});
|
});
|
||||||
const p = useGlobal(EDGlobal, "EDITOR");
|
const p = useGlobal(EDGlobal, "EDITOR");
|
||||||
|
|
||||||
let metaOptions: MetaOption[] = [];
|
|
||||||
|
|
||||||
config.opt[name] = () => {
|
config.opt[name] = () => {
|
||||||
local.metaFn = null;
|
local.metaFn = null;
|
||||||
local.loaded = null;
|
local.loaded = null;
|
||||||
|
|
@ -86,17 +85,14 @@ export const EdPropInstanceOptions: FC<{
|
||||||
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 metaOptions = resOpt;
|
else local.options = resOpt;`
|
||||||
|
|
||||||
|
|
||||||
console.log(metaOptions, local)`
|
|
||||||
);
|
);
|
||||||
res(...Object.values(arg),local);
|
res(...Object.values(arg),local);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
metaOptions = local.loaded;
|
local.options = local.loaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local.metaFn && !local.loaded && !local.loading) {
|
if (local.metaFn && !local.loaded && !local.loading) {
|
||||||
|
|
@ -118,7 +114,7 @@ console.log(metaOptions, local)`
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (Array.isArray(metaOptions) && !Array.isArray(evalue)) {
|
if (Array.isArray(local.options) && !Array.isArray(evalue)) {
|
||||||
local.val = evalue;
|
local.val = evalue;
|
||||||
local.render();
|
local.render();
|
||||||
}
|
}
|
||||||
|
|
@ -147,10 +143,10 @@ console.log(metaOptions, local)`
|
||||||
let mode = cprop.meta?.option_mode;
|
let mode = cprop.meta?.option_mode;
|
||||||
if (!mode) mode = "button";
|
if (!mode) mode = "button";
|
||||||
|
|
||||||
if (metaOptions && metaOptions.length > 0) {
|
if (local.options && local.options.length > 0) {
|
||||||
for (const [k, v] of Object.entries(metaOptions)) {
|
for (const [k, v] of Object.entries(local.options)) {
|
||||||
if (typeof v === "string") {
|
if (typeof v === "string") {
|
||||||
metaOptions[k as any] = { label: v, value: v };
|
local.options[k as any] = { label: v, value: v };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -166,12 +162,12 @@ console.log(metaOptions, local)`
|
||||||
onChange={(ev) => {
|
onChange={(ev) => {
|
||||||
onChange(
|
onChange(
|
||||||
`"${ev.currentTarget.value}"`,
|
`"${ev.currentTarget.value}"`,
|
||||||
metaOptions.find((e) => e.value === ev.currentTarget.value)
|
local.options.find((e) => e.value === ev.currentTarget.value)
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{Array.isArray(metaOptions) &&
|
{Array.isArray(local.options) &&
|
||||||
metaOptions.map((item, idx) => {
|
local.options.map((item, idx) => {
|
||||||
return (
|
return (
|
||||||
<option key={idx} value={item.value}>
|
<option key={idx} value={item.value}>
|
||||||
{item.label}
|
{item.label}
|
||||||
|
|
@ -183,8 +179,8 @@ console.log(metaOptions, local)`
|
||||||
|
|
||||||
{mode === "button" && (
|
{mode === "button" && (
|
||||||
<div className="flex-1 pt-1 px-1 flex flex-wrap justify-end space-x-1">
|
<div className="flex-1 pt-1 px-1 flex flex-wrap justify-end space-x-1">
|
||||||
{Array.isArray(metaOptions) &&
|
{Array.isArray(local.options) &&
|
||||||
metaOptions.map((item, idx) => {
|
local.options.map((item, idx) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={idx}
|
key={idx}
|
||||||
|
|
@ -221,8 +217,8 @@ console.log(metaOptions, local)`
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div className={cx("flex flex-col bg-white")}>
|
<div className={cx("flex flex-col bg-white")}>
|
||||||
{Array.isArray(metaOptions) &&
|
{Array.isArray(local.options) &&
|
||||||
metaOptions.map((item, idx) => {
|
local.options.map((item, idx) => {
|
||||||
const val: any[] = Array.isArray(evalue) ? evalue : [];
|
const val: any[] = Array.isArray(evalue) ? evalue : [];
|
||||||
|
|
||||||
const found = val.find((e) => {
|
const found = val.find((e) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue