@nocobase/plugin-mobile-client 0.11.1-alpha.4 → 0.12.0-alpha.1
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.
- package/client.d.ts +2 -3
- package/client.js +1 -1
- package/dist/client/index.js +2465 -0
- package/{lib → dist}/index.d.ts +1 -0
- package/dist/index.js +18 -0
- package/dist/locale/en-US.js +6 -0
- package/dist/locale/fr-FR.js +6 -0
- package/dist/locale/zh-CN.js +36 -0
- package/dist/server/index.js +11 -0
- package/dist/server/migrations/20230620203218-mobile-ui-schema-uid.js +33 -0
- package/dist/server/plugin.js +68 -0
- package/dist/server/routes.js +42 -0
- package/docs/en-US/index.md +7 -0
- package/docs/en-US/installation.md +13 -0
- package/docs/en-US/tabs.json +14 -0
- package/docs/en-US/usage.md +1 -0
- package/docs/zh-CN/index.md +7 -0
- package/docs/zh-CN/installation.md +13 -0
- package/docs/zh-CN/tabs.json +14 -0
- package/docs/zh-CN/usage.md +2 -0
- package/package.json +16 -27
- package/server.d.ts +2 -3
- package/server.js +1 -1
- package/lib/client/MobileClientProvider.js +0 -64
- package/lib/client/configuration/App.js +0 -40
- package/lib/client/configuration/Interface.js +0 -20
- package/lib/client/configuration/index.js +0 -27
- package/lib/client/core/bridge/index.js +0 -17
- package/lib/client/core/bridge/injects.js +0 -13
- package/lib/client/core/bridge/native-call.js +0 -24
- package/lib/client/core/index.js +0 -46
- package/lib/client/core/schema/common/index.js +0 -16
- package/lib/client/core/schema/common/page.js +0 -23
- package/lib/client/core/schema/components/container/Container.Designer.js +0 -139
- package/lib/client/core/schema/components/container/Container.js +0 -119
- package/lib/client/core/schema/components/container/index.js +0 -16
- package/lib/client/core/schema/components/container/style.js +0 -48
- package/lib/client/core/schema/components/header/Header.Designer.js +0 -72
- package/lib/client/core/schema/components/header/Header.js +0 -86
- package/lib/client/core/schema/components/header/index.js +0 -16
- package/lib/client/core/schema/components/index.js +0 -71
- package/lib/client/core/schema/components/menu/Menu.Designer.js +0 -81
- package/lib/client/core/schema/components/menu/Menu.Item.js +0 -106
- package/lib/client/core/schema/components/menu/Menu.js +0 -80
- package/lib/client/core/schema/components/menu/MenuBlockInitializer.js +0 -51
- package/lib/client/core/schema/components/menu/index.js +0 -27
- package/lib/client/core/schema/components/menu/schema.js +0 -25
- package/lib/client/core/schema/components/menu/style.js +0 -34
- package/lib/client/core/schema/components/page/Page.Designer.js +0 -161
- package/lib/client/core/schema/components/page/Page.js +0 -130
- package/lib/client/core/schema/components/page/index.js +0 -16
- package/lib/client/core/schema/components/page/style.js +0 -55
- package/lib/client/core/schema/components/settings/Settings.Designer.js +0 -37
- package/lib/client/core/schema/components/settings/Settings.js +0 -36
- package/lib/client/core/schema/components/settings/SettingsBlockInitializer.js +0 -51
- package/lib/client/core/schema/components/settings/index.js +0 -27
- package/lib/client/core/schema/components/tab-bar/TabBar.Item.js +0 -73
- package/lib/client/core/schema/components/tab-bar/TabBar.js +0 -135
- package/lib/client/core/schema/components/tab-bar/index.js +0 -16
- package/lib/client/core/schema/components/tab-bar/schema.js +0 -25
- package/lib/client/core/schema/helpers/index.js +0 -49
- package/lib/client/core/schema/hooks/index.js +0 -16
- package/lib/client/core/schema/hooks/useSchemaPatch.js +0 -64
- package/lib/client/core/schema/index.js +0 -38
- package/lib/client/core/schema/initializers/BlockInitializers.js +0 -79
- package/lib/client/core/schema/initializers/index.js +0 -16
- package/lib/client/core/schema/scopes/grid-card.js +0 -45
- package/lib/client/core/schema/scopes/index.js +0 -16
- package/lib/client/devices/iOS6.js +0 -32
- package/lib/client/devices/index.js +0 -43
- package/lib/client/index.js +0 -83
- package/lib/client/locale/index.js +0 -40
- package/lib/client/router/Application.js +0 -128
- package/lib/client/router/InterfaceProvider.js +0 -29
- package/lib/client/router/InterfaceRouter.js +0 -30
- package/lib/client/router/index.js +0 -16
- package/lib/index.js +0 -13
- package/lib/locale/en-US.js +0 -9
- package/lib/locale/fr-FR.js +0 -9
- package/lib/locale/zh-CN.js +0 -39
- package/lib/server/index.js +0 -13
- package/lib/server/migrations/20230620203218-mobile-ui-schema-uid.js +0 -56
- package/lib/server/plugin.js +0 -102
- package/lib/server/routes.js +0 -41
- package/src/client/MobileClientProvider.tsx +0 -41
- package/src/client/configuration/App.tsx +0 -23
- package/src/client/configuration/Interface.tsx +0 -11
- package/src/client/configuration/index.ts +0 -2
- package/src/client/core/bridge/index.ts +0 -2
- package/src/client/core/bridge/injects.ts +0 -15
- package/src/client/core/bridge/native-call.ts +0 -23
- package/src/client/core/index.tsx +0 -45
- package/src/client/core/schema/common/index.ts +0 -1
- package/src/client/core/schema/common/page.ts +0 -16
- package/src/client/core/schema/components/container/Container.Designer.tsx +0 -89
- package/src/client/core/schema/components/container/Container.tsx +0 -89
- package/src/client/core/schema/components/container/index.ts +0 -1
- package/src/client/core/schema/components/container/style.ts +0 -35
- package/src/client/core/schema/components/header/Header.Designer.tsx +0 -39
- package/src/client/core/schema/components/header/Header.tsx +0 -49
- package/src/client/core/schema/components/header/index.ts +0 -1
- package/src/client/core/schema/components/index.ts +0 -6
- package/src/client/core/schema/components/menu/Menu.Designer.tsx +0 -46
- package/src/client/core/schema/components/menu/Menu.Item.tsx +0 -89
- package/src/client/core/schema/components/menu/Menu.tsx +0 -75
- package/src/client/core/schema/components/menu/MenuBlockInitializer.tsx +0 -20
- package/src/client/core/schema/components/menu/index.ts +0 -2
- package/src/client/core/schema/components/menu/schema.ts +0 -19
- package/src/client/core/schema/components/menu/style.ts +0 -20
- package/src/client/core/schema/components/page/Page.Designer.tsx +0 -107
- package/src/client/core/schema/components/page/Page.tsx +0 -115
- package/src/client/core/schema/components/page/index.ts +0 -1
- package/src/client/core/schema/components/page/style.ts +0 -43
- package/src/client/core/schema/components/settings/Settings.Designer.tsx +0 -22
- package/src/client/core/schema/components/settings/Settings.tsx +0 -24
- package/src/client/core/schema/components/settings/SettingsBlockInitializer.tsx +0 -20
- package/src/client/core/schema/components/settings/index.ts +0 -2
- package/src/client/core/schema/components/tab-bar/TabBar.Item.tsx +0 -66
- package/src/client/core/schema/components/tab-bar/TabBar.tsx +0 -115
- package/src/client/core/schema/components/tab-bar/index.ts +0 -1
- package/src/client/core/schema/components/tab-bar/schema.ts +0 -18
- package/src/client/core/schema/helpers/index.ts +0 -38
- package/src/client/core/schema/hooks/index.ts +0 -1
- package/src/client/core/schema/hooks/useSchemaPatch.ts +0 -30
- package/src/client/core/schema/index.ts +0 -3
- package/src/client/core/schema/initializers/BlockInitializers.ts +0 -81
- package/src/client/core/schema/initializers/index.ts +0 -1
- package/src/client/core/schema/scopes/grid-card.ts +0 -35
- package/src/client/core/schema/scopes/index.ts +0 -1
- package/src/client/devices/iOS6.tsx +0 -24
- package/src/client/devices/index.tsx +0 -27
- package/src/client/index.tsx +0 -48
- package/src/client/locale/index.ts +0 -21
- package/src/client/router/Application.tsx +0 -128
- package/src/client/router/InterfaceProvider.tsx +0 -11
- package/src/client/router/InterfaceRouter.tsx +0 -16
- package/src/client/router/index.ts +0 -1
- package/src/index.ts +0 -1
- package/src/locale/en-US.ts +0 -3
- package/src/locale/fr-FR.ts +0 -3
- package/src/locale/zh-CN.ts +0 -33
- package/src/server/collections/.gitkeep +0 -0
- package/src/server/index.ts +0 -1
- package/src/server/migrations/20230620203218-mobile-ui-schema-uid.ts +0 -26
- package/src/server/plugin.ts +0 -63
- package/src/server/routes.ts +0 -38
- /package/{lib → dist}/client/MobileClientProvider.d.ts +0 -0
- /package/{lib → dist}/client/configuration/App.d.ts +0 -0
- /package/{lib → dist}/client/configuration/Interface.d.ts +0 -0
- /package/{lib → dist}/client/configuration/index.d.ts +0 -0
- /package/{lib → dist}/client/core/bridge/index.d.ts +0 -0
- /package/{lib → dist}/client/core/bridge/injects.d.ts +0 -0
- /package/{lib → dist}/client/core/bridge/native-call.d.ts +0 -0
- /package/{lib → dist}/client/core/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/common/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/common/page.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/container/Container.Designer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/container/Container.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/container/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/container/style.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/header/Header.Designer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/header/Header.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/header/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/Menu.Designer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/Menu.Item.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/Menu.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/MenuBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/schema.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/menu/style.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/page/Page.Designer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/page/Page.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/page/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/page/style.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/settings/Settings.Designer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/settings/Settings.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/settings/SettingsBlockInitializer.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/settings/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/tab-bar/TabBar.Item.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/tab-bar/TabBar.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/tab-bar/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/components/tab-bar/schema.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/helpers/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/hooks/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/hooks/useSchemaPatch.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/initializers/BlockInitializers.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/initializers/index.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/scopes/grid-card.d.ts +0 -0
- /package/{lib → dist}/client/core/schema/scopes/index.d.ts +0 -0
- /package/{lib → dist}/client/devices/iOS6.d.ts +0 -0
- /package/{lib → dist}/client/devices/index.d.ts +0 -0
- /package/{lib → dist}/client/index.d.ts +0 -0
- /package/{lib → dist}/client/locale/index.d.ts +0 -0
- /package/{lib → dist}/client/router/Application.d.ts +0 -0
- /package/{lib → dist}/client/router/InterfaceProvider.d.ts +0 -0
- /package/{lib → dist}/client/router/InterfaceRouter.d.ts +0 -0
- /package/{lib → dist}/client/router/index.d.ts +0 -0
- /package/{lib → dist}/locale/en-US.d.ts +0 -0
- /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
- /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
- /package/{lib → dist}/server/index.d.ts +0 -0
- /package/{lib → dist}/server/migrations/20230620203218-mobile-ui-schema-uid.d.ts +0 -0
- /package/{lib → dist}/server/plugin.d.ts +0 -0
- /package/{lib → dist}/server/routes.d.ts +0 -0
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { useField } from '@formily/react';
|
|
2
|
-
import { cx, SortableItem, useCompile, useDesigner, useDocumentTitle, useToken } from '@nocobase/client';
|
|
3
|
-
import { NavBar, NavBarProps } from 'antd-mobile';
|
|
4
|
-
import React, { useEffect, useMemo } from 'react';
|
|
5
|
-
import { useNavigate } from 'react-router-dom';
|
|
6
|
-
import { generateNTemplate } from '../../../../locale';
|
|
7
|
-
import { HeaderDesigner } from './Header.Designer';
|
|
8
|
-
|
|
9
|
-
export interface HeaderProps extends NavBarProps {
|
|
10
|
-
title?: string;
|
|
11
|
-
showBack?: boolean;
|
|
12
|
-
}
|
|
13
|
-
const InternalHeader = (props: HeaderProps) => {
|
|
14
|
-
const field = useField();
|
|
15
|
-
const { title = generateNTemplate('Untitled'), showBack = false } = { ...props, ...field?.componentProps };
|
|
16
|
-
const Designer = useDesigner();
|
|
17
|
-
const compile = useCompile();
|
|
18
|
-
const compiledTitle = compile(title);
|
|
19
|
-
const navigate = useNavigate();
|
|
20
|
-
const { setTitle } = useDocumentTitle();
|
|
21
|
-
const { token } = useToken();
|
|
22
|
-
|
|
23
|
-
useEffect(() => {
|
|
24
|
-
// sync title
|
|
25
|
-
setTitle(compiledTitle);
|
|
26
|
-
}, [compiledTitle]);
|
|
27
|
-
|
|
28
|
-
const style = useMemo(() => {
|
|
29
|
-
return {
|
|
30
|
-
width: '100%',
|
|
31
|
-
background: token.colorBgContainer,
|
|
32
|
-
};
|
|
33
|
-
}, [token.colorBgContainer]);
|
|
34
|
-
|
|
35
|
-
return (
|
|
36
|
-
<SortableItem className={cx('nb-mobile-header')} style={style}>
|
|
37
|
-
<NavBar backArrow={showBack} onBack={() => navigate(-1)}>
|
|
38
|
-
{compiledTitle}
|
|
39
|
-
</NavBar>
|
|
40
|
-
<Designer />
|
|
41
|
-
</SortableItem>
|
|
42
|
-
);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const MHeader = InternalHeader as unknown as typeof InternalHeader & {
|
|
46
|
-
Designer: typeof HeaderDesigner;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
MHeader.Designer = HeaderDesigner;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Header';
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { MenuOutlined } from '@ant-design/icons';
|
|
2
|
-
import { useField, useFieldSchema } from '@formily/react';
|
|
3
|
-
import { SchemaSettings, useDesignable } from '@nocobase/client';
|
|
4
|
-
import { Button } from 'antd';
|
|
5
|
-
import React from 'react';
|
|
6
|
-
import { useTranslation } from '../../../../locale';
|
|
7
|
-
|
|
8
|
-
export const MenuDesigner: React.FC = (props) => {
|
|
9
|
-
const { t } = useTranslation();
|
|
10
|
-
const fieldSchema = useFieldSchema();
|
|
11
|
-
const { dn } = useDesignable();
|
|
12
|
-
const field = useField();
|
|
13
|
-
const schemaSettingsProps = {
|
|
14
|
-
dn,
|
|
15
|
-
field,
|
|
16
|
-
fieldSchema,
|
|
17
|
-
};
|
|
18
|
-
return (
|
|
19
|
-
<SchemaSettings
|
|
20
|
-
title={
|
|
21
|
-
<Button
|
|
22
|
-
style={{
|
|
23
|
-
borderColor: 'var(--colorSettings)',
|
|
24
|
-
color: 'var(--colorSettings)',
|
|
25
|
-
}}
|
|
26
|
-
icon={<MenuOutlined />}
|
|
27
|
-
type="dashed"
|
|
28
|
-
>
|
|
29
|
-
{t('Menu configuration')}
|
|
30
|
-
</Button>
|
|
31
|
-
}
|
|
32
|
-
{...schemaSettingsProps}
|
|
33
|
-
>
|
|
34
|
-
<SchemaSettings.Remove
|
|
35
|
-
key="remove"
|
|
36
|
-
removeParentsIfNoChildren
|
|
37
|
-
confirm={{
|
|
38
|
-
title: t('Delete menu block'),
|
|
39
|
-
}}
|
|
40
|
-
breakRemoveOn={{
|
|
41
|
-
'x-component': 'Grid',
|
|
42
|
-
}}
|
|
43
|
-
/>
|
|
44
|
-
</SchemaSettings>
|
|
45
|
-
);
|
|
46
|
-
};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import { useField, useFieldSchema } from '@formily/react';
|
|
2
|
-
import {
|
|
3
|
-
GeneralSchemaDesigner,
|
|
4
|
-
Icon,
|
|
5
|
-
SchemaSettings,
|
|
6
|
-
SortableItem,
|
|
7
|
-
css,
|
|
8
|
-
cx,
|
|
9
|
-
useCompile,
|
|
10
|
-
useDesigner,
|
|
11
|
-
} from '@nocobase/client';
|
|
12
|
-
import { List, ListItemProps } from 'antd-mobile';
|
|
13
|
-
import React from 'react';
|
|
14
|
-
import { useLocation, useNavigate, useParams } from 'react-router-dom';
|
|
15
|
-
import { useTranslation } from '../../../../locale';
|
|
16
|
-
import { useSchemaPatch } from '../../hooks';
|
|
17
|
-
import { menuItemSchema } from './schema';
|
|
18
|
-
|
|
19
|
-
interface MMenuItemProps extends ListItemProps {
|
|
20
|
-
name: string;
|
|
21
|
-
icon: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const InternalMenuItem: React.FC<MMenuItemProps> = (props) => {
|
|
25
|
-
const { icon, name } = props;
|
|
26
|
-
const Designer = useDesigner();
|
|
27
|
-
const navigate = useNavigate();
|
|
28
|
-
const location = useLocation();
|
|
29
|
-
const fieldSchema = useFieldSchema();
|
|
30
|
-
const compile = useCompile();
|
|
31
|
-
const params = useParams<{ name: string }>();
|
|
32
|
-
|
|
33
|
-
const onToPage = () => {
|
|
34
|
-
const locationPath = location.pathname.endsWith('/') ? location.pathname.slice(0, -1) : location.pathname;
|
|
35
|
-
navigate(params.name ? `/mobile/${fieldSchema['x-uid']}` : `${locationPath}/${fieldSchema['x-uid']}`);
|
|
36
|
-
};
|
|
37
|
-
return (
|
|
38
|
-
<SortableItem
|
|
39
|
-
className={cx(
|
|
40
|
-
'nb-mobile-menu-item',
|
|
41
|
-
css`
|
|
42
|
-
width: 100%;
|
|
43
|
-
background: var(--adm-color-background);
|
|
44
|
-
> .adm-list-item {
|
|
45
|
-
background: inherit;
|
|
46
|
-
}
|
|
47
|
-
`,
|
|
48
|
-
)}
|
|
49
|
-
>
|
|
50
|
-
<List.Item arrow clickable {...props} prefix={<Icon type={icon} />} onClick={onToPage}>
|
|
51
|
-
{compile(name)}
|
|
52
|
-
</List.Item>
|
|
53
|
-
<Designer></Designer>
|
|
54
|
-
</SortableItem>
|
|
55
|
-
);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const MenuItemDesigner: React.FC = () => {
|
|
59
|
-
const { t } = useTranslation();
|
|
60
|
-
const { onUpdateComponentProps } = useSchemaPatch();
|
|
61
|
-
const field = useField();
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<GeneralSchemaDesigner>
|
|
65
|
-
<SchemaSettings.ModalItem
|
|
66
|
-
title={t('Edit menu info')}
|
|
67
|
-
initialValues={field.componentProps}
|
|
68
|
-
schema={menuItemSchema}
|
|
69
|
-
onSubmit={onUpdateComponentProps}
|
|
70
|
-
/>
|
|
71
|
-
<SchemaSettings.Remove
|
|
72
|
-
key="remove"
|
|
73
|
-
removeParentsIfNoChildren
|
|
74
|
-
confirm={{
|
|
75
|
-
title: t('Delete menu item?'),
|
|
76
|
-
}}
|
|
77
|
-
breakRemoveOn={{
|
|
78
|
-
'x-component': 'MMenu',
|
|
79
|
-
}}
|
|
80
|
-
/>
|
|
81
|
-
</GeneralSchemaDesigner>
|
|
82
|
-
);
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export const MenuItem = InternalMenuItem as typeof InternalMenuItem as unknown as {
|
|
86
|
-
Designer: typeof MenuItemDesigner;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
MenuItem.Designer = MenuItemDesigner;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { useFieldSchema } from '@formily/react';
|
|
2
|
-
import {
|
|
3
|
-
cx,
|
|
4
|
-
DndContext,
|
|
5
|
-
SchemaComponent,
|
|
6
|
-
SchemaInitializer,
|
|
7
|
-
SortableItem,
|
|
8
|
-
useDesignable,
|
|
9
|
-
useDesigner,
|
|
10
|
-
} from '@nocobase/client';
|
|
11
|
-
import { List } from 'antd-mobile';
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import { useTranslation } from '../../../../locale';
|
|
14
|
-
import { PageSchema } from '../../common';
|
|
15
|
-
import { MenuDesigner } from './Menu.Designer';
|
|
16
|
-
import { MenuItem } from './Menu.Item';
|
|
17
|
-
import { menuItemSchema } from './schema';
|
|
18
|
-
import useStyles from './style';
|
|
19
|
-
|
|
20
|
-
const InternalMenu: React.FC = (props) => {
|
|
21
|
-
const { styles } = useStyles();
|
|
22
|
-
const Designer = useDesigner();
|
|
23
|
-
const fieldSchema = useFieldSchema();
|
|
24
|
-
const { insertBeforeEnd, designable } = useDesignable();
|
|
25
|
-
|
|
26
|
-
const { t } = useTranslation();
|
|
27
|
-
|
|
28
|
-
const onAddMenuItem = (values: any) => {
|
|
29
|
-
const properties = {
|
|
30
|
-
page: PageSchema,
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
return insertBeforeEnd({
|
|
34
|
-
type: 'void',
|
|
35
|
-
title: values.name,
|
|
36
|
-
'x-component': 'MMenu.Item',
|
|
37
|
-
'x-component-props': values,
|
|
38
|
-
'x-designer': 'MMenu.Item.Designer',
|
|
39
|
-
properties,
|
|
40
|
-
});
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return (
|
|
44
|
-
<SortableItem className={cx('nb-mobile-menu', styles.mobileMenu)}>
|
|
45
|
-
<List>
|
|
46
|
-
{designable && (
|
|
47
|
-
<List.Item>
|
|
48
|
-
<Designer />
|
|
49
|
-
</List.Item>
|
|
50
|
-
)}
|
|
51
|
-
<DndContext>
|
|
52
|
-
<SchemaComponent onlyRenderProperties schema={fieldSchema}></SchemaComponent>
|
|
53
|
-
</DndContext>
|
|
54
|
-
{designable ? (
|
|
55
|
-
<List.Item>
|
|
56
|
-
<SchemaInitializer.ActionModal
|
|
57
|
-
buttonText={t('Add menu item')}
|
|
58
|
-
title={t('Add menu item')}
|
|
59
|
-
schema={menuItemSchema}
|
|
60
|
-
onSubmit={onAddMenuItem}
|
|
61
|
-
/>
|
|
62
|
-
</List.Item>
|
|
63
|
-
) : null}
|
|
64
|
-
</List>
|
|
65
|
-
</SortableItem>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const MMenu = InternalMenu as unknown as typeof InternalMenu & {
|
|
70
|
-
Item: typeof MenuItem;
|
|
71
|
-
Designer: typeof MenuDesigner;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
MMenu.Item = MenuItem;
|
|
75
|
-
MMenu.Designer = MenuDesigner;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { MenuOutlined } from '@ant-design/icons';
|
|
3
|
-
import { SchemaInitializer } from '@nocobase/client';
|
|
4
|
-
|
|
5
|
-
export const MMenuBlockInitializer = (props) => {
|
|
6
|
-
const { insert } = props;
|
|
7
|
-
return (
|
|
8
|
-
<SchemaInitializer.Item
|
|
9
|
-
icon={<MenuOutlined />}
|
|
10
|
-
onClick={async () => {
|
|
11
|
-
insert({
|
|
12
|
-
type: 'void',
|
|
13
|
-
'x-component': 'MMenu',
|
|
14
|
-
'x-designer': 'MMenu.Designer',
|
|
15
|
-
'x-component-props': {},
|
|
16
|
-
});
|
|
17
|
-
}}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { generateNTemplate } from '../../../../locale';
|
|
2
|
-
|
|
3
|
-
export const menuItemSchema = {
|
|
4
|
-
properties: {
|
|
5
|
-
name: {
|
|
6
|
-
type: 'string',
|
|
7
|
-
title: generateNTemplate('Menu name'),
|
|
8
|
-
required: true,
|
|
9
|
-
'x-component': 'Input',
|
|
10
|
-
'x-decorator': 'FormItem',
|
|
11
|
-
},
|
|
12
|
-
icon: {
|
|
13
|
-
'x-decorator': 'FormItem',
|
|
14
|
-
'x-component': 'IconPicker',
|
|
15
|
-
title: generateNTemplate('Icon'),
|
|
16
|
-
'x-component-props': {},
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@nocobase/client';
|
|
2
|
-
|
|
3
|
-
const useStyles = createStyles(({ token, css }) => {
|
|
4
|
-
return {
|
|
5
|
-
mobileMenu: css`
|
|
6
|
-
--adm-color-primary: ${token.colorPrimary};
|
|
7
|
-
--adm-color-primary-hover: ${token.colorPrimaryHover};
|
|
8
|
-
--adm-color-primary-active: ${token.colorPrimaryActive};
|
|
9
|
-
--padding-left: ${token.paddingSM}px;
|
|
10
|
-
--adm-color-background: ${token.colorBgContainer};
|
|
11
|
-
--adm-color-border: ${token.colorBorder};
|
|
12
|
-
|
|
13
|
-
background: ${token.colorBgContainer};
|
|
14
|
-
width: 100%;
|
|
15
|
-
margin-bottom: var(--nb-spacing);
|
|
16
|
-
`,
|
|
17
|
-
};
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export default useStyles;
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { MenuOutlined } from '@ant-design/icons';
|
|
2
|
-
import { useField, useFieldSchema } from '@formily/react';
|
|
3
|
-
import { uid } from '@formily/shared';
|
|
4
|
-
import { SchemaSettings, useDesignable } from '@nocobase/client';
|
|
5
|
-
import { Button } from 'antd';
|
|
6
|
-
import React from 'react';
|
|
7
|
-
import { generateNTemplate, useTranslation } from '../../../../locale';
|
|
8
|
-
import { findGridSchema } from '../../helpers';
|
|
9
|
-
|
|
10
|
-
export const PageDesigner = (props) => {
|
|
11
|
-
const { showBack } = props;
|
|
12
|
-
const { t } = useTranslation();
|
|
13
|
-
const fieldSchema = useFieldSchema();
|
|
14
|
-
const { dn } = useDesignable();
|
|
15
|
-
const headerSchema = fieldSchema?.properties?.['header'];
|
|
16
|
-
const tabsSchema = fieldSchema?.properties?.['tabs'];
|
|
17
|
-
const field = useField();
|
|
18
|
-
const schemaSettingsProps = {
|
|
19
|
-
dn,
|
|
20
|
-
field,
|
|
21
|
-
fieldSchema,
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return (
|
|
25
|
-
<SchemaSettings
|
|
26
|
-
title={
|
|
27
|
-
<Button
|
|
28
|
-
style={{
|
|
29
|
-
borderColor: 'var(--colorSettings)',
|
|
30
|
-
color: 'var(--colorSettings)',
|
|
31
|
-
width: '100%',
|
|
32
|
-
}}
|
|
33
|
-
icon={<MenuOutlined />}
|
|
34
|
-
type="dashed"
|
|
35
|
-
>
|
|
36
|
-
{t('Page configuration')}
|
|
37
|
-
</Button>
|
|
38
|
-
}
|
|
39
|
-
{...schemaSettingsProps}
|
|
40
|
-
>
|
|
41
|
-
<SchemaSettings.SwitchItem
|
|
42
|
-
checked={!!headerSchema}
|
|
43
|
-
title={t('Enable Header')}
|
|
44
|
-
onChange={async (v) => {
|
|
45
|
-
if (v) {
|
|
46
|
-
await dn.insertAfterBegin({
|
|
47
|
-
type: 'void',
|
|
48
|
-
name: 'header',
|
|
49
|
-
'x-component': 'MHeader',
|
|
50
|
-
'x-designer': 'MHeader.Designer',
|
|
51
|
-
'x-component-props': {
|
|
52
|
-
title: fieldSchema.parent['x-component-props']?.name,
|
|
53
|
-
showBack,
|
|
54
|
-
},
|
|
55
|
-
});
|
|
56
|
-
} else {
|
|
57
|
-
await dn.remove(headerSchema);
|
|
58
|
-
}
|
|
59
|
-
dn.refresh();
|
|
60
|
-
}}
|
|
61
|
-
/>
|
|
62
|
-
<SchemaSettings.SwitchItem
|
|
63
|
-
checked={!!tabsSchema}
|
|
64
|
-
title={t('Enable Tabs')}
|
|
65
|
-
onChange={async (v) => {
|
|
66
|
-
if (v) {
|
|
67
|
-
const gridSchema = findGridSchema(fieldSchema);
|
|
68
|
-
if (gridSchema) {
|
|
69
|
-
return dn.remove(gridSchema).then(() => {
|
|
70
|
-
return dn.insertBeforeEnd({
|
|
71
|
-
type: 'void',
|
|
72
|
-
name: 'tabs',
|
|
73
|
-
'x-component': 'Tabs',
|
|
74
|
-
'x-component-props': {},
|
|
75
|
-
'x-initializer': 'TabPaneInitializers',
|
|
76
|
-
'x-initializer-props': {
|
|
77
|
-
gridInitializer: 'MBlockInitializers',
|
|
78
|
-
},
|
|
79
|
-
properties: {
|
|
80
|
-
tab1: {
|
|
81
|
-
type: 'void',
|
|
82
|
-
title: generateNTemplate('Untitled'),
|
|
83
|
-
'x-component': 'Tabs.TabPane',
|
|
84
|
-
'x-designer': 'Tabs.Designer',
|
|
85
|
-
'x-component-props': {},
|
|
86
|
-
properties: {
|
|
87
|
-
grid: {
|
|
88
|
-
...gridSchema,
|
|
89
|
-
'x-uid': uid(),
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
} else {
|
|
98
|
-
const gridSchema = findGridSchema(tabsSchema.properties[Object.keys(tabsSchema.properties)[0]]);
|
|
99
|
-
if (gridSchema) {
|
|
100
|
-
return dn.remove(tabsSchema).then(() => dn.insertBeforeEnd(gridSchema, {}));
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
}}
|
|
104
|
-
/>
|
|
105
|
-
</SchemaSettings>
|
|
106
|
-
);
|
|
107
|
-
};
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { RecursionField, useFieldSchema } from '@formily/react';
|
|
2
|
-
import { ActionBarProvider, SortableItem, TabsContextProvider, cx, useDesigner } from '@nocobase/client';
|
|
3
|
-
import { TabsProps } from 'antd';
|
|
4
|
-
import React, { useCallback } from 'react';
|
|
5
|
-
import { useSearchParams } from 'react-router-dom';
|
|
6
|
-
import { countGridCol } from '../../helpers';
|
|
7
|
-
import { PageDesigner } from './Page.Designer';
|
|
8
|
-
import useStyles from './style';
|
|
9
|
-
|
|
10
|
-
const InternalPage: React.FC = (props) => {
|
|
11
|
-
const { styles } = useStyles();
|
|
12
|
-
const Designer = useDesigner();
|
|
13
|
-
const fieldSchema = useFieldSchema();
|
|
14
|
-
const [searchParams, setSearchParams] = useSearchParams();
|
|
15
|
-
const tabsSchema = fieldSchema.properties?.['tabs'];
|
|
16
|
-
// Only support globalActions in page
|
|
17
|
-
const onlyInPage = fieldSchema.root === fieldSchema.parent;
|
|
18
|
-
let hasGlobalActions = false;
|
|
19
|
-
if (!tabsSchema && fieldSchema.properties) {
|
|
20
|
-
hasGlobalActions = countGridCol(fieldSchema.properties['grid'], 2) === 1;
|
|
21
|
-
} else if (searchParams.has('tab') && tabsSchema?.properties?.[searchParams.get('tab')]) {
|
|
22
|
-
hasGlobalActions = countGridCol(tabsSchema.properties[searchParams.get('tab')]?.properties?.['grid'], 2) === 1;
|
|
23
|
-
} else if (tabsSchema?.properties) {
|
|
24
|
-
const schema = Object.values(tabsSchema.properties).sort((t1, t2) => t1['x-index'] - t2['x-index'])[0];
|
|
25
|
-
if (schema) {
|
|
26
|
-
setTimeout(() => {
|
|
27
|
-
setSearchParams([['tab', schema.name.toString()]], {
|
|
28
|
-
replace: true,
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const onTabsChange = useCallback<TabsProps['onChange']>(
|
|
35
|
-
(key) => {
|
|
36
|
-
setSearchParams([['tab', key]], {
|
|
37
|
-
replace: true,
|
|
38
|
-
});
|
|
39
|
-
},
|
|
40
|
-
[setSearchParams],
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
const GlobalActionProvider = useCallback(
|
|
44
|
-
(props) => {
|
|
45
|
-
if (hasGlobalActions) {
|
|
46
|
-
return (
|
|
47
|
-
<TabsContextProvider>
|
|
48
|
-
<ActionBarProvider
|
|
49
|
-
container={
|
|
50
|
-
(typeof props.active !== 'undefined' ? props.active : true) && onlyInPage
|
|
51
|
-
? document.getElementById('nb-position-container')
|
|
52
|
-
: null
|
|
53
|
-
}
|
|
54
|
-
forceProps={{
|
|
55
|
-
layout: 'one-column',
|
|
56
|
-
className: styles.globalActionCSS,
|
|
57
|
-
}}
|
|
58
|
-
>
|
|
59
|
-
{props.children}
|
|
60
|
-
</ActionBarProvider>
|
|
61
|
-
</TabsContextProvider>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
64
|
-
return <>{props.children}</>;
|
|
65
|
-
},
|
|
66
|
-
[hasGlobalActions, onlyInPage],
|
|
67
|
-
);
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<SortableItem eid="nb-mobile-scroll-wrapper" className={cx('nb-mobile-page', styles.mobilePage)}>
|
|
71
|
-
<Designer {...fieldSchema?.['x-designer-props']}></Designer>
|
|
72
|
-
<div
|
|
73
|
-
style={{
|
|
74
|
-
paddingBottom: tabsSchema ? null : 'var(--nb-spacing)',
|
|
75
|
-
}}
|
|
76
|
-
className={cx('nb-mobile-page-header', styles.mobilePageHeader)}
|
|
77
|
-
>
|
|
78
|
-
<RecursionField
|
|
79
|
-
schema={fieldSchema}
|
|
80
|
-
filterProperties={(s) => {
|
|
81
|
-
return 'MHeader' === s['x-component'];
|
|
82
|
-
}}
|
|
83
|
-
></RecursionField>
|
|
84
|
-
<TabsContextProvider
|
|
85
|
-
PaneRoot={GlobalActionProvider}
|
|
86
|
-
activeKey={searchParams.get('tab')}
|
|
87
|
-
onChange={onTabsChange}
|
|
88
|
-
>
|
|
89
|
-
<RecursionField
|
|
90
|
-
schema={fieldSchema}
|
|
91
|
-
filterProperties={(s) => {
|
|
92
|
-
return 'Tabs' === s['x-component'];
|
|
93
|
-
}}
|
|
94
|
-
></RecursionField>
|
|
95
|
-
</TabsContextProvider>
|
|
96
|
-
</div>
|
|
97
|
-
<GlobalActionProvider>
|
|
98
|
-
{!tabsSchema && (
|
|
99
|
-
<RecursionField
|
|
100
|
-
schema={fieldSchema}
|
|
101
|
-
filterProperties={(s) => {
|
|
102
|
-
return s['x-component'] !== 'MHeader';
|
|
103
|
-
}}
|
|
104
|
-
></RecursionField>
|
|
105
|
-
)}
|
|
106
|
-
</GlobalActionProvider>
|
|
107
|
-
</SortableItem>
|
|
108
|
-
);
|
|
109
|
-
};
|
|
110
|
-
|
|
111
|
-
export const MPage = InternalPage as unknown as typeof InternalPage & {
|
|
112
|
-
Designer: typeof PageDesigner;
|
|
113
|
-
};
|
|
114
|
-
MPage.Designer = PageDesigner;
|
|
115
|
-
MPage.displayName = 'MPage';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './Page';
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createStyles } from '@nocobase/client';
|
|
2
|
-
|
|
3
|
-
const useStyles = createStyles(({ token, css }) => {
|
|
4
|
-
return {
|
|
5
|
-
globalActionCSS: css`
|
|
6
|
-
#nb-position-container > & {
|
|
7
|
-
height: ${token.sizeXXL}px;
|
|
8
|
-
border-top: 1px solid var(--nb-box-bg);
|
|
9
|
-
margin-bottom: 0px !important;
|
|
10
|
-
padding: 0 var(--nb-spacing);
|
|
11
|
-
align-items: center;
|
|
12
|
-
overflow-x: auto;
|
|
13
|
-
background: ${token.colorBgContainer};
|
|
14
|
-
z-index: 100;
|
|
15
|
-
}
|
|
16
|
-
`,
|
|
17
|
-
|
|
18
|
-
mobilePage: css`
|
|
19
|
-
background: var(--nb-box-bg);
|
|
20
|
-
display: flex;
|
|
21
|
-
flex-direction: column;
|
|
22
|
-
width: 100%;
|
|
23
|
-
height: 100%;
|
|
24
|
-
overflow-x: hidden;
|
|
25
|
-
overflow-y: auto;
|
|
26
|
-
padding-bottom: var(--nb-spacing);
|
|
27
|
-
`,
|
|
28
|
-
|
|
29
|
-
mobilePageHeader: css`
|
|
30
|
-
& > .ant-tabs > .ant-tabs-nav {
|
|
31
|
-
.ant-tabs-tab {
|
|
32
|
-
margin: 0 !important;
|
|
33
|
-
padding: 0 ${token.paddingContentHorizontal}px !important;
|
|
34
|
-
}
|
|
35
|
-
background: ${token.colorBgContainer};
|
|
36
|
-
}
|
|
37
|
-
display: flex;
|
|
38
|
-
flex-direction: column;
|
|
39
|
-
`,
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
export default useStyles;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { GeneralSchemaDesigner, SchemaSettings } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { useTranslation } from '../../../../locale';
|
|
4
|
-
|
|
5
|
-
export const SettingsDesigner = () => {
|
|
6
|
-
const { t } = useTranslation();
|
|
7
|
-
|
|
8
|
-
return (
|
|
9
|
-
<GeneralSchemaDesigner>
|
|
10
|
-
<SchemaSettings.Remove
|
|
11
|
-
key="remove"
|
|
12
|
-
removeParentsIfNoChildren
|
|
13
|
-
confirm={{
|
|
14
|
-
title: t('Delete settings block'),
|
|
15
|
-
}}
|
|
16
|
-
breakRemoveOn={{
|
|
17
|
-
'x-component': 'Grid',
|
|
18
|
-
}}
|
|
19
|
-
/>
|
|
20
|
-
</GeneralSchemaDesigner>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { css, cx, SettingsMenu, SortableItem, useDesigner } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { SettingsDesigner } from './Settings.Designer';
|
|
4
|
-
export const InternalSettings = () => {
|
|
5
|
-
const Designer = useDesigner();
|
|
6
|
-
return (
|
|
7
|
-
<SortableItem
|
|
8
|
-
className={cx(
|
|
9
|
-
'nb-mobile-setting',
|
|
10
|
-
css`
|
|
11
|
-
margin-bottom: var(--nb-spacing);
|
|
12
|
-
`,
|
|
13
|
-
)}
|
|
14
|
-
>
|
|
15
|
-
<Designer />
|
|
16
|
-
<SettingsMenu redirectUrl="/mobile" />
|
|
17
|
-
</SortableItem>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
export const MSettings = InternalSettings as unknown as typeof InternalSettings & {
|
|
21
|
-
Designer: typeof SettingsDesigner;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
MSettings.Designer = SettingsDesigner;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { SettingOutlined } from '@ant-design/icons';
|
|
3
|
-
import { SchemaInitializer } from '@nocobase/client';
|
|
4
|
-
|
|
5
|
-
export const MSettingsBlockInitializer = (props) => {
|
|
6
|
-
const { insert } = props;
|
|
7
|
-
return (
|
|
8
|
-
<SchemaInitializer.Item
|
|
9
|
-
icon={<SettingOutlined />}
|
|
10
|
-
onClick={async () => {
|
|
11
|
-
insert({
|
|
12
|
-
type: 'void',
|
|
13
|
-
'x-component': 'MSettings',
|
|
14
|
-
'x-designer': 'MSettings.Designer',
|
|
15
|
-
'x-component-props': {},
|
|
16
|
-
});
|
|
17
|
-
}}
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
};
|