-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update folder structure * Remove unused preview component
- Loading branch information
Showing
82 changed files
with
639 additions
and
645 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
3 changes: 3 additions & 0 deletions
3
assets/js/src/assets/icons/core/unordered-list-outlined.inline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
19 changes: 19 additions & 0 deletions
19
assets/js/src/components/formatted-date/formatted-date.tsx
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,19 @@ | ||
import React from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
interface FormattedDateProps { | ||
timestamp: number | ||
} | ||
|
||
const FormattedDate = (props: FormattedDateProps): React.JSX.Element => { | ||
const { i18n } = useTranslation() | ||
const formattedDate = i18n.format(new Date(props.timestamp), 'datetime', i18n.language) | ||
|
||
return ( | ||
<> | ||
{formattedDate} | ||
</> | ||
) | ||
} | ||
|
||
export { FormattedDate } |
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,46 @@ | ||
import React from 'react' | ||
import { type Meta } from '@storybook/react' | ||
import { Grid } from './grid' | ||
import { createColumnHelper } from '@tanstack/react-table' | ||
|
||
const config: Meta = { | ||
title: 'Pimcore studio/UI/Grid', | ||
component: Grid, | ||
parameters: { | ||
layout: 'centered' | ||
}, | ||
|
||
tags: ['autodocs'] | ||
} | ||
|
||
export default config | ||
|
||
interface User { | ||
firstname: string | ||
lastname: string | ||
age: number | ||
} | ||
|
||
const data: User[] = [ | ||
{ firstname: 'John', lastname: 'Doe', age: 25 }, | ||
{ firstname: 'Jane', lastname: 'Doe', age: 22 } | ||
] | ||
|
||
const columnHelper = createColumnHelper<User>() | ||
|
||
const columns = [ | ||
columnHelper.accessor('firstname', {}), | ||
columnHelper.accessor('lastname', { | ||
cell: info => <b>{info.getValue()}</b> | ||
}), | ||
columnHelper.accessor('age', { | ||
cell: info => <b>{info.getValue()}</b> | ||
}) | ||
] | ||
|
||
export const _default = { | ||
args: { | ||
data, | ||
columns | ||
} | ||
} |
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,19 @@ | ||
import { createStyles } from 'antd-style' | ||
|
||
export const useStyles = createStyles(({ token, css }) => { | ||
return { | ||
grid: css` | ||
table { | ||
table-layout: auto; | ||
} | ||
.ant-table-cell { | ||
border-left: 1px solid #F0F0F0; | ||
&:first-of-type { | ||
border-left: 0; | ||
} | ||
} | ||
` | ||
} | ||
}) |
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,62 @@ | ||
import { useCssComponentHash } from '@Pimcore/modules/ant-design/hooks/use-css-component-hash' | ||
import { type ColumnDef, flexRender, getCoreRowModel, useReactTable } from '@tanstack/react-table' | ||
import React, { useState } from 'react' | ||
import { useStyles } from './grid.styles' | ||
|
||
export interface GridProps { | ||
data: any[] | ||
columns: Array<ColumnDef<any>> | ||
} | ||
|
||
export const Grid = (props: GridProps): React.JSX.Element => { | ||
const { columns } = props | ||
const [data] = useState(props.data) | ||
const hashId = useCssComponentHash('table') | ||
const { styles } = useStyles() | ||
|
||
const table = useReactTable({ | ||
data, | ||
columns, | ||
getCoreRowModel: getCoreRowModel() | ||
}) | ||
|
||
return ( | ||
<div className={['ant-table-wrapper', hashId, styles.grid].join(' ')}> | ||
<div className="ant-table ant-table-small"> | ||
<div className='ant-table-container'> | ||
<div className='ant-table-content'> | ||
<table> | ||
<thead className='ant-table-thead'> | ||
{table.getHeaderGroups().map(headerGroup => ( | ||
<tr key={headerGroup.id}> | ||
{headerGroup.headers.map(header => ( | ||
<th className='ant-table-cell' key={header.id} style={{ width: header.column.getSize() }}> | ||
{header.isPlaceholder | ||
? null | ||
: flexRender( | ||
header.column.columnDef.header, | ||
header.getContext() | ||
)} | ||
</th> | ||
))} | ||
</tr> | ||
))} | ||
</thead> | ||
<tbody className="ant-table-tbody"> | ||
{table.getRowModel().rows.map(row => ( | ||
<tr className='ant-table-row' key={row.id}> | ||
{row.getVisibleCells().map(cell => ( | ||
<td className='ant-table-cell' key={cell.id} style={{ width: cell.column.getSize() }} > | ||
{flexRender(cell.column.columnDef.cell, cell.getContext())} | ||
</td> | ||
))} | ||
</tr> | ||
))} | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
} |
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
12 changes: 12 additions & 0 deletions
12
assets/js/src/modules/ant-design/hooks/use-css-component-hash.ts
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,12 @@ | ||
import useStyle from 'antd/es/table/style' | ||
import { ConfigContext } from 'antd/es/config-provider/context' | ||
import { useContext } from 'react' | ||
|
||
export const useCssComponentHash = (componentName: string): string => { | ||
const context = useContext(ConfigContext) | ||
const prefix = context.getPrefixCls(componentName, '') | ||
|
||
const hashId = useStyle(prefix)[1] | ||
|
||
return hashId | ||
} |
6 changes: 3 additions & 3 deletions
6
assets/js/src/modules/app/components/app.tsx → assets/js/src/modules/app/app-view.tsx
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
2 changes: 1 addition & 1 deletion
2
...odules/app/components/global-provider.tsx → ...ts/js/src/modules/app/global-provider.tsx
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,47 @@ | ||
import { Tree } from '@Pimcore/components/tree/tree' | ||
import React from 'react' | ||
import { useNodeApiHook } from './hooks/use-node-api-hook' | ||
import { type TreeNodeProps } from '@Pimcore/components/tree/node/tree-node' | ||
import { PagerContainer } from './pager/pager-container' | ||
import { useAsset } from '@Pimcore/modules/asset/hooks/use-asset' | ||
import { api } from '@Pimcore/modules/asset/asset-api-slice.gen' | ||
import { store } from '@Pimcore/app/store' | ||
|
||
export interface AssetTreeContainerProps { | ||
id: number | ||
} | ||
|
||
const defaultProps: AssetTreeContainerProps = { | ||
id: 1 | ||
} | ||
|
||
const AssetTreeContainer = (props: AssetTreeContainerProps): React.JSX.Element => { | ||
const { id } = props | ||
const { openAsset } = useAsset() | ||
|
||
async function onSelect (node: TreeNodeProps): Promise<void> { | ||
await store.dispatch(api.endpoints.apiAssetsIdGet.initiate({ id: node.id })) | ||
|
||
openAsset({ | ||
name: node.label, | ||
icon: node.icon, | ||
config: { | ||
id: node.id | ||
} | ||
}) | ||
} | ||
|
||
return ( | ||
<Tree | ||
nodeId={id} | ||
nodeApiHook={useNodeApiHook} | ||
maxItemsPerNode={20} | ||
renderPager={PagerContainer} | ||
onSelect={onSelect} | ||
/> | ||
) | ||
} | ||
|
||
AssetTreeContainer.defaultProps = defaultProps | ||
|
||
export { AssetTreeContainer } |
43 changes: 0 additions & 43 deletions
43
assets/js/src/modules/asset-tree/containers/asset-tree.tsx
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,7 +1,7 @@ | ||
import { registerWidget } from '../widget-manager/utils/widget-registry' | ||
import { AssetTree } from './containers/asset-tree' | ||
import { AssetTreeContainer } from './asset-tree-container' | ||
|
||
registerWidget({ | ||
name: 'asset-tree', | ||
component: AssetTree | ||
component: AssetTreeContainer | ||
}) |
Oops, something went wrong.