Skip to content

Commit

Permalink
React18_integration_FINAL_v3 (#1926)
Browse files Browse the repository at this point in the history
* adding back everything

* update mdx-js package, update storybook peerDep react version

* React.PropsWithChildren changeset

* add transition changeset

* formfooter changeset

* guidecue changeset

* lib changeset

* modal changeset

* numberInput changeset

* remove position utils exports

* portal changeset

* revert search-input change

* segmented-control changeset

* side-nav changeset

* guide-cue and side-nav changeset tweaks

* side nav cs updates

* add ticket to fail table skeleton test

* table changeset

* tooltip changeset

* typo

* changeset changes and modal changes

* portal patch to major

* fix some combobox tests

* remove PropsWithChildren from Icon

* missed some PropsWithChildren in Icon

* remove PropsWithChildren from Logo

* rm disabled from menu story

* add back focus-visible to menu

* missed one

* remove PropsWithChildren from passeordInput and pipepline

* tooltip changeset

* tooltip changeset again

* changeset for tools/build

* number input changeset

* test that first menu item is focused

* menu, return single value instead of object

* update polymorphic error comment

* poly and guideCcue comments

* guideCue comments

* transition types updates

* var for index

* tooltip tests

* updates submenu types, builds in react17/18

* React18 select internal props (#1927)

* update select to accept internal props

* fix

* update changeset

* updates changesets

* react transition group changeset

* code changeset

* combobox changeset

* icon changeset

* lib changetset

* update lib changeset

* select changeset

* testing-lib changeset

* tooltip changeset

* storybook tools changeset

* update storybook changeset

* fix lint

* fix checks?

* add internal prop to skipProps

* testing

* test changesets

* update changesets

* remove number-input CustomSelectMenuButton

* update __INTERNAL__menuButtonSlotProps__ type

* add focusTrapOptions type

* revert menu changes

* fix TS error

* remoe table todo

* fix validate errors

* fix syntax

* remove disabled from headerRow story

* remove table README changeset
  • Loading branch information
shaneeza authored Aug 22, 2023
1 parent 8e06bb2 commit 4fcf2e9
Show file tree
Hide file tree
Showing 117 changed files with 2,918 additions and 5,522 deletions.
5 changes: 5 additions & 0 deletions .changeset/angry-rice-reply.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/form-footer': patch
---

Updates `PrimaryButton` type from `React.ReactChild` to `React.ReactElement`.
5 changes: 5 additions & 0 deletions .changeset/beige-books-fly.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/testing-lib': patch
---

Fixes `isPromiseLike` TS errors
5 changes: 5 additions & 0 deletions .changeset/cold-planes-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/portal': major
---

Modified the ReactDOM peerDependency to ensure compatibility with either version 17 or 18.
5 changes: 5 additions & 0 deletions .changeset/cuddly-donkeys-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/icon': patch
---

Updates internal function, `isComponentGlyph`
5 changes: 5 additions & 0 deletions .changeset/curvy-cheetahs-tap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/lib': patch
---

Updates helper function, `isComponentType` and updates `ExtendedComponentProps` type.
5 changes: 5 additions & 0 deletions .changeset/cyan-squids-kick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/build': patch
---

adds `@babel/core` as a peerDependency.
5 changes: 5 additions & 0 deletions .changeset/dull-meals-press.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/segmented-control': patch
---

Refactor internal function `childrenIdList`.
5 changes: 5 additions & 0 deletions .changeset/eleven-trees-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/combobox': patch
---

Type assert children as `Array<React.ReactNode>` inside the internal function `renderedMenuContents` and add explicit return type to internal function `renderCombobox`.
7 changes: 7 additions & 0 deletions .changeset/forty-crews-promise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/guide-cue': major
---

Downgrades `focus-trap-react` package to `^9.0.2` so that tests still pass without requiring the use of the `fallbackFocus` option on the `<FocusTrap>` component.

Refactors multi-step guideCue so that the tooltip no longer uses a portal, as React 18 displays the tooltip in the wrong position when the viewport changes.
7 changes: 7 additions & 0 deletions .changeset/friendly-planets-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/tooltip': patch
---

Adds the `setOpen()` state update inside `onMouseEnter` inside the [flushSync](https://react.dev/reference/react-dom/flushSync) callback to prevent batch updates in React 18. This addresses an issue where the tooltip would occasionally appear without a transition, particularly when hovering. This should have no impact on behavior in React 17.

Adds an additional check, `isValidElement(trigger)` when checking if the trigger is a LeafyGreenUI Icon or Glyph component.
5 changes: 5 additions & 0 deletions .changeset/good-deers-repeat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/menu': patch
---

Internally refactored how we deal with refs to a Menu component's children to better handle keyboard navigation.
5 changes: 5 additions & 0 deletions .changeset/grumpy-bats-protect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/storybook-decorators': minor
---

Move `@leafygreen-ui/leafygreen-provider` inside `peerDependencies`.
5 changes: 5 additions & 0 deletions .changeset/mean-cats-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/select': patch
---

Bumps `@types/react-is` and `react-is` to latest major version
8 changes: 8 additions & 0 deletions .changeset/ninety-rice-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@leafygreen-ui/expandable-card': patch
'@leafygreen-ui/checkbox': patch
'@leafygreen-ui/side-nav': patch
'@leafygreen-ui/table': patch
---

Adds a `nodeRef` to <Transition> to get rid of StrictMode warnings
5 changes: 5 additions & 0 deletions .changeset/popular-suits-wait.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/test': minor
---

Upgrade `jest` and `testing-library` packages to support React 18
7 changes: 7 additions & 0 deletions .changeset/quick-geckos-leave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/side-nav': major
---

Refactors the `CollapseToggle` tooltip so that it no longer uses a portal, as React 18 displays the tooltip in the wrong position when the side nav is toggled.

Refactor the internal function, `renderedChildren`.
5 changes: 5 additions & 0 deletions .changeset/red-pens-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/select': patch
---

Adds new internal prop, `__INTERNAL__menuButtonSlotProps__`.
6 changes: 6 additions & 0 deletions .changeset/selfish-bobcats-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@leafygreen-ui/guide-cue': patch
'@leafygreen-ui/modal': patch
---

Add `focusTrapOptions` type
7 changes: 7 additions & 0 deletions .changeset/selfish-phones-give.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@lg-tools/storybook': minor
---

Bump `@mdx-js/react` to the latest major version, `2.3.0`. This version will not work with React 17.

Modified the ReactDOM peerDependency to ensure compatibility with either version 17 or 18.
5 changes: 5 additions & 0 deletions .changeset/seven-panthers-battle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/lib': major
---

Modified the React peerDependency to ensure compatibility with either version 17 or 18.
5 changes: 5 additions & 0 deletions .changeset/shaggy-pears-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@lg-tools/storybook': patch
---

Modified the React peerDependency to ensure compatibility with either version 17 or 18.
6 changes: 6 additions & 0 deletions .changeset/sharp-timers-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@leafygreen-ui/number-input': patch
'@leafygreen-ui/code': patch
---

Move custom select menu button into separate components and passes custom select menu button props to new internal select prop, `__INTERNAL__menuButtonSlotProps__`.
5 changes: 5 additions & 0 deletions .changeset/silly-buttons-greet.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/modal': major
---

Upgrades `focus-trap-react` package to `^9.0.2` to maintain uniformity across other LG components using this package.
13 changes: 13 additions & 0 deletions .changeset/sour-ducks-change.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@leafygreen-ui/polymorphic': patch
'@leafygreen-ui/callout': patch
'@leafygreen-ui/banner': patch
'@leafygreen-ui/table': patch
'@leafygreen-ui/toast': patch
'@leafygreen-ui/logo': patch
'@leafygreen-ui/menu': patch
'@leafygreen-ui/box': patch
'@leafygreen-ui/lib': patch
---

Updates types with `React.PropsWithChildren`
5 changes: 5 additions & 0 deletions .changeset/spotty-onions-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@leafygreen-ui/code': patch
---

Updates LanguageSwitcher hover styles specificity to `&:hover[aria-disabled='false']`.
7 changes: 7 additions & 0 deletions .changeset/swift-deers-enjoy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/tooltip': patch
---

Updates `PopoverFunctionParameters` interface to use `PopoverAlign` alias.

Omit `children` from `PopoverProps` since it was overriding `Tooltip` children.
11 changes: 11 additions & 0 deletions .changeset/swift-rockets-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@leafygreen-ui/expandable-card': patch
'@leafygreen-ui/checkbox': patch
'@leafygreen-ui/popover': patch
'@leafygreen-ui/modal': patch
'@leafygreen-ui/table': patch
'@leafygreen-ui/toast': patch
'@leafygreen-ui/menu': patch
---

Bumps `react-transition-group` to `^4.4.5`.
7 changes: 7 additions & 0 deletions .changeset/two-games-carry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
'@leafygreen-ui/number-input': patch
---

Adds the `setOpen()` state update inside the [flushSync](https://react.dev/reference/react-dom/flushSync) callback to prevent batch updates in React 18. This addresses an issue where the unit tooltip would occasionally appear without a transition, particularly when hovering. This should have no impact on behavior in React 17.

Updates `README` code snippet.
16 changes: 16 additions & 0 deletions __mocks__/tabbable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// https://github.com/focus-trap/tabbable#testing-in-jsdom
const lib = jest.requireActual('tabbable');

const tabbable = {
...lib,
tabbable: (node, options) =>
lib.tabbable(node, { ...options, displayCheck: 'none' }),
focusable: (node, options) =>
lib.focusable(node, { ...options, displayCheck: 'none' }),
isFocusable: (node, options) =>
lib.isFocusable(node, { ...options, displayCheck: 'none' }),
isTabbable: (node, options) =>
lib.isTabbable(node, { ...options, displayCheck: 'none' }),
};

module.exports = tabbable;
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,32 +30,32 @@
"validate": "lg validate"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/core": "7.21.8",
"@changesets/cli": "^2.26.0",
"@lg-tools/cli": "*",
"@lg-tools/meta": "*",
"@lg-tools/slackbot": "*",
"@lg-tools/storybook": "*",
"@lg-tools/storybook-decorators": "*",
"@types/lodash": "^4.14.170",
"@types/react": "^16.9.56",
"@types/react-dom": "^16.9.9",
"@types/react-transition-group": "4.4.1",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
"@types/react-transition-group": "^4.4.6",
"chromatic": "^6.17.2",
"dotenv": "^10.0.0",
"gh-pages": "^3.1.0",
"npm-run-all": "^4.1.5",
"prop-types": "^15.7.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "5.2.0",
"storybook": "7.1.1",
"turbo": "^1.10.7",
"typescript": "~4.7.0"
},
"resolutions": {
"caniuse-lite": "^1.0.30001135",
"@types/react": "^16.9.56"
"@types/react-transition-group/@types/react": "^17.0.2"
},
"workspaces": [
"packages/*",
Expand Down
1 change: 1 addition & 0 deletions packages/banner/src/Banner.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const meta: StoryMetaType<typeof Banner> = {
dismissible: false,
},
argTypes: {
darkMode: storybookArgTypes.darkMode,
dismissible: {
control: 'boolean',
},
Expand Down
5 changes: 4 additions & 1 deletion packages/banner/src/BannerIcon/BannerIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ import {
} from './styles';
import BannerIconProps from './types';

const Icons: Record<Variant, React.ComponentType<any>> = {
const Icons: Record<
Variant,
React.ComponentType<React.PropsWithChildren<any>>
> = {
[Variant.Info]: InfoWithCircleIcon,
[Variant.Warning]: ImportantWithCircleIcon,
[Variant.Danger]: WarningIcon,
Expand Down
6 changes: 4 additions & 2 deletions packages/box/src/Box.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ type BoxComponent<TProps = {}, ExtraProps = {}> = Override2<
/**
* The component or HTML Element that the button is rendered as.
*/
as: React.ComponentType<TProps>;
as: React.ComponentType<React.PropsWithChildren<TProps>>;
},
ExtraProps
>;
Expand Down Expand Up @@ -115,7 +115,9 @@ export interface ExtendableBox<
ExtraProps,
Default extends React.ElementType = 'div',
> extends Pick<
React.FunctionComponent<BoxProps<Default, ExtraProps>>,
React.FunctionComponent<
React.PropsWithChildren<BoxProps<Default, ExtraProps>>
>,
'displayName' | 'propTypes'
> {
<TElement extends keyof JSX.IntrinsicElements>(
Expand Down
5 changes: 4 additions & 1 deletion packages/callout/src/Callout/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,10 @@ export const headerLabels: Record<Variant, string> = {
[Variant.Example]: 'Example',
} as const;

export const headerIcons: Record<Variant, React.ComponentType<any>> = {
export const headerIcons: Record<
Variant,
React.ComponentType<React.PropsWithChildren<any>>
> = {
[Variant.Note]: InfoWithCircleIcon,
[Variant.Tip]: BulbIcon,
[Variant.Important]: ImportantWithCircleIcon,
Expand Down
2 changes: 1 addition & 1 deletion packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@leafygreen-ui/palette": "^4.0.7",
"@leafygreen-ui/tokens": "^2.1.4",
"@leafygreen-ui/typography": "^16.5.4",
"react-transition-group": "^4.4.1"
"react-transition-group": "^4.4.5"
},
"peerDependencies": {
"@leafygreen-ui/leafygreen-provider": "^3.1.6"
Expand Down
5 changes: 4 additions & 1 deletion packages/checkbox/src/Check/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useRef } from 'react';
import { Transition } from 'react-transition-group';

import { usePrefersReducedMotion } from '@leafygreen-ui/a11y';
Expand Down Expand Up @@ -56,6 +56,8 @@ export function Check({
const showCheckIcon = indeterminate || isChecked;
const shouldAnimate = animate && !indeterminate && !prefersReducedMotion;

const transitionRef = useRef<HTMLElement | null>(null);

return (
<>
<div
Expand All @@ -72,6 +74,7 @@ export function Check({
timeout={prefersReducedMotion ? 0 : checkAnimationDuration}
enter={shouldAnimate}
exit={shouldAnimate}
nodeRef={transitionRef}
>
{state => (
<CheckSVG
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';

import Button, { ButtonProps } from '@leafygreen-ui/button';

/**
* Custom language switcher button.
*
* Passing down just the function which will be instantiated inside `Select`
* @internal
*/
export const CustomSelectMenuButton = React.forwardRef(
({ children, ...props }: ButtonProps, ref) => (
<Button {...props} ref={ref}>
{children}
</Button>
),
);

CustomSelectMenuButton.displayName = 'CustomSelectMenuButton';
1 change: 1 addition & 0 deletions packages/code/src/CustomSelectMenuButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { CustomSelectMenuButton } from './CustomSelectMenuButton';
Loading

0 comments on commit 4fcf2e9

Please sign in to comment.