@xyo-network/react-node 2.35.6 → 2.35.8
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/dist/cjs/contexts/Context.d.ts +2 -2
- package/dist/cjs/contexts/Context.d.ts.map +1 -1
- package/dist/cjs/contexts/Context.js +2 -2
- package/dist/cjs/contexts/Context.js.map +1 -1
- package/dist/cjs/contexts/Provider.d.ts +6 -2
- package/dist/cjs/contexts/Provider.d.ts.map +1 -1
- package/dist/cjs/contexts/Provider.js +6 -4
- package/dist/cjs/contexts/Provider.js.map +1 -1
- package/dist/cjs/contexts/State.d.ts +1 -1
- package/dist/cjs/contexts/State.d.ts.map +1 -1
- package/dist/cjs/contexts/useNode.js +1 -1
- package/dist/cjs/contexts/useNode.js.map +1 -1
- package/dist/docs.json +298 -159
- package/dist/esm/contexts/Context.d.ts +2 -2
- package/dist/esm/contexts/Context.d.ts.map +1 -1
- package/dist/esm/contexts/Context.js +1 -1
- package/dist/esm/contexts/Context.js.map +1 -1
- package/dist/esm/contexts/Provider.d.ts +6 -2
- package/dist/esm/contexts/Provider.d.ts.map +1 -1
- package/dist/esm/contexts/Provider.js +5 -3
- package/dist/esm/contexts/Provider.js.map +1 -1
- package/dist/esm/contexts/State.d.ts +1 -1
- package/dist/esm/contexts/State.d.ts.map +1 -1
- package/dist/esm/contexts/useNode.js +2 -2
- package/dist/esm/contexts/useNode.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Node.stories.tsx +36 -0
- package/src/contexts/Context.ts +2 -2
- package/src/contexts/Provider.tsx +10 -4
- package/src/contexts/State.ts +1 -1
- package/src/contexts/useNode.ts +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import {
|
|
3
|
-
export declare const
|
|
2
|
+
import { NodeContextState } from './State';
|
|
3
|
+
export declare const NodeContext: import("react").Context<NodeContextState & import("@xyo-network/react-shared").ContextExState>;
|
|
4
4
|
//# sourceMappingURL=Context.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Context.d.ts","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE1C,eAAO,MAAM,WAAW,gGAAsC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAI3D,MAAM,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../src/contexts/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAI3D,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,EAAoB,CAAA"}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { WithChildren } from '@xylabs/react-shared';
|
|
3
3
|
import { XyoNode } from '@xyo-network/node';
|
|
4
|
-
export interface
|
|
4
|
+
export interface NodeProviderProps {
|
|
5
5
|
required?: boolean;
|
|
6
6
|
node?: XyoNode;
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
/** @deprecated use NodeProviderProps instead */
|
|
9
|
+
export declare type XyoNodeProviderProps = NodeProviderProps;
|
|
10
|
+
export declare const NodeProvider: React.FC<WithChildren<NodeProviderProps>>;
|
|
11
|
+
/** @deprecated use NodeProvider instead */
|
|
12
|
+
export declare const XyoNodeProvider: import("react").FC<WithChildren<NodeProviderProps>>;
|
|
9
13
|
//# sourceMappingURL=Provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAK3C,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAK3C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,gDAAgD;AAChD,oBAAY,oBAAoB,GAAG,iBAAiB,CAAA;AAEpD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,YAAY,CAAC,iBAAiB,CAAC,CAQlE,CAAA;AAED,2CAA2C;AAC3C,eAAO,MAAM,eAAe,qDAAe,CAAA"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useEffect, useState } from 'react';
|
|
3
|
-
import {
|
|
4
|
-
export const
|
|
3
|
+
import { NodeContext } from './Context';
|
|
4
|
+
export const NodeProvider = ({ node: nodeProp, required = false, children }) => {
|
|
5
5
|
const [node, setNode] = useState();
|
|
6
6
|
useEffect(() => {
|
|
7
7
|
setNode(nodeProp);
|
|
8
8
|
}, [nodeProp]);
|
|
9
|
-
return !required || node ? _jsx(
|
|
9
|
+
return !required || node ? _jsx(NodeContext.Provider, { value: { node, provided: true, setNode }, children: children }) : null;
|
|
10
10
|
};
|
|
11
|
+
/** @deprecated use NodeProvider instead */
|
|
12
|
+
export const XyoNodeProvider = NodeProvider;
|
|
11
13
|
//# sourceMappingURL=Provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../src/contexts/Provider.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAE3C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAUvC,MAAM,CAAC,MAAM,YAAY,GAA8C,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,GAAG,KAAK,EAAE,QAAQ,EAAE,EAAE,EAAE;IACxH,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,GAAG,QAAQ,EAAW,CAAA;IAE3C,SAAS,CAAC,GAAG,EAAE;QACb,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;IAEd,OAAO,CAAC,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAC,WAAW,CAAC,QAAQ,IAAC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,YAAG,QAAQ,GAAwB,CAAC,CAAC,CAAC,IAAI,CAAA;AACrI,CAAC,CAAA;AAED,2CAA2C;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/contexts/State.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../../src/contexts/State.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAA;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAEhC,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;CAC5B"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { useContextEx } from '@xyo-network/react-shared';
|
|
2
|
-
import {
|
|
2
|
+
import { NodeContext } from './Context';
|
|
3
3
|
export const useNode = () => {
|
|
4
|
-
const { node, setNode } = useContextEx(
|
|
4
|
+
const { node, setNode } = useContextEx(NodeContext, 'XyoNode');
|
|
5
5
|
return [node, setNode];
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=useNode.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useNode.js","sourceRoot":"","sources":["../../../src/contexts/useNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGxD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"useNode.js","sourceRoot":"","sources":["../../../src/contexts/useNode.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAA;AAEvC,MAAM,CAAC,MAAM,OAAO,GAAG,GAAyD,EAAE;IAChF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,YAAY,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;IAE9D,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;AACxB,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/react-flexbox": "^2.14.20",
|
|
14
14
|
"@xylabs/react-shared": "^2.14.20",
|
|
15
|
-
"@xyo-network/react-shared": "^2.35.
|
|
15
|
+
"@xyo-network/react-shared": "^2.35.8",
|
|
16
16
|
"lodash": "^4.17.21",
|
|
17
17
|
"tslib": "^2.4.0"
|
|
18
18
|
},
|
|
@@ -73,5 +73,5 @@
|
|
|
73
73
|
},
|
|
74
74
|
"sideEffects": false,
|
|
75
75
|
"types": "dist/esm/index.d.ts",
|
|
76
|
-
"version": "2.35.
|
|
76
|
+
"version": "2.35.8"
|
|
77
77
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentMeta, ComponentStory } from '@storybook/react'
|
|
2
|
+
import {} from '@xyo-network/node'
|
|
3
|
+
|
|
4
|
+
import { NodeProvider } from '../contexts'
|
|
5
|
+
import { NodeBox } from './Node'
|
|
6
|
+
|
|
7
|
+
const StorybookEntry = {
|
|
8
|
+
argTypes: {
|
|
9
|
+
responsive: {
|
|
10
|
+
defaultValue: false,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
component: NodeBox,
|
|
14
|
+
parameters: {
|
|
15
|
+
docs: {
|
|
16
|
+
page: null,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
title: 'node/NodeBox',
|
|
20
|
+
} as ComponentMeta<typeof NodeBox>
|
|
21
|
+
|
|
22
|
+
const Template: ComponentStory<typeof NodeBox> = (args) => {
|
|
23
|
+
return (
|
|
24
|
+
<NodeProvider>
|
|
25
|
+
<NodeBox {...args}></NodeBox>
|
|
26
|
+
</NodeProvider>
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const Default = Template.bind({})
|
|
31
|
+
Default.args = {}
|
|
32
|
+
|
|
33
|
+
export { Default }
|
|
34
|
+
|
|
35
|
+
// eslint-disable-next-line import/no-default-export
|
|
36
|
+
export default StorybookEntry
|
package/src/contexts/Context.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContextEx } from '@xyo-network/react-shared'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { NodeContextState } from './State'
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const NodeContext = createContextEx<NodeContextState>()
|
|
@@ -2,19 +2,25 @@ import { WithChildren } from '@xylabs/react-shared'
|
|
|
2
2
|
import { XyoNode } from '@xyo-network/node'
|
|
3
3
|
import { useEffect, useState } from 'react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { NodeContext } from './Context'
|
|
6
6
|
|
|
7
|
-
export interface
|
|
7
|
+
export interface NodeProviderProps {
|
|
8
8
|
required?: boolean
|
|
9
9
|
node?: XyoNode
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
/** @deprecated use NodeProviderProps instead */
|
|
13
|
+
export type XyoNodeProviderProps = NodeProviderProps
|
|
14
|
+
|
|
15
|
+
export const NodeProvider: React.FC<WithChildren<NodeProviderProps>> = ({ node: nodeProp, required = false, children }) => {
|
|
13
16
|
const [node, setNode] = useState<XyoNode>()
|
|
14
17
|
|
|
15
18
|
useEffect(() => {
|
|
16
19
|
setNode(nodeProp)
|
|
17
20
|
}, [nodeProp])
|
|
18
21
|
|
|
19
|
-
return !required || node ? <
|
|
22
|
+
return !required || node ? <NodeContext.Provider value={{ node, provided: true, setNode }}>{children}</NodeContext.Provider> : null
|
|
20
23
|
}
|
|
24
|
+
|
|
25
|
+
/** @deprecated use NodeProvider instead */
|
|
26
|
+
export const XyoNodeProvider = NodeProvider
|
package/src/contexts/State.ts
CHANGED
package/src/contexts/useNode.ts
CHANGED
|
@@ -2,10 +2,10 @@ import { XyoNode } from '@xyo-network/node'
|
|
|
2
2
|
import { useContextEx } from '@xyo-network/react-shared'
|
|
3
3
|
import { Dispatch } from 'react'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { NodeContext } from './Context'
|
|
6
6
|
|
|
7
7
|
export const useNode = (): [XyoNode | undefined, Dispatch<XyoNode> | undefined] => {
|
|
8
|
-
const { node, setNode } = useContextEx(
|
|
8
|
+
const { node, setNode } = useContextEx(NodeContext, 'XyoNode')
|
|
9
9
|
|
|
10
10
|
return [node, setNode]
|
|
11
11
|
}
|