mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-14 22:23:42 +01:00
* Merge intermediate component wrappers into OL-prefixed components * Replace all intermediate wrapper consumers with OL-prefixed components directly * Fix jsx/js files still importing deleted shim components * Remove duplicate OLNotification imports left by first pass * Rename OLTagIcon to TagIcon, remove OL prefix * Rename OLDropdownMenuItem to DropdownMenuItem, remove OL prefix * Remove OLNotification, use Notification directly * Move Notification to the main shared component folder * Update tag-icon import path out of ol/ * Move TagIcon to the main shared component folder * Update dropdown-menu-item import path out of ol/ * Move DropdownMenuItem to the main shared component folder * Fix dropdown-menu-item import path to dropdown/ subfolder * Remove BS5 alias prefixes from shared components * Restore notification-list wrapper in Notification component * Add translation for loading button * Remove redundant import aliasing * Resolve conflicts * Restore notification container `notification-list` GitOrigin-RevId: 24a5af18599a3e02ac6fd61c09cf5a49ef6e0020
54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import React, { forwardRef } from 'react'
|
|
import { Form, FormControlProps as FormControlProps } from 'react-bootstrap'
|
|
import classnames from 'classnames'
|
|
import OLSpinner from './ol-spinner'
|
|
|
|
export type OLFormControlProps = FormControlProps & {
|
|
prepend?: React.ReactNode
|
|
append?: React.ReactNode
|
|
rows?: number
|
|
'data-ol-dirty'?: unknown
|
|
'main-field'?: any // For the CM6's benefit in the editor search panel
|
|
loading?: boolean
|
|
}
|
|
|
|
const OLFormControl = forwardRef<HTMLInputElement, OLFormControlProps>(
|
|
({ prepend, append, loading, className, ...props }, ref) => {
|
|
const resolvedAppend = loading ? <OLSpinner size="sm" /> : append
|
|
|
|
if (prepend || resolvedAppend) {
|
|
const wrapperClassNames = classnames('form-control-wrapper', {
|
|
'form-control-wrapper-sm': props.size === 'sm',
|
|
'form-control-wrapper-lg': props.size === 'lg',
|
|
'form-control-wrapper-disabled': props.disabled,
|
|
})
|
|
|
|
const formControlClassNames = classnames(className, {
|
|
'form-control-offset-start': prepend,
|
|
'form-control-offset-end': resolvedAppend,
|
|
})
|
|
|
|
return (
|
|
<div className={wrapperClassNames}>
|
|
{prepend && (
|
|
<span className="form-control-start-icon">{prepend}</span>
|
|
)}
|
|
<Form.Control
|
|
{...props}
|
|
className={formControlClassNames}
|
|
ref={ref}
|
|
/>
|
|
{resolvedAppend && (
|
|
<span className="form-control-end-icon">{resolvedAppend}</span>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return <Form.Control ref={ref} className={className} {...props} />
|
|
}
|
|
)
|
|
OLFormControl.displayName = 'OLFormControl'
|
|
|
|
export default OLFormControl
|