solid-ui 2.6.1-d631dfca → 2.6.1-dc6afe0

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 (366) hide show
  1. package/LICENSE.md +3 -1
  2. package/README.md +85 -26
  3. package/dist/acl/access-controller.js +293 -0
  4. package/dist/acl/access-controller.js.map +1 -0
  5. package/dist/acl/access-groups.js +372 -0
  6. package/dist/acl/access-groups.js.map +1 -0
  7. package/dist/acl/acl-control.js +217 -0
  8. package/dist/acl/acl-control.js.map +1 -0
  9. package/dist/acl/acl.js +550 -0
  10. package/dist/acl/acl.js.map +1 -0
  11. package/dist/acl/add-agent-buttons.js +260 -0
  12. package/dist/acl/add-agent-buttons.js.map +1 -0
  13. package/dist/acl/index.js +35 -0
  14. package/dist/acl/index.js.map +1 -0
  15. package/dist/acl/types.js +7 -0
  16. package/dist/acl/types.js.map +1 -0
  17. package/{lib → dist}/chat/keys.d.ts +1 -1
  18. package/{lib → dist}/chat/keys.d.ts.map +1 -1
  19. package/dist/chat/keys.js +148 -0
  20. package/dist/chat/keys.js.map +1 -0
  21. package/dist/chat/signature.js +71 -0
  22. package/dist/chat/signature.js.map +1 -0
  23. package/dist/create/create.js +288 -0
  24. package/dist/create/create.js.map +1 -0
  25. package/dist/create/index.js +8 -0
  26. package/dist/create/index.js.map +1 -0
  27. package/dist/create/types.js +3 -0
  28. package/dist/create/types.js.map +1 -0
  29. package/dist/debug.js +23 -0
  30. package/dist/debug.js.map +1 -0
  31. package/dist/footer/index.js +72 -0
  32. package/dist/footer/index.js.map +1 -0
  33. package/dist/header/empty-profile.js +14 -0
  34. package/dist/header/empty-profile.js.map +1 -0
  35. package/dist/header/index.js +305 -0
  36. package/dist/header/index.js.map +1 -0
  37. package/dist/iconBase.js +40 -0
  38. package/dist/iconBase.js.map +1 -0
  39. package/dist/icons/solid_logo.js.map +1 -0
  40. package/{lib → dist}/index.d.ts +7 -9
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +162 -0
  43. package/dist/index.js.map +1 -0
  44. package/{lib → dist}/log.js +85 -99
  45. package/dist/log.js.map +1 -0
  46. package/dist/login/login.js +910 -0
  47. package/dist/login/login.js.map +1 -0
  48. package/dist/matrix/index.js +8 -0
  49. package/dist/matrix/index.js.map +1 -0
  50. package/dist/matrix/matrix.js +253 -0
  51. package/dist/matrix/matrix.js.map +1 -0
  52. package/dist/matrix/types.js +3 -0
  53. package/dist/matrix/types.js.map +1 -0
  54. package/dist/media/index.js +9 -0
  55. package/dist/media/index.js.map +1 -0
  56. package/dist/media/media-capture.js +198 -0
  57. package/dist/media/media-capture.js.map +1 -0
  58. package/dist/pad.js +795 -0
  59. package/dist/pad.js.map +1 -0
  60. package/dist/participation.js +228 -0
  61. package/dist/participation.js.map +1 -0
  62. package/dist/solid-ui.esm.js +25542 -0
  63. package/dist/solid-ui.esm.js.map +1 -0
  64. package/dist/solid-ui.esm.min.js +43 -0
  65. package/dist/solid-ui.esm.min.js.map +1 -0
  66. package/dist/solid-ui.js +23485 -68926
  67. package/dist/solid-ui.js.map +1 -1
  68. package/dist/solid-ui.min.js +40 -2
  69. package/dist/solid-ui.min.js.map +1 -1
  70. package/dist/tabs.js +398 -0
  71. package/dist/tabs.js.map +1 -0
  72. package/dist/utils/headerFooterHelpers.js +122 -0
  73. package/dist/utils/headerFooterHelpers.js.map +1 -0
  74. package/{lib → dist}/utils/keyHelpers/accessData.d.ts +3 -3
  75. package/{lib → dist}/utils/keyHelpers/accessData.d.ts.map +1 -1
  76. package/dist/utils/keyHelpers/accessData.js +108 -0
  77. package/dist/utils/keyHelpers/accessData.js.map +1 -0
  78. package/dist/utils/keyHelpers/acl.js +112 -0
  79. package/dist/utils/keyHelpers/acl.js.map +1 -0
  80. package/{lib → dist}/utils/keyHelpers/otherHelpers.d.ts +1 -1
  81. package/{lib → dist}/utils/keyHelpers/otherHelpers.d.ts.map +1 -1
  82. package/dist/utils/keyHelpers/otherHelpers.js +19 -0
  83. package/dist/utils/keyHelpers/otherHelpers.js.map +1 -0
  84. package/dist/utils/label.js +150 -0
  85. package/dist/utils/label.js.map +1 -0
  86. package/dist/versionInfo.js +33 -0
  87. package/dist/versionInfo.js.map +1 -0
  88. package/dist/widgets/buttons/iconLinks.js +49 -0
  89. package/dist/widgets/buttons/iconLinks.js.map +1 -0
  90. package/dist/widgets/buttons.js +1355 -0
  91. package/dist/widgets/buttons.js.map +1 -0
  92. package/dist/widgets/error.js +42 -0
  93. package/dist/widgets/error.js.map +1 -0
  94. package/dist/widgets/forms/autocomplete/autocompleteBar.js +162 -0
  95. package/dist/widgets/forms/autocomplete/autocompleteBar.js.map +1 -0
  96. package/dist/widgets/forms/autocomplete/autocompleteField.js +235 -0
  97. package/dist/widgets/forms/autocomplete/autocompleteField.js.map +1 -0
  98. package/dist/widgets/forms/autocomplete/autocompletePicker.js +296 -0
  99. package/dist/widgets/forms/autocomplete/autocompletePicker.js.map +1 -0
  100. package/dist/widgets/forms/autocomplete/language.js +147 -0
  101. package/dist/widgets/forms/autocomplete/language.js.map +1 -0
  102. package/{lib → dist}/widgets/forms/autocomplete/publicData.d.ts +3 -3
  103. package/dist/widgets/forms/autocomplete/publicData.d.ts.map +1 -0
  104. package/dist/widgets/forms/autocomplete/publicData.js +507 -0
  105. package/dist/widgets/forms/autocomplete/publicData.js.map +1 -0
  106. package/dist/widgets/forms/basic.js +250 -0
  107. package/dist/widgets/forms/basic.js.map +1 -0
  108. package/dist/widgets/forms/comment.js +52 -0
  109. package/dist/widgets/forms/comment.js.map +1 -0
  110. package/dist/widgets/forms/fieldFunction.js +49 -0
  111. package/dist/widgets/forms/fieldFunction.js.map +1 -0
  112. package/dist/widgets/forms/fieldParams.js +95 -0
  113. package/dist/widgets/forms/fieldParams.js.map +1 -0
  114. package/dist/widgets/forms/formStyle.js +43 -0
  115. package/dist/widgets/forms/formStyle.js.map +1 -0
  116. package/{lib → dist}/widgets/widgetHelpers.d.ts.map +1 -1
  117. package/{lib → dist}/widgets/widgetHelpers.js +19 -24
  118. package/dist/widgets/widgetHelpers.js.map +1 -0
  119. package/package.json +44 -47
  120. package/dist/789.solid-ui.min.js +0 -1
  121. package/dist/841.solid-ui.min.js +0 -3
  122. package/dist/841.solid-ui.min.js.LICENSE.txt +0 -58
  123. package/dist/841.solid-ui.min.js.map +0 -1
  124. package/dist/_2b19.solid-ui.js +0 -14
  125. package/dist/_2b19.solid-ui.js.map +0 -1
  126. package/dist/index.html +0 -1
  127. package/dist/solid-ui.min.js.LICENSE.txt +0 -57
  128. package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +0 -12247
  129. package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +0 -1
  130. package/lib/acl/access-controller.js +0 -391
  131. package/lib/acl/access-controller.js.map +0 -1
  132. package/lib/acl/access-groups.js +0 -507
  133. package/lib/acl/access-groups.js.map +0 -1
  134. package/lib/acl/acl-control.js +0 -237
  135. package/lib/acl/acl-control.js.map +0 -1
  136. package/lib/acl/acl.js +0 -517
  137. package/lib/acl/acl.js.map +0 -1
  138. package/lib/acl/add-agent-buttons.js +0 -434
  139. package/lib/acl/add-agent-buttons.js.map +0 -1
  140. package/lib/acl/index.js +0 -39
  141. package/lib/acl/index.js.map +0 -1
  142. package/lib/acl/types.js +0 -6
  143. package/lib/acl/types.js.map +0 -1
  144. package/lib/chat/bookmarks.js +0 -303
  145. package/lib/chat/bookmarks.js.map +0 -1
  146. package/lib/chat/chatLogic.js +0 -420
  147. package/lib/chat/chatLogic.js.map +0 -1
  148. package/lib/chat/dateFolder.js +0 -328
  149. package/lib/chat/dateFolder.js.map +0 -1
  150. package/lib/chat/infinite.js +0 -994
  151. package/lib/chat/infinite.js.map +0 -1
  152. package/lib/chat/keys.js +0 -232
  153. package/lib/chat/keys.js.map +0 -1
  154. package/lib/chat/message.js +0 -715
  155. package/lib/chat/message.js.map +0 -1
  156. package/lib/chat/messageTools.js +0 -538
  157. package/lib/chat/messageTools.js.map +0 -1
  158. package/lib/chat/signature.js +0 -109
  159. package/lib/chat/signature.js.map +0 -1
  160. package/lib/chat/thread.js +0 -535
  161. package/lib/chat/thread.js.map +0 -1
  162. package/lib/create/create.js +0 -242
  163. package/lib/create/create.js.map +0 -1
  164. package/lib/create/index.js +0 -11
  165. package/lib/create/index.js.map +0 -1
  166. package/lib/create/types.js +0 -6
  167. package/lib/create/types.js.map +0 -1
  168. package/lib/debug.js +0 -30
  169. package/lib/debug.js.map +0 -1
  170. package/lib/folders.js +0 -132
  171. package/lib/folders.js.map +0 -1
  172. package/lib/footer/index.js +0 -123
  173. package/lib/footer/index.js.map +0 -1
  174. package/lib/header/empty-profile.js +0 -8
  175. package/lib/header/empty-profile.js.map +0 -1
  176. package/lib/header/index.js +0 -375
  177. package/lib/header/index.js.map +0 -1
  178. package/lib/iconBase.js +0 -44
  179. package/lib/iconBase.js.map +0 -1
  180. package/lib/icons/solid_logo.js.map +0 -1
  181. package/lib/index.d.ts.map +0 -1
  182. package/lib/index.js +0 -223
  183. package/lib/index.js.map +0 -1
  184. package/lib/log.js.map +0 -1
  185. package/lib/login/login.js +0 -1241
  186. package/lib/login/login.js.map +0 -1
  187. package/lib/matrix/index.js +0 -11
  188. package/lib/matrix/index.js.map +0 -1
  189. package/lib/matrix/matrix.js +0 -216
  190. package/lib/matrix/matrix.js.map +0 -1
  191. package/lib/matrix/types.js +0 -6
  192. package/lib/matrix/types.js.map +0 -1
  193. package/lib/media/index.js +0 -12
  194. package/lib/media/index.js.map +0 -1
  195. package/lib/media/media-capture.js +0 -194
  196. package/lib/media/media-capture.js.map +0 -1
  197. package/lib/messageArea.js +0 -319
  198. package/lib/messageArea.js.map +0 -1
  199. package/lib/noun_Camera_1618446_000000.js +0 -8
  200. package/lib/noun_Camera_1618446_000000.js.map +0 -1
  201. package/lib/ns.js +0 -17
  202. package/lib/ns.js.map +0 -1
  203. package/lib/pad.js +0 -805
  204. package/lib/pad.js.map +0 -1
  205. package/lib/participation.js +0 -219
  206. package/lib/participation.js.map +0 -1
  207. package/lib/preferences.js +0 -215
  208. package/lib/preferences.js.map +0 -1
  209. package/lib/signup/config-default.js +0 -43
  210. package/lib/signup/config-default.js.map +0 -1
  211. package/lib/signup/signup.js +0 -74
  212. package/lib/signup/signup.js.map +0 -1
  213. package/lib/stories/decorators.js +0 -10
  214. package/lib/stories/decorators.js.map +0 -1
  215. package/lib/style.js +0 -158
  216. package/lib/style.js.map +0 -1
  217. package/lib/styleConstants.js +0 -35
  218. package/lib/styleConstants.js.map +0 -1
  219. package/lib/style_multiSelect.js +0 -62
  220. package/lib/style_multiSelect.js.map +0 -1
  221. package/lib/table.js +0 -1573
  222. package/lib/table.js.map +0 -1
  223. package/lib/tabs.js +0 -448
  224. package/lib/tabs.js.map +0 -1
  225. package/lib/typings.d.js +0 -2
  226. package/lib/typings.d.js.map +0 -1
  227. package/lib/utils/headerFooterHelpers.js +0 -165
  228. package/lib/utils/headerFooterHelpers.js.map +0 -1
  229. package/lib/utils/index.js +0 -527
  230. package/lib/utils/index.js.map +0 -1
  231. package/lib/utils/keyHelpers/accessData.js +0 -131
  232. package/lib/utils/keyHelpers/accessData.js.map +0 -1
  233. package/lib/utils/keyHelpers/acl.js +0 -90
  234. package/lib/utils/keyHelpers/acl.js.map +0 -1
  235. package/lib/utils/keyHelpers/otherHelpers.js +0 -21
  236. package/lib/utils/keyHelpers/otherHelpers.js.map +0 -1
  237. package/lib/utils/label.js +0 -103
  238. package/lib/utils/label.js.map +0 -1
  239. package/lib/versionInfo.d.ts +0 -32
  240. package/lib/versionInfo.d.ts.map +0 -1
  241. package/lib/versionInfo.js +0 -37
  242. package/lib/versionInfo.js.map +0 -1
  243. package/lib/widgets/buttons/iconLinks.js +0 -53
  244. package/lib/widgets/buttons/iconLinks.js.map +0 -1
  245. package/lib/widgets/buttons.js +0 -1306
  246. package/lib/widgets/buttons.js.map +0 -1
  247. package/lib/widgets/dragAndDrop.js +0 -194
  248. package/lib/widgets/dragAndDrop.js.map +0 -1
  249. package/lib/widgets/error.js +0 -46
  250. package/lib/widgets/error.js.map +0 -1
  251. package/lib/widgets/forms/autocomplete/autocompleteBar.js +0 -271
  252. package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +0 -1
  253. package/lib/widgets/forms/autocomplete/autocompleteField.js +0 -258
  254. package/lib/widgets/forms/autocomplete/autocompleteField.js.map +0 -1
  255. package/lib/widgets/forms/autocomplete/autocompletePicker.js +0 -436
  256. package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +0 -1
  257. package/lib/widgets/forms/autocomplete/language.js +0 -189
  258. package/lib/widgets/forms/autocomplete/language.js.map +0 -1
  259. package/lib/widgets/forms/autocomplete/publicData.d.ts.map +0 -1
  260. package/lib/widgets/forms/autocomplete/publicData.js +0 -636
  261. package/lib/widgets/forms/autocomplete/publicData.js.map +0 -1
  262. package/lib/widgets/forms/basic.js +0 -254
  263. package/lib/widgets/forms/basic.js.map +0 -1
  264. package/lib/widgets/forms/comment.js +0 -54
  265. package/lib/widgets/forms/comment.js.map +0 -1
  266. package/lib/widgets/forms/fieldFunction.js +0 -52
  267. package/lib/widgets/forms/fieldFunction.js.map +0 -1
  268. package/lib/widgets/forms/fieldParams.js +0 -77
  269. package/lib/widgets/forms/fieldParams.js.map +0 -1
  270. package/lib/widgets/forms/formStyle.js +0 -44
  271. package/lib/widgets/forms/formStyle.js.map +0 -1
  272. package/lib/widgets/forms.js +0 -2045
  273. package/lib/widgets/forms.js.map +0 -1
  274. package/lib/widgets/index.js +0 -110
  275. package/lib/widgets/index.js.map +0 -1
  276. package/lib/widgets/multiSelect.js +0 -658
  277. package/lib/widgets/multiSelect.js.map +0 -1
  278. package/lib/widgets/peoplePicker.js +0 -467
  279. package/lib/widgets/peoplePicker.js.map +0 -1
  280. package/lib/widgets/widgetHelpers.js.map +0 -1
  281. /package/{lib → dist}/acl/access-controller.d.ts +0 -0
  282. /package/{lib → dist}/acl/access-controller.d.ts.map +0 -0
  283. /package/{lib → dist}/acl/access-groups.d.ts +0 -0
  284. /package/{lib → dist}/acl/access-groups.d.ts.map +0 -0
  285. /package/{lib → dist}/acl/acl-control.d.ts +0 -0
  286. /package/{lib → dist}/acl/acl-control.d.ts.map +0 -0
  287. /package/{lib → dist}/acl/acl.d.ts +0 -0
  288. /package/{lib → dist}/acl/acl.d.ts.map +0 -0
  289. /package/{lib → dist}/acl/add-agent-buttons.d.ts +0 -0
  290. /package/{lib → dist}/acl/add-agent-buttons.d.ts.map +0 -0
  291. /package/{lib → dist}/acl/index.d.ts +0 -0
  292. /package/{lib → dist}/acl/index.d.ts.map +0 -0
  293. /package/{lib → dist}/acl/types.d.ts +0 -0
  294. /package/{lib → dist}/acl/types.d.ts.map +0 -0
  295. /package/{lib → dist}/chat/signature.d.ts +0 -0
  296. /package/{lib → dist}/chat/signature.d.ts.map +0 -0
  297. /package/{lib → dist}/create/create.d.ts +0 -0
  298. /package/{lib → dist}/create/create.d.ts.map +0 -0
  299. /package/{lib → dist}/create/index.d.ts +0 -0
  300. /package/{lib → dist}/create/index.d.ts.map +0 -0
  301. /package/{lib → dist}/create/types.d.ts +0 -0
  302. /package/{lib → dist}/create/types.d.ts.map +0 -0
  303. /package/{lib → dist}/debug.d.ts +0 -0
  304. /package/{lib → dist}/debug.d.ts.map +0 -0
  305. /package/{lib → dist}/footer/index.d.ts +0 -0
  306. /package/{lib → dist}/footer/index.d.ts.map +0 -0
  307. /package/{lib → dist}/header/empty-profile.d.ts +0 -0
  308. /package/{lib → dist}/header/empty-profile.d.ts.map +0 -0
  309. /package/{lib → dist}/header/index.d.ts +0 -0
  310. /package/{lib → dist}/header/index.d.ts.map +0 -0
  311. /package/{lib → dist}/iconBase.d.ts +0 -0
  312. /package/{lib → dist}/iconBase.d.ts.map +0 -0
  313. /package/{lib → dist}/icons/solid_logo.d.ts +0 -0
  314. /package/{lib → dist}/icons/solid_logo.d.ts.map +0 -0
  315. /package/{lib → dist}/icons/solid_logo.js +0 -0
  316. /package/{lib → dist}/log.d.ts +0 -0
  317. /package/{lib → dist}/log.d.ts.map +0 -0
  318. /package/{lib → dist}/login/login.d.ts +0 -0
  319. /package/{lib → dist}/login/login.d.ts.map +0 -0
  320. /package/{lib → dist}/matrix/index.d.ts +0 -0
  321. /package/{lib → dist}/matrix/index.d.ts.map +0 -0
  322. /package/{lib → dist}/matrix/matrix.d.ts +0 -0
  323. /package/{lib → dist}/matrix/matrix.d.ts.map +0 -0
  324. /package/{lib → dist}/matrix/types.d.ts +0 -0
  325. /package/{lib → dist}/matrix/types.d.ts.map +0 -0
  326. /package/{lib → dist}/media/index.d.ts +0 -0
  327. /package/{lib → dist}/media/index.d.ts.map +0 -0
  328. /package/{lib → dist}/media/media-capture.d.ts +0 -0
  329. /package/{lib → dist}/media/media-capture.d.ts.map +0 -0
  330. /package/{lib → dist}/pad.d.ts +0 -0
  331. /package/{lib → dist}/pad.d.ts.map +0 -0
  332. /package/{lib → dist}/participation.d.ts +0 -0
  333. /package/{lib → dist}/participation.d.ts.map +0 -0
  334. /package/{lib → dist}/tabs.d.ts +0 -0
  335. /package/{lib → dist}/tabs.d.ts.map +0 -0
  336. /package/{lib → dist}/utils/headerFooterHelpers.d.ts +0 -0
  337. /package/{lib → dist}/utils/headerFooterHelpers.d.ts.map +0 -0
  338. /package/{lib → dist}/utils/keyHelpers/acl.d.ts +0 -0
  339. /package/{lib → dist}/utils/keyHelpers/acl.d.ts.map +0 -0
  340. /package/{lib → dist}/utils/label.d.ts +0 -0
  341. /package/{lib → dist}/utils/label.d.ts.map +0 -0
  342. /package/{lib → dist}/widgets/buttons/iconLinks.d.ts +0 -0
  343. /package/{lib → dist}/widgets/buttons/iconLinks.d.ts.map +0 -0
  344. /package/{lib → dist}/widgets/buttons.d.ts +0 -0
  345. /package/{lib → dist}/widgets/buttons.d.ts.map +0 -0
  346. /package/{lib → dist}/widgets/error.d.ts +0 -0
  347. /package/{lib → dist}/widgets/error.d.ts.map +0 -0
  348. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteBar.d.ts +0 -0
  349. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteBar.d.ts.map +0 -0
  350. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteField.d.ts +0 -0
  351. /package/{lib → dist}/widgets/forms/autocomplete/autocompleteField.d.ts.map +0 -0
  352. /package/{lib → dist}/widgets/forms/autocomplete/autocompletePicker.d.ts +0 -0
  353. /package/{lib → dist}/widgets/forms/autocomplete/autocompletePicker.d.ts.map +0 -0
  354. /package/{lib → dist}/widgets/forms/autocomplete/language.d.ts +0 -0
  355. /package/{lib → dist}/widgets/forms/autocomplete/language.d.ts.map +0 -0
  356. /package/{lib → dist}/widgets/forms/basic.d.ts +0 -0
  357. /package/{lib → dist}/widgets/forms/basic.d.ts.map +0 -0
  358. /package/{lib → dist}/widgets/forms/comment.d.ts +0 -0
  359. /package/{lib → dist}/widgets/forms/comment.d.ts.map +0 -0
  360. /package/{lib → dist}/widgets/forms/fieldFunction.d.ts +0 -0
  361. /package/{lib → dist}/widgets/forms/fieldFunction.d.ts.map +0 -0
  362. /package/{lib → dist}/widgets/forms/fieldParams.d.ts +0 -0
  363. /package/{lib → dist}/widgets/forms/fieldParams.d.ts.map +0 -0
  364. /package/{lib → dist}/widgets/forms/formStyle.d.ts +0 -0
  365. /package/{lib → dist}/widgets/forms/formStyle.d.ts.map +0 -0
  366. /package/{lib → dist}/widgets/widgetHelpers.d.ts +0 -0
@@ -0,0 +1,1355 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __importDefault = (this && this.__importDefault) || function (mod) {
36
+ return (mod && mod.__esModule) ? mod : { "default": mod };
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.index = exports.personTR = exports.iconForClass = void 0;
40
+ exports.complain = complain;
41
+ exports.clearElement = clearElement;
42
+ exports.extractLogURI = extractLogURI;
43
+ exports.shortDate = shortDate;
44
+ exports.formatDateTime = formatDateTime;
45
+ exports.timestamp = timestamp;
46
+ exports.shortTime = shortTime;
47
+ exports.setName = setName;
48
+ exports.imagesOf = imagesOf;
49
+ exports.findImageFromURI = findImageFromURI;
50
+ exports.findImage = findImage;
51
+ exports.setImage = setImage;
52
+ exports.faviconOrDefault = faviconOrDefault;
53
+ exports.deleteButtonWithCheck = deleteButtonWithCheck;
54
+ exports.button = button;
55
+ exports.cancelButton = cancelButton;
56
+ exports.continueButton = continueButton;
57
+ exports.askName = askName;
58
+ exports.renderAsRow = renderAsRow;
59
+ exports.createNameDiv = createNameDiv;
60
+ exports.createLinkDiv = createLinkDiv;
61
+ exports.renderAsDiv = renderAsDiv;
62
+ exports.refreshTree = refreshTree;
63
+ exports.attachmentList = attachmentList;
64
+ exports.openHrefInOutlineMode = openHrefInOutlineMode;
65
+ exports.defaultAnnotationStore = defaultAnnotationStore;
66
+ exports.allClassURIs = allClassURIs;
67
+ exports.propertyTriage = propertyTriage;
68
+ exports.linkButton = linkButton;
69
+ exports.removeButton = removeButton;
70
+ exports.selectorPanel = selectorPanel;
71
+ exports.selectorPanelRefresh = selectorPanelRefresh;
72
+ exports.addStyleSheet = addStyleSheet;
73
+ exports.isAudio = isAudio;
74
+ exports.isVideo = isVideo;
75
+ exports.isImage = isImage;
76
+ exports.fileUploadButtonDiv = fileUploadButtonDiv;
77
+ /* Buttons
78
+ */
79
+ const rdflib_1 = require("rdflib");
80
+ const iconBase_1 = require("../iconBase");
81
+ const ns_1 = __importDefault(require("../ns"));
82
+ const style_1 = require("../style");
83
+ const debug = __importStar(require("../debug"));
84
+ const log_1 = require("../log");
85
+ const dragAndDrop_1 = require("./dragAndDrop");
86
+ const solid_logic_1 = require("solid-logic");
87
+ const utils = __importStar(require("../utils"));
88
+ const error_1 = require("./error");
89
+ const widgetHelpers_1 = require("./widgetHelpers");
90
+ const iconLinks_1 = require("./buttons/iconLinks");
91
+ /**
92
+ * UI Widgets such as buttons
93
+ * @packageDocumentation
94
+ */
95
+ /* global alert */
96
+ const { iconBase } = iconBase_1.icons;
97
+ const cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
98
+ const checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
99
+ function getStatusArea(context) {
100
+ let box = (context && context.statusArea) || (context && context.div) || null;
101
+ if (box)
102
+ return box;
103
+ let dom = context && context.dom;
104
+ if (!dom && typeof document !== 'undefined') {
105
+ dom = document;
106
+ }
107
+ if (dom) {
108
+ const body = dom.getElementsByTagName('body')[0];
109
+ box = dom.createElement('div');
110
+ body.insertBefore(box, body.firstElementChild);
111
+ if (context) {
112
+ context.statusArea = box;
113
+ }
114
+ return box;
115
+ }
116
+ return null;
117
+ }
118
+ /**
119
+ * Display an error message block
120
+ */
121
+ function complain(context, err) {
122
+ if (!err)
123
+ return; // only if error
124
+ const ele = getStatusArea(context);
125
+ debug.log('Complaint: ' + err);
126
+ if (ele)
127
+ ele.appendChild((0, error_1.errorMessageBlock)((context && context.dom) || document, err));
128
+ else
129
+ alert(err);
130
+ }
131
+ /**
132
+ * Remove all the children of an HTML element
133
+ */
134
+ function clearElement(ele) {
135
+ while (ele.firstChild) {
136
+ ele.removeChild(ele.firstChild);
137
+ }
138
+ return ele;
139
+ }
140
+ /**
141
+ * To figure out the log URI from the full URI used to invoke the reasoner
142
+ */
143
+ function extractLogURI(fullURI) {
144
+ const logPos = fullURI.search(/logFile=/);
145
+ const rulPos = fullURI.search(/&rulesFile=/);
146
+ return fullURI.substring(logPos + 8, rulPos);
147
+ }
148
+ /**
149
+ * By default, converts e.g. '2020-02-19T19:35:28.557Z' to '19:35'
150
+ * if today is 19 Feb 2020, and to 'Feb 19' if not.
151
+ * @@@ TODO This needs to be changed to local time
152
+ * @param noTime Return a string like 'Feb 19' even if it's today.
153
+ */
154
+ function shortDate(str, noTime) {
155
+ if (!str)
156
+ return '???';
157
+ const month = [
158
+ 'Jan',
159
+ 'Feb',
160
+ 'Mar',
161
+ 'Apr',
162
+ 'May',
163
+ 'Jun',
164
+ 'Jul',
165
+ 'Aug',
166
+ 'Sep',
167
+ 'Oct',
168
+ 'Nov',
169
+ 'Dec'
170
+ ];
171
+ try {
172
+ const nowZ = new Date().toISOString();
173
+ // var nowZ = $rdf.term(now).value
174
+ // var n = now.getTimezoneOffset() // Minutes
175
+ if (str.slice(0, 10) === nowZ.slice(0, 10) && !noTime) {
176
+ return str.slice(11, 16);
177
+ }
178
+ if (str.slice(0, 4) === nowZ.slice(0, 4)) {
179
+ return (month[parseInt(str.slice(5, 7), 10) - 1] +
180
+ ' ' +
181
+ parseInt(str.slice(8, 10), 10));
182
+ }
183
+ return str.slice(0, 10);
184
+ }
185
+ catch (e) {
186
+ return 'shortdate:' + e;
187
+ }
188
+ }
189
+ /**
190
+ * Format a date and time
191
+ * @param date for instance `new Date()`
192
+ * @param format for instance '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}'
193
+ * @returns for instance '2000-01-15T23:14:23.002'
194
+ */
195
+ function formatDateTime(date, format) {
196
+ return format
197
+ .split('{')
198
+ .map(function (s) {
199
+ const k = s.split('}')[0];
200
+ const width = { Milliseconds: 3, FullYear: 4 };
201
+ const d = { Month: 1 };
202
+ return s
203
+ ? ('000' + (date['get' + k]() + (d[k] || 0))).slice(-(width[k] || 2)) + s.split('}')[1]
204
+ : '';
205
+ })
206
+ .join('');
207
+ }
208
+ /**
209
+ * Get a string representation of the current time
210
+ * @returns for instance '2000-01-15T23:14:23.002'
211
+ */
212
+ function timestamp() {
213
+ return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
214
+ }
215
+ /**
216
+ * Get a short string representation of the current time
217
+ * @returns for instance '23:14:23.002'
218
+ */
219
+ function shortTime() {
220
+ return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
221
+ }
222
+ // ///////////////////// Handy UX widgets
223
+ /**
224
+ * Sets the best name we have and looks up a better one
225
+ */
226
+ function setName(element, x) {
227
+ const kb = solid_logic_1.store;
228
+ const findName = function (x) {
229
+ const name = kb.any(x, ns_1.default.vcard('fn')) ||
230
+ kb.any(x, ns_1.default.foaf('name')) ||
231
+ kb.any(x, ns_1.default.vcard('organization-name'));
232
+ return name ? name.value : null;
233
+ };
234
+ const name = x.sameTerm(ns_1.default.foaf('Agent')) ? 'Everyone' : findName(x);
235
+ element.textContent = name || utils.label(x);
236
+ if (!name && x.uri) {
237
+ if (!kb.fetcher) {
238
+ throw new Error('kb has no fetcher');
239
+ }
240
+ // Note this is only a fetch, not a lookUP of all sameAs etc
241
+ kb.fetcher.nowOrWhenFetched(x.doc(), undefined, function (_ok) {
242
+ element.textContent = findName(x) || utils.label(x); // had: (ok ? '' : '? ') +
243
+ });
244
+ }
245
+ }
246
+ /**
247
+ * Set of suitable images
248
+ * See also [[findImage]]
249
+ * @param x The thing for which we want to find an image
250
+ * @param kb The RDF store to look in
251
+ * @returns It goes looking for triples in `kb`,
252
+ * `(subject: x), (predicate: see list below) (object: image-url)`
253
+ * to find any image linked from the thing with one of the following
254
+ * predicates (in order):
255
+ * * ns.sioc('avatar')
256
+ * * ns.foaf('img')
257
+ * * ns.vcard('logo')
258
+ * * ns.vcard('hasPhoto')
259
+ * * ns.vcard('photo')
260
+ * * ns.foaf('depiction')
261
+
262
+ */
263
+ function imagesOf(x, kb) {
264
+ return kb
265
+ .each(x, ns_1.default.sioc('avatar'))
266
+ .concat(kb.each(x, ns_1.default.foaf('img')))
267
+ .concat(kb.each(x, ns_1.default.vcard('logo')))
268
+ .concat(kb.each(x, ns_1.default.vcard('hasPhoto')))
269
+ .concat(kb.each(x, ns_1.default.vcard('photo')))
270
+ .concat(kb.each(x, ns_1.default.foaf('depiction')));
271
+ }
272
+ /**
273
+ * Best logo or avatar or photo etc to represent someone or some group etc
274
+ */
275
+ exports.iconForClass = {
276
+ // Potentially extendable by other apps, panes, etc
277
+ // Relative URIs to the iconBase
278
+ 'solid:AppProviderClass': 'noun_144.svg', // @@ classs name should not contain 'Class'
279
+ 'solid:AppProvider': 'noun_15177.svg', // @@
280
+ 'solid:Pod': 'noun_Cabinet_1434380.svg',
281
+ 'vcard:Group': 'noun_339237.svg',
282
+ 'vcard:Organization': 'noun_143899.svg',
283
+ 'vcard:Individual': 'noun_15059.svg',
284
+ 'schema:Person': 'noun_15059.svg',
285
+ 'foaf:Person': 'noun_15059.svg',
286
+ 'foaf:Agent': 'noun_98053.svg',
287
+ 'acl:AuthenticatedAgent': 'noun_99101.svg',
288
+ 'prov:SoftwareAgent': 'noun_Robot_849764.svg', // Bot
289
+ 'vcard:AddressBook': 'noun_15695.svg',
290
+ 'trip:Trip': 'noun_581629.svg',
291
+ 'meeting:LongChat': 'noun_1689339.svg',
292
+ 'meeting:Meeting': 'noun_66617.svg',
293
+ 'meeting:Project': 'noun_1036577.svg',
294
+ 'ui:Form': 'noun_122196.svg',
295
+ 'rdfs:Class': 'class-rectangle.svg', // For RDF developers
296
+ 'rdf:Property': 'property-diamond.svg',
297
+ 'owl:Ontology': 'noun_classification_1479198.svg',
298
+ 'wf:Tracker': 'noun_122196.svg',
299
+ 'wf:Task': 'noun_17020_gray-tick.svg',
300
+ 'wf:Open': 'noun_17020_sans-tick.svg',
301
+ 'wf:Closed': 'noun_17020.svg'
302
+ };
303
+ /**
304
+ * Returns the origin of the URI of a NamedNode
305
+ */
306
+ function tempSite(x) {
307
+ // use only while one in rdflib fails with origins 2019
308
+ const str = x.uri.split('#')[0];
309
+ const p = str.indexOf('//');
310
+ if (p < 0)
311
+ throw new Error('This URI does not have a web site part (origin)');
312
+ const q = str.indexOf('/', p + 2);
313
+ if (q < 0) {
314
+ // no third slash?
315
+ return str.slice(0) + '/'; // Add slash to a bare origin
316
+ }
317
+ else {
318
+ return str.slice(0, q + 1);
319
+ }
320
+ }
321
+ /**
322
+ * Find an image for this thing as a class
323
+ */
324
+ function findImageFromURI(x) {
325
+ const iconDir = iconBase;
326
+ // Special cases from URI scheme:
327
+ if (typeof x !== 'string' && x.uri) {
328
+ if (x.uri.split('/').length === 4 &&
329
+ !x.uri.split('/')[1] &&
330
+ !x.uri.split('/')[3]) {
331
+ return iconDir + 'noun_15177.svg'; // App -- this is an origin
332
+ }
333
+ // Non-HTTP URI types imply types
334
+ if (x.uri.startsWith('message:') || x.uri.startsWith('mid:')) {
335
+ // message: is apple bug-- should be mid:
336
+ return iconDir + 'noun_480183.svg'; // envelope noun_567486
337
+ }
338
+ if (x.uri.startsWith('mailto:')) {
339
+ return iconDir + 'noun_567486.svg'; // mailbox - an email desitination
340
+ }
341
+ // For HTTP(s) documents, we could look at the MIME type if we know it.
342
+ if (x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
343
+ return tempSite(x) + 'favicon.ico'; // was x.site().uri + ...
344
+ // Todo: make the document icon a fallback for if the favicon does not exist
345
+ // todo: pick up a possible favicon for the web page itself from a link
346
+ // was: return iconDir + 'noun_681601.svg' // document - under solid assumptions
347
+ }
348
+ return null;
349
+ }
350
+ return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
351
+ }
352
+ /**
353
+ * Find something we have as explicit image data for the thing
354
+ * See also [[imagesOf]]
355
+ * @param thing The thing for which we want to find an image
356
+ * @returns The URL of a globe icon if thing equals `ns.foaf('Agent')`
357
+ * or `ns.rdf('Resource')`. Otherwise, it goes looking for
358
+ * triples in `store`,
359
+ * `(subject: thing), (predicate: see list below) (object: image-url)`
360
+ * to find any image linked from the thing with one of the following
361
+ * predicates (in order):
362
+ * * ns.sioc('avatar')
363
+ * * ns.foaf('img')
364
+ * * ns.vcard('logo')
365
+ * * ns.vcard('hasPhoto')
366
+ * * ns.vcard('photo')
367
+ * * ns.foaf('depiction')
368
+ */
369
+ function findImage(thing) {
370
+ const kb = solid_logic_1.store;
371
+ const iconDir = iconBase;
372
+ if (thing.sameTerm(ns_1.default.foaf('Agent')) || thing.sameTerm(ns_1.default.rdf('Resource'))) {
373
+ return iconDir + 'noun_98053.svg'; // Globe
374
+ }
375
+ const image = kb.any(thing, ns_1.default.sioc('avatar')) ||
376
+ kb.any(thing, ns_1.default.foaf('img')) ||
377
+ kb.any(thing, ns_1.default.vcard('logo')) ||
378
+ kb.any(thing, ns_1.default.vcard('hasPhoto')) ||
379
+ kb.any(thing, ns_1.default.vcard('photo')) ||
380
+ kb.any(thing, ns_1.default.foaf('depiction'));
381
+ return image ? image.uri : null;
382
+ }
383
+ /**
384
+ * Do the best you can with the data available
385
+ *
386
+ * @return {Boolean} Are we happy with this icon?
387
+ * Sets src AND STYLE of the image.
388
+ */
389
+ function trySetImage(element, thing, iconForClassMap) {
390
+ const kb = solid_logic_1.store;
391
+ const explitImage = findImage(thing);
392
+ if (explitImage) {
393
+ element.setAttribute('src', explitImage);
394
+ return true;
395
+ }
396
+ // This is one of the classes we know about - the class itself?
397
+ const typeIcon = iconForClassMap[thing.uri];
398
+ if (typeIcon) {
399
+ element.setAttribute('src', typeIcon);
400
+ element.style = style_1.style.classIconStyle;
401
+ // element.style.border = '0.1em solid green;'
402
+ // element.style.backgroundColor = '#eeffee' // pale green
403
+ return true;
404
+ }
405
+ const schemeIcon = findImageFromURI(thing);
406
+ if (schemeIcon) {
407
+ element.setAttribute('src', schemeIcon);
408
+ return true; // happy with this -- don't look it up
409
+ }
410
+ // Do we have a generic icon for something in any class its in?
411
+ const types = kb.findTypeURIs(thing);
412
+ for (const typeURI in types) {
413
+ if (iconForClassMap[typeURI]) {
414
+ element.setAttribute('src', iconForClassMap[typeURI]);
415
+ return false; // maybe we can do better
416
+ }
417
+ }
418
+ element.setAttribute('src', iconBase + 'noun_10636_grey.svg'); // Grey Circle - some thing
419
+ return false; // we can do better
420
+ }
421
+ /**
422
+ * ToDo: Also add icons for *properties* like home, work, email, range, domain, comment,
423
+ */
424
+ function setImage(element, thing) {
425
+ const kb = solid_logic_1.store;
426
+ const iconForClassMap = {};
427
+ for (const k in exports.iconForClass) {
428
+ const pref = k.split(':')[0];
429
+ const id = k.split(':')[1];
430
+ const theClass = ns_1.default[pref](id);
431
+ iconForClassMap[theClass.uri] = rdflib_1.uri.join(exports.iconForClass[k], iconBase);
432
+ }
433
+ const happy = trySetImage(element, thing, iconForClassMap);
434
+ if (!happy && thing.uri) {
435
+ if (!kb.fetcher) {
436
+ throw new Error('kb has no fetcher');
437
+ }
438
+ kb.fetcher.nowOrWhenFetched(thing.doc(), undefined, (ok) => {
439
+ if (ok) {
440
+ trySetImage(element, thing, iconForClassMap);
441
+ }
442
+ });
443
+ }
444
+ }
445
+ // If a web page, then a favicon, with a fallback to ???
446
+ // See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
447
+ function faviconOrDefault(dom, x) {
448
+ const image = dom.createElement('img');
449
+ image.style = style_1.style.iconStyle;
450
+ const isOrigin = function (x) {
451
+ if (!x.uri)
452
+ return false;
453
+ const parts = x.uri.split('/');
454
+ return parts.length === 3 || (parts.length === 4 && parts[3] === '');
455
+ };
456
+ image.setAttribute('src', iconBase + (isOrigin(x) ? 'noun_15177.svg' : 'noun_681601.svg') // App symbol vs document
457
+ );
458
+ if (x.uri && x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
459
+ const res = dom.createElement('object'); // favico with a fallback of a default image if no favicon
460
+ res.setAttribute('data', tempSite(x) + 'favicon.ico');
461
+ res.setAttribute('type', 'image/x-icon');
462
+ res.appendChild(image); // fallback
463
+ return res;
464
+ }
465
+ else {
466
+ setImage(image, x);
467
+ return image;
468
+ }
469
+ }
470
+ /* Two-option dialog pop-up
471
+ */
472
+ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction) {
473
+ function removePopup() {
474
+ refererenceElement.parentElement.removeChild(refererenceElement);
475
+ }
476
+ function removePopupAndDoDeletion() {
477
+ removePopup();
478
+ deleteFunction();
479
+ }
480
+ const popup = dom.createElement('div');
481
+ popup.style = style_1.style.confirmPopupStyle;
482
+ popup.style.position = 'absolute';
483
+ popup.style.top = '-1em'; // try leaving original button clear
484
+ popup.style.display = 'grid';
485
+ popup.style.gridTemplateColumns = 'auto auto';
486
+ const affirm = dom.createElement('div');
487
+ affirm.style.gridColumn = '1/2';
488
+ affirm.style.gridRow = '1'; // @@ sigh; TS. could pass number in fact
489
+ const cancel = dom.createElement('div');
490
+ cancel.style.gridColumn = '1/2';
491
+ cancel.style.gridRow = '2';
492
+ const xButton = cancelButton(dom, removePopup);
493
+ popup.appendChild(xButton);
494
+ xButton.style.gridColumn = '1';
495
+ xButton.style.gridRow = '2';
496
+ const cancelPrompt = popup.appendChild(dom.createElement('button'));
497
+ cancelPrompt.style = style_1.style.buttonStyle;
498
+ cancelPrompt.style.gridRow = '2';
499
+ cancelPrompt.style.gridColumn = '2';
500
+ cancelPrompt.textContent = 'Cancel'; // @@ I18n
501
+ const affirmIcon = button(dom, iconBase_1.icons.iconBase + 'noun_925021.svg', 'Delete it'); // trashcan
502
+ popup.appendChild(affirmIcon);
503
+ affirmIcon.style.gridRow = '1';
504
+ affirmIcon.style.gridColumn = '1';
505
+ const sureButtonElt = popup.appendChild(dom.createElement('button'));
506
+ sureButtonElt.style = style_1.style.buttonStyle;
507
+ sureButtonElt.style.gridRow = '1';
508
+ sureButtonElt.style.gridColumn = '2';
509
+ sureButtonElt.textContent = prompt;
510
+ popup.appendChild(sureButtonElt);
511
+ affirmIcon.addEventListener('click', removePopupAndDoDeletion);
512
+ sureButtonElt.addEventListener('click', removePopupAndDoDeletion);
513
+ // xButton.addEventListener('click', removePopup)
514
+ cancelPrompt.addEventListener('click', removePopup);
515
+ return popup;
516
+ }
517
+ /**
518
+ * Delete button with a check you really mean it
519
+ * @@ Supress check if command key held down?
520
+ */
521
+ function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
522
+ function createPopup() {
523
+ const refererenceElement = dom.createElement('div');
524
+ container.insertBefore(refererenceElement, deleteButton);
525
+ refererenceElement.style.position = 'relative'; // Needed as reference for popup
526
+ refererenceElement.appendChild(renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction));
527
+ }
528
+ const minusIconURI = iconBase + 'noun_2188_red.svg'; // white minus in red #cc0000 circle
529
+ const deleteButton = dom.createElement('img');
530
+ deleteButton.setAttribute('src', minusIconURI);
531
+ deleteButton.setAttribute('style', style_1.style.smallButtonStyle); // @@tsc - would set deleteButton.style
532
+ deleteButton.style.float = 'right'; // Historically this has alwaus floated right
533
+ const prompt = 'Remove this ' + noun;
534
+ deleteButton.title = prompt;
535
+ // @@ In an ideal world, make use of hover an accessibility option
536
+ deleteButton.classList.add('hoverControlHide');
537
+ deleteButton.addEventListener('click', createPopup);
538
+ container.classList.add('hoverControl');
539
+ container.appendChild(deleteButton);
540
+ deleteButton.setAttribute('data-testid', 'deleteButtonWithCheck');
541
+ return deleteButton; // or button div? caller may change size of image
542
+ }
543
+ /* Make a button
544
+ *
545
+ * @param dom - the DOM document object
546
+ * @Param iconURI - the URI of the icon to use (if any)
547
+ * @param text - the tooltip text or possibly button contents text
548
+ * @param handler <function> - A handler to called when button is clicked
549
+ *
550
+ * @returns <dDomElement> - the button
551
+ */
552
+ function button(dom, iconURI, text, handler, options = { buttonColor: 'Primary', needsBorder: false }) {
553
+ const button = dom.createElement('button');
554
+ button.setAttribute('type', 'button');
555
+ // button.innerHTML = text // later, user preferences may make text preferred for some
556
+ if (iconURI) {
557
+ const img = button.appendChild(dom.createElement('img'));
558
+ img.setAttribute('src', iconURI);
559
+ img.setAttribute('style', 'width: 2em; height: 2em;'); // trial and error. 2em disappears
560
+ img.title = text;
561
+ button.setAttribute('style', style_1.style.buttonStyle);
562
+ }
563
+ else {
564
+ button.textContent = text.toLocaleUpperCase();
565
+ button.onmouseover = function () {
566
+ if (options.buttonColor === 'Secondary') {
567
+ if (options.needsBorder) {
568
+ button.setAttribute('style', style_1.style.secondaryButtonNoBorderHover);
569
+ }
570
+ else {
571
+ button.setAttribute('style', style_1.style.secondaryButtonHover);
572
+ }
573
+ }
574
+ else {
575
+ if (options.needsBorder) {
576
+ button.setAttribute('style', style_1.style.primaryButtonNoBorderHover);
577
+ }
578
+ else {
579
+ button.setAttribute('style', style_1.style.primaryButtonHover);
580
+ }
581
+ }
582
+ };
583
+ button.onmouseout = function () {
584
+ if (options.buttonColor === 'Secondary') {
585
+ if (options.needsBorder) {
586
+ button.setAttribute('style', style_1.style.secondaryButtonNoBorder);
587
+ }
588
+ else {
589
+ button.setAttribute('style', style_1.style.secondaryButton);
590
+ }
591
+ }
592
+ else {
593
+ if (options.needsBorder) {
594
+ button.setAttribute('style', style_1.style.primaryButtonNoBorder);
595
+ }
596
+ else {
597
+ button.setAttribute('style', style_1.style.primaryButton);
598
+ }
599
+ }
600
+ };
601
+ if (options.buttonColor === 'Secondary') {
602
+ if (options.needsBorder) {
603
+ button.setAttribute('style', style_1.style.secondaryButtonNoBorder);
604
+ }
605
+ else {
606
+ button.setAttribute('style', style_1.style.secondaryButton);
607
+ }
608
+ }
609
+ else {
610
+ if (options.needsBorder) {
611
+ button.setAttribute('style', style_1.style.primaryButtonNoBorder);
612
+ }
613
+ else {
614
+ button.setAttribute('style', style_1.style.primaryButton);
615
+ }
616
+ }
617
+ }
618
+ if (handler) {
619
+ button.addEventListener('click', handler, false);
620
+ }
621
+ return button;
622
+ }
623
+ /* Make a cancel button
624
+ *
625
+ * @param dom - the DOM document object
626
+ * @param handler <function> - A handler to called when button is clicked
627
+ *
628
+ * @returns <dDomElement> - the button
629
+ */
630
+ function cancelButton(dom, handler) {
631
+ const b = button(dom, cancelIconURI, 'Cancel', handler);
632
+ if (b.firstChild) { // sigh for tsc
633
+ b.firstChild.style.opacity = '0.3'; // Black X is too harsh: current language is grey X
634
+ }
635
+ return b;
636
+ }
637
+ /* Make a continue button
638
+ *
639
+ * @param dom - the DOM document object
640
+ * @param handler <function> - A handler to called when button is clicked
641
+ *
642
+ * @returns <dDomElement> - the button
643
+ */
644
+ function continueButton(dom, handler) {
645
+ return button(dom, checkIconURI, 'Continue', handler);
646
+ }
647
+ /* Grab a name for a new thing
648
+ *
649
+ * Form to get the name of a new thing before we create it
650
+ * @params theClass Misspelt to avoid clashing with the JavaScript keyword
651
+ * @returns: a promise of (a name or null if cancelled)
652
+ */
653
+ function askName(dom, kb, container, predicate, theClass, noun) {
654
+ return new Promise(function (resolve, _reject) {
655
+ const form = dom.createElement('div'); // form is broken as HTML behaviour can resurface on js error
656
+ // classLabel = utils.label(ns.vcard('Individual'))
657
+ predicate = predicate || ns_1.default.foaf('name'); // eg 'name' in user's language
658
+ noun = noun || (theClass ? utils.label(theClass) : ' '); // eg 'folder' in users's language
659
+ const prompt = noun + ' ' + utils.label(predicate) + ': ';
660
+ form.appendChild(dom.createElement('p')).textContent = prompt;
661
+ const namefield = dom.createElement('input');
662
+ namefield.setAttribute('type', 'text');
663
+ namefield.setAttribute('size', '100');
664
+ namefield.setAttribute('maxLength', '2048'); // No arbitrary limits
665
+ namefield.setAttribute('style', style_1.style.textInputStyle);
666
+ namefield.select(); // focus next user input
667
+ form.appendChild(namefield);
668
+ container.appendChild(form);
669
+ // namefield.focus()
670
+ function gotName() {
671
+ form.parentNode.removeChild(form);
672
+ resolve(namefield.value.trim());
673
+ }
674
+ namefield.addEventListener('keyup', function (e) {
675
+ if (e.keyCode === 13) {
676
+ gotName();
677
+ }
678
+ }, false);
679
+ form.appendChild(dom.createElement('br'));
680
+ form.appendChild(cancelButton(dom, function (_event) {
681
+ form.parentNode.removeChild(form);
682
+ resolve(null);
683
+ }));
684
+ form.appendChild(continueButton(dom, function (_event) {
685
+ gotName();
686
+ }));
687
+ namefield.focus();
688
+ }); // Promise
689
+ }
690
+ /**
691
+ * A TR to represent a draggable person, etc in a list
692
+ *
693
+ * pred is unused param at the moment
694
+ */
695
+ exports.personTR = renderAsRow; // The legacy name is used in a lot of places
696
+ function renderAsRow(dom, pred, obj, options) {
697
+ const tr = dom.createElement('tr');
698
+ options = options || {};
699
+ // tr.predObj = [pred.uri, obj.uri] moved to acl-control
700
+ const td1 = tr.appendChild(dom.createElement('td'));
701
+ const td2 = tr.appendChild(dom.createElement('td'));
702
+ const td3 = tr.appendChild(dom.createElement('td'));
703
+ // const image = td1.appendChild(dom.createElement('img'))
704
+ const image = options.image || faviconOrDefault(dom, obj);
705
+ td1.setAttribute('style', 'vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;');
706
+ td2.setAttribute('style', 'vertical-align: middle; text-align:left;');
707
+ td3.setAttribute('style', 'vertical-align: middle; width:2em; padding:0.5em; height: 4em;');
708
+ td1.appendChild(image);
709
+ if (options.title) {
710
+ td2.textContent = options.title;
711
+ }
712
+ else {
713
+ setName(td2, obj); // This is async
714
+ }
715
+ if (options.deleteFunction) {
716
+ deleteButtonWithCheck(dom, td3, options.noun || 'one', options.deleteFunction);
717
+ }
718
+ if (obj.uri) {
719
+ // blank nodes need not apply
720
+ if (options.link !== false) {
721
+ const anchor = td3.appendChild((0, iconLinks_1.linkIcon)(dom, obj));
722
+ anchor.classList.add('HoverControlHide');
723
+ td3.appendChild(dom.createElement('br'));
724
+ }
725
+ if (options.draggable !== false) {
726
+ // default is on
727
+ image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
728
+ (0, dragAndDrop_1.makeDraggable)(tr, obj);
729
+ }
730
+ }
731
+ ;
732
+ tr.subject = obj;
733
+ return tr;
734
+ }
735
+ /* A helper function for renderAsDiv
736
+ * creates the NameDiv for the person
737
+ * Note: could not move it to the helper file because they call exported functions
738
+ * from buttons
739
+ * @internal exporting this only for unit tests
740
+ */
741
+ function createNameDiv(dom, div, title, obj) {
742
+ const nameDiv = div.appendChild(dom.createElement('div'));
743
+ if (title) {
744
+ nameDiv.textContent = title;
745
+ }
746
+ else {
747
+ setName(nameDiv, obj); // This is async
748
+ }
749
+ }
750
+ /* A helper function for renderAsDiv
751
+ * creates the linkDiv for the person
752
+ * Note: could not move it to the helper file because they call exported functions
753
+ * from buttons
754
+ * @internal exporting this only for unit tests
755
+ */
756
+ function createLinkDiv(dom, div, obj, options) {
757
+ const linkDiv = div.appendChild(dom.createElement('div'));
758
+ linkDiv.setAttribute('style', style_1.style.linkDivStyle);
759
+ if (options.deleteFunction) {
760
+ deleteButtonWithCheck(dom, linkDiv, options.noun || 'one', options.deleteFunction);
761
+ }
762
+ if (obj.uri) {
763
+ // blank nodes need not apply
764
+ if (options.link !== false) {
765
+ (0, iconLinks_1.createLinkForURI)(dom, linkDiv, obj);
766
+ }
767
+ (0, dragAndDrop_1.makeDraggable)(div, obj);
768
+ }
769
+ }
770
+ /**
771
+ * A Div to represent a draggable person, etc in a list
772
+ * configurable to add an onClick listener
773
+ */
774
+ function renderAsDiv(dom, obj, options) {
775
+ const div = dom.createElement('div');
776
+ div.setAttribute('style', style_1.style.renderAsDivStyle);
777
+ options = options || {};
778
+ const image = options.image || faviconOrDefault(dom, obj);
779
+ (0, widgetHelpers_1.createImageDiv)(dom, div, image);
780
+ createNameDiv(dom, div, options.title, obj);
781
+ createLinkDiv(dom, div, obj, options);
782
+ if (options.clickable && options.onClickFunction) {
783
+ (0, widgetHelpers_1.addClickListenerToElement)(div, options.onClickFunction);
784
+ }
785
+ // to be compatible with the SolidOS table layout
786
+ if (options.wrapInATR) {
787
+ const tr = (0, widgetHelpers_1.wrapDivInATR)(dom, div, obj);
788
+ return tr;
789
+ }
790
+ return div;
791
+ }
792
+ /**
793
+ * Refresh a DOM tree recursively
794
+ */
795
+ function refreshTree(root) {
796
+ if (root.refresh) {
797
+ root.refresh();
798
+ return;
799
+ }
800
+ for (let i = 0; i < root.children.length; i++) {
801
+ refreshTree(root.children[i]);
802
+ }
803
+ }
804
+ /**
805
+ * Component that displays a list of resources, for instance
806
+ * the attachments of a message, or the various documents related
807
+ * to a meeting.
808
+ * Accepts dropping URLs onto it to add attachments to it.
809
+ */
810
+ function attachmentList(dom, subject, div, options = {}) {
811
+ // options = options || {}
812
+ const deleteAttachment = function (target) {
813
+ if (!kb.updater) {
814
+ throw new Error('kb has no updater');
815
+ }
816
+ kb.updater.update((0, rdflib_1.st)(subject, predicate, target, doc), [], function (uri, ok, errorBody, _xhr) {
817
+ if (ok) {
818
+ refresh();
819
+ }
820
+ else {
821
+ complain(undefined, 'Error deleting one: ' + errorBody);
822
+ }
823
+ });
824
+ };
825
+ function createNewRow(target) {
826
+ const theTarget = target;
827
+ const opt = { noun };
828
+ if (modify) {
829
+ opt.deleteFunction = function () {
830
+ deleteAttachment(theTarget);
831
+ };
832
+ }
833
+ return (0, exports.personTR)(dom, predicate, target, opt);
834
+ }
835
+ const refresh = function () {
836
+ const things = kb.each(subject, predicate);
837
+ things.sort();
838
+ utils.syncTableToArray(attachmentTable, things, createNewRow);
839
+ };
840
+ function droppedURIHandler(uris) {
841
+ const ins = [];
842
+ uris.forEach(function (u) {
843
+ const target = (0, rdflib_1.sym)(u); // Attachment needs text label to disinguish I think not icon.
844
+ debug.log('Dropped on attachemnt ' + u); // icon was: iconBase + 'noun_25830.svg'
845
+ ins.push((0, rdflib_1.st)(subject, predicate, target, doc));
846
+ });
847
+ if (!kb.updater) {
848
+ throw new Error('kb has no updater');
849
+ }
850
+ kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
851
+ if (ok) {
852
+ refresh();
853
+ }
854
+ else {
855
+ complain(undefined, 'Error adding one: ' + errorBody);
856
+ }
857
+ });
858
+ }
859
+ function droppedFileHandler(files) {
860
+ (0, dragAndDrop_1.uploadFiles)(kb.fetcher, files, options.uploadFolder?.uri, // Files
861
+ options.uploadFolder?.uri, // Pictures
862
+ function (theFile, destURI) {
863
+ const ins = [(0, rdflib_1.st)(subject, predicate, kb.sym(destURI), doc)];
864
+ if (!kb.updater) {
865
+ throw new Error('kb has no updater');
866
+ }
867
+ kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
868
+ if (ok) {
869
+ refresh();
870
+ }
871
+ else {
872
+ complain(undefined, 'Error adding link to uploaded file: ' + errorBody);
873
+ }
874
+ });
875
+ });
876
+ }
877
+ const doc = options.doc || subject.doc();
878
+ if (options.modify === undefined)
879
+ options.modify = true;
880
+ const modify = options.modify;
881
+ const promptIcon = options.promptIcon || iconBase + 'noun_748003.svg'; // target
882
+ // const promptIcon = options.promptIcon || (iconBase + 'noun_25830.svg') // paperclip
883
+ const predicate = options.predicate || ns_1.default.wf('attachment');
884
+ const noun = options.noun || 'attachment';
885
+ const kb = solid_logic_1.store;
886
+ const attachmentOuter = div.appendChild(dom.createElement('table'));
887
+ attachmentOuter.setAttribute('style', 'margin-top: 1em; margin-bottom: 1em;');
888
+ const attachmentOne = attachmentOuter.appendChild(dom.createElement('tr'));
889
+ const attachmentLeft = attachmentOne.appendChild(dom.createElement('td'));
890
+ const attachmentRight = attachmentOne.appendChild(dom.createElement('td'));
891
+ const attachmentTable = attachmentRight.appendChild(dom.createElement('table'));
892
+ attachmentTable.appendChild(dom.createElement('tr')) // attachmentTableTop
893
+ ;
894
+ attachmentOuter.refresh = refresh; // Participate in downstream changes
895
+ // ;(attachmentTable as any).refresh = refresh <- outer should be best?
896
+ refresh();
897
+ if (modify) {
898
+ // const buttonStyle = 'width; 2em; height: 2em; margin: 0.5em; padding: 0.1em;'
899
+ const paperclip = button(dom, promptIcon, 'Drop attachments here');
900
+ // paperclip.style = buttonStyle // @@ needed? default has white background
901
+ attachmentLeft.appendChild(paperclip);
902
+ const fhandler = options.uploadFolder ? droppedFileHandler : null;
903
+ (0, dragAndDrop_1.makeDropTarget)(paperclip, droppedURIHandler, fhandler); // beware missing the wire of the paparclip!
904
+ (0, dragAndDrop_1.makeDropTarget)(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
905
+ if (options.uploadFolder) { // Addd an explicit file upload button as well
906
+ const buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
907
+ attachmentLeft.appendChild(buttonDiv);
908
+ // buttonDiv.children[1].style = buttonStyle
909
+ }
910
+ }
911
+ return attachmentOuter;
912
+ }
913
+ // /////////////////////////////////////////////////////////////////////////////
914
+ /**
915
+ * Event Handler for links within solid apps.
916
+ *
917
+ * Note that native links have constraints in Firefox, they
918
+ * don't work with local files for instance (2011)
919
+ */
920
+ function openHrefInOutlineMode(e) {
921
+ e.preventDefault();
922
+ e.stopPropagation();
923
+ const target = utils.getTarget(e);
924
+ const uri = target.getAttribute('href');
925
+ if (!uri)
926
+ return debug.log('openHrefInOutlineMode: No href found!\n');
927
+ const dom = window.document;
928
+ if (dom.outlineManager) {
929
+ // @@ TODO Remove the use of document as a global object
930
+ // TODO fix dependency cycle to solid-panes by calling outlineManager
931
+ ;
932
+ dom.outlineManager.GotoSubject(solid_logic_1.store.sym(uri), true, undefined, true, undefined);
933
+ }
934
+ else if (window && window.panes && window.panes.getOutliner) {
935
+ // @@ TODO Remove the use of window as a global object
936
+ ;
937
+ window.panes
938
+ .getOutliner()
939
+ .GotoSubject(solid_logic_1.store.sym(uri), true, undefined, true, undefined);
940
+ }
941
+ else {
942
+ debug.log('ERROR: Can\'t access outline manager in this config');
943
+ }
944
+ // dom.outlineManager.GotoSubject(store.sym(uri), true, undefined, true, undefined)
945
+ }
946
+ /**
947
+ * Make a URI in the Tabulator.org annotation store out of the URI of the thing to be annotated.
948
+ *
949
+ * @@ Todo: make it a personal preference.
950
+ */
951
+ function defaultAnnotationStore(subject) {
952
+ if (subject.uri === undefined)
953
+ return undefined;
954
+ let s = subject.uri;
955
+ if (s.slice(0, 7) !== 'http://')
956
+ return undefined;
957
+ s = s.slice(7); // Remove
958
+ const hash = s.indexOf('#');
959
+ if (hash >= 0)
960
+ s = s.slice(0, hash);
961
+ // Strip trailing
962
+ else {
963
+ const slash = s.lastIndexOf('/');
964
+ if (slash < 0)
965
+ return undefined;
966
+ s = s.slice(0, slash);
967
+ }
968
+ return solid_logic_1.store.sym('http://tabulator.org/wiki/annnotation/' + s);
969
+ }
970
+ /**
971
+ * Retrieve all RDF class URIs from solid-ui's RDF store
972
+ * @returns an object `ret` such that `Object.keys(ret)` is
973
+ * the list of all class URIs.
974
+ */
975
+ function allClassURIs() {
976
+ const set = {};
977
+ solid_logic_1.store
978
+ .statementsMatching(undefined, ns_1.default.rdf('type'), undefined)
979
+ .forEach(function (st) {
980
+ if (st.object.value)
981
+ set[st.object.value] = true;
982
+ });
983
+ solid_logic_1.store
984
+ .statementsMatching(undefined, ns_1.default.rdfs('subClassOf'), undefined)
985
+ .forEach(function (st) {
986
+ if (st.object.value)
987
+ set[st.object.value] = true;
988
+ if (st.subject.value)
989
+ set[st.subject.value] = true;
990
+ });
991
+ solid_logic_1.store
992
+ .each(undefined, ns_1.default.rdf('type'), ns_1.default.rdfs('Class'))
993
+ .forEach(function (c) {
994
+ if (c.value)
995
+ set[c.value] = true;
996
+ });
997
+ return set;
998
+ }
999
+ /**
1000
+ * Figuring which properties we know about
1001
+ *
1002
+ * When the user inputs an RDF property, like for a form field
1003
+ * or when specifying the relationship between two arbitrary things,
1004
+ * then er can prompt them with properties the session knows about
1005
+ *
1006
+ * TODO: Look again by catching this somewhere. (On the kb?)
1007
+ * TODO: move to diff module? Not really a button.
1008
+ * @param {Store} kb The quadstore to be searched.
1009
+ */
1010
+ function propertyTriage(kb) {
1011
+ const possibleProperties = {};
1012
+ // if (possibleProperties === undefined) possibleProperties = {}
1013
+ // const kb = store
1014
+ const dp = {};
1015
+ const op = {};
1016
+ let no = 0;
1017
+ let nd = 0;
1018
+ let nu = 0;
1019
+ const pi = kb.predicateIndex; // One entry for each pred
1020
+ for (const p in pi) {
1021
+ const object = pi[p][0].object;
1022
+ if (object.termType === 'Literal') {
1023
+ dp[p] = true;
1024
+ nd++;
1025
+ }
1026
+ else {
1027
+ op[p] = true;
1028
+ no++;
1029
+ }
1030
+ } // If nothing discovered, then could be either:
1031
+ const ps = kb.each(undefined, ns_1.default.rdf('type'), ns_1.default.rdf('Property'));
1032
+ for (let i = 0; i < ps.length; i++) {
1033
+ const p = ps[i].toNT();
1034
+ if (!op[p] && !dp[p]) {
1035
+ dp[p] = true;
1036
+ op[p] = true;
1037
+ nu++;
1038
+ }
1039
+ }
1040
+ possibleProperties.op = op;
1041
+ possibleProperties.dp = dp;
1042
+ (0, log_1.info)(`propertyTriage: ${no} non-lit, ${nd} literal. ${nu} unknown.`);
1043
+ return possibleProperties;
1044
+ }
1045
+ /**
1046
+ * General purpose widgets
1047
+ */
1048
+ /**
1049
+ * A button for jumping
1050
+ */
1051
+ function linkButton(dom, object) {
1052
+ const b = dom.createElement('button');
1053
+ b.setAttribute('type', 'button');
1054
+ b.textContent = 'Goto ' + utils.label(object);
1055
+ b.addEventListener('click', function (_event) {
1056
+ // b.parentNode.removeChild(b)
1057
+ // TODO fix dependency cycle to solid-panes by calling outlineManager
1058
+ ;
1059
+ dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
1060
+ }, true);
1061
+ return b;
1062
+ }
1063
+ /**
1064
+ * A button to remove some other element from the page
1065
+ */
1066
+ function removeButton(dom, element) {
1067
+ const b = dom.createElement('button');
1068
+ b.setAttribute('type', 'button');
1069
+ b.textContent = '✕'; // MULTIPLICATION X
1070
+ b.addEventListener('click', function (_event) {
1071
+ ;
1072
+ element.parentNode.removeChild(element);
1073
+ }, true);
1074
+ return b;
1075
+ }
1076
+ // Description text area
1077
+ //
1078
+ // Make a box to demand a description or display existing one
1079
+ //
1080
+ // @param dom - the document DOM for the user interface
1081
+ // @param kb - the graph which is the knowledge base we are working with
1082
+ // @param subject - a term, the subject of the statement(s) being edited.
1083
+ // @param predicate - a term, the predicate of the statement(s) being edited
1084
+ // @param store - The web document being edited
1085
+ // @param callbackFunction - takes (boolean ok, string errorBody)
1086
+ // /////////////////////////////////////// Random I/O widgets /////////////
1087
+ // //// Column Header Buttons
1088
+ //
1089
+ // These are for selecting different modes, sources,styles, etc.
1090
+ //
1091
+ /*
1092
+ buttons.headerButtons = function (dom, kb, name, words) {
1093
+ const box = dom.createElement('table')
1094
+ var i, word, s = '<tr>'
1095
+ box.setAttribute('style', 'width: 90%; height: 1.5em')
1096
+ for (i=0; i<words.length; i++) {
1097
+ s += '<td><input type="radio" name="' + name + '" id="' + words[i] + '" value='
1098
+ }
1099
+ box.innerHTML = s + '</tr>'
1100
+
1101
+ }
1102
+ */
1103
+ // ////////////////////////////////////////////////////////////
1104
+ //
1105
+ // selectorPanel
1106
+ //
1107
+ // A vertical panel for selecting connections to left or right.
1108
+ //
1109
+ // @param inverse means this is the object rather than the subject
1110
+ //
1111
+ function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
1112
+ return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
1113
+ }
1114
+ function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
1115
+ const style0 = 'border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;';
1116
+ let selected = null;
1117
+ list.innerHTML = '';
1118
+ const refreshItem = function (box, x) {
1119
+ // Scope to hold item and x
1120
+ let item;
1121
+ // eslint-disable-next-line prefer-const
1122
+ let image;
1123
+ const setStyle = function () {
1124
+ const already = inverse
1125
+ ? kb.each(undefined, predicate, x)
1126
+ : kb.each(x, predicate);
1127
+ iconDiv.setAttribute('class', already.length === 0 ? 'hideTillHover' : ''); // See tabbedtab.css
1128
+ image.setAttribute('src', options.connectIcon || iconBase + 'noun_25830.svg');
1129
+ image.setAttribute('title', already.length ? already.length : 'attach');
1130
+ };
1131
+ const f = exports.index.twoLine.widgetForClass(type);
1132
+ // eslint-disable-next-line prefer-const
1133
+ item = f(dom, x);
1134
+ item.setAttribute('style', style0);
1135
+ const nav = dom.createElement('div');
1136
+ nav.setAttribute('class', 'hideTillHover'); // See tabbedtab.css
1137
+ nav.setAttribute('style', 'float:right; width:10%');
1138
+ const a = dom.createElement('a');
1139
+ a.setAttribute('href', x.uri);
1140
+ a.setAttribute('style', 'float:right');
1141
+ nav.appendChild(a).textContent = '>';
1142
+ box.appendChild(nav);
1143
+ const iconDiv = dom.createElement('div');
1144
+ iconDiv.setAttribute('style', (inverse ? 'float:left;' : 'float:right;') + ' width:30px;');
1145
+ image = dom.createElement('img');
1146
+ setStyle();
1147
+ iconDiv.appendChild(image);
1148
+ box.appendChild(iconDiv);
1149
+ item.addEventListener('click', function (event) {
1150
+ if (selected === item) {
1151
+ // deselect
1152
+ item.setAttribute('style', style0);
1153
+ selected = null;
1154
+ }
1155
+ else {
1156
+ if (selected)
1157
+ selected.setAttribute('style', style0);
1158
+ item.setAttribute('style', style0 + 'background-color: #ccc; color:black;');
1159
+ selected = item;
1160
+ }
1161
+ callbackFunction(x, event, selected === item);
1162
+ setStyle();
1163
+ }, false);
1164
+ image.addEventListener('click', function (event) {
1165
+ linkCallback(x, event, inverse, setStyle);
1166
+ }, false);
1167
+ box.appendChild(item);
1168
+ return box;
1169
+ };
1170
+ for (let i = 0; i < possible.length; i++) {
1171
+ const box = dom.createElement('div');
1172
+ list.appendChild(box);
1173
+ refreshItem(box, possible[i]);
1174
+ }
1175
+ return list;
1176
+ }
1177
+ // ###########################################################################
1178
+ //
1179
+ // Small compact views of things
1180
+ //
1181
+ exports.index = {};
1182
+ // ///////////////////////////////////////////////////////////////////////////
1183
+ // We need these for anything which is a subject of an attachment.
1184
+ //
1185
+ // These should be moved to type-dependeent UI code. Related panes maybe
1186
+ function twoLineDefault(dom, x) {
1187
+ // Default
1188
+ const box = dom.createElement('div');
1189
+ box.textContent = utils.label(x);
1190
+ return box;
1191
+ }
1192
+ /**
1193
+ * Find a function that can create a widget for a given class
1194
+ * @param c The RDF class for which we want a widget generator function
1195
+ */
1196
+ function twoLineWidgetForClass(c) {
1197
+ let widget = exports.index.twoLine[c.uri];
1198
+ const kb = solid_logic_1.store;
1199
+ if (widget)
1200
+ return widget;
1201
+ const sup = kb.findSuperClassesNT(c);
1202
+ for (const cl in sup) {
1203
+ widget = exports.index.twoLine[kb.fromNT(cl).uri];
1204
+ if (widget)
1205
+ return widget;
1206
+ }
1207
+ return exports.index.twoLine[''];
1208
+ }
1209
+ /**
1210
+ * Display a transaction
1211
+ * @param x Should have attributes through triples in store:
1212
+ * * ns.qu('payee') -> a named node
1213
+ * * ns.qu('date) -> a literal
1214
+ * * ns.qu('amount') -> a literal
1215
+ */
1216
+ function twoLineTransaction(dom, x) {
1217
+ let failed = '';
1218
+ const enc = function (p) {
1219
+ const y = solid_logic_1.store.any(x, ns_1.default.qu(p));
1220
+ if (!y)
1221
+ failed += '@@ No value for ' + p + '! ';
1222
+ return y ? utils.escapeForXML(y.value) : '?'; // @@@@
1223
+ };
1224
+ const box = dom.createElement('table');
1225
+ box.innerHTML = `
1226
+ <tr>
1227
+ <td colspan="2"> ${enc('payee')}</td>
1228
+ < /tr>
1229
+ < tr >
1230
+ <td>${enc('date').slice(0, 10)}</td>
1231
+ <td style = "text-align: right;">${enc('amount')}</td>
1232
+ </tr>`;
1233
+ if (failed) {
1234
+ box.innerHTML = `
1235
+ <tr>
1236
+ <td><a href="${utils.escapeForXML(x.uri)}">${utils.escapeForXML(failed)}</a></td>
1237
+ </tr>`;
1238
+ }
1239
+ return box;
1240
+ }
1241
+ /**
1242
+ * Display a trip
1243
+ * @param x Should have attributes through triples in store:
1244
+ * * ns.dc('title') -> a literal
1245
+ * * ns.cal('dtstart') -> a literal
1246
+ * * ns.cal('dtend') -> a literal
1247
+ */
1248
+ function twoLineTrip(dom, x) {
1249
+ const enc = function (p) {
1250
+ const y = solid_logic_1.store.any(x, p);
1251
+ return y ? utils.escapeForXML(y.value) : '?';
1252
+ };
1253
+ const box = dom.createElement('table');
1254
+ box.innerHTML = `
1255
+ <tr>
1256
+ <td colspan="2">${enc(ns_1.default.dc('title'))}</td>
1257
+ </tr>
1258
+ <tr style="color: #777">
1259
+ <td>${enc(ns_1.default.cal('dtstart'))}</td>
1260
+ <td>${enc(ns_1.default.cal('dtend'))}</td>
1261
+ </tr>`;
1262
+ return box;
1263
+ }
1264
+ /**
1265
+ * Stick a stylesheet link the document if not already there
1266
+ */
1267
+ function addStyleSheet(dom, href) {
1268
+ const links = dom.querySelectorAll('link');
1269
+ for (let i = 0; i < links.length; i++) {
1270
+ if ((links[i].getAttribute('rel') || '') === 'stylesheet' &&
1271
+ (links[i].getAttribute('href') || '') === href) {
1272
+ return;
1273
+ }
1274
+ }
1275
+ const link = dom.createElement('link');
1276
+ link.setAttribute('rel', 'stylesheet');
1277
+ link.setAttribute('type', 'text/css');
1278
+ link.setAttribute('href', href);
1279
+ dom.getElementsByTagName('head')[0].appendChild(link);
1280
+ }
1281
+ // Figure (or guess) whether this is an image, etc
1282
+ //
1283
+ function isAudio(file) {
1284
+ return isImage(file, 'audio');
1285
+ }
1286
+ function isVideo(file) {
1287
+ return isImage(file, 'video');
1288
+ }
1289
+ /**
1290
+ *
1291
+ */
1292
+ function isImage(file, kind) {
1293
+ const dcCLasses = {
1294
+ audio: 'http://purl.org/dc/dcmitype/Sound',
1295
+ image: 'http://purl.org/dc/dcmitype/Image',
1296
+ video: 'http://purl.org/dc/dcmitype/MovingImage'
1297
+ };
1298
+ const what = kind || 'image';
1299
+ // See https://github.com/linkeddata/rdflib.js/blob/e367d5088c/src/formula.ts#L554
1300
+ //
1301
+ const typeURIs = solid_logic_1.store.findTypeURIs(file);
1302
+ // See https://github.com/linkeddata/rdflib.js/blob/d5000f/src/utils-js.js#L14
1303
+ // e.g.'http://www.w3.org/ns/iana/media-types/audio'
1304
+ const prefix = rdflib_1.Util.mediaTypeClass(what + '/*').uri.split('*')[0];
1305
+ for (const t in typeURIs) {
1306
+ if (t.startsWith(prefix))
1307
+ return true;
1308
+ }
1309
+ if (dcCLasses[what] in typeURIs)
1310
+ return true;
1311
+ return false;
1312
+ }
1313
+ /**
1314
+ * File upload button
1315
+ * @param dom The DOM aka document
1316
+ * @param droppedFileHandler Same handler function as drop, takes array of file objects
1317
+ * @returns {Element} - a div with a button and a inout in it
1318
+ * The input is hidden, as it is uglky - the user clicks on the nice icons and fires the input.
1319
+ */
1320
+ // See https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
1321
+ function fileUploadButtonDiv(dom, droppedFileHandler) {
1322
+ const div = dom.createElement('div');
1323
+ const input = div.appendChild(dom.createElement('input'));
1324
+ input.setAttribute('type', 'file');
1325
+ input.setAttribute('multiple', 'true');
1326
+ input.addEventListener('change', (event) => {
1327
+ debug.log('File drop event: ', event);
1328
+ if (event.files) {
1329
+ droppedFileHandler(event.files);
1330
+ }
1331
+ else if (event.target && event.target.files) {
1332
+ droppedFileHandler(event.target.files);
1333
+ }
1334
+ else {
1335
+ alert('Sorry no files .. internal error?');
1336
+ }
1337
+ }, false);
1338
+ input.style = 'display:none';
1339
+ const buttonElt = div.appendChild(button(dom, iconBase + 'noun_Upload_76574_000000.svg', 'Upload files', _event => {
1340
+ input.click();
1341
+ }));
1342
+ (0, dragAndDrop_1.makeDropTarget)(buttonElt, null, droppedFileHandler); // Can also just drop on button
1343
+ return div;
1344
+ }
1345
+ exports.index = {
1346
+ line: { // Approx 80em
1347
+ },
1348
+ twoLine: {
1349
+ '': twoLineDefault,
1350
+ 'http://www.w3.org/2000/10/swap/pim/qif#Transaction': twoLineTransaction,
1351
+ 'http://www.w3.org/ns/pim/trip#Trip': twoLineTrip,
1352
+ widgetForClass: twoLineWidgetForClass
1353
+ }
1354
+ };
1355
+ //# sourceMappingURL=buttons.js.map