🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
♻️ refactor(settings): migrate the credentials settings to StyleX (#21325)
Innei19e88a8adbde
diff --git a/scripts/stylexMigration/codemod/css.test.ts b/scripts/stylexMigration/codemod/css.test.tsindex 0dd12d2d6f2..3a7e901ffb9 100644--- a/scripts/stylexMigration/codemod/css.test.ts+++ b/scripts/stylexMigration/codemod/css.test.ts@@ -295,10 +295,49 @@ describe('expandShorthand', () => {['borderBottomLeftRadius', '8px'],],],- ['background', 'rgb(0 0 0 / 50%)', [['background', 'rgb(0 0 0 / 50%)']]],+ [+ 'background',+ 'rgb(0 0 0 / 50%)',+ [+ ['backgroundColor', 'rgb(0 0 0 / 50%)'],+ ['backgroundImage', 'none'],+ ],+ ],+ [+ 'background',+ '__lobeX0__',+ [+ ['backgroundColor', '__lobeX0__'],+ ['backgroundImage', 'none'],+ ],+ ],+ [+ 'background',+ 'inherit',+ [+ ['backgroundColor', 'inherit'],+ ['backgroundImage', 'inherit'],+ ],+ ],+ [+ 'background',+ 'none',+ [+ ['backgroundColor', 'transparent'],+ ['backgroundImage', 'none'],+ ],+ ],])('%s: %s', (prop, value, expected) => {expect(expandShorthand(prop, value)).toEqual(expected);});++ it.each([+ ['background', 'linear-gradient(red, blue)'],+ ['background', 'url(a.png) no-repeat'],+ ['animation', 'spin 1s linear infinite'],+ ])('rejects %s: %s, which StyleX would compile to nothing', (prop, value) => {+ expect(() => expandShorthand(prop, value)).toThrow(UnsupportedCssError);+ });});describe('isShorthandOf', () => {diff --git a/scripts/stylexMigration/codemod/css.ts b/scripts/stylexMigration/codemod/css.tsindex 8694a862751..e9f172f03f3 100644--- a/scripts/stylexMigration/codemod/css.ts+++ b/scripts/stylexMigration/codemod/css.ts@@ -225,6 +225,28 @@ export const expandShorthand = (prop: string, value: string): [string, string][]if (color.length === 1) result.push([`${prop}Color`, color[0]]);return result;}+ // StyleX compiles `background` and `animation` to no class at all, without an error.+ if (prop === 'background') {+ if (value.trim() === 'none')+ return [+ ['backgroundColor', 'transparent'],+ ['backgroundImage', 'none'],+ ];+ if (/^(?:inherit|initial|unset|revert|revert-layer)$/.test(value.trim()))+ return [+ ['backgroundColor', value],+ ['backgroundImage', value],+ ];+ const isImage = /^(?:url|image-set|(?:repeating-)?(?:linear|radial|conic)-gradient)\(/;+ // The shorthand also resets the image a component may have set.+ if (parts.length === 1 && !isImage.test(parts[0]))+ return [+ ['backgroundColor', value],+ ['backgroundImage', 'none'],+ ];+ throw new UnsupportedCssError(`background: ${value}`);+ }+ if (prop === 'animation') throw new UnsupportedCssError(`animation: ${value}`);return [[prop, value]];};diff --git a/scripts/stylexMigration/codemod/transform.test.ts b/scripts/stylexMigration/codemod/transform.test.tsindex 85b58ccb955..247b1fd1286 100644--- a/scripts/stylexMigration/codemod/transform.test.ts+++ b/scripts/stylexMigration/codemod/transform.test.ts@@ -158,4 +158,79 @@ export const A = () => <Modal className={styles.a} styles={{ body: { padding: 0'<Modal className={stylex.props(styles.a).className} styles={{ body: { padding: 0 } }} />',);});++ it('merges template-literal class lists into one stylex.props call', () => {+ const source = `import { Block, createStaticStyles } from '@lobehub/ui';+const styles = createStaticStyles(({ css }) => ({+ a: css\`cursor: pointer;\`,+ b: css\`cursor: not-allowed;\`,+ c: css\`gap: 1px;\`,+}));+export const A = ({ off, on }: { off: boolean; on: boolean }) => (+ <>+ <Block className={\`\${styles.a} \${off ? styles.b : ''}\`} />+ <div className={\`\${styles.c} \${on ? '' : styles.b}\`} />+ </>+);+`;+ const out = squash(transformSource(source).code);++ expect(out).toContain(+ '<Block className={stylex.props(styles.a, off && styles.b).className} />',+ );+ expect(out).toContain('<div {...stylex.props(styles.c, !on && styles.b)} />');+ });++ it('refuses template literals that mix StyleX classes with other text', () => {+ const source = `import { createStaticStyles } from '@lobehub/ui';+const styles = createStaticStyles(({ css }) => ({ a: css\`gap: 1px;\` }));+export const A = ({ className }: { className?: string }) => (+ <div className={\`\${styles.a} \${className}\`} />+);+`;+ expect(() => transformSource(source)).toThrow(UnsupportedCssError);+ });++ it('drops cx when it only wraps StyleX arguments', () => {+ const source = `import { createStaticStyles, cx, Text } from '@lobehub/ui';+const styles = createStaticStyles(({ css }) => ({ a: css\`gap: 1px;\` }));+export const A = ({ on }: { on: boolean }) => <Text className={cx(!on && styles.a)} />;+`;+ expect(squash(transformSource(source).code)).toContain(+ '<Text className={stylex.props(!on && styles.a).className} />',+ );+ });++ it('keeps compound template conditions grouped', () => {+ const source = `import { createStaticStyles } from '@lobehub/ui';+const styles = createStaticStyles(({ css }) => ({+ a: css\`gap: 1px;\`,+ b: css\`gap: 2px;\`,+ c: css\`gap: 3px;\`,+}));+export const A = ({ x, y }: { x?: boolean; y?: boolean }) => (+ <>+ <div className={\`\${styles.a} \${x || y ? styles.b : ''}\`} />+ <div className={\`\${styles.a} \${x ?? y ? '' : styles.b}\`} />+ <div className={\`\${styles.a} \${x ? (y ? styles.b : styles.c) : ''}\`} />+ </>+);+`;+ const out = squash(transformSource(source).code);++ expect(out).toContain('<div {...stylex.props(styles.a, (x || y) && styles.b)} />');+ expect(out).toContain('<div {...stylex.props(styles.a, !(x ?? y) && styles.b)} />');+ expect(out).toContain('<div {...stylex.props(styles.a, x && (y ? styles.b : styles.c))} />');+ });++ it('rejects class templates stored outside JSX', () => {+ const source = `import { createStaticStyles } from '@lobehub/ui';+const styles = createStaticStyles(({ css }) => ({ a: css\`gap: 1px;\`, b: css\`gap: 2px;\` }));+export const A = () => {+ const cls = \`\${styles.a} \${styles.b}\`;+ return <div className={cls} />;+};+`;+ expect(() => transformSource(source)).toThrow(UnsupportedCssError);+ });});diff --git a/scripts/stylexMigration/codemod/transform.ts b/scripts/stylexMigration/codemod/transform.tsindex 5b238e649c9..75ed4deba19 100644--- a/scripts/stylexMigration/codemod/transform.ts+++ b/scripts/stylexMigration/codemod/transform.ts@@ -201,6 +201,54 @@ export const transformSource = (source: string, fileName = 'file.tsx'): Transforreturn { rest, styleArgs };};+ const isEmptyString = (node: ts.Expression) =>+ (ts.isStringLiteral(node) || ts.isNoSubstitutionTemplateLiteral(node)) && node.text === '';+ const operand = (node: ts.Expression) =>+ ts.isIdentifier(node) ||+ ts.isPropertyAccessExpression(node) ||+ ts.isElementAccessExpression(node) ||+ ts.isCallExpression(node) ||+ ts.isParenthesizedExpression(node)+ ? text(node)+ : `(${text(node)})`;+ const guarded = (condition: ts.Expression, style: ts.Expression) =>+ `${operand(condition)} && ${ts.isConditionalExpression(style) ? `(${text(style)})` : text(style)}`;++ /**+ * StyleX args of a `${styles.a} ${on ? styles.b : ''}` class list. Joined+ * stylex.props class strings would resolve conflicts by CSS order, so the list+ * must become one call; any other text in it cannot.+ */+ const templateStyleArgs = (tpl: ts.TemplateExpression) => {+ const unsupported = () => new UnsupportedCssError(`class template ${text(tpl)}`);+ const literals = [tpl.head.text, ...tpl.templateSpans.map((span) => span.literal.text)];+ if (literals.some((literal) => literal.trim())) throw unsupported();+ return tpl.templateSpans.map(({ expression: e }) => {+ if (isStyleArg(e)) return text(e);+ if (ts.isConditionalExpression(e) && !containsStyleRef(e.condition)) {+ if (isStyleArg(e.whenTrue) && isEmptyString(e.whenFalse))+ return guarded(e.condition, e.whenTrue);+ if (isEmptyString(e.whenTrue) && isStyleArg(e.whenFalse))+ return `!${guarded(e.condition, e.whenFalse)}`;+ }+ throw unsupported();+ });+ };+ const isStyleTemplate = (node: ts.Node): node is ts.TemplateExpression =>+ ts.isTemplateExpression(node) && containsStyleRef(node);++ // A class kept in a variable or a lookup object is later combined with other+ // classes; separate stylex.props calls would resolve by CSS order, not by+ // argument order. Object values inside JSX props (classNames slots) are fine.+ const inJsxProp = (n: ts.Node): boolean =>+ !!n.parent &&+ (ts.isJsxExpression(n.parent) ||+ ((ts.isObjectLiteralExpression(n.parent) || ts.isPropertyAssignment(n.parent)) &&+ inJsxProp(n.parent)));+ const isStoredOutsideJsx = (node: ts.Node) =>+ ts.isVariableDeclaration(node.parent) ||+ (ts.isPropertyAssignment(node.parent) && !inJsxProp(node.parent));+const visit = (node: ts.Node) => {if (ts.isJsxAttribute(node) && text(node.name) === 'className' && node.initializer) {const init = node.initializer;@@ -223,33 +271,36 @@ export const transformSource = (source: string, fileName = 'file.tsx'): Transforreturn;}}+ if (isStyleTemplate(expr)) {+ replace(node, `{...stylex.props(${templateStyleArgs(expr).join(', ')})}`);+ return;+ }}}+ if (isStyleTemplate(node)) {+ if (isStoredOutsideJsx(node))+ throw new UnsupportedCssError('class template stored outside JSX');+ replace(node, `stylex.props(${templateStyleArgs(node).join(', ')}).className`);+ return;+ }+if (isCx(node)) {const { rest, styleArgs } = splitCx(node);if (styleArgs.length > 0) {- if (rest.length > 0) mergesOutsideClassName++;const props = `stylex.props(${styleArgs.join(', ')}).className`;+ if (rest.length === 0) {+ replace(node, props);+ return;+ }+ mergesOutsideClassName++;replace(node, `${text(node.expression)}(${[props, ...rest].join(', ')})`);return;}}if (isStyleArg(node as ts.Expression) && !isStyleArg(node.parent as ts.Expression)) {- // A ref kept in a variable or a lookup object is later combined with other- // classes; separate stylex.props calls would resolve by CSS order, not by- // argument order. Object values inside JSX props (classNames slots) are fine.- const inJsxProp = (n: ts.Node): boolean =>- !!n.parent &&- (ts.isJsxExpression(n.parent) ||- ((ts.isObjectLiteralExpression(n.parent) || ts.isPropertyAssignment(n.parent)) &&- inJsxProp(n.parent)));- if (- ts.isVariableDeclaration(node.parent) ||- (ts.isPropertyAssignment(node.parent) && !inJsxProp(node.parent))- )- throw new UnsupportedCssError('style ref stored outside JSX');+ if (isStoredOutsideJsx(node)) throw new UnsupportedCssError('style ref stored outside JSX');replace(node, `stylex.props(${text(node)}).className`);return;}diff --git a/scripts/stylexMigration/legacyFiles.json b/scripts/stylexMigration/legacyFiles.jsonindex c5ae535a968..79140c44401 100644--- a/scripts/stylexMigration/legacyFiles.json+++ b/scripts/stylexMigration/legacyFiles.json@@ -1074,15 +1074,6 @@"src/features/Settings/appearance/features/Font/FallbackFontList.tsx","src/features/Settings/chat-appearance/features/ChatAppearance/LinkIconPreview.tsx","src/features/Settings/common/features/Appearance/Preview.tsx",- "src/features/Settings/creds/features/CreateCredModal/Content.tsx",- "src/features/Settings/creds/features/CreateCredModal/CredTypeSelector.tsx",- "src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx",- "src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx",- "src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx",- "src/features/Settings/creds/features/CredsList.tsx",- "src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx",- "src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx",- "src/features/Settings/creds/features/ViewCredModal/Content.tsx","src/features/Settings/creds/features/style.ts","src/features/Settings/integrations/index.tsx","src/features/Settings/oauth-apps/features/AppDetail/CredentialsCard.tsx",diff --git a/src/features/Settings/creds/features/CreateCredModal/Content.tsx b/src/features/Settings/creds/features/CreateCredModal/Content.tsxindex 889cb05f7f3..07a89128e86 100644--- a/src/features/Settings/creds/features/CreateCredModal/Content.tsx+++ b/src/features/Settings/creds/features/CreateCredModal/Content.tsx@@ -1,7 +1,8 @@'use client';import { type CredType } from '@lobechat/types';-import { createStaticStyles, Steps, useModalContext } from '@lobehub/ui';+import { Steps, useModalContext } from '@lobehub/ui';+import * as stylex from '@stylexjs/stylex';import { type FC, useState } from 'react';import { useTranslation } from 'react-i18next';@@ -11,11 +12,7 @@ import FileCredForm from './FileCredForm';import KVCredForm from './KVCredForm';import OAuthCredForm from './OAuthCredForm';-const styles = createStaticStyles(({ css }) => ({- steps: css`- margin-block-end: 24px;- `,-}));+const styles = stylex.create({ steps: { marginBlockEnd: '24px' } });export interface CreateCredModalContentProps {/**@@ -78,7 +75,7 @@ const CreateCredModalContent: FC<CreateCredModalContentProps> = ({ credsApi, onSreturn (<><Steps- className={styles.steps}+ className={stylex.props(styles.steps).className}current={step}items={[{ title: t('creds.createModal.selectType') },diff --git a/src/features/Settings/creds/features/CreateCredModal/CredTypeSelector.tsx b/src/features/Settings/creds/features/CreateCredModal/CredTypeSelector.tsxindex 7fc6f1fd54e..395015feff1 100644--- a/src/features/Settings/creds/features/CreateCredModal/CredTypeSelector.tsx+++ b/src/features/Settings/creds/features/CreateCredModal/CredTypeSelector.tsx@@ -1,53 +1,37 @@'use client';import { type CredType } from '@lobechat/types';-import { Block, createStaticStyles, Flexbox } from '@lobehub/ui';+import { Block, Flexbox } from '@lobehub/ui';+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';import { File, Globe, Key, TerminalSquare } from 'lucide-react';import { type FC } from 'react';import { useTranslation } from 'react-i18next';-const styles = createStaticStyles(({ css, cssVar }) => ({- card: css`- cursor: pointer;- border-radius: ${cssVar.borderRadiusLG};- transition: all 0.2s;-- &:hover {- border-color: ${cssVar.colorPrimary};- box-shadow: 0 2px 8px rgb(0 0 0 / 10%);- }- `,- cardDisabled: css`- cursor: not-allowed;- opacity: 0.5;- `,- description: css`- font-size: 12px;- color: ${cssVar.colorTextSecondary};- text-align: center;- `,- grid: css`- display: grid;- grid-template-columns: repeat(2, 1fr);- gap: 16px;- `,- icon: css`- display: flex;- align-items: center;- justify-content: center;-- width: 48px;- height: 48px;- margin-block-end: 12px;- border-radius: 12px;-- background: ${cssVar.colorFillSecondary};- `,- title: css`- margin-block-end: 4px;- font-weight: 500;- `,-}));+const styles = stylex.create({+ card: {+ cursor: 'pointer',+ borderRadius: cssVar.borderRadiusLG,+ transition: 'all 0.2s',+ borderColor: { 'default': null, ':hover': cssVar.colorPrimary },+ boxShadow: { 'default': null, ':hover': '0 2px 8px rgb(0 0 0 / 10%)' },+ },+ cardDisabled: { cursor: 'not-allowed', opacity: 0.5 },+ description: { fontSize: '12px', color: cssVar.colorTextSecondary, textAlign: 'center' },+ grid: { display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '16px' },+ icon: {+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ width: '48px',+ height: '48px',+ marginBlockEnd: '12px',+ borderRadius: '12px',+ backgroundColor: cssVar.colorFillSecondary,+ backgroundImage: 'none',+ },+ title: { marginBlockEnd: '4px', fontWeight: 500 },+});interface CredTypeSelectorProps {disabled?: boolean;@@ -85,10 +69,10 @@ const CredTypeSelector: FC<CredTypeSelectorProps> = ({ disabled, onSelect }) =>const { t } = useTranslation('setting');return (- <div className={styles.grid}>+ <div {...stylex.props(styles.grid)}>{typeConfigs.map(({ type, icon, description }) => (<Block- className={`${styles.card} ${disabled ? styles.cardDisabled : ''}`}+ className={stylex.props(styles.card, disabled && styles.cardDisabled).className}key={type}padding={12}variant={'outlined'}@@ -98,9 +82,9 @@ const CredTypeSelector: FC<CredTypeSelectorProps> = ({ disabled, onSelect }) =>}}><Flexbox align="center">- <div className={styles.icon}>{icon}</div>- <div className={styles.title}>{t(`creds.types.${type}`)}</div>- <div className={styles.description}>{t(description as any)}</div>+ <div {...stylex.props(styles.icon)}>{icon}</div>+ <div {...stylex.props(styles.title)}>{t(`creds.types.${type}`)}</div>+ <div {...stylex.props(styles.description)}>{t(description as any)}</div></Flexbox></Block>))}diff --git a/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx b/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsxindex 21e7a358d3b..8ee28981573 100644--- a/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx+++ b/src/features/Settings/creds/features/CreateCredModal/FileCredForm.tsx@@ -1,21 +1,17 @@'use client';-import { Button, createStaticStyles, Input, TextArea, toast, Upload } from '@lobehub/ui';+import { Button, Input, TextArea, toast, Upload } from '@lobehub/ui';import { Form, useForm } from '@lobehub/ui/form';+import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';import { type FC, useState } from 'react';import { useTranslation } from 'react-i18next';import { type CredsApi } from '../useCredsApi';-const styles = createStaticStyles(({ css }) => ({- footer: css`- display: flex;- gap: 8px;- justify-content: flex-end;- margin-block-start: 24px;- `,-}));+const styles = stylex.create({+ footer: { display: 'flex', gap: '8px', justifyContent: 'flex-end', marginBlockStart: '24px' },+});interface FileCredFormProps {credsApi: CredsApi;@@ -154,7 +150,7 @@ const FileCredForm: FC<FileCredFormProps> = ({ credsApi, disabled, onBack, onSuc/></Form.Field>- <div className={styles.footer}>+ <div {...stylex.props(styles.footer)}><Button onClick={onBack}>{t('creds.form.back')}</Button><Buttondisabled={!fileHashId || disabled}diff --git a/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx b/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsxindex 132d33744c5..51aa3b4cfff 100644--- a/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx+++ b/src/features/Settings/creds/features/CreateCredModal/KVCredForm.tsx@@ -1,7 +1,8 @@'use client';-import { Button, createStaticStyles, Flexbox, Input, InputPassword, TextArea } from '@lobehub/ui';+import { Button, Flexbox, Input, InputPassword, TextArea } from '@lobehub/ui';import { Form, useForm } from '@lobehub/ui/form';+import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';import { Minus, Plus } from 'lucide-react';import { type FC } from 'react';@@ -9,19 +10,10 @@ import { useTranslation } from 'react-i18next';import { type CredsApi } from '../useCredsApi';-const styles = createStaticStyles(({ css }) => ({- footer: css`- display: flex;- gap: 8px;- justify-content: flex-end;- margin-block-start: 24px;- `,- kvPair: css`- display: flex;- gap: 8px;- align-items: flex-start;- `,-}));+const styles = stylex.create({+ footer: { display: 'flex', gap: '8px', justifyContent: 'flex-end', marginBlockStart: '24px' },+ kvPair: { display: 'flex', gap: '8px', alignItems: 'flex-start' },+});interface KVCredFormProps {credsApi: CredsApi;@@ -101,7 +93,7 @@ const KVCredForm: FC<KVCredFormProps> = ({ credsApi, type, disabled, onBack, onS{({ fields, add, remove }) => (<Flexbox gap={8}>{fields.map(({ key, index }) => (- <div className={styles.kvPair} key={key}>+ <div {...stylex.props(styles.kvPair)} key={key}><div style={{ flex: 1 }}><Form.Field bare name={`kvPairs.${index}.key`}><Input@@ -152,7 +144,7 @@ const KVCredForm: FC<KVCredFormProps> = ({ credsApi, type, disabled, onBack, onS/></Form.Field>- <div className={styles.footer}>+ <div {...stylex.props(styles.footer)}><Button onClick={onBack}>{t('creds.form.back')}</Button><Buttondisabled={disabled}diff --git a/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx b/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsxindex 316cefc598c..fb8918297b1 100644--- a/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx+++ b/src/features/Settings/creds/features/CreateCredModal/OAuthCredForm.tsx@@ -1,42 +1,21 @@'use client';-import {- Avatar,- Button,- createStaticStyles,- Empty,- Flexbox,- Input,- Select,- Spin,- TextArea,-} from '@lobehub/ui';+import { Avatar, Button, Empty, Flexbox, Input, Select, Spin, TextArea } from '@lobehub/ui';import { Form, useForm } from '@lobehub/ui/form';+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';import { type FC } from 'react';import { useTranslation } from 'react-i18next';import { type CredsApi } from '../useCredsApi';-const styles = createStaticStyles(({ css, cssVar }) => ({- connectionOption: css`- display: flex;- gap: 8px;- align-items: center;- `,- footer: css`- display: flex;- gap: 8px;- justify-content: flex-end;- margin-block-start: 24px;- `,- provider: css`- font-weight: 500;- `,- username: css`- color: ${cssVar.colorTextSecondary};- `,-}));+const styles = stylex.create({+ connectionOption: { display: 'flex', gap: '8px', alignItems: 'center' },+ footer: { display: 'flex', gap: '8px', justifyContent: 'flex-end', marginBlockStart: '24px' },+ provider: { fontWeight: 500 },+ username: { color: cssVar.colorTextSecondary },+});interface OAuthCredFormProps {credsApi: CredsApi;@@ -65,11 +44,11 @@ const OAuthCredForm: FC<OAuthCredFormProps> = ({ credsApi, disabled, onBack, onSreturn {label: (- <span className={styles.connectionOption}>+ <span {...stylex.props(styles.connectionOption)}>{conn.avatar && <Avatar avatar={conn.avatar} size={24} />}<span>- <span className={styles.provider}>{provider}</span>- {displayName && <span className={styles.username}> - {displayName}</span>}+ <span {...stylex.props(styles.provider)}>{provider}</span>+ {displayName && <span {...stylex.props(styles.username)}> - {displayName}</span>}</span></span>),@@ -112,7 +91,7 @@ const OAuthCredForm: FC<OAuthCredFormProps> = ({ credsApi, disabled, onBack, onSreturn (<Flexbox gap={16}><Empty description={t('creds.oauth.noConnections')} />- <div className={styles.footer}>+ <div {...stylex.props(styles.footer)}><Button onClick={onBack}>{t('creds.form.back')}</Button></div></Flexbox>@@ -156,7 +135,7 @@ const OAuthCredForm: FC<OAuthCredFormProps> = ({ credsApi, disabled, onBack, onS/></Form.Field>- <div className={styles.footer}>+ <div {...stylex.props(styles.footer)}><Button onClick={onBack}>{t('creds.form.back')}</Button><Buttondisabled={disabled}diff --git a/src/features/Settings/creds/features/CredsList.tsx b/src/features/Settings/creds/features/CredsList.tsxindex d5e5378395b..45ba6a76f6c 100644--- a/src/features/Settings/creds/features/CredsList.tsx+++ b/src/features/Settings/creds/features/CredsList.tsx@@ -1,7 +1,8 @@'use client';import { type UserCredSummary } from '@lobechat/types';-import { Button, createStaticStyles, Empty, Flexbox } from '@lobehub/ui';+import { Button, Empty, Flexbox } from '@lobehub/ui';+import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';import { TRPCClientError } from '@trpc/client';import { LogIn } from 'lucide-react';@@ -19,26 +20,18 @@ import { createEditCredModal } from './EditCredModal';import { defaultCredsApi, useCredsApi } from './useCredsApi';import { createViewCredModal } from './ViewCredModal';-const styles = createStaticStyles(({ css }) => ({- container: css`- display: flex;- flex-direction: column;- gap: 8px;- `,- empty: css`- padding-block: 48px;- padding-inline: 0;- `,- signInPrompt: css`- display: flex;- flex-direction: column;- gap: 16px;- align-items: center;- justify-content: center;-- padding: 48px;- `,-}));+const styles = stylex.create({+ container: { display: 'flex', flexDirection: 'column', gap: '8px' },+ empty: { paddingBlock: '48px', paddingInline: '0' },+ signInPrompt: {+ display: 'flex',+ flexDirection: 'column',+ gap: '16px',+ alignItems: 'center',+ justifyContent: 'center',+ padding: '48px',+ },+});const CredsList: FC = () => {const { t } = useTranslation('setting');@@ -90,7 +83,7 @@ const CredsList: FC = () => {if (!isAuthenticated) {return (- <div className={styles.signInPrompt}>+ <div {...stylex.props(styles.signInPrompt)}><Empty description={t('creds.signInRequired')} /><Button icon={LogIn} type={'primary'} onClick={() => signIn()}>{t('creds.signIn')}@@ -102,22 +95,24 @@ const CredsList: FC = () => {// Org not created: guide users to complete Community Profile setup first.if (!isLoading && error instanceof TRPCClientError && error.data?.code === 'NOT_FOUND') {return (- <div className={styles.signInPrompt}>+ <div {...stylex.props(styles.signInPrompt)}><Empty description={t('creds.orgSetupRequired')} /></div>);}return (- <div className={styles.container}>+ <div {...stylex.props(styles.container)}><AsyncBoundarydata={data}- empty={<Empty className={styles.empty} description={t('creds.empty')} />}error={error}errorVariant={'block'}isEmpty={credentials.length === 0}isLoading={isLoading}loading={<ListSkeleton paddingInline={0} />}+ empty={+ <Empty className={stylex.props(styles.empty).className} description={t('creds.empty')} />+ }onRetry={() => refetch()}><Flexbox gap={0}>diff --git a/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx b/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsxindex 35795951531..aa98967a8c9 100644--- a/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx+++ b/src/features/Settings/creds/features/EditCredModal/EditKVForm.tsx@@ -1,16 +1,9 @@'use client';import { type UserCredSummary } from '@lobechat/types';-import {- Button,- createStaticStyles,- Flexbox,- Input,- InputPassword,- Spin,- TextArea,-} from '@lobehub/ui';+import { Button, Flexbox, Input, InputPassword, Spin, TextArea } from '@lobehub/ui';import { Form, useForm } from '@lobehub/ui/form';+import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';import { Minus, Plus } from 'lucide-react';import { type FC, useEffect, useState } from 'react';@@ -20,19 +13,10 @@ import { usePermission } from '@/hooks/usePermission';import { type CredsApi } from '../useCredsApi';-const styles = createStaticStyles(({ css }) => ({- footer: css`- display: flex;- gap: 8px;- justify-content: flex-end;- margin-block-start: 24px;- `,- kvPair: css`- display: flex;- gap: 8px;- align-items: flex-start;- `,-}));+const styles = stylex.create({+ footer: { display: 'flex', gap: '8px', justifyContent: 'flex-end', marginBlockStart: '24px' },+ kvPair: { display: 'flex', gap: '8px', alignItems: 'flex-start' },+});interface EditKVFormProps {cred: UserCredSummary;@@ -146,7 +130,7 @@ const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess }{({ fields, add, remove }) => (<Flexbox gap={8}>{fields.map(({ key, index }) => (- <div className={styles.kvPair} key={key}>+ <div {...stylex.props(styles.kvPair)} key={key}><div style={{ flex: 1 }}><Form.Field bare name={`kvPairs.${index}.key`}><Input@@ -197,7 +181,7 @@ const EditKVForm: FC<EditKVFormProps> = ({ cred, credsApi, onCancel, onSuccess }/></Form.Field>- <div className={styles.footer}>+ <div {...stylex.props(styles.footer)}><Button onClick={onCancel}>{t('creds.form.cancel')}</Button><Buttondisabled={!canManageCredentials}diff --git a/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx b/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsxindex d94500ef8ff..117581e238a 100644--- a/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx+++ b/src/features/Settings/creds/features/EditCredModal/EditMetaForm.tsx@@ -1,8 +1,9 @@'use client';import { type UserCredSummary } from '@lobechat/types';-import { Button, createStaticStyles, Input, TextArea } from '@lobehub/ui';+import { Button, Input, TextArea } from '@lobehub/ui';import { Form, useForm } from '@lobehub/ui/form';+import * as stylex from '@stylexjs/stylex';import { useMutation } from '@tanstack/react-query';import { type FC } from 'react';import { useTranslation } from 'react-i18next';@@ -11,14 +12,9 @@ import { usePermission } from '@/hooks/usePermission';import { type CredsApi } from '../useCredsApi';-const styles = createStaticStyles(({ css }) => ({- footer: css`- display: flex;- gap: 8px;- justify-content: flex-end;- margin-block-start: 24px;- `,-}));+const styles = stylex.create({+ footer: { display: 'flex', gap: '8px', justifyContent: 'flex-end', marginBlockStart: '24px' },+});interface EditMetaFormProps {cred: UserCredSummary;@@ -78,7 +74,7 @@ const EditMetaForm: FC<EditMetaFormProps> = ({ cred, credsApi, onCancel, onSucce/></Form.Field>- <div className={styles.footer}>+ <div {...stylex.props(styles.footer)}><Button onClick={onCancel}>{t('creds.form.cancel')}</Button><Buttondisabled={!canManageCredentials}diff --git a/src/features/Settings/creds/features/ViewCredModal/Content.tsx b/src/features/Settings/creds/features/ViewCredModal/Content.tsxindex 381a8d1d500..59f5edd532f 100644--- a/src/features/Settings/creds/features/ViewCredModal/Content.tsx+++ b/src/features/Settings/creds/features/ViewCredModal/Content.tsx@@ -1,15 +1,9 @@'use client';import { type UserCredSummary } from '@lobechat/types';-import {- Alert,- CopyButton,- createStaticStyles,- cx,- Descriptions,- Flexbox,- Text,-} from '@lobehub/ui';+import { Alert, CopyButton, Descriptions, Flexbox, Text } from '@lobehub/ui';+import { cssVar } from '@lobehub/ui/stylex/cssVar.stylex';+import * as stylex from '@stylexjs/stylex';import { useQuery } from '@tanstack/react-query';import { Eye, EyeOff } from 'lucide-react';import { type FC, useState } from 'react';@@ -19,76 +13,63 @@ import { ArticleSkeleton } from '@/components/Skeleton';import { type CredsApi } from '../useCredsApi';-const styles = createStaticStyles(({ css, cssVar }) => ({- kvKey: css`- min-width: 140px;- padding-block: 8px;- padding-inline: 12px;- border-radius: ${cssVar.borderRadius} 0 0 ${cssVar.borderRadius};-- font-family: ${cssVar.fontFamilyCode};- font-size: 13px;- color: ${cssVar.colorTextSecondary};-- background: ${cssVar.colorFillQuaternary};- `,- kvRow: css`- display: flex;- align-items: stretch;- border: 1px solid ${cssVar.colorBorderSecondary};- border-radius: ${cssVar.borderRadius};-- &:not(:last-child) {- margin-block-end: 8px;- }- `,- kvValue: css`- display: flex;- flex: 1;- gap: 8px;- align-items: center;- justify-content: space-between;-- padding-block: 8px;- padding-inline: 12px;- border-radius: 0 ${cssVar.borderRadius} ${cssVar.borderRadius} 0;-- font-family: ${cssVar.fontFamilyCode};- font-size: 13px;-- background: ${cssVar.colorBgContainer};- `,- maskedValue: css`- color: ${cssVar.colorTextQuaternary};- letter-spacing: 2px;- `,- toggleBtn: css`- cursor: pointer;-- display: flex;- align-items: center;- justify-content: center;-- padding: 4px;- border-radius: ${cssVar.borderRadiusSM};-- color: ${cssVar.colorTextTertiary};-- transition: all 0.2s;-- &:hover {- color: ${cssVar.colorText};- background: ${cssVar.colorFillSecondary};- }- `,- valuesSection: css`- margin-block-start: 16px;- `,- valuesTitle: css`- margin-block-end: 12px;- font-weight: 500;- `,-}));+const styles = stylex.create({+ kvKey: {+ minWidth: '140px',+ paddingBlock: '8px',+ paddingInline: '12px',+ borderTopLeftRadius: cssVar.borderRadius,+ borderTopRightRadius: '0',+ borderBottomRightRadius: '0',+ borderBottomLeftRadius: cssVar.borderRadius,+ fontFamily: cssVar.fontFamilyCode,+ fontSize: '13px',+ color: cssVar.colorTextSecondary,+ backgroundColor: cssVar.colorFillQuaternary,+ backgroundImage: 'none',+ },+ kvRow: {+ display: 'flex',+ alignItems: 'stretch',+ borderWidth: '1px',+ borderStyle: 'solid',+ borderColor: cssVar.colorBorderSecondary,+ borderRadius: cssVar.borderRadius,+ marginBlockEnd: { 'default': null, ':not(:last-child)': '8px' },+ },+ kvValue: {+ display: 'flex',+ flex: '1',+ gap: '8px',+ alignItems: 'center',+ justifyContent: 'space-between',+ paddingBlock: '8px',+ paddingInline: '12px',+ borderTopLeftRadius: '0',+ borderTopRightRadius: cssVar.borderRadius,+ borderBottomRightRadius: cssVar.borderRadius,+ borderBottomLeftRadius: '0',+ fontFamily: cssVar.fontFamilyCode,+ fontSize: '13px',+ backgroundColor: cssVar.colorBgContainer,+ backgroundImage: 'none',+ },+ maskedValue: { color: cssVar.colorTextQuaternary, letterSpacing: '2px' },+ toggleBtn: {+ cursor: 'pointer',+ display: 'flex',+ alignItems: 'center',+ justifyContent: 'center',+ padding: '4px',+ borderRadius: cssVar.borderRadiusSM,+ color: { 'default': cssVar.colorTextTertiary, ':hover': cssVar.colorText },+ transition: 'all 0.2s',+ backgroundColor: { 'default': null, ':hover': cssVar.colorFillSecondary },+ backgroundImage: { 'default': null, ':hover': 'none' },+ },+ valuesSection: { marginBlockStart: '16px' },+ valuesTitle: { marginBlockEnd: '12px', fontWeight: 500 },+});const maskValue = (value: string): string => {if (value.length <= 4) return '••••••••';@@ -104,12 +85,12 @@ const KVRow: FC<KVRowProps> = ({ keyName, value }) => {const [visible, setVisible] = useState(false);return (- <div className={styles.kvRow}>- <div className={styles.kvKey}>{keyName}</div>- <div className={styles.kvValue}>+ <div {...stylex.props(styles.kvRow)}>+ <div {...stylex.props(styles.kvKey)}>{keyName}</div>+ <div {...stylex.props(styles.kvValue)}><Textas={'span'}- className={cx(!visible && styles.maskedValue)}+ className={stylex.props(!visible && styles.maskedValue).className}style={{flex: 1,fontFamily: 'var(--lobe-font-family-code)',@@ -120,7 +101,7 @@ const KVRow: FC<KVRowProps> = ({ keyName, value }) => {{visible ? value : maskValue(value)}</Text><Flexbox horizontal align={'center'} gap={4}>- <div className={styles.toggleBtn} onClick={() => setVisible(!visible)}>+ <div {...stylex.props(styles.toggleBtn)} onClick={() => setVisible(!visible)}>{visible ? <EyeOff size={16} /> : <Eye size={16} />}</div><CopyButton content={value} size={'small'} />@@ -194,8 +175,8 @@ const ViewCredModalContent: FC<ViewCredModalContentProps> = ({ cred, credsApi })/>{valueEntries.length > 0 && (- <div className={styles.valuesSection}>- <div className={styles.valuesTitle}>{t('creds.view.values')}</div>+ <div {...stylex.props(styles.valuesSection)}>+ <div {...stylex.props(styles.valuesTitle)}>{t('creds.view.values')}</div>{valueEntries.map(([key, value]) => (<KVRow key={key} keyName={key} value={String(value)} />))}