@reykjavik/hanna-react 0.10.165 → 0.10.166
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/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.166
|
|
8
|
+
|
|
9
|
+
_2026-02-16_
|
|
10
|
+
|
|
11
|
+
- `Modal`:
|
|
12
|
+
- feat: Allow `children` to be render function receiving `closeModal`
|
|
13
|
+
dispacther and `visible` state
|
|
14
|
+
- feat: Deprecate `render` prop in favor of `children` as render function
|
|
15
|
+
|
|
7
16
|
## 0.10.165
|
|
8
17
|
|
|
9
18
|
_2026-01-23_
|
|
@@ -85,12 +85,26 @@ export type AbstractModalProps = {
|
|
|
85
85
|
*/
|
|
86
86
|
portal?: boolean;
|
|
87
87
|
} & EitherObj<{
|
|
88
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use children instead (Will be removed in v0.11)
|
|
90
|
+
*
|
|
91
|
+
* Render function that receives a `closeModal` action dispatcher.
|
|
92
|
+
*/
|
|
89
93
|
render: (props: {
|
|
90
94
|
closeModal(): void;
|
|
91
95
|
}) => ReactNode;
|
|
92
96
|
}, {
|
|
93
|
-
|
|
97
|
+
/** Either a `ReactNode` or render function */
|
|
98
|
+
children: ReactNode | ((props: {
|
|
99
|
+
/** Action dispacher that initiates modal closing action */
|
|
100
|
+
closeModal(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the modal is visible or not. The `onOpen` and `onClosed`
|
|
103
|
+
* callbacks are triggered once the modal has become fully visible or
|
|
104
|
+
* fully hidden.
|
|
105
|
+
*/
|
|
106
|
+
visible: boolean;
|
|
107
|
+
}) => ReactNode);
|
|
94
108
|
}> & WrapperElmProps<'div', 'hidden' | 'role'> & SSRSupportProps;
|
|
95
109
|
type AbstractModalProps_private = AbstractModalProps & BemProps<true>;
|
|
96
110
|
export declare const AbstractModal: (props: AbstractModalProps_private) => JSX.Element;
|
|
@@ -48,7 +48,8 @@ exports.defaultAbstractModalTexts = {
|
|
|
48
48
|
// eslint-disable-next-line complexity
|
|
49
49
|
const AbstractModal = (props) => {
|
|
50
50
|
var _a;
|
|
51
|
-
const { bem, modifier, closeDelay = 500, wrapperProps = {}, ssr
|
|
51
|
+
const { bem, modifier, closeDelay = 500, wrapperProps = {}, ssr, render, // eslint-disable-line deprecation/deprecation
|
|
52
|
+
children, } = props;
|
|
52
53
|
// eslint-disable-next-line deprecation/deprecation
|
|
53
54
|
const isFickle = !((_a = props.stable) !== null && _a !== void 0 ? _a : props.fickle === false) || undefined;
|
|
54
55
|
const txt = (0, i18n_1.getTexts)(props, exports.defaultAbstractModalTexts);
|
|
@@ -128,7 +129,11 @@ const AbstractModal = (props) => {
|
|
|
128
129
|
: closeOnCurtainClick || onClick, id: domid }),
|
|
129
130
|
isBrowser && react_1.default.createElement(FocusTrap_js_1.FocusTrap, { atTop: true }),
|
|
130
131
|
react_1.default.createElement("div", { className: (0, hanna_utils_1.modifiedClass)(bem, modifier), ref: modalElmRef },
|
|
131
|
-
|
|
132
|
+
render
|
|
133
|
+
? render({ closeModal })
|
|
134
|
+
: typeof children === 'function'
|
|
135
|
+
? children({ closeModal, visible })
|
|
136
|
+
: children,
|
|
132
137
|
isBrowser && !props.noCloseButton && (react_1.default.createElement("button", { className: `${bem}__closebutton`, type: "button", onClick: closeModal, "aria-label": closeButtonLabel, "aria-controls": domid, title: closeButtonLabel }, txt.closeButton))),
|
|
133
138
|
isBrowser && react_1.default.createElement(FocusTrap_js_1.FocusTrap, null)))));
|
|
134
139
|
};
|
|
@@ -85,12 +85,26 @@ export type AbstractModalProps = {
|
|
|
85
85
|
*/
|
|
86
86
|
portal?: boolean;
|
|
87
87
|
} & EitherObj<{
|
|
88
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* @deprecated Use children instead (Will be removed in v0.11)
|
|
90
|
+
*
|
|
91
|
+
* Render function that receives a `closeModal` action dispatcher.
|
|
92
|
+
*/
|
|
89
93
|
render: (props: {
|
|
90
94
|
closeModal(): void;
|
|
91
95
|
}) => ReactNode;
|
|
92
96
|
}, {
|
|
93
|
-
|
|
97
|
+
/** Either a `ReactNode` or render function */
|
|
98
|
+
children: ReactNode | ((props: {
|
|
99
|
+
/** Action dispacher that initiates modal closing action */
|
|
100
|
+
closeModal(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Whether the modal is visible or not. The `onOpen` and `onClosed`
|
|
103
|
+
* callbacks are triggered once the modal has become fully visible or
|
|
104
|
+
* fully hidden.
|
|
105
|
+
*/
|
|
106
|
+
visible: boolean;
|
|
107
|
+
}) => ReactNode);
|
|
94
108
|
}> & WrapperElmProps<'div', 'hidden' | 'role'> & SSRSupportProps;
|
|
95
109
|
type AbstractModalProps_private = AbstractModalProps & BemProps<true>;
|
|
96
110
|
export declare const AbstractModal: (props: AbstractModalProps_private) => JSX.Element;
|
|
@@ -44,7 +44,8 @@ export const defaultAbstractModalTexts = {
|
|
|
44
44
|
// eslint-disable-next-line complexity
|
|
45
45
|
export const AbstractModal = (props) => {
|
|
46
46
|
var _a;
|
|
47
|
-
const { bem, modifier, closeDelay = 500, wrapperProps = {}, ssr
|
|
47
|
+
const { bem, modifier, closeDelay = 500, wrapperProps = {}, ssr, render, // eslint-disable-line deprecation/deprecation
|
|
48
|
+
children, } = props;
|
|
48
49
|
// eslint-disable-next-line deprecation/deprecation
|
|
49
50
|
const isFickle = !((_a = props.stable) !== null && _a !== void 0 ? _a : props.fickle === false) || undefined;
|
|
50
51
|
const txt = getTexts(props, defaultAbstractModalTexts);
|
|
@@ -124,7 +125,11 @@ export const AbstractModal = (props) => {
|
|
|
124
125
|
: closeOnCurtainClick || onClick, id: domid }),
|
|
125
126
|
isBrowser && React.createElement(FocusTrap, { atTop: true }),
|
|
126
127
|
React.createElement("div", { className: modifiedClass(bem, modifier), ref: modalElmRef },
|
|
127
|
-
|
|
128
|
+
render
|
|
129
|
+
? render({ closeModal })
|
|
130
|
+
: typeof children === 'function'
|
|
131
|
+
? children({ closeModal, visible })
|
|
132
|
+
: children,
|
|
128
133
|
isBrowser && !props.noCloseButton && (React.createElement("button", { className: `${bem}__closebutton`, type: "button", onClick: closeModal, "aria-label": closeButtonLabel, "aria-controls": domid, title: closeButtonLabel }, txt.closeButton))),
|
|
129
134
|
isBrowser && React.createElement(FocusTrap, null)))));
|
|
130
135
|
};
|