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