Skip to content

Commit

Permalink
removing default props
Browse files Browse the repository at this point in the history
  • Loading branch information
SteRiccio committed Sep 2, 2024
1 parent 559619a commit f51d1c4
Show file tree
Hide file tree
Showing 31 changed files with 180 additions and 311 deletions.
6 changes: 0 additions & 6 deletions webapp/components/ImageProgressive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,4 @@ ImageProgressive.propTypes = {
src: PropTypes.string.isRequired,
}

ImageProgressive.defaultProps = {
alt: undefined,
altSrc: undefined,
className: undefined,
}

export default ImageProgressive
12 changes: 1 addition & 11 deletions webapp/components/Map/Map.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ L.Marker.prototype.options.icon = L.icon({
const INITIAL_ZOOM_LEVEL = 3

export const Map = (props) => {
const { editable, layers, markerPoint, markerTitle, showOptions } = props
const { editable = false, layers = [], markerPoint, markerTitle, showOptions = true } = props
const { centerPositionLatLon, markerPointUpdated, markerPointUpdatedToString, onMarkerPointUpdated, onSaveClick } =
useMap(props)

Expand Down Expand Up @@ -91,13 +91,3 @@ Map.propTypes = {
onMarkerPointChange: PropTypes.func,
showOptions: PropTypes.bool,
}

Map.defaultProps = {
centerPoint: null,
editable: false,
layers: [],
markerPoint: null,
markerTitle: null,
onMarkerPointChange: null,
showOptions: true,
}
6 changes: 1 addition & 5 deletions webapp/components/Map/MapLayersControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useMapContext } from './MapContext'
import { WmtsComponent } from './WmtsComponent'

export const MapLayersControl = (props) => {
const { layers } = props
const { layers = [] } = props

const user = useUser()
const surveyId = useSurveyId()
Expand Down Expand Up @@ -66,7 +66,3 @@ export const MapLayersControl = (props) => {
MapLayersControl.propTypes = {
layers: PropTypes.array,
}

MapLayersControl.defaultProps = {
layers: [],
}
9 changes: 1 addition & 8 deletions webapp/components/PanelRight/PanelRight.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { TestId } from '@webapp/utils/testId'
import { Button, ButtonIconClose } from '../buttons'

const PanelRight = (props) => {
const { children, className, header, onClose, showFooter, width } = props
const { children, className, header = '', onClose, showFooter = false, width = '500px' } = props

return ReactDOM.createPortal(
<div
Expand Down Expand Up @@ -41,11 +41,4 @@ PanelRight.propTypes = {
width: PropTypes.string, // width of the panel (e.g. '1000px' or '90vw')
}

PanelRight.defaultProps = {
className: null,
header: '',
showFooter: false,
width: '500px',
}

export default PanelRight
23 changes: 16 additions & 7 deletions webapp/components/ResizableModal/ResizableModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import './ResizableModal.scss'
import React, { useEffect, useRef } from 'react'
import ReactModal from 'react-modal-resizable-draggable'
import classNames from 'classnames'
import PropTypes from 'prop-types'

import { useI18n } from '@webapp/store/system'
import { Button, ButtonIconClose } from '../buttons'
Expand All @@ -12,9 +13,9 @@ export const ResizableModal = (props) => {
children,
className,
header: headerProp,
initHeight,
initWidth,
isOpen,
initHeight = 400,
initWidth = 600,
isOpen = true,
left,
onClose,
onDetach,
Expand Down Expand Up @@ -57,8 +58,16 @@ export const ResizableModal = (props) => {
)
}

ResizableModal.defaultProps = {
initHeight: 400,
initWidth: 600,
isOpen: true,
ResizableModal.propTypes = {
children: PropTypes.node,
className: PropTypes.string,
header: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
initHeight: PropTypes.number,
initWidth: PropTypes.number,
isOpen: PropTypes.bool,
left: PropTypes.number,
onClose: PropTypes.func,
onDetach: PropTypes.func,
onRequestClose: PropTypes.func,
top: PropTypes.number,
}
18 changes: 10 additions & 8 deletions webapp/components/ScriptEditor/ScriptEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@ const { snippetCompleter, textCompleter, keyWordCompleter } = aceLangTools
const defaultCompleters = [snippetCompleter, textCompleter, keyWordCompleter]

export const ScriptEditor = (props) => {
const { name, mode, script, completer, height, width, onChange, readOnly } = props
const {
completer = null,
height = '200px',
mode,
name,
onChange,
readOnly = false,
script,
width = 'inherit',
} = props

const editorRef = useRef()

Expand Down Expand Up @@ -72,10 +81,3 @@ ScriptEditor.propTypes = {
onChange: PropTypes.func.isRequired,
readOnly: PropTypes.bool,
}

ScriptEditor.defaultProps = {
completer: null,
height: '200px',
width: 'inherit',
readOnly: false,
}
8 changes: 1 addition & 7 deletions webapp/components/Slider/Slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Slider.propTypes = {
id: PropTypes.string.isRequired,
max: PropTypes.number,
min: PropTypes.number,
name: PropTypes.string,
onChange: PropTypes.func,
onMouseDown: PropTypes.func,
onMouseUp: PropTypes.func,
Expand All @@ -51,10 +52,3 @@ Slider.propTypes = {
step: PropTypes.number,
value: PropTypes.number,
}

Slider.defaultProps = {
onChange: null,
onMouseDown: null,
onMouseUp: null,
options: null,
}
45 changes: 13 additions & 32 deletions webapp/components/form/InputChips/InputChips.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@ import Chip from '../chip'

const InputChips = (props) => {
const {
className,
idInput,
className = undefined,
disabled = false,
idInput = null,
itemLabel = 'label',
itemKey = 'value',
items,
itemKey,
itemLabel,
selection,
requiredItems,
minCharactersToAutocomplete,
readOnly,
disabled,
minCharactersToAutocomplete = 0,
onChange = null, // Callback to receive all selection change
onItemAdd = null, // Callback to receive added item
onItemRemove = null, // Callback to receive removed item
placeholder = undefined,
readOnly = false,
requiredItems = 0,
selection = [],
validation,
placeholder,
onChange,
onItemAdd,
onItemRemove,
} = props

const { state, Actions } = useLocalState({
Expand Down Expand Up @@ -87,23 +87,4 @@ InputChips.propTypes = {
onItemRemove: PropTypes.func,
}

InputChips.defaultProps = {
className: undefined,
idInput: null,

itemLabel: 'label',
itemKey: 'value',
selection: [],
requiredItems: 0,
minCharactersToAutocomplete: 0,
readOnly: false,
disabled: false,
validation: {},
placeholder: undefined,

onChange: null, // Callback to receive all selection change
onItemAdd: null, // Callback to receive added item
onItemRemove: null, // Callback to receive removed item
}

export default InputChips
38 changes: 10 additions & 28 deletions webapp/components/form/InputChips/InputChipsText.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ import Chip from '../chip'
const InputChipsText = (props) => {
const {
className,
disabled = false,
idInput,
selection,
requiredItems,
minCharactersToAutocomplete,
readOnly,
disabled,
validation,
isInputFieldValueValid = () => true,
minCharactersToAutocomplete = 0,
onChange = null, // Callback to receive all selection change
onItemAdd = null, // Callback to receive added item
onItemRemove = null, // Callback to receive removed item
placeholder,
readOnly = false,
requiredItems = 0,
selection = [],
textTransformFunction,
isInputFieldValueValid,
onChange,
onItemAdd,
onItemRemove,
validation = {},
} = props

const { state, Actions } = useLocalState({
Expand Down Expand Up @@ -95,22 +95,4 @@ InputChipsText.propTypes = {
onItemRemove: PropTypes.func,
}

InputChipsText.defaultProps = {
className: undefined,
idInput: null,

selection: [],
requiredItems: 0,
minCharactersToAutocomplete: 0,
readOnly: false,
disabled: false,
validation: {},
placeholder: undefined,
isInputFieldValueValid: () => true,

onChange: null, // Callback to receive all selection change
onItemAdd: null, // Callback to receive added item
onItemRemove: null, // Callback to receive removed item
}

export default InputChipsText
6 changes: 1 addition & 5 deletions webapp/components/form/InputSwitch/InputSwitch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ReactSwitch from 'react-switch'
import PropTypes from 'prop-types'

const InputSwitch = (props) => {
const { checked, disabled, onChange } = props
const { checked, disabled = false, onChange } = props

return (
<ReactSwitch
Expand Down Expand Up @@ -35,8 +35,4 @@ InputSwitch.propTypes = {
onChange: PropTypes.func.isRequired,
}

InputSwitch.defaultProps = {
disabled: false,
}

export default InputSwitch
9 changes: 1 addition & 8 deletions webapp/components/form/LabelWithTooltip/LabelWithTooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import classNames from 'classnames'
const TOLERANCE = 2 // pixels of tolerance when considering text as ellipsed

export const LabelWithTooltip = (props) => {
const { className, label, style, testId, children } = props
const { className, label = '', style, testId, children } = props

const labelRef = useRef(null)

Expand Down Expand Up @@ -44,10 +44,3 @@ LabelWithTooltip.propTypes = {
style: PropTypes.object,
testId: PropTypes.string,
}

LabelWithTooltip.defaultProps = {
className: undefined,
label: '',
style: {},
children: null,
}
4 changes: 0 additions & 4 deletions webapp/components/form/PasswordInput/PasswordInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,4 @@ PasswordInput.propTypes = {
...SimpleTextInput.propTypes,
}

PasswordInput.defaultProps = {
...SimpleTextInput.defaultProps,
}

export default PasswordInput
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,4 @@ ButtonMetaItemAdd.propTypes = {
metaItemType: PropTypes.string.isRequired,
}

ButtonMetaItemAdd.defaultProps = {
id: null,
}

export default ButtonMetaItemAdd
8 changes: 1 addition & 7 deletions webapp/components/survey/CategoryDetails/CategoryDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { State, useActions, useLocalState } from './store'
const MAX_LEVELS = 5

const CategoryDetails = (props) => {
const { showClose, onCategoryUpdate, categoryUuid: categoryUuidProp } = props
const { categoryUuid: categoryUuidProp, onCategoryUpdate, showClose = true } = props

const { categoryUuid: categoryUuidParam } = useParams()
const i18n = useI18n()
Expand Down Expand Up @@ -229,10 +229,4 @@ CategoryDetails.propTypes = {
showClose: PropTypes.bool,
}

CategoryDetails.defaultProps = {
categoryUuid: null,
onCategoryUpdate: null,
showClose: true,
}

export default CategoryDetails
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { State, useActions } from '../store'
import { ItemsList } from './ItemsList'

const LevelDetails = (props) => {
const { level, single, state, setState } = props
const { level, single = false, state, setState } = props

const readOnly = !useAuthCanEditSurvey()
const i18n = useI18n()
Expand Down Expand Up @@ -110,8 +110,4 @@ LevelDetails.propTypes = {
setState: PropTypes.func.isRequired,
}

LevelDetails.defaultProps = {
single: false,
}

export default LevelDetails
10 changes: 1 addition & 9 deletions webapp/components/survey/CategoryList/CategoryList.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getType = ({ category }) => {
return 'flat'
}
const CategoryList = (props) => {
const { canSelect, onCategoryCreated, onCategoryOpen, onSelect, selectedItemUuid } = props
const { canSelect = false, onCategoryCreated, onCategoryOpen, onSelect, selectedItemUuid } = props

const i18n = useI18n()

Expand Down Expand Up @@ -174,12 +174,4 @@ CategoryList.propTypes = {
selectedItemUuid: PropTypes.string,
}

CategoryList.defaultProps = {
canSelect: false,
onCategoryCreated: null,
onCategoryOpen: null,
onSelect: null,
selectedItemUuid: null,
}

export default CategoryList
Loading

0 comments on commit f51d1c4

Please sign in to comment.