Skip to content

Commit bf8f2b7

Browse files
authored
Merge pull request #401 from solid/timbl-forms
Timbl forms. Decided to leave Storyboard to another time. Addresses other comments I think, including basic tests. Thanks for all the reviews.
2 parents 01c5422 + 0b66e6c commit bf8f2b7

23 files changed

Lines changed: 26988 additions & 2999 deletions

Documentation/forms-intro.html

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,48 @@ <h4 class="class">Options</h4>
545545
</tr>
546546
</table>
547547

548+
<h4 class="class" id="Autocomplete">Autocomplete</h4>
549+
550+
<p>The autocomplete field alllows the user to select one
551+
out of a large number of existing choices, by typing enough of its
552+
name to be unambiguous.
553+
</p>
554+
555+
<p>The field stores two triples,one of the given <tt>property</tt> linking to the
556+
object the user has selcted, and the other stoting the name of that object,
557+
as seen in the completed feld, using the <tt>labelProperty</tt>.
558+
</p>
559+
560+
<p>The field must specify a <tt>dataSource</tt> which gives the paramters
561+
and form of the query make over the net.
562+
</p>
563+
564+
<table class="properties">
565+
566+
<tr>
567+
<td>labelProperty</td>
568+
<td>String</td>
569+
<td>The property which will be used to store the name of the selected thing as a separate triple</td>
570+
</tr>
571+
572+
<tr>
573+
<td>dataSource</td>
574+
575+
<td>DataSource</td>
576+
577+
<td>The API details or query endpint and query details to be usde to search of the itemn in
578+
the databasse.</td>
579+
</tr>
580+
<tr>
581+
<td>targetClass</td>
582+
<td>rdfs:Class</td>
583+
<td>Is tyhis is specified, it be used to replace any occuurences of
584+
"$(targetClass)" in the query template. this allows different instances
585+
of AutocompleteField to share the same DatSource, by specifying different values for <tt>targetClass</tt>.</td>
586+
</tr>
587+
588+
</table>
589+
548590
<h3>Documentation fields</h3>
549591

550592
<h4 class="class">Heading</h4>

package-lock.json

Lines changed: 23697 additions & 2742 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
},
5454
"homepage": "https://github.com/solid/solid-ui",
5555
"dependencies": {
56-
"@babel/runtime": "^7.12.5",
56+
"@babel/runtime": "^7.14.0",
5757
"crypto-browserify": "^3.12.0",
5858
"escape-html": "^1.0.3",
5959
"jss": "^10.5.1",
@@ -82,18 +82,22 @@
8282
"@storybook/addon-essentials": "^6.1.20",
8383
"@storybook/addon-links": "^6.1.15",
8484
"@storybook/html": "^6.1.20",
85+
"@testing-library/dom": "^7.31.0",
8586
"@types/jest": "^26.0.20",
8687
"@types/jsdom": "^16.2.6",
8788
"@types/node": "^14.14.22",
8889
"@typescript-eslint/eslint-plugin": "^4.14.1",
8990
"@typescript-eslint/parser": "^4.14.1",
91+
"autoprefixer": "^10.2.6",
9092
"babel-loader": "^8.2.2",
9193
"eslint": "^7.18.0",
9294
"eslint-plugin-jest": "^24.1.3",
9395
"husky": "^4.3.8",
9496
"jest": "^26.6.3",
9597
"jsdom": "^16.4.0",
9698
"lint-staged": "^10.5.3",
99+
"nock": "^13.0.11",
100+
"postcss-flexbugs-fixes": "^5.0.2",
97101
"raw-loader": "^4.0.2",
98102
"react-is": "^17.0.1",
99103
"solid-auth-cli": "^1.0.15",

src/acl/access-controller.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@ export class AccessController {
233233
const updater = newAClGraph.updater || new UpdateManager(newAClGraph)
234234

235235
// save ACL resource
236-
237236
return new Promise((resolve, reject) => {
238237
// check acl for acl:Write alert and acl:Control confirm
239238
const hasWrite = newAClGraph.any(undefined, ns.acl('mode'), ns.acl('Write'), this.targetACLDoc)

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ If you would like to know more about the solid Solid project, please see
2525
https://github.com/solid/solid
2626
*/
2727
'use strict'
28-
/* eslint-disable no-console */
2928
/**
3029
* Provides a Solid client helper object (which exposes various static modules).
3130
* @module solidUi.js
@@ -108,7 +107,6 @@ if (typeof window !== 'undefined') {
108107
initHeader
109108
} // Simpler access by non-node scripts
110109
}
111-
console.log('widgets imported to UI:', widgets)
112110

113111
export {
114112
ns,

src/style.js

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
// These must all end with semicolon so they can be appended to.
66

77
const formBorderColor = '#888888' // Mid-grey
8+
const lowProfileLinkColor = '#3B5998' // Grey-blue, e.g., for field labels linking to ontology
9+
const formFieldNameBoxWidth = '8em' // The fixed amount to get form fields to line up
10+
// The latter we put in when switching awy from using tables. Getting allignment between
11+
// fields in different groups though is hard problem.
812

913
export const style = { // styleModule
14+
formSelectSTyle:
15+
'background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;',
1016
textInputStyle:
11-
'background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em; ',
17+
'background-color: #eef; padding: 0.5em; border: .05em solid #88c; border-radius:0.2em; font-size: 100%; margin:0.2em;',
1218
textInputStyleUneditable: // Color difference only
1319
'background-color: white; padding: 0.5em; border: .05em solid white; border-radius:0.2em; font-size: 100%; margin:0.2em; ',
1420
textInputSize: 20, // Default text input size in characters roughly
1521
buttonStyle:
1622
'background-color: #fff; padding: 0.7em; border: .01em solid white; border-radius:0.2em; font-size: 100%; margin: 0.3em;', // 'background-color: #eef;
1723
commentStyle: 'padding: 0.7em; border: none; font-size: 100%; white-space: pre-wrap;',
1824
iconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 1em;',
19-
classIconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 0; border: 0.1em solid green; padding: 0.2em; background-color: #efe;', // combine with buttonStyle
25+
classIconStyle: 'width: 3em; height: 3em; margin: 0.1em; border-radius: 0.2em; border: 0.1em solid green; padding: 0.2em; background-color: #efe;', // combine with buttonStyle
2026
tabBorderRadius: '0.2em',
2127
messageBodyStyle:
2228
'white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; border-radius:0.2em; padding: .3em 0.5em; margin: 0.1em;',
@@ -25,28 +31,38 @@ export const style = { // styleModule
2531

2632
// Contacts
2733
personaBarStyle: 'width: 100%; height: 4em; background-color: #eee; vertical-align: middle;',
28-
searchInputStyle: 'border: 0.1em solid #444; border-radius: 0.5em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;',
34+
searchInputStyle: 'border: 0.1em solid #444; border-radius: 0.2em; width: 100%; font-size: 100%; padding: 0.1em 0.6em; margin 0.2em;',
2935
autocompleteRowStyle: 'border: 0.2em solid straw;',
3036

3137
// Login buttons
3238
signInButtonStyle: 'padding: 1em; border-radius:0.2em; margin: 2em; font-size: 100%;', // was 0.5em radius
3339

3440
// Forms
35-
heading1Style: 'font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.2em 0.7em;', // originally was brown; now grey
36-
heading2Style: 'font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.2em 0.7em;', // originally was brown; now grey
37-
heading3Style: 'font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.2em 0.7em;', // For example, in large forms or before a small form
38-
heading4Style: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.2em 0.7em;', // Lowest level used by default in small things
41+
heading1Style: 'font-size: 180%; font-weight: bold; color: #888888; padding: 0.5em; margin: 0.7em 0.0m;', // originally was brown; now grey
42+
heading2Style: 'font-size: 130%; font-weight: bold; color: #888888; padding: 0.4em; margin: 0.7em 0.0em;', // originally was brown; now grey
43+
heading3Style: 'font-size: 120%; font-weight: bold; color: #888888; padding: 0.3em; margin: 0.7em 0.0em;', // For example, in large forms or before a small form
44+
heading4Style: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;', // Lowest level used by default in small things
3945

4046
formBorderColor: formBorderColor, // originally was brown; now grey
4147
formHeadingColor: '#888888', // originally was brown; now grey
42-
formHeadingStyle: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.2em 0.7em;', // originally was brown; now grey
48+
formHeadingStyle: 'font-size: 110%; font-weight: bold; color: #888888; padding: 0.2em; margin: 0.7em 0.0em;', // originally was brown; now grey
4349
formTextInput: 'font-size: 100%; margin: 0.1em; padding: 0.1em;', // originally used this
44-
formGroupStyle: `padding-left: 2em; border: 0.05em solid ${formBorderColor};`,
50+
formGroupStyle: [`padding-left: 0em; border: 0.0em solid ${formBorderColor}; border-radius: 0.2em;`, // weight 0
51+
`padding-left: 2em; border: 0.05em solid ${formBorderColor}; border-radius: 0.2em;`,
52+
`padding-left: 2em; border: 0.1em solid ${formBorderColor}; border-radius: 0.2em;`,
53+
`padding-left: 2em; border: 0.2em solid ${formBorderColor}; border-radius: 0.2em;` // @@ pink
54+
],
4555

56+
formFieldLabelStyle: `'color: ${lowProfileLinkColor}; text-decoration: none;'`,
57+
formFieldNameBoxWidth: formFieldNameBoxWidth,
58+
formFieldNameBoxStyle: `padding: 0.3em; vertical-align: middle; width:${formFieldNameBoxWidth};`,
4659
textInputBackgroundColor: '#eef',
4760
textInputBackgroundColorUneditable: '#fff',
61+
textInputColor: '#000',
62+
textInputColorPending: '#888',
4863
multilineTextInputStyle: 'font-size:100%; white-space: pre-wrap; background-color: #eef;' +
4964
' border: 0.07em solid gray; padding: 1em 0.5em; margin: 1em 1em;',
65+
5066
checkboxStyle: 'colour: black; font-size: 100%; padding-left: 0.5 em; padding-right: 0.5 em;'
5167

5268
}

src/widgets/buttons.ts

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -441,17 +441,18 @@ export function faviconOrDefault (dom: HTMLDocument, x: NamedNode) {
441441
*/
442442
export function deleteButtonWithCheck (
443443
dom: HTMLDocument,
444-
container: HTMLElement,
444+
_container: HTMLElement, // Used to interfere with style of this
445445
noun: string,
446446
deleteFunction: () => any
447447
) {
448448
function setStyle () {
449-
container.style.border = ''
450-
container.style.margin = '0.3em'
451-
container.style.borderRadius = '0'
452-
container.style.padding = '0.3em white'
453-
container.style.boxShadow = ''
449+
buttonDiv.style.border = ''
450+
buttonDiv.style.margin = '0.3em'
451+
buttonDiv.style.borderRadius = '0'
452+
buttonDiv.style.padding = '0.3em white'
453+
buttonDiv.style.boxShadow = ''
454454
}
455+
const buttonDiv = dom.createElement('div')
455456
const minusIconURI = iconBase + 'noun_2188_red.svg' // white minus in red #cc0000 circle
456457
const img = dom.createElement('img')
457458
let sureButtonElt, cancelButtonElt
@@ -460,45 +461,46 @@ export function deleteButtonWithCheck (
460461
img.title = 'Remove this ' + noun
461462
const deleteButtonElt = img
462463

463-
container.appendChild(deleteButtonElt)
464-
container.setAttribute('class', 'hoverControl') // See tabbedtab.css (sigh global CSS)
464+
buttonDiv.appendChild(deleteButtonElt)
465+
buttonDiv.setAttribute('class', 'hoverControl') // See tabbedtab.css (sigh global CSS)
465466
setStyle()
466467

467468
deleteButtonElt.setAttribute('class', 'hoverControlHide')
468469

469470
deleteButtonElt.addEventListener(
470471
'click',
471472
function (_event) {
472-
container.style.borderRadius = '0.5em'
473-
container.style.border = 'orange 0.05em;'
474-
container.style.boxShadow = '0.2em 0.5em #888888'
473+
buttonDiv.style.borderRadius = '0.5em'
474+
buttonDiv.style.border = 'orange 0.05em;'
475+
buttonDiv.style.boxShadow = '0.2em 0.5em #888888'
476+
buttonDiv.style.padding = '0.3em'
475477

476-
container.removeChild(deleteButtonElt) // Ask -- are you sure?
478+
buttonDiv.removeChild(deleteButtonElt) // Ask -- are you sure?
477479
cancelButtonElt = dom.createElement('button')
478480
// cancelButton.textContent = 'cancel'
479481
cancelButtonElt.setAttribute('style', style.buttonStyle)
480482
const img = cancelButtonElt.appendChild(dom.createElement('img'))
481483
img.setAttribute('src', cancelIconURI)
482484
img.setAttribute('style', style.buttonStyle)
483485

484-
container.appendChild(cancelButtonElt).addEventListener(
486+
buttonDiv.appendChild(cancelButtonElt).addEventListener(
485487
'click',
486488
function (_event) {
487-
container.removeChild(sureButtonElt)
488-
container.removeChild(cancelButtonElt)
489+
buttonDiv.removeChild(sureButtonElt)
490+
buttonDiv.removeChild(cancelButtonElt)
489491
setStyle()
490-
container.appendChild(deleteButtonElt)
492+
buttonDiv.appendChild(deleteButtonElt)
491493
},
492494
false
493495
)
494496
sureButtonElt = dom.createElement('button')
495497
sureButtonElt.textContent = 'Delete ' + noun
496498
sureButtonElt.setAttribute('style', style.buttonStyle)
497-
container.appendChild(sureButtonElt).addEventListener(
499+
buttonDiv.appendChild(sureButtonElt).addEventListener(
498500
'click',
499501
function (_event) {
500-
container.removeChild(sureButtonElt)
501-
container.removeChild(cancelButtonElt)
502+
buttonDiv.removeChild(sureButtonElt)
503+
buttonDiv.removeChild(cancelButtonElt)
502504
setStyle()
503505
deleteFunction()
504506
},
@@ -507,7 +509,7 @@ export function deleteButtonWithCheck (
507509
},
508510
false
509511
)
510-
return deleteButtonElt
512+
return buttonDiv // deleteButtonElt
511513
}
512514

513515
/**

src/widgets/error.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
/**
22
* Create an error message block
33
* @param dom The DOM on which dom.createElement will be called
4-
* @param err The error message string to display
4+
* @param err The error message string to display (or an error object)
55
* @param backgroundColor Background color. Default: '#fee'
6+
* @param err2 Is the second param is a string, you can put the original Error in here
67
* @returns A div element with the err string
8+
*
9+
* This will return a DOM element you can put in the UI as a notice for the user
10+
* Meanwhile the stack is dumped to the console for the developer, so you actually know
11+
* where it happened!
712
*/
813
/* eslint-disable no-console */
914

10-
export function errorMessageBlock (dom: HTMLDocument, err: string | Error, backgroundColor?: string): HTMLDivElement {
15+
export function errorMessageBlock (dom: HTMLDocument, err: string | Error, backgroundColor?: string, err2?: Error): HTMLDivElement {
1116
const div = dom.createElement('div')
12-
if (err instanceof Error) {
13-
console.error(`errorMessageBlock: Error ${err} at: ${err.stack || '??'}`, err) // @@ pick one
14-
div.textContent = err.message
17+
18+
/* tslint:disable-next-line */ // Too complex for TS?
19+
// @ts-ignore
20+
const errorObject:Error = err2 || err instanceof Error ? err : null
21+
22+
if (errorObject) {
23+
console.error(`errorMessageBlock: ${errorObject} at: ${errorObject.stack || '??'}`, errorObject) // @@ pick one
24+
div.textContent = errorObject.message
1525
} else {
16-
div.textContent = err
26+
div.textContent = err as string
1727
}
1828
div.setAttribute(
1929
'style',

0 commit comments

Comments
 (0)