-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1、fix: 修复transition addItem导致的数据问题 2、fix: 修复code mode数据问题 3、fix: 修复mode切换问题
- Loading branch information
1 parent
6b3107d
commit b2cee00
Showing
8 changed files
with
122 additions
and
32 deletions.
There are no files selected for viewing
21 changes: 19 additions & 2 deletions
21
web/apps/web/src/components/app/config-form/button-config/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,41 @@ | ||
'use client'; | ||
|
||
import { TValues } from '@shellagent/form-engine'; | ||
import { TValues, TFieldMode } from '@shellagent/form-engine'; | ||
import { useCallback } from 'react'; | ||
|
||
import NodeForm from '@/components/app/node-form'; | ||
import { useAppState } from '@/stores/app/use-app-state'; | ||
import { buttonConfigSchema } from '@/stores/app/utils/schema'; | ||
import { useAppStore } from '@/stores/app/app-provider'; | ||
|
||
interface ButtonConfigProps { | ||
values: TValues; | ||
id: string; | ||
onChange: (values: TValues) => void; | ||
} | ||
|
||
export const ButtonConfig = ({ values, onChange }: ButtonConfigProps) => { | ||
export const ButtonConfig = ({ values, onChange, id }: ButtonConfigProps) => { | ||
const { setFieldsModeMap, fieldsModeMap } = useAppStore(state => ({ | ||
setFieldsModeMap: state.setFieldsModeMap, | ||
fieldsModeMap: state.config?.fieldsModeMap, | ||
})); | ||
const currentButtonId = useAppState(state => state.currentButtonId); | ||
|
||
const onModeChange = useCallback( | ||
(name: string, mode: TFieldMode) => { | ||
setFieldsModeMap({ id: `${id}.${currentButtonId}`, name, mode }); | ||
}, | ||
[currentButtonId, id, setFieldsModeMap], | ||
); | ||
|
||
return ( | ||
<NodeForm | ||
key={currentButtonId} | ||
schema={buttonConfigSchema} | ||
values={values as TValues} | ||
onChange={onChange} | ||
onModeChange={onModeChange} | ||
modeMap={fieldsModeMap?.[`${id}.${currentButtonId}`] || {}} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters