Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(DualListSelector): promoted Next version #10359

Merged
merged 7 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/react-core/single-packages.config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packageName": "@patternfly/react-core",
"moduleGlob": ["/dist/esm/helpers/**/*.js", "/dist/esm/styles/**/index.js", "/dist/esm/*/*/**/index.js"],
"exclude": ["/dist/esm/helpers/Popper/thirdparty"]
"exclude": ["/dist/esm/helpers/Popper/thirdparty", "/dist/esm/next"]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't recall if we previously had to do anything else, but this resolves the build failing due to Next no longer exporting anything.

}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const DualListSelectorListContext = React.createContext<{
displayOption?: (option: React.ReactNode) => boolean;
selectedOptions?: string[] | number[];
id?: string;
onOptionSelect?: (e: React.MouseEvent | React.ChangeEvent | React.KeyboardEvent, index: number, id: string) => void;
options?: React.ReactNode[];
isDisabled?: boolean;
}>({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface DualListSelectorControlProps extends Omit<React.HTMLProps<HTMLD

export const DualListSelectorControlBase: React.FunctionComponent<DualListSelectorControlProps> = ({
innerRef,
children = null,
children,
className,
'aria-label': ariaLabel,
isDisabled = true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { handleArrows } from '../../helpers';
/** Acts as the container for the DualListSelectorControl sub-components. */

export interface DualListSelectorControlsWrapperProps extends React.HTMLProps<HTMLDivElement> {
/** Anything that can be rendered inside of the wrapper. */
/** Content to be rendered inside of the controls wrapper. */
children?: React.ReactNode;
/** Additional classes added to the wrapper. */
className?: string;
Expand Down Expand Up @@ -60,6 +60,7 @@ export const DualListSelectorControlsWrapperBase: React.FunctionComponent<DualLi
return () => {
window.removeEventListener('keydown', handleKeys);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [wrapperRef.current]);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,16 @@ import { DualListSelectorListContext } from './DualListSelectorContext';
/** Acts as the container for DualListSelectorListItem sub-components. */

export interface DualListSelectorListProps extends React.HTMLProps<HTMLUListElement> {
/** Content rendered inside the dual list selector list */
/** Content rendered inside the dual list selector list. */
children?: React.ReactNode;
}

export const DualListSelectorList: React.FunctionComponent<DualListSelectorListProps> = ({
children,
...props
}: DualListSelectorListProps) => {
const {
setFocusedOption,
isTree,
ariaLabelledBy,
focusedOption,
displayOption,
selectedOptions,
id,
onOptionSelect,
options,
isDisabled
} = React.useContext(DualListSelectorListContext);

// only called when options are passed via options prop
const onOptionClick = (e: React.MouseEvent | React.ChangeEvent | React.KeyboardEvent, index: number, id: string) => {
setFocusedOption(id);
onOptionSelect(e, index, id);
};
const { isTree, ariaLabelledBy, focusedOption, displayOption, selectedOptions, id, options, isDisabled } =
React.useContext(DualListSelectorListContext);

const hasOptions = () =>
options.length !== 0 || (children !== undefined && (children as React.ReactNode[]).length !== 0);
Expand All @@ -58,7 +42,6 @@ export const DualListSelectorList: React.FunctionComponent<DualListSelectorListP
key={index}
isSelected={(selectedOptions as number[]).indexOf(index) !== -1}
id={`${id}-option-${index}`}
onOptionSelect={(e, id) => onOptionClick(e, index, id)}
orderIndex={index}
isDisabled={isDisabled}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export interface DualListSelectorListItemProps extends React.HTMLProps<HTMLLIEle
className?: string;
/** Flag indicating the list item is currently selected. */
isSelected?: boolean;
/** Callback fired when an option is selected. */
/** Callback fired when an option is selected. */
onOptionSelect?: (event: React.MouseEvent | React.ChangeEvent | React.KeyboardEvent, id?: string) => void;
/** ID of the option. */
id?: string;
/** @hide Internal field used to keep track of order of unfiltered options. */
orderIndex?: number;
/** @hide Forwarded ref */
innerRef?: React.RefObject<HTMLLIElement>;
/** Flag indicating this item is draggable for reordring */
/** Flag indicating this item is draggable for reordering. */
isDraggable?: boolean;
/** Accessible label for the draggable button on draggable list items */
/** Accessible label for the draggable button on draggable list items. */
draggableButtonAriaLabel?: string;
/** Flag indicating if the dual list selector is in a disabled state */
/** Flag indicating if the dual list selector is in a disabled state. */
isDisabled?: boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,19 @@ import { DualListSelectorContext, DualListSelectorListContext } from './DualList
export interface DualListSelectorListWrapperProps extends React.HTMLProps<HTMLDivElement> {
/** Additional classes applied to the dual list selector. */
className?: string;
/** Anything that can be rendered inside of the list */
/** Anything that can be rendered inside of the list. */
children?: React.ReactNode;
/** Id of the dual list selector list */
/** ID of the dual list selector list. */
id?: string;
/** Accessibly label for the list */
/** Accessibly label for the list. */
'aria-labelledby': string;
/** @hide forwarded ref */
innerRef?: React.RefObject<HTMLDivElement>;
/** @hide Options to list in the pane. */
options?: React.ReactNode[];
/** @hide Options currently selected in the pane. */
selectedOptions?: string[] | number[];
/** @hide Callback for when an option is selected. Optionally used only when options prop is provided. */
onOptionSelect?: (e: React.MouseEvent | React.ChangeEvent | React.KeyboardEvent, index: number, id: string) => void;
/** @hide Function to determine if an option should be displayed depending on a dynamically built filter value */
/** @hide Function to determine if an option should be displayed depending on a custom filter value. */
displayOption?: (option: React.ReactNode) => boolean;
/** Flag indicating whether the component is disabled. */
isDisabled?: boolean;
Expand All @@ -35,7 +33,6 @@ export const DualListSelectorListWrapperBase: React.FunctionComponent<DualListSe
innerRef,
options = [],
selectedOptions = [],
onOptionSelect,
displayOption,
id = getUniqueId('dual-list-selector-list'),
isDisabled = false,
Expand All @@ -46,8 +43,7 @@ export const DualListSelectorListWrapperBase: React.FunctionComponent<DualListSe
const menuRef = innerRef || ref;
const { isTree } = React.useContext(DualListSelectorContext);

// sets up keyboard focus handling for the dual list selector menu child of the pane. This keyboard
// handling is applied whether the pane is dynamically built or passed via the children prop.
// Sets up keyboard focus handling for the dual list selector menu child of the pane.
const handleKeys = (event: KeyboardEvent) => {
if (
!menuRef.current ||
Expand Down Expand Up @@ -94,6 +90,7 @@ export const DualListSelectorListWrapperBase: React.FunctionComponent<DualListSe
return () => {
window.removeEventListener('keydown', handleKeys);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [menuRef.current]);

return (
Expand All @@ -108,7 +105,6 @@ export const DualListSelectorListWrapperBase: React.FunctionComponent<DualListSe
selectedOptions,
id,
options,
onOptionSelect,
isDisabled
}}
>
Expand Down
Loading
Loading