solid-ui 2.4.22-34747cd0 → 2.4.22-39d66c72

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.
package/README.md CHANGED
@@ -7,13 +7,26 @@ User Interface widgets and utilities for Solid (solid-ui)
7
7
  These are HTML5 widgets which connect to a solid store. Building blocks for solid-based apps.
8
8
  Vanilla JS. Includes large widgets like chat, table, matrix, form fields, and small widgets.
9
9
 
10
+ See [Solid-Ui Storybook](http://solidos.github.io/solid-ui/examples/storybook/) for SolidUI widgets.
11
+ See [Solid-UI API](https://solidos.github.io/solid-ui/Documentation/api/) for SolidUI functions.
12
+ See [Forms introduction](./Documentation/FormsReadme.md) for UI vocabulary implementation.
13
+
14
+ Table of content:
15
+ - Getting started(#getting-started)
16
+ - Further documentation(#further-ocumentation)
17
+
18
+
10
19
  ## Getting started
20
+
21
+ Contributions of bug fixes and new functionality, documentation, and tests are
22
+ always appreciated.
23
+
11
24
  ### In npm-based projects
12
25
  When including solid-ui in an npm-based project, you can use it with:
13
26
 
14
27
  ```js
15
- import { ns, rdf, acl, aclControl, authn, create, dom, icons, log, matrix, media,
16
- messageArea, infiniteMessageArea, pad, preferences, store, style, table, tabs, utils, widgets, versionInfo
28
+ import { ns, rdf, acl, aclControl, create, dom, icons, log, matrix, media,
29
+ messageArea, infiniteMessageArea, pad, preferences, style, table, tabs, utils, widgets, versionInfo
17
30
  } from 'solid-ui'
18
31
 
19
32
  ```
@@ -23,10 +36,8 @@ Clone this repo, and in the repo root run:
23
36
  * `npm install`
24
37
  * `npm run build`
25
38
 
26
- This will generate a `lib/` folder containing, among other artifacts, `lib/webpack-bundle.js`.
27
- Now run `npx serve` and go to http://localhost:5000/examples/ with your browser to see some examples.
28
- See the ['examples' folder](https://github.com/solidos/solid-ui/tree/examples/examples) for the
29
- source code of those examples.
39
+ This will generate a `dist/` folder containing, among other artifacts, `dist/main.js`.
40
+ Now run `npx serve` and go to http://localhost:3000/Documentation/ with your browser to see some examples.
30
41
 
31
42
  While viewing one of those examples, you can open the web console in your browser and for instance
32
43
  try how you can create a button:
@@ -44,56 +55,7 @@ const chat = UI.infiniteMessageArea(document, store, UI.rdf.namedNode(chatChanne
44
55
  document.body.appendChild(chat)
45
56
  ```
46
57
 
47
- Or a full ACL Control Box:
48
- ```js
49
- const exampleFolder = 'https://example-user.inrupt.net/public/public-control/'
50
- const aclControlBox = UI.aclControl.ACLControlBox5(UI.rdf.namedNode(exampleFolder), { dom: document }, '', store)
51
- document.body.appendChild(aclControlBox)
52
- ```
53
-
54
-
55
- ## Documentation
56
- - [talk presentation](https://solidos.github.io/solid-ui/Documentation/talks/FormsTalk.html)
57
- - API https://solidos.github.io/solid-ui/Documentation/api/ for the API documentation.
58
- - The UI components are presented in a [storybook](http://solidos.github.io/solid-ui/examples/storybook/).
59
-
60
- ## Overview
61
- This has been a place to put any functionality from solid views which has been generalized to be usable in other views.
62
-
63
- - Authentication UI: manage the user's logged in/out state.
64
- - Discovery: finding the user's stuff, and leaving records of new things
65
- - Preferences: UI for managing a user's preferences with two axes of defaults
66
- - An Access Control List widget for Solid ACL system
67
- - Acess Control Logic
68
- - Create a new object from modules/extensions which have registered their ability to create things
69
-
70
- - A [form system](https://solidos.github.io/solid-ui/Documentation/forms-intro.html): Forms are defined in RDF, and create/edit RDF data, including form definitions
71
- - A collection of shortcut namespace objects for a selection of relevant RDF vocabularies.
72
- - Small atomic widgets (buttons etc) of which the others are constructed.
73
- - An error message panel
74
-
75
- Some of the larger controls include:
76
-
77
- - A chat widget: add discussion to any object. Infinite scroll, embedded images, social reactions, etc etc
78
- - A people picker widget for choosing a set of people or an existing group
79
- - A general purpose table display with built-in faceted browsing
80
- - A two-dimentional matrix of editable live data that extends in both dimensions.
81
- - A notepad of shared notes for real-time collaboration
82
- - Drag and drop code for linking things and uploading files
83
- - A set of tabs for holding other widgets and arbitrary UI elements
84
-
85
- The typical style of the widgets is to know what data it has been derived from,
86
- allow users to edit it, and to automatically sync with data as it changes in the future.
87
- To see how these are used, see the panes which use them within the data browser.
88
-
89
- The level of support for this varies.
90
-
91
- See also: [A short introduction to the Form system](https://solidos.github.io/solid-ui/Documentation/forms-intro.html)
92
-
93
- Contributions of bug fixes and new functionality, documentation, and tests are
94
- always appreciated.
95
-
96
- ## Development
58
+ ### Development new components
97
59
 
98
60
  When developing a component in solid-ui you can test it in isolation using storybook
99
61
 
@@ -104,5 +66,8 @@ npm run storybook
104
66
 
105
67
  If there is no story for the component yet, add a new one to `./src/stories`.
106
68
 
107
- When you want to test the component within a solid-pane, you can use the [development mode of solid-panes](https://github.com/solidos/solid-panes#development) or
108
- [mashlib-dev](https://github.com/solidos/mashlib-dev).
69
+ When you want to test the component within a solid-pane, you can use the [development mode of solid-panes](https://github.com/solidos/solid-panes#development).
70
+
71
+ ## Further documentation
72
+
73
+ - [Some code know-how](https://github.com/SolidOS/solidos/wiki/2.-Solid-UI-know-how)
package/dist/main.js CHANGED
@@ -15172,7 +15172,7 @@ function slice(s, suffix) {
15172
15172
 
15173
15173
  function getWellKnownLabel(thing) {
15174
15174
  return _solidLogic.store.any(thing, UI.ns.ui('label')) || // Prioritize ui:label
15175
- _solidLogic.store.any(thing, UI.ns.link('message')) || _solidLogic.store.any(thing, UI.ns.vcard('fn')) || _solidLogic.store.any(thing, UI.ns.foaf('name')) || _solidLogic.store.any(thing, UI.ns.dct('title')) || _solidLogic.store.any(thing, UI.ns.dc('title')) || _solidLogic.store.any(thing, UI.ns.rss('title')) || _solidLogic.store.any(thing, UI.ns.contact('fullName')) || _solidLogic.store.any(thing, _solidLogic.store.sym('http://www.w3.org/2001/04/roadmap/org#name')) || _solidLogic.store.any(thing, UI.ns.cal('summary')) || _solidLogic.store.any(thing, UI.ns.foaf('nick')) || _solidLogic.store.any(thing, UI.ns.as('name')) || _solidLogic.store.any(thing, UI.ns.schema('name')) || _solidLogic.store.any(thing, UI.ns.rdfs('label'));
15175
+ _solidLogic.store.any(thing, UI.ns.link('message')) || _solidLogic.store.any(thing, UI.ns.vcard('fn')) || _solidLogic.store.any(thing, UI.ns.foaf('name')) || _solidLogic.store.any(thing, UI.ns.dct('title')) || _solidLogic.store.any(thing, UI.ns.dc('title')) || _solidLogic.store.any(thing, UI.ns.rss('title')) || _solidLogic.store.any(thing, UI.ns.contact('fullName')) || _solidLogic.store.any(thing, _solidLogic.store.sym('http://www.w3.org/2001/04/roadmap/org#name')) || _solidLogic.store.any(thing, UI.ns.cal('summary')) || _solidLogic.store.any(thing, UI.ns.foaf('nick')) || _solidLogic.store.any(thing, UI.ns.as('name')) || _solidLogic.store.any(thing, UI.ns.schema('name')) || _solidLogic.store.any(thing, UI.ns.rdfs('label')) || _solidLogic.store.any(thing, _solidLogic.store.sym('http://www.w3.org/2004/02/skos/core#prefLabel'));
15176
15176
  }
15177
15177
  //# sourceMappingURL=label.js.map
15178
15178
 
@@ -15192,11 +15192,11 @@ Object.defineProperty(exports, "__esModule", ({
15192
15192
  }));
15193
15193
  exports.versionInfo = void 0;
15194
15194
  var versionInfo = {
15195
- buildTime: '2022-05-02T13:37:35Z',
15196
- commit: '34747cd0e7be84514d29e13b42586ebe4442e1f0',
15195
+ buildTime: '2022-05-20T06:55:49Z',
15196
+ commit: '39d66c72c1c4f433317f3a8f6e3df4d0db35fd6e',
15197
15197
  npmInfo: {
15198
15198
  'solid-ui': '2.4.22',
15199
- npm: '6.14.16',
15199
+ npm: '6.14.17',
15200
15200
  ares: '1.18.1',
15201
15201
  brotli: '1.0.9',
15202
15202
  cldr: '40.0',
@@ -15205,12 +15205,12 @@ var versionInfo = {
15205
15205
  modules: '83',
15206
15206
  napi: '8',
15207
15207
  nghttp2: '1.42.0',
15208
- node: '14.19.1',
15208
+ node: '14.19.2',
15209
15209
  openssl: '1.1.1n',
15210
15210
  tz: '2021a3',
15211
15211
  unicode: '14.0',
15212
15212
  uv: '1.42.0',
15213
- v8: '8.4.371.23-node.85',
15213
+ v8: '8.4.371.23-node.87',
15214
15214
  zlib: '1.2.11'
15215
15215
  }
15216
15216
  };
@@ -16280,6 +16280,7 @@ function openHrefInOutlineMode(e) {
16280
16280
 
16281
16281
  if (dom.outlineManager) {
16282
16282
  // @@ TODO Remove the use of document as a global object
16283
+ // TODO fix dependency cycle to solid-panes by calling outlineManager
16283
16284
  ;
16284
16285
  dom.outlineManager.GotoSubject(_solidLogic.store.sym(uri), true, undefined, true, undefined);
16285
16286
  } else if (window && window.panes && window.panes.getOutliner) {
@@ -16407,6 +16408,7 @@ function linkButton(dom, object) {
16407
16408
  b.textContent = 'Goto ' + utils.label(object);
16408
16409
  b.addEventListener('click', function (_event) {
16409
16410
  // b.parentNode.removeChild(b)
16411
+ // TODO fix dependency cycle to solid-panes by calling outlineManager
16410
16412
  ;
16411
16413
  dom.outlineManager.GotoSubject(object, true, undefined, true, undefined);
16412
16414
  }, true);
@@ -17147,6 +17149,7 @@ exports.findClosest = findClosest;
17147
17149
  exports.formsFor = formsFor;
17148
17150
  exports.makeDescription = makeDescription;
17149
17151
  exports.makeSelectForCategory = makeSelectForCategory;
17152
+ exports.makeSelectForChoice = makeSelectForChoice;
17150
17153
  exports.makeSelectForNestedCategory = makeSelectForNestedCategory;
17151
17154
  exports.makeSelectForOptions = makeSelectForOptions;
17152
17155
  exports.newButton = newButton;
@@ -17258,14 +17261,16 @@ _fieldFunction.field[ns.ui('Form').uri] = _fieldFunction.field[ns.ui('Group').ur
17258
17261
  var ui = ns.ui;
17259
17262
  if (container) container.appendChild(box); // Prevent loops
17260
17263
 
17264
+ if (!form) return;
17261
17265
  var key = subject.toNT() + '|' + form.toNT();
17262
17266
 
17263
17267
  if (already[key]) {
17264
17268
  // been there done that
17265
- box.appendChild(dom.createTextNode('Group: see above ' + key));
17266
- var plist = [$rdf.st(subject, ns.owl('sameAs'), subject)]; // @@ need prev subject
17269
+ box.appendChild(dom.createTextNode('Group: see above ' + key)); // TODO fix dependency cycle to solid-panes by calling outlineManager
17270
+ // const plist = [$rdf.st(subject, ns.owl('sameAs'), subject)] // @@ need prev subject
17271
+ // dom.outlineManager.appendPropertyTRs(box, plist)
17272
+ // dom.appendChild(plist)
17267
17273
 
17268
- dom.outlineManager.appendPropertyTRs(box, plist);
17269
17274
  return box;
17270
17275
  }
17271
17276
 
@@ -17694,7 +17699,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17694
17699
  // delete button and move buttons
17695
17700
 
17696
17701
  if (kb.updater.editable(dataDoc.uri)) {
17697
- buttons.deleteButtonWithCheck(dom, subField, utils.label(property), deleteThisItem);
17702
+ buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
17698
17703
 
17699
17704
  if (ordered) {
17700
17705
  // Add controsl in a frame
@@ -17745,7 +17750,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17745
17750
 
17746
17751
  var _shim = dom.createElement('div');
17747
17752
 
17748
- _shim.appendChild(subField); // Subfield has its own laytout
17753
+ _shim.appendChild(subField); // Subfield has its own layout
17749
17754
 
17750
17755
 
17751
17756
  frame.appendChild(_shim);
@@ -17794,6 +17799,8 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17794
17799
  return shim;
17795
17800
  }
17796
17801
 
17802
+ var multipleUIlabel = kb.any(form, ui('label'));
17803
+ if (!multipleUIlabel) multipleUIlabel = utils.label(property);
17797
17804
  var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
17798
17805
 
17799
17806
  min = min ? 0 + min.value : 0;
@@ -17834,10 +17841,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17834
17841
  img.setAttribute('src', plusIconURI); // plus sign
17835
17842
 
17836
17843
  img.setAttribute('style', 'margin: 0.2em; width: 1.5em; height:1.5em');
17837
- img.title = 'Click to add one or more ' + utils.predicateLabel(property, reverse);
17838
- var prompt = tail.appendChild(dom.createElement('span'));
17839
- prompt.textContent = (values.length === 0 ? 'Add one or more ' : 'Add more ') + utils.predicateLabel(property, reverse); // utils.label(property)
17840
-
17844
+ img.title = 'Click to add another ' + multipleUIlabel;
17845
+ var prompt = dom.createElement('span');
17846
+ prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
17841
17847
  tail.addEventListener('click', /*#__PURE__*/function () {
17842
17848
  var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
17843
17849
  return _regenerator["default"].wrap(function _callee5$(_context5) {
@@ -17859,6 +17865,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17859
17865
  return _ref3.apply(this, arguments);
17860
17866
  };
17861
17867
  }(), true);
17868
+ tail.appendChild(prompt);
17862
17869
  }
17863
17870
 
17864
17871
  function createListIfNecessary() {
@@ -18120,28 +18127,39 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
18120
18127
  **
18121
18128
  ** Not nested. Generates a link to something from a given class.
18122
18129
  ** Optional subform for the thing selected.
18130
+ ** Generates a subForm based on a ui:use form
18131
+ ** Will look like:
18132
+ ** <div id=dropDownDiv>
18133
+ ** <div id=labelOfDropDown>
18134
+ ** <div id=selectDiv>
18135
+ ** <select id=dropDownSelect>
18136
+ ** <option> ....
18137
+ ** <subForm>
18123
18138
  ** Alternative implementatons caould be:
18124
18139
  ** -- pop-up menu (as here)
18125
18140
  ** -- radio buttons
18126
18141
  ** -- auto-complete typing
18127
18142
  **
18128
- ** Todo: Deal with multiple. Maybe merge with multiple code.
18143
+ ** TODO: according to ontology ui:choice can also have ns.ui('default') - this is not implemented yet
18129
18144
  */
18130
18145
 
18131
18146
 
18132
18147
  _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
18133
18148
  var ui = ns.ui;
18134
18149
  var kb = _solidLogic.store;
18135
- var multiple = false;
18136
18150
  var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
18137
18151
 
18152
+ var multiSelect = false;
18138
18153
  var p;
18139
- var box = dom.createElement('div'); // Set flexDirection column?
18154
+ var box = dom.createElement('div');
18155
+ box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
18140
18156
 
18141
18157
  if (container) container.appendChild(box);
18142
18158
  var lhs = dom.createElement('div');
18159
+ lhs.setAttribute('class', 'formFieldName choiceBox-label');
18143
18160
  box.appendChild(lhs);
18144
18161
  var rhs = dom.createElement('div');
18162
+ rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
18145
18163
  box.appendChild(rhs);
18146
18164
  var property = kb.any(form, ui('property'));
18147
18165
 
@@ -18150,9 +18168,9 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18150
18168
  }
18151
18169
 
18152
18170
  lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
18153
- var from = kb.any(form, ui('from'));
18171
+ var uiFrom = kb.any(form, ui('from'));
18154
18172
 
18155
- if (!from) {
18173
+ if (!uiFrom) {
18156
18174
  return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
18157
18175
  }
18158
18176
 
@@ -18160,77 +18178,95 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18160
18178
 
18161
18179
  var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
18162
18180
 
18163
- var possible = [];
18164
- var possibleProperties;
18165
- var nullLabel = '--' + utils.label(property) + '-?';
18166
18181
  var opts = {
18167
18182
  form: form,
18168
- multiple: multiple,
18169
- nullLabel: nullLabel,
18183
+ subForm: subForm,
18184
+ multiSelect: multiSelect,
18170
18185
  disambiguate: false
18171
18186
  };
18172
- possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
18173
18187
 
18174
- for (var x in kb.findMembersNT(from)) {
18175
- possible.push(kb.fromNT(x));
18176
- } // Use rdfs
18188
+ function getSelectorOptions() {
18189
+ var possible = [];
18190
+ var possibleProperties;
18191
+ possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
18177
18192
 
18193
+ for (var x in kb.findMembersNT(uiFrom)) {
18194
+ possible.push(kb.fromNT(x));
18195
+ } // Use rdfs
18178
18196
 
18179
- if (from.sameTerm(ns.rdfs('Class'))) {
18180
- for (p in buttons.allClassURIs()) {
18181
- possible.push(kb.sym(p));
18182
- } // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
18183
18197
 
18184
- } else if (from.sameTerm(ns.rdf('Property'))) {
18185
- possibleProperties = buttons.propertyTriage(kb);
18198
+ if (uiFrom.sameTerm(ns.rdfs('Class'))) {
18199
+ for (p in buttons.allClassURIs()) {
18200
+ possible.push(kb.sym(p));
18201
+ } // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
18186
18202
 
18187
- for (p in possibleProperties.op) {
18188
- possible.push(kb.fromNT(p));
18189
- }
18203
+ } else if (uiFrom.sameTerm(ns.rdf('Property'))) {
18204
+ possibleProperties = buttons.propertyTriage(kb);
18190
18205
 
18191
- for (p in possibleProperties.dp) {
18192
- possible.push(kb.fromNT(p));
18193
- }
18206
+ for (p in possibleProperties.op) {
18207
+ possible.push(kb.fromNT(p));
18208
+ }
18194
18209
 
18195
- opts.disambiguate = true; // This is a big class, and the labels won't be enough.
18196
- } else if (from.sameTerm(ns.owl('ObjectProperty'))) {
18197
- possibleProperties = buttons.propertyTriage(kb);
18210
+ for (p in possibleProperties.dp) {
18211
+ possible.push(kb.fromNT(p));
18212
+ }
18198
18213
 
18199
- for (p in possibleProperties.op) {
18200
- possible.push(kb.fromNT(p));
18201
- }
18214
+ opts.disambiguate = true; // This is a big class, and the labels won't be enough.
18215
+ } else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
18216
+ possibleProperties = buttons.propertyTriage(kb);
18202
18217
 
18203
- opts.disambiguate = true;
18204
- } else if (from.sameTerm(ns.owl('DatatypeProperty'))) {
18205
- possibleProperties = buttons.propertyTriage(kb);
18218
+ for (p in possibleProperties.op) {
18219
+ possible.push(kb.fromNT(p));
18220
+ }
18221
+
18222
+ opts.disambiguate = true;
18223
+ } else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
18224
+ possibleProperties = buttons.propertyTriage(kb);
18206
18225
 
18207
- for (p in possibleProperties.dp) {
18208
- possible.push(kb.fromNT(p));
18226
+ for (p in possibleProperties.dp) {
18227
+ possible.push(kb.fromNT(p));
18228
+ }
18229
+
18230
+ opts.disambiguate = true;
18209
18231
  }
18210
18232
 
18211
- opts.disambiguate = true;
18212
- }
18233
+ return sortByLabel(possible);
18234
+ } // TODO: this checks for any occurrence, regardless of true or false setting
18213
18235
 
18214
- var object = kb.any(subject, property);
18215
18236
 
18216
- function addSubForm() {
18217
- object = kb.any(subject, property);
18218
- (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
18237
+ if (kb.any(form, ui('canMintNew'))) {
18238
+ opts.mint = '* Create new *'; // @@ could be better
18219
18239
  }
18220
18240
 
18221
- var possible2 = sortByLabel(possible);
18241
+ var selector;
18222
18242
 
18223
- if (kb.any(form, ui('canMintNew'))) {
18224
- opts.mint = '* New *'; // @@ could be better
18243
+ rhs.refresh = function () {
18244
+ var selectorOptions = getSelectorOptions();
18245
+ selector = makeSelectForChoice(dom, rhs, kb, subject, property, selectorOptions, uiFrom, opts, dataDoc, callbackFunction);
18246
+ rhs.innerHTML = '';
18247
+ rhs.appendChild(selector);
18248
+ };
18225
18249
 
18226
- opts.subForm = subForm;
18250
+ rhs.refresh();
18251
+ if (selector && selector.refresh) selector.refresh();
18252
+ return box;
18253
+ };
18254
+ /**
18255
+ * Removes all sibling elements after specified
18256
+ * @param {HTMLElement} currentElement
18257
+ * @private
18258
+ */
18259
+
18260
+
18261
+ function removeNextSiblingsAfterElement(currentElement) {
18262
+ while (currentElement.nextElementSibling) {
18263
+ currentElement.nextElementSibling.remove();
18227
18264
  }
18265
+ }
18228
18266
 
18229
- var selector = makeSelectForOptions(dom, kb, subject, property, possible2, opts, dataDoc, callbackFunction);
18230
- rhs.appendChild(selector);
18231
- if (object && subForm) addSubForm();
18232
- return box;
18233
- }; // Documentation - non-interactive fields
18267
+ function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
18268
+ (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
18269
+ } // Documentation - non-interactive fields
18234
18270
  //
18235
18271
 
18236
18272
 
@@ -18433,7 +18469,8 @@ function promptForNew(dom, kb, subject, predicate, theClass, form, dataDoc, call
18433
18469
  b.setAttribute('type', 'button');
18434
18470
  b.setAttribute('style', 'float: right;');
18435
18471
  b.innerHTML = 'Goto ' + utils.label(theClass);
18436
- b.addEventListener('click', function (_e) {
18472
+ b.addEventListener('click', // TODO fix dependency cycle to solid-panes by calling outlineManager
18473
+ function (_e) {
18437
18474
  dom.outlineManager.GotoSubject(theClass, true, undefined, true, undefined);
18438
18475
  }, false);
18439
18476
  return box;
@@ -18609,7 +18646,9 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18609
18646
  actual = kb.findTypeURIs(subject);
18610
18647
  } else {
18611
18648
  kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
18612
- actual[x.uri] = true;
18649
+ if (x.uri) {
18650
+ actual[x.uri] = true;
18651
+ }
18613
18652
  });
18614
18653
  }
18615
18654
 
@@ -18636,6 +18675,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18636
18675
  var opt = select.options[_i];
18637
18676
 
18638
18677
  if (opt.selected && opt.AJAR_mint) {
18678
+ // not sure if this 'if' is used because I cannot find mintClass
18639
18679
  if (options.mintClass) {
18640
18680
  var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
18641
18681
  if (!ok) {
@@ -18650,7 +18690,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18650
18690
  newObject = newThing(dataDoc);
18651
18691
  }
18652
18692
 
18653
- is.push($rdf.st(subject, predicate, newObject, dataDoc));
18693
+ is.push($rdf.st(subject, predicate, newObject, dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
18654
18694
 
18655
18695
  if (options.mintStatementsFun) {
18656
18696
  is = is.concat(options.mintStatementsFun(newObject));
@@ -19002,6 +19042,199 @@ function newThing(doc) {
19002
19042
  var now = new Date();
19003
19043
  return $rdf.sym(doc.uri + '#' + 'id' + ('' + now.getTime()));
19004
19044
  }
19045
+ /** Make SELECT element to select options
19046
+ //
19047
+ // @param subject - a term, the subject of the statement(s) being edited.
19048
+ // @param predicate - a term, the predicate of the statement(s) being edited
19049
+ // @param possible - a list of terms, the possible value the object can take
19050
+ // @param options.multiSelect - Boolean - Whether more than one at a time is allowed
19051
+ // @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
19052
+ // @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
19053
+ // @param options.subForm - If mint, then the form to be used for minting the new thing
19054
+ // @param dataDoc - The web document being edited
19055
+ // @param callbackFunction - takes (boolean ok, string errorBody)
19056
+ */
19057
+
19058
+
19059
+ function makeSelectForChoice(dom, container, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
19060
+ var n = 0;
19061
+ var uris = {}; // Count them
19062
+
19063
+ var editable = kb.updater.editable(dataDoc.uri);
19064
+
19065
+ for (var i = 0; i < possible.length; i++) {
19066
+ var sub = possible[i]; // @@ Maybe; make this so it works with blank nodes too
19067
+
19068
+ if (!sub.uri) debug.warn("makeSelectForOptions: option does not have an uri: ".concat(sub, ", with predicate: ").concat(predicate));
19069
+ if (!sub.uri || sub.uri in uris) continue;
19070
+ uris[sub.uri] = true;
19071
+ n++;
19072
+ } // uris is now the set of possible options
19073
+
19074
+
19075
+ if (n === 0 && !options.mint) {
19076
+ return (0, _error.errorMessageBlock)(dom, "Can't do selector with no options, subject= " + subject + ' property = ' + predicate + '.');
19077
+ }
19078
+
19079
+ log.debug('makeSelectForOptions: dataDoc=' + dataDoc);
19080
+
19081
+ function determinFirstSelectOption() {
19082
+ var firstSelectOptionText = '--- classify ---';
19083
+ var option = dom.createElement('option');
19084
+
19085
+ if (predicate && !(predicate.termType === 'BlankNode')) {
19086
+ firstSelectOptionText = '* Select for property: ' + utils.label(predicate) + ' *';
19087
+ }
19088
+
19089
+ if (subject && !(subject.termType === 'BlankNode')) {
19090
+ firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *';
19091
+ }
19092
+
19093
+ option.appendChild(dom.createTextNode(firstSelectOptionText));
19094
+ option.disabled = true;
19095
+ option.value = true;
19096
+ option.hidden = true;
19097
+ option.selected = true;
19098
+ return option;
19099
+ }
19100
+
19101
+ var onChange = function onChange(_e) {
19102
+ select.refresh();
19103
+ };
19104
+
19105
+ var select = dom.createElement('select');
19106
+ select.setAttribute('style', style.formSelectSTyle);
19107
+ if (options.multiSelect) select.setAttribute('multiSelect', 'true');
19108
+ select.currentURI = null;
19109
+ var object = kb.any(subject, predicate);
19110
+ if (object) select.currentURI = object;
19111
+
19112
+ for (var uri in uris) {
19113
+ select.appendChild(createOption(uri));
19114
+ }
19115
+
19116
+ if (editable && options.mint) {
19117
+ var mint = dom.createElement('option');
19118
+ mint.appendChild(dom.createTextNode(options.mint));
19119
+ mint.AJAR_mint = true; // Flag it
19120
+
19121
+ select.insertBefore(mint, select.firstChild);
19122
+ }
19123
+
19124
+ if (select.children.length === 0) select.insertBefore(determinFirstSelectOption(), select.firstChild);
19125
+
19126
+ select.refresh = function () {
19127
+ select.disabled = true; // unlocked any conflict we had got into
19128
+
19129
+ var ds = [];
19130
+ var is = [];
19131
+
19132
+ var removeValue = function removeValue(t) {
19133
+ if (kb.holds(subject, predicate, t, dataDoc)) {
19134
+ ds.push($rdf.st(subject, predicate, t, dataDoc));
19135
+ }
19136
+ };
19137
+
19138
+ var newObject;
19139
+
19140
+ for (var _i3 = 0; _i3 < select.options.length; _i3++) {
19141
+ var opt = select.options[_i3];
19142
+
19143
+ if (opt.selected && opt.AJAR_mint) {
19144
+ // not sure if this 'if' is used because I cannot find mintClass
19145
+ if (options.mintClass) {
19146
+ var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
19147
+ if (!ok) {
19148
+ callbackFunction(ok, body, {
19149
+ change: 'new'
19150
+ }); // @@ if ok, need some form of refresh of the select for the new thing
19151
+ }
19152
+ });
19153
+ select.parentNode.appendChild(thisForm);
19154
+ newObject = thisForm.AJAR_subject;
19155
+ } else {
19156
+ newObject = newThing(dataDoc);
19157
+ }
19158
+
19159
+ is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
19160
+ if (uiFrom) is.push($rdf.st(newObject, ns.rdf('type'), kb.sym(uiFrom), dataDoc)); // not sure if this 'if' is used because I cannot find mintStatementsFun
19161
+
19162
+ if (options.mintStatementsFun) {
19163
+ is = is.concat(options.mintStatementsFun(newObject));
19164
+ }
19165
+
19166
+ select.currentURI = newObject;
19167
+ }
19168
+
19169
+ if (!opt.AJAR_uri) continue; // a prompt or mint
19170
+
19171
+ if (opt.selected) select.currentURI = opt.AJAR_uri;
19172
+ }
19173
+
19174
+ var sel = select.subSelect; // All subclasses must also go
19175
+
19176
+ while (sel && sel.currentURI) {
19177
+ removeValue(kb.sym(sel.currentURI));
19178
+ sel = sel.subSelect;
19179
+ }
19180
+
19181
+ sel = select.superSelect; // All superclasses are redundant
19182
+
19183
+ while (sel && sel.currentURI) {
19184
+ removeValue(kb.sym(sel.currentURI));
19185
+ sel = sel.superSelect;
19186
+ }
19187
+
19188
+ log.info('selectForOptions: data doc = ' + dataDoc);
19189
+
19190
+ if (select.currentURI) {
19191
+ removeNextSiblingsAfterElement(select);
19192
+ addSubFormChoice(dom, container, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
19193
+ if (ok) {
19194
+ kb.updater.update(ds, is, function (uri, success, errorBody) {
19195
+ if (!success) container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
19196
+ });
19197
+ if (callbackFunction) callbackFunction(ok, {
19198
+ widget: 'select',
19199
+ event: 'new'
19200
+ }); // widgets.refreshTree(container)
19201
+ } else {
19202
+ container.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
19203
+ }
19204
+ });
19205
+ }
19206
+
19207
+ select.disabled = false;
19208
+ };
19209
+
19210
+ function createOption(uri) {
19211
+ var option = dom.createElement('option');
19212
+ var c = kb.sym(uri);
19213
+
19214
+ if (options.disambiguate) {
19215
+ option.appendChild(dom.createTextNode(utils.labelWithOntology(c, true))); // Init. cap
19216
+ } else {
19217
+ option.appendChild(dom.createTextNode(utils.label(c, true))); // Init.
19218
+ }
19219
+
19220
+ var backgroundColor = kb.any(c, kb.sym('http://www.w3.org/ns/ui#backgroundColor'));
19221
+
19222
+ if (backgroundColor) {
19223
+ option.setAttribute('style', 'background-color: ' + backgroundColor.value + '; ');
19224
+ }
19225
+
19226
+ option.AJAR_uri = uri;
19227
+ if (c.toString() === '' + select.currentURI) option.selected = true;
19228
+ return option;
19229
+ }
19230
+
19231
+ if (editable) {
19232
+ select.addEventListener('change', onChange, false);
19233
+ }
19234
+
19235
+ select.refresh();
19236
+ return select;
19237
+ } // makeSelectForChoice
19005
19238
  //# sourceMappingURL=forms.js.map
19006
19239
 
19007
19240
  /***/ }),