Skip to content

Commit

Permalink
fix API documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Nickolay Stepanov (Nick) committed Mar 11, 2022
1 parent bb2f495 commit 6647809
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 33 deletions.
61 changes: 38 additions & 23 deletions doc/src/pages/api/API.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import styles from './API.module.css';

export type APIProps = {};

const PREFIX = process.env.prefixMOD || "/";

const CONTENT = [
{
method: "<b>formState</b>",
Expand All @@ -13,12 +15,12 @@ const CONTENT = [
},
{
method: "<b>setViewMode</b>: (viewMode: boolean) => boolean",
desc: "Set view mode in a form.",
desc: "Set view mode of form.",
type: "Inside form"
},
{
method: "<b>isViewMode</b>: () => boolean",
desc: "Check a form in view mode.",
desc: "Check view mode endabled.",
type: "Inside form"
},
{
Expand All @@ -45,13 +47,26 @@ const CONTENT = [
type: "Inside form"
},
{
method: "<b>setValue</b>: (inputName: InputName, inputValue: InputValue, skipUpdate?: boolean | undefined, inputId?: GroupInputId | undefined) => false | FormState",
desc: "Set value of input or item of group inputs. <br/> - If property <b>skipUpdate</b> is true, the rendering will be canceled. <br/> - If using property <b>inputId</b> will set value for a item of group input.<br/> Return a form state or false.",
method: "<b>getValue</b>: (inputName?: string, props?: { inputId?: GroupInputId; cloneDeep?: boolean } ) => ",
desc: "Get value of input or form value.<br/><br/> - If <b>inputName</b> filled return an input value else a form value. <br/> - If <b>inputId</b> filled return value of group item.<br/> - Property <b>cloneDeep</b> return clonned value - use it if modify it then.",
type: "Inside form"
},
{
method: `<b>setValue</b>: (
inputName: InputName,
inputValue: InputValue,
props?: {
skipUpdate?: boolean;
inputId?: GroupInputId;
skipValidation?: boolean;
}) => false | FormState`,
desc: "Set value of input or group item. <br/> - If property <b>skipUpdate</b> is true, the rendering will be canceled. <br/> - If using property <b>inputId</b> will set value for a group item.<br/> Return a new form state or false.",
type: "Inside form"
},
{
method: "<b>setValues</b>: (inputsValues: FormValue) => false | FormState",
desc: "Set value for a multiple inputs.",
method: `<b>setValues</b>: ( inputsValues: FormValue,
props?: { init?: boolean; skipUpdate?: boolean }) => false | FormState`,
desc: `Set value for a multiple inputs. <br/> - If <b>init</b> has true value set init value one time (for edit mode). Please reed details <a href="/#${PREFIX}editmode/">here</a> <br/> - If <b>skipUpdate</b> skiped rendering. <br/>`,
type: "Inside form"
},
{
Expand All @@ -60,8 +75,8 @@ const CONTENT = [
type: "Inside form"
},
{
method: "<b>getError</b>: (inputName: InputName, inputId?: GroupInputId | undefined) => string | null",
desc: "Get error of input or item of group. Return a message of error or null if value is valid.",
method: "<b>getError</b>: (inputName: InputName, props?: { inputId?: GroupInputId }) => string | null",
desc: "Get error of input or group item. Return a message of error or null if value is valid.",
type: "Inside form"
},
{
Expand All @@ -70,19 +85,19 @@ const CONTENT = [
type: "Inside form"
},
{
method: "<b>useRefMod</b>: (inputName: InputName) => refMod",
desc: "Create a reference object for input component.<br/> Use it only for make smart inputs.",
method: "<b>isVisible</b>: (inputName: string) => boolean",
desc: "Check if a input is visible. Using for an optional inputs.",
type: "Inside form"
},
{
method: "<b>isVisible</b>: (inputName: InputName) => boolean",
desc: "Check if a input is visible. Using for a optional inputs.",
method: "<b>useRefMod</b>: (inputName: InputName) => refMod",
desc: "Create a reference object for smart input component.<br/>",
type: "Inside form"
},
];


const CONTENT_UNCONTROLLED = [
const CONTENT_SMART = [
{
method: "<b>refMod</b>",
desc: "The link of smart input with API.",
Expand All @@ -100,23 +115,23 @@ const CONTENT_UNCONTROLLED = [
},
{
method: `<b>refMod.getError</b>: (params?: {
inputId?: GroupInputId | undefined;
} | undefined) => string | null`,
desc: "Get error of input or item of group input.",
inputId?: GroupInputId;
}) => string | null`,
desc: "Get error of input or group item.",
type: "Inside smart input (UI component)."
},
{
method: `<b>refMod.getValue</b>: (params?: {
inputId?: GroupInputId | undefined;
} | undefined) => InputValue`,
desc: "Get value of input or item of group input.",
inputId?: GroupInputId;
}) => InputValue`,
desc: "Get value of input or group item.",
type: "Inside smart input (UI component)."
},
{
method: `<b>refMod.isVisible</b>: (params?: {
inputId?: GroupInputId | undefined;
} | undefined) => boolean`,
desc: "Check if optional input or item of group is visible. Using for optional inputs.",
inputId?: GroupInputId;
}) => boolean`,
desc: "Check if optional input or group item is visible. Using for optional inputs.",
type: "Inside smart input (UI component)."
},
]
Expand All @@ -134,7 +149,7 @@ export const API = () => {
};

const renderUncontrolled = () => {
return CONTENT_UNCONTROLLED.map((content, index) => {
return CONTENT_SMART.map((content, index) => {
return (<tr key={index}>
<td dangerouslySetInnerHTML={{__html: content.method}}></td>
<td dangerouslySetInnerHTML={{__html: content.desc}}></td>
Expand Down
4 changes: 2 additions & 2 deletions doc/src/pages/dynamic/Reference/_docs/part_4.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export default `
<div class="steps">
<div class="steps-header">Steps</div>
Step 1: Set input-id (input-id is ID of item group) and reference in input element(<b>line 11</b>).<br/>
Step 2: Get errors for item of group(<b>line 12</b>).<br/>
Step 1: Set input-id (input-id is id of group item) and reference in input element(<b>line 11</b>).<br/>
Step 2: Get errors for group item(<b>line 12</b>).<br/>
</div>
`
2 changes: 1 addition & 1 deletion doc/src/pages/rules/Custom/_docs/part_2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PREFIX = process.env.prefixMOD || "/";

export default `
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</>.<br/><br/>
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</a>.<br/><br/>
`
2 changes: 1 addition & 1 deletion doc/src/pages/rules/Email/_docs/part_2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PREFIX = process.env.prefixMOD || "/";

export default `
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</>.<br/><br/>
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</a>.<br/><br/>
`
2 changes: 1 addition & 1 deletion doc/src/pages/rules/Empty/_docs/part_2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PREFIX = process.env.prefixMOD || "/";

export default `
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</>.<br/><br/>
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</a>.<br/><br/>
`
2 changes: 1 addition & 1 deletion doc/src/pages/rules/Introduction/_docs/part_2.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const PREFIX = process.env.prefixMOD || "/";

export default `
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</>.<br/><br/>
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</a>.<br/><br/>
`
2 changes: 1 addition & 1 deletion doc/src/pages/rules/Max/_docs/part_2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PREFIX = process.env.prefixMOD || "/";
export default `
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</>.<br/><br/>
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</a>.<br/><br/>
`
2 changes: 1 addition & 1 deletion doc/src/pages/rules/Min/_docs/part_2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PREFIX = process.env.prefixMOD || "/";
export default `
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</>.<br/><br/>
Please see the full infromation about form scheme <a href="/#${PREFIX}scheme/">here</a>.<br/><br/>
`
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "formmod",
"version": "1.4.4",
"version": "1.5.0",
"description": "Powerful form system for React with hooks",
"author": "Stepanov Nickolay",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export const useFormMod = (initFormState: FormState) => {
},
validate: (
updateValidation: boolean,
callback: (valide: boolean | null, formValue: FormValue) => any
callback: (valid: boolean | null, formValue: FormValue) => any
) =>
validate({
formState: getFormState(),
Expand Down

0 comments on commit 6647809

Please sign in to comment.