From 0d60da61cbd3bcec0544a4f328fc45dd065a004d Mon Sep 17 00:00:00 2001 From: Innei Date: Thu, 29 Aug 2024 19:57:54 +0800 Subject: [PATCH] fix: setting item support props Signed-off-by: Innei --- .../src/atoms/settings/integration.ts | 4 ++-- .../src/hooks/common/useInputComposition.ts | 11 +++++++-- src/renderer/src/modules/settings/control.tsx | 24 ++++++++++++++++--- .../src/modules/settings/setting-builder.tsx | 10 ++++++++ .../src/modules/settings/tabs/integration.tsx | 7 ++++++ 5 files changed, 49 insertions(+), 7 deletions(-) diff --git a/src/renderer/src/atoms/settings/integration.ts b/src/renderer/src/atoms/settings/integration.ts index c732f39ab..f8cee02bc 100644 --- a/src/renderer/src/atoms/settings/integration.ts +++ b/src/renderer/src/atoms/settings/integration.ts @@ -4,9 +4,9 @@ import { createSettingAtom } from "./helper" export const createDefaultSettings = (): IntegrationSettings => ({ enableEagle: true, - enableReadwise: true, + enableReadwise: false, readwiseToken: "", - enableInstapaper: true, + enableInstapaper: false, instapaperUsername: "", instapaperPassword: "", }) diff --git a/src/renderer/src/hooks/common/useInputComposition.ts b/src/renderer/src/hooks/common/useInputComposition.ts index 8629e78d7..b97e4a42a 100644 --- a/src/renderer/src/hooks/common/useInputComposition.ts +++ b/src/renderer/src/hooks/common/useInputComposition.ts @@ -57,10 +57,17 @@ export const useInputComposition = ( [onKeyDown], ) - return { + const ret = { onCompositionEnd: handleCompositionEnd, onCompositionStart: handleCompositionStart, onKeyDown: handleKeyDown, - isCompositionRef, + + } + Object.defineProperty(ret, "isCompositionRef", { + value: isCompositionRef, + enumerable: false, + }) + return ret as typeof ret & { + isCompositionRef: typeof isCompositionRef } } diff --git a/src/renderer/src/modules/settings/control.tsx b/src/renderer/src/modules/settings/control.tsx index 6bb6ff618..2242ac62c 100644 --- a/src/renderer/src/modules/settings/control.tsx +++ b/src/renderer/src/modules/settings/control.tsx @@ -53,14 +53,32 @@ export const SettingInput: Component<{ value: string onChange: ChangeEventHandler type: string -}> = ({ value, label, onChange, className, type }) => { + vertical?: boolean + labelClassName?: string +}> = ({ + value, + label, + onChange, + labelClassName, + className, + type, + vertical, +}) => { const id = useId() return (
- + = { description?: string onChange: (value: T[K]) => void type?: "password" + + vertical?: boolean + + componentProps?: { + labelClassName?: string + className?: string + [key: string]: any + } } & SharedSettingItem type SectionSettingItem = { @@ -97,6 +105,8 @@ export const createSettingBuilder = case "string": { ControlElement = ( ( }), defineSettingItem("readwiseToken", { label: "Readwise Access Token", + vertical: true, type: "password", description: <>You can get it here: readwise.io/access_token., }), @@ -62,10 +63,16 @@ export const SettingIntegration = () => ( }), defineSettingItem("instapaperUsername", { label: "Instapaper Username", + componentProps: { + labelClassName: "w-[150px]", + }, }), defineSettingItem("instapaperPassword", { label: "Instapaper Password", type: "password", + componentProps: { + labelClassName: "w-[150px]", + }, }), ]} />