Skip to content

Commit

Permalink
Refactor PT - Related #4360, #4293, #4352, #4359
Browse files Browse the repository at this point in the history
  • Loading branch information
ulasturann committed May 11, 2023
1 parent f03f4d7 commit d1b72a7
Show file tree
Hide file tree
Showing 25 changed files with 169 additions and 112 deletions.
61 changes: 35 additions & 26 deletions components/doc/inplace/pt/ptdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,58 +7,67 @@ import { InplaceContent } from '../../../lib/inplace/Inplace';
export function PTDoc(props) {
const code = {
basic: `
<Card
title="Simple Card"
<Inplace
pt={{
body: { className: 'bg-primary border-round-lg' }
display: { className: 'bg-primary' }
}}
>
<p className="m-0">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
quas!
</p>
</Card>
<InplaceDisplay>View Content</InplaceDisplay>
<InplaceContent>
<p className="m-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</InplaceContent>
</Inplace>
`,
javascript: `
import React from 'react';
import { Card } from 'primereact/card';
import { Inplace } from 'primereact/inplace';
export default function PTDemo() {
return (
<div className="card">
<Card
title="Simple Card"
<Inplace
pt={{
body: { className: 'bg-primary border-round-lg' }
display: { className: 'bg-primary' }
}}
>
<p className="m-0">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
quas!
</p>
</Card>
<InplaceDisplay>View Content</InplaceDisplay>
<InplaceContent>
<p className="m-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</InplaceContent>
</Inplace>
</div>
)
}
`,
typescript: `
import React from 'react';
import { Card } from 'primereact/card';
import { Inplace } from 'primereact/inplace';
export default function PTDemo() {
return (
<div className="card">
<Card
title="Simple Card"
<Inplace
pt={{
body: { className: 'bg-primary border-round-lg' }
display: { className: 'bg-primary' }
}}
>
<p className="m-0">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Inventore sed consequuntur error repudiandae numquam deserunt quisquam repellat libero asperiores earum nam nobis, culpa ratione quam perferendis esse, cupiditate neque
quas!
</p>
</Card>
<InplaceDisplay>View Content</InplaceDisplay>
<InplaceContent>
<p className="m-0">
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est
laborum.
</p>
</InplaceContent>
</Inplace>
</div>
)
}
Expand Down
2 changes: 0 additions & 2 deletions components/doc/splitter/pt/ptdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,3 @@ export default function PTDemo() {
</>
);
}

export default PTDoc;
2 changes: 0 additions & 2 deletions components/doc/tabview/pt/ptdoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,3 @@ export default function PTDemo() {
</>
);
}

export default PTDoc;
2 changes: 1 addition & 1 deletion components/lib/accordion/accordion.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface AccordionTabPassThroughOptions {
/**
* Uses to pass attributes to the headericon's DOM element.
*/
headerIcon?: AccordionTabPassThroughType<React.HTMLAttributes<HTMLSpanElement | SVGSVGElement>>;
headerIcon?: AccordionTabPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the headertitle's DOM element.
*/
Expand Down
7 changes: 6 additions & 1 deletion components/lib/avatar/avatar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface AvatarPassThroughOptions {
/**
* Uses to pass attributes to the icon's DOM element.
*/
icon?: AvatarPassThroughType<React.HTMLAttributes<SVGSVGElement>>;
icon?: AvatarPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the image's DOM element.
*/
Expand Down Expand Up @@ -97,6 +97,11 @@ export interface AvatarProps extends Omit<React.DetailedHTMLProps<React.HTMLAttr
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {AvatarPassThroughOptions}
*/
pt?: AvatarPassThroughOptions;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions components/lib/avatargroup/avatargroup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ export interface AvatarGroupProps extends Omit<React.DetailedHTMLProps<React.HTM
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {AvatarGroupPassThroughOptions}
*/
pt?: AvatarGroupPassThroughOptions;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions components/lib/badge/badge.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ export interface BadgeProps extends Omit<React.DetailedHTMLProps<React.HTMLAttri
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {BadgePassThroughOptions}
*/
pt?: BadgePassThroughOptions;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions components/lib/blockui/blockui.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ export interface BlockUIProps extends Omit<React.DetailedHTMLProps<React.HTMLAtt
* Template of mask.
*/
template?: React.ReactNode | ((props: BlockUIProps) => React.ReactNode) | null | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {BlockUIPassThroughOptions}
*/
pt?: BlockUIPassThroughOptions;
/**
* Fired when the element gets blocked.
*/
Expand Down
5 changes: 2 additions & 3 deletions components/lib/chip/Chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export const Chip = React.memo(
ptm('removeIcon')
);

const iconProps = { ...removeIconProps };
const icon = props.removeIcon || <TimesCircleIcon {...iconProps} />;
const icon = props.removeIcon || <TimesCircleIcon {...removeIconProps} />;

if (props.image) {
const imageProps = mergeProps(
Expand Down Expand Up @@ -81,7 +80,7 @@ export const Chip = React.memo(
}

if (props.removable) {
content.push(IconUtils.getJSXIcon(icon, { ...iconProps }, { props }));
content.push(IconUtils.getJSXIcon(icon, { ...removeIconProps }, { props }));
}

return content;
Expand Down
9 changes: 7 additions & 2 deletions components/lib/chip/chip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ export interface ChipPassThroughOptions {
/**
* Uses to pass attributes to the icon's DOM element.
*/
icon?: ChipPassThroughType<React.HTMLAttributes<SVGSVGElement>>;
icon?: ChipPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the label' DOM element.
*/
label?: ChipPassThroughType<React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the removeIcon's DOM element.
*/
removeIcon?: ChipPassThroughType<React.HTMLAttributes<SVGSVGElement>>;
removeIcon?: ChipPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
}

/**
Expand Down Expand Up @@ -106,6 +106,11 @@ export interface ChipProps extends Omit<React.DetailedHTMLProps<React.HTMLAttrib
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {ChipPassThroughOptions}
*/
pt?: ChipPassThroughOptions;
}

/**
Expand Down
9 changes: 7 additions & 2 deletions components/lib/confirmdialog/confirmdialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*
*/
import * as React from 'react';
import { DialogPassThroughOptions, DialogProps } from '../dialog';
import { DialogProps } from '../dialog';
import { IconType, PassThroughType } from '../utils';
import { ButtonPassThroughOptions } from '../button/button';

Expand Down Expand Up @@ -143,7 +143,7 @@ interface ConfirmDialogOptions {
* Defines valid properties in ConfirmDialog component. In addition to these, all properties of {@link dialog} can be used in this component.
* @group Properties
*/
export interface ConfirmDialogProps extends Omit<DialogProps, 'onHide' | 'footer'> {
export interface ConfirmDialogProps extends Omit<DialogProps, 'onHide' | 'footer' | 'pt'> {
/**
* Unique tag key used to separate the confirmDialog components in the page.
*/
Expand Down Expand Up @@ -217,6 +217,11 @@ export interface ConfirmDialogProps extends Omit<DialogProps, 'onHide' | 'footer
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {ConfirmDialogPassThroughOptions}
*/
pt?: ConfirmDialogPassThroughOptions;
}

/**
Expand Down
40 changes: 20 additions & 20 deletions components/lib/confirmpopup/ConfirmPopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ export const ConfirmPopup = React.memo(
const [visibleState, setVisibleState] = React.useState(props.visible);
const [reshowState, setReshowState] = React.useState(false);
const { ptm } = ConfirmPopupBase.setMetaData({
props
props,
state: {
visible: visibleState,
reshow: reshowState
}
});

const overlayRef = React.useRef(null);
Expand Down Expand Up @@ -256,26 +260,22 @@ export const ConfirmPopup = React.memo(
ptm('footer')
);

const rejectButtonProps = mergeProps(
{
label: rejectLabel,
icon: getPropValue('rejectIcon'),
className: rejectClassName,
onClick: reject
},
ptm('rejectButton')
);
const rejectButtonProps = mergeProps({
label: rejectLabel,
icon: getPropValue('rejectIcon'),
className: rejectClassName,
onClick: reject,
pt: ptm('rejectButton')
});

const acceptButtonProps = mergeProps(
{
ref: acceptBtnRef,
label: acceptLabel,
icon: getPropValue('acceptIcon'),
className: acceptClassName,
onClick: accept
},
ptm('acceptButton')
);
const acceptButtonProps = mergeProps({
ref: acceptBtnRef,
label: acceptLabel,
icon: getPropValue('acceptIcon'),
className: acceptClassName,
onClick: accept,
pt: ptm('acceptButton')
});

const content = (
<div {...footerProps}>
Expand Down
12 changes: 11 additions & 1 deletion components/lib/confirmpopup/confirmpopup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export interface ConfirmPopupPassThroughOptions {
/**
* Uses to pass attributes to the icon's DOM element.
*/
icon?: ConfirmPopupPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement | SVGSVGElement>>;
icon?: ConfirmPopupPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the message's DOM element.
*/
Expand Down Expand Up @@ -68,6 +68,11 @@ export interface ConfirmPopupState {
* @defaultValue false
*/
visible: boolean;
/**
* Current reshow state as a boolean.
* @defaultValue false
*/
reshow: boolean;
}

/**
Expand Down Expand Up @@ -218,6 +223,11 @@ export interface ConfirmPopupProps {
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {ConfirmPopupPassThroughOptions}
*/
pt?: ConfirmPopupPassThroughOptions;
}

/**
Expand Down
9 changes: 7 additions & 2 deletions components/lib/dialog/dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ export interface DialogPassThroughOptions {
/**
* Uses to pass attributes to the close button's component.
*/
closeButton?: DialogPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
closeButton?: DialogPassThroughType<React.HTMLAttributes<HTMLButtonElement>>;
/**
* Uses to pass attributes to the close button icon's component.
*/
closeButtonIcon?: DialogPassThroughType<React.HTMLAttributes<HTMLButtonElement>>;
closeButtonIcon?: DialogPassThroughType<React.SVGProps<SVGSVGElement> | React.HTMLAttributes<HTMLSpanElement>>;
/**
* Uses to pass attributes to the content's DOM element.
*/
Expand Down Expand Up @@ -292,6 +292,11 @@ export interface DialogProps {
* @defaultValue false
*/
visible?: boolean | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {DialogPassThroughOptions}
*/
pt?: DialogPassThroughOptions;
/**
* Callback to invoke when dialog is clicked.
* @param {React.PointerEvent<HTMLElement>} event - Browser event.
Expand Down
5 changes: 5 additions & 0 deletions components/lib/divider/divider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ export interface DividerProps extends Omit<React.DetailedHTMLProps<React.HTMLAtt
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {DividerPassThroughOptions}
*/
pt?: DividerPassThroughOptions;
}

/**
Expand Down
5 changes: 5 additions & 0 deletions components/lib/fieldset/fieldset.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ export interface FieldsetProps extends Omit<React.DetailedHTMLProps<React.HTMLAt
* @readonly
*/
children?: React.ReactNode | undefined;
/**
* Uses to pass attributes to DOM elements inside the component.
* @type {FieldsetPassThroughOptions}
*/
pt?: FieldsetPassThroughOptions;
}

/**
Expand Down
Loading

0 comments on commit d1b72a7

Please sign in to comment.