chore: prop disableEditableHeading in availability settings (#15041)
This commit is contained in:
1 parent
775010cd2d
commit
5d3c72271b
3 files changed
+17
-9
No files matched your search
@@ -8,37 +8,39 @@ export const EditableHeading = function EditableHeading({
|
||||
value,
|
||||
onChange,
|
||||
isReady,
|
||||
disabled = false,
|
||||
...passThroughProps
|
||||
}: {
|
||||
isReady?: boolean;
|
||||
disabled?: boolean;
|
||||
} & Omit<JSX.IntrinsicElements["input"], "name" | "onChange"> &
|
||||
ControllerRenderProps) {
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const enableEditing = () => setIsEditing(true);
|
||||
const enableEditing = () => setIsEditing(!disabled);
|
||||
return (
|
||||
<div
|
||||
className="group pointer-events-none relative truncate sm:pointer-events-auto"
|
||||
onClick={enableEditing}>
|
||||
<div className="flex cursor-pointer items-center">
|
||||
<div className={classNames(!disabled && "cursor-pointer", "flex items-center")}>
|
||||
<label className="min-w-8 relative inline-block">
|
||||
<span className="whitespace-pre text-xl tracking-normal text-transparent">{value} </span>
|
||||
{!isEditing && isReady && (
|
||||
<Icon
|
||||
name="pencil"
|
||||
className=" text-subtle group-hover:text-subtle -mt-px ml-1 inline h-3 w-3"
|
||||
/>
|
||||
{!isEditing && isReady && !disabled && (
|
||||
<Icon name="pencil" className="text-subtle group-hover:text-subtle -mt-px ml-1 inline h-3 w-3" />
|
||||
)}
|
||||
<input
|
||||
{...passThroughProps}
|
||||
disabled={disabled}
|
||||
type="text"
|
||||
value={value}
|
||||
required
|
||||
className={classNames(
|
||||
"text-emphasis hover:text-default focus:text-emphasis absolute left-0 top-0 w-full cursor-pointer truncate border-none bg-transparent p-0 align-top text-xl focus:outline-none focus:ring-0",
|
||||
!disabled &&
|
||||
"hover:text-default focus:text-emphasis cursor-pointer focus:outline-none focus:ring-0",
|
||||
"text-emphasis absolute left-0 top-0 w-full truncate border-none bg-transparent p-0 align-top text-xl ",
|
||||
passThroughProps.className
|
||||
)}
|
||||
onFocus={(e) => {
|
||||
setIsEditing(true);
|
||||
setIsEditing(!disabled);
|
||||
passThroughProps.onFocus && passThroughProps.onFocus(e);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
|
||||
Reference in new issue
Block a user