-              
-                register:{" "}
-                {`(name: string, RegisterOptions?) => ({ onChange, onBlur, name, ref })`}
-              
-            
-
-            diff --git a/src/components/ApiRefTable.module.css b/src/components/ApiRefTable.module.css deleted file mode 100644 index 4fd5eddc7..000000000 --- a/src/components/ApiRefTable.module.css +++ /dev/null @@ -1,25 +0,0 @@ -.fieldset { - padding: 10px 15px; - border: 1px solid var(--color-light-blue); - border-radius: 4px; -} - -.fieldset > legend { - padding: 0 10px; -} - -.fieldset > label { - padding-bottom: 15px; - display: block; - cursor: pointer; -} - -.fieldset > label:nth-child(2) { - padding-top: 10px; -} - -.fieldset > label > input { - margin-right: 10px; - top: -2px; - position: relative; -} diff --git a/src/components/ApiRefTable.tsx b/src/components/ApiRefTable.tsx deleted file mode 100644 index 4fc0897f4..000000000 --- a/src/components/ApiRefTable.tsx +++ /dev/null @@ -1,804 +0,0 @@ -import { useState } from "react" -import CodeArea from "./CodeArea" -import generic from "../data/generic" -import apiData from "../data/api" -import typographyStyles from "../styles/typography.module.css" -import tableStyles from "../styles/table.module.css" -import styles from "./ApiRefTable.module.css" -import register from "./codeExamples/register" -import registerTs from "./codeExamples/registerTs" - -export default function ApiRefTable({ api }: { api: typeof apiData }) { - const [isStandard, toggleOption] = useState(true) - - return ( - <> - {api.register.description} - -
-                Input {generic.name}
-               | 
-              {api.register.example} | -
|---|---|
-                register("firstName")
-               | 
-              
-                {`{firstName: 'value'}`}
-               | 
-            
-                register("name.firstName")
-               | 
-              
-                {`{name: { firstName: 'value' }}`}
-               | 
-            
-                register("name.firstName.0")
-               | 
-              
-                {`{name: { firstName: [ 'value' ] }}`}
-               | 
-            
- Tip:: What's happened to the - input after invoke register API: -
-{api.register.selectHelp}
- - - -| - {generic.name} - | -- {generic.description} - | -- {generic.codeExample} - | -
|---|---|---|
-                ref
-                - React.Ref
-               | 
-              React element ref | -
-                 | 
-            
-                required
-                - 
-                  {isStandard
-                    ? "boolean"
-                    : `string |
-{
-  value: boolean,
-  message: string
-}`}
-                
-               | 
-              {api.register.validation.required} | -
-                 | 
-            
-                maxLength
-                - 
-                  
-               | 
-              {api.register.validation.maxLength} | -
-                 | 
-            
-                minLength
-                - 
-                  
-               | 
-              {api.register.validation.minLength} | -
-                 | 
-            
-                max
-                - 
-                  
-               | 
-              {api.register.validation.max} | -
-                 | 
-            
-                min
-                - 
-                  
-               | 
-              {api.register.validation.min} | -
-                 | 
-            
-                pattern
-                - 
-                  
-               | 
-              {api.register.validation.pattern} | -
-                 | 
-            
-                validate
-                - 
-                  Function | Object
-                
-               | 
-              {api.register.validation.validate} | -
-                 error message TS only support string` - } - })} -/> -// object of callback functions - parseInt(v) > 0, - lessThanTen: v => parseInt(v) < 10, - validateNumber: (_, values) => - !!(values.number1 + values.number2), - checkUrl: async () => await fetch(), - }` - : `{ - positive: v => parseInt(v) > 0 || 'should be greater than 0', - lessThanTen: v => parseInt(v) < 10 || 'should be lower than 10', - validateNumber: (_: number, formValues: FormValues) => { - return formValues.number1 + formValues.number2 === 3 || 'Check sum number'; - }, - // you can do asynchronous validation as well - checkUrl: async () => await fetch() || 'error message', // JS only:error message TS only support string - messages: v => !v && ['test', 'test2'] - }` - } - })} -/> -`} - /> - | 
-            
| 
-                valueAsNumber:
-                 - boolean
-               | 
-              
-                 
-                  Returns a Number normally. If something goes wrong{" "}
-                   
  | 
-              
-                 | 
-            
| 
-                valueAsDate:
-                 - boolean
-               | 
-              
-                 
-                  Returns a  
  | 
-              
-                 | 
-            
| 
-                setValueAs:
-                 - {`
-               | 
-              
-                 Return input value by running through the function. -
  | 
-              
-                 | 
-            
-                disabled
-                - 
-                  boolean = false
-                
-               | 
-              
-                 
-                  Set  
 
-                     
-                    For schema validation, you can leverage the{" "}
-                      | 
-              
-                 | 
-            
-                onChange
-                - {`(e: SyntheticEvent) => void`}
-               | 
-              
-                 
-                    | 
-              
-                 | 
-            
-                onBlur
-                - {`(e: SyntheticEvent) => void`}
-               | 
-              
-                 
-                    | 
-              
-                 | 
-            
-                value
-                - unknown
-               | 
-              
-                 
-                  Set up value for the registered input. This prop should be
-                  utilised inside   | 
-              
-                 | 
-            
| 
-                shouldUnregister:
-                 - boolean
-               | 
-              
-                 - Input will be unregistered after unmount and defaultValues - will be removed as well. - -
-                  Note: this prop should be avoided when using with{" "}
-                    | 
-              
-                 | 
-            
| 
-                deps:
-                 - 
-                  string | string[]
-                
-               | 
-              
-                 
-                  Validation will be triggered for the dependent inputs,it only
-                  limited to   | 
-              
-                 | 
-            
-              name is required and unique (except
-              native radio and checkbox). Input name supports both dot and
-              bracket syntax, which allows you to easily create nested form
-              fields.
-            
-              name can neither start with a number nor use number
-              as key name. Please avoid special characters as well.
-            
-              we are using dot syntax only for typescript usage consistency, so
-              bracket [] will not work for array form value.
-            
-              disabled input will result in an{" "}
-              undefined form value. If you want to prevent users
-              from updating the input, you can use readOnly or
-              disable the entire {`
-              To produce an array of fields, input names should be followed by a{" "}
-              dot and number. For example: test.0.data
-            
- Changing the name on each render will result in new inputs being - registered. It's recommended to keep static names for each - registered input. -
-- Input value and reference will no longer gets removed based on - unmount. You can invoke unregister to remove that value and - reference. -
-
-              Individual register option can't be removed by{" "}
-              undefined or {`{}`}. You can update
-              individual attribute instead.
-            
-              There are certain keyword which need to avoid before conflicting
-              with type check. They are ref, _f
-            
-          The following video explain register API in detail.
-        
- Register uncontrolled/controlled inputs -
- -
-              
-                register:{" "}
-                {`(name: string, RegisterOptions?) => ({ onChange, onBlur, name, ref })`}
-              
-            
-
-