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

Potential forward ref #1134

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"react-text-mask": "~5.0.2",
"react-transition-group": "^2.9.0",
"react-use": "^17.3.2",
"reactstrap": "^9.1.5",
"reactstrap": "9.1.6-v10-f1a1f7e.0",
"styled-jsx": "^3.3.2",
"text-mask-addons": "^3.8.0",
"tributejs": "^5.1.3",
Expand Down
1 change: 1 addition & 0 deletions src/components/Activity/Activity.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ interface ActivityProps extends Omit<ListGroupItemProps, 'action'> {
* Extension to Bootstrap [ListGroupItem](https://getbootstrap.com/docs/4.3/components/list-group-item/)
* representing a timeline event.
*/
// Forward ref
const Activity: FC<ActivityProps> = ({
action,
by,
Expand Down
1 change: 1 addition & 0 deletions src/components/Activity/ActivityLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ListGroup, ListGroupProps } from 'reactstrap';
* Extension to Bootstrap [ListGroup](https://getbootstrap.com/docs/4.3/components/list-group/)
* for listing a timeline of Activities
*/
// Passes in ref
const ActivityLog: FC<ListGroupProps> = ({ children, ...props }) => (
<ListGroup {...props}>{children}</ListGroup>
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Address/CountryInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const defaultProps = {
onChange: () => {},
};

// Forwards ref
const CountryInput: FC<CountryInputProps> = ({
onChange = defaultProps.onChange,
...otherProps
Expand Down
1 change: 1 addition & 0 deletions src/components/Address/StateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const defaultProps = {
onChange: () => {},
};

// Forwards ref
const StateInput: FC<StateInputProps> = ({
className,
countries = defaultProps.countries,
Expand Down
1 change: 1 addition & 0 deletions src/components/Alert/Alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ type Props = {
* Extension to Bootstrap [Alert](https://getbootstrap.com/docs/4.3/components/alert/)
* adding icon support and onToggle callback when dismissed.
*/
// passes in ref potentially
const Alert: FC<Props> = ({
color = 'warning',
children,
Expand Down
1 change: 1 addition & 0 deletions src/components/BlockPanel/BlockPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const defaultProps = {
/**
* BlockPanel is an extension to Bootstrap Card, which allows for expand/collapse and standardized header.
*/
// Ref stuff
const BlockPanel: FC<BlockPanelProps> = ({
children,
className = defaultProps.className,
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/Close.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { FC } from 'react';

// Pass in ref here
const Close: FC<React.ComponentPropsWithoutRef<'button'>> = ({ className = '', ...props }) => (
<button type="button" className={`btn-close ${className}`} aria-label="Close" {...props} />
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Button/ConfirmationButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface ConfirmationButtonProps extends ButtonProps {

const defaultProps = { onClick: noop };

// Pass in ref here
const ConfirmationButton: FC<ConfirmationButtonProps> = ({
children,
confirmation,
Expand Down
1 change: 1 addition & 0 deletions src/components/Calendar/Calendar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ const defaultProps = {
weekDayFormat: 'dd',
};

// Pass in ref
const Calendar: FC<CalendarProps> = ({
date = defaultProps.date,
dateFormat = defaultProps.dateFormat,
Expand Down
1 change: 1 addition & 0 deletions src/components/Calendar/components/Day.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface DayProps
onClick: MouseEventHandler<HTMLTableCellElement>;
}

// Pass in ref
const Day: FC<DayProps> = ({ day, dateFormat, locale, onClick, ...props }) => {
const disabled = !day.enabled;
const classNames = classnames(
Expand Down
1 change: 1 addition & 0 deletions src/components/Callout/Callout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface CalloutProps extends HTMLProps<HTMLDivElement> {
placement: 'top' | 'bottom' | 'left' | 'right';
}

// forward ref maybe
const Callout = ({ className, color, background, placement, children, ...props }: CalloutProps) => (
<>
<div className={`callout text-${color} m${placement[0]}-5 ${className}`} {...props}>
Expand Down
1 change: 1 addition & 0 deletions src/components/Carousel/ImageCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import Icon from '../Icon/Icon';
import Modal from '../Modal/Modal';
import UncontrolledCarousel from './UncontrolledCarousel';

// ref stuff
export default class ImageCarousel extends React.Component {
static propTypes = {
items: PropTypes.array.isRequired,
Expand Down
1 change: 1 addition & 0 deletions src/components/Carousel/UncontrolledCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const propTypes = {
goToIndex: PropTypes.func,
};

// Forward ref
class UncontrolledCarousel extends Component {
constructor(props) {
super(props);
Expand Down
1 change: 1 addition & 0 deletions src/components/Checkbox/CheckboxBooleanInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ function getID() {
return `checkbox-boolean-input-${count++}`;
}

// Forwards ref
class CheckboxBooleanInput extends React.Component<CheckboxBooleanInputProps> {
static propTypes = {
id: PropTypes.string,
Expand Down
1 change: 1 addition & 0 deletions src/components/Checkbox/CheckboxInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import CheckboxListInput, { CheckboxListInputProps } from './CheckboxListInput';

type CheckboxInputProps = CheckboxListInputProps | CheckboxBooleanInputProps;

// Forward ref
const CheckboxInput: FC<CheckboxInputProps> = (props) =>
props.children ? (
<CheckboxListInput {...(props as CheckboxListInputProps)} />
Expand Down
2 changes: 2 additions & 0 deletions src/components/Checkbox/CheckboxListInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export interface CheckboxListInputProps {
value?: string[];
}

// Forward ref

class CheckboxListInput extends React.Component<CheckboxListInputProps> {
static propTypes = {
children: PropTypes.node,
Expand Down
1 change: 1 addition & 0 deletions src/components/ClickableContainer/ClickableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface ContainerProps extends HTMLAttributes<HTMLElement> {
/**
* Accessible generic container component that responds to click events
* */
// Maybe forward ref
const ClickableContainer: FC<ContainerProps> = ({
className,
onClick,
Expand Down
2 changes: 2 additions & 0 deletions src/components/Combobox/Combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ type OptionGroup<T> = {
options: Option<T>[];
};

// Forward ref

interface ComboboxProps<T> extends Omit<InputProps, 'onChange'> {
options: Option<T>[] | OptionGroup<T>[];
direction?: Direction;
Expand Down
1 change: 1 addition & 0 deletions src/components/Datapair/Datapair.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface DatapairProps extends ComponentProps<typeof FormLabelGroup> {
* of two parts: the key (label) and a value. The key is an identifier for some form of data and
* the value can be text or links.
*/
// Forward ref
const Datapair: FC<DatapairProps> = ({ children, className, label, value, ...attributes }) => {
const classNames = classnames('js-datapair', className);
return (
Expand Down
1 change: 1 addition & 0 deletions src/components/Form/BoundForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import Form from './Form';

// ref and maybe get rid of comp
class BoundForm extends React.Component {
static propTypes = {
errors: PropTypes.object,
Expand Down
1 change: 1 addition & 0 deletions src/components/Form/FormChoice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ function getID() {
return `form-choice-${count++}`;
}

// Ref
class FormChoice extends React.Component {
static propTypes = {
inline: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions src/components/Form/FormGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import classnames from 'classnames';
import React from 'react';
import { FormGroup as RSFormGroup } from 'reactstrap';

// ref
const FormGroup = (props: any) => {
let className = 'form-group';
if (props.className) {
Expand Down
1 change: 1 addition & 0 deletions src/components/Form/FormRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type FormRowProps<T extends TypeProp> = Omit<
> &
BaseFormRowProps & { type?: T };

// ref
function FormRow<T extends TypeProp>({
children,
feedback = '',
Expand Down
1 change: 1 addition & 0 deletions src/components/HasManyFields/HasManyFieldsAdd.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React from 'react';
import Button from '../Button/Button';
import Icon from '../Icon/Icon';

// ref
const HasManyFieldsAdd = ({ children, className, ...props }) => {
const classes = classNames('border-0', className);

Expand Down
1 change: 1 addition & 0 deletions src/components/HasManyFields/HasManyFieldsRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function getID() {
return `hmf-${(count += 1)}`; // eslint-disable-line no-return-assign
}

// ref
interface HasManyFieldsRowProps {
children: React.ReactNode;
className?: string;
Expand Down
1 change: 1 addition & 0 deletions src/components/HelpBubble/HelpBubble.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const style = {
cursor: 'pointer',
};

// ref
function HelpBubble(props: HelpBubbleProps) {
const idRef = useRef<string | undefined>();
if (!idRef.current) {
Expand Down
1 change: 1 addition & 0 deletions src/components/Icon/FontAwesomeAPM.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export interface FontAwesomeAPMProps extends React.HTMLAttributes<any> {
* @module FontAwesome
* @type {ReactClass}
*/
// ref
export default class FontAwesomeAPM extends React.Component<FontAwesomeAPMProps> {
render() {
const {
Expand Down
1 change: 1 addition & 0 deletions src/components/Icon/Icon.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from 'react';
import FontAwesomeAPM, { FontAwesomeAPMProps } from './FontAwesomeAPM';

// ref
const Icon: FC<FontAwesomeAPMProps> = (props) => <FontAwesomeAPM {...props} />;

Icon.displayName = 'Icon';
Expand Down
1 change: 1 addition & 0 deletions src/components/InfoBox/InfoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface InfoBoxProps extends Omit<React.HTMLProps<HTMLDivElement>, 'className'
vertical?: boolean;
}

// ref
const InfoBox = ({
children,
className,
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/CreditCardNumber.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const defaultProps = {
onChange: () => {},
};

// ref
const CreditCardNumber: FC<CreditCardNumberProps> = ({
types = defaultProps.types,
onChange = defaultProps.onChange,
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/CurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ const CurrencyInput: FC<Props> = ({
(maskedProps as any).inputRef = innerRef;
}

// ref
return (
<InputGroup size={size} className={className}>
<InputGroupText>$</InputGroupText>
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/DateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ export default class DateInput extends React.Component {

// <DropdownToggle tag="div" disabled> is to wrap the input in a container for positioning dropdown/up, without breaking showOnFocus
// TODO extract a DropdownInput component that can encapsulate the defaultValue/value controlled/uncontrolled behavior.
// ref
return (
<div>
<Dropdown direction={direction} isOpen={!disabled && open} toggle={this.toggle}>
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/FileInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const FileInput = (props: FileInputProps) => {
onChange?.(files);
};

// ref
return <Input {...props} type="file" onChange={handleChange} />;
};

Expand Down
1 change: 1 addition & 0 deletions src/components/Input/MaskedInput.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from 'react';
import MaskedInputBase, { MaskedInputProps } from 'react-text-mask';

// ref
const MaskedInput: FC<MaskedInputProps> = ({ guide = false, ...props }) => (
<MaskedInputBase className="form-control" guide={guide} {...props} />
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/MonthInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ function parseValue(defaultValue, dateFormat, parseDate) {
return date;
}

// ref
export default class MonthInput extends React.Component {
static propTypes = {
centerYearSelection: PropTypes.bool,
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/PatternInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class PatternInput extends React.Component {
}
};

// ref
render() {
/* eslint-disable-next-line @typescript-eslint/no-unused-vars -- This should go away when converting to function component */
const { pattern, restrictInput, ...inputProps } = this.props;
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/StaticInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export interface StaticInputProps extends InputProps {
children?: React.ReactNode;
}

// ref
/* eslint-disable-next-line @typescript-eslint/no-unused-vars -- Figure out a better way to omit children (will need a reusable solution) */
const StaticInput: FC<StaticInputProps> = ({ children, ...props }) => (
<Input {...props} type="text" plaintext />
Expand Down
1 change: 1 addition & 0 deletions src/components/Input/TimeInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ export default class TimeInput extends React.Component {
} = this.props;
/* eslint-enable @typescript-eslint/no-unused-vars */

// ref
const times = this.times();

return (
Expand Down
1 change: 1 addition & 0 deletions src/components/List/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function List<T extends Item>({

const showHeader = header || select === 'checkbox' || select === 'switch' || onFilter || onSort;

// ref
return (
<ListGroup flush={flush} tag="div" {...props}>
{showHeader && (
Expand Down
1 change: 1 addition & 0 deletions src/components/List/ListGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ type Props = {
striped?: boolean;
} & ListGroupProps;

// ref
const ListGroup: FC<Props> = ({ className, striped, ...props }) => (
<ListGroupComponent
className={classnames(className, { 'list-group-striped': striped })}
Expand Down
1 change: 1 addition & 0 deletions src/components/List/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ function ListItem<T>({

const unselectedColor = (expanded && expandedColor) || color;

// ref
return (
<ListGroupItem
color={selected ? 'primary' : unselectedColor}
Expand Down
1 change: 1 addition & 0 deletions src/components/List/SortableList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function SortableList<T>({
setAscending(sortBy?.ascending);
};

// ref
return (
<List
filter={filter}
Expand Down
1 change: 1 addition & 0 deletions src/components/List/components/FilterHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export interface FilterHeaderProps
onChange?: (value: string) => void;
}

// ref
const FilterHeader = ({ value, onChange, className, id, ...props }: FilterHeaderProps) => {
const [filterId] = useState(() => uniqueId('filter-'));
return (
Expand Down
1 change: 1 addition & 0 deletions src/components/Modal/Modal.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Modal } from 'reactstrap';

// ref lookup
Modal.defaultProps = {
...Modal.defaultProps,
backdrop: false,
Expand Down
1 change: 1 addition & 0 deletions src/components/MultiSelectCombobox/MultiSelectCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ interface MultiSelectComboboxProps<T extends ComboboxOption>
extends Partial<UncontrolledMultiSelectComboboxProps<T>>,
Partial<ComboboxWrapperProps> {}

// ref
function MultiSelectCombobox<T extends ComboboxOption>({
children,
onChange,
Expand Down
1 change: 1 addition & 0 deletions src/components/Placeholder/Placeholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface PlaceholderProps extends Omit<HTMLProps<HTMLDivElement>, 'size'> {
words?: number;
}

// ref
const Placeholder = ({
className,
color,
Expand Down
1 change: 1 addition & 0 deletions src/components/Popover/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from 'react';
import { Popover as PopoverInternal, PopoverProps } from 'reactstrap';

// ref
const Popover: FC<PopoverProps> = ({ fade = false, trigger = 'legacy', ...props }) => (
<PopoverInternal fade={fade} trigger={trigger} {...props} />
);
Expand Down
1 change: 1 addition & 0 deletions src/components/Popover/PopoverHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { FC } from 'react';
import { PopoverHeaderProps, PopoverHeader as InternalPopoverHeader } from 'reactstrap';

// ref
const PopoverHeader: FC<PopoverHeaderProps> = ({ tag = 'h4', ...props }) => (
<InternalPopoverHeader tag={tag} {...props} />
);
Expand Down
Loading