solid-ui 2.4.22-4e7a23dc → 2.4.22-72c4afee

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:12:16Z',
15196
- commit: '4e7a23dcab0793bde0b5d0affdfbbdd8124bd0ea',
15195
+ buildTime: '2022-05-10T17:01:21Z',
15196
+ commit: '72c4afee56908963538f4a84ec9c770c7ec241ff',
15197
15197
  npmInfo: {
15198
15198
  'solid-ui': '2.4.22',
15199
15199
  npm: '6.14.16',
@@ -17694,7 +17694,7 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17694
17694
  // delete button and move buttons
17695
17695
 
17696
17696
  if (kb.updater.editable(dataDoc.uri)) {
17697
- buttons.deleteButtonWithCheck(dom, subField, utils.label(property), deleteThisItem);
17697
+ buttons.deleteButtonWithCheck(dom, subField, multipleUIlabel, deleteThisItem);
17698
17698
 
17699
17699
  if (ordered) {
17700
17700
  // Add controsl in a frame
@@ -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);
@@ -17794,6 +17794,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
17794
17794
  return shim;
17795
17795
  }
17796
17796
 
17797
+ var multipleUIlabel = kb.any(form, ui('label'));
17798
+ if (!multipleUIlabel) multipleUIlabel = utils.label(property, true); // Init capital
17799
+
17797
17800
  var min = kb.any(form, ui('min')); // This is the minimum number -- default 0
17798
17801
 
17799
17802
  min = min ? 0 + min.value : 0;
@@ -17834,10 +17837,9 @@ _fieldFunction.field[ns.ui('Multiple').uri] = function (dom, container, already,
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 another ' + multipleUIlabel;
17841
+ var prompt = dom.createElement('span');
17842
+ prompt.textContent = (values.length === 0 ? 'Add another ' : 'Add ') + multipleUIlabel;
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,28 +18123,40 @@ _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
18126
18137
  ** -- auto-complete typing
18127
18138
  **
18128
- ** Todo: Deal with multiple. Maybe merge with multiple code.
18129
18139
  */
18130
18140
 
18131
18141
 
18132
18142
  _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, subject, form, dataDoc, callbackFunction) {
18133
18143
  var ui = ns.ui;
18134
18144
  var kb = _solidLogic.store;
18135
- var multiple = false;
18136
18145
  var formDoc = form.doc ? form.doc() : null; // @@ if blank no way to know
18137
18146
 
18147
+ var uiMultipleInUse = false; // this signals to ui:choice that it is part of a ui:multiple
18148
+
18149
+ var multiSelect = false;
18138
18150
  var p;
18139
- var box = dom.createElement('div'); // Set flexDirection column?
18151
+ var box = dom.createElement('div');
18152
+ box.setAttribute('class', 'choiceBox'); // Set flexDirection column?
18140
18153
 
18141
18154
  if (container) container.appendChild(box);
18142
18155
  var lhs = dom.createElement('div');
18156
+ lhs.setAttribute('class', 'formFieldName choiceBox-label');
18143
18157
  box.appendChild(lhs);
18144
18158
  var rhs = dom.createElement('div');
18159
+ rhs.setAttribute('class', 'formFieldValue choiceBox-selectBox');
18145
18160
  box.appendChild(rhs);
18146
18161
  var property = kb.any(form, ui('property'));
18147
18162
 
@@ -18150,9 +18165,9 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18150
18165
  }
18151
18166
 
18152
18167
  lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
18153
- var from = kb.any(form, ui('from'));
18168
+ var uiFrom = kb.any(form, ui('from'));
18154
18169
 
18155
- if (!from) {
18170
+ if (!uiFrom) {
18156
18171
  return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
18157
18172
  }
18158
18173
 
@@ -18162,26 +18177,35 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18162
18177
 
18163
18178
  var possible = [];
18164
18179
  var possibleProperties;
18165
- var nullLabel = '--' + utils.label(property) + '-?';
18180
+ var firstSelectOptionText = '* Select for ' + utils.label(subject, true) + ' *'; // if we do NOT have a container it means it is a ui:Multiple
18181
+ // only important for the first option text in select
18182
+
18183
+ if (!container) {
18184
+ uiMultipleInUse = true;
18185
+ firstSelectOptionText = utils.label(subject, true);
18186
+ }
18187
+
18166
18188
  var opts = {
18167
18189
  form: form,
18168
- multiple: multiple,
18169
- nullLabel: nullLabel,
18190
+ subForm: subForm,
18191
+ multiSelect: multiSelect,
18192
+ firstSelectOptionText: firstSelectOptionText,
18193
+ uiMultipleInUse: uiMultipleInUse,
18170
18194
  disambiguate: false
18171
18195
  };
18172
- possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
18196
+ possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
18173
18197
 
18174
- for (var x in kb.findMembersNT(from)) {
18198
+ for (var x in kb.findMembersNT(uiFrom)) {
18175
18199
  possible.push(kb.fromNT(x));
18176
18200
  } // Use rdfs
18177
18201
 
18178
18202
 
18179
- if (from.sameTerm(ns.rdfs('Class'))) {
18203
+ if (uiFrom.sameTerm(ns.rdfs('Class'))) {
18180
18204
  for (p in buttons.allClassURIs()) {
18181
18205
  possible.push(kb.sym(p));
18182
18206
  } // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
18183
18207
 
18184
- } else if (from.sameTerm(ns.rdf('Property'))) {
18208
+ } else if (uiFrom.sameTerm(ns.rdf('Property'))) {
18185
18209
  possibleProperties = buttons.propertyTriage(kb);
18186
18210
 
18187
18211
  for (p in possibleProperties.op) {
@@ -18193,7 +18217,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18193
18217
  }
18194
18218
 
18195
18219
  opts.disambiguate = true; // This is a big class, and the labels won't be enough.
18196
- } else if (from.sameTerm(ns.owl('ObjectProperty'))) {
18220
+ } else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
18197
18221
  possibleProperties = buttons.propertyTriage(kb);
18198
18222
 
18199
18223
  for (p in possibleProperties.op) {
@@ -18201,7 +18225,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18201
18225
  }
18202
18226
 
18203
18227
  opts.disambiguate = true;
18204
- } else if (from.sameTerm(ns.owl('DatatypeProperty'))) {
18228
+ } else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
18205
18229
  possibleProperties = buttons.propertyTriage(kb);
18206
18230
 
18207
18231
  for (p in possibleProperties.dp) {
@@ -18211,26 +18235,45 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
18211
18235
  opts.disambiguate = true;
18212
18236
  }
18213
18237
 
18214
- var object = kb.any(subject, property);
18238
+ var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurrence, regardless of true or false setting
18215
18239
 
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);
18240
+ if (kb.any(form, ui('canMintNew'))) {
18241
+ opts.mint = '* Create new *'; // @@ could be better
18219
18242
  }
18220
18243
 
18221
- var possible2 = sortByLabel(possible);
18244
+ var selector = makeSelectForOptions(dom, kb, subject, property, sortedPossible, uiFrom, opts, dataDoc, callbackFunction);
18245
+ rhs.appendChild(selector);
18246
+ var object;
18222
18247
 
18223
- if (kb.any(form, ui('canMintNew'))) {
18224
- opts.mint = '* New *'; // @@ could be better
18248
+ if (selector.currentURI) {
18249
+ object = $rdf.sym(selector.currentURI);
18250
+ } else {
18251
+ object = kb.any(subject, property);
18252
+ }
18225
18253
 
18226
- opts.subForm = subForm;
18254
+ if (object && subForm) {
18255
+ removeNextSiblingsAfterElement(selector);
18256
+ addSubFormChoice(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
18227
18257
  }
18228
18258
 
18229
- var selector = makeSelectForOptions(dom, kb, subject, property, possible2, opts, dataDoc, callbackFunction);
18230
- rhs.appendChild(selector);
18231
- if (object && subForm) addSubForm();
18232
18259
  return box;
18233
- }; // Documentation - non-interactive fields
18260
+ };
18261
+ /**
18262
+ * Removes all sibling elements after specified
18263
+ * @param {HTMLElement} currentElement
18264
+ * @private
18265
+ */
18266
+
18267
+
18268
+ function removeNextSiblingsAfterElement(currentElement) {
18269
+ while (currentElement.nextElementSibling) {
18270
+ currentElement.nextElementSibling.remove();
18271
+ }
18272
+ }
18273
+
18274
+ function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
18275
+ (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
18276
+ } // Documentation - non-interactive fields
18234
18277
  //
18235
18278
 
18236
18279
 
@@ -18568,9 +18611,10 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
18568
18611
  // @param subject - a term, the subject of the statement(s) being edited.
18569
18612
  // @param predicate - a term, the predicate of the statement(s) being edited
18570
18613
  // @param possible - a list of terms, the possible value the object can take
18571
- // @param options.multiple - Boolean - Whether more than one at a time is allowed
18572
- // @param options.nullLabel - a string to be displayed as the
18573
- // option for none selected (for non multiple)
18614
+ // @param options.multiSelect - Boolean - Whether more than one at a time is allowed
18615
+ // @param options.firstSelectOptionText - a string to be displayed as the
18616
+ // option for none selected (for non multiSelect)
18617
+ // @param options.uiMultipleInUse - signals that the ui:choise is used with a ui:multiple
18574
18618
  // @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
18575
18619
  // @param options.subForm - If mint, then the form to be used for minting the new thing
18576
18620
  // @param dataDoc - The web document being edited
@@ -18578,7 +18622,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
18578
18622
  */
18579
18623
 
18580
18624
 
18581
- function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
18625
+ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
18582
18626
  log.debug('Select list length now ' + possible.length);
18583
18627
  var n = 0;
18584
18628
  var uris = {}; // Count them
@@ -18609,7 +18653,9 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18609
18653
  actual = kb.findTypeURIs(subject);
18610
18654
  } else {
18611
18655
  kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
18612
- actual[x.uri] = true;
18656
+ if (x.uri) {
18657
+ actual[x.uri] = true;
18658
+ }
18613
18659
  });
18614
18660
  }
18615
18661
 
@@ -18619,8 +18665,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18619
18665
  actual = getActual();
18620
18666
 
18621
18667
  var onChange = function onChange(_e) {
18622
- select.disabled = true; // until data written back - gives user feedback too
18623
-
18624
18668
  var ds = [];
18625
18669
  var is = [];
18626
18670
 
@@ -18636,6 +18680,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18636
18680
  var opt = select.options[_i];
18637
18681
 
18638
18682
  if (opt.selected && opt.AJAR_mint) {
18683
+ // not sure if this 'if' is used because I cannot find mintClass
18639
18684
  if (options.mintClass) {
18640
18685
  var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
18641
18686
  if (!ok) {
@@ -18650,11 +18695,14 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18650
18695
  newObject = newThing(dataDoc);
18651
18696
  }
18652
18697
 
18653
- is.push($rdf.st(subject, predicate, newObject, dataDoc));
18698
+ is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
18699
+ 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
18700
 
18655
18701
  if (options.mintStatementsFun) {
18656
18702
  is = is.concat(options.mintStatementsFun(newObject));
18657
18703
  }
18704
+
18705
+ select.currentURI = newObject;
18658
18706
  }
18659
18707
 
18660
18708
  if (!opt.AJAR_uri) continue; // a prompt or mint
@@ -18662,11 +18710,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18662
18710
  if (opt.selected && !(opt.AJAR_uri in actual)) {
18663
18711
  // new class
18664
18712
  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));
18713
+ select.currentURI = opt.AJAR_uri;
18670
18714
  }
18671
18715
 
18672
18716
  if (opt.selected) select.currentURI = opt.AJAR_uri;
@@ -18686,38 +18730,29 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18686
18730
  sel = sel.superSelect;
18687
18731
  }
18688
18732
 
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
18733
+ log.info('selectForOptions: data doc = ' + dataDoc); // refresh subForm
18699
18734
 
18735
+ removeNextSiblingsAfterElement(select);
18736
+ addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
18700
18737
  if (ok) {
18701
- select.disabled = false; // data written back
18738
+ kb.updater.update(ds, is, function (uri, success, errorBody) {
18739
+ actual = getActual(); // refresh
18702
18740
 
18703
- if (newObject) {
18704
- var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
18705
- fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
18706
- }
18741
+ if (!success) select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating select: ' + errorBody));
18742
+ });
18743
+ if (callbackFunction) callbackFunction(ok, {
18744
+ widget: 'select',
18745
+ event: 'new'
18746
+ });
18707
18747
  } else {
18708
- return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
18748
+ select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
18709
18749
  }
18710
-
18711
- if (callbackFunction) callbackFunction(ok, {
18712
- widget: 'select',
18713
- event: 'change'
18714
- });
18715
18750
  });
18716
18751
  };
18717
18752
 
18718
18753
  var select = dom.createElement('select');
18719
18754
  select.setAttribute('style', style.formSelectSTyle);
18720
- if (options.multiple) select.setAttribute('multiple', 'true');
18755
+ if (options.multiSelect) select.setAttribute('multiSelect', 'true');
18721
18756
  select.currentURI = null;
18722
18757
 
18723
18758
  select.refresh = function () {
@@ -18768,11 +18803,14 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18768
18803
  select.insertBefore(mint, select.firstChild);
18769
18804
  }
18770
18805
 
18771
- if (select.currentURI == null && !options.multiple) {
18806
+ if (!select.currentURI && options.uiMultipleInUse) {
18772
18807
  var prompt = dom.createElement('option');
18773
- prompt.appendChild(dom.createTextNode(options.nullLabel));
18774
- select.insertBefore(prompt, select.firstChild);
18808
+ prompt.appendChild(dom.createTextNode(options.firstSelectOptionText));
18809
+ prompt.disabled = true;
18810
+ prompt.value = true;
18811
+ prompt.hidden = true;
18775
18812
  prompt.selected = true;
18813
+ select.insertBefore(prompt, select.firstChild);
18776
18814
  }
18777
18815
 
18778
18816
  if (editable) {
@@ -18791,11 +18829,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, da
18791
18829
  function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunction) {
18792
18830
  var du = kb.any(category, ns.owl('disjointUnionOf'));
18793
18831
  var subs;
18794
- var multiple = false;
18832
+ var multiSelect = false;
18795
18833
 
18796
18834
  if (!du) {
18797
18835
  subs = kb.each(undefined, ns.rdfs('subClassOf'), category);
18798
- multiple = true;
18836
+ multiSelect = true;
18799
18837
  } else {
18800
18838
  subs = du.elements;
18801
18839
  }
@@ -18803,16 +18841,15 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
18803
18841
  log.debug('Select list length ' + subs.length);
18804
18842
 
18805
18843
  if (subs.length === 0) {
18806
- return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
18844
+ return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiSelect ? 'multiple ' : '') + 'selector with no subclasses of category: ' + category);
18807
18845
  }
18808
18846
 
18809
18847
  if (subs.length === 1) {
18810
- return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
18848
+ return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiSelect ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
18811
18849
  }
18812
18850
 
18813
- return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
18814
- multiple: multiple,
18815
- nullPrompt: '--classify--'
18851
+ return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
18852
+ multiSelect: multiSelect
18816
18853
  }, dataDoc, callbackFunction);
18817
18854
  }
18818
18855
  /** Make SELECT element to select subclasses recurively