solid-ui 2.4.14-bbf45639 → 2.4.14-bbf45639-e81d3e08

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