Skip to content

Commit

Permalink
add auto-select to TextField component (#1034)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoecheza authored Nov 12, 2024
1 parent a19ffba commit 5502b7c
Show file tree
Hide file tree
Showing 42 changed files with 98 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -673,6 +673,7 @@ export default withSdk<Props>(({ sdk, entity: entityId }) => {
type="number"
value={getPartialPayload<ActionType.SET_COUNTER>(action)?.counter}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeCounter(e, idx)}
autoSelect
/>
</div>
</div>
Expand All @@ -687,6 +688,7 @@ export default withSdk<Props>(({ sdk, entity: entityId }) => {
type="number"
value={getPartialPayload<ActionType.INCREMENT_COUNTER>(action)?.amount}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeAmount(e, idx)}
autoSelect
/>
</div>
</div>
Expand All @@ -701,6 +703,7 @@ export default withSdk<Props>(({ sdk, entity: entityId }) => {
type="number"
value={getPartialPayload<ActionType.DECREASE_COUNTER>(action)?.amount}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeAmount(e, idx)}
autoSelect
/>
</div>
</div>
Expand Down Expand Up @@ -958,6 +961,7 @@ export default withSdk<Props>(({ sdk, entity: entityId }) => {
onChange={(e) => handleChangeName(e, idx)}
onFocus={handleFocusInput}
onBlur={handleFocusInput}
autoSelect
/>
<Dropdown
label="Select an Action"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,21 @@ const CloneEntityAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="number"
value={payload.position?.x}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangePositionX(e)}
autoSelect
/>
<TextField
leftLabel="Y"
type="number"
value={payload.position?.y}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangePositionY(e)}
autoSelect
/>
<TextField
leftLabel="Z"
type="number"
value={payload.position?.z}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangePositionZ(e)}
autoSelect
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,14 @@ const FollowPlayerAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="text"
value={payload.speed}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeSpeed(e)}
autoSelect
/>
<TextField
label="Min. Distance"
type="text"
value={payload.minDistance}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeMinDistance(e)}
autoSelect
/>
</Block>
<Block label="Axes">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,21 @@ const MovePlayerAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="number"
value={payload.position?.x}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangePositionX(e)}
autoSelect
/>
<TextField
label="Y"
type="number"
value={payload.position?.y}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangePositionY(e)}
autoSelect
/>
<TextField
label="Z"
type="number"
value={payload.position?.z}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangePositionZ(e)}
autoSelect
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const OpenLinkAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
label="URL"
value={payload.url}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeEmote(e)}
autoSelect
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const PlayAudioStreamAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
return (
<div className="PlayAudioStreamActionContainer">
<Block>
<TextField label="URL" value={payload.url} onChange={handleChangeUrl} />
<TextField label="URL" value={payload.url} onChange={handleChangeUrl} autoSelect />
</Block>
<Block>
<RangeField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ const PlayVideoStreamAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
{!payload.dclCast ? (
<>
<Block>
<TextField label={<>URL {renderUrlInfo()}</>} value={payload.src} onChange={handleChangeSrc} />
<TextField label={<>URL {renderUrlInfo()}</>} value={payload.src} onChange={handleChangeSrc} autoSelect />
</Block>
<Block>
<Dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ const SetPositionAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="number"
value={payload.x}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeX(e)}
autoSelect
/>
<TextField
leftLabel="Y"
type="number"
value={payload.y}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeY(e)}
autoSelect
/>
<TextField
leftLabel="Z"
type="number"
value={payload.z}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeZ(e)}
autoSelect
/>
</Block>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ const SetRotationAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="number"
value={payload.x}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeX(e)}
autoSelect
/>
<TextField
leftLabel="Y"
type="number"
value={payload.y}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeY(e)}
autoSelect
/>
<TextField
leftLabel="Z"
type="number"
value={payload.z}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeZ(e)}
autoSelect
/>
</Block>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,18 +73,21 @@ const SetScaleAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="number"
value={payload.x}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeX(e)}
autoSelect
/>
<TextField
leftLabel="Y"
type="number"
value={payload.y}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeY(e)}
autoSelect
/>
<TextField
leftLabel="Z"
type="number"
value={payload.z}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeZ(e)}
autoSelect
/>
</Block>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,8 @@ const ShowImageAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
/>
</Block>
<Block label="Size">
<TextField leftLabel="Height" type="number" value={payload.height} onChange={handleChangeHeight} />
<TextField leftLabel="Width" type="number" value={payload.width} onChange={handleChangeWidth} />
<TextField autoSelect leftLabel="Height" type="number" value={payload.height} onChange={handleChangeHeight} />
<TextField autoSelect leftLabel="Width" type="number" value={payload.width} onChange={handleChangeWidth} />
</Block>
<Block label="Align Image">
<Dropdown
Expand Down Expand Up @@ -132,7 +132,7 @@ const ShowImageAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
<TextArea label="Text" value={payload.text} onChange={handleChangeText} />
</Block>
<Block label="Font Size">
<TextField type="number" value={payload.fontSize} onChange={handleChangeFontSize} />
<TextField autoSelect type="number" value={payload.fontSize} onChange={handleChangeFontSize} />
</Block>
</div>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ const ShowTextAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
return (
<div className="ShowTextActionContainer">
<Block>
<TextField label="Text" type="text" value={payload.text} onChange={handleChangeText} />
<TextField autoSelect label="Text" type="text" value={payload.text} onChange={handleChangeText} />
</Block>
<Block>
<RangeField
Expand All @@ -78,7 +78,7 @@ const ShowTextAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
<Dropdown placeholder="Select a Font" options={FONTS} value={payload.font} onChange={handleChangeFont} />
</Block>
<Block label="Font Size">
<TextField type="number" value={payload.fontSize} onChange={handleChangeFontSize} />
<TextField autoSelect type="number" value={payload.fontSize} onChange={handleChangeFontSize} />
</Block>
<Block label="Text Align">
<Dropdown
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ const TeleportPlayerAction: React.FC<Props> = ({ value, onUpdate }: Props) => {
type="number"
value={payload.x}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeX(e)}
autoSelect
/>
<TextField
leftLabel="Y"
type="number"
value={payload.y}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeY(e)}
autoSelect
/>
</Block>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ const TriggerProximityAction: React.FC<Props> = ({ value, onUpdate }: Props) =>
type="number"
value={payload.radius}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeRadius(e)}
autoSelect
/>
<TextField
label="Hits"
type="number"
value={payload.hits || 1}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => handleChangeHits(e)}
autoSelect
/>
<Dropdown
label="Layer"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ const TweenAction: React.FC<Props> = ({ tween: tweenProp, onUpdateTween }: Props
error={isNaN(parseFloat(endPosition.x))}
onChange={(e) => handleChangeEndPosition(e, 'x')}
onBlur={(e) => handleBlurEndPosition(e, 'x')}
autoSelect
/>
<TextField
leftLabel="Y"
Expand All @@ -164,6 +165,7 @@ const TweenAction: React.FC<Props> = ({ tween: tweenProp, onUpdateTween }: Props
error={isNaN(parseFloat(endPosition.y))}
onChange={(e) => handleChangeEndPosition(e, 'y')}
onBlur={(e) => handleBlurEndPosition(e, 'y')}
autoSelect
/>
<TextField
leftLabel="Z"
Expand All @@ -172,6 +174,7 @@ const TweenAction: React.FC<Props> = ({ tween: tweenProp, onUpdateTween }: Props
error={isNaN(parseFloat(endPosition.z))}
onChange={(e) => handleChangeEndPosition(e, 'z')}
onBlur={(e) => handleBlurEndPosition(e, 'z')}
autoSelect
/>
</Block>
<div className="row">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export default withSdk<Props>(({ sdk, entity: entityId }) => {
{states.map(($, idx) => (
<React.Fragment key={idx}>
<Block label="Clip">
<TextField type="text" disabled value={$.clip} />
<TextField autoSelect type="text" disabled value={$.clip} />
</Block>
<Block label="Playing">
<CheckboxField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default withSdk<Props>(({ sdk, entity }) => {
onRemoveContainer={handleRemove}
>
<Block label="Url">
<TextField type="text" {...url} error={!isValid} />
<TextField autoSelect type="text" {...url} error={!isValid} />
</Block>
<Block label="Playback">
<CheckboxField label="Start playing" checked={!!playing.value} {...playing} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default withSdk<Props>(({ sdk, entity }) => {
}
onRemoveContainer={handleRemove}
>
<TextField label="Max Value" type="number" {...getInputProps('maxValue')} />
<TextField autoSelect label="Max Value" type="number" {...getInputProps('maxValue')} />
<Block>
<ColorField label="Primary Color" {...getInputProps('primaryColor')} />
</Block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default withSdk<Props>(({ sdk, entity }) => {
}
onRemoveContainer={handleRemove}
>
<TextField leftLabel="Value" type="number" {...getInputProps('value')} />
<TextField autoSelect leftLabel="Value" type="number" {...getInputProps('value')} />
</Container>
)
})
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ export default withSdk<Props>(({ sdk, entity }) => {
</Block>
{mesh.value === MeshType.MT_CYLINDER && (
<Block label="Radius">
<TextField leftLabel="Top" type="number" {...getInputProps('radiusTop')} />
<TextField leftLabel="Bottom" type="number" {...getInputProps('radiusBottom')} />
<TextField autoSelect leftLabel="Top" type="number" {...getInputProps('radiusTop')} />
<TextField autoSelect leftLabel="Bottom" type="number" {...getInputProps('radiusBottom')} />
</Block>
)}
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default withSdk<Props>(({ sdk, entity }) => {
case MeshType.MT_CYLINDER: {
return (
<Block label="Radius">
<TextField leftLabel="Top" type="number" {...getInputProps('radiusTop')} />
<TextField leftLabel="Bottom" type="number" {...getInputProps('radiusBottom')} />
<TextField autoSelect leftLabel="Top" type="number" {...getInputProps('radiusTop')} />
<TextField autoSelect leftLabel="Bottom" type="number" {...getInputProps('radiusBottom')} />
</Block>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,14 @@ export default withSdk<Props>(({ sdk, entity }) => {
label="Contract"
value={urnTokens.contract || ''}
onChange={(e) => handleUrnTokenChange({ contract: e.target.value })}
autoSelect
/>
<TextField
type="text"
label="Token"
value={urnTokens.token || ''}
onChange={(e) => handleUrnTokenChange({ token: e.target.value })}
autoSelect
/>
</Block>
<Block label="Color">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export default withSdk<Props>(({ sdk, entity: entityId }) => {
type="text"
value={$.eventInfo?.hoverText ?? DEFAULTS.eventInfo.hoverText}
onChange={(e) => handleEventInfoChange({ hoverText: e.target.value }, idx)}
autoSelect
/>
</Block>
<Block label="Max distance">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export function ModeAdvanced({ value, onSubmit, onGoBack }: Props) {

return (
<Block className="advanced">
<TextField label="Custom Coordinates" value={coords} onChange={handleCoordsChange} />
<TextField label="Origin Point" value={base} onChange={handleBaseParcelChange} />
<TextField autoSelect label="Custom Coordinates" value={coords} onChange={handleCoordsChange} />
<TextField autoSelect label="Origin Point" value={base} onChange={handleBaseParcelChange} />
<Block>
<Button type="dark" onClick={onGoBack}>
Back
Expand Down
Loading

0 comments on commit 5502b7c

Please sign in to comment.