@common-stack/components-pro 7.0.4-alpha.28 → 7.1.1-alpha.2

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.
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
+ import { ILoadedPlugin } from '../slot-fill/interfaces';
2
3
  export interface IFillRenderContext {
3
- loadedPlugins: any;
4
+ loadedPlugins: ILoadedPlugin[];
4
5
  }
5
6
  declare const FillRenderContext: React.Context<IFillRenderContext>;
6
7
  export default FillRenderContext;
@@ -1 +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"}
1
+ {"version":3,"file":"context.js","sources":["../../src/plugin/context.tsx"],"sourcesContent":[null],"names":[],"mappings":"4BAOM,MAAA,iBAAiB,GAAG,KAAK,CAAC,aAAa,CAA4B,IAAI"}
@@ -1,6 +1,13 @@
1
1
  import React from 'react';
2
+ import { ILoadedPlugin, Name } from '../slot-fill/interfaces';
3
+ interface IPluginRenderProps {
4
+ fills: ILoadedPlugin[];
5
+ name: Name;
6
+ [key: string]: any;
7
+ }
2
8
  export declare const ChildrenRender: ({ children, ...props }: {
3
9
  [x: string]: any;
4
10
  children: any;
5
11
  }) => React.JSX.Element;
6
- export declare const PluginRender: (props: any) => React.JSX.Element;
12
+ export declare const PluginRender: (props: IPluginRenderProps) => React.JSX.Element;
13
+ export {};
@@ -3,13 +3,12 @@ import React__default,{useContext}from'react';import {DynamicRender}from'./dynam
3
3
  };
4
4
  const PluginRender = (props) => {
5
5
  const context = useContext(FillRenderContext);
6
- if (!context) {
6
+ if (!context?.loadedPlugins) {
7
7
  throw new Error('PluginRender must be used within a FillRenderContext.Provider');
8
8
  }
9
- const { loadedPlugins } = context;
10
9
  const FillRender = ({ fill, ...props }) => {
11
- const plugin = loadedPlugins.find((plugin) => plugin.index === fill.index);
12
- const loaderData = plugin ? plugin.loaderData : {};
10
+ const plugin = context.loadedPlugins.find((plugin) => plugin.index === fill.index);
11
+ const loaderData = plugin?.loaderData || {};
13
12
  if (plugin?.Component) {
14
13
  return React__default.createElement(plugin.Component, { ...props, loaderData: loaderData });
15
14
  }
@@ -19,8 +18,11 @@ const PluginRender = (props) => {
19
18
  else if (plugin?.render) {
20
19
  let children = null;
21
20
  try {
22
- const FillComponent = plugin.render();
23
- children = FillComponent.props?.children;
21
+ const FillComponent = plugin.render(props);
22
+ if (React__default.isValidElement(FillComponent)) {
23
+ const element = FillComponent;
24
+ children = element.props?.children;
25
+ }
24
26
  }
25
27
  catch (error) {
26
28
  console.error('Error in PluginRender', error);
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-render.js","sources":["../../src/plugin/plugin-render.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"+LAKO,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,OAAO,GAAG,UAAU,CAAqB,iBAAiB,CAAC,CAAC;IAClE,IAAI,CAAC,OAAO,EAAE;AACV,QAAA,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;KACpF;AACD,IAAA,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,CAAC;IAElC,MAAM,UAAU,GAAG,CAAC,EAAE,IAAI,EAAE,GAAG,KAAK,EAAE,KAAI;AACtC,QAAA,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,KAAK,KAAK,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3E,QAAA,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,CA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cAAA,CAAA,QAAA,EAAA,IAAA,EACK,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAI;AACzB,QAAA,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE;YAC/B,QACIA,cAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,CAAC,oBAAkB,CAAQ,KAAA,EAAA,KAAK,CAAC,IAAI,CAAE,CAAA,EAAA;gBAC7CA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,IAAI,EAAE,IAAI,KAAM,KAAK,EAAA,CAAI,CACnC,EACR;SACL;aAAM;AACH,YAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,EAAM,GAAA,KAAK,GAAI,CAAC;SACxD;KACJ,CAAC,CACH,EACL;AACN"}
@@ -1,4 +1,4 @@
1
1
  import React__default from'react';import {useLoaderData}from'@remix-run/react';import FillRenderContext from'./context.js';const FillRenderProvider = ({ children }) => {
2
2
  const { loadedPlugins } = useLoaderData();
3
- return React__default.createElement(FillRenderContext.Provider, { value: loadedPlugins }, children);
3
+ return React__default.createElement(FillRenderContext.Provider, { value: { loadedPlugins } }, children);
4
4
  };export{FillRenderProvider as default};//# sourceMappingURL=provider.js.map
@@ -1 +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,EAAG,aAAa,EAAA,EAAI,QAAQ,CAA8B,CAAC;AACvG"}
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;AAE/C,IAAA,OAAOA,cAAC,CAAA,aAAA,CAAA,iBAAiB,CAAC,QAAQ,EAAC,EAAA,KAAK,EAAE,EAAE,aAAa,EAAE,EAAG,EAAA,QAAQ,CAA8B,CAAC;AACzG"}
@@ -1 +1 @@
1
- import 'jest';
1
+ import '@testing-library/jest-dom';
@@ -1 +1 @@
1
- import 'jest';
1
+ import '@testing-library/jest-dom';
@@ -1,58 +1,79 @@
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(() => {
1
+ import React__default,{Component,Children,cloneElement}from'react';import {Consumer}from'./context.js';import {isFunction}from'../utils/index.js';import {PluginRender}from'../../plugin/plugin-render.js';import {isEmptyElement}from'../utils/isEmptyElement.js';class SlotComponent extends Component {
2
+ node;
3
+ isUnmounted;
4
+ constructor(props) {
5
+ super(props);
6
+ this.isUnmounted = false;
7
+ this.bindNode = this.bindNode.bind(this);
8
+ }
9
+ componentDidMount() {
10
+ const { registerSlot, serverMode } = this.props;
7
11
  if (!serverMode) {
8
- registerSlot(name, nodeRef.current);
12
+ registerSlot(this.props.name, this);
9
13
  }
10
- return () => {
11
- isUnmountedRef.current = true;
12
- unregisterSlot(name, nodeRef.current);
13
- };
14
- }, [name, registerSlot, unregisterSlot, serverMode]);
15
- useCallback(() => {
16
- if (isUnmountedRef.current) {
14
+ }
15
+ componentWillUnmount() {
16
+ const { unregisterSlot } = this.props;
17
+ this.isUnmounted = true;
18
+ unregisterSlot(this.props.name, this);
19
+ }
20
+ componentDidUpdate(prevProps) {
21
+ this.props;
22
+ // Commented following as we need the Slot to render at multiple places
23
+ // if (prevProps.name !== name) {
24
+ // unregisterSlot(prevProps.name);
25
+ // registerSlot(name, this);
26
+ // }
27
+ }
28
+ bindNode(node) {
29
+ this.node = node;
30
+ }
31
+ forceUpdate() {
32
+ if (this.isUnmounted) {
17
33
  return;
18
34
  }
19
- if (!serverMode) {
20
- // Trigger re-render
21
- console.log(`The slot ${name} is being updated`);
22
- setState({});
35
+ if (!this.props.serverMode) {
36
+ super.forceUpdate();
37
+ }
38
+ }
39
+ render() {
40
+ const { children, name, fillProps = {}, getFills, serverMode } = this.props;
41
+ const fills = getFills(name).filter((element) => !isEmptyElement(element));
42
+ if (fills.length > 0) {
43
+ if (isFunction(children)) {
44
+ const childrenFills = fills.map((fill) => {
45
+ const fillChildren = isFunction(fill.children) ? fill.children(fillProps) : fill.children;
46
+ return Children.map(fillChildren, (child, childIndex) => {
47
+ if (!child || typeof child === 'string') {
48
+ return child;
49
+ }
50
+ const childKey = child.key || childIndex;
51
+ return cloneElement(child, { key: childKey });
52
+ });
53
+ });
54
+ return React__default.createElement(React__default.Fragment, null, children(childrenFills));
55
+ }
56
+ else {
57
+ return React__default.createElement(PluginRender, { ...fillProps, name: name, fills: fills });
58
+ }
59
+ }
60
+ /*
61
+ if (serverMode) {
62
+ const fills = (getFills(name, this) ?? [])
63
+ .map((fill: any, i) => {
64
+ // unregisterFill(name, fill);
65
+ if (typeof fill === 'function') {
66
+ const child = fill({...fillProps, key: i});
67
+ return <div data-slot-name={`slot-${name}`}>{child}</div>;
68
+ }
69
+ return null;
70
+ });
71
+ return fills;
23
72
  }
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 });
73
+ */
74
+ return null;
53
75
  }
54
- return null;
55
- };
76
+ }
56
77
  const Slot = (props) => {
57
78
  const serverMode = (typeof window === 'undefined');
58
79
  return (React__default.createElement(Consumer, null, ({ registerSlot, unregisterSlot, getFills }) => (React__default.createElement(SlotComponent, { ...props,
@@ -1 +1 @@
1
- {"version":3,"file":"slot.js","sources":["../../../src/slot-fill/base/slot.tsx"],"sourcesContent":[null],"names":["React"],"mappings":"sKAUA,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,OAAO,GAAG,MAAM,CAAiB,IAAI,CAAC,CAAC;AAC7C,IAAA,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IACrC,MAAM,CAAC,CAAC,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC;IAEnC,SAAS,CAAC,MAAK;QACX,IAAI,CAAC,UAAU,EAAE;AACb,YAAA,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;SACvC;AACD,QAAA,OAAO,MAAK;AACR,YA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OAAO,MAAM,KAAK,WAAW,CAAC,CAAC;AACnD,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,4 +1,5 @@
1
1
  import { ReactNode, Component } from 'react';
2
+ import { IPlugin } from '@common-stack/client-core';
2
3
  export type Name = string | Symbol;
3
4
  export interface IFillProps {
4
5
  name: Name;
@@ -82,3 +83,8 @@ export interface ISlotProps {
82
83
  */
83
84
  serverMode?: boolean;
84
85
  }
86
+ export interface ILoadedPlugin extends IPlugin {
87
+ index?: number;
88
+ Component?: React.ComponentType<any>;
89
+ loaderData?: Record<string, any>;
90
+ }
@@ -4,4 +4,4 @@
4
4
  * @param element React Component to check.
5
5
  * @returns True when an element is considered empty.
6
6
  */
7
- export declare const isEmptyElement: (element: any) => boolean;
7
+ export declare const isEmptyElement: (element: any) => any;
@@ -0,0 +1,19 @@
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
+ if (typeof element === 'object' && element !== null) {
15
+ return Object.keys(element).length === 0 ||
16
+ Object.values(element).every((value) => isEmptyElement(value));
17
+ }
18
+ return !element;
19
+ };export{isEmptyElement};//# sourceMappingURL=isEmptyElement.js.map
@@ -0,0 +1 @@
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,IAAK,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAG;QACtD,OAAO,MAAM,CAAC,IAAI,CAAE,OAAO,CAAE,CAAC,MAAM,KAAK,CAAC;AACzC,YAAA,MAAM,CAAC,MAAM,CAAE,OAAO,CAAE,CAAC,KAAK,CAAE,CAAE,KAAK,KAAM,cAAc,CAAE,KAAK,CAAE,CAAE,CAAC;KACxE;IAED,OAAO,CAAE,OAAO,CAAC;AAClB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@common-stack/components-pro",
3
- "version": "7.0.4-alpha.28",
3
+ "version": "7.1.1-alpha.2",
4
4
  "description": "browser plugin for git",
5
5
  "homepage": "https://github.com/cdmbase/fullstack-pro#readme",
6
6
  "bugs": {
@@ -24,13 +24,13 @@
24
24
  "build:lib:watch": "npm run build:lib -- --watch",
25
25
  "jest": "./node_modules/.bin/jest",
26
26
  "prepublish": "npm run build",
27
- "test": "jest",
27
+ "test": "vitest",
28
28
  "test:debug": "npm test -- --runInBand",
29
29
  "test:watch": "npm test -- --watch",
30
30
  "watch": "npm run build:lib:watch"
31
31
  },
32
32
  "dependencies": {
33
- "@common-stack/client-core": "7.0.4-alpha.17",
33
+ "@common-stack/client-core": "7.1.1-alpha.2",
34
34
  "@wordpress/element": "^5.30.0",
35
35
  "@wordpress/hooks": "^3.53.0",
36
36
  "@wordpress/is-shallow-equal": "^4.53.0",
@@ -50,8 +50,8 @@
50
50
  "publishConfig": {
51
51
  "access": "public"
52
52
  },
53
+ "gitHead": "d8da1d3c53dc790afcb924aada008cbb0a541812",
53
54
  "typescript": {
54
55
  "definition": "lib/index.d.ts"
55
- },
56
- "gitHead": "cd5e2a90eada6a941cead717336f4184cf432b01"
56
+ }
57
57
  }
@@ -1 +0,0 @@
1
- export * from './plugin/middleware';
@@ -1 +0,0 @@
1
- export{middleware}from'./plugin/middleware.js';//# sourceMappingURL=index.server.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.server.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export declare const middleware: ({ context }: {
2
- context: any;
3
- }, dataLoader: any, next: any) => Promise<void>;
@@ -1,19 +0,0 @@
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
@@ -1 +0,0 @@
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"}