solid-ui 2.4.22-2b59ecec → 2.4.22-3f0c7b9d

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.
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.versionInfo = void 0;
7
7
  var versionInfo = {
8
- buildTime: '2022-05-06T18:28:57Z',
9
- commit: '2b59ececdbeff0b9fc6c2b0710d65711cb6fce3b',
8
+ buildTime: '2022-05-09T08:10:27Z',
9
+ commit: '3f0c7b9db840ec851709d06a51a606851115ccf1',
10
10
  npmInfo: {
11
11
  'solid-ui': '2.4.22',
12
12
  npm: '6.14.16',
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/versionInfo.ts"],"names":["versionInfo","buildTime","commit","npmInfo","npm","ares","brotli","cldr","icu","llhttp","modules","napi","nghttp2","node","openssl","tz","unicode","uv","v8","zlib"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,SAAS,EAAE,sBADc;AAEzBC,EAAAA,MAAM,EAAE,0CAFiB;AAGzBC,EAAAA,OAAO,EACT;AACE,gBAAY,QADd;AAEEC,IAAAA,GAAG,EAAE,SAFP;AAGEC,IAAAA,IAAI,EAAE,QAHR;AAIEC,IAAAA,MAAM,EAAE,OAJV;AAKEC,IAAAA,IAAI,EAAE,MALR;AAMEC,IAAAA,GAAG,EAAE,MANP;AAOEC,IAAAA,MAAM,EAAE,OAPV;AAQEC,IAAAA,OAAO,EAAE,IARX;AASEC,IAAAA,IAAI,EAAE,GATR;AAUEC,IAAAA,OAAO,EAAE,QAVX;AAWEC,IAAAA,IAAI,EAAE,SAXR;AAYEC,IAAAA,OAAO,EAAE,QAZX;AAaEC,IAAAA,EAAE,EAAE,QAbN;AAcEC,IAAAA,OAAO,EAAE,MAdX;AAeEC,IAAAA,EAAE,EAAE,QAfN;AAgBEC,IAAAA,EAAE,EAAE,oBAhBN;AAiBEC,IAAAA,IAAI,EAAE;AAjBR;AAJ2B,CAApB","sourcesContent":["export const versionInfo = {\n buildTime: '2022-05-06T18:28:57Z',\n commit: '2b59ececdbeff0b9fc6c2b0710d65711cb6fce3b',\n npmInfo:\n{\n 'solid-ui': '2.4.22',\n npm: '6.14.16',\n ares: '1.18.1',\n brotli: '1.0.9',\n cldr: '40.0',\n icu: '70.1',\n llhttp: '2.1.4',\n modules: '83',\n napi: '8',\n nghttp2: '1.42.0',\n node: '14.19.1',\n openssl: '1.1.1n',\n tz: '2021a3',\n unicode: '14.0',\n uv: '1.42.0',\n v8: '8.4.371.23-node.85',\n zlib: '1.2.11'\n}\n}\n"],"file":"versionInfo.js"}
1
+ {"version":3,"sources":["../src/versionInfo.ts"],"names":["versionInfo","buildTime","commit","npmInfo","npm","ares","brotli","cldr","icu","llhttp","modules","napi","nghttp2","node","openssl","tz","unicode","uv","v8","zlib"],"mappings":";;;;;;AAAO,IAAMA,WAAW,GAAG;AACzBC,EAAAA,SAAS,EAAE,sBADc;AAEzBC,EAAAA,MAAM,EAAE,0CAFiB;AAGzBC,EAAAA,OAAO,EACT;AACE,gBAAY,QADd;AAEEC,IAAAA,GAAG,EAAE,SAFP;AAGEC,IAAAA,IAAI,EAAE,QAHR;AAIEC,IAAAA,MAAM,EAAE,OAJV;AAKEC,IAAAA,IAAI,EAAE,MALR;AAMEC,IAAAA,GAAG,EAAE,MANP;AAOEC,IAAAA,MAAM,EAAE,OAPV;AAQEC,IAAAA,OAAO,EAAE,IARX;AASEC,IAAAA,IAAI,EAAE,GATR;AAUEC,IAAAA,OAAO,EAAE,QAVX;AAWEC,IAAAA,IAAI,EAAE,SAXR;AAYEC,IAAAA,OAAO,EAAE,QAZX;AAaEC,IAAAA,EAAE,EAAE,QAbN;AAcEC,IAAAA,OAAO,EAAE,MAdX;AAeEC,IAAAA,EAAE,EAAE,QAfN;AAgBEC,IAAAA,EAAE,EAAE,oBAhBN;AAiBEC,IAAAA,IAAI,EAAE;AAjBR;AAJ2B,CAApB","sourcesContent":["export const versionInfo = {\n buildTime: '2022-05-09T08:10:27Z',\n commit: '3f0c7b9db840ec851709d06a51a606851115ccf1',\n npmInfo:\n{\n 'solid-ui': '2.4.22',\n npm: '6.14.16',\n ares: '1.18.1',\n brotli: '1.0.9',\n cldr: '40.0',\n icu: '70.1',\n llhttp: '2.1.4',\n modules: '83',\n napi: '8',\n nghttp2: '1.42.0',\n node: '14.19.1',\n openssl: '1.1.1n',\n tz: '2021a3',\n unicode: '14.0',\n uv: '1.42.0',\n v8: '8.4.371.23-node.85',\n zlib: '1.2.11'\n}\n}\n"],"file":"versionInfo.js"}
@@ -1017,14 +1017,6 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
1017
1017
  **
1018
1018
  ** Not nested. Generates a link to something from a given class.
1019
1019
  ** Optional subform for the thing selected.
1020
- ** Generates a subForm based on a ui:use form
1021
- ** Will look like:
1022
- ** <div id=dropDownDiv>
1023
- ** <div id=labelOfDropDown>
1024
- ** <div id=selectDiv>
1025
- ** <select id=dropDownSelect>
1026
- ** <option> ....
1027
- ** <subForm>
1028
1020
  ** Alternative implementatons caould be:
1029
1021
  ** -- pop-up menu (as here)
1030
1022
  ** -- radio buttons
@@ -1055,39 +1047,38 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1055
1047
  }
1056
1048
 
1057
1049
  lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
1050
+ var from = kb.any(form, ui('from'));
1051
+
1052
+ if (!from) {
1053
+ return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
1054
+ }
1055
+
1058
1056
  var subForm = kb.any(form, ui('use')); // Optional
1059
1057
 
1060
1058
  var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
1061
1059
 
1062
1060
  var possible = [];
1063
1061
  var possibleProperties;
1064
- var firstSelectOptionText = '* Select from ' + utils.label(subject, true) + ' *';
1062
+ var nullLabel = '--' + utils.label(property) + '-?';
1065
1063
  var opts = {
1066
1064
  form: form,
1067
- subForm: subForm,
1068
1065
  multiple: multiple,
1069
- firstSelectOptionText: firstSelectOptionText,
1066
+ nullLabel: nullLabel,
1070
1067
  disambiguate: false
1071
1068
  };
1072
- var uiFrom = kb.any(form, ui('from'));
1069
+ possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
1073
1070
 
1074
- if (!uiFrom) {
1075
- return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
1076
- }
1077
-
1078
- possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
1079
-
1080
- for (var x in kb.findMembersNT(uiFrom)) {
1071
+ for (var x in kb.findMembersNT(from)) {
1081
1072
  possible.push(kb.fromNT(x));
1082
1073
  } // Use rdfs
1083
1074
 
1084
1075
 
1085
- if (uiFrom.sameTerm(ns.rdfs('Class'))) {
1076
+ if (from.sameTerm(ns.rdfs('Class'))) {
1086
1077
  for (p in buttons.allClassURIs()) {
1087
1078
  possible.push(kb.sym(p));
1088
1079
  } // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
1089
1080
 
1090
- } else if (uiFrom.sameTerm(ns.rdf('Property'))) {
1081
+ } else if (from.sameTerm(ns.rdf('Property'))) {
1091
1082
  possibleProperties = buttons.propertyTriage(kb);
1092
1083
 
1093
1084
  for (p in possibleProperties.op) {
@@ -1099,7 +1090,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1099
1090
  }
1100
1091
 
1101
1092
  opts.disambiguate = true; // This is a big class, and the labels won't be enough.
1102
- } else if (uiFrom.sameTerm(ns.owl('ObjectProperty'))) {
1093
+ } else if (from.sameTerm(ns.owl('ObjectProperty'))) {
1103
1094
  possibleProperties = buttons.propertyTriage(kb);
1104
1095
 
1105
1096
  for (p in possibleProperties.op) {
@@ -1107,7 +1098,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1107
1098
  }
1108
1099
 
1109
1100
  opts.disambiguate = true;
1110
- } else if (uiFrom.sameTerm(ns.owl('DatatypeProperty'))) {
1101
+ } else if (from.sameTerm(ns.owl('DatatypeProperty'))) {
1111
1102
  possibleProperties = buttons.propertyTriage(kb);
1112
1103
 
1113
1104
  for (p in possibleProperties.dp) {
@@ -1117,45 +1108,26 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1117
1108
  opts.disambiguate = true;
1118
1109
  }
1119
1110
 
1120
- var sortedPossible = sortByLabel(possible); // TODO: this checks for any occurance regardles if it is set to true or false
1121
-
1122
- if (kb.any(form, ui('canMintNew'))) {
1123
- opts.mint = '* Create new *'; // @@ could be better
1124
- }
1111
+ var object = kb.any(subject, property);
1125
1112
 
1126
- var selector = makeSelectForOptions(dom, kb, subject, property, sortedPossible, uiFrom, opts, dataDoc, callbackFunction);
1127
- rhs.appendChild(selector);
1128
- var object;
1129
-
1130
- if (selector.currentURI) {
1131
- object = $rdf.sym(selector.currentURI);
1132
- } else {
1113
+ function addSubForm() {
1133
1114
  object = kb.any(subject, property);
1115
+ (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
1134
1116
  }
1135
1117
 
1136
- if (object && subForm) {
1137
- removeNextSiblingsAfterElement(selector);
1138
- addSubFormChoice(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
1139
- }
1140
-
1141
- return box;
1142
- };
1143
- /**
1144
- * Removes all sibling elements after specified
1145
- * @param {HTMLElement} currentElement
1146
- * @private
1147
- */
1118
+ var possible2 = sortByLabel(possible);
1148
1119
 
1120
+ if (kb.any(form, ui('canMintNew'))) {
1121
+ opts.mint = '* New *'; // @@ could be better
1149
1122
 
1150
- function removeNextSiblingsAfterElement(currentElement) {
1151
- while (currentElement.nextElementSibling) {
1152
- currentElement.nextElementSibling.remove();
1123
+ opts.subForm = subForm;
1153
1124
  }
1154
- }
1155
1125
 
1156
- function addSubFormChoice(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction) {
1157
- (0, _fieldFunction.fieldFunction)(dom, subForm)(dom, selectDiv, already, subject, subForm, dataDoc, callbackFunction);
1158
- } // Documentation - non-interactive fields
1126
+ var selector = makeSelectForOptions(dom, kb, subject, property, possible2, opts, dataDoc, callbackFunction);
1127
+ rhs.appendChild(selector);
1128
+ if (object && subForm) addSubForm();
1129
+ return box;
1130
+ }; // Documentation - non-interactive fields
1159
1131
  //
1160
1132
 
1161
1133
 
@@ -1494,7 +1466,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
1494
1466
  // @param predicate - a term, the predicate of the statement(s) being edited
1495
1467
  // @param possible - a list of terms, the possible value the object can take
1496
1468
  // @param options.multiple - Boolean - Whether more than one at a time is allowed
1497
- // @param options.firstSelectOptionText - a string to be displayed as the
1469
+ // @param options.nullLabel - a string to be displayed as the
1498
1470
  // option for none selected (for non multiple)
1499
1471
  // @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
1500
1472
  // @param options.subForm - If mint, then the form to be used for minting the new thing
@@ -1503,7 +1475,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
1503
1475
  */
1504
1476
 
1505
1477
 
1506
- function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, options, dataDoc, callbackFunction) {
1478
+ function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
1507
1479
  log.debug('Select list length now ' + possible.length);
1508
1480
  var n = 0;
1509
1481
  var uris = {}; // Count them
@@ -1534,9 +1506,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1534
1506
  actual = kb.findTypeURIs(subject);
1535
1507
  } else {
1536
1508
  kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
1537
- if (x.uri) {
1538
- actual[x.uri] = true;
1539
- }
1509
+ actual[x.uri] = true;
1540
1510
  });
1541
1511
  }
1542
1512
 
@@ -1546,6 +1516,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1546
1516
  actual = getActual();
1547
1517
 
1548
1518
  var onChange = function onChange(_e) {
1519
+ select.disabled = true; // until data written back - gives user feedback too
1520
+
1549
1521
  var ds = [];
1550
1522
  var is = [];
1551
1523
 
@@ -1561,7 +1533,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1561
1533
  var opt = select.options[_i];
1562
1534
 
1563
1535
  if (opt.selected && opt.AJAR_mint) {
1564
- // not sure if this if is used because I cannot find mintClass
1565
1536
  if (options.mintClass) {
1566
1537
  var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
1567
1538
  if (!ok) {
@@ -1576,14 +1547,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1576
1547
  newObject = newThing(dataDoc);
1577
1548
  }
1578
1549
 
1579
- is.push($rdf.st(subject, predicate, kb.sym(newObject), dataDoc));
1580
- 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
1550
+ is.push($rdf.st(subject, predicate, newObject, dataDoc));
1581
1551
 
1582
1552
  if (options.mintStatementsFun) {
1583
1553
  is = is.concat(options.mintStatementsFun(newObject));
1584
1554
  }
1585
-
1586
- select.currentURI = newObject;
1587
1555
  }
1588
1556
 
1589
1557
  if (!opt.AJAR_uri) continue; // a prompt or mint
@@ -1591,7 +1559,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1591
1559
  if (opt.selected && !(opt.AJAR_uri in actual)) {
1592
1560
  // new class
1593
1561
  is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
1594
- select.currentURI = opt.AJAR_uri;
1562
+ }
1563
+
1564
+ if (!opt.selected && opt.AJAR_uri in actual) {
1565
+ // old class
1566
+ removeValue(kb.sym(opt.AJAR_uri));
1595
1567
  }
1596
1568
 
1597
1569
  if (opt.selected) select.currentURI = opt.AJAR_uri;
@@ -1611,21 +1583,32 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1611
1583
  sel = sel.superSelect;
1612
1584
  }
1613
1585
 
1614
- log.info('selectForOptions: data doc = ' + dataDoc); // refresh subForm
1586
+ function doneNew(ok, _body) {
1587
+ callbackFunction(ok, {
1588
+ widget: 'select',
1589
+ event: 'new'
1590
+ });
1591
+ }
1592
+
1593
+ log.info('selectForOptions: data doc = ' + dataDoc);
1594
+ kb.updater.update(ds, is, function (uri, ok, body) {
1595
+ actual = getActual(); // refresh
1615
1596
 
1616
- removeNextSiblingsAfterElement(select);
1617
- addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
1618
1597
  if (ok) {
1619
- kb.updater.update(ds, is, function (uri, success, errorBody) {
1620
- actual = getActual(); // refresh
1598
+ select.disabled = false; // data written back
1621
1599
 
1622
- if (!success) return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + errorBody));
1623
- if (callbackFunction) callbackFunction(success, {
1624
- widget: 'select',
1625
- event: 'new'
1626
- });
1627
- });
1628
- } else return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in field of select: ' + body));
1600
+ if (newObject) {
1601
+ var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
1602
+ fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
1603
+ }
1604
+ } else {
1605
+ return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
1606
+ }
1607
+
1608
+ if (callbackFunction) callbackFunction(ok, {
1609
+ widget: 'select',
1610
+ event: 'change'
1611
+ });
1629
1612
  });
1630
1613
  };
1631
1614
 
@@ -1682,14 +1665,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
1682
1665
  select.insertBefore(mint, select.firstChild);
1683
1666
  }
1684
1667
 
1685
- if (!select.currentURI && !options.multiple) {
1668
+ if (select.currentURI == null && !options.multiple) {
1686
1669
  var prompt = dom.createElement('option');
1687
- prompt.appendChild(dom.createTextNode(options.firstSelectOptionText));
1688
- prompt.selected = true;
1689
- prompt.disabled = true;
1690
- prompt.value = true;
1691
- prompt.hidden = true;
1670
+ prompt.appendChild(dom.createTextNode(options.nullLabel));
1692
1671
  select.insertBefore(prompt, select.firstChild);
1672
+ prompt.selected = true;
1693
1673
  }
1694
1674
 
1695
1675
  if (editable) {
@@ -1727,8 +1707,9 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
1727
1707
  return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
1728
1708
  }
1729
1709
 
1730
- return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, null, {
1731
- multiple: multiple
1710
+ return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
1711
+ multiple: multiple,
1712
+ nullPrompt: '--classify--'
1732
1713
  }, dataDoc, callbackFunction);
1733
1714
  }
1734
1715
  /** Make SELECT element to select subclasses recurively