@contember/create 2.1.0-alpha.3 → 2.1.0-alpha.5

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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@contember/create",
3
- "version": "2.1.0-alpha.3",
3
+ "version": "2.1.0-alpha.5",
4
4
  "license": "Apache-2.0",
5
5
  "bin": "dist/production/run.js",
6
6
  "dependencies": {
7
- "@contember/cli-common": "2.1.0-alpha.3",
7
+ "@contember/cli-common": "2.1.0-alpha.5",
8
8
  "chalk": "^5.3.0",
9
9
  "fs-extra": "^11.2.0",
10
10
  "js-yaml": "^4.1.0"
@@ -1,18 +1,15 @@
1
1
  import { EyeIcon, EyeOffIcon } from 'lucide-react'
2
2
  import { dict } from '../dict'
3
3
  import * as React from 'react'
4
- import { ReactNode } from 'react'
5
- import { DataViewVisibilityTrigger, useDataViewElements } from '@contember/react-dataview'
4
+ import { DataViewElementData, DataViewVisibilityTrigger, useDataViewElements } from '@contember/react-dataview'
6
5
  import { ScrollArea } from '../ui/scroll-area'
6
+ import { Fragment } from 'react'
7
7
 
8
8
  /**
9
9
  * Props for {@link DataGridToolbarVisibleElements}.
10
10
  */
11
11
  export interface DataGridToolbarVisibleElementsProps {
12
- elements?: {
13
- name: string
14
- label: ReactNode
15
- }[]
12
+ elements?: DataViewElementData[]
16
13
  }
17
14
 
18
15
  /**
@@ -31,18 +28,32 @@ export const DataGridToolbarVisibleElements = ({ elements }: DataGridToolbarVisi
31
28
  <div className="flex flex-col bg-gray-50 p-2 border rounded shadow-inner">
32
29
  <ScrollArea className={'max-h-48'}>
33
30
  <div className="flex flex-col">
34
- {resolvedElements.map(element => (
35
- element.name && <DataViewVisibilityTrigger key={element.name} name={element.name} value={it => !(it ?? true)}>
36
- <button className={'gap-2 group text-gray-400 data-[current]:text-black text-left inline-flex items-center p-0.5 text-sm rounded hover:bg-white'}>
37
- <EyeIcon className={'w-3 h-3 hidden group-data-[current]:block'} />
38
- <EyeOffIcon className={'w-3 h-3 block group-data-[current]:hidden'} />
39
- <span>{element.label}</span>
40
- </button>
41
- </DataViewVisibilityTrigger>
42
- ))}
31
+ <DataGridToolbarVisibleElementsList elements={resolvedElements} />
43
32
  </div>
44
33
  </ScrollArea>
45
34
  </div>
46
35
  </div>
47
36
  )
48
37
  }
38
+
39
+
40
+ const DataGridToolbarVisibleElementsList = ({ elements }: { elements: DataViewElementData[] }) => {
41
+ return elements.map(element => {
42
+ if (!element.name) {
43
+ return null
44
+ }
45
+ return (
46
+ <Fragment key={element.name}>
47
+ <DataViewVisibilityTrigger key={element.name} name={element.name} value={it => !(it ?? true)}>
48
+ <button className={'gap-2 group text-gray-400 data-[current]:text-black text-left inline-flex items-center p-0.5 text-sm rounded hover:bg-white'}>
49
+ <EyeIcon className={'w-3 h-3 hidden group-data-[current]:block'} />
50
+ <EyeOffIcon className={'w-3 h-3 block group-data-[current]:hidden'} />
51
+ <span>{element.label}</span>
52
+ </button>
53
+ </DataViewVisibilityTrigger>
54
+ {element.children && <div className="flex flex-col ml-4"><DataGridToolbarVisibleElementsList elements={element.children} /></div>}
55
+ </Fragment>
56
+ )
57
+ })
58
+
59
+ }