diff --git a/package.json b/package.json index b052399..ba7c51b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@numaryhq/storybook", - "version": "1.3.0", + "version": "1.2.0", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", "files": [ diff --git a/src/Table/index.tsx b/src/Table/index.tsx index ff9d315..7a7bf6b 100644 --- a/src/Table/index.tsx +++ b/src/Table/index.tsx @@ -68,7 +68,7 @@ export type RowProps = { keys: Array void) | null | ReactElement>; item: any; id?: string; - renderActions?: () => Promise | any; + renderActions?: () => any; sx?: SxProps; }; @@ -78,20 +78,8 @@ export const Row: FunctionComponent = ({ renderActions, sx, }) => { - const [actions, setActions] = useState(); const pSx = sx || {}; - useEffect(() => { - (async () => { - if (renderActions) { - const renderActionsPromise = await renderActions(); - if (renderActionsPromise) { - setActions(renderActionsPromise); - } - } - })(); - }, []); - const styles = { whiteSpace: 'nowrap', width: '350px', @@ -136,7 +124,7 @@ export const Row: FunctionComponent = ({ } } })} - {actions && renderActions && {actions}} + {renderActions && {renderActions()}} ); diff --git a/src/Table/stories.tsx b/src/Table/stories.tsx index 34972c6..b152667 100644 --- a/src/Table/stories.tsx +++ b/src/Table/stories.tsx @@ -1,13 +1,12 @@ import React, { useState } from 'react'; import { Box } from '@mui/material'; -import { get, reverse, sortBy, uniqueId } from 'lodash'; +import { get, reverse, sortBy } from 'lodash'; import { DefaultAutocompleteCheckbox } from './Filters/AutocompleteSelect/stories'; import { Row, Table } from './index'; -import { LoadingButton } from '../Buttons/LoadingButton'; import { Chip } from '../Chip'; import { SourceDestination } from '../Sections/SourceDestination'; import { storyDocsParameters } from '../utils'; @@ -84,87 +83,6 @@ export const DefaultTable = () => ( DefaultTable.storyName = 'Default'; DefaultTable.parameters = storyDocsParameters; -const getDumbPromise = async () => new Promise((resolve) => resolve('Async')); - -export const AsyncActionTable = () => { - const renderActionsItem = async (user: User) => { - const label = await getDumbPromise(); - const onClick = () => { - alert('work'); - }; - - return ( - - - - ); - }; - - return ( - null} - onPrevious={() => null} - renderItem={(user: User, index) => ( - await renderActionsItem(user)} - item={user} - /> - )} - /> - ); -}; - -AsyncActionTable.storyName = 'Async Action'; -AsyncActionTable.parameters = storyDocsParameters; - -export const ActionTable = () => { - const renderActionsItem = (user: User) => { - const onClick = () => { - alert('work'); - }; - - return ( - - - - ); - }; - - return ( -
null} - onPrevious={() => null} - renderItem={(user: User, index) => ( - renderActionsItem(user)} - item={user} - /> - )} - /> - ); -}; - -ActionTable.storyName = 'Action'; -ActionTable.parameters = storyDocsParameters; - export const SortTable = () => { const [data, setData] = useState(items); const [idSort, setIdSort] = useState('asc');