solid-ui 2.4.14-842f7f26 → 2.4.14-alpha

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 (260) 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 +334 -441
  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 +347 -492
  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 +168 -198
  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 +444 -459
  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 +318 -515
  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 +27 -35
  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 +84 -90
  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 +5 -4
  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 +14 -21
  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 +1391 -1935
  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 +26 -37
  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 +1 -4
  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 +209 -214
  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 +4 -10
  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 +1 -4
  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 +30 -28
  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 +20 -0
  86. package/lib/footer/index.d.ts.map +1 -0
  87. package/lib/footer/index.js +130 -0
  88. package/lib/footer/index.js.map +1 -0
  89. package/lib/footer/styleMap.d.ts +8 -0
  90. package/lib/footer/styleMap.d.ts.map +1 -0
  91. package/lib/footer/styleMap.js +11 -0
  92. package/lib/footer/styleMap.js.map +1 -0
  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 +2 -6
  96. package/lib/header/empty-profile.js.map +1 -1
  97. package/lib/header/index.d.ts +11 -8
  98. package/lib/header/index.d.ts.map +1 -1
  99. package/lib/header/index.js +291 -355
  100. package/lib/header/index.js.map +1 -1
  101. package/lib/header/styleMap.d.ts +0 -2
  102. package/lib/header/styleMap.d.ts.map +1 -1
  103. package/lib/header/styleMap.js +116 -136
  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 +23 -30
  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 +2 -1
  114. package/lib/index.d.ts.map +1 -1
  115. package/lib/index.js +103 -198
  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 +21 -30
  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 +83 -131
  124. package/lib/log.js.map +1 -1
  125. package/lib/logic.d.ts +0 -0
  126. package/lib/logic.d.ts.map +0 -0
  127. package/lib/logic.js +82 -69
  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 +4 -10
  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 +210 -237
  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 +1 -4
  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 +5 -11
  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 +187 -181
  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 +794 -954
  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 +170 -199
  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 +235 -342
  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/{header/headerHelpers.d.ts → utils/headerFooterHelpers.d.ts} +11 -3
  178. package/lib/utils/headerFooterHelpers.d.ts.map +1 -0
  179. package/lib/utils/headerFooterHelpers.js +164 -0
  180. package/lib/utils/headerFooterHelpers.js.map +1 -0
  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 +121 -113
  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 +23 -28
  190. package/lib/versionInfo.js.map +1 -1
  191. package/lib/webpack-bundle.js +454 -160
  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 +19 -30
  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 +935 -1113
  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 +18 -24
  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 +234 -325
  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 +246 -276
  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 +317 -497
  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 +159 -212
  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 +485 -718
  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 +208 -239
  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 +31 -50
  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 +102 -81
  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 +52 -50
  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 +18 -30
  256. package/lib/widgets/widgetHelpers.js.map +1 -1
  257. package/package.json +5 -4
  258. package/lib/header/headerHelpers.d.ts.map +0 -1
  259. package/lib/header/headerHelpers.js +0 -96
  260. package/lib/header/headerHelpers.js.map +0 -1
@@ -1,248 +1,203 @@
1
1
  "use strict";
2
-
3
- var _typeof = require("@babel/runtime/helpers/typeof");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
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;
7
13
  });
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
-
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;
79
23
  /* Buttons
80
24
  */
81
-
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");
82
38
  /**
83
39
  * UI Widgets such as buttons
84
40
  * @packageDocumentation
85
41
  */
86
-
87
42
  /* global alert */
88
- var iconBase = _iconBase.icons.iconBase;
43
+ var iconBase = iconBase_1.icons.iconBase;
89
44
  var cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
90
-
91
45
  var checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
92
-
93
46
  function getStatusArea(context) {
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;
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;
109
53
  }
110
-
111
- return box;
112
- }
113
-
114
- return null;
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;
62
+ }
63
+ return null;
115
64
  }
116
65
  /**
117
66
  * Display an error message block
118
67
  */
119
-
120
-
121
68
  function complain(context, 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);
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);
127
77
  }
78
+ exports.complain = complain;
128
79
  /**
129
80
  * Remove all the children of an HTML element
130
81
  */
131
-
132
-
133
82
  function clearElement(ele) {
134
- while (ele.firstChild) {
135
- ele.removeChild(ele.firstChild);
136
- }
137
-
138
- return ele;
83
+ while (ele.firstChild) {
84
+ ele.removeChild(ele.firstChild);
85
+ }
86
+ return ele;
139
87
  }
88
+ exports.clearElement = clearElement;
140
89
  /**
141
90
  * To figure out the log URI from the full URI used to invoke the reasoner
142
91
  */
143
-
144
-
145
92
  function extractLogURI(fullURI) {
146
- var logPos = fullURI.search(/logFile=/);
147
- var rulPos = fullURI.search(/&rulesFile=/);
148
- return fullURI.substring(logPos + 8, rulPos);
93
+ var logPos = fullURI.search(/logFile=/);
94
+ var rulPos = fullURI.search(/&rulesFile=/);
95
+ return fullURI.substring(logPos + 8, rulPos);
149
96
  }
97
+ exports.extractLogURI = extractLogURI;
150
98
  /**
151
99
  * By default, converts e.g. '2020-02-19T19:35:28.557Z' to '19:35'
152
100
  * if today is 19 Feb 2020, and to 'Feb 19' if not.
153
101
  * @@@ TODO This needs to be changed to local time
154
102
  * @param noTime Return a string like 'Feb 19' even if it's today.
155
103
  */
156
-
157
-
158
104
  function shortDate(str, noTime) {
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);
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);
168
134
  }
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);
135
+ catch (e) {
136
+ return 'shortdate:' + e;
172
137
  }
173
-
174
- return str.slice(0, 10);
175
- } catch (e) {
176
- return 'shortdate:' + e;
177
- }
178
138
  }
139
+ exports.shortDate = shortDate;
179
140
  /**
180
141
  * Format a date and time
181
142
  * @param date for instance `new Date()`
182
143
  * @param format for instance '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}'
183
144
  * @returns for instance '2000-01-15T23:14:23.002'
184
145
  */
185
-
186
-
187
146
  function formatDateTime(date, format) {
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('');
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('');
199
158
  }
159
+ exports.formatDateTime = formatDateTime;
200
160
  /**
201
161
  * Get a string representation of the current time
202
162
  * @returns for instance '2000-01-15T23:14:23.002'
203
163
  */
204
-
205
-
206
164
  function timestamp() {
207
- return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
165
+ return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
208
166
  }
167
+ exports.timestamp = timestamp;
209
168
  /**
210
169
  * Get a short string representation of the current time
211
170
  * @returns for instance '23:14:23.002'
212
171
  */
213
-
214
-
215
172
  function shortTime() {
216
- return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
217
- } // ///////////////////// Handy UX widgets
218
-
173
+ return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
174
+ }
175
+ exports.shortTime = shortTime;
176
+ // ///////////////////// Handy UX widgets
219
177
  /**
220
178
  * Sets the best name we have and looks up a better one
221
179
  */
222
-
223
-
224
180
  function setName(element, x) {
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
- }
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
+ }
245
199
  }
200
+ exports.setName = setName;
246
201
  /**
247
202
  * Set of suitable images
248
203
  * See also [[findImage]]
@@ -260,104 +215,97 @@ function setName(element, x) {
260
215
  * * ns.foaf('depiction')
261
216
 
262
217
  */
263
-
264
-
265
218
  function imagesOf(x, kb) {
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')));
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')));
267
226
  }
227
+ exports.imagesOf = imagesOf;
268
228
  /**
269
229
  * Best logo or avatar or photo etc to represent someone or some group etc
270
230
  */
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'
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'
304
258
  };
305
259
  /**
306
260
  * Returns the origin of the URI of a NamedNode
307
261
  */
308
-
309
- exports.iconForClass = iconForClass;
310
-
311
262
  function tempSite(x) {
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
- }
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
+ }
324
276
  }
325
277
  /**
326
278
  * Find an image for this thing as a class
327
279
  */
328
-
329
-
330
280
  function findImageFromURI(x) {
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
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;
354
305
  }
355
-
356
- return null;
357
- }
358
-
359
- return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
306
+ return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
360
307
  }
308
+ exports.findImageFromURI = findImageFromURI;
361
309
  /**
362
310
  * Find something we have as explicit image data for the thing
363
311
  * See also [[imagesOf]]
@@ -375,260 +323,224 @@ function findImageFromURI(x) {
375
323
  * * ns.vcard('photo')
376
324
  * * ns.foaf('depiction')
377
325
  */
378
-
379
-
380
326
  function findImage(thing) {
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;
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;
390
339
  }
340
+ exports.findImage = findImage;
391
341
  /**
392
342
  * Do the best you can with the data available
393
343
  *
394
344
  * @return {Boolean} Are we happy with this icon?
395
345
  * Sets src AND STYLE of the image.
396
346
  */
397
-
398
-
399
347
  function trySetImage(element, thing, iconForClassMap) {
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
348
+ var kb = logic_1.store;
349
+ var explitImage = findImage(thing);
350
+ if (explitImage) {
351
+ element.setAttribute('src', explitImage);
352
+ return true;
433
353
  }
434
- }
435
-
436
- element.setAttribute('src', iconBase + 'noun_10636_grey.svg'); // Grey Circle - some thing
437
-
438
- return false; // we can do better
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
+ }
375
+ }
376
+ element.setAttribute('src', iconBase + 'noun_10636_grey.svg'); // Grey Circle - some thing
377
+ return false; // we can do better
439
378
  }
440
379
  /**
441
380
  * ToDo: Also add icons for *properties* like home, work, email, range, domain, comment,
442
381
  */
443
-
444
-
445
382
  function setImage(element, thing) {
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');
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);
462
390
  }
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 ???
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
+ });
401
+ }
402
+ }
403
+ exports.setImage = setImage;
404
+ // If a web page, then a favicon, with a fallback to ???
471
405
  // See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
472
-
473
-
474
406
  function faviconOrDefault(dom, x) {
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
- }
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
+ }
499
428
  }
429
+ exports.faviconOrDefault = faviconOrDefault;
500
430
  /* Two-option dialog pop-up
501
431
  */
502
-
503
-
504
432
  function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction) {
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;
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;
554
476
  }
555
477
  /**
556
478
  * Delete button with a check you really mean it
557
479
  * @@ Supress check if command key held down?
558
480
  */
559
-
560
-
561
481
  function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
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
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
587
502
  }
503
+ exports.deleteButtonWithCheck = deleteButtonWithCheck;
588
504
  /**
589
505
  * Get the button style, based on options.
590
506
  * See https://design.inrupt.com/atomic-core/?cat=Atoms#Buttons
591
507
  */
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'
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;
630
524
  }
631
- };
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
+ };
632
544
  }
633
545
  /* Make a button
634
546
  *
@@ -639,42 +551,32 @@ function getButtonStyle() {
639
551
  *
640
552
  * @returns <dDomElement> - the button
641
553
  */
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;
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;
677
578
  }
579
+ exports.button = button;
678
580
  /* Make a cancel button
679
581
  *
680
582
  * @param dom - the DOM document object
@@ -682,11 +584,10 @@ function button(dom, iconURI, text, handler) {
682
584
  *
683
585
  * @returns <dDomElement> - the button
684
586
  */
685
-
686
-
687
587
  function cancelButton(dom, handler) {
688
- return button(dom, cancelIconURI, 'Cancel', handler);
588
+ return button(dom, cancelIconURI, 'Cancel', handler);
689
589
  }
590
+ exports.cancelButton = cancelButton;
690
591
  /* Make a continue button
691
592
  *
692
593
  * @param dom - the DOM document object
@@ -694,415 +595,374 @@ function cancelButton(dom, handler) {
694
595
  *
695
596
  * @returns <dDomElement> - the button
696
597
  */
697
-
698
-
699
598
  function continueButton(dom, handler) {
700
- return button(dom, checkIconURI, 'Continue', handler);
599
+ return button(dom, checkIconURI, 'Continue', handler);
701
600
  }
601
+ exports.continueButton = continueButton;
702
602
  /* Grab a name for a new thing
703
603
  *
704
604
  * Form to get the name of a new thing before we create it
705
605
  * @params theClass Misspelt to avoid clashing with the JavaScript keyword
706
606
  * @returns: a promise of (a name or null if cancelled)
707
607
  */
708
-
709
-
710
608
  function askName(dom, kb, container, predicate, theClass, noun) {
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
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
753
645
  }
646
+ exports.askName = askName;
754
647
  /**
755
648
  * A TR to represent a draggable person, etc in a list
756
649
  *
757
650
  * pred is unused param at the moment
758
651
  */
759
-
760
-
761
- var personTR = renderAsRow; // The legacy name is used in a lot of places
762
-
763
- exports.personTR = personTR;
764
-
652
+ exports.personTR = renderAsRow; // The legacy name is used in a lot of places
765
653
  function renderAsRow(dom, pred, obj, options) {
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'));
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;
795
668
  }
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);
669
+ else {
670
+ setName(td2, obj); // This is async
802
671
  }
803
- }
804
-
805
- ;
806
- tr.subject = obj;
807
- return tr;
672
+ if (options.deleteFunction) {
673
+ deleteButtonWithCheck(dom, td3, options.noun || 'one', options.deleteFunction);
674
+ }
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
+ }
687
+ }
688
+ ;
689
+ tr.subject = obj;
690
+ return tr;
808
691
  }
692
+ exports.renderAsRow = renderAsRow;
809
693
  /* A helper function for renderAsDiv
810
694
  * creates the NameDiv for the person
811
695
  * Note: could not move it to the helper file because they call exported functions
812
696
  * from buttons
813
697
  * @internal exporting this only for unit tests
814
698
  */
815
-
816
-
817
699
  function createNameDiv(dom, div, title, obj) {
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
- }
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
+ }
825
707
  }
708
+ exports.createNameDiv = createNameDiv;
826
709
  /* A helper function for renderAsDiv
827
710
  * creates the linkDiv for the person
828
711
  * Note: could not move it to the helper file because they call exported functions
829
712
  * from buttons
830
713
  * @internal exporting this only for unit tests
831
714
  */
832
-
833
-
834
715
  function createLinkDiv(dom, div, obj, options) {
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);
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);
846
727
  }
847
-
848
- (0, _dragAndDrop.makeDraggable)(div, obj);
849
- }
850
728
  }
729
+ exports.createLinkDiv = createLinkDiv;
851
730
  /**
852
731
  * A Div to represent a draggable person, etc in a list
853
732
  * configurable to add an onClick listener
854
733
  */
855
-
856
-
857
734
  function renderAsDiv(dom, obj, options) {
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;
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;
877
751
  }
752
+ exports.renderAsDiv = renderAsDiv;
878
753
  /**
879
754
  * Refresh a DOM tree recursively
880
755
  */
881
-
882
-
883
756
  function refreshTree(root) {
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
- }
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
+ }
892
764
  }
893
- /**
894
- * Options argument for [[attachmentList]] function
895
- */
896
-
897
-
765
+ exports.refreshTree = refreshTree;
898
766
  /**
899
767
  * Component that displays a list of resources, for instance
900
768
  * the attachments of a message, or the various documents related
901
769
  * to a meeting.
902
770
  * Accepts dropping URLs onto it to add attachments to it.
903
771
  */
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');
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);
911
797
  }
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
798
+ var refresh = function () {
799
+ var things = kb.each(subject, predicate);
800
+ things.sort();
801
+ utils.syncTableToArray(attachmentTable, things, createNewRow);
926
802
  };
927
-
928
- if (modify) {
929
- opt.deleteFunction = function () {
930
- deleteAttachment(theTarget);
931
- };
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
+ });
932
821
  }
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');
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
+ });
955
840
  }
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);
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
983
873
  }
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
1024
874
  }
1025
- }
1026
-
1027
- return attachmentOuter;
1028
- } // /////////////////////////////////////////////////////////////////////////////
1029
-
875
+ return attachmentOuter;
876
+ }
877
+ exports.attachmentList = attachmentList;
878
+ // /////////////////////////////////////////////////////////////////////////////
1030
879
  /**
1031
880
  * Event Handler for links within solid apps.
1032
881
  *
1033
882
  * Note that native links have constraints in Firefox, they
1034
883
  * don't work with local files for instance (2011)
1035
884
  */
1036
-
1037
-
1038
885
  function openHrefInOutlineMode(e) {
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
-
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)
1058
909
  }
910
+ exports.openHrefInOutlineMode = openHrefInOutlineMode;
1059
911
  /**
1060
912
  * Make a URI in the Tabulator.org annotation store out of the URI of the thing to be annotated.
1061
913
  *
1062
914
  * @@ Todo: make it a personal preference.
1063
915
  */
1064
-
1065
-
1066
916
  function defaultAnnotationStore(subject) {
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);
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);
1080
934
  }
935
+ exports.defaultAnnotationStore = defaultAnnotationStore;
1081
936
  /**
1082
937
  * Retrieve all RDF class URIs from solid-ui's RDF store
1083
938
  * @returns an object `ret` such that `Object.keys(ret)` is
1084
939
  * the list of all class URIs.
1085
940
  */
1086
-
1087
-
1088
941
  function allClassURIs() {
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;
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;
1105
964
  }
965
+ exports.allClassURIs = allClassURIs;
1106
966
  /**
1107
967
  * Figuring which properties we know about
1108
968
  *
@@ -1114,85 +974,75 @@ function allClassURIs() {
1114
974
  * TODO: move to diff module? Not really a button.
1115
975
  * @param {Store} kb The quadstore to be searched.
1116
976
  */
1117
-
1118
-
1119
977
  function propertyTriage(kb) {
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++;
1139
- }
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++;
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
+ }
1152
1006
  }
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;
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;
1159
1011
  }
1012
+ exports.propertyTriage = propertyTriage;
1160
1013
  /**
1161
1014
  * General purpose widgets
1162
1015
  */
1163
-
1164
1016
  /**
1165
1017
  * A button for jumping
1166
1018
  */
1167
-
1168
-
1169
1019
  function linkButton(dom, object) {
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;
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;
1179
1029
  }
1030
+ exports.linkButton = linkButton;
1180
1031
  /**
1181
1032
  * A button to remove some other element from the page
1182
1033
  */
1183
-
1184
-
1185
1034
  function removeButton(dom, element) {
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
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
1196
1046
  //
1197
1047
  // Make a box to demand a description or display existing one
1198
1048
  //
@@ -1207,7 +1057,6 @@ function removeButton(dom, element) {
1207
1057
  //
1208
1058
  // These are for selecting different modes, sources,styles, etc.
1209
1059
  //
1210
-
1211
1060
  /*
1212
1061
  buttons.headerButtons = function (dom, kb, name, words) {
1213
1062
  const box = dom.createElement('table')
@@ -1228,115 +1077,105 @@ buttons.headerButtons = function (dom, kb, name, words) {
1228
1077
  //
1229
1078
  // @param inverse means this is the object rather than the subject
1230
1079
  //
1231
-
1232
-
1233
1080
  function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
1234
- return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
1081
+ return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
1235
1082
  }
1236
-
1083
+ exports.selectorPanel = selectorPanel;
1237
1084
  function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
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');
1254
- };
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
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);
1278
1104
  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
- } // ###########################################################################
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;
1139
+ };
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
+ // ###########################################################################
1304
1149
  //
1305
1150
  // Small compact views of things
1306
1151
  //
1307
-
1308
-
1309
- var index = {}; // ///////////////////////////////////////////////////////////////////////////
1152
+ exports.index = {};
1153
+ // ///////////////////////////////////////////////////////////////////////////
1310
1154
  // We need these for anything which is a subject of an attachment.
1311
1155
  //
1312
1156
  // These should be moved to type-dependeent UI code. Related panes maybe
1313
-
1314
- exports.index = index;
1315
-
1316
1157
  function twoLineDefault(dom, x) {
1317
- // Default
1318
- var box = dom.createElement('div');
1319
- box.textContent = utils.label(x);
1320
- return box;
1158
+ // Default
1159
+ var box = dom.createElement('div');
1160
+ box.textContent = utils.label(x);
1161
+ return box;
1321
1162
  }
1322
1163
  /**
1323
1164
  * Find a function that can create a widget for a given class
1324
1165
  * @param c The RDF class for which we want a widget generator function
1325
1166
  */
1326
-
1327
-
1328
1167
  function twoLineWidgetForClass(c) {
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[''];
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[''];
1340
1179
  }
1341
1180
  /**
1342
1181
  * Display a transaction
@@ -1345,26 +1184,20 @@ function twoLineWidgetForClass(c) {
1345
1184
  * * ns.qu('date) -> a literal
1346
1185
  * * ns.qu('amount') -> a literal
1347
1186
  */
1348
-
1349
-
1350
1187
  function twoLineTransaction(dom, x) {
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;
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;
1368
1201
  }
1369
1202
  /**
1370
1203
  * Display a trip
@@ -1373,76 +1206,68 @@ function twoLineTransaction(dom, x) {
1373
1206
  * * ns.cal('dtstart') -> a literal
1374
1207
  * * ns.cal('dtend') -> a literal
1375
1208
  */
1376
-
1377
-
1378
1209
  function twoLineTrip(dom, x) {
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;
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;
1388
1217
  }
1389
1218
  /**
1390
1219
  * Stick a stylesheet link the document if not already there
1391
1220
  */
1392
-
1393
-
1394
1221
  function addStyleSheet(dom, href) {
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;
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
+ }
1400
1228
  }
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
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
1409
1237
  //
1410
-
1411
-
1412
1238
  function isAudio(file) {
1413
- return isImage(file, 'audio');
1239
+ return isImage(file, 'audio');
1414
1240
  }
1415
-
1241
+ exports.isAudio = isAudio;
1416
1242
  function isVideo(file) {
1417
- return isImage(file, 'video');
1243
+ return isImage(file, 'video');
1418
1244
  }
1245
+ exports.isVideo = isVideo;
1419
1246
  /**
1420
1247
  *
1421
1248
  */
1422
-
1423
-
1424
1249
  function isImage(file, kind) {
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;
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;
1445
1269
  }
1270
+ exports.isImage = isImage;
1446
1271
  /**
1447
1272
  * File upload button
1448
1273
  * @param dom The DOM aka document
@@ -1451,42 +1276,39 @@ function isImage(file, kind) {
1451
1276
  * The input is hidden, as it is uglky - the user clicks on the nice icons and fires the input.
1452
1277
  */
1453
1278
  // See https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
1454
-
1455
-
1456
1279
  function fileUploadButtonDiv(dom, droppedFileHandler) {
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?');
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;
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;
1479
1302
  }
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
- }
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
1312
+ }
1491
1313
  };
1492
1314
  //# sourceMappingURL=buttons.js.map