@gingkoo/pandora-explorer 0.0.1-alpha.97 → 0.0.1-alpha.98
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,7 +3,7 @@ import { ReactNode } from 'react';
|
|
|
3
3
|
interface MenuProps {
|
|
4
4
|
menu?: MenuItem[];
|
|
5
5
|
onChange?: (key: string, parent?: MenuItem) => any;
|
|
6
|
-
loadMenu?: (item: MenuItem) => MenuItem;
|
|
6
|
+
loadMenu?: (item: MenuItem) => MenuItem | MenuItem[];
|
|
7
7
|
store?: any;
|
|
8
8
|
}
|
|
9
9
|
export interface MenuItem {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export declare function getMenu(key: string): import("react").ComponentType<{}>;
|
|
3
3
|
export declare function registerMenu(key: string, component: any): void;
|
|
4
|
+
export declare function addMenuItem(key: string | string[], menu: any[]): void;
|
|
5
|
+
export declare function removeMenuItem(key: string | string[], menuItem: string[]): void;
|
package/lib/es/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Explorer from './explorer';
|
|
2
2
|
import ExplorerMenu from './components/menu';
|
|
3
|
-
export { registerMenu } from './components/menu/menulist';
|
|
3
|
+
export { registerMenu, addMenuItem, removeMenuItem } from './components/menu/menulist';
|
|
4
4
|
export { Icons } from './explorer';
|
|
5
5
|
export * from './types';
|
|
6
6
|
export * from './enum';
|
package/lib/es/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @gingkoo/pandora-explorer v0.0.1-alpha.
|
|
2
|
+
* @gingkoo/pandora-explorer v0.0.1-alpha.98
|
|
3
3
|
*/
|
|
4
4
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
5
5
|
import cx$1 from 'classnames';
|
|
@@ -1603,6 +1603,32 @@ function getMenu(key) {
|
|
|
1603
1603
|
function registerMenu(key, component) {
|
|
1604
1604
|
iconFactory[key] = component;
|
|
1605
1605
|
}
|
|
1606
|
+
function addMenuItem(key, menu) {
|
|
1607
|
+
let keys = [];
|
|
1608
|
+
if (Array.isArray(key)) {
|
|
1609
|
+
keys = key;
|
|
1610
|
+
} else {
|
|
1611
|
+
keys = [key];
|
|
1612
|
+
}
|
|
1613
|
+
keys.map(v => {
|
|
1614
|
+
let component = getMenu(v);
|
|
1615
|
+
let arr = [...component, ...menu];
|
|
1616
|
+
registerMenu(v, arr);
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
function removeMenuItem(key, menuItem) {
|
|
1620
|
+
let keys = [];
|
|
1621
|
+
if (Array.isArray(key)) {
|
|
1622
|
+
keys = key;
|
|
1623
|
+
} else {
|
|
1624
|
+
keys = [key];
|
|
1625
|
+
}
|
|
1626
|
+
keys.map(v => {
|
|
1627
|
+
let component = getMenu(v);
|
|
1628
|
+
let arr = component.filter(item => !menuItem.includes(item.key));
|
|
1629
|
+
registerMenu(v, arr);
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1606
1632
|
//
|
|
1607
1633
|
registerMenu('basis', [{
|
|
1608
1634
|
key: 'open',
|
|
@@ -1892,12 +1918,17 @@ function Menu(props) {
|
|
|
1892
1918
|
let upload = ['file-upload'];
|
|
1893
1919
|
let delect = ['remove'];
|
|
1894
1920
|
let arr = [];
|
|
1895
|
-
let _menu =
|
|
1921
|
+
let _menu = [];
|
|
1922
|
+
menu.map(v => {
|
|
1896
1923
|
let data = v;
|
|
1897
1924
|
if (loadMenu) {
|
|
1898
1925
|
data = loadMenu(v);
|
|
1899
1926
|
}
|
|
1900
|
-
|
|
1927
|
+
if (Array.isArray(data)) {
|
|
1928
|
+
_menu = [..._menu, ...data];
|
|
1929
|
+
} else {
|
|
1930
|
+
_menu.push(data);
|
|
1931
|
+
}
|
|
1901
1932
|
});
|
|
1902
1933
|
_menu.map(v => {
|
|
1903
1934
|
if (!store?.isEdit && edit.includes(v?.key)) {
|
|
@@ -9277,6 +9308,7 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
9277
9308
|
onExpand,
|
|
9278
9309
|
loadData: _loadData,
|
|
9279
9310
|
onRename: _onRename,
|
|
9311
|
+
onSelectFile,
|
|
9280
9312
|
onMenuClick: _onMenuClick,
|
|
9281
9313
|
onMoveFile: _onMoveFile
|
|
9282
9314
|
} = props;
|
|
@@ -9948,7 +9980,13 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
9948
9980
|
setLoading,
|
|
9949
9981
|
setReName: setRename,
|
|
9950
9982
|
setMenuRename,
|
|
9951
|
-
setCurSelect
|
|
9983
|
+
setCurSelect: v => {
|
|
9984
|
+
if (v == '_ending') {
|
|
9985
|
+
v = null;
|
|
9986
|
+
}
|
|
9987
|
+
setCurSelect(v);
|
|
9988
|
+
onSelectFile?.(v, dataMap?.[v || '']);
|
|
9989
|
+
},
|
|
9952
9990
|
setCurSelectFile,
|
|
9953
9991
|
setLoadKey,
|
|
9954
9992
|
setNavLoadKey,
|
|
@@ -9973,5 +10011,5 @@ const Explorer = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
9973
10011
|
});
|
|
9974
10012
|
});
|
|
9975
10013
|
|
|
9976
|
-
export { ApiStatusEnum, Explorer, Menu as ExplorerMenu, Icons, ImgSuffix, Explorer as default, registerMenu };
|
|
10014
|
+
export { ApiStatusEnum, Explorer, Menu as ExplorerMenu, Icons, ImgSuffix, addMenuItem, Explorer as default, registerMenu, removeMenuItem };
|
|
9977
10015
|
//# sourceMappingURL=index.js.map
|