From 43c7cff75055f72c7d59a7180ae8da2554456d8d Mon Sep 17 00:00:00 2001 From: Sebastian Date: Mon, 7 Nov 2022 19:29:47 -0300 Subject: un-uglyfy, fix: 7442 --- .../src/components/AmountField.tsx | 33 +++-- .../src/cta/InvoiceCreate/views.tsx | 2 +- .../src/cta/TransferCreate/views.tsx | 2 +- .../src/mui/TextField.stories.tsx | 4 +- .../src/mui/TextField.tsx | 9 +- .../src/mui/input/FormControl.tsx | 14 +- .../src/mui/input/FormHelperText.tsx | 2 +- .../src/mui/input/FormLabel.tsx | 6 +- .../src/mui/input/InputBase.tsx | 16 ++- .../src/mui/input/InputFilled.tsx | 4 +- .../src/mui/input/InputLabel.tsx | 6 +- .../src/mui/input/InputStandard.tsx | 4 +- .../src/wallet/ManageAccount/stories.tsx | 3 +- .../src/wallet/ManageAccount/views.tsx | 147 +++++++++++++-------- .../src/wallet/Transaction.tsx | 4 +- 15 files changed, 149 insertions(+), 107 deletions(-) (limited to 'packages/taler-wallet-webextension/src') diff --git a/packages/taler-wallet-webextension/src/components/AmountField.tsx b/packages/taler-wallet-webextension/src/components/AmountField.tsx index 79c510d2f..1c57be0df 100644 --- a/packages/taler-wallet-webextension/src/components/AmountField.tsx +++ b/packages/taler-wallet-webextension/src/components/AmountField.tsx @@ -45,23 +45,20 @@ export function AmountField({ return handler.value; } return ( - - {currency} - } - value={handler.value} - disabled={!handler.onInput} - onInput={positiveAmount} - /> - {handler.error && {handler.error}} - + {currency} + } + value={handler.value} + disabled={!handler.onInput} + onInput={positiveAmount} + /> ); } diff --git a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx index 603392b60..4970f590f 100644 --- a/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx +++ b/packages/taler-wallet-webextension/src/cta/InvoiceCreate/views.tsx @@ -78,7 +78,7 @@ export function ReadyView({ { value="disabled" /> {label && {label}} {children} - {helperText && {helperText}} + {helperText && ( + {helperText} + )} + {props.error ? ( + {props.error} + ) : undefined} ); } diff --git a/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx b/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx index 8454b0fad..e80e7f8d8 100644 --- a/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx +++ b/packages/taler-wallet-webextension/src/mui/input/FormControl.tsx @@ -22,7 +22,7 @@ import { Colors } from "../style"; export interface Props { color: Colors; disabled: boolean; - error: boolean; + error?: string; focused: boolean; fullWidth: boolean; hiddenLabel: boolean; @@ -64,7 +64,7 @@ export const FormControlContext = createContext(null); export function FormControl({ color = "primary", disabled = false, - error = false, + error = undefined, focused: visuallyFocused, fullWidth = false, hiddenLabel = false, @@ -75,9 +75,9 @@ export function FormControl({ children, }: Partial): VNode { const [filled, setFilled] = useState(false); - const [focusedState, setFocused] = useState(false); + const [focusedState, setFocused] = useState(visuallyFocused); const focused = - visuallyFocused !== undefined && !disabled ? visuallyFocused : focusedState; + focusedState !== undefined && !disabled ? focusedState : false; const value: FCCProps = { color, @@ -124,7 +124,7 @@ export interface FCCProps { // setAdornedStart, color: Colors; disabled: boolean; - error: boolean; + error: string | undefined; filled: boolean; focused: boolean; fullWidth: boolean; @@ -142,7 +142,7 @@ export interface FCCProps { const defaultContextValue: FCCProps = { color: "primary", disabled: false, - error: false, + error: undefined, filled: false, focused: false, fullWidth: false, @@ -159,7 +159,7 @@ const defaultContextValue: FCCProps = { function withoutUndefinedProperties(obj: any): any { return Object.keys(obj).reduce((acc, key) => { const _acc: any = acc; - if (obj[key] !== undefined) _acc[key] = obj[key]; + if (obj[key] !== undefined && obj[key] !== false) _acc[key] = obj[key]; return _acc; }, {}); } diff --git a/packages/taler-wallet-webextension/src/mui/input/FormHelperText.tsx b/packages/taler-wallet-webextension/src/mui/input/FormHelperText.tsx index 739b41e32..5e40ba616 100644 --- a/packages/taler-wallet-webextension/src/mui/input/FormHelperText.tsx +++ b/packages/taler-wallet-webextension/src/mui/input/FormHelperText.tsx @@ -43,7 +43,7 @@ const containedStyle = css` interface Props { disabled?: boolean; - error?: boolean; + error?: string; filled?: boolean; focused?: boolean; margin?: "dense"; diff --git a/packages/taler-wallet-webextension/src/mui/input/FormLabel.tsx b/packages/taler-wallet-webextension/src/mui/input/FormLabel.tsx index 1d4b5eff5..11404b5c1 100644 --- a/packages/taler-wallet-webextension/src/mui/input/FormLabel.tsx +++ b/packages/taler-wallet-webextension/src/mui/input/FormLabel.tsx @@ -22,7 +22,7 @@ import { useFormControl } from "./FormControl.js"; export interface Props { class?: string; disabled?: boolean; - error?: boolean; + error?: string; filled?: boolean; focused?: boolean; required?: boolean; @@ -67,9 +67,9 @@ export function FormLabel({ }); return (