@reykjavik/hanna-react 0.10.164 → 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/Alert.js +4 -1
- package/CHANGELOG.md +18 -0
- package/Picture.d.ts +2 -2
- package/Picture.js +4 -1
- package/_abstract/_AbstractModal.d.ts +16 -2
- package/_abstract/_AbstractModal.js +7 -2
- package/esm/Alert.js +4 -1
- package/esm/Picture.d.ts +2 -2
- package/esm/Picture.js +4 -1
- package/esm/_abstract/_AbstractModal.d.ts +16 -2
- package/esm/_abstract/_AbstractModal.js +7 -2
- package/package.json +1 -1
package/Alert.js
CHANGED
|
@@ -47,9 +47,12 @@ exports.alertTypes = {
|
|
|
47
47
|
error: 1,
|
|
48
48
|
critical: 1,
|
|
49
49
|
};
|
|
50
|
+
// eslint-disable-next-line complexity
|
|
50
51
|
const Alert = (props) => {
|
|
51
|
-
|
|
52
|
+
var _a;
|
|
53
|
+
const { type, childrenHTML, children, onClose, closeUrl, ssr, onClosed, instantShow, wrapperProps, } = props;
|
|
52
54
|
const autoClose = Math.max(props.autoClose || 0, 0);
|
|
55
|
+
const closable = (_a = props.closable) !== null && _a !== void 0 ? _a : !!(onClose || (onClosed && !autoClose) || closeUrl != null);
|
|
53
56
|
const closing = (0, react_1.useRef)();
|
|
54
57
|
const isBrowser = (0, utils_js_1.useIsBrowserSide)(ssr);
|
|
55
58
|
const [open, setOpen] = (0, react_1.useState)(instantShow || !isBrowser);
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,24 @@
|
|
|
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
|
+
|
|
16
|
+
## 0.10.165
|
|
17
|
+
|
|
18
|
+
_2026-01-23_
|
|
19
|
+
|
|
20
|
+
- `Alert`:
|
|
21
|
+
- feat: Auto-show close button if `onClosed` is set without `autoClose`
|
|
22
|
+
- `Picture`:
|
|
23
|
+
- feat: Add prop `inline` to support inlined SVGs
|
|
24
|
+
|
|
7
25
|
## 0.10.164
|
|
8
26
|
|
|
9
27
|
_2026-01-20_
|
package/Picture.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageProps } from './_abstract/_Image.js';
|
|
2
2
|
import { WrapperElmProps } from './utils.js';
|
|
3
|
-
export type PictureProps =
|
|
3
|
+
export type PictureProps = ImageProps & {
|
|
4
4
|
contain?: boolean;
|
|
5
5
|
className?: string;
|
|
6
6
|
} & WrapperElmProps;
|
package/Picture.js
CHANGED
|
@@ -4,6 +4,9 @@ exports.Picture = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const _Image_js_1 = require("./_abstract/_Image.js");
|
|
7
|
-
const Picture = (props) => (react_1.default.createElement(_Image_js_1.Image, Object.assign({}, props, { bem: "Picture", modifier:
|
|
7
|
+
const Picture = (props) => (react_1.default.createElement(_Image_js_1.Image, Object.assign({}, props, { bem: "Picture", modifier: [
|
|
8
|
+
props.contain && 'contain',
|
|
9
|
+
props.inline && /\.svg(?:\?|$)/i.test(props.src) && 'inlined',
|
|
10
|
+
] })));
|
|
8
11
|
exports.Picture = Picture;
|
|
9
12
|
exports.default = exports.Picture;
|
|
@@ -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
|
};
|
package/esm/Alert.js
CHANGED
|
@@ -43,9 +43,12 @@ export const alertTypes = {
|
|
|
43
43
|
error: 1,
|
|
44
44
|
critical: 1,
|
|
45
45
|
};
|
|
46
|
+
// eslint-disable-next-line complexity
|
|
46
47
|
export const Alert = (props) => {
|
|
47
|
-
|
|
48
|
+
var _a;
|
|
49
|
+
const { type, childrenHTML, children, onClose, closeUrl, ssr, onClosed, instantShow, wrapperProps, } = props;
|
|
48
50
|
const autoClose = Math.max(props.autoClose || 0, 0);
|
|
51
|
+
const closable = (_a = props.closable) !== null && _a !== void 0 ? _a : !!(onClose || (onClosed && !autoClose) || closeUrl != null);
|
|
49
52
|
const closing = useRef();
|
|
50
53
|
const isBrowser = useIsBrowserSide(ssr);
|
|
51
54
|
const [open, setOpen] = useState(instantShow || !isBrowser);
|
package/esm/Picture.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ImageProps } from './_abstract/_Image.js';
|
|
2
2
|
import { WrapperElmProps } from './utils.js';
|
|
3
|
-
export type PictureProps =
|
|
3
|
+
export type PictureProps = ImageProps & {
|
|
4
4
|
contain?: boolean;
|
|
5
5
|
className?: string;
|
|
6
6
|
} & WrapperElmProps;
|
package/esm/Picture.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Image } from './_abstract/_Image.js';
|
|
3
|
-
export const Picture = (props) => (React.createElement(Image, Object.assign({}, props, { bem: "Picture", modifier:
|
|
3
|
+
export const Picture = (props) => (React.createElement(Image, Object.assign({}, props, { bem: "Picture", modifier: [
|
|
4
|
+
props.contain && 'contain',
|
|
5
|
+
props.inline && /\.svg(?:\?|$)/i.test(props.src) && 'inlined',
|
|
6
|
+
] })));
|
|
4
7
|
export default Picture;
|
|
@@ -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
|
};
|