@coveord/plasma-mantine 56.18.0 → 56.20.1

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 (218) hide show
  1. package/.turbo/turbo-build.log +4 -4
  2. package/.turbo/turbo-test.log +113 -113
  3. package/dist/.tsbuildinfo +1 -1
  4. package/dist/cjs/components/Checkbox/Checkbox.d.ts.map +1 -1
  5. package/dist/cjs/components/Checkbox/Checkbox.js +1 -0
  6. package/dist/cjs/components/Checkbox/Checkbox.js.map +1 -1
  7. package/dist/cjs/components/CodeEditor/CodeEditor.d.ts.map +1 -1
  8. package/dist/cjs/components/CodeEditor/CodeEditor.js +2 -1
  9. package/dist/cjs/components/CodeEditor/CodeEditor.js.map +1 -1
  10. package/dist/cjs/components/Collection/Collection.d.ts +75 -12
  11. package/dist/cjs/components/Collection/Collection.d.ts.map +1 -1
  12. package/dist/cjs/components/Collection/Collection.js +94 -38
  13. package/dist/cjs/components/Collection/Collection.js.map +1 -1
  14. package/dist/cjs/components/Collection/Collection.module.css +13 -1
  15. package/dist/cjs/components/Collection/CollectionAddButton.d.ts +25 -0
  16. package/dist/cjs/components/Collection/CollectionAddButton.d.ts.map +1 -0
  17. package/dist/cjs/components/Collection/CollectionAddButton.js +33 -0
  18. package/dist/cjs/components/Collection/CollectionAddButton.js.map +1 -0
  19. package/dist/cjs/components/Collection/CollectionColumn.types.d.ts +72 -0
  20. package/dist/cjs/components/Collection/CollectionColumn.types.d.ts.map +1 -0
  21. package/dist/cjs/components/Collection/CollectionColumn.types.js +6 -0
  22. package/dist/cjs/components/Collection/CollectionColumn.types.js.map +1 -0
  23. package/dist/cjs/components/Collection/CollectionContext.d.ts +5 -0
  24. package/dist/cjs/components/Collection/CollectionContext.d.ts.map +1 -1
  25. package/dist/cjs/components/Collection/CollectionContext.js.map +1 -1
  26. package/dist/cjs/components/Collection/CollectionItem.d.ts +2 -2
  27. package/dist/cjs/components/Collection/CollectionItem.d.ts.map +1 -1
  28. package/dist/cjs/components/Collection/CollectionItem.js +18 -38
  29. package/dist/cjs/components/Collection/CollectionItem.js.map +1 -1
  30. package/dist/cjs/components/Collection/layouts/CollectionLayout.types.d.ts +46 -0
  31. package/dist/cjs/components/Collection/layouts/CollectionLayout.types.d.ts.map +1 -0
  32. package/dist/cjs/components/Collection/layouts/CollectionLayout.types.js +6 -0
  33. package/dist/cjs/components/Collection/layouts/CollectionLayout.types.js.map +1 -0
  34. package/dist/cjs/components/Collection/layouts/CollectionLayouts.d.ts +26 -0
  35. package/dist/cjs/components/Collection/layouts/CollectionLayouts.d.ts.map +1 -0
  36. package/dist/cjs/components/Collection/layouts/CollectionLayouts.js +29 -0
  37. package/dist/cjs/components/Collection/layouts/CollectionLayouts.js.map +1 -0
  38. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts +12 -0
  39. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts.map +1 -0
  40. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.js +24 -0
  41. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.js.map +1 -0
  42. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayout.module.css +37 -0
  43. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts +6 -0
  44. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts.map +1 -0
  45. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js +78 -0
  46. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js.map +1 -0
  47. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts +6 -0
  48. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts.map +1 -0
  49. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js +56 -0
  50. package/dist/cjs/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js.map +1 -0
  51. package/dist/cjs/components/Collection/layouts/shared/DragHandle.d.ts +12 -0
  52. package/dist/cjs/components/Collection/layouts/shared/DragHandle.d.ts.map +1 -0
  53. package/dist/cjs/components/Collection/layouts/shared/DragHandle.js +28 -0
  54. package/dist/cjs/components/Collection/layouts/shared/DragHandle.js.map +1 -0
  55. package/dist/cjs/components/Collection/layouts/shared/RemoveButton.d.ts +11 -0
  56. package/dist/cjs/components/Collection/layouts/shared/RemoveButton.d.ts.map +1 -0
  57. package/dist/cjs/components/Collection/layouts/shared/RemoveButton.js +39 -0
  58. package/dist/cjs/components/Collection/layouts/shared/RemoveButton.js.map +1 -0
  59. package/dist/cjs/components/Collection/layouts/shared/columnUtils.d.ts +8 -0
  60. package/dist/cjs/components/Collection/layouts/shared/columnUtils.d.ts.map +1 -0
  61. package/dist/cjs/components/Collection/layouts/shared/columnUtils.js +24 -0
  62. package/dist/cjs/components/Collection/layouts/shared/columnUtils.js.map +1 -0
  63. package/dist/cjs/components/Collection/layouts/shared/headerUtils.d.ts +8 -0
  64. package/dist/cjs/components/Collection/layouts/shared/headerUtils.d.ts.map +1 -0
  65. package/dist/cjs/components/Collection/layouts/shared/headerUtils.js +21 -0
  66. package/dist/cjs/components/Collection/layouts/shared/headerUtils.js.map +1 -0
  67. package/dist/cjs/components/Collection/layouts/shared/itemRenderer.d.ts +78 -0
  68. package/dist/cjs/components/Collection/layouts/shared/itemRenderer.d.ts.map +1 -0
  69. package/dist/cjs/components/Collection/layouts/shared/itemRenderer.js +160 -0
  70. package/dist/cjs/components/Collection/layouts/shared/itemRenderer.js.map +1 -0
  71. package/dist/cjs/components/Collection/layouts/shared/layoutConstants.d.ts +38 -0
  72. package/dist/cjs/components/Collection/layouts/shared/layoutConstants.d.ts.map +1 -0
  73. package/dist/cjs/components/Collection/layouts/shared/layoutConstants.js +31 -0
  74. package/dist/cjs/components/Collection/layouts/shared/layoutConstants.js.map +1 -0
  75. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts +12 -0
  76. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts.map +1 -0
  77. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.js +24 -0
  78. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.js.map +1 -0
  79. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayout.module.css +35 -0
  80. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts +6 -0
  81. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts.map +1 -0
  82. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js +134 -0
  83. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js.map +1 -0
  84. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts +10 -0
  85. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts.map +1 -0
  86. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js +15 -0
  87. package/dist/cjs/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js.map +1 -0
  88. package/dist/cjs/components/CopyToClipboard/CopyToClipboard.js +1 -0
  89. package/dist/cjs/components/CopyToClipboard/CopyToClipboard.js.map +1 -1
  90. package/dist/cjs/hooks/useParentHeight.d.ts.map +1 -1
  91. package/dist/cjs/hooks/useParentHeight.js +6 -4
  92. package/dist/cjs/hooks/useParentHeight.js.map +1 -1
  93. package/dist/cjs/index.d.ts +2 -0
  94. package/dist/cjs/index.d.ts.map +1 -1
  95. package/dist/cjs/index.js.map +1 -1
  96. package/dist/esm/components/Checkbox/Checkbox.d.ts.map +1 -1
  97. package/dist/esm/components/Checkbox/Checkbox.js +1 -0
  98. package/dist/esm/components/Checkbox/Checkbox.js.map +1 -1
  99. package/dist/esm/components/CodeEditor/CodeEditor.d.ts.map +1 -1
  100. package/dist/esm/components/CodeEditor/CodeEditor.js +2 -1
  101. package/dist/esm/components/CodeEditor/CodeEditor.js.map +1 -1
  102. package/dist/esm/components/Collection/Collection.d.ts +75 -12
  103. package/dist/esm/components/Collection/Collection.d.ts.map +1 -1
  104. package/dist/esm/components/Collection/Collection.js +87 -32
  105. package/dist/esm/components/Collection/Collection.js.map +1 -1
  106. package/dist/esm/components/Collection/Collection.module.css +13 -1
  107. package/dist/esm/components/Collection/CollectionAddButton.d.ts +25 -0
  108. package/dist/esm/components/Collection/CollectionAddButton.d.ts.map +1 -0
  109. package/dist/esm/components/Collection/CollectionAddButton.js +19 -0
  110. package/dist/esm/components/Collection/CollectionAddButton.js.map +1 -0
  111. package/dist/esm/components/Collection/CollectionColumn.types.d.ts +72 -0
  112. package/dist/esm/components/Collection/CollectionColumn.types.d.ts.map +1 -0
  113. package/dist/esm/components/Collection/CollectionColumn.types.js +5 -0
  114. package/dist/esm/components/Collection/CollectionColumn.types.js.map +1 -0
  115. package/dist/esm/components/Collection/CollectionContext.d.ts +5 -0
  116. package/dist/esm/components/Collection/CollectionContext.d.ts.map +1 -1
  117. package/dist/esm/components/Collection/CollectionContext.js.map +1 -1
  118. package/dist/esm/components/Collection/CollectionItem.d.ts +2 -2
  119. package/dist/esm/components/Collection/CollectionItem.d.ts.map +1 -1
  120. package/dist/esm/components/Collection/CollectionItem.js +15 -34
  121. package/dist/esm/components/Collection/CollectionItem.js.map +1 -1
  122. package/dist/esm/components/Collection/layouts/CollectionLayout.types.d.ts +46 -0
  123. package/dist/esm/components/Collection/layouts/CollectionLayout.types.d.ts.map +1 -0
  124. package/dist/esm/components/Collection/layouts/CollectionLayout.types.js +6 -0
  125. package/dist/esm/components/Collection/layouts/CollectionLayout.types.js.map +1 -0
  126. package/dist/esm/components/Collection/layouts/CollectionLayouts.d.ts +26 -0
  127. package/dist/esm/components/Collection/layouts/CollectionLayouts.d.ts.map +1 -0
  128. package/dist/esm/components/Collection/layouts/CollectionLayouts.js +10 -0
  129. package/dist/esm/components/Collection/layouts/CollectionLayouts.js.map +1 -0
  130. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts +12 -0
  131. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.d.ts.map +1 -0
  132. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.js +11 -0
  133. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.js.map +1 -0
  134. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayout.module.css +37 -0
  135. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts +6 -0
  136. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.d.ts.map +1 -0
  137. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js +49 -0
  138. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.js.map +1 -0
  139. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts +6 -0
  140. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.d.ts.map +1 -0
  141. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js +36 -0
  142. package/dist/esm/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.js.map +1 -0
  143. package/dist/esm/components/Collection/layouts/shared/DragHandle.d.ts +12 -0
  144. package/dist/esm/components/Collection/layouts/shared/DragHandle.d.ts.map +1 -0
  145. package/dist/esm/components/Collection/layouts/shared/DragHandle.js +20 -0
  146. package/dist/esm/components/Collection/layouts/shared/DragHandle.js.map +1 -0
  147. package/dist/esm/components/Collection/layouts/shared/RemoveButton.d.ts +11 -0
  148. package/dist/esm/components/Collection/layouts/shared/RemoveButton.d.ts.map +1 -0
  149. package/dist/esm/components/Collection/layouts/shared/RemoveButton.js +30 -0
  150. package/dist/esm/components/Collection/layouts/shared/RemoveButton.js.map +1 -0
  151. package/dist/esm/components/Collection/layouts/shared/columnUtils.d.ts +8 -0
  152. package/dist/esm/components/Collection/layouts/shared/columnUtils.d.ts.map +1 -0
  153. package/dist/esm/components/Collection/layouts/shared/columnUtils.js +17 -0
  154. package/dist/esm/components/Collection/layouts/shared/columnUtils.js.map +1 -0
  155. package/dist/esm/components/Collection/layouts/shared/headerUtils.d.ts +8 -0
  156. package/dist/esm/components/Collection/layouts/shared/headerUtils.d.ts.map +1 -0
  157. package/dist/esm/components/Collection/layouts/shared/headerUtils.js +14 -0
  158. package/dist/esm/components/Collection/layouts/shared/headerUtils.js.map +1 -0
  159. package/dist/esm/components/Collection/layouts/shared/itemRenderer.d.ts +78 -0
  160. package/dist/esm/components/Collection/layouts/shared/itemRenderer.d.ts.map +1 -0
  161. package/dist/esm/components/Collection/layouts/shared/itemRenderer.js +150 -0
  162. package/dist/esm/components/Collection/layouts/shared/itemRenderer.js.map +1 -0
  163. package/dist/esm/components/Collection/layouts/shared/layoutConstants.d.ts +38 -0
  164. package/dist/esm/components/Collection/layouts/shared/layoutConstants.d.ts.map +1 -0
  165. package/dist/esm/components/Collection/layouts/shared/layoutConstants.js +18 -0
  166. package/dist/esm/components/Collection/layouts/shared/layoutConstants.js.map +1 -0
  167. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts +12 -0
  168. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.d.ts.map +1 -0
  169. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.js +11 -0
  170. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.js.map +1 -0
  171. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayout.module.css +35 -0
  172. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts +6 -0
  173. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.d.ts.map +1 -0
  174. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js +103 -0
  175. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutBody.js.map +1 -0
  176. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts +10 -0
  177. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.d.ts.map +1 -0
  178. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js +6 -0
  179. package/dist/esm/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.js.map +1 -0
  180. package/dist/esm/components/CopyToClipboard/CopyToClipboard.js +1 -0
  181. package/dist/esm/components/CopyToClipboard/CopyToClipboard.js.map +1 -1
  182. package/dist/esm/hooks/useParentHeight.d.ts.map +1 -1
  183. package/dist/esm/hooks/useParentHeight.js +5 -4
  184. package/dist/esm/hooks/useParentHeight.js.map +1 -1
  185. package/dist/esm/index.d.ts +2 -0
  186. package/dist/esm/index.d.ts.map +1 -1
  187. package/dist/esm/index.js.map +1 -1
  188. package/package.json +3 -3
  189. package/src/components/Checkbox/Checkbox.ts +1 -0
  190. package/src/components/CodeEditor/CodeEditor.tsx +2 -8
  191. package/src/components/CodeEditor/__tests__/CodeEditor.spec.tsx +18 -0
  192. package/src/components/Collection/Collection.module.css +13 -1
  193. package/src/components/Collection/Collection.tsx +149 -50
  194. package/src/components/Collection/CollectionAddButton.tsx +42 -0
  195. package/src/components/Collection/CollectionColumn.types.ts +79 -0
  196. package/src/components/Collection/CollectionContext.ts +5 -0
  197. package/src/components/Collection/CollectionItem.tsx +10 -21
  198. package/src/components/Collection/__tests__/CollectionWithColumns.spec.tsx +560 -0
  199. package/src/components/Collection/layouts/CollectionLayout.types.ts +56 -0
  200. package/src/components/Collection/layouts/CollectionLayouts.tsx +15 -0
  201. package/src/components/Collection/layouts/horizontal-layout/HorizontalLayout.module.css +37 -0
  202. package/src/components/Collection/layouts/horizontal-layout/HorizontalLayout.tsx +9 -0
  203. package/src/components/Collection/layouts/horizontal-layout/HorizontalLayoutBody.tsx +68 -0
  204. package/src/components/Collection/layouts/horizontal-layout/HorizontalLayoutHeader.tsx +33 -0
  205. package/src/components/Collection/layouts/shared/DragHandle.tsx +22 -0
  206. package/src/components/Collection/layouts/shared/RemoveButton.tsx +30 -0
  207. package/src/components/Collection/layouts/shared/columnUtils.ts +20 -0
  208. package/src/components/Collection/layouts/shared/headerUtils.ts +14 -0
  209. package/src/components/Collection/layouts/shared/itemRenderer.tsx +242 -0
  210. package/src/components/Collection/layouts/shared/layoutConstants.ts +51 -0
  211. package/src/components/Collection/layouts/vertical-layout/VerticalLayout.module.css +35 -0
  212. package/src/components/Collection/layouts/vertical-layout/VerticalLayout.tsx +9 -0
  213. package/src/components/Collection/layouts/vertical-layout/VerticalLayoutBody.tsx +120 -0
  214. package/src/components/Collection/layouts/vertical-layout/VerticalLayoutHeader.tsx +8 -0
  215. package/src/components/CopyToClipboard/CopyToClipboard.tsx +2 -0
  216. package/src/hooks/__tests__/useParentHeight.spec.tsx +150 -0
  217. package/src/hooks/useParentHeight.ts +6 -3
  218. package/src/index.ts +11 -0
@@ -1,5 +1,6 @@
1
1
  import { Checkbox } from '@mantine/core';
2
2
  Checkbox.displayName = 'Checkbox';
3
+ Checkbox.Group.displayName = 'Checkbox.Group';
3
4
  export { Checkbox } from '@mantine/core';
4
5
 
5
6
  //# sourceMappingURL=Checkbox.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Checkbox/Checkbox.ts"],"sourcesContent":["import {Checkbox} from '@mantine/core';\n\nCheckbox.displayName = 'Checkbox';\n\nexport {Checkbox, type CheckboxFactory, type CheckboxProps} from '@mantine/core';\n"],"names":["Checkbox","displayName"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,gBAAgB;AAEvCA,SAASC,WAAW,GAAG;AAEvB,SAAQD,QAAQ,QAAiD,gBAAgB"}
1
+ {"version":3,"sources":["../../../../src/components/Checkbox/Checkbox.ts"],"sourcesContent":["import {Checkbox} from '@mantine/core';\n\nCheckbox.displayName = 'Checkbox';\nCheckbox.Group.displayName = 'Checkbox.Group';\n\nexport {Checkbox, type CheckboxFactory, type CheckboxProps} from '@mantine/core';\n"],"names":["Checkbox","displayName","Group"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,gBAAgB;AAEvCA,SAASC,WAAW,GAAG;AACvBD,SAASE,KAAK,CAACD,WAAW,GAAG;AAE7B,SAAQD,QAAQ,QAAiD,gBAAgB"}
@@ -1 +1 @@
1
- {"version":3,"file":"CodeEditor.d.ts","sourceRoot":"","sources":["../../../../src/components/CodeEditor/CodeEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAKH,iBAAiB,EAIjB,UAAU,EAKb,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAiB,MAAM,IAAI,YAAY,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,EAAC,iBAAiB,EAA8B,MAAM,OAAO,CAAC;AAQrE,UAAU,eACN,SACI,IAAI,CAAC,iBAAiB,EAAE,gBAAgB,GAAG,mBAAmB,GAAG,YAAY,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC,EAC/G,IAAI,CAAC,UAAU,EAAE,UAAU,GAAG,YAAY,CAAC;IAC/C;;;;OAIG;IACH,QAAQ,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,CAAC,MAAM,GAAG,OAAO,CAAC,CAAC;IACrF,2CAA2C;IAC3C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,iCAAiC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,0CAA0C;IAC1C,QAAQ,CAAC,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kDAAkD;IAClD,QAAQ,CAAC,IAAI,IAAI,CAAC;IAClB,+CAA+C;IAC/C,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,oEAAoE;IACpE,YAAY,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,YAAY,CAAC,qBAAqB,GAAG,IAAI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,MAAM,CAAC,IAAI,IAAI,CAAC;IAChB,qDAAqD;IACrD,OAAO,CAAC,IAAI,IAAI,CAAC;IACjB,oEAAoE;IACpE,YAAY,CAAC,EAAE,KAAK,CAAC,gBAAgB,CAAC,YAAY,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAAC;IACjF;;;;;;;OAOG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,KAAK,GAAG,OAAO,CAAC;IAC/B;;;;OAIG;IACH,OAAO,CAAC,EAAE,IAAI,CAAC,YAAY,CAAC,oCAAoC,EAAE,SAAS,CAAC,CAAC;CAChF;AASD,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,eAAe,CAsLzD,CAAC"}
@@ -166,10 +166,11 @@ export const CodeEditor = (props)=>{
166
166
  className: CodeEditorClasses.editor,
167
167
  children: /*#__PURE__*/ _jsx(Loader, {})
168
168
  });
169
+ const height = Math.max(Number.isNaN(parentHeight) ? 0 : parentHeight, minHeight);
169
170
  return /*#__PURE__*/ _jsxs(Stack, {
170
171
  justify: "flex-start",
171
172
  gap: "sm",
172
- h: Math.max(parentHeight, minHeight),
173
+ h: height,
173
174
  mah: maxHeight,
174
175
  ref: ref,
175
176
  ...others,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/CodeEditor/CodeEditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n Group,\n Input,\n InputWrapperProps,\n Loader,\n Space,\n Stack,\n StackProps,\n px,\n useMantineColorScheme,\n useMantineTheme,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {Monaco, loader} from '@monaco-editor/react';\nimport {MarkerSeverity, editor as monacoEditor} from 'monaco-editor';\nimport {FunctionComponent, useEffect, useRef, useState} from 'react';\n\nimport cx from 'clsx';\nimport {useParentHeight} from '../../hooks/useParentHeight.js';\nimport {CopyToClipboard} from '../CopyToClipboard/CopyToClipboard.js';\nimport CodeEditorClasses from './CodeEditor.module.css';\nimport {XML} from './languages/xml.js';\nimport {Search} from './search/Search.js';\ninterface CodeEditorProps\n extends\n Omit<InputWrapperProps, 'inputContainer' | 'inputWrapperOrder' | 'classNames' | 'styles' | 'vars' | 'onChange'>,\n Omit<StackProps, 'onChange' | 'attributes'> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml' | (string & unknown);\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the search icon is clicked */\n onSearch?(): void;\n /** Called whenever the copy icon is clicked */\n onCopy?(): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /** Ref object that provides access to the editor's functionality */\n editorHandle?: React.MutableRefObject<monacoEditor.IStandaloneCodeEditor | null>;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n /**\n * Options to pass to the monaco editor.\n * Currently only supporting [`tabSize`](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html#tabSize).\n *\n */\n options?: Pick<monacoEditor.IStandaloneEditorConstructionOptions, 'tabSize'>;\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onCopy,\n onSearch,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n options: {tabSize} = {tabSize: 2},\n editorHandle,\n ...others\n } = useProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const registerThemes = (monaco: Monaco) => {\n monaco.editor.defineTheme('light', {\n base: 'vs',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': theme.colors.gray[0],\n },\n });\n };\n\n const handleSearch = () => {\n if (editorRef.current) {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n onSearch?.();\n }\n };\n\n const [hasMonacoError, setHasMonacoError] = useState(false);\n const hasMonacoErrorRef = useRef(false);\n\n hasMonacoErrorRef.current = hasMonacoError;\n\n const hasError = !!error || hasMonacoError;\n const theme = useMantineTheme();\n const {colorScheme} = useMantineColorScheme();\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const handleValidate = (markers: monacoEditor.IMarker[]) => {\n setHasMonacoError(markers.some((marker) => marker.severity === MarkerSeverity.Error));\n };\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? <Input.Error {...errorProps}>{error}</Input.Error> : <Space h=\"sm\" />;\n\n const _header =\n _label || _description ? (\n <Stack gap=\"xxs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const _buttons = (\n <Group justify=\"right\" gap=\"xs\">\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} onCopy={() => onCopy?.()} />\n </Group>\n );\n let editorTheme = colorScheme === 'light' ? 'light' : 'vs-dark';\n if (disabled) {\n editorTheme += '-disabled';\n }\n\n const _editor = loaded ? (\n <Box\n p=\"md\"\n pl=\"xs\"\n className={cx(\n CodeEditorClasses.root,\n {[CodeEditorClasses.error]: hasError},\n {[CodeEditorClasses.disabled]: disabled},\n )}\n data-testid=\"editor-wrapper\"\n >\n <Editor\n onValidate={handleValidate}\n defaultLanguage={language}\n theme={editorTheme}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs) as number,\n readOnly: disabled,\n stickyScroll: {enabled: false},\n tabSize,\n }}\n value={_value}\n onChange={handleChange}\n beforeMount={(monaco) => {\n registerLanguages(monaco);\n registerThemes(monaco);\n }}\n onMount={(editor) => {\n editorRef.current = editor;\n if (editorHandle) {\n editorHandle.current = editor;\n }\n editor.onDidFocusEditorText(() => onFocus?.());\n editor.onDidBlurEditorText(async () => {\n // monaco editor has a timeout of 500ms populating errors, we want to ensure that checking errors happen after that\n setTimeout(async () => {\n if (!hasMonacoErrorRef.current) {\n await editor?.getAction('editor.action.formatDocument')?.run();\n }\n }, 550);\n });\n }}\n />\n </Box>\n ) : (\n <Center className={CodeEditorClasses.editor}>\n <Loader />\n </Center>\n );\n\n return (\n <Stack\n justify=\"flex-start\"\n gap=\"sm\"\n h={Math.max(parentHeight, minHeight)}\n mah={maxHeight}\n ref={ref}\n {...others}\n >\n <Group justify=\"space-between\">\n {_header}\n {_buttons}\n </Group>\n {_editor}\n {_error}\n </Stack>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n"],"names":["Box","Center","Group","Input","Loader","Space","Stack","px","useMantineColorScheme","useMantineTheme","useProps","useUncontrolled","Editor","loader","MarkerSeverity","useEffect","useRef","useState","cx","useParentHeight","CopyToClipboard","CodeEditorClasses","XML","Search","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onCopy","onSearch","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","options","tabSize","editorHandle","others","loaded","setLoaded","_value","handleChange","finalValue","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","registerThemes","editor","defineTheme","base","inherit","rules","colors","theme","gray","handleSearch","current","focus","trigger","hasMonacoError","setHasMonacoError","hasMonacoErrorRef","hasError","colorScheme","handleValidate","markers","some","marker","severity","Error","_label","Label","_description","Description","_error","h","_header","gap","_buttons","justify","editorTheme","_editor","p","pl","className","root","data-testid","onValidate","defaultLanguage","minimap","enabled","wordWrap","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","stickyScroll","beforeMount","onMount","onDidFocusEditorText","onDidBlurEditorText","setTimeout","getAction","run","Math","max","mah","displayName"],"mappings":";AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,EAAE,EACFC,qBAAqB,EACrBC,eAAe,EACfC,QAAQ,QACL,gBAAgB;AACvB,SAAQC,eAAe,QAAO,iBAAiB;AAC/C,OAAOC,UAAiBC,MAAM,QAAO,uBAAuB;AAC5D,SAAQC,cAAc,QAA+B,gBAAgB;AACrE,SAA2BC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAO,QAAQ;AAErE,OAAOC,QAAQ,OAAO;AACtB,SAAQC,eAAe,QAAO,iCAAiC;AAC/D,SAAQC,eAAe,QAAO,wCAAwC;AACtE,OAAOC,uBAAuB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ditor.tsx"],"sourcesContent":["import {\n Box,\n Center,\n Group,\n Input,\n InputWrapperProps,\n Loader,\n Space,\n Stack,\n StackProps,\n px,\n useMantineColorScheme,\n useMantineTheme,\n useProps,\n} from '@mantine/core';\nimport {useUncontrolled} from '@mantine/hooks';\nimport Editor, {Monaco, loader} from '@monaco-editor/react';\nimport {MarkerSeverity, editor as monacoEditor} from 'monaco-editor';\nimport {FunctionComponent, useEffect, useRef, useState} from 'react';\n\nimport cx from 'clsx';\nimport {useParentHeight} from '../../hooks/useParentHeight.js';\nimport {CopyToClipboard} from '../CopyToClipboard/CopyToClipboard.js';\nimport CodeEditorClasses from './CodeEditor.module.css';\nimport {XML} from './languages/xml.js';\nimport {Search} from './search/Search.js';\ninterface CodeEditorProps\n extends\n Omit<InputWrapperProps, 'inputContainer' | 'inputWrapperOrder' | 'classNames' | 'styles' | 'vars' | 'onChange'>,\n Omit<StackProps, 'onChange' | 'attributes'> {\n /**\n * The language syntax of the editor\n *\n * @default 'plaintext'\n */\n language?: 'plaintext' | 'json' | 'markdown' | 'python' | 'xml' | (string & unknown);\n /** Default value for uncontrolled input */\n defaultValue?: string;\n /** Value for controlled input */\n value?: string;\n /** onChange value for controlled input */\n onChange?(value: string): void;\n /** Called whenever the search icon is clicked */\n onSearch?(): void;\n /** Called whenever the copy icon is clicked */\n onCopy?(): void;\n /** Called whenever the code editor gets the focus */\n onFocus?(): void;\n /** Ref object that provides access to the editor's functionality */\n editorHandle?: React.MutableRefObject<monacoEditor.IStandaloneCodeEditor | null>;\n /**\n * The minimal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height is too short, it will use this value as minimum.\n *\n * @default 300\n */\n minHeight?: number;\n /**\n * The maximal height of the CodeEditor (label and description included)\n *\n * By default the CodeEditor is adjusted to fill its parent height.\n * In the case where the parent height would be too high for your liking, you can use this prop to set a maximum.\n */\n maxHeight?: number;\n disabled?: boolean;\n /**\n * Defines how the monaco editor files will be loaded.\n * Note that using `'local'` requires [some additional configuration](https://github.com/suren-atoyan/monaco-react#use-monaco-editor-as-an-npm-package).\n *\n * @default 'local'\n */\n monacoLoader?: 'cdn' | 'local';\n /**\n * Options to pass to the monaco editor.\n * Currently only supporting [`tabSize`](https://microsoft.github.io/monaco-editor/typedoc/interfaces/editor.IStandaloneEditorConstructionOptions.html#tabSize).\n *\n */\n options?: Pick<monacoEditor.IStandaloneEditorConstructionOptions, 'tabSize'>;\n}\n\nconst defaultProps: Partial<CodeEditorProps> = {\n language: 'plaintext',\n monacoLoader: 'local',\n defaultValue: '',\n minHeight: 300,\n};\n\nexport const CodeEditor: FunctionComponent<CodeEditorProps> = (props) => {\n const {\n language,\n defaultValue,\n onChange,\n onCopy,\n onSearch,\n onFocus,\n value,\n label,\n required,\n labelProps,\n error,\n errorProps,\n description,\n descriptionProps,\n minHeight,\n maxHeight,\n disabled,\n monacoLoader,\n options: {tabSize} = {tabSize: 2},\n editorHandle,\n ...others\n } = useProps('CodeEditor', defaultProps, props);\n const [loaded, setLoaded] = useState(false);\n const [_value, handleChange] = useUncontrolled<string>({\n value,\n defaultValue,\n onChange,\n finalValue: '',\n });\n const [parentHeight, ref] = useParentHeight();\n const editorRef = useRef(null);\n\n const loadLocalMonaco = async () => {\n const monacoInstance = await import('monaco-editor');\n loader.config({monaco: monacoInstance});\n setLoaded(true);\n };\n\n const registerLanguages = (monaco: Monaco) => {\n if (monaco && language === 'xml') {\n XML.register(monaco);\n }\n };\n\n const registerThemes = (monaco: Monaco) => {\n monaco.editor.defineTheme('light', {\n base: 'vs',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': theme.colors.gray[0],\n },\n });\n };\n\n const handleSearch = () => {\n if (editorRef.current) {\n editorRef.current.focus();\n editorRef.current.trigger('editor', 'actions.find', '');\n onSearch?.();\n }\n };\n\n const [hasMonacoError, setHasMonacoError] = useState(false);\n const hasMonacoErrorRef = useRef(false);\n\n hasMonacoErrorRef.current = hasMonacoError;\n\n const hasError = !!error || hasMonacoError;\n const theme = useMantineTheme();\n const {colorScheme} = useMantineColorScheme();\n\n useEffect(() => {\n if (monacoLoader === 'local') {\n loadLocalMonaco();\n } else {\n setLoaded(true);\n }\n }, []);\n\n const handleValidate = (markers: monacoEditor.IMarker[]) => {\n setHasMonacoError(markers.some((marker) => marker.severity === MarkerSeverity.Error));\n };\n\n const _label = label ? (\n <Input.Label required={required} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n\n const _error = error ? <Input.Error {...errorProps}>{error}</Input.Error> : <Space h=\"sm\" />;\n\n const _header =\n _label || _description ? (\n <Stack gap=\"xxs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const _buttons = (\n <Group justify=\"right\" gap=\"xs\">\n <Search handleSearch={handleSearch} />\n <CopyToClipboard value={_value} onCopy={() => onCopy?.()} />\n </Group>\n );\n let editorTheme = colorScheme === 'light' ? 'light' : 'vs-dark';\n if (disabled) {\n editorTheme += '-disabled';\n }\n\n const _editor = loaded ? (\n <Box\n p=\"md\"\n pl=\"xs\"\n className={cx(\n CodeEditorClasses.root,\n {[CodeEditorClasses.error]: hasError},\n {[CodeEditorClasses.disabled]: disabled},\n )}\n data-testid=\"editor-wrapper\"\n >\n <Editor\n onValidate={handleValidate}\n defaultLanguage={language}\n theme={editorTheme}\n options={{\n minimap: {enabled: false},\n wordWrap: 'on',\n scrollBeyondLastLine: false,\n formatOnPaste: true,\n fontSize: px(theme.fontSizes.xs) as number,\n readOnly: disabled,\n stickyScroll: {enabled: false},\n tabSize,\n }}\n value={_value}\n onChange={handleChange}\n beforeMount={(monaco) => {\n registerLanguages(monaco);\n registerThemes(monaco);\n }}\n onMount={(editor) => {\n editorRef.current = editor;\n if (editorHandle) {\n editorHandle.current = editor;\n }\n editor.onDidFocusEditorText(() => onFocus?.());\n editor.onDidBlurEditorText(async () => {\n // monaco editor has a timeout of 500ms populating errors, we want to ensure that checking errors happen after that\n setTimeout(async () => {\n if (!hasMonacoErrorRef.current) {\n await editor?.getAction('editor.action.formatDocument')?.run();\n }\n }, 550);\n });\n }}\n />\n </Box>\n ) : (\n <Center className={CodeEditorClasses.editor}>\n <Loader />\n </Center>\n );\n\n const height = Math.max(Number.isNaN(parentHeight) ? 0 : parentHeight, minHeight);\n return (\n <Stack justify=\"flex-start\" gap=\"sm\" h={height} mah={maxHeight} ref={ref} {...others}>\n <Group justify=\"space-between\">\n {_header}\n {_buttons}\n </Group>\n {_editor}\n {_error}\n </Stack>\n );\n};\n\nCodeEditor.displayName = 'CodeEditor';\n"],"names":["Box","Center","Group","Input","Loader","Space","Stack","px","useMantineColorScheme","useMantineTheme","useProps","useUncontrolled","Editor","loader","MarkerSeverity","useEffect","useRef","useState","cx","useParentHeight","CopyToClipboard","CodeEditorClasses","XML","Search","defaultProps","language","monacoLoader","defaultValue","minHeight","CodeEditor","props","onChange","onCopy","onSearch","onFocus","value","label","required","labelProps","error","errorProps","description","descriptionProps","maxHeight","disabled","options","tabSize","editorHandle","others","loaded","setLoaded","_value","handleChange","finalValue","parentHeight","ref","editorRef","loadLocalMonaco","monacoInstance","config","monaco","registerLanguages","register","registerThemes","editor","defineTheme","base","inherit","rules","colors","theme","gray","handleSearch","current","focus","trigger","hasMonacoError","setHasMonacoError","hasMonacoErrorRef","hasError","colorScheme","handleValidate","markers","some","marker","severity","Error","_label","Label","_description","Description","_error","h","_header","gap","_buttons","justify","editorTheme","_editor","p","pl","className","root","data-testid","onValidate","defaultLanguage","minimap","enabled","wordWrap","scrollBeyondLastLine","formatOnPaste","fontSize","fontSizes","xs","readOnly","stickyScroll","beforeMount","onMount","onDidFocusEditorText","onDidBlurEditorText","setTimeout","getAction","run","height","Math","max","Number","isNaN","mah","displayName"],"mappings":";AAAA,SACIA,GAAG,EACHC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,MAAM,EACNC,KAAK,EACLC,KAAK,EAELC,EAAE,EACFC,qBAAqB,EACr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AkB2C,MAAM;kBACvC,cAAA,KAAC5D;;IAIT,MAAMuH,SAASC,KAAKC,GAAG,CAACC,OAAOC,KAAK,CAACzE,gBAAgB,IAAIA,cAAc1B;IACvE,qBACI,MAACtB;QAAM0F,SAAQ;QAAaF,KAAI;QAAKF,GAAG+B;QAAQK,KAAKrF;QAAWY,KAAKA;QAAM,GAAGP,MAAM;;0BAChF,MAAC9C;gBAAM8F,SAAQ;;oBACVH;oBACAE;;;YAEJG;YACAP;;;AAGb,EAAE;AAEF9D,WAAWoG,WAAW,GAAG"}
@@ -1,18 +1,16 @@
1
1
  import { __InputWrapperProps, BoxProps, Factory, MantineSpacing, StylesApiProps } from '@mantine/core';
2
2
  import { ForwardedRef, ReactNode } from 'react';
3
3
  import { CustomComponentThemeExtend } from '../../utils/createFactoryComponent.js';
4
- export interface CollectionProps<T> extends __InputWrapperProps, BoxProps, StylesApiProps<CollectionFactory> {
4
+ import { CollectionColumnDef } from './CollectionColumn.types.js';
5
+ import { CollectionLayout } from './layouts/CollectionLayout.types.js';
6
+ /**
7
+ * Base props shared by both column-based and children-based patterns
8
+ */
9
+ interface BaseCollectionProps<T> extends __InputWrapperProps, BoxProps, StylesApiProps<CollectionFactory> {
5
10
  /**
6
11
  * The default value each new item should have
7
12
  */
8
13
  newItem: T | (() => T);
9
- /**
10
- * A render function called for each item passed in the `value` prop.
11
- *
12
- * @param item The current item's value
13
- * @param index The current item's index
14
- */
15
- children: (item: T, index: number) => ReactNode;
16
14
  /**
17
15
  * The list of items to display inside the collection
18
16
  *
@@ -92,7 +90,7 @@ export interface CollectionProps<T> extends __InputWrapperProps, BoxProps, Style
92
90
  *
93
91
  * @default "Add item"
94
92
  */
95
- addLabel?: string;
93
+ addLabel?: ReactNode;
96
94
  /**
97
95
  * The tooltip text displayed when hovering over the disabled add item button
98
96
  *
@@ -100,9 +98,9 @@ export interface CollectionProps<T> extends __InputWrapperProps, BoxProps, Style
100
98
  */
101
99
  addDisabledTooltip?: string;
102
100
  /**
103
- * The gap between the colleciton items
101
+ * The gap between the collection items
104
102
  *
105
- * @default 'xs'
103
+ * @default 'md'
106
104
  */
107
105
  gap?: MantineSpacing;
108
106
  /**
@@ -112,7 +110,49 @@ export interface CollectionProps<T> extends __InputWrapperProps, BoxProps, Style
112
110
  */
113
111
  required?: boolean;
114
112
  }
115
- export type CollectionStylesNames = 'root' | 'item' | 'items' | 'itemDragging' | 'dragHandle';
113
+ /**
114
+ * Collection with column-based layout
115
+ */
116
+ interface CollectionWithColumns<T> extends BaseCollectionProps<T> {
117
+ /**
118
+ * Column definitions for the collection
119
+ */
120
+ columns: Array<CollectionColumnDef<T>>;
121
+ /**
122
+ * Layout component to use for rendering
123
+ * @default CollectionLayouts.Horizontal
124
+ */
125
+ layout?: CollectionLayout;
126
+ /**
127
+ * Must not have children when using columns
128
+ */
129
+ children?: never;
130
+ }
131
+ /**
132
+ * Collection with legacy children render prop
133
+ */
134
+ interface CollectionWithChildren<T> extends BaseCollectionProps<T> {
135
+ /**
136
+ * A render function called for each item passed in the `value` prop.
137
+ *
138
+ * @param item The current item's value
139
+ * @param index The current item's index
140
+ */
141
+ children: (item: T, index: number) => ReactNode;
142
+ /**
143
+ * Must not have columns when using children
144
+ */
145
+ columns?: never;
146
+ /**
147
+ * Must not have layout when using children
148
+ */
149
+ layout?: never;
150
+ }
151
+ /**
152
+ * Collection props - either columns OR children, never both
153
+ */
154
+ export type CollectionProps<T> = CollectionWithColumns<T> | CollectionWithChildren<T>;
155
+ export type CollectionStylesNames = 'root' | 'item' | 'items' | 'itemDragging' | 'dragHandle' | 'removeButton';
116
156
  export type CollectionFactory = Factory<{
117
157
  props: CollectionProps<unknown>;
118
158
  ref: HTMLDivElement;
@@ -128,5 +168,28 @@ export declare const Collection: {
128
168
  ref: HTMLDivElement;
129
169
  stylesNames: CollectionStylesNames;
130
170
  }>;
171
+ Layouts: {
172
+ readonly Horizontal: {
173
+ ({ children }: import("./layouts/shared/layoutConstants.js").LayoutProps): import("react/jsx-runtime").JSX.Element;
174
+ Body: <T>(props: import("./layouts/shared/layoutConstants.js").LayoutBodyProps<T> & {
175
+ ref?: ForwardedRef<HTMLDivElement>;
176
+ }) => import("react/jsx-runtime").JSX.Element;
177
+ Header: (props: import("./layouts/shared/layoutConstants.js").LayoutHeaderProps & {
178
+ ref?: ForwardedRef<HTMLDivElement>;
179
+ }) => import("react/jsx-runtime").JSX.Element;
180
+ displayName: string;
181
+ };
182
+ readonly Vertical: {
183
+ ({ children }: import("./layouts/shared/layoutConstants.js").LayoutProps): import("react/jsx-runtime").JSX.Element;
184
+ Body: <T>(props: import("./layouts/shared/layoutConstants.js").LayoutBodyProps<T> & {
185
+ ref?: ForwardedRef<HTMLDivElement>;
186
+ }) => import("react/jsx-runtime").JSX.Element;
187
+ Header: (_props: import("./layouts/shared/layoutConstants.js").LayoutHeaderProps & {
188
+ ref?: ForwardedRef<HTMLDivElement>;
189
+ }) => null;
190
+ displayName: string;
191
+ };
192
+ };
131
193
  };
194
+ export {};
132
195
  //# sourceMappingURL=Collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/Collection.tsx"],"names":[],"mappings":"AAIA,OAAO,EACH,mBAAmB,EAEnB,QAAQ,EACR,OAAO,EAEP,cAAc,EAEd,cAAc,EAGjB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,OAAO,CAAC;AAE9C,OAAO,EAAC,0BAA0B,EAAW,MAAM,uCAAuC,CAAC;AAM3F,MAAM,WAAW,eAAe,CAAC,CAAC,CAAE,SAAQ,mBAAmB,EAAE,QAAQ,EAAE,cAAc,CAAC,iBAAiB,CAAC;IACxG;;OAEG;IACH,OAAO,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,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QAAQ,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,SAAS,CAAC;IAEhD;;OAEG;IACH,OAAO,CAAC,EAAE,KAAK,CAAC;IAEhB;;OAEG;IACH,MAAM,CAAC,EAAE,KAAK,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,qBAAqB,CAAC,CAAC,CAAC,GAAG,sBAAsB,CAAC,CAAC,CAAC,CAAC;AAEtF,MAAM,MAAM,qBAAqB,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,GAAG,YAAY,GAAG,cAAc,CAAC;AAE/G,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC;IACpC,KAAK,EAAE,eAAe,CAAC,OAAO,CAAC,CAAC;IAChC,GAAG,EAAE,cAAc,CAAC;IACpB,WAAW,EAAE,qBAAqB,CAAC;CACtC,CAAC,CAAC;AAaH,eAAO,MAAM,UAAU;KAAI,CAAC,SAAU,eAAe,CAAC,CAAC,CAAC,GAAG;QAAC,GAAG,CAAC,EAAE,YAAY,CAAC,cAAc,CAAC,CAAA;KAAC;;;eAhBpF,eAAe,CAAC,OAAO,CAAC;aAC1B,cAAc;qBACN,qBAAqB;;;;;;mBAxJzB,CAAA;;;mBAlBoB,CAAA;;;;;;;mBA8EqE,CAAC;;;mBA1FtF,CAAC;;;;;CA6YjB,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { IconPlus } from '@coveord/plasma-react-icons';
3
2
  import { DndContext, KeyboardSensor, PointerSensor, useSensor, useSensors } from '@dnd-kit/core';
4
3
  import { restrictToParentElement, restrictToVerticalAxis } from '@dnd-kit/modifiers';
5
4
  import { SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy } from '@dnd-kit/sortable';
6
5
  import { Box, Input, Stack, useProps, useStyles } from '@mantine/core';
7
6
  import { useDidUpdate } from '@mantine/hooks';
8
7
  import { identity } from '../../utils/createFactoryComponent.js';
9
- import { Button } from '../Button/Button.js';
10
8
  import classes from './Collection.module.css';
9
+ import { CollectionAddButton } from './CollectionAddButton.js';
11
10
  import { CollectionProvider } from './CollectionContext.js';
12
11
  import { CollectionItem } from './CollectionItem.js';
12
+ import { CollectionLayouts } from './layouts/CollectionLayouts.js';
13
13
  const defaultProps = {
14
14
  draggable: false,
15
15
  addLabel: 'Add item',
@@ -21,8 +21,15 @@ const defaultProps = {
21
21
  getItemId: ({ id })=>id
22
22
  };
23
23
  export const Collection = (props)=>{
24
- const { value, onChange, onRemoveItem, onReorderItem, onInsertItem, disabled, readOnly, draggable, children, gap, required, newItem, addLabel, addDisabledTooltip, allowAdd, label, labelProps, withAsterisk, description, descriptionProps, error, errorProps, getItemId, ref, // Style props
24
+ const { value, onChange, onRemoveItem, onReorderItem, onInsertItem, disabled, readOnly, draggable, children, columns, layout, gap, required, newItem, addLabel, addDisabledTooltip, allowAdd, label, labelProps, withAsterisk, description, descriptionProps, error, errorProps, getItemId, ref, // Style props
25
25
  style, className, classNames, styles, unstyled, ...others } = useProps('Collection', defaultProps, props);
26
+ // Runtime validation: ensure columns and children are mutually exclusive
27
+ if (columns && children) {
28
+ throw new Error('Collection: Cannot use both "columns" and "children" props.');
29
+ }
30
+ if (layout && !columns) {
31
+ throw new Error('Collection: "layout" prop can only be used with "columns" prop.');
32
+ }
26
33
  const getStyles = useStyles({
27
34
  name: 'Collection',
28
35
  classes,
@@ -37,13 +44,14 @@ export const Collection = (props)=>{
37
44
  coordinateGetter: sortableKeyboardCoordinates
38
45
  }));
39
46
  const canEdit = !disabled && !readOnly;
40
- const hasOnlyOneItem = value.length === 1;
47
+ const items = value ?? [];
48
+ const hasOnlyOneItem = items.length === 1;
41
49
  /**
42
50
  * Enforcing onChange when the value is modified will make sure the errors are carried through.
43
51
  */ useDidUpdate(()=>{
44
- onChange?.(value);
52
+ onChange?.(items);
45
53
  }, [
46
- JSON.stringify(value)
54
+ JSON.stringify(items)
47
55
  ]);
48
56
  const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;
49
57
  const _label = label ? /*#__PURE__*/ _jsx(Input.Label, {
@@ -68,34 +76,10 @@ export const Collection = (props)=>{
68
76
  _description
69
77
  ]
70
78
  }) : null;
71
- const standardizedItems = value.map((item, index)=>({
79
+ const standardizedItems = items.map((item, index)=>({
72
80
  id: getItemId?.(item, index) ?? String(index),
73
81
  data: item
74
82
  }));
75
- const items = standardizedItems.map((item, index)=>/*#__PURE__*/ _jsx(CollectionItem, {
76
- id: item.id,
77
- disabled: !canEdit,
78
- draggable: draggable,
79
- onRemove: ()=>onRemoveItem?.(index),
80
- removable: !(isRequired && hasOnlyOneItem),
81
- children: children(item.data, index)
82
- }, item.id));
83
- const addAllowed = typeof allowAdd === 'boolean' ? allowAdd : allowAdd?.(value) ?? true;
84
- const _addButton = canEdit ? /*#__PURE__*/ _jsx(Box, {
85
- className: classes.addButtonContainer,
86
- children: /*#__PURE__*/ _jsx(Button.Quaternary, {
87
- leftSection: /*#__PURE__*/ _jsx(IconPlus, {
88
- size: 16
89
- }),
90
- onClick: ()=>{
91
- const newItemValue = typeof newItem === 'function' ? newItem() : newItem;
92
- onInsertItem(newItemValue, value?.length ?? 0);
93
- },
94
- disabled: !addAllowed,
95
- disabledTooltip: addDisabledTooltip,
96
- children: addLabel
97
- })
98
- }) : null;
99
83
  const getIndex = (id)=>standardizedItems.findIndex((item)=>item.id === id);
100
84
  const handleDragEnd = ({ over, active })=>{
101
85
  if (over) {
@@ -109,6 +93,76 @@ export const Collection = (props)=>{
109
93
  }
110
94
  }
111
95
  };
96
+ const addAllowed = typeof allowAdd === 'boolean' ? allowAdd : allowAdd?.(items) ?? true;
97
+ const handleAdd = ()=>{
98
+ const newItemValue = typeof newItem === 'function' ? newItem() : newItem;
99
+ onInsertItem?.(newItemValue, items?.length ?? 0);
100
+ };
101
+ const _addButton = canEdit ? /*#__PURE__*/ _jsx(CollectionAddButton, {
102
+ addLabel: addLabel,
103
+ addDisabledTooltip: addDisabledTooltip,
104
+ addAllowed: addAllowed,
105
+ onAdd: handleAdd
106
+ }) : null;
107
+ // Column-based layout pattern
108
+ if (columns) {
109
+ const Layout = layout || CollectionLayouts.Horizontal;
110
+ return /*#__PURE__*/ _jsx(CollectionProvider, {
111
+ value: {
112
+ getStyles,
113
+ columns: columns
114
+ },
115
+ children: /*#__PURE__*/ _jsx(DndContext, {
116
+ onDragEnd: handleDragEnd,
117
+ sensors: sensors,
118
+ modifiers: [
119
+ restrictToVerticalAxis,
120
+ restrictToParentElement
121
+ ],
122
+ children: /*#__PURE__*/ _jsx(SortableContext, {
123
+ items: standardizedItems,
124
+ strategy: verticalListSortingStrategy,
125
+ children: /*#__PURE__*/ _jsxs(Box, {
126
+ ref: ref,
127
+ ...others,
128
+ ...getStyles('root'),
129
+ children: [
130
+ _header,
131
+ /*#__PURE__*/ _jsxs(Layout, {
132
+ children: [
133
+ /*#__PURE__*/ _jsx(Layout.Header, {
134
+ draggable: draggable && canEdit,
135
+ removable: canEdit && !(isRequired && hasOnlyOneItem)
136
+ }),
137
+ /*#__PURE__*/ _jsx(Layout.Body, {
138
+ items: items,
139
+ onRemove: canEdit ? onRemoveItem : undefined,
140
+ removable: canEdit && !(isRequired && hasOnlyOneItem),
141
+ draggable: draggable && canEdit,
142
+ disabled: disabled,
143
+ readOnly: readOnly,
144
+ getItemId: getItemId,
145
+ gap: gap
146
+ })
147
+ ]
148
+ }),
149
+ _addButton,
150
+ _error
151
+ ]
152
+ })
153
+ })
154
+ })
155
+ });
156
+ }
157
+ // Legacy children render prop pattern
158
+ const renderedItems = standardizedItems.map((item, index)=>/*#__PURE__*/ _jsx(CollectionItem, {
159
+ id: item.id,
160
+ disabled: !canEdit,
161
+ draggable: draggable,
162
+ onRemove: ()=>onRemoveItem?.(index),
163
+ removable: !(isRequired && hasOnlyOneItem),
164
+ children: children(item.data, index)
165
+ }, item.id));
112
166
  return /*#__PURE__*/ _jsx(CollectionProvider, {
113
167
  value: {
114
168
  getStyles
@@ -133,7 +187,7 @@ export const Collection = (props)=>{
133
187
  gap: gap,
134
188
  ...getStyles('items'),
135
189
  children: [
136
- items,
190
+ renderedItems,
137
191
  _addButton
138
192
  ]
139
193
  }),
@@ -146,5 +200,6 @@ export const Collection = (props)=>{
146
200
  };
147
201
  Collection.displayName = 'Collection';
148
202
  Collection.extend = identity;
203
+ Collection.Layouts = CollectionLayouts;
149
204
 
150
205
  //# sourceMappingURL=Collection.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/components/Collection/Collection.tsx"],"sourcesContent":["import {IconPlus} from '@coveord/plasma-react-icons';\nimport {DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors} from '@dnd-kit/core';\nimport {restrictToParentElement, restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {\n __InputWrapperProps,\n Box,\n BoxProps,\n Factory,\n Input,\n MantineSpacing,\n Stack,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport {useDidUpdate} from '@mantine/hooks';\nimport {ForwardedRef, ReactNode} from 'react';\n\nimport {CustomComponentThemeExtend, identity} from '../../utils/createFactoryComponent.js';\nimport {Button} from '../Button/Button.js';\nimport classes from './Collection.module.css';\nimport {CollectionProvider} from './CollectionContext.js';\nimport {CollectionItem} from './CollectionItem.js';\n\nexport interface CollectionProps<T> extends __InputWrapperProps, BoxProps, StylesApiProps<CollectionFactory> {\n /**\n * The default value each new item should have\n */\n newItem: T | (() => T);\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * Defines how each item is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.\n *\n * This method is required when using this component with ReactHookForm.\n *\n * @see {@link https://react-hook-form.com/api/usefieldarray/} for using a collection with ReactHookForm.\n *\n * @param originalItem The original item\n * @param itemIndex The index of the original item\n */\n getItemId?: (originalItem: T, itemIndex: number) => string;\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Function that gets called whenever a collection item needs to be reordered\n *\n * @param payload The origin and destination index of the item to reorder\n */\n onReorderItem?: (payload: {from: number; to: number}) => void;\n /**\n * Function that gets called when a new item needs to be added to the collection\n *\n * @param value The value of the item to insert\n * @param index The index of the new item to insert\n */\n onInsertItem?: (value: T, index: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Whether the collection is readOnly. If true, the collection will not allow adding or removing items\n *\n * @default false\n */\n readOnly?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: boolean | ((values: T[]) => boolean);\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: string;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The gap between the colleciton items\n *\n * @default 'xs'\n */\n gap?: MantineSpacing;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\nexport type CollectionStylesNames = 'root' | 'item' | 'items' | 'itemDragging' | 'dragHandle';\n\nexport type CollectionFactory = Factory<{\n props: CollectionProps<unknown>;\n ref: HTMLDivElement;\n stylesNames: CollectionStylesNames;\n}>;\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n readOnly: false,\n gap: 'md',\n required: false,\n getItemId: ({id}: any) => id,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T> & {ref?: ForwardedRef<HTMLDivElement>}) => {\n const {\n value,\n onChange,\n onRemoveItem,\n onReorderItem,\n onInsertItem,\n disabled,\n readOnly,\n draggable,\n children,\n gap,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n withAsterisk,\n description,\n descriptionProps,\n error,\n errorProps,\n getItemId,\n ref,\n\n // Style props\n style,\n className,\n classNames,\n styles,\n unstyled,\n ...others\n } = useProps('Collection', defaultProps as CollectionProps<T>, props);\n\n const getStyles = useStyles<CollectionFactory>({\n name: 'Collection',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const canEdit = !disabled && !readOnly;\n const hasOnlyOneItem = value.length === 1;\n\n /**\n * Enforcing onChange when the value is modified will make sure the errors are carried through.\n */\n useDidUpdate(() => {\n onChange?.(value);\n }, [JSON.stringify(value)]);\n\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const _label = label ? (\n <Input.Label required={isRequired} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? (\n <Input.Error {...errorProps} pt=\"xs\">\n {error}\n </Input.Error>\n ) : null;\n const _header =\n _label || _description ? (\n <Stack gap=\"xxs\" pb=\"xs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const standardizedItems = value.map((item, index) => ({id: getItemId?.(item, index) ?? String(index), data: item}));\n\n const items = standardizedItems.map((item, index) => (\n <CollectionItem\n key={item.id}\n id={item.id}\n disabled={!canEdit}\n draggable={draggable}\n onRemove={() => onRemoveItem?.(index)}\n removable={!(isRequired && hasOnlyOneItem)}\n >\n {children(item.data, index)}\n </CollectionItem>\n ));\n\n const addAllowed = typeof allowAdd === 'boolean' ? allowAdd : (allowAdd?.(value) ?? true);\n\n const _addButton = canEdit ? (\n <Box className={classes.addButtonContainer}>\n <Button.Quaternary\n leftSection={<IconPlus size={16} />}\n onClick={() => {\n const newItemValue = typeof newItem === 'function' ? (newItem as () => T)() : newItem;\n onInsertItem(newItemValue, value?.length ?? 0);\n }}\n disabled={!addAllowed}\n disabledTooltip={addDisabledTooltip}\n >\n {addLabel}\n </Button.Quaternary>\n </Box>\n ) : null;\n\n const getIndex = (id: string) => standardizedItems.findIndex((item) => item.id === id);\n\n const handleDragEnd = ({over, active}: DragEndEvent): void => {\n if (over) {\n const activeIndex = getIndex(String(active.id));\n const overIndex = getIndex(String(over.id));\n if (activeIndex !== overIndex) {\n onReorderItem?.({from: activeIndex, to: overIndex});\n }\n }\n };\n\n return (\n <CollectionProvider value={{getStyles}}>\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box ref={ref} {...others} {...getStyles('root')}>\n {_header}\n <Stack gap={gap} {...getStyles('items')}>\n {items}\n {_addButton}\n </Stack>\n {_error}\n </Box>\n </SortableContext>\n </DndContext>\n </CollectionProvider>\n );\n};\n\nCollection.displayName = 'Collection';\n\nCollection.extend = identity as CustomComponentThemeExtend<CollectionFactory>;\n"],"names":["IconPlus","DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","restrictToParentElement","restrictToVerticalAxis","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","Box","Input","Stack","useProps","useStyles","useDidUpdate","identity","Button","classes","CollectionProvider","CollectionItem","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","readOnly","gap","required","getItemId","id","Collection","props","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","newItem","allowAdd","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","ref","style","className","classNames","styles","unstyled","others","getStyles","name","sensors","coordinateGetter","canEdit","hasOnlyOneItem","length","JSON","stringify","isRequired","_label","Label","_description","Description","_error","Error","pt","_header","pb","standardizedItems","map","item","index","String","data","items","onRemove","removable","addAllowed","_addButton","addButtonContainer","Quaternary","leftSection","size","onClick","newItemValue","disabledTooltip","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","onDragEnd","modifiers","strategy","displayName","extend"],"mappings":";AAAA,SAAQA,QAAQ,QAAO,8BAA8B;AACrD,SAAQC,UAAU,EAAgBC,cAAc,EAAEC,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAO,gBAAgB;AAC7G,SAAQC,uBAAuB,EAAEC,sBAAsB,QAAO,qBAAqB;AACnF,SAAQC,eAAe,EAAEC,2BAA2B,EAAEC,2BAA2B,QAAO,oBAAoB;AAC5G,SAEIC,GAAG,EAGHC,KAAK,EAELC,KAAK,EAELC,QAAQ,EACRC,SAAS,QACN,gBAAgB;AACvB,SAAQC,YAAY,QAAO,iBAAiB;AAG5C,SAAoCC,QAAQ,QAAO,wCAAwC;AAC3F,SAAQC,MAAM,QAAO,sBAAsB;AAC3C,OAAOC,aAAa,0BAA0B;AAC9C,SAAQC,kBAAkB,QAAO,yBAAyB;AAC1D,SAAQC,cAAc,QAAO,sBAAsB;AAuHnD,MAAMC,eAAkD;IACpDC,WAAW;IACXC,UAAU;IACVC,oBAAoB;IACpBC,UAAU;IACVC,UAAU;IACVC,KAAK;IACLC,UAAU;IACVC,WAAW,CAAC,EAACC,EAAE,EAAM,GAAKA;AAC9B;AAEA,OAAO,MAAMC,aAAa,CAAKC;IAC3B,MAAM,EACFC,KAAK,EACLC,QAAQ,EACRC,YAAY,EACZC,aAAa,EACbC,YAAY,EACZZ,QAAQ,EACRC,QAAQ,EACRJ,SAAS,EACTgB,QAAQ,EACRX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AAA,MAACC;oBAAIsC,KAAKA;oBAAM,GAAGM,MAAM;oBAAG,GAAGC,UAAU,OAAO;;wBAC3CiB;sCACD,MAAC5D;4BAAMe,KAAKA;4BAAM,GAAG4B,UAAU,QAAQ;;gCAClCyB;gCACAI;;;wBAEJf;;;;;;AAMzB,EAAE;AAEFtC,WAAWyE,WAAW,GAAG;AAEzBzE,WAAW0E,MAAM,GAAGzF"}
1
+ {"version":3,"sources":["../../../../src/components/Collection/Collection.tsx"],"sourcesContent":["import {DndContext, DragEndEvent, KeyboardSensor, PointerSensor, useSensor, useSensors} from '@dnd-kit/core';\nimport {restrictToParentElement, restrictToVerticalAxis} from '@dnd-kit/modifiers';\nimport {SortableContext, sortableKeyboardCoordinates, verticalListSortingStrategy} from '@dnd-kit/sortable';\nimport {\n __InputWrapperProps,\n Box,\n BoxProps,\n Factory,\n Input,\n MantineSpacing,\n Stack,\n StylesApiProps,\n useProps,\n useStyles,\n} from '@mantine/core';\nimport {useDidUpdate} from '@mantine/hooks';\nimport {ForwardedRef, ReactNode} from 'react';\n\nimport {CustomComponentThemeExtend, identity} from '../../utils/createFactoryComponent.js';\nimport classes from './Collection.module.css';\nimport {CollectionAddButton} from './CollectionAddButton.js';\nimport {CollectionColumnDef} from './CollectionColumn.types.js';\nimport {CollectionProvider} from './CollectionContext.js';\nimport {CollectionItem} from './CollectionItem.js';\nimport {CollectionLayout} from './layouts/CollectionLayout.types.js';\nimport {CollectionLayouts} from './layouts/CollectionLayouts.js';\n\n/**\n * Base props shared by both column-based and children-based patterns\n */\ninterface BaseCollectionProps<T> extends __InputWrapperProps, BoxProps, StylesApiProps<CollectionFactory> {\n /**\n * The default value each new item should have\n */\n newItem: T | (() => T);\n /**\n * The list of items to display inside the collection\n *\n * @default []\n */\n value?: T[];\n /**\n * Defines how each item is uniquely identified. It is highly recommended that you specify this prop to an ID that makes sense.\n *\n * This method is required when using this component with ReactHookForm.\n *\n * @see {@link https://react-hook-form.com/api/usefieldarray/} for using a collection with ReactHookForm.\n *\n * @param originalItem The original item\n * @param itemIndex The index of the original item\n */\n getItemId?: (originalItem: T, itemIndex: number) => string;\n /**\n * Unused, has no effect\n */\n onFocus?: () => void;\n /**\n * Function called whenever the value needs to be updated\n *\n * @param value The whole list of items after the change\n */\n onChange?: (value: T[]) => void;\n /**\n * Function called after an item is removed from the collection using the remove button\n *\n * @param itemIndex The index of the item that was removed\n */\n onRemoveItem?: (itemIndex: number) => void;\n /**\n * Function that gets called whenever a collection item needs to be reordered\n *\n * @param payload The origin and destination index of the item to reorder\n */\n onReorderItem?: (payload: {from: number; to: number}) => void;\n /**\n * Function that gets called when a new item needs to be added to the collection\n *\n * @param value The value of the item to insert\n * @param index The index of the new item to insert\n */\n onInsertItem?: (value: T, index: number) => void;\n /**\n * Whether the collection should have drag and drop behavior enabled\n *\n * @default false\n */\n draggable?: boolean;\n /**\n * Whether the collection is disabled, or in other words in read only mode\n *\n * @default false\n */\n disabled?: boolean;\n /**\n * Whether the collection is readOnly. If true, the collection will not allow adding or removing items\n *\n * @default false\n */\n readOnly?: boolean;\n /**\n * Function that determines if the add item button should be enabled given the current items of the collection.\n * The button is always enabled if this props remains undefined\n *\n * @param values The current items of the collection\n */\n allowAdd?: boolean | ((values: T[]) => boolean);\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: ReactNode;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * The gap between the collection items\n *\n * @default 'md'\n */\n gap?: MantineSpacing;\n /**\n * Whether the collection is required. When required is true, the collection will hide the remove button if there is only one item\n *\n * @default false\n */\n required?: boolean;\n}\n\n/**\n * Collection with column-based layout\n */\ninterface CollectionWithColumns<T> extends BaseCollectionProps<T> {\n /**\n * Column definitions for the collection\n */\n columns: Array<CollectionColumnDef<T>>;\n\n /**\n * Layout component to use for rendering\n * @default CollectionLayouts.Horizontal\n */\n layout?: CollectionLayout;\n\n /**\n * Must not have children when using columns\n */\n children?: never;\n}\n\n/**\n * Collection with legacy children render prop\n */\ninterface CollectionWithChildren<T> extends BaseCollectionProps<T> {\n /**\n * A render function called for each item passed in the `value` prop.\n *\n * @param item The current item's value\n * @param index The current item's index\n */\n children: (item: T, index: number) => ReactNode;\n\n /**\n * Must not have columns when using children\n */\n columns?: never;\n\n /**\n * Must not have layout when using children\n */\n layout?: never;\n}\n\n/**\n * Collection props - either columns OR children, never both\n */\nexport type CollectionProps<T> = CollectionWithColumns<T> | CollectionWithChildren<T>;\n\nexport type CollectionStylesNames = 'root' | 'item' | 'items' | 'itemDragging' | 'dragHandle' | 'removeButton';\n\nexport type CollectionFactory = Factory<{\n props: CollectionProps<unknown>;\n ref: HTMLDivElement;\n stylesNames: CollectionStylesNames;\n}>;\n\nconst defaultProps: Partial<CollectionProps<unknown>> = {\n draggable: false,\n addLabel: 'Add item',\n addDisabledTooltip: 'There is already an empty item',\n disabled: false,\n readOnly: false,\n gap: 'md',\n required: false,\n getItemId: ({id}: any) => id,\n};\n\nexport const Collection = <T,>(props: CollectionProps<T> & {ref?: ForwardedRef<HTMLDivElement>}) => {\n const {\n value,\n onChange,\n onRemoveItem,\n onReorderItem,\n onInsertItem,\n disabled,\n readOnly,\n draggable,\n children,\n columns,\n layout,\n gap,\n required,\n newItem,\n addLabel,\n addDisabledTooltip,\n allowAdd,\n label,\n labelProps,\n withAsterisk,\n description,\n descriptionProps,\n error,\n errorProps,\n getItemId,\n ref,\n\n // Style props\n style,\n className,\n classNames,\n styles,\n unstyled,\n ...others\n } = useProps('Collection', defaultProps as CollectionProps<T>, props);\n\n // Runtime validation: ensure columns and children are mutually exclusive\n if (columns && children) {\n throw new Error('Collection: Cannot use both \"columns\" and \"children\" props.');\n }\n\n if (layout && !columns) {\n throw new Error('Collection: \"layout\" prop can only be used with \"columns\" prop.');\n }\n\n const getStyles = useStyles<CollectionFactory>({\n name: 'Collection',\n classes,\n props,\n className,\n style,\n classNames,\n styles,\n unstyled,\n });\n const sensors = useSensors(\n useSensor(PointerSensor),\n useSensor(KeyboardSensor, {\n coordinateGetter: sortableKeyboardCoordinates,\n }),\n );\n\n const canEdit = !disabled && !readOnly;\n const items = value ?? [];\n const hasOnlyOneItem = items.length === 1;\n\n /**\n * Enforcing onChange when the value is modified will make sure the errors are carried through.\n */\n useDidUpdate(() => {\n onChange?.(items);\n }, [JSON.stringify(items)]);\n\n const isRequired = typeof withAsterisk === 'boolean' ? withAsterisk : required;\n const _label = label ? (\n <Input.Label required={isRequired} {...labelProps}>\n {label}\n </Input.Label>\n ) : null;\n\n const _description = description ? (\n <Input.Description {...descriptionProps}>{description}</Input.Description>\n ) : null;\n const _error = error ? (\n <Input.Error {...errorProps} pt=\"xs\">\n {error}\n </Input.Error>\n ) : null;\n const _header =\n _label || _description ? (\n <Stack gap=\"xxs\" pb=\"xs\">\n {_label}\n {_description}\n </Stack>\n ) : null;\n\n const standardizedItems = items.map((item, index) => ({id: getItemId?.(item, index) ?? String(index), data: item}));\n\n const getIndex = (id: string) => standardizedItems.findIndex((item) => item.id === id);\n\n const handleDragEnd = ({over, active}: DragEndEvent): void => {\n if (over) {\n const activeIndex = getIndex(String(active.id));\n const overIndex = getIndex(String(over.id));\n if (activeIndex !== overIndex) {\n onReorderItem?.({from: activeIndex, to: overIndex});\n }\n }\n };\n\n const addAllowed = typeof allowAdd === 'boolean' ? allowAdd : (allowAdd?.(items) ?? true);\n\n const handleAdd = () => {\n const newItemValue = typeof newItem === 'function' ? (newItem as () => T)() : newItem;\n onInsertItem?.(newItemValue, items?.length ?? 0);\n };\n\n const _addButton = canEdit ? (\n <CollectionAddButton\n addLabel={addLabel}\n addDisabledTooltip={addDisabledTooltip}\n addAllowed={addAllowed}\n onAdd={handleAdd}\n />\n ) : null;\n\n // Column-based layout pattern\n if (columns) {\n const Layout = layout || CollectionLayouts.Horizontal;\n\n return (\n <CollectionProvider value={{getStyles, columns: columns as Array<CollectionColumnDef<unknown>>}}>\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box ref={ref} {...others} {...getStyles('root')}>\n {_header}\n <Layout>\n <Layout.Header\n draggable={draggable && canEdit}\n removable={canEdit && !(isRequired && hasOnlyOneItem)}\n />\n <Layout.Body\n items={items}\n onRemove={canEdit ? onRemoveItem : undefined}\n removable={canEdit && !(isRequired && hasOnlyOneItem)}\n draggable={draggable && canEdit}\n disabled={disabled}\n readOnly={readOnly}\n getItemId={getItemId}\n gap={gap}\n />\n </Layout>\n {_addButton}\n {_error}\n </Box>\n </SortableContext>\n </DndContext>\n </CollectionProvider>\n );\n }\n\n // Legacy children render prop pattern\n const renderedItems = standardizedItems.map((item, index) => (\n <CollectionItem\n key={item.id}\n id={item.id}\n disabled={!canEdit}\n draggable={draggable}\n onRemove={() => onRemoveItem?.(index)}\n removable={!(isRequired && hasOnlyOneItem)}\n >\n {children(item.data, index)}\n </CollectionItem>\n ));\n\n return (\n <CollectionProvider value={{getStyles}}>\n <DndContext\n onDragEnd={handleDragEnd}\n sensors={sensors}\n modifiers={[restrictToVerticalAxis, restrictToParentElement]}\n >\n <SortableContext items={standardizedItems} strategy={verticalListSortingStrategy}>\n <Box ref={ref} {...others} {...getStyles('root')}>\n {_header}\n <Stack gap={gap} {...getStyles('items')}>\n {renderedItems}\n {_addButton}\n </Stack>\n {_error}\n </Box>\n </SortableContext>\n </DndContext>\n </CollectionProvider>\n );\n};\n\nCollection.displayName = 'Collection';\n\nCollection.extend = identity as CustomComponentThemeExtend<CollectionFactory>;\n\nCollection.Layouts = CollectionLayouts;\n"],"names":["DndContext","KeyboardSensor","PointerSensor","useSensor","useSensors","restrictToParentElement","restrictToVerticalAxis","SortableContext","sortableKeyboardCoordinates","verticalListSortingStrategy","Box","Input","Stack","useProps","useStyles","useDidUpdate","identity","classes","CollectionAddButton","CollectionProvider","CollectionItem","CollectionLayouts","defaultProps","draggable","addLabel","addDisabledTooltip","disabled","readOnly","gap","required","getItemId","id","Collection","props","value","onChange","onRemoveItem","onReorderItem","onInsertItem","children","columns","layout","newItem","allowAdd","label","labelProps","withAsterisk","description","descriptionProps","error","errorProps","ref","style","className","classNames","styles","unstyled","others","Error","getStyles","name","sensors","coordinateGetter","canEdit","items","hasOnlyOneItem","length","JSON","stringify","isRequired","_label","Label","_description","Description","_error","pt","_header","pb","standardizedItems","map","item","index","String","data","getIndex","findIndex","handleDragEnd","over","active","activeIndex","overIndex","from","to","addAllowed","handleAdd","newItemValue","_addButton","onAdd","Layout","Horizontal","onDragEnd","modifiers","strategy","Header","removable","Body","onRemove","undefined","renderedItems","displayName","extend","Layouts"],"mappings":";AAAA,SAAQA,UAAU,EAAgBC,cAAc,EAAEC,aAAa,EAAEC,SAAS,EAAEC,UAAU,QAAO,gBAAgB;AAC7G,SAAQC,uBAAuB,EAAEC,sBAAsB,QAAO,qBAAqB;AACnF,SAAQC,eAAe,EAAEC,2BAA2B,EAAEC,2BAA2B,QAAO,oBAAoB;AAC5G,SAEIC,GAAG,EAGHC,KAAK,EAELC,KAAK,EAELC,QAAQ,EACRC,SAAS,QACN,gBAAgB;AACvB,SAAQC,YAAY,QAAO,iBAAiB;AAG5C,SAAoCC,QAAQ,QAAO,wCAAwC;AAC3F,OAAOC,aAAa,0BAA0B;AAC9C,SAAQC,mBAAmB,QAAO,2BAA2B;AAE7D,SAAQC,kBAAkB,QAAO,yBAAyB;AAC1D,SAAQC,cAAc,QAAO,sBAAsB;AAEnD,SAAQC,iBAAiB,QAAO,iCAAiC;AAoKjE,MAAMC,eAAkD;IACpDC,WAAW;IACXC,UAAU;IACVC,oBAAoB;IACpBC,UAAU;IACVC,UAAU;IACVC,KAAK;IACLC,UAAU;IACVC,WAAW,CAAC,EAACC,EAAE,EAAM,GAAKA;AAC9B;AAEA,OAAO,MAAMC,aAAa,CAAKC;IAC3B,MAAM,EACFC,KAAK,EACLC,QAAQ,EACRC,YAAY,EACZC,aA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AAG1F"}
@@ -20,9 +20,21 @@
20
20
  }
21
21
 
22
22
  .dragHandle {
23
- cursor: move;
23
+ cursor: grab;
24
+ display: flex;
25
+ align-items: center;
26
+
27
+ &:active {
28
+ cursor: grabbing;
29
+ }
30
+ }
31
+
32
+ .removeButton {
33
+ display: flex;
34
+ align-items: center;
24
35
  }
25
36
 
26
37
  .addButtonContainer {
27
38
  align-self: flex-start;
39
+ width: min-content;
28
40
  }
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ export interface CollectionAddButtonProps {
3
+ /**
4
+ * The label of the add item button
5
+ *
6
+ * @default "Add item"
7
+ */
8
+ addLabel?: ReactNode;
9
+ /**
10
+ * The tooltip text displayed when hovering over the disabled add item button
11
+ *
12
+ * @default 'There is already an empty item'
13
+ */
14
+ addDisabledTooltip?: string;
15
+ /**
16
+ * Whether the add button is allowed/enabled
17
+ */
18
+ addAllowed: boolean;
19
+ /**
20
+ * Callback when the add button is clicked
21
+ */
22
+ onAdd: () => void;
23
+ }
24
+ export declare const CollectionAddButton: ({ addLabel, addDisabledTooltip, addAllowed, onAdd }: CollectionAddButtonProps) => import("react/jsx-runtime").JSX.Element;
25
+ //# sourceMappingURL=CollectionAddButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CollectionAddButton.d.ts","sourceRoot":"","sources":["../../../../src/components/Collection/CollectionAddButton.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AAKhC,MAAM,WAAW,wBAAwB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;OAEG;IACH,UAAU,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,eAAO,MAAM,mBAAmB,GAAI,qDAAmD,wBAAwB,4CAW9G,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { IconPlus } from '@coveord/plasma-react-icons';
3
+ import { Box } from '@mantine/core';
4
+ import { Button } from '../Button/Button.js';
5
+ import classes from './Collection.module.css';
6
+ export const CollectionAddButton = ({ addLabel, addDisabledTooltip, addAllowed, onAdd })=>/*#__PURE__*/ _jsx(Box, {
7
+ className: classes.addButtonContainer,
8
+ children: /*#__PURE__*/ _jsx(Button.Quaternary, {
9
+ leftSection: /*#__PURE__*/ _jsx(IconPlus, {
10
+ size: 16
11
+ }),
12
+ onClick: onAdd,
13
+ disabled: !addAllowed,
14
+ disabledTooltip: addDisabledTooltip,
15
+ children: addLabel
16
+ })
17
+ });
18
+
19
+ //# sourceMappingURL=CollectionAddButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/components/Collection/CollectionAddButton.tsx"],"sourcesContent":["import {IconPlus} from '@coveord/plasma-react-icons';\nimport {Box} from '@mantine/core';\nimport {ReactNode} from 'react';\n\nimport {Button} from '../Button/Button.js';\nimport classes from './Collection.module.css';\n\nexport interface CollectionAddButtonProps {\n /**\n * The label of the add item button\n *\n * @default \"Add item\"\n */\n addLabel?: ReactNode;\n /**\n * The tooltip text displayed when hovering over the disabled add item button\n *\n * @default 'There is already an empty item'\n */\n addDisabledTooltip?: string;\n /**\n * Whether the add button is allowed/enabled\n */\n addAllowed: boolean;\n /**\n * Callback when the add button is clicked\n */\n onAdd: () => void;\n}\n\nexport const CollectionAddButton = ({addLabel, addDisabledTooltip, addAllowed, onAdd}: CollectionAddButtonProps) => (\n <Box className={classes.addButtonContainer}>\n <Button.Quaternary\n leftSection={<IconPlus size={16} />}\n onClick={onAdd}\n disabled={!addAllowed}\n disabledTooltip={addDisabledTooltip}\n >\n {addLabel}\n </Button.Quaternary>\n </Box>\n);\n"],"names":["IconPlus","Box","Button","classes","CollectionAddButton","addLabel","addDisabledTooltip","addAllowed","onAdd","className","addButtonContainer","Quaternary","leftSection","size","onClick","disabled","disabledTooltip"],"mappings":";AAAA,SAAQA,QAAQ,QAAO,8BAA8B;AACrD,SAAQC,GAAG,QAAO,gBAAgB;AAGlC,SAAQC,MAAM,QAAO,sBAAsB;AAC3C,OAAOC,aAAa,0BAA0B;AAyB9C,OAAO,MAAMC,sBAAsB,CAAC,EAACC,QAAQ,EAAEC,kBAAkB,EAAEC,UAAU,EAAEC,KAAK,EAA2B,iBAC3G,KAACP;QAAIQ,WAAWN,QAAQO,kBAAkB;kBACtC,cAAA,KAACR,OAAOS,UAAU;YACdC,2BAAa,KAACZ;gBAASa,MAAM;;YAC7BC,SAASN;YACTO,UAAU,CAACR;YACXS,iBAAiBV;sBAEhBD;;OAGX"}