@@ -5,10 +5,13 @@ import * as React from 'react';
55
66export interface IValidations {
77 required : boolean ;
8- validations : Dictionary < unknown > | { } ;
8+ validations : ( Dictionary < unknown > | { } ) & { deprecated ?: boolean } ;
99}
1010
11- export const Validations : React . FunctionComponent < IValidations > = ( { required, validations } ) => {
11+ export const Validations : React . FunctionComponent < IValidations > = ( {
12+ required,
13+ validations : { deprecated, ...validations } ,
14+ } ) => {
1215 const validationCount = Object . keys ( validations ) . length ;
1316
1417 const requiredElem = (
@@ -18,49 +21,54 @@ export const Validations: React.FunctionComponent<IValidations> = ({ required, v
1821 </ div >
1922 ) ;
2023
21- return validationCount ? (
22- < Popover
23- boundary = "window"
24- interactionKind = "hover"
25- content = {
26- < div className = "p-5" style = { { maxHeight : 500 , maxWidth : 400 } } >
27- { Object . keys ( validations ) . map ( ( key , index ) => {
28- const validation = validations [ key ] ;
24+ return (
25+ < >
26+ { deprecated ? < span className = "ml-2 text-orange-7 dark:text-orange-6" > deprecated</ span > : null }
27+ { validationCount ? (
28+ < Popover
29+ boundary = "window"
30+ interactionKind = "hover"
31+ content = {
32+ < div className = "p-5" style = { { maxHeight : 500 , maxWidth : 400 } } >
33+ { Object . keys ( validations ) . map ( ( key , index ) => {
34+ const validation = validations [ key ] ;
2935
30- let elem = null ;
31- if ( Array . isArray ( validation ) ) {
32- elem = validation . map ( ( v , i ) => (
33- < div key = { i } className = "mt-1 mr-1 flex items-center" >
34- < div className = "px-1 bg-gray-2 dark:bg-gray-8 font-bold text-sm rounded" > { String ( v ) } </ div >
35- { i < validation . length - 1 ? < div > ,</ div > : null }
36- </ div >
37- ) ) ;
38- } else if ( typeof validation === 'object' ) {
39- elem = (
40- < div className = "m-1 px-1 bg-gray-2 dark:bg-gray-8 font-bold text-sm rounded" key = { index } >
41- { '{...}' }
42- </ div >
43- ) ;
44- } else {
45- elem = (
46- < div className = "m-1 px-1 bg-gray-2 dark:bg-gray-8 font-bold text-sm rounded" key = { index } >
47- { JSON . stringify ( validation ) }
48- </ div >
49- ) ;
50- }
36+ let elem = null ;
37+ if ( Array . isArray ( validation ) ) {
38+ elem = validation . map ( ( v , i ) => (
39+ < div key = { i } className = "mt-1 mr-1 flex items-center" >
40+ < div className = "px-1 bg-gray-2 dark:bg-gray-8 font-bold text-sm rounded" > { String ( v ) } </ div >
41+ { i < validation . length - 1 ? < div > ,</ div > : null }
42+ </ div >
43+ ) ) ;
44+ } else if ( typeof validation === 'object' ) {
45+ elem = (
46+ < div className = "m-1 px-1 bg-gray-2 dark:bg-gray-8 font-bold text-sm rounded" key = { index } >
47+ { '{...}' }
48+ </ div >
49+ ) ;
50+ } else {
51+ elem = (
52+ < div className = "m-1 px-1 bg-gray-2 dark:bg-gray-8 font-bold text-sm rounded" key = { index } >
53+ { JSON . stringify ( validation ) }
54+ </ div >
55+ ) ;
56+ }
5157
52- return (
53- < div key = { index } className = "py-1 flex items-baseline" >
54- < div className = "font-medium pr-2" > { key } :</ div >
55- < div className = "flex-1 flex flex-wrap justify-end" > { elem } </ div >
56- </ div >
57- ) ;
58- } ) }
59- </ div >
60- }
61- target = { requiredElem }
62- />
63- ) : (
64- requiredElem
58+ return (
59+ < div key = { index } className = "py-1 flex items-baseline" >
60+ < div className = "font-medium pr-2" > { key } :</ div >
61+ < div className = "flex-1 flex flex-wrap justify-end" > { elem } </ div >
62+ </ div >
63+ ) ;
64+ } ) }
65+ </ div >
66+ }
67+ target = { requiredElem }
68+ />
69+ ) : (
70+ requiredElem
71+ ) }
72+ </ >
6573 ) ;
6674} ;
0 commit comments