@@ -615,7 +637,7 @@ export function BeeTableInternal
({
onHeaderClick={onHeaderClick}
onHeaderKeyUp={onHeaderKeyUp}
lastColumnMinWidth={lastColumnMinWidth}
- setEditing={setEditing}
+ setActiveCellEditing={setActiveCellEditing}
/>
rowWrapper={rowWrapper}
@@ -649,22 +671,41 @@ export function BeeTableInternal({
);
}
-export type BeeTableRef = BeeTableResizableColumnsDispatchContextType;
+export type BeeTableRef = BeeTableResizingRef & BeeTableSelectionRef;
-export type ForwardRefBeeTableProps = BeeTableProps & { forwardRef?: React.Ref } & {
+export type ForwardRefBeeTableProps = BeeTableProps & {
+ forwardRef?: React.Ref;
+} & {
onColumnResizingWidthChange?: (args: Map) => void;
};
-export const BeeTable = (props: ForwardRefBeeTableProps) => {
+export const BeeTable = ({
+ forwardRef,
+ onColumnResizingWidthChange,
+ ...props
+}: ForwardRefBeeTableProps) => {
+ const beeTableResizingRef = useRef(null);
+ const beeTableSelectionRef = useRef(null);
+
+ useImperativeHandle(
+ forwardRef,
+ () => {
+ if (!beeTableResizingRef.current || !beeTableSelectionRef.current) {
+ return null;
+ }
+
+ return {
+ ...beeTableSelectionRef.current!,
+ ...beeTableResizingRef.current!,
+ };
+ },
+ []
+ );
return (
-
+
-
+
diff --git a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
index 0549a1b224a..4c0057aaa7f 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/BeeTableHeader.tsx
@@ -81,7 +81,7 @@ export interface BeeTableHeaderProps {
resizerStopBehavior: ResizerStopBehavior;
lastColumnMinWidth?: number;
- setEditing: React.Dispatch>;
+ setActiveCellEditing: (isEditing: boolean) => void;
}
export function BeeTableHeader({
@@ -99,7 +99,7 @@ export function BeeTableHeader({
shouldShowRowsInlineControls,
resizerStopBehavior,
lastColumnMinWidth,
- setEditing,
+ setActiveCellEditing,
}: BeeTableHeaderProps) {
const getColumnLabel: (groupType: string) => string | undefined = useCallback(
(groupType) => {
@@ -235,7 +235,7 @@ export function BeeTableHeader({
column.headerCellElement
) : column.isInlineEditable ? (
({
getColumnLabel,
onColumnAdded,
lastColumnMinWidth,
- setEditing,
+ setActiveCellEditing,
onExpressionHeaderUpdated,
]
);
diff --git a/packages/boxed-expression-component/src/table/BeeTable/InlineEditableTextInput.tsx b/packages/boxed-expression-component/src/table/BeeTable/InlineEditableTextInput.tsx
index 7df524d9dfc..fe62b621845 100644
--- a/packages/boxed-expression-component/src/table/BeeTable/InlineEditableTextInput.tsx
+++ b/packages/boxed-expression-component/src/table/BeeTable/InlineEditableTextInput.tsx
@@ -27,7 +27,7 @@ import { useBeeTableSelectableCellRef } from "../../selection/BeeTableSelectionC
export interface InlineEditableTextInputProps {
value: string;
onChange: (updatedValue: string) => void;
- setEditing: React.Dispatch>;
+ setActiveCellEditing: (isEditing: boolean) => void;
rowIndex: number;
columnIndex: number;
}
@@ -36,21 +36,26 @@ export const InlineEditableTextInput: React.FunctionComponent {
const { i18n } = useBoxedExpressionEditorI18n();
const inputRef = useRef(null);
- const { isEditing } = useBeeTableSelectableCellRef(rowIndex, columnIndex, undefined, undefined);
+ const { isEditing } = useBeeTableSelectableCellRef(
+ rowIndex,
+ columnIndex,
+ onChange,
+ useCallback(() => value, [value])
+ );
const stopEditingPersistingValue = useCallback(() => {
const newValue = inputRef.current?.value;
if (newValue && newValue !== value) {
onChange(newValue);
}
- setEditing(false);
- }, [onChange, setEditing, value]);
+ setActiveCellEditing(false);
+ }, [onChange, setActiveCellEditing, value]);
const onInputKeyDown = useMemo(
() => (e: React.KeyboardEvent) => {
@@ -61,17 +66,17 @@ export const InlineEditableTextInput: React.FunctionComponent {
- setEditing(true);
- }, [setEditing]);
+ setActiveCellEditing(true);
+ }, [setActiveCellEditing]);
- const getTextStyle = useMemo(() => {
+ const textStyle = useMemo(() => {
if (_.isEmpty(value)) {
return { fontStyle: "italic", cursor: "pointer", color: "gray" };
} else {
@@ -87,7 +92,11 @@ export const InlineEditableTextInput: React.FunctionComponent
+
{value || i18n.enterText}
) : (