Skip to content

Commit ca7519f

Browse files
authored
fix: ensure the load_data event returns a Promise (#82)
* fix: ensure the load_data event returns a Proimse * chore: update deps * fix: changeset * fix: ensure the same key and value in the tree data
1 parent ef8f398 commit ca7519f

18 files changed

Lines changed: 1031 additions & 802 deletions

File tree

.changeset/fair-pianos-rule.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: ensure the same key and value in the tree data

.changeset/hip-apes-bathe.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@modelscope-studio/legacy-waterfall-gallery': patch
3+
'@modelscope-studio/legacy-multimodal-input': patch
4+
'@modelscope-studio/legacy-markdown': patch
5+
'@modelscope-studio/legacy-compiled': patch
6+
'@modelscope-studio/legacy-flow': patch
7+
'@modelscope-studio/lint-config': patch
8+
'@modelscope-studio/changelog': patch
9+
'@modelscope-studio/antd': patch
10+
'@modelscope-studio/frontend': patch
11+
'modelscope_studio': patch
12+
---
13+
14+
chore: update deps

.changeset/yellow-tables-dance.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@modelscope-studio/antd': patch
3+
---
4+
5+
fix: ensure the load_data event returns a Promise

config/changelog/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
},
2626
"devDependencies": {
2727
"@changesets/types": "^6.1.0",
28-
"@types/node": "^24.0.0",
28+
"@types/node": "^24.0.10",
2929
"tsup": "^8.5.0"
3030
}
3131
}

config/lint-config/package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,21 @@
1616
}
1717
},
1818
"dependencies": {
19-
"@eslint/compat": "^1.2.9",
20-
"@eslint/js": "^9.28.0",
21-
"@typescript-eslint/parser": "^8.34.0",
19+
"@eslint/compat": "^1.3.1",
20+
"@eslint/js": "^9.30.1",
21+
"@typescript-eslint/parser": "^8.35.1",
2222
"eslint-config-prettier": "^10.1.5",
23-
"eslint-import-resolver-typescript": "^4.4.3",
24-
"eslint-plugin-import": "^2.31.0",
23+
"eslint-import-resolver-typescript": "^4.4.4",
24+
"eslint-plugin-import": "^2.32.0",
2525
"eslint-plugin-jsx-a11y": "^6.10.2",
26-
"eslint-plugin-prettier": "5.4.1",
26+
"eslint-plugin-prettier": "5.5.1",
2727
"eslint-plugin-react": "^7.37.5",
2828
"eslint-plugin-react-hooks": "^5.2.0",
2929
"eslint-plugin-react-refresh": "^0.4.20",
3030
"eslint-plugin-simple-import-sort": "^12.1.0",
31-
"eslint-plugin-svelte": "^3.9.2",
32-
"globals": "^16.2.0",
33-
"postcss": "^8.5.4",
31+
"eslint-plugin-svelte": "^3.10.1",
32+
"globals": "^16.3.0",
33+
"postcss": "^8.5.6",
3434
"postcss-less": "^6.0.0",
3535
"stylelint-config-ali": "^2.1.2",
3636
"stylelint-config-rational-order": "^0.1.2",
@@ -39,7 +39,7 @@
3939
"stylelint-order": "^7.0.0",
4040
"stylelint-prettier": "^5.0.3",
4141
"svelte-eslint-parser": "^1.2.0",
42-
"typescript-eslint": "^8.34.0"
42+
"typescript-eslint": "^8.35.1"
4343
},
4444
"devDependencies": {
4545
"@types/eslint": "^9.6.1",

frontend/antd/tree-select/tree-select.tsx

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,28 @@ export const TreeSelect = sveltify<
6363
const componentProps: TreeSelectProps = useMemo(() => {
6464
return {
6565
...props,
66-
loadData: onLoadData,
66+
// eslint-disable-next-line require-await
67+
loadData: async (...args) => onLoadData?.(...args),
6768
treeData:
6869
treeData ||
6970
renderItems<NonNullable<TreeSelectProps['treeData']>[number]>(
7071
resolvedSlotItems,
71-
{ clone: true }
72+
{
73+
clone: true,
74+
itemPropsTransformer: (itemProps) => {
75+
if (
76+
itemProps.value &&
77+
itemProps.key &&
78+
itemProps.value !== itemProps.key
79+
) {
80+
return {
81+
...itemProps,
82+
key: undefined,
83+
};
84+
}
85+
return itemProps;
86+
},
87+
}
7288
),
7389
dropdownRender: slots.dropdownRender
7490
? renderParamsSlot({ slots, setSlotParams, key: 'dropdownRender' })
@@ -131,6 +147,7 @@ export const TreeSelect = sveltify<
131147
treeData,
132148
treeTitleRenderFunction,
133149
]);
150+
134151
return (
135152
<>
136153
<div style={{ display: 'none' }}>{children}</div>

frontend/antd/tree/tree.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,19 @@ export const Tree = sveltify<
6565
resolvedSlotItems,
6666
{
6767
clone: true,
68+
itemPropsTransformer: (itemProps) => {
69+
if (
70+
itemProps.value &&
71+
itemProps.key &&
72+
itemProps.value !== itemProps.key
73+
) {
74+
return {
75+
...itemProps,
76+
key: undefined,
77+
};
78+
}
79+
return itemProps;
80+
},
6881
}
6982
),
7083
showLine: slots['showLine.showLeafIcon']
@@ -101,7 +114,8 @@ export const Tree = sveltify<
101114
nodeDraggable: draggableNodeDraggableFunction,
102115
}
103116
: draggableFunction || draggable,
104-
loadData: onLoadData,
117+
// eslint-disable-next-line require-await
118+
loadData: async (...args: any[]) => onLoadData?.(...args),
105119
};
106120
}, [
107121
props,

frontend/legacy/Flow/Awaited.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
};
6363
}
6464
}
65-
$: background_props, update_background_props();
65+
$: (background_props, update_background_props());
6666
// process schema
6767
$: _schema = {
6868
...schema,

frontend/legacy/Markdown/Awaited.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
: src.replaceAll('/file=', replaceStr);
4444
};
4545
$: _value = redirect_src_url(value);
46-
$: label, gradio.dispatch('change');
46+
$: (label, gradio.dispatch('change'));
4747
</script>
4848

4949
<Block

frontend/legacy/Markdown/shared/Markdown.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
dispatch('custom', { tag, tag_index, value: v });
3333
}
3434
35-
$: value, dispatch('change');
35+
$: (value, dispatch('change'));
3636
</script>
3737

3838
<div

0 commit comments

Comments
 (0)