Skip to content

Commit

Permalink
Fix #5652: Ripple set deprecated static when context is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Dec 29, 2023
1 parent 47d5663 commit 509f772
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 11 deletions.
27 changes: 22 additions & 5 deletions components/doc/confirmpopup/headlessdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function HeadlessDoc(props) {
confirmPopup({
group: 'headless',
target: event.currentTarget,
message: 'Are you sure you want to proceed?',
message: 'Are you sure you want to proceed?',
icon: 'pi pi-exclamation-triangle',
defaultFocus: 'accept',
accept,
Expand Down Expand Up @@ -204,15 +204,32 @@ export default function HeadlessDemo() {
<Toast ref={toast} />
<ConfirmPopup
group="headless"
content={({message, acceptBtnRef, rejectBtnRef, hide}) =>
content={({ message, acceptBtnRef, rejectBtnRef, hide }) => (
<div className="bg-gray-900 text-white border-round p-3">
<span>{message}</span>
<div className="flex align-items-center gap-2 mt-3">
<Button ref={acceptBtnRef} label="Save" onClick={() => {accept(); hide();}} className="p-button-sm p-button-outlined"></Button>
<Button ref={rejectBtnRef} label="Cancel" outlined onClick={() => {reject(); hide();}}className="p-button-sm p-button-text"></Button>
<Button
ref={acceptBtnRef}
label="Save"
onClick={() => {
accept();
hide();
}}
className="p-button-sm p-button-outlined"
></Button>
<Button
ref={rejectBtnRef}
label="Cancel"
outlined
onClick={() => {
reject();
hide();
}}
className="p-button-sm p-button-text"
></Button>
</div>
</div>
}
)}
/>
<div className="card flex flex-wrap gap-2 justify-content-center">
<Button onClick={confirm1} icon="pi pi-check" label="Confirm"></Button>
Expand Down
1 change: 0 additions & 1 deletion components/doc/dropdown/editabledoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function EditableDoc(props) {
{ name: 'Paris', code: 'PRS' }
];


const code = {
basic: `
<Dropdown value={selectedCity} onChange={(e) => setSelectedCity(e.value)} options={cities} optionLabel="name"
Expand Down
3 changes: 3 additions & 0 deletions components/lib/api/PrimeReact.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { FilterMatchMode } from './FilterMatchMode';

/**
* @deprecated please use PrimeReactContext
*/
export default class PrimeReact {
static ripple = false;

Expand Down
22 changes: 22 additions & 0 deletions components/lib/api/PrimeReactContext.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { FilterMatchMode } from './FilterMatchMode';
import PrimeReact from './PrimeReact';

export const PrimeReactContext = React.createContext();

Expand Down Expand Up @@ -58,6 +59,27 @@ export const PrimeReactProvider = (props) => {
linkElement.parentNode?.insertBefore(cloneLinkElement, linkElement.nextSibling);
};

/**
* @deprecated
*/
React.useEffect(() => {
PrimeReact.ripple = ripple;
}, [ripple]);

/**
* @deprecated
*/
React.useEffect(() => {
PrimeReact.inputStyle = inputStyle;
}, [inputStyle]);

/**
* @deprecated
*/
React.useEffect(() => {
PrimeReact.locale = locale;
}, [locale]);

const value = {
changeTheme,
ripple,
Expand Down
2 changes: 0 additions & 2 deletions components/lib/confirmdialog/confirmdialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ interface ConfirmDialogOptions {
[key: string]: any;
}


/**
* Defines valid properties in ConfirmDialog component. In addition to these, all properties of {@link dialog} can be used in this component.
* @group Properties
Expand Down Expand Up @@ -256,7 +255,6 @@ export interface ConfirmDialogProps extends Omit<DialogProps, 'onHide' | 'footer
* @defaultValue false
*/
unstyled?: boolean;

}

/**
Expand Down
1 change: 0 additions & 1 deletion components/lib/dialog/dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@ interface ContentPropsMessage {
message: string;
}


/**
* Defines valid properties in Dialog component.
* @group Properties
Expand Down
1 change: 0 additions & 1 deletion components/lib/panel/Panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,6 @@ export const Panel = React.forwardRef((inProps, ref) => {
return null;
};


const createFooter = () => {
const footer = ObjectUtils.getJSXElement(props.footer, props);

Expand Down
1 change: 0 additions & 1 deletion components/lib/toast/toast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ interface ContentProps {
message: ContentPropsMessage;
}


/**
* Defines valid properties in Toast component. In addition to these, all properties of HTMLDivElement can be used in this component.
* @group Properties
Expand Down

0 comments on commit 509f772

Please sign in to comment.