@contember/react-board 2.1.0-alpha.3 → 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.
Files changed (195) hide show
  1. package/package.json +9 -9
  2. package/src/components/Board.tsx +152 -143
  3. package/src/components/BoardEachColumn.tsx +20 -16
  4. package/src/components/BoardEachItem.tsx +15 -14
  5. package/src/contexts.ts +0 -1
  6. package/src/internal/useBoardItemsMethods.ts +13 -8
  7. package/src/internal/useCreateBoardColumns.ts +0 -3
  8. package/src/internal/useDynamicBoard.ts +2 -13
  9. package/src/internal/useGroupItemsByColumn.ts +4 -1
  10. package/src/internal/useStaticBoard.ts +0 -2
  11. package/src/types/BoardData.ts +3 -4
  12. package/src/types/BoardMethods.ts +5 -1
  13. package/dist/development/index.cjs +0 -28
  14. package/dist/development/index.cjs.map +0 -1
  15. package/dist/development/index.js +0 -28
  16. package/dist/development/index.js.map +0 -1
  17. package/dist/development/src/components/Board.cjs +0 -274
  18. package/dist/development/src/components/Board.cjs.map +0 -1
  19. package/dist/development/src/components/Board.js +0 -274
  20. package/dist/development/src/components/Board.js.map +0 -1
  21. package/dist/development/src/components/BoardColumn.cjs +0 -7
  22. package/dist/development/src/components/BoardColumn.cjs.map +0 -1
  23. package/dist/development/src/components/BoardColumn.js +0 -7
  24. package/dist/development/src/components/BoardColumn.js.map +0 -1
  25. package/dist/development/src/components/BoardColumnLabel.cjs +0 -14
  26. package/dist/development/src/components/BoardColumnLabel.cjs.map +0 -1
  27. package/dist/development/src/components/BoardColumnLabel.js +0 -14
  28. package/dist/development/src/components/BoardColumnLabel.js.map +0 -1
  29. package/dist/development/src/components/BoardEachColumn.cjs +0 -37
  30. package/dist/development/src/components/BoardEachColumn.cjs.map +0 -1
  31. package/dist/development/src/components/BoardEachColumn.js +0 -37
  32. package/dist/development/src/components/BoardEachColumn.js.map +0 -1
  33. package/dist/development/src/components/BoardEachItem.cjs +0 -56
  34. package/dist/development/src/components/BoardEachItem.cjs.map +0 -1
  35. package/dist/development/src/components/BoardEachItem.js +0 -56
  36. package/dist/development/src/components/BoardEachItem.js.map +0 -1
  37. package/dist/development/src/components/BoardItem.cjs +0 -8
  38. package/dist/development/src/components/BoardItem.cjs.map +0 -1
  39. package/dist/development/src/components/BoardItem.js +0 -8
  40. package/dist/development/src/components/BoardItem.js.map +0 -1
  41. package/dist/development/src/components/BoardNullColumn.cjs +0 -18
  42. package/dist/development/src/components/BoardNullColumn.cjs.map +0 -1
  43. package/dist/development/src/components/BoardNullColumn.js +0 -18
  44. package/dist/development/src/components/BoardNullColumn.js.map +0 -1
  45. package/dist/development/src/const.cjs +0 -5
  46. package/dist/development/src/const.cjs.map +0 -1
  47. package/dist/development/src/const.js +0 -5
  48. package/dist/development/src/const.js.map +0 -1
  49. package/dist/development/src/contexts.cjs +0 -24
  50. package/dist/development/src/contexts.cjs.map +0 -1
  51. package/dist/development/src/contexts.js +0 -24
  52. package/dist/development/src/contexts.js.map +0 -1
  53. package/dist/development/src/internal/boardAnalyzer.cjs +0 -13
  54. package/dist/development/src/internal/boardAnalyzer.cjs.map +0 -1
  55. package/dist/development/src/internal/boardAnalyzer.js +0 -13
  56. package/dist/development/src/internal/boardAnalyzer.js.map +0 -1
  57. package/dist/development/src/internal/useBoardItemsMethods.cjs +0 -100
  58. package/dist/development/src/internal/useBoardItemsMethods.cjs.map +0 -1
  59. package/dist/development/src/internal/useBoardItemsMethods.js +0 -100
  60. package/dist/development/src/internal/useBoardItemsMethods.js.map +0 -1
  61. package/dist/development/src/internal/useCreateBoardColumns.cjs +0 -30
  62. package/dist/development/src/internal/useCreateBoardColumns.cjs.map +0 -1
  63. package/dist/development/src/internal/useCreateBoardColumns.js +0 -30
  64. package/dist/development/src/internal/useCreateBoardColumns.js.map +0 -1
  65. package/dist/development/src/internal/useDynamicBoard.cjs +0 -95
  66. package/dist/development/src/internal/useDynamicBoard.cjs.map +0 -1
  67. package/dist/development/src/internal/useDynamicBoard.js +0 -95
  68. package/dist/development/src/internal/useDynamicBoard.js.map +0 -1
  69. package/dist/development/src/internal/useGroupItemsByColumn.cjs +0 -19
  70. package/dist/development/src/internal/useGroupItemsByColumn.cjs.map +0 -1
  71. package/dist/development/src/internal/useGroupItemsByColumn.js +0 -19
  72. package/dist/development/src/internal/useGroupItemsByColumn.js.map +0 -1
  73. package/dist/development/src/internal/useStaticBoard.cjs +0 -43
  74. package/dist/development/src/internal/useStaticBoard.cjs.map +0 -1
  75. package/dist/development/src/internal/useStaticBoard.js +0 -43
  76. package/dist/development/src/internal/useStaticBoard.js.map +0 -1
  77. package/dist/development/src/utils/arrayMove.cjs +0 -9
  78. package/dist/development/src/utils/arrayMove.cjs.map +0 -1
  79. package/dist/development/src/utils/arrayMove.js +0 -9
  80. package/dist/development/src/utils/arrayMove.js.map +0 -1
  81. package/dist/production/index.cjs +0 -28
  82. package/dist/production/index.cjs.map +0 -1
  83. package/dist/production/index.js +0 -28
  84. package/dist/production/index.js.map +0 -1
  85. package/dist/production/src/components/Board.cjs +0 -122
  86. package/dist/production/src/components/Board.cjs.map +0 -1
  87. package/dist/production/src/components/Board.js +0 -122
  88. package/dist/production/src/components/Board.js.map +0 -1
  89. package/dist/production/src/components/BoardColumn.cjs +0 -7
  90. package/dist/production/src/components/BoardColumn.cjs.map +0 -1
  91. package/dist/production/src/components/BoardColumn.js +0 -7
  92. package/dist/production/src/components/BoardColumn.js.map +0 -1
  93. package/dist/production/src/components/BoardColumnLabel.cjs +0 -10
  94. package/dist/production/src/components/BoardColumnLabel.cjs.map +0 -1
  95. package/dist/production/src/components/BoardColumnLabel.js +0 -10
  96. package/dist/production/src/components/BoardColumnLabel.js.map +0 -1
  97. package/dist/production/src/components/BoardEachColumn.cjs +0 -21
  98. package/dist/production/src/components/BoardEachColumn.cjs.map +0 -1
  99. package/dist/production/src/components/BoardEachColumn.js +0 -21
  100. package/dist/production/src/components/BoardEachColumn.js.map +0 -1
  101. package/dist/production/src/components/BoardEachItem.cjs +0 -33
  102. package/dist/production/src/components/BoardEachItem.cjs.map +0 -1
  103. package/dist/production/src/components/BoardEachItem.js +0 -33
  104. package/dist/production/src/components/BoardEachItem.js.map +0 -1
  105. package/dist/production/src/components/BoardItem.cjs +0 -8
  106. package/dist/production/src/components/BoardItem.cjs.map +0 -1
  107. package/dist/production/src/components/BoardItem.js +0 -8
  108. package/dist/production/src/components/BoardItem.js.map +0 -1
  109. package/dist/production/src/components/BoardNullColumn.cjs +0 -14
  110. package/dist/production/src/components/BoardNullColumn.cjs.map +0 -1
  111. package/dist/production/src/components/BoardNullColumn.js +0 -14
  112. package/dist/production/src/components/BoardNullColumn.js.map +0 -1
  113. package/dist/production/src/const.cjs +0 -5
  114. package/dist/production/src/const.cjs.map +0 -1
  115. package/dist/production/src/const.js +0 -5
  116. package/dist/production/src/const.js.map +0 -1
  117. package/dist/production/src/contexts.cjs +0 -24
  118. package/dist/production/src/contexts.cjs.map +0 -1
  119. package/dist/production/src/contexts.js +0 -24
  120. package/dist/production/src/contexts.js.map +0 -1
  121. package/dist/production/src/internal/boardAnalyzer.cjs +0 -13
  122. package/dist/production/src/internal/boardAnalyzer.cjs.map +0 -1
  123. package/dist/production/src/internal/boardAnalyzer.js +0 -13
  124. package/dist/production/src/internal/boardAnalyzer.js.map +0 -1
  125. package/dist/production/src/internal/useBoardItemsMethods.cjs +0 -100
  126. package/dist/production/src/internal/useBoardItemsMethods.cjs.map +0 -1
  127. package/dist/production/src/internal/useBoardItemsMethods.js +0 -100
  128. package/dist/production/src/internal/useBoardItemsMethods.js.map +0 -1
  129. package/dist/production/src/internal/useCreateBoardColumns.cjs +0 -30
  130. package/dist/production/src/internal/useCreateBoardColumns.cjs.map +0 -1
  131. package/dist/production/src/internal/useCreateBoardColumns.js +0 -30
  132. package/dist/production/src/internal/useCreateBoardColumns.js.map +0 -1
  133. package/dist/production/src/internal/useDynamicBoard.cjs +0 -95
  134. package/dist/production/src/internal/useDynamicBoard.cjs.map +0 -1
  135. package/dist/production/src/internal/useDynamicBoard.js +0 -95
  136. package/dist/production/src/internal/useDynamicBoard.js.map +0 -1
  137. package/dist/production/src/internal/useGroupItemsByColumn.cjs +0 -19
  138. package/dist/production/src/internal/useGroupItemsByColumn.cjs.map +0 -1
  139. package/dist/production/src/internal/useGroupItemsByColumn.js +0 -19
  140. package/dist/production/src/internal/useGroupItemsByColumn.js.map +0 -1
  141. package/dist/production/src/internal/useStaticBoard.cjs +0 -43
  142. package/dist/production/src/internal/useStaticBoard.cjs.map +0 -1
  143. package/dist/production/src/internal/useStaticBoard.js +0 -43
  144. package/dist/production/src/internal/useStaticBoard.js.map +0 -1
  145. package/dist/production/src/utils/arrayMove.cjs +0 -9
  146. package/dist/production/src/utils/arrayMove.cjs.map +0 -1
  147. package/dist/production/src/utils/arrayMove.js +0 -9
  148. package/dist/production/src/utils/arrayMove.js.map +0 -1
  149. package/dist/types/components/Board.d.ts +0 -28
  150. package/dist/types/components/Board.d.ts.map +0 -1
  151. package/dist/types/components/BoardColumn.d.ts +0 -5
  152. package/dist/types/components/BoardColumn.d.ts.map +0 -1
  153. package/dist/types/components/BoardColumnLabel.d.ts +0 -2
  154. package/dist/types/components/BoardColumnLabel.d.ts.map +0 -1
  155. package/dist/types/components/BoardEachColumn.d.ts +0 -10
  156. package/dist/types/components/BoardEachColumn.d.ts.map +0 -1
  157. package/dist/types/components/BoardEachItem.d.ts +0 -10
  158. package/dist/types/components/BoardEachItem.d.ts.map +0 -1
  159. package/dist/types/components/BoardItem.d.ts +0 -8
  160. package/dist/types/components/BoardItem.d.ts.map +0 -1
  161. package/dist/types/components/BoardNullColumn.d.ts +0 -7
  162. package/dist/types/components/BoardNullColumn.d.ts.map +0 -1
  163. package/dist/types/components/index.d.ts +0 -8
  164. package/dist/types/components/index.d.ts.map +0 -1
  165. package/dist/types/const.d.ts +0 -2
  166. package/dist/types/const.d.ts.map +0 -1
  167. package/dist/types/contexts.d.ts +0 -18
  168. package/dist/types/contexts.d.ts.map +0 -1
  169. package/dist/types/index.d.ts +0 -5
  170. package/dist/types/index.d.ts.map +0 -1
  171. package/dist/types/internal/boardAnalyzer.d.ts +0 -8
  172. package/dist/types/internal/boardAnalyzer.d.ts.map +0 -1
  173. package/dist/types/internal/useBoardItemsMethods.d.ts +0 -15
  174. package/dist/types/internal/useBoardItemsMethods.d.ts.map +0 -1
  175. package/dist/types/internal/useCreateBoardColumns.d.ts +0 -10
  176. package/dist/types/internal/useCreateBoardColumns.d.ts.map +0 -1
  177. package/dist/types/internal/useDynamicBoard.d.ts +0 -10
  178. package/dist/types/internal/useDynamicBoard.d.ts.map +0 -1
  179. package/dist/types/internal/useGroupItemsByColumn.d.ts +0 -5
  180. package/dist/types/internal/useGroupItemsByColumn.d.ts.map +0 -1
  181. package/dist/types/internal/useStaticBoard.d.ts +0 -9
  182. package/dist/types/internal/useStaticBoard.d.ts.map +0 -1
  183. package/dist/types/tsconfig.tsbuildinfo +0 -1
  184. package/dist/types/types/BoardColumnNode.d.ts +0 -15
  185. package/dist/types/types/BoardColumnNode.d.ts.map +0 -1
  186. package/dist/types/types/BoardData.d.ts +0 -5
  187. package/dist/types/types/BoardData.d.ts.map +0 -1
  188. package/dist/types/types/BoardItemNode.d.ts +0 -7
  189. package/dist/types/types/BoardItemNode.d.ts.map +0 -1
  190. package/dist/types/types/BoardMethods.d.ts +0 -17
  191. package/dist/types/types/BoardMethods.d.ts.map +0 -1
  192. package/dist/types/types/index.d.ts +0 -4
  193. package/dist/types/types/index.d.ts.map +0 -1
  194. package/dist/types/utils/arrayMove.d.ts +0 -2
  195. 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.3",
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/interface.git",
33
+ "url": "git+https://github.com/contember/contember.git",
34
34
  "directory": "packages/react-board"
35
35
  },
36
36
  "dependencies": {
37
- "@contember/react-binding": "2.1.0-alpha.3",
38
- "@contember/react-multipass-rendering": "2.1.0-alpha.3",
39
- "@contember/react-utils": "2.1.0-alpha.3"
37
+ "@contember/react-binding": "workspace:*",
38
+ "@contember/react-multipass-rendering": "workspace:*",
39
+ "@contember/react-utils": "workspace:*"
40
40
  },
41
41
  "peerDependencies": {
42
- "react": "^18 || ^19",
43
- "react-dom": "^18 || ^19"
42
+ "react": "catalog:",
43
+ "react-dom": "catalog:"
44
44
  },
45
45
  "devDependencies": {
46
- "react": "^18.3.1",
47
- "react-dom": "^18.3.1"
46
+ "react": "catalog:",
47
+ "react-dom": "catalog:"
48
48
  }
49
49
  }
@@ -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
- children: ReactNode
60
- sortableBy?: string | SugaredRelativeSingleField
61
- sortScope?: 'column' | 'board'
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 BoardRelativeItemsProps =
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>(({ entities, orderBy, limit, offset, columns, columnsSortableBy, discriminationField, sortableBy, sortScope, children }) => {
78
- const itemsAccessor = useEntityListSubTree({ entities, orderBy, limit, offset })
79
- const columnsAccessor = useEntityListSubTree({ entities: columns })
80
- const [data, methods] = useDynamicBoard({
81
- columnEntities: columnsAccessor,
82
- itemEntities: itemsAccessor,
83
- columns,
84
- sortableBy,
85
- sortScope,
86
- columnsSortableBy,
87
- discriminationField,
88
- })
89
- return (
90
- <BoardMethodsContext.Provider value={methods}>
91
- <BoardColumnsContext.Provider value={data.columns}>
92
- {children}
93
- </BoardColumnsContext.Provider>
94
- </BoardMethodsContext.Provider>
95
- )
96
- }, ({ entities, orderBy, limit, offset, columns, discriminationField, sortableBy, columnsSortableBy, children }, env) => {
97
-
98
- const childrenByType = boardAnalyzer.processChildren(children, env)
99
- const columnChildren = childrenByType.filter(it => it.type === 'column').map(it => it.children)
100
- const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
101
-
102
- return (<>
103
- <EntityListSubTree entities={entities} orderBy={orderBy} limit={limit} offset={offset}>
104
- <HasOne {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
105
- {sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
106
- {itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
107
- </EntityListSubTree>
108
- <EntityListSubTree entities={columns}>
109
- {columnsSortableBy && <Field {...typeof columnsSortableBy === 'string' ? { field: columnsSortableBy } : columnsSortableBy} />}
110
- {columnChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
111
- </EntityListSubTree>
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
- const RelativeDynamicBoard = Component<BoardRelativeDynamicProps>(({ field, orderBy, limit, offset, columns, columnsSortableBy, discriminationField, sortableBy, sortScope, children }) => {
123
- const itemsAccessor = useEntityList({ field, orderBy, limit, offset })
124
- const columnsAccessor = useEntityListSubTree({ entities: columns })
125
- const [data, methods] = useDynamicBoard({
126
- columnEntities: columnsAccessor,
127
- itemEntities: itemsAccessor,
128
- columns,
129
- sortableBy,
130
- sortScope,
131
- columnsSortableBy,
132
- discriminationField,
133
- })
134
- return (
135
- <BoardMethodsContext.Provider value={methods}>
136
- <BoardColumnsContext.Provider value={data.columns}>
137
- {children}
138
- </BoardColumnsContext.Provider>
139
- </BoardMethodsContext.Provider>
140
- )
141
- }, ({ field, orderBy, limit, offset, columns, discriminationField, sortableBy, columnsSortableBy, children }, env) => {
142
- const childrenByType = boardAnalyzer.processChildren(children, env)
143
- const columnChildren = childrenByType.filter(it => it.type === 'column').map(it => it.children)
144
- const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
145
- return (<>
146
- <HasMany field={field} orderBy={orderBy} limit={limit} offset={offset}>
147
- <HasOne {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
148
- {sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
149
- {itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
150
- </HasMany>
151
- <EntityListSubTree entities={columns}>
152
- {columnsSortableBy && <Field {...typeof columnsSortableBy === 'string' ? { field: columnsSortableBy } : columnsSortableBy} />}
153
- {columnChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
154
- </EntityListSubTree>
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
- const BoardQualifiedStatic = Component<BoardQualifiedStaticProps>(({ entities, orderBy, limit, offset, columns, discriminationField, sortableBy, sortScope, children }) => {
164
- const itemsAccessor = useEntityListSubTree({ entities, orderBy, limit, offset })
165
- const [data, methods] = useStaticBoard({
166
- itemEntities: itemsAccessor,
167
- columns,
168
- sortableBy,
169
- sortScope,
170
- discriminationField,
171
- })
172
- return (
173
- <BoardMethodsContext.Provider value={methods}>
174
- <BoardColumnsContext.Provider value={data.columns}>
175
- {children}
176
- </BoardColumnsContext.Provider>
177
- </BoardMethodsContext.Provider>
178
- )
179
- }, ({ entities, orderBy, limit, offset, columns, discriminationField, sortableBy, children }, env) => {
180
- const childrenByType = boardAnalyzer.processChildren(children, env)
181
- const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
182
- return (<>
183
- <EntityListSubTree entities={entities} orderBy={orderBy} limit={limit} offset={offset}>
184
- <Field {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
185
- {sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
186
- {itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
187
- </EntityListSubTree>
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>(({ field, orderBy, limit, offset, columns, discriminationField, sortableBy, sortScope, children }) => {
198
- const itemsAccessor = useEntityList({ field, orderBy, limit, offset })
199
- const [data, methods] = useStaticBoard({
200
- itemEntities: itemsAccessor,
201
- columns,
202
- sortableBy,
203
- sortScope,
204
- discriminationField,
205
- })
206
- return (
207
- <BoardMethodsContext.Provider value={methods}>
208
- <BoardColumnsContext.Provider value={data.columns}>
209
- {children}
210
- </BoardColumnsContext.Provider>
211
- </BoardMethodsContext.Provider>
212
- )
213
- }, ({ field, orderBy, limit, offset, columns, discriminationField, sortableBy, children }, env) => {
214
- const childrenByType = boardAnalyzer.processChildren(children, env)
215
- const itemChildren = childrenByType.filter(it => it.type === 'item').map(it => it.children)
216
- return (<>
217
- <HasMany field={field} orderBy={orderBy} limit={limit} offset={offset}>
218
- <Field {...typeof discriminationField === 'string' ? { field: discriminationField } : discriminationField} />
219
- {sortableBy && <Field {...typeof sortableBy === 'string' ? { field: sortableBy } : sortableBy} />}
220
- {itemChildren.map((it, index) => <Fragment key={index}>{it}</Fragment>)}
221
- </HasMany>
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
- {columns.map(column => {
15
- if (column.id === BoardNullColumnPlaceholder) {
16
- return null
17
- }
18
- return (
19
- <BoardCurrentColumnContext.Provider value={column} key={column.id}>
20
- {isEntityAccessor(column.value) ? (
21
- <Entity accessor={column.value}>
22
- {children}
23
- </Entity>
24
- ) : children}
25
- </BoardCurrentColumnContext.Provider>
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
- {currentColumn.items.map((item, index) => {
14
- return (
15
- <BoardEachItemInner
16
- key={item.id}
17
- item={item}
18
- column={currentColumn}
19
- >
20
- {children}
21
- </BoardEachItemInner>
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, sortEntities,
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
- }, [columnIdGetter, connectItemToColumn, desugaredSortableByField, getDiscriminatorValue, getSortScopeItems, groupItemsByColumn, itemEntitiesEntitiesGetter, resolveScopedIndex, sortScope])
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 = (getDiscriminatorValue: (entity: EntityAccessor) => BoardColumnKey, sortBy: RelativeSingleField | undefined): 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