From 237ac23601444aa8fd7f8eab28ff14cc20d800f5 Mon Sep 17 00:00:00 2001 From: CNFeffery Date: Fri, 10 Jan 2025 23:40:48 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8DAntdMenu=E5=9C=A8AntdS?= =?UTF-8?q?ider=E5=86=85=E9=83=A8=E6=97=B6=E5=8F=97=E6=8A=98=E5=8F=A0?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=8A=B6=E6=80=81=E6=97=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feffery_antd_components/AntdMenu.py | 2 +- feffery_antd_components/AntdTreeSelect.py | 10 ++- .../components/navigation/AntdMenu.react.js | 1 - tests/navigation/AntdMenu/fix_with_sider.py | 71 +++++++++++++++++++ 4 files changed, 79 insertions(+), 5 deletions(-) create mode 100644 tests/navigation/AntdMenu/fix_with_sider.py diff --git a/feffery_antd_components/AntdMenu.py b/feffery_antd_components/AntdMenu.py index 62457b49..dd5fbfaf 100644 --- a/feffery_antd_components/AntdMenu.py +++ b/feffery_antd_components/AntdMenu.py @@ -74,7 +74,7 @@ class AntdMenu(Component): - popupContainer (a value equal to: 'parent', 'body'; default 'body'): 菜单展开层锚定策略,可选项有`'parent'`、`'body'` 默认值:`'body'`. -- inlineCollapsed (boolean; default False): +- inlineCollapsed (boolean; optional): 当前菜单是否折叠,仅inline模式下有效 默认值:`False`. - inlineIndent (number; default 24): diff --git a/feffery_antd_components/AntdTreeSelect.py b/feffery_antd_components/AntdTreeSelect.py index 9661ebe0..8ce3b5dc 100644 --- a/feffery_antd_components/AntdTreeSelect.py +++ b/feffery_antd_components/AntdTreeSelect.py @@ -70,6 +70,10 @@ class AntdTreeSelect(Component): - defaultValue (string | number | list of string | numbers; optional): 初始化已选值. +- maxCount (number; optional): + 当`multiple=True`时,可选中的最大数量 + 如果`showCheckedStrategy='show-all'`且`treeCheckStrictly=False`,或者`showCheckedStrategy='show-parent'`,则`maxCount`无效. + - maxTagCount (number | a value equal to: 'responsive'; optional): 当`multiple=True`时,已选值tag展示的最大数量. @@ -190,10 +194,10 @@ class AntdTreeSelect(Component): _namespace = 'feffery_antd_components' _type = 'AntdTreeSelect' @_explicitize_args - def __init__(self, id=Component.UNDEFINED, key=Component.UNDEFINED, style=Component.UNDEFINED, className=Component.UNDEFINED, popupClassName=Component.UNDEFINED, name=Component.UNDEFINED, locale=Component.UNDEFINED, treeDataMode=Component.UNDEFINED, treeData=Component.REQUIRED, treeNodeKeyToTitle=Component.UNDEFINED, disabled=Component.UNDEFINED, size=Component.UNDEFINED, bordered=Component.UNDEFINED, variant=Component.UNDEFINED, placeholder=Component.UNDEFINED, placement=Component.UNDEFINED, treeLine=Component.UNDEFINED, value=Component.UNDEFINED, defaultValue=Component.UNDEFINED, maxTagCount=Component.UNDEFINED, maxTagPlaceholder=Component.UNDEFINED, maxTagTextLength=Component.UNDEFINED, listHeight=Component.UNDEFINED, multiple=Component.UNDEFINED, suffixIcon=Component.UNDEFINED, switcherIcon=Component.UNDEFINED, treeCheckable=Component.UNDEFINED, treeCheckStrictly=Component.UNDEFINED, treeDefaultExpandAll=Component.UNDEFINED, treeDefaultExpandedKeys=Component.UNDEFINED, treeExpandedKeys=Component.UNDEFINED, virtual=Component.UNDEFINED, status=Component.UNDEFINED, allowClear=Component.UNDEFINED, treeNodeFilterProp=Component.UNDEFINED, treeNodeFilterMode=Component.UNDEFINED, autoClearSearchValue=Component.UNDEFINED, showCheckedStrategy=Component.UNDEFINED, dropdownBefore=Component.UNDEFINED, dropdownAfter=Component.UNDEFINED, prefix=Component.UNDEFINED, readOnly=Component.UNDEFINED, enableAsyncLoad=Component.UNDEFINED, loadingNode=Component.UNDEFINED, popupContainer=Component.UNDEFINED, batchPropsNames=Component.UNDEFINED, batchPropsValues=Component.UNDEFINED, loading_state=Component.UNDEFINED, persistence=Component.UNDEFINED, persisted_props=Component.UNDEFINED, persistence_type=Component.UNDEFINED, **kwargs): - self._prop_names = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type'] + def __init__(self, id=Component.UNDEFINED, key=Component.UNDEFINED, style=Component.UNDEFINED, className=Component.UNDEFINED, popupClassName=Component.UNDEFINED, name=Component.UNDEFINED, locale=Component.UNDEFINED, treeDataMode=Component.UNDEFINED, treeData=Component.REQUIRED, treeNodeKeyToTitle=Component.UNDEFINED, disabled=Component.UNDEFINED, size=Component.UNDEFINED, bordered=Component.UNDEFINED, variant=Component.UNDEFINED, placeholder=Component.UNDEFINED, placement=Component.UNDEFINED, treeLine=Component.UNDEFINED, value=Component.UNDEFINED, defaultValue=Component.UNDEFINED, maxCount=Component.UNDEFINED, maxTagCount=Component.UNDEFINED, maxTagPlaceholder=Component.UNDEFINED, maxTagTextLength=Component.UNDEFINED, listHeight=Component.UNDEFINED, multiple=Component.UNDEFINED, suffixIcon=Component.UNDEFINED, switcherIcon=Component.UNDEFINED, treeCheckable=Component.UNDEFINED, treeCheckStrictly=Component.UNDEFINED, treeDefaultExpandAll=Component.UNDEFINED, treeDefaultExpandedKeys=Component.UNDEFINED, treeExpandedKeys=Component.UNDEFINED, virtual=Component.UNDEFINED, status=Component.UNDEFINED, allowClear=Component.UNDEFINED, treeNodeFilterProp=Component.UNDEFINED, treeNodeFilterMode=Component.UNDEFINED, autoClearSearchValue=Component.UNDEFINED, showCheckedStrategy=Component.UNDEFINED, dropdownBefore=Component.UNDEFINED, dropdownAfter=Component.UNDEFINED, prefix=Component.UNDEFINED, readOnly=Component.UNDEFINED, enableAsyncLoad=Component.UNDEFINED, loadingNode=Component.UNDEFINED, popupContainer=Component.UNDEFINED, batchPropsNames=Component.UNDEFINED, batchPropsValues=Component.UNDEFINED, loading_state=Component.UNDEFINED, persistence=Component.UNDEFINED, persisted_props=Component.UNDEFINED, persistence_type=Component.UNDEFINED, **kwargs): + self._prop_names = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxCount', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type'] self._valid_wildcard_attributes = ['data-', 'aria-'] - self.available_properties = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type'] + self.available_properties = ['id', 'key', 'style', 'className', 'popupClassName', 'name', 'locale', 'treeDataMode', 'treeData', 'treeNodeKeyToTitle', 'disabled', 'size', 'bordered', 'variant', 'placeholder', 'placement', 'treeLine', 'value', 'defaultValue', 'maxCount', 'maxTagCount', 'maxTagPlaceholder', 'maxTagTextLength', 'listHeight', 'multiple', 'suffixIcon', 'switcherIcon', 'treeCheckable', 'treeCheckStrictly', 'treeDefaultExpandAll', 'treeDefaultExpandedKeys', 'treeExpandedKeys', 'virtual', 'status', 'allowClear', 'treeNodeFilterProp', 'treeNodeFilterMode', 'autoClearSearchValue', 'showCheckedStrategy', 'dropdownBefore', 'dropdownAfter', 'prefix', 'readOnly', 'enableAsyncLoad', 'loadingNode', 'popupContainer', 'batchPropsNames', 'batchPropsValues', 'data-*', 'aria-*', 'loading_state', 'persistence', 'persisted_props', 'persistence_type'] self.available_wildcard_properties = ['data-', 'aria-'] _explicit_args = kwargs.pop('_explicit_args') _locals = locals() diff --git a/src/lib/components/navigation/AntdMenu.react.js b/src/lib/components/navigation/AntdMenu.react.js index 52569930..4c2a46bc 100644 --- a/src/lib/components/navigation/AntdMenu.react.js +++ b/src/lib/components/navigation/AntdMenu.react.js @@ -656,7 +656,6 @@ AntdMenu.defaultProps = { onlyExpandCurrentSubMenu: false, renderCollapsedButton: false, popupContainer: 'body', - inlineCollapsed: false, inlineIndent: 24, triggerSubMenuAction: 'hover', persisted_props: ['currentKey', 'openKeys'], diff --git a/tests/navigation/AntdMenu/fix_with_sider.py b/tests/navigation/AntdMenu/fix_with_sider.py new file mode 100644 index 00000000..e91c1460 --- /dev/null +++ b/tests/navigation/AntdMenu/fix_with_sider.py @@ -0,0 +1,71 @@ +if True: + import sys + + sys.path.append('../../../') + from dash import Dash + import feffery_antd_components as fac + +app = Dash(__name__) + +app.layout = fac.AntdLayout( + [ + fac.AntdSider( + [ + fac.AntdMenu( + menuItems=[ + { + 'component': 'Item', + 'props': { + 'key': f'图标{icon}', + 'title': f'图标{icon}', + 'icon': icon, + }, + } + for icon in [ + 'antd-home', + 'antd-cloud-upload', + 'antd-bar-chart', + 'antd-pie-chart', + 'antd-dot-chart', + 'antd-line-chart', + 'antd-apartment', + 'antd-app-store', + 'antd-app-store-add', + 'antd-bell', + 'antd-calculator', + 'antd-calendar', + 'antd-database', + 'antd-history', + ] + ], + mode='inline', + style={ + 'height': '100%', + 'width': '100%', + 'overflow': 'hidden auto', + }, + ) + ], + collapsible=True, + collapsedWidth=60, + style={'backgroundColor': 'rgb(240, 242, 245)'}, + ), + fac.AntdContent( + fac.AntdCenter( + fac.AntdTitle( + '内容区示例', + level=2, + style={'margin': '0'}, + ), + style={ + 'height': '100%', + }, + ), + style={'backgroundColor': 'white'}, + ), + ], + style={'height': '100vh'}, +) + +if __name__ == '__main__': + app.run(debug=True)