fixing field
This commit is contained in:
parent
96d4bf72fb
commit
0e3b4f7c4a
|
|
@ -192,13 +192,12 @@ export function Popover({
|
||||||
const popover = usePopover({ modal, ...restOptions });
|
const popover = usePopover({ modal, ...restOptions });
|
||||||
|
|
||||||
let _content = content;
|
let _content = content;
|
||||||
console.log(!content)
|
|
||||||
if (!content) _content = <div className={"w-[300px] h-[150px]"}></div>;
|
if (!content) _content = <div className={"w-[300px] h-[150px]"}></div>;
|
||||||
console.log(typeof restOptions.open)
|
|
||||||
return (
|
return (
|
||||||
<PopoverContext.Provider value={popover}>
|
<PopoverContext.Provider value={popover}>
|
||||||
<PopoverTrigger
|
<PopoverTrigger
|
||||||
asChild
|
asChild
|
||||||
|
className="c-w-full c-h-full"
|
||||||
onClick={
|
onClick={
|
||||||
typeof restOptions.open !== "undefined"
|
typeof restOptions.open !== "undefined"
|
||||||
? () => {
|
? () => {
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,11 @@ export const Field: FC<FieldProp> = (arg) => {
|
||||||
) {
|
) {
|
||||||
validate(field, fm);
|
validate(field, fm);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (arg.on_change) {
|
||||||
|
arg.on_change({ value: fm.data[name], name, fm });
|
||||||
|
}
|
||||||
|
|
||||||
fm.events.on_change(name, fm.data[name]);
|
fm.events.on_change(name, fm.data[name]);
|
||||||
fm.render();
|
fm.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -62,7 +62,11 @@ export type FieldProp = {
|
||||||
required: ("y" | "n") | (() => "y" | "n");
|
required: ("y" | "n") | (() => "y" | "n");
|
||||||
field_ref?: (ref: any) => void;
|
field_ref?: (ref: any) => void;
|
||||||
required_msg: (name: string) => string | ReactElement;
|
required_msg: (name: string) => string | ReactElement;
|
||||||
on_change: (arg: { value: any }) => void | Promise<void>;
|
on_change: (arg: {
|
||||||
|
value: any;
|
||||||
|
name: string;
|
||||||
|
fm: any;
|
||||||
|
}) => void | Promise<void>;
|
||||||
PassProp: any;
|
PassProp: any;
|
||||||
disabled: ("y" | "n") | (() => true | false);
|
disabled: ("y" | "n") | (() => true | false);
|
||||||
child: any;
|
child: any;
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ type LYTChild = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Layout: FC<LYTChild> = (props) => {
|
export const Layout: FC<LYTChild> = (props) => {
|
||||||
const local = useLocal({ loading: false });
|
const local = useLocal({ loading: false, current_menu: "" });
|
||||||
const render = local.render;
|
const render = local.render;
|
||||||
useLayoutEffect(() => {
|
useLayoutEffect(() => {
|
||||||
if (!isEditor) {
|
if (!isEditor) {
|
||||||
|
|
@ -174,6 +174,8 @@ export const Layout: FC<LYTChild> = (props) => {
|
||||||
local.render();
|
local.render();
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
layout={local}
|
||||||
|
current_menu={local.current_menu}
|
||||||
>
|
>
|
||||||
{props.default_layout}
|
{props.default_layout}
|
||||||
</props.PassProp>
|
</props.PassProp>
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,12 @@ export const Menu: FC<MenuProp> = (props) => {
|
||||||
pm={props}
|
pm={props}
|
||||||
depth={0}
|
depth={0}
|
||||||
mode={local.mode}
|
mode={local.mode}
|
||||||
|
activate={(label) => {
|
||||||
|
if (typeof props.layout !== "undefined") {
|
||||||
|
props.layout.current_menu = label;
|
||||||
|
props.layout.render();
|
||||||
|
}
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -72,9 +78,10 @@ export const SideBar: FC<{
|
||||||
depth: number;
|
depth: number;
|
||||||
pm: MenuProp;
|
pm: MenuProp;
|
||||||
mode: "full" | "mini";
|
mode: "full" | "mini";
|
||||||
|
activate: (label: string) => void;
|
||||||
expanded?: boolean;
|
expanded?: boolean;
|
||||||
parent?: string;
|
parent?: string;
|
||||||
}> = ({ data: _data, local, depth, pm, mode, expanded, parent }) => {
|
}> = ({ data: _data, local, depth, pm, mode, expanded, parent, activate }) => {
|
||||||
const PassProp = pm.PassProp;
|
const PassProp = pm.PassProp;
|
||||||
w.prasi_menu = {
|
w.prasi_menu = {
|
||||||
...w.prasi_menu,
|
...w.prasi_menu,
|
||||||
|
|
@ -93,6 +100,7 @@ export const SideBar: FC<{
|
||||||
let should_render = false;
|
let should_render = false;
|
||||||
if (local.active !== menu.hash && !local.loading) {
|
if (local.active !== menu.hash && !local.loading) {
|
||||||
local.active = menu.hash;
|
local.active = menu.hash;
|
||||||
|
activate(menu.label);
|
||||||
should_render = true;
|
should_render = true;
|
||||||
}
|
}
|
||||||
if (!local.open.has(menu.hash)) {
|
if (!local.open.has(menu.hash)) {
|
||||||
|
|
@ -159,11 +167,12 @@ export const SideBar: FC<{
|
||||||
local.open.delete(hashMenu(e));
|
local.open.delete(hashMenu(e));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
local.loading = true;
|
local.loading = true;
|
||||||
if (typeof menu.value === "string") {
|
if (typeof menu.value === "string") {
|
||||||
local.active = menu.hash;
|
local.active = menu.hash;
|
||||||
|
|
||||||
clearTimeout(local.nav_timeout);
|
clearTimeout(local.nav_timeout);
|
||||||
local.nav_timeout = setTimeout(() => {
|
local.nav_timeout = setTimeout(() => {
|
||||||
if (
|
if (
|
||||||
|
|
@ -182,6 +191,7 @@ export const SideBar: FC<{
|
||||||
!Array.isArray(menu.value) &&
|
!Array.isArray(menu.value) &&
|
||||||
typeof menu.value === "string"
|
typeof menu.value === "string"
|
||||||
) {
|
) {
|
||||||
|
activate(menu.label);
|
||||||
if (pm.on_load) {
|
if (pm.on_load) {
|
||||||
if (preloaded(menu.value)) {
|
if (preloaded(menu.value)) {
|
||||||
pm.on_load((exec) => {
|
pm.on_load((exec) => {
|
||||||
|
|
@ -222,6 +232,7 @@ export const SideBar: FC<{
|
||||||
<SideBar
|
<SideBar
|
||||||
data={menu.value}
|
data={menu.value}
|
||||||
local={local}
|
local={local}
|
||||||
|
activate={activate}
|
||||||
depth={(depth || 0) + 1}
|
depth={(depth || 0) + 1}
|
||||||
pm={pm}
|
pm={pm}
|
||||||
mode={mode}
|
mode={mode}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ export type MenuProp = {
|
||||||
mode: "full" | "mini";
|
mode: "full" | "mini";
|
||||||
item: PrasiItem;
|
item: PrasiItem;
|
||||||
style: "navbar" | "sidebar";
|
style: "navbar" | "sidebar";
|
||||||
|
layout?: { current_menu: string; render: () => void };
|
||||||
on_load?: (on_done: (exec: () => void) => void) => void;
|
on_load?: (on_done: (exec: () => void) => void) => void;
|
||||||
get_menu?: (mn: Array<Record<string, IMenu[]>>) => Array<Record<string, IMenu[]>>
|
get_menu?: (mn: Array<Record<string, IMenu[]>>) => Array<Record<string, IMenu[]>>
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue