Skip to content

Commit

Permalink
Merge branch 'develop' into fix/wp-6.61-anonymous-block-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaHungDinh authored Sep 9, 2024
2 parents 6d50d38 + e2f14ca commit 251341e
Show file tree
Hide file tree
Showing 21 changed files with 48 additions and 156 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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%;
Expand All @@ -56,11 +55,6 @@ textarea {
font-weight: 500;
line-height: 1.2;

&[aria-invalid="true"],
&:invalid {
border-color: red;
}

&::placeholder {
opacity: 0.6;
}
Expand Down
7 changes: 6 additions & 1 deletion src/DonationForms/resources/styles/_base-overrides.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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}` : '',
Expand Down Expand Up @@ -156,10 +156,4 @@ AuthorizeControl.propTypes = {
onChange: PropTypes.func,
};

AuthorizeControl.defaultProps = {
label: null,
value: null,
onChange: null,
};

export default AuthorizeControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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}` : ''
Expand Down Expand Up @@ -124,10 +124,4 @@ CardControl.propTypes = {
onChange: PropTypes.func,
};

CardControl.defaultProps = {
label: null,
value: null,
onChange: null,
};

export default CardControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -78,10 +78,4 @@ SquareControl.propTypes = {
onChange: PropTypes.func,
};

SquareControl.defaultProps = {
label: null,
value: null,
onChange: null,
};

export default SquareControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -29,9 +29,4 @@ ColorControl.propTypes = {
hideLabelFromVision: PropTypes.bool,
};

ColorControl.defaultProps = {
onChange: null,
options: null,
};

export default ColorControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -29,9 +29,4 @@ ColorControl.propTypes = {
hideLabelFromVision: PropTypes.bool,
};

ColorControl.defaultProps = {
onChange: null,
options: null,
};

export default ColorControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,8 +59,4 @@ DateTimeControl.propTypes = {
className: PropTypes.string,
};

DateTimeControl.defaultProps = {
onChange: null,
};

export default DateTimeControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -53,9 +53,4 @@ ImageControl.propTypes = {
hideLabelFromVision: PropTypes.bool,
};

ImageControl.defaultProps = {
onChange: null,
options: null,
};

export default ImageControl;
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,20 @@ export class ServerSideRenderX extends Component {
prevResponseHTML = `<div style="position:relative;"><div style="position:absolute;right:${right}${unit};top:${top}${unit};z-index:1"><span class="components-spinner"></span></div>${prevResponse}</div>`;
}

const {className, EmptyResponsePlaceholder, ErrorResponsePlaceholder} = this.props;
const {
className,
EmptyResponsePlaceholder = ({className}) => (
<Placeholder className={className}>{__('Block rendered as empty.')}</Placeholder>
),
ErrorResponsePlaceholder = ({response, className}) => {
const errorMessage = sprintf(
// translators: %s: error message describing the problem
__('Error loading block: %s'),
response.errorMsg
);
return <Placeholder className={className}>{errorMessage}</Placeholder>;
},
} = this.props;

if (response === '') {
return <EmptyResponsePlaceholder response={response} {...this.props} />;
Expand All @@ -122,18 +135,4 @@ export class ServerSideRenderX extends Component {
}
}

ServerSideRenderX.defaultProps = {
EmptyResponsePlaceholder: ({className}) => (
<Placeholder className={className}>{__('Block rendered as empty.')}</Placeholder>
),
ErrorResponsePlaceholder: ({response, className}) => {
const errorMessage = sprintf(
// translators: %s: error message describing the problem
__('Error loading block: %s'),
response.errorMsg
);
return <Placeholder className={className}>{errorMessage}</Placeholder>;
},
};

export default ServerSideRenderX;
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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&section=offline-donations'
),
Expand Down
8 changes: 1 addition & 7 deletions src/Views/Components/Card/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div className={styles.card} style={{gridColumn: 'span ' + width}}>
{title && <div className={styles.title}>{title}</div>}
Expand All @@ -21,10 +21,4 @@ Card.propTypes = {
children: PropTypes.node.isRequired,
};

Card.defaultProps = {
width: 4,
title: null,
children: null,
};

export default Card;
13 changes: 5 additions & 8 deletions src/Views/Components/ListTable/Pagination/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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);
}
}}
Expand Down Expand Up @@ -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);
}
}}
Expand Down Expand Up @@ -117,11 +121,4 @@ Pagination.propTypes = {
disabled: PropTypes.bool.isRequired,
};

Pagination.defaultProps = {
currentPage: 1,
totalPages: 0,
setPage: () => {},
disabled: false,
};

export default Pagination;
10 changes: 1 addition & 9 deletions src/Views/Components/Modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -156,12 +156,4 @@ Modal.AdditionalContext.propTypes = {
context: PropTypes.any.isRequired,
};

Modal.defaultProps = {
visible: true,
isLoading: false,
type: 'notice',
children: {},
handleClose: () => {},
};

export default Modal;
Loading

0 comments on commit 251341e

Please sign in to comment.