react-iframe-bridge 0.9.0 → 1.0.0
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/README.md +4 -7
- package/lib/components/ErrorPage.d.ts +1 -1
- package/lib/components/Input.d.ts +10 -0
- package/lib/components/Input.js +5 -0
- package/lib/components/home/HomeContext.d.ts +2 -2
- package/lib/components/home/HomeContext.js +1 -1
- package/lib/components/home/HomeHeader.js +2 -1
- package/lib/contexts/iframeBridge.d.ts +4 -3
- package/lib/contexts/iframeBridge.js +1 -1
- package/lib/contexts/roc.d.ts +1 -1
- package/lib/hooks/localStorage.d.ts +1 -1
- package/lib/hooks/useRocQuery.d.ts +1 -1
- package/lib-cjs/components/ErrorPage.d.ts +1 -1
- package/lib-cjs/components/ErrorPage.js +1 -1
- package/lib-cjs/components/Input.d.ts +10 -0
- package/lib-cjs/components/Input.js +11 -0
- package/lib-cjs/components/LoadingFull.js +1 -1
- package/lib-cjs/components/Spinner.js +1 -1
- package/lib-cjs/components/home/Home.js +1 -2
- package/lib-cjs/components/home/HomeContext.d.ts +2 -2
- package/lib-cjs/components/home/HomeContext.js +3 -4
- package/lib-cjs/components/home/HomeHeader.js +6 -2
- package/lib-cjs/components/home/HomeIframe.js +1 -1
- package/lib-cjs/components/home/HomeNoSample.js +1 -1
- package/lib-cjs/components/home/HomeSamples.js +1 -1
- package/lib-cjs/components/home/HomeSelector.js +1 -1
- package/lib-cjs/contexts/iframeBridge.d.ts +4 -3
- package/lib-cjs/contexts/iframeBridge.js +3 -4
- package/lib-cjs/contexts/roc.d.ts +1 -1
- package/lib-cjs/contexts/roc.js +2 -3
- package/lib-cjs/hooks/localStorage.d.ts +1 -1
- package/lib-cjs/hooks/localStorage.js +2 -3
- package/lib-cjs/hooks/useRocQuery.d.ts +1 -1
- package/lib-cjs/hooks/useRocQuery.js +1 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -10,12 +10,9 @@ Install the package:
|
|
|
10
10
|
npm i react-iframe-bridge
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
Add the package's files to TailwindCSS
|
|
13
|
+
Add the package's files to TailwindCSS configuration:
|
|
14
14
|
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
'./node_modules/react-iframe-bridge/lib/**/*.js',
|
|
19
|
-
},
|
|
20
|
-
};
|
|
15
|
+
```css
|
|
16
|
+
@import 'tailwindcss';
|
|
17
|
+
@source '../node_modules/react-iframe-bridge/lib';
|
|
21
18
|
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
interface InputProps {
|
|
3
|
+
name: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function Input(props: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import clsx from 'clsx';
|
|
3
|
+
export default function Input(props) {
|
|
4
|
+
return (_jsx("input", { name: props.name, type: "text", className: clsx('appearance-none border border-neutral-600 bg-white px-3 py-2 text-base leading-none', props.className), value: props.value, readOnly: props.readOnly, onChange: props.onChange }));
|
|
5
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { produce } from 'immer';
|
|
3
|
-
import { createContext, useContext, useReducer
|
|
3
|
+
import { createContext, useContext, useReducer } from 'react';
|
|
4
4
|
import { RocProvider } from '../../contexts/roc';
|
|
5
5
|
import { useSaveToLocalStorage } from '../../hooks/localStorage';
|
|
6
6
|
import { getItem } from '../../utils/localStorage';
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Input from '../Input';
|
|
2
3
|
import { useHomeContext, useHomeDispatchContext } from './HomeContext';
|
|
3
4
|
export default function HomeHeader() {
|
|
4
5
|
const { rocUrl, database, iframePath } = useHomeContext();
|
|
5
6
|
const dispatch = useHomeDispatchContext();
|
|
6
|
-
return (_jsxs("header", { className: "flex flex-row p-2 space-x-4", children: [_jsx(
|
|
7
|
+
return (_jsxs("header", { className: "flex flex-row p-2 space-x-4", children: [_jsx(Input, { name: "rocUrl", className: "flex-1", value: rocUrl, readOnly: true }), _jsx(Input, { name: "database", value: database, readOnly: true }), _jsx(Input, { name: "iframe-page", value: iframePath, className: "flex-1", onChange: (event) => {
|
|
7
8
|
dispatch({ type: 'SET_IFRAME_PAGE', payload: event.target.value });
|
|
8
9
|
} })] }));
|
|
9
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { RocDocument } from 'rest-on-couch-client';
|
|
3
|
+
import { Roc } from 'rest-on-couch-client';
|
|
4
|
+
import type { SampleEntryContent, SampleEntryId } from '../types/db';
|
|
4
5
|
export declare function useIframeBridgeContext<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo, PrivateUserInfo>;
|
|
5
6
|
export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
|
|
6
7
|
interface IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
// https://github.com/import-js/eslint-plugin-import/issues/1810
|
|
3
3
|
import { onMessage, ready } from 'iframe-bridge/iframe';
|
|
4
4
|
import { produce } from 'immer';
|
|
5
|
-
import { createContext, useContext, useEffect, useReducer
|
|
5
|
+
import { createContext, useContext, useEffect, useReducer } from 'react';
|
|
6
6
|
import { Roc } from 'rest-on-couch-client';
|
|
7
7
|
import ErrorPage from '../components/ErrorPage';
|
|
8
8
|
import LoadingFull from '../components/LoadingFull';
|
package/lib/contexts/roc.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
import { Roc } from 'rest-on-couch-client';
|
|
3
3
|
export declare function useRoc<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): Roc<PublicUserInfo, PrivateUserInfo>;
|
|
4
4
|
export declare function RocProvider(props: {
|
|
@@ -10,4 +10,4 @@ export declare function useLocalStorage<ValueType>(key: string, initialValue: Va
|
|
|
10
10
|
* @param key localStorage key. Will be appended to the `react-iframe-bridge-` prefix.
|
|
11
11
|
* @param value Value to save.
|
|
12
12
|
*/
|
|
13
|
-
export declare function useSaveToLocalStorage
|
|
13
|
+
export declare function useSaveToLocalStorage(key: string, value: unknown): void;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = ErrorPage;
|
|
3
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
5
|
function ErrorPage(props) {
|
|
5
6
|
return ((0, jsx_runtime_1.jsx)("div", { className: "max-w-2xl m-auto md:max-w-4xl", children: (0, jsx_runtime_1.jsx)("div", { className: "flex justify-between px-2 pt-4", children: (0, jsx_runtime_1.jsxs)("div", { className: "min-w-0", children: [(0, jsx_runtime_1.jsx)("h1", { className: "text-5xl font-bold sm:mt-16 text-primary-900", children: props.title }), (0, jsx_runtime_1.jsx)("h2", { className: "mt-16 text-lg sm:mt-8", children: props.subtitle }), (0, jsx_runtime_1.jsx)("div", { className: "mt-4", children: props.children })] }) }) }));
|
|
6
7
|
}
|
|
7
|
-
exports.default = ErrorPage;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ChangeEvent } from 'react';
|
|
2
|
+
interface InputProps {
|
|
3
|
+
name: string;
|
|
4
|
+
className?: string;
|
|
5
|
+
value: string;
|
|
6
|
+
readOnly?: boolean;
|
|
7
|
+
onChange?: (event: ChangeEvent<HTMLInputElement>) => void;
|
|
8
|
+
}
|
|
9
|
+
export default function Input(props: InputProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = Input;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
9
|
+
function Input(props) {
|
|
10
|
+
return ((0, jsx_runtime_1.jsx)("input", { name: props.name, type: "text", className: (0, clsx_1.default)('appearance-none border border-neutral-600 bg-white px-3 py-2 text-base leading-none', props.className), value: props.value, readOnly: props.readOnly, onChange: props.onChange }));
|
|
11
|
+
}
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = LoadingFull;
|
|
6
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
8
|
const Spinner_1 = __importDefault(require("./Spinner"));
|
|
8
9
|
function LoadingFull() {
|
|
9
10
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center w-full h-full", children: (0, jsx_runtime_1.jsx)(Spinner_1.default, { className: "w-10 h-10 text-alternative-500" }) }));
|
|
10
11
|
}
|
|
11
|
-
exports.default = LoadingFull;
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = Spinner;
|
|
6
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
8
|
const clsx_1 = __importDefault(require("clsx"));
|
|
8
9
|
function Spinner(props) {
|
|
9
10
|
return ((0, jsx_runtime_1.jsxs)("svg", { className: (0, clsx_1.default)('animate-spin', props.className), xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [(0, jsx_runtime_1.jsx)("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), (0, jsx_runtime_1.jsx)("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }));
|
|
10
11
|
}
|
|
11
|
-
exports.default = Spinner;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Home =
|
|
6
|
+
exports.Home = Home;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = require("react");
|
|
9
9
|
const HomeContext_1 = require("./HomeContext");
|
|
@@ -15,7 +15,6 @@ function Home(props) {
|
|
|
15
15
|
const { baseUrl, noSampleSelection, rocUrl, database, defaultPath } = props;
|
|
16
16
|
return ((0, jsx_runtime_1.jsx)(HomeContext_1.HomeContextProvider, { rocUrl: rocUrl, database: database, defaultPath: defaultPath, children: (0, jsx_runtime_1.jsx)(HomeInternal, { noSampleSelection: noSampleSelection, baseUrl: baseUrl }) }));
|
|
17
17
|
}
|
|
18
|
-
exports.Home = Home;
|
|
19
18
|
function HomeInternal(props) {
|
|
20
19
|
const homeDispatch = (0, HomeContext_1.useHomeDispatchContext)();
|
|
21
20
|
(0, react_1.useEffect)(() => {
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.HomeContextProvider = HomeContextProvider;
|
|
4
|
+
exports.useHomeContext = useHomeContext;
|
|
5
|
+
exports.useHomeDispatchContext = useHomeDispatchContext;
|
|
4
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
7
|
const immer_1 = require("immer");
|
|
6
8
|
const react_1 = require("react");
|
|
@@ -44,12 +46,9 @@ function HomeContextProvider(props) {
|
|
|
44
46
|
(0, localStorage_1.useSaveToLocalStorage)('dev-home-iframe-path', homeState.iframePath);
|
|
45
47
|
return ((0, jsx_runtime_1.jsx)(homeContext.Provider, { value: homeState, children: (0, jsx_runtime_1.jsx)(homeDispatchContext.Provider, { value: dispatch, children: (0, jsx_runtime_1.jsx)(roc_1.RocProvider, { url: homeState.rocUrl, database: homeState.database, children: children }) }) }));
|
|
46
48
|
}
|
|
47
|
-
exports.HomeContextProvider = HomeContextProvider;
|
|
48
49
|
function useHomeContext() {
|
|
49
50
|
return (0, react_1.useContext)(homeContext);
|
|
50
51
|
}
|
|
51
|
-
exports.useHomeContext = useHomeContext;
|
|
52
52
|
function useHomeDispatchContext() {
|
|
53
53
|
return (0, react_1.useContext)(homeDispatchContext);
|
|
54
54
|
}
|
|
55
|
-
exports.useHomeDispatchContext = useHomeDispatchContext;
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = HomeHeader;
|
|
3
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const Input_1 = __importDefault(require("../Input"));
|
|
4
9
|
const HomeContext_1 = require("./HomeContext");
|
|
5
10
|
function HomeHeader() {
|
|
6
11
|
const { rocUrl, database, iframePath } = (0, HomeContext_1.useHomeContext)();
|
|
7
12
|
const dispatch = (0, HomeContext_1.useHomeDispatchContext)();
|
|
8
|
-
return ((0, jsx_runtime_1.jsxs)("header", { className: "flex flex-row p-2 space-x-4", children: [(0, jsx_runtime_1.jsx)(
|
|
13
|
+
return ((0, jsx_runtime_1.jsxs)("header", { className: "flex flex-row p-2 space-x-4", children: [(0, jsx_runtime_1.jsx)(Input_1.default, { name: "rocUrl", className: "flex-1", value: rocUrl, readOnly: true }), (0, jsx_runtime_1.jsx)(Input_1.default, { name: "database", value: database, readOnly: true }), (0, jsx_runtime_1.jsx)(Input_1.default, { name: "iframe-page", value: iframePath, className: "flex-1", onChange: (event) => {
|
|
9
14
|
dispatch({ type: 'SET_IFRAME_PAGE', payload: event.target.value });
|
|
10
15
|
} })] }));
|
|
11
16
|
}
|
|
12
|
-
exports.default = HomeHeader;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = HomeIframe;
|
|
3
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
5
|
// https://github.com/import-js/eslint-plugin-import/issues/1810
|
|
5
6
|
const main_1 = require("iframe-bridge/main");
|
|
@@ -34,4 +35,3 @@ function HomeIframe(props) {
|
|
|
34
35
|
}, [windowId, database, rocUrl, selectedSample]);
|
|
35
36
|
return ((0, jsx_runtime_1.jsx)("div", { className: "flex items-center justify-center flex-1", children: iframeMode !== 'closed' ? ((0, jsx_runtime_1.jsx)("iframe", { allowFullScreen: true, src: `${baseUrl || ''}${iframePath}`, className: "w-full h-full" }, selectedSample)) : ((0, jsx_runtime_1.jsx)("div", { children: "Please select something" })) }));
|
|
36
37
|
}
|
|
37
|
-
exports.default = HomeIframe;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = HomeNoSample;
|
|
6
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
8
|
const HomeContext_1 = require("./HomeContext");
|
|
8
9
|
const HomeSelector_1 = __importDefault(require("./HomeSelector"));
|
|
@@ -11,4 +12,3 @@ function HomeNoSample() {
|
|
|
11
12
|
const dispatch = (0, HomeContext_1.useHomeDispatchContext)();
|
|
12
13
|
return ((0, jsx_runtime_1.jsx)("div", { children: (0, jsx_runtime_1.jsx)(HomeSelector_1.default, { onClick: () => dispatch({ type: 'OPEN_NO_SAMPLE' }), selected: iframeMode === 'no-sample', text: "No sample" }) }));
|
|
13
14
|
}
|
|
14
|
-
exports.default = HomeNoSample;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = HomeSamples;
|
|
6
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
8
|
const useRocQuery_1 = require("../../hooks/useRocQuery");
|
|
8
9
|
const Spinner_1 = __importDefault(require("../Spinner"));
|
|
@@ -15,7 +16,6 @@ function HomeSamples() {
|
|
|
15
16
|
}
|
|
16
17
|
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h1", { className: "mb-4 text-lg font-bold text-center", children: "Sample TOC" }), (0, jsx_runtime_1.jsx)("div", { className: "flex-1", children: loading || !result ? (0, jsx_runtime_1.jsx)(Loading, {}) : (0, jsx_runtime_1.jsx)(SampleToc, { samples: result }) })] }));
|
|
17
18
|
}
|
|
18
|
-
exports.default = HomeSamples;
|
|
19
19
|
function SampleToc(props) {
|
|
20
20
|
const { selectedSample } = (0, HomeContext_1.useHomeContext)();
|
|
21
21
|
const dispatch = (0, HomeContext_1.useHomeDispatchContext)();
|
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = HomeSelector;
|
|
6
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
8
|
const clsx_1 = __importDefault(require("clsx"));
|
|
8
9
|
function HomeSelector(props) {
|
|
9
10
|
return ((0, jsx_runtime_1.jsx)("div", { className: (0, clsx_1.default)('p-1 border rounded cursor-pointer border-neutral-400', props.selected && 'bg-primary-50 shadow-inner'), onClick: props.onClick, children: props.text }));
|
|
10
11
|
}
|
|
11
|
-
exports.default = HomeSelector;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import type { RocDocument } from 'rest-on-couch-client';
|
|
3
|
+
import { Roc } from 'rest-on-couch-client';
|
|
4
|
+
import type { SampleEntryContent, SampleEntryId } from '../types/db';
|
|
4
5
|
export declare function useIframeBridgeContext<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): IframeBridgeReadyContextType<PublicUserInfo, PrivateUserInfo>;
|
|
5
6
|
export declare function useIframeBridgeSample(): RocDocument<SampleEntryContent, SampleEntryId>;
|
|
6
7
|
interface IframeBridgeReadyContextTypeBase<PublicUserInfo, PrivateUserInfo> {
|
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.useIframeBridgeContext = useIframeBridgeContext;
|
|
7
|
+
exports.useIframeBridgeSample = useIframeBridgeSample;
|
|
8
|
+
exports.IframeBridgeProvider = IframeBridgeProvider;
|
|
7
9
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
10
|
// https://github.com/import-js/eslint-plugin-import/issues/1810
|
|
9
11
|
const iframe_1 = require("iframe-bridge/iframe");
|
|
@@ -22,7 +24,6 @@ function useIframeBridgeContext() {
|
|
|
22
24
|
}
|
|
23
25
|
return context;
|
|
24
26
|
}
|
|
25
|
-
exports.useIframeBridgeContext = useIframeBridgeContext;
|
|
26
27
|
function useIframeBridgeSample() {
|
|
27
28
|
const context = useIframeBridgeContext();
|
|
28
29
|
if (!context.sample) {
|
|
@@ -30,7 +31,6 @@ function useIframeBridgeSample() {
|
|
|
30
31
|
}
|
|
31
32
|
return context.sample;
|
|
32
33
|
}
|
|
33
|
-
exports.useIframeBridgeSample = useIframeBridgeSample;
|
|
34
34
|
const iframeBridgeReducer = (0, immer_1.produce)((state, action) => {
|
|
35
35
|
switch (action.type) {
|
|
36
36
|
case 'RECEIVE_DATA': {
|
|
@@ -128,4 +128,3 @@ function IframeBridgeProvider(props) {
|
|
|
128
128
|
}
|
|
129
129
|
return ((0, jsx_runtime_1.jsx)(iframeBridgeContext.Provider, { value: state, children: props.children }));
|
|
130
130
|
}
|
|
131
|
-
exports.IframeBridgeProvider = IframeBridgeProvider;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
import { Roc } from 'rest-on-couch-client';
|
|
3
3
|
export declare function useRoc<PublicUserInfo = unknown, PrivateUserInfo = unknown>(): Roc<PublicUserInfo, PrivateUserInfo>;
|
|
4
4
|
export declare function RocProvider(props: {
|
package/lib-cjs/contexts/roc.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useRoc = useRoc;
|
|
4
|
+
exports.RocProvider = RocProvider;
|
|
4
5
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
6
|
const react_1 = require("react");
|
|
6
7
|
const rest_on_couch_client_1 = require("rest-on-couch-client");
|
|
@@ -12,10 +13,8 @@ function useRoc() {
|
|
|
12
13
|
}
|
|
13
14
|
return roc;
|
|
14
15
|
}
|
|
15
|
-
exports.useRoc = useRoc;
|
|
16
16
|
function RocProvider(props) {
|
|
17
17
|
const { url, database, children } = props;
|
|
18
18
|
const roc = (0, react_1.useMemo)(() => new rest_on_couch_client_1.Roc({ url, database }), [url, database]);
|
|
19
19
|
return (0, jsx_runtime_1.jsx)(rocContext.Provider, { value: roc, children: children });
|
|
20
20
|
}
|
|
21
|
-
exports.RocProvider = RocProvider;
|
|
@@ -10,4 +10,4 @@ export declare function useLocalStorage<ValueType>(key: string, initialValue: Va
|
|
|
10
10
|
* @param key localStorage key. Will be appended to the `react-iframe-bridge-` prefix.
|
|
11
11
|
* @param value Value to save.
|
|
12
12
|
*/
|
|
13
|
-
export declare function useSaveToLocalStorage
|
|
13
|
+
export declare function useSaveToLocalStorage(key: string, value: unknown): void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.useLocalStorage = useLocalStorage;
|
|
4
|
+
exports.useSaveToLocalStorage = useSaveToLocalStorage;
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
const localStorage_1 = require("../utils/localStorage");
|
|
6
7
|
/**
|
|
@@ -25,7 +26,6 @@ function useLocalStorage(key, initialValue) {
|
|
|
25
26
|
}, [key]);
|
|
26
27
|
return [storedValue, setValue];
|
|
27
28
|
}
|
|
28
|
-
exports.useLocalStorage = useLocalStorage;
|
|
29
29
|
/**
|
|
30
30
|
* Save the provided value to `localStorage` everytime it changes.
|
|
31
31
|
* @param key localStorage key. Will be appended to the `react-iframe-bridge-` prefix.
|
|
@@ -36,4 +36,3 @@ function useSaveToLocalStorage(key, value) {
|
|
|
36
36
|
(0, localStorage_1.setItem)(key, value);
|
|
37
37
|
}, [key, value]);
|
|
38
38
|
}
|
|
39
|
-
exports.useSaveToLocalStorage = useSaveToLocalStorage;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useRocQuery =
|
|
3
|
+
exports.useRocQuery = useRocQuery;
|
|
4
4
|
const react_1 = require("react");
|
|
5
5
|
const roc_1 = require("../contexts/roc");
|
|
6
6
|
function rocQueryReducer(state, action) {
|
|
@@ -43,4 +43,3 @@ function useRocQuery(viewName, options = {}) {
|
|
|
43
43
|
}, [roc, viewName, mine]);
|
|
44
44
|
return state;
|
|
45
45
|
}
|
|
46
|
-
exports.useRocQuery = useRocQuery;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-iframe-bridge",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "React hooks and components to work with iframe-bridge.",
|
|
5
5
|
"main": "lib-cjs/index.js",
|
|
6
6
|
"module": "lib/index.js",
|
|
@@ -36,11 +36,11 @@
|
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@types/react": "^18.3.1",
|
|
38
38
|
"@types/react-dom": "^18.3.0",
|
|
39
|
-
"eslint": "^
|
|
40
|
-
"eslint-config-zakodium": "^
|
|
41
|
-
"prettier": "^3.
|
|
39
|
+
"eslint": "^9.27.0",
|
|
40
|
+
"eslint-config-zakodium": "^15.0.1",
|
|
41
|
+
"prettier": "^3.5.3",
|
|
42
42
|
"react": "^18.3.1",
|
|
43
43
|
"react-dom": "^18.3.1",
|
|
44
|
-
"typescript": "^5.
|
|
44
|
+
"typescript": "^5.8.3"
|
|
45
45
|
}
|
|
46
46
|
}
|