@voplus/morpho-document 1.0.0-dev214 → 1.0.0-dev216

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 (276) hide show
  1. package/es/components/ActivityLog/index.less +64 -64
  2. package/es/components/AddDocDropdown/index.js +23 -5
  3. package/es/components/AddDocDropdown/index.js.map +1 -1
  4. package/es/components/AddDocDropdown/index.less +3 -2
  5. package/es/components/AddDocDropdown/state.d.ts +1 -0
  6. package/es/components/AddDocDropdown/state.js +9 -3
  7. package/es/components/AddDocDropdown/state.js.map +1 -1
  8. package/es/components/BreadCrumbsHeader/index.d.ts +9 -0
  9. package/es/components/BreadCrumbsHeader/index.js +30 -0
  10. package/es/components/BreadCrumbsHeader/index.js.map +1 -0
  11. package/es/components/BreadCrumbsHeader/index.less +10 -0
  12. package/es/components/BreadCrumbsHeader/state.d.ts +10 -0
  13. package/es/components/BreadCrumbsHeader/state.js +34 -0
  14. package/es/components/BreadCrumbsHeader/state.js.map +1 -0
  15. package/es/components/DocumentItem/index.js +2 -8
  16. package/es/components/DocumentItem/index.js.map +1 -1
  17. package/es/components/DocumentList/Header.d.ts +13 -0
  18. package/es/components/DocumentList/Header.js +16 -0
  19. package/es/components/DocumentList/Header.js.map +1 -0
  20. package/es/components/DocumentList/index.js +35 -29
  21. package/es/components/DocumentList/index.js.map +1 -1
  22. package/es/components/DocumentList/index.less +39 -15
  23. package/es/components/DocumentList/state.d.ts +9 -27
  24. package/es/components/DocumentList/state.js +20 -115
  25. package/es/components/DocumentList/state.js.map +1 -1
  26. package/es/components/DocumentListView/index.d.ts +3 -2
  27. package/es/components/DocumentListView/index.js +31 -54
  28. package/es/components/DocumentListView/index.js.map +1 -1
  29. package/es/components/DocumentListView/state.d.ts +1 -36
  30. package/es/components/DocumentListView/state.js +1 -100
  31. package/es/components/DocumentListView/state.js.map +1 -1
  32. package/es/components/DocumentSortableTree/index.js +32 -4
  33. package/es/components/DocumentSortableTree/index.js.map +1 -1
  34. package/es/components/DocumentSortableTree/state.d.ts +7 -6
  35. package/es/components/DocumentSortableTree/state.js +23 -32
  36. package/es/components/DocumentSortableTree/state.js.map +1 -1
  37. package/es/components/DocumentTabs/index.js +2 -4
  38. package/es/components/DocumentTabs/index.js.map +1 -1
  39. package/es/components/DocumentTree/index.js +1 -1
  40. package/es/components/DocumentTree/index.js.map +1 -1
  41. package/es/components/FileViewer/ImageViewer.js +4 -3
  42. package/es/components/FileViewer/ImageViewer.js.map +1 -1
  43. package/es/components/FileViewer/PDFViewer.js +4 -2
  44. package/es/components/FileViewer/PDFViewer.js.map +1 -1
  45. package/es/components/FileViewer/Preview.js +12 -10
  46. package/es/components/FileViewer/Preview.js.map +1 -1
  47. package/es/components/FileViewer/index.less +33 -0
  48. package/es/components/Links/index.less +111 -111
  49. package/es/components/NewDocumentForm/index.d.ts +1 -1
  50. package/es/components/NewDocumentForm/index.js +10 -3
  51. package/es/components/NewDocumentForm/index.js.map +1 -1
  52. package/es/components/NewDocumentForm/index.less +9 -1
  53. package/es/components/QuickAccessSearch/index.js +5 -4
  54. package/es/components/QuickAccessSearch/index.js.map +1 -1
  55. package/es/components/QuickViewDialog/QuickSubTab/index.d.ts +10 -4
  56. package/es/components/QuickViewDialog/QuickSubTab/index.js +16 -16
  57. package/es/components/QuickViewDialog/QuickSubTab/index.js.map +1 -1
  58. package/es/components/QuickViewDialog/QuickSubTab/index.less +7 -19
  59. package/es/components/QuickViewDialog/index.js +2 -1
  60. package/es/components/QuickViewDialog/index.js.map +1 -1
  61. package/es/components/QuickViewDialog/index.less +8 -1
  62. package/es/components/helper.d.ts +1 -1
  63. package/es/components/helper.js +4 -0
  64. package/es/components/helper.js.map +1 -1
  65. package/es/components/styles/common.less +4 -1
  66. package/es/controls/filters/DocumentTypeFilter/index.d.ts +3 -0
  67. package/es/controls/filters/DocumentTypeFilter/index.js +21 -0
  68. package/es/controls/filters/DocumentTypeFilter/index.js.map +1 -0
  69. package/es/controls/filters/DocumentTypeFilter/state.d.ts +18 -0
  70. package/es/controls/filters/DocumentTypeFilter/state.js +57 -0
  71. package/es/controls/filters/DocumentTypeFilter/state.js.map +1 -0
  72. package/es/controls/filters/index.d.ts +1 -0
  73. package/es/controls/filters/index.js +1 -0
  74. package/es/controls/filters/index.js.map +1 -1
  75. package/es/data/DocumentStore/hooks/useDocumentListEffect.d.ts +2 -1
  76. package/es/data/DocumentStore/hooks/useDocumentListEffect.js +2 -2
  77. package/es/data/DocumentStore/hooks/useDocumentListEffect.js.map +1 -1
  78. package/es/data/DocumentType.d.ts +3 -1
  79. package/es/data/DocumentType.js +3 -1
  80. package/es/data/DocumentType.js.map +1 -1
  81. package/es/data/metas/ShortcutMeta.js +1 -1
  82. package/es/data/metas/ShortcutMeta.js.map +1 -1
  83. package/es/modules/unit/components/ActivityLog/index.d.ts +6 -0
  84. package/es/modules/unit/components/ActivityLog/index.js +62 -0
  85. package/es/modules/unit/components/ActivityLog/index.js.map +1 -0
  86. package/es/modules/unit/components/ActivityLog/index.less +64 -0
  87. package/es/modules/unit/components/ActivityLog/state.d.ts +14 -0
  88. package/es/modules/unit/components/ActivityLog/state.js +51 -0
  89. package/es/modules/unit/components/ActivityLog/state.js.map +1 -0
  90. package/es/modules/unit/components/BreadCrumbsHeader/index.d.ts +6 -0
  91. package/es/modules/unit/components/BreadCrumbsHeader/index.js +27 -0
  92. package/es/modules/unit/components/BreadCrumbsHeader/index.js.map +1 -0
  93. package/es/modules/unit/components/BreadCrumbsHeader/index.less +10 -0
  94. package/es/modules/unit/components/BreadCrumbsHeader/state.d.ts +5 -0
  95. package/es/modules/unit/components/BreadCrumbsHeader/state.js +19 -0
  96. package/es/modules/unit/components/BreadCrumbsHeader/state.js.map +1 -0
  97. package/es/modules/unit/components/Members/index.d.ts +4 -0
  98. package/es/modules/unit/components/Members/index.js +91 -0
  99. package/es/modules/unit/components/Members/index.js.map +1 -0
  100. package/es/modules/unit/components/Members/index.less +19 -0
  101. package/es/modules/unit/components/Members/state.d.ts +18 -0
  102. package/es/modules/unit/components/Members/state.js +29 -0
  103. package/es/modules/unit/components/Members/state.js.map +1 -0
  104. package/es/modules/unit/components/NewUnitForm/index.d.ts +11 -0
  105. package/es/modules/unit/components/NewUnitForm/index.js +51 -0
  106. package/es/modules/unit/components/NewUnitForm/index.js.map +1 -0
  107. package/es/modules/unit/components/NewUnitForm/index.less +33 -0
  108. package/es/modules/unit/components/NewUnitForm/state.d.ts +22 -0
  109. package/es/modules/unit/components/NewUnitForm/state.js +49 -0
  110. package/es/modules/unit/components/NewUnitForm/state.js.map +1 -0
  111. package/es/modules/unit/components/SortableTreeUnitTheme/index.d.ts +4 -0
  112. package/es/modules/unit/components/SortableTreeUnitTheme/index.js +23 -0
  113. package/es/modules/unit/components/SortableTreeUnitTheme/index.js.map +1 -0
  114. package/es/modules/unit/components/SortableTreeUnitTheme/node-content-renderer.d.ts +3 -0
  115. package/es/modules/unit/components/SortableTreeUnitTheme/node-content-renderer.js +58 -0
  116. package/es/modules/unit/components/SortableTreeUnitTheme/node-content-renderer.js.map +1 -0
  117. package/es/modules/unit/components/SortableTreeUnitTheme/node-content-renderer.less +46 -0
  118. package/es/modules/unit/components/SortableTreeUnitTheme/tree-node-renderer.d.ts +3 -0
  119. package/es/modules/unit/components/SortableTreeUnitTheme/tree-node-renderer.js +73 -0
  120. package/es/modules/unit/components/SortableTreeUnitTheme/tree-node-renderer.js.map +1 -0
  121. package/es/modules/unit/components/SortableTreeUnitTheme/tree-node-renderer.less +12 -0
  122. package/es/modules/unit/components/SubUnitList/index.d.ts +5 -0
  123. package/es/modules/unit/components/SubUnitList/index.js +70 -0
  124. package/es/modules/unit/components/SubUnitList/index.js.map +1 -0
  125. package/es/modules/unit/components/SubUnitList/index.less +13 -0
  126. package/es/modules/unit/components/SubUnitList/state.d.ts +14 -0
  127. package/es/modules/unit/components/SubUnitList/state.js +21 -0
  128. package/es/modules/unit/components/SubUnitList/state.js.map +1 -0
  129. package/es/modules/unit/components/UnitAvatar/index.d.ts +1 -0
  130. package/es/modules/unit/components/UnitAvatar/index.js +5 -4
  131. package/es/modules/unit/components/UnitAvatar/index.js.map +1 -1
  132. package/es/modules/unit/components/UnitAvatar/index.less +2 -3
  133. package/es/modules/unit/components/UnitDetails/index.js +98 -7
  134. package/es/modules/unit/components/UnitDetails/index.js.map +1 -1
  135. package/es/modules/unit/components/UnitDetails/index.less +41 -5
  136. package/es/modules/unit/components/UnitDetails/state.d.ts +8 -0
  137. package/es/modules/unit/components/UnitDetails/state.js +24 -0
  138. package/es/modules/unit/components/UnitDetails/state.js.map +1 -0
  139. package/es/modules/unit/components/UnitHead/index.d.ts +2 -0
  140. package/es/modules/unit/components/UnitHead/index.js +31 -7
  141. package/es/modules/unit/components/UnitHead/index.js.map +1 -1
  142. package/es/modules/unit/components/UnitHead/index.less +18 -3
  143. package/es/modules/unit/components/UnitHead/state.d.ts +11 -0
  144. package/es/modules/unit/components/UnitHead/state.js +8 -0
  145. package/es/modules/unit/components/UnitHead/state.js.map +1 -0
  146. package/es/modules/unit/components/UnitItem/DefaultUnitItem.d.ts +4 -0
  147. package/es/modules/unit/components/UnitItem/DefaultUnitItem.js +29 -0
  148. package/es/modules/unit/components/UnitItem/DefaultUnitItem.js.map +1 -0
  149. package/es/modules/unit/components/UnitItem/SubUnitItem.d.ts +4 -0
  150. package/es/modules/unit/components/UnitItem/SubUnitItem.js +35 -0
  151. package/es/modules/unit/components/UnitItem/SubUnitItem.js.map +1 -0
  152. package/es/modules/unit/components/UnitItem/index.less +23 -5
  153. package/es/modules/unit/components/UnitItem/state.d.ts +20 -0
  154. package/es/modules/unit/components/UnitItem/state.js +20 -0
  155. package/es/modules/unit/components/UnitItem/state.js.map +1 -0
  156. package/es/modules/unit/components/UnitList/index.d.ts +4 -0
  157. package/es/modules/unit/components/UnitList/index.js +37 -0
  158. package/es/modules/unit/components/UnitList/index.js.map +1 -0
  159. package/es/modules/unit/components/UnitList/state.d.ts +15 -0
  160. package/es/modules/unit/components/UnitList/state.js +31 -0
  161. package/es/modules/unit/components/UnitList/state.js.map +1 -0
  162. package/es/modules/unit/components/UnitPropertiesView/index.d.ts +6 -0
  163. package/es/modules/unit/components/UnitPropertiesView/index.js +22 -0
  164. package/es/modules/unit/components/UnitPropertiesView/index.js.map +1 -0
  165. package/es/modules/unit/components/UnitSortableTree/index.d.ts +10 -0
  166. package/es/modules/unit/components/UnitSortableTree/index.js +54 -0
  167. package/es/modules/unit/components/UnitSortableTree/index.js.map +1 -0
  168. package/es/modules/unit/components/UnitSortableTree/state.d.ts +50 -0
  169. package/es/modules/unit/components/UnitSortableTree/state.js +151 -0
  170. package/es/modules/unit/components/UnitSortableTree/state.js.map +1 -0
  171. package/es/modules/unit/components/UnitTabs/index.d.ts +6 -0
  172. package/es/modules/unit/components/UnitTabs/index.js +29 -0
  173. package/es/modules/unit/components/UnitTabs/index.js.map +1 -0
  174. package/es/modules/unit/controls/ContactSelect/index.d.ts +9 -0
  175. package/es/modules/unit/controls/ContactSelect/index.js +78 -0
  176. package/es/modules/unit/controls/ContactSelect/index.js.map +1 -0
  177. package/es/modules/unit/controls/ContactSelect/state.d.ts +23 -0
  178. package/es/modules/unit/controls/ContactSelect/state.js +43 -0
  179. package/es/modules/unit/controls/ContactSelect/state.js.map +1 -0
  180. package/es/modules/unit/controls/QuickDataIcon/UnitTeamsIcon/index.d.ts +6 -0
  181. package/es/modules/unit/controls/QuickDataIcon/UnitTeamsIcon/index.js +32 -0
  182. package/es/modules/unit/controls/QuickDataIcon/UnitTeamsIcon/index.js.map +1 -0
  183. package/es/modules/unit/{components → controls}/QuickDataIcon/index.d.ts +2 -6
  184. package/es/modules/unit/controls/QuickDataIcon/index.js +36 -0
  185. package/es/modules/unit/controls/QuickDataIcon/index.js.map +1 -0
  186. package/es/modules/unit/controls/QuickDataIcon/index.less +0 -0
  187. package/es/modules/unit/controls/ToolBar/ContactMenu/index.d.ts +13 -0
  188. package/es/modules/unit/controls/ToolBar/ContactMenu/index.js +59 -0
  189. package/es/modules/unit/controls/ToolBar/ContactMenu/index.js.map +1 -0
  190. package/es/modules/unit/controls/ToolBar/ContactMenu/index.less +20 -0
  191. package/es/modules/unit/controls/ToolBar/ContactMenu/state.d.ts +34 -0
  192. package/es/modules/unit/controls/ToolBar/ContactMenu/state.js +71 -0
  193. package/es/modules/unit/controls/ToolBar/ContactMenu/state.js.map +1 -0
  194. package/es/modules/unit/controls/ToolBar/index.d.ts +12 -0
  195. package/es/modules/unit/controls/ToolBar/index.js +54 -0
  196. package/es/modules/unit/controls/ToolBar/index.js.map +1 -0
  197. package/es/modules/unit/controls/ToolBar/index.less +18 -0
  198. package/es/modules/unit/controls/ToolBar/state.d.ts +40 -0
  199. package/es/modules/unit/controls/ToolBar/state.js +50 -0
  200. package/es/modules/unit/controls/ToolBar/state.js.map +1 -0
  201. package/es/modules/unit/controls/UnitTypeFilter/index.d.ts +3 -0
  202. package/es/modules/unit/controls/UnitTypeFilter/index.js +21 -0
  203. package/es/modules/unit/controls/UnitTypeFilter/index.js.map +1 -0
  204. package/es/modules/unit/controls/UnitTypeFilter/state.d.ts +18 -0
  205. package/es/modules/unit/controls/UnitTypeFilter/state.js +63 -0
  206. package/es/modules/unit/controls/UnitTypeFilter/state.js.map +1 -0
  207. package/es/modules/unit/data/FileStore/FileContext.d.ts +6 -0
  208. package/es/modules/unit/data/FileStore/FileContext.js +40 -0
  209. package/es/modules/unit/data/FileStore/FileContext.js.map +1 -0
  210. package/es/modules/unit/data/FileStore/index.d.ts +1 -0
  211. package/es/modules/unit/data/FileStore/index.js +2 -0
  212. package/es/modules/unit/data/FileStore/index.js.map +1 -0
  213. package/es/modules/unit/data/StoreContext/index.d.ts +3 -0
  214. package/es/modules/unit/data/StoreContext/index.js +4 -0
  215. package/es/modules/unit/data/StoreContext/index.js.map +1 -0
  216. package/es/modules/unit/data/UnitContext/index.d.ts +20 -0
  217. package/es/modules/unit/data/UnitContext/index.js +32 -0
  218. package/es/modules/unit/data/UnitContext/index.js.map +1 -0
  219. package/es/modules/unit/data/UnitStore.d.ts +103 -0
  220. package/es/modules/unit/data/UnitStore.js +180 -0
  221. package/es/modules/unit/data/UnitStore.js.map +1 -0
  222. package/es/modules/unit/data/hooks.d.ts +25 -0
  223. package/es/modules/unit/data/hooks.js +91 -0
  224. package/es/modules/unit/data/hooks.js.map +1 -0
  225. package/es/modules/unit/data/index.d.ts +3 -0
  226. package/es/modules/unit/data/index.js +3 -0
  227. package/es/modules/unit/data/index.js.map +1 -0
  228. package/es/modules/unit/data/interfaces/IAddress.d.ts +14 -0
  229. package/es/modules/unit/data/interfaces/IAddress.js +1 -0
  230. package/es/modules/unit/data/interfaces/IAddress.js.map +1 -0
  231. package/es/modules/unit/data/interfaces/IEntityName.d.ts +6 -0
  232. package/es/modules/unit/data/interfaces/IEntityName.js +1 -0
  233. package/es/modules/unit/data/interfaces/IEntityName.js.map +1 -0
  234. package/es/modules/unit/data/interfaces/IUnit.d.ts +47 -0
  235. package/es/modules/unit/data/interfaces/IUnit.js +1 -0
  236. package/es/modules/unit/data/interfaces/IUnit.js.map +1 -0
  237. package/es/modules/unit/data/interfaces/index.d.ts +3 -0
  238. package/es/modules/unit/data/interfaces/index.js +1 -0
  239. package/es/modules/unit/data/interfaces/index.js.map +1 -0
  240. package/es/modules/unit/pages/UnitDefaultView/index.d.ts +3 -0
  241. package/es/modules/unit/pages/UnitDefaultView/index.js +47 -0
  242. package/es/modules/unit/pages/UnitDefaultView/index.js.map +1 -0
  243. package/es/modules/unit/pages/UnitDefaultView/index.less +17 -0
  244. package/es/modules/unit/pages/UnitListView/index.d.ts +3 -0
  245. package/es/modules/unit/pages/UnitListView/index.js +10 -0
  246. package/es/modules/unit/pages/UnitListView/index.js.map +1 -0
  247. package/es/modules/unit/pages/UnitTreeView/index.d.ts +3 -0
  248. package/es/modules/unit/pages/UnitTreeView/index.js +47 -0
  249. package/es/modules/unit/pages/UnitTreeView/index.js.map +1 -0
  250. package/es/modules/unit/pages/UnitTreeView/index.less +31 -0
  251. package/es/modules/unit/pages/UnitTreeView/state.d.ts +5 -0
  252. package/es/modules/unit/pages/UnitTreeView/state.js +14 -0
  253. package/es/modules/unit/pages/UnitTreeView/state.js.map +1 -0
  254. package/es/pages/TreeViewPage/index.js +27 -20
  255. package/es/pages/TreeViewPage/index.js.map +1 -1
  256. package/es/pages/TreeViewPage/index.less +28 -19
  257. package/es/pages/TreeViewPage/state.d.ts +5 -0
  258. package/es/pages/TreeViewPage/state.js +14 -0
  259. package/es/pages/TreeViewPage/state.js.map +1 -0
  260. package/es/routes.d.ts +18 -0
  261. package/es/routes.js +40 -1
  262. package/es/routes.js.map +1 -1
  263. package/package.json +3 -1
  264. package/es/controls/DocumentTypeFilter/index.js +0 -54
  265. package/es/controls/DocumentTypeFilter/index.js.map +0 -1
  266. package/es/modules/unit/components/QuickDataIcon/UnitTeamsIcon/index.d.ts +0 -14
  267. package/es/modules/unit/components/QuickDataIcon/UnitTeamsIcon/index.js +0 -28
  268. package/es/modules/unit/components/QuickDataIcon/UnitTeamsIcon/index.js.map +0 -1
  269. package/es/modules/unit/components/QuickDataIcon/index.js +0 -45
  270. package/es/modules/unit/components/QuickDataIcon/index.js.map +0 -1
  271. package/es/modules/unit/components/UnitItem/index.d.ts +0 -6
  272. package/es/modules/unit/components/UnitItem/index.js +0 -19
  273. package/es/modules/unit/components/UnitItem/index.js.map +0 -1
  274. /package/es/modules/unit/components/{QuickDataIcon → UnitList}/index.less +0 -0
  275. /package/es/{controls/DocumentTypeFilter/index.d.ts → modules/unit/components/UnitPropertiesView/index.less} +0 -0
  276. /package/es/modules/unit/{components → controls}/QuickDataIcon/UnitTeamsIcon/index.less +0 -0
@@ -0,0 +1 @@
1
+ export * from "./FileContext";
@@ -0,0 +1,2 @@
1
+ export * from "./FileContext";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/FileStore/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC"}
@@ -0,0 +1,3 @@
1
+ import moment from "moment";
2
+ export declare const localFormat: (time?: any, format?: string | undefined) => string;
3
+ export declare const toLocal: (time: any) => moment.Moment;
@@ -0,0 +1,4 @@
1
+ import moment from "moment";
2
+ export const localFormat = (time, format) => moment(moment.utc(time).toDate()).format(format);
3
+ export const toLocal = (time) => moment(moment.utc(time).valueOf());
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/StoreContext/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAU,EAAE,MAAe,EAAE,EAAE,CAC1D,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAClD,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAS,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC"}
@@ -0,0 +1,20 @@
1
+ /// <reference types="react" />
2
+ /// <reference types="react-addons-transition-group" />
3
+ /// <reference types="react-addons-css-transition-group" />
4
+ export declare class UnitContextState {
5
+ onUnitSelected?: (params?: any) => void;
6
+ /** Construct a new UnitContextState
7
+ * @param options - Optional initial Unit options values.
8
+ */
9
+ constructor(options?: {
10
+ onUnitSelected?: (params?: any) => void;
11
+ });
12
+ /** Retrieve a clean OptionsObject */
13
+ get options(): {
14
+ UnitSelected: ((params?: any) => void) | undefined;
15
+ };
16
+ }
17
+ /** React context for ContextState. */
18
+ export declare const UnitContext: import("react").Context<UnitContextState>;
19
+ /** React hook to retrieve the nearest ContextState. */
20
+ export declare function useUnitContext(): UnitContextState;
@@ -0,0 +1,32 @@
1
+ import { __decorate } from "tslib";
2
+ import { computed, observable, toJS } from "mobx";
3
+ import { createContext, useContext } from "react";
4
+ export class UnitContextState {
5
+ /** Construct a new UnitContextState
6
+ * @param options - Optional initial Unit options values.
7
+ */
8
+ constructor(options) {
9
+ if (options) {
10
+ this.onUnitSelected = options.onUnitSelected;
11
+ }
12
+ }
13
+ /** Retrieve a clean OptionsObject */
14
+ get options() {
15
+ return {
16
+ UnitSelected: toJS(this.onUnitSelected)
17
+ };
18
+ }
19
+ }
20
+ __decorate([
21
+ observable
22
+ ], UnitContextState.prototype, "onUnitSelected", void 0);
23
+ __decorate([
24
+ computed
25
+ ], UnitContextState.prototype, "options", null);
26
+ /** React context for ContextState. */
27
+ export const UnitContext = createContext(null);
28
+ /** React hook to retrieve the nearest ContextState. */
29
+ export function useUnitContext() {
30
+ return useContext(UnitContext);
31
+ }
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/UnitContext/index.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAElD,MAAM,OAAO,gBAAgB;IAG5B;;OAEG;IACH,YAAmB,OAAqD;QACvE,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC;SAC7C;IACF,CAAC;IAED,qCAAqC;IAErC,IAAW,OAAO;QACjB,OAAO;YACN,YAAY,EAAE,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC;SACvC,CAAC;IACH,CAAC;CACD;AAlBY;IAAX,UAAU;wDAAgD;AAa3D;IADC,QAAQ;+CAKR;AAGF,sCAAsC;AACtC,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAmB,IAAW,CAAC,CAAC;AAExE,uDAAuD;AACvD,MAAM,UAAU,cAAc;IAC7B,OAAO,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC"}
@@ -0,0 +1,103 @@
1
+ import { ApiEndPoint } from "@voplus/api";
2
+ import { CountedMap, LoadOptions, Store } from "@voplus/morpho-data";
3
+ import { FilterOption, PageParameters } from "@voplus/morpho-data/es/types";
4
+ import { IAddress, IUnit } from "./interfaces";
5
+ import { IActivityLog } from "@voplus/morpho-collaboration/es/data/interfaces/IActivityLog";
6
+ /** Custom load contact list options type */
7
+ export declare type LoadUnitListOptions = {
8
+ Includes?: string;
9
+ reload?: boolean;
10
+ /** Parent id of of the units to be loaded */
11
+ parent?: string;
12
+ Filters?: FilterOption[];
13
+ Page?: PageParameters;
14
+ };
15
+ /** Custom load contact options type */
16
+ export declare type LoadUnitOptions = {
17
+ /** Comma separated include options e.g. path */
18
+ includes?: string;
19
+ } & LoadOptions<IUnit>;
20
+ export declare type EditUnitOptions = {
21
+ /** New name of the contact. */
22
+ Name?: string;
23
+ /** New Size of the contact. */
24
+ Size?: string;
25
+ /** New Gender of the contact. */
26
+ Gender?: "Male" | "Female";
27
+ /** New Email of the contact. */
28
+ Email?: string;
29
+ /** New Address of the contact. */
30
+ Address?: IAddress;
31
+ /** New Phone of the contact. */
32
+ Phone?: string;
33
+ /** New Nationality of the contact. */
34
+ Nationality?: string;
35
+ /** New Birthday of the contact. */
36
+ Birthday?: string;
37
+ };
38
+ /** Custom load contact list options type. */
39
+ export declare type DeleteUnitOptions = {
40
+ DeleteChilds?: boolean;
41
+ };
42
+ export declare class UnitStore extends Store {
43
+ private readonly _api;
44
+ readonly name: string;
45
+ /** Contac created event dispatcher */
46
+ private readonly _created;
47
+ private readonly _deleted;
48
+ constructor(_api: ApiEndPoint);
49
+ /** Event fires when a new contact has been created. */
50
+ get UnitCreatedEvent(): import("strongly-typed-events").IEvent<UnitStore, IUnit>;
51
+ /** Event fires when a delete contact has been deleted. */
52
+ get UnitDeletedEvent(): import("strongly-typed-events").IEvent<UnitStore, IUnit>;
53
+ readonly items: CountedMap<string, IUnit>;
54
+ /** Create a default contact object with optional default values. */
55
+ static createDefaultContact(defaultValues?: Partial<IUnit>): IUnit;
56
+ /** Create a new contact base on type. */
57
+ createFromType(options: {
58
+ name: string;
59
+ parentId: string;
60
+ type: string;
61
+ }): Promise<IUnit>;
62
+ /** 新增用戶至Group.
63
+ * pid是小組id
64
+ * id 是現有用戶id (必须是用户)
65
+ */
66
+ addUserFromGroup(options: {
67
+ pid: string;
68
+ id: string;
69
+ }): Promise<IUnit>;
70
+ /** Load a task from server.
71
+ * @param {string} id - id of the task.
72
+ * @param {LoadTaskOptions} options - Optional load options.
73
+ */
74
+ load(id: string, options: LoadUnitOptions): Promise<IUnit>;
75
+ /** Refresh a loaded unit. */
76
+ refresh(id: string, options: LoadUnitOptions): Promise<void>;
77
+ private _listCache;
78
+ /** Load a list of contacts from server.
79
+ * @param {LoadTaskListOptions}
80
+ */
81
+ loadList(options?: LoadUnitListOptions): Promise<any>;
82
+ private loadUnitsFromServer;
83
+ /** Load a list of activities of a contact from server.
84
+ * @param id - id of the contact.
85
+ * @param {LoadUnitListOptions}
86
+ */
87
+ loadActivityList(id: string, options?: LoadUnitListOptions): Promise<IActivityLog[]>;
88
+ /** Edit an existing item on server. */
89
+ edit(id: string, options: EditUnitOptions): Promise<void>;
90
+ delete(id: string): Promise<IUnit>;
91
+ /** 把用戶從Group移除
92
+ * pid是小組id
93
+ * id 是現有用戶id (必须是用户)
94
+ */
95
+ deleteUser(options: {
96
+ pid: string;
97
+ id: string;
98
+ }): Promise<IUnit>;
99
+ moveAfter(id: string, afterId?: string): Promise<void>;
100
+ move(ids: string[], targetId?: string): Promise<any>;
101
+ }
102
+ /** React hook to retrieve ContactStore */
103
+ export declare const useUnitStore: () => UnitStore;
@@ -0,0 +1,180 @@
1
+ import { __decorate } from "tslib";
2
+ import { RequestBuilder } from "@voplus/api";
3
+ import { CountedMap, Store, useApplicationContext } from "@voplus/morpho-data";
4
+ import { action, observable } from "mobx";
5
+ import { EventDispatcher } from "strongly-typed-events";
6
+ import hash from "object-hash";
7
+ import invariant from "invariant";
8
+ import { setTimeout } from "timers";
9
+ const StoreName = "UnitStore";
10
+ export class UnitStore extends Store {
11
+ constructor(_api) {
12
+ super();
13
+ this._api = _api;
14
+ this.name = StoreName;
15
+ /** Contac created event dispatcher */
16
+ this._created = new EventDispatcher();
17
+ this._deleted = new EventDispatcher();
18
+ this.items = new CountedMap((key) => UnitStore.createDefaultContact({ id: key }), observable.map([], { deep: true }));
19
+ this._listCache = new Map();
20
+ invariant(_api, `API cannot be ${_api}.`);
21
+ }
22
+ /** Event fires when a new contact has been created. */
23
+ get UnitCreatedEvent() {
24
+ return this._created.asEvent();
25
+ }
26
+ /** Event fires when a delete contact has been deleted. */
27
+ get UnitDeletedEvent() {
28
+ return this._deleted.asEvent();
29
+ }
30
+ /** Create a default contact object with optional default values. */
31
+ static createDefaultContact(defaultValues) {
32
+ const v = { loaded: false, address: {}, primaryLegalIdentity: {} };
33
+ if (defaultValues)
34
+ Object.assign(v, defaultValues);
35
+ return v;
36
+ }
37
+ /** Create a new contact base on type. */
38
+ async createFromType(options) {
39
+ invariant(options.name, "Name cannot be empty.");
40
+ const r = await this._api.post(`api/groups/create`, new RequestBuilder().form(options));
41
+ const t = (await r.json());
42
+ this._created.dispatch(this, t);
43
+ console.log("createFromType", t);
44
+ return t;
45
+ }
46
+ /** 新增用戶至Group.
47
+ * pid是小組id
48
+ * id 是現有用戶id (必须是用户)
49
+ */
50
+ async addUserFromGroup(options) {
51
+ // invariant(options.name, "Name cannot be empty.");
52
+ const r = await this._api.post(`api/groups/${options.pid}/add/${options.id}`
53
+ // new RequestBuilder().form(options)
54
+ );
55
+ console.log("addUserFromGroup", r);
56
+ const t = (await r.json());
57
+ this._created.dispatch(this, t);
58
+ console.log("addUserFromGroup", t);
59
+ return t;
60
+ }
61
+ /** Load a task from server.
62
+ * @param {string} id - id of the task.
63
+ * @param {LoadTaskOptions} options - Optional load options.
64
+ */
65
+ async load(id, options) {
66
+ let query = "";
67
+ if (options.includes)
68
+ query = query.concat(`includes=${options.includes}`);
69
+ if (query)
70
+ query = "?".concat(query);
71
+ const r = await this._api.get(`/units/${id}${query}`);
72
+ return (await r.json());
73
+ }
74
+ /** Refresh a loaded unit. */
75
+ async refresh(id, options) {
76
+ if (!this.items.has(id))
77
+ return;
78
+ const c = await this.load(id, options);
79
+ this.items.overwrite(id, c);
80
+ }
81
+ /** Load a list of contacts from server.
82
+ * @param {LoadTaskListOptions}
83
+ */
84
+ async loadList(options) {
85
+ options = options !== null && options !== void 0 ? options : { Filters: [] };
86
+ // skip local cache with paging.
87
+ if (options === null || options === void 0 ? void 0 : options.Page)
88
+ return await this.loadUnitsFromServer(options);
89
+ // const reload = options.reload;
90
+ delete options["reload"];
91
+ // Calculate hash code for load options.
92
+ const hc = hash(options);
93
+ // load from server if not cached
94
+ if (!this._listCache.has(hc)) {
95
+ const result = await this.loadUnitsFromServer(options);
96
+ // Save cache and clear time out.
97
+ this._listCache.set(hc, result);
98
+ setTimeout(() => {
99
+ this._listCache.delete(hc);
100
+ }, 5 * 60 * 1000);
101
+ }
102
+ return this._listCache.get(hc);
103
+ }
104
+ async loadUnitsFromServer(options) {
105
+ const urlPostFix = options.parent ? `/${options.parent}/units` : "";
106
+ const r = await this._api.post(`/units${urlPostFix}`, new RequestBuilder().json(options));
107
+ const result = await r.json();
108
+ return result;
109
+ }
110
+ /** Load a list of activities of a contact from server.
111
+ * @param id - id of the contact.
112
+ * @param {LoadUnitListOptions}
113
+ */
114
+ async loadActivityList(id, options) {
115
+ invariant(id, "id cannot be empty");
116
+ let query = "";
117
+ if (options === null || options === void 0 ? void 0 : options.Includes) {
118
+ query = query.concat(`includes=${options.Includes}`);
119
+ }
120
+ if (query)
121
+ query = "?".concat(query);
122
+ const r = await this._api.post(`/units/${id}/activities${query}`, new RequestBuilder().json(options ? options : { Filters: [] }));
123
+ return (await r.json());
124
+ }
125
+ /** Edit an existing item on server. */
126
+ async edit(id, options) {
127
+ const r = await this._api.post(`api/units/${id}/info`, new RequestBuilder().json(options));
128
+ const t = await r.json();
129
+ this.items.overwrite(t.id, t);
130
+ }
131
+ async delete(id) {
132
+ await this._api.delete(`api/groups/${id}`);
133
+ const item = this.items.peek(id);
134
+ this._deleted.dispatch(this, item);
135
+ return item;
136
+ }
137
+ /** 把用戶從Group移除
138
+ * pid是小組id
139
+ * id 是現有用戶id (必须是用户)
140
+ */
141
+ async deleteUser(options) {
142
+ await this._api.delete(`api/groups/${options.pid}/add/${options.id}`);
143
+ const item = this.items.peek(options.id);
144
+ this._deleted.dispatch(this, item);
145
+ return item;
146
+ }
147
+ async moveAfter(id, afterId) {
148
+ await this._api.post(`api/units/${id}/move?afterId=${afterId}`);
149
+ }
150
+ async move(ids, targetId) {
151
+ const result = await this._api.post(`api/units/move`, new RequestBuilder().json({ Ids: ids, TargetId: targetId }));
152
+ const moved = await result.json();
153
+ for (const item of moved) {
154
+ this._created.dispatch(this, item);
155
+ }
156
+ this._deleted.dispatch(this, moved);
157
+ return moved;
158
+ }
159
+ }
160
+ __decorate([
161
+ observable
162
+ ], UnitStore.prototype, "items", void 0);
163
+ __decorate([
164
+ action
165
+ ], UnitStore.prototype, "delete", null);
166
+ __decorate([
167
+ action
168
+ ], UnitStore.prototype, "moveAfter", null);
169
+ __decorate([
170
+ action
171
+ ], UnitStore.prototype, "move", null);
172
+ /** React hook to retrieve ContactStore */
173
+ export const useUnitStore = () => {
174
+ const context = useApplicationContext();
175
+ if (!context.getStore(StoreName)) {
176
+ context.addStore(new UnitStore(context.api.currentEndPoint));
177
+ }
178
+ return context.getStore(StoreName);
179
+ };
180
+ //# sourceMappingURL=UnitStore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnitStore.js","sourceRoot":"","sources":["../../../../src/modules/unit/data/UnitStore.ts"],"names":[],"mappings":";AAAA,OAAO,EAAe,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAe,KAAK,EAAE,qBAA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it, LoadUnitListOptions, LoadUnitOptions, UnitStore } from ".";
2
+ import { IActivityLog } from "@voplus/morpho-collaboration/es/data/interfaces/IActivityLog";
3
+ import { ListDataContextState } from "@voplus/morpho-ui/es/data";
4
+ /** React hook to retrieve a contact
5
+ * @param {string} id - id of the task
6
+ * @param {LoadUnitOptions} options - options
7
+ */
8
+ export declare const useUnit: (id: string, options?: LoadUnitOptions | undefined) => IUnit;
9
+ /** React hook to retrieve a list of tasks
10
+ * @param effect - Effect callback to be ran after successful retrieved the list.
11
+ * @param options - Optional task list loading options.
12
+ */
13
+ export declare const useUnitListEffect: (list: ListDataContextState<IUnit> | null, effect: (list: IUnit[]) => void, options?: LoadUnitListOptions | undefined) => void;
14
+ /** React hook to retrieve a list of activities of a contact.
15
+ * @param id - the id of the contact.
16
+ * @param effect - Effect callback to be ran after successful retrieved the list.
17
+ * @param options - Optional task list loading options.
18
+ */
19
+ export declare const useUnitActivityListEffect: (id: string, effect: (list: IActivityLog[]) => void, options?: LoadUnitListOptions | undefined) => void;
20
+ /** React hook to call action when a new contact has been created. */
21
+ export declare const useOnNewUnit: (action: (store: UnitStore, doc: IUnit) => void) => void;
22
+ /** React hook to call action when a delete contact has been created. */
23
+ export declare const useOnDeleteUnit: (action: (store: UnitStore, doc: IUnit) => void) => void;
24
+ /** React hook to call action when a new contact has been created. */
25
+ export declare const useAutoUpdateUnitListData: (list: ListDataContextState<IUnit>, shouldUpdate: (d: IUnit, event: string) => boolean) => void;
@@ -0,0 +1,91 @@
1
+ import { useUnitStore } from ".";
2
+ import { useCountedMapListEffect, useLoadCountedMapItem } from "@voplus/morpho-data";
3
+ import { useDeepDepEffect } from "@voplus/morpho-data";
4
+ import { useEffect } from "react";
5
+ /** React hook to retrieve a contact
6
+ * @param {string} id - id of the task
7
+ * @param {LoadUnitOptions} options - options
8
+ */
9
+ export const useUnit = (id, options) => {
10
+ options = options ? options : {};
11
+ const store = useUnitStore();
12
+ return useLoadCountedMapItem(id, store.items, () => store.load(id, options), options);
13
+ };
14
+ /** React hook to retrieve a list of tasks
15
+ * @param effect - Effect callback to be ran after successful retrieved the list.
16
+ * @param options - Optional task list loading options.
17
+ */
18
+ export const useUnitListEffect = (list, effect, options) => {
19
+ const deps = options ? options : {};
20
+ const contacts = useUnitStore();
21
+ // Call useContactListEffect and ensure won't load twice for same loading options.
22
+ // return useCountedMapListEffect(list, effect, contacts.items, () => contacts.loadList(options), [deps]);
23
+ return useCountedMapListEffect(effect ? innerEffect : effect, contacts.items, () => contacts.loadList(options), [deps], {
24
+ preload: () => {
25
+ if (list)
26
+ list.loading = true;
27
+ },
28
+ postload: () => {
29
+ if (list)
30
+ list.loading = false;
31
+ }
32
+ });
33
+ function innerEffect(result) {
34
+ if (list && result.length < list.filters.paging.PageSize)
35
+ list.hasMore = false;
36
+ effect(result);
37
+ }
38
+ };
39
+ /** React hook to retrieve a list of activities of a contact.
40
+ * @param id - the id of the contact.
41
+ * @param effect - Effect callback to be ran after successful retrieved the list.
42
+ * @param options - Optional task list loading options.
43
+ */
44
+ export const useUnitActivityListEffect = (id, effect, options) => {
45
+ const deps = options ? options : {};
46
+ const store = useUnitStore();
47
+ // Call useDeepDepEffect directly because returned links do not need to be stored in counted map.
48
+ useDeepDepEffect(() => {
49
+ store.loadActivityList(id, options).then(effect);
50
+ }, [deps]);
51
+ };
52
+ /** React hook to call action when a new contact has been created. */
53
+ export const useOnNewUnit = (action) => {
54
+ const store = useUnitStore();
55
+ const onNewContact = (store, doc) => {
56
+ console.log(`onNewContact - ${doc.id} ${doc.name}`);
57
+ action(store, doc);
58
+ };
59
+ useEffect(() => {
60
+ store.UnitCreatedEvent.subscribe(onNewContact);
61
+ return () => {
62
+ store.UnitCreatedEvent.unsubscribe(onNewContact);
63
+ };
64
+ });
65
+ };
66
+ /** React hook to call action when a delete contact has been created. */
67
+ export const useOnDeleteUnit = (action) => {
68
+ const store = useUnitStore();
69
+ const onDeleteContact = (store, doc) => {
70
+ console.log(`onDeleteContact - ${doc.id} ${doc.name}`);
71
+ action(store, doc);
72
+ };
73
+ useEffect(() => {
74
+ store.UnitDeletedEvent.subscribe(onDeleteContact);
75
+ return () => {
76
+ store.UnitDeletedEvent.unsubscribe(onDeleteContact);
77
+ };
78
+ });
79
+ };
80
+ /** React hook to call action when a new contact has been created. */
81
+ export const useAutoUpdateUnitListData = (list, shouldUpdate) => {
82
+ useOnNewUnit((s, d) => {
83
+ if (shouldUpdate(d, "new"))
84
+ list.union([d]);
85
+ });
86
+ useOnDeleteUnit((s, d) => {
87
+ if (shouldUpdate(d, "delete"))
88
+ list.remove(d.id);
89
+ });
90
+ };
91
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../../src/modules/unit/data/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0D,YAAY,EAAE,MAAM,GAAG,CAAC;AACzF,OAAO,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAIrF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAElC;;;GAGG;AACH,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,EAAU,EAAE,OAAyB,EAAE,EAAE;IAChE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAE,EAAsB,CAAC;IACtD,MAAM,KAAK,GAAG,YAAY,EAAE,CAAC;IAE7B,OAAO,qBAAqB,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,OAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AACxF,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAChC,IAAwC,EACxC,MAA+B,EAC/B,OAA6B,EAC5B,EAAE;IACH,MAAM,IAAI,GAAG,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,EACjD,EAAE;IACH,YAAY,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACrB,IAAI,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC;YAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;IAEH,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE;QACxB,IAAI,YAAY,CAAC,CAAC,EAAE,QAAQ,CAAC;YAAE,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from "./UnitStore";
2
+ export * from "./interfaces";
3
+ export * from "./hooks";
@@ -0,0 +1,3 @@
1
+ export * from "./UnitStore";
2
+ export * from "./hooks";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/modules/unit/data/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAE5B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,14 @@
1
+ export interface IAddress {
2
+ /** Address line 1 */
3
+ line1: string;
4
+ /** Address line 2 */
5
+ line2?: string;
6
+ /** City of the address*/
7
+ city?: string;
8
+ /** Province/State of the address */
9
+ state?: string;
10
+ /** Postal code of the address */
11
+ postalCode?: string;
12
+ /** Country of the address */
13
+ country: string;
14
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=IAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IAddress.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/interfaces/IAddress.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export interface IEntityId {
2
+ id: string;
3
+ }
4
+ export interface IEntityName extends IEntityId {
5
+ name: string;
6
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=IEntityName.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IEntityName.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/interfaces/IEntityName.ts"],"names":[],"mappings":""}
@@ -0,0 +1,47 @@
1
+ import { IAddress } from "./IAddress";
2
+ import { ILoadable } from "@voplus/morpho-data";
3
+ export interface ILegalIdentities {
4
+ /** Number of the identity document. */
5
+ number: string;
6
+ /** Name appear on the legal identity.*/
7
+ name: string;
8
+ /** Type of the legal identity */
9
+ type: "IdentityCard" | "Passport" | "BusinessRegistrationNo";
10
+ /** Country issued the identity */
11
+ country: string;
12
+ }
13
+ export interface IUnit extends ILoadable {
14
+ /** Id of the contact */
15
+ id: string;
16
+ /** containerId of the contact */
17
+ containerId: string;
18
+ /** Id of the parent contact. */
19
+ parentNodeId?: string;
20
+ /** Name of the contact */
21
+ name: string;
22
+ /** Whether the contact is a group or not. */
23
+ isGroup?: boolean;
24
+ /** Email of the contact. */
25
+ email?: string;
26
+ /** Phone of the contact. */
27
+ phone?: string;
28
+ /** Nationality of the contact */
29
+ nationality?: string;
30
+ /** Birthday of the contact */
31
+ birthday?: Date;
32
+ /** Gender of the contact */
33
+ gender?: "Male" | "Female";
34
+ /** Address of the contact. */
35
+ address: IAddress;
36
+ /** Site of the contact. */
37
+ site?: string;
38
+ /** Primary legal identity of the contact if has. */
39
+ primaryLegalIdentity: ILegalIdentities;
40
+ /** Type of the contact. */
41
+ type: string;
42
+ /** path of the contact */
43
+ path?: {
44
+ id: string;
45
+ name: string;
46
+ }[];
47
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=IUnit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"IUnit.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/interfaces/IUnit.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ export * from "./IUnit";
2
+ export * from "./IEntityName";
3
+ export * from "./IAddress";
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/modules/unit/data/interfaces/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ /// <reference types="react" />
2
+ declare const UnitDefaultView: () => JSX.Element;
3
+ export default UnitDefaultView;