mirror of
https://github.com/Grasscutters/Cultivation.git
synced 2026-02-06 02:06:29 +01:00
custom clear function
This commit is contained in:
@@ -14,6 +14,7 @@ interface IProps {
|
|||||||
readonly?: boolean
|
readonly?: boolean
|
||||||
placeholder?: string
|
placeholder?: string
|
||||||
folder?: boolean
|
folder?: boolean
|
||||||
|
customClearBehaviour?: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
interface IState {
|
interface IState {
|
||||||
@@ -95,6 +96,7 @@ export default class DirInput extends React.Component<IProps, IState> {
|
|||||||
|
|
||||||
if (this.props.onChange) this.props.onChange(text)
|
if (this.props.onChange) this.props.onChange(text)
|
||||||
}}
|
}}
|
||||||
|
customClearBehaviour={this.props.customClearBehaviour}
|
||||||
/>
|
/>
|
||||||
<div className="FileSelectIcon" onClick={this.handleIconClick}>
|
<div className="FileSelectIcon" onClick={this.handleIconClick}>
|
||||||
<img src={File} />
|
<img src={File} />
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ interface IProps {
|
|||||||
readOnly?: boolean;
|
readOnly?: boolean;
|
||||||
id?: string;
|
id?: string;
|
||||||
clearable?: boolean;
|
clearable?: boolean;
|
||||||
|
customClearBehaviour?: () => void;
|
||||||
style?: {
|
style?: {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
}
|
}
|
||||||
@@ -51,6 +52,10 @@ export default class TextInput extends React.Component<IProps, IState> {
|
|||||||
{
|
{
|
||||||
this.props.clearable ?
|
this.props.clearable ?
|
||||||
<div className="TextClear" onClick={() => {
|
<div className="TextClear" onClick={() => {
|
||||||
|
// Run custom behaviour first
|
||||||
|
console.log('cleared')
|
||||||
|
if (this.props.customClearBehaviour) return this.props.customClearBehaviour()
|
||||||
|
|
||||||
this.setState({ value: '' })
|
this.setState({ value: '' })
|
||||||
|
|
||||||
if (this.props.onChange) this.props.onChange('')
|
if (this.props.onChange) this.props.onChange('')
|
||||||
|
|||||||
@@ -154,7 +154,17 @@ export default class Options extends React.Component<IProps, IState> {
|
|||||||
<Tr text="options.background" />
|
<Tr text="options.background" />
|
||||||
</div>
|
</div>
|
||||||
<div className='OptionValue'>
|
<div className='OptionValue'>
|
||||||
<DirInput onChange={this.setCustomBackground} value={this.state?.bg_url_or_path} extensions={['png', 'jpg', 'jpeg']} readonly={false} />
|
<DirInput
|
||||||
|
onChange={this.setCustomBackground}
|
||||||
|
value={this.state?.bg_url_or_path}
|
||||||
|
extensions={['png', 'jpg', 'jpeg']}
|
||||||
|
readonly={false}
|
||||||
|
clearable={true}
|
||||||
|
customClearBehaviour={async () => {
|
||||||
|
await setConfigOption('customBackground', '')
|
||||||
|
window.location.reload()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user