Skip to content

[In Progress] [Feat] Table Lite Component #1939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 18 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
remove change value props
  • Loading branch information
iamfaran committed Aug 18, 2025
commit 38c86536b9ffc8486d61cb21755bfd1c6ef2bff4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DateTimeComp } from "comps/comps/tableComp/column/columnTypeComps/columnDateTimeComp";
import { TimeComp } from "./columnTypeComps/columnTimeComp";
import { ButtonComp } from "comps/comps/tableComp/column/simpleColumnTypeComps";
import { ButtonComp } from "./simpleColumnTypeComps";
import { withType } from "comps/generators";
import { trans } from "i18n";
import { Dropdown } from "lowcoder-design/src/components/Dropdown";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,21 @@ type ViewValueFnType<ChildrenCtorMap extends Record<string, CompConstructor<unkn
nodeValue: RecordConstructorToNodeValue<ChildrenCtorMap>
) => JSONValue;

type NewChildrenCtorMap<ChildrenCtorMap, T extends JSONValue> = ChildrenCtorMap & {
changeValue: ReturnType<typeof stateComp<T | null>>;
};

export type ColumnTypeViewFn<ChildrenCtroMap, T extends JSONValue, ViewReturn> = ViewFnTypeForComp<
ViewReturn,
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtroMap, T>>
RecordConstructorToComp<ChildrenCtroMap>
>;

export class ColumnTypeCompBuilder<
ChildrenCtorMap extends Record<string, CompConstructor<unknown>>,
T extends JSONValue = JSONValue
> {
private childrenMap: NewChildrenCtorMap<ChildrenCtorMap, T>;
private childrenMap: ChildrenCtorMap;
private propertyViewFn?: PropertyViewFnTypeForComp<
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
RecordConstructorToComp<ChildrenCtorMap>
>;
private stylePropertyViewFn?: PropertyViewFnTypeForComp<
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
RecordConstructorToComp<ChildrenCtorMap>
>;
private cleanupFunctions: (() => void)[] = [];

Expand All @@ -56,7 +52,7 @@ export class ColumnTypeCompBuilder<
private displayValueFn: ViewValueFnType<ChildrenCtorMap>,
private baseValueFn?: ColumnTypeViewFn<ChildrenCtorMap, T, T>
) {
this.childrenMap = { ...childrenMap, changeValue: stateComp<T | null>(null) };
this.childrenMap = { ...childrenMap } as ChildrenCtorMap;
}

setEditViewFn(_: any) {
Expand All @@ -66,7 +62,7 @@ export class ColumnTypeCompBuilder<

setPropertyViewFn(
propertyViewFn: PropertyViewFnTypeForComp<
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
RecordConstructorToComp<ChildrenCtorMap>
>
) {
this.propertyViewFn = propertyViewFn;
Expand All @@ -75,7 +71,7 @@ export class ColumnTypeCompBuilder<

setStylePropertyViewFn(
stylePropertyViewFn: PropertyViewFnTypeForComp<
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
RecordConstructorToComp<ChildrenCtorMap>
>
) {
this.stylePropertyViewFn = stylePropertyViewFn;
Expand All @@ -92,17 +88,7 @@ export class ColumnTypeCompBuilder<
(props: any, dispatch: any) => {
const baseValue = this.baseValueFn?.(props, dispatch);
const normalView = this.viewFn(props, dispatch);
return (
// <EditableCell<T>
// {...props}
// normalView={normalView}
// dispatch={dispatch}
// baseValue={baseValue}
// changeValue={props.changeValue as any}
// editViewFn={this.editViewFn}
// />
normalView
);
return normalView;
},
(props) => {
let safeOptions = [];
Expand Down Expand Up @@ -139,8 +125,8 @@ export class ColumnTypeCompBuilder<
(cellProps) => memoizedViewFn({ ...props, ...cellProps } as any, dispatch);

const ColumnTypeCompTmp = new MultiCompBuilder(
this.childrenMap as ToConstructor<
RecordConstructorToComp<NewChildrenCtorMap<ChildrenCtorMap, T>>
(this.childrenMap as unknown) as ToConstructor<
RecordConstructorToComp<ChildrenCtorMap>
>,
viewFn
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const ColumnNumberComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return <ColumnNumberView value={value} {...props} />;
},
(nodeValue) => nodeValue.text.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ export const BooleanComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return (
<CheckBoxView
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ export const DateComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return formatDate(value, props.format);
},
(nodeValue) => formatDate(nodeValue.text.value, nodeValue.format.value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const DateTimeComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return formatDate(value, props.format);
},
(nodeValue) => formatDate(nodeValue.text.value, nodeValue.format.value),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const ImageComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return <ImageView src={value} size={props.size} onEvent={props.onEvent} />;
},
(nodeValue) => nodeValue.src.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const LinkCompTmp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return <ColumnLink disabled={props.disabled} label={value} onClick={props.onClick} />;
},
(nodeValue) => nodeValue.text.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const ColumnMarkdownComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return <MarkdownView value={value} onEvent={props.onEvent} />;
},
(nodeValue) => nodeValue.text.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const ProgressComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
const Progress = () => {
const style = useStyle(ProgressStyle);
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const RatingComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return <RateStyled disabled value={value} />;
},
(nodeValue) => nodeValue.text.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const ColumnSelectComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
const option = props.options.find(x => x.value === value);
return (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,8 @@ export const BadgeStatusComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const text = props.changeValue?.value ?? getBaseValue(props, dispatch).value;
const status = props.changeValue?.status ?? getBaseValue(props, dispatch).status;
const text = getBaseValue(props, dispatch).value;
const status = getBaseValue(props, dispatch).status;
return status === "none" ? text : <Badge status={status} text={text}/>;
},
(nodeValue) => [nodeValue.status.value, nodeValue.text.value].filter((t) => t).join(" "),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export const SwitchComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return (
<SwitchView
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ export const ColumnTagsComp = (function () {
childrenMap,
(props, dispatch) => {
const tagOptions = props.tagColors;
let value = props.changeValue ?? getBaseValue(props, dispatch);
let value = getBaseValue(props, dispatch);
value = typeof value === "string" && value.split(",")[1] ? value.split(",") : value;
const tags = _.isArray(value) ? value : (value.length ? [value] : []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export const TimeComp = (function () {
return new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return (
<>
{hasIcon(props.prefixIcon) && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ const SimpleTextPropertyView = React.memo(({ children }: { children: RecordConst
export const SimpleTextComp = new ColumnTypeCompBuilder(
childrenMap,
(props, dispatch) => {
const value = props.changeValue ?? getBaseValue(props, dispatch);
const value = getBaseValue(props, dispatch);
return (
<SimpleTextContent
value={value}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,34 +418,16 @@ export class ColumnComp extends ColumnInitComp {
}

getChangeSet() {
const dataIndex = this.children.dataIndex.getView();
const changeSet = _.mapValues(this.children.render.getMap(), (value) =>{
return value.getComp().children.comp.children.changeValue.getView()
});
return { [dataIndex]: changeSet };
// Editing disabled in Table Lite
return {} as any;
}

dispatchClearChangeSet() {
this.children.render.dispatch(
deferAction(
RenderComp.forEachAction(
wrapChildAction(
"comp",
wrapChildAction("comp", changeChildAction("changeValue", null, false))
)
)
)
);
// clear render comp cache when change set is cleared
this.children.render.dispatch(RenderComp.clearAction());
// No-op in Table Lite
}

dispatchClearInsertSet() {
const renderMap = this.children.render.getMap();
Object.keys(renderMap).forEach(key => {
const render = renderMap[key];
render.getComp().children.comp.children.changeValue.dispatchChangeValueAction(null);
});
// No-op in Table Lite
}

static setSelectionAction(key: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,12 @@ export class SummaryColumnComp extends ColumnInitComp {
}

getChangeSet() {
const dataIndex = this.children.dataIndex.getView();
const changeSet = _.mapValues(this.children.render.getMap(), (value) =>
value.getComp().children.comp.children.changeValue.getView()
);
return { [dataIndex]: changeSet };
// Editing disabled in Table Lite
return {} as any;
}

dispatchClearChangeSet() {
this.children.render.dispatch(
deferAction(
RenderComp.forEachAction(
wrapChildAction(
"comp",
wrapChildAction("comp", changeChildAction("changeValue", null, false))
)
)
)
);
// No-op in Table Lite
}

static setSelectionAction(key: string) {
Expand Down