@charcoal-ui/react 4.4.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@charcoal-ui/react",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.esm.js",
@@ -49,7 +49,7 @@
49
49
  "tsup": "^6.5.0",
50
50
  "typescript": "^4.9.5",
51
51
  "vitest": "^2.0.1",
52
- "@charcoal-ui/esbuild-plugin-styled-components": "4.4.1"
52
+ "@charcoal-ui/esbuild-plugin-styled-components": "4.5.0"
53
53
  },
54
54
  "dependencies": {
55
55
  "@react-aria/button": "^3.9.1",
@@ -67,10 +67,10 @@
67
67
  "react-spring": "^9.0.0",
68
68
  "react-stately": "^3.26.0",
69
69
  "warning": "^4.0.3",
70
- "@charcoal-ui/foundation": "4.4.1",
71
- "@charcoal-ui/icons": "4.4.1",
72
- "@charcoal-ui/utils": "4.4.1",
73
- "@charcoal-ui/theme": "4.4.1"
70
+ "@charcoal-ui/foundation": "4.5.0",
71
+ "@charcoal-ui/icons": "4.5.0",
72
+ "@charcoal-ui/theme": "4.5.0",
73
+ "@charcoal-ui/utils": "4.5.0"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "react": ">=17.0.0",
@@ -1,6 +1,10 @@
1
1
  import { useEffect } from 'react'
2
2
 
3
- export function usePreventScroll(element: HTMLElement | null, isOpen: boolean) {
3
+ export function usePreventScroll(
4
+ element: HTMLElement | null,
5
+ isOpen: boolean,
6
+ useClip = false
7
+ ) {
4
8
  useEffect(() => {
5
9
  if (isOpen && element) {
6
10
  const defaultPaddingRight = element.style.paddingRight
@@ -8,11 +12,11 @@ export function usePreventScroll(element: HTMLElement | null, isOpen: boolean) {
8
12
  element.style.paddingRight = `${
9
13
  window.innerWidth - element.clientWidth
10
14
  }px`
11
- element.style.overflow = 'hidden'
15
+ element.style.overflow = useClip ? 'clip' : 'hidden'
12
16
  return () => {
13
17
  element.style.paddingRight = defaultPaddingRight
14
18
  element.style.overflow = defaultOverflow
15
19
  }
16
20
  }
17
- }, [element, isOpen])
21
+ }, [element, isOpen, useClip])
18
22
  }
@@ -1,6 +1,6 @@
1
1
  import { useContext, forwardRef, memo } from 'react'
2
2
  import * as React from 'react'
3
- import { AriaModalOverlayProps, Overlay } from '@react-aria/overlays'
3
+ import { Overlay } from '@react-aria/overlays'
4
4
  import type { AriaDialogProps } from '@react-types/dialog'
5
5
  import { animated, useTransition, easings } from 'react-spring'
6
6
  import Button, { ButtonProps } from '../Button'
@@ -9,6 +9,7 @@ import { useObjectRef } from '@react-aria/utils'
9
9
  import { Dialog } from './Dialog'
10
10
  import { ModalBackgroundContext } from './ModalBackgroundContext'
11
11
  import {
12
+ CharcoalModalOverlayProps,
12
13
  useCharcoalModalOverlay,
13
14
  useWindowWidth,
14
15
  } from './useCustomModalOverlay'
@@ -18,7 +19,7 @@ import './index.css'
18
19
  export type BottomSheet = boolean | 'full'
19
20
  export type Size = 'S' | 'M' | 'L'
20
21
 
21
- export type ModalProps = AriaModalOverlayProps &
22
+ export type ModalProps = CharcoalModalOverlayProps &
22
23
  AriaDialogProps & {
23
24
  children: React.ReactNode
24
25
  zIndex?: number
@@ -13,8 +13,11 @@ import { usePreventScroll } from '../DropdownSelector/Popover/usePreventScroll'
13
13
  * but `useModalOverlay` (specifically, `useOverlay` within it) detects pointer events on the scrollbar.
14
14
  * Therefore, to prevent this issue, we need to override `shouldCloseOnInteractOutside` in `useModalOverlay`.
15
15
  */
16
+ export type CharcoalModalOverlayProps = AriaModalOverlayProps & {
17
+ overflowClip?: boolean
18
+ }
16
19
  export function useCharcoalModalOverlay(
17
- props: AriaModalOverlayProps,
20
+ props: CharcoalModalOverlayProps,
18
21
  state: { isOpen: boolean; onClose: () => void },
19
22
  ref: React.RefObject<HTMLElement | null>
20
23
  ): ModalOverlayAria {
@@ -30,7 +33,8 @@ export function useCharcoalModalOverlay(
30
33
 
31
34
  usePreventScroll(
32
35
  typeof document !== 'undefined' ? document.body : null,
33
- state.isOpen
36
+ state.isOpen,
37
+ props.overflowClip
34
38
  )
35
39
 
36
40
  useOverlayFocusContain()