Skip to content
This repository was archived by the owner on May 25, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f0f55d1
Merge pull request #63 from inrupt/release/0.4.0
james-martin-jd May 15, 2019
3941213
Merge pull request #69 from inrupt/release/0.4.0
james-martin-jd May 16, 2019
9f39beb
removed save functionality into submit and create new function saveForm
jairo-campos-JD May 17, 2019
78e7279
Creating only one provider
pablo-rodriguez-jd May 17, 2019
4785719
added validator class and add fetch utils
jairo-campos-JD May 17, 2019
beba75b
Fixed test to work with one provider
pablo-rodriguez-jd May 17, 2019
ba4de0e
remove update from builder component to useShex hook
jairo-campos-JD May 18, 2019
53b494c
remove updateShexJ from component render builder
jairo-campos-JD May 18, 2019
02bb6f7
Merge pull request #70 from inrupt/feature/unique-provider
jairo-campos-JD May 20, 2019
b943284
added autosave on input text
jairo-campos-JD May 20, 2019
aa2e3c2
Input labels
pablo-rodriguez-jd May 20, 2019
edbb99f
added autosave option
jairo-campos-JD May 20, 2019
67ab24f
added conditional to fire onBlur only when autoSavemode is true
jairo-campos-JD May 20, 2019
7f780a4
Merge branch 'feature/refactor-shex-hook' of https://github.com/inrup…
jairo-campos-JD May 20, 2019
14883e3
added liveUpdates
jairo-campos-JD May 21, 2019
6493b14
Merge pull request #71 from inrupt/feature/shex-form-live-update
pablo-rodriguez-jd May 21, 2019
5a02eca
fixed error on test hook
jairo-campos-JD May 21, 2019
6daba09
fixed shex form test value error
jairo-campos-JD May 21, 2019
c85ada6
remove jest.fn to avoid act issues
jairo-campos-JD May 21, 2019
e601d10
Merge pull request #72 from inrupt/release/0.4.0
james-martin-jd May 22, 2019
c50644f
Merge pull request #74 from inrupt/master
james-martin-jd May 22, 2019
60584c0
update live
jairo-campos-JD May 24, 2019
ec27b3f
added resolution conflict solution
jairo-campos-JD May 27, 2019
818ac03
move shex hook functions to util
jairo-campos-JD May 27, 2019
b8fa335
autoSave true
jairo-campos-JD May 27, 2019
16794d0
fixed owner data
jairo-campos-JD May 28, 2019
220996b
refactor and fix on conflict resolutions
jairo-campos-JD May 28, 2019
f63463f
fixed issue 467
jairo-campos-JD May 29, 2019
f2e4aaa
Fixed validation on autosave
jairo-campos-JD May 29, 2019
94081f8
fixed add new field issues
jairo-campos-JD May 29, 2019
2bc8d2c
fixed duplicate issues on websokets
jairo-campos-JD May 29, 2019
5ef9a13
fixed onerror message
jairo-campos-JD May 29, 2019
f1a112e
fixed link updates data
jairo-campos-JD May 30, 2019
77e3048
fixed parentLinkUri on empty values
jairo-campos-JD May 30, 2019
95fec80
fixed console error
jairo-campos-JD May 30, 2019
bd9de70
removed consoles
jairo-campos-JD May 30, 2019
5bf5d45
added test on shex form live
jairo-campos-JD May 30, 2019
fe92818
singlequtes
jairo-campos-JD May 30, 2019
f2f0811
added useCallback into shexHook
jairo-campos-JD May 30, 2019
bad8adc
added comments on hook
jairo-campos-JD May 30, 2019
d9963de
added comments on shex utils
jairo-campos-JD May 30, 2019
c3462b6
Merge pull request #75 from inrupt/feature/conflict-resolution
james-martin-jd May 30, 2019
acd13ee
fixed error to warning
jairo-campos-JD May 30, 2019
ed0baeb
fixed unique name form values
jairo-campos-JD May 31, 2019
14480c5
added themelanguaje to conflict resolution
jairo-campos-JD May 31, 2019
2e301ad
added themelanguaje to conflict resolution
jairo-campos-JD May 31, 2019
1fb59b6
Merge pull request #76 from inrupt/fix/conflict-resolution
james-martin-jd May 31, 2019
7d234c5
Updating version number
james-martin-jd May 31, 2019
72efe22
remove warning until user save value
jairo-campos-JD Jun 3, 2019
3dc90c3
autosave true
jairo-campos-JD Jun 3, 2019
0ca552b
type fixed on warningResolution
jairo-campos-JD Jun 3, 2019
9c899b9
Merge pull request #77 from inrupt/feature/remove-warning
james-martin-jd Jun 3, 2019
c0bbc23
Merge pull request #78 from inrupt/develop
pablo-rodriguez-jd Jun 4, 2019
584083f
Updating package version
james-martin-jd Jun 4, 2019
4652f55
Updating version and readme/changelog
james-martin-jd Jun 5, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Solid React Components Library

## 0.4.1 ( June 5, 2019 )

### Updated

* ShexFormBuilder
* LiveUpdate added to ShexForm, so any changes to the form data outside of the current application will immediately be displayed in the form in real time
* Conflict Resolution added. If two users are editing the same field at the same time, incoming changes will be displayed to the second editor, to inform them that another change has occurred
* Form now autosaves. Triggered by the onBlur event, any changes to a field will be immediately and automatically saved, rather than relying on a button to save everything at once. This is an optional form state, and can be turned on or off
* New error messages added to handle new error events, such as conflicts
* Refactors to the ShexForm components to account for new functionality

## 0.4.0 ( May 22, 2019 )

### Added
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,12 @@ In the future, labels will be generated more dynamically.
| shexUri | string | null | Required. The URL to the ShEx shape to use to render the form.
| rootShape | string | null | Optional. The shape in the shexUri file to begin parsing. If a START shape is defined in the shape, this is not necessary.
| theme | Object | null | Optional. An object (defined below) allowing custom overrides to the look and feel of the form.
| language | string | null | Optional. The language identifier to translate text. For example, 'en' or 'es'.
| languageTheme | Object | null | Optional. An object (defined below) allowing customization of the text of the form. Can be used in combination with i18n in the parent app.
| successCallback | Function | Function that writes a success message to console | Optional. Overrides the existing success callback and allows custom success functions.
| errorCallback | Function | Function that writes the error message to console | Optional. Overrides the existing error callback function.
| messageValidation | Object | null | An Object containing an array of error strings. The error strings will be used in most non-validation situations.
| autoSaveMode | Boolean | false | Optional. Determines of the form will autosave or have a save/cancel button. Default is save/cancel button.


Theme object:

Expand All @@ -218,5 +220,17 @@ Theme object:
| deleteButton | string | solid-button-shex | Custom class name for the delete button.
| form | string | solid-shex-form | Custom class name for the form.

LanguageTheme object:

| Key | Type | Default | Description
| --------------------- | ----------|---------------------------------- | -------------------------------------------------------
| language | string | 'en' | String representing the language code to use for the translations
| saveBtn | string | 'Save' | String representing the save button text
| resetBtn | string | 'Reset' | String representing the reset button text
| addButtonText | string | '+ Add new' | String representing the add new item button text
| deleteButton | string | 'Delete' | String representing the delete button text
| dropdownDefaultText | string | '- Select -' | String representing the default text for a dropdown menu


##### Shapes
A set of example shapes can be found [here](https://shexshapes.inrupt.net/public/), which show various ShEx shapes.
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
{
"name": "@inrupt/solid-react-components",
"version": "0.4.0",
"version": "0.4.1",
"description": "Solid React Components",
"main": "build/index.js",
"prettier": {
"singleQuote": true
},
"scripts": {
"start": "node scripts/start.js",
"build": "node scripts/build.js",
Expand Down
27 changes: 14 additions & 13 deletions src/demo/components/HandleShexForm/handle-shex-form.component.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useState} from 'react';
import styled from "styled-components";
import {ShexFormBuilder} from "@components";
import React, { useState } from 'react';
import styled from 'styled-components';
import { ShexFormBuilder } from '@components';

const Form = styled.form``;

Expand Down Expand Up @@ -39,23 +39,24 @@ const HandleShexForm = ({ webId }:Props) => {
}
// By default addButton and deleteButton will be Add new and Delete
const languageTheme = {
language: 'en',
saveBtn: "Save",
resetBtn: "Reset",
addButtonText: "+ Add new ",
deleteButton: "Delete",
dropdownDefaultText: "- Select -"
language: 'en',
saveBtn: 'Save',
resetBtn: 'Reset',
addButtonText: '+ Add new ',
deleteButton: 'Delete',
dropdownDefaultText: '- Select -',
warningResolution: 'Field value has been updated to:'
};

return(
<div>
<h2>Shex Form</h2>
<Form onSubmit={onSubmit}>
<Input placeholder={'Document Url'} name='documentUri' onChange={onChangeInput}/>
<Input placeholder={'ShexC Url'} name='shexUri' onChange={onChangeInput}/>
<Button type='submit'>Load Form</Button>
<Input placeholder={'Document Url'} name="documentUri" onChange={onChangeInput}/>
<Input placeholder={'ShexC Url'} name="shexUri" onChange={onChangeInput}/>
<Button type="submit">Load Form</Button>
</Form>
<ShexFormBuilder {...{ ...podData, languageTheme}} />
<ShexFormBuilder {...{ ...podData, languageTheme, autoSaveMode : true }} />
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import React from "react";
import { shexFormLabel } from "@utils";
import { ThemeShex, Language } from "@context";
import { shexUtil } from "@utils";
import { ShexConfig } from "@context";

export const AddButton = ({
addNewShexField,
expression,
defaultExpression,
allowNewFields,
text = "+ Add new"
}) => {
return (allowNewFields && (
<ThemeShex.Consumer>
{theme => (
<Language.Consumer>
{({ language, addButtonText }) => (
<button
onClick={() => addNewShexField(defaultExpression, expression)}
type="button"
className={theme && theme.addButtonStyle}
>
{addButtonText || text}{" "}
{shexFormLabel(defaultExpression, language)}
</button>
)}
</Language.Consumer>
<ShexConfig.Consumer>
{({
theme,
languageTheme: { language, addButtonText },
config: { addNewShexField }
}) => (
<button
onClick={() => addNewShexField(defaultExpression, expression)}
type="button"
className={theme && theme.addButtonStyle}
>
{addButtonText || text} {shexUtil.formLabel(defaultExpression, language)}
</button>
)}
</ThemeShex.Consumer>
</ShexConfig.Consumer>
): null);
};
Original file line number Diff line number Diff line change
@@ -1,60 +1,64 @@
import React from 'react';
import { Language } from '@context';
import { cleanup, render } from 'react-testing-library';
import { AddButton } from './add-button.component';
import 'jest-dom/extend-expect';
import React from "react";
import { ShexConfig } from "@context";
import { cleanup, render } from "react-testing-library";
import { AddButton } from "./add-button.component";
import "jest-dom/extend-expect";

afterAll(cleanup);

const languageTheme = {
language: 'en',
addButtonText: '+ Add new '
const config = {
languageTheme: {
language: "en",
addButtonText: "+ Add new "
},
theme: {},
config: {}
};

const defaultExpression = {
annotations: []
};

const setup = (props, languageTheme) => {
const setup = (props, config) => {
return (
<Language.Provider value={languageTheme}>
<ShexConfig.Provider value={config}>
<AddButton {...props} />
</Language.Provider>
</ShexConfig.Provider>
);
};

describe('Shex ShapeForm Component', () => {
describe("Shex ShapeForm Component", () => {
const component = setup(
{ allowNewFields: true, defaultExpression },
languageTheme
config
);
const { container, rerender } = render(component);

it('should renders without crashing', () => {
it("should renders without crashing", () => {
expect(container).toBeTruthy();
});

it('should renders language version', () => {
it("should renders language version", () => {
const languageTheme = {
language: 'es',
addButtonText: '+ Agregar '
language: "es",
addButtonText: "+ Agregar "
};
const component = setup(
{ allowNewFields: true, defaultExpression },
languageTheme
{...config, languageTheme}
);

rerender(component);
expect(container).toHaveTextContent('+ Agregar');
expect(container).toHaveTextContent("+ Agregar");
});

it('should not renders if allowNewField is false', () => {
it("should not renders if allowNewField is false", () => {
const component = setup(
{ allowNewFields: false, defaultExpression },
languageTheme
config
);
rerender(component);

expect(container).toHaveTextContent('');
expect(container).toHaveTextContent("");
});
});
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from "react";
import styled from "styled-components";
import { ThemeShex } from "@context";
import { Language } from "@context";
import { ShexConfig } from "@context";

const DeleteButtonWrapper = styled.button`
position: ${({ floating }) => (floating ? "absolute" : "relative")};
Expand All @@ -14,33 +13,28 @@ const DeleteButtonWrapper = styled.button`
`;

export const DeleteButton = ({
onDelete,
fieldData,
predicate,
parent,
text = "Remove"
}) => {
return (
<ThemeShex.Consumer>
{theme => (
<Language.Consumer>
{({ deleteButton }) => (
<DeleteButtonWrapper
className={theme && theme.deleteButton}
type="button"
onClick={() =>
onDelete(
predicate ? { ...fieldData, predicate } : fieldData,
parent
)
}
floating={parent}
>
{deleteButton || text}
</DeleteButtonWrapper>
)}
</Language.Consumer>
<ShexConfig.Consumer>
{({ theme, languageTheme: { deleteButton }, config: { onDelete } }) => (
<DeleteButtonWrapper
className={theme && theme.deleteButton}
type="button"
onClick={() =>
onDelete(
predicate ? { ...fieldData, predicate } : fieldData,
parent
)
}
floating={parent}
>
{deleteButton || text}
</DeleteButtonWrapper>
)}
</ThemeShex.Consumer>
</ShexConfig.Consumer>
);
};
Loading