solid-ui 2.4.22-349966b9 → 2.4.22-4e7a23dc
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 +68 -87
- package/dist/main.js.map +1 -1
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/forms.js +66 -85
- package/lib/widgets/forms.js.map +1 -1
- package/package.json +1 -1
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-
|
|
15196
|
-
commit: '
|
|
15195
|
+
buildTime: '2022-05-09T08:12:16Z',
|
|
15196
|
+
commit: '4e7a23dcab0793bde0b5d0affdfbbdd8124bd0ea',
|
|
15197
15197
|
npmInfo: {
|
|
15198
15198
|
'solid-ui': '2.4.22',
|
|
15199
15199
|
npm: '6.14.16',
|
|
@@ -18120,14 +18120,6 @@ _fieldFunction.field[ns.ui('Classifier').uri] = function (dom, container, alread
|
|
|
18120
18120
|
**
|
|
18121
18121
|
** Not nested. Generates a link to something from a given class.
|
|
18122
18122
|
** Optional subform for the thing selected.
|
|
18123
|
-
** Generates a subForm based on a ui:use form
|
|
18124
|
-
** Will look like:
|
|
18125
|
-
** <div id=dropDownDiv>
|
|
18126
|
-
** <div id=labelOfDropDown>
|
|
18127
|
-
** <div id=selectDiv>
|
|
18128
|
-
** <select id=dropDownSelect>
|
|
18129
|
-
** <option> ....
|
|
18130
|
-
** <subForm>
|
|
18131
18123
|
** Alternative implementatons caould be:
|
|
18132
18124
|
** -- pop-up menu (as here)
|
|
18133
18125
|
** -- radio buttons
|
|
@@ -18158,39 +18150,38 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18158
18150
|
}
|
|
18159
18151
|
|
|
18160
18152
|
lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
|
|
18153
|
+
var from = kb.any(form, ui('from'));
|
|
18154
|
+
|
|
18155
|
+
if (!from) {
|
|
18156
|
+
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
18157
|
+
}
|
|
18158
|
+
|
|
18161
18159
|
var subForm = kb.any(form, ui('use')); // Optional
|
|
18162
18160
|
|
|
18163
18161
|
var follow = kb.anyJS(form, ui('follow'), null, formDoc); // data doc moves to new subject?
|
|
18164
18162
|
|
|
18165
18163
|
var possible = [];
|
|
18166
18164
|
var possibleProperties;
|
|
18167
|
-
var
|
|
18165
|
+
var nullLabel = '--' + utils.label(property) + '-?';
|
|
18168
18166
|
var opts = {
|
|
18169
18167
|
form: form,
|
|
18170
|
-
subForm: subForm,
|
|
18171
18168
|
multiple: multiple,
|
|
18172
|
-
|
|
18169
|
+
nullLabel: nullLabel,
|
|
18173
18170
|
disambiguate: false
|
|
18174
18171
|
};
|
|
18175
|
-
|
|
18176
|
-
|
|
18177
|
-
if (!uiFrom) {
|
|
18178
|
-
return (0, _error.errorMessageBlock)(dom, "No 'from' for Choice: " + form);
|
|
18179
|
-
}
|
|
18180
|
-
|
|
18181
|
-
possible = kb.each(undefined, ns.rdf('type'), uiFrom, formDoc);
|
|
18172
|
+
possible = kb.each(undefined, ns.rdf('type'), from, formDoc);
|
|
18182
18173
|
|
|
18183
|
-
for (var x in kb.findMembersNT(
|
|
18174
|
+
for (var x in kb.findMembersNT(from)) {
|
|
18184
18175
|
possible.push(kb.fromNT(x));
|
|
18185
18176
|
} // Use rdfs
|
|
18186
18177
|
|
|
18187
18178
|
|
|
18188
|
-
if (
|
|
18179
|
+
if (from.sameTerm(ns.rdfs('Class'))) {
|
|
18189
18180
|
for (p in buttons.allClassURIs()) {
|
|
18190
18181
|
possible.push(kb.sym(p));
|
|
18191
18182
|
} // log.debug("%%% Choice field: possible.length 2 = "+possible.length)
|
|
18192
18183
|
|
|
18193
|
-
} else if (
|
|
18184
|
+
} else if (from.sameTerm(ns.rdf('Property'))) {
|
|
18194
18185
|
possibleProperties = buttons.propertyTriage(kb);
|
|
18195
18186
|
|
|
18196
18187
|
for (p in possibleProperties.op) {
|
|
@@ -18202,7 +18193,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18202
18193
|
}
|
|
18203
18194
|
|
|
18204
18195
|
opts.disambiguate = true; // This is a big class, and the labels won't be enough.
|
|
18205
|
-
} else if (
|
|
18196
|
+
} else if (from.sameTerm(ns.owl('ObjectProperty'))) {
|
|
18206
18197
|
possibleProperties = buttons.propertyTriage(kb);
|
|
18207
18198
|
|
|
18208
18199
|
for (p in possibleProperties.op) {
|
|
@@ -18210,7 +18201,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18210
18201
|
}
|
|
18211
18202
|
|
|
18212
18203
|
opts.disambiguate = true;
|
|
18213
|
-
} else if (
|
|
18204
|
+
} else if (from.sameTerm(ns.owl('DatatypeProperty'))) {
|
|
18214
18205
|
possibleProperties = buttons.propertyTriage(kb);
|
|
18215
18206
|
|
|
18216
18207
|
for (p in possibleProperties.dp) {
|
|
@@ -18220,45 +18211,26 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
|
|
|
18220
18211
|
opts.disambiguate = true;
|
|
18221
18212
|
}
|
|
18222
18213
|
|
|
18223
|
-
var
|
|
18224
|
-
|
|
18225
|
-
if (kb.any(form, ui('canMintNew'))) {
|
|
18226
|
-
opts.mint = '* Create new *'; // @@ could be better
|
|
18227
|
-
}
|
|
18214
|
+
var object = kb.any(subject, property);
|
|
18228
18215
|
|
|
18229
|
-
|
|
18230
|
-
rhs.appendChild(selector);
|
|
18231
|
-
var object;
|
|
18232
|
-
|
|
18233
|
-
if (selector.currentURI) {
|
|
18234
|
-
object = $rdf.sym(selector.currentURI);
|
|
18235
|
-
} else {
|
|
18216
|
+
function addSubForm() {
|
|
18236
18217
|
object = kb.any(subject, property);
|
|
18218
|
+
(0, _fieldFunction.fieldFunction)(dom, subForm)(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
|
|
18237
18219
|
}
|
|
18238
18220
|
|
|
18239
|
-
|
|
18240
|
-
removeNextSiblingsAfterElement(selector);
|
|
18241
|
-
addSubFormChoice(dom, rhs, already, object, subForm, follow ? object.doc() : dataDoc, callbackFunction);
|
|
18242
|
-
}
|
|
18243
|
-
|
|
18244
|
-
return box;
|
|
18245
|
-
};
|
|
18246
|
-
/**
|
|
18247
|
-
* Removes all sibling elements after specified
|
|
18248
|
-
* @param {HTMLElement} currentElement
|
|
18249
|
-
* @private
|
|
18250
|
-
*/
|
|
18221
|
+
var possible2 = sortByLabel(possible);
|
|
18251
18222
|
|
|
18223
|
+
if (kb.any(form, ui('canMintNew'))) {
|
|
18224
|
+
opts.mint = '* New *'; // @@ could be better
|
|
18252
18225
|
|
|
18253
|
-
|
|
18254
|
-
while (currentElement.nextElementSibling) {
|
|
18255
|
-
currentElement.nextElementSibling.remove();
|
|
18226
|
+
opts.subForm = subForm;
|
|
18256
18227
|
}
|
|
18257
|
-
}
|
|
18258
18228
|
|
|
18259
|
-
|
|
18260
|
-
|
|
18261
|
-
|
|
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
|
|
18262
18234
|
//
|
|
18263
18235
|
|
|
18264
18236
|
|
|
@@ -18597,7 +18569,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
18597
18569
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
18598
18570
|
// @param possible - a list of terms, the possible value the object can take
|
|
18599
18571
|
// @param options.multiple - Boolean - Whether more than one at a time is allowed
|
|
18600
|
-
// @param options.
|
|
18572
|
+
// @param options.nullLabel - a string to be displayed as the
|
|
18601
18573
|
// option for none selected (for non multiple)
|
|
18602
18574
|
// @param options.mint - User may create thing if this sent to the prompt string eg "New foo"
|
|
18603
18575
|
// @param options.subForm - If mint, then the form to be used for minting the new thing
|
|
@@ -18606,7 +18578,7 @@ function makeDescription(dom, kb, subject, predicate, dataDoc, callbackFunction)
|
|
|
18606
18578
|
*/
|
|
18607
18579
|
|
|
18608
18580
|
|
|
18609
|
-
function makeSelectForOptions(dom, kb, subject, predicate, possible,
|
|
18581
|
+
function makeSelectForOptions(dom, kb, subject, predicate, possible, options, dataDoc, callbackFunction) {
|
|
18610
18582
|
log.debug('Select list length now ' + possible.length);
|
|
18611
18583
|
var n = 0;
|
|
18612
18584
|
var uris = {}; // Count them
|
|
@@ -18637,9 +18609,7 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18637
18609
|
actual = kb.findTypeURIs(subject);
|
|
18638
18610
|
} else {
|
|
18639
18611
|
kb.each(subject, predicate, null, dataDoc).forEach(function (x) {
|
|
18640
|
-
|
|
18641
|
-
actual[x.uri] = true;
|
|
18642
|
-
}
|
|
18612
|
+
actual[x.uri] = true;
|
|
18643
18613
|
});
|
|
18644
18614
|
}
|
|
18645
18615
|
|
|
@@ -18649,6 +18619,8 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18649
18619
|
actual = getActual();
|
|
18650
18620
|
|
|
18651
18621
|
var onChange = function onChange(_e) {
|
|
18622
|
+
select.disabled = true; // until data written back - gives user feedback too
|
|
18623
|
+
|
|
18652
18624
|
var ds = [];
|
|
18653
18625
|
var is = [];
|
|
18654
18626
|
|
|
@@ -18664,7 +18636,6 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18664
18636
|
var opt = select.options[_i];
|
|
18665
18637
|
|
|
18666
18638
|
if (opt.selected && opt.AJAR_mint) {
|
|
18667
|
-
// not sure if this if is used because I cannot find mintClass
|
|
18668
18639
|
if (options.mintClass) {
|
|
18669
18640
|
var thisForm = promptForNew(dom, kb, subject, predicate, options.mintClass, null, dataDoc, function (ok, body) {
|
|
18670
18641
|
if (!ok) {
|
|
@@ -18679,14 +18650,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18679
18650
|
newObject = newThing(dataDoc);
|
|
18680
18651
|
}
|
|
18681
18652
|
|
|
18682
|
-
is.push($rdf.st(subject, predicate,
|
|
18683
|
-
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
|
|
18653
|
+
is.push($rdf.st(subject, predicate, newObject, dataDoc));
|
|
18684
18654
|
|
|
18685
18655
|
if (options.mintStatementsFun) {
|
|
18686
18656
|
is = is.concat(options.mintStatementsFun(newObject));
|
|
18687
18657
|
}
|
|
18688
|
-
|
|
18689
|
-
select.currentURI = newObject;
|
|
18690
18658
|
}
|
|
18691
18659
|
|
|
18692
18660
|
if (!opt.AJAR_uri) continue; // a prompt or mint
|
|
@@ -18694,7 +18662,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18694
18662
|
if (opt.selected && !(opt.AJAR_uri in actual)) {
|
|
18695
18663
|
// new class
|
|
18696
18664
|
is.push($rdf.st(subject, predicate, kb.sym(opt.AJAR_uri), dataDoc));
|
|
18697
|
-
|
|
18665
|
+
}
|
|
18666
|
+
|
|
18667
|
+
if (!opt.selected && opt.AJAR_uri in actual) {
|
|
18668
|
+
// old class
|
|
18669
|
+
removeValue(kb.sym(opt.AJAR_uri));
|
|
18698
18670
|
}
|
|
18699
18671
|
|
|
18700
18672
|
if (opt.selected) select.currentURI = opt.AJAR_uri;
|
|
@@ -18714,21 +18686,32 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18714
18686
|
sel = sel.superSelect;
|
|
18715
18687
|
}
|
|
18716
18688
|
|
|
18717
|
-
|
|
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
|
|
18718
18699
|
|
|
18719
|
-
removeNextSiblingsAfterElement(select);
|
|
18720
|
-
addSubFormChoice(dom, select.parentNode, {}, $rdf.sym(select.currentURI), options.subForm, dataDoc, function (ok, body) {
|
|
18721
18700
|
if (ok) {
|
|
18722
|
-
|
|
18723
|
-
actual = getActual(); // refresh
|
|
18701
|
+
select.disabled = false; // data written back
|
|
18724
18702
|
|
|
18725
|
-
|
|
18726
|
-
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
|
|
18731
|
-
}
|
|
18703
|
+
if (newObject) {
|
|
18704
|
+
var fn = (0, _fieldFunction.fieldFunction)(dom, options.subForm);
|
|
18705
|
+
fn(dom, select.parentNode, {}, newObject, options.subForm, dataDoc, doneNew);
|
|
18706
|
+
}
|
|
18707
|
+
} else {
|
|
18708
|
+
return select.parentNode.appendChild((0, _error.errorMessageBlock)(dom, 'Error updating data in select: ' + body));
|
|
18709
|
+
}
|
|
18710
|
+
|
|
18711
|
+
if (callbackFunction) callbackFunction(ok, {
|
|
18712
|
+
widget: 'select',
|
|
18713
|
+
event: 'change'
|
|
18714
|
+
});
|
|
18732
18715
|
});
|
|
18733
18716
|
};
|
|
18734
18717
|
|
|
@@ -18785,14 +18768,11 @@ function makeSelectForOptions(dom, kb, subject, predicate, possible, uiFrom, opt
|
|
|
18785
18768
|
select.insertBefore(mint, select.firstChild);
|
|
18786
18769
|
}
|
|
18787
18770
|
|
|
18788
|
-
if (
|
|
18771
|
+
if (select.currentURI == null && !options.multiple) {
|
|
18789
18772
|
var prompt = dom.createElement('option');
|
|
18790
|
-
prompt.appendChild(dom.createTextNode(options.
|
|
18791
|
-
prompt.selected = true;
|
|
18792
|
-
prompt.disabled = true;
|
|
18793
|
-
prompt.value = true;
|
|
18794
|
-
prompt.hidden = true;
|
|
18773
|
+
prompt.appendChild(dom.createTextNode(options.nullLabel));
|
|
18795
18774
|
select.insertBefore(prompt, select.firstChild);
|
|
18775
|
+
prompt.selected = true;
|
|
18796
18776
|
}
|
|
18797
18777
|
|
|
18798
18778
|
if (editable) {
|
|
@@ -18830,8 +18810,9 @@ function makeSelectForCategory(dom, kb, subject, category, dataDoc, callbackFunc
|
|
|
18830
18810
|
return (0, _error.errorMessageBlock)(dom, "Can't do " + (multiple ? 'multiple ' : '') + 'selector with only 1 subclass of category: ' + category + ':' + subs[1]);
|
|
18831
18811
|
}
|
|
18832
18812
|
|
|
18833
|
-
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs,
|
|
18834
|
-
multiple: multiple
|
|
18813
|
+
return makeSelectForOptions(dom, kb, subject, ns.rdf('type'), subs, {
|
|
18814
|
+
multiple: multiple,
|
|
18815
|
+
nullPrompt: '--classify--'
|
|
18835
18816
|
}, dataDoc, callbackFunction);
|
|
18836
18817
|
}
|
|
18837
18818
|
/** Make SELECT element to select subclasses recurively
|