-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into 261-feat-ipaddress-generator
- Loading branch information
Showing
36 changed files
with
1,291 additions
and
253 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import React from "react"; | ||
import {ErrorTooltip, InfoTooltip} from "@/components/Utils"; | ||
import {useIntl} from "@/locale"; | ||
import {isNullOrWhiteSpace} from "@/utils/stringUtils"; | ||
import {DatePicker} from "@douyinfe/semi-ui"; | ||
import {hasValue} from "@/utils/typeUtils"; | ||
|
||
export interface OptionsDatetimePickerProps { | ||
label: string | React.ReactNode; | ||
type?: "date" | "dateTime" | "dateRange" | "dateTimeRange"; | ||
infoTooltip?: string | React.ReactNode; | ||
errorMessage?: string; | ||
value: string | number | Date | string[] | number[] | Date[]; | ||
onChange: (value: any) => void; | ||
style?: React.CSSProperties; | ||
required?: boolean; | ||
} | ||
|
||
export const OptionsDatetimePicker: React.FunctionComponent<OptionsDatetimePickerProps> = ({...props}) => { | ||
const {label, type, infoTooltip, errorMessage, value, style, onChange, required} = props; | ||
const intl = useIntl(); | ||
|
||
// Add a new useState to manage the validation error message | ||
const [validationError, setValidationError] = React.useState<string | undefined>(); | ||
|
||
// Add effect to validate value when it changes or when required status changes | ||
React.useEffect(() => { | ||
if (required && !hasValue(value)) { | ||
setValidationError(intl.formatMessage({id: 'error.input.isRequired'})); // Set default required error message or use props.errorMessage | ||
} else { | ||
setValidationError(undefined); // Clear error message when input is valid | ||
} | ||
}, [value, required]); | ||
|
||
return ( | ||
<div className="generatorConfig_column"> | ||
<div className='generatorConfig_column__label'> | ||
{label} | ||
{infoTooltip && <InfoTooltip> | ||
{infoTooltip} | ||
</InfoTooltip>} | ||
</div> | ||
<ErrorTooltip message={validationError || errorMessage}> | ||
<DatePicker | ||
density="compact" | ||
type={type} | ||
onChange={(date, dateString) => onChange(dateString)} | ||
value={value} | ||
style={style} | ||
validateStatus={!isNullOrWhiteSpace(validationError || errorMessage) ? 'error' : 'default'} | ||
/> | ||
</ErrorTooltip> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.