@canonical/react-ds-app-launchpad 0.9.0-experimental.2 → 0.9.0-experimental.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/dist/esm/ui/FileTree/Context.js +4 -0
  2. package/dist/esm/ui/FileTree/Context.js.map +1 -0
  3. package/dist/esm/ui/FileTree/Provider.js +74 -0
  4. package/dist/esm/ui/FileTree/Provider.js.map +1 -0
  5. package/dist/esm/ui/FileTree/common/File/File.js +12 -0
  6. package/dist/esm/ui/FileTree/common/File/File.js.map +1 -0
  7. package/dist/esm/ui/FileTree/common/File/index.js +4 -0
  8. package/dist/esm/ui/FileTree/common/File/index.js.map +1 -0
  9. package/dist/esm/ui/FileTree/common/File/types.js.map +1 -0
  10. package/dist/esm/ui/FileTree/common/Folder/Folder.js +12 -0
  11. package/dist/esm/ui/FileTree/common/Folder/Folder.js.map +1 -0
  12. package/dist/esm/ui/FileTree/common/Folder/index.js +4 -0
  13. package/dist/esm/ui/FileTree/common/Folder/index.js.map +1 -0
  14. package/dist/esm/ui/FileTree/common/Folder/types.js.map +1 -0
  15. package/dist/esm/ui/FileTree/common/IndentationBlock/IndentationBlock.js +16 -0
  16. package/dist/esm/ui/FileTree/common/IndentationBlock/IndentationBlock.js.map +1 -0
  17. package/dist/esm/ui/FileTree/common/IndentationBlock/index.js +4 -0
  18. package/dist/esm/ui/FileTree/common/IndentationBlock/index.js.map +1 -0
  19. package/dist/esm/ui/FileTree/common/IndentationBlock/types.js +2 -0
  20. package/dist/esm/ui/FileTree/common/IndentationBlock/types.js.map +1 -0
  21. package/dist/esm/ui/FileTree/common/Node/Context.js +10 -0
  22. package/dist/esm/ui/FileTree/common/Node/Context.js.map +1 -0
  23. package/dist/esm/ui/FileTree/common/Node/Provider.js +163 -0
  24. package/dist/esm/ui/FileTree/common/Node/Provider.js.map +1 -0
  25. package/dist/esm/ui/FileTree/common/Node/hooks/index.js +2 -0
  26. package/dist/esm/ui/FileTree/common/Node/hooks/index.js.map +1 -0
  27. package/dist/esm/ui/FileTree/common/Node/hooks/useNode.js +12 -0
  28. package/dist/esm/ui/FileTree/common/Node/hooks/useNode.js.map +1 -0
  29. package/dist/esm/ui/FileTree/common/Node/index.js +4 -0
  30. package/dist/esm/ui/FileTree/common/Node/index.js.map +1 -0
  31. package/dist/esm/ui/FileTree/common/Node/types.js +2 -0
  32. package/dist/esm/ui/FileTree/common/Node/types.js.map +1 -0
  33. package/dist/esm/ui/FileTree/common/SearchBox/SearchBox.js +31 -0
  34. package/dist/esm/ui/FileTree/common/SearchBox/SearchBox.js.map +1 -0
  35. package/dist/esm/ui/FileTree/common/SearchBox/index.js +4 -0
  36. package/dist/esm/ui/FileTree/common/SearchBox/index.js.map +1 -0
  37. package/dist/esm/ui/FileTree/common/SearchBox/types.js +2 -0
  38. package/dist/esm/ui/FileTree/common/SearchBox/types.js.map +1 -0
  39. package/dist/esm/ui/FileTree/common/TreeView/TreeView.js +60 -0
  40. package/dist/esm/ui/FileTree/common/TreeView/TreeView.js.map +1 -0
  41. package/dist/esm/ui/FileTree/common/TreeView/index.js +4 -0
  42. package/dist/esm/ui/FileTree/common/TreeView/index.js.map +1 -0
  43. package/dist/esm/ui/FileTree/common/TreeView/types.js +2 -0
  44. package/dist/esm/ui/FileTree/common/TreeView/types.js.map +1 -0
  45. package/dist/esm/ui/FileTree/common/index.js +5 -0
  46. package/dist/esm/ui/FileTree/common/index.js.map +1 -0
  47. package/dist/esm/ui/FileTree/hooks/index.js +2 -0
  48. package/dist/esm/ui/FileTree/hooks/index.js.map +1 -0
  49. package/dist/esm/ui/FileTree/hooks/useFileTree.js +11 -0
  50. package/dist/esm/ui/FileTree/hooks/useFileTree.js.map +1 -0
  51. package/dist/esm/ui/FileTree/index.js +10 -0
  52. package/dist/esm/ui/FileTree/index.js.map +1 -0
  53. package/dist/esm/ui/FileTree/styles.css +47 -0
  54. package/dist/esm/ui/FileTree/types.js +2 -0
  55. package/dist/esm/ui/{Button → FileTree}/types.js.map +1 -1
  56. package/dist/esm/ui/FileTree/utils/hashNodeName.js +11 -0
  57. package/dist/esm/ui/FileTree/utils/hashNodeName.js.map +1 -0
  58. package/dist/esm/ui/FileTree/utils/index.js +2 -0
  59. package/dist/esm/ui/FileTree/utils/index.js.map +1 -0
  60. package/dist/esm/ui/GitDiffViewer/Context.js +4 -0
  61. package/dist/esm/ui/GitDiffViewer/Context.js.map +1 -0
  62. package/dist/esm/ui/GitDiffViewer/Provider.js +31 -0
  63. package/dist/esm/ui/GitDiffViewer/Provider.js.map +1 -0
  64. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.js +119 -0
  65. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.js.map +1 -0
  66. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.js +33 -0
  67. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.js.map +1 -0
  68. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/index.js +4 -0
  69. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/index.js.map +1 -0
  70. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.js +2 -0
  71. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.js.map +1 -0
  72. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/index.js +2 -0
  73. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/common/index.js.map +1 -0
  74. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/index.js +4 -0
  75. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/index.js.map +1 -0
  76. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/types.js +2 -0
  77. package/dist/esm/ui/GitDiffViewer/common/CodeDiffViewer/types.js.map +1 -0
  78. package/dist/esm/ui/GitDiffViewer/common/FileHeader/FileHeader.js +35 -0
  79. package/dist/esm/ui/GitDiffViewer/common/FileHeader/FileHeader.js.map +1 -0
  80. package/dist/esm/ui/GitDiffViewer/common/FileHeader/index.js +4 -0
  81. package/dist/esm/ui/GitDiffViewer/common/FileHeader/index.js.map +1 -0
  82. package/dist/esm/ui/GitDiffViewer/common/FileHeader/types.js +2 -0
  83. package/dist/esm/ui/GitDiffViewer/common/FileHeader/types.js.map +1 -0
  84. package/dist/esm/ui/GitDiffViewer/common/index.js +3 -0
  85. package/dist/esm/ui/GitDiffViewer/common/index.js.map +1 -0
  86. package/dist/esm/ui/GitDiffViewer/hooks/index.js +2 -0
  87. package/dist/esm/ui/GitDiffViewer/hooks/index.js.map +1 -0
  88. package/dist/esm/ui/GitDiffViewer/hooks/useGitDiffViewer.js +11 -0
  89. package/dist/esm/ui/GitDiffViewer/hooks/useGitDiffViewer.js.map +1 -0
  90. package/dist/esm/ui/GitDiffViewer/index.js +9 -0
  91. package/dist/esm/ui/GitDiffViewer/index.js.map +1 -0
  92. package/dist/esm/ui/GitDiffViewer/styles.css +38 -0
  93. package/dist/esm/ui/GitDiffViewer/types.js +2 -0
  94. package/dist/esm/ui/{Chip → GitDiffViewer}/types.js.map +1 -1
  95. package/dist/esm/ui/GitDiffViewer/utils/index.js +2 -0
  96. package/dist/esm/ui/GitDiffViewer/utils/index.js.map +1 -0
  97. package/dist/esm/ui/GitDiffViewer/utils/parseGitDiff.js +73 -0
  98. package/dist/esm/ui/GitDiffViewer/utils/parseGitDiff.js.map +1 -0
  99. package/dist/esm/ui/index.js +1 -1
  100. package/dist/esm/ui/index.js.map +1 -1
  101. package/dist/types/ui/FileTree/Context.d.ts +4 -0
  102. package/dist/types/ui/FileTree/Context.d.ts.map +1 -0
  103. package/dist/types/ui/FileTree/Provider.d.ts +7 -0
  104. package/dist/types/ui/FileTree/Provider.d.ts.map +1 -0
  105. package/dist/types/ui/FileTree/common/File/File.d.ts +10 -0
  106. package/dist/types/ui/FileTree/common/File/File.d.ts.map +1 -0
  107. package/dist/types/ui/FileTree/common/File/index.d.ts +3 -0
  108. package/dist/types/ui/FileTree/common/File/index.d.ts.map +1 -0
  109. package/dist/types/ui/FileTree/common/File/types.d.ts +16 -0
  110. package/dist/types/ui/FileTree/common/File/types.d.ts.map +1 -0
  111. package/dist/types/ui/FileTree/common/Folder/Folder.d.ts +10 -0
  112. package/dist/types/ui/FileTree/common/Folder/Folder.d.ts.map +1 -0
  113. package/dist/types/ui/FileTree/common/Folder/index.d.ts +3 -0
  114. package/dist/types/ui/FileTree/common/Folder/index.d.ts.map +1 -0
  115. package/dist/types/ui/FileTree/common/Folder/types.d.ts +16 -0
  116. package/dist/types/ui/FileTree/common/Folder/types.d.ts.map +1 -0
  117. package/dist/types/ui/FileTree/common/IndentationBlock/IndentationBlock.d.ts +10 -0
  118. package/dist/types/ui/FileTree/common/IndentationBlock/IndentationBlock.d.ts.map +1 -0
  119. package/dist/types/ui/FileTree/common/IndentationBlock/index.d.ts +3 -0
  120. package/dist/types/ui/FileTree/common/IndentationBlock/index.d.ts.map +1 -0
  121. package/dist/types/ui/FileTree/common/IndentationBlock/types.d.ts +12 -0
  122. package/dist/types/ui/FileTree/common/IndentationBlock/types.d.ts.map +1 -0
  123. package/dist/types/ui/FileTree/common/Node/Context.d.ts +5 -0
  124. package/dist/types/ui/FileTree/common/Node/Context.d.ts.map +1 -0
  125. package/dist/types/ui/FileTree/common/Node/Provider.d.ts +6 -0
  126. package/dist/types/ui/FileTree/common/Node/Provider.d.ts.map +1 -0
  127. package/dist/types/ui/FileTree/common/Node/hooks/index.d.ts +2 -0
  128. package/dist/types/ui/FileTree/common/Node/hooks/index.d.ts.map +1 -0
  129. package/dist/types/ui/FileTree/common/Node/hooks/useNode.d.ts +3 -0
  130. package/dist/types/ui/FileTree/common/Node/hooks/useNode.d.ts.map +1 -0
  131. package/dist/types/ui/FileTree/common/Node/index.d.ts +5 -0
  132. package/dist/types/ui/FileTree/common/Node/index.d.ts.map +1 -0
  133. package/dist/types/ui/FileTree/common/Node/types.d.ts +28 -0
  134. package/dist/types/ui/FileTree/common/Node/types.d.ts.map +1 -0
  135. package/dist/types/ui/FileTree/common/SearchBox/SearchBox.d.ts +10 -0
  136. package/dist/types/ui/FileTree/common/SearchBox/SearchBox.d.ts.map +1 -0
  137. package/dist/types/ui/FileTree/common/SearchBox/index.d.ts +3 -0
  138. package/dist/types/ui/FileTree/common/SearchBox/index.d.ts.map +1 -0
  139. package/dist/types/ui/FileTree/common/SearchBox/types.d.ts +12 -0
  140. package/dist/types/ui/FileTree/common/SearchBox/types.d.ts.map +1 -0
  141. package/dist/types/ui/FileTree/common/TreeView/TreeView.d.ts +16 -0
  142. package/dist/types/ui/FileTree/common/TreeView/TreeView.d.ts.map +1 -0
  143. package/dist/types/ui/FileTree/common/TreeView/index.d.ts +3 -0
  144. package/dist/types/ui/FileTree/common/TreeView/index.d.ts.map +1 -0
  145. package/dist/types/ui/FileTree/common/TreeView/types.d.ts +20 -0
  146. package/dist/types/ui/FileTree/common/TreeView/types.d.ts.map +1 -0
  147. package/dist/types/ui/FileTree/common/index.d.ts +5 -0
  148. package/dist/types/ui/FileTree/common/index.d.ts.map +1 -0
  149. package/dist/types/ui/FileTree/hooks/index.d.ts +2 -0
  150. package/dist/types/ui/FileTree/hooks/index.d.ts.map +1 -0
  151. package/dist/types/ui/FileTree/hooks/useFileTree.d.ts +3 -0
  152. package/dist/types/ui/FileTree/hooks/useFileTree.d.ts.map +1 -0
  153. package/dist/types/ui/FileTree/index.d.ts +5 -0
  154. package/dist/types/ui/FileTree/index.d.ts.map +1 -0
  155. package/dist/types/ui/FileTree/types.d.ts +69 -0
  156. package/dist/types/ui/FileTree/types.d.ts.map +1 -0
  157. package/dist/types/ui/FileTree/utils/hashNodeName.d.ts +3 -0
  158. package/dist/types/ui/FileTree/utils/hashNodeName.d.ts.map +1 -0
  159. package/dist/types/ui/FileTree/utils/index.d.ts +2 -0
  160. package/dist/types/ui/FileTree/utils/index.d.ts.map +1 -0
  161. package/dist/types/ui/GitDiffViewer/Context.d.ts +4 -0
  162. package/dist/types/ui/GitDiffViewer/Context.d.ts.map +1 -0
  163. package/dist/types/ui/GitDiffViewer/Provider.d.ts +5 -0
  164. package/dist/types/ui/GitDiffViewer/Provider.d.ts.map +1 -0
  165. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.d.ts +16 -0
  166. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.d.ts.map +1 -0
  167. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.d.ts +11 -0
  168. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.d.ts.map +1 -0
  169. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/index.d.ts +3 -0
  170. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/index.d.ts.map +1 -0
  171. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.d.ts +20 -0
  172. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.d.ts.map +1 -0
  173. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/index.d.ts +2 -0
  174. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/common/index.d.ts.map +1 -0
  175. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/index.d.ts +3 -0
  176. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/index.d.ts.map +1 -0
  177. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/types.d.ts +18 -0
  178. package/dist/types/ui/GitDiffViewer/common/CodeDiffViewer/types.d.ts.map +1 -0
  179. package/dist/types/ui/GitDiffViewer/common/FileHeader/FileHeader.d.ts +15 -0
  180. package/dist/types/ui/GitDiffViewer/common/FileHeader/FileHeader.d.ts.map +1 -0
  181. package/dist/types/ui/GitDiffViewer/common/FileHeader/index.d.ts +3 -0
  182. package/dist/types/ui/GitDiffViewer/common/FileHeader/index.d.ts.map +1 -0
  183. package/dist/types/ui/GitDiffViewer/common/FileHeader/types.d.ts +17 -0
  184. package/dist/types/ui/GitDiffViewer/common/FileHeader/types.d.ts.map +1 -0
  185. package/dist/types/ui/GitDiffViewer/common/index.d.ts +3 -0
  186. package/dist/types/ui/GitDiffViewer/common/index.d.ts.map +1 -0
  187. package/dist/types/ui/GitDiffViewer/hooks/index.d.ts +2 -0
  188. package/dist/types/ui/GitDiffViewer/hooks/index.d.ts.map +1 -0
  189. package/dist/types/ui/GitDiffViewer/hooks/useGitDiffViewer.d.ts +3 -0
  190. package/dist/types/ui/GitDiffViewer/hooks/useGitDiffViewer.d.ts.map +1 -0
  191. package/dist/types/ui/GitDiffViewer/index.d.ts +6 -0
  192. package/dist/types/ui/GitDiffViewer/index.d.ts.map +1 -0
  193. package/dist/types/ui/GitDiffViewer/types.d.ts +77 -0
  194. package/dist/types/ui/GitDiffViewer/types.d.ts.map +1 -0
  195. package/dist/types/ui/GitDiffViewer/utils/index.d.ts +2 -0
  196. package/dist/types/ui/GitDiffViewer/utils/index.d.ts.map +1 -0
  197. package/dist/types/ui/GitDiffViewer/utils/parseGitDiff.d.ts +4 -0
  198. package/dist/types/ui/GitDiffViewer/utils/parseGitDiff.d.ts.map +1 -0
  199. package/dist/types/ui/index.d.ts +1 -1
  200. package/dist/types/ui/index.d.ts.map +1 -1
  201. package/package.json +5 -3
  202. package/dist/esm/ui/Button/Button.js +0 -10
  203. package/dist/esm/ui/Button/Button.js.map +0 -1
  204. package/dist/esm/ui/Button/index.js +0 -2
  205. package/dist/esm/ui/Button/index.js.map +0 -1
  206. package/dist/esm/ui/Button/styles.css +0 -63
  207. package/dist/esm/ui/Chip/Chip.css +0 -79
  208. package/dist/esm/ui/Chip/Chip.js +0 -15
  209. package/dist/esm/ui/Chip/Chip.js.map +0 -1
  210. package/dist/esm/ui/Chip/index.js +0 -4
  211. package/dist/esm/ui/Chip/index.js.map +0 -1
  212. package/dist/types/ui/Button/Button.d.ts +0 -6
  213. package/dist/types/ui/Button/Button.d.ts.map +0 -1
  214. package/dist/types/ui/Button/index.d.ts +0 -3
  215. package/dist/types/ui/Button/index.d.ts.map +0 -1
  216. package/dist/types/ui/Button/types.d.ts +0 -15
  217. package/dist/types/ui/Button/types.d.ts.map +0 -1
  218. package/dist/types/ui/Chip/Chip.d.ts +0 -10
  219. package/dist/types/ui/Chip/Chip.d.ts.map +0 -1
  220. package/dist/types/ui/Chip/index.d.ts +0 -3
  221. package/dist/types/ui/Chip/index.d.ts.map +0 -1
  222. package/dist/types/ui/Chip/types.d.ts +0 -27
  223. package/dist/types/ui/Chip/types.d.ts.map +0 -1
  224. /package/dist/esm/ui/{Button → FileTree/common/File}/types.js +0 -0
  225. /package/dist/esm/ui/{Chip → FileTree/common/Folder}/types.js +0 -0
@@ -0,0 +1,10 @@
1
+ /* @canonical/generator-ds 0.9.0-experimental.1 */
2
+ export * from "./hooks/index.js";
3
+ import Provider from "./Provider.js";
4
+ import { File, Folder, SearchBox, TreeView } from "./common/index.js";
5
+ export const FileTree = Provider;
6
+ FileTree.SearchBox = SearchBox;
7
+ FileTree.File = File;
8
+ FileTree.TreeView = TreeView;
9
+ FileTree.Folder = Folder;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/FileTree/index.ts"],"names":[],"mappings":"AAAA,kDAAkD;AAClD,cAAc,kBAAkB,CAAC;AAOjC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGtE,MAAM,CAAC,MAAM,QAAQ,GAAG,QAA6B,CAAC;AACtD,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC;AAC/B,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;AACrB,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAC;AAC7B,QAAQ,CAAC,MAAM,GAAG,MAAM,CAAC"}
@@ -0,0 +1,47 @@
1
+ /* @canonical/generator-ds 0.9.0-experimental.1 */
2
+
3
+ .ds.file-tree {
4
+ --file-tree-container-border-color: #c4c4c4;
5
+
6
+ --file-tree-node-icon-size: 16px;
7
+ --file-tree-node-text-color-default: rgba(0, 0, 0, 0.6);
8
+ --file-tree-node-text-color-active: #000000;
9
+
10
+ --file-tree-node-background-color: #ffffff;
11
+ --file-tree-node-background-color-hover: #f2f2f2;
12
+ --file-tree-node-focus-outline-color: #878787;
13
+
14
+ --file-tree-node-indent-width: 16px;
15
+ --file-tree-node-indent-bar-color: #efefef;
16
+ --file-tree-node-indent-bar-width: 1px;
17
+ --file-tree-node-items-gap: 8px;
18
+ --file-tree-node-horizontal-padding: 8px;
19
+ --file-tree-node-vertical-padding: 2px;
20
+
21
+ --file-tree-node-file-icon: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M6.99194 2.5H4.5V13.5H11.5V7.00806H9.24194C7.9993 7.00806 6.99194 6.0007 6.99194 4.75806V2.5ZM10.8869 5.50806L8.49194 3.1127V4.75806C8.49194 5.17227 8.82773 5.50806 9.24194 5.50806H10.8869ZM3 2.5C3 1.67157 3.67157 1 4.5 1H8.08647C8.35172 1 8.60609 1.10538 8.79364 1.29295L12.7072 5.20712C12.8947 5.39465 13 5.64898 13 5.91417V13.5C13 14.3284 12.3284 15 11.5 15H4.5C3.67157 15 3 14.3284 3 13.5V2.5ZM5.65837 8.48389H10.4917V9.98389H5.65837V8.48389ZM5.65837 10.7339V12.2339H10.4917V10.7339H5.65837Z' fill='black'/%3E%3C/svg%3E%0A");
22
+ --file-tree-node-closed-folder-icon: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M10 5H13.5C14.3284 5 15 5.67157 15 6.5V12.5C15 13.3284 14.3284 14 13.5 14H2.5C1.67157 14 1 13.3284 1 12.5V3.5C1 2.67157 1.67157 2 2.5 2H8.5C9.32843 2 10 2.67157 10 3.5V5ZM8.5 3.5V5H2.5V3.5H8.5ZM2.5 12.5L2.5 6.5H13.5V12.5H2.5Z' fill='black'/%3E%3C/svg%3E%0A");
23
+ --file-tree-node-opened-folder-icon: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M6 5.46408V3.60693H2.5V8.66667L2.94235 7.09388C3.12429 6.44696 3.7143 6 4.38632 6H11.5V5.46408H6ZM13 6H14.0216C15.0862 6 15.812 7.07821 15.4113 8.06457L13.38 13.0646C13.1503 13.6301 12.6007 14 11.9903 14H2.98007C2.97153 14 2.963 13.9999 2.9545 13.9998H2.5C1.67157 13.9998 1 13.3282 1 12.4998V3.60693C1 2.77851 1.67157 2.10693 2.5 2.10693H6C6.82843 2.10693 7.5 2.77851 7.5 3.60693V3.96408H11.5C12.3284 3.96408 13 4.63565 13 5.46408V6ZM4.38632 7.5H14.0216L11.9903 12.5H2.98007L4.38632 7.5Z' fill='black'/%3E%3C/svg%3E%0A");
24
+
25
+ --file-tree-search-box-vertical-padding: 6px;
26
+ --file-tree-search-box-horizontal-padding: 8px;
27
+
28
+ --file-tree-search-box-line-height: 24px;
29
+ --file-tree-search-box-button-size: 24px;
30
+ --file-tree-search-box-border-color: #6c6c6c;
31
+
32
+ --file-tree-search-box-search-icon: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.96399 1C8.08013 1.00013 9.17384 1.31346 10.1207 1.90436C11.0676 2.49526 11.8297 3.34002 12.3203 4.34256C12.8109 5.34511 13.0103 6.4652 12.8959 7.57547C12.7815 8.68573 12.3578 9.7416 11.673 10.623L15.976 14.928L14.916 15.988L10.61 11.683C9.85937 12.2631 8.98121 12.6558 8.0484 12.8284C7.1156 13.001 6.15506 12.9487 5.24655 12.6757C4.33805 12.4026 3.50777 11.9168 2.82467 11.2586C2.14157 10.6003 1.62534 9.7886 1.31886 8.89083C1.01237 7.99305 0.924467 7.03512 1.06244 6.09656C1.20042 5.158 1.5603 4.26589 2.11219 3.49431C2.66409 2.72273 3.39208 2.09393 4.23573 1.66012C5.07938 1.22631 6.01434 1.00001 6.96299 1H6.96399ZM6.96399 2.5C6.37221 2.49114 5.78458 2.60005 5.23528 2.82039C4.68598 3.04072 4.18598 3.36809 3.76436 3.78344C3.34274 4.19879 3.00793 4.69384 2.7794 5.23978C2.55087 5.78572 2.43318 6.37166 2.43318 6.9635C2.43318 7.55534 2.55087 8.14128 2.7794 8.68722C3.00793 9.23316 3.34274 9.72821 3.76436 10.1436C4.18598 10.5589 4.68598 10.8863 5.23528 11.1066C5.78458 11.327 6.37221 11.4359 6.96399 11.427C8.13621 11.4095 9.25448 10.9315 10.0772 10.0963C10.9 9.26115 11.3612 8.13585 11.3612 6.9635C11.3612 5.79115 10.9 4.66585 10.0772 3.83069C9.25448 2.99553 8.13621 2.51755 6.96399 2.5Z' fill='black'/%3E%3C/svg%3E%0A");
33
+ --file-tree-search-box-reset-icon: url("data:image/svg+xml,%3Csvg width='16' height='16' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill='%23000' fill-rule='nonzero' d='M13.041 1.898l1.06 1.06L9.062 8l5.04 5.042-1.06 1.06L8 9.062 2.96 14.1l-1.06-1.06L6.938 8 1.9 2.96l1.06-1.06 5.04 5.04z'/%3E%3C/svg%3E");
34
+
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: 0;
38
+ border: 1px solid var(--file-tree-container-border-color);
39
+ overflow: auto;
40
+ padding: 0;
41
+ margin: 0;
42
+
43
+ ul {
44
+ margin: 0;
45
+ padding: 0;
46
+ }
47
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ui/Button/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ui/FileTree/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ const hashNodeName = (name) => {
2
+ let hash = 0;
3
+ for (let i = 0; i < name.length; i++) {
4
+ const char = name.charCodeAt(i);
5
+ hash = (hash << 5) - hash + char;
6
+ hash |= 0;
7
+ }
8
+ return hash;
9
+ };
10
+ export default hashNodeName;
11
+ //# sourceMappingURL=hashNodeName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hashNodeName.js","sourceRoot":"","sources":["../../../../../src/ui/FileTree/utils/hashNodeName.ts"],"names":[],"mappings":"AAAA,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE;IACpC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACrC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;QAChC,IAAI,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;QACjC,IAAI,IAAI,CAAC,CAAC;IACZ,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as hashNodeName } from "./hashNodeName.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/FileTree/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createContext } from "react";
2
+ const GitDiffViewerContext = createContext(null);
3
+ export default GitDiffViewerContext;
4
+ //# sourceMappingURL=Context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Context.js","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/Context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAGtC,MAAM,oBAAoB,GAAG,aAAa,CAAwB,IAAI,CAAC,CAAC;AAExE,eAAe,oBAAoB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useCallback, useState } from "react";
3
+ import Context from "./Context.js";
4
+ import "./styles.css";
5
+ const componentCssClassName = "ds git-diff-viewer";
6
+ const Provider = ({ id, className, style, children, ...contextOptions }) => {
7
+ const [addCommentEnabled, setAddCommentEnabled] = useState(false);
8
+ const [addCommentOpenLocations, setAddCommentOpenLocations] = useState(new Set());
9
+ const toggleAddCommentLocation = useCallback((lineNumber) => {
10
+ if (!addCommentEnabled) {
11
+ return;
12
+ }
13
+ const newSet = new Set(addCommentOpenLocations);
14
+ if (newSet.has(lineNumber)) {
15
+ newSet.delete(lineNumber);
16
+ }
17
+ else {
18
+ newSet.add(lineNumber);
19
+ }
20
+ setAddCommentOpenLocations(newSet);
21
+ }, [addCommentOpenLocations, addCommentEnabled]);
22
+ return (_jsx(Context.Provider, { value: {
23
+ ...contextOptions,
24
+ addCommentEnabled,
25
+ setAddCommentEnabled,
26
+ addCommentOpenLocations,
27
+ toggleAddCommentLocation,
28
+ }, children: _jsx("div", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), children: children }) }));
29
+ };
30
+ export default Provider;
31
+ //# sourceMappingURL=Provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/Provider.tsx"],"names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AAI,CAAC,GAAG,CAAC,YAEtE,QAAQ,GACL,GACW,CACpB,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,119 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Fragment, useCallback, useEffect, useMemo, useRef } from "react";
3
+ import { useGitDiffViewer } from "../../hooks/index.js";
4
+ import { DiffLine } from "./common/index.js";
5
+ import "./styles.css";
6
+ // TODO: decide where to put this once we provide an external syntax highlighter option
7
+ import hljs from "highlight.js";
8
+ import "./HighlighTheme.css";
9
+ const componentCssClassName = "ds code-diff-viewer";
10
+ const tableWidthCSSVar = "--table-width";
11
+ /**
12
+ * Displays a diff in a table format with line numbers and syntax highlighting.
13
+ * With option to add comments to specific lines and interactive gutter for adding comments.
14
+ *
15
+ * @returns {React.ReactElement} - Rendered CodeDiffViewer
16
+ */
17
+ const CodeDiffViewer = ({ id, AddComment, className, style, }) => {
18
+ const { isCollapsed, diff, addCommentEnabled, setAddCommentEnabled, addCommentOpenLocations, toggleAddCommentLocation, lineDecorations, } = useGitDiffViewer();
19
+ const tableRef = useRef(null);
20
+ // TODO: temporary syntax highlighting
21
+ // replace with a proper syntax highlighter
22
+ // add support for option to have external syntax highlighter
23
+ const diffCodeLanguage = useMemo(() => {
24
+ const extension = diff?.newPath.split(".").pop();
25
+ const mapping = {
26
+ js: "javascript",
27
+ jsx: "javascript",
28
+ ts: "typescript",
29
+ tsx: "typescript",
30
+ css: "css",
31
+ scss: "scss",
32
+ html: "xml",
33
+ py: "python",
34
+ java: "java",
35
+ // Add more mappings as needed
36
+ };
37
+ return mapping[extension || ""] || "plaintext";
38
+ }, [diff?.newPath]);
39
+ const highlight = useCallback((code) => {
40
+ if (hljs.getLanguage(diffCodeLanguage)) {
41
+ return hljs.highlight(code, { language: diffCodeLanguage }).value;
42
+ }
43
+ return hljs.highlight(code, { language: "plaintext" }).value;
44
+ }, [diffCodeLanguage]);
45
+ const highlightedLines = useMemo(() => {
46
+ if (!diff)
47
+ return [];
48
+ return diff.hunks.map((hunk) => {
49
+ return hunk.lines.map((line) => {
50
+ return highlight(line.content);
51
+ });
52
+ });
53
+ }, [diff, highlight]);
54
+ /**
55
+ * Observe the table for size changes and update the CSS variable
56
+ */
57
+ useEffect(() => {
58
+ // SSR check
59
+ if (typeof ResizeObserver === "undefined")
60
+ return;
61
+ if (!tableRef.current)
62
+ return;
63
+ const resizeObserver = new ResizeObserver(() => {
64
+ if (!tableRef.current)
65
+ return;
66
+ const tableWidth = tableRef.current?.clientWidth ?? 0;
67
+ tableRef.current.style.cssText = `${tableWidthCSSVar}: ${tableWidth}px`;
68
+ });
69
+ // Observe the table for size changes
70
+ resizeObserver.observe(tableRef.current);
71
+ // Cleanup on unmount
72
+ return () => {
73
+ resizeObserver.disconnect();
74
+ };
75
+ }, []);
76
+ useEffect(() => {
77
+ if (AddComment && !addCommentEnabled) {
78
+ setAddCommentEnabled(true);
79
+ }
80
+ else if (!AddComment && addCommentEnabled) {
81
+ setAddCommentEnabled(false);
82
+ }
83
+ }, [AddComment, addCommentEnabled, setAddCommentEnabled]);
84
+ if (isCollapsed) {
85
+ return null;
86
+ }
87
+ return (_jsx("div", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), children: diff.hunks.map((hunk, hunkIndex) => {
88
+ // We'll track the counters for old and new lines
89
+ // as we iterate through each hunk.
90
+ let oldLineCounter = hunk.oldStart;
91
+ let newLineCounter = hunk.newStart;
92
+ return (_jsx("div", { className: "diff-hunk", children: _jsx("table", { className: "diff-table", ref: tableRef, tabIndex: -1, children: _jsxs("tbody", { children: [_jsx(DiffLine, { type: "hunk", hunkHeader: hunk.header }), hunk.lines.map((line, lineIndex) => {
93
+ let lineNum1 = null;
94
+ let lineNum2 = null;
95
+ if (line.type === "remove") {
96
+ // Only the old line number advances
97
+ lineNum1 = oldLineCounter++;
98
+ }
99
+ else if (line.type === "add") {
100
+ // Only the new line number advances
101
+ lineNum2 = newLineCounter++;
102
+ }
103
+ else {
104
+ // context line => both lines advance
105
+ lineNum1 = oldLineCounter++;
106
+ lineNum2 = newLineCounter++;
107
+ }
108
+ const lineNumber = lineNum2 || lineNum1 || 0;
109
+ // For rendering, if lineNum1 or lineNum2 is null,
110
+ // you can display e.g. '+' or '-' or an empty cell.
111
+ return (_jsxs(Fragment, { children: [_jsx(DiffLine, { lineNum1: lineNum1, lineNum2: lineNum2, content: highlightedLines[hunkIndex][lineIndex], type: line.type }), lineNum2 && lineDecorations?.[lineNum2] && (_jsx("tr", { className: "line-decoration", children: _jsx("td", { className: "container", children: lineDecorations[lineNum2] }) })), lineNum2 &&
112
+ AddComment &&
113
+ addCommentOpenLocations.has(lineNum2) && (_jsx("tr", { className: "line-decoration", children: _jsx("td", { className: "container", children: _jsx(AddComment, { lineNumber: lineNumber, onClose: () => toggleAddCommentLocation(lineNumber) }) }) }))] }, `${diff.oldPath}-${hunkIndex}-${lineIndex}`));
114
+ })] }) }) }, `${diff.oldPath}-${hunkIndex}`));
115
+ }) }));
116
+ };
117
+ CodeDiffViewer.displayName = "GitDiffViewer.CodeDiff";
118
+ export default CodeDiffViewer;
119
+ //# sourceMappingURL=CodeDiffViewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodeDiffViewer.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/CodeDiffViewer.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,cAAc,CAAC;AACtB,uFAAuF;AACvF,OAAO,IAAI,MAAM,cAAc,CAAC;AAEhC,OAAO,qBAAqB,CAAC;AAE7B,MAAM,qBAAqB,GAAG,qBAAqB,CA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cAAc,CAAC"}
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useGitDiffViewer } from "../../../../hooks/index.js";
3
+ import "./styles.css";
4
+ const componentCssClassName = "ds diff-line";
5
+ /**
6
+ * Displays a single line of a diff as a table row with line numbers.
7
+ *
8
+ * @returns {React.ReactElement} - Rendered DiffLine
9
+ */
10
+ const DiffLine = ({ id, className, style, ...props }) => {
11
+ const { wrapLines, addCommentEnabled, toggleAddCommentLocation } = useGitDiffViewer();
12
+ const gutterIsInteractive = addCommentEnabled;
13
+ const typeClass = `diff-line-${props.type}`;
14
+ const lineNumber = props.type !== "hunk" ? Number(props.lineNum2 || props.lineNum1) : 0;
15
+ return (_jsxs("tr", { id: id, style: style, className: [
16
+ componentCssClassName,
17
+ typeClass,
18
+ gutterIsInteractive ? "interactive" : "",
19
+ className,
20
+ ]
21
+ .filter(Boolean)
22
+ .join(" "), children: [_jsx("td", { className: `diff-gutter ${wrapLines ? "wrap" : ""} ${props.type}`, tabIndex: gutterIsInteractive && props.type !== "hunk" ? 0 : undefined, onClick: () => toggleAddCommentLocation(lineNumber), onKeyUp: (e) => {
23
+ if (e.key === "Enter") {
24
+ toggleAddCommentLocation(lineNumber);
25
+ }
26
+ }, onKeyDown: undefined, children: props.type === "hunk" ? ("\u00A0") : (_jsxs("div", { className: "diff-line-numbers", children: [_jsx("span", { className: "line-num", children: props.lineNum1 ?? "+" }), _jsx("span", { className: "line-num", children: props.lineNum2 ?? "-" })] })) }), _jsx("td", { className: `diff-content ${wrapLines ? "wrap" : ""}`, children: props.type === "hunk" ? (_jsx("pre", { children: props.hunkHeader })) : (_jsx("pre", {
27
+ // biome-ignore lint/security/noDangerouslySetInnerHtml: syntax highlighting requires adding generated HTML
28
+ dangerouslySetInnerHTML: {
29
+ __html: props.content ? props.content : "\u00A0",
30
+ } })) })] }));
31
+ };
32
+ export default DiffLine;
33
+ //# sourceMappingURL=DiffLine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DiffLine.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/DiffLine.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,cAAc,CAAC;AAGtB,MAAM,qBAAqB,GAAG,cAAc,CAAC;AAE7C;;;;GAIG;AACH,MAAM,QAAQ,GAAG,CAAC,EAChB,EAAE,EACF,SAAS,EACT,KAAK,EACL,GAAG,KAAK,EACM,EAAsB,EAAE;IACtC,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,GAC9D,gBAAgB,EAAE,CAAC;IACrB,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;IAC9C,MAAM,SAAS,GAAG,aAAa,KAAK,CAAC,IAAI,EAAE,CAAC;IAE5C,MAAM,UAAU,GACd,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAEvE,OAAO,CACL,cACE,EAAE,EAAE,EAAE,EACN,KAAK,EAAE,KAAK,EACZ,SAAS,EAAE;YACT,qBAAqB;YACrB,SAAS;YACT,mBAAmB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE;YACxC,SAAS;SACV;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,aAEZ,aACE,SAAS,EAAE,eAAe,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,KAAK,CAAC,IAAI,EAAE,EACjE,QAAQ,EAAE,mBAAmB,IAAI,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EACtE,OAAO,EAAE,GAAG,EAAE,CAAC,wBAAwB,CAAC,UAAU,CAAC,EACnD,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;oBACb,IAAI,CAAC,CAAC,GAAG,KAAK,OAAO,EAAE,CAAC;wBACtB,wBAAwB,CAAC,UAAU,CAAC,CAAC;oBACvC,CAAC;gBACH,CAAC,EACD,SAAS,EAAE,SAAS,YAEnB,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACvB,QAAQ,CACT,CAAC,CAAC,CAAC,CACF,eAAK,SAAS,EAAC,mBAAmB,aAChC,eAAM,SAAS,EAAC,UAAU,YAAE,KAAK,CAAC,QAAQ,IAAI,GAAG,GAAQ,EACzD,eAAM,SAAS,EAAC,UAAU,YAAE,KAAK,CAAC,QAAQ,IAAI,GAAG,GAAQ,IACrD,CACP,GACE,EACL,aAAI,SAAS,EAAE,gBAAgB,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,YACrD,KAAK,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,CACvB,wBAAM,KAAK,CAAC,UAAU,GAAO,CAC9B,CAAC,CAAC,CAAC,CACF;oBACE,2GAA2G;oBAC3G,uBAAuB,EAAE;wBACvB,MAAM,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,QAAQ;qBACjD,GACD,CACH,GACE,IACF,CACN,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -0,0 +1,4 @@
1
+ /* @canonical/generator-canonical-ds 0.0.1 */
2
+ export { default as DiffLine } from "./DiffLine.js";
3
+ export * from "./types.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/DiffLine/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export * from "./DiffLine/index.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
@@ -0,0 +1,4 @@
1
+ /* @canonical/generator-canonical-ds 0.0.1 */
2
+ export { default as CodeDiffViewer } from "./CodeDiffViewer.js";
3
+ export * from "./types.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/CodeDiffViewer/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { useCallback } from "react";
3
+ import { useGitDiffViewer } from "../../hooks/index.js";
4
+ import "./styles.css";
5
+ const componentCssClassName = "ds file-header";
6
+ /**
7
+ * Displays the file name and change count for a diff.
8
+ * With option to add custom elements to the left and right of the file header.
9
+ *
10
+ * @returns {React.ReactElement} - Rendered FileHeader
11
+ */
12
+ const FileHeader = ({ id, children, className, style, hideCollapse = false, showChangeCount, leftContent, rightContent, ...props }) => {
13
+ const { isCollapsed, onCollapseToggle, diff } = useGitDiffViewer();
14
+ const shouldRenderCollapse = !hideCollapse && isCollapsed !== undefined;
15
+ const calculateChangeCount = useCallback(() => {
16
+ let additions = 0;
17
+ let deletions = 0;
18
+ for (const hunk of diff.hunks) {
19
+ for (const line of hunk.lines) {
20
+ if (line.type === "add") {
21
+ additions++;
22
+ }
23
+ else if (line.type === "remove") {
24
+ deletions++;
25
+ }
26
+ }
27
+ }
28
+ return { additions, deletions };
29
+ }, [diff]);
30
+ const changesCount = calculateChangeCount();
31
+ return (_jsxs("div", { id: id, style: style, className: [componentCssClassName, className].filter(Boolean).join(" "), ...props, children: [_jsxs("div", { className: "left-content", children: [leftContent, shouldRenderCollapse && (_jsx("button", { className: `collapse-button ${isCollapsed ? "collapsed" : ""}`, onClick: () => onCollapseToggle(!isCollapsed), "aria-label": "Collapse file", type: "button", children: _jsxs("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [_jsx("title", { children: "Collapse" }), _jsx("path", { d: "M11.811 8.124L5.62399 1.937L4.56299 2.997L9.68999 8.124L4.56299 13.25L5.62399 14.311L11.811 8.124Z", fill: "currentColor" })] }) })), _jsx("h5", { className: "file-name", children: diff.newPath })] }), _jsxs("div", { className: "right-content", children: [showChangeCount && (_jsx("div", { className: "change-count", children: diff.fileChangeState === "modified" ? (_jsxs(_Fragment, { children: [_jsxs("span", { className: "deletions", children: ["-", changesCount.deletions] }), _jsxs("span", { className: "insertions", children: ["+", changesCount.additions] })] })) : diff.fileChangeState === "added" ? (_jsx("span", { className: "insertions", children: "Added" })) : diff.fileChangeState === "deleted" ? (_jsx("span", { className: "deletions", children: "Removed" })) : (_jsx(_Fragment, {})) })), rightContent] }), children] }));
32
+ };
33
+ FileHeader.displayName = "GitDiffViewer.FileHeader";
34
+ export default FileHeader;
35
+ //# sourceMappingURL=FileHeader.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FileHeader.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/FileHeader/FileHeader.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,cAAc,CAAC;AAGtB,MAAM,qBAAqB,GAAG,gBAAgB,CAAC;AAE/C;;;;;GAKG;AACH,MAAM,UAAU,GAAG,CAAC,EAClB,EAAE,EACF,QAAQ,EACR,SAAS,EACT,KAAK,EACL,YAAY,GAAG,KAAK,EACpB,eAAe,EACf,WAAW,EACX,YAAY,EACZ,GAAG,KAAK,EACQ,EAAsB,EAAE;IACxC,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,gBAAgB,EAAE,CAAC;IACnE,MAAM,oBAAoB,GAAG,CAAC,YAAY,IAAI,WAAW,KAAK,SAAS,CAAC;IAExE,MAAM,oBAAoB,GAAG,WAAW,CAAC,GAAG,EAAE;QAC5C,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,IAAI,SAAS,GAAG,CAAC,CAAC;QAClB,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YAC9B,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;oBACxB,SAAS,EAAE,CAAC;gBACd,CAAC;qBAAM,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBAClC,SAAS,EAAE,CAAC;gBACd,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;IAClC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACX,MAAM,YAAY,GAA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AC,WAAW,wBAAe,CAC3C,CAAC,CAAC,CAAC,CACF,mBAAK,CACN,GACG,CACP,EACA,YAAY,IACT,EACL,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,UAAU,CAAC,WAAW,GAAG,0BAA0B,CAAC;AAEpD,eAAe,UAAU,CAAC"}
@@ -0,0 +1,4 @@
1
+ /* @canonical/generator-canonical-ds 0.0.1 */
2
+ export { default as FileHeader } from "./FileHeader.js";
3
+ export * from "./types.js";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/FileHeader/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACxD,cAAc,YAAY,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../src/ui/GitDiffViewer/common/FileHeader/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from "./CodeDiffViewer/index.js";
2
+ export * from "./FileHeader/index.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/common/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { default as useGitDiffViewer } from "./useGitDiffViewer.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { useContext } from "react";
2
+ import Context from "../Context.js";
3
+ const useGitDiffViewer = () => {
4
+ const context = useContext(Context);
5
+ if (!context) {
6
+ throw new Error("useGitDiffViewer must be used within a DiffViewerProvider or GitDiffViewer component");
7
+ }
8
+ return context;
9
+ };
10
+ export default useGitDiffViewer;
11
+ //# sourceMappingURL=useGitDiffViewer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useGitDiffViewer.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/hooks/useGitDiffViewer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,OAAO,MAAM,eAAe,CAAC;AAEpC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IAC5B,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CACb,sFAAsF,CACvF,CAAC;IACJ,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,9 @@
1
+ /* @canonical/generator-canonical-ds 0.0.1 */
2
+ export * from "./hooks/index.js";
3
+ export * from "./utils/index.js";
4
+ import Provider from "./Provider.js";
5
+ import { CodeDiffViewer, FileHeader } from "./common/index.js";
6
+ export const GitDiffViewer = Provider;
7
+ GitDiffViewer.FileHeader = FileHeader;
8
+ GitDiffViewer.CodeDiffViewer = CodeDiffViewer;
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/index.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,cAAc,kBAAkB,CAAC;AAEjC,cAAc,kBAAkB,CAAC;AAEjC,OAAO,QAAQ,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/D,MAAM,CAAC,MAAM,aAAa,GAAG,QAAkC,CAAC;AAChE,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC;AACtC,aAAa,CAAC,cAAc,GAAG,cAAc,CAAC"}
@@ -0,0 +1,38 @@
1
+ /* GitDiffViewer.css */
2
+ .ds.git-diff-viewer {
3
+ --git-diff-viewer-code-default-background: #f7f7f7;
4
+ --git-diff-viewer-code-default-color: #636363;
5
+ --git-diff-viewer-code-insertion-background: #dff1e2;
6
+ --git-diff-viewer-code-insertion-color: #8cd297;
7
+ --git-diff-viewer-code-deletion-background: #f8e8ea;
8
+ --git-diff-viewer-code-deletion-color: #fba1aa;
9
+
10
+ --git-diff-viewer-border-color: rgba(0, 0, 0, 0.2);
11
+ --git-diff-viewer-border-color-tinted: rgba(0, 0, 0, 0.1);
12
+
13
+ --git-diff-viewer-gutter-width: 7.5em;
14
+ --git-diff-viewer-hunk-header-background: #ffffff;
15
+ --git-diff-viewer-hunk-header-color: rgba(0, 0, 0, 0.6);
16
+
17
+ --git-diff-file-header-horizontal-padding: 1em;
18
+ --git-diff-file-header-vertical-padding: 0.4em;
19
+ --git-diff-file-header-background-color: #ebebeb;
20
+ --git-diff-file-header-items-gap: 0.5em;
21
+
22
+ --git-diff-file-header-button-background: transparent;
23
+ --git-diff-file-header-button-hover-background: rgba(0, 0, 0, 0.1);
24
+ --git-diff-file-header-button-focus-background: rgba(0, 0, 0, 0.1);
25
+
26
+ --git-diff-file-header-insertion-background: rgba(10, 189, 37, 0.1);
27
+ --git-diff-file-header-insertion-color: var(
28
+ --git-diff-viewer-code-insertion-color,
29
+ #8cd297
30
+ );
31
+ --git-diff-file-header-deletion-background: rgba(255, 102, 120, 0.1);
32
+ --git-diff-file-header-deletion-color: var(
33
+ --git-diff-viewer-code-deletion-color,
34
+ #fba1aa
35
+ );
36
+
37
+ border: 1px solid var(--git-diff-viewer-border-color);
38
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ui/Chip/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/ui/GitDiffViewer/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export { default as parseGitDiff } from "./parseGitDiff.js";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,mBAAmB,CAAC"}
@@ -0,0 +1,73 @@
1
+ function parseGitDiff(diffText) {
2
+ const lines = diffText.split("\n");
3
+ const files = [];
4
+ let currentFile = null;
5
+ let currentHunk = null;
6
+ // Regular expressions to match file and hunk headers
7
+ const fileRegex = /^diff --git a\/(.+) b\/(.+)$/;
8
+ const hunkRegex = /^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@/;
9
+ const oldFileRegex = /^--- (.+)$/;
10
+ const newFileRegex = /^\+\+\+ (.+)$/;
11
+ for (const line of lines) {
12
+ const fileMatch = line.match(fileRegex);
13
+ if (fileMatch) {
14
+ // New file diff start
15
+ if (currentFile)
16
+ files.push(currentFile);
17
+ currentFile = {
18
+ oldPath: fileMatch[1],
19
+ newPath: fileMatch[2],
20
+ fileChangeState: "none",
21
+ hunks: [],
22
+ };
23
+ currentHunk = null;
24
+ continue;
25
+ }
26
+ if (!currentFile)
27
+ continue; // Skip lines until first file header
28
+ const oldFileMatch = line.match(oldFileRegex);
29
+ const newFileMatch = line.match(newFileRegex);
30
+ if (oldFileMatch || newFileMatch) {
31
+ // Determine file change state based on the old/new file indicators
32
+ if (oldFileMatch?.[0].includes("/dev/null")) {
33
+ currentFile.fileChangeState = "added"; // File is new
34
+ }
35
+ else if (newFileMatch?.[0].includes("/dev/null")) {
36
+ currentFile.fileChangeState = "deleted"; // File is deleted
37
+ }
38
+ else if (currentFile.fileChangeState === "none") {
39
+ currentFile.fileChangeState = "modified"; // Assume file is modified
40
+ }
41
+ continue;
42
+ }
43
+ const hunkMatch = line.match(hunkRegex);
44
+ if (hunkMatch && currentFile) {
45
+ // New hunk start
46
+ currentHunk = {
47
+ header: line,
48
+ oldStart: Number.parseInt(hunkMatch[1], 10),
49
+ oldLines: hunkMatch[2] ? Number.parseInt(hunkMatch[2], 10) : 1,
50
+ newStart: Number.parseInt(hunkMatch[3], 10),
51
+ newLines: hunkMatch[4] ? Number.parseInt(hunkMatch[4], 10) : 1,
52
+ lines: [],
53
+ };
54
+ currentFile.hunks.push(currentHunk);
55
+ continue;
56
+ }
57
+ if (currentHunk && currentFile) {
58
+ // Determine line type and content
59
+ const type = line.startsWith("+")
60
+ ? "add"
61
+ : line.startsWith("-")
62
+ ? "remove"
63
+ : "context";
64
+ const content = line.slice(1); // Remove the leading +, - or space
65
+ currentHunk.lines.push({ type, content });
66
+ }
67
+ }
68
+ if (currentFile)
69
+ files.push(currentFile);
70
+ return files;
71
+ }
72
+ export default parseGitDiff;
73
+ //# sourceMappingURL=parseGitDiff.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseGitDiff.js","sourceRoot":"","sources":["../../../../../src/ui/GitDiffViewer/utils/parseGitDiff.ts"],"names":[],"mappings":"AAEA,SAAS,YAAY,CAAC,QAAgB;IACpC,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IACnC,MAAM,KAAK,GAAe,EAAE,CAAC;IAC7B,IAAI,WAAW,GAAoB,IAAI,CAAC;IACxC,IAAI,WAAW,GAAgB,IAAI,CAAC;IAEpC,qDAAqD;IACrD,MAAM,SAAS,GAAG,8BAA8B,CAAC;IACjD,MAAM,SAAS,GAAG,qCAAqC,CAAC;IACxD,MAAM,YAAY,GAAG,YAAY,CAAC;IAClC,MAAM,YAAY,GAAG,eAAe,CAAC;IAErC,KAAK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