Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.

Commit 29890e6

Browse files
Merge pull request #181 from inrupt/release/0.5.0
Release/0.5.0
2 parents 328e764 + 944170a commit 29890e6

128 files changed

Lines changed: 10158 additions & 5963 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
"import/no-cycle": [0],
1717
"quotes": [1, "single"],
1818
"react/no-array-index-key": [1],
19-
"react/jsx-one-expression-per-line": [0]
19+
"react/jsx-one-expression-per-line": [0],
20+
"jsx-a11y/label-has-for": [0]
2021
},
2122
"settings": {
2223
"import/resolver": { "babel-module": {} }

CHANGELOG.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,36 @@
11
# Solid React Components Library
22

3+
## 0.5.0 ( December 18, 2019 )
4+
5+
### Added
6+
7+
- FormModel component:
8+
- New component that renders a form from a Form Model
9+
- New components added to support the form model. The following list of components are all compatible with the Form Model:
10+
- Textbox
11+
- TextArea
12+
- Date / DateTime / Time fields, using [react-datepicker](https://reactdatepicker.com/)
13+
- Dropdown
14+
- Checkbox (Boolean, not tri-state)
15+
- ColorPicker, using [react-color](https://casesandberg.github.io/react-color/)
16+
- Header (an `<h2>` tag rendered inside of the form)
17+
- Comment (a `<p>` tag rendered inside of the form)
18+
- Decimal / Float / Integer fields
19+
- Email field
20+
- Phone field
21+
- Multiple, a custom Form Model field that indicates the child element is repeatable
22+
- Group, an ordered set of fields that can be treated as a single sub-form
23+
24+
### Updated
25+
26+
- Notification class was updated to validate notifications when being read from an inbox. This way only compatible notifications are retrieved and the data is more predictable for display purposes
27+
- Updated ACL class predicate from `acl:defaultForNew`, which is deprecated, to `acl:default`
28+
- Renamed the rdf predicate prefix from `a` to `rdf` to align with standard convention
29+
30+
### Deprecated
31+
32+
- The ShExFormBuilder component is now deprecated in favor of the new FormModel component. The component remains in the library for now, but the documentation has been removed
33+
334
## 0.4.4 ( August 14, 2019 )
435

536
### Added

README.md

Lines changed: 92 additions & 56 deletions
Large diffs are not rendered by default.

config/webpack.config.demo.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,7 @@ module.exports = {
221221
'@hooks': path.resolve(__dirname, '../src/lib/hooks'),
222222
'@context': path.resolve(__dirname, '../src/lib/context'),
223223
'@classes': path.resolve(__dirname, '../src/lib/classes'),
224+
'@lib': path.resolve(__dirname, '../src/lib'),
224225
'@constants': path.resolve(__dirname, '../src/lib/constants')
225226
},
226227
plugins: [

config/webpack.config.dev.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ module.exports = {
226226
'@hooks': path.resolve(paths.appLibSrc, './hooks'),
227227
'@context': path.resolve(paths.appLibSrc, './context'),
228228
'@classes': path.resolve(__dirname, '../src/lib/classes'),
229+
'@lib': path.resolve(__dirname, '../src/lib'),
229230
'@constants': path.resolve(__dirname, '../src/lib/constants')
230231
}
231232
}

config/webpack.config.prod.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ module.exports = {
224224
'@hooks': path.resolve(__dirname, '../src/lib/hooks'),
225225
'@context': path.resolve(__dirname, '../src/lib/context'),
226226
'@classes': path.resolve(__dirname, '../src/lib/classes'),
227+
'@lib': path.resolve(__dirname, '../src/lib'),
227228
'@constants': path.resolve(__dirname, '../src/lib/constants')
228229
},
229230
plugins: [

package-lock.json

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

package.json

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@inrupt/solid-react-components",
3-
"version": "0.4.4",
3+
"version": "0.5.0",
44
"description": "Solid React Components",
55
"scripts": {
66
"start": "node scripts/start.js",
@@ -23,7 +23,7 @@
2323
"type": "git",
2424
"url": "git+https://github.com/Inrupt-inc/solid-react-components"
2525
},
26-
"homepage": "https://solid.inrupt.com/docs",
26+
"homepage": "https://solidproject.org",
2727
"contributors": [
2828
{
2929
"name": "Justin Bingham",
@@ -35,35 +35,49 @@
3535
},
3636
{
3737
"name": "Pablo Rodriguez",
38-
"email": "pablo.rodriguez@janeirodigital.com"
38+
"email": ""
3939
},
4040
{
4141
"name": "Jairo Campos",
42-
"email": "jairo.campos@janeirodigital.com"
42+
"email": ""
4343
},
4444
{
4545
"name": "Arne Hassel",
4646
"email": "arneh@inrupt.com"
47+
},
48+
{
49+
"name": "Angel Araya",
50+
"email": "angel.araya@janeirodigital.com"
51+
},
52+
{
53+
"name": "Eliamar Agüero",
54+
"email": "eliamar.aguero@janeirodigital.com"
4755
}
4856
],
4957
"license": "MIT",
5058
"dependencies": {
5159
"@babel/runtime": "^7.1.2",
60+
"@inrupt/solid-sdk-forms": "0.1.0",
5261
"@rdfjs/data-model": "^1.1.1",
5362
"@shexjs/core": "^1.0.0-alpha.4",
63+
"@shexjs/loader": "^1.0.0-alpha.5",
5464
"@shexjs/parser": "^1.0.0-alpha.4",
55-
"@solid/react": "^1.6.0",
65+
"@solid/query-ldflex": "^2.6.0",
66+
"@solid/react": "^1.8.0",
67+
"date-fns": "^2.8.0",
5668
"file-type": "^10.7.1",
5769
"html-webpack-include-assets-plugin": "^1.0.6",
5870
"jsonld": "^1.6.2",
5971
"ldflex": "^2.4.0",
6072
"lodash": "^4.17.15",
6173
"mime-types": "^2.1.24",
62-
"moment": "^2.24.0",
6374
"n3": "^1.1.1",
6475
"rdflib": "^0.20.1",
76+
"react-color": "^2.17.3",
77+
"react-datepicker": "^2.9.6",
6578
"react-router-dom": "^4.3.1",
6679
"react-select": "^2.2.0",
80+
"request-promise": "^4.2.5",
6781
"solid-auth-client": "^2.3.0",
6882
"unique": "0.0.1",
6983
"unique-string": "^1.0.0"
@@ -143,7 +157,7 @@
143157
"terser-webpack-plugin": "1.1.0",
144158
"uglify-js": "^3.6.0",
145159
"url-loader": "1.1.1",
146-
"webpack": "4.19.1",
160+
"webpack": "^4.41.2",
147161
"webpack-dev-server": "3.1.14",
148162
"webpack-manifest-plugin": "2.0.4",
149163
"workbox-webpack-plugin": "3.6.3"
@@ -200,6 +214,7 @@
200214
"@contex": "<rootDir>/src/lib/context",
201215
"@testSetup": "<rootDir>/src/test/setup",
202216
"@classes": "<rootDir>/src/lib/classes",
217+
"@lib": "<rootDir>/src/lib",
203218
"@constants": "<rootDir>/src/lib/constants",
204219
"^.+\\.module\\.(css|sass|scss)$": "identity-obj-proxy"
205220
},

src/demo/App.js

Lines changed: 128 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import React, { useEffect, useState, useCallback } from 'react';
22
import { useWebId } from '@solid/react';
33
import styled from 'styled-components';
4+
// import { FormModel as FormModelClass } from '@inrupt/solid-sdk-forms';
45
import SolidImg from '../assets/solid_logo.png';
5-
import { ProviderLogin, Uploader, ProfileUploader, useNotification } from '../lib';
6+
import {
7+
ProviderLogin,
8+
Uploader,
9+
ProfileUploader,
10+
useNotification,
11+
FormModel,
12+
AutoSaveDefaultSpinner,
13+
ProfileViewer
14+
} from '@lib';
615
import { AccessControlList } from '@classes';
7-
import HandleShexForm from './components';
16+
import { NotificationTypes } from '@constants';
817

918
const HeaderWrapper = styled.section`
1019
margin-top: 60px;
@@ -23,17 +32,6 @@ const Headline = styled.h1`
2332
font-weight: 300;
2433
`;
2534

26-
const ShexFormComponent = styled.div`
27-
border-top: 1px solid black;
28-
29-
input {
30-
margin: 20px 0;
31-
padding: 10px;
32-
width: 100%
33-
box-sizing: border-box;
34-
}
35-
`;
36-
3735
const NotificationSection = styled.div`
3836
button {
3937
&:disabled {
@@ -59,21 +57,46 @@ const Header = () => {
5957
};
6058

6159
const App = () => {
62-
const [userInbox, setUserInbox] = useState(null);
60+
const [userWebID, setUserWebID] = useState('');
61+
6362
const webId = useWebId();
64-
const { fetchNotification, notification, createNotification, discoverInbox } = useNotification(
63+
const { notification, createNotification, discoverInbox, fetchNotification } = useNotification(
6564
webId
6665
);
6766

68-
const onChange = useCallback((event: Event) => {
67+
const onWebIDChange = useCallback((event: Event) => {
6968
const { target } = event;
70-
setUserInbox(target.value);
69+
setUserWebID(target.value);
7170
});
7271

7372
const init = async () => {
74-
const result = await discoverInbox(webId);
73+
/*
74+
* This code snippet will fetch notifications of a given inbox, running the full ShEx validation and everything
75+
* Comment out if you want to speed up App.js rendering
76+
*/
77+
/*
78+
const inboxes = [{ path: 'https://jmartin.inrupt.net/public/games/tictactoe/inbox/', inboxName: 'Global Inbox', shape: 'default' }];
79+
await fetchNotification(inboxes);
80+
console.log(notification);
81+
*/
82+
/*
83+
* This code snippet will run a form model conversion on a given shex shape.
84+
* Comment this out if you want to increase App.js performance. To enable, uncomment this
85+
* section and also the import statement for FormModelClass
86+
*/
87+
/*
88+
const formModel = new FormModelClass(
89+
'https://solidsdk.inrupt.net/public/FormLanguage/examples/ShEx/decimal.shex',
90+
'https://jmartin.inrupt.net/profile/card#me'
91+
);
92+
const schema = await formModel.parseSchema(
93+
'https://solidsdk.inrupt.net/public/FormLanguage/examples/ShEx/decimal.shex'
94+
);
95+
const formModelOutput = await formModel.parseShEx(schema);
7596
76-
fetchNotification([{ path: result, inboxName: 'Global App' }]);
97+
// eslint-disable-next-line no-console
98+
console.log(formModelOutput, 'model new');
99+
*/
77100
};
78101

79102
const createAcl = async () => {
@@ -87,18 +110,98 @@ const App = () => {
87110
}
88111
};
89112

113+
const sendSampleNotification = async () => {
114+
try {
115+
// Discover the inbox url from the resource, using ldp:inbox predicate
116+
const inboxUrl = await discoverInbox(userWebID);
117+
// The actor in this case is the current application, so we can use the current URL
118+
// Removing actor temporarily until we figure out how to link applications
119+
// const actor = window.location.href;
120+
121+
if (!inboxUrl) {
122+
throw new Error('Inbox not found');
123+
}
124+
125+
createNotification(
126+
{
127+
title: 'Notification Example',
128+
summary: 'This is a basic solid notification example.',
129+
actor: 'https://solidsdk.inrupt.net/profile/card#me'
130+
},
131+
inboxUrl,
132+
NotificationTypes.ANNOUNCE
133+
);
134+
} catch (ex) {
135+
// eslint-disable-next-line no-console
136+
console.log(ex);
137+
}
138+
};
139+
90140
useEffect(() => {
91141
if (webId) init();
92142
}, [notification.notify, webId]);
93143

94144
return (
95145
<DemoWrapper>
96146
<Header />
147+
<ProfileViewer
148+
{...{
149+
webId: 'https://jmartin.inrupt.net/profile/card#me',
150+
direction: 'down',
151+
viewMoreText: 'See Profile',
152+
onError: error => {
153+
// eslint-disable-next-line no-console
154+
console.log('ERROR', error.statusText);
155+
},
156+
onClick: false
157+
}}
158+
>
159+
<span>James</span>
160+
</ProfileViewer>
161+
162+
<br />
97163
<button type="button" onClick={createAcl}>
98164
Create ACL
99165
</button>
100166
<p>{JSON.stringify(notification && notification.notifications)}</p>
101167
<ProviderLogin callbackUri={`${window.location.origin}/`} />
168+
<FormModel
169+
{...{
170+
modelPath: 'https://khoward.dev.inrupt.net/public/FormModel/datetime.ttl#formRoot',
171+
podPath: 'https://jmartin.inrupt.net/profile/card#me',
172+
settings: {
173+
theme: {
174+
inputText: 'sdk-input',
175+
inputCheckbox: 'sdk-checkbox checkbox',
176+
inputTextArea: 'sdk-textarea'
177+
},
178+
savingComponent: AutoSaveDefaultSpinner
179+
},
180+
viewer: false,
181+
onError: error => {
182+
// eslint-disable-next-line no-console
183+
console.log(error, 'error');
184+
},
185+
onSuccess: success => {
186+
// eslint-disable-next-line no-console
187+
console.log(success);
188+
},
189+
onSave: response => {
190+
// eslint-disable-next-line no-console
191+
console.log(response);
192+
},
193+
onAddNewField: response => {
194+
// eslint-disable-next-line no-console
195+
console.log(response);
196+
},
197+
onDelete: response => {
198+
// eslint-disable-next-line no-console
199+
console.log(response);
200+
}
201+
}}
202+
autoSave
203+
liveUpdate
204+
/>
102205
<Uploader
103206
{...{
104207
fileBase: 'Your POD folder here',
@@ -116,34 +219,16 @@ const App = () => {
116219
render: props => <ProfileUploader {...{ ...props }} />
117220
}}
118221
/>
119-
{webId && (
120-
<ShexFormComponent>
121-
<HandleShexForm {...{ webId }} />
122-
</ShexFormComponent>
123-
)}
124222
<NotificationSection>
125-
<h3>Create notification example using your inbox</h3>
223+
<h3>Create notification example using a WebID or Resource path</h3>
126224
<input
127225
type="text"
128-
placeholder="Inbox Path"
129-
name="userInbox"
130-
defaultValue=""
131-
onChange={onChange}
132-
value={userInbox}
226+
placeholder="WebID or Resource"
227+
name="userWebID"
228+
onChange={onWebIDChange}
229+
value={userWebID}
133230
/>
134-
<button
135-
type="button"
136-
disabled={!userInbox}
137-
onClick={() =>
138-
createNotification(
139-
{
140-
title: 'Notification Example',
141-
summary: 'This is a basic solid notification example.'
142-
},
143-
userInbox
144-
)
145-
}
146-
>
231+
<button type="button" disabled={!userWebID} onClick={sendSampleNotification}>
147232
Create notification
148233
</button>
149234
</NotificationSection>

0 commit comments

Comments
 (0)