@coreui/react 4.4.0 → 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.
Files changed (50) hide show
  1. package/README.md +1 -1
  2. package/dist/components/Types.d.ts +6 -6
  3. package/dist/components/button/CButton.d.ts +4 -3
  4. package/dist/components/carousel/CCarousel.d.ts +6 -0
  5. package/dist/components/dropdown/CDropdown.d.ts +3 -3
  6. package/dist/components/dropdown/CDropdownItem.d.ts +1 -1
  7. package/dist/components/form/CFormCheck.d.ts +1 -1
  8. package/dist/components/form/CFormControlWrapper.d.ts +6 -0
  9. package/dist/components/form/CFormLabel.d.ts +2 -2
  10. package/dist/components/form/CFormRange.d.ts +1 -1
  11. package/dist/components/form/CFormSelect.d.ts +1 -1
  12. package/dist/components/form/CInputGroupText.d.ts +2 -2
  13. package/dist/components/form/index.d.ts +3 -1
  14. package/dist/components/grid/CCol.d.ts +3 -3
  15. package/dist/components/grid/CRow.d.ts +1 -1
  16. package/dist/components/header/CHeaderBrand.d.ts +2 -2
  17. package/dist/components/link/CLink.d.ts +2 -2
  18. package/dist/components/list-group/CListGroupItem.d.ts +3 -3
  19. package/dist/components/nav/CNavLink.d.ts +1 -1
  20. package/dist/components/toast/CToastClose.d.ts +4 -1
  21. package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
  22. package/dist/index.es.js +652 -628
  23. package/dist/index.es.js.map +1 -1
  24. package/dist/index.js +944 -925
  25. package/dist/index.js.map +1 -1
  26. package/dist/utils/hooks/useForkedRef.d.ts +1 -1
  27. package/dist/utils/index.d.ts +2 -0
  28. package/dist/utils/isVisible.d.ts +2 -0
  29. package/package.json +9 -10
  30. package/src/components/button/CButton.tsx +3 -3
  31. package/src/components/carousel/CCarousel.tsx +38 -10
  32. package/src/components/form/CFormControlWrapper.tsx +20 -1
  33. package/src/components/form/CFormInput.tsx +2 -0
  34. package/src/components/form/CFormLabel.tsx +2 -2
  35. package/src/components/form/CFormRange.tsx +1 -1
  36. package/src/components/form/CFormSelect.tsx +2 -0
  37. package/src/components/form/CFormTextarea.tsx +2 -0
  38. package/src/components/form/CInputGroupText.tsx +3 -2
  39. package/src/components/form/__tests__/CFormRange.spec.tsx +2 -2
  40. package/src/components/form/__tests__/CInputGroupText.spec.tsx +9 -0
  41. package/src/components/form/__tests__/__snapshots__/CInputGroupText.spec.tsx.snap +11 -0
  42. package/src/components/form/index.ts +4 -0
  43. package/src/components/header/CHeaderBrand.tsx +3 -2
  44. package/src/components/link/CLink.tsx +2 -2
  45. package/src/components/list-group/CListGroupItem.tsx +2 -2
  46. package/src/components/modal/CModal.tsx +4 -1
  47. package/src/components/sidebar/CSidebar.tsx +1 -10
  48. package/src/components/toast/CToastClose.tsx +4 -1
  49. package/src/utils/index.ts +3 -0
  50. package/src/utils/isVisible.ts +11 -0
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- export declare type AssignableRef<ValueType> = {
2
+ export type AssignableRef<ValueType> = {
3
3
  bivarianceHack(instance: ValueType | null): void;
4
4
  }['bivarianceHack'] | React.MutableRefObject<ValueType | null>;
5
5
  export declare function useForkedRef<RefValueType = any>(...refs: (AssignableRef<RefValueType> | null | undefined)[]): ((node: any) => void) | null;
@@ -0,0 +1,2 @@
1
+ import isVisible from './isVisible';
2
+ export { isVisible };
@@ -0,0 +1,2 @@
1
+ declare const isVisible: (element: HTMLElement) => boolean;
2
+ export default isVisible;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coreui/react",
3
- "version": "4.4.0",
3
+ "version": "4.5.0",
4
4
  "description": "UI Components Library for React.js",
5
5
  "keywords": [
6
6
  "react",
@@ -32,16 +32,16 @@
32
32
  "src/"
33
33
  ],
34
34
  "scripts": {
35
- "build": "rollup -c"
35
+ "build": "rollup -c --bundleConfigAsCjs"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@popperjs/core": "^2.11.5",
39
- "@rollup/plugin-commonjs": "^22.0.2",
40
- "@rollup/plugin-node-resolve": "^13.3.0",
41
- "@rollup/plugin-typescript": "^8.5.0",
39
+ "@rollup/plugin-commonjs": "^23.0.7",
40
+ "@rollup/plugin-node-resolve": "^15.0.1",
41
+ "@rollup/plugin-typescript": "^10.0.1",
42
42
  "@testing-library/jest-dom": "^5.16.5",
43
43
  "@testing-library/react": "^13.4.0",
44
- "@types/react": "18.0.19",
44
+ "@types/react": "18.0.26",
45
45
  "@types/react-dom": "^18.0.6",
46
46
  "@types/react-transition-group": "^4.4.5",
47
47
  "classnames": "^2.3.2",
@@ -50,10 +50,9 @@
50
50
  "react-dom": "^18.2.0",
51
51
  "react-popper": "^2.2.5",
52
52
  "react-transition-group": "^4.4.5",
53
- "rollup": "^2.79.0",
54
- "rollup-plugin-peer-deps-external": "^2.2.4",
55
- "tslib": "^2.4.0",
56
- "typescript": "^4.8.3"
53
+ "rollup": "^3.7.5",
54
+ "tslib": "^2.4.1",
55
+ "typescript": "^4.9.4"
57
56
  },
58
57
  "peerDependencies": {
59
58
  "react": ">=17",
@@ -1,11 +1,11 @@
1
- import React, { ButtonHTMLAttributes, ElementType, forwardRef } from 'react'
1
+ import React, { ElementType, forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
5
  import { Colors, Shapes, colorPropType } from '../Types'
6
- import { CLink } from '../link/CLink'
6
+ import { CLink, CLinkProps } from '../link/CLink'
7
7
 
8
- export interface CButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
8
+ export interface CButtonProps extends Omit<CLinkProps, 'size'> {
9
9
  /**
10
10
  * Toggle the active state for the component.
11
11
  */
@@ -3,6 +3,7 @@ import React, {
3
3
  createContext,
4
4
  forwardRef,
5
5
  HTMLAttributes,
6
+ TouchEvent,
6
7
  useState,
7
8
  useEffect,
8
9
  useRef,
@@ -10,18 +11,9 @@ import React, {
10
11
  import PropTypes from 'prop-types'
11
12
  import classNames from 'classnames'
12
13
 
14
+ import { isVisible } from '../../utils'
13
15
  import { useForkedRef } from '../../utils/hooks'
14
16
 
15
- const isVisible = (element: HTMLDivElement) => {
16
- const rect = element.getBoundingClientRect()
17
- return (
18
- rect.top >= 0 &&
19
- rect.left >= 0 &&
20
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
21
- rect.right <= (window.innerWidth || document.documentElement.clientWidth)
22
- )
23
- }
24
-
25
17
  export interface CCarouselProps extends HTMLAttributes<HTMLDivElement> {
26
18
  /**
27
19
  * index of the active item.
@@ -59,6 +51,12 @@ export interface CCarouselProps extends HTMLAttributes<HTMLDivElement> {
59
51
  * If set to 'hover', pauses the cycling of the carousel on mouseenter and resumes the cycling of the carousel on mouseleave. If set to false, hovering over the carousel won't pause it.
60
52
  */
61
53
  pause?: boolean | 'hover'
54
+ /**
55
+ * Set whether the carousel should support left/right swipe interactions on touchscreen devices.
56
+ *
57
+ * @since 4.5.0
58
+ */
59
+ touch?: boolean
62
60
  /**
63
61
  * Set type of the transition.
64
62
  */
@@ -93,6 +91,7 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
93
91
  onSlid,
94
92
  onSlide,
95
93
  pause = 'hover',
94
+ touch = true,
96
95
  transition,
97
96
  wrap = true,
98
97
  ...rest
@@ -108,6 +107,7 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
108
107
  const [customInterval, setCustomInterval] = useState<boolean | number>()
109
108
  const [direction, setDirection] = useState<string>('next')
110
109
  const [itemsNumber, setItemsNumber] = useState<number>(0)
110
+ const [touchPosition, setTouchPosition] = useState<number | null>(null)
111
111
  const [visible, setVisible] = useState<boolean>()
112
112
 
113
113
  useEffect(() => {
@@ -202,11 +202,38 @@ export const CCarousel = forwardRef<HTMLDivElement, CCarouselProps>(
202
202
  }
203
203
  }
204
204
 
205
+ const handleTouchMove = (e: TouchEvent) => {
206
+ const touchDown = touchPosition
207
+
208
+ if (touchDown === null) {
209
+ return
210
+ }
211
+
212
+ const currentTouch = e.touches[0].clientX
213
+ const diff = touchDown - currentTouch
214
+
215
+ if (diff > 5) {
216
+ handleControlClick('next')
217
+ }
218
+
219
+ if (diff < -5) {
220
+ handleControlClick('prev')
221
+ }
222
+
223
+ setTouchPosition(null)
224
+ }
225
+
226
+ const handleTouchStart = (e: TouchEvent) => {
227
+ const touchDown = e.touches[0].clientX
228
+ setTouchPosition(touchDown)
229
+ }
230
+
205
231
  return (
206
232
  <div
207
233
  className={_className}
208
234
  onMouseEnter={_pause}
209
235
  onMouseLeave={cycle}
236
+ {...(touch && { onTouchStart: handleTouchStart, onTouchMove: handleTouchMove })}
210
237
  {...rest}
211
238
  ref={forkedRef}
212
239
  >
@@ -271,6 +298,7 @@ CCarousel.propTypes = {
271
298
  onSlid: PropTypes.func,
272
299
  onSlide: PropTypes.func,
273
300
  pause: PropTypes.oneOf([false, 'hover']),
301
+ touch: PropTypes.bool,
274
302
  transition: PropTypes.oneOf(['slide', 'crossfade']),
275
303
  wrap: PropTypes.bool,
276
304
  }
@@ -12,6 +12,12 @@ export interface CFormControlWrapperProps extends CFormControlValidationProps {
12
12
  * @ignore
13
13
  */
14
14
  children?: ReactNode
15
+ /**
16
+ * A string of all className you want applied to the floating label wrapper.
17
+ *
18
+ * @since 4.5.0
19
+ */
20
+ floatingClassName?: string
15
21
  /**
16
22
  * Provide valuable, actionable valid feedback when using standard HTML form validation which applied two CSS pseudo-classes, `:invalid` and `:valid`.
17
23
  *
@@ -42,6 +48,7 @@ export const CFormControlWrapper: FC<CFormControlWrapperProps> = ({
42
48
  feedback,
43
49
  feedbackInvalid,
44
50
  feedbackValid,
51
+ floatingClassName,
45
52
  floatingLabel,
46
53
  id,
47
54
  invalid,
@@ -51,9 +58,20 @@ export const CFormControlWrapper: FC<CFormControlWrapperProps> = ({
51
58
  valid,
52
59
  }) => {
53
60
  return floatingLabel ? (
54
- <CFormFloating>
61
+ <CFormFloating className={floatingClassName}>
55
62
  {children}
56
63
  <CFormLabel htmlFor={id}>{label || floatingLabel}</CFormLabel>
64
+ {text && <CFormText id={describedby}>{text}</CFormText>}
65
+ <CFormControlValidation
66
+ describedby={describedby}
67
+ feedback={feedback}
68
+ feedbackInvalid={feedbackInvalid}
69
+ feedbackValid={feedbackValid}
70
+ floatingLabel={floatingLabel}
71
+ invalid={invalid}
72
+ tooltipFeedback={tooltipFeedback}
73
+ valid={valid}
74
+ />
57
75
  </CFormFloating>
58
76
  ) : (
59
77
  <>
@@ -76,6 +94,7 @@ export const CFormControlWrapper: FC<CFormControlWrapperProps> = ({
76
94
 
77
95
  CFormControlWrapper.propTypes = {
78
96
  children: PropTypes.node,
97
+ floatingClassName: PropTypes.string,
79
98
  floatingLabel: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
80
99
  label: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
81
100
  text: PropTypes.oneOfType([PropTypes.node, PropTypes.string]),
@@ -58,6 +58,7 @@ export const CFormInput = forwardRef<HTMLInputElement, CFormInputProps>(
58
58
  feedback,
59
59
  feedbackInvalid,
60
60
  feedbackValid,
61
+ floatingClassName,
61
62
  floatingLabel,
62
63
  id,
63
64
  invalid,
@@ -101,6 +102,7 @@ export const CFormInput = forwardRef<HTMLInputElement, CFormInputProps>(
101
102
  feedback={feedback}
102
103
  feedbackInvalid={feedbackInvalid}
103
104
  feedbackValid={feedbackValid}
105
+ floatingClassName={floatingClassName}
104
106
  floatingLabel={floatingLabel}
105
107
  id={id}
106
108
  invalid={invalid}
@@ -1,8 +1,8 @@
1
- import React, { forwardRef, AllHTMLAttributes } from 'react'
1
+ import React, { forwardRef, LabelHTMLAttributes } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
- export interface CFormLabelProps extends AllHTMLAttributes<HTMLLabelElement> {
5
+ export interface CFormLabelProps extends LabelHTMLAttributes<HTMLLabelElement> {
6
6
  /**
7
7
  * A string of all className you want applied to the component.
8
8
  */
@@ -38,7 +38,7 @@ export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
38
38
  /**
39
39
  * Specifies the interval between legal numbers in the component.
40
40
  */
41
- steps: number
41
+ step?: number
42
42
  /**
43
43
  * The `value` attribute of component.
44
44
  *
@@ -52,6 +52,7 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
52
52
  feedback,
53
53
  feedbackInvalid,
54
54
  feedbackValid,
55
+ floatingClassName,
55
56
  floatingLabel,
56
57
  htmlSize,
57
58
  id,
@@ -81,6 +82,7 @@ export const CFormSelect = forwardRef<HTMLSelectElement, CFormSelectProps>(
81
82
  feedback={feedback}
82
83
  feedbackInvalid={feedbackInvalid}
83
84
  feedbackValid={feedbackValid}
85
+ floatingClassName={floatingClassName}
84
86
  floatingLabel={floatingLabel}
85
87
  id={id}
86
88
  invalid={invalid}
@@ -44,6 +44,7 @@ export const CFormTextarea = forwardRef<HTMLTextAreaElement, CFormTextareaProps>
44
44
  feedback,
45
45
  feedbackInvalid,
46
46
  feedbackValid,
47
+ floatingClassName,
47
48
  floatingLabel,
48
49
  id,
49
50
  invalid,
@@ -70,6 +71,7 @@ export const CFormTextarea = forwardRef<HTMLTextAreaElement, CFormTextareaProps>
70
71
  feedback={feedback}
71
72
  feedbackInvalid={feedbackInvalid}
72
73
  feedbackValid={feedbackValid}
74
+ floatingClassName={floatingClassName}
73
75
  floatingLabel={floatingLabel}
74
76
  id={id}
75
77
  invalid={invalid}
@@ -1,8 +1,9 @@
1
- import React, { ElementType, forwardRef, HTMLAttributes } from 'react'
1
+ import React, { ElementType, forwardRef, LabelHTMLAttributes } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
- export interface CInputGroupTextProps extends HTMLAttributes<HTMLLabelElement | HTMLSpanElement> {
5
+ export interface CInputGroupTextProps
6
+ extends LabelHTMLAttributes<HTMLLabelElement | HTMLSpanElement> {
6
7
  /**
7
8
  * A string of all className you want applied to the component.
8
9
  */
@@ -4,7 +4,7 @@ import '@testing-library/jest-dom/extend-expect'
4
4
  import { CFormRange } from '../../../index'
5
5
 
6
6
  test('loads and displays CFormRange component', async () => {
7
- const { container } = render(<CFormRange steps={3} />)
7
+ const { container } = render(<CFormRange step={3} />)
8
8
  expect(container).toMatchSnapshot()
9
9
  })
10
10
 
@@ -12,7 +12,7 @@ test('CFormRange customize', async () => {
12
12
  const { container } = render(
13
13
  <CFormRange
14
14
  className="bazinga"
15
- steps={2}
15
+ step={2}
16
16
  disabled={true}
17
17
  max={150}
18
18
  min={20}
@@ -8,6 +8,15 @@ test('loads and displays CInputGroupText component', async () => {
8
8
  expect(container).toMatchSnapshot()
9
9
  })
10
10
 
11
+ test('renders CInputGroupText component as a label', async () => {
12
+ const { container } = render(
13
+ <CInputGroupText component="label" htmlFor="input">
14
+ Test
15
+ </CInputGroupText>,
16
+ )
17
+ expect(container).toMatchSnapshot()
18
+ })
19
+
11
20
  test('CInputGroupText customize', async () => {
12
21
  const { container } = render(<CInputGroupText className="bazinga">Test</CInputGroupText>)
13
22
  expect(container).toMatchSnapshot()
@@ -19,3 +19,14 @@ exports[`loads and displays CInputGroupText component 1`] = `
19
19
  </span>
20
20
  </div>
21
21
  `;
22
+
23
+ exports[`renders CInputGroupText component as a label 1`] = `
24
+ <div>
25
+ <label
26
+ class="input-group-text"
27
+ for="input"
28
+ >
29
+ Test
30
+ </label>
31
+ </div>
32
+ `;
@@ -1,5 +1,7 @@
1
1
  import { CForm } from './CForm'
2
2
  import { CFormCheck } from './CFormCheck'
3
+ import { CFormControlValidation } from './CFormControlValidation'
4
+ import { CFormControlWrapper } from './CFormControlWrapper'
3
5
  import { CFormFeedback } from './CFormFeedback'
4
6
  import { CFormFloating } from './CFormFloating'
5
7
  import { CFormInput } from './CFormInput'
@@ -15,6 +17,8 @@ import { CInputGroupText } from './CInputGroupText'
15
17
  export {
16
18
  CForm,
17
19
  CFormCheck,
20
+ CFormControlValidation,
21
+ CFormControlWrapper,
18
22
  CFormFeedback,
19
23
  CFormFloating,
20
24
  CFormInput,
@@ -1,8 +1,9 @@
1
- import React, { ElementType, forwardRef, HTMLAttributes } from 'react'
1
+ import React, { ElementType, forwardRef, AnchorHTMLAttributes } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
- export interface CHeaderBrandProps extends HTMLAttributes<HTMLAnchorElement | HTMLSpanElement> {
5
+ export interface CHeaderBrandProps
6
+ extends AnchorHTMLAttributes<HTMLAnchorElement | HTMLSpanElement> {
6
7
  /**
7
8
  * A string of all className you want applied to the component.
8
9
  */
@@ -2,7 +2,7 @@ import React, { AllHTMLAttributes, ElementType, forwardRef, MouseEvent } from 'r
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
5
- export interface CLinkProps extends AllHTMLAttributes<HTMLElement> {
5
+ export interface CLinkProps extends AllHTMLAttributes<HTMLButtonElement | HTMLAnchorElement> {
6
6
  /**
7
7
  * Toggle the active state for the component.
8
8
  */
@@ -36,7 +36,7 @@ export const CLink = forwardRef<HTMLButtonElement | HTMLAnchorElement, CLinkProp
36
36
  {...(active && { 'aria-current': 'page' })}
37
37
  {...(Component === 'a' && disabled && { 'aria-disabled': true, tabIndex: -1 })}
38
38
  {...((Component === 'a' || Component === 'button') && {
39
- onClick: (event: MouseEvent<HTMLElement>) => {
39
+ onClick: (event: MouseEvent<HTMLButtonElement | HTMLAnchorElement>) => {
40
40
  event.preventDefault
41
41
  !disabled && rest.onClick && rest.onClick(event)
42
42
  },
@@ -1,4 +1,4 @@
1
- import React, { ElementType, HTMLAttributes, forwardRef } from 'react'
1
+ import React, { ElementType, AnchorHTMLAttributes, forwardRef } from 'react'
2
2
  import PropTypes from 'prop-types'
3
3
  import classNames from 'classnames'
4
4
 
@@ -6,7 +6,7 @@ import { Colors, colorPropType } from '../Types'
6
6
  import { CLink } from '../link/CLink'
7
7
 
8
8
  export interface CListGroupItemProps
9
- extends HTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement> {
9
+ extends AnchorHTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement> {
10
10
  /**
11
11
  * Toggle the active state for the component.
12
12
  */
@@ -108,6 +108,7 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
108
108
  transition = true,
109
109
  unmountOnClose = true,
110
110
  visible,
111
+ ...rest
111
112
  },
112
113
  ref,
113
114
  ) => {
@@ -233,7 +234,9 @@ export const CModal = forwardRef<HTMLDivElement, CModalProps>(
233
234
  scrollable={scrollable}
234
235
  size={size}
235
236
  >
236
- <CModalContent ref={modalContentRef}>{children}</CModalContent>
237
+ <CModalContent {...rest} ref={modalContentRef}>
238
+ {children}
239
+ </CModalContent>
237
240
  </CModalDialog>
238
241
  </div>
239
242
  </CModalContext.Provider>
@@ -3,6 +3,7 @@ import { createPortal } from 'react-dom'
3
3
  import PropTypes from 'prop-types'
4
4
  import classNames from 'classnames'
5
5
 
6
+ import { isVisible } from '../../utils'
6
7
  import { useForkedRef } from '../../utils/hooks'
7
8
  import { CBackdrop } from '../backdrop/CBackdrop'
8
9
 
@@ -52,16 +53,6 @@ export interface CSidebarProps extends HTMLAttributes<HTMLDivElement> {
52
53
  const isOnMobile = (element: HTMLDivElement) =>
53
54
  Boolean(getComputedStyle(element).getPropertyValue('--cui-is-mobile'))
54
55
 
55
- const isVisible = (element: HTMLDivElement) => {
56
- const rect = element.getBoundingClientRect()
57
- return (
58
- rect.top >= 0 &&
59
- rect.left >= 0 &&
60
- rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
61
- rect.right <= (window.innerWidth || document.documentElement.clientWidth)
62
- )
63
- }
64
-
65
56
  export const CSidebar = forwardRef<HTMLDivElement, CSidebarProps>(
66
57
  (
67
58
  {
@@ -3,7 +3,10 @@ import PropTypes from 'prop-types'
3
3
  import { CToastContext } from './CToast'
4
4
  import { CCloseButton, CCloseButtonProps } from '../close-button/CCloseButton'
5
5
 
6
- export interface CToastCloseProps extends CCloseButtonProps {
6
+ import type { CButtonProps } from '../button/CButton'
7
+
8
+ type CombineButtonProps = CCloseButtonProps & CButtonProps
9
+ export interface CToastCloseProps extends CombineButtonProps {
7
10
  /**
8
11
  * Component used for the root node. Either a string to use a HTML element or a component.
9
12
  */
@@ -0,0 +1,3 @@
1
+ import isVisible from './isVisible'
2
+
3
+ export { isVisible }
@@ -0,0 +1,11 @@
1
+ const isVisible = (element: HTMLElement) => {
2
+ const rect = element.getBoundingClientRect()
3
+ return (
4
+ rect.top >= 0 &&
5
+ rect.left >= 0 &&
6
+ rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
7
+ rect.right <= (window.innerWidth || document.documentElement.clientWidth)
8
+ )
9
+ }
10
+
11
+ export default isVisible