-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix styling in filter combobox, editable label
- Loading branch information
Showing
6 changed files
with
175 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export * from "./ColumnPicker"; | ||
export * from "./ExpandoCombobox"; | ||
export * from "./FilterClause"; | ||
export * from "./value-editors/FilterClauseValueEditorText"; |
39 changes: 39 additions & 0 deletions
39
vuu-ui/packages/vuu-filters/src/filter-clause/useExpandoCombobox.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { ChangeEvent, SyntheticEvent, useState } from "react"; | ||
|
||
export const useExpandoComboBox = ({ | ||
onSelect, | ||
value: valueProp, | ||
}: { | ||
onSelect: (evt: SyntheticEvent, columnName: string) => void; | ||
value: string; | ||
}) => { | ||
const [value, setValue] = useState(valueProp); | ||
const handleChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
const value = event.target.value; | ||
setValue(value); | ||
}; | ||
|
||
// const handleSelectionChange = ( | ||
// _evt: SyntheticEvent, | ||
// newSelected: string[], | ||
// ) => { | ||
// if (newSelected.length === 1) { | ||
// setValue(newSelected[0]); | ||
// } else { | ||
// setValue(""); | ||
// } | ||
// }; | ||
|
||
const handleSelectionChange = ( | ||
evt: SyntheticEvent, | ||
newSelected: string[], | ||
) => { | ||
onSelect?.(evt, newSelected[0]); | ||
}; | ||
|
||
return { | ||
onChange: handleChange, | ||
onSelectionChange: handleSelectionChange, | ||
value: value.toString().trim(), | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 69 additions & 20 deletions
89
vuu-ui/showcase/src/examples/UiControls/EditableLabel.examples.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,85 @@ | ||
import { EditableLabel } from "@finos/vuu-ui-controls"; | ||
import { useState } from "react"; | ||
import { | ||
EditableLabel, | ||
ExitEditModeHandler, | ||
Icon, | ||
} from "@finos/vuu-ui-controls"; | ||
import { Button, Input } from "@salt-ds/core"; | ||
import { ReactNode, useRef, useState } from "react"; | ||
|
||
const ExpandoContainer = ({ children }: { children: ReactNode }) => ( | ||
<div | ||
style={{ | ||
alignItems: "center", | ||
border: "solid 1px black", | ||
display: "flex", | ||
flexDirection: "column", | ||
gap: 12, | ||
padding: 12, | ||
width: 300, | ||
}} | ||
> | ||
<Input /> | ||
{children} | ||
<Input /> | ||
</div> | ||
); | ||
|
||
export const EditableLabelControlledValueUncontrolledEditing = () => { | ||
const [value, setValue] = useState<string>("Initial value"); | ||
const [editing, setEditing] = useState(false); | ||
const editButtonRef = useRef<HTMLButtonElement>(null); | ||
|
||
const handleEnterEditMode = () => { | ||
console.log("handleEnterEditMode"); | ||
}; | ||
|
||
const handleExitEditMode = (finalValue = "") => { | ||
console.log(`handleExitEditMode '${value}'`); | ||
const handleExitEditMode: ExitEditModeHandler = ( | ||
originalValue, | ||
finalValue = "", | ||
) => { | ||
console.log(`handleExitEditMode finalValue ${finalValue} value '${value}'`); | ||
if (finalValue !== value) { | ||
setValue(finalValue); | ||
} | ||
setEditing(false); | ||
requestAnimationFrame(() => { | ||
editButtonRef.current?.focus(); | ||
}); | ||
}; | ||
|
||
const beginEdit = () => { | ||
requestAnimationFrame(() => { | ||
setEditing(true); | ||
}); | ||
}; | ||
|
||
return ( | ||
<div | ||
style={{ | ||
display: "inline-block", | ||
border: "solid 1px #ccc", | ||
position: "absolute", | ||
top: 100, | ||
left: 100, | ||
}} | ||
> | ||
<EditableLabel | ||
value={value} | ||
onChange={setValue} | ||
onEnterEditMode={handleEnterEditMode} | ||
onExitEditMode={handleExitEditMode} | ||
/> | ||
</div> | ||
<ExpandoContainer> | ||
<div | ||
style={{ | ||
alignItems: "center", | ||
display: "flex", | ||
padding: 4, | ||
flex: "0 0 40px", | ||
}} | ||
> | ||
<EditableLabel | ||
editing={editing} | ||
value={value} | ||
onChange={setValue} | ||
onEnterEditMode={handleEnterEditMode} | ||
onExitEditMode={handleExitEditMode} | ||
/> | ||
|
||
<Button | ||
className="vuuIconButton" | ||
disabled={editing} | ||
ref={editButtonRef} | ||
onClick={beginEdit} | ||
> | ||
<Icon name="edit" /> | ||
</Button> | ||
</div> | ||
</ExpandoContainer> | ||
); | ||
}; |