@vitessce/vit-s 2.0.3-beta.0 → 3.0.0

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 (277) hide show
  1. package/dist/index.js +41348 -18
  2. package/dist-tsc/CallbackPublisher.d.ts +18 -0
  3. package/dist-tsc/CallbackPublisher.d.ts.map +1 -0
  4. package/{dist → dist-tsc}/CallbackPublisher.js +6 -12
  5. package/dist-tsc/LoadingIndicator.d.ts +2 -0
  6. package/dist-tsc/LoadingIndicator.d.ts.map +1 -0
  7. package/{dist → dist-tsc}/LoadingIndicator.js +1 -2
  8. package/dist-tsc/TitleInfo.d.ts +2 -0
  9. package/dist-tsc/TitleInfo.d.ts.map +1 -0
  10. package/{dist → dist-tsc}/TitleInfo.js +6 -83
  11. package/dist-tsc/VitS.d.ts +45 -0
  12. package/dist-tsc/VitS.d.ts.map +1 -0
  13. package/dist-tsc/VitS.js +119 -0
  14. package/dist-tsc/VitessceGrid.d.ts +23 -0
  15. package/dist-tsc/VitessceGrid.d.ts.map +1 -0
  16. package/{dist → dist-tsc}/VitessceGrid.js +14 -13
  17. package/dist-tsc/VitessceGrid.test.d.ts +2 -0
  18. package/dist-tsc/VitessceGrid.test.d.ts.map +1 -0
  19. package/{dist → dist-tsc}/VitessceGrid.test.js +8 -4
  20. package/dist-tsc/Warning.d.ts +2 -0
  21. package/dist-tsc/Warning.d.ts.map +1 -0
  22. package/{dist → dist-tsc}/Warning.js +2 -2
  23. package/dist-tsc/classNames.d.ts +8 -0
  24. package/dist-tsc/classNames.d.ts.map +1 -0
  25. package/dist-tsc/data/AbstractLoader.d.ts +22 -0
  26. package/dist-tsc/data/AbstractLoader.d.ts.map +1 -0
  27. package/dist-tsc/data/AbstractLoader.js +18 -0
  28. package/dist-tsc/data/AbstractTwoStepLoader.d.ts +6 -0
  29. package/dist-tsc/data/AbstractTwoStepLoader.d.ts.map +1 -0
  30. package/{dist → dist-tsc}/data/AbstractTwoStepLoader.js +1 -1
  31. package/dist-tsc/data/LoaderResult.d.ts +7 -0
  32. package/dist-tsc/data/LoaderResult.d.ts.map +1 -0
  33. package/dist-tsc/data/index.d.ts +4 -0
  34. package/dist-tsc/data/index.d.ts.map +1 -0
  35. package/dist-tsc/data/index.js +3 -0
  36. package/dist-tsc/data/loader-registry.d.ts +9 -0
  37. package/dist-tsc/data/loader-registry.d.ts.map +1 -0
  38. package/dist-tsc/data/loader-registry.js +27 -0
  39. package/dist-tsc/data-hook-utils.d.ts +69 -0
  40. package/dist-tsc/data-hook-utils.d.ts.map +1 -0
  41. package/{dist → dist-tsc}/data-hook-utils.js +4 -6
  42. package/dist-tsc/data-hooks.d.ts +77 -0
  43. package/dist-tsc/data-hooks.d.ts.map +1 -0
  44. package/{dist → dist-tsc}/data-hooks.js +4 -4
  45. package/dist-tsc/errors/AbstractLoaderError.d.ts +10 -0
  46. package/dist-tsc/errors/AbstractLoaderError.d.ts.map +1 -0
  47. package/dist-tsc/errors/DataSourceFetchError.d.ts +8 -0
  48. package/dist-tsc/errors/DataSourceFetchError.d.ts.map +1 -0
  49. package/{dist → dist-tsc}/errors/DataSourceFetchError.js +1 -1
  50. package/dist-tsc/errors/DatasetNotFoundError.d.ts +6 -0
  51. package/dist-tsc/errors/DatasetNotFoundError.d.ts.map +1 -0
  52. package/{dist → dist-tsc}/errors/DatasetNotFoundError.js +1 -1
  53. package/dist-tsc/errors/LoaderNotFoundError.d.ts +10 -0
  54. package/dist-tsc/errors/LoaderNotFoundError.d.ts.map +1 -0
  55. package/{dist → dist-tsc}/errors/LoaderNotFoundError.js +1 -1
  56. package/dist-tsc/errors/LoaderValidationError.d.ts +10 -0
  57. package/dist-tsc/errors/LoaderValidationError.d.ts.map +1 -0
  58. package/{dist → dist-tsc}/errors/LoaderValidationError.js +1 -1
  59. package/dist-tsc/errors/index.d.ts +6 -0
  60. package/dist-tsc/errors/index.d.ts.map +1 -0
  61. package/{dist → dist-tsc}/errors/index.js +5 -6
  62. package/dist-tsc/hooks.d.ts +80 -0
  63. package/dist-tsc/hooks.d.ts.map +1 -0
  64. package/{dist → dist-tsc}/hooks.js +60 -4
  65. package/dist-tsc/index.d.ts +11 -0
  66. package/dist-tsc/index.d.ts.map +1 -0
  67. package/dist-tsc/index.js +11 -0
  68. package/dist-tsc/plugins.test.fixtures.d.ts +61 -0
  69. package/dist-tsc/plugins.test.fixtures.d.ts.map +1 -0
  70. package/{dist → dist-tsc}/schemas/config-1.0.16.schema.json +21 -41
  71. package/dist-tsc/schemas/obsSets.schema.d.ts +179 -0
  72. package/dist-tsc/schemas/obsSets.schema.d.ts.map +1 -0
  73. package/dist-tsc/schemas/obsSetsTabular.schema.d.ts +57 -0
  74. package/dist-tsc/schemas/obsSetsTabular.schema.d.ts.map +1 -0
  75. package/dist-tsc/schemas/raster.schema.d.ts +239 -0
  76. package/dist-tsc/schemas/raster.schema.d.ts.map +1 -0
  77. package/dist-tsc/shared-mui/components.d.ts +2 -0
  78. package/dist-tsc/shared-mui/components.d.ts.map +1 -0
  79. package/{dist → dist-tsc}/shared-mui/components.js +2 -8
  80. package/dist-tsc/shared-mui/container.d.ts +2 -0
  81. package/dist-tsc/shared-mui/container.d.ts.map +1 -0
  82. package/{dist → dist-tsc}/shared-mui/container.js +1 -1
  83. package/dist-tsc/shared-mui/styles.d.ts +5 -0
  84. package/dist-tsc/shared-mui/styles.d.ts.map +1 -0
  85. package/{dist → dist-tsc}/shared-mui/styles.js +4 -2
  86. package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts +2 -0
  87. package/dist-tsc/shared-plot-options/CellColorEncodingOption.d.ts.map +1 -0
  88. package/{dist → dist-tsc}/shared-plot-options/CellColorEncodingOption.js +3 -4
  89. package/dist-tsc/shared-plot-options/OptionSelect.d.ts +2 -0
  90. package/dist-tsc/shared-plot-options/OptionSelect.d.ts.map +1 -0
  91. package/{dist → dist-tsc}/shared-plot-options/OptionSelect.js +2 -2
  92. package/dist-tsc/shared-plot-options/OptionsContainer.d.ts +2 -0
  93. package/dist-tsc/shared-plot-options/OptionsContainer.d.ts.map +1 -0
  94. package/{dist → dist-tsc}/shared-plot-options/OptionsContainer.js +2 -5
  95. package/dist-tsc/shared-plot-options/index.d.ts +5 -0
  96. package/dist-tsc/shared-plot-options/index.d.ts.map +1 -0
  97. package/dist-tsc/shared-plot-options/index.js +4 -0
  98. package/dist-tsc/shared-plot-options/styles.d.ts +2 -0
  99. package/dist-tsc/shared-plot-options/styles.d.ts.map +1 -0
  100. package/{dist → dist-tsc}/shared-plot-options/styles.js +1 -1
  101. package/dist-tsc/state/hooks.d.ts +216 -0
  102. package/dist-tsc/state/hooks.d.ts.map +1 -0
  103. package/{dist → dist-tsc}/state/hooks.js +47 -21
  104. package/dist-tsc/title-styles.d.ts +2 -0
  105. package/dist-tsc/title-styles.d.ts.map +1 -0
  106. package/dist-tsc/title-styles.js +72 -0
  107. package/dist-tsc/view-config-utils.d.ts +30 -0
  108. package/dist-tsc/view-config-utils.d.ts.map +1 -0
  109. package/{dist → dist-tsc}/view-config-utils.js +32 -84
  110. package/dist-tsc/view-config-utils.test.d.ts +2 -0
  111. package/dist-tsc/view-config-utils.test.d.ts.map +1 -0
  112. package/dist-tsc/view-config-utils.test.fixtures.d.ts +1049 -0
  113. package/dist-tsc/view-config-utils.test.fixtures.d.ts.map +1 -0
  114. package/{dist → dist-tsc}/view-config-utils.test.fixtures.js +118 -0
  115. package/dist-tsc/view-config-utils.test.js +209 -0
  116. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts +8 -0
  117. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts.map +1 -0
  118. package/{dist → dist-tsc}/vitessce-grid-layout/VitessceGridLayout.js +47 -28
  119. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts +2 -0
  120. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.test.d.ts.map +1 -0
  121. package/{dist → dist-tsc}/vitessce-grid-layout/VitessceGridLayout.test.js +13 -5
  122. package/dist-tsc/vitessce-grid-layout/index.d.ts +2 -0
  123. package/dist-tsc/vitessce-grid-layout/index.d.ts.map +1 -0
  124. package/dist-tsc/vitessce-grid-layout/index.js +1 -0
  125. package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts +15 -0
  126. package/dist-tsc/vitessce-grid-layout/layout-utils.d.ts.map +1 -0
  127. package/{dist → dist-tsc}/vitessce-grid-layout/layout-utils.js +2 -1
  128. package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts +2 -0
  129. package/dist-tsc/vitessce-grid-layout/layout-utils.test.d.ts.map +1 -0
  130. package/{dist → dist-tsc}/vitessce-grid-layout/layout-utils.test.js +3 -1
  131. package/dist-tsc/vitessce-grid-utils.d.ts +13 -0
  132. package/dist-tsc/vitessce-grid-utils.d.ts.map +1 -0
  133. package/{dist → dist-tsc}/vitessce-grid-utils.js +15 -14
  134. package/package.json +24 -11
  135. package/src/CallbackPublisher.js +77 -0
  136. package/src/LoadingIndicator.js +33 -0
  137. package/src/TitleInfo.js +167 -0
  138. package/src/VitS.js +202 -0
  139. package/src/VitessceGrid.js +118 -0
  140. package/src/VitessceGrid.test.jsx +57 -0
  141. package/src/Warning.js +62 -0
  142. package/src/classNames.js +8 -0
  143. package/src/data/AbstractLoader.js +23 -0
  144. package/src/data/AbstractTwoStepLoader.js +8 -0
  145. package/src/data/LoaderResult.js +8 -0
  146. package/src/data/index.js +3 -0
  147. package/src/data/loader-registry.js +28 -0
  148. package/src/data-hook-utils.js +195 -0
  149. package/src/data-hooks.js +354 -0
  150. package/src/errors/AbstractLoaderError.js +14 -0
  151. package/src/errors/DataSourceFetchError.js +15 -0
  152. package/src/errors/DatasetNotFoundError.js +23 -0
  153. package/src/errors/LoaderNotFoundError.js +24 -0
  154. package/src/errors/LoaderValidationError.js +23 -0
  155. package/src/errors/index.js +5 -0
  156. package/src/hooks.js +317 -0
  157. package/src/index.js +76 -0
  158. package/src/plugins.test.fixtures.js +78 -0
  159. package/src/schemas/config-0.1.0.schema.json +85 -0
  160. package/src/schemas/config-1.0.0.schema.json +733 -0
  161. package/src/schemas/config-1.0.1.schema.json +909 -0
  162. package/src/schemas/config-1.0.10.schema.json +969 -0
  163. package/src/schemas/config-1.0.11.schema.json +990 -0
  164. package/src/schemas/config-1.0.12.schema.json +997 -0
  165. package/src/schemas/config-1.0.13.schema.json +1013 -0
  166. package/src/schemas/config-1.0.14.schema.json +1048 -0
  167. package/src/schemas/config-1.0.15.schema.json +1048 -0
  168. package/src/schemas/config-1.0.16.schema.json +1089 -0
  169. package/src/schemas/config-1.0.2.schema.json +911 -0
  170. package/src/schemas/config-1.0.3.schema.json +911 -0
  171. package/src/schemas/config-1.0.4.schema.json +949 -0
  172. package/src/schemas/config-1.0.5.schema.json +949 -0
  173. package/src/schemas/config-1.0.6.schema.json +950 -0
  174. package/src/schemas/config-1.0.7.schema.json +950 -0
  175. package/src/schemas/config-1.0.8.schema.json +966 -0
  176. package/src/schemas/config-1.0.9.schema.json +965 -0
  177. package/src/schemas/fixtures/cellSets.good.json +16 -0
  178. package/src/schemas/fixtures/config-1.0.1.bad.json +1 -0
  179. package/src/schemas/fixtures/config-1.0.1.bad.message.json +11 -0
  180. package/src/schemas/fixtures/config-1.0.1.good.json +37 -0
  181. package/src/schemas/fixtures/config-1.0.2.bad.json +1 -0
  182. package/src/schemas/fixtures/config-1.0.2.bad.message.json +11 -0
  183. package/src/schemas/fixtures/config-1.0.2.good.json +38 -0
  184. package/src/schemas/fixtures/config-1.0.3.bad.json +1 -0
  185. package/src/schemas/fixtures/config-1.0.3.bad.message.json +11 -0
  186. package/src/schemas/fixtures/config-1.0.3.good.json +38 -0
  187. package/src/schemas/fixtures/obsSets.bad.json +1 -0
  188. package/src/schemas/fixtures/obsSets.bad.message.json +11 -0
  189. package/src/schemas/fixtures/obsSets.good.json +16 -0
  190. package/src/schemas/fixtures/obsSetsTabular.bad.json +1 -0
  191. package/src/schemas/fixtures/obsSetsTabular.bad.message.json +11 -0
  192. package/src/schemas/fixtures/obsSetsTabular.good.json +26 -0
  193. package/src/schemas/fixtures/raster.bad.json +1 -0
  194. package/src/schemas/fixtures/raster.bad.message.json +11 -0
  195. package/src/schemas/fixtures/raster.good.json +39 -0
  196. package/src/schemas/obsSets.schema.js +195 -0
  197. package/src/schemas/obsSetsTabular.schema.js +39 -0
  198. package/src/schemas/raster.schema.js +121 -0
  199. package/src/schemas/schema-schema.sh +34 -0
  200. package/src/shared-mui/components.js +81 -0
  201. package/src/shared-mui/container.js +212 -0
  202. package/src/shared-mui/styles.js +113 -0
  203. package/src/shared-plot-options/CellColorEncodingOption.js +42 -0
  204. package/src/shared-plot-options/OptionSelect.js +19 -0
  205. package/src/shared-plot-options/OptionsContainer.js +23 -0
  206. package/src/shared-plot-options/index.js +4 -0
  207. package/src/shared-plot-options/styles.js +49 -0
  208. package/src/state/hooks.js +640 -0
  209. package/src/title-styles.js +73 -0
  210. package/src/view-config-utils.js +263 -0
  211. package/src/view-config-utils.test.fixtures.js +893 -0
  212. package/src/view-config-utils.test.jsx +222 -0
  213. package/src/vitessce-grid-layout/VitessceGridLayout.js +179 -0
  214. package/src/vitessce-grid-layout/VitessceGridLayout.test.jsx +64 -0
  215. package/src/vitessce-grid-layout/index.js +1 -0
  216. package/src/vitessce-grid-layout/layout-utils.js +76 -0
  217. package/src/vitessce-grid-layout/layout-utils.test.js +167 -0
  218. package/src/vitessce-grid-utils.js +172 -0
  219. package/dist/VitS.js +0 -117
  220. package/dist/Vitessce.integration.test.js +0 -36
  221. package/dist/Vitessce.js +0 -101
  222. package/dist/component-registry.js +0 -16
  223. package/dist/data/AbstractLoader.js +0 -35
  224. package/dist/data/index.js +0 -3
  225. package/dist/data/loader-registry.js +0 -15
  226. package/dist/errors/OptionsValidationError.js +0 -15
  227. package/dist/export-utils.js +0 -70
  228. package/dist/export-utils.test.js +0 -66
  229. package/dist/file-options-schemas-legacy.js +0 -136
  230. package/dist/file-options-schemas-legacy.test.js +0 -126
  231. package/dist/file-options-schemas.js +0 -322
  232. package/dist/file-options-schemas.test.js +0 -23
  233. package/dist/joint-file-types-legacy.js +0 -278
  234. package/dist/joint-file-types-legacy.test.js +0 -400
  235. package/dist/joint-file-types.js +0 -148
  236. package/dist/joint-file-types.test.js +0 -139
  237. package/dist/loader-registry.js +0 -98
  238. package/dist/plugins.js +0 -154
  239. package/dist/plugins.test.js +0 -30
  240. package/dist/schemas/PrettyJsonSchema.js +0 -34
  241. package/dist/schemas/config-1.0.15.schema.test.js +0 -22
  242. package/dist/schemas/config-1.0.16.schema.test.js +0 -22
  243. package/dist/schemas/obs-sets-tabular.schema.js +0 -37
  244. package/dist/schemas/obs-sets.schema.js +0 -194
  245. package/dist/schemas/schema.test-old.js +0 -50
  246. package/dist/schemas/schema.test.js +0 -46
  247. package/dist/schemas-extra.js +0 -3
  248. package/dist/schemas.js +0 -4
  249. package/dist/shared-plot-options/index.js +0 -4
  250. package/dist/view-config-upgraders.js +0 -525
  251. package/dist/view-config-utils.test.js +0 -66
  252. package/dist/view-config-versions.js +0 -47
  253. package/dist/vitessce-grid-layout/index.js +0 -1
  254. /package/{dist → dist-tsc}/classNames.js +0 -0
  255. /package/{dist → dist-tsc}/data/LoaderResult.js +0 -0
  256. /package/{dist → dist-tsc}/errors/AbstractLoaderError.js +0 -0
  257. /package/{dist → dist-tsc}/plugins.test.fixtures.js +0 -0
  258. /package/{dist → dist-tsc}/schemas/config-0.1.0.schema.json +0 -0
  259. /package/{dist → dist-tsc}/schemas/config-1.0.0.schema.json +0 -0
  260. /package/{dist → dist-tsc}/schemas/config-1.0.1.schema.json +0 -0
  261. /package/{dist → dist-tsc}/schemas/config-1.0.10.schema.json +0 -0
  262. /package/{dist → dist-tsc}/schemas/config-1.0.11.schema.json +0 -0
  263. /package/{dist → dist-tsc}/schemas/config-1.0.12.schema.json +0 -0
  264. /package/{dist → dist-tsc}/schemas/config-1.0.13.schema.json +0 -0
  265. /package/{dist → dist-tsc}/schemas/config-1.0.14.schema.json +0 -0
  266. /package/{dist → dist-tsc}/schemas/config-1.0.15.schema.json +0 -0
  267. /package/{dist → dist-tsc}/schemas/config-1.0.2.schema.json +0 -0
  268. /package/{dist → dist-tsc}/schemas/config-1.0.3.schema.json +0 -0
  269. /package/{dist → dist-tsc}/schemas/config-1.0.4.schema.json +0 -0
  270. /package/{dist → dist-tsc}/schemas/config-1.0.5.schema.json +0 -0
  271. /package/{dist → dist-tsc}/schemas/config-1.0.6.schema.json +0 -0
  272. /package/{dist → dist-tsc}/schemas/config-1.0.7.schema.json +0 -0
  273. /package/{dist → dist-tsc}/schemas/config-1.0.8.schema.json +0 -0
  274. /package/{dist → dist-tsc}/schemas/config-1.0.9.schema.json +0 -0
  275. /package/{dist → dist-tsc}/schemas/obsSets.schema.js +0 -0
  276. /package/{dist → dist-tsc}/schemas/obsSetsTabular.schema.js +0 -0
  277. /package/{dist → dist-tsc}/schemas/raster.schema.js +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"view-config-utils.test.fixtures.d.ts","sourceRoot":"","sources":["../src/view-config-utils.test.fixtures.js"],"names":[],"mappings":""}
@@ -763,3 +763,121 @@ export const initializedViewConfig = {
763
763
  },
764
764
  ],
765
765
  };
766
+ export const implicitPerDatasetCoordinations = {
767
+ version: '1.0.9',
768
+ name: 'Per-dataset coordinations',
769
+ description: 'My config description',
770
+ initStrategy: 'auto',
771
+ coordinationSpace: {
772
+ dataset: {
773
+ A: 'first',
774
+ B: 'second',
775
+ },
776
+ embeddingCellRadius: {
777
+ small: 2,
778
+ big: 20,
779
+ },
780
+ embeddingCellRadiusMode: {
781
+ all: 'manual',
782
+ },
783
+ },
784
+ datasets: [
785
+ {
786
+ files: [],
787
+ name: 'First dataset',
788
+ uid: 'first',
789
+ },
790
+ {
791
+ files: [],
792
+ name: 'Second dataset',
793
+ uid: 'second',
794
+ },
795
+ ],
796
+ layout: [
797
+ {
798
+ component: 'somePluginView',
799
+ coordinationScopes: {
800
+ dataset: ['A', 'B'],
801
+ embeddingCellRadius: { A: 'small', B: 'big' },
802
+ embeddingCellRadiusMode: 'all',
803
+ },
804
+ h: 4,
805
+ w: 5,
806
+ x: 0,
807
+ y: 2,
808
+ },
809
+ {
810
+ component: 'scatterplot',
811
+ coordinationScopes: {
812
+ dataset: 'A',
813
+ embeddingCellRadius: 'small',
814
+ embeddingCellRadiusMode: 'all',
815
+ },
816
+ h: 4,
817
+ w: 5,
818
+ x: 0,
819
+ y: 2,
820
+ },
821
+ ],
822
+ };
823
+ export const explicitPerDatasetCoordinations = {
824
+ version: '1.0.16',
825
+ name: 'Per-dataset coordinations',
826
+ description: 'My config description',
827
+ initStrategy: 'auto',
828
+ coordinationSpace: {
829
+ dataset: {
830
+ A: 'first',
831
+ B: 'second',
832
+ },
833
+ embeddingCellRadius: {
834
+ small: 2,
835
+ big: 20,
836
+ },
837
+ embeddingCellRadiusMode: {
838
+ all: 'manual',
839
+ },
840
+ },
841
+ datasets: [
842
+ {
843
+ files: [],
844
+ name: 'First dataset',
845
+ uid: 'first',
846
+ },
847
+ {
848
+ files: [],
849
+ name: 'Second dataset',
850
+ uid: 'second',
851
+ },
852
+ ],
853
+ layout: [
854
+ {
855
+ component: 'somePluginView',
856
+ coordinationScopes: {
857
+ dataset: ['A', 'B'],
858
+ embeddingCellRadiusMode: 'all',
859
+ },
860
+ coordinationScopesBy: {
861
+ dataset: {
862
+ embeddingCellRadius: { A: 'small', B: 'big' },
863
+ },
864
+ },
865
+ h: 4,
866
+ w: 5,
867
+ x: 0,
868
+ y: 2,
869
+ },
870
+ {
871
+ component: 'scatterplot',
872
+ coordinationScopes: {
873
+ dataset: 'A',
874
+ embeddingCellRadius: 'small',
875
+ embeddingCellRadiusMode: 'all',
876
+ },
877
+ h: 4,
878
+ w: 5,
879
+ x: 0,
880
+ y: 2,
881
+ },
882
+ ],
883
+ };
@@ -0,0 +1,209 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /* eslint-disable camelcase */
3
+ import React from 'react';
4
+ import { z } from '@vitessce/schemas';
5
+ import { PluginViewType, PluginCoordinationType } from '@vitessce/plugins';
6
+ import { getExistingScopesForCoordinationType, initialize, } from './view-config-utils.js';
7
+ function FakeComponent(props) {
8
+ const { text } = props;
9
+ return _jsx("span", { children: text });
10
+ }
11
+ const jointFileTypes = [];
12
+ const coordinationTypes = [
13
+ new PluginCoordinationType('dataset', null, z.string().nullable()),
14
+ new PluginCoordinationType('embeddingTargetX', 0, z.number()),
15
+ new PluginCoordinationType('embeddingTargetY', 0, z.number()),
16
+ new PluginCoordinationType('embeddingZoom', 3, z.number()),
17
+ new PluginCoordinationType('embeddingType', null, z.string().nullable()),
18
+ ];
19
+ const viewTypes = [
20
+ new PluginViewType('description', FakeComponent, ['dataset']),
21
+ new PluginViewType('scatterplot', FakeComponent, ['dataset', 'embeddingType', 'embeddingZoom', 'embeddingTargetX', 'embeddingTargetY']),
22
+ ];
23
+ describe('src/app/view-config-utils.js', () => {
24
+ describe('getExistingScopesForCoordinationType', () => {
25
+ it('gets all scope names for a particular coordination type', () => {
26
+ const config = {
27
+ coordinationSpace: {
28
+ dataset: {
29
+ A: 'my-dataset-1',
30
+ B: 'my-dataset-2',
31
+ },
32
+ },
33
+ layout: [
34
+ {
35
+ coordinationScopes: {
36
+ dataset: 'A',
37
+ },
38
+ },
39
+ {
40
+ coordinationScopes: {
41
+ dataset: 'C',
42
+ },
43
+ },
44
+ ],
45
+ };
46
+ expect(getExistingScopesForCoordinationType(config, 'dataset')).toEqual(['A', 'B', 'C']);
47
+ });
48
+ });
49
+ describe('initialize', () => {
50
+ it('initializes coordination space and component coordination scopes when initStrategy is auto', () => {
51
+ const preInitializationConfig = {
52
+ version: '1.0.16',
53
+ name: 'My config name',
54
+ description: 'My config description',
55
+ initStrategy: 'auto',
56
+ coordinationSpace: {
57
+ embeddingTargetX: {
58
+ A: 0,
59
+ },
60
+ embeddingTargetY: {
61
+ A: 0,
62
+ },
63
+ embeddingType: {
64
+ 't-SNE': 't-SNE',
65
+ },
66
+ },
67
+ datasets: [
68
+ {
69
+ files: [],
70
+ name: 'A',
71
+ uid: 'A',
72
+ },
73
+ ],
74
+ layout: [
75
+ {
76
+ component: 'description',
77
+ coordinationScopes: {},
78
+ h: 2,
79
+ w: 3,
80
+ x: 9,
81
+ y: 0,
82
+ },
83
+ {
84
+ component: 'scatterplot',
85
+ coordinationScopes: {
86
+ embeddingTargetX: 'A',
87
+ embeddingTargetY: 'A',
88
+ embeddingType: 't-SNE',
89
+ },
90
+ h: 4,
91
+ w: 5,
92
+ x: 0,
93
+ y: 2,
94
+ },
95
+ ],
96
+ };
97
+ const initializedViewConfig = {
98
+ version: '1.0.16',
99
+ uid: 'A',
100
+ name: 'My config name',
101
+ description: 'My config description',
102
+ initStrategy: 'auto',
103
+ coordinationSpace: {
104
+ dataset: {
105
+ A: 'A',
106
+ },
107
+ embeddingTargetX: {
108
+ A: 0,
109
+ },
110
+ embeddingTargetY: {
111
+ A: 0,
112
+ },
113
+ embeddingType: {
114
+ 't-SNE': 't-SNE',
115
+ },
116
+ embeddingZoom: {
117
+ A: 3,
118
+ },
119
+ },
120
+ datasets: [
121
+ {
122
+ files: [],
123
+ name: 'A',
124
+ uid: 'A',
125
+ },
126
+ ],
127
+ layout: [
128
+ {
129
+ component: 'description',
130
+ coordinationScopes: {
131
+ dataset: 'A',
132
+ },
133
+ h: 2,
134
+ uid: 'A',
135
+ w: 3,
136
+ x: 9,
137
+ y: 0,
138
+ },
139
+ {
140
+ component: 'scatterplot',
141
+ coordinationScopes: {
142
+ dataset: 'A',
143
+ embeddingTargetX: 'A',
144
+ embeddingTargetY: 'A',
145
+ embeddingType: 't-SNE',
146
+ embeddingZoom: 'A',
147
+ },
148
+ h: 4,
149
+ uid: 'B',
150
+ w: 5,
151
+ x: 0,
152
+ y: 2,
153
+ },
154
+ ],
155
+ };
156
+ expect(initialize(preInitializationConfig, jointFileTypes, coordinationTypes, viewTypes))
157
+ .toEqual(initializedViewConfig);
158
+ });
159
+ it('does not initialize when initStrategy is none', () => {
160
+ const preInitializationConfig = {
161
+ version: '1.0.16',
162
+ name: 'My config name',
163
+ description: 'My config description',
164
+ initStrategy: 'none',
165
+ coordinationSpace: {
166
+ embeddingTargetX: {
167
+ A: 0,
168
+ },
169
+ embeddingTargetY: {
170
+ A: 0,
171
+ },
172
+ embeddingType: {
173
+ 't-SNE': 't-SNE',
174
+ },
175
+ },
176
+ datasets: [
177
+ {
178
+ files: [],
179
+ name: 'A',
180
+ uid: 'A',
181
+ },
182
+ ],
183
+ layout: [
184
+ {
185
+ component: 'description',
186
+ coordinationScopes: {},
187
+ h: 2,
188
+ w: 3,
189
+ x: 9,
190
+ y: 0,
191
+ },
192
+ {
193
+ component: 'scatterplot',
194
+ coordinationScopes: {
195
+ embeddingTargetX: 'A',
196
+ embeddingTargetY: 'A',
197
+ embeddingType: 't-SNE',
198
+ },
199
+ h: 4,
200
+ w: 5,
201
+ x: 0,
202
+ y: 2,
203
+ },
204
+ ],
205
+ };
206
+ expect(initialize(preInitializationConfig, jointFileTypes, coordinationTypes, viewTypes).coordinationSpace).toEqual(preInitializationConfig.coordinationSpace);
207
+ });
208
+ });
209
+ });
@@ -0,0 +1,8 @@
1
+ export function VitessceGridLayout(props: any): any;
2
+ export namespace VitessceGridLayout {
3
+ namespace defaultProps {
4
+ const padding: number;
5
+ const margin: number;
6
+ }
7
+ }
8
+ //# sourceMappingURL=VitessceGridLayout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitessceGridLayout.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/VitessceGridLayout.js"],"names":[],"mappings":"AAeA,oDA8JC"}
@@ -1,8 +1,8 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- import React, { useState } from 'react';
2
+ import React, { useState, useMemo, useCallback } from 'react';
3
3
  import { Responsive, WidthProvider } from 'react-grid-layout-with-lodash';
4
- import isEqual from 'lodash/isEqual';
5
- import { getMaxRows, resolveLayout } from './layout-utils';
4
+ import { isEqual } from 'lodash-es';
5
+ import { getMaxRows, resolveLayout } from './layout-utils.js';
6
6
  const ResponsiveGridLayout = WidthProvider(Responsive);
7
7
  class ResponsiveHeightGridLayout extends ResponsiveGridLayout {
8
8
  componentDidUpdate(prevProps) {
@@ -12,10 +12,21 @@ class ResponsiveHeightGridLayout extends ResponsiveGridLayout {
12
12
  }
13
13
  }
14
14
  export function VitessceGridLayout(props) {
15
- const { layout, getComponent, padding, margin, draggableHandle: draggableHandleClass, onResize, onResizeStop, rowHeight, theme, height, onRemoveComponent, onLayoutChange: onLayoutChangeProp, isBounded, } = props;
15
+ const { layout, viewTypes, padding, margin: marginProp, draggableHandle: draggableHandleClass, onResize, onResizeStop, rowHeight, theme, height, onRemoveComponent, onLayoutChange: onLayoutChangeProp, isBounded, } = props;
16
+ const getComponent = useCallback((viewType) => {
17
+ if (Array.isArray(viewTypes)) {
18
+ const matchingViewType = viewTypes.find(v => v.name === viewType);
19
+ if (matchingViewType) {
20
+ return matchingViewType.component;
21
+ }
22
+ }
23
+ return () => null;
24
+ }, [viewTypes]);
16
25
  const draggableHandle = `.${draggableHandleClass}`;
17
26
  // If layout changes, update grid components.
18
- const { cols: gridCols, layouts: gridLayouts, breakpoints: gridBreakpoints, components: gridComponents, } = resolveLayout(layout);
27
+ const { cols: gridCols, layouts: gridLayouts, breakpoints: gridBreakpoints, components: gridComponents, } = useMemo(() => resolveLayout(layout), [layout]);
28
+ const containerPadding = useMemo(() => ([padding, padding]), [padding]);
29
+ const margin = useMemo(() => ([marginProp, marginProp]), [marginProp]);
19
30
  const maxRows = getMaxRows(gridLayouts);
20
31
  // Inline CSS is generally avoided, but this saves the end-user a little work,
21
32
  // and prevents class names from getting out of sync.
@@ -34,15 +45,15 @@ export function VitessceGridLayout(props) {
34
45
  //
35
46
  // Additionally, react-grid-layout doesn't revert if you don't save a new/changed layouts. If you
36
47
  // wish to do this, first you have to save the new layouts and render the grid with it, and then
37
- // you can revert to the original layouts. Thus, we need one state for the current grid layouts,
48
+ // you can revert to the original layouts. Thus, we need one state for a temporary grid layout,
38
49
  // which gets called on every onLayoutChange. If the grid height is still valid, we then call
39
- // onValidLayoutChange, otherwise we reset currentGridLayouts to lastValidGridLayouts.
50
+ // onValidLayoutChange, otherwise we call onValidLayoutChange with lastValidGridLayouts.
40
51
  //
41
52
  // See the following GitHub issue for more information.
42
53
  // https://github.com/react-grid-layout/react-grid-layout/issues/1104#issuecomment-827785217
43
- const [currentGridLayouts, setCurrentGridLayouts] = useState(gridLayouts);
54
+ const [tempGridLayouts, setTempGridLayouts] = useState(null);
44
55
  const [lastValidGridLayouts, setLastValidGridLayouts] = useState(gridLayouts);
45
- const onValidLayoutChange = (newLayout) => {
56
+ const onValidLayoutChange = useCallback((newLayout) => {
46
57
  if (newLayout.length === Object.entries(gridComponents).length) {
47
58
  const newComponentProps = {};
48
59
  newLayout.forEach((nextC) => {
@@ -64,30 +75,38 @@ export function VitessceGridLayout(props) {
64
75
  onLayoutChangeProp(newComponentProps);
65
76
  }
66
77
  }
67
- };
68
- const onLayoutChange = (newLayout, allLayouts) => {
69
- setCurrentGridLayouts(allLayouts);
70
- if (!isBounded || getMaxRows({ ID: newLayout }) <= maxRows) {
71
- onValidLayoutChange(newLayout);
72
- setLastValidGridLayouts(allLayouts);
73
- }
74
- else {
75
- setCurrentGridLayouts(lastValidGridLayouts);
76
- }
77
- };
78
- const saveCurrentLayouts = () => {
79
- setLastValidGridLayouts(currentGridLayouts);
80
- };
81
- const layoutChildren = Object.values(gridComponents).map((v) => {
78
+ }, [gridComponents, onLayoutChangeProp]);
79
+ const onLayoutChange = useCallback((newLayout, allLayouts) => {
80
+ // We first need to set the new layout to the potentially-invalid allLayouts
81
+ // (see comments above about react-grid-layout limitations).
82
+ setTempGridLayouts(allLayouts);
83
+ // Then we wait 50ms and validate/set the new layout.
84
+ setTimeout(() => {
85
+ if (!isBounded || getMaxRows({ ID: newLayout }) <= maxRows) {
86
+ // Good, new layout was valid with respect to isBounded, so set in parent.
87
+ onValidLayoutChange(newLayout);
88
+ setLastValidGridLayouts(allLayouts);
89
+ }
90
+ else {
91
+ // Bad, new layout was not valid with respect to isBounded.
92
+ onValidLayoutChange(lastValidGridLayouts);
93
+ }
94
+ setTempGridLayouts(null);
95
+ }, 50);
96
+ }, [isBounded, lastValidGridLayouts, maxRows, onValidLayoutChange]);
97
+ const saveCurrentLayouts = useCallback(() => {
98
+ setLastValidGridLayouts(gridLayouts);
99
+ }, [gridLayouts]);
100
+ const layoutChildren = useMemo(() => Object.values(gridComponents).map((v) => {
82
101
  const Component = getComponent(v.component);
83
102
  const removeGridComponent = () => {
84
103
  onRemoveComponent(v.uid);
85
104
  };
86
- return (_jsx("div", { children: _jsx(Component, { ...v.props, uuid: v.uid, coordinationScopes: v.coordinationScopes, theme: theme, removeGridComponent: removeGridComponent }) }, v.uid));
87
- });
88
- return (currentGridLayouts && gridComponents && gridBreakpoints && gridCols) && (_jsxs(_Fragment, { children: [style, _jsx(ResponsiveHeightGridLayout, { className: "layout", cols: gridCols, layouts: currentGridLayouts, breakpoints: gridBreakpoints, height: height, rowHeight: rowHeight
105
+ return (_jsx("div", { children: _jsx(Component, { ...v.props, uuid: v.uid, coordinationScopes: v.coordinationScopes, coordinationScopesBy: v.coordinationScopesBy, theme: theme, removeGridComponent: removeGridComponent }) }, v.uid));
106
+ }), [gridComponents, getComponent, onRemoveComponent, theme]);
107
+ return (gridLayouts && gridComponents && gridBreakpoints && gridCols) && (_jsxs(_Fragment, { children: [style, _jsx(ResponsiveHeightGridLayout, { className: "layout", cols: gridCols, layouts: tempGridLayouts || gridLayouts, breakpoints: gridBreakpoints, height: height, rowHeight: rowHeight
89
108
  || ((window.innerHeight - 2 * padding - (maxRows - 1) * margin)
90
- / maxRows), containerPadding: [padding, padding], margin: [margin, margin], draggableHandle: draggableHandle, onLayoutChange: onLayoutChange, isBounded: isBounded, onResizeStart: saveCurrentLayouts, onDragStart: saveCurrentLayouts, onResize: onResize, onResizeStop: onResizeStop, children: layoutChildren })] }));
109
+ / maxRows), containerPadding: containerPadding, margin: margin, draggableHandle: draggableHandle, onLayoutChange: onLayoutChange, isBounded: isBounded, onResizeStart: saveCurrentLayouts, onDragStart: saveCurrentLayouts, onResize: onResize, onResizeStop: onResizeStop, children: layoutChildren })] }));
91
110
  }
92
111
  VitessceGridLayout.defaultProps = {
93
112
  padding: 10,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=VitessceGridLayout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"VitessceGridLayout.test.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/VitessceGridLayout.test.jsx"],"names":[],"mappings":""}
@@ -2,7 +2,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import '@testing-library/jest-dom';
3
3
  import { cleanup, render, screen } from '@testing-library/react';
4
4
  import { afterEach } from 'vitest';
5
- import { VitessceGridLayout } from './VitessceGridLayout';
5
+ import React from 'react';
6
+ import { PluginViewType } from '@vitessce/plugins';
7
+ import { VitessceGridLayout } from './VitessceGridLayout.js';
6
8
  afterEach(() => {
7
9
  cleanup();
8
10
  });
@@ -15,16 +17,21 @@ const layoutJson = {
15
17
  600: [0, 2, 4, 8],
16
18
  },
17
19
  components: [
18
- { component: 'FakeComponent',
20
+ {
21
+ component: 'FakeComponent',
19
22
  uid: 'fake',
20
23
  props: { text: 'Hello World' },
21
- x: 0, y: 0, w: 2 },
24
+ x: 0,
25
+ y: 0,
26
+ w: 2,
27
+ },
22
28
  ],
23
29
  };
24
30
  describe('VitessceGridLayout.js', () => {
25
31
  describe('<VitessceGridLayout />', () => {
26
32
  it('mount() works', async () => {
27
- const { container } = render(_jsx(VitessceGridLayout, { layout: layoutJson, getComponent: () => FakeComponent, draggableHandle: ".my-handle" }));
33
+ const viewTypes = [new PluginViewType('FakeComponent', FakeComponent, [])];
34
+ const { container } = render(_jsx(VitessceGridLayout, { layout: layoutJson, viewTypes: viewTypes, draggableHandle: ".my-handle" }));
28
35
  expect(await screen.findByText('Hello World'));
29
36
  expect(container.querySelectorAll('.react-grid-item span:not(.react-resizable-handle)').length).toEqual(1);
30
37
  const style = container.querySelectorAll('style');
@@ -33,7 +40,8 @@ describe('VitessceGridLayout.js', () => {
33
40
  expect(style[0].textContent).toContain('.my-handle:active {');
34
41
  });
35
42
  it('rowHeight works', () => {
36
- const { container } = render(_jsx(VitessceGridLayout, { layout: layoutJson, getComponent: () => FakeComponent, draggableHandle: ".my-handle", rowHeight: 123 }));
43
+ const viewTypes = [new PluginViewType('FakeComponent', FakeComponent, [])];
44
+ const { container } = render(_jsx(VitessceGridLayout, { layout: layoutJson, viewTypes: viewTypes, draggableHandle: ".my-handle", rowHeight: 123 }));
37
45
  expect(container.querySelector('.react-grid-item').style.height).toEqual('123px');
38
46
  });
39
47
  });
@@ -0,0 +1,2 @@
1
+ export { VitessceGridLayout } from "./VitessceGridLayout.js";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/index.js"],"names":[],"mappings":""}
@@ -0,0 +1 @@
1
+ export { VitessceGridLayout } from './VitessceGridLayout.js';
@@ -0,0 +1,15 @@
1
+ export function makeGridLayout(colXs: any, colLayout: any): {
2
+ i: string;
3
+ y: any;
4
+ h: any;
5
+ x: any;
6
+ w: any;
7
+ }[];
8
+ export function getMaxRows(layouts: any): number;
9
+ export function resolveLayout(layout: any): {
10
+ cols: {};
11
+ layouts: {};
12
+ breakpoints: {};
13
+ components: {};
14
+ };
15
+ //# sourceMappingURL=layout-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-utils.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/layout-utils.js"],"names":[],"mappings":"AAMA;;;;;;IAYC;AAED,iDAQC;AAED;;;;;EA6CC"}
@@ -1,4 +1,4 @@
1
- import range from 'lodash/range';
1
+ import { range } from 'lodash-es';
2
2
  function sum(a) {
3
3
  return a.reduce((x, y) => x + y, 0);
4
4
  }
@@ -31,6 +31,7 @@ export function resolveLayout(layout) {
31
31
  component: def.component,
32
32
  props: def.props || {},
33
33
  coordinationScopes: def.coordinationScopes || {},
34
+ coordinationScopesBy: def.coordinationScopesBy || {},
34
35
  };
35
36
  positions[id] = {
36
37
  id, x: def.x, y: def.y, w: def.w, h: def.h,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=layout-utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"layout-utils.test.d.ts","sourceRoot":"","sources":["../../src/vitessce-grid-layout/layout-utils.test.js"],"names":[],"mappings":""}
@@ -1,4 +1,4 @@
1
- import { makeGridLayout, getMaxRows, resolveLayout, } from './layout-utils';
1
+ import { makeGridLayout, getMaxRows, resolveLayout, } from './layout-utils.js';
2
2
  describe('layout-utils.js', () => {
3
3
  describe('makeGridLayout', () => {
4
4
  it('applies columnXs and makes list from object', () => {
@@ -82,12 +82,14 @@ describe('layout-utils.js', () => {
82
82
  uid: 'i0',
83
83
  component: 'NoProps',
84
84
  coordinationScopes: {},
85
+ coordinationScopesBy: {},
85
86
  props: {},
86
87
  },
87
88
  i1: {
88
89
  uid: 'i1',
89
90
  component: 'HasProps',
90
91
  coordinationScopes: {},
92
+ coordinationScopesBy: {},
91
93
  props: {
92
94
  foo: 'bar',
93
95
  },
@@ -0,0 +1,13 @@
1
+ export function useRowHeight(config: any, initialRowHeight: any, height: any, margin: any, padding: any): any[];
2
+ /**
3
+ * Create a mapping from dataset ID to loader objects by data type.
4
+ * @param {object[]} datasets The datasets array from the view config.
5
+ * @param {string} configDescription The top-level description in the
6
+ * @param {PluginFileType[]} fileTypes
7
+ * @param {PluginCoordinationType[]} coordinationTypes
8
+ * view config.
9
+ * @returns {object} Mapping from dataset ID to data type to loader
10
+ * instance.
11
+ */
12
+ export function createLoaders(datasets: object[], configDescription: string, fileTypes: PluginFileType[], coordinationTypes: PluginCoordinationType[]): object;
13
+ //# sourceMappingURL=vitessce-grid-utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vitessce-grid-utils.d.ts","sourceRoot":"","sources":["../src/vitessce-grid-utils.js"],"names":[],"mappings":"AA0CA,gHA6CC;AA4BD;;;;;;;;;GASG;AACH,wCARW,MAAM,EAAE,qBACR,MAAM,aACN,gBAAgB,qBAChB,wBAAwB,GAEtB,MAAM,CAiDlB"}