diff --git a/src/DonationForms/FormDesigns/ClassicFormDesign/css/_inputs.scss b/src/DonationForms/FormDesigns/ClassicFormDesign/css/_inputs.scss index e29ab4055e..decc52860a 100644 --- a/src/DonationForms/FormDesigns/ClassicFormDesign/css/_inputs.scss +++ b/src/DonationForms/FormDesigns/ClassicFormDesign/css/_inputs.scss @@ -43,7 +43,6 @@ input[type="email"], textarea { border-width: 0.078rem; border-style: solid; - border-color: rgb(102, 102, 102); border-radius: 0.25rem; padding: 1.1875rem; width: 100%; @@ -56,11 +55,6 @@ textarea { font-weight: 500; line-height: 1.2; - &[aria-invalid="true"], - &:invalid { - border-color: red; - } - &::placeholder { opacity: 0.6; } diff --git a/src/DonationForms/resources/styles/_base-overrides.scss b/src/DonationForms/resources/styles/_base-overrides.scss index 494eb8e836..dfc9f8f4b8 100644 --- a/src/DonationForms/resources/styles/_base-overrides.scss +++ b/src/DonationForms/resources/styles/_base-overrides.scss @@ -83,10 +83,15 @@ input[type="password"], input[type="email"], input[type="checkbox"], textarea { - border-color: var(--givewp-primary-color); + border-color: rgb(102, 102, 102); &:focus { border-color: transparent; --box-shadow: 0 0 0 var(--outline-width) var(--form-element-focus-color); } + + &[aria-invalid="true"], + &:invalid { + border-color: red; + } } diff --git a/src/DonorDashboards/resources/js/app/components/select-control/index.js b/src/DonorDashboards/resources/js/app/components/select-control/index.js index 4974d178be..f641589889 100644 --- a/src/DonorDashboards/resources/js/app/components/select-control/index.js +++ b/src/DonorDashboards/resources/js/app/components/select-control/index.js @@ -11,7 +11,7 @@ import './style.scss'; import {__} from '@wordpress/i18n'; -const SelectControl = ({label, value, isLoading, onChange, options, placeholder, width, isClearable}) => { +const SelectControl = ({value, options, isLoading, label = null, onChange = null, placeholder = __('Select...', 'give'), width = null, isClearable = false}) => { if (options && options.length < 2) { return null; } @@ -107,14 +107,4 @@ SelectControl.propTypes = { isClearable: PropTypes.bool, }; -SelectControl.defaultProps = { - label: null, - value: null, - onChange: null, - options: null, - placeholder: __('Select...', 'give'), - width: null, - isClearable: false, -}; - export default SelectControl; diff --git a/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/authorize-control/index.js b/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/authorize-control/index.js index 63be2238bb..7e02984a75 100644 --- a/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/authorize-control/index.js +++ b/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/authorize-control/index.js @@ -7,7 +7,7 @@ import {useAcceptJs} from 'react-acceptjs'; import './style.scss'; -const AuthorizeControl = ({label, value, forwardedRef, gateway}) => { +const AuthorizeControl = ({label = null, value = null, forwardedRef, gateway}) => { const [cardNumber, setCardNumber] = useState(value ? value.card_number : ''); const [cardExpiryDate, setCardExpiryDate] = useState( value ? `${value.card_exp_month} \ ${value.card_exp_year}` : '', @@ -156,10 +156,4 @@ AuthorizeControl.propTypes = { onChange: PropTypes.func, }; -AuthorizeControl.defaultProps = { - label: null, - value: null, - onChange: null, -}; - export default AuthorizeControl; diff --git a/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/card-control/index.js b/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/card-control/index.js index ec3c060e32..196adc1dca 100644 --- a/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/card-control/index.js +++ b/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/card-control/index.js @@ -6,7 +6,7 @@ import {useAccentColor} from '../../../../hooks'; import './style.scss'; -const CardControl = ({label, value, forwardedRef}) => { +const CardControl = ({label = null, value = null, forwardedRef}) => { const [cardNumber, setCardNumber] = useState(value ? value.card_number : ''); const [cardExpiryDate, setCardExpiryDate] = useState( value ? `${value.card_exp_month} \ ${value.card_exp_year}` : '' @@ -124,10 +124,4 @@ CardControl.propTypes = { onChange: PropTypes.func, }; -CardControl.defaultProps = { - label: null, - value: null, - onChange: null, -}; - export default CardControl; diff --git a/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/square-control/index.js b/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/square-control/index.js index 4f757c17c2..af402787b3 100644 --- a/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/square-control/index.js +++ b/src/DonorDashboards/resources/js/app/components/subscription-manager/payment-method-control/square-control/index.js @@ -7,7 +7,7 @@ import './style.scss'; const cardTokenizeResponse = {}; let cardBrand = 'unknown'; -const SquareControl = ({label, value, forwardedRef, gateway}) => { +const SquareControl = ({label = null, value, forwardedRef, gateway}) => { const {applicationID, locationID} = gateway; @@ -78,10 +78,4 @@ SquareControl.propTypes = { onChange: PropTypes.func, }; -SquareControl.defaultProps = { - label: null, - value: null, - onChange: null, -}; - export default SquareControl; diff --git a/src/DonorDashboards/resources/js/app/components/text-control/index.js b/src/DonorDashboards/resources/js/app/components/text-control/index.js index c98aa61459..41198f465a 100644 --- a/src/DonorDashboards/resources/js/app/components/text-control/index.js +++ b/src/DonorDashboards/resources/js/app/components/text-control/index.js @@ -3,7 +3,7 @@ import {toUniqueId} from '../../utils'; import './style.scss'; -const TextControl = ({label, value, onChange, icon, type}) => { +const TextControl = ({label = null, value = '', onChange = null, icon = null, type = 'text'}) => { const id = toUniqueId(label); return ( @@ -21,12 +21,4 @@ const TextControl = ({label, value, onChange, icon, type}) => { ); }; -TextControl.defaultProps = { - label: null, - value: '', - onChange: null, - icon: null, - type: 'text', -}; - export default TextControl; diff --git a/src/DonorDashboards/resources/js/block/color-control/index.js b/src/DonorDashboards/resources/js/block/color-control/index.js index 05540e3a4a..d6d6123936 100644 --- a/src/DonorDashboards/resources/js/block/color-control/index.js +++ b/src/DonorDashboards/resources/js/block/color-control/index.js @@ -9,7 +9,7 @@ import PropTypes from 'prop-types'; const {useInstanceId} = wp.compose; const {BaseControl, ColorPalette} = wp.components; -const ColorControl = ({name, label, help, className, value, hideLabelFromVision, onChange, colors}) => { +const ColorControl = ({name, label, help, className, value, hideLabelFromVision, onChange = null, colors}) => { const instanceId = useInstanceId(ColorControl); const id = `give-color-control-${name}-${instanceId}`; return ( @@ -29,9 +29,4 @@ ColorControl.propTypes = { hideLabelFromVision: PropTypes.bool, }; -ColorControl.defaultProps = { - onChange: null, - options: null, -}; - export default ColorControl; diff --git a/src/MultiFormGoals/resources/js/components/color-control/index.js b/src/MultiFormGoals/resources/js/components/color-control/index.js index 05540e3a4a..d6d6123936 100644 --- a/src/MultiFormGoals/resources/js/components/color-control/index.js +++ b/src/MultiFormGoals/resources/js/components/color-control/index.js @@ -9,7 +9,7 @@ import PropTypes from 'prop-types'; const {useInstanceId} = wp.compose; const {BaseControl, ColorPalette} = wp.components; -const ColorControl = ({name, label, help, className, value, hideLabelFromVision, onChange, colors}) => { +const ColorControl = ({name, label, help, className, value, hideLabelFromVision, onChange = null, colors}) => { const instanceId = useInstanceId(ColorControl); const id = `give-color-control-${name}-${instanceId}`; return ( @@ -29,9 +29,4 @@ ColorControl.propTypes = { hideLabelFromVision: PropTypes.bool, }; -ColorControl.defaultProps = { - onChange: null, - options: null, -}; - export default ColorControl; diff --git a/src/MultiFormGoals/resources/js/components/date-time-control/index.js b/src/MultiFormGoals/resources/js/components/date-time-control/index.js index 4baf604e1d..1cc82b62c9 100644 --- a/src/MultiFormGoals/resources/js/components/date-time-control/index.js +++ b/src/MultiFormGoals/resources/js/components/date-time-control/index.js @@ -11,7 +11,7 @@ const {DateTimePicker, BaseControl, Button, Dropdown} = wp.components; const {__experimentalGetSettings, date} = wp.date; import { __ } from '@wordpress/i18n' -const DateTimeControl = ({name, label, help, className, value, onChange}) => { +const DateTimeControl = ({name, label, help, className, value, onChange = null}) => { const instanceId = useInstanceId(DateTimeControl); const id = `give-date-time-control-${name}-${instanceId}`; const settings = __experimentalGetSettings(); // eslint-disable-line no-restricted-syntax @@ -59,8 +59,4 @@ DateTimeControl.propTypes = { className: PropTypes.string, }; -DateTimeControl.defaultProps = { - onChange: null, -}; - export default DateTimeControl; diff --git a/src/MultiFormGoals/resources/js/components/image-control/index.js b/src/MultiFormGoals/resources/js/components/image-control/index.js index f09e7b9104..0aba95ce7c 100644 --- a/src/MultiFormGoals/resources/js/components/image-control/index.js +++ b/src/MultiFormGoals/resources/js/components/image-control/index.js @@ -11,7 +11,7 @@ const {BaseControl, Button} = wp.components; const {MediaUpload} = wp.blockEditor; import { __ } from '@wordpress/i18n' -const ImageControl = ({name, label, help, className, value, hideLabelFromVision, onChange}) => { +const ImageControl = ({name, label, help, className, value, hideLabelFromVision, onChange = null}) => { const instanceId = useInstanceId(ImageControl); const id = `give-image-control-${name}-${instanceId}`; return ( @@ -53,9 +53,4 @@ ImageControl.propTypes = { hideLabelFromVision: PropTypes.bool, }; -ImageControl.defaultProps = { - onChange: null, - options: null, -}; - export default ImageControl; diff --git a/src/MultiFormGoals/resources/js/components/multi-select-control/index.js b/src/MultiFormGoals/resources/js/components/multi-select-control/index.js index d7b58395f7..ca8f535e95 100644 --- a/src/MultiFormGoals/resources/js/components/multi-select-control/index.js +++ b/src/MultiFormGoals/resources/js/components/multi-select-control/index.js @@ -18,16 +18,16 @@ import './style.scss'; const MultiSelectControl = ({ name, - label, + label = null, help, className, - value, - placeholder, + value = null, + placeholder = `${__('Select', 'give')}...`, hideLabelFromVision, isLoading, isDisabled, - onChange, - options, + onChange = null, + options = null, }) => { const instanceId = useInstanceId(MultiSelectControl); const id = `give-multi-select-control-${name}-${instanceId}`; @@ -76,12 +76,4 @@ MultiSelectControl.propTypes = { placeholder: PropTypes.string, }; -MultiSelectControl.defaultProps = { - label: null, - value: null, - onChange: null, - placeholder: `${__('Select', 'give')}...`, - options: null, -}; - export default MultiSelectControl; diff --git a/src/MultiFormGoals/resources/js/components/server-side-render-x/index.js b/src/MultiFormGoals/resources/js/components/server-side-render-x/index.js index ac4f0f0e81..899c36f736 100644 --- a/src/MultiFormGoals/resources/js/components/server-side-render-x/index.js +++ b/src/MultiFormGoals/resources/js/components/server-side-render-x/index.js @@ -98,7 +98,20 @@ export class ServerSideRenderX extends Component { prevResponseHTML = `
${prevResponse}
`; } - const {className, EmptyResponsePlaceholder, ErrorResponsePlaceholder} = this.props; + const { + className, + EmptyResponsePlaceholder = ({className}) => ( + {__('Block rendered as empty.')} + ), + ErrorResponsePlaceholder = ({response, className}) => { + const errorMessage = sprintf( + // translators: %s: error message describing the problem + __('Error loading block: %s'), + response.errorMsg + ); + return {errorMessage}; + }, + } = this.props; if (response === '') { return ; @@ -122,18 +135,4 @@ export class ServerSideRenderX extends Component { } } -ServerSideRenderX.defaultProps = { - EmptyResponsePlaceholder: ({className}) => ( - {__('Block rendered as empty.')} - ), - ErrorResponsePlaceholder: ({response, className}) => { - const errorMessage = sprintf( - // translators: %s: error message describing the problem - __('Error loading block: %s'), - response.errorMsg - ); - return {errorMessage}; - }, -}; - export default ServerSideRenderX; diff --git a/src/PaymentGateways/Gateways/Offline/Actions/EnqueueOfflineFormBuilderScripts.php b/src/PaymentGateways/Gateways/Offline/Actions/EnqueueOfflineFormBuilderScripts.php index ffc3b83032..827aaa11f9 100644 --- a/src/PaymentGateways/Gateways/Offline/Actions/EnqueueOfflineFormBuilderScripts.php +++ b/src/PaymentGateways/Gateways/Offline/Actions/EnqueueOfflineFormBuilderScripts.php @@ -9,6 +9,8 @@ class EnqueueOfflineFormBuilderScripts /** * Enqueues the Stripe scripts and styles for the Form Builder. * + * @unreleased On the "offlineEnabled" option check if the offline gateway is enabled for v3 forms instead of v2 forms + * * @return void */ public function __invoke() @@ -34,7 +36,7 @@ public function __invoke() 'givewp-offline-gateway-form-builder', 'window.giveOfflineGatewaySettings = ' . wp_json_encode( [ - 'offlineEnabled' => give_is_gateway_active(OfflineGateway::id()), + 'offlineEnabled' => give_is_gateway_active(OfflineGateway::id(), 3), 'offlineSettingsUrl' => admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=gateways§ion=offline-donations' ), diff --git a/src/Views/Components/Card/index.js b/src/Views/Components/Card/index.js index ed2d1e6b92..4977fe4380 100644 --- a/src/Views/Components/Card/index.js +++ b/src/Views/Components/Card/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; // Import styles import styles from './style.module.scss'; -const Card = ({width, title, children}) => { +const Card = ({width = 4, title = null, children = null}) => { return (
{title &&
{title}
} @@ -21,10 +21,4 @@ Card.propTypes = { children: PropTypes.node.isRequired, }; -Card.defaultProps = { - width: 4, - title: null, - children: null, -}; - export default Card; diff --git a/src/Views/Components/ListTable/Pagination/index.tsx b/src/Views/Components/ListTable/Pagination/index.tsx index fef67b3345..afa1d5f4fd 100644 --- a/src/Views/Components/ListTable/Pagination/index.tsx +++ b/src/Views/Components/ListTable/Pagination/index.tsx @@ -4,14 +4,16 @@ import styles from './Pagination.module.scss'; import cx from 'classnames'; import {__, sprintf} from '@wordpress/i18n'; -const Pagination = ({currentPage, totalPages, totalItems = -1, disabled, setPage, singleName, pluralName}) => { +const Pagination = ({currentPage = 1, totalPages = 0, totalItems = -1, disabled = false, setPage = (n) => {}, singleName, pluralName}) => { const [pageInput, setPageInput] = useState(1); useEffect(() => { setPageInput(currentPage); }, [currentPage]); + // @ts-ignore const nextPage = parseInt(currentPage) + 1; + // @ts-ignore const previousPage = parseInt(currentPage) - 1; return ( @@ -42,6 +44,7 @@ const Pagination = ({currentPage, totalPages, totalItems = -1, disabled, setPage aria-label={__('previous page')} onClick={(e) => { if (e.currentTarget.getAttribute('aria-disabled') === 'false') { + // @ts-ignore setPage(parseInt(currentPage) - 1); } }} @@ -80,6 +83,7 @@ const Pagination = ({currentPage, totalPages, totalItems = -1, disabled, setPage aria-label={__('next page')} onClick={(e) => { if (e.currentTarget.getAttribute('aria-disabled') === 'false') { + // @ts-ignore setPage(parseInt(currentPage) + 1); } }} @@ -117,11 +121,4 @@ Pagination.propTypes = { disabled: PropTypes.bool.isRequired, }; -Pagination.defaultProps = { - currentPage: 1, - totalPages: 0, - setPage: () => {}, - disabled: false, -}; - export default Pagination; diff --git a/src/Views/Components/Modal/index.js b/src/Views/Components/Modal/index.js index aece6874f7..fdeffd7cbe 100644 --- a/src/Views/Components/Modal/index.js +++ b/src/Views/Components/Modal/index.js @@ -7,7 +7,7 @@ import styles from './styles.module.scss'; import {__} from '@wordpress/i18n'; -const Modal = ({visible, type, children, isLoading, handleClose, ...rest}) => { +const Modal = ({visible = true, type = 'notice', children = {}, isLoading = false, handleClose = () => {}, ...rest}) => { const closeModal = useCallback((event) => { if (event.keyCode === 27 && typeof handleClose === 'function') { handleClose(); @@ -156,12 +156,4 @@ Modal.AdditionalContext.propTypes = { context: PropTypes.any.isRequired, }; -Modal.defaultProps = { - visible: true, - isLoading: false, - type: 'notice', - children: {}, - handleClose: () => {}, -}; - export default Modal; diff --git a/src/Views/Components/Pagination/index.js b/src/Views/Components/Pagination/index.js index 8edaeca2d7..9be6bc49e1 100644 --- a/src/Views/Components/Pagination/index.js +++ b/src/Views/Components/Pagination/index.js @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import { __ } from '@wordpress/i18n' -const Pagination = ({currentPage, totalPages, disabled, setPage}) => { +const Pagination = ({currentPage = 1, totalPages = 0, disabled = false, setPage = () => {}}) => { if (1 >= totalPages) { return false; } @@ -100,11 +100,4 @@ Pagination.propTypes = { disabled: PropTypes.bool.isRequired, }; -Pagination.defaultProps = { - currentPage: 1, - totalPages: 0, - setPage: () => {}, - disabled: false, -}; - export default Pagination; diff --git a/src/Views/Components/PeriodSelector/index.js b/src/Views/Components/PeriodSelector/index.js index 95c30ddaf2..6822e87467 100644 --- a/src/Views/Components/PeriodSelector/index.js +++ b/src/Views/Components/PeriodSelector/index.js @@ -9,7 +9,7 @@ import 'react-dates/lib/css/_datepicker.css'; import styles from './style.module.scss'; -const PeriodSelector = ({period, setDates}) => { +const PeriodSelector = ({period = {startDate: null, endDate: null}, setDates = () => {}}) => { const [focusedInput, setFocusedInput] = useState(null); const icon = ( @@ -59,12 +59,4 @@ PeriodSelector.propTypes = { setDates: PropTypes.func.isRequired, }; -PeriodSelector.defaultProps = { - period: { - startDate: null, - endDate: null, - }, - setDates: () => {}, -}; - export default PeriodSelector; diff --git a/src/Views/Components/Spinner/index.js b/src/Views/Components/Spinner/index.js index 66bda80094..c149a28da6 100644 --- a/src/Views/Components/Spinner/index.js +++ b/src/Views/Components/Spinner/index.js @@ -3,7 +3,7 @@ import PropTypes from 'prop-types'; import styles from './style.module.scss'; -const Spinner = ({size, ...rest}) => { +const Spinner = ({size = 'small', ...rest}) => { const spinnerClasses = classNames({ [styles.spinner]: true, [styles.large]: size === 'large', @@ -24,8 +24,4 @@ Spinner.propTypes = { size: PropTypes.string, }; -Spinner.defaultProps = { - size: 'small', -}; - export default Spinner; diff --git a/src/Views/Components/Table/index.js b/src/Views/Components/Table/index.js index c41bb2f598..7547d6010c 100644 --- a/src/Views/Components/Table/index.js +++ b/src/Views/Components/Table/index.js @@ -7,7 +7,7 @@ import styles from './style.module.scss'; import {__} from '@wordpress/i18n'; -const Table = ({title, columns, data, columnFilters, stripped, isLoading, isSorting, ...rest}) => { +const Table = ({title = null, columns = [], data = [], columnFilters = {}, stripped = false, isLoading = false, isSorting, ...rest}) => { const [state, setState] = useState({}); const [cachedData, setCachedData] = useState([]); @@ -161,13 +161,4 @@ Table.propTypes = { isLoading: PropTypes.bool, }; -Table.defaultProps = { - title: null, - columns: [], - data: [], - columnFilters: {}, - stripped: true, - isLoading: false, -}; - export default Table;