@coreui/react-pro 4.8.0 → 4.9.0-next.1
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 +1 -1
- package/dist/components/alert/CAlert.d.ts +1 -1
- package/dist/components/avatar/CAvatar.d.ts +1 -1
- package/dist/components/badge/CBadge.d.ts +1 -1
- package/dist/components/button/CButton.d.ts +1 -1
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/utils.d.ts +22 -0
- package/dist/components/callout/CCallout.d.ts +1 -1
- package/dist/components/card/CCard.d.ts +1 -1
- package/dist/components/date-picker/CDatePicker.d.ts +1 -1
- package/dist/components/date-range-picker/CDateRangePicker.d.ts +3 -3
- package/dist/components/date-range-picker/utils.d.ts +1 -0
- package/dist/components/dropdown/CDropdown.d.ts +1 -1
- package/dist/components/dropdown/CDropdownToggle.d.ts +1 -1
- package/dist/components/element-cover/CElementCover.d.ts +0 -4
- package/dist/components/element-cover/index.d.ts +2 -0
- package/dist/components/form/CFormCheck.d.ts +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/list-group/CListGroupItem.d.ts +4 -5
- package/dist/components/multi-select/CMultiSelect.d.ts +1 -13
- package/dist/components/multi-select/CMultiSelectNativeSelect.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectOptions.d.ts +1 -1
- package/dist/components/multi-select/CMultiSelectSelection.d.ts +1 -1
- package/dist/components/multi-select/types.d.ts +14 -0
- package/dist/components/multi-select/utils.d.ts +6 -0
- package/dist/components/navbar/CNavbar.d.ts +1 -1
- package/dist/components/offcanvas/COffcanvas.d.ts +7 -1
- package/dist/components/picker/CPicker.d.ts +1 -1
- package/dist/components/placeholder/CPlaceholder.d.ts +1 -1
- package/dist/components/popover/CPopover.d.ts +1 -1
- package/dist/components/progress/CProgressBar.d.ts +1 -1
- package/dist/components/smart-table/CSmartTableBody.d.ts +6 -5
- package/dist/components/smart-table/CSmartTableHead.d.ts +6 -3
- package/dist/components/smart-table/CSmartTableInterface.d.ts +38 -59
- package/dist/components/smart-table/types.d.ts +53 -0
- package/dist/components/smart-table/utils.d.ts +16 -0
- package/dist/components/spinner/CSpinner.d.ts +1 -1
- package/dist/components/table/CTable.d.ts +2 -18
- package/dist/components/table/CTableBody.d.ts +1 -1
- package/dist/components/table/CTableDataCell.d.ts +1 -1
- package/dist/components/table/CTableFoot.d.ts +1 -1
- package/dist/components/table/CTableHead.d.ts +1 -1
- package/dist/components/table/CTableHeaderCell.d.ts +1 -1
- package/dist/components/table/CTableRow.d.ts +1 -1
- package/dist/components/table/types.d.ts +17 -0
- package/dist/components/table/utils.d.ts +5 -0
- package/dist/components/time-picker/types.d.ts +15 -0
- package/dist/components/time-picker/utils.d.ts +23 -0
- package/dist/components/toast/CToast.d.ts +1 -1
- package/dist/components/toast/CToastClose.d.ts +1 -1
- package/dist/components/tooltip/CTooltip.d.ts +1 -1
- package/dist/components/virtual-scroller/CVirtualScroller.d.ts +0 -8
- package/dist/components/widgets/CWidgetStatsA.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsB.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsC.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsD.d.ts +1 -1
- package/dist/components/widgets/CWidgetStatsF.d.ts +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/useForkedRef.d.ts +7 -0
- package/dist/hooks/useStateWithCallback.d.ts +2 -0
- package/dist/index.es.js +1171 -1109
- package/dist/index.es.js.map +1 -1
- package/dist/index.js +1171 -1108
- package/dist/index.js.map +1 -1
- package/dist/props.d.ts +8 -0
- package/dist/types.d.ts +7 -0
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/isObjectInArray.d.ts +2 -0
- package/package.json +11 -11
- package/src/components/accordion/CAccordionBody.tsx +1 -0
- package/src/components/accordion/CAccordionCollapse.tsx +1 -0
- package/src/components/alert/CAlert.tsx +3 -2
- package/src/components/avatar/CAvatar.tsx +2 -8
- package/src/components/backdrop/CBackdrop.tsx +2 -2
- package/src/components/badge/CBadge.tsx +2 -10
- package/src/components/button/CButton.tsx +3 -1
- package/src/components/calendar/CCalendar.tsx +351 -240
- package/src/components/calendar/index.ts +3 -0
- package/src/{utils/calendar.ts → components/calendar/utils.ts} +1 -47
- package/src/components/callout/CCallout.tsx +2 -1
- package/src/components/card/CCard.tsx +2 -1
- package/src/components/carousel/CCarousel.tsx +1 -1
- package/src/components/carousel/CCarouselItem.tsx +1 -1
- package/src/components/collapse/CCollapse.tsx +1 -1
- package/src/components/date-picker/CDatePicker.tsx +1 -1
- package/src/components/date-range-picker/CDateRangePicker.tsx +4 -4
- package/src/components/date-range-picker/utils.ts +49 -0
- package/src/components/dropdown/CDropdown.tsx +3 -2
- package/src/components/dropdown/CDropdownItem.tsx +1 -2
- package/src/components/dropdown/CDropdownMenu.tsx +2 -1
- package/src/components/dropdown/CDropdownToggle.tsx +5 -4
- package/src/components/element-cover/CElementCover.tsx +16 -22
- package/src/components/element-cover/index.ts +3 -0
- package/src/components/form/CFormCheck.tsx +3 -3
- package/src/components/form/CFormControlValidation.tsx +0 -1
- package/src/components/form/CFormControlWrapper.tsx +0 -1
- package/src/components/form/CFormInput.tsx +8 -4
- package/src/components/form/CFormRange.tsx +1 -2
- package/src/components/form/CFormSelect.tsx +1 -2
- package/src/components/form/CFormTextarea.tsx +1 -2
- package/src/components/index.ts +1 -0
- package/src/components/list-group/CListGroupItem.tsx +8 -8
- package/src/components/list-group/CListGroupItem.tsx~HEAD +3 -1
- package/src/components/modal/CModal.tsx +2 -2
- package/src/components/modal/CModalHeader.tsx +3 -2
- package/src/components/multi-select/CMultiSelect.tsx +15 -74
- package/src/components/multi-select/CMultiSelectNativeSelect.tsx +1 -1
- package/src/components/multi-select/CMultiSelectOptions.tsx +2 -2
- package/src/components/multi-select/CMultiSelectSelection.tsx +1 -1
- package/src/components/multi-select/types.ts +15 -0
- package/src/components/multi-select/utils.ts +92 -0
- package/src/components/nav/CNavItem.tsx +1 -0
- package/src/components/nav/CNavLink.tsx +4 -3
- package/src/components/navbar/CNavbar.tsx +2 -1
- package/src/components/offcanvas/COffcanvas.tsx +38 -19
- package/src/components/picker/CPicker.tsx +1 -1
- package/src/components/placeholder/CPlaceholder.tsx +2 -1
- package/src/components/popover/CPopover.tsx +2 -1
- package/src/components/progress/CProgress.tsx +1 -0
- package/src/components/progress/CProgressBar.tsx +2 -1
- package/src/components/sidebar/CSidebar.tsx +3 -2
- package/src/components/smart-table/CSmartTable.tsx +263 -257
- package/src/components/smart-table/CSmartTableBody.tsx +98 -107
- package/src/components/smart-table/CSmartTableCleaner.tsx +1 -1
- package/src/components/smart-table/CSmartTableFilter.tsx +1 -3
- package/src/components/smart-table/CSmartTableHead.tsx +56 -103
- package/src/components/smart-table/CSmartTableInterface.tsx +49 -71
- package/src/components/smart-table/CSmartTableItemsPerPageSelector.tsx +1 -2
- package/src/components/smart-table/types.ts +65 -0
- package/src/components/smart-table/utils.ts +199 -0
- package/src/components/spinner/CSpinner.tsx +2 -1
- package/src/components/table/CTable.tsx +25 -59
- package/src/components/table/CTableBody.tsx +2 -1
- package/src/components/table/CTableDataCell.tsx +2 -1
- package/src/components/table/CTableFoot.tsx +2 -1
- package/src/components/table/CTableHead.tsx +2 -1
- package/src/components/table/CTableHeaderCell.tsx +2 -1
- package/src/components/table/CTableRow.tsx +2 -1
- package/src/components/table/types.ts +20 -0
- package/src/components/table/utils.ts +29 -0
- package/src/components/tabs/CTabPane.tsx +2 -1
- package/src/components/time-picker/CTimePicker.tsx +48 -23
- package/src/components/time-picker/CTimePickerRollCol.tsx +1 -1
- package/src/components/time-picker/types.ts +15 -0
- package/src/{utils/time.ts → components/time-picker/utils.ts} +43 -2
- package/src/components/toast/CToast.tsx +4 -4
- package/src/components/toast/CToastClose.tsx +2 -2
- package/src/components/toast/CToaster.tsx +2 -1
- package/src/components/tooltip/CTooltip.tsx +3 -2
- package/src/components/virtual-scroller/CVirtualScroller.tsx +32 -55
- package/src/components/widgets/CWidgetStatsA.tsx +3 -3
- package/src/components/widgets/CWidgetStatsB.tsx +4 -4
- package/src/components/widgets/CWidgetStatsC.tsx +4 -4
- package/src/components/widgets/CWidgetStatsD.tsx +4 -5
- package/src/components/widgets/CWidgetStatsE.tsx +1 -2
- package/src/components/widgets/CWidgetStatsF.tsx +3 -4
- package/src/{components/Types.tsx → props.ts} +1 -68
- package/src/types.ts +68 -0
- package/src/utils/index.ts +2 -3
- package/src/utils/isObjectInArray.ts +14 -0
- package/src/components/multi-select/CMultiSelectCleaner.tsx +0 -18
- package/src/utils/getNextSibling.ts +0 -18
- package/src/utils/getPreviousSibling.ts +0 -18
- /package/src/{utils/hooks → hooks}/index.ts +0 -0
- /package/src/{utils/hooks → hooks}/useForkedRef.ts +0 -0
- /package/src/{utils/hooks → hooks}/useStateWithCallback.ts +0 -0
|
@@ -4,7 +4,7 @@ export const convertToLocalDate = (d: Date, locale: string, options = {}) =>
|
|
|
4
4
|
export const convertToLocalTime = (d: Date, locale: string, options = {}) =>
|
|
5
5
|
d.toLocaleTimeString(locale, options)
|
|
6
6
|
|
|
7
|
-
export const createGroupsInArray = (arr:
|
|
7
|
+
export const createGroupsInArray = <T>(arr: T[], numberOfGroups: number): T[][] => {
|
|
8
8
|
const perGroup = Math.ceil(arr.length / numberOfGroups)
|
|
9
9
|
return new Array(numberOfGroups)
|
|
10
10
|
.fill('')
|
|
@@ -15,52 +15,6 @@ export const getCurrentYear = () => new Date().getFullYear()
|
|
|
15
15
|
|
|
16
16
|
export const getCurrentMonth = () => new Date().getMonth()
|
|
17
17
|
|
|
18
|
-
export const getLocalDateFromString = (string: string, locale: string, time?: boolean) => {
|
|
19
|
-
const date = new Date(2013, 11, 31, 17, 19, 22)
|
|
20
|
-
let regex = time ? date.toLocaleString(locale) : date.toLocaleDateString(locale)
|
|
21
|
-
regex = regex
|
|
22
|
-
.replace('2013', '(?<year>[0-9]{2,4})')
|
|
23
|
-
.replace('12', '(?<month>[0-9]{1,2})')
|
|
24
|
-
.replace('31', '(?<day>[0-9]{1,2})')
|
|
25
|
-
|
|
26
|
-
if (time) {
|
|
27
|
-
regex = regex
|
|
28
|
-
.replace('5', '(?<hour>[0-9]{1,2})')
|
|
29
|
-
.replace('17', '(?<hour>[0-9]{1,2})')
|
|
30
|
-
.replace('19', '(?<minute>[0-9]{1,2})')
|
|
31
|
-
.replace('22', '(?<second>[0-9]{1,2})')
|
|
32
|
-
.replace('PM', '(?<ampm>[A-Z]{2})')
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const rgx = RegExp(`${regex}`)
|
|
36
|
-
const partials = string.match(rgx)
|
|
37
|
-
|
|
38
|
-
if (partials === null) return
|
|
39
|
-
|
|
40
|
-
const newDate =
|
|
41
|
-
partials.groups &&
|
|
42
|
-
(time
|
|
43
|
-
? new Date(
|
|
44
|
-
Number(partials.groups['year']),
|
|
45
|
-
Number(partials.groups['month']) - 1,
|
|
46
|
-
Number(partials.groups['day']),
|
|
47
|
-
partials.groups['ampm']
|
|
48
|
-
? partials.groups['ampm'] === 'PM'
|
|
49
|
-
? Number(partials.groups['hour']) + 12
|
|
50
|
-
: Number(partials.groups['hour'])
|
|
51
|
-
: Number(partials.groups['hour']),
|
|
52
|
-
Number(partials.groups['minute']),
|
|
53
|
-
Number(partials.groups['second']),
|
|
54
|
-
)
|
|
55
|
-
: new Date(
|
|
56
|
-
Number(partials.groups['year']),
|
|
57
|
-
Number(partials.groups['month']) - 1,
|
|
58
|
-
Number(partials.groups['day']),
|
|
59
|
-
))
|
|
60
|
-
|
|
61
|
-
return newDate
|
|
62
|
-
}
|
|
63
|
-
|
|
64
18
|
export const getMonthName = (month: number, locale: string) => {
|
|
65
19
|
const d = new Date()
|
|
66
20
|
d.setDate(1)
|
|
@@ -2,7 +2,8 @@ import React, { forwardRef, HTMLAttributes } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { colorPropType } from '../../props'
|
|
6
|
+
import type { Colors } from '../../types'
|
|
6
7
|
|
|
7
8
|
export interface CCalloutProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
/**
|
|
@@ -2,7 +2,8 @@ import React, { forwardRef, HTMLAttributes } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { colorPropType, gradientsPropType } from '../../props'
|
|
6
|
+
import type { Colors, Gradients } from '../../types'
|
|
6
7
|
|
|
7
8
|
export interface CCardProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
/**
|
|
@@ -12,7 +12,7 @@ import PropTypes from 'prop-types'
|
|
|
12
12
|
import classNames from 'classnames'
|
|
13
13
|
|
|
14
14
|
import { isInViewport } from '../../utils'
|
|
15
|
-
import { useForkedRef } from '../../
|
|
15
|
+
import { useForkedRef } from '../../hooks'
|
|
16
16
|
|
|
17
17
|
export interface CCarouselProps extends HTMLAttributes<HTMLDivElement> {
|
|
18
18
|
/**
|
|
@@ -2,7 +2,7 @@ import React, { forwardRef, HTMLAttributes, useContext, useEffect, useState, use
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { useForkedRef } from '../../
|
|
5
|
+
import { useForkedRef } from '../../hooks'
|
|
6
6
|
import { CCarouselContext } from './CCarousel'
|
|
7
7
|
export interface CCarouselItemProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
8
|
/**
|
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { CSSTransition } from 'react-transition-group'
|
|
5
5
|
|
|
6
|
-
import { useForkedRef } from '../../
|
|
6
|
+
import { useForkedRef } from '../../hooks'
|
|
7
7
|
|
|
8
8
|
export interface CCollapseProps extends HTMLAttributes<HTMLDivElement> {
|
|
9
9
|
/**
|
|
@@ -23,7 +23,7 @@ export interface CDatePickerProps
|
|
|
23
23
|
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
24
24
|
*
|
|
25
25
|
* The name attribute for the input element is generated based on the `id` property:
|
|
26
|
-
* - {id}-date
|
|
26
|
+
* - \{id\}-date
|
|
27
27
|
*/
|
|
28
28
|
id?: string
|
|
29
29
|
/**
|
|
@@ -12,9 +12,9 @@ import { CFormControlWrapper, CFormControlWrapperProps } from '../form/CFormCont
|
|
|
12
12
|
import { CPicker, CPickerProps } from '../picker/CPicker'
|
|
13
13
|
import { CTimePicker } from '../time-picker/CTimePicker'
|
|
14
14
|
|
|
15
|
-
import { getLocalDateFromString } from '
|
|
15
|
+
import { getLocalDateFromString } from './utils'
|
|
16
16
|
|
|
17
|
-
import { Colors } from '
|
|
17
|
+
import { Colors } from '../../types'
|
|
18
18
|
export interface CDateRangePickerProps
|
|
19
19
|
extends Omit<CFormControlWrapperProps, 'floatingLabel'>,
|
|
20
20
|
Omit<CPickerProps, 'autoClose' | 'component' | 'dark' | 'placeholder' | 'variant'>,
|
|
@@ -46,8 +46,8 @@ export interface CDateRangePickerProps
|
|
|
46
46
|
* The id global attribute defines an identifier (ID) that must be unique in the whole document.
|
|
47
47
|
*
|
|
48
48
|
* The name attributes for input elements are generated based on the `id` property:
|
|
49
|
-
* - {id}-start-date
|
|
50
|
-
* - {id}-end-date
|
|
49
|
+
* - \{id\}-start-date
|
|
50
|
+
* - \{id\}-end-date
|
|
51
51
|
*/
|
|
52
52
|
id?: string
|
|
53
53
|
/**
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export const getLocalDateFromString = (string: string, locale: string, time?: boolean) => {
|
|
2
|
+
if (!isNaN(Date.parse(string))) {
|
|
3
|
+
return new Date(Date.parse(string))
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
const date = new Date(2013, 11, 31, 17, 19, 22)
|
|
7
|
+
let regex = time ? date.toLocaleString(locale) : date.toLocaleDateString(locale)
|
|
8
|
+
regex = regex
|
|
9
|
+
.replace('2013', '(?<year>[0-9]{2,4})')
|
|
10
|
+
.replace('12', '(?<month>[0-9]{1,2})')
|
|
11
|
+
.replace('31', '(?<day>[0-9]{1,2})')
|
|
12
|
+
|
|
13
|
+
if (time) {
|
|
14
|
+
regex = regex
|
|
15
|
+
.replace('5', '(?<hour>[0-9]{1,2})')
|
|
16
|
+
.replace('17', '(?<hour>[0-9]{1,2})')
|
|
17
|
+
.replace('19', '(?<minute>[0-9]{1,2})')
|
|
18
|
+
.replace('22', '(?<second>[0-9]{1,2})')
|
|
19
|
+
.replace('PM', '(?<ampm>[A-Z]{2})')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const rgx = RegExp(`${regex}`)
|
|
23
|
+
const partials = string.match(rgx)
|
|
24
|
+
|
|
25
|
+
if (partials === null) return
|
|
26
|
+
|
|
27
|
+
const newDate =
|
|
28
|
+
partials.groups &&
|
|
29
|
+
(time
|
|
30
|
+
? new Date(
|
|
31
|
+
Number(partials.groups['year']),
|
|
32
|
+
Number(partials.groups['month']) - 1,
|
|
33
|
+
Number(partials.groups['day']),
|
|
34
|
+
partials.groups['ampm']
|
|
35
|
+
? partials.groups['ampm'] === 'PM'
|
|
36
|
+
? Number(partials.groups['hour']) + 12
|
|
37
|
+
: Number(partials.groups['hour'])
|
|
38
|
+
: Number(partials.groups['hour']),
|
|
39
|
+
Number(partials.groups['minute']),
|
|
40
|
+
Number(partials.groups['second']),
|
|
41
|
+
)
|
|
42
|
+
: new Date(
|
|
43
|
+
Number(partials.groups['year']),
|
|
44
|
+
Number(partials.groups['month']) - 1,
|
|
45
|
+
Number(partials.groups['day']),
|
|
46
|
+
))
|
|
47
|
+
|
|
48
|
+
return newDate
|
|
49
|
+
}
|
|
@@ -12,8 +12,9 @@ import PropTypes from 'prop-types'
|
|
|
12
12
|
import classNames from 'classnames'
|
|
13
13
|
import { Manager } from 'react-popper'
|
|
14
14
|
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
15
|
+
import { useForkedRef } from '../../hooks'
|
|
16
|
+
import { placementPropType } from '../../props'
|
|
17
|
+
import type { Placements } from '../../types'
|
|
17
18
|
|
|
18
19
|
export type Directions = 'start' | 'end'
|
|
19
20
|
|
|
@@ -2,8 +2,7 @@ import React, { ElementType, forwardRef } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { CLinkProps } from '../link/CLink'
|
|
6
|
-
import { CLink } from '../link/CLink'
|
|
5
|
+
import { CLink, CLinkProps } from '../link/CLink'
|
|
7
6
|
|
|
8
7
|
export interface CDropdownItemProps extends CLinkProps {
|
|
9
8
|
/**
|
|
@@ -3,9 +3,10 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { Popper, PopperChildrenProps } from 'react-popper'
|
|
5
5
|
|
|
6
|
-
import { Placements } from '../Types'
|
|
7
6
|
import { Alignments, CDropdownContext } from './CDropdown'
|
|
8
7
|
|
|
8
|
+
import type { Placements } from '../../types'
|
|
9
|
+
|
|
9
10
|
export interface CDropdownMenuProps
|
|
10
11
|
extends HTMLAttributes<HTMLDivElement | HTMLUListElement>,
|
|
11
12
|
Omit<
|
|
@@ -3,13 +3,14 @@ import PropTypes from 'prop-types'
|
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
import { Reference } from 'react-popper'
|
|
5
5
|
|
|
6
|
-
import { useForkedRef } from '../../utils/hooks'
|
|
7
|
-
|
|
8
|
-
import { Triggers, triggerPropType } from '../Types'
|
|
9
|
-
|
|
10
6
|
import { CButton, CButtonProps } from '../button/CButton'
|
|
7
|
+
|
|
11
8
|
import { CDropdownContext } from './CDropdown'
|
|
12
9
|
|
|
10
|
+
import { useForkedRef } from '../../hooks'
|
|
11
|
+
import { triggerPropType } from '../../props'
|
|
12
|
+
import type { Triggers } from '../../types'
|
|
13
|
+
|
|
13
14
|
export interface CDropdownToggleProps extends Omit<CButtonProps, 'type'> {
|
|
14
15
|
/**
|
|
15
16
|
* Enables pseudo element caret on toggler.
|
|
@@ -9,7 +9,7 @@ import React, {
|
|
|
9
9
|
} from 'react'
|
|
10
10
|
import classNames from 'classnames'
|
|
11
11
|
|
|
12
|
-
import { useForkedRef } from '../../
|
|
12
|
+
import { useForkedRef } from '../../hooks'
|
|
13
13
|
import { CSpinner } from '../spinner/CSpinner'
|
|
14
14
|
|
|
15
15
|
interface CElementCoverProps extends HTMLAttributes<HTMLDivElement> {
|
|
@@ -21,14 +21,10 @@ interface CElementCoverProps extends HTMLAttributes<HTMLDivElement> {
|
|
|
21
21
|
* Array of custom boundaries. Use to create custom cover area (instead of parent element area). Area is defined by four sides: 'top', 'bottom', 'right', 'left'. If side is not defined by any custom boundary it is equal to parent element boundary. Each custom boundary is object with keys:
|
|
22
22
|
* - sides (array) - select boundaries of element to define boundaries. Sides names: 'top', 'bottom', 'right', 'left'.
|
|
23
23
|
* - query (string) - query used to get element which define boundaries. Search will be done only inside parent element, by parent.querySelector(query) function.
|
|
24
|
-
*
|
|
25
|
-
* @type {sides: string[], query: string}[]
|
|
26
24
|
*/
|
|
27
|
-
boundaries?: { sides: string[]; query: string }[]
|
|
25
|
+
boundaries?: { sides: string[]; query: string }[]
|
|
28
26
|
/**
|
|
29
27
|
* Opacity of the cover.
|
|
30
|
-
*
|
|
31
|
-
* @type number
|
|
32
28
|
*/
|
|
33
29
|
opacity?: number
|
|
34
30
|
}
|
|
@@ -36,17 +32,18 @@ export const CElementCover = forwardRef<HTMLDivElement, CElementCoverProps>(
|
|
|
36
32
|
({ children, className, boundaries, opacity = 0.4, ...rest }, ref) => {
|
|
37
33
|
const elementCoverRef = useRef<HTMLDivElement>(null)
|
|
38
34
|
const forkedRef = useForkedRef(ref, elementCoverRef)
|
|
39
|
-
|
|
40
35
|
const [customBoundaries, setCustomBoundaries] = useState({})
|
|
41
36
|
|
|
42
37
|
const getCustomBoundaries = () => {
|
|
43
38
|
if (!elementCoverRef || !elementCoverRef.current || !boundaries) {
|
|
44
39
|
return {}
|
|
45
40
|
}
|
|
41
|
+
|
|
46
42
|
const parent = elementCoverRef.current.parentElement
|
|
47
43
|
if (!parent) {
|
|
48
44
|
return {}
|
|
49
45
|
}
|
|
46
|
+
|
|
50
47
|
const parentCoords = parent.getBoundingClientRect()
|
|
51
48
|
const customBoundaries = {}
|
|
52
49
|
boundaries.forEach(({ sides, query }) => {
|
|
@@ -54,6 +51,7 @@ export const CElementCover = forwardRef<HTMLDivElement, CElementCoverProps>(
|
|
|
54
51
|
if (!element || !sides) {
|
|
55
52
|
return
|
|
56
53
|
}
|
|
54
|
+
|
|
57
55
|
const coords = element.getBoundingClientRect()
|
|
58
56
|
sides.forEach((side) => {
|
|
59
57
|
const sideMargin = Math.abs(coords[side] - parentCoords[side])
|
|
@@ -67,8 +65,6 @@ export const CElementCover = forwardRef<HTMLDivElement, CElementCoverProps>(
|
|
|
67
65
|
setCustomBoundaries(getCustomBoundaries())
|
|
68
66
|
}, [JSON.stringify(getCustomBoundaries())])
|
|
69
67
|
|
|
70
|
-
//render
|
|
71
|
-
|
|
72
68
|
const classes = classNames(className)
|
|
73
69
|
|
|
74
70
|
const containerCoords = {
|
|
@@ -82,23 +78,21 @@ export const CElementCover = forwardRef<HTMLDivElement, CElementCoverProps>(
|
|
|
82
78
|
const coverStyles: CSSProperties = {
|
|
83
79
|
...containerCoords,
|
|
84
80
|
position: 'absolute',
|
|
85
|
-
backgroundColor: `
|
|
81
|
+
backgroundColor: `rgba(255,255,255,${opacity})`,
|
|
86
82
|
}
|
|
87
83
|
|
|
88
84
|
return (
|
|
89
85
|
<div className={classes} style={coverStyles} {...rest} ref={forkedRef}>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
</div>
|
|
101
|
-
)}
|
|
86
|
+
<div
|
|
87
|
+
style={{
|
|
88
|
+
position: 'absolute',
|
|
89
|
+
top: '50%',
|
|
90
|
+
left: '50%',
|
|
91
|
+
transform: 'translateX(-50%) translateY(-50%)',
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{children || <CSpinner variant="grow" color="primary" />}
|
|
95
|
+
</div>
|
|
102
96
|
</div>
|
|
103
97
|
)
|
|
104
98
|
},
|
|
@@ -2,12 +2,12 @@ import React, { forwardRef, InputHTMLAttributes, ReactNode, useEffect, useRef }
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { useForkedRef } from '../../utils/hooks'
|
|
6
|
-
import { Colors, Shapes } from '../Types'
|
|
7
|
-
|
|
8
5
|
import { CFormControlValidation, CFormControlValidationProps } from './CFormControlValidation'
|
|
9
6
|
import { CFormLabel } from './CFormLabel'
|
|
10
7
|
|
|
8
|
+
import { useForkedRef } from '../../hooks'
|
|
9
|
+
import type { Colors, Shapes } from '../../types'
|
|
10
|
+
|
|
11
11
|
export type ButtonObject = {
|
|
12
12
|
/**
|
|
13
13
|
* Sets the color context of the component to one of CoreUI’s themed colors.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
ChangeEventHandler,
|
|
3
|
+
forwardRef,
|
|
4
|
+
InputHTMLAttributes,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react'
|
|
4
8
|
import PropTypes from 'prop-types'
|
|
9
|
+
import classNames from 'classnames'
|
|
5
10
|
|
|
6
11
|
import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
|
|
7
|
-
import { useEffect } from 'react'
|
|
8
12
|
|
|
9
13
|
export interface CFormInputProps
|
|
10
14
|
extends CFormControlWrapperProps,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes, ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames'
|
|
4
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import classNames from 'classnames'
|
|
5
4
|
|
|
6
5
|
import { CFormLabel } from './CFormLabel'
|
|
7
6
|
export interface CFormRangeProps extends InputHTMLAttributes<HTMLInputElement> {
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { ChangeEventHandler, forwardRef, InputHTMLAttributes } from 'react'
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames'
|
|
4
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import classNames from 'classnames'
|
|
5
4
|
|
|
6
5
|
import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
|
|
7
6
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { ChangeEventHandler, forwardRef, TextareaHTMLAttributes } from 'react'
|
|
2
|
-
|
|
3
|
-
import classNames from 'classnames'
|
|
4
2
|
import PropTypes from 'prop-types'
|
|
3
|
+
import classNames from 'classnames'
|
|
5
4
|
|
|
6
5
|
import { CFormControlWrapper, CFormControlWrapperProps } from './CFormControlWrapper'
|
|
7
6
|
|
package/src/components/index.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import React, { ElementType,
|
|
1
|
+
import React, { ElementType, AnchorHTMLAttributes, forwardRef } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { Colors, colorPropType } from '../Types'
|
|
6
5
|
import { CLink } from '../link/CLink'
|
|
7
6
|
|
|
7
|
+
import { colorPropType } from '../../props'
|
|
8
|
+
import type { Colors } from '../../types'
|
|
9
|
+
|
|
8
10
|
export interface CListGroupItemProps
|
|
9
|
-
extends
|
|
11
|
+
extends AnchorHTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement> {
|
|
10
12
|
/**
|
|
11
13
|
* Toggle the active state for the component.
|
|
12
14
|
*/
|
|
@@ -29,13 +31,12 @@ export interface CListGroupItemProps
|
|
|
29
31
|
* Component used for the root node. Either a string to use a HTML element or a component.
|
|
30
32
|
*/
|
|
31
33
|
component?: string | ElementType
|
|
32
|
-
href?: string
|
|
33
34
|
}
|
|
34
35
|
|
|
35
36
|
export const CListGroupItem = forwardRef<
|
|
36
|
-
HTMLLIElement | HTMLAnchorElement | HTMLButtonElement
|
|
37
|
+
HTMLLIElement | HTMLAnchorElement | HTMLButtonElement,
|
|
37
38
|
CListGroupItemProps
|
|
38
|
-
>(({ children, active, className, disabled,
|
|
39
|
+
>(({ children, active, className, disabled, color, component = 'li', ...rest }, ref) => {
|
|
39
40
|
const _className = classNames(
|
|
40
41
|
'list-group-item',
|
|
41
42
|
{
|
|
@@ -52,9 +53,8 @@ export const CListGroupItem = forwardRef<
|
|
|
52
53
|
rest = {
|
|
53
54
|
...((component === 'a' || component === 'button') && {
|
|
54
55
|
active,
|
|
55
|
-
component,
|
|
56
56
|
disabled,
|
|
57
|
-
|
|
57
|
+
component,
|
|
58
58
|
ref: ref,
|
|
59
59
|
}),
|
|
60
60
|
...(active && { 'aria-current': true }),
|
|
@@ -2,9 +2,11 @@ import React, { ElementType, AnchorHTMLAttributes, forwardRef } from 'react'
|
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
3
|
import classNames from 'classnames'
|
|
4
4
|
|
|
5
|
-
import { Colors, colorPropType } from '../Types'
|
|
6
5
|
import { CLink } from '../link/CLink'
|
|
7
6
|
|
|
7
|
+
import { colorPropType } from '../../props'
|
|
8
|
+
import type { Colors } from '../../types'
|
|
9
|
+
|
|
8
10
|
export interface CListGroupItemProps
|
|
9
11
|
extends AnchorHTMLAttributes<HTMLLIElement | HTMLAnchorElement | HTMLButtonElement> {
|
|
10
12
|
/**
|
|
@@ -13,12 +13,12 @@ import PropTypes from 'prop-types'
|
|
|
13
13
|
import classNames from 'classnames'
|
|
14
14
|
import { Transition } from 'react-transition-group'
|
|
15
15
|
|
|
16
|
-
import { useForkedRef } from '../../utils/hooks'
|
|
17
|
-
|
|
18
16
|
import { CBackdrop } from '../backdrop/CBackdrop'
|
|
19
17
|
import { CModalContent } from './CModalContent'
|
|
20
18
|
import { CModalDialog } from './CModalDialog'
|
|
21
19
|
|
|
20
|
+
import { useForkedRef } from '../../hooks'
|
|
21
|
+
|
|
22
22
|
export interface CModalProps extends HTMLAttributes<HTMLDivElement> {
|
|
23
23
|
/**
|
|
24
24
|
* Align the modal in the center or top of the screen.
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import React, { forwardRef, HTMLAttributes, useContext } from 'react'
|
|
2
2
|
import PropTypes from 'prop-types'
|
|
3
|
-
import { CModalContext } from './CModal'
|
|
4
|
-
import { CCloseButton } from '../close-button/CCloseButton'
|
|
5
3
|
import classNames from 'classnames'
|
|
6
4
|
|
|
5
|
+
import { CCloseButton } from '../close-button/CCloseButton'
|
|
6
|
+
import { CModalContext } from './CModal'
|
|
7
|
+
|
|
7
8
|
export interface CModalHeaderProps extends HTMLAttributes<HTMLDivElement> {
|
|
8
9
|
/**
|
|
9
10
|
* A string of all className you want applied to the base component.
|