@coreui/react 4.9.0-rc.0 → 5.0.0-alpha.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/README.md CHANGED
@@ -46,7 +46,7 @@
46
46
 
47
47
  Several quick start options are available:
48
48
 
49
- - [Download the latest release](https://github.com/coreui/coreui-react/archive/v4.9.0-rc.0.zip)
49
+ - [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.0.0-alpha.0.zip)
50
50
  - Clone the repo: `git clone https://github.com/coreui/coreui-react.git`
51
51
  - Install with [npm](https://www.npmjs.com/): `npm install @coreui/react`
52
52
  - Install with [yarn](https://yarnpkg.com/): `yarn add @coreui/react`
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { CCollapseProps } from '../collapse/CCollapse';
3
+ export declare const CAccordionCollapse: React.ForwardRefExoticComponent<Omit<CCollapseProps, "horizontal"> & React.RefAttributes<HTMLDivElement>>;
@@ -53,7 +53,7 @@ export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIEl
53
53
  /**
54
54
  * Callback fired when the component requests to be hidden.
55
55
  *
56
- * @since 4.9.0-rc.0
56
+ * @since 4.9.0
57
57
  */
58
58
  onHide?: () => void;
59
59
  /**
@@ -0,0 +1,89 @@
1
+ import React, { ElementType, HTMLAttributes, RefObject } from 'react';
2
+ import type { Placements } from '../../types';
3
+ export type Directions = 'start' | 'end';
4
+ export type Breakpoints = {
5
+ xs: Directions;
6
+ } | {
7
+ sm: Directions;
8
+ } | {
9
+ md: Directions;
10
+ } | {
11
+ lg: Directions;
12
+ } | {
13
+ xl: Directions;
14
+ } | {
15
+ xxl: Directions;
16
+ };
17
+ export type Alignments = Directions | Breakpoints;
18
+ export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIElement> {
19
+ /**
20
+ * Set aligment of dropdown menu.
21
+ *
22
+ * @type 'start' | 'end' | { xs: 'start' | 'end' } | { sm: 'start' | 'end' } | { md: 'start' | 'end' } | { lg: 'start' | 'end' } | { xl: 'start' | 'end'} | { xxl: 'start' | 'end'}
23
+ */
24
+ alignment?: Alignments;
25
+ /**
26
+ * Configure the auto close behavior of the dropdown:
27
+ * - `true` - the dropdown will be closed by clicking outside or inside the dropdown menu.
28
+ * - `false` - the dropdown will be closed by clicking the toggle button and manually calling hide or toggle method. (Also will not be closed by pressing esc key)
29
+ * - `'inside'` - the dropdown will be closed (only) by clicking inside the dropdown menu.
30
+ * - `'outside'` - the dropdown will be closed (only) by clicking outside the dropdown menu.
31
+ */
32
+ autoClose?: 'inside' | 'outside' | boolean;
33
+ /**
34
+ * A string of all className you want applied to the base component.
35
+ */
36
+ className?: string;
37
+ /**
38
+ * Component used for the root node. Either a string to use a HTML element or a component.
39
+ */
40
+ component?: string | ElementType;
41
+ /**
42
+ * Sets a darker color scheme to match a dark navbar.
43
+ */
44
+ dark?: boolean;
45
+ /**
46
+ * Sets a specified direction and location of the dropdown menu.
47
+ */
48
+ direction?: 'center' | 'dropup' | 'dropup-center' | 'dropend' | 'dropstart';
49
+ /**
50
+ * Callback fired when the component requests to be hidden.
51
+ */
52
+ onHide?: () => void;
53
+ /**
54
+ * Callback fired when the component requests to be shown.
55
+ */
56
+ onShow?: () => void;
57
+ /**
58
+ * Describes the placement of your component after Popper.js has applied all the modifiers that may have flipped or altered the originally provided placement property.
59
+ *
60
+ * @type 'auto' | 'top-end' | 'top' | 'top-start' | 'bottom-end' | 'bottom' | 'bottom-start' | 'right-start' | 'right' | 'right-end' | 'left-start' | 'left' | 'left-end'
61
+ */
62
+ placement?: Placements;
63
+ /**
64
+ * If you want to disable dynamic positioning set this property to `true`.
65
+ */
66
+ popper?: boolean;
67
+ /**
68
+ * Generates dropdown menu using createPortal.
69
+ *
70
+ * @since 4.8.0
71
+ */
72
+ portal?: boolean;
73
+ /**
74
+ * Set the dropdown variant to an btn-group, dropdown, input-group, and nav-item.
75
+ */
76
+ variant?: 'btn-group' | 'dropdown' | 'input-group' | 'nav-item';
77
+ /**
78
+ * Toggle the visibility of dropdown menu component.
79
+ */
80
+ visible?: boolean;
81
+ }
82
+ interface ContextProps extends CDropdownProps {
83
+ dropdownToggleRef: RefObject<any> | undefined;
84
+ setVisible: React.Dispatch<React.SetStateAction<boolean | undefined>>;
85
+ portal: boolean;
86
+ }
87
+ export declare const CDropdownContext: React.Context<ContextProps>;
88
+ export declare const CDropdown: React.ForwardRefExoticComponent<CDropdownProps & React.RefAttributes<HTMLDivElement | HTMLLIElement>>;
89
+ export {};
@@ -0,0 +1,8 @@
1
+ import React, { HTMLAttributes } from 'react';
2
+ export interface CDropdownDividerProps extends HTMLAttributes<HTMLHRElement> {
3
+ /**
4
+ * A string of all className you want applied to the component.
5
+ */
6
+ className?: string;
7
+ }
8
+ export declare const CDropdownDivider: React.ForwardRefExoticComponent<CDropdownDividerProps & React.RefAttributes<HTMLHRElement>>;
@@ -0,0 +1,12 @@
1
+ import React, { ElementType, HTMLAttributes } from 'react';
2
+ export interface CDropdownHeaderProps extends HTMLAttributes<HTMLHeadingElement> {
3
+ /**
4
+ * A string of all className you want applied to the component.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * Component used for the root node. Either a string to use a HTML element or a component.
9
+ */
10
+ component?: string | ElementType;
11
+ }
12
+ export declare const CDropdownHeader: React.ForwardRefExoticComponent<CDropdownHeaderProps & React.RefAttributes<HTMLHeadingElement>>;
@@ -0,0 +1,13 @@
1
+ import React, { ElementType } from 'react';
2
+ import { CLinkProps } from '../link/CLink';
3
+ export interface CDropdownItemProps extends CLinkProps {
4
+ /**
5
+ * A string of all className you want applied to the component.
6
+ */
7
+ className?: string;
8
+ /**
9
+ * Component used for the root node. Either a string to use a HTML element or a component.
10
+ */
11
+ component?: string | ElementType;
12
+ }
13
+ export declare const CDropdownItem: React.ForwardRefExoticComponent<CDropdownItemProps & React.RefAttributes<HTMLButtonElement | HTMLAnchorElement>>;
@@ -0,0 +1,12 @@
1
+ import React, { ElementType, HTMLAttributes } from 'react';
2
+ export interface CDropdownItemPlainProps extends HTMLAttributes<HTMLSpanElement> {
3
+ /**
4
+ * A string of all className you want applied to the component.
5
+ */
6
+ className?: string;
7
+ /**
8
+ * Component used for the root node. Either a string to use a HTML element or a component.
9
+ */
10
+ component?: string | ElementType;
11
+ }
12
+ export declare const CDropdownItemPlain: React.ForwardRefExoticComponent<CDropdownItemPlainProps & React.RefAttributes<HTMLSpanElement>>;
@@ -0,0 +1,13 @@
1
+ import { ElementType, FC, HTMLAttributes } from 'react';
2
+ import { PopperChildrenProps } from 'react-popper';
3
+ export interface CDropdownMenuProps extends HTMLAttributes<HTMLDivElement | HTMLUListElement>, Omit<PopperChildrenProps, 'arrowProps' | 'forceUpdate' | 'hasPopperEscaped' | 'isReferenceHidden' | 'placement' | 'ref' | 'style' | 'update'> {
4
+ /**
5
+ * A string of all className you want applied to the base component.
6
+ */
7
+ className?: string;
8
+ /**
9
+ * Component used for the root node. Either a string to use a HTML element or a component.
10
+ */
11
+ component?: string | ElementType;
12
+ }
13
+ export declare const CDropdownMenu: FC<CDropdownMenuProps>;
@@ -0,0 +1,24 @@
1
+ import { FC } from 'react';
2
+ import { CButtonProps } from '../button/CButton';
3
+ import type { Triggers } from '../../types';
4
+ export interface CDropdownToggleProps extends Omit<CButtonProps, 'type'> {
5
+ /**
6
+ * Enables pseudo element caret on toggler.
7
+ */
8
+ caret?: boolean;
9
+ /**
10
+ * Create a custom toggler which accepts any content.
11
+ */
12
+ custom?: boolean;
13
+ /**
14
+ * Similarly, create split button dropdowns with virtually the same markup as single button dropdowns, but with the addition of `.dropdown-toggle-split` className for proper spacing around the dropdown caret.
15
+ */
16
+ split?: boolean;
17
+ /**
18
+ * Sets which event handlers you’d like provided to your toggle prop. You can specify one trigger or an array of them.
19
+ *
20
+ * @type 'hover' | 'focus' | 'click'
21
+ */
22
+ trigger?: Triggers | Triggers[];
23
+ }
24
+ export declare const CDropdownToggle: FC<CDropdownToggleProps>;
@@ -0,0 +1,8 @@
1
+ import { CDropdown } from './CDropdown';
2
+ import { CDropdownDivider } from './CDropdownDivider';
3
+ import { CDropdownHeader } from './CDropdownHeader';
4
+ import { CDropdownItem } from './CDropdownItem';
5
+ import { CDropdownItemPlain } from './CDropdownItemPlain';
6
+ import { CDropdownMenu } from './CDropdownMenu';
7
+ import { CDropdownToggle } from './CDropdownToggle';
8
+ export { CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownItemPlain, CDropdownMenu, CDropdownToggle, };
@@ -4,7 +4,7 @@ export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'tit
4
4
  /**
5
5
  * Apply a CSS fade transition to the popover.
6
6
  *
7
- * @since 4.9.0-rc.0
7
+ * @since 4.9.0
8
8
  */
9
9
  animation?: boolean;
10
10
  /**
@@ -22,7 +22,7 @@ export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'tit
22
22
  /**
23
23
  * The delay for displaying and hiding the popover (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: `{ 'show': 500, 'hide': 100 }`.
24
24
  *
25
- * @since 4.9.0-rc.0
25
+ * @since 4.9.0
26
26
  */
27
27
  delay?: number | {
28
28
  show: number;
@@ -31,7 +31,7 @@ export interface CPopoverProps extends Omit<HTMLAttributes<HTMLDivElement>, 'tit
31
31
  /**
32
32
  * Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference.
33
33
  *
34
- * @since 4.9.0-rc.0
34
+ * @since 4.9.0
35
35
  */
36
36
  fallbackPlacements?: Placements | Placements[];
37
37
  /**
@@ -4,7 +4,7 @@ export interface CTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'con
4
4
  /**
5
5
  * Apply a CSS fade transition to the tooltip.
6
6
  *
7
- * @since 4.9.0-rc.0
7
+ * @since 4.9.0
8
8
  */
9
9
  animation?: boolean;
10
10
  /**
@@ -18,7 +18,7 @@ export interface CTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'con
18
18
  /**
19
19
  * The delay for displaying and hiding the tooltip (in milliseconds). When a numerical value is provided, the delay applies to both the hide and show actions. The object structure for specifying the delay is as follows: delay: `{ 'show': 500, 'hide': 100 }`.
20
20
  *
21
- * @since 4.9.0-rc.0
21
+ * @since 4.9.0
22
22
  */
23
23
  delay?: number | {
24
24
  show: number;
@@ -27,7 +27,7 @@ export interface CTooltipProps extends Omit<HTMLAttributes<HTMLDivElement>, 'con
27
27
  /**
28
28
  * Specify the desired order of fallback placements by providing a list of placements as an array. The placements should be prioritized based on preference.
29
29
  *
30
- * @since 4.9.0-rc.0
30
+ * @since 4.9.0
31
31
  */
32
32
  fallbackPlacements?: Placements | Placements[];
33
33
  /**
@@ -1,3 +1,4 @@
1
+ import { useColorModes } from './useColorModes';
1
2
  import { useForkedRef } from './useForkedRef';
2
3
  import { usePopper } from './usePopper';
3
- export { useForkedRef, usePopper };
4
+ export { useColorModes, useForkedRef, usePopper };
package/dist/index.es.js CHANGED
@@ -2475,6 +2475,54 @@ CSSTransition.propTypes = process.env.NODE_ENV !== "production" ? _extends({}, T
2475
2475
  }) : {};
2476
2476
  var CSSTransition$1 = CSSTransition;
2477
2477
 
2478
+ var getStoredTheme = function (localStorageItemName) {
2479
+ return typeof window !== 'undefined' && localStorage.getItem(localStorageItemName);
2480
+ };
2481
+ var setStoredTheme = function (localStorageItemName, colorMode) {
2482
+ return localStorage.setItem(localStorageItemName, colorMode);
2483
+ };
2484
+ var getPreferredColorScheme = function (localStorageItemName) {
2485
+ if (typeof window === 'undefined') {
2486
+ return 'light';
2487
+ }
2488
+ var storedTheme = getStoredTheme(localStorageItemName);
2489
+ if (storedTheme) {
2490
+ return storedTheme;
2491
+ }
2492
+ return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';
2493
+ };
2494
+ var setTheme = function (colorMode) {
2495
+ document.documentElement.dataset.coreuiTheme =
2496
+ colorMode === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches
2497
+ ? 'dark'
2498
+ : colorMode;
2499
+ var event = new Event('ColorSchemeChange');
2500
+ document.documentElement.dispatchEvent(event);
2501
+ };
2502
+ var useColorModes = function (localStorageItemName) {
2503
+ if (localStorageItemName === void 0) { localStorageItemName = 'coreui-react-color-scheme'; }
2504
+ var _a = useState(getPreferredColorScheme(localStorageItemName)), colorMode = _a[0], setColorMode = _a[1];
2505
+ useEffect(function () {
2506
+ if (colorMode) {
2507
+ setStoredTheme(localStorageItemName, colorMode);
2508
+ setTheme(colorMode);
2509
+ }
2510
+ }, [colorMode]);
2511
+ useEffect(function () {
2512
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', function () {
2513
+ var storedTheme = getStoredTheme(localStorageItemName);
2514
+ if (storedTheme !== 'light' && storedTheme !== 'dark' && colorMode) {
2515
+ setTheme(colorMode);
2516
+ }
2517
+ });
2518
+ });
2519
+ return {
2520
+ colorMode: colorMode,
2521
+ isColorModeSet: function () { return Boolean(getStoredTheme(localStorageItemName)); },
2522
+ setColorMode: setColorMode,
2523
+ };
2524
+ };
2525
+
2478
2526
  // code borrowed from https://github.com/reach/reach-ui
2479
2527
  // problem described https://github.com/facebook/react/issues/13029
2480
2528
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -4832,6 +4880,16 @@ CCardTitle.propTypes = {
4832
4880
  };
4833
4881
  CCardTitle.displayName = 'CCardTitle';
4834
4882
 
4883
+ var isRTL = function (element) {
4884
+ if (typeof document !== 'undefined' && document.documentElement.dir === 'rtl') {
4885
+ return true;
4886
+ }
4887
+ if (element) {
4888
+ return element.closest('[dir="rtl"]') !== null;
4889
+ }
4890
+ return false;
4891
+ };
4892
+
4835
4893
  var getRTLPlacement = function (placement, element) {
4836
4894
  switch (placement) {
4837
4895
  case 'right': {
@@ -4854,16 +4912,6 @@ var isInViewport = function (element) {
4854
4912
  Math.floor(rect.right) <= (window.innerWidth || document.documentElement.clientWidth));
4855
4913
  };
4856
4914
 
4857
- var isRTL = function (element) {
4858
- if (typeof document !== 'undefined' && document.documentElement.dir === 'rtl') {
4859
- return true;
4860
- }
4861
- if (element) {
4862
- return element.closest('[dir="rtl"]') !== null;
4863
- }
4864
- return false;
4865
- };
4866
-
4867
4915
  var CCarouselContext = createContext({});
4868
4916
  var CCarousel = forwardRef(function (_a, ref) {
4869
4917
  var children = _a.children, _b = _a.activeIndex, activeIndex = _b === void 0 ? 0 : _b, className = _a.className, controls = _a.controls, dark = _a.dark, indicators = _a.indicators, _c = _a.interval, interval = _c === void 0 ? 5000 : _c, onSlid = _a.onSlid, onSlide = _a.onSlide, _d = _a.pause, pause = _d === void 0 ? 'hover' : _d, _e = _a.touch, touch = _e === void 0 ? true : _e, transition = _a.transition, _f = _a.wrap, wrap = _f === void 0 ? true : _f, rest = __rest(_a, ["children", "activeIndex", "className", "controls", "dark", "indicators", "interval", "onSlid", "onSlide", "pause", "touch", "transition", "wrap"]);
@@ -7417,5 +7465,5 @@ CWidgetStatsF.propTypes = {
7417
7465
  };
7418
7466
  CWidgetStatsF.displayName = 'CWidgetStatsF';
7419
7467
 
7420
- export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem, CAlert, CAlertHeading, CAlertLink, CAvatar, CBackdrop, CBadge, CBreadcrumb, CBreadcrumbItem, CButton, CButtonGroup, CButtonToolbar, CCallout, CCard, CCardBody, CCardFooter, CCardGroup, CCardHeader, CCardImage, CCardImageOverlay, CCardLink, CCardSubtitle, CCardText, CCardTitle, CCarousel, CCarouselCaption, CCarouselItem, CCloseButton, CCol, CCollapse, CConditionalPortal, CContainer, CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownItemPlain, CDropdownMenu, CDropdownToggle, CFooter, CForm, CFormCheck, CFormControlValidation, CFormControlWrapper, CFormFeedback, CFormFloating, CFormInput, CFormLabel, CFormRange, CFormSelect, CFormSwitch, CFormText, CFormTextarea, CHeader, CHeaderBrand, CHeaderDivider, CHeaderNav, CHeaderText, CHeaderToggler, CImage, CInputGroup, CInputGroupText, CLink, CListGroup, CListGroupItem, CModal, CModalBody, CModalContent, CModalDialog, CModalFooter, CModalHeader, CModalTitle, CNav, CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavTitle, CNavbar, CNavbarBrand, CNavbarNav, CNavbarText, CNavbarToggler, COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasTitle, CPagination, CPaginationItem, CPlaceholder, CPopover, CProgress, CProgressBar, CProgressStacked, CRow, CSidebar, CSidebarBrand, CSidebarFooter, CSidebarHeader, CSidebarNav, CSidebarToggler, CSpinner, CTabContent, CTabPane, CTable, CTableBody, CTableCaption, CTableDataCell, CTableFoot, CTableHead, CTableHeaderCell, CTableRow, CToast, CToastBody, CToastClose, CToastHeader, CToaster, CTooltip, CWidgetStatsA, CWidgetStatsB, CWidgetStatsC, CWidgetStatsD, CWidgetStatsE, CWidgetStatsF, useForkedRef, usePopper };
7468
+ export { CAccordion, CAccordionBody, CAccordionButton, CAccordionHeader, CAccordionItem, CAlert, CAlertHeading, CAlertLink, CAvatar, CBackdrop, CBadge, CBreadcrumb, CBreadcrumbItem, CButton, CButtonGroup, CButtonToolbar, CCallout, CCard, CCardBody, CCardFooter, CCardGroup, CCardHeader, CCardImage, CCardImageOverlay, CCardLink, CCardSubtitle, CCardText, CCardTitle, CCarousel, CCarouselCaption, CCarouselItem, CCloseButton, CCol, CCollapse, CConditionalPortal, CContainer, CDropdown, CDropdownDivider, CDropdownHeader, CDropdownItem, CDropdownItemPlain, CDropdownMenu, CDropdownToggle, CFooter, CForm, CFormCheck, CFormControlValidation, CFormControlWrapper, CFormFeedback, CFormFloating, CFormInput, CFormLabel, CFormRange, CFormSelect, CFormSwitch, CFormText, CFormTextarea, CHeader, CHeaderBrand, CHeaderDivider, CHeaderNav, CHeaderText, CHeaderToggler, CImage, CInputGroup, CInputGroupText, CLink, CListGroup, CListGroupItem, CModal, CModalBody, CModalContent, CModalDialog, CModalFooter, CModalHeader, CModalTitle, CNav, CNavGroup, CNavGroupItems, CNavItem, CNavLink, CNavTitle, CNavbar, CNavbarBrand, CNavbarNav, CNavbarText, CNavbarToggler, COffcanvas, COffcanvasBody, COffcanvasHeader, COffcanvasTitle, CPagination, CPaginationItem, CPlaceholder, CPopover, CProgress, CProgressBar, CProgressStacked, CRow, CSidebar, CSidebarBrand, CSidebarFooter, CSidebarHeader, CSidebarNav, CSidebarToggler, CSpinner, CTabContent, CTabPane, CTable, CTableBody, CTableCaption, CTableDataCell, CTableFoot, CTableHead, CTableHeaderCell, CTableRow, CToast, CToastBody, CToastClose, CToastHeader, CToaster, CTooltip, CWidgetStatsA, CWidgetStatsB, CWidgetStatsC, CWidgetStatsD, CWidgetStatsE, CWidgetStatsF, useColorModes, useForkedRef, usePopper };
7421
7469
  //# sourceMappingURL=index.es.js.map