Skip to content

Commit 2a8cc1e

Browse files
committed
Revert "refactor(FormControl): update existing code for sub-components to prep for migration (#5342)"
This reverts commit 39df71e.
1 parent ad3610b commit 2a8cc1e

File tree

13 files changed

+136
-199
lines changed

13 files changed

+136
-199
lines changed

.changeset/soft-bananas-behave.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,5 @@
9393
"webpack": false,
9494
"running": false
9595
}
96-
],
97-
"packageManager": "[email protected]+sha512.c89530d37c4baa38afd43e76a077a84b9aa63840b986426584fd5c5a54ab0a0b21bb1595c851042b733784b0b43706d36a494b4d8ae1a086a762cb8d3f95942a"
96+
]
9897
}

packages/react/src/FormControl/FormControl.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {get} from '../constants'
1414
import {useSlots} from '../hooks/useSlots'
1515
import type {SxProp} from '../sx'
1616
import {useId} from '../hooks/useId'
17-
import {FormControlCaption} from './FormControlCaption'
18-
import FormControlLabel from './FormControlLabel'
19-
import FormControlLeadingVisual from './FormControlLeadingVisual'
17+
import FormControlCaption from './_FormControlCaption'
18+
import FormControlLabel from './_FormControlLabel'
19+
import FormControlLeadingVisual from './_FormControlLeadingVisual'
2020
import FormControlValidation from './_FormControlValidation'
2121
import {FormControlContextProvider} from './_FormControlContext'
2222
import {warning} from '../utils/warning'

packages/react/src/FormControl/FormControlCaption.tsx

Lines changed: 0 additions & 36 deletions
This file was deleted.

packages/react/src/FormControl/FormControlLeadingVisual.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
import InputCaption from '../internal/components/InputCaption'
3+
import type {SxProp} from '../sx'
4+
import {useFormControlContext} from './_FormControlContext'
5+
6+
const FormControlCaption: React.FC<React.PropsWithChildren<{id?: string} & SxProp>> = ({children, sx, id}) => {
7+
const {captionId, disabled} = useFormControlContext()
8+
return (
9+
<InputCaption id={id || captionId || ''} disabled={disabled} sx={sx}>
10+
{children}
11+
</InputCaption>
12+
)
13+
}
14+
15+
export default FormControlCaption

packages/react/src/FormControl/FormControlLabel.tsx renamed to packages/react/src/FormControl/_FormControlLabel.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React from 'react'
2+
import InputLabel from '../internal/components/InputLabel'
23
import type {SxProp} from '../sx'
34
import {useFormControlContext} from './_FormControlContext'
4-
import {InputLabel} from '../internal/components/InputLabel'
55

66
export type Props = {
77
/**
@@ -49,7 +49,6 @@ const FormControlLabel: React.FC<
4949
sx,
5050
...props,
5151
}
52-
5352
return <InputLabel {...labelProps}>{children}</InputLabel>
5453
}
5554

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React from 'react'
2+
import Box from '../Box'
3+
import {get} from '../constants'
4+
import type {SxProp} from '../sx'
5+
import {useFormControlContext} from './_FormControlContext'
6+
7+
const FormControlLeadingVisual: React.FC<React.PropsWithChildren<SxProp>> = ({children, sx}) => {
8+
const {disabled, captionId} = useFormControlContext()
9+
return (
10+
<Box
11+
color={disabled ? 'fg.muted' : 'fg.default'}
12+
sx={{
13+
'> *': {
14+
minWidth: captionId ? get('fontSizes.4') : get('fontSizes.2'),
15+
minHeight: captionId ? get('fontSizes.4') : get('fontSizes.2'),
16+
fill: 'currentColor',
17+
},
18+
...sx,
19+
}}
20+
ml={2}
21+
>
22+
{children}
23+
</Box>
24+
)
25+
}
26+
27+
export default FormControlLeadingVisual

packages/react/src/experimental/SelectPanel2/SelectPanel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {useSlots} from '../../hooks/useSlots'
2020
import {useProvidedRefOrCreate, useId, useAnchoredPosition} from '../../hooks'
2121
import type {OverlayProps} from '../../Overlay/Overlay'
2222
import {StyledOverlay, heightMap} from '../../Overlay/Overlay'
23-
import {InputLabel} from '../../internal/components/InputLabel'
23+
import InputLabel from '../../internal/components/InputLabel'
2424
import {invariant} from '../../utils/invariant'
2525
import {AriaStatus} from '../../live-region'
2626
import {useResponsiveValue} from '../../hooks/useResponsiveValue'

0 commit comments

Comments
 (0)