diff --git a/components/form/Field.tsx b/components/form/Field.tsx index 0255d7c..95071dc 100644 --- a/components/form/Field.tsx +++ b/components/form/Field.tsx @@ -52,7 +52,7 @@ export const Field: React.FC<{ }> = ({ fm, label, - isBetter, + isBetter = false, name, onLoad, type = "text", diff --git a/components/form/field/TypeDropdown.tsx b/components/form/field/TypeDropdown.tsx index e5b445d..636d885 100644 --- a/components/form/field/TypeDropdown.tsx +++ b/components/form/field/TypeDropdown.tsx @@ -23,6 +23,7 @@ export const TypeDropdown: React.FC = ({ ? [fm.data?.[name]] : [] } + isBetter={isBetter} allowNew={allowNew} unique={mode === "multi" ? (isBetter ? false : true) : false} disabledSearch={false} diff --git a/components/form/field/typeahead-opt.tsx b/components/form/field/typeahead-opt.tsx index f9252e0..08dc47a 100644 --- a/components/form/field/typeahead-opt.tsx +++ b/components/form/field/typeahead-opt.tsx @@ -74,11 +74,9 @@ export const TypeaheadOptions: FC<{ : width ? css` min-width: ${width}px; - height: 450px; ` : css` min-width: 150px; - height: 450px; `, css` max-height: 400px; @@ -207,7 +205,7 @@ export const TypeaheadOptions: FC<{ )} - ) : ( + ) : isBetter ? ( {options.map((item, idx) => { const is_selected = isBetter @@ -261,10 +259,64 @@ export const TypeaheadOptions: FC<{ ); })} + ) : ( +
+ {options.map((item, idx) => { + const is_selected = isBetter + ? init.selectBetter.all + ? true + : selected?.({ item, options, idx }) + : selected?.({ item, options, idx }); + + if (is_selected) { + local.selectedIdx = idx; + } + if (isBetter) { + return ( +
+ { + if (is_selected) { + if (typeof onRemove === "function") onRemove(item); + } else { + onSelect?.(item.value); + } + }} + /> + {item.label || <> } +
+ ); + } + return ( +
0 && "border-t" + )} + onClick={() => { + onSelect?.(item.value); + }} + > + {item.label || <> } +
+ ); + })} +
)} )} - {isBetter ? ( + {false ? (
diff --git a/components/ui/alert.tsx b/components/ui/alert.tsx index 4aa6c5c..556cb63 100644 --- a/components/ui/alert.tsx +++ b/components/ui/alert.tsx @@ -13,7 +13,7 @@ import { export const Alert: FC<{ type: string; - onClick?: () => Promise | void; + onClick?: (event?: any) => Promise | any; children?: any; className?: string; content?: any;