diff --git a/comps/filter/FilterContent.tsx b/comps/filter/FilterContent.tsx
index 22083a6..7517ac0 100755
--- a/comps/filter/FilterContent.tsx
+++ b/comps/filter/FilterContent.tsx
@@ -14,6 +14,8 @@ export const FilterContent: FC<{
_item: PrasiItem;
}> = ({ mode, filter, PassProp, child, _item, onSubmit }) => {
const internal = useLocal({});
+
+
return (
{
if (typeof onSubmit === "function" && mode === "raw") {
- const data = await onSubmit(form.fm);
- if(typeof form.fm?.data === "object"){
- form.fm.data = {
- ...form.fm.data,
- _where: data
- }
- }
+ await onSubmit(form.fm);
}
const f = getFilter(filter.name);
diff --git a/comps/filter/FilterField.tsx b/comps/filter/FilterField.tsx
index 0d2d2a6..5a68037 100755
--- a/comps/filter/FilterField.tsx
+++ b/comps/filter/FilterField.tsx
@@ -15,7 +15,10 @@ export const FilterField: FC<{
type: FilterFieldType;
modifiers?: any[];
}> = ({ filter, name, label, type, modifiers }) => {
- const internal = useLocal({ render_timeout: null as any });
+ const internal = useLocal({
+ render_timeout: null as any,
+ search_timeout: null as any,
+ });
if (!name) return <>No Name>;
if (!filter.form) return
Loading...
;
@@ -80,20 +83,22 @@ export const FilterField: FC<{
- {
+ clearTimeout(internal.search_timeout);
+ filter.form?.submit();
+ }}
+ spellCheck={false}
+ className="c-flex-1 c-transition-all c-bg-transparent c-outline-none c-px-2 c-text-sm c-w-full"
+ onChange={(e) => {
+ field.fm.data[name] = e.currentTarget.value;
+
+ clearTimeout(internal.search_timeout);
+ internal.search_timeout = setTimeout(() => {
filter.form?.submit();
- },
- onChange(val) {
- if (!val) {
- filter.form?.submit();
- }
- },
+ }, 1500);
}}
/>
diff --git a/comps/filter/MasterFilter.tsx b/comps/filter/MasterFilter.tsx
index 10c5d06..28fb173 100755
--- a/comps/filter/MasterFilter.tsx
+++ b/comps/filter/MasterFilter.tsx
@@ -1,12 +1,12 @@
import { useLocal } from "@/utils/use-local";
import { FC, ReactNode } from "react";
-import { createPortal } from "react-dom";
import { FMLocal, GenField } from "../form/typings";
import { FilterContent } from "./FilterContent";
import { getFilter } from "./utils/get-filter";
import { default_filter_local } from "./utils/types";
+import { FieldLoading } from "lib/exports";
-type FilterMode = "regular" | "inline" | "popup";
+type FilterMode = "raw" | "inline";
type FilterProps = {
gen_fields: GenField[];
@@ -17,6 +17,7 @@ type FilterProps = {
children?: ReactNode;
onClose?: () => void;
onSubmit?: (fm: FMLocal | null) => Promise;
+ onLoad?: () => Promise;
PassProp: any;
child: any;
_item: PrasiItem;
@@ -33,6 +34,7 @@ export const MasterFilter: FC = ({
onClose,
_item,
onSubmit,
+ onLoad,
}): ReactNode => {
const filter = useLocal({ ...default_filter_local });
filter.name = name;
@@ -41,55 +43,27 @@ export const MasterFilter: FC = ({
if (!isEditor) {
const wf = getFilter(name);
if (wf) {
+ if (wf.filter.ref[_item.id]) {
+ filter.data = wf.filter.ref[_item.id].data;
+ } else {
+ if (mode === "raw" && onLoad) {
+ if (filter.raw_status === "init") {
+ filter.raw_status = "loading";
+ filter.data = onLoad();
+ filter.raw_status = "ready";
+ filter.render();
+ }
+
+ if (filter.raw_status !== "ready") {
+ return ;
+ }
+ }
+ }
wf.filter.ref[_item.id] = filter;
wf.list.render();
}
}
- if (mode === "popup") {
- let popup = document.querySelector(".main-content-preview > .portal");
- if (!popup) {
- popup = document.createElement("div");
- popup.classList.add("portal");
-
- const main = document.querySelector(".main-content-preview");
- if (main) {
- main.appendChild(popup);
- }
- }
- return (
- <>
- {createPortal(
-
-
-
,
- popup
- )}
- >
- );
- }
-
return (
<>
,
name: "",
mode: "",
+ raw_status: "init" as "init" | "loading" | "ready",
};
export const modifiers = {
@@ -69,7 +70,7 @@ export const filter_window = window as unknown as {
Record<
string,
{
- filter: {ref: Record, render: () => void;};
+ filter: { ref: Record; render: () => void };
list: {
ref: Record void }>;
reload: () => void;
@@ -82,4 +83,3 @@ export const filter_window = window as unknown as {
render: () => void;
};
};
-
diff --git a/comps/form/field/type/KeyValue.tsx b/comps/form/field/type/KeyValue.tsx
new file mode 100755
index 0000000..6168c1b
--- /dev/null
+++ b/comps/form/field/type/KeyValue.tsx
@@ -0,0 +1,26 @@
+export const KeyValue = () => {
+ return (
+
+ );
+};
diff --git a/comps/form/field/type/TypeInput.tsx b/comps/form/field/type/TypeInput.tsx
index d0fd8bd..2eec322 100755
--- a/comps/form/field/type/TypeInput.tsx
+++ b/comps/form/field/type/TypeInput.tsx
@@ -8,6 +8,7 @@ import { FMLocal, FieldLocal, FieldProp } from "../../typings";
import { FieldMoney } from "./TypeMoney";
import { FieldRichText } from "./TypeRichText";
import { FieldUpload } from "./TypeUpload";
+import { KeyValue } from "./KeyValue";
export type PropTypeInput = {
type: "input";
@@ -27,7 +28,8 @@ export type PropTypeInput = {
| "search"
| "password"
| "import"
- | "monthly";
+ | "monthly"
+ | "key-value";
placeholder?: string;
onFocus?: (e: FocusEvent) => void;
onBlur?: (e: FocusEvent) => void;
@@ -212,6 +214,8 @@ export const FieldTypeInput: FC<{
/>
);
}
+ case "key-value":
+ return ;
case "monthly": {
return (
{
{
`
)}
>
-
+ {md.props.mode === "full" && (
+
+ )}