@coreui/react 5.8.0 → 5.9.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/cjs/components/dropdown/CDropdown.d.ts +21 -1
- package/dist/cjs/components/dropdown/CDropdown.js +67 -33
- package/dist/cjs/components/dropdown/CDropdown.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownHeader.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownItemPlain.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownMenu.js.map +1 -1
- package/dist/cjs/components/dropdown/CDropdownToggle.d.ts +7 -0
- package/dist/cjs/components/dropdown/CDropdownToggle.js +3 -2
- package/dist/cjs/components/dropdown/CDropdownToggle.js.map +1 -1
- package/dist/cjs/components/dropdown/utils.d.ts +2 -0
- package/dist/cjs/components/dropdown/utils.js +13 -0
- package/dist/cjs/components/dropdown/utils.js.map +1 -1
- package/dist/cjs/components/focus-trap/CFocusTrap.js +23 -6
- package/dist/cjs/components/focus-trap/CFocusTrap.js.map +1 -1
- package/dist/cjs/components/focus-trap/utils.d.ts +10 -0
- package/dist/cjs/components/focus-trap/utils.js +25 -5
- package/dist/cjs/components/focus-trap/utils.js.map +1 -1
- package/dist/cjs/components/modal/CModal.js +10 -11
- package/dist/cjs/components/modal/CModal.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdown.d.ts +21 -1
- package/dist/esm/components/dropdown/CDropdown.js +68 -34
- package/dist/esm/components/dropdown/CDropdown.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownHeader.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownItemPlain.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownMenu.js.map +1 -1
- package/dist/esm/components/dropdown/CDropdownToggle.d.ts +7 -0
- package/dist/esm/components/dropdown/CDropdownToggle.js +3 -2
- package/dist/esm/components/dropdown/CDropdownToggle.js.map +1 -1
- package/dist/esm/components/dropdown/utils.d.ts +2 -0
- package/dist/esm/components/dropdown/utils.js +13 -1
- package/dist/esm/components/dropdown/utils.js.map +1 -1
- package/dist/esm/components/focus-trap/CFocusTrap.js +24 -7
- package/dist/esm/components/focus-trap/CFocusTrap.js.map +1 -1
- package/dist/esm/components/focus-trap/utils.d.ts +10 -0
- package/dist/esm/components/focus-trap/utils.js +25 -6
- package/dist/esm/components/focus-trap/utils.js.map +1 -1
- package/dist/esm/components/modal/CModal.js +10 -11
- package/dist/esm/components/modal/CModal.js.map +1 -1
- package/package.json +10 -10
- package/src/components/dropdown/CDropdown.tsx +126 -60
- package/src/components/dropdown/CDropdownHeader.tsx +1 -0
- package/src/components/dropdown/CDropdownItemPlain.tsx +1 -0
- package/src/components/dropdown/CDropdownMenu.tsx +1 -0
- package/src/components/dropdown/CDropdownToggle.tsx +15 -1
- package/src/components/dropdown/utils.ts +21 -0
- package/src/components/focus-trap/CFocusTrap.tsx +33 -8
- package/src/components/focus-trap/utils.ts +24 -6
- package/src/components/modal/CModal.tsx +30 -31
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/v5.
|
|
49
|
+
- [Download the latest release](https://github.com/coreui/coreui-react/archive/v5.9.1.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`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ElementType, HTMLAttributes } from 'react';
|
|
1
|
+
import React, { ElementType, HTMLAttributes } from 'react';
|
|
2
2
|
import type { Options } from '@popperjs/core';
|
|
3
3
|
import { PolymorphicRefForwardingComponent } from '../../helpers';
|
|
4
4
|
import type { Placements } from '../../types';
|
|
@@ -126,6 +126,26 @@ export interface CDropdownProps extends HTMLAttributes<HTMLDivElement | HTMLLIEl
|
|
|
126
126
|
* @since 4.8.0
|
|
127
127
|
*/
|
|
128
128
|
portal?: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* Sets the reference element for positioning the React Dropdown Menu.
|
|
131
|
+
* - `toggle` - The React Dropdown Toggle button (default).
|
|
132
|
+
* - `parent` - The React Dropdown wrapper element.
|
|
133
|
+
* - `HTMLElement` - A custom HTML element.
|
|
134
|
+
* - `React.RefObject` - A custom reference element.
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* // Use the parent element as reference for positioning
|
|
138
|
+
* <CDropdown reference="parent">
|
|
139
|
+
* <CDropdownToggle>Toggle dropdown</CDropdownToggle>
|
|
140
|
+
* <CDropdownMenu>
|
|
141
|
+
* <CDropdownItem>Action</CDropdownItem>
|
|
142
|
+
* <CDropdownItem>Another Action</CDropdownItem>
|
|
143
|
+
* </CDropdownMenu>
|
|
144
|
+
* </CDropdown>
|
|
145
|
+
*
|
|
146
|
+
* @since 5.9.0
|
|
147
|
+
*/
|
|
148
|
+
reference?: 'parent' | 'toggle' | HTMLElement | React.RefObject<HTMLElement | null>;
|
|
129
149
|
/**
|
|
130
150
|
* Defines the visual variant of the React Dropdown
|
|
131
151
|
*/
|
|
@@ -11,9 +11,10 @@ var props = require('../../props.js');
|
|
|
11
11
|
var getNextActiveElement = require('../../utils/getNextActiveElement.js');
|
|
12
12
|
var isRTL = require('../../utils/isRTL.js');
|
|
13
13
|
var utils = require('./utils.js');
|
|
14
|
+
var CFocusTrap = require('../focus-trap/CFocusTrap.js');
|
|
14
15
|
|
|
15
16
|
const CDropdown = React.forwardRef((_a, ref) => {
|
|
16
|
-
var { children, alignment, as = 'div', autoClose = true, className, container, dark, direction, offset = [0, 2], onHide, onShow, placement = 'bottom-start', popper = true, popperConfig, portal = false, variant = 'btn-group', visible = false } = _a, rest = tslib_es6.__rest(_a, ["children", "alignment", "as", "autoClose", "className", "container", "dark", "direction", "offset", "onHide", "onShow", "placement", "popper", "popperConfig", "portal", "variant", "visible"]);
|
|
17
|
+
var { children, alignment, as = 'div', autoClose = true, className, container, dark, direction, offset = [0, 2], onHide, onShow, placement = 'bottom-start', popper = true, popperConfig, portal = false, reference = 'toggle', variant = 'btn-group', visible = false } = _a, rest = tslib_es6.__rest(_a, ["children", "alignment", "as", "autoClose", "className", "container", "dark", "direction", "offset", "onHide", "onShow", "placement", "popper", "popperConfig", "portal", "reference", "variant", "visible"]);
|
|
17
18
|
const dropdownRef = React.useRef(null);
|
|
18
19
|
const dropdownMenuRef = React.useRef(null);
|
|
19
20
|
const forkedRef = useForkedRef.useForkedRef(ref, dropdownRef);
|
|
@@ -51,12 +52,19 @@ const CDropdown = React.forwardRef((_a, ref) => {
|
|
|
51
52
|
}
|
|
52
53
|
}, [visible]);
|
|
53
54
|
React.useEffect(() => {
|
|
54
|
-
|
|
55
|
+
return () => {
|
|
56
|
+
if (_visible) {
|
|
57
|
+
handleHide();
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
}, []);
|
|
61
|
+
React.useEffect(() => {
|
|
62
|
+
const referenceElement = utils.getReferenceElement(reference, dropdownToggleElement, dropdownRef);
|
|
55
63
|
const menuElement = dropdownMenuRef.current;
|
|
56
|
-
if (allowPopperUse && menuElement &&
|
|
57
|
-
initPopper(
|
|
64
|
+
if (allowPopperUse && menuElement && referenceElement && _visible) {
|
|
65
|
+
initPopper(referenceElement, menuElement, computedPopperConfig);
|
|
58
66
|
}
|
|
59
|
-
}, [dropdownToggleElement]);
|
|
67
|
+
}, [dropdownToggleElement, reference]);
|
|
60
68
|
React.useEffect(() => {
|
|
61
69
|
if (pendingKeyDownEvent !== null) {
|
|
62
70
|
handleKeydown(pendingKeyDownEvent);
|
|
@@ -65,19 +73,22 @@ const CDropdown = React.forwardRef((_a, ref) => {
|
|
|
65
73
|
}, [pendingKeyDownEvent]);
|
|
66
74
|
const handleHide = React.useCallback(() => {
|
|
67
75
|
setVisible(false);
|
|
68
|
-
const toggleElement = dropdownToggleElement;
|
|
69
76
|
const menuElement = dropdownMenuRef.current;
|
|
77
|
+
const toggleElement = dropdownToggleElement;
|
|
70
78
|
if (allowPopperUse) {
|
|
71
79
|
destroyPopper();
|
|
72
80
|
}
|
|
73
|
-
toggleElement === null || toggleElement === void 0 ? void 0 : toggleElement.removeEventListener('keydown', handleKeydown);
|
|
74
81
|
menuElement === null || menuElement === void 0 ? void 0 : menuElement.removeEventListener('keydown', handleKeydown);
|
|
75
|
-
|
|
82
|
+
toggleElement === null || toggleElement === void 0 ? void 0 : toggleElement.removeEventListener('keydown', handleKeydown);
|
|
83
|
+
window.removeEventListener('click', handleClick);
|
|
76
84
|
window.removeEventListener('keyup', handleKeyup);
|
|
77
85
|
onHide === null || onHide === void 0 ? void 0 : onHide();
|
|
78
|
-
}, [
|
|
86
|
+
}, [allowPopperUse, dropdownToggleElement, destroyPopper, onHide]);
|
|
79
87
|
const handleKeydown = React.useCallback((event) => {
|
|
80
|
-
if (dropdownMenuRef.current
|
|
88
|
+
if (!dropdownMenuRef.current) {
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (event.key === 'ArrowDown' || event.key === 'ArrowUp') {
|
|
81
92
|
event.preventDefault();
|
|
82
93
|
const target = event.target;
|
|
83
94
|
const items = [
|
|
@@ -94,35 +105,44 @@ const CDropdown = React.forwardRef((_a, ref) => {
|
|
|
94
105
|
handleHide();
|
|
95
106
|
dropdownToggleElement === null || dropdownToggleElement === void 0 ? void 0 : dropdownToggleElement.focus();
|
|
96
107
|
}
|
|
97
|
-
}, [autoClose, handleHide]);
|
|
98
|
-
const
|
|
108
|
+
}, [autoClose, dropdownToggleElement, handleHide]);
|
|
109
|
+
const handleClick = React.useCallback((event) => {
|
|
99
110
|
if (!dropdownToggleElement || !dropdownMenuRef.current) {
|
|
100
111
|
return;
|
|
101
112
|
}
|
|
102
|
-
if (
|
|
113
|
+
if (event.button === 2) {
|
|
103
114
|
return;
|
|
104
115
|
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
!dropdownMenuRef.current.contains(event.target))) {
|
|
110
|
-
setTimeout(() => handleHide(), 1);
|
|
116
|
+
const composedPath = event.composedPath();
|
|
117
|
+
const isOnToggle = composedPath.includes(dropdownToggleElement);
|
|
118
|
+
const isOnMenu = composedPath.includes(dropdownMenuRef.current);
|
|
119
|
+
if (isOnToggle) {
|
|
111
120
|
return;
|
|
112
121
|
}
|
|
122
|
+
const target = event.target;
|
|
123
|
+
const FORM_TAG_RE = /^(input|select|option|textarea|form|button|label)$/i;
|
|
124
|
+
if (isOnMenu && target && FORM_TAG_RE.test(target.tagName)) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (autoClose === true ||
|
|
128
|
+
(autoClose === 'inside' && isOnMenu) ||
|
|
129
|
+
(autoClose === 'outside' && !isOnMenu)) {
|
|
130
|
+
handleHide();
|
|
131
|
+
}
|
|
113
132
|
}, [autoClose, dropdownToggleElement, handleHide]);
|
|
114
133
|
const handleShow = React.useCallback((event) => {
|
|
115
|
-
const toggleElement = dropdownToggleElement;
|
|
116
134
|
const menuElement = dropdownMenuRef.current;
|
|
117
|
-
|
|
135
|
+
const referenceElement = utils.getReferenceElement(reference, dropdownToggleElement, dropdownRef);
|
|
136
|
+
const toggleElement = dropdownToggleElement;
|
|
137
|
+
if (menuElement && referenceElement && toggleElement) {
|
|
118
138
|
setVisible(true);
|
|
119
139
|
if (allowPopperUse) {
|
|
120
|
-
initPopper(
|
|
140
|
+
initPopper(referenceElement, menuElement, computedPopperConfig);
|
|
121
141
|
}
|
|
122
142
|
toggleElement.focus();
|
|
123
143
|
toggleElement.addEventListener('keydown', handleKeydown);
|
|
124
144
|
menuElement.addEventListener('keydown', handleKeydown);
|
|
125
|
-
window.addEventListener('
|
|
145
|
+
window.addEventListener('click', handleClick);
|
|
126
146
|
window.addEventListener('keyup', handleKeyup);
|
|
127
147
|
if (event && (event.key === 'ArrowDown' || event.key === 'ArrowUp')) {
|
|
128
148
|
setPendingKeyDownEvent(event);
|
|
@@ -130,16 +150,17 @@ const CDropdown = React.forwardRef((_a, ref) => {
|
|
|
130
150
|
onShow === null || onShow === void 0 ? void 0 : onShow();
|
|
131
151
|
}
|
|
132
152
|
}, [
|
|
133
|
-
dropdownToggleElement,
|
|
134
153
|
allowPopperUse,
|
|
135
|
-
initPopper,
|
|
136
154
|
computedPopperConfig,
|
|
155
|
+
dropdownToggleElement,
|
|
156
|
+
reference,
|
|
157
|
+
handleClick,
|
|
137
158
|
handleKeydown,
|
|
138
|
-
handleMouseUp,
|
|
139
159
|
handleKeyup,
|
|
160
|
+
initPopper,
|
|
140
161
|
onShow,
|
|
141
162
|
]);
|
|
142
|
-
const contextValues = {
|
|
163
|
+
const contextValues = React.useMemo(() => ({
|
|
143
164
|
alignment,
|
|
144
165
|
container,
|
|
145
166
|
dark,
|
|
@@ -151,12 +172,25 @@ const CDropdown = React.forwardRef((_a, ref) => {
|
|
|
151
172
|
portal,
|
|
152
173
|
variant,
|
|
153
174
|
visible: _visible,
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
175
|
+
}), [
|
|
176
|
+
alignment,
|
|
177
|
+
container,
|
|
178
|
+
dark,
|
|
179
|
+
dropdownMenuRef,
|
|
180
|
+
dropdownToggleRef,
|
|
181
|
+
handleHide,
|
|
182
|
+
handleShow,
|
|
183
|
+
allowPopperUse,
|
|
184
|
+
portal,
|
|
185
|
+
variant,
|
|
186
|
+
_visible,
|
|
187
|
+
]);
|
|
188
|
+
return (React.createElement(CDropdownContext.CDropdownContext.Provider, { value: contextValues },
|
|
189
|
+
React.createElement(CFocusTrap.CFocusTrap, { active: portal && _visible, additionalContainer: dropdownMenuRef, restoreFocus: true }, variant === 'input-group' ? (React.createElement(React.Fragment, null, children)) : (React.createElement(Component, Object.assign({ className: index.default(variant === 'nav-item' ? 'nav-item dropdown' : variant, {
|
|
190
|
+
'dropdown-center': direction === 'center',
|
|
191
|
+
'dropup dropup-center': direction === 'dropup-center',
|
|
192
|
+
[`${direction}`]: direction && direction !== 'center' && direction !== 'dropup-center',
|
|
193
|
+
}, className) }, rest, { ref: forkedRef }), children)))));
|
|
160
194
|
});
|
|
161
195
|
const alignmentDirection = PropTypes.oneOf(['start', 'end']);
|
|
162
196
|
CDropdown.propTypes = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CDropdown.js","sources":["../../../../src/components/dropdown/CDropdown.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","useRef","useForkedRef","useState","usePopper","useCallback","useMemo","getPlacement","isRTL","useEffect","getNextActiveElement","CDropdownContext","classNames","placementPropType"],"mappings":"
|
|
1
|
+
{"version":3,"file":"CDropdown.js","sources":["../../../../src/components/dropdown/CDropdown.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","useRef","useForkedRef","useState","usePopper","useCallback","useMemo","getPlacement","isRTL","useEffect","getReferenceElement","getNextActiveElement","CDropdownContext","CFocusTrap","classNames","placementPropType"],"mappings":";;;;;;;;;;;;;;;AA8MO,MAAM,SAAS,GAA6DA,gBAAU,CAI3F,CACE,EAoBC,EACD,GAAG,KACD;AAtBF,IAAA,IAAA,EACE,QAAQ,EACR,SAAS,EACT,EAAE,GAAG,KAAK,EACV,SAAS,GAAG,IAAI,EAChB,SAAS,EACT,SAAS,EACT,IAAI,EACJ,SAAS,EACT,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACf,MAAM,EACN,MAAM,EACN,SAAS,GAAG,cAAc,EAC1B,MAAM,GAAG,IAAI,EACb,YAAY,EACZ,MAAM,GAAG,KAAK,EACd,SAAS,GAAG,QAAQ,EACpB,OAAO,GAAG,WAAW,EACrB,OAAO,GAAG,KAAK,EAAA,GAAA,EAEhB,EADI,IAAI,GAAAC,gBAAA,CAAA,EAAA,EAnBT,6MAoBC,CADQ;AAIT,IAAA,MAAM,WAAW,GAAGC,YAAM,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Header.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","classNames"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"CDropdownHeader.js","sources":["../../../../src/components/dropdown/CDropdownHeader.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","classNames"],"mappings":";;;;;;;AAkBO,MAAM,eAAe,GAC1BA,gBAAU,CACR,CAAC,EAAsD,EAAE,GAAG,KAAI;AAA/D,IAAA,IAAA,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,SAAS,EAAA,GAAA,EAAW,EAAN,IAAI,GAAAC,gBAAA,CAAA,EAAA,EAApD,+BAAsD,CAAF;IACnD,QACE,oBAAC,SAAS,EAAA,MAAA,CAAA,MAAA,CAAA,EAAC,SAAS,EAAEC,aAAU,CAAC,iBAAiB,EAAE,SAAS,CAAC,EAAA,EAAM,IAAI,IAAE,GAAG,EAAE,GAAG,EAAA,CAAA,EAC/E,QAAQ,CACC;AAEhB,CAAC;AAGL,eAAe,CAAC,SAAS,GAAG;IAC1B,EAAE,EAAE,SAAS,CAAC,WAAW;IACzB,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,SAAS,EAAE,SAAS,CAAC,MAAM;CAC5B;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CDropdownItemPlain.js","sources":["../../../../src/components/dropdown/CDropdownItemPlain.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","classNames"],"mappings":";;;;;;;
|
|
1
|
+
{"version":3,"file":"CDropdownItemPlain.js","sources":["../../../../src/components/dropdown/CDropdownItemPlain.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","classNames"],"mappings":";;;;;;;AAkBO,MAAM,kBAAkB,GAG3BA,gBAAU,CACZ,CAAC,EAAwD,EAAE,GAAG,KAAI;AAAjE,IAAA,IAAA,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,MAAM,EAAE,SAAS,EAAA,GAAA,EAAW,EAAN,IAAI,GAAAC,gBAAA,CAAA,EAAA,EAAtD,+BAAwD,CAAF;IACrD,QACE,oBAAC,SAAS,EAAA,MAAA,CAAA,MAAA,CAAA,EAAC,SAAS,EAAEC,aAAU,CAAC,oBAAoB,EAAE,SAAS,CAAC,EAAA,EAAM,IAAI,IAAE,GAAG,EAAE,GAAG,EAAA,CAAA,EAClF,QAAQ,CACC;AAEhB,CAAC;AAGH,kBAAkB,CAAC,SAAS,GAAG;IAC7B,EAAE,EAAE,SAAS,CAAC,WAAW;IACzB,QAAQ,EAAE,SAAS,CAAC,IAAI;IACxB,SAAS,EAAE,SAAS,CAAC,MAAM;CAC5B;AAED,kBAAkB,CAAC,WAAW,GAAG,oBAAoB;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CDropdownMenu.js","sources":["../../../../src/components/dropdown/CDropdownMenu.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","useContext","CDropdownContext","useForkedRef","CConditionalPortal","classNames","getAlignmentClassNames"],"mappings":";;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CDropdownMenu.js","sources":["../../../../src/components/dropdown/CDropdownMenu.tsx"],"sourcesContent":[null],"names":["forwardRef","__rest","useContext","CDropdownContext","useForkedRef","CConditionalPortal","classNames","getAlignmentClassNames"],"mappings":";;;;;;;;;;;;AAwBO,MAAM,aAAa,GACxBA,gBAAU,CACR,CAAC,EAAsD,EAAE,GAAG,KAAI;AAA/D,IAAA,IAAA,EAAE,QAAQ,EAAE,EAAE,EAAE,SAAS,GAAG,IAAI,EAAE,SAAS,EAAA,GAAA,EAAW,EAAN,IAAI,GAAAC,gBAAA,CAAA,EAAA,EAApD,+BAAsD,CAAF;IACnD,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,GAC5EC,gBAAU,CAACC,iCAAgB,CAAC;I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leProps extends Omit<CButtonProps, 'type'> {
|
|
|
23
23
|
* className for proper spacing around the dropdown caret.
|
|
24
24
|
*/
|
|
25
25
|
split?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Screen reader label for split button dropdown toggle.
|
|
28
|
+
*
|
|
29
|
+
* @default 'Toggle Dropdown'
|
|
30
|
+
* @since 5.9.0
|
|
31
|
+
*/
|
|
32
|
+
splitLabel?: string;
|
|
26
33
|
/**
|
|
27
34
|
* Sets which event handlers you'd like provided to your toggle prop. You can
|
|
28
35
|
* specify one trigger or an array of them.
|
|
@@ -9,7 +9,7 @@ var CDropdownContext = require('./CDropdownContext.js');
|
|
|
9
9
|
var props = require('../../props.js');
|
|
10
10
|
|
|
11
11
|
const CDropdownToggle = (_a) => {
|
|
12
|
-
var { children, caret = true, custom, className, navLink = true, split, trigger = 'click' } = _a, rest = tslib_es6.__rest(_a, ["children", "caret", "custom", "className", "navLink", "split", "trigger"]);
|
|
12
|
+
var { children, caret = true, custom, className, navLink = true, split, splitLabel = 'Toggle Dropdown', trigger = 'click' } = _a, rest = tslib_es6.__rest(_a, ["children", "caret", "custom", "className", "navLink", "split", "splitLabel", "trigger"]);
|
|
13
13
|
const { dropdownToggleRef, handleHide, handleShow, variant, visible } = React.useContext(CDropdownContext.CDropdownContext);
|
|
14
14
|
const triggers = Object.assign(Object.assign(Object.assign({}, ((trigger === 'click' || trigger.includes('click')) && {
|
|
15
15
|
onClick: (event) => {
|
|
@@ -44,7 +44,7 @@ const CDropdownToggle = (_a) => {
|
|
|
44
44
|
}
|
|
45
45
|
return (React.createElement(CButton.CButton, Object.assign({}, togglerProps, { tabIndex: 0 }, rest, { ref: dropdownToggleRef }),
|
|
46
46
|
children,
|
|
47
|
-
split && React.createElement("span", { className: "visually-hidden" },
|
|
47
|
+
split && React.createElement("span", { className: "visually-hidden" }, splitLabel)));
|
|
48
48
|
};
|
|
49
49
|
CDropdownToggle.propTypes = {
|
|
50
50
|
caret: PropTypes.bool,
|
|
@@ -52,6 +52,7 @@ CDropdownToggle.propTypes = {
|
|
|
52
52
|
className: PropTypes.string,
|
|
53
53
|
custom: PropTypes.bool,
|
|
54
54
|
split: PropTypes.bool,
|
|
55
|
+
splitLabel: PropTypes.string,
|
|
55
56
|
trigger: props.triggerPropType,
|
|
56
57
|
};
|
|
57
58
|
CDropdownToggle.displayName = 'CDropdownToggle';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CDropdownToggle.js","sources":["../../../../src/components/dropdown/CDropdownToggle.tsx"],"sourcesContent":[null],"names":["__rest","useContext","CDropdownContext","classNames","CButton","triggerPropType"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"CDropdownToggle.js","sources":["../../../../src/components/dropdown/CDropdownToggle.tsx"],"sourcesContent":[null],"names":["__rest","useContext","CDropdownContext","classNames","CButton","triggerPropType"],"mappings":";;;;;;;;;;AAqDO,MAAM,eAAe,GAA6B,CAAC,EAUzD,KAAI;AAVqD,IAAA,IAAA,EACxD,QAAQ,EACR,KAAK,GAAG,IAAI,EACZ,MAAM,EACN,SAAS,EACT,OAAO,GAAG,IAAI,EACd,KAAK,EACL,UAAU,GAAG,iBAAiB,EAC9B,OAAO,GAAG,OAAO,EAAA,GAAA,EAElB,EADI,IAAI,GAAAA,gBAAA,CAAA,EAAA,EATiD,CAAA,UAAA,EAAA,OAAA,EAAA,QAAA,EAAA,WAAA,EAAA,SAAA,EAAA,OAAA,EAAA,YAAA,EAAA,SAAA,CAUzD,CADQ;AAEP,IAAA,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,GACnEC,gBAAU,CAACC,iCAAgB,CAAC;AAE9B,IAAA,MAAM,QAAQ,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,GACR,CAAC,OAAO,KAAK,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,OAAO,CA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AAM;AAC5B,IAAA,OAAO,EAAEC,qBAAe;CACzB;AAED,eAAe,CAAC,WAAW,GAAG,iBAAiB;;;;"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import React from 'react';
|
|
1
2
|
import type { Placement } from '@popperjs/core';
|
|
2
3
|
import type { Placements } from '../../types';
|
|
3
4
|
import type { Alignments } from './types';
|
|
4
5
|
export declare const getAlignmentClassNames: (alignment: Alignments) => string[];
|
|
5
6
|
export declare const getPlacement: (placement: Placement, direction: string | undefined, alignment: Alignments | string | undefined, isRTL: boolean) => Placements;
|
|
7
|
+
export declare const getReferenceElement: (reference: "parent" | "toggle" | React.RefObject<HTMLElement | null> | HTMLElement, dropdownToggleElement: HTMLElement | null, dropdownRef: React.RefObject<HTMLElement | null>) => HTMLElement | null;
|
|
@@ -31,7 +31,20 @@ const getPlacement = (placement, direction, alignment, isRTL) => {
|
|
|
31
31
|
}
|
|
32
32
|
return _placement;
|
|
33
33
|
};
|
|
34
|
+
const getReferenceElement = (reference, dropdownToggleElement, dropdownRef) => {
|
|
35
|
+
if (reference === 'parent') {
|
|
36
|
+
return dropdownRef.current;
|
|
37
|
+
}
|
|
38
|
+
if (reference instanceof HTMLElement) {
|
|
39
|
+
return reference;
|
|
40
|
+
}
|
|
41
|
+
if (reference instanceof Object && 'current' in reference) {
|
|
42
|
+
return reference.current;
|
|
43
|
+
}
|
|
44
|
+
return dropdownToggleElement;
|
|
45
|
+
};
|
|
34
46
|
|
|
35
47
|
exports.getAlignmentClassNames = getAlignmentClassNames;
|
|
36
48
|
exports.getPlacement = getPlacement;
|
|
49
|
+
exports.getReferenceElement = getReferenceElement;
|
|
37
50
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/components/dropdown/utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/dropdown/utils.ts"],"sourcesContent":[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A,IAAI,SAAS,KAAK,QAAQ,EAAE;QAC1B,OAAO,WAAW,CAAC,OAAO;IAC5B;AAEA,IAAA,IAAI,SAAS,YAAY,WAAW,EAAE;AACpC,QAAA,OAAO,SAAS;IAClB;IAEA,IAAI,SAAS,YAAY,MAAM,IAAI,SAAS,IAAI,SAAS,EAAE;QACzD,OAAO,SAAS,CAAC,OAAO;IAC1B;AAEA,IAAA,OAAO,qBAAqB;AAC9B;;;;;;"}
|
|
@@ -64,8 +64,9 @@ const CFocusTrap = ({ active = true, additionalContainer, children, focusFirstEl
|
|
|
64
64
|
const elements = utils.focusableChildren(container);
|
|
65
65
|
if (elements.length === 0) {
|
|
66
66
|
container.focus({ preventScroll: true });
|
|
67
|
+
return;
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
+
if (lastTabNavDirectionRef.current === 'backward') {
|
|
69
70
|
(_a = elements.at(-1)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
70
71
|
}
|
|
71
72
|
else {
|
|
@@ -79,17 +80,30 @@ const CFocusTrap = ({ active = true, additionalContainer, children, focusFirstEl
|
|
|
79
80
|
}
|
|
80
81
|
tabEventSourceRef.current = container;
|
|
81
82
|
lastTabNavDirectionRef.current = event.shiftKey ? 'backward' : 'forward';
|
|
82
|
-
if (!_additionalContainer) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
83
|
const containerElements = utils.focusableChildren(container);
|
|
86
|
-
const additionalElements = utils.focusableChildren(_additionalContainer);
|
|
84
|
+
const additionalElements = _additionalContainer ? utils.focusableChildren(_additionalContainer) : [];
|
|
87
85
|
if (containerElements.length === 0 && additionalElements.length === 0) {
|
|
88
86
|
// No focusable elements, prevent tab
|
|
89
87
|
event.preventDefault();
|
|
90
88
|
return;
|
|
91
89
|
}
|
|
90
|
+
const focusableElements = [...containerElements, ...additionalElements];
|
|
91
|
+
const firstFocusableElement = focusableElements[0];
|
|
92
|
+
const lastFocusableElement = focusableElements.at(-1);
|
|
92
93
|
const activeElement = document.activeElement;
|
|
94
|
+
if (event.shiftKey && activeElement === firstFocusableElement) {
|
|
95
|
+
event.preventDefault();
|
|
96
|
+
lastFocusableElement.focus();
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (!event.shiftKey && activeElement === lastFocusableElement) {
|
|
100
|
+
event.preventDefault();
|
|
101
|
+
firstFocusableElement.focus();
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
if (!_additionalContainer) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
93
107
|
const isInContainer = containerElements.includes(activeElement);
|
|
94
108
|
const isInAdditional = additionalElements.includes(activeElement);
|
|
95
109
|
// Handle tab navigation between container and additional elements
|
|
@@ -151,7 +165,10 @@ const CFocusTrap = ({ active = true, additionalContainer, children, focusFirstEl
|
|
|
151
165
|
}, [active, additionalContainer, focusFirstElement, onActivate, onDeactivate, restoreFocus]);
|
|
152
166
|
// Attach our ref to the ONLY child — no extra wrappers
|
|
153
167
|
const onlyChild = React.Children.only(children);
|
|
154
|
-
|
|
168
|
+
// Handle different ref access patterns between React versions
|
|
169
|
+
// React 19+: ref is accessed via element.props.ref
|
|
170
|
+
// React 18 and earlier: ref is accessed via element.ref
|
|
171
|
+
const childRef = utils.getChildRef(onlyChild);
|
|
155
172
|
const mergedRef = utils.mergeRefs(childRef, (node) => {
|
|
156
173
|
containerRef.current = node;
|
|
157
174
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CFocusTrap.js","sources":["../../../../src/components/focus-trap/CFocusTrap.tsx"],"sourcesContent":[null],"names":["useRef","useEffect","focusableChildren","mergeRefs","cloneElement"],"mappings":";;;;;AAmEO,MAAM,UAAU,GAAwB,CAAC,EAC9C,MAAM,GAAG,IAAI,EACb,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,GAAG,KAAK,EACzB,UAAU,EACV,YAAY,EACZ,YAAY,GAAG,IAAI,GACpB,KAAI;AACH,IAAA,MAAM,YAAY,GAAGA,YA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,EAAE;AACvB,gBAAA,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;YAC5C;iBAAO;;gBAEL,SAAS,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;YAC1C;QACF;aAAO;YACL,SAAS,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;QAC1C;AAEA,QAAA,UAAU,KAAA,IAAA,IAAV,UAAU,KAAA,MAAA,GAAA,MAAA,GAAV,UAAU,EAAI;AAEd,QAAA,MAAM,aAAa,GAAG,CAAC,KAAiB,KAAI;;;YAE1C,IAAI,YAAY,CAAC,OAAO,KAAK,iBAAiB,CAAC,OAAO,EAAE;gBACtD;YACF;AAEA,YAAA,MAAM,MAAM,GAAG,KAAK,CAAC,MAAc;;AAGnC,YAAA,IAAI,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,SAAS,IAAI,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;gBAC7E;YACF;;AAGA,YAAA,IACE,oBAAoB;AACpB,iBAAC,MAAM,KAAK,oBAAoB,IAAI,oBAAoB,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAC1E;gBACA;YACF;;AAGA,YAAA,MAAM,QAAQ,GAAGA,uBAAiB,CAAC,SAAS,CAAC;AAE7C,YAAA,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;gBACzB,SAAS,CAAC,KAAK,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"CFocusTrap.js","sources":["../../../../src/components/focus-trap/CFocusTrap.tsx"],"sourcesContent":[null],"names":["useRef","useEffect","focusableChildren","getChildRef","mergeRefs","cloneElement"],"mappings":";;;;;AAmEO,MAAM,UAAU,GAAwB,CAAC,EAC9C,MAAM,GAAG,IAAI,EACb,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,GAAG,KAAK,E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A,YAAY,KAAA,IAAA,IAAZ,YAAY,KAAA,MAAA,GAAA,MAAA,GAAZ,YAAY,EAAI;AAChB,gBAAA,WAAW,CAAC,OAAO,GAAG,KAAK;YAC7B;AAEA,YAAA,cAAc,CAAC,OAAO,GAAG,IAAI;AAC/B,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,UAAU,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC;;IAG5F,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;;;;AAK/C,IAAA,MAAM,QAAQ,GAAuCC,iBAAW,CAAC,SAAS,CAAC;IAE3E,MAAM,SAAS,GAAGC,eAAS,CAAC,QAAQ,EAAE,CAAC,IAAwB,KAAI;AACjE,QAAA,YAAY,CAAC,OAAO,GAAG,IAAI;AAC7B,IAAA,CAAC,CAAC;IAEF,OAAOC,kBAAY,CAAC,SAAS,EAAE,EAAE,GAAG,EAAE,SAAS,EAAqC,CAAC;AACvF;;;;"}
|
|
@@ -6,6 +6,16 @@ import React from 'react';
|
|
|
6
6
|
* @returns Array of focusable HTML elements
|
|
7
7
|
*/
|
|
8
8
|
export declare const focusableChildren: (element: HTMLElement) => HTMLElement[];
|
|
9
|
+
/**
|
|
10
|
+
* Extracts the ref from a React element, handling version differences between React 18 and 19+.
|
|
11
|
+
*
|
|
12
|
+
* In React 18 and earlier, refs are stored directly on the element object.
|
|
13
|
+
* In React 19+, refs are stored in the element's props object due to changes in React's internals.
|
|
14
|
+
* This function automatically detects the React version and uses the appropriate access pattern.
|
|
15
|
+
* @param child - The React element to extract the ref from
|
|
16
|
+
* @returns The ref attached to the element, or undefined if no ref is present
|
|
17
|
+
*/
|
|
18
|
+
export declare const getChildRef: (child: React.ReactElement) => React.Ref<HTMLElement> | undefined;
|
|
9
19
|
/**
|
|
10
20
|
* Checks if an element is disabled.
|
|
11
21
|
* Considers various ways an element can be disabled including CSS classes and attributes.
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var React = require('react');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Gets all focusable child elements within a container.
|
|
5
7
|
* Uses a comprehensive selector to find elements that can receive focus.
|
|
@@ -20,6 +22,28 @@ const focusableChildren = (element) => {
|
|
|
20
22
|
const elements = [...element.querySelectorAll(focusableSelectors)];
|
|
21
23
|
return elements.filter((el) => !isDisabled(el) && isVisible(el));
|
|
22
24
|
};
|
|
25
|
+
/**
|
|
26
|
+
* Extracts the ref from a React element, handling version differences between React 18 and 19+.
|
|
27
|
+
*
|
|
28
|
+
* In React 18 and earlier, refs are stored directly on the element object.
|
|
29
|
+
* In React 19+, refs are stored in the element's props object due to changes in React's internals.
|
|
30
|
+
* This function automatically detects the React version and uses the appropriate access pattern.
|
|
31
|
+
* @param child - The React element to extract the ref from
|
|
32
|
+
* @returns The ref attached to the element, or undefined if no ref is present
|
|
33
|
+
*/
|
|
34
|
+
const getChildRef = (child) => {
|
|
35
|
+
var _a, _b, _c;
|
|
36
|
+
const major = Number((_c = (_b = (_a = React.version) === null || _a === void 0 ? void 0 : _a.split) === null || _b === void 0 ? void 0 : _b.call(_a, '.')[0]) !== null && _c !== void 0 ? _c : 18);
|
|
37
|
+
// React 18 stores ref directly on the element
|
|
38
|
+
if (major <= 18 && 'ref' in child && child.ref !== undefined) {
|
|
39
|
+
return child.ref;
|
|
40
|
+
}
|
|
41
|
+
// React 19 stores ref in props
|
|
42
|
+
if (child.props && typeof child.props === 'object' && 'ref' in child.props) {
|
|
43
|
+
return child.props.ref;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
};
|
|
23
47
|
/**
|
|
24
48
|
* Checks if an element is disabled.
|
|
25
49
|
* Considers various ways an element can be disabled including CSS classes and attributes.
|
|
@@ -48,11 +72,6 @@ const isElement = (object) => {
|
|
|
48
72
|
if (!object || typeof object !== 'object') {
|
|
49
73
|
return false;
|
|
50
74
|
}
|
|
51
|
-
// Handle jQuery objects
|
|
52
|
-
if ('jquery' in object && object.jquery !== undefined) {
|
|
53
|
-
const jQueryObject = object;
|
|
54
|
-
return isElement(jQueryObject[0]);
|
|
55
|
-
}
|
|
56
75
|
return 'nodeType' in object && typeof object.nodeType === 'number';
|
|
57
76
|
};
|
|
58
77
|
/**
|
|
@@ -106,6 +125,7 @@ const mergeRefs = (...refs) => (node) => {
|
|
|
106
125
|
};
|
|
107
126
|
|
|
108
127
|
exports.focusableChildren = focusableChildren;
|
|
128
|
+
exports.getChildRef = getChildRef;
|
|
109
129
|
exports.isDisabled = isDisabled;
|
|
110
130
|
exports.isElement = isElement;
|
|
111
131
|
exports.isVisible = isVisible;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../../../../src/components/focus-trap/utils.ts"],"sourcesContent":[null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../../../../src/components/focus-trap/utils.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;AAEA;;;;;AAKG;AACI,MAAM,iBAAiB,GAAG,CAAC,OAAoB,KAAmB;AACvE,IAAA,MAAM,kBAAkB,GAAG;QACzB,SAAS;QACT,wBAAwB;QACxB,uBAAuB;QACvB,0BAA0B;QAC1B,wBAAwB;QACxB,SAAS;QACT,iCAAiC;QACjC,0BAA0B;AAC3B,KAAA,CAAC,IAAI,CAAC,GAAG,CAAC;IAEX,MAAM,QAAQ,GAAG,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAc,kBAAkB,CAAC,CAAkB;IAEhG,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,EAAE,CAAC,IAAI,SAAS,CAAC,EAAE,CAAC,CAAC;AAClE;AAEA;;;;;;;;AAQG;AACI,MAAM,WAAW,GAAG,CAAC,KAAyB,KAAwC;;IAC3F,MAAM,KAAK,GAAG,MAAM,CAAC,M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;;;;;;;;"}
|
|
@@ -17,7 +17,6 @@ var Transition = require('../../node_modules/react-transition-group/esm/Transiti
|
|
|
17
17
|
const CModal = React.forwardRef((_a, ref) => {
|
|
18
18
|
var { children, alignment, backdrop = true, className, container, duration = 150, focus = true, fullscreen, keyboard = true, onClose, onClosePrevented, onShow, portal = true, scrollable, size, transition = true, unmountOnClose = true, visible } = _a, rest = tslib_es6.__rest(_a, ["children", "alignment", "backdrop", "className", "container", "duration", "focus", "fullscreen", "keyboard", "onClose", "onClosePrevented", "onShow", "portal", "scrollable", "size", "transition", "unmountOnClose", "visible"]);
|
|
19
19
|
const modalRef = React.useRef(null);
|
|
20
|
-
const modalContentRef = React.useRef(null);
|
|
21
20
|
const forkedRef = useForkedRef.useForkedRef(ref, modalRef);
|
|
22
21
|
const [_visible, setVisible] = React.useState(visible);
|
|
23
22
|
const [staticBackdrop, setStaticBackdrop] = React.useState(false);
|
|
@@ -85,16 +84,16 @@ const CModal = React.forwardRef((_a, ref) => {
|
|
|
85
84
|
return (React.createElement(React.Fragment, null,
|
|
86
85
|
React.createElement(Transition.default, { in: _visible, mountOnEnter: true, nodeRef: modalRef, onEnter: onShow, onExit: onClose, unmountOnExit: unmountOnClose, timeout: transition ? duration : 0 }, (state) => (React.createElement(CConditionalPortal.CConditionalPortal, { container: container, portal: portal },
|
|
87
86
|
React.createElement(CModalContext.CModalContext.Provider, { value: contextValues },
|
|
88
|
-
React.createElement(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
React.createElement(
|
|
97
|
-
React.createElement(CModalContent.CModalContent,
|
|
87
|
+
React.createElement(CFocusTrap.CFocusTrap, { active: focus && state === 'entered' },
|
|
88
|
+
React.createElement("div", Object.assign({ className: index.default('modal', {
|
|
89
|
+
'modal-static': staticBackdrop,
|
|
90
|
+
fade: transition,
|
|
91
|
+
show: state === 'entered',
|
|
92
|
+
}, className), tabIndex: -1 }, (_visible
|
|
93
|
+
? { 'aria-modal': true, role: 'dialog' }
|
|
94
|
+
: { 'aria-hidden': 'true' }), { style: Object.assign({}, (state !== 'exited' && { display: 'block' })) }, rest, { ref: forkedRef }),
|
|
95
|
+
React.createElement(CModalDialog.CModalDialog, { alignment: alignment, fullscreen: fullscreen, scrollable: scrollable, size: size },
|
|
96
|
+
React.createElement(CModalContent.CModalContent, null, children)))))))),
|
|
98
97
|
backdrop && (React.createElement(CConditionalPortal.CConditionalPortal, { container: container, portal: portal },
|
|
99
98
|
React.createElement(CBackdrop.CBackdrop, { visible: _visible })))));
|
|
100
99
|
});
|