@clicoh/orion-library 1.1.0-beta.8 → 1.1.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/dist/components/00-base/Each/Each.d.ts +13 -0
- package/dist/components/00-base/Each/Each.d.ts.map +1 -1
- package/dist/components/00-base/Each/Each.jsx +19 -2
- package/dist/components/00-base/Each/Each.jsx.map +1 -1
- package/dist/components/03-organisms/DataTable/DataTable.d.ts +1 -1
- package/dist/components/03-organisms/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/03-organisms/DataTable/DataTable.jsx +2 -2
- package/dist/components/03-organisms/DataTable/DataTable.jsx.map +1 -1
- package/package.json +1 -1
|
@@ -6,6 +6,12 @@ type EachProps<T> = {
|
|
|
6
6
|
/**
|
|
7
7
|
* A utility component that iterates over an array and renders each item using the provided render function.
|
|
8
8
|
*
|
|
9
|
+
* Each rendered item is wrapped in a keyed `Fragment`, so consumers do not need
|
|
10
|
+
* to set a key themselves. When the render function does return an element with
|
|
11
|
+
* its own key, that key wins: a consumer that needs stable identity across
|
|
12
|
+
* reordering keeps it. The `Fragment` adds no DOM node, so the rendered items
|
|
13
|
+
* stay direct children of the parent and CSS grid or flex layouts are unaffected.
|
|
14
|
+
*
|
|
9
15
|
* @component
|
|
10
16
|
* @example
|
|
11
17
|
* // Example usage of Each component
|
|
@@ -16,6 +22,13 @@ type EachProps<T> = {
|
|
|
16
22
|
* )}
|
|
17
23
|
* />
|
|
18
24
|
*
|
|
25
|
+
* @example
|
|
26
|
+
* // Providing a stable key for lists that reorder
|
|
27
|
+
* <Each
|
|
28
|
+
* of={fruits}
|
|
29
|
+
* render={(fruit) => <li key={fruit.id}>{fruit.name}</li>}
|
|
30
|
+
* />
|
|
31
|
+
*
|
|
19
32
|
* @param {Object} props - The properties of the Each component.
|
|
20
33
|
* @param {T[]} props.of - The array of items to iterate over and render.
|
|
21
34
|
* @param {(item: T, index: number) => ReactNode} props.render - A function that renders each item in the array.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Each.d.ts","sourceRoot":"","sources":["../../../../src/components/00-base/Each/Each.tsx"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Each.d.ts","sourceRoot":"","sources":["../../../../src/components/00-base/Each/Each.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA4B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAEjE,KAAK,SAAS,CAAC,CAAC,IAAI;IAClB,EAAE,EAAE,CAAC,EAAE,CAAC;IACR,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;CAC/C,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAO/D"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Fragment, isValidElement } from 'react';
|
|
2
2
|
/**
|
|
3
3
|
* A utility component that iterates over an array and renders each item using the provided render function.
|
|
4
4
|
*
|
|
5
|
+
* Each rendered item is wrapped in a keyed `Fragment`, so consumers do not need
|
|
6
|
+
* to set a key themselves. When the render function does return an element with
|
|
7
|
+
* its own key, that key wins: a consumer that needs stable identity across
|
|
8
|
+
* reordering keeps it. The `Fragment` adds no DOM node, so the rendered items
|
|
9
|
+
* stay direct children of the parent and CSS grid or flex layouts are unaffected.
|
|
10
|
+
*
|
|
5
11
|
* @component
|
|
6
12
|
* @example
|
|
7
13
|
* // Example usage of Each component
|
|
@@ -12,6 +18,13 @@ import { Children } from 'react';
|
|
|
12
18
|
* )}
|
|
13
19
|
* />
|
|
14
20
|
*
|
|
21
|
+
* @example
|
|
22
|
+
* // Providing a stable key for lists that reorder
|
|
23
|
+
* <Each
|
|
24
|
+
* of={fruits}
|
|
25
|
+
* render={(fruit) => <li key={fruit.id}>{fruit.name}</li>}
|
|
26
|
+
* />
|
|
27
|
+
*
|
|
15
28
|
* @param {Object} props - The properties of the Each component.
|
|
16
29
|
* @param {T[]} props.of - The array of items to iterate over and render.
|
|
17
30
|
* @param {(item: T, index: number) => ReactNode} props.render - A function that renders each item in the array.
|
|
@@ -19,6 +32,10 @@ import { Children } from 'react';
|
|
|
19
32
|
* @returns {ReactNode} The rendered Each component.
|
|
20
33
|
*/
|
|
21
34
|
export function Each({ of, render }) {
|
|
22
|
-
return
|
|
35
|
+
return of.map((item, index) => {
|
|
36
|
+
const rendered = render(item, index);
|
|
37
|
+
const key = isValidElement(rendered) && rendered.key ? rendered.key : index;
|
|
38
|
+
return <Fragment key={key}>{rendered}</Fragment>;
|
|
39
|
+
});
|
|
23
40
|
}
|
|
24
41
|
//# sourceMappingURL=Each.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Each.jsx","sourceRoot":"","sources":["../../../../src/components/00-base/Each/Each.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"Each.jsx","sourceRoot":"","sources":["../../../../src/components/00-base/Each/Each.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAkB,MAAM,OAAO,CAAC;AAOjE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,UAAU,IAAI,CAAI,EAAE,EAAE,EAAE,MAAM,EAAgB;IAClD,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE;QAC5B,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACrC,MAAM,GAAG,GAAG,cAAc,CAAC,QAAQ,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC;QAE5E,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -48,7 +48,7 @@ export type DataTableVariants = 'card' | 'plain';
|
|
|
48
48
|
* @param {number} props.pagination.itemsPerPage - The number of items per page.
|
|
49
49
|
* @param {number} props.pagination.totalItems - The total number of items.
|
|
50
50
|
* @param {ReactNode} [props.summary] - Optional content aligned to the left of the pagination row.
|
|
51
|
-
* @param {'card' | 'plain'} [props.modifier='
|
|
51
|
+
* @param {'card' | 'plain'} [props.modifier='plain'] - Whether the table is framed in a box.
|
|
52
52
|
* @param {Object} [props.restProps] - Additional properties to be passed to the component.
|
|
53
53
|
*
|
|
54
54
|
* @returns {ReactNode} The rendered DataTable component.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../../src/components/03-organisms/DataTable/DataTable.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAE5E,OAAO,EACL,UAAU,EACV,KAAK,EAGN,MAAM,oBAAoB,CAAC;AAE5B,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,IAAI,CACT,cAAc,CAAC,OAAO,KAAK,CAAC,EAC1B,IAAI,GACJ,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,SAAS,GACT,YAAY,GACZ,UAAU,GACV,kBAAkB,GAClB,qBAAqB,GACrB,WAAW,GACX,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,QAAQ,GACR,YAAY,CACf,CAAC;IACF,UAAU,EAAE,IAAI,CACd,cAAc,CAAC,OAAO,UAAU,CAAC,EAC/B,aAAa,GACb,YAAY,GACZ,cAAc,GACd,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,eAAe,GACf,mBAAmB,CACtB,CAAC;IACF,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEnC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAOjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,OAAO,EACP,
|
|
1
|
+
{"version":3,"file":"DataTable.d.ts","sourceRoot":"","sources":["../../../../src/components/03-organisms/DataTable/DataTable.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,SAAS,EAAY,MAAM,OAAO,CAAC;AAE5E,OAAO,EACL,UAAU,EACV,KAAK,EAGN,MAAM,oBAAoB,CAAC;AAE5B,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,IAAI,CACT,cAAc,CAAC,OAAO,KAAK,CAAC,EAC1B,IAAI,GACJ,SAAS,GACT,MAAM,GACN,QAAQ,GACR,SAAS,GACT,SAAS,GACT,YAAY,GACZ,UAAU,GACV,kBAAkB,GAClB,qBAAqB,GACrB,WAAW,GACX,gBAAgB,GAChB,sBAAsB,GACtB,mBAAmB,GACnB,QAAQ,GACR,YAAY,CACf,CAAC;IACF,UAAU,EAAE,IAAI,CACd,cAAc,CAAC,OAAO,UAAU,CAAC,EAC/B,aAAa,GACb,YAAY,GACZ,cAAc,GACd,YAAY,GACZ,iBAAiB,GACjB,mBAAmB,GACnB,eAAe,GACf,mBAAmB,CACtB,CAAC;IACF,OAAO,CAAC,EAAE,SAAS,CAAC;IACpB,QAAQ,CAAC,EAAE,iBAAiB,CAAC;CAC9B,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAEnC,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,OAAO,CAAC;AAOjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,wBAAgB,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,OAAO,EACP,QAAkB,EAClB,GAAG,SAAS,EACb,EAAE,cAAc,GAAG,SAAS,CA6E5B"}
|
|
@@ -48,12 +48,12 @@ const styleMap = {
|
|
|
48
48
|
* @param {number} props.pagination.itemsPerPage - The number of items per page.
|
|
49
49
|
* @param {number} props.pagination.totalItems - The total number of items.
|
|
50
50
|
* @param {ReactNode} [props.summary] - Optional content aligned to the left of the pagination row.
|
|
51
|
-
* @param {'card' | 'plain'} [props.modifier='
|
|
51
|
+
* @param {'card' | 'plain'} [props.modifier='plain'] - Whether the table is framed in a box.
|
|
52
52
|
* @param {Object} [props.restProps] - Additional properties to be passed to the component.
|
|
53
53
|
*
|
|
54
54
|
* @returns {ReactNode} The rendered DataTable component.
|
|
55
55
|
*/
|
|
56
|
-
export function DataTable({ table, pagination, summary, modifier = '
|
|
56
|
+
export function DataTable({ table, pagination, summary, modifier = 'plain', ...restProps }) {
|
|
57
57
|
const [numberOfRows, setNumberOfRows] = useState(pagination.itemsPerPage?.at(0) || 10);
|
|
58
58
|
const handlePageChange = (page, itemsPerPage) => {
|
|
59
59
|
setNumberOfRows(itemsPerPage || 10);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DataTable.jsx","sourceRoot":"","sources":["../../../../src/components/03-organisms/DataTable/DataTable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAA6C,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EACL,UAAU,EACV,KAAK,GAGN,MAAM,oBAAoB,CAAC;AAuC5B,MAAM,QAAQ,GAAsC;IAClD,IAAI,EAAE,IAAI,CAAC,oDAAoD,CAAC;IAChE,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,OAAO,EACP,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"DataTable.jsx","sourceRoot":"","sources":["../../../../src/components/03-organisms/DataTable/DataTable.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;AAEb,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAA6C,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EACL,UAAU,EACV,KAAK,GAGN,MAAM,oBAAoB,CAAC;AAuC5B,MAAM,QAAQ,GAAsC;IAClD,IAAI,EAAE,IAAI,CAAC,oDAAoD,CAAC;IAChE,KAAK,EAAE,EAAE;CACV,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,KAAK,EACL,UAAU,EACV,OAAO,EACP,QAAQ,GAAG,OAAO,EAClB,GAAG,SAAS,EACG;IACf,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAC9C,UAAU,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CACrC,CAAC;IAEF,MAAM,gBAAgB,GAAG,CAAC,IAAY,EAAE,YAAqB,EAAE,EAAE;QAC/D,eAAe,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC;QACpC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC5C,CAAC,CAAC;IAEF,OAAO,CACL,CAAC,GAAG,CACF,IAAI,SAAS,CAAC,CACd,SAAS,CAAC,CAAC,IAAI,CACb,iBAAiB,EACjB,QAAQ,CAAC,QAAQ,CAAC,EACl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