etudes 0.65.0 → 0.66.0
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/Conditional.js +9 -6
- package/lib/Conditional.js.map +1 -1
- package/package.json +1 -1
package/lib/Conditional.js
CHANGED
|
@@ -6,12 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
var react_1 = __importDefault(require("react"));
|
|
7
7
|
function Conditional(_a) {
|
|
8
8
|
var children = _a.children, boolOrExpression = _a.if;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
switch (typeof boolOrExpression) {
|
|
10
|
+
case 'boolean':
|
|
11
|
+
return boolOrExpression ? react_1.default.createElement(react_1.default.Fragment, null, children) : react_1.default.createElement(react_1.default.Fragment, null);
|
|
12
|
+
case 'function':
|
|
13
|
+
return boolOrExpression() ? react_1.default.createElement(react_1.default.Fragment, null, children) : react_1.default.createElement(react_1.default.Fragment, null);
|
|
14
|
+
default:
|
|
15
|
+
console.error("[etudes::Conditional] The type of provided condition ".concat(boolOrExpression, " is not supported."));
|
|
16
|
+
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
17
|
+
}
|
|
15
18
|
}
|
|
16
19
|
exports.default = Conditional;
|
|
17
20
|
//# sourceMappingURL=Conditional.js.map
|
package/lib/Conditional.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Conditional.js","sourceRoot":"/","sources":["Conditional.tsx"],"names":[],"mappings":";;;;;AAAA,gDAAgD;AAMhD,SAAwB,WAAW,CAAC,EAAyC;QAAvC,QAAQ,cAAA,EAAM,gBAAgB,QAAA;IAClE,
|
|
1
|
+
{"version":3,"file":"Conditional.js","sourceRoot":"/","sources":["Conditional.tsx"],"names":[],"mappings":";;;;;AAAA,gDAAgD;AAMhD,SAAwB,WAAW,CAAC,EAAyC;QAAvC,QAAQ,cAAA,EAAM,gBAAgB,QAAA;IAClE,QAAQ,OAAO,gBAAgB,EAAE;QACjC,KAAK,SAAS;YACZ,OAAO,gBAAgB,CAAC,CAAC,CAAC,8DAAG,QAAQ,CAAI,CAAC,CAAC,CAAC,6DAAK,CAAA;QACnD,KAAK,UAAU;YACb,OAAO,gBAAgB,EAAE,CAAC,CAAC,CAAC,8DAAG,QAAQ,CAAI,CAAC,CAAC,CAAC,6DAAK,CAAA;QACrD;YACE,OAAO,CAAC,KAAK,CAAC,+DAAwD,gBAAgB,uBAAoB,CAAC,CAAA;YAC3G,OAAO,6DAAK,CAAA;KACb;AACH,CAAC;AAVD,8BAUC","sourcesContent":["import React, { PropsWithChildren } from 'react'\n\ntype Props = PropsWithChildren<{\n if: boolean | (() => boolean)\n}>\n\nexport default function Conditional({ children, if: boolOrExpression }: Props) {\n switch (typeof boolOrExpression) {\n case 'boolean':\n return boolOrExpression ? <>{children}</> : <></>\n case 'function':\n return boolOrExpression() ? <>{children}</> : <></>\n default:\n console.error(`[etudes::Conditional] The type of provided condition ${boolOrExpression} is not supported.`)\n return <></>\n }\n}\n"]}
|