-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(@h6s/table): Add import react statement (#166)
* chore(@h6s/calendar): add scope to test command * chore: change cjs to esm * docs: add calendar route * docs: setup table example * env: update next to 12.0.10 * ci: add working-directory to example job * env: update dependencies of examples * ci: fix working-directory path * chore: move mock directory * ci: add prebuild step * fix(@h6s/table): Add import react statement * docs: arrange code
- Loading branch information
1 parent
8ea44dc
commit 2c62975
Showing
163 changed files
with
2,991 additions
and
2,736 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file removed
BIN
-2.65 KB
.yarn/cache/@babel-plugin-syntax-jsx-npm-7.14.5-14192e29dd-3a2ba87534.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+28.2 KB
...rdion-npm-1.4.2-1804a9c72a-fc77794b53.zip → ...rdion-npm-1.4.5-602ce83730-5e93e71d14.zip
Binary file not shown.
Binary file renamed
BIN
+13.6 KB
...alert-npm-1.3.2-4bebffae1c-b80f545411.zip → ...alert-npm-1.3.3-59c0439fc1-55f5a033a2.zip
Binary file not shown.
Binary file renamed
BIN
+10.9 KB
...atomy-npm-1.2.1-50e14f8b8c-21dee3b381.zip → ...atomy-npm-1.2.2-fd10a87364-9b846fef27.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+16.1 KB
...crumb-npm-1.3.1-37912e9d62-09ba4d865b.zip → ...crumb-npm-1.3.2-9359052126-d453339303.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+20.9 KB
...kable-npm-1.2.1-e728fb891e-e8ed078c47.zip → ...kable-npm-1.2.2-a73a75243f-f000956f57.zip
Binary file not shown.
Binary file renamed
BIN
+9.94 KB
...utton-npm-1.2.2-897f17cd5c-ef18aa06be.zip → ...utton-npm-1.2.3-4fcd212fec-dd4db49f73.zip
Binary file not shown.
Binary file removed
BIN
-23.7 KB
.yarn/cache/@chakra-ui-color-mode-npm-1.3.2-489d7268b6-4ae17330a0.zip
Binary file not shown.
Binary file added
BIN
+24.3 KB
.yarn/cache/@chakra-ui-color-mode-npm-1.4.1-e3b895bbb2-d84f416fa3.zip
Binary file not shown.
Binary file renamed
BIN
+12 KB
...l-box-npm-1.1.1-6184ecb51d-e0f408ad4e.zip → ...l-box-npm-1.1.2-797e5276b2-4ca8b592c4.zip
Binary file not shown.
Binary file renamed
BIN
+14.6 KB
...unter-npm-1.2.1-ed0c417e82-2248ee79dc.zip → ...unter-npm-1.2.3-81346b5215-80244f63d1.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+10.4 KB
...-lock-npm-1.2.1-57e6ba7b09-1bc1afeba9.zip → ...-lock-npm-1.2.2-08a4c31c65-44ac9057ad.zip
Binary file not shown.
Binary file renamed
BIN
+27.1 KB
...ntrol-npm-1.5.2-9c7f615abd-2ab7937c35.zip → ...ntrol-npm-1.5.4-7021eca5c2-1813fc2333.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+19.3 KB
...image-npm-1.1.1-b94bc3ea4d-7aec52a4b8.zip → ...image-npm-1.1.3-ea727ce6e7-ceb673a415.zip
Binary file not shown.
Binary file renamed
BIN
+18.3 KB
...input-npm-1.3.2-bf677ef6a3-d6b673e952.zip → ...input-npm-1.3.4-32cc6bf11d-4284f15b44.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+13.5 KB
...egion-npm-1.1.1-3d3ab4526f-ad14471ffd.zip → ...egion-npm-1.1.2-048a4de18e-0dff43e70e.zip
Binary file not shown.
Binary file removed
BIN
-27.9 KB
.yarn/cache/@chakra-ui-media-query-npm-1.2.2-f53e4a33eb-c965237e4a.zip
Binary file not shown.
Binary file added
BIN
+28.2 KB
.yarn/cache/@chakra-ui-media-query-npm-1.2.4-f8e6ef0f85-25e6d9bb46.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+38.8 KB
...odal-npm-1.10.2-b389b9d846-92da9e051d.zip → ...odal-npm-1.10.5-6a2a9da0d9-108f0bcd89.zip
Binary file not shown.
Binary file removed
BIN
-37.9 KB
.yarn/cache/@chakra-ui-number-input-npm-1.3.2-96b1b0ae85-4b0e140aa8.zip
Binary file not shown.
Binary file added
BIN
+42.4 KB
.yarn/cache/@chakra-ui-number-input-npm-1.4.0-6990bedbe2-aaeec88f9f.zip
Binary file not shown.
Binary file renamed
BIN
+25.9 KB
...input-npm-1.7.1-d96dc609f1-0adc7a9831.zip → ...input-npm-1.7.3-5be768c958-72295e1e14.zip
Binary file not shown.
Binary file removed
BIN
-31.8 KB
.yarn/cache/@chakra-ui-popover-npm-1.11.0-008ba300ed-2883722a1d.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+18 KB
...ortal-npm-1.3.1-8a9c3ffa22-8baee2c19d.zip → ...ortal-npm-1.3.3-f0198e4906-8e63c53b67.zip
Binary file not shown.
Binary file renamed
BIN
+27.4 KB
...gress-npm-1.2.1-0761108613-6f76b06150.zip → ...gress-npm-1.2.2-61974c9a69-aec703f1cc.zip
Binary file not shown.
Binary file renamed
BIN
+9.15 KB
...vider-npm-1.7.3-0bb84d8d02-3761161dc2.zip → ...vider-npm-1.7.7-c055688682-59a764fd93.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+13.4 KB
...t-env-npm-1.1.1-5848e1b57c-a84f7cd318.zip → ...t-env-npm-1.1.2-b6485b79c7-9848bc501a.zip
Binary file not shown.
Binary file renamed
BIN
+24.2 KB
...react-npm-1.7.3-285a54b101-0a49ec0a3b.zip → ...react-npm-1.8.2-fc6983b2b9-450c6bb126.zip
Binary file not shown.
Binary file renamed
BIN
+13.9 KB
...elect-npm-1.2.2-025fea8d97-b809d0060d.zip → ...elect-npm-1.2.4-bc193f12fb-be66110018.zip
Binary file not shown.
Binary file renamed
BIN
+12.7 KB
...leton-npm-1.2.3-51f4c286a7-97c2400d91.zip → ...leton-npm-1.2.8-d91a381825-e3013e8283.zip
Binary file not shown.
Binary file renamed
BIN
+49.8 KB
...lider-npm-1.5.2-e7bcea5729-904595099e.zip → ...lider-npm-1.5.4-4d88618ba5-b379d3e669.zip
Binary file not shown.
Binary file renamed
BIN
+13.3 KB
...inner-npm-1.2.1-0f9712b79c-9f91b8a4d1.zip → ...inner-npm-1.2.2-446a8bb6ac-e2681062ef.zip
Binary file not shown.
Binary file renamed
BIN
+11.7 KB
...-stat-npm-1.2.2-998777bfee-f04884c564.zip → ...-stat-npm-1.2.3-9e526d779b-b779536755.zip
Binary file not shown.
Binary file removed
BIN
-128 KB
.yarn/cache/@chakra-ui-styled-system-npm-1.15.0-bb664223b7-e54c33d9a7.zip
Binary file not shown.
Binary file added
BIN
+136 KB
.yarn/cache/@chakra-ui-styled-system-npm-1.17.0-c4b1ec8a11-836e984bd3.zip
Binary file not shown.
Binary file renamed
BIN
+13.6 KB
...witch-npm-1.3.1-89a60bab6e-b3c459629f.zip → ...witch-npm-1.3.4-8ebfc0fd4f-4181eb0911.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+12.3 KB
...table-npm-1.3.1-ea1a47a06e-9a4a3fe527.zip → ...table-npm-1.3.2-3b42ad553e-defb339308.zip
Binary file not shown.
Binary file renamed
BIN
+36.2 KB
...-tabs-npm-1.6.1-77dc560627-d4b1369b90.zip → ...-tabs-npm-1.6.3-21ba86ea2e-8d132947b9.zip
Binary file not shown.
Binary file renamed
BIN
+10.7 KB
...i-tag-npm-1.2.2-dcf7e6d46b-f1674b93b2.zip → ...i-tag-npm-1.2.3-cbec6626ed-d62eb4eeee.zip
Binary file not shown.
Binary file renamed
BIN
+9.2 KB
...tarea-npm-1.2.2-84c653a2fe-31a1cbdd06.zip → ...tarea-npm-1.2.4-13c3620b43-811412d41e.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added
BIN
+28.5 KB
.yarn/cache/@chakra-ui-theme-tools-npm-1.3.2-a665f77689-d7fef65d33.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+28.8 KB
...ition-npm-1.4.2-ca9929459f-38990f3c70.zip → ...ition-npm-1.4.3-bd7bbf0c16-9bb8ea050a.zip
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+9.99 KB
...idden-npm-1.1.1-d6346ddf60-1e6ed8a1d9.zip → ...idden-npm-1.1.2-468d1d3892-3d776df29f.zip
Binary file not shown.
Binary file added
BIN
+3.14 MB
.yarn/cache/@faker-js-faker-npm-6.0.0-alpha.5-3ef77c0e02-aa145eaeba.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-3.51 KB
.yarn/cache/@next-polyfill-module-npm-12.0.4-06677031c5-701f563ef8.zip
Binary file not shown.
Binary file removed
BIN
-146 KB
.yarn/cache/@next-react-dev-overlay-npm-12.0.4-05495b4cf0-ac54baf041.zip
Binary file not shown.
Binary file removed
BIN
-11.3 KB
.yarn/cache/@next-react-refresh-utils-npm-12.0.4-d8661f51f6-7c1c9c3284.zip
Binary file not shown.
Binary file renamed
BIN
+14.9 MB
...linux-x64-gnu-npm-12.0.4-9fb12508a1-8.zip → ...c-darwin-x64-npm-12.0.10-4a8143783e-8.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-7.61 KB
.yarn/cache/available-typed-arrays-npm-1.0.5-88f321e4d3-20eb47b3ce.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-77.2 KB
.yarn/cache/cssnano-preset-simple-npm-3.0.0-42fae6d1e4-03ad717960.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-12.6 KB
.yarn/cache/is-generator-function-npm-1.0.10-1d0f3809ef-d54644e7db.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-33.9 KB
.yarn/cache/jest-worker-npm-27.0.0-next.5-6f53fab806-d56bfe67cd.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file renamed
BIN
+6.04 MB
...next-npm-12.0.4-fcbd6e5d3e-b9711e7d42.zip → ...ext-npm-12.0.10-84f5caa189-e92ff09c1f.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed
BIN
-9.17 KB
.yarn/cache/regenerator-runtime-npm-0.13.4-09f9ad5d1a-ba49669ddb.zip
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import { Heading, Stack, Text } from '@chakra-ui/react' | ||
|
||
interface Props { | ||
title: string; | ||
description?: string; | ||
} | ||
|
||
export function Header({ title, description }: Props) { | ||
return ( | ||
<Stack | ||
padding={12} | ||
justifyContent="center" | ||
direction="column" | ||
alignItems="center" | ||
spacing={4} | ||
> | ||
<Heading as="h1" size="xl"> | ||
{title} | ||
</Heading> | ||
<Text color="gray.500"> | ||
{description} with <a href="https://chakra-ui.com/">chakra-ui</a> | ||
</Text> | ||
</Stack> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,205 @@ | ||
import faker from '@faker-js/faker' | ||
import { Cell, CellRendererProps, composeDataset, TableModel } from '@h6s/table' | ||
import { format } from 'date-fns' | ||
|
||
const TOTAL_BY_DATE = '#TOTAL_BY_DATE' | ||
const TOTAL_BY_DATE_AND_ID = '#TOTAL_BY_DATE_AND_ID' | ||
|
||
export interface DatasetType { | ||
date: string; | ||
id: string; | ||
subId: string; | ||
amount: number; | ||
cancelAmount: number; | ||
buyer: string; | ||
plcc: number; | ||
debit: number; | ||
transfer: number; | ||
meta: { | ||
transactionId: string; | ||
}; | ||
message: string; | ||
} | ||
|
||
export const DATASET: DatasetType[] = generateMockDataset() | ||
|
||
export const DATASET_WITH_SUMMARY = composeDataset(DATASET, { | ||
groupBy: 'date', | ||
compose: rows => { | ||
const appended = composeDataset(rows, { | ||
groupBy: 'id', | ||
compose: rows => { | ||
return rows.concat({ | ||
subId: TOTAL_BY_DATE_AND_ID, | ||
amount: sum(rows.map(x => x.amount)), | ||
cancelAmount: sum(rows.map(x => x.cancelAmount)), | ||
buyer: '', | ||
plcc: sum(rows.map(x => x.plcc)), | ||
debit: sum(rows.map(x => x.debit)), | ||
transfer: sum(rows.map(x => x.transfer)), | ||
meta: { | ||
transactionId: '', | ||
}, | ||
message: '', | ||
}) | ||
}, | ||
}) | ||
|
||
return appended.concat({ | ||
id: TOTAL_BY_DATE, | ||
subId: '', | ||
amount: sum(rows.map(x => x.amount)), | ||
cancelAmount: sum(rows.map(x => x.cancelAmount)), | ||
buyer: '', | ||
plcc: sum(rows.map(x => x.plcc)), | ||
debit: sum(rows.map(x => x.debit)), | ||
transfer: sum(rows.map(x => x.transfer)), | ||
meta: { | ||
transactionId: '', | ||
}, | ||
message: '', | ||
}) | ||
}, | ||
}) | ||
|
||
function generateMockDataset() { | ||
return [...new Array(30).keys()].map(() => { | ||
return { | ||
date: format(faker.date.between('2022-01-01', '2022-01-04'), 'yyyy-MM-dd'), | ||
id: faker.datatype.number({ min: 103, max: 106 }).toString(), | ||
subId: faker.datatype.number({ min: 9870, max: 9900 }).toString(), | ||
|
||
amount: Number(faker.commerce.price()), | ||
cancelAmount: Number(faker.commerce.price()), | ||
|
||
buyer: faker.name.findName(), | ||
|
||
plcc: Number(faker.commerce.price()), | ||
debit: Number(faker.commerce.price()), | ||
transfer: Number(faker.commerce.price()), | ||
|
||
meta: { | ||
transactionId: faker.lorem.slug(2), | ||
}, | ||
message: faker.commerce.productName(), | ||
} | ||
}) | ||
.sort((a, b) => Number(b.subId) - Number(a.subId)) | ||
.sort((a, b) => Number(b.id) - Number(a.id)) | ||
.sort((a, b) => new Date(b.date).getTime() - new Date(a.date).getTime()) | ||
} | ||
|
||
export const TABLE_MODEL: TableModel<DatasetType> = [ | ||
{ | ||
accessor: 'date', | ||
label: 'Date', | ||
cell: { | ||
mergeRow: 'date', | ||
}, | ||
foot: [() => <>{'Total'}</>], | ||
}, | ||
{ | ||
accessor: 'id', | ||
label: 'Id', | ||
cell: { | ||
mergeRow: ['date', 'id'], | ||
colSpanAs: x => x.id === TOTAL_BY_DATE ? 2 : 1, | ||
render: [({ cellProps, children }) => { | ||
if (cellProps.value === TOTAL_BY_DATE) { | ||
return <span>{format(new Date(cellProps.rowValues.date), 'M/d')} TOTAL</span> | ||
} | ||
|
||
return <>{children}</> | ||
}], | ||
}, | ||
}, | ||
{ | ||
accessor: 'subId', | ||
label: 'Sub Id', | ||
cell: { | ||
mergeRow: ({ date, id, subId }) => date + id + subId, | ||
colSpanAs: x => x.id === TOTAL_BY_DATE ? 0 : 1, | ||
render: [({ cellProps, children }) => { | ||
if (cellProps.value === TOTAL_BY_DATE_AND_ID) { | ||
return <span>{cellProps.rowValues.id} TOTAL</span> | ||
} | ||
|
||
return <>{children}</> | ||
}], | ||
}, | ||
}, | ||
{ | ||
accessor: [ | ||
{ | ||
accessor: 'amount', | ||
label: 'Paid', | ||
cell: [CurrencyCellValue], | ||
foot: [() => <>{sum(DATASET.map(x => x.amount)).toLocaleString()}</>], | ||
}, | ||
{ | ||
accessor: 'cancelAmount', | ||
label: 'Canceled', | ||
cell: [CurrencyCellValue], | ||
foot: { | ||
render: [() => <>{sum(DATASET.map(x => x.cancelAmount)).toLocaleString()}</>], | ||
extends: false, | ||
}, | ||
}, | ||
], | ||
label: 'AMOUNT', | ||
}, | ||
{ | ||
accessor: 'buyer', | ||
label: 'Buyer', | ||
}, | ||
{ | ||
accessor: [ | ||
{ | ||
accessor: [ | ||
{ | ||
accessor: 'plcc', | ||
label: 'Plcc', | ||
cell: [CurrencyCellValue], | ||
foot: { | ||
render: [() => <>{sum(DATASET.map(x => x.plcc)).toLocaleString()}</>], | ||
}, | ||
}, | ||
{ | ||
accessor: 'debit', | ||
label: 'Debit', | ||
cell: [CurrencyCellValue], | ||
foot: { | ||
render: [() => <>{sum(DATASET.map(x => x.debit)).toLocaleString()}</>], | ||
}, | ||
}, | ||
], | ||
label: 'CARD', | ||
}, | ||
{ | ||
accessor: 'transfer', | ||
label: 'Transfer', | ||
cell: [CurrencyCellValue], | ||
foot: { | ||
render: [() => <>{sum(DATASET.map(x => x.transfer)).toLocaleString()}</>], | ||
}, | ||
}, | ||
], | ||
label: 'PAY METHOD', | ||
}, | ||
{ | ||
accessor: 'meta.transactionId', | ||
label: 'Transaction Id', | ||
}, | ||
{ | ||
accessor: 'message', | ||
label: 'Message', | ||
}, | ||
] | ||
|
||
export function sum(...arr: number[] | number[][]) { | ||
return arr.flat().reduce((a, b) => a + b, 0) | ||
} | ||
|
||
function CurrencyCellValue({ cellProps }: CellRendererProps<Cell<DatasetType>>) { | ||
return <>{cellProps.value?.toLocaleString()}</> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.