solid-ui 2.4.18-c89d416d → 2.4.18-d0dfe92f

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.
@@ -1,5 +1,5 @@
1
1
  import { BlankNode, NamedNode, Node, Store, Variable } from 'rdflib';
2
- export declare function renderNameValuePair(dom: HTMLDocument, kb: Store, box: HTMLElement, form: NamedNode): HTMLElement;
2
+ export declare function renderNameValuePair(dom: HTMLDocument, kb: Store, box: HTMLElement, form: NamedNode, label?: string): HTMLElement;
3
3
  /**
4
4
  * Create an anchor element with a label as the anchor text.
5
5
  *
@@ -1 +1 @@
1
- {"version":3,"file":"basic.d.ts","sourceRoot":"","sources":["../../../src/widgets/forms/basic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,SAAS,EAAE,IAAI,EAAM,KAAK,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAA;AAajF,wBAAgB,mBAAmB,CAAE,GAAG,EAAE,YAAY,EAAE,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,GAAE,WAAW,CAkBhH;AAED;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CAAE,GAAG,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,GAAG,SAAS,EAAE,eAAe,EAAE,IAAI,GAAG,WAAW,GAAG,IAAI,CAYzH;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,UAAU,CAAE,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,EAAE,SAAS,EAAE,SAAS,GAAG,QAAQ,EAAE,GAAG,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAczJ;AAED;;;;;;;;;;;;;;;GAeG;AAEH,wBAAgB,UAAU,CACxB,GAAG,EAAE,YAAY,EACjB,SAAS,EAAE,WAAW,GAAG,SAAS,EAClC,OAAO,KAAA,EACP,OAAO,EAAE,SAAS,GAAG,SAAS,GAAG,QAA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ogic.solidLogicSingleton.store;
34
34
  /* Style and create a name, value pair
35
35
  */
36
36
 
37
- function renderNameValuePair(dom, kb, box, form) {
38
- var property = kb.any(form, ns.ui('property'));
37
+ function renderNameValuePair(dom, kb, box, form, label) {
38
+ // const property = kb.any(form, ns.ui('property'))
39
39
  box.style.display = 'flex';
40
40
  box.style.flexDirection = 'row';
41
41
  var lhs = box.appendChild(dom.createElement('div'));
@@ -45,12 +45,14 @@ function renderNameValuePair(dom, kb, box, form) {
45
45
  lhs.setAttribute('style', _style.formFieldNameBoxStyle);
46
46
  rhs.setAttribute('class', 'formFieldValue');
47
47
 
48
- if (!property) {
48
+ if (label) {
49
+ lhs.appendChild(dom.createTextNode(label));
50
+ } else if (kb.any(form, ns.ui('property'))) {
49
51
  // Assume more space for error on right
50
- rhs.appendChild((0, _error.errorMessageBlock)(dom, 'No property given for form field: ' + form));
51
- lhs.appendChild(dom.createTextNode('???'));
52
+ lhs.appendChild(fieldLabel(dom, kb.any(form, ns.ui('property')), form));
52
53
  } else {
53
- lhs.appendChild(fieldLabel(dom, property, form));
54
+ rhs.appendChild((0, _error.errorMessageBlock)(dom, 'No property or label given for form field: ' + form));
55
+ lhs.appendChild(dom.createTextNode('???'));
54
56
  }
55
57
 
56
58
  return rhs;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/widgets/forms/basic.ts"],"names":["store","solidLogicSingleton","renderNameValuePair","dom","kb","box","form","property","any","ns","ui","style","display","flexDirection","lhs","appendChild","createElement","width","formFieldNameBoxWidth","rhs","setAttribute","formFieldNameBoxStyle","createTextNode","fieldLabel","fieldInQuestion","lab","undefined","anchor","uri","textContent","fieldStore","subject","predicate","def","sts","statementsMatching","length","updater","Error","why","value","editable","sym","basicField","container","already","doc","callbackFunction","formDoc","suppressEmptyUneditable","anyJS","params","fieldParams","paramStyle","textInputStyle","field","type","size","textInputSize","maxLength","obj","uriPrefix","decodeURIComponent","replace","readOnly","textInputStyleUneditable","addEventListener","_e","pattern","match","disabled","ds","result","namedNode","encodeURIComponent","dt","Literal","trim","xsd","is","map","statement","updateMany","callback","docs","forEach","st","includes","push","update","pop","is1","filter","is2","ds1","ds2","ok","body"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,KAAK,GAAGC,gCAAoBD,KAAlC;AAEA;AACA;;AACO,SAASE,mBAAT,CAA8BC,GAA9B,EAAiDC,EAAjD,EAA4DC,GAA5D,EAA8EC,IAA9E,EAA2G;AAChH,MAAMC,QAAQ,GAAGH,EAAE,CAACI,GAAH,CAAOF,IAAP,EAAaG,EAAE,CAACC,EAAH,CAAM,UAAN,CAAb,CAAjB;AACAL,EAAAA,GAAG,CAACM,KAAJ,CAAUC,OAAV,GAAoB,MAApB;AACAP,EAAAA,GAAG,CAACM,KAAJ,CAAUE,aAAV,GAA0B,KAA1B;AACA,MAAMC,GAAG,GAAGT,GAAG,CAACU,WAAJ,CAAgBZ,GAAG,CAACa,aAAJ,CAAkB,KAAlB,CAAhB,CAAZ;AACAF,EAAAA,GAAG,CAACH,KAAJ,CAAUM,KAAV,GAAkBC,4BAAlB;AACA,MAAMC,GAAG,GAAGd,GAAG,CAACU,WAAJ,CAAgBZ,GAAG,CAACa,aAAJ,CAAkB,KAAlB,CAAhB,CAAZ;AAEAF,EAAAA,GAAG,CAACM,YAAJ,CAAiB,OAAjB,EAA0B,eAA1B;AACAN,EAAAA,GAAG,CAACM,YAAJ,CAAiB,OAAjB,EAA0BC,4BAA1B;AACAF,EAAAA,GAAG,CAACC,YAAJ,CAAiB,OAAjB,EAA0B,gBAA1B;;AACA,MAAI,CAACb,QAAL,EAAe;AAAE;AACfY,IAAAA,GAAG,CAACJ,WAAJ,CAAgB,8BAAkBZ,GAAlB,EAAuB,uCAAuCG,IAA9D,CAAhB;AACAQ,IAAAA,GAAG,CAACC,WAAJ,CAAgBZ,GAAG,CAACmB,cAAJ,CAAmB,KAAnB,CAAhB;AACD,GAHD,MA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AAD,EAAMF,GAAN,EAAWV,QAAX,CAAV;AACD,SAFD,MAEO;AACLA,UAAAA,QAAQ,CAACvD,GAAD,EAAMoE,EAAN,EAAUC,IAAV,CAAR;AACD;AACF,OAND;AAOD;;AAEDf,IAAAA,UAAU,CAACX,EAAD,EAAKQ,EAAL,EAAgB,UAAUnD,GAAV,EAAeoE,EAAf,EAAmBC,IAAnB,EAAyB;AACjD;AACA,UAAID,EAAJ,EAAQ;AACNzC,QAAAA,KAAK,CAACe,QAAN,GAAiB,KAAjB;AACAf,QAAAA,KAAK,CAACnC,YAAN,CAAmB,OAAnB,EAA4BT,KAA5B;AACD,OAHD,MAGO;AACLN,QAAAA,GAAG,CAACU,WAAJ,CAAgB,8BAAkBZ,GAAlB,EAAuB8F,IAAvB,CAAhB;AACD;;AACDlD,MAAAA,gBAAgB,CAACiD,EAAD,EAAKC,IAAL,CAAhB;AACD,KATS,CAAV;AAUD,GA5EH,EA6EE,IA7EF;AA+EA,SAAO5F,GAAP;AACD","sourcesContent":["import { BlankNode, Literal, NamedNode, Node, st, Store, Variable } from 'rdflib'\nimport { solidLogicSingleton } from 'solid-logic'\nimport * as ns from '../../ns'\nimport { formFieldNameBoxStyle, formFieldNameBoxWidth, textInputSize, textInputStyle, textInputStyleUneditable } from '../../style'\nimport { label } from '../../utils'\nimport { errorMessageBlock } from '../error'\nimport { mostSpecificClassURI } from './fieldFunction'\nimport { fieldParams } from './fieldParams'\n\nconst store = solidLogicSingleton.store\n\n/* Style and create a name, value pair\n*/\nexport function renderNameValuePair (dom: HTMLDocument, kb: Store, box: HTMLElement, form: NamedNode):HTMLElement {\n const property = kb.any(form, ns.ui('property'))\n box.style.display = 'flex'\n box.style.flexDirection = 'row'\n const lhs = box.appendChild(dom.createElement('div'))\n lhs.style.width = formFieldNameBoxWidth\n const rhs = box.appendChild(dom.createElement('div'))\n\n lhs.setAttribute('class', 'formFieldName')\n lhs.setAttribute('style', formFieldNameBoxStyle)\n rhs.setAttribute('class', 'formFieldValue')\n if (!property) { // Assume more space for error on right\n rhs.appendChild(errorMessageBlock(dom, 'No property given for form field: ' + form))\n lhs.appendChild(dom.createTextNode('???'))\n } else {\n lhs.appendChild(fieldLabel(dom, property as NamedNode, form))\n }\n return rhs\n}\n\n/**\n * Create an anchor element with a label as the anchor text.\n *\n * @param dom The DOM\n * @param property href for the anchor element\n * @param fieldInQuestion field to produce a label for\n *\n * @internal exporting this only for unit tests\n */\nexport function fieldLabel (dom: HTMLDocument, property: NamedNode | undefined, fieldInQuestion: Node): HTMLElement | Text {\n let lab = store.any(fieldInQuestion as any, ns.ui('label'))\n if (!lab) lab = label(property, true) // Init capital\n if (property === undefined) {\n return dom.createTextNode('@@Internal error: undefined property')\n }\n const anchor = dom.createElement('a')\n /* istanbul ignore next */\n if (property.uri) anchor.setAttribute('href', property.uri)\n anchor.setAttribute('style', 'color: #3B5998; text-decoration: none;') // Not too blue and no underline\n anchor.textContent = lab as any\n return anchor\n}\n\n/**\n * Returns the document for the first quad that matches\n * the subject and predicate provided, or default if that\n * store is not editable.\n *\n * @param subject Subject about which we want to find an editable RDF document\n * @param predicate Predicate about which we want to find an editable RDF document\n * @param def default RDF document to return if none found\n *\n * @internal exporting this only for unit tests\n */\nexport function fieldStore (subject: NamedNode | BlankNode | Variable, predicate: NamedNode | Variable, def: NamedNode | undefined): NamedNode | undefined {\n const sts = store.statementsMatching(subject, predicate)\n if (sts.length === 0) return def // can used default as no data yet\n if (!store.updater) {\n throw new Error('Store has no updater')\n }\n if (\n sts.length > 0 &&\n sts[0].why.value &&\n store.updater.editable(sts[0].why.value, store)\n ) {\n return store.sym(sts[0].why.value)\n }\n return def\n}\n\n/**\n * Render a basic form field\n *\n * The same function is used for many similar one-value fields, with different\n * regexps used to validate.\n *\n * @param dom The HTML Document object aka Document Object Model\n * @param container If present, the created widget will be appended to this\n * @param already A hash table of (form, subject) kept to prevent recursive forms looping\n * @param subject The thing about which the form displays/edits data\n * @param form The form or field to be rendered\n * @param doc The web document in which the data is\n * @param callbackFunction Called when data is changed?\n *\n * @returns The HTML widget created\n */\n// eslint-disable-next-line complexity\nexport function basicField (\n dom: HTMLDocument,\n container: HTMLElement | undefined,\n already,\n subject: NamedNode | BlankNode | Variable,\n form: NamedNode,\n doc: NamedNode | undefined,\n callbackFunction: (_ok: boolean, _errorMessage: string) => void\n): HTMLElement {\n const kb = store\n const formDoc = form.doc ? form.doc() : null // @@ if blank no way to know\n\n const box = dom.createElement('div')\n\n const property = kb.any(form, ns.ui('property'))\n if (container) container.appendChild(box)\n if (!property) {\n return box.appendChild(\n errorMessageBlock(dom, 'Error: No property given for text field: ' + form)\n )\n }\n const rhs = renderNameValuePair(dom, kb, box, form)\n\n // It can be cleaner to just remove empty fields if you can't edit them anyway\n const suppressEmptyUneditable = kb.anyJS(form, ns.ui('suppressEmptyUneditable'), null, formDoc)\n\n const uri = mostSpecificClassURI(form)\n let params = fieldParams[uri]\n if (params === undefined) params = { style: '' } // non-bottom field types can do this\n const paramStyle = params.style || ''\n const style = textInputStyle + paramStyle\n const field = dom.createElement('input')\n ;(field as any).style = style\n rhs.appendChild(field)\n field.setAttribute('type', params.type ? params.type : 'text')\n\n const size = kb.anyJS(form, ns.ui('size')) || textInputSize || 20\n field.setAttribute('size', size)\n\n const maxLength = kb.any(form, ns.ui('maxLength'))\n field.setAttribute('maxLength', maxLength ? '' + maxLength : '4096')\n\n doc = doc || fieldStore(subject, property as any, doc)\n\n let obj = kb.any(subject, property as any, undefined, doc)\n if (!obj) {\n obj = kb.any(form, ns.ui('default'))\n }\n if (obj && obj.value && params.uriPrefix) {\n // eg tel: or mailto:\n field.value = decodeURIComponent(obj.value.replace(params.uriPrefix, '')) // should have no spaces but in case\n .replace(/ /g, '')\n } else if (obj) {\n /* istanbul ignore next */\n field.value = obj.value || obj.value || ''\n }\n field.setAttribute('style', style)\n if (!kb.updater) {\n throw new Error('kb has no updater')\n }\n if (!kb.updater.editable((doc as NamedNode).uri)) {\n field.readOnly = true // was: disabled. readOnly is better\n ;(field as any).style = textInputStyleUneditable + paramStyle\n // backgroundColor = textInputBackgroundColorUneditable\n if (suppressEmptyUneditable && field.value === '') {\n box.style.display = 'none' // clutter\n }\n return box\n }\n\n // read-write:\n field.addEventListener(\n 'keyup',\n function (_e) {\n if (params.pattern) {\n field.setAttribute(\n 'style',\n style +\n (field.value.match(params.pattern)\n ? 'color: green;'\n : 'color: red;')\n )\n }\n },\n true\n )\n field.addEventListener(\n 'change',\n function (_e) {\n // i.e. lose focus with changed data\n if (params.pattern && !field.value.match(params.pattern)) return\n field.disabled = true // See if this stops getting two dates from fumbling e.g the chrome datepicker.\n field.setAttribute('style', style + 'color: gray;') // pending\n const ds = kb.statementsMatching(subject, property as any) // remove any multiple values\n let result\n if (params.namedNode) {\n result = kb.sym(field.value)\n } else if (params.uriPrefix) {\n result = encodeURIComponent(field.value.replace(/ /g, ''))\n result = kb.sym(params.uriPrefix + field.value)\n } else {\n if (params.dt) {\n result = new Literal(\n field.value.trim(),\n undefined,\n ns.xsd(params.dt)\n )\n } else {\n result = new Literal(field.value)\n }\n }\n let is = ds.map(statement => st(statement.subject, statement.predicate, result, statement.why)) // can include >1 doc\n if (is.length === 0) {\n // or none\n is = [st(subject, property as any, result, doc)]\n }\n\n function updateMany (ds, is: { why: { uri: string } }[], callback) {\n const docs: any[] = []\n is.forEach(st => {\n if (!docs.includes(st.why.uri)) docs.push(st.why.uri)\n })\n ds.forEach(st => {\n /* istanbul ignore next */\n if (!docs.includes(st.why.uri)) docs.push(st.why.uri)\n })\n /* istanbul ignore next */\n if (docs.length === 0) {\n throw new Error('updateMany has no docs to patch')\n }\n if (!kb.updater) {\n throw new Error('kb has no updater')\n }\n if (docs.length === 1) {\n return kb.updater.update(ds, is as any, callback)\n }\n // return kb.updater.update(ds, is, callback)\n\n const doc = docs.pop()\n const is1 = is.filter(st => st.why.uri === doc)\n const is2 = is.filter(st => st.why.uri !== doc)\n const ds1 = ds.filter(st => st.why.uri === doc)\n const ds2 = ds.filter(st => st.why.uri !== doc)\n kb.updater.update(ds1, is1 as any, function (uri, ok, body) {\n if (ok) {\n updateMany(ds2, is2, callback)\n } else {\n callback(uri, ok, body)\n }\n })\n }\n\n updateMany(ds, is as any, function (uri, ok, body) {\n // kb.updater.update(ds, is, function (uri, ok, body) {\n if (ok) {\n field.disabled = false\n field.setAttribute('style', style)\n } else {\n box.appendChild(errorMessageBlock(dom, body))\n }\n callbackFunction(ok, body)\n })\n },\n true\n )\n return box\n}\n"],"file":"basic.js"}
1
+ {"version":3,"sources":["../../../src/widgets/forms/basic.ts"],"names":["store","solidLogicSingleton","renderNameValuePair","dom","kb","box","form","label","style","display","flexDirection","lhs","appendChild","createElement","width","formFieldNameBoxWidth","rhs","setAttribute","formFieldNameBoxStyle","createTextNode","any","ns","ui","fieldLabel","property","fieldInQuestion","lab","undefined","anchor","uri","textContent","fieldStore","subject","predicate","def","sts","statementsMatching","length","updater","Error","why","value","editable","sym","basicField","container","already","doc","callbackFunction","formDoc","suppressEmptyUneditable","anyJS","params","fieldParams","paramStyle","textInputStyle","field","type","size","textInputSize","maxLength","obj","uriPrefix","decodeURIComponent","replace","readOnly","textInputStyleUneditable","addEventListener","_e","pattern","match","disabled","ds","result","namedNode","encodeURIComponent","dt","Literal","trim","xsd","is","map","statement","updateMany","callback","docs","forEach","st","includes","push","update","pop","is1","filter","is2","ds1","ds2","ok","body"],"mappings":";;;;;;;;;;;;AAAA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAEA,IAAMA,KAAK,GAAGC,gCAAoBD,KAAlC;AAEA;AACA;;AACO,SAASE,mBAAT,CAA8BC,GAA9B,EAAiDC,EAAjD,EAA4DC,GAA5D,EAA8EC,IAA9E,EAA+FC,KAA/F,EAA2H;AAChI;AACAF,EAAAA,GAAG,CAACG,KAAJ,CAAUC,OAAV,GAAoB,MAApB;AACAJ,EAAAA,GAAG,CAACG,KAAJ,CAAUE,aAAV,GAA0B,KAA1B;AACA,MAAMC,GAAG,GAA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KAAjB;AACAf,QAAAA,KAAK,CAACvC,YAAN,CAAmB,OAAnB,EAA4BT,KAA5B;AACD,OAHD,MAGO;AACLH,QAAAA,GAAG,CAACO,WAAJ,CAAgB,8BAAkBT,GAAlB,EAAuB+F,IAAvB,CAAhB;AACD;;AACDlD,MAAAA,gBAAgB,CAACiD,EAAD,EAAKC,IAAL,CAAhB;AACD,KATS,CAAV;AAUD,GA5EH,EA6EE,IA7EF;AA+EA,SAAO7F,GAAP;AACD","sourcesContent":["import { BlankNode, Literal, NamedNode, Node, st, Store, Variable } from 'rdflib'\nimport { solidLogicSingleton } from 'solid-logic'\nimport * as ns from '../../ns'\nimport { formFieldNameBoxStyle, formFieldNameBoxWidth, textInputSize, textInputStyle, textInputStyleUneditable } from '../../style'\nimport { label } from '../../utils'\nimport { errorMessageBlock } from '../error'\nimport { mostSpecificClassURI } from './fieldFunction'\nimport { fieldParams } from './fieldParams'\n\nconst store = solidLogicSingleton.store\n\n/* Style and create a name, value pair\n*/\nexport function renderNameValuePair (dom: HTMLDocument, kb: Store, box: HTMLElement, form: NamedNode, label?: string):HTMLElement {\n // const property = kb.any(form, ns.ui('property'))\n box.style.display = 'flex'\n box.style.flexDirection = 'row'\n const lhs = box.appendChild(dom.createElement('div'))\n lhs.style.width = formFieldNameBoxWidth\n const rhs = box.appendChild(dom.createElement('div'))\n\n lhs.setAttribute('class', 'formFieldName')\n lhs.setAttribute('style', formFieldNameBoxStyle)\n rhs.setAttribute('class', 'formFieldValue')\n if (label) {\n lhs.appendChild(dom.createTextNode(label))\n } else if (kb.any(form, ns.ui('property'))) { // Assume more space for error on right\n lhs.appendChild(fieldLabel(dom, kb.any(form, ns.ui('property')) as NamedNode, form))\n } else {\n rhs.appendChild(errorMessageBlock(dom, 'No property or label given for form field: ' + form))\n lhs.appendChild(dom.createTextNode('???'))\n }\n return rhs\n}\n\n/**\n * Create an anchor element with a label as the anchor text.\n *\n * @param dom The DOM\n * @param property href for the anchor element\n * @param fieldInQuestion field to produce a label for\n *\n * @internal exporting this only for unit tests\n */\nexport function fieldLabel (dom: HTMLDocument, property: NamedNode | undefined, fieldInQuestion: Node): HTMLElement | Text {\n let lab = store.any(fieldInQuestion as any, ns.ui('label'))\n if (!lab) lab = label(property, true) // Init capital\n if (property === undefined) {\n return dom.createTextNode('@@Internal error: undefined property')\n }\n const anchor = dom.createElement('a')\n /* istanbul ignore next */\n if (property.uri) anchor.setAttribute('href', property.uri)\n anchor.setAttribute('style', 'color: #3B5998; text-decoration: none;') // Not too blue and no underline\n anchor.textContent = lab as any\n return anchor\n}\n\n/**\n * Returns the document for the first quad that matches\n * the subject and predicate provided, or default if that\n * store is not editable.\n *\n * @param subject Subject about which we want to find an editable RDF document\n * @param predicate Predicate about which we want to find an editable RDF document\n * @param def default RDF document to return if none found\n *\n * @internal exporting this only for unit tests\n */\nexport function fieldStore (subject: NamedNode | BlankNode | Variable, predicate: NamedNode | Variable, def: NamedNode | undefined): NamedNode | undefined {\n const sts = store.statementsMatching(subject, predicate)\n if (sts.length === 0) return def // can used default as no data yet\n if (!store.updater) {\n throw new Error('Store has no updater')\n }\n if (\n sts.length > 0 &&\n sts[0].why.value &&\n store.updater.editable(sts[0].why.value, store)\n ) {\n return store.sym(sts[0].why.value)\n }\n return def\n}\n\n/**\n * Render a basic form field\n *\n * The same function is used for many similar one-value fields, with different\n * regexps used to validate.\n *\n * @param dom The HTML Document object aka Document Object Model\n * @param container If present, the created widget will be appended to this\n * @param already A hash table of (form, subject) kept to prevent recursive forms looping\n * @param subject The thing about which the form displays/edits data\n * @param form The form or field to be rendered\n * @param doc The web document in which the data is\n * @param callbackFunction Called when data is changed?\n *\n * @returns The HTML widget created\n */\n// eslint-disable-next-line complexity\nexport function basicField (\n dom: HTMLDocument,\n container: HTMLElement | undefined,\n already,\n subject: NamedNode | BlankNode | Variable,\n form: NamedNode,\n doc: NamedNode | undefined,\n callbackFunction: (_ok: boolean, _errorMessage: string) => void\n): HTMLElement {\n const kb = store\n const formDoc = form.doc ? form.doc() : null // @@ if blank no way to know\n\n const box = dom.createElement('div')\n\n const property = kb.any(form, ns.ui('property'))\n if (container) container.appendChild(box)\n if (!property) {\n return box.appendChild(\n errorMessageBlock(dom, 'Error: No property given for text field: ' + form)\n )\n }\n const rhs = renderNameValuePair(dom, kb, box, form)\n\n // It can be cleaner to just remove empty fields if you can't edit them anyway\n const suppressEmptyUneditable = kb.anyJS(form, ns.ui('suppressEmptyUneditable'), null, formDoc)\n\n const uri = mostSpecificClassURI(form)\n let params = fieldParams[uri]\n if (params === undefined) params = { style: '' } // non-bottom field types can do this\n const paramStyle = params.style || ''\n const style = textInputStyle + paramStyle\n const field = dom.createElement('input')\n ;(field as any).style = style\n rhs.appendChild(field)\n field.setAttribute('type', params.type ? params.type : 'text')\n\n const size = kb.anyJS(form, ns.ui('size')) || textInputSize || 20\n field.setAttribute('size', size)\n\n const maxLength = kb.any(form, ns.ui('maxLength'))\n field.setAttribute('maxLength', maxLength ? '' + maxLength : '4096')\n\n doc = doc || fieldStore(subject, property as any, doc)\n\n let obj = kb.any(subject, property as any, undefined, doc)\n if (!obj) {\n obj = kb.any(form, ns.ui('default'))\n }\n if (obj && obj.value && params.uriPrefix) {\n // eg tel: or mailto:\n field.value = decodeURIComponent(obj.value.replace(params.uriPrefix, '')) // should have no spaces but in case\n .replace(/ /g, '')\n } else if (obj) {\n /* istanbul ignore next */\n field.value = obj.value || obj.value || ''\n }\n field.setAttribute('style', style)\n if (!kb.updater) {\n throw new Error('kb has no updater')\n }\n if (!kb.updater.editable((doc as NamedNode).uri)) {\n field.readOnly = true // was: disabled. readOnly is better\n ;(field as any).style = textInputStyleUneditable + paramStyle\n // backgroundColor = textInputBackgroundColorUneditable\n if (suppressEmptyUneditable && field.value === '') {\n box.style.display = 'none' // clutter\n }\n return box\n }\n\n // read-write:\n field.addEventListener(\n 'keyup',\n function (_e) {\n if (params.pattern) {\n field.setAttribute(\n 'style',\n style +\n (field.value.match(params.pattern)\n ? 'color: green;'\n : 'color: red;')\n )\n }\n },\n true\n )\n field.addEventListener(\n 'change',\n function (_e) {\n // i.e. lose focus with changed data\n if (params.pattern && !field.value.match(params.pattern)) return\n field.disabled = true // See if this stops getting two dates from fumbling e.g the chrome datepicker.\n field.setAttribute('style', style + 'color: gray;') // pending\n const ds = kb.statementsMatching(subject, property as any) // remove any multiple values\n let result\n if (params.namedNode) {\n result = kb.sym(field.value)\n } else if (params.uriPrefix) {\n result = encodeURIComponent(field.value.replace(/ /g, ''))\n result = kb.sym(params.uriPrefix + field.value)\n } else {\n if (params.dt) {\n result = new Literal(\n field.value.trim(),\n undefined,\n ns.xsd(params.dt)\n )\n } else {\n result = new Literal(field.value)\n }\n }\n let is = ds.map(statement => st(statement.subject, statement.predicate, result, statement.why)) // can include >1 doc\n if (is.length === 0) {\n // or none\n is = [st(subject, property as any, result, doc)]\n }\n\n function updateMany (ds, is: { why: { uri: string } }[], callback) {\n const docs: any[] = []\n is.forEach(st => {\n if (!docs.includes(st.why.uri)) docs.push(st.why.uri)\n })\n ds.forEach(st => {\n /* istanbul ignore next */\n if (!docs.includes(st.why.uri)) docs.push(st.why.uri)\n })\n /* istanbul ignore next */\n if (docs.length === 0) {\n throw new Error('updateMany has no docs to patch')\n }\n if (!kb.updater) {\n throw new Error('kb has no updater')\n }\n if (docs.length === 1) {\n return kb.updater.update(ds, is as any, callback)\n }\n // return kb.updater.update(ds, is, callback)\n\n const doc = docs.pop()\n const is1 = is.filter(st => st.why.uri === doc)\n const is2 = is.filter(st => st.why.uri !== doc)\n const ds1 = ds.filter(st => st.why.uri === doc)\n const ds2 = ds.filter(st => st.why.uri !== doc)\n kb.updater.update(ds1, is1 as any, function (uri, ok, body) {\n if (ok) {\n updateMany(ds2, is2, callback)\n } else {\n callback(uri, ok, body)\n }\n })\n }\n\n updateMany(ds, is as any, function (uri, ok, body) {\n // kb.updater.update(ds, is, function (uri, ok, body) {\n if (ok) {\n field.disabled = false\n field.setAttribute('style', style)\n } else {\n box.appendChild(errorMessageBlock(dom, body))\n }\n callbackFunction(ok, body)\n })\n },\n true\n )\n return box\n}\n"],"file":"basic.js"}
@@ -8,6 +8,12 @@ Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
10
  exports.appendForm = appendForm;
11
+ Object.defineProperty(exports, "basicField", {
12
+ enumerable: true,
13
+ get: function get() {
14
+ return _basic.basicField;
15
+ }
16
+ });
11
17
  exports.buildCheckboxForm = buildCheckboxForm;
12
18
  exports.editFormButton = editFormButton;
13
19
  Object.defineProperty(exports, "field", {
@@ -16,14 +22,24 @@ Object.defineProperty(exports, "field", {
16
22
  return _fieldFunction.field;
17
23
  }
18
24
  });
19
- exports.fieldLabel = fieldLabel;
25
+ Object.defineProperty(exports, "fieldLabel", {
26
+ enumerable: true,
27
+ get: function get() {
28
+ return _basic.fieldLabel;
29
+ }
30
+ });
20
31
  Object.defineProperty(exports, "fieldParams", {
21
32
  enumerable: true,
22
33
  get: function get() {
23
34
  return _fieldParams.fieldParams;
24
35
  }
25
36
  });
26
- exports.fieldStore = fieldStore;
37
+ Object.defineProperty(exports, "fieldStore", {
38
+ enumerable: true,
39
+ get: function get() {
40
+ return _basic.fieldStore;
41
+ }
42
+ });
27
43
  exports.findClosest = findClosest;
28
44
  exports.formsFor = formsFor;
29
45
  exports.makeDescription = makeDescription;
@@ -34,6 +50,12 @@ exports.newButton = newButton;
34
50
  exports.newThing = newThing;
35
51
  exports.promptForNew = promptForNew;
36
52
  exports.propertiesForClass = propertiesForClass;
53
+ Object.defineProperty(exports, "renderNameValuePair", {
54
+ enumerable: true,
55
+ get: function get() {
56
+ return _basic.renderNameValuePair;
57
+ }
58
+ });
37
59
  exports.sortByLabel = sortByLabel;
38
60
  exports.sortBySequence = sortBySequence;
39
61
 
@@ -906,8 +928,8 @@ _fieldFunction.field[ns.ui('MultiLineTextField').uri] = function (dom, container
906
928
  var left = box.appendChild(dom.createElement('div'));
907
929
  left.style.width = style.formFieldNameBoxWidth;
908
930
  var right = box.appendChild(dom.createElement('div'));
909
- left.appendChild(fieldLabel(dom, property, form));
910
- dataDoc = fieldStore(subject, property, dataDoc);
931
+ left.appendChild((0, _basic.fieldLabel)(dom, property, form));
932
+ dataDoc = (0, _basic.fieldStore)(subject, property, dataDoc);
911
933
  var text = kb.anyJS(subject, property, null, dataDoc) || '';
912
934
  var editable = kb.updater.editable(dataDoc.uri);
913
935
  var suppressEmptyUneditable = form && kb.anyJS(form, ns.ui('suppressEmptyUneditable'), null, formDoc);
@@ -941,7 +963,7 @@ function booleanField(dom, container, already, subject, form, dataDoc, callbackF
941
963
  var lab = kb.any(form, ui('label'));
942
964
  if (!lab) lab = utils.label(property, true); // Init capital
943
965
 
944
- dataDoc = fieldStore(subject, property, dataDoc);
966
+ dataDoc = (0, _basic.fieldStore)(subject, property, dataDoc);
945
967
  var state = kb.any(subject, property);
946
968
 
947
969
  if (state === undefined) {
@@ -1024,7 +1046,7 @@ _fieldFunction.field[ns.ui('Choice').uri] = function (dom, container, already, s
1024
1046
  return box.appendChild((0, _error.errorMessageBlock)(dom, 'No property for Choice: ' + form));
1025
1047
  }
1026
1048
 
1027
- lhs.appendChild(fieldLabel(dom, property, form));
1049
+ lhs.appendChild((0, _basic.fieldLabel)(dom, property, form));
1028
1050
  var from = kb.any(form, ui('from'));
1029
1051
 
1030
1052
  if (!from) {
@@ -1741,7 +1763,7 @@ function makeSelectForNestedCategory(dom, kb, subject, category, dataDoc, callba
1741
1763
 
1742
1764
  function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
1743
1765
  var box = dom.createElement('div');
1744
- var rhs = (0, _basic.renderNameValuePair)(dom, kb, box, form);
1766
+ var rhs = (0, _basic.renderNameValuePair)(dom, kb, box, form, lab);
1745
1767
  var editable = kb.updater.editable(dataDoc.uri);
1746
1768
  var input = dom.createElement('button');
1747
1769
  var colorCarrier = input;
@@ -1840,33 +1862,34 @@ function buildCheckboxForm(dom, kb, lab, del, ins, form, dataDoc, tristate) {
1840
1862
  input.addEventListener('click', boxHandler, false);
1841
1863
  return box;
1842
1864
  }
1843
-
1844
- function fieldLabel(dom, property, form) {
1845
- var lab = kb.any(form, ns.ui('label'));
1846
- if (!lab) lab = utils.label(property, true); // Init capital
1847
-
1865
+ /*
1866
+ export function fieldLabel (dom, property, form) {
1867
+ let lab = kb.any(form, ns.ui('label'))
1868
+ if (!lab) lab = utils.label(property, true) // Init capital
1848
1869
  if (property === undefined) {
1849
- return dom.createTextNode('@@Internal error: undefined property');
1870
+ return dom.createTextNode('@@Internal error: undefined property')
1850
1871
  }
1851
-
1852
- var anchor = dom.createElement('a');
1853
- if (property.uri) anchor.setAttribute('href', property.uri);
1854
- anchor.setAttribute('style', style.fieldLabelStyle); // Not too blue and no underline
1855
-
1856
- anchor.textContent = lab;
1857
- return anchor;
1872
+ const anchor = dom.createElement('a')
1873
+ if (property.uri) anchor.setAttribute('href', property.uri)
1874
+ anchor.setAttribute('style', style.fieldLabelStyle) // Not too blue and no underline
1875
+ anchor.textContent = lab
1876
+ return anchor
1858
1877
  }
1859
1878
 
1860
- function fieldStore(subject, predicate, def) {
1861
- var sts = kb.statementsMatching(subject, predicate);
1862
- if (sts.length === 0) return def; // can used default as no data yet
1863
-
1864
- if (sts.length > 0 && sts[0].why.uri && kb.updater.editable(sts[0].why.uri)) {
1865
- return kb.sym(sts[0].why.uri);
1879
+ export function fieldStore (subject, predicate, def) {
1880
+ const sts = kb.statementsMatching(subject, predicate)
1881
+ if (sts.length === 0) return def // can used default as no data yet
1882
+ if (
1883
+ sts.length > 0 &&
1884
+ sts[0].why.uri &&
1885
+ kb.updater.editable(sts[0].why.uri)
1886
+ ) {
1887
+ return kb.sym(sts[0].why.uri)
1866
1888
  }
1867
-
1868
- return def;
1889
+ return def
1869
1890
  }
1891
+ */
1892
+
1870
1893
  /** Mint local ID using timestamp
1871
1894
  * @param {NamedNode} doc - the document in which the ID is to be generated
1872
1895
  */