etudes 1.1.0 → 1.2.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/Each.d.ts +4 -3
- package/lib/Each.js +5 -5
- package/lib/Each.js.map +1 -1
- package/lib/Repeat.d.ts +3 -2
- package/lib/Repeat.js +2 -2
- package/lib/Repeat.js.map +1 -1
- package/package.json +1 -1
package/lib/Each.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export declare type Props<T> = {
|
|
3
|
-
children
|
|
4
|
-
|
|
3
|
+
children?: ReactNode | ((value: T, index: number) => ReactNode);
|
|
4
|
+
in?: T[];
|
|
5
|
+
render?: (value: T, index: number) => ReactNode;
|
|
5
6
|
};
|
|
6
|
-
export default function Each<T>({
|
|
7
|
+
export default function Each<T>({ in: array, children, render, }: Props<T>): JSX.Element;
|
package/lib/Each.js
CHANGED
|
@@ -25,12 +25,12 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
26
|
var react_1 = __importStar(require("react"));
|
|
27
27
|
function Each(_a) {
|
|
28
|
-
var
|
|
29
|
-
if (
|
|
28
|
+
var array = _a.in, children = _a.children, render = _a.render;
|
|
29
|
+
if (array === undefined || array === null)
|
|
30
30
|
return react_1.default.createElement(react_1.default.Fragment, null);
|
|
31
|
-
if (!(
|
|
32
|
-
throw TypeError("Provided list
|
|
33
|
-
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
31
|
+
if (!(array instanceof Array))
|
|
32
|
+
throw TypeError("Provided list <".concat(array, "> is not an array"));
|
|
33
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, array.map(function (v, i) { return (react_1.default.createElement(react_1.Fragment, { key: "item-".concat(i) }, render ? render(v, i) : typeof children === 'function' ? children(v, i) : children)); })));
|
|
34
34
|
}
|
|
35
35
|
exports.default = Each;
|
|
36
36
|
//# sourceMappingURL=Each.js.map
|
package/lib/Each.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Each.js","sourceRoot":"/","sources":["Each.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAkD;
|
|
1
|
+
{"version":3,"file":"Each.js","sourceRoot":"/","sources":["Each.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAkD;AAQlD,SAAwB,IAAI,CAAI,EAIrB;QAHL,KAAK,QAAA,EACT,QAAQ,cAAA,EACR,MAAM,YAAA;IAEN,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,6DAAK,CAAA;IACvD,IAAI,CAAC,CAAC,KAAK,YAAY,KAAK,CAAC;QAAE,MAAM,SAAS,CAAC,yBAAkB,KAAK,sBAAmB,CAAC,CAAA;IAE1F,OAAO,CACL,8DACG,KAAK,CAAC,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CACnB,8BAAC,gBAAQ,IAAC,GAAG,EAAE,eAAQ,CAAC,CAAE,IACvB,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAC1E,CACZ,EAJoB,CAIpB,CAAC,CACD,CACJ,CAAA;AACH,CAAC;AAjBD,uBAiBC","sourcesContent":["import React, { Fragment, ReactNode } from 'react'\n\nexport type Props<T> = {\n children?: ReactNode | ((value: T, index: number) => ReactNode)\n in?: T[]\n render?: (value: T, index: number) => ReactNode\n}\n\nexport default function Each<T>({\n in: array,\n children,\n render,\n}: Props<T>) {\n if (array === undefined || array === null) return <></>\n if (!(array instanceof Array)) throw TypeError(`Provided list <${array}> is not an array`)\n\n return (\n <>\n {array.map((v, i) => (\n <Fragment key={`item-${i}`}>\n {render ? render(v, i) : typeof children === 'function' ? children(v, i) : children}\n </Fragment>\n ))}\n </>\n )\n}\n"]}
|
package/lib/Repeat.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
export declare type Props = {
|
|
3
|
-
children
|
|
3
|
+
children?: ReactNode | ((index: number) => ReactNode);
|
|
4
4
|
count?: number;
|
|
5
|
+
render?: (index: number) => ReactNode;
|
|
5
6
|
};
|
|
6
7
|
/**
|
|
7
8
|
* A tag-less component that repeats its children, automatically assigning each a unique key.
|
|
8
9
|
*/
|
|
9
|
-
export default function Repeat({ count, children, }: Props): JSX.Element;
|
|
10
|
+
export default function Repeat({ count, children, render, }: Props): JSX.Element;
|
package/lib/Repeat.js
CHANGED
|
@@ -53,8 +53,8 @@ var react_1 = __importStar(require("react"));
|
|
|
53
53
|
* A tag-less component that repeats its children, automatically assigning each a unique key.
|
|
54
54
|
*/
|
|
55
55
|
function Repeat(_a) {
|
|
56
|
-
var _b = _a.count, count = _b === void 0 ? 1 : _b, children = _a.children;
|
|
57
|
-
return (react_1.default.createElement(react_1.default.Fragment, null, __spreadArray([], __read(Array(count)), false).map(function (_, i) { return (react_1.default.createElement(react_1.Fragment, { key: "element-".concat(i) }, typeof children === 'function' ? children(i) : children)); })));
|
|
56
|
+
var _b = _a.count, count = _b === void 0 ? 1 : _b, children = _a.children, render = _a.render;
|
|
57
|
+
return (react_1.default.createElement(react_1.default.Fragment, null, __spreadArray([], __read(Array(count)), false).map(function (_, i) { return (react_1.default.createElement(react_1.Fragment, { key: "element-".concat(i) }, render ? render(i) : typeof children === 'function' ? children(i) : children)); })));
|
|
58
58
|
}
|
|
59
59
|
exports.default = Repeat;
|
|
60
60
|
//# sourceMappingURL=Repeat.js.map
|
package/lib/Repeat.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Repeat.js","sourceRoot":"/","sources":["Repeat.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAkD;
|
|
1
|
+
{"version":3,"file":"Repeat.js","sourceRoot":"/","sources":["Repeat.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAkD;AAQlD;;GAEG;AACH,SAAwB,MAAM,CAAC,EAIvB;QAHN,aAAS,EAAT,KAAK,mBAAG,CAAC,KAAA,EACT,QAAQ,cAAA,EACR,MAAM,YAAA;IAEN,OAAO,CACL,8DACG,yBAAI,KAAK,CAAC,KAAK,CAAC,UAAE,GAAG,CAAC,UAAC,CAAC,EAAE,CAAC,IAAK,OAAA,CAC/B,8BAAC,gBAAQ,IAAC,GAAG,EAAE,kBAAW,CAAC,CAAE,IAC1B,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CACpE,CACZ,EAJgC,CAIhC,CAAC,CACD,CACJ,CAAA;AACH,CAAC;AAdD,yBAcC","sourcesContent":["import React, { Fragment, ReactNode } from 'react'\n\nexport type Props = {\n children?: ReactNode | ((index: number) => ReactNode)\n count?: number\n render?: (index: number) => ReactNode\n}\n\n/**\n * A tag-less component that repeats its children, automatically assigning each a unique key.\n */\nexport default function Repeat({\n count = 1,\n children,\n render,\n}: Props) {\n return (\n <>\n {[...Array(count)].map((_, i) => (\n <Fragment key={`element-${i}`}>\n {render ? render(i) : typeof children === 'function' ? children(i) : children}\n </Fragment>\n ))}\n </>\n )\n}\n"]}
|