solid-ui 2.4.22-4af9be21 → 2.4.22-6ae4df24

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/dist/main.js CHANGED
@@ -15192,8 +15192,8 @@ Object.defineProperty(exports, "__esModule", ({
15192
15192
  }));
15193
15193
  exports.versionInfo = void 0;
15194
15194
  var versionInfo = {
15195
- buildTime: '2022-05-09T08:19:02Z',
15196
- commit: '4af9be213db48f4f001f37d4e663632c2e44821b',
15195
+ buildTime: '2022-05-10T15:38:52Z',
15196
+ commit: '6ae4df243e825dee4607d8bde360d12bd9de6925',
15197
15197
  npmInfo: {
15198
15198
  'solid-ui': '2.4.22',
15199
15199
  npm: '6.14.16',
@@ -17745,7 +17745,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17745
17745
 
17746
17746
  var _shim = dom.createElement('div');
17747
17747
 
17748
- _shim.appendChild(subField); // Subfield has its own laytout
17748
+ _shim.appendChild(subField); // Subfield has its own layout
17749
17749
 
17750
17750
 
17751
17751
  frame.appendChild(_shim);
@@ -17830,14 +17830,16 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17830
17830
  if (kb.updater.editable(dataDoc.uri)) {
17831
17831
  var tail = box.appendChild(dom.createElement('div'));
17832
17832
  tail.style.padding = '0.5em';
17833
+ var label = kb.any(form, ui('label'));
17834
+ if (!label) label = utils.label(property, true); // Init capital
17835
+
17833
17836
  var img = tail.appendChild(dom.createElement('img'));
17834
17837
  img.setAttribute('src', plusIconURI); // plus sign
17835
17838
 
17836
17839
  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
-
17840
+ img.title = 'Click to add one or more ' + label;
17841
+ var prompt = dom.createElement('span');
17842
+ prompt.textContent = (values.length === 0 ? 'Add one or more ' : 'Add more ') + utils.predicateLabel(property, reverse);
17841
17843
  tail.addEventListener('click', /*#__PURE__*/function () {
17842
17844
  var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_eventNotUsed) {
17843
17845
  return _regenerator["default"].wrap(function _callee5$(_context5) {
@@ -17859,6 +17861,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17859
17861
  return _ref3.apply(this, arguments);
17860
17862
  };
17861
17863
  }(), true);
17864
+ tail.appendChild(prompt);
17862
17865
  }
17863
17866
 
17864
17867
  function createListIfNecessary() {
@@ -18120,6 +18123,14 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
18120
18123
  **
18121
18124
  ** Not nested. Generates a link to something from a given class.
18122
18125
  ** Optional subform for the thing selected.
18126
+ ** Generates a subForm based on a ui:use form
18127
+ ** Will look like:
18128
+ ** <div id=dropDownDiv>
18129
+ ** <div id=labelOfDropDown>
18130
+ ** <div id=selectDiv>
18131
+ ** <select id=dropDownSelect>
18132
+ ** <option> ....
18133
+ ** <subForm>
18123
18134
  ** Alternative implementatons caould be:
18124
18135
  ** -- pop-up menu (as here)
18125
18136
  ** -- radio buttons
@@ -18132,16 +18143,18 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
18132
18143
  _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
18133
18144
  var ui = ns.ui;
18134
18145
  var kb = _solidLogic.store;
18135
- var multiple = false;
18136
18146
  var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
18137
18147
 
18138
18148
  var p;
18139
- var box = dom.createElement('div'); // Set flexDirection column?
18149
+ var box = dom.createElement('div');
18150
+ box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
18140
18151
 
18141
18152
  if (container) container.appendChild(box);
18142
18153
  var lhs = dom.createElement('div');
18154
+ lhs.setAttribute('class', 'formFieldName choiceBox-label');
18143
18155
  box.appendChild(lhs);
18144
18156
  var rhs = dom.createElement('div');
18157
+ rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
18145
18158
  box.appendChild(rhs);
18146
18159
  var property = kb.any(form, ui('property'));
18147
18160
 
@@ -18150,9 +18163,9 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18150
18163
  }
18151
18164
 
18152
18165
  lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
18153
- var from = kb.any(form, ui('from'));
18166
+ var uiFrom = kb.any(form, ui('from'));
18154
18167
 
18155
- if (!from) {
18168
+ if (!uiFrom) {
18156
18169
  return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
18157
18170
  }
18158
18171
 
@@ -18162,26 +18175,35 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18162
18175
 
18163
18176
  var possible = [];
18164
18177
  var possibleProperties;
18165
- var nullLabel = '--' + utils.label(property) + '-?';
18178
+ var multiple = false;
18179
+ var firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *'; // if we do NOT have a container it means it is a ui:Multiple
18180
+ // only important for the first option text in select
18181
+
18182
+ if (!container) {
18183
+ multiple = true;
18184
+ firstSelectOptionText = utils.label(subject, true);
18185
+ }
18186
+
18166
18187
  var opts = {
18167
18188
  form: form,
18189
+ subForm: subForm,
18168
18190
  multiple: multiple,
18169
- nullLabel: nullLabel,
18191
+ firstSelectOptionText: firstSelectOptionText,
18170
18192
  disambiguate: false
18171
18193
  };
18172
- possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
18194
+ possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
18173
18195
 
18174
- for (var x in kb.findMembersNT(from)) {
18196
+ for (var x in kb.findMembersNT(uiFrom)) {
18175
18197
  possible.push(kb.fromNT(x));
18176
18198
  } // Use rdfs
18177
18199
 
18178
18200
 
18179
- if (from.sameTerm(ns.rdfs('Class'))) {
18201
+ if (uiFrom.sameTerm(ns.rdfs('Class'))) {
18180
18202
  for (p in buttons.allClassURIs()) {
18181
18203
  possible.push(kb.sym(p));
18182
18204
  } // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
18183
18205
 
18184
- } else if (from.sameTerm(ns.rdf('Property'))) {
18206
+ } else if (uiFrom.sameTerm(ns.rdf('Property'))) {
18185
18207
  possibleProperties = buttons.propertyTriage(kb);
18186
18208
 
18187
18209
  for (p in possibleProperties.op) {
@@ -18193,7 +18215,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18193
18215
  }
18194
18216
 
18195
18217
  opts.disambiguate = true; // This is a big class, and the labels won't be enough.
18196
- } else if (from.sameTerm(ns.owl('ObjectProperty'))) {
18218
+ } else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
18197
18219
  possibleProperties = buttons.propertyTriage(kb);
18198
18220
 
18199
18221
  for (p in possibleProperties.op) {
@@ -18201,7 +18223,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18201
18223
  }
18202
18224
 
18203
18225
  opts.disambiguate = true;
18204
- } else if (from.sameTerm(ns.owl('DatatypeProperty'))) {
18226
+ } else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
18205
18227
  possibleProperties = buttons.propertyTriage(kb);
18206
18228
 
18207
18229
  for (p in possibleProperties.dp) {
@@ -18211,26 +18233,45 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18211
18233
  opts.disambiguate = true;
18212
18234
  }
18213
18235
 
18214
- var object = kb.any(subject, property);
18236
+ var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurrence, regardless of true or false setting
18215
18237
 
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);
18238
+ if (kb.any(form, ui('canMintNew'))) {
18239
+ opts.mint = '* Create new *'; // @@ could be better
18219
18240
  }
18220
18241
 
18221
- var possible2 = sortByLabel(possible);
18242
+ var selector = makeSelectForOptions(dom, kb, subject, property, sortedPossible, uiFrom, opts, dataDoc, callbackFunction);
18243
+ rhs.appendChild(selector);
18244
+ var object;
18222
18245
 
18223
- if (kb.any(form, ui('canMintNew'))) {
18224
- opts.mint = '* New *'; // @@ could be better
18246
+ if (selector.currentURI) {
18247
+ object = $rdf.sym(selector.currentURI);
18248
+ } else {
18249
+ object = kb.any(subject, property);
18250
+ }
18225
18251
 
18226
- opts.subForm = subForm;
18252
+ if (object && subForm) {
18253
+ removeNextSiblingsAfterElement(selector);
18254
+ addSubFormChoice(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
18227
18255
  }
18228
18256
 
18229
- var selector = makeSelectForOptions(dom, kb, subject, property, possible2, opts, dataDoc, callbackFunction);
18230
- rhs.appendChild(selector);
18231
- if (object && subForm) addSubForm();
18232
18257
  return box;
18233
- }; // Documentation - non-interactive fields
18258
+ };
18259
+ /**
18260
+ * Removes all sibling elements after specified
18261
+ * @param {HTMLElement} currentElement
18262
+ * @private
18263
+ */
18264
+
18265
+
18266
+ function removeNextSiblingsAfterElement(currentElement) {
18267
+ while (currentElement.nextElementSibling) {
18268
+ currentElement.nextElementSibling.remove();
18269
+ }
18270
+ }
18271
+
18272
+ function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
18273
+ (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
18274
+ } // Documentation - non-interactive fields
18234
18275
  //
18235
18276
 
18236
18277
 
@@ -18569,7 +18610,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
18569
18610
  // @param predicate - a term, the predicate of the statement(s) being edited
18570
18611
  // @param possible - a list of terms, the possible value the object can take
18571
18612
  // @param options.multiple - Boolean - Whether more than one at a time is allowed
18572
- // @param options.nullLabel - a string to be displayed as the
18613
+ // @param options.firstSelectOptionText - a string to be displayed as the
18573
18614
  // option for none selected (for non multiple)
18574
18615
  // @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
18575
18616
  // @param options.subForm - If mint, then the form to be used for minting the new thing
@@ -18578,7 +18619,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
18578
18619
  */
18579
18620
 
18580
18621
 
18581
- function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
18622
+ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
18582
18623
  log.debug('Select list length now ' + possible.length);
18583
18624
  var n = 0;
18584
18625
  var uris = {}; // Count them
@@ -18609,7 +18650,9 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18609
18650
  actual = kb.findTypeURIs(subject);
18610
18651
  } else {
18611
18652
  kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
18612
- actual[x.uri] = true;
18653
+ if (x.uri) {
18654
+ actual[x.uri] = true;
18655
+ }
18613
18656
  });
18614
18657
  }
18615
18658
 
@@ -18619,8 +18662,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18619
18662
  actual = getActual();
18620
18663
 
18621
18664
  var onChange = function onChange(_e) {
18622
- select.disabled = true; // until data written back - gives user feedback too
18623
-
18624
18665
  var ds = [];
18625
18666
  var is = [];
18626
18667
 
@@ -18636,6 +18677,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18636
18677
  var opt = select.options[_i];
18637
18678
 
18638
18679
  if (opt.selected && opt.AJAR_mint) {
18680
+ // not sure if this 'if' is used because I cannot find mintClass
18639
18681
  if (options.mintClass) {
18640
18682
  var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
18641
18683
  if (!ok) {
@@ -18650,11 +18692,14 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18650
18692
  newObject = newThing(dataDoc);
18651
18693
  }
18652
18694
 
18653
- is.push($rdf.st(subject, predicate, newObject, dataDoc));
18695
+ is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
18696
+ 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
18654
18697
 
18655
18698
  if (options.mintStatementsFun) {
18656
18699
  is = is.concat(options.mintStatementsFun(newObject));
18657
18700
  }
18701
+
18702
+ select.currentURI = newObject;
18658
18703
  }
18659
18704
 
18660
18705
  if (!opt.AJAR_uri) continue; // a prompt or mint
@@ -18662,11 +18707,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18662
18707
  if (opt.selected && !(opt.AJAR_uri in actual)) {
18663
18708
  // new class
18664
18709
  is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
18665
- }
18666
-
18667
- if (!opt.selected && opt.AJAR_uri in actual) {
18668
- // old class
18669
- removeValue(kb.sym(opt.AJAR_uri));
18710
+ select.currentURI = opt.AJAR_uri;
18670
18711
  }
18671
18712
 
18672
18713
  if (opt.selected) select.currentURI = opt.AJAR_uri;
@@ -18686,38 +18727,29 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18686
18727
  sel = sel.superSelect;
18687
18728
  }
18688
18729
 
18689
- function doneNew(ok, _body) {
18690
- callbackFunction(ok, {
18691
- widget: 'select',
18692
- event: 'new'
18693
- });
18694
- }
18695
-
18696
- log.info('selectForOptions: data doc = ' + dataDoc);
18697
- kb.updater.update(ds, is, function (uri, ok, body) {
18698
- actual = getActual(); // refresh
18730
+ log.info('selectForOptions: data doc = ' + dataDoc); // refresh subForm
18699
18731
 
18732
+ removeNextSiblingsAfterElement(select);
18733
+ addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
18700
18734
  if (ok) {
18701
- select.disabled = false; // data written back
18735
+ kb.updater.update(ds, is, function (uri, success, errorBody) {
18736
+ actual = getActual(); // refresh
18702
18737
 
18703
- if (newObject) {
18704
- var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
18705
- fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
18706
- }
18738
+ if (!success) select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
18739
+ });
18740
+ if (callbackFunction) callbackFunction(ok, {
18741
+ widget: 'select',
18742
+ event: 'new'
18743
+ });
18707
18744
  } else {
18708
- return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
18745
+ select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
18709
18746
  }
18710
-
18711
- if (callbackFunction) callbackFunction(ok, {
18712
- widget: 'select',
18713
- event: 'change'
18714
- });
18715
18747
  });
18716
18748
  };
18717
18749
 
18718
18750
  var select = dom.createElement('select');
18719
- select.setAttribute('style', style.formSelectSTyle);
18720
- if (options.multiple) select.setAttribute('multiple', 'true');
18751
+ select.setAttribute('style', style.formSelectSTyle); // if (options.multiple) select.setAttribute('multiple', 'true') // use case merged with ui:Multiple
18752
+
18721
18753
  select.currentURI = null;
18722
18754
 
18723
18755
  select.refresh = function () {
@@ -18768,11 +18800,14 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18768
18800
  select.insertBefore(mint, select.firstChild);
18769
18801
  }
18770
18802
 
18771
- if (select.currentURI == null && !options.multiple) {
18803
+ if (!select.currentURI && options.multiple) {
18772
18804
  var prompt = dom.createElement('option');
18773
- prompt.appendChild(dom.createTextNode(options.nullLabel));
18774
- select.insertBefore(prompt, select.firstChild);
18805
+ prompt.appendChild(dom.createTextNode(options.firstSelectOptionText));
18806
+ prompt.disabled = true;
18807
+ prompt.value = true;
18808
+ prompt.hidden = true;
18775
18809
  prompt.selected = true;
18810
+ select.insertBefore(prompt, select.firstChild);
18776
18811
  }
18777
18812
 
18778
18813
  if (editable) {
@@ -18810,9 +18845,8 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
18810
18845
  return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
18811
18846
  }
18812
18847
 
18813
- return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
18814
- multiple: multiple,
18815
- nullPrompt: '--classify--'
18848
+ return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
18849
+ multiple: multiple
18816
18850
  }, dataDoc, callbackFunction);
18817
18851
  }
18818
18852
  /** Make SELECT element to select subclasses recurively