react-bootstrap 2.0.2 → 2.1.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/cjs/Accordion.d.ts +5 -4
- package/cjs/Accordion.js +4 -2
- package/cjs/AccordionButton.js +21 -6
- package/cjs/AccordionCollapse.js +2 -2
- package/cjs/AccordionContext.d.ts +6 -3
- package/cjs/AccordionContext.js +6 -2
- package/cjs/ElementChildren.d.ts +6 -1
- package/cjs/ElementChildren.js +10 -0
- package/cjs/FormCheck.js +4 -2
- package/cjs/Modal.d.ts +1 -1
- package/cjs/NavDropdown.d.ts +1 -1
- package/cjs/Overlay.js +6 -5
- package/cjs/ThemeProvider.d.ts +4 -2
- package/dist/react-bootstrap.js +112 -51
- package/dist/react-bootstrap.min.js +1 -1
- package/esm/Accordion.d.ts +5 -4
- package/esm/Accordion.js +4 -2
- package/esm/AccordionButton.js +21 -6
- package/esm/AccordionCollapse.js +2 -2
- package/esm/AccordionContext.d.ts +6 -3
- package/esm/AccordionContext.js +3 -0
- package/esm/ElementChildren.d.ts +6 -1
- package/esm/ElementChildren.js +10 -1
- package/esm/FormCheck.js +3 -2
- package/esm/Modal.d.ts +1 -1
- package/esm/NavDropdown.d.ts +1 -1
- package/esm/Overlay.js +6 -5
- package/esm/ThemeProvider.d.ts +4 -2
- package/package.json +3 -4
package/cjs/Accordion.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { AccordionSelectCallback, AccordionEventKey } from './AccordionContext';
|
|
3
3
|
import { BsPrefixProps, BsPrefixRefForwardingComponent } from './helpers';
|
|
4
4
|
export interface AccordionProps extends Omit<React.HTMLAttributes<HTMLElement>, 'onSelect'>, BsPrefixProps {
|
|
5
|
-
activeKey?:
|
|
6
|
-
defaultActiveKey?:
|
|
7
|
-
onSelect?:
|
|
5
|
+
activeKey?: AccordionEventKey;
|
|
6
|
+
defaultActiveKey?: AccordionEventKey;
|
|
7
|
+
onSelect?: AccordionSelectCallback;
|
|
8
8
|
flush?: boolean;
|
|
9
|
+
alwaysOpen?: boolean;
|
|
9
10
|
}
|
|
10
11
|
declare const _default: BsPrefixRefForwardingComponent<"div", AccordionProps> & {
|
|
11
12
|
Button: BsPrefixRefForwardingComponent<"div", import("./AccordionButton").AccordionButtonProps>;
|
package/cjs/Accordion.js
CHANGED
|
@@ -40,6 +40,7 @@ const Accordion = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
40
40
|
className,
|
|
41
41
|
onSelect,
|
|
42
42
|
flush,
|
|
43
|
+
alwaysOpen,
|
|
43
44
|
...controlledProps
|
|
44
45
|
} = (0, _uncontrollable.useUncontrolled)(props, {
|
|
45
46
|
activeKey: 'onSelect'
|
|
@@ -47,8 +48,9 @@ const Accordion = /*#__PURE__*/React.forwardRef((props, ref) => {
|
|
|
47
48
|
const prefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'accordion');
|
|
48
49
|
const contextValue = (0, React.useMemo)(() => ({
|
|
49
50
|
activeEventKey: activeKey,
|
|
50
|
-
onSelect
|
|
51
|
-
|
|
51
|
+
onSelect,
|
|
52
|
+
alwaysOpen
|
|
53
|
+
}), [activeKey, onSelect, alwaysOpen]);
|
|
52
54
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_AccordionContext.default.Provider, {
|
|
53
55
|
value: contextValue,
|
|
54
56
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
package/cjs/AccordionButton.js
CHANGED
|
@@ -10,7 +10,7 @@ var React = _interopRequireWildcard(require("react"));
|
|
|
10
10
|
|
|
11
11
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
12
12
|
|
|
13
|
-
var _AccordionContext =
|
|
13
|
+
var _AccordionContext = _interopRequireWildcard(require("./AccordionContext"));
|
|
14
14
|
|
|
15
15
|
var _AccordionItemContext = _interopRequireDefault(require("./AccordionItemContext"));
|
|
16
16
|
|
|
@@ -25,16 +25,31 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
25
25
|
function useAccordionButton(eventKey, onClick) {
|
|
26
26
|
const {
|
|
27
27
|
activeEventKey,
|
|
28
|
-
onSelect
|
|
28
|
+
onSelect,
|
|
29
|
+
alwaysOpen
|
|
29
30
|
} = (0, React.useContext)(_AccordionContext.default);
|
|
30
31
|
return e => {
|
|
31
32
|
/*
|
|
32
33
|
Compare the event key in context with the given event key.
|
|
33
34
|
If they are the same, then collapse the component.
|
|
34
35
|
*/
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (
|
|
36
|
+
let eventKeyPassed = eventKey === activeEventKey ? null : eventKey;
|
|
37
|
+
|
|
38
|
+
if (alwaysOpen) {
|
|
39
|
+
if (Array.isArray(activeEventKey)) {
|
|
40
|
+
if (activeEventKey.includes(eventKey)) {
|
|
41
|
+
eventKeyPassed = activeEventKey.filter(k => k !== eventKey);
|
|
42
|
+
} else {
|
|
43
|
+
eventKeyPassed = [...activeEventKey, eventKey];
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
// activeEventKey is undefined.
|
|
47
|
+
eventKeyPassed = [eventKey];
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onSelect == null ? void 0 : onSelect(eventKeyPassed, e);
|
|
52
|
+
onClick == null ? void 0 : onClick(e);
|
|
38
53
|
};
|
|
39
54
|
}
|
|
40
55
|
|
|
@@ -64,7 +79,7 @@ const AccordionButton = /*#__PURE__*/React.forwardRef(({
|
|
|
64
79
|
onClick: accordionOnClick,
|
|
65
80
|
...props,
|
|
66
81
|
"aria-expanded": eventKey === activeEventKey,
|
|
67
|
-
className: (0, _classnames.default)(className, bsPrefix,
|
|
82
|
+
className: (0, _classnames.default)(className, bsPrefix, !(0, _AccordionContext.isAccordionItemSelected)(activeEventKey, eventKey) && 'collapsed')
|
|
68
83
|
});
|
|
69
84
|
});
|
|
70
85
|
AccordionButton.displayName = 'AccordionButton';
|
package/cjs/AccordionCollapse.js
CHANGED
|
@@ -13,7 +13,7 @@ var _ThemeProvider = require("./ThemeProvider");
|
|
|
13
13
|
|
|
14
14
|
var _Collapse = _interopRequireDefault(require("./Collapse"));
|
|
15
15
|
|
|
16
|
-
var _AccordionContext =
|
|
16
|
+
var _AccordionContext = _interopRequireWildcard(require("./AccordionContext"));
|
|
17
17
|
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
|
|
@@ -35,7 +35,7 @@ const AccordionCollapse = /*#__PURE__*/React.forwardRef(({
|
|
|
35
35
|
bsPrefix = (0, _ThemeProvider.useBootstrapPrefix)(bsPrefix, 'accordion-collapse');
|
|
36
36
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Collapse.default, {
|
|
37
37
|
ref: ref,
|
|
38
|
-
in: activeEventKey
|
|
38
|
+
in: (0, _AccordionContext.isAccordionItemSelected)(activeEventKey, eventKey),
|
|
39
39
|
...props,
|
|
40
40
|
className: (0, _classnames.default)(className, bsPrefix),
|
|
41
41
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
|
|
2
|
+
export declare type AccordionEventKey = string | string[] | null | undefined;
|
|
3
|
+
export declare type AccordionSelectCallback = (eventKey: AccordionEventKey, e: React.SyntheticEvent<unknown>) => void;
|
|
3
4
|
export interface AccordionContextValue {
|
|
4
|
-
activeEventKey?:
|
|
5
|
-
onSelect?:
|
|
5
|
+
activeEventKey?: AccordionEventKey;
|
|
6
|
+
onSelect?: AccordionSelectCallback;
|
|
7
|
+
alwaysOpen?: boolean;
|
|
6
8
|
}
|
|
9
|
+
export declare function isAccordionItemSelected(activeEventKey: AccordionEventKey, eventKey: string): boolean;
|
|
7
10
|
declare const context: React.Context<AccordionContextValue>;
|
|
8
11
|
export default context;
|
package/cjs/AccordionContext.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.default = void 0;
|
|
5
|
+
exports.isAccordionItemSelected = isAccordionItemSelected;
|
|
5
6
|
|
|
6
7
|
var React = _interopRequireWildcard(require("react"));
|
|
7
8
|
|
|
@@ -9,8 +10,11 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
9
10
|
|
|
10
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
11
12
|
|
|
13
|
+
function isAccordionItemSelected(activeEventKey, eventKey) {
|
|
14
|
+
return Array.isArray(activeEventKey) ? activeEventKey.includes(eventKey) : activeEventKey === eventKey;
|
|
15
|
+
}
|
|
16
|
+
|
|
12
17
|
const context = /*#__PURE__*/React.createContext({});
|
|
13
18
|
context.displayName = 'AccordionContext';
|
|
14
19
|
var _default = context;
|
|
15
|
-
exports.default = _default;
|
|
16
|
-
module.exports = exports.default;
|
|
20
|
+
exports.default = _default;
|
package/cjs/ElementChildren.d.ts
CHANGED
|
@@ -15,4 +15,9 @@ declare function map<P = any>(children: any, func: (el: React.ReactElement<P>, i
|
|
|
15
15
|
* leaf child with the index reflecting the position relative to "valid components".
|
|
16
16
|
*/
|
|
17
17
|
declare function forEach<P = any>(children: any, func: (el: React.ReactElement<P>, index: number) => void): void;
|
|
18
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Finds whether a component's `children` prop includes a React element of the
|
|
20
|
+
* specified type.
|
|
21
|
+
*/
|
|
22
|
+
declare function hasChildOfType<P = any>(children: React.ReactNode, type: string | React.JSXElementConstructor<P>): boolean;
|
|
23
|
+
export { map, forEach, hasChildOfType };
|
package/cjs/ElementChildren.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.forEach = forEach;
|
|
5
|
+
exports.hasChildOfType = hasChildOfType;
|
|
5
6
|
exports.map = map;
|
|
6
7
|
|
|
7
8
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -35,4 +36,13 @@ function forEach(children, func) {
|
|
|
35
36
|
React.Children.forEach(children, child => {
|
|
36
37
|
if ( /*#__PURE__*/React.isValidElement(child)) func(child, index++);
|
|
37
38
|
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Finds whether a component's `children` prop includes a React element of the
|
|
42
|
+
* specified type.
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
function hasChildOfType(children, type) {
|
|
47
|
+
return React.Children.toArray(children).some(child => /*#__PURE__*/React.isValidElement(child) && child.type === type);
|
|
38
48
|
}
|
package/cjs/FormCheck.js
CHANGED
|
@@ -19,6 +19,8 @@ var _FormContext = _interopRequireDefault(require("./FormContext"));
|
|
|
19
19
|
|
|
20
20
|
var _ThemeProvider = require("./ThemeProvider");
|
|
21
21
|
|
|
22
|
+
var _ElementChildren = require("./ElementChildren");
|
|
23
|
+
|
|
22
24
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
25
|
|
|
24
26
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
@@ -54,7 +56,7 @@ const FormCheck = /*#__PURE__*/React.forwardRef(({
|
|
|
54
56
|
const innerFormContext = (0, React.useMemo)(() => ({
|
|
55
57
|
controlId: id || controlId
|
|
56
58
|
}), [controlId, id]);
|
|
57
|
-
const hasLabel = label != null && label !== false
|
|
59
|
+
const hasLabel = !children && label != null && label !== false || (0, _ElementChildren.hasChildOfType)(children, _FormCheckLabel.default);
|
|
58
60
|
const input = /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormCheckInput.default, { ...props,
|
|
59
61
|
type: type === 'switch' ? 'checkbox' : type,
|
|
60
62
|
ref: ref,
|
|
@@ -67,7 +69,7 @@ const FormCheck = /*#__PURE__*/React.forwardRef(({
|
|
|
67
69
|
value: innerFormContext,
|
|
68
70
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
69
71
|
style: style,
|
|
70
|
-
className: (0, _classnames.default)(className,
|
|
72
|
+
className: (0, _classnames.default)(className, hasLabel && bsPrefix, inline && `${bsPrefix}-inline`, type === 'switch' && bsSwitchPrefix),
|
|
71
73
|
children: children || /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
72
74
|
children: [input, hasLabel && /*#__PURE__*/(0, _jsxRuntime.jsx)(_FormCheckLabel.default, {
|
|
73
75
|
title: title,
|
package/cjs/Modal.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { BaseModalProps } from '@restart/ui/Modal';
|
|
3
3
|
import { BsPrefixRefForwardingComponent } from './helpers';
|
|
4
4
|
export interface ModalProps extends Omit<BaseModalProps, 'role' | 'renderBackdrop' | 'renderDialog' | 'transition' | 'backdropTransition' | 'children'> {
|
|
5
5
|
size?: 'sm' | 'lg' | 'xl';
|
package/cjs/NavDropdown.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { DropdownProps } from './Dropdown';
|
|
3
3
|
import { DropdownMenuVariant } from './DropdownMenu';
|
|
4
4
|
import { BsPrefixRefForwardingComponent } from './helpers';
|
|
5
|
-
export interface NavDropdownProps extends Omit<DropdownProps, '
|
|
5
|
+
export interface NavDropdownProps extends Omit<DropdownProps, 'title'> {
|
|
6
6
|
title: React.ReactNode;
|
|
7
7
|
disabled?: boolean;
|
|
8
8
|
active?: boolean;
|
package/cjs/Overlay.js
CHANGED
|
@@ -63,21 +63,22 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
|
63
63
|
transition: actualTransition,
|
|
64
64
|
children: (overlayProps, {
|
|
65
65
|
arrowProps,
|
|
66
|
-
placement,
|
|
67
66
|
popper: popperObj,
|
|
68
67
|
show
|
|
69
68
|
}) => {
|
|
70
69
|
var _popperObj$state, _popperObj$state$modi;
|
|
71
70
|
|
|
72
|
-
wrapRefs(overlayProps, arrowProps);
|
|
71
|
+
wrapRefs(overlayProps, arrowProps); // Need to get placement from popper object, handling case when overlay is flipped using 'flip' prop
|
|
72
|
+
|
|
73
|
+
const updatedPlacement = popperObj == null ? void 0 : popperObj.placement;
|
|
73
74
|
const popper = Object.assign(popperRef.current, {
|
|
74
75
|
state: popperObj == null ? void 0 : popperObj.state,
|
|
75
76
|
scheduleUpdate: popperObj == null ? void 0 : popperObj.update,
|
|
76
|
-
placement,
|
|
77
|
+
placement: updatedPlacement,
|
|
77
78
|
outOfBoundaries: (popperObj == null ? void 0 : (_popperObj$state = popperObj.state) == null ? void 0 : (_popperObj$state$modi = _popperObj$state.modifiersData.hide) == null ? void 0 : _popperObj$state$modi.isReferenceHidden) || false
|
|
78
79
|
});
|
|
79
80
|
if (typeof overlay === 'function') return overlay({ ...overlayProps,
|
|
80
|
-
placement,
|
|
81
|
+
placement: updatedPlacement,
|
|
81
82
|
show,
|
|
82
83
|
...(!transition && show && {
|
|
83
84
|
className: 'show'
|
|
@@ -86,7 +87,7 @@ const Overlay = /*#__PURE__*/React.forwardRef(({
|
|
|
86
87
|
arrowProps
|
|
87
88
|
});
|
|
88
89
|
return /*#__PURE__*/React.cloneElement(overlay, { ...overlayProps,
|
|
89
|
-
placement,
|
|
90
|
+
placement: updatedPlacement,
|
|
90
91
|
arrowProps,
|
|
91
92
|
popper,
|
|
92
93
|
className: (0, _classnames.default)(overlay.props.className, !transition && show && 'show'),
|
package/cjs/ThemeProvider.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export interface ThemeContextValue {
|
|
|
4
4
|
dir?: string;
|
|
5
5
|
}
|
|
6
6
|
export interface ThemeProviderProps extends Partial<ThemeContextValue> {
|
|
7
|
-
children: React.
|
|
7
|
+
children: React.ReactNode;
|
|
8
8
|
}
|
|
9
9
|
declare const Consumer: React.Consumer<ThemeContextValue>;
|
|
10
10
|
declare function ThemeProvider({ prefixes, dir, children }: ThemeProviderProps): JSX.Element;
|
|
@@ -13,6 +13,8 @@ declare namespace ThemeProvider {
|
|
|
13
13
|
}
|
|
14
14
|
export declare function useBootstrapPrefix(prefix: string | undefined, defaultPrefix: string): string;
|
|
15
15
|
export declare function useIsRTL(): boolean;
|
|
16
|
-
declare function createBootstrapComponent(Component: any, opts: any): React.ForwardRefExoticComponent<
|
|
16
|
+
declare function createBootstrapComponent(Component: any, opts: any): React.ForwardRefExoticComponent<{
|
|
17
|
+
bsPrefix?: string | undefined;
|
|
18
|
+
} & React.RefAttributes<any>>;
|
|
17
19
|
export { createBootstrapComponent, Consumer as ThemeConsumer };
|
|
18
20
|
export default ThemeProvider;
|