@contember/react-board 2.1.0-alpha.30 → 2.1.0-alpha.35
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 +9 -9
- package/src/components/Board.tsx +152 -143
- package/src/components/BoardEachColumn.tsx +20 -16
- package/src/components/BoardEachItem.tsx +15 -14
- package/src/contexts.ts +0 -1
- package/src/internal/useBoardItemsMethods.ts +13 -8
- package/src/internal/useCreateBoardColumns.ts +0 -3
- package/src/internal/useDynamicBoard.ts +2 -13
- package/src/internal/useGroupItemsByColumn.ts +4 -1
- package/src/internal/useStaticBoard.ts +0 -2
- package/src/types/BoardData.ts +3 -4
- package/src/types/BoardMethods.ts +5 -1
- package/dist/development/index.cjs +0 -28
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -28
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/components/Board.cjs +0 -274
- package/dist/development/src/components/Board.cjs.map +0 -1
- package/dist/development/src/components/Board.js +0 -274
- package/dist/development/src/components/Board.js.map +0 -1
- package/dist/development/src/components/BoardColumn.cjs +0 -7
- package/dist/development/src/components/BoardColumn.cjs.map +0 -1
- package/dist/development/src/components/BoardColumn.js +0 -7
- package/dist/development/src/components/BoardColumn.js.map +0 -1
- package/dist/development/src/components/BoardColumnLabel.cjs +0 -14
- package/dist/development/src/components/BoardColumnLabel.cjs.map +0 -1
- package/dist/development/src/components/BoardColumnLabel.js +0 -14
- package/dist/development/src/components/BoardColumnLabel.js.map +0 -1
- package/dist/development/src/components/BoardEachColumn.cjs +0 -37
- package/dist/development/src/components/BoardEachColumn.cjs.map +0 -1
- package/dist/development/src/components/BoardEachColumn.js +0 -37
- package/dist/development/src/components/BoardEachColumn.js.map +0 -1
- package/dist/development/src/components/BoardEachItem.cjs +0 -56
- package/dist/development/src/components/BoardEachItem.cjs.map +0 -1
- package/dist/development/src/components/BoardEachItem.js +0 -56
- package/dist/development/src/components/BoardEachItem.js.map +0 -1
- package/dist/development/src/components/BoardItem.cjs +0 -8
- package/dist/development/src/components/BoardItem.cjs.map +0 -1
- package/dist/development/src/components/BoardItem.js +0 -8
- package/dist/development/src/components/BoardItem.js.map +0 -1
- package/dist/development/src/components/BoardNullColumn.cjs +0 -18
- package/dist/development/src/components/BoardNullColumn.cjs.map +0 -1
- package/dist/development/src/components/BoardNullColumn.js +0 -18
- package/dist/development/src/components/BoardNullColumn.js.map +0 -1
- package/dist/development/src/const.cjs +0 -5
- package/dist/development/src/const.cjs.map +0 -1
- package/dist/development/src/const.js +0 -5
- package/dist/development/src/const.js.map +0 -1
- package/dist/development/src/contexts.cjs +0 -24
- package/dist/development/src/contexts.cjs.map +0 -1
- package/dist/development/src/contexts.js +0 -24
- package/dist/development/src/contexts.js.map +0 -1
- package/dist/development/src/internal/boardAnalyzer.cjs +0 -13
- package/dist/development/src/internal/boardAnalyzer.cjs.map +0 -1
- package/dist/development/src/internal/boardAnalyzer.js +0 -13
- package/dist/development/src/internal/boardAnalyzer.js.map +0 -1
- package/dist/development/src/internal/useBoardItemsMethods.cjs +0 -100
- package/dist/development/src/internal/useBoardItemsMethods.cjs.map +0 -1
- package/dist/development/src/internal/useBoardItemsMethods.js +0 -100
- package/dist/development/src/internal/useBoardItemsMethods.js.map +0 -1
- package/dist/development/src/internal/useCreateBoardColumns.cjs +0 -30
- package/dist/development/src/internal/useCreateBoardColumns.cjs.map +0 -1
- package/dist/development/src/internal/useCreateBoardColumns.js +0 -30
- package/dist/development/src/internal/useCreateBoardColumns.js.map +0 -1
- package/dist/development/src/internal/useDynamicBoard.cjs +0 -95
- package/dist/development/src/internal/useDynamicBoard.cjs.map +0 -1
- package/dist/development/src/internal/useDynamicBoard.js +0 -95
- package/dist/development/src/internal/useDynamicBoard.js.map +0 -1
- package/dist/development/src/internal/useGroupItemsByColumn.cjs +0 -19
- package/dist/development/src/internal/useGroupItemsByColumn.cjs.map +0 -1
- package/dist/development/src/internal/useGroupItemsByColumn.js +0 -19
- package/dist/development/src/internal/useGroupItemsByColumn.js.map +0 -1
- package/dist/development/src/internal/useStaticBoard.cjs +0 -43
- package/dist/development/src/internal/useStaticBoard.cjs.map +0 -1
- package/dist/development/src/internal/useStaticBoard.js +0 -43
- package/dist/development/src/internal/useStaticBoard.js.map +0 -1
- package/dist/development/src/utils/arrayMove.cjs +0 -9
- package/dist/development/src/utils/arrayMove.cjs.map +0 -1
- package/dist/development/src/utils/arrayMove.js +0 -9
- package/dist/development/src/utils/arrayMove.js.map +0 -1
- package/dist/production/index.cjs +0 -28
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -28
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/components/Board.cjs +0 -122
- package/dist/production/src/components/Board.cjs.map +0 -1
- package/dist/production/src/components/Board.js +0 -122
- package/dist/production/src/components/Board.js.map +0 -1
- package/dist/production/src/components/BoardColumn.cjs +0 -7
- package/dist/production/src/components/BoardColumn.cjs.map +0 -1
- package/dist/production/src/components/BoardColumn.js +0 -7
- package/dist/production/src/components/BoardColumn.js.map +0 -1
- package/dist/production/src/components/BoardColumnLabel.cjs +0 -10
- package/dist/production/src/components/BoardColumnLabel.cjs.map +0 -1
- package/dist/production/src/components/BoardColumnLabel.js +0 -10
- package/dist/production/src/components/BoardColumnLabel.js.map +0 -1
- package/dist/production/src/components/BoardEachColumn.cjs +0 -21
- package/dist/production/src/components/BoardEachColumn.cjs.map +0 -1
- package/dist/production/src/components/BoardEachColumn.js +0 -21
- package/dist/production/src/components/BoardEachColumn.js.map +0 -1
- package/dist/production/src/components/BoardEachItem.cjs +0 -33
- package/dist/production/src/components/BoardEachItem.cjs.map +0 -1
- package/dist/production/src/components/BoardEachItem.js +0 -33
- package/dist/production/src/components/BoardEachItem.js.map +0 -1
- package/dist/production/src/components/BoardItem.cjs +0 -8
- package/dist/production/src/components/BoardItem.cjs.map +0 -1
- package/dist/production/src/components/BoardItem.js +0 -8
- package/dist/production/src/components/BoardItem.js.map +0 -1
- package/dist/production/src/components/BoardNullColumn.cjs +0 -14
- package/dist/production/src/components/BoardNullColumn.cjs.map +0 -1
- package/dist/production/src/components/BoardNullColumn.js +0 -14
- package/dist/production/src/components/BoardNullColumn.js.map +0 -1
- package/dist/production/src/const.cjs +0 -5
- package/dist/production/src/const.cjs.map +0 -1
- package/dist/production/src/const.js +0 -5
- package/dist/production/src/const.js.map +0 -1
- package/dist/production/src/contexts.cjs +0 -24
- package/dist/production/src/contexts.cjs.map +0 -1
- package/dist/production/src/contexts.js +0 -24
- package/dist/production/src/contexts.js.map +0 -1
- package/dist/production/src/internal/boardAnalyzer.cjs +0 -13
- package/dist/production/src/internal/boardAnalyzer.cjs.map +0 -1
- package/dist/production/src/internal/boardAnalyzer.js +0 -13
- package/dist/production/src/internal/boardAnalyzer.js.map +0 -1
- package/dist/production/src/internal/useBoardItemsMethods.cjs +0 -100
- package/dist/production/src/internal/useBoardItemsMethods.cjs.map +0 -1
- package/dist/production/src/internal/useBoardItemsMethods.js +0 -100
- package/dist/production/src/internal/useBoardItemsMethods.js.map +0 -1
- package/dist/production/src/internal/useCreateBoardColumns.cjs +0 -30
- package/dist/production/src/internal/useCreateBoardColumns.cjs.map +0 -1
- package/dist/production/src/internal/useCreateBoardColumns.js +0 -30
- package/dist/production/src/internal/useCreateBoardColumns.js.map +0 -1
- package/dist/production/src/internal/useDynamicBoard.cjs +0 -95
- package/dist/production/src/internal/useDynamicBoard.cjs.map +0 -1
- package/dist/production/src/internal/useDynamicBoard.js +0 -95
- package/dist/production/src/internal/useDynamicBoard.js.map +0 -1
- package/dist/production/src/internal/useGroupItemsByColumn.cjs +0 -19
- package/dist/production/src/internal/useGroupItemsByColumn.cjs.map +0 -1
- package/dist/production/src/internal/useGroupItemsByColumn.js +0 -19
- package/dist/production/src/internal/useGroupItemsByColumn.js.map +0 -1
- package/dist/production/src/internal/useStaticBoard.cjs +0 -43
- package/dist/production/src/internal/useStaticBoard.cjs.map +0 -1
- package/dist/production/src/internal/useStaticBoard.js +0 -43
- package/dist/production/src/internal/useStaticBoard.js.map +0 -1
- package/dist/production/src/utils/arrayMove.cjs +0 -9
- package/dist/production/src/utils/arrayMove.cjs.map +0 -1
- package/dist/production/src/utils/arrayMove.js +0 -9
- package/dist/production/src/utils/arrayMove.js.map +0 -1
- package/dist/types/components/Board.d.ts +0 -28
- package/dist/types/components/Board.d.ts.map +0 -1
- package/dist/types/components/BoardColumn.d.ts +0 -5
- package/dist/types/components/BoardColumn.d.ts.map +0 -1
- package/dist/types/components/BoardColumnLabel.d.ts +0 -2
- package/dist/types/components/BoardColumnLabel.d.ts.map +0 -1
- package/dist/types/components/BoardEachColumn.d.ts +0 -10
- package/dist/types/components/BoardEachColumn.d.ts.map +0 -1
- package/dist/types/components/BoardEachItem.d.ts +0 -10
- package/dist/types/components/BoardEachItem.d.ts.map +0 -1
- package/dist/types/components/BoardItem.d.ts +0 -8
- package/dist/types/components/BoardItem.d.ts.map +0 -1
- package/dist/types/components/BoardNullColumn.d.ts +0 -7
- package/dist/types/components/BoardNullColumn.d.ts.map +0 -1
- package/dist/types/components/index.d.ts +0 -8
- package/dist/types/components/index.d.ts.map +0 -1
- package/dist/types/const.d.ts +0 -2
- package/dist/types/const.d.ts.map +0 -1
- package/dist/types/contexts.d.ts +0 -18
- package/dist/types/contexts.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/internal/boardAnalyzer.d.ts +0 -8
- package/dist/types/internal/boardAnalyzer.d.ts.map +0 -1
- package/dist/types/internal/useBoardItemsMethods.d.ts +0 -15
- package/dist/types/internal/useBoardItemsMethods.d.ts.map +0 -1
- package/dist/types/internal/useCreateBoardColumns.d.ts +0 -10
- package/dist/types/internal/useCreateBoardColumns.d.ts.map +0 -1
- package/dist/types/internal/useDynamicBoard.d.ts +0 -10
- package/dist/types/internal/useDynamicBoard.d.ts.map +0 -1
- package/dist/types/internal/useGroupItemsByColumn.d.ts +0 -5
- package/dist/types/internal/useGroupItemsByColumn.d.ts.map +0 -1
- package/dist/types/internal/useStaticBoard.d.ts +0 -9
- package/dist/types/internal/useStaticBoard.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/types/BoardColumnNode.d.ts +0 -15
- package/dist/types/types/BoardColumnNode.d.ts.map +0 -1
- package/dist/types/types/BoardData.d.ts +0 -5
- package/dist/types/types/BoardData.d.ts.map +0 -1
- package/dist/types/types/BoardItemNode.d.ts +0 -7
- package/dist/types/types/BoardItemNode.d.ts.map +0 -1
- package/dist/types/types/BoardMethods.d.ts +0 -17
- package/dist/types/types/BoardMethods.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -4
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/utils/arrayMove.d.ts +0 -2
- package/dist/types/utils/arrayMove.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contember/react-board",
|
|
3
3
|
"license": "Apache-2.0",
|
|
4
|
-
"version": "2.1.0-alpha.
|
|
4
|
+
"version": "2.1.0-alpha.35",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"main": "./dist/production/index.js",
|
|
@@ -30,20 +30,20 @@
|
|
|
30
30
|
},
|
|
31
31
|
"repository": {
|
|
32
32
|
"type": "git",
|
|
33
|
-
"url": "https://github.com/contember/
|
|
33
|
+
"url": "git+https://github.com/contember/contember.git",
|
|
34
34
|
"directory": "packages/react-board"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@contember/react-binding": "
|
|
38
|
-
"@contember/react-multipass-rendering": "
|
|
39
|
-
"@contember/react-utils": "
|
|
37
|
+
"@contember/react-binding": "workspace:*",
|
|
38
|
+
"@contember/react-multipass-rendering": "workspace:*",
|
|
39
|
+
"@contember/react-utils": "workspace:*"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"react": "
|
|
43
|
-
"react-dom": "
|
|
42
|
+
"react": "catalog:",
|
|
43
|
+
"react-dom": "catalog:"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"react": "
|
|
47
|
-
"react-dom": "
|
|
46
|
+
"react": "catalog:",
|
|
47
|
+
"react-dom": "catalog:"
|
|
48
48
|
}
|
|
49
49
|
}
|
package/src/components/Board.tsx
CHANGED
|
@@ -23,7 +23,6 @@ export type BoardProps =
|
|
|
23
23
|
| BoardQualifiedStaticProps
|
|
24
24
|
| BoardRelativeStaticProps
|
|
25
25
|
|
|
26
|
-
|
|
27
26
|
export const Board = Component<BoardProps>(props => {
|
|
28
27
|
if ('entities' in props) {
|
|
29
28
|
if (Array.isArray(props.columns)) {
|
|
@@ -54,170 +53,180 @@ export type BoardStaticColumnsBindingProps = {
|
|
|
54
53
|
discriminationField: string | SugaredRelativeSingleField
|
|
55
54
|
}
|
|
56
55
|
|
|
57
|
-
export type BoardCommonProps =
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export type BoardQualifiedItemsProps =
|
|
65
|
-
& Pick<SugaredQualifiedEntityList, 'entities' | 'orderBy' | 'limit' | 'offset'>
|
|
66
|
-
|
|
56
|
+
export type BoardCommonProps = {
|
|
57
|
+
children: ReactNode
|
|
58
|
+
sortableBy?: string | SugaredRelativeSingleField
|
|
59
|
+
sortScope?: 'column' | 'board'
|
|
60
|
+
}
|
|
67
61
|
|
|
68
|
-
export type
|
|
69
|
-
& Pick<SugaredRelativeEntityList, 'field' | 'orderBy' | 'limit' | 'offset'>
|
|
62
|
+
export type BoardQualifiedItemsProps = Pick<SugaredQualifiedEntityList, 'entities' | 'orderBy' | 'limit' | 'offset'>
|
|
70
63
|
|
|
64
|
+
export type BoardRelativeItemsProps = Pick<SugaredRelativeEntityList, 'field' | 'orderBy' | 'limit' | 'offset'>
|
|
71
65
|
|
|
72
66
|
export type BoardQualifiedDynamicProps =
|
|
73
67
|
& BoardCommonProps
|
|
74
68
|
& BoardDynamicColumnsBindingProps
|
|
75
69
|
& BoardQualifiedItemsProps
|
|
76
70
|
|
|
77
|
-
const BoardQualifiedDynamic = Component<BoardQualifiedDynamicProps>(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
<
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
71
|
+
const BoardQualifiedDynamic = Component<BoardQualifiedDynamicProps>(
|
|
72
|
+
({ entities, orderBy, limit, offset, columns, columnsSortableBy, discriminationField, sortableBy, sortScope, children }) => {
|
|
73
|
+
const itemsAccessor = useEntityListSubTree({ entities, orderBy, limit, offset })
|
|
74
|
+
const columnsAccessor = useEntityListSubTree({ entities: columns })
|
|
75
|
+
const [data, methods] = useDynamicBoard({
|
|
76
|
+
columnEntities: columnsAccessor,
|
|
77
|
+
itemEntities: itemsAccessor,
|
|
78
|
+
columns,
|
|
79
|
+
sortableBy,
|
|
80
|
+
sortScope,
|
|
81
|
+
columnsSortableBy,
|
|
82
|
+
discriminationField,
|
|
83
|
+
})
|
|
84
|
+
return (
|
|
85
|
+
<BoardMethodsContext.Provider value={methods}>
|
|
86
|
+
<BoardColumnsContext.Provider value={data.columns}>
|
|
87
|
+
{children}
|
|
88
|
+
</BoardColumnsContext.Provider>
|
|
89
|
+
</BoardMethodsContext.Provider>
|
|
90
|
+
)
|
|
91
|
+
},
|
|
92
|
+
({ entities, orderBy, limit, offset, columns, discriminationField, sortableBy, columnsSortableBy, children }, env) => {
|
|
93
|
+
const childrenByType = boardAnalyzer.processChildren(children, env)
|
|
94
|
+
const columnChildren = childrenByType.filter(it => it.type === 'column').map(it => it.children)
|
|
95
|
+
const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
<EntityListSubTree entities={entities} orderBy={orderBy} limit={limit} offset={offset}>
|
|
100
|
+
<HasOne {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
|
|
101
|
+
{sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
|
|
102
|
+
{itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
|
|
103
|
+
</EntityListSubTree>
|
|
104
|
+
<EntityListSubTree entities={columns}>
|
|
105
|
+
{columnsSortableBy && <Field {...typeof columnsSortableBy === 'string' ? { field: columnsSortableBy } : columnsSortableBy} />}
|
|
106
|
+
{columnChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
|
|
107
|
+
</EntityListSubTree>
|
|
108
|
+
</>
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
)
|
|
115
112
|
|
|
116
113
|
export type BoardRelativeDynamicProps =
|
|
117
114
|
& BoardCommonProps
|
|
118
115
|
& BoardDynamicColumnsBindingProps
|
|
119
116
|
& BoardRelativeItemsProps
|
|
120
117
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
},
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
118
|
+
const RelativeDynamicBoard = Component<BoardRelativeDynamicProps>(
|
|
119
|
+
({ field, orderBy, limit, offset, columns, columnsSortableBy, discriminationField, sortableBy, sortScope, children }) => {
|
|
120
|
+
const itemsAccessor = useEntityList({ field, orderBy, limit, offset })
|
|
121
|
+
const columnsAccessor = useEntityListSubTree({ entities: columns })
|
|
122
|
+
const [data, methods] = useDynamicBoard({
|
|
123
|
+
columnEntities: columnsAccessor,
|
|
124
|
+
itemEntities: itemsAccessor,
|
|
125
|
+
columns,
|
|
126
|
+
sortableBy,
|
|
127
|
+
sortScope,
|
|
128
|
+
columnsSortableBy,
|
|
129
|
+
discriminationField,
|
|
130
|
+
})
|
|
131
|
+
return (
|
|
132
|
+
<BoardMethodsContext.Provider value={methods}>
|
|
133
|
+
<BoardColumnsContext.Provider value={data.columns}>
|
|
134
|
+
{children}
|
|
135
|
+
</BoardColumnsContext.Provider>
|
|
136
|
+
</BoardMethodsContext.Provider>
|
|
137
|
+
)
|
|
138
|
+
},
|
|
139
|
+
({ field, orderBy, limit, offset, columns, discriminationField, sortableBy, columnsSortableBy, children }, env) => {
|
|
140
|
+
const childrenByType = boardAnalyzer.processChildren(children, env)
|
|
141
|
+
const columnChildren = childrenByType.filter(it => it.type === 'column').map(it => it.children)
|
|
142
|
+
const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
|
|
143
|
+
return (
|
|
144
|
+
<>
|
|
145
|
+
<HasMany field={field} orderBy={orderBy} limit={limit} offset={offset}>
|
|
146
|
+
<HasOne {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
|
|
147
|
+
{sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
|
|
148
|
+
{itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
|
|
149
|
+
</HasMany>
|
|
150
|
+
<EntityListSubTree entities={columns}>
|
|
151
|
+
{columnsSortableBy && <Field {...typeof columnsSortableBy === 'string' ? { field: columnsSortableBy } : columnsSortableBy} />}
|
|
152
|
+
{columnChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
|
|
153
|
+
</EntityListSubTree>
|
|
154
|
+
</>
|
|
155
|
+
)
|
|
156
|
+
},
|
|
157
|
+
)
|
|
157
158
|
export type BoardQualifiedStaticProps =
|
|
158
159
|
& BoardCommonProps
|
|
159
160
|
& BoardStaticColumnsBindingProps
|
|
160
161
|
& BoardQualifiedItemsProps
|
|
161
162
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
},
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
163
|
+
const BoardQualifiedStatic = Component<BoardQualifiedStaticProps>(
|
|
164
|
+
({ entities, orderBy, limit, offset, columns, discriminationField, sortableBy, sortScope, children }) => {
|
|
165
|
+
const itemsAccessor = useEntityListSubTree({ entities, orderBy, limit, offset })
|
|
166
|
+
const [data, methods] = useStaticBoard({
|
|
167
|
+
itemEntities: itemsAccessor,
|
|
168
|
+
columns,
|
|
169
|
+
sortableBy,
|
|
170
|
+
sortScope,
|
|
171
|
+
discriminationField,
|
|
172
|
+
})
|
|
173
|
+
return (
|
|
174
|
+
<BoardMethodsContext.Provider value={methods}>
|
|
175
|
+
<BoardColumnsContext.Provider value={data.columns}>
|
|
176
|
+
{children}
|
|
177
|
+
</BoardColumnsContext.Provider>
|
|
178
|
+
</BoardMethodsContext.Provider>
|
|
179
|
+
)
|
|
180
|
+
},
|
|
181
|
+
({ entities, orderBy, limit, offset, columns, discriminationField, sortableBy, children }, env) => {
|
|
182
|
+
const childrenByType = boardAnalyzer.processChildren(children, env)
|
|
183
|
+
const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
|
|
184
|
+
return (
|
|
185
|
+
<>
|
|
186
|
+
<EntityListSubTree entities={entities} orderBy={orderBy} limit={limit} offset={offset}>
|
|
187
|
+
<Field {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
|
|
188
|
+
{sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
|
|
189
|
+
{itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
|
|
190
|
+
</EntityListSubTree>
|
|
191
|
+
</>
|
|
192
|
+
)
|
|
193
|
+
},
|
|
194
|
+
)
|
|
191
195
|
|
|
192
196
|
export type BoardRelativeStaticProps =
|
|
193
197
|
& BoardCommonProps
|
|
194
198
|
& BoardStaticColumnsBindingProps
|
|
195
199
|
& BoardRelativeItemsProps
|
|
196
200
|
|
|
197
|
-
const RelativeStaticBoard = Component<BoardRelativeStaticProps>(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
<
|
|
209
|
-
{
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
})
|
|
201
|
+
const RelativeStaticBoard = Component<BoardRelativeStaticProps>(
|
|
202
|
+
({ field, orderBy, limit, offset, columns, discriminationField, sortableBy, sortScope, children }) => {
|
|
203
|
+
const itemsAccessor = useEntityList({ field, orderBy, limit, offset })
|
|
204
|
+
const [data, methods] = useStaticBoard({
|
|
205
|
+
itemEntities: itemsAccessor,
|
|
206
|
+
columns,
|
|
207
|
+
sortableBy,
|
|
208
|
+
sortScope,
|
|
209
|
+
discriminationField,
|
|
210
|
+
})
|
|
211
|
+
return (
|
|
212
|
+
<BoardMethodsContext.Provider value={methods}>
|
|
213
|
+
<BoardColumnsContext.Provider value={data.columns}>
|
|
214
|
+
{children}
|
|
215
|
+
</BoardColumnsContext.Provider>
|
|
216
|
+
</BoardMethodsContext.Provider>
|
|
217
|
+
)
|
|
218
|
+
},
|
|
219
|
+
({ field, orderBy, limit, offset, columns, discriminationField, sortableBy, children }, env) => {
|
|
220
|
+
const childrenByType = boardAnalyzer.processChildren(children, env)
|
|
221
|
+
const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
|
|
222
|
+
return (
|
|
223
|
+
<>
|
|
224
|
+
<HasMany field={field} orderBy={orderBy} limit={limit} offset={offset}>
|
|
225
|
+
<Field {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
|
|
226
|
+
{sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
|
|
227
|
+
{itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
|
|
228
|
+
</HasMany>
|
|
229
|
+
</>
|
|
230
|
+
)
|
|
231
|
+
},
|
|
232
|
+
)
|
|
@@ -10,22 +10,26 @@ export const BoardEachColumn = ({ children }: {
|
|
|
10
10
|
}) => {
|
|
11
11
|
const columns = useBoardColumns()
|
|
12
12
|
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
{
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{columns.map(column => {
|
|
16
|
+
if (column.id === BoardNullColumnPlaceholder) {
|
|
17
|
+
return null
|
|
18
|
+
}
|
|
19
|
+
return (
|
|
20
|
+
<BoardCurrentColumnContext.Provider value={column} key={column.id}>
|
|
21
|
+
{isEntityAccessor(column.value)
|
|
22
|
+
? (
|
|
23
|
+
<Entity accessor={column.value}>
|
|
24
|
+
{children}
|
|
25
|
+
</Entity>
|
|
26
|
+
)
|
|
27
|
+
: children}
|
|
28
|
+
</BoardCurrentColumnContext.Provider>
|
|
29
|
+
)
|
|
30
|
+
})}
|
|
31
|
+
</>
|
|
32
|
+
)
|
|
29
33
|
}
|
|
30
34
|
BoardEachColumn.staticRender = ({ children }: { children: ReactNode }) => {
|
|
31
35
|
return <BoardColumn>{children}</BoardColumn>
|
|
@@ -9,19 +9,21 @@ export const BoardEachItem = ({ children }: {
|
|
|
9
9
|
}) => {
|
|
10
10
|
const currentColumn = useBoardCurrentColumn()
|
|
11
11
|
|
|
12
|
-
return
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
return (
|
|
13
|
+
<>
|
|
14
|
+
{currentColumn.items.map((item, index) => {
|
|
15
|
+
return (
|
|
16
|
+
<BoardEachItemInner
|
|
17
|
+
key={item.id}
|
|
18
|
+
item={item}
|
|
19
|
+
column={currentColumn}
|
|
20
|
+
>
|
|
21
|
+
{children}
|
|
22
|
+
</BoardEachItemInner>
|
|
23
|
+
)
|
|
24
|
+
})}
|
|
25
|
+
</>
|
|
26
|
+
)
|
|
25
27
|
}
|
|
26
28
|
BoardEachItem.staticRender = ({ children }: { children: ReactNode }) => {
|
|
27
29
|
return <BoardItem>{children}</BoardItem>
|
|
@@ -31,7 +33,6 @@ const BoardEachItemInner = ({ children, item, column }: {
|
|
|
31
33
|
children: ReactNode
|
|
32
34
|
column: BoardColumnNode
|
|
33
35
|
item: BoardItemNode
|
|
34
|
-
|
|
35
36
|
}) => {
|
|
36
37
|
const itemWithColumn = useMemo(() => ({
|
|
37
38
|
...item,
|
package/src/contexts.ts
CHANGED
|
@@ -6,7 +6,6 @@ const _BoardMethodsContext = createRequiredContext<BoardMethods<any>>('BoardMeth
|
|
|
6
6
|
export const BoardMethodsContext = _BoardMethodsContext[0]
|
|
7
7
|
export const useBoardMethods = _BoardMethodsContext[1] as <T extends BoardColumnValue = BoardColumnValue>() => BoardMethods<T>
|
|
8
8
|
|
|
9
|
-
|
|
10
9
|
const BoardColumnsContext_ = createRequiredContext<BoardColumnNode[]>('BoardColumnsContext')
|
|
11
10
|
/** @internal */
|
|
12
11
|
export const BoardColumnsContext = BoardColumnsContext_[0]
|
|
@@ -5,13 +5,13 @@ import {
|
|
|
5
5
|
EntityAccessor,
|
|
6
6
|
EntityListAccessor,
|
|
7
7
|
RelativeSingleField,
|
|
8
|
-
repairEntitiesOrder,
|
|
8
|
+
repairEntitiesOrder,
|
|
9
|
+
sortEntities,
|
|
9
10
|
} from '@contember/react-binding'
|
|
10
11
|
import { BoardColumnKey, UseGroupItemsByColumn } from './useGroupItemsByColumn'
|
|
11
12
|
import { arrayMove } from '../utils/arrayMove'
|
|
12
13
|
import { BoardAddItemMethod, BoardColumnValue, BoardMethods, BoardMoveItemMethod, BoardRemoveItemMethod } from '../types'
|
|
13
14
|
|
|
14
|
-
|
|
15
15
|
export type UseBoardItemsMethodsProps<ColumnValue extends BoardColumnValue> = {
|
|
16
16
|
itemEntities: EntityListAccessor
|
|
17
17
|
connectItemToColumn: (item: EntityAccessor, column: ColumnValue | null) => void
|
|
@@ -33,7 +33,6 @@ export const useBoardItemsMethods = <ColumnValue extends BoardColumnValue>({
|
|
|
33
33
|
columnIdGetter,
|
|
34
34
|
sortScope = 'column',
|
|
35
35
|
}: UseBoardItemsMethodsProps<ColumnValue>): BoardItemsMethods<ColumnValue> => {
|
|
36
|
-
|
|
37
36
|
const itemEntitiesEntitiesGetter = itemEntities.getAccessor
|
|
38
37
|
|
|
39
38
|
const getSortScopeItems = useCallback((column: string | number | null) => {
|
|
@@ -77,7 +76,6 @@ export const useBoardItemsMethods = <ColumnValue extends BoardColumnValue>({
|
|
|
77
76
|
|
|
78
77
|
const resolvedIndex = resolveScopedIndex(columnId, index) ?? sortScopeItems.length
|
|
79
78
|
|
|
80
|
-
|
|
81
79
|
itemEntities.createNewEntity((getEntity, options) => {
|
|
82
80
|
sortScopeItems.splice(resolvedIndex, 0, getEntity())
|
|
83
81
|
repairEntitiesOrder(desugaredSortableByField, sortScopeItems)
|
|
@@ -85,7 +83,6 @@ export const useBoardItemsMethods = <ColumnValue extends BoardColumnValue>({
|
|
|
85
83
|
})
|
|
86
84
|
}, [columnIdGetter, connectItemToColumn, desugaredSortableByField, getSortScopeItems, itemEntitiesEntitiesGetter, resolveScopedIndex])
|
|
87
85
|
|
|
88
|
-
|
|
89
86
|
const moveItem = useMemo<BoardMoveItemMethod<ColumnValue> | undefined>(() => {
|
|
90
87
|
if (!desugaredSortableByField) {
|
|
91
88
|
return undefined
|
|
@@ -105,7 +102,6 @@ export const useBoardItemsMethods = <ColumnValue extends BoardColumnValue>({
|
|
|
105
102
|
return
|
|
106
103
|
}
|
|
107
104
|
|
|
108
|
-
|
|
109
105
|
// sort scope is column
|
|
110
106
|
const itemEntities = itemEntitiesEntitiesGetter()
|
|
111
107
|
const groupedItems = groupItemsByColumn(itemEntities)
|
|
@@ -118,9 +114,18 @@ export const useBoardItemsMethods = <ColumnValue extends BoardColumnValue>({
|
|
|
118
114
|
const newColumnItems = groupedItems.get(columnId)?.slice() ?? []
|
|
119
115
|
newColumnItems.splice(index, 0, entity)
|
|
120
116
|
repairEntitiesOrder(desugaredSortableByField, newColumnItems)
|
|
121
|
-
|
|
122
117
|
}
|
|
123
|
-
}, [
|
|
118
|
+
}, [
|
|
119
|
+
columnIdGetter,
|
|
120
|
+
connectItemToColumn,
|
|
121
|
+
desugaredSortableByField,
|
|
122
|
+
getDiscriminatorValue,
|
|
123
|
+
getSortScopeItems,
|
|
124
|
+
groupItemsByColumn,
|
|
125
|
+
itemEntitiesEntitiesGetter,
|
|
126
|
+
resolveScopedIndex,
|
|
127
|
+
sortScope,
|
|
128
|
+
])
|
|
124
129
|
|
|
125
130
|
const removeItem = useCallback<BoardRemoveItemMethod>(entity => {
|
|
126
131
|
if (desugaredSortableByField) {
|
|
@@ -10,7 +10,6 @@ export const useCreateBoardColumns = <ColumnValue extends BoardColumnValue>({ gr
|
|
|
10
10
|
columnIdGetter: (column: ColumnValue) => string | number
|
|
11
11
|
groupItemsByColumn: UseGroupItemsByColumn
|
|
12
12
|
}): BoardColumnNode<ColumnValue>[] => {
|
|
13
|
-
|
|
14
13
|
return useMemo(() => {
|
|
15
14
|
const itemsByColumn = groupItemsByColumn(items)
|
|
16
15
|
|
|
@@ -25,7 +24,6 @@ export const useCreateBoardColumns = <ColumnValue extends BoardColumnValue>({ gr
|
|
|
25
24
|
]
|
|
26
25
|
let index = 0
|
|
27
26
|
|
|
28
|
-
|
|
29
27
|
for (const column of columns) {
|
|
30
28
|
result.push({
|
|
31
29
|
id: columnIdGetter(column),
|
|
@@ -35,6 +33,5 @@ export const useCreateBoardColumns = <ColumnValue extends BoardColumnValue>({ gr
|
|
|
35
33
|
})
|
|
36
34
|
}
|
|
37
35
|
return result
|
|
38
|
-
|
|
39
36
|
}, [columnIdGetter, columns, groupItemsByColumn, items])
|
|
40
37
|
}
|
|
@@ -10,12 +10,7 @@ import {
|
|
|
10
10
|
useDesugaredRelativeSingleEntity,
|
|
11
11
|
useDesugaredRelativeSingleField,
|
|
12
12
|
} from '@contember/react-binding'
|
|
13
|
-
import {
|
|
14
|
-
BoardAddColumnMethod,
|
|
15
|
-
BoardMethods,
|
|
16
|
-
BoardMoveColumnMethod,
|
|
17
|
-
BoardRemoveColumnMethod,
|
|
18
|
-
} from '../types'
|
|
13
|
+
import { BoardAddColumnMethod, BoardMethods, BoardMoveColumnMethod, BoardRemoveColumnMethod } from '../types'
|
|
19
14
|
import { useGroupItemsByColumn } from './useGroupItemsByColumn'
|
|
20
15
|
import { useCreateBoardColumns } from './useCreateBoardColumns'
|
|
21
16
|
import { arrayMove } from '../utils/arrayMove'
|
|
@@ -23,7 +18,6 @@ import { useBoardItemsMethods } from './useBoardItemsMethods'
|
|
|
23
18
|
import { BoardData } from '../types/BoardData'
|
|
24
19
|
import { BoardCommonProps, BoardDynamicColumnsBindingProps } from '../components'
|
|
25
20
|
|
|
26
|
-
|
|
27
21
|
export type UseDynamicBoardBindingProps =
|
|
28
22
|
& Omit<BoardCommonProps, 'children'>
|
|
29
23
|
& BoardDynamicColumnsBindingProps
|
|
@@ -46,15 +40,13 @@ export const useDynamicBoard = ({
|
|
|
46
40
|
columnEntities,
|
|
47
41
|
itemEntities,
|
|
48
42
|
}: UseDynamicBoardBindingProps): [BoardData<EntityAccessor>, BoardMethods<EntityAccessor>] => {
|
|
49
|
-
|
|
50
43
|
const desugaredSortableByField = useDesugaredRelativeSingleField(sortableBy)
|
|
51
44
|
const desugaredColumnSortableByField = useDesugaredRelativeSingleField(columnsSortableBy)
|
|
52
45
|
const desugaredDiscriminationField = useDesugaredRelativeSingleEntity(discriminationField)
|
|
53
46
|
|
|
54
47
|
const columnEntitiesGetter = columnEntities.getAccessor
|
|
55
48
|
|
|
56
|
-
|
|
57
|
-
const exitingColumnIds = useMemo(() => new Set(Array.from(columnEntities).map(it => it.id)), [columnEntities])
|
|
49
|
+
const exitingColumnIds = useMemo(() => new Set(Array.from(columnEntities).map((it: EntityAccessor) => it.id)), [columnEntities])
|
|
58
50
|
|
|
59
51
|
const getDiscriminatorValue = useCallback((entity: EntityAccessor) => {
|
|
60
52
|
const entityId = entity.getEntity(desugaredDiscriminationField).id
|
|
@@ -91,10 +83,8 @@ export const useDynamicBoard = ({
|
|
|
91
83
|
} else {
|
|
92
84
|
parentEntity.disconnectEntityAtField(hasOne[hasOne.length - 1].field)
|
|
93
85
|
}
|
|
94
|
-
|
|
95
86
|
}, [desugaredDiscriminationField.hasOneRelationPath])
|
|
96
87
|
|
|
97
|
-
|
|
98
88
|
const moveColumn = useMemo<BoardMoveColumnMethod | undefined>(() => {
|
|
99
89
|
if (!desugaredColumnSortableByField) {
|
|
100
90
|
return undefined
|
|
@@ -107,7 +97,6 @@ export const useDynamicBoard = ({
|
|
|
107
97
|
}
|
|
108
98
|
}, [columnEntitiesGetter, desugaredColumnSortableByField, getSortedColumns])
|
|
109
99
|
|
|
110
|
-
|
|
111
100
|
const removeColumn = useCallback<BoardRemoveColumnMethod>(entity => {
|
|
112
101
|
entity.deleteEntity()
|
|
113
102
|
if (desugaredSortableByField) {
|
|
@@ -3,7 +3,10 @@ import { useCallback } from 'react'
|
|
|
3
3
|
|
|
4
4
|
export type BoardColumnKey = string | EntityId | null
|
|
5
5
|
export type UseGroupItemsByColumn = (itemEntities: EntityListAccessor) => Map<BoardColumnKey, EntityAccessor[]>
|
|
6
|
-
export const useGroupItemsByColumn = (
|
|
6
|
+
export const useGroupItemsByColumn = (
|
|
7
|
+
getDiscriminatorValue: (entity: EntityAccessor) => BoardColumnKey,
|
|
8
|
+
sortBy: RelativeSingleField | undefined,
|
|
9
|
+
): UseGroupItemsByColumn => {
|
|
7
10
|
return useCallback((itemEntities: EntityListAccessor) => {
|
|
8
11
|
const itemsByColumn = new Map<BoardColumnKey, EntityAccessor[]>()
|
|
9
12
|
|
|
@@ -7,7 +7,6 @@ import { useBoardItemsMethods } from './useBoardItemsMethods'
|
|
|
7
7
|
import { BoardData } from '../types/BoardData'
|
|
8
8
|
import { BoardCommonProps, BoardStaticColumnsBindingProps } from '../components'
|
|
9
9
|
|
|
10
|
-
|
|
11
10
|
export type UseStaticBoardBindingProps =
|
|
12
11
|
& Omit<BoardCommonProps, 'children'>
|
|
13
12
|
& BoardStaticColumnsBindingProps
|
|
@@ -22,7 +21,6 @@ export const useStaticBoard = ({
|
|
|
22
21
|
discriminationField,
|
|
23
22
|
itemEntities,
|
|
24
23
|
}: UseStaticBoardBindingProps): [BoardData<BoardStaticColumnValue>, BoardMethods<BoardStaticColumnValue>] => {
|
|
25
|
-
|
|
26
24
|
const desugaredSortableByField = useDesugaredRelativeSingleField(sortableBy)
|
|
27
25
|
const desugaredDiscriminationField = useDesugaredRelativeSingleField(discriminationField)
|
|
28
26
|
|