Skip to content

Commit d3044b2

Browse files
committed
fix: global context alias
1 parent 4d65708 commit d3044b2

5 files changed

Lines changed: 24 additions & 10 deletions

File tree

.changeset/free-jokes-remain.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@modelscope-studio/antd': patch
3+
'@modelscope-studio/frontend': patch
4+
'modelscope_studio': patch
5+
---
6+
7+
fix: global context alias

frontend/antd/form/form.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { sveltify } from '@svelte-preprocess-react';
22
import { useEffect } from 'react';
33
import { useFunction } from '@utils/hooks/useFunction';
4+
import { useMemoizedEqualValue } from '@utils/hooks/useMemoizedEqualValue';
45
import { useMemoizedFn } from '@utils/hooks/useMemoizedFn';
56
import { renderParamsSlot } from '@utils/renderParamsSlot';
67
import { Form as AForm, type GetProps } from 'antd';
@@ -22,13 +23,14 @@ export const Form = sveltify<FormProps, ['requiredMark']>(
2223
feedbackIcons,
2324
slots,
2425
onResetFormAction,
26+
children,
2527
...props
2628
}) => {
2729
const [form] = AForm.useForm();
2830
const feedbackIconsFunction = useFunction(feedbackIcons);
2931
const requiredMarkFunction = useFunction(requiredMark);
3032
const onResetFormActionMemoized = useMemoizedFn(onResetFormAction);
31-
33+
const valueMemoized = useMemoizedEqualValue(value);
3234
useEffect(() => {
3335
switch (formAction) {
3436
case 'reset':
@@ -45,12 +47,13 @@ export const Form = sveltify<FormProps, ['requiredMark']>(
4547
}, [form, formAction, onResetFormActionMemoized]);
4648

4749
useEffect(() => {
48-
if (value) {
49-
form.setFieldsValue(value);
50+
if (valueMemoized) {
51+
form.setFieldsValue(valueMemoized);
5052
} else {
5153
form.resetFields();
5254
}
53-
}, [form, value]);
55+
}, [form, valueMemoized]);
56+
5457
return (
5558
<AForm
5659
{...props}
@@ -70,7 +73,9 @@ export const Form = sveltify<FormProps, ['requiredMark']>(
7073
onValueChange(values);
7174
onValuesChange?.(changedValues, values);
7275
}}
73-
/>
76+
>
77+
{children}
78+
</AForm>
7479
);
7580
}
7681
);

frontend/plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const baseGlobals = {
1111
'@ant-design/cssinjs': 'window.ms_globals.antdCssinjs',
1212
'@ant-design/icons': 'window.ms_globals.antdIcons',
1313

14-
'@svelte-preprocess-react/react-context':
15-
'window.ms_globals.internalReactContext',
14+
'@svelte-preprocess-react/react-contexts':
15+
'window.ms_globals.internalReactContexts',
1616
dayjs: 'window.ms_globals.dayjs',
1717
'@utils/createItemsContext': 'window.ms_globals.createItemsContext',
1818
'@globals/components': 'window.ms_globals.components',

frontend/svelte-preprocess-react/inject.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as internalReactContext from './react-contexts';
1+
import * as internalReactContexts from './react-contexts';
22
import type { loader as monacoLoader } from '@monaco-editor/react';
33
import { loader } from '@monaco-editor/react';
44
import React from 'react';
@@ -31,7 +31,7 @@ declare global {
3131
antdIcons: typeof antdIcons;
3232
dayjs: typeof dayjs;
3333

34-
internalReactContext: typeof internalReactContext;
34+
internalReactContexts: typeof internalReactContexts;
3535
initializePromise: Promise<void> | null;
3636
initialize: () => void;
3737
tickPromise: Promise<void> | null;
@@ -71,7 +71,7 @@ window.ms_globals = {
7171
antdCssinjs,
7272
antdIcons,
7373
dayjs,
74-
internalReactContext,
74+
internalReactContexts,
7575
autokey: 0,
7676
loadingKey: 0,
7777
sharedRoot: undefined,

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ artifacts = [
243243
"/backend/modelscope_studio/components/antdx/sources/item/templates",
244244
"/backend/modelscope_studio/components/antdx/think/templates",
245245
"/backend/modelscope_studio/components/antdx/thought_chain/thought_chain_item/templates",
246+
"/backend/modelscope_studio/components/antd/tag/checkable_tag_group/templates",
247+
"/backend/modelscope_studio/components/antd/tag/checkable_tag_group/option/templates",
246248
]
247249

248250
[tool.yapfignore]

0 commit comments

Comments
 (0)