piral-core 0.14.8-beta.3500 → 0.14.8-beta.3511
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/esm/Piral.d.ts +2 -2
- package/esm/Piral.js +3 -1
- package/esm/Piral.js.map +1 -1
- package/esm/RootListener.d.ts +2 -0
- package/esm/RootListener.js +23 -0
- package/esm/RootListener.js.map +1 -0
- package/esm/components/ExtensionSlot.js +2 -2
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/components/Mediator.js +11 -8
- package/esm/components/Mediator.js.map +1 -1
- package/esm/components/ResponsiveLayout.js +3 -3
- package/esm/components/ResponsiveLayout.js.map +1 -1
- package/esm/components/SetComponent.js +2 -2
- package/esm/components/SetComponent.js.map +1 -1
- package/esm/components/SetError.js +2 -2
- package/esm/components/SetError.js.map +1 -1
- package/esm/components/SetProvider.js +2 -2
- package/esm/components/SetProvider.js.map +1 -1
- package/esm/components/SetRedirect.js +2 -2
- package/esm/components/SetRedirect.js.map +1 -1
- package/esm/components/SetRoute.js +2 -2
- package/esm/components/SetRoute.js.map +1 -1
- package/esm/createInstance.d.ts +2 -2
- package/esm/createInstance.js +3 -1
- package/esm/createInstance.js.map +1 -1
- package/esm/modules/api.d.ts +3 -4
- package/esm/modules/api.js +1 -106
- package/esm/modules/api.js.map +1 -1
- package/esm/modules/core.d.ts +3 -0
- package/esm/modules/core.js +48 -0
- package/esm/modules/core.js.map +1 -0
- package/esm/modules/element.d.ts +5 -0
- package/esm/modules/element.js +83 -0
- package/esm/modules/element.js.map +1 -0
- package/esm/modules/index.d.ts +1 -0
- package/esm/modules/index.js +1 -0
- package/esm/modules/index.js.map +1 -1
- package/esm/state/withApi.js +2 -3
- package/esm/state/withApi.js.map +1 -1
- package/esm/types/extension.d.ts +7 -3
- package/esm/types/instance.d.ts +18 -3
- package/esm/utils/extension.d.ts +13 -0
- package/esm/utils/extension.js +32 -0
- package/esm/utils/extension.js.map +1 -1
- package/lib/Piral.d.ts +2 -2
- package/lib/Piral.js +3 -1
- package/lib/Piral.js.map +1 -1
- package/lib/RootListener.d.ts +2 -0
- package/lib/RootListener.js +27 -0
- package/lib/RootListener.js.map +1 -0
- package/lib/components/ExtensionSlot.js +2 -2
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/components/Mediator.js +10 -7
- package/lib/components/Mediator.js.map +1 -1
- package/lib/components/ResponsiveLayout.js +2 -2
- package/lib/components/ResponsiveLayout.js.map +1 -1
- package/lib/components/SetComponent.js +1 -1
- package/lib/components/SetComponent.js.map +1 -1
- package/lib/components/SetError.js +1 -1
- package/lib/components/SetError.js.map +1 -1
- package/lib/components/SetProvider.js +1 -1
- package/lib/components/SetProvider.js.map +1 -1
- package/lib/components/SetRedirect.js +1 -1
- package/lib/components/SetRedirect.js.map +1 -1
- package/lib/components/SetRoute.js +1 -1
- package/lib/components/SetRoute.js.map +1 -1
- package/lib/createInstance.d.ts +2 -2
- package/lib/createInstance.js +3 -1
- package/lib/createInstance.js.map +1 -1
- package/lib/modules/api.d.ts +3 -4
- package/lib/modules/api.js +3 -109
- package/lib/modules/api.js.map +1 -1
- package/lib/modules/core.d.ts +3 -0
- package/lib/modules/core.js +52 -0
- package/lib/modules/core.js.map +1 -0
- package/lib/modules/element.d.ts +5 -0
- package/lib/modules/element.js +87 -0
- package/lib/modules/element.js.map +1 -0
- package/lib/modules/index.d.ts +1 -0
- package/lib/modules/index.js +1 -0
- package/lib/modules/index.js.map +1 -1
- package/lib/state/withApi.js +1 -2
- package/lib/state/withApi.js.map +1 -1
- package/lib/types/extension.d.ts +7 -3
- package/lib/types/instance.d.ts +18 -3
- package/lib/utils/extension.d.ts +13 -0
- package/lib/utils/extension.js +34 -1
- package/lib/utils/extension.js.map +1 -1
- package/package.json +4 -4
- package/src/Piral.tsx +5 -3
- package/src/RootListener.tsx +26 -0
- package/src/actions/app.ts +1 -1
- package/src/components/ExtensionSlot.tsx +2 -1
- package/src/components/Mediator.test.tsx +4 -3
- package/src/components/Mediator.tsx +15 -8
- package/src/components/ResponsiveLayout.test.tsx +15 -5
- package/src/components/ResponsiveLayout.tsx +3 -3
- package/src/components/SetComponent.tsx +2 -2
- package/src/components/SetError.tsx +2 -2
- package/src/components/SetProvider.tsx +2 -2
- package/src/components/SetRedirect.tsx +2 -2
- package/src/components/SetRoute.tsx +2 -2
- package/src/createInstance.tsx +5 -2
- package/src/modules/api.test.ts +15 -15
- package/src/modules/api.ts +3 -125
- package/src/modules/core.test.ts +148 -0
- package/src/modules/core.ts +50 -0
- package/src/modules/element.ts +103 -0
- package/src/modules/index.ts +1 -0
- package/src/state/withApi.tsx +2 -3
- package/src/types/extension.ts +7 -2
- package/src/types/instance.ts +19 -3
- package/src/utils/extension.tsx +41 -0
package/src/types/instance.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import type { PiletApi, PiletApiCreator, LoadPiletsOptions, EventEmitter } from 'piral-base';
|
|
2
2
|
import type { GlobalStateContext } from './state';
|
|
3
3
|
import type { LayoutBreakpoints } from './layout';
|
|
4
|
+
import { PiralConfiguration } from './config';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* The props of the Piral component.
|
|
7
8
|
*/
|
|
8
|
-
export interface
|
|
9
|
+
export interface PiralProps {
|
|
9
10
|
/**
|
|
10
11
|
* The specific Piral instance to be used.
|
|
11
12
|
*/
|
|
@@ -17,10 +18,25 @@ export interface PortalProps {
|
|
|
17
18
|
}
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
|
-
* The
|
|
21
|
-
|
|
21
|
+
* The options for creating a new PiralInstance object.
|
|
22
|
+
*/
|
|
23
|
+
export interface PiralInstanceOptions extends PiralConfiguration {
|
|
24
|
+
/**
|
|
25
|
+
* Defines the id of this instance. Used in case of multiple instances.
|
|
26
|
+
*/
|
|
27
|
+
id?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The PiralInstance object, which is an event emitter with some other
|
|
32
|
+
* utilities and helper. This object is the source for the React
|
|
33
|
+
* functional component (`Piral`).
|
|
22
34
|
*/
|
|
23
35
|
export interface PiralInstance extends EventEmitter {
|
|
36
|
+
/**
|
|
37
|
+
* The id of the Piral instance.
|
|
38
|
+
*/
|
|
39
|
+
id: string;
|
|
24
40
|
/**
|
|
25
41
|
* The global state context instance.
|
|
26
42
|
*/
|
package/src/utils/extension.tsx
CHANGED
|
@@ -1,6 +1,47 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { ExtensionComponentProps, WrappedComponent } from '../types';
|
|
3
3
|
|
|
4
|
+
function removeAll(nodes: Array<ChildNode>) {
|
|
5
|
+
nodes.forEach((node) => node.remove());
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
interface SlotCarrierProps {
|
|
9
|
+
nodes: Array<ChildNode>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const SlotCarrier: React.FC<SlotCarrierProps> = ({ nodes }) => {
|
|
13
|
+
const host = React.useRef<HTMLSlotElement>();
|
|
14
|
+
|
|
15
|
+
React.useEffect(() => {
|
|
16
|
+
host.current?.append(...nodes);
|
|
17
|
+
return () => removeAll(nodes);
|
|
18
|
+
}, [nodes]);
|
|
19
|
+
|
|
20
|
+
if (nodes.length) {
|
|
21
|
+
return <slot ref={host} />;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return null;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Transforms the given component to an extension component.
|
|
29
|
+
* @param Component The component to transform.
|
|
30
|
+
* @returns The extension component (receiving its props via params).
|
|
31
|
+
*/
|
|
4
32
|
export function toExtension<T>(Component: React.ComponentType<T>): WrappedComponent<ExtensionComponentProps<T>> {
|
|
5
33
|
return (props) => <Component {...props.params} />;
|
|
6
34
|
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Reactifies the list of child nodes to a React Node by removing the
|
|
38
|
+
* nodes from the DOM and carrying it in a React Node, where it would be
|
|
39
|
+
* attached at a slot.
|
|
40
|
+
* @param childNodes The child nodes to reactify.
|
|
41
|
+
* @returns The React Node.
|
|
42
|
+
*/
|
|
43
|
+
export function reactifyContent(childNodes: NodeListOf<ChildNode>): React.ReactNode {
|
|
44
|
+
const nodes: Array<ChildNode> = Array.prototype.filter.call(childNodes, Boolean);
|
|
45
|
+
removeAll(nodes);
|
|
46
|
+
return <SlotCarrier nodes={nodes} />;
|
|
47
|
+
}
|