fix input bug

This commit is contained in:
rizrmd 2024-06-12 19:18:47 -07:00
parent ce10917c27
commit 0fe4955ecb
7 changed files with 64 additions and 38 deletions

View File

@ -64,6 +64,7 @@ export const FieldInput: FC<{
on_init={() => { on_init={() => {
return fm; return fm;
}} }}
show_header={arg.tbl_show_header}
name={arg.name} name={arg.name}
child={child} child={child}
PassProp={PassProp} PassProp={PassProp}

View File

@ -10,9 +10,10 @@ export const TableEdit: FC<{
child: any; child: any;
PassProp: any; PassProp: any;
item: PrasiItem; item: PrasiItem;
show_header?: "y" | "n";
bottom: any; bottom: any;
body: any; body: any;
}> = ({ on_init, name, child, PassProp, item, bottom, body }) => { }> = ({ on_init, name, child, PassProp, item, bottom, show_header }) => {
const fm = on_init(); const fm = on_init();
const local = useLocal( const local = useLocal(
{ {
@ -36,9 +37,9 @@ export const TableEdit: FC<{
<div className="c-w-full c-h-full c-flex c-flex-col"> <div className="c-w-full c-h-full c-flex c-flex-col">
<div <div
className={cx( className={cx(
"c-h-[50px] c-w-full", "c-w-full",
css` css`
> .rdg { .rdg {
overflow-y: hidden !important; overflow-y: hidden !important;
} }
.rdg-cell > div { .rdg-cell > div {
@ -53,40 +54,36 @@ export const TableEdit: FC<{
.field-error { .field-error {
display: none; display: none;
} }
` .rdg-cell {
min-height: 50px !important;
}
.rdg-header-row {
border-top-right-radius: 5px;
border-top-left-radius: 5px;
}
`,
value.length === 0 &&
(show_header === "n"
? css`
display: none;
`
: css`
height: 50px;
`),
value.length > 0 &&
css`
height: ${50 *
(show_header === "n" ? value.length : value.length + 1)}px;
`,
show_header === "n" &&
css`
.rdg-header-row {
display: none;
}
`
)} )}
style={{
height: isEditor
? 100
: value.length === 0
? 50
: value.length * 50 + 50,
}}
ref={ref} ref={ref}
> >
{/* <button
onClick={(e) => {
e.preventDefault();
e.stopPropagation();
db.milestone.create({
data: {
goal_setting: {
connect: {
id: "456222b4-4c0c-4f53-b62e-3e1f685f9c4a",
},
},
name: "124124",
goal: {
connect: {
id: "9fa14b83-2d8b-4c3d-a18c-c17d99a37813",
},
},
},
});
}}
>
COBA
</button> */}
<TableList <TableList
row_height={50} row_height={50}
feature={[]} feature={[]}
@ -105,6 +102,7 @@ export const TableEdit: FC<{
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
}} }}
show_header={show_header === "y"}
selected={() => { selected={() => {
return false; return false;
}} }}

View File

@ -368,7 +368,19 @@ export const genTableEdit = async (
const option = { const option = {
id: createId(), id: createId(),
name: "bottom", name: "bottom",
padding: { b: 10, l: 10, r: 10, t: 0 }, padding: {
b: 10,
l: 10,
r: 10,
t: 7,
},
border: {
style: "solid",
stroke: {
t: 1,
},
color: "#e6e6e6",
},
type: "item", type: "item",
childs: [ childs: [
{ {

View File

@ -72,6 +72,7 @@ export type FieldProp = {
name: string; name: string;
type: string; type: string;
}) => any; }) => any;
tbl_show_header?: "y" | "n"
opt_set_value: (arg: { opt_set_value: (arg: {
selected: string[]; selected: string[];
options: { label: string; value: string; item?: string }[]; options: { label: string; value: string; item?: string }[];

View File

@ -50,6 +50,7 @@ type TableListProp = {
gen_fields: string[]; gen_fields: string[];
row_click: OnRowClick; row_click: OnRowClick;
selected: SelectedRow; selected: SelectedRow;
show_header?: boolean;
id_parent?: string; id_parent?: string;
feature?: Array<any>; feature?: Array<any>;
filter_name: string; filter_name: string;
@ -92,6 +93,7 @@ export const TableList: FC<TableListProp> = ({
render_row, render_row,
row_height: rowHeight, row_height: rowHeight,
render_col, render_col,
show_header,
value, value,
cache_row, cache_row,
}) => { }) => {
@ -469,7 +471,7 @@ export const TableList: FC<TableListProp> = ({
return ( return (
<div <div
className={cx( className={cx(
"c-w-full c-h-full c-flex-1 c-relative c-overflow-hidden", "table-list c-w-full c-h-full c-flex-1 c-relative c-overflow-hidden",
dataGridStyle(local), dataGridStyle(local),
css` css`
.rdg { .rdg {
@ -491,7 +493,7 @@ export const TableList: FC<TableListProp> = ({
<Skeleton className={cx("c-w-[180px] c-h-[11px]")} /> <Skeleton className={cx("c-w-[180px] c-h-[11px]")} />
</div> </div>
)} )}
<div className="c-absolute c-inset-0"> <div className="table-list-inner c-absolute c-inset-0">
{toaster_el && createPortal(<Toaster cn={cn} />, toaster_el)} {toaster_el && createPortal(<Toaster cn={cn} />, toaster_el)}
{local.status === "init" ? ( {local.status === "init" ? (
<DataGrid <DataGrid
@ -528,6 +530,7 @@ export const TableList: FC<TableListProp> = ({
selectedRows={new Set() as ReadonlySet<any>} selectedRows={new Set() as ReadonlySet<any>}
onSelectedCellChange={() => {}} onSelectedCellChange={() => {}}
onSelectedRowsChange={() => {}} onSelectedRowsChange={() => {}}
headerRowHeight={show_header === false ? 0 : undefined}
renderers={ renderers={
local.status !== "ready" local.status !== "ready"
? undefined ? undefined

View File

@ -19,6 +19,7 @@ const buttonVariants = cva(
"c-bg-secondary c-text-secondary-foreground hover:c-bg-secondary/80", "c-bg-secondary c-text-secondary-foreground hover:c-bg-secondary/80",
ghost: "hover:c-bg-accent hover:c-text-accent-foreground", ghost: "hover:c-bg-accent hover:c-text-accent-foreground",
link: "c-text-primary c-underline-offset-4 hover:c-underline", link: "c-text-primary c-underline-offset-4 hover:c-underline",
"no-style": "",
}, },
size: { size: {
default: "c-h-10 c-px-4 c-py-2", default: "c-h-10 c-px-4 c-py-2",
@ -45,11 +46,17 @@ export interface ButtonProps
const Button = React.forwardRef<HTMLDivElement, ButtonProps>( const Button = React.forwardRef<HTMLDivElement, ButtonProps>(
({ className, variant, size, asChild = false, ...props }, ref) => { ({ className, variant, size, asChild = false, ...props }, ref) => {
const Comp = asChild ? Slot : "button"; const Comp = asChild ? Slot : "button";
return ( return (
<div <div
className={cn( className={cn(
buttonVariants({ variant, size, className }), buttonVariants({ variant, size, className }),
`btn-${variant || "default"} btn c-transition-all c-duration-300` `btn-${variant || "default"} btn c-transition-all c-duration-300`,
css`
> div {
border-radius: calc(var(--radius) - 2px);
}
`
)} )}
ref={ref} ref={ref}
{...props} {...props}

View File

@ -423,6 +423,10 @@ export const Typeahead: FC<{
local.render(); local.render();
} }
} }
if (local.mode === "single") {
e.currentTarget.select();
}
}} }}
onChange={async (e) => { onChange={async (e) => {
const val = e.currentTarget.value; const val = e.currentTarget.value;