@reykjavik/hanna-react 0.10.117 → 0.10.119

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,18 @@
4
4
 
5
5
  - ... <!-- Add new lines here. -->
6
6
 
7
+ ## 0.10.119
8
+
9
+ _2024-02-29_
10
+
11
+ - fix: Stop `Multiselect` dropdown closing on touch-based page scroll
12
+
13
+ ## 0.10.118
14
+
15
+ _2024-02-07_
16
+
17
+ - feat: Add component `IframeBlockClientScript`
18
+
7
19
  ## 0.10.117
8
20
 
9
21
  _2024-01-26_
@@ -0,0 +1,14 @@
1
+ export type IframeBlockClientScriptProps = {
2
+ /**
3
+ * Restricts the domain of the parent page, to prevent unknown sites
4
+ * from recieving the benefits of automated resizing.
5
+ *
6
+ * Default: `'*'` (resizable on any domain)
7
+ */
8
+ targetOrigin?: string;
9
+ };
10
+ /**
11
+ * Drop this component into the iframed page to enable auto-resizing of the
12
+ * `<iframe/>` on the parent pages's `IframeBlock` component.
13
+ */
14
+ export declare const IframeBlockClientScript: (props: IframeBlockClientScriptProps) => JSX.Element;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IframeBlockClientScript = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const react_1 = tslib_1.__importDefault(require("react"));
6
+ const assets_1 = require("@reykjavik/hanna-utils/assets");
7
+ /**
8
+ * Drop this component into the iframed page to enable auto-resizing of the
9
+ * `<iframe/>` on the parent pages's `IframeBlock` component.
10
+ */
11
+ const IframeBlockClientScript = (props) => {
12
+ const { targetOrigin } = props;
13
+ return (react_1.default.createElement(react_1.default.Fragment, null,
14
+ !!targetOrigin && (react_1.default.createElement("script", { dangerouslySetInnerHTML: {
15
+ __html: `window.iFrameResizer=${JSON.stringify({ targetOrigin })}`,
16
+ } })),
17
+ react_1.default.createElement("script", { src: (0, assets_1.getAssetUrl)('scripts/iframeResizer.contentWindow@4.js') })));
18
+ };
19
+ exports.IframeBlockClientScript = IframeBlockClientScript;
@@ -0,0 +1,14 @@
1
+ export type IframeBlockClientScriptProps = {
2
+ /**
3
+ * Restricts the domain of the parent page, to prevent unknown sites
4
+ * from recieving the benefits of automated resizing.
5
+ *
6
+ * Default: `'*'` (resizable on any domain)
7
+ */
8
+ targetOrigin?: string;
9
+ };
10
+ /**
11
+ * Drop this component into the iframed page to enable auto-resizing of the
12
+ * `<iframe/>` on the parent pages's `IframeBlock` component.
13
+ */
14
+ export declare const IframeBlockClientScript: (props: IframeBlockClientScriptProps) => JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ import { getAssetUrl } from '@reykjavik/hanna-utils/assets';
3
+ /**
4
+ * Drop this component into the iframed page to enable auto-resizing of the
5
+ * `<iframe/>` on the parent pages's `IframeBlock` component.
6
+ */
7
+ export const IframeBlockClientScript = (props) => {
8
+ const { targetOrigin } = props;
9
+ return (React.createElement(React.Fragment, null,
10
+ !!targetOrigin && (React.createElement("script", { dangerouslySetInnerHTML: {
11
+ __html: `window.iFrameResizer=${JSON.stringify({ targetOrigin })}`,
12
+ } })),
13
+ React.createElement("script", { src: getAssetUrl('scripts/iframeResizer.contentWindow@4.js') })));
14
+ };
package/esm/index.d.ts CHANGED
@@ -55,6 +55,7 @@
55
55
  /// <reference path="./ImageCards.d.tsx" />
56
56
  /// <reference path="./Illustration.d.tsx" />
57
57
  /// <reference path="./IframedLayout.d.tsx" />
58
+ /// <reference path="./IframeBlockClientScript.d.tsx" />
58
59
  /// <reference path="./IframeBlock.d.tsx" />
59
60
  /// <reference path="./HeroBlock.d.tsx" />
60
61
  /// <reference path="./Heading.d.tsx" />
@@ -5,5 +5,5 @@ type Ref<E extends HTMLElement> = MutableRefObject<E> | RefObject<E>;
5
5
  * @param ref single or array of refs to check for click outside
6
6
  * @param handler callback to run when clicked outside of the ref
7
7
  */
8
- declare const useOnClickOutside: <E extends HTMLElement>(ref: Ref<E> | Ref<E>[], handler: (event: globalThis.MouseEvent | globalThis.TouchEvent) => void) => void;
9
- export { useOnClickOutside };
8
+ export declare const useOnClickOutside: <E extends HTMLElement>(ref: Ref<E> | Ref<E>[], handler: (event: globalThis.MouseEvent | globalThis.TouchEvent) => void) => void;
9
+ export {};
@@ -4,7 +4,7 @@ import { useEffect, useMemo } from 'react';
4
4
  * @param ref single or array of refs to check for click outside
5
5
  * @param handler callback to run when clicked outside of the ref
6
6
  */
7
- const useOnClickOutside = (ref, handler) => {
7
+ export const useOnClickOutside = (ref, handler) => {
8
8
  const refs = Array.isArray(ref) ? ref : [ref];
9
9
  // eslint-disable-next-line react-hooks/exhaustive-deps
10
10
  const stableRefs = useMemo(() => refs, refs);
@@ -21,12 +21,9 @@ const useOnClickOutside = (ref, handler) => {
21
21
  handler(event);
22
22
  }
23
23
  };
24
- document.addEventListener('mousedown', listener);
25
- document.addEventListener('touchstart', listener);
24
+ document.addEventListener('click', listener);
26
25
  return () => {
27
- document.removeEventListener('mousedown', listener);
28
- document.removeEventListener('touchstart', listener);
26
+ document.removeEventListener('click', listener);
29
27
  };
30
28
  }, [handler, stableRefs]);
31
29
  };
32
- export { useOnClickOutside };
package/index.d.ts CHANGED
@@ -55,6 +55,7 @@
55
55
  /// <reference path="./ImageCards.d.tsx" />
56
56
  /// <reference path="./Illustration.d.tsx" />
57
57
  /// <reference path="./IframedLayout.d.tsx" />
58
+ /// <reference path="./IframeBlockClientScript.d.tsx" />
58
59
  /// <reference path="./IframeBlock.d.tsx" />
59
60
  /// <reference path="./HeroBlock.d.tsx" />
60
61
  /// <reference path="./Heading.d.tsx" />
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reykjavik/hanna-react",
3
- "version": "0.10.117",
3
+ "version": "0.10.119",
4
4
  "author": "Reykjavík (http://www.reykjavik.is)",
5
5
  "contributors": [
6
6
  "Hugsmiðjan ehf (http://www.hugsmidjan.is)",
@@ -273,6 +273,10 @@
273
273
  "import": "./esm/IframedLayout.js",
274
274
  "require": "./IframedLayout.js"
275
275
  },
276
+ "./IframeBlockClientScript": {
277
+ "import": "./esm/IframeBlockClientScript.js",
278
+ "require": "./IframeBlockClientScript.js"
279
+ },
276
280
  "./IframeBlock": {
277
281
  "import": "./esm/IframeBlock.js",
278
282
  "require": "./IframeBlock.js"
@@ -5,5 +5,5 @@ type Ref<E extends HTMLElement> = MutableRefObject<E> | RefObject<E>;
5
5
  * @param ref single or array of refs to check for click outside
6
6
  * @param handler callback to run when clicked outside of the ref
7
7
  */
8
- declare const useOnClickOutside: <E extends HTMLElement>(ref: Ref<E> | Ref<E>[], handler: (event: globalThis.MouseEvent | globalThis.TouchEvent) => void) => void;
9
- export { useOnClickOutside };
8
+ export declare const useOnClickOutside: <E extends HTMLElement>(ref: Ref<E> | Ref<E>[], handler: (event: globalThis.MouseEvent | globalThis.TouchEvent) => void) => void;
9
+ export {};
@@ -24,11 +24,9 @@ const useOnClickOutside = (ref, handler) => {
24
24
  handler(event);
25
25
  }
26
26
  };
27
- document.addEventListener('mousedown', listener);
28
- document.addEventListener('touchstart', listener);
27
+ document.addEventListener('click', listener);
29
28
  return () => {
30
- document.removeEventListener('mousedown', listener);
31
- document.removeEventListener('touchstart', listener);
29
+ document.removeEventListener('click', listener);
32
30
  };
33
31
  }, [handler, stableRefs]);
34
32
  };