@reykjavik/hanna-react 0.10.107 → 0.10.108
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 +8 -0
- package/Pagination.js +1 -1
- package/esm/Pagination.js +1 -1
- package/esm/utils/useDomid.d.ts +5 -3
- package/esm/utils/useDomid.js +13 -5
- package/package.json +1 -1
- package/utils/useDomid.d.ts +5 -3
- package/utils/useDomid.js +14 -6
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@
|
|
|
4
4
|
|
|
5
5
|
- ... <!-- Add new lines here. -->
|
|
6
6
|
|
|
7
|
+
## 0.10.108
|
|
8
|
+
|
|
9
|
+
_2023-10-09_
|
|
10
|
+
|
|
11
|
+
- fix: Add `rel="nofollow"` to all `Pagination` links
|
|
12
|
+
- fix: Fix esm import inside `useDomid` causing build errors in React<=v17
|
|
13
|
+
- fix: Make `useDomid` more efficient in React<=v17
|
|
14
|
+
|
|
7
15
|
## 0.10.107
|
|
8
16
|
|
|
9
17
|
_2023-10-05_
|
package/Pagination.js
CHANGED
|
@@ -22,7 +22,7 @@ const PaginationButton = (props) => {
|
|
|
22
22
|
'aria-current': modifier === 'active' || undefined,
|
|
23
23
|
'aria-controls': props.ariaControls,
|
|
24
24
|
};
|
|
25
|
-
return href && !disabled ? (react_1.default.createElement(_Link_js_1.Link, Object.assign({ href: href(page) }, btnProps))) : (react_1.default.createElement("button", Object.assign({ type: props.type, disabled: disabled }, btnProps)));
|
|
25
|
+
return href && !disabled ? (react_1.default.createElement(_Link_js_1.Link, Object.assign({ href: href(page), rel: "nofollow" }, btnProps))) : (react_1.default.createElement("button", Object.assign({ type: props.type, disabled: disabled }, btnProps)));
|
|
26
26
|
};
|
|
27
27
|
// ---------------------------------------------------------------------------
|
|
28
28
|
const getBtnRenderer = (cfg) => {
|
package/esm/Pagination.js
CHANGED
|
@@ -18,7 +18,7 @@ const PaginationButton = (props) => {
|
|
|
18
18
|
'aria-current': modifier === 'active' || undefined,
|
|
19
19
|
'aria-controls': props.ariaControls,
|
|
20
20
|
};
|
|
21
|
-
return href && !disabled ? (React.createElement(Link, Object.assign({ href: href(page) }, btnProps))) : (React.createElement("button", Object.assign({ type: props.type, disabled: disabled }, btnProps)));
|
|
21
|
+
return href && !disabled ? (React.createElement(Link, Object.assign({ href: href(page), rel: "nofollow" }, btnProps))) : (React.createElement("button", Object.assign({ type: props.type, disabled: disabled }, btnProps)));
|
|
22
22
|
};
|
|
23
23
|
// ---------------------------------------------------------------------------
|
|
24
24
|
const getBtnRenderer = (cfg) => {
|
package/esm/utils/useDomid.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a stable, unique ID string.
|
|
3
3
|
*
|
|
4
|
-
* Uses useId from React
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Uses useId from React (v18+) when available, falling back on a custom
|
|
5
|
+
* unique id generator.
|
|
6
|
+
*
|
|
7
|
+
* (NOTE: The custom generator causes angry hydration warnings in dev
|
|
8
|
+
* mode and there's nothing we can do about it.)
|
|
7
9
|
*/
|
|
8
10
|
export declare const useDomid: (staticId?: string) => string;
|
package/esm/utils/useDomid.js
CHANGED
|
@@ -1,17 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import domid from '@hugsmidjan/qj/domid';
|
|
3
3
|
// @ts-expect-error (transparently feature-detect useId hook, which is introduced in React@18)
|
|
4
4
|
const useId = React.useId;
|
|
5
5
|
/**
|
|
6
6
|
* Returns a stable, unique ID string.
|
|
7
7
|
*
|
|
8
|
-
* Uses useId from React
|
|
9
|
-
*
|
|
10
|
-
*
|
|
8
|
+
* Uses useId from React (v18+) when available, falling back on a custom
|
|
9
|
+
* unique id generator.
|
|
10
|
+
*
|
|
11
|
+
* (NOTE: The custom generator causes angry hydration warnings in dev
|
|
12
|
+
* mode and there's nothing we can do about it.)
|
|
11
13
|
*/
|
|
12
14
|
export const useDomid = useId
|
|
13
15
|
? (staticId) => {
|
|
14
16
|
const id = useId();
|
|
15
17
|
return staticId || id;
|
|
16
18
|
}
|
|
17
|
-
: (staticId) =>
|
|
19
|
+
: (staticId) => {
|
|
20
|
+
const idRef = React.useRef();
|
|
21
|
+
if (!idRef.current) {
|
|
22
|
+
idRef.current = staticId || domid();
|
|
23
|
+
}
|
|
24
|
+
return idRef.current;
|
|
25
|
+
};
|
package/package.json
CHANGED
package/utils/useDomid.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns a stable, unique ID string.
|
|
3
3
|
*
|
|
4
|
-
* Uses useId from React
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Uses useId from React (v18+) when available, falling back on a custom
|
|
5
|
+
* unique id generator.
|
|
6
|
+
*
|
|
7
|
+
* (NOTE: The custom generator causes angry hydration warnings in dev
|
|
8
|
+
* mode and there's nothing we can do about it.)
|
|
7
9
|
*/
|
|
8
10
|
export declare const useDomid: (staticId?: string) => string;
|
package/utils/useDomid.js
CHANGED
|
@@ -2,20 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useDomid = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const
|
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
|
6
6
|
const domid_1 = tslib_1.__importDefault(require("@hugsmidjan/qj/domid"));
|
|
7
7
|
// @ts-expect-error (transparently feature-detect useId hook, which is introduced in React@18)
|
|
8
|
-
const useId =
|
|
8
|
+
const useId = react_1.default.useId;
|
|
9
9
|
/**
|
|
10
10
|
* Returns a stable, unique ID string.
|
|
11
11
|
*
|
|
12
|
-
* Uses useId from React
|
|
13
|
-
*
|
|
14
|
-
*
|
|
12
|
+
* Uses useId from React (v18+) when available, falling back on a custom
|
|
13
|
+
* unique id generator.
|
|
14
|
+
*
|
|
15
|
+
* (NOTE: The custom generator causes angry hydration warnings in dev
|
|
16
|
+
* mode and there's nothing we can do about it.)
|
|
15
17
|
*/
|
|
16
18
|
exports.useDomid = useId
|
|
17
19
|
? (staticId) => {
|
|
18
20
|
const id = useId();
|
|
19
21
|
return staticId || id;
|
|
20
22
|
}
|
|
21
|
-
: (staticId) =>
|
|
23
|
+
: (staticId) => {
|
|
24
|
+
const idRef = react_1.default.useRef();
|
|
25
|
+
if (!idRef.current) {
|
|
26
|
+
idRef.current = staticId || (0, domid_1.default)();
|
|
27
|
+
}
|
|
28
|
+
return idRef.current;
|
|
29
|
+
};
|