From 7094df120005251c0382e2e7720034024a6b0b63 Mon Sep 17 00:00:00 2001 From: IRBorisov <8611739+IRBorisov@users.noreply.github.com> Date: Mon, 27 Nov 2023 13:50:56 +0300 Subject: [PATCH] Refactoring: props naming Use props to name ALL props and restProps to name partials props --- rsconcept/frontend/src/components/Common/Button.tsx | 4 ++-- rsconcept/frontend/src/components/Common/Checkbox.tsx | 4 ++-- rsconcept/frontend/src/components/Common/ConceptTooltip.tsx | 4 ++-- .../frontend/src/components/Common/DropdownCheckbox.tsx | 4 ++-- rsconcept/frontend/src/components/Common/FileInput.tsx | 4 ++-- rsconcept/frontend/src/components/Common/Label.tsx | 4 ++-- rsconcept/frontend/src/components/Common/MiniButton.tsx | 4 ++-- rsconcept/frontend/src/components/Common/SelectMulti.tsx | 2 +- rsconcept/frontend/src/components/Common/SelectSingle.tsx | 2 +- rsconcept/frontend/src/components/Common/SelectorButton.tsx | 4 ++-- rsconcept/frontend/src/components/Common/SwitchButton.tsx | 4 ++-- rsconcept/frontend/src/components/Common/TextArea.tsx | 4 ++-- rsconcept/frontend/src/components/Common/TextInput.tsx | 4 ++-- rsconcept/frontend/src/components/Common/Tristate.tsx | 6 ++++-- rsconcept/frontend/src/components/ConceptToaster.tsx | 2 +- rsconcept/frontend/src/components/Help/InfoConstituenta.tsx | 4 ++-- rsconcept/frontend/src/components/RSInput/RSInput.tsx | 4 ++-- rsconcept/frontend/src/components/RefsInput/RefsInput.tsx | 4 ++-- .../src/dialogs/DlgEditReference/WordformButton.tsx | 4 ++-- .../frontend/src/pages/RSFormPage/EditorRSExpression.tsx | 4 ++-- 20 files changed, 39 insertions(+), 37 deletions(-) diff --git a/rsconcept/frontend/src/components/Common/Button.tsx b/rsconcept/frontend/src/components/Common/Button.tsx index 94c3ae70..f0d6b17c 100644 --- a/rsconcept/frontend/src/components/Common/Button.tsx +++ b/rsconcept/frontend/src/components/Common/Button.tsx @@ -15,7 +15,7 @@ function Button({ colors = 'clr-btn-default', dimensions = 'w-fit h-fit', loading, - ...props + ...restProps }: ButtonProps) { const borderClass = noBorder ? '' : 'border rounded'; const padding = dense ? 'px-1' : 'px-3 py-2'; @@ -26,7 +26,7 @@ function Button({ disabled={disabled ?? loading} title={tooltip} className={`inline-flex items-center gap-2 align-middle justify-center select-none ${padding} ${colors} ${outlineClass} ${borderClass} ${dimensions} ${cursor}`} - {...props} + {...restProps} > {icon ? icon : null} {text ? {text} : null} diff --git a/rsconcept/frontend/src/components/Common/Checkbox.tsx b/rsconcept/frontend/src/components/Common/Checkbox.tsx index 4190b763..ff063524 100644 --- a/rsconcept/frontend/src/components/Common/Checkbox.tsx +++ b/rsconcept/frontend/src/components/Common/Checkbox.tsx @@ -16,7 +16,7 @@ extends Omit, 'className' | 'child function Checkbox({ id, disabled, tooltip, label, - dimensions = 'w-fit', value, setValue, ...props + dimensions = 'w-fit', value, setValue, ...restProps }: CheckboxProps) { const cursor = useMemo( () => { @@ -47,7 +47,7 @@ function Checkbox({ title={tooltip} disabled={disabled} onClick={handleClick} - {...props} + {...restProps} >
{value ? diff --git a/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx b/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx index 375dcad6..dc4e8529 100644 --- a/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx +++ b/rsconcept/frontend/src/components/Common/ConceptTooltip.tsx @@ -12,7 +12,7 @@ function ConceptTooltip({ layer='z-tooltip', place='bottom', style, - ...props + ...restProps }: ConceptTooltipProps) { const { darkMode } = useConceptTheme(); @@ -23,7 +23,7 @@ function ConceptTooltip({ className={`overflow-auto border shadow-md ${layer} ${className}`} variant={(darkMode ? 'dark' : 'light')} place={place} - {...props} + {...restProps} /> ); } diff --git a/rsconcept/frontend/src/components/Common/DropdownCheckbox.tsx b/rsconcept/frontend/src/components/Common/DropdownCheckbox.tsx index 4398ceac..2fe4afe7 100644 --- a/rsconcept/frontend/src/components/Common/DropdownCheckbox.tsx +++ b/rsconcept/frontend/src/components/Common/DropdownCheckbox.tsx @@ -8,7 +8,7 @@ interface DropdownCheckboxProps { setValue?: (newValue: boolean) => void } -function DropdownCheckbox({ tooltip, setValue, disabled, ...props }: DropdownCheckboxProps) { +function DropdownCheckbox({ tooltip, setValue, disabled, ...restProps }: DropdownCheckboxProps) { const behavior = (setValue && !disabled) ? 'clr-hover' : ''; return (
); diff --git a/rsconcept/frontend/src/components/Common/FileInput.tsx b/rsconcept/frontend/src/components/Common/FileInput.tsx index 053347d9..a6aaff04 100644 --- a/rsconcept/frontend/src/components/Common/FileInput.tsx +++ b/rsconcept/frontend/src/components/Common/FileInput.tsx @@ -17,7 +17,7 @@ extends Omit, 'className' | 'title' function FileInput({ label, acceptType, tooltip, dimensions = 'w-fit', onChange, - ...props + ...restProps }: FileInputProps) { const inputRef = useRef(null); const [fileName, setFileName] = useState(''); @@ -44,7 +44,7 @@ function FileInput({ style={{ display: 'none' }} accept={acceptType} onChange={handleFileChange} - {...props} + {...restProps} /> diff --git a/rsconcept/frontend/src/components/Common/SelectMulti.tsx b/rsconcept/frontend/src/components/Common/SelectMulti.tsx index bfa68d7f..93a500ce 100644 --- a/rsconcept/frontend/src/components/Common/SelectMulti.tsx +++ b/rsconcept/frontend/src/components/Common/SelectMulti.tsx @@ -14,7 +14,7 @@ extends Omit, 'theme'> { function SelectMulti< Option, Group extends GroupBase
); diff --git a/rsconcept/frontend/src/components/Common/TextInput.tsx b/rsconcept/frontend/src/components/Common/TextInput.tsx index 0210d663..cc4961fb 100644 --- a/rsconcept/frontend/src/components/Common/TextInput.tsx +++ b/rsconcept/frontend/src/components/Common/TextInput.tsx @@ -17,7 +17,7 @@ function TextInput({ id, label, dense, tooltip, noBorder, noOutline, allowEnter, onKeyDown, dimensions = 'w-full', colors = 'clr-input', - ...props + ...restProps }: TextInputProps) { const borderClass = noBorder ? '' : 'border'; const outlineClass = noOutline ? '' : 'clr-outline'; @@ -32,7 +32,7 @@ function TextInput({ title={tooltip} onKeyDown={!allowEnter && !onKeyDown ? preventEnterCapture : onKeyDown} className={`px-3 py-2 leading-tight truncate hover:text-clip ${colors} ${outlineClass} ${borderClass} ${dense ? 'w-full' : dimensions}`} - {...props} + {...restProps} /> ); diff --git a/rsconcept/frontend/src/components/Common/Tristate.tsx b/rsconcept/frontend/src/components/Common/Tristate.tsx index ff560367..2889d7d5 100644 --- a/rsconcept/frontend/src/components/Common/Tristate.tsx +++ b/rsconcept/frontend/src/components/Common/Tristate.tsx @@ -13,7 +13,9 @@ extends Omit { function Tristate({ id, disabled, tooltip, label, - dimensions = 'w-fit', value, setValue, ...props + dimensions = 'w-fit', + value, setValue, + ...restProps }: TristateProps) { const cursor = useMemo( () => { @@ -50,7 +52,7 @@ function Tristate({ title={tooltip} disabled={disabled} onClick={handleClick} - {...props} + {...restProps} >
{value ?
: null} diff --git a/rsconcept/frontend/src/components/ConceptToaster.tsx b/rsconcept/frontend/src/components/ConceptToaster.tsx index 5f1cc184..061075dc 100644 --- a/rsconcept/frontend/src/components/ConceptToaster.tsx +++ b/rsconcept/frontend/src/components/ConceptToaster.tsx @@ -4,7 +4,7 @@ import { useConceptTheme } from '../context/ThemeContext'; interface ToasterThemedProps extends Omit{} -function ToasterThemed({ ...props }: ToasterThemedProps) { +function ToasterThemed(props: ToasterThemedProps) { const { darkMode } = useConceptTheme(); return ( diff --git a/rsconcept/frontend/src/components/Help/InfoConstituenta.tsx b/rsconcept/frontend/src/components/Help/InfoConstituenta.tsx index 54a9f5e6..0ef5d8cb 100644 --- a/rsconcept/frontend/src/components/Help/InfoConstituenta.tsx +++ b/rsconcept/frontend/src/components/Help/InfoConstituenta.tsx @@ -6,9 +6,9 @@ extends React.HTMLAttributes { data: IConstituenta } -function InfoConstituenta({ data, ...props }: InfoConstituentaProps) { +function InfoConstituenta({ data, ...restProps }: InfoConstituentaProps) { return ( -
+

Конституента {data.alias}

Типизация: diff --git a/rsconcept/frontend/src/components/RSInput/RSInput.tsx b/rsconcept/frontend/src/components/RSInput/RSInput.tsx index e4e72a71..abe31189 100644 --- a/rsconcept/frontend/src/components/RSInput/RSInput.tsx +++ b/rsconcept/frontend/src/components/RSInput/RSInput.tsx @@ -59,7 +59,7 @@ function RSInput({ id, label, innerref, onChange, disabled, noTooltip, dimensions = 'w-full', - ...props + ...restProps }: RSInputProps) { const { darkMode, colors } = useConceptTheme(); const { schema } = useRSForm(); @@ -167,7 +167,7 @@ function RSInput({ onChange={onChange} editable={!disabled} onKeyDown={handleInput} - {...props} + {...restProps} />

); diff --git a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx index f1c5ffc8..9c931939 100644 --- a/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx +++ b/rsconcept/frontend/src/components/RefsInput/RefsInput.tsx @@ -67,7 +67,7 @@ function RefsInput({ id, label, innerref, disabled, items, initialValue, value, resolved, onFocus, onBlur, onChange, - ...props + ...restProps }: RefsInputInputProps) { const { darkMode, colors } = useConceptTheme(); const { schema } = useRSForm(); @@ -221,7 +221,7 @@ function RefsInput({ onBlur={handleFocusOut} spellCheck // spellCheck= // TODO: figure out while automatic spellcheck doesnt work or implement with extension - {...props} + {...restProps} />
); diff --git a/rsconcept/frontend/src/dialogs/DlgEditReference/WordformButton.tsx b/rsconcept/frontend/src/dialogs/DlgEditReference/WordformButton.tsx index 617cca74..f22a6ca3 100644 --- a/rsconcept/frontend/src/dialogs/DlgEditReference/WordformButton.tsx +++ b/rsconcept/frontend/src/dialogs/DlgEditReference/WordformButton.tsx @@ -8,12 +8,12 @@ interface WordformButtonProps { onSelectGrams: (grams: Grammeme[]) => void } -function WordformButton({ text, example, grams, onSelectGrams, isSelected, ...props }: WordformButtonProps) { +function WordformButton({ text, example, grams, onSelectGrams, isSelected, ...restProps }: WordformButtonProps) { return (