/* * Elements allow us to use partially typed default jsx components from main URLsLab app. * All jsx elements properties are required by default, set them to default undefined value that represents default behavior if property is not used in component. */ import React from 'react'; import JSXButton from '../../../../src/elements/Button'; import JSXSingleSelectMenu from '../../../../src/elements/SingleSelectMenu'; import JSXTextArea from '../../../../src/elements/Textarea'; import JSXInputField from '../../../../src/elements/InputField'; import JSXCheckbox from '../../../../src/elements/Checkbox'; import JSXTooltip from '../../../../src/elements/Tooltip'; import { InfoTooltipIcon } from './InfoTooltipIcon'; // Customized SingleSelectMenu element, with ability to use also tooltip react component in label. // Default component inserts label text using "dangerouslySetInnerHTML" what disallow us to use another components in label. type SingleSelectMenuType = Partial<{ className: string name: string style: React.CSSProperties, items: {[key:string]: string} description: string value: string, defaultValue: string, defaultAccept: boolean autoClose: boolean required: boolean disabled: boolean isFilter: boolean onChange: ( value: string ) => void, dark: boolean, tooltipLabel: { tooltip: string, label: string noWrapText?: boolean }, labels: React.ReactElement[] | HTMLElement[] }> & React.PropsWithChildren export const SingleSelectMenu: React.FC = React.memo( ( { tooltipLabel, children, className = undefined, name = undefined, style = undefined, items = undefined, description = undefined, value = undefined, defaultValue = undefined, defaultAccept = undefined, autoClose = undefined, disabled = undefined, isFilter = undefined, required = undefined, onChange = undefined, dark = undefined, labels = undefined, }:SingleSelectMenuType ) => { return ( <> { tooltipLabel ?
{ tooltipLabel.label }
: null } { tooltipLabel ? null : children } ); } ); SingleSelectMenu.displayName = 'SingleSelectMenu'; type TooltipType = Partial<{ active: boolean center: boolean className: string style: React.CSSProperties width: string }> & React.PropsWithChildren export const Tooltip:React.FC = React.memo( ( { active, center, className, width, style, children, }: TooltipType ) => { return { children }; } ); Tooltip.displayName = 'Tooltip'; type CheckboxType = Partial<{ defaultValue: boolean value: boolean textBefore: boolean smallText: boolean readOnly: boolean disabled: boolean radial: boolean hasComponent: boolean name: string className: string onChange: ( isChecked: boolean ) => void }> & React.PropsWithChildren export const Checkbox: React.FC = React.memo( ( { defaultValue = undefined, value = undefined, hasComponent = undefined, smallText = undefined, disabled = undefined, readOnly = undefined, radial = undefined, name = undefined, className = undefined, onChange = undefined, textBefore = undefined, children, }: CheckboxType ) => { return { children }; } ); Checkbox.displayName = 'Checkbox'; type ButtonType = Partial<{ className: string style: React.CSSProperties type: 'button' | 'submit' | 'reset' active: boolean danger: boolean disabled: boolean href: string onClick: () => void target: string }> & React.PropsWithChildren export const Button: React.FC = React.memo( ( { children, active = undefined, danger = undefined, type = undefined, style = undefined, className = undefined, disabled = undefined, onClick = undefined, href = undefined, target = undefined, }:ButtonType ) => { return { children }; } ); Button.displayName = 'Button'; type TextAreaType = Partial<{ defaultValue: string autoFocus: boolean newLineSeparator: boolean placeholder: string liveUpdate: boolean className: string readonly: boolean disabled: boolean required: boolean title: string label: string description: string labelInline: boolean onChange: ( value: string ) => void style: React.CSSProperties rows: number allowResize: boolean }> & React.PropsWithChildren export const TextArea: React.FC = React.memo( ( { allowResize, children, defaultValue = undefined, autoFocus = undefined, placeholder = undefined, liveUpdate = undefined, className = undefined, readonly = undefined, disabled = undefined, newLineSeparator = undefined, title = undefined, label = undefined, description = undefined, labelInline = undefined, required = undefined, onChange = undefined, style = undefined, rows = undefined, }: TextAreaType ) => { return { children }; } ); TextArea.displayName = 'TextArea'; type InputFieldType = Partial<{ type: 'text' | 'email' | 'number' | 'url' defaultValue: number | string value: number | string isLoading: boolean autoFocus: boolean placeholder: string min: number max: number message: string liveUpdate: boolean className: string readonly: boolean disabled: boolean required: boolean label: string title: string description: string labelInline: boolean style: React.CSSProperties onChange: ( value: string | number ) => void // follow type by source jsx element where onChange manipulate with direct value instead of event onKeyDown: ( event: KeyboardEvent ) => void onKeyUp: ( event: KeyboardEvent ) => void onBlur: ( event: FocusEvent ) => void onFocus: ( event: FocusEvent ) => void }> & React.PropsWithChildren export const InputField: React.FC = React.memo( ( { defaultValue = undefined, value = undefined, isLoading = undefined, autoFocus = undefined, placeholder = undefined, message = undefined, liveUpdate = undefined, className = undefined, type = undefined, min = undefined, max = undefined, required = undefined, readonly = undefined, disabled = undefined, title = undefined, label = undefined, description = undefined, labelInline = undefined, onChange = undefined, onKeyDown = undefined, onBlur = undefined, onFocus = undefined, onKeyUp = undefined, children = undefined, style = undefined }: InputFieldType, ) => { return { children }; } ); InputField.displayName = 'InputField';