Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware committed Jan 9, 2024
1 parent ce3dd4e commit 4918218
Show file tree
Hide file tree
Showing 27 changed files with 40 additions and 30 deletions.
4 changes: 2 additions & 2 deletions components/lib/api/api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ import { OverlayPanelPassThroughOptions } from '../overlaypanel/overlaypanel';
import { PaginatorPassThroughOptions } from '../paginator/paginator';
import { PanelPassThroughOptions } from '../panel/panel';
import { PanelMenuPassThroughOptions } from '../panelmenu/panelmenu';
import { PassThroughOptions } from '../passthrough';
import { PasswordPassThroughOptions } from '../password/password';
import { PickListPassThroughOptions } from '../picklist/picklist';
import { ProgressBarPassThroughOptions } from '../progressbar/progressbar';
Expand Down Expand Up @@ -93,7 +94,6 @@ import { TreePassThroughOptions } from '../tree/tree';
import { TreeSelectPassThroughOptions } from '../treeselect/treeselect';
import { TreeTablePassThroughOptions } from '../treetable/treetable';
import { VirtualScrollerPassThroughOptions } from '../virtualscroller/virtualscroller';
import { PassThroughOptions } from '../passthrough';

// Config
/**
Expand Down Expand Up @@ -129,7 +129,7 @@ export interface ZIndexOptions {

export type InputStyleType = 'outlined' | 'filled';

export type AppendToType = 'self' | HTMLElement | undefined | null;
export type AppendToType = 'self' | HTMLElement | undefined | null | (() => HTMLElement);

export type StyleContainerType = ShadowRoot | HTMLElement | undefined | null;

Expand Down
2 changes: 1 addition & 1 deletion components/lib/autocomplete/autocomplete.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export interface AutoCompleteProps extends Omit<React.DetailedHTMLProps<React.HT
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* When present, it specifies that the component should automatically get focus on load.
* @defaultValue false
Expand Down
4 changes: 3 additions & 1 deletion components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -1534,7 +1534,9 @@ export const Calendar = React.memo(
};

const appendDisabled = () => {
return props.appendTo === 'self' || props.inline;
const appendTo = props.appendTo || (context && context.appendTo) || PrimeReact.appendTo;

return appendTo === 'self' || props.inline;
};

const alignOverlay = () => {
Expand Down
2 changes: 1 addition & 1 deletion components/lib/calendar/calendar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ interface CalendarBaseProps {
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* When present, it specifies that the component should automatically get focus on load.
* @defaultValue false
Expand Down
2 changes: 1 addition & 1 deletion components/lib/cascadeselect/cascadeselect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export interface CascadeSelectProps extends Omit<React.DetailedHTMLProps<React.I
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
* @type {CSSTransitionProps}
Expand Down
2 changes: 1 addition & 1 deletion components/lib/colorpicker/colorpicker.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export interface ColorPickerProps extends Omit<React.DetailedHTMLProps<React.Inp
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* When present, it specifies that the component should automatically get focus on load.
* @defaultValue false
Expand Down
2 changes: 1 addition & 1 deletion components/lib/confirmdialog/confirmdialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export interface ConfirmDialogProps extends Omit<DialogProps, 'onHide' | 'footer
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Style class of the element.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/confirmpopup/confirmpopup.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ export interface ConfirmPopupProps {
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Enables to hide the popup when outside is clicked.
* @defaultValue true
Expand Down
2 changes: 1 addition & 1 deletion components/lib/contextmenu/contextmenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ export interface ContextMenuProps extends Omit<React.DetailedHTMLProps<React.HTM
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/datatable/datatable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1222,7 +1222,7 @@ interface DataTableBaseProps<TValue extends DataTableValueArray> extends Omit<Re
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
paginatorDropdownAppendTo?: 'self' | HTMLElement | null | undefined;
paginatorDropdownAppendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Content for the left side of the paginator.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dataview/dataview.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export interface DataViewProps extends Omit<React.DetailedHTMLProps<React.HTMLAt
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
paginatorDropdownAppendTo?: 'self' | HTMLElement | undefined | null;
paginatorDropdownAppendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Array of integer values to display inside rows per page dropdown.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dialog/dialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ export interface DialogProps {
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Defines a string that labels the close icon.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/dropdown/dropdown.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export interface DropdownProps extends Omit<React.DetailedHTMLProps<React.InputH
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Used to define a string that labels the component.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/menu/menu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export interface MenuProps extends Omit<React.DetailedHTMLProps<React.HTMLAttrib
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
* @type {CSSTransitionProps}
Expand Down
2 changes: 1 addition & 1 deletion components/lib/multiselect/multiselect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export interface MultiSelectProps extends Omit<React.DetailedHTMLProps<React.Inp
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Establishes relationships between the component and label(s) where its value should be one or more element IDs.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/overlaypanel/overlaypanel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export interface OverlayPanelProps extends Omit<React.DetailedHTMLProps<React.HT
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Aria label of the close icon.
* @defaultValue close
Expand Down
4 changes: 2 additions & 2 deletions components/lib/paginator/paginator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ interface PaginatorRowsPerPageDropdownOptions {
/**
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and "self". The "self" value is used to render a component where it is located.
*/
appendTo: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* The current page number.
*/
Expand Down Expand Up @@ -610,7 +610,7 @@ export interface PaginatorProps extends Omit<React.DetailedHTMLProps<React.HTMLA
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
dropdownAppendTo?: 'self' | HTMLElement | null | undefined;
dropdownAppendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Callback to invoke when page changes, the event object contains information about the new state.
* @param {PaginatorPageChangeEvent} event - Custom page change event.
Expand Down
2 changes: 1 addition & 1 deletion components/lib/password/password.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export interface PasswordProps extends Omit<React.DetailedHTMLProps<React.InputH
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Template of panel header if "feedback" is enabled.
*/
Expand Down
12 changes: 10 additions & 2 deletions components/lib/portal/Portal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import ReactDOM from 'react-dom';
import PrimeReact, { PrimeReactContext } from '../api/Api';
import { useMountEffect, useUnmountEffect, useUpdateEffect } from '../hooks/Hooks';
import { DomHandler } from '../utils/Utils';
import { DomHandler, ObjectUtils } from '../utils/Utils';
import { PortalBase } from './PortalBase';

export const Portal = React.memo((inProps) => {
Expand All @@ -29,7 +29,15 @@ export const Portal = React.memo((inProps) => {
const element = props.element || props.children;

if (element && mountedState) {
const appendTo = props.appendTo || (context && context.appendTo) || PrimeReact.appendTo || document.body;
let appendTo = props.appendTo || (context && context.appendTo) || PrimeReact.appendTo;

if (ObjectUtils.isFunction(appendTo)) {
appendTo = appendTo();
}

if (!appendTo) {
appendTo = document.body;
}

return appendTo === 'self' ? element : ReactDOM.createPortal(element, appendTo);
}
Expand Down
2 changes: 1 addition & 1 deletion components/lib/sidebar/sidebar.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export interface SidebarProps extends Omit<React.DetailedHTMLProps<React.HTMLAtt
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and self. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
* @type {CSSTransitionProps}
Expand Down
2 changes: 1 addition & 1 deletion components/lib/slidemenu/slidemenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export interface SlideMenuProps extends Omit<React.DetailedHTMLProps<React.HTMLA
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Whether to automatically manage layering.
* @defaultValue true
Expand Down
2 changes: 1 addition & 1 deletion components/lib/splitbutton/splitbutton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export interface SplitButtonProps extends Omit<React.DetailedHTMLProps<React.HTM
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Content of the tooltip.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/tieredmenu/tieredmenu.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export interface TieredMenuProps extends Omit<React.DetailedHTMLProps<React.HTML
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* The properties of CSSTransition can be customized, except for "nodeRef" and "in" properties.
* @type {CSSTransitionProps}
Expand Down
2 changes: 1 addition & 1 deletion components/lib/toast/toast.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ export interface ToastProps extends Omit<React.DetailedHTMLProps<React.HTMLAttri
* DOM element instance where the component should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue self
*/
appendTo?: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Callback to invoke when an active tab is collapsed by clicking on the header.
* @param {ToastMessage} message - Clicked message
Expand Down
2 changes: 1 addition & 1 deletion components/lib/tooltip/tooltipoptions.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export interface TooltipOptions {
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | null | undefined;
appendTo?: 'self' | HTMLElement | null | undefined | (() => HTMLElement);
/**
* Defines which position on the target element to align the positioned tooltip.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/treeselect/treeselect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ export interface TreeSelectProps extends Omit<React.DetailedHTMLProps<React.Inpu
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
appendTo?: 'self' | HTMLElement | undefined | null;
appendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Used to define a string that labels the component.
*/
Expand Down
2 changes: 1 addition & 1 deletion components/lib/treetable/treetable.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,7 +733,7 @@ export interface TreeTableProps extends Omit<React.DetailedHTMLProps<React.Input
* DOM element instance where the overlay panel should be mounted. Valid values are any DOM Element and 'self'. The self value is used to render a component where it is located.
* @defaultValue document.body
*/
paginatorDropdownAppendTo?: 'self' | HTMLElement | undefined | null;
paginatorDropdownAppendTo?: 'self' | HTMLElement | undefined | null | (() => HTMLElement);
/**
* Content for the left side of the paginator.
*/
Expand Down

0 comments on commit 4918218

Please sign in to comment.