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