EditableName.js — react Source File
Architecture documentation for EditableName.js, a javascript file in the react codebase. 4 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 04e82e8f_4cf5_68df_3f32_fe28fb509921["EditableName.js"] 02194688_f76e_9fd1_c1a7_fcc33ebcc5ab["AutoSizeInput.js"] 04e82e8f_4cf5_68df_3f32_fe28fb509921 --> 02194688_f76e_9fd1_c1a7_fcc33ebcc5ab c7888179_9b91_c305_4113_eda40bc5d70c["AutoSizeInput"] 04e82e8f_4cf5_68df_3f32_fe28fb509921 --> c7888179_9b91_c305_4113_eda40bc5d70c f37974a3_4d7c_eb1d_2d0a_42bf3ad8fc90["EditableName.css"] 04e82e8f_4cf5_68df_3f32_fe28fb509921 --> f37974a3_4d7c_eb1d_2d0a_42bf3ad8fc90 ac587885_e294_a1e9_b13f_5e7b920fdb42["react"] 04e82e8f_4cf5_68df_3f32_fe28fb509921 --> ac587885_e294_a1e9_b13f_5e7b920fdb42 276bc34e_3008_101e_3cd7_cc895fcd3848["KeyValue.js"] 276bc34e_3008_101e_3cd7_cc895fcd3848 --> 04e82e8f_4cf5_68df_3f32_fe28fb509921 bb770434_43dc_71aa_77ec_098236a83413["NewArrayValue.js"] bb770434_43dc_71aa_77ec_098236a83413 --> 04e82e8f_4cf5_68df_3f32_fe28fb509921 0e638bf4_827b_30d0_21d6_77d4d615d353["NewKeyValue.js"] 0e638bf4_827b_30d0_21d6_77d4d615d353 --> 04e82e8f_4cf5_68df_3f32_fe28fb509921 style 04e82e8f_4cf5_68df_3f32_fe28fb509921 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
*/
import * as React from 'react';
import {useCallback, useState} from 'react';
import AutoSizeInput from './NativeStyleEditor/AutoSizeInput';
import styles from './EditableName.css';
type Type = 'props' | 'state' | 'context' | 'hooks';
type OverrideNameFn = (
oldName: Array<string | number>,
newName: Array<string | number>,
) => void;
type EditableNameProps = {
allowEmpty?: boolean,
allowWhiteSpace?: boolean,
autoFocus?: boolean,
className?: string,
initialValue?: string,
overrideName: OverrideNameFn,
path: Array<string | number>,
type: Type,
};
export default function EditableName({
allowEmpty = false,
allowWhiteSpace = false,
autoFocus = false,
className = '',
initialValue = '',
overrideName,
path,
type,
}: EditableNameProps): React.Node {
const [editableName, setEditableName] = useState(initialValue);
const [isValid, setIsValid] = useState(false);
const handleChange = useCallback(
({target}: $FlowFixMe) => {
let value = target.value;
if (!allowWhiteSpace) {
value = value.trim();
}
if (allowEmpty || value !== '') {
setIsValid(true);
} else {
setIsValid(false);
}
setEditableName(value);
},
[overrideName],
);
const handleKeyDown = useCallback(
(event: $FlowFixMe) => {
// Prevent keydown events from e.g. change selected element in the tree
event.stopPropagation();
switch (event.key) {
case 'Enter':
case 'Tab':
if (isValid) {
const basePath = path.slice(0, path.length - 1);
overrideName(
[...basePath, initialValue],
[...basePath, editableName],
);
}
break;
case 'Escape':
setEditableName(initialValue);
break;
default:
break;
}
},
[editableName, setEditableName, isValid, initialValue, overrideName],
);
return (
<AutoSizeInput
autoFocus={autoFocus}
className={[styles.Input, className].join(' ')}
onChange={handleChange}
onKeyDown={handleKeyDown}
placeholder="new entry"
testName="EditableName"
type="text"
value={editableName}
/>
);
}
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does EditableName.js do?
EditableName.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Validation subdomain.
What functions are defined in EditableName.js?
EditableName.js defines 1 function(s): EditableName.
What does EditableName.js depend on?
EditableName.js imports 4 module(s): AutoSizeInput, AutoSizeInput.js, EditableName.css, react.
What files import EditableName.js?
EditableName.js is imported by 3 file(s): KeyValue.js, NewArrayValue.js, NewKeyValue.js.
Where is EditableName.js in the architecture?
EditableName.js is located at packages/react-devtools-shared/src/devtools/views/Components/EditableName.js (domain: BabelCompiler, subdomain: Validation, directory: packages/react-devtools-shared/src/devtools/views/Components).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free