@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 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) => {
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * Returns a stable, unique ID string.
3
3
  *
4
- * Uses useId from React@18 when available, but falls back on a custom id
5
- * generator. (The custom generator causes angry hydration warnings in dev
6
- * mode).
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;
@@ -1,17 +1,25 @@
1
- import * as React from 'react';
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@18 when available, but falls back on a custom id
9
- * generator. (The custom generator causes angry hydration warnings in dev
10
- * mode).
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) => React.useRef(staticId || domid()).current;
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.107",
3
+ "version": "0.10.108",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",
@@ -1,8 +1,10 @@
1
1
  /**
2
2
  * Returns a stable, unique ID string.
3
3
  *
4
- * Uses useId from React@18 when available, but falls back on a custom id
5
- * generator. (The custom generator causes angry hydration warnings in dev
6
- * mode).
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 React = tslib_1.__importStar(require("react"));
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 = React.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@18 when available, but falls back on a custom id
13
- * generator. (The custom generator causes angry hydration warnings in dev
14
- * mode).
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) => React.useRef(staticId || (0, domid_1.default)()).current;
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
+ };