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

refactor: Remove @adobe/react-spectrum imports where prohibited #2198

Merged
merged 2 commits into from
Aug 23, 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
7 changes: 5 additions & 2 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ module.exports = {
},
{
name: '@adobe/react-spectrum',
message:
'Import from @deephaven/components instead of @adobe/react-spectrum.',
message: `Import from ${
packageName === '@deephaven/components'
? './spectrum'
: '@deephaven/components'
} instead of @adobe/react-spectrum.`,
},
],
},
Expand Down
1 change: 1 addition & 0 deletions packages/app-utils/src/plugins/remote-component.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import react from 'react';
import * as redux from 'redux';
import * as reactRedux from 'react-redux';
import ReactDOM from 'react-dom';
// eslint-disable-next-line no-restricted-imports
import * as AdobeReactSpectrum from '@adobe/react-spectrum';
import * as DeephavenAuthPlugins from '@deephaven/auth-plugins';
import * as DeephavenChart from '@deephaven/chart';
Expand Down
1 change: 1 addition & 0 deletions packages/code-studio/src/styleguide/GotoTopButton.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { useCallback, useEffect } from 'react';
// eslint-disable-next-line no-restricted-imports
import { Button, Icon } from '@adobe/react-spectrum';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { vsChevronUp } from '@deephaven/icons';
Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/styleguide/Grids.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '@deephaven/grid';
import { IrisGrid } from '@deephaven/iris-grid';
import { useApi } from '@deephaven/jsapi-bootstrap';
import { Flex } from '@adobe/react-spectrum';
import { Flex } from '@deephaven/components';
import MockIrisGridTreeModel from './MockIrisGridTreeModel';
import StaticExample from './grid-examples/StaticExample';
import QuadrillionExample from './grid-examples/QuadrillionExample';
Expand Down
3 changes: 1 addition & 2 deletions packages/code-studio/src/styleguide/Icons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ import {
dhSquareFilled,
dhAddSmall,
} from '@deephaven/icons';
import { Icon } from '@adobe/react-spectrum';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Button } from '@deephaven/components';
import { Button, Icon } from '@deephaven/components';
import PropTypes from 'prop-types';
import SampleSection from './SampleSection';

Expand Down
2 changes: 1 addition & 1 deletion packages/code-studio/src/styleguide/Pickers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
ComboBox,
ComboBoxNormalized,
Flex,
Icon,
Item,
ItemKey,
PICKER_ITEM_HEIGHTS,
Expand All @@ -14,7 +15,6 @@ import {
Text,
} from '@deephaven/components';
import { vsPerson } from '@deephaven/icons';
import { Icon } from '@adobe/react-spectrum';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { getPositionOfSelectedItem } from '@deephaven/react-hooks';
import { generateItemElements, generateNormalizedItems } from './utils';
Expand Down
1 change: 1 addition & 0 deletions packages/code-studio/src/styleguide/SamplesMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React, { Key, useCallback, useEffect, useState } from 'react';
// eslint-disable-next-line no-restricted-imports
import {
ActionButton,
Icon,
Expand Down
1 change: 1 addition & 0 deletions packages/code-studio/src/styleguide/SpectrumComparison.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react/style-prop-object */
import React, { Fragment, useState } from 'react';
// eslint-disable-next-line no-restricted-imports
import {
ActionButton,
Button,
Expand Down
1 change: 1 addition & 0 deletions packages/code-studio/src/styleguide/SpectrumComponents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable react/style-prop-object */
import React from 'react';
// eslint-disable-next-line no-restricted-imports
import {
ActionButton,
Button,
Expand Down
2 changes: 1 addition & 1 deletion packages/components/src/BulkActionBar.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionBar } from '@adobe/react-spectrum';
import type { StyleProps } from '@react-types/shared';
import { ActionBar } from './spectrum';
import commonStyles from './SpectrumComponent.module.scss';

export interface BulkActionBarProps {
Expand Down
6 changes: 3 additions & 3 deletions packages/components/src/SearchableCombobox.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable react/jsx-props-no-spreading */
import { Key, useCallback } from 'react';
import { ComboBox, Item, SpectrumComboBoxProps } from '@adobe/react-spectrum';
import type { DOMRefValue, FocusableRef } from '@react-types/shared';
import { SpectrumComboBox, Item, SpectrumComboBoxProps } from './spectrum';
import TextWithTooltip from './TextWithTooltip';

export interface SearchableComboboxProps<TItem, TKey extends Key>
Expand Down Expand Up @@ -36,7 +36,7 @@ export function SearchableCombobox<TItem, TKey extends Key>({
);

return (
<ComboBox
<SpectrumComboBox
{...props}
// The `ref`prop type defined by React Spectrum is incorrect here
ref={scrollRef as unknown as FocusableRef<HTMLElement>}
Expand All @@ -46,7 +46,7 @@ export function SearchableCombobox<TItem, TKey extends Key>({
onSelectionChange={props.onSelectionChange as (key: Key | null) => void}
>
{renderItem}
</ComboBox>
</SpectrumComboBox>
);
}

Expand Down
7 changes: 1 addition & 6 deletions packages/components/src/TableViewEmptyState.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { useEffect, useState } from 'react';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import {
Content,
Heading,
Icon,
IllustratedMessage,
} from '@adobe/react-spectrum';
import { vsEmptyWindow } from '@deephaven/icons';
import { Content, Heading, Icon, IllustratedMessage } from './spectrum';

const DEFAULT_DELAY_MS = 500;

Expand Down
8 changes: 2 additions & 6 deletions packages/components/src/actions/IconActionButton.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/* eslint-disable react/jsx-props-no-spreading */
import {
ActionButton,
Icon,
SpectrumActionButtonProps,
} from '@adobe/react-spectrum';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import type { IconProp } from '@fortawesome/fontawesome-svg-core';
import { ActionButton, Icon, ActionButtonProps } from '../spectrum';
import { Tooltip } from '../popper';
import { ACTION_ICON_HEIGHT } from '../UIConstants';

export interface IconActionButtonProps
extends Omit<SpectrumActionButtonProps, 'aria-label' | 'isQuiet' | 'height'> {
extends Omit<ActionButtonProps, 'aria-label' | 'isQuiet' | 'height'> {
icon: IconProp;
label: string;
tooltip?: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ReactElement } from 'react';
import { ActionButton, DialogTrigger, Icon } from '@adobe/react-spectrum';
import type { SpectrumDialogClose } from '@react-types/dialog';
import type { StyleProps } from '@react-types/shared';
import type { IconDefinition } from '@fortawesome/fontawesome-common-types';
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
import { Text } from '../spectrum';
import { ActionButton, DialogTrigger, Icon, Text } from '../spectrum';
import { Tooltip } from '../popper';

export interface ActionButtonDialogTriggerProps extends StyleProps {
Expand Down
18 changes: 9 additions & 9 deletions packages/components/src/dialogs/ConfirmationDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
/* eslint-disable react/jsx-props-no-spreading */
import { ReactElement, ReactNode } from 'react';
import type { SpectrumLabelableProps } from '@react-types/shared';
bmingles marked this conversation as resolved.
Show resolved Hide resolved
import { useFormWithDetachedSubmitButton } from '@deephaven/react-hooks';
import {
Button,
SpectrumButton,
ButtonGroup,
Content,
Dialog,
Divider,
Form,
} from '@adobe/react-spectrum';
import type { SpectrumLabelableProps } from '@react-types/shared';
import { useFormWithDetachedSubmitButton } from '@deephaven/react-hooks';
import { Heading } from '../spectrum';
Heading,
} from '../spectrum';
import styles from '../SpectrumComponent.module.scss';

export interface ConfirmationDialogProps {
Expand Down Expand Up @@ -50,10 +50,10 @@ export function ConfirmationDialog({
</Form>
</Content>
<ButtonGroup>
<Button variant="secondary" onPress={onCancel}>
<SpectrumButton variant="secondary" onPress={onCancel}>
Cancel
</Button>
<Button
</SpectrumButton>
<SpectrumButton
{...submitButtonProps}
// eslint-disable-next-line react/style-prop-object
style="fill"
Expand All @@ -62,7 +62,7 @@ export function ConfirmationDialog({
type="submit"
>
{confirmationButtonLabel}
</Button>
</SpectrumButton>
</ButtonGroup>
</Dialog>
);
Expand Down
2 changes: 2 additions & 0 deletions packages/components/src/spectrum/comboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { PickerPropsT, usePickerProps } from '../picker';

export type ComboBoxProps = PickerPropsT<SpectrumComboBoxProps<NormalizedItem>>;

export { SpectrumComboBox };

export const ComboBox = React.forwardRef(function ComboBox(
{ UNSAFE_className, ...props }: ComboBoxProps,
ref: DOMRef<HTMLDivElement>
Expand Down
1 change: 1 addition & 0 deletions packages/react-hooks/src/SpectrumUtils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// eslint-disable-next-line no-restricted-imports
import type { SpectrumTextFieldProps } from '@adobe/react-spectrum';
import { KeyedItem } from '@deephaven/utils';
import type { DOMRefValue } from '@react-types/shared';
Expand Down
3 changes: 2 additions & 1 deletion packages/react-hooks/src/useWindowedListData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ListData } from '@adobe/react-spectrum';
// eslint-disable-next-line no-restricted-imports
import type { ListData } from '@adobe/react-spectrum';
import { Key, useCallback, useMemo, useState } from 'react';

/**
Expand Down
Loading