Skip to content

Commit

Permalink
Add paged form, conditionals in schema
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesej committed Aug 21, 2019
1 parent e091b4a commit 309e94e
Show file tree
Hide file tree
Showing 39 changed files with 18,409 additions and 7,054 deletions.
38 changes: 38 additions & 0 deletions .vscode/launch.json
@@ -0,0 +1,38 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand"],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
},
{
"type": "node",
"request": "launch",
"name": "Jest Current File",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": [
"${fileBasenameNoExtension}",
"--config",
"jest.config.js"
],
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"disableOptimisticBPs": true,
"windows": {
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
}
}
]
}
14 changes: 14 additions & 0 deletions babel.config.js
@@ -0,0 +1,14 @@
// babel.config.js
module.exports = {
presets: [
[
'@babel/preset-env',
{
targets: {
node: 'current',
},
},
],
'@babel/preset-typescript',
]
};
8 changes: 7 additions & 1 deletion build/components/schema-form-interfaces.d.ts
@@ -1,13 +1,19 @@
/// <reference types="react" />
import Ajv from 'ajv';
import { ErrorObject } from 'error';
export declare enum ActionType {
Create = 0,
Delete = 1,
Up = 2,
Down = 3
}
export interface ISchemaContainerProps {
schema: object;
path: string[];
value: object;
errors: ErrorObject | Ajv.ErrorObject[];
context: ISchemaFormContext;
onChange(value: object, path: string[]): void;
onChange(value: object, path: string[], action?: ActionType): void;
onFocus(path: string[]): void;
onBlur(): void;
}
Expand Down
4 changes: 2 additions & 2 deletions build/components/schema-form.d.ts
@@ -1,10 +1,10 @@
import React from "react";
import { ErrorObject } from "error";
import { IComponentMap, IContainerMap } from "components/schema-form-interfaces";
import { IComponentMap, IContainerMap, ActionType } from "components/schema-form-interfaces";
export interface ISchemaFormProps {
schema: object;
value: object;
onChange?(value: object, path: string[], errors: ErrorObject): void;
onChange?(value: object, path: string[], errors: ErrorObject, action?: ActionType): void;
onFocus?(path: string[]): void;
showErrors?: boolean;
components?: IComponentMap;
Expand Down
11 changes: 11 additions & 0 deletions build/components/schema-paged-form.d.ts
@@ -0,0 +1,11 @@
import React from 'react';
import { ISchemaFormProps } from 'components/schema-form';
export interface ISchemaPagedFormProps extends ISchemaFormProps {
onSubmit?(value: object): void;
onPage?(value: object, page: number): void;
makeNextLink(nextPage: number, onClick: (page: number) => void): React.ReactNode;
makePreviousLink(previousPage: number, onClick: (page: number) => void): React.ReactNode;
makeSubmitLink(onClick: () => void): React.ReactNode;
page: number;
}
export default function SchemaPagedForm(props: ISchemaPagedFormProps): JSX.Element;
4 changes: 2 additions & 2 deletions build/components/schema-submit-form.d.ts
@@ -1,7 +1,7 @@
/// <reference types="react" />
import React from 'react';
import { ISchemaFormProps } from 'components/schema-form';
export interface ISchemaSubmitFormProps extends ISchemaFormProps {
onSubmit?(value: object): void;
submitLabel?: string;
makeSubmitLink(onClick: () => void): React.ReactNode;
}
export default function SchemaSubmitForm(props: ISchemaSubmitFormProps): JSX.Element;
10 changes: 7 additions & 3 deletions build/index.css
Expand Up @@ -7,11 +7,11 @@
.sf-row {
display: flex;
justify-content: flex-end;
padding: 0.5em 1em;
padding: 0.5em 1em 0.5em 0;
}

.sf-object {
padding-left: 2em;
.sf-object-fieldset, .sf-array-fieldset {
padding-left: 1.5em;
}

.sf-row > label.sf-caption {
Expand Down Expand Up @@ -44,4 +44,8 @@
.sf-error-row {
justify-content: flex-start;
color: red;
}

.sf-buttons {
margin-top: 1.5em;
}
4 changes: 3 additions & 1 deletion build/index.d.ts
@@ -1,7 +1,9 @@
import SchemaForm, { ISchemaFormProps } from "components/schema-form";
import SchemaSubmitForm, { ISchemaSubmitFormProps } from "components/schema-submit-form";
import SchemaPagedForm, { ISchemaPagedFormProps } from "components/schema-paged-form";
import { ActionType } from "components/schema-form-interfaces";
import { getByPath, setByPath } from 'utility';
import { ErrorObject } from 'error';
import "./scss/layout.scss";
export default SchemaForm;
export { getByPath, setByPath, ISchemaFormProps, SchemaSubmitForm, ISchemaSubmitFormProps, ErrorObject };
export { getByPath, setByPath, ISchemaFormProps, SchemaSubmitForm, ISchemaSubmitFormProps, ErrorObject, ActionType, SchemaPagedForm, ISchemaPagedFormProps };
10 changes: 7 additions & 3 deletions build/index.es.css
Expand Up @@ -7,11 +7,11 @@
.sf-row {
display: flex;
justify-content: flex-end;
padding: 0.5em 1em;
padding: 0.5em 1em 0.5em 0;
}

.sf-object {
padding-left: 2em;
.sf-object-fieldset, .sf-array-fieldset {
padding-left: 1.5em;
}

.sf-row > label.sf-caption {
Expand Down Expand Up @@ -44,4 +44,8 @@
.sf-error-row {
justify-content: flex-start;
color: red;
}

.sf-buttons {
margin-top: 1.5em;
}

0 comments on commit 309e94e

Please sign in to comment.