piral-core 0.14.24-beta.4157 → 0.14.24-beta.4168
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/components/ExtensionSlot.js +2 -2
- package/esm/components/ExtensionSlot.js.map +1 -1
- package/esm/types/extension.d.ts +1 -1
- package/lib/components/ExtensionSlot.js +2 -2
- package/lib/components/ExtensionSlot.js.map +1 -1
- package/lib/types/extension.d.ts +1 -1
- package/package.json +4 -4
- package/src/components/ExtensionSlot.test.tsx +4 -4
- package/src/components/ExtensionSlot.tsx +10 -2
- package/src/types/extension.ts +1 -1
|
@@ -11,13 +11,13 @@ function defaultOrder(extensions) {
|
|
|
11
11
|
* location.
|
|
12
12
|
*/
|
|
13
13
|
export function ExtensionSlot(props) {
|
|
14
|
-
const { name, render = defaultRender, empty, params, children,
|
|
14
|
+
const { name, render = defaultRender, empty, params, children, emptySkipsRender = false, order = defaultOrder, } = props;
|
|
15
15
|
const extensions = useGlobalState((s) => s.registry.extensions[name] || none);
|
|
16
16
|
const isEmpty = extensions.length === 0 && isfunc(empty);
|
|
17
17
|
const content = isEmpty
|
|
18
18
|
? [defaultRender(empty(), 'empty')]
|
|
19
19
|
: order(extensions).map(({ component: Component, reference, defaults = {} }, i) => (React.createElement(Component, { key: `${(reference === null || reference === void 0 ? void 0 : reference.displayName) || '_'}${i}`, children: children, params: Object.assign(Object.assign({}, defaults), (params || {})) })));
|
|
20
|
-
if (isEmpty &&
|
|
20
|
+
if (isEmpty && emptySkipsRender) {
|
|
21
21
|
return content[0];
|
|
22
22
|
}
|
|
23
23
|
return render(content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionSlot.js","sourceRoot":"","sources":["../../src/components/ExtensionSlot.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc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,QAAQ,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAC/E,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,KAAI,GAAG,GAAG,CAAC,EAAE,EAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,kCACD,QAAQ,GACR,CAAC,MAAM,IAAI,EAAE,CAAC,IAEnB,CACH,CAAC,CAAC;IAEP,IAAI,OAAO,IAAI,gBAAgB,EAAE;QAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;KACnB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
package/esm/types/extension.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface BaseExtensionSlotProps<TName, TParams> {
|
|
|
27
27
|
* If false, `render` will be called with the result of calling `empty`.
|
|
28
28
|
* The result of calling `render` will then be returned from the slot.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
emptySkipsRender?: boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Defines the order of the components to render.
|
|
33
33
|
* May be more convient than using `render` w.r.t. ordering extensions
|
|
@@ -14,13 +14,13 @@ function defaultOrder(extensions) {
|
|
|
14
14
|
* location.
|
|
15
15
|
*/
|
|
16
16
|
function ExtensionSlot(props) {
|
|
17
|
-
const { name, render = utils_1.defaultRender, empty, params, children,
|
|
17
|
+
const { name, render = utils_1.defaultRender, empty, params, children, emptySkipsRender = false, order = defaultOrder, } = props;
|
|
18
18
|
const extensions = (0, hooks_1.useGlobalState)((s) => s.registry.extensions[name] || utils_1.none);
|
|
19
19
|
const isEmpty = extensions.length === 0 && (0, piral_base_1.isfunc)(empty);
|
|
20
20
|
const content = isEmpty
|
|
21
21
|
? [(0, utils_1.defaultRender)(empty(), 'empty')]
|
|
22
22
|
: order(extensions).map(({ component: Component, reference, defaults = {} }, i) => (React.createElement(Component, { key: `${(reference === null || reference === void 0 ? void 0 : reference.displayName) || '_'}${i}`, children: children, params: Object.assign(Object.assign({}, defaults), (params || {})) })));
|
|
23
|
-
if (isEmpty &&
|
|
23
|
+
if (isEmpty && emptySkipsRender) {
|
|
24
24
|
return content[0];
|
|
25
25
|
}
|
|
26
26
|
return render(content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExtensionSlot.js","sourceRoot":"","sources":["../../src/components/ExtensionSlot.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AACpC,oCAA0C;AAC1C,oCAA+C;AAG/C,SAAS,YAAY,CAAC,UAAwC;IAC5D,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAmB,KAA4B;IAC1E,MAAM,
|
|
1
|
+
{"version":3,"file":"ExtensionSlot.js","sourceRoot":"","sources":["../../src/components/ExtensionSlot.tsx"],"names":[],"mappings":";;;AAAA,+BAA+B;AAC/B,2CAAoC;AACpC,oCAA0C;AAC1C,oCAA+C;AAG/C,SAAS,YAAY,CAAC,UAAwC;IAC5D,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;GAIG;AACH,SAAgB,aAAa,CAAmB,KAA4B;IAC1E,MAAM,EACJ,IAAI,EACJ,MAAM,GAAG,qBAAa,EACtB,KAAK,EACL,MAAM,EACN,QAAQ,EACR,gBAAgB,GAAG,KAAK,EACxB,KAAK,GAAG,YAAY,GACrB,GAAG,KAAK,CAAC;IACV,MAAM,UAAU,GAAG,IAAA,sBAAc,EAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,YAAI,CAAC,CAAC;IAC9E,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,IAAA,mBAAM,EAAC,KAAK,CAAC,CAAC;IACzD,MAAM,OAAO,GAAG,OAAO;QACrB,CAAC,CAAC,CAAC,IAAA,qBAAa,EAAC,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;QACnC,CAAC,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,CAC/E,oBAAC,SAAS,IACR,GAAG,EAAE,GAAG,CAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,WAAW,KAAI,GAAG,GAAG,CAAC,EAAE,EAC3C,QAAQ,EAAE,QAAQ,EAClB,MAAM,kCACD,QAAQ,GACR,CAAC,MAAM,IAAI,EAAE,CAAC,IAEnB,CACH,CAAC,CAAC;IAEP,IAAI,OAAO,IAAI,gBAAgB,EAAE;QAC/B,OAAO,OAAO,CAAC,CAAC,CAAC,CAAC;KACnB;IAED,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AA9BD,sCA8BC;AAED,aAAa,CAAC,WAAW,GAAG,eAAe,CAAC"}
|
package/lib/types/extension.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export interface BaseExtensionSlotProps<TName, TParams> {
|
|
|
27
27
|
* If false, `render` will be called with the result of calling `empty`.
|
|
28
28
|
* The result of calling `render` will then be returned from the slot.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
emptySkipsRender?: boolean;
|
|
31
31
|
/**
|
|
32
32
|
* Defines the order of the components to render.
|
|
33
33
|
* May be more convient than using `render` w.r.t. ordering extensions
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "piral-core",
|
|
3
|
-
"version": "0.14.24-beta.
|
|
3
|
+
"version": "0.14.24-beta.4168",
|
|
4
4
|
"description": "The core library for creating a Piral instance.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"portal",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@dbeining/react-atom": "^4.0.0",
|
|
66
|
-
"piral-base": "0.14.24-beta.
|
|
67
|
-
"piral-debug-utils": "0.14.24-beta.
|
|
66
|
+
"piral-base": "0.14.24-beta.4168",
|
|
67
|
+
"piral-debug-utils": "0.14.24-beta.4168"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"react": ">=16.8.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"@libre/atom",
|
|
92
92
|
"@dbeining/react-atom"
|
|
93
93
|
],
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "5c3d75e1148d7def9bbc0d5c2628671c2356f816"
|
|
95
95
|
}
|
|
@@ -93,11 +93,11 @@ describe('Extension Module', () => {
|
|
|
93
93
|
expect(node.find(StubComponent2).length).toBe(1);
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
it('does not use the render function with empty when
|
|
96
|
+
it('does not use the render function with empty when emptySkipsRender is set', () => {
|
|
97
97
|
const node = mount(
|
|
98
98
|
<ExtensionSlot
|
|
99
99
|
name="foo"
|
|
100
|
-
|
|
100
|
+
emptySkipsRender
|
|
101
101
|
empty={() => <StubComponent2 key="empty" />}
|
|
102
102
|
render={(nodes) => <StubComponent1 children={nodes} />}
|
|
103
103
|
/>,
|
|
@@ -106,11 +106,11 @@ describe('Extension Module', () => {
|
|
|
106
106
|
expect(node.find(StubComponent2).length).toBe(1);
|
|
107
107
|
});
|
|
108
108
|
|
|
109
|
-
it('does use the render function without empty independent if
|
|
109
|
+
it('does use the render function without empty independent if emptySkipsRender is set', () => {
|
|
110
110
|
const node = mount(
|
|
111
111
|
<ExtensionSlot
|
|
112
112
|
name="lol"
|
|
113
|
-
|
|
113
|
+
emptySkipsRender
|
|
114
114
|
empty={() => <StubComponent2 key="empty" />}
|
|
115
115
|
render={(nodes) => <StubComponent1 children={nodes} />}
|
|
116
116
|
/>,
|
|
@@ -14,7 +14,15 @@ function defaultOrder(extensions: Array<ExtensionRegistration>) {
|
|
|
14
14
|
* location.
|
|
15
15
|
*/
|
|
16
16
|
export function ExtensionSlot<T extends string>(props: ExtensionSlotProps<T>) {
|
|
17
|
-
const {
|
|
17
|
+
const {
|
|
18
|
+
name,
|
|
19
|
+
render = defaultRender,
|
|
20
|
+
empty,
|
|
21
|
+
params,
|
|
22
|
+
children,
|
|
23
|
+
emptySkipsRender = false,
|
|
24
|
+
order = defaultOrder,
|
|
25
|
+
} = props;
|
|
18
26
|
const extensions = useGlobalState((s) => s.registry.extensions[name] || none);
|
|
19
27
|
const isEmpty = extensions.length === 0 && isfunc(empty);
|
|
20
28
|
const content = isEmpty
|
|
@@ -30,7 +38,7 @@ export function ExtensionSlot<T extends string>(props: ExtensionSlotProps<T>) {
|
|
|
30
38
|
/>
|
|
31
39
|
));
|
|
32
40
|
|
|
33
|
-
if (isEmpty &&
|
|
41
|
+
if (isEmpty && emptySkipsRender) {
|
|
34
42
|
return content[0];
|
|
35
43
|
}
|
|
36
44
|
|
package/src/types/extension.ts
CHANGED
|
@@ -28,7 +28,7 @@ export interface BaseExtensionSlotProps<TName, TParams> {
|
|
|
28
28
|
* If false, `render` will be called with the result of calling `empty`.
|
|
29
29
|
* The result of calling `render` will then be returned from the slot.
|
|
30
30
|
*/
|
|
31
|
-
|
|
31
|
+
emptySkipsRender?: boolean;
|
|
32
32
|
/**
|
|
33
33
|
* Defines the order of the components to render.
|
|
34
34
|
* May be more convient than using `render` w.r.t. ordering extensions
|