Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(components, app): rename input field in components #15964

Merged
merged 2 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'

import {
InputField,
LegacyInputField,
DeprecatedCheckboxField,
INPUT_TYPE_TEXT,
INPUT_TYPE_PASSWORD,
Expand Down Expand Up @@ -37,7 +37,7 @@ export const TextField = (props: TextFieldProps): JSX.Element => {

return (
<FormRow label={label} labelFor={id}>
<InputField
<LegacyInputField
{...{ className, type, id, name, value, error, onChange, onBlur }}
/>
{isPassword && (
Expand Down
2 changes: 1 addition & 1 deletion components/src/forms/InputField.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react'
import { Box, SIZE_6 } from '@opentrons/components'

import { InputField as InputFieldComponent } from './InputField'
import { LegacyInputField as InputFieldComponent } from './LegacyInputField'

import type { Story, Meta } from '@storybook/react'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const INPUT_TYPE_PASSWORD: 'password' = 'password'

// TODO: Ian 2018-09-14 remove 'label' prop when IngredientPropertiesForm gets updated

export interface InputFieldProps {
export interface LegacyInputFieldProps {
/** field is disabled if value is true */
disabled?: boolean
/** change handler */
Expand Down Expand Up @@ -57,7 +57,7 @@ export interface InputFieldProps {
* @deprecated Use `InputField` in App/atoms instead
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you modify this comment to remove the App/atoms? Since InputField will be moved in a follow up

Suggested change
* @deprecated Use `InputField` in App/atoms instead
* @deprecated Use `InputField`

*/

export function InputField(props: InputFieldProps): JSX.Element {
export function LegacyInputField(props: LegacyInputFieldProps): JSX.Element {
const error = props.error != null
const labelClass = cx(styles.form_field, props.className, {
[styles.error]: error,
Expand Down Expand Up @@ -88,7 +88,7 @@ export function InputField(props: InputFieldProps): JSX.Element {
}

// TODO(mc, 2018-02-21): maybe simplify further and split out?
function Input(props: InputFieldProps): JSX.Element {
function Input(props: LegacyInputFieldProps): JSX.Element {
const error = props.error != null
const value = props.isIndeterminate ? '' : props.value ?? ''
const placeHolder = props.isIndeterminate ? '-' : props.placeholder
Expand Down
2 changes: 1 addition & 1 deletion components/src/forms/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './DeprecatedCheckboxField'
export * from './DropdownField'
export * from './FormGroup'
export * from './InputField'
export * from './LegacyInputField'
export * from './RadioGroup'
export * from './Select'
export * from './SelectField'
Expand Down
10 changes: 5 additions & 5 deletions labware-library/src/labware-creator/components/TextField.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import * as React from 'react'
import { Field } from 'formik'
import { InputField } from '@opentrons/components'
import { LegacyInputField } from '@opentrons/components'
import { reportFieldEdit } from '../analyticsUtils'
import { getIsHidden } from '../formSelectors'
import { getLabel } from '../fields'
import type { InputFieldProps } from '@opentrons/components'
import type { LegacyInputFieldProps } from '@opentrons/components'
import type { LabwareFields } from '../fields'
import type { FieldProps } from 'formik'
import fieldStyles from './fieldStyles.module.css'
Expand All @@ -13,9 +13,9 @@ interface Props {
name: keyof LabwareFields
label?: string
placeholder?: string
caption?: InputFieldProps['caption']
caption?: LegacyInputFieldProps['caption']
inputMasks?: Array<(prevValue: string, update: string) => string>
units?: InputFieldProps['units']
units?: LegacyInputFieldProps['units']
}

// NOTE(Ian 2019-07-23): per-field hide-when-autofilled is not yet necessary,
Expand Down Expand Up @@ -44,7 +44,7 @@ export const TextField = (props: Props): JSX.Element => {
<div className={fieldStyles.field_wrapper}>
<label className={fieldStyles.field_label}>
{label ?? getLabel(props.name, form.values as LabwareFields)}
<InputField
<LegacyInputField
name={field.name}
value={field.value}
caption={caption}
Expand Down
4 changes: 2 additions & 2 deletions protocol-designer/src/components/EditableTextField.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// TODO: Ian 2018-10-30 if we like this, add it to components library
import * as React from 'react'
import { ClickOutside, Icon, InputField } from '@opentrons/components'
import { ClickOutside, Icon, LegacyInputField } from '@opentrons/components'
import styles from './editableTextField.module.css'

interface Props {
Expand Down Expand Up @@ -53,7 +53,7 @@ export function EditableTextField(props: Props): JSX.Element {
onSubmit={handleFormSubmit}
ref={ref}
>
<InputField
<LegacyInputField
autoFocus
value={transientValue}
onChange={updateValue}
Expand Down
8 changes: 4 additions & 4 deletions protocol-designer/src/components/FilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
InstrumentGroup,
OutlineButton,
DeprecatedPrimaryButton,
InputField,
LegacyInputField,
} from '@opentrons/components'
import { resetScrollElements } from '../ui/steps/utils'
import { EditModulesCard } from './modules'
Expand Down Expand Up @@ -149,7 +149,7 @@ export const FilePage = (): JSX.Element => {
control={control}
name="protocolName"
render={({ field }) => (
<InputField
<LegacyInputField
placeholder="Untitled"
name="protocolName"
value={protocolName}
Expand All @@ -170,7 +170,7 @@ export const FilePage = (): JSX.Element => {
control={control}
name="author"
render={({ field }) => (
<InputField
<LegacyInputField
name="author"
value={author}
onChange={field.onChange}
Expand All @@ -191,7 +191,7 @@ export const FilePage = (): JSX.Element => {
control={control}
name="description"
render={({ field }) => (
<InputField
<LegacyInputField
name="description"
value={description}
onChange={field.onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
FormGroup,
OutlineButton,
DeprecatedPrimaryButton,
InputField,
LegacyInputField,
} from '@opentrons/components'
import styles from './LiquidPlacementForm.module.css'
import formStyles from '../forms/forms.module.css'
Expand Down Expand Up @@ -212,7 +212,7 @@ export const LiquidPlacementForm = (): JSX.Element | null => {
required: true,
}}
render={({ field }) => (
<InputField
<LegacyInputField
name="volume"
units={t('application:units.microliter')}
value={volume}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Card,
DeprecatedCheckboxField,
FormGroup,
InputField,
LegacyInputField,
OutlineButton,
DeprecatedPrimaryButton,
Flex,
Expand Down Expand Up @@ -133,7 +133,7 @@ export function LiquidEditForm(props: LiquidEditFormProps): JSX.Element {
control={control}
name="name"
render={({ field }) => (
<InputField
<LegacyInputField
name="name"
error={
touchedFields.name != null ? errors.name?.message : null
Expand All @@ -153,7 +153,7 @@ export function LiquidEditForm(props: LiquidEditFormProps): JSX.Element {
control={control}
name="description"
render={({ field }) => (
<InputField
<LegacyInputField
name="description"
value={description}
onChange={field.onChange}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
AlertModal,
FormGroup,
RadioGroup,
InputField,
LegacyInputField,
Flex,
useHoverTooltip,
Tooltip,
Expand Down Expand Up @@ -147,7 +147,7 @@ export const FlowRateInput = (props: FlowRateInputProps): JSX.Element => {
}

const FlowRateInputField = (
<InputField
<LegacyInputField
disabled={disabled}
caption={rangeDescription}
error={errorMessage}
Expand Down Expand Up @@ -215,7 +215,7 @@ export const FlowRateInput = (props: FlowRateInputProps): JSX.Element => {
<>
{flowRateType === 'blowout' ? (
<Flex {...targetProps}>
<InputField
<LegacyInputField
className={className || stepFormStyles.small_field}
disabled={disabled}
isIndeterminate={isIndeterminate}
Expand All @@ -229,7 +229,7 @@ export const FlowRateInput = (props: FlowRateInputProps): JSX.Element => {
</Flex>
) : (
<FormGroup label={label || DEFAULT_LABEL} disabled={disabled}>
<InputField
<LegacyInputField
className={className || stepFormStyles.small_field}
disabled={disabled}
isIndeterminate={isIndeterminate}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useDispatch } from 'react-redux'
import cx from 'classnames'
import {
Icon,
InputField,
LegacyInputField,
OutlineButton,
Tooltip,
useConditionalConfirm,
Expand Down Expand Up @@ -270,7 +270,7 @@ const ProfileField = (props: ProfileFieldProps): JSX.Element => {
}
return (
<div className={styles.step_input_wrapper}>
<InputField
<LegacyInputField
className={cx(styles.step_input, className)}
error={errorToShow}
units={units}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react'
import { InputField } from '@opentrons/components'
import { LegacyInputField } from '@opentrons/components'
import type { FieldProps } from '../types'

type TextFieldProps = FieldProps & {
Expand All @@ -20,7 +20,7 @@ export const TextField = (props: TextFieldProps): JSX.Element => {
} = props

return (
<InputField
<LegacyInputField
{...otherProps}
error={errorToShow}
onBlur={onFieldBlur}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
AlertModal,
DIRECTION_COLUMN,
Flex,
InputField,
LegacyInputField,
RadioGroup,
SPACING,
LegacyStyledText,
Expand Down Expand Up @@ -245,7 +245,7 @@ export const TipPositionModal = (
<LegacyStyledText as="label" paddingLeft={SPACING.spacing24}>
{t('tip_position.field_titles.x_position')}
</LegacyStyledText>
<InputField
<LegacyInputField
caption={t('tip_position.caption', {
min: roundedXMin,
max: roundedXMax,
Expand All @@ -267,7 +267,7 @@ export const TipPositionModal = (
<LegacyStyledText as="label" paddingLeft={SPACING.spacing24}>
{t('tip_position.field_titles.y_position')}
</LegacyStyledText>
<InputField
<LegacyInputField
caption={t('tip_position.caption', {
min: roundedYMin,
max: roundedYMax,
Expand All @@ -285,7 +285,7 @@ export const TipPositionModal = (
<LegacyStyledText as="label" paddingLeft={SPACING.spacing24}>
{t('tip_position.field_titles.z_position')}
</LegacyStyledText>
<InputField
<LegacyInputField
caption={t('tip_position.caption', {
min: minMmFromBottom,
max: maxMmFromBottom,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
Flex,
HandleKeypress,
Icon,
InputField,
LegacyInputField,
OutlineButton,
RadioGroup,
} from '@opentrons/components'
Expand Down Expand Up @@ -160,7 +160,7 @@ export function ZTipPositionModal(props: ZTipPositionModalProps): JSX.Element {
}

const TipPositionInputField = !isDefault && (
<InputField
<LegacyInputField
caption={t('tip_position.caption', {
min: minMm,
max: maxMm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
Flex,
FormGroup,
Icon,
InputField,
LegacyInputField,
Tooltip,
useHoverTooltip,
} from '@opentrons/components'
Expand Down Expand Up @@ -185,7 +185,7 @@ export function TipPositionField(props: TipPositionFieldProps): JSX.Element {
/>
</Flex>
) : (
<InputField
<LegacyInputField
disabled={disabled}
className={stepFormStyles.small_field}
readOnly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'
import { useTranslation } from 'react-i18next'
import { useSelector } from 'react-redux'
import { createPortal } from 'react-dom'
import { FormGroup, InputField } from '@opentrons/components'
import { FormGroup, LegacyInputField } from '@opentrons/components'
import { getPipetteEntities } from '../../../../step-forms/selectors'
import { getNozzleType } from '../../utils'
import { getMainPagePortalEl } from '../../../portals/MainPageModalPortal'
Expand Down Expand Up @@ -68,7 +68,7 @@ export function TipWellSelectionField(
label={t('step_edit_form.wellSelectionLabel.wells')}
className={styles.small_field}
>
<InputField
<LegacyInputField
readOnly
error={errorToShow}
name={name}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'
import { createPortal } from 'react-dom'
import { useDispatch, useSelector } from 'react-redux'
import { useTranslation } from 'react-i18next'
import { FormGroup, InputField } from '@opentrons/components'
import { FormGroup, LegacyInputField } from '@opentrons/components'
import { COLUMN } from '@opentrons/shared-data'
import {
actions as stepsActions,
Expand Down Expand Up @@ -80,7 +80,7 @@ export const WellSelectionField = (props: Props): JSX.Element => {
: t('step_edit_form.wellSelectionLabel.wells')
return (
<FormGroup label={label} disabled={disabled} className={styles.small_field}>
<InputField
<LegacyInputField
readOnly
name={name}
value={primaryWellCount ?? null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useDispatch } from 'react-redux'
import { useTranslation } from 'react-i18next'
import {
FormGroup,
InputField,
LegacyInputField,
LegacyModal,
OutlineButton,
} from '@opentrons/components'
Expand Down Expand Up @@ -54,7 +54,7 @@ export function MoreOptionsModal(props: Props): JSX.Element {
label={t('form:step_edit_form.field.step_name.label')}
className={styles.form_group}
>
<InputField
<LegacyInputField
onChange={makeHandleChange('stepName')}
value={String(formData.stepName)}
/>
Expand Down
Loading