-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #101 from irontec/color-picker
Added color picker field type
- Loading branch information
Showing
14 changed files
with
178 additions
and
64 deletions.
There are no files selected for viewing
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
113 changes: 56 additions & 57 deletions
113
library/src/components/List/Content/ListContent.styles.tsx
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
66 changes: 66 additions & 0 deletions
66
library/src/services/form/FormFieldFactory/Factory/ColorFactory.tsx
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,66 @@ | ||
import { | ||
InputAdornment, | ||
InputBaseComponentProps, | ||
OutlinedInputProps, | ||
} from '@mui/material'; | ||
import { FormOnChangeEvent } from '../../../../entities/DefaultEntityBehavior/Form/Form'; | ||
import { ScalarProperty } from '../../../api'; | ||
import { ScalarEntityValue } from '../../../entity'; | ||
import { StyledColorField } from '../../Field/TextField/TextField.styles'; | ||
|
||
type ColorFactoryPropsType = { | ||
fld: string; | ||
property: ScalarProperty; | ||
disabled: boolean; | ||
value: ScalarEntityValue | Array<ScalarEntityValue>; | ||
hasChanged: boolean; | ||
error: React.ReactNode; | ||
touched: boolean | undefined; | ||
inputProps: InputBaseComponentProps; | ||
InputProps: Partial<OutlinedInputProps>; | ||
changeHandler: (event: FormOnChangeEvent) => void; | ||
handleBlur: (event: React.FocusEvent) => void; | ||
}; | ||
|
||
export const ColorFactory = (props: ColorFactoryPropsType): JSX.Element => { | ||
const { | ||
fld, | ||
property, | ||
disabled, | ||
value, | ||
hasChanged, | ||
error, | ||
touched, | ||
inputProps, | ||
InputProps, | ||
changeHandler, | ||
handleBlur, | ||
} = props; | ||
|
||
if (!InputProps.endAdornment) { | ||
InputProps.endAdornment = ( | ||
<InputAdornment position='end'> | ||
<span>{value}</span> | ||
</InputAdornment> | ||
); | ||
} | ||
|
||
return ( | ||
<StyledColorField | ||
name={fld} | ||
type={'color'} | ||
value={value} | ||
disabled={disabled} | ||
label={property.label} | ||
required={property.required} | ||
onChange={changeHandler} | ||
onBlur={handleBlur} | ||
error={touched && Boolean(error)} | ||
errorMsg={touched && error} | ||
helperText={property.helpText} | ||
InputProps={InputProps} | ||
inputProps={inputProps} | ||
hasChanged={hasChanged} | ||
/> | ||
); | ||
}; |
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