@modular-component/with-conditional-render 0.1.1 → 0.1.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.
- package/CHANGELOG.md +8 -0
- package/dist/index.d.ts +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +7 -2
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { FunctionComponent } from 'react';
|
|
2
|
+
declare const withConditionalFallback: unique symbol;
|
|
3
|
+
declare const withConditionalRender: unique symbol;
|
|
2
4
|
export declare const WithConditionalRender: {
|
|
3
5
|
readonly withCondition: {
|
|
4
6
|
readonly field: "condition";
|
|
@@ -11,6 +13,7 @@ export declare const WithConditionalRender: {
|
|
|
11
13
|
readonly withConditionalFallback: {
|
|
12
14
|
readonly field: "render";
|
|
13
15
|
readonly multiple: true;
|
|
16
|
+
readonly symbol: typeof withConditionalFallback;
|
|
14
17
|
readonly transform: <A_1 extends {
|
|
15
18
|
condition?: boolean | undefined;
|
|
16
19
|
render?: import("react").ReactElement<any, any> | null | undefined;
|
|
@@ -19,6 +22,7 @@ export declare const WithConditionalRender: {
|
|
|
19
22
|
};
|
|
20
23
|
readonly withConditionalRender: {
|
|
21
24
|
readonly field: "render";
|
|
25
|
+
readonly symbol: typeof withConditionalRender;
|
|
22
26
|
readonly transform: <A_2 extends {
|
|
23
27
|
condition?: boolean | undefined;
|
|
24
28
|
render?: import("react").ReactElement<any, any> | null | undefined;
|
|
@@ -28,8 +32,9 @@ export declare const WithConditionalRender: {
|
|
|
28
32
|
};
|
|
29
33
|
declare module '@modular-component/core' {
|
|
30
34
|
interface ModularStageTransform<T> {
|
|
31
|
-
withConditionalFallback: T | null;
|
|
32
|
-
withConditionalRender: T | null;
|
|
35
|
+
[withConditionalFallback]: T | null;
|
|
36
|
+
[withConditionalRender]: T | null;
|
|
33
37
|
}
|
|
34
38
|
}
|
|
39
|
+
export {};
|
|
35
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAEzC,eAAO,MAAM,qBAAqB;;;;;;kCAML,OAAO
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAA;AAEzC,QAAA,MAAM,uBAAuB,eAAW,CAAA;AACxC,QAAA,MAAM,qBAAqB,eAAW,CAAA;AAEtC,eAAO,MAAM,qBAAqB;;;;;;kCAML,OAAO;;;;;;;;;;;;;;;;;;;;;;CA8CzB,CAAA;AAEX,OAAO,QAAQ,yBAAyB,CAAC;IACvC,UAAiB,qBAAqB,CAAC,CAAC;QACtC,CAAC,uBAAuB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;QACnC,CAAC,qBAAqB,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;KAClC;CACF"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { createMethodRecord } from '@modular-component/core';
|
|
2
|
+
const withConditionalFallback = Symbol();
|
|
3
|
+
const withConditionalRender = Symbol();
|
|
2
4
|
export const WithConditionalRender = createMethodRecord({
|
|
3
5
|
withCondition: {
|
|
4
6
|
field: 'condition',
|
|
@@ -10,6 +12,7 @@ export const WithConditionalRender = createMethodRecord({
|
|
|
10
12
|
withConditionalFallback: {
|
|
11
13
|
field: 'render',
|
|
12
14
|
multiple: true,
|
|
15
|
+
symbol: withConditionalFallback,
|
|
13
16
|
transform: (args, useRender) => {
|
|
14
17
|
if (args.condition !== false || args.render) {
|
|
15
18
|
return args.render;
|
|
@@ -20,6 +23,7 @@ export const WithConditionalRender = createMethodRecord({
|
|
|
20
23
|
},
|
|
21
24
|
withConditionalRender: {
|
|
22
25
|
field: 'render',
|
|
26
|
+
symbol: withConditionalRender,
|
|
23
27
|
transform: (args, useRender) => {
|
|
24
28
|
if (args.condition === false) {
|
|
25
29
|
return args.render;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;IACtD,aAAa,EAAE;QACb,KAAK,EAAE,WAAW;QAClB,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAIT,IAAO,EACP,YAAe,EACf,EAAE,CACF,IAAI,CAAC,SAAS,KAAK,KAAK;YACxB,CAAC,OAAO,YAAY,KAAK,UAAU,CAAC,CAAC,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC1E,QAAQ,EAAE,EAAa;KACxB;IACD,uBAAuB,EAAE;QACvB,KAAK,EAAE,QAAQ;QACf,QAAQ,EAAE,IAAI;QACd,SAAS,EAAE,CAIT,IAAO,EACP,SAAY,EACZ,EAAE;YACF,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,IAAI,IAAI,CAAC,MAAM,EAAE;gBAC3C,OAAO,IAAI,CAAC,MAAM,CAAA;aACnB;YAED,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACtE,CAAC;QACD,QAAQ,EAAE,EAAmC;KAC9C;IACD,qBAAqB,EAAE;QACrB,KAAK,EAAE,QAAQ;QACf,SAAS,EAAE,CAIT,IAAO,EACP,SAAY,EACZ,EAAE;YACF,IAAI,IAAI,CAAC,SAAS,KAAK,KA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AE,QAAQ;QACf,MAAM,EAAE,qBAAqB;QAC7B,SAAS,EAAE,CAIT,IAAO,EACP,SAAY,EACZ,EAAE;YACF,IAAI,IAAI,CAAC,SAAS,KAAK,KAAK,EAAE;gBAC5B,OAAO,IAAI,CAAC,MAAM,CAAA;aACnB;YAED,OAAO,OAAO,SAAS,KAAK,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACtE,CAAC;QACD,QAAQ,EAAE,EAAmC;KAC9C;CACO,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"Default",
|
|
9
9
|
"Conditional"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.1.
|
|
11
|
+
"version": "0.1.2",
|
|
12
12
|
"type": "module",
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"publishConfig": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"license": "cp ../../LICENSE ./LICENSE"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@modular-component/core": "0.1.
|
|
29
|
+
"@modular-component/core": "0.1.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"react": ">=17 <19"
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { createMethodRecord } from '@modular-component/core'
|
|
2
2
|
import { FunctionComponent } from 'react'
|
|
3
3
|
|
|
4
|
+
const withConditionalFallback = Symbol()
|
|
5
|
+
const withConditionalRender = Symbol()
|
|
6
|
+
|
|
4
7
|
export const WithConditionalRender = createMethodRecord({
|
|
5
8
|
withCondition: {
|
|
6
9
|
field: 'condition',
|
|
@@ -19,6 +22,7 @@ export const WithConditionalRender = createMethodRecord({
|
|
|
19
22
|
withConditionalFallback: {
|
|
20
23
|
field: 'render',
|
|
21
24
|
multiple: true,
|
|
25
|
+
symbol: withConditionalFallback,
|
|
22
26
|
transform: <
|
|
23
27
|
A extends { condition?: boolean; render?: ReturnType<FunctionComponent> },
|
|
24
28
|
P extends FunctionComponent<A>,
|
|
@@ -36,6 +40,7 @@ export const WithConditionalRender = createMethodRecord({
|
|
|
36
40
|
},
|
|
37
41
|
withConditionalRender: {
|
|
38
42
|
field: 'render',
|
|
43
|
+
symbol: withConditionalRender,
|
|
39
44
|
transform: <
|
|
40
45
|
A extends { condition?: boolean; render?: ReturnType<FunctionComponent> },
|
|
41
46
|
P extends FunctionComponent<A>,
|
|
@@ -55,7 +60,7 @@ export const WithConditionalRender = createMethodRecord({
|
|
|
55
60
|
|
|
56
61
|
declare module '@modular-component/core' {
|
|
57
62
|
export interface ModularStageTransform<T> {
|
|
58
|
-
withConditionalFallback: T | null
|
|
59
|
-
withConditionalRender: T | null
|
|
63
|
+
[withConditionalFallback]: T | null
|
|
64
|
+
[withConditionalRender]: T | null
|
|
60
65
|
}
|
|
61
66
|
}
|