mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-11 23:26:30 +08:00
fa82842cd7
fix AF-1582 fix AF-1671 - mobile doc info dialog styles - added ConfigModal for editing property values in modal, including: - workspace properties: text, number, tags - db properties: text, number, label, link
95 lines
2.3 KiB
TypeScript
95 lines
2.3 KiB
TypeScript
import clsx from 'clsx';
|
|
import type {
|
|
CSSProperties,
|
|
ForwardedRef,
|
|
InputHTMLAttributes,
|
|
KeyboardEventHandler,
|
|
ReactNode,
|
|
} from 'react';
|
|
import { forwardRef } from 'react';
|
|
|
|
import { RowInput } from './row-input';
|
|
import { input, inputWrapper, mobileInputWrapper } from './style.css';
|
|
|
|
export type InputProps = {
|
|
disabled?: boolean;
|
|
onChange?: (value: string) => void;
|
|
onBlur?: (ev: FocusEvent & { currentTarget: HTMLInputElement }) => void;
|
|
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
|
autoSelect?: boolean;
|
|
noBorder?: boolean;
|
|
status?: 'error' | 'success' | 'warning' | 'default';
|
|
size?: 'default' | 'large' | 'extraLarge';
|
|
preFix?: ReactNode;
|
|
endFix?: ReactNode;
|
|
type?: HTMLInputElement['type'];
|
|
inputStyle?: CSSProperties;
|
|
onEnter?: () => void;
|
|
} & Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'size' | 'onBlur'>;
|
|
|
|
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
|
{
|
|
disabled,
|
|
onChange: propsOnChange,
|
|
noBorder = false,
|
|
className,
|
|
status = 'default',
|
|
style = {},
|
|
inputStyle = {},
|
|
size = 'default',
|
|
preFix,
|
|
endFix,
|
|
onEnter,
|
|
onKeyDown,
|
|
onBlur,
|
|
autoFocus,
|
|
autoSelect,
|
|
...otherProps
|
|
}: InputProps,
|
|
upstreamRef: ForwardedRef<HTMLInputElement>
|
|
) {
|
|
return (
|
|
<div
|
|
className={clsx(
|
|
BUILD_CONFIG.isMobileEdition ? mobileInputWrapper : inputWrapper,
|
|
className,
|
|
{
|
|
// status
|
|
disabled: disabled,
|
|
'no-border': noBorder,
|
|
// color
|
|
error: status === 'error',
|
|
success: status === 'success',
|
|
warning: status === 'warning',
|
|
default: status === 'default',
|
|
// size
|
|
large: size === 'large',
|
|
'extra-large': size === 'extraLarge',
|
|
}
|
|
)}
|
|
style={{
|
|
...style,
|
|
}}
|
|
>
|
|
{preFix}
|
|
<RowInput
|
|
className={clsx(input, {
|
|
large: size === 'large',
|
|
'extra-large': size === 'extraLarge',
|
|
})}
|
|
ref={upstreamRef}
|
|
disabled={disabled}
|
|
style={inputStyle}
|
|
onChange={propsOnChange}
|
|
onEnter={onEnter}
|
|
onKeyDown={onKeyDown}
|
|
onBlur={onBlur}
|
|
autoFocus={autoFocus}
|
|
autoSelect={autoSelect}
|
|
{...otherProps}
|
|
/>
|
|
{endFix}
|
|
</div>
|
|
);
|
|
});
|