@common-stack/components-pro 8.0.1-alpha.0 → 8.0.2-alpha.1
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/lib/index.d.ts +2 -1
- package/lib/index.js +1 -1
- package/lib/index.server.d.ts +1 -0
- package/lib/index.server.js +1 -0
- package/lib/index.server.js.map +1 -0
- package/lib/plugin/context.d.ts +6 -0
- package/lib/plugin/context.js +1 -0
- package/lib/plugin/context.js.map +1 -0
- package/lib/plugin/dynamic-render.d.ts +5 -0
- package/lib/plugin/dynamic-render.js +19 -0
- package/lib/plugin/dynamic-render.js.map +1 -0
- package/lib/plugin/index.d.ts +2 -0
- package/lib/plugin/loader.d.ts +1 -0
- package/lib/plugin/loader.js +11 -0
- package/lib/plugin/loader.js.map +1 -0
- package/lib/plugin/middleware.d.ts +3 -0
- package/lib/plugin/middleware.js +19 -0
- package/lib/plugin/middleware.js.map +1 -0
- package/lib/plugin/plugin-render.d.ts +6 -0
- package/lib/plugin/plugin-render.js +38 -0
- package/lib/plugin/plugin-render.js.map +1 -0
- package/lib/plugin/provider.d.ts +6 -0
- package/lib/plugin/provider.js +4 -0
- package/lib/plugin/provider.js.map +1 -0
- package/lib/plugin/utils.server.d.ts +1 -0
- package/lib/slot-fill/base/fill.js +17 -15
- package/lib/slot-fill/base/fill.js.map +1 -1
- package/lib/slot-fill/base/provider.d.ts +4 -21
- package/lib/slot-fill/base/provider.js +61 -83
- package/lib/slot-fill/base/provider.js.map +1 -1
- package/lib/slot-fill/base/slot.js +51 -76
- package/lib/slot-fill/base/slot.js.map +1 -1
- package/lib/slot-fill/index.js.map +1 -1
- package/lib/slot-fill/utils/index.d.ts +7 -0
- package/lib/slot-fill/utils/index.js +9 -0
- package/lib/slot-fill/utils/index.js.map +1 -0
- package/package.json +3 -2
- package/lib/slot-fill/utils/isEmptyElement.js +0 -15
- package/lib/slot-fill/utils/isEmptyElement.js.map +0 -1
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, useSlot as __experimentalUseSlot } from './slot-fill';
|
|
1
|
+
export { createSlotFill, Slot, Fill, Provider as SlotFillProvider, useSlot as __experimentalUseSlot, } from './slot-fill';
|
|
2
2
|
export { removeUniversalPortals, replaceServerFills } from './slot-fill/utils';
|
|
3
|
+
export * from './plugin';
|
package/lib/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{Fill,Slot,Provider as SlotFillProvider,createSlotFill}from'./slot-fill/index.js';export{removeUniversalPortals}from'./slot-fill/utils/removeUniversalPortals.js';export{replaceServerFills}from'./slot-fill/utils/replaceServerFills.js';export{default as __experimentalUseSlot}from'./slot-fill/bubbles-virtually/use-slot.js';//# sourceMappingURL=index.js.map
|
|
1
|
+
export{Fill,Slot,Provider as SlotFillProvider,createSlotFill}from'./slot-fill/index.js';export{removeUniversalPortals}from'./slot-fill/utils/removeUniversalPortals.js';export{replaceServerFills}from'./slot-fill/utils/replaceServerFills.js';export{default as FillRenderProvider}from'./plugin/provider.js';export{PluginsLoader}from'./plugin/loader.js';export{default as __experimentalUseSlot}from'./slot-fill/bubbles-virtually/use-slot.js';//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './plugin/middleware';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{middleware}from'./plugin/middleware.js';//# sourceMappingURL=index.server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as React from'react';const FillRenderContext = React.createContext(null);export{FillRenderContext as default};//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../src/plugin/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"4BAMM,MAAA,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAA4B,IAAI"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React__default,{useState,useEffect}from'react';const DynamicRender = ({ renderImporter, ...props }) => {
|
|
2
|
+
const [Component, setComponent] = useState(null);
|
|
3
|
+
useEffect(() => {
|
|
4
|
+
if (renderImporter) {
|
|
5
|
+
renderImporter()
|
|
6
|
+
.then((module) => {
|
|
7
|
+
const ImportedComponent = module.default;
|
|
8
|
+
setComponent(() => ImportedComponent);
|
|
9
|
+
})
|
|
10
|
+
.catch((error) => {
|
|
11
|
+
console.error(`Failed to load component from ${renderImporter}:`, error);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
}, [renderImporter]);
|
|
15
|
+
if (!Component) {
|
|
16
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
17
|
+
}
|
|
18
|
+
return React__default.createElement(Component, { ...props });
|
|
19
|
+
};export{DynamicRender};//# sourceMappingURL=dynamic-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamic-render.js","sources":["../../src/plugin/dynamic-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"sDAEO,MAAM,aAAa,GAAG,CAAC,EAAE,cAAc,EAAE,GAAG,KAAK,EAAE,KAAI;IAC1D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAkB,IAAI,CAAC,CAAC;IAElE,SAAS,CAAC,MAAK;QACX,IAAI,cAAc,EAAE;AAChB,YAAA,cAAc,EAAE;AACX,iBAAA,IAAI,CAAC,CAAC,MAAM,KAAI;AACb,gBAAA,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC;AACzC,gBAAA,YAAY,CAAC,MAAM,iBAAiB,CAAC,CAAC;AAC1C,aAAC,CAAC;AACD,iBAAA,KAAK,CAAC,CAAC,KAAK,KAAI;gBACb,OAAO,CAAC,KAAK,CAAC,CAAA,8BAAA,EAAiC,cAAc,CAAG,CAAA,CAAA,EAAE,KAAK,CAAC,CAAC;AAC7E,aAAC,CAAC,CAAC;SACV;AACL,KAAC,EAAE,CAAC,cAAc,CAAC,CAAC,CAAC;IAErB,IAAI,CAAC,SAAS,EAAE;AACZ,QAAA,OAAOA,2DAAK,CAAC;KAChB;AAED,IAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,SAAS,EAAK,EAAA,GAAA,KAAK,GAAI,CAAC;AACpC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function PluginsLoader(plugins: any[]): Promise<any[]>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
async function PluginsLoader(plugins) {
|
|
2
|
+
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
3
|
+
if (plugin.renderImporter) {
|
|
4
|
+
const module = await plugin.renderImporter();
|
|
5
|
+
const ImportedComponent = module.default;
|
|
6
|
+
return { ...plugin, Component: ImportedComponent };
|
|
7
|
+
}
|
|
8
|
+
return plugin;
|
|
9
|
+
}));
|
|
10
|
+
return loadedPlugins;
|
|
11
|
+
}export{PluginsLoader};//# sourceMappingURL=loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sources":["../../src/plugin/loader.ts"],"sourcesContent":[null],"names":[],"mappings":"AAAO,eAAe,aAAa,CAAC,OAAc,EAAA;AAC9C,IAAA,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CACnC,OAAO,CAAC,GAAG,CAAC,OAAO,MAAW,KAAI;AAC9B,QAAA,IAAI,MAAM,CAAC,cAAc,EAAE;AACvB,YAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;AAC7C,YAAA,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC;YACzC,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;SACtD;AACD,QAAA,OAAO,MAAM,CAAC;KACjB,CAAC,CACL,CAAC;AACF,IAAA,OAAO,aAAa,CAAC;AACzB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const middleware = async ({ context }, dataLoader, next) => {
|
|
2
|
+
const { modules } = context;
|
|
3
|
+
try {
|
|
4
|
+
const plugins = modules.getComponentFillPlugins();
|
|
5
|
+
const loadedPlugins = await Promise.all(plugins.map(async (plugin) => {
|
|
6
|
+
if (plugin.renderImporter) {
|
|
7
|
+
const module = await plugin.renderImporter();
|
|
8
|
+
const ImportedComponent = module.default;
|
|
9
|
+
return { ...plugin, Component: ImportedComponent };
|
|
10
|
+
}
|
|
11
|
+
return plugin;
|
|
12
|
+
}));
|
|
13
|
+
dataLoader.loadedPlugins = loadedPlugins;
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
console.error(error, 'Error with plugin middleware');
|
|
17
|
+
}
|
|
18
|
+
await next();
|
|
19
|
+
};export{middleware};//# sourceMappingURL=middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"middleware.js","sources":["../../src/plugin/middleware.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEO,MAAM,UAAU,GAAG,OAAO,EAAE,OAAO,EAAE,EAAE,UAAU,EAAE,IAAI,KAAI;AAC9D,IAAA,MAAM,EAAE,OAAO,EAAE,GAAG,OAA0B,CAAC;AAE/C,IAAA,IAAI;AACA,QAAA,MAAM,OAAO,GAAI,OAAe,CAAC,uBAAuB,EAAE,CAAC;AAC3D,QAAA,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,GAAG,CACnC,OAAO,CAAC,GAAG,CAAC,OAAO,MAAW,KAAI;AAC9B,YAAA,IAAI,MAAM,CAAC,cAAc,EAAE;AACvB,gBAAA,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,cAAc,EAAE,CAAC;AAC7C,gBAAA,MAAM,iBAAiB,GAAG,MAAM,CAAC,OAAO,CAAC;gBACzC,OAAO,EAAE,GAAG,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,CAAC;aACtD;AACD,YAAA,OAAO,MAAM,CAAC;SACjB,CAAC,CACL,CAAC;AACF,QAAA,UAAU,CAAC,aAAa,GAAG,aAAa,CAAC;KAC5C;IAAC,OAAO,KAAK,EAAE;AACZ,QAAA,OAAO,CAAC,KAAK,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;KACxD;IACD,MAAM,IAAI,EAAE,CAAC;AACjB"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import React__default,{useContext}from'react';import {DynamicRender}from'./dynamic-render.js';import {isFunction}from'../slot-fill/utils/index.js';import FillRenderContext from'./context.js';const ChildrenRender = ({ children, ...props }) => {
|
|
2
|
+
return React__default.createElement(React__default.Fragment, null, isFunction(children) ? children(props) : children);
|
|
3
|
+
};
|
|
4
|
+
const PluginRender = (props) => {
|
|
5
|
+
const loadedPlugins = useContext(FillRenderContext);
|
|
6
|
+
const plugins = typeof window === 'undefined' ? loadedPlugins.filter((plugin) => plugin.name === props.name) : props.fills;
|
|
7
|
+
return (React__default.createElement(React__default.Fragment, null, plugins.map((fill, i) => {
|
|
8
|
+
if (typeof window === 'undefined') {
|
|
9
|
+
if (fill.Component) {
|
|
10
|
+
return (React__default.createElement("div", { key: i, "data-slot-name": `slot-${fill.name}` },
|
|
11
|
+
React__default.createElement(fill.Component, { ...props })));
|
|
12
|
+
}
|
|
13
|
+
else if (fill.render) {
|
|
14
|
+
let children = null;
|
|
15
|
+
try {
|
|
16
|
+
const FillComponent = fill.render();
|
|
17
|
+
children = FillComponent.props?.children;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
console.error('Error in PluginRender', error);
|
|
21
|
+
}
|
|
22
|
+
if (children) {
|
|
23
|
+
return (React__default.createElement("div", { key: i, "data-slot-name": `slot-${fill.name}` },
|
|
24
|
+
React__default.createElement(ChildrenRender, { ...props, children: children })));
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
if (fill.renderImporter) {
|
|
30
|
+
return React__default.createElement(DynamicRender, { key: i, ...props, renderImporter: fill.renderImporter });
|
|
31
|
+
}
|
|
32
|
+
else if (fill.children) {
|
|
33
|
+
return React__default.createElement(ChildrenRender, { key: i, ...props, children: fill.children });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return null;
|
|
37
|
+
})));
|
|
38
|
+
};export{ChildrenRender,PluginRender};//# sourceMappingURL=plugin-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-render.js","sources":["../../src/plugin/plugin-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"+LAMO,MAAM,cAAc,GAAG,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,KAAI;AACrD,IAAA,OAAOA,4DAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAI,CAAC;AACpE,EAAE;AAEW,MAAA,YAAY,GAAG,CAAC,KAAK,KAAI;AAClC,IAAA,MAAM,aAAa,GAAQ,UAAU,CAAqB,iBAAiB,CAAC,CAAC;AAE7E,IAAA,MAAM,OAAO,GACT,OAAO,MAAM,KAAK,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IAE/G,QACIA,cACK,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EAAA,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAI;AACrB,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;AAC/B,YAAA,IAAI,IAAI,CAAC,SAAS,EAAE;gBAChB,QACIA,cAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,CAAC,oBAAkB,CAAQ,KAAA,EAAA,IAAI,CAAC,IAAI,CAAE,CAAA,EAAA;oBAC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__default from'react';import {useLoaderData}from'@remix-run/react';import FillRenderContext from'./context.js';const FillRenderProvider = ({ children }) => {
|
|
2
|
+
const { loadedPlugins } = useLoaderData();
|
|
3
|
+
return React__default.createElement(FillRenderContext.Provider, { value: loadedPlugins }, children);
|
|
4
|
+
};export{FillRenderProvider as default};//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../src/plugin/provider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"2HAQA,MAAM,kBAAkB,GAAsC,CAAC,EAAE,QAAQ,EAAE,KAAI;AAC3E,IAAA,MAAM,EAAE,aAAa,EAAE,GAAQ,aAAa,EAAE,CAAC;IAE/C,OAAOA,cAAA,CAAA,aAAA,CAAC,iBAAiB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,aAAa,EAAA,EAAG,QAAQ,CAA8B,CAAC;AACrG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function resolveComponent(renderImporter: string): Promise<any>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React__default,{useRef}from'react';import {
|
|
1
|
+
import React__default,{useRef}from'react';import {Consumer}from'./context.js';import {useSlot}from'./use-slot.js';const FillComponent = ({ name, renderImporter, children, registerFill, unregisterFill, serverMode, }) => {
|
|
2
2
|
const slot = useSlot(name);
|
|
3
3
|
let useLayoutEffect;
|
|
4
|
+
const nodeProps = { renderImporter, children };
|
|
4
5
|
if (serverMode) {
|
|
5
6
|
useLayoutEffect = (args) => { };
|
|
6
|
-
if (!!name
|
|
7
|
-
registerFill(name,
|
|
7
|
+
if (!!name) {
|
|
8
|
+
registerFill(name, nodeProps);
|
|
8
9
|
}
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
@@ -13,33 +14,33 @@ import React__default,{useRef}from'react';import {createPortal}from'react-dom';i
|
|
|
13
14
|
}
|
|
14
15
|
const ref = useRef({
|
|
15
16
|
name,
|
|
16
|
-
|
|
17
|
+
nodeProps,
|
|
17
18
|
});
|
|
18
19
|
useLayoutEffect(() => {
|
|
19
20
|
const refValue = ref.current;
|
|
20
|
-
registerFill(name, refValue);
|
|
21
|
-
return () => unregisterFill(name, refValue);
|
|
21
|
+
registerFill(name, refValue.nodeProps);
|
|
22
|
+
return () => unregisterFill(name, refValue.nodeProps);
|
|
22
23
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
23
24
|
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
24
25
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
25
26
|
}, []);
|
|
26
27
|
useLayoutEffect(() => {
|
|
27
|
-
ref.current.
|
|
28
|
+
ref.current.nodeProps = nodeProps;
|
|
28
29
|
if (slot) {
|
|
29
30
|
slot.forceUpdate();
|
|
30
31
|
}
|
|
31
32
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
32
33
|
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
33
34
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
}, [children]);
|
|
35
|
+
}, [renderImporter, children]);
|
|
35
36
|
useLayoutEffect(() => {
|
|
36
37
|
if (name === ref.current.name) {
|
|
37
38
|
// ignore initial effect
|
|
38
39
|
return;
|
|
39
40
|
}
|
|
40
|
-
unregisterFill(ref.current.name, ref.current);
|
|
41
|
+
unregisterFill(ref.current.name, ref.current.nodeProps);
|
|
41
42
|
ref.current.name = name;
|
|
42
|
-
registerFill(name, ref.current);
|
|
43
|
+
registerFill(name, ref.current.nodeProps);
|
|
43
44
|
// Ignore reason: the useLayoutEffects here are written to fire at specific times, and introducing new dependencies could cause unexpected changes in behavior.
|
|
44
45
|
// We'll leave them as-is until a more detailed investigation/refactor can be performed.
|
|
45
46
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -48,12 +49,13 @@ import React__default,{useRef}from'react';import {createPortal}from'react-dom';i
|
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
51
|
// If a function is passed as a child, provide it with the fillProps.
|
|
51
|
-
if (typeof children === 'function') {
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
return createPortal(children, slot.node);
|
|
52
|
+
// if (typeof children === 'function') {
|
|
53
|
+
// children = children(slot.props.fillProps);
|
|
54
|
+
// }
|
|
55
|
+
// return createPortal(children, slot.node);
|
|
56
|
+
return React__default.createElement(React__default.Fragment, null);
|
|
55
57
|
};
|
|
56
58
|
const Fill = (props) => {
|
|
57
|
-
const serverMode =
|
|
59
|
+
const serverMode = typeof window === 'undefined';
|
|
58
60
|
return (React__default.createElement(Consumer, null, ({ registerFill, unregisterFill }) => (React__default.createElement(FillComponent, { ...props, registerFill: registerFill, unregisterFill: unregisterFill, serverMode: serverMode }))));
|
|
59
61
|
};export{Fill as default};//# sourceMappingURL=fill.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fill.js","sources":["../../../src/slot-fill/base/fill.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"fill.js","sources":["../../../src/slot-fill/base/fill.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"kHAUA,MAAM,aAAa,GAAG,CAAC,EACnB,IAAI,EACJ,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,UAAU,GACS,KAAI;AACvB,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAC3B,IAAA,IAAI,eAAe,CAAC;AACpB,IAAA,MAAM,SAAS,GAAG,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC;IAE/C,IAAI,UAAU,EAAE;AACZ,QAAA,eAAe,GAAG,CAAC,IAAI,KAAI,GAAG,CAAC;AAC/B,QAAA,IAAI,CAAC,CAAC,IAAI,EAAE;AACR,YAAA,YAAY,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;SACjC;AACD,QAA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AAA,MAAM,UAAU,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC;AACjD,IAAA,QACIA,cAAA,CAAA,aAAA,CAAC,QAAQ,EAAA,IAAA,EACJ,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,MAC9BA,6BAAC,aAAa,EAAA,EAAA,GACN,KAAK,EACT,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,EAAA,CACxB,CACL,CACM,EACb;AACN"}
|
|
@@ -1,24 +1,7 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
declare class SlotFillProvider extends Component<{
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
|
+
interface SlotFillProviderProps {
|
|
4
3
|
children: ReactNode;
|
|
5
|
-
|
|
6
|
-
private slots;
|
|
7
|
-
private fills;
|
|
8
|
-
private listeners;
|
|
9
|
-
private contextValue;
|
|
10
|
-
private returnValue;
|
|
11
|
-
constructor(props: any);
|
|
12
|
-
registerSlot(name: any, slot: any): void;
|
|
13
|
-
registerFill(name: any, instance: any): void;
|
|
14
|
-
unregisterSlot(name: any, instance: any): void;
|
|
15
|
-
unregisterFill(name: any, instance: IFill): void;
|
|
16
|
-
getSlot(name: any): ISlot;
|
|
17
|
-
getFills(name: any, slotInstance: any): IFill[];
|
|
18
|
-
hasFills(name: any): boolean;
|
|
19
|
-
private forceUpdateSlot;
|
|
20
|
-
private triggerListeners;
|
|
21
|
-
subscribe(listener: any): () => void;
|
|
22
|
-
render(): React.JSX.Element;
|
|
4
|
+
context?: any;
|
|
23
5
|
}
|
|
6
|
+
declare const SlotFillProvider: React.FC<SlotFillProviderProps>;
|
|
24
7
|
export default SlotFillProvider;
|
|
@@ -1,100 +1,78 @@
|
|
|
1
|
-
import React__default,{
|
|
2
|
-
slots;
|
|
3
|
-
fills;
|
|
4
|
-
listeners;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
this.registerFill = this.registerFill.bind(this);
|
|
11
|
-
this.unregisterSlot = this.unregisterSlot.bind(this);
|
|
12
|
-
this.unregisterFill = this.unregisterFill.bind(this);
|
|
13
|
-
this.getSlot = this.getSlot.bind(this);
|
|
14
|
-
this.getFills = this.getFills.bind(this);
|
|
15
|
-
this.subscribe = this.subscribe.bind(this);
|
|
16
|
-
this.slots = {};
|
|
17
|
-
this.fills = {};
|
|
18
|
-
this.listeners = [];
|
|
19
|
-
this.contextValue = {
|
|
20
|
-
registerSlot: this.registerSlot,
|
|
21
|
-
unregisterSlot: this.unregisterSlot,
|
|
22
|
-
registerFill: this.registerFill,
|
|
23
|
-
unregisterFill: this.unregisterFill,
|
|
24
|
-
getSlot: this.getSlot,
|
|
25
|
-
getFills: this.getFills,
|
|
26
|
-
hasFills: this.hasFills,
|
|
27
|
-
subscribe: this.subscribe,
|
|
28
|
-
};
|
|
29
|
-
if (props.context) {
|
|
30
|
-
this.returnValue = props.context;
|
|
31
|
-
this.returnValue.fills = this.fills;
|
|
1
|
+
import React__default,{useRef,useCallback}from'react';import {sortBy}from'lodash-es';import {Provider}from'./context.js';const SlotFillProvider = ({ children, context }) => {
|
|
2
|
+
const slots = useRef({});
|
|
3
|
+
const fills = useRef({});
|
|
4
|
+
const listeners = useRef([]);
|
|
5
|
+
const returnValue = useRef(context);
|
|
6
|
+
const forceUpdateSlot = useCallback((name) => {
|
|
7
|
+
const slot = slots.current[name];
|
|
8
|
+
if (slot) {
|
|
9
|
+
slot.forceUpdate();
|
|
32
10
|
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
11
|
+
}, []);
|
|
12
|
+
const triggerListeners = useCallback(() => {
|
|
13
|
+
listeners.current.forEach((listener) => listener());
|
|
14
|
+
}, []);
|
|
15
|
+
const registerSlot = useCallback((name, slot) => {
|
|
16
|
+
const previousSlot = slots.current[name];
|
|
17
|
+
slots.current[name] = slot;
|
|
18
|
+
triggerListeners();
|
|
38
19
|
// Sometimes the fills are registered after the initial render of slot
|
|
39
20
|
// But before the registerSlot call, we need to rerender the slot
|
|
40
|
-
|
|
21
|
+
forceUpdateSlot(name);
|
|
41
22
|
// If a new instance of a slot is being mounted while another with the
|
|
42
23
|
// same name exists, force its update _after_ the new slot has been
|
|
43
|
-
// assigned into the instance,
|
|
24
|
+
// assigned into the instance, such that its own rendering of children
|
|
44
25
|
// will be empty (the new Slot will subsume all fills for this name).
|
|
45
26
|
if (previousSlot) {
|
|
46
27
|
previousSlot.forceUpdate();
|
|
47
28
|
}
|
|
48
|
-
}
|
|
49
|
-
registerFill(name, instance) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
unregisterSlot(name, instance) {
|
|
29
|
+
}, [forceUpdateSlot, triggerListeners]);
|
|
30
|
+
const registerFill = useCallback((name, instance) => {
|
|
31
|
+
fills.current[name] = [...(fills.current[name] || []), instance];
|
|
32
|
+
forceUpdateSlot(name);
|
|
33
|
+
}, [forceUpdateSlot]);
|
|
34
|
+
const unregisterSlot = useCallback((name, instance) => {
|
|
54
35
|
// If a previous instance of a Slot by this name unmounts, do nothing,
|
|
55
36
|
// as the slot and its fills should only be removed for the current
|
|
56
37
|
// known instance.
|
|
57
|
-
if (
|
|
38
|
+
if (slots.current[name] !== instance) {
|
|
58
39
|
return;
|
|
59
40
|
}
|
|
60
|
-
delete
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
unregisterFill(name, instance) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
getSlot(name) {
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
getFills(name, slotInstance) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
hasFills(name) {
|
|
80
|
-
return this.fills[name] && !!this.fills[name].length;
|
|
81
|
-
}
|
|
82
|
-
forceUpdateSlot(name) {
|
|
83
|
-
const slot = this.getSlot(name);
|
|
84
|
-
if (slot) {
|
|
85
|
-
slot.forceUpdate();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
triggerListeners() {
|
|
89
|
-
this.listeners.forEach((listener) => listener());
|
|
90
|
-
}
|
|
91
|
-
subscribe(listener) {
|
|
92
|
-
this.listeners.push(listener);
|
|
41
|
+
delete slots.current[name];
|
|
42
|
+
triggerListeners();
|
|
43
|
+
}, [triggerListeners]);
|
|
44
|
+
const unregisterFill = useCallback((name, instance) => {
|
|
45
|
+
fills.current[name] = fills.current[name]?.filter((fill) => fill !== instance) ?? [];
|
|
46
|
+
forceUpdateSlot(name);
|
|
47
|
+
}, [forceUpdateSlot]);
|
|
48
|
+
const getSlot = useCallback((name) => {
|
|
49
|
+
return slots.current[name];
|
|
50
|
+
}, []);
|
|
51
|
+
const getFills = useCallback((name, slotInstance) => {
|
|
52
|
+
return sortBy(fills.current[name]);
|
|
53
|
+
}, []);
|
|
54
|
+
const hasFills = useCallback((name) => {
|
|
55
|
+
return fills.current[name] && !!fills.current[name].length;
|
|
56
|
+
}, []);
|
|
57
|
+
const subscribe = useCallback((listener) => {
|
|
58
|
+
listeners.current.push(listener);
|
|
93
59
|
return () => {
|
|
94
|
-
|
|
60
|
+
listeners.current = listeners.current.filter((l) => l !== listener);
|
|
95
61
|
};
|
|
62
|
+
}, []);
|
|
63
|
+
const contextValue = {
|
|
64
|
+
registerSlot,
|
|
65
|
+
unregisterSlot,
|
|
66
|
+
registerFill,
|
|
67
|
+
unregisterFill,
|
|
68
|
+
getSlot,
|
|
69
|
+
getFills,
|
|
70
|
+
hasFills,
|
|
71
|
+
subscribe,
|
|
72
|
+
};
|
|
73
|
+
if (context) {
|
|
74
|
+
returnValue.current = context;
|
|
75
|
+
returnValue.current.fills = fills.current;
|
|
96
76
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
}export{SlotFillProvider as default};//# sourceMappingURL=provider.js.map
|
|
77
|
+
return React__default.createElement(Provider, { value: contextValue }, children);
|
|
78
|
+
};export{SlotFillProvider as default};//# sourceMappingURL=provider.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sources":["../../../src/slot-fill/base/provider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"provider.js","sources":["../../../src/slot-fill/base/provider.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"yHAUM,MAAA,gBAAgB,GAAoC,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAI;AAChF,IAAA,MAAM,KAAK,GAAG,MAAM,CAA2B,EAAE,CAAC,CAAC;AACnD,IAAA,MAAM,KAAK,GAAG,MAAM,CAA6B,EAAE,CAAC,CAAC;AACrD,IAAA,MAAM,SAAS,GAAG,MAAM,CAAiB,EAAE,CAAC,CAAC;AAC7C,IAAA,MAAM,WAAW,GAAG,MAAM,CAAM,OAAO,CAAC,CAAC;AAEzC,IAAA,MAAM,eAAe,GAAG,WAAW,CAAC,CAAC,IAAY,KAAI;QACjD,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,IAAI,EAAE;YACN,IAAI,CAAC,WAAW,EAAE,CAAC;SACtB;KACJ,EAAE,EAAE,CAAC,CAAC;AAEP,IAAA,MAAM,gBAAgB,GAAG,WAAW,CAAC,MAAK;AACtC,QAAA,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,KAAK,QAAQ,EAAE,CAAC,CAAC;KACvD,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,YAAY,GAAG,WAAW,CAC5B,CAAC,IAAY,EAAE,IAAW,KAAI;QAC1B,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzC,QAAA,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;AAC3B,QAAA,gBA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
7
|
-
function isFunction(maybeFunc) {
|
|
8
|
-
return typeof maybeFunc === 'function';
|
|
9
|
-
}
|
|
10
|
-
class SlotComponent extends Component {
|
|
11
|
-
node;
|
|
12
|
-
isUnmounted;
|
|
13
|
-
constructor(props) {
|
|
14
|
-
super(props);
|
|
15
|
-
this.isUnmounted = false;
|
|
16
|
-
this.bindNode = this.bindNode.bind(this);
|
|
17
|
-
}
|
|
18
|
-
componentDidMount() {
|
|
19
|
-
const { registerSlot, serverMode } = this.props;
|
|
1
|
+
import React__default,{useRef,useState,useEffect,useCallback}from'react';import {Consumer}from'./context.js';import {PluginRender}from'../../plugin/plugin-render.js';const SlotComponent = (props) => {
|
|
2
|
+
const { registerSlot, unregisterSlot, getFills, serverMode, name, fillProps = {}, children } = props;
|
|
3
|
+
const nodeRef = useRef(null);
|
|
4
|
+
const isUnmountedRef = useRef(false);
|
|
5
|
+
const [_, setState] = useState({});
|
|
6
|
+
useEffect(() => {
|
|
20
7
|
if (!serverMode) {
|
|
21
|
-
registerSlot(
|
|
8
|
+
registerSlot(name, nodeRef.current);
|
|
22
9
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
this.props;
|
|
31
|
-
// Commented following as we need the Slot to render at multiple places
|
|
32
|
-
// if (prevProps.name !== name) {
|
|
33
|
-
// unregisterSlot(prevProps.name);
|
|
34
|
-
// registerSlot(name, this);
|
|
35
|
-
// }
|
|
36
|
-
}
|
|
37
|
-
bindNode(node) {
|
|
38
|
-
this.node = node;
|
|
39
|
-
}
|
|
40
|
-
forceUpdate() {
|
|
41
|
-
if (this.isUnmounted) {
|
|
10
|
+
return () => {
|
|
11
|
+
isUnmountedRef.current = true;
|
|
12
|
+
unregisterSlot(name, nodeRef.current);
|
|
13
|
+
};
|
|
14
|
+
}, [name, registerSlot, unregisterSlot, serverMode]);
|
|
15
|
+
useCallback(() => {
|
|
16
|
+
if (isUnmountedRef.current) {
|
|
42
17
|
return;
|
|
43
18
|
}
|
|
44
|
-
if (!
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
render() {
|
|
49
|
-
const { children, name, fillProps = {}, getFills, serverMode } = this.props;
|
|
50
|
-
if (serverMode) {
|
|
51
|
-
const fills = (getFills(name, this) ?? [])
|
|
52
|
-
.map((fill, i) => {
|
|
53
|
-
// unregisterFill(name, fill);
|
|
54
|
-
if (typeof fill === 'function') {
|
|
55
|
-
const child = fill({ ...fillProps, key: i });
|
|
56
|
-
return React__default.createElement("div", { "data-slot-name": `slot-${name}` }, child);
|
|
57
|
-
}
|
|
58
|
-
return null;
|
|
59
|
-
});
|
|
60
|
-
return fills;
|
|
19
|
+
if (!serverMode) {
|
|
20
|
+
// Trigger re-render
|
|
21
|
+
console.log(`The slot ${name} is being updated`);
|
|
22
|
+
setState({});
|
|
61
23
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
24
|
+
}, [serverMode]);
|
|
25
|
+
// const fills = (getFills(name) ?? [])
|
|
26
|
+
// .map((fill: any, i) => {
|
|
27
|
+
// if (serverMode) {
|
|
28
|
+
// if (typeof fill === 'function') {
|
|
29
|
+
// const child = fill({...fillProps, key: i});
|
|
30
|
+
// return <div data-slot-name={`slot-${name}`}>{child}</div>;
|
|
31
|
+
// }
|
|
32
|
+
// return null;
|
|
33
|
+
// } else {
|
|
34
|
+
// const fillChildren: ReactElement = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
|
|
35
|
+
// return Children.map(fillChildren, (child, childIndex) => {
|
|
36
|
+
// if (!child || typeof child === 'string') {
|
|
37
|
+
// return child;
|
|
38
|
+
// }
|
|
39
|
+
// const childKey = child.key || childIndex;
|
|
40
|
+
// return cloneElement(child, { key: childKey });
|
|
41
|
+
// });
|
|
42
|
+
// }
|
|
43
|
+
// })
|
|
44
|
+
// .filter(
|
|
45
|
+
// // In some cases fills are rendered only when some conditions apply.
|
|
46
|
+
// // This ensures that we only use non-empty fills when rendering, i.e.,
|
|
47
|
+
// // it allows us to render wrappers only when the fills are actually present.
|
|
48
|
+
// (element) => !isEmptyElement(element),
|
|
49
|
+
// );
|
|
50
|
+
const fills = getFills(name);
|
|
51
|
+
if (fills.length > 0) {
|
|
52
|
+
return React__default.createElement(PluginRender, { ...fillProps, name: name, fills: fills });
|
|
79
53
|
}
|
|
80
|
-
|
|
54
|
+
return null;
|
|
55
|
+
};
|
|
81
56
|
const Slot = (props) => {
|
|
82
|
-
const serverMode =
|
|
57
|
+
const serverMode = typeof window === 'undefined';
|
|
83
58
|
return (React__default.createElement(Consumer, null, ({ registerSlot, unregisterSlot, getFills }) => (React__default.createElement(SlotComponent, { ...props,
|
|
84
|
-
// We need to add id to fillProps with slot name,
|
|
59
|
+
// We need to add id to fillProps with slot name,
|
|
85
60
|
// so that we can use it when remove the component during hydration.
|
|
86
61
|
getFills: getFills, registerSlot: registerSlot, unregisterSlot: unregisterSlot, serverMode: serverMode }))));
|
|
87
62
|
};export{Slot as default};//# sourceMappingURL=slot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.js","sources":["../../../src/slot-fill/base/slot.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"
|
|
1
|
+
{"version":3,"file":"slot.js","sources":["../../../src/slot-fill/base/slot.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"sKAoBA,MAAM,aAAa,GAA6B,CAAC,KAAK,KAAI;AACtD,IAAA,MAAM,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;AACrG,IAAA,MAAM,OAA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AG,OAAO,MAAM,KAAK,WAAW,CAAC;AACjD,IAAA,QACIA,cAAC,CAAA,aAAA,CAAA,QAAQ,QACJ,CAAC,EAAE,YAAY,EAAE,cAAc,EAAE,QAAQ,EAAE,MACxCA,cAAC,CAAA,aAAA,CAAA,aAAa,OACN,KAAK;;;AAGT,QAAA,QAAQ,EAAE,QAAQ,EAClB,YAAY,EAAE,YAAY,EAC1B,cAAc,EAAE,cAAc,EAC9B,UAAU,EAAE,UAAU,GACxB,CACL,CACM,EACb;AACN"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/slot-fill/index.tsx"],"sourcesContent":[null],"names":["React","BaseFill","BubblesVirtuallyFill","BaseSlot","BubblesVirtuallySlotFillProvider"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/slot-fill/index.tsx"],"sourcesContent":[null],"names":["React","BaseFill","BubblesVirtuallyFill","BaseSlot","BubblesVirtuallySlotFillProvider"],"mappings":"6ZAaM,SAAU,IAAI,CAAC,KAAK,EAAA;;;;AAItB,IAAA,QACIA,cAAA,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA;QACIA,cAAC,CAAA,aAAA,CAAAC,MAAQ,EAAK,EAAA,GAAA,KAAK,EAAI,CAAA;AACvB,QAAAD,cAAA,CAAA,aAAA,CAACE,MAAoB,EAAK,EAAA,GAAA,KAAK,EAAI,CAAA,CACpC,EACL;AACN,CAAC;AAEY,MAAA,IAAI,GAAG,UAAU,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,KAAK,EAAc,EAAE,GAAG,KAAI;IAC/E,IAAI,gBAAgB,EAAE;QAClB,OAAOF,cAAA,CAAA,aAAA,CAAC,oBAAoB,EAAK,EAAA,GAAA,KAAK,EAAE,GAAG,EAAE,GAAG,EAAA,CAAI,CAAC;KACxD;AACD,IAAA,OAAOA,cAAC,CAAA,aAAA,CAAAG,MAAQ,EAAK,EAAA,GAAA,KAAK,GAAI,CAAC;AACnC,CAAC,EAAE;AAEG,SAAU,QAAQ,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAA;AAC3C,IAAA,QACIH,cAAA,CAAA,aAAA,CAAC,gBAAgB,EAAA,EAAA,GAAK,KAAK,EAAA;AACvB,QAAAA,cAAA,CAAA,aAAA,CAACI,kBAAgC,EAAE,IAAA,EAAA,QAAQ,CAAoC,CAChE,EACrB;AACN,CAAC;AAEK,SAAU,cAAc,CAAkC,IAAY,EAAA;AACxE,IAAA,MAAM,aAAa,GAAG,CAAC,KAAyB,KAAKJ,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAE,IAAI,EAAM,GAAA,KAAK,GAAI,CAAC;AACrF,IAAA,aAAa,CAAC,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;AAE1C,IAAA,MAAM,aAAa,GAAG,CAAC,KAAuB,KAAKA,cAAA,CAAA,aAAA,CAAC,IAAI,EAAA,EAAC,IAAI,EAAE,IAAI,EAAM,GAAA,KAAK,GAAI,CAAC;AACnF,IAAA,aAAa,CAAC,WAAW,GAAG,IAAI,GAAG,MAAM,CAAC;AAC1C,IAAA,aAAa,CAAC,cAAc,GAAG,IAAI,CAAC;IAEpC,OAAO;AACH,QAAA,IAAI,EAAE,aAAa;AACnB,QAAA,IAAI,EAAE,aAAa;KACtB,CAAC;AACN"}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
1
|
export * from './isEmptyElement';
|
|
2
2
|
export * from './removeUniversalPortals';
|
|
3
3
|
export * from './replaceServerFills';
|
|
4
|
+
/**
|
|
5
|
+
* Whether the argument is a function.
|
|
6
|
+
*
|
|
7
|
+
* @param {*} maybeFunc The argument to check.
|
|
8
|
+
* @returns {boolean} True if the argument is a function, false otherwise.
|
|
9
|
+
*/
|
|
10
|
+
export declare function isFunction(maybeFunc: any): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import'cheerio';/**
|
|
2
|
+
* Whether the argument is a function.
|
|
3
|
+
*
|
|
4
|
+
* @param {*} maybeFunc The argument to check.
|
|
5
|
+
* @returns {boolean} True if the argument is a function, false otherwise.
|
|
6
|
+
*/
|
|
7
|
+
function isFunction(maybeFunc) {
|
|
8
|
+
return typeof maybeFunc === 'function';
|
|
9
|
+
}export{isFunction};//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/slot-fill/utils/index.ts"],"sourcesContent":[null],"names":[],"mappings":"gBAIA;;;;;AAKG;AACG,SAAU,UAAU,CAAC,SAAc,EAAA;AACrC,IAAA,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC;AAC3C"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/components-pro",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2-alpha.1",
|
|
4
4
|
"description": "browser plugin for git",
|
|
5
5
|
"homepage": "https://github.com/cdmbase/fullstack-pro#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
"watch": "npm run build:lib:watch"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
+
"@common-stack/client-core": "8.0.2-alpha.0",
|
|
33
34
|
"@wordpress/element": "^5.30.0",
|
|
34
35
|
"@wordpress/hooks": "^3.53.0",
|
|
35
36
|
"@wordpress/is-shallow-equal": "^4.53.0",
|
|
@@ -52,5 +53,5 @@
|
|
|
52
53
|
"typescript": {
|
|
53
54
|
"definition": "lib/index.d.ts"
|
|
54
55
|
},
|
|
55
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "82a7dcad7dc514c2cc92ec8f12832838c1fbec1a"
|
|
56
57
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Checks if the provided element to check.
|
|
3
|
-
*
|
|
4
|
-
* @param element React Component to check.
|
|
5
|
-
* @returns True when an element is considered empty.
|
|
6
|
-
*/
|
|
7
|
-
const isEmptyElement = (element) => {
|
|
8
|
-
if (typeof element === 'number') {
|
|
9
|
-
return false;
|
|
10
|
-
}
|
|
11
|
-
if (typeof element?.valueOf() === 'string' || Array.isArray(element)) {
|
|
12
|
-
return !element.length;
|
|
13
|
-
}
|
|
14
|
-
return !element;
|
|
15
|
-
};export{isEmptyElement};//# sourceMappingURL=isEmptyElement.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isEmptyElement.js","sources":["../../../src/slot-fill/utils/isEmptyElement.ts"],"sourcesContent":[null],"names":[],"mappings":"AAEA;;;;;AAKG;AAEU,MAAA,cAAc,GAAG,CAAE,OAAO,KAAK;AAC3C,IAAA,IAAK,OAAO,OAAO,KAAK,QAAQ,EAAG;AAClC,QAAA,OAAO,KAAK,CAAC;KACb;AAED,IAAA,IAAK,OAAO,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAE,OAAO,CAAE,EAAG;AACzE,QAAA,OAAO,CAAE,OAAO,CAAC,MAAM,CAAC;KACxB;IAED,OAAO,CAAE,OAAO,CAAC;AAClB"}
|