@nocobase/plugin-mobile-client 0.11.1-alpha.5 → 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 -59
- 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 -29
- 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,66 +0,0 @@
|
|
|
1
|
-
import { useField, useFieldSchema } from '@formily/react';
|
|
2
|
-
import { css, cx, GeneralSchemaDesigner, SchemaSettings, SortableItem, useDesigner } from '@nocobase/client';
|
|
3
|
-
import { TabBarItemProps } from 'antd-mobile';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
import { useTranslation } from '../../../../locale';
|
|
6
|
-
import { useSchemaPatch } from '../../hooks';
|
|
7
|
-
import { tabItemSchema } from './schema';
|
|
8
|
-
|
|
9
|
-
const InternalItem: React.FC<TabBarItemProps> = () => {
|
|
10
|
-
// NOTE: nothing to do
|
|
11
|
-
// return <TabBar.Item {...props}></TabBar.Item>;
|
|
12
|
-
const Designer = useDesigner();
|
|
13
|
-
return (
|
|
14
|
-
<SortableItem
|
|
15
|
-
className={cx(
|
|
16
|
-
'nb-mobile-tab-bar-item',
|
|
17
|
-
css`
|
|
18
|
-
position: absolute !important;
|
|
19
|
-
width: 100%;
|
|
20
|
-
height: 100%;
|
|
21
|
-
top: 0;
|
|
22
|
-
left: 0;
|
|
23
|
-
`,
|
|
24
|
-
)}
|
|
25
|
-
>
|
|
26
|
-
<Designer />
|
|
27
|
-
</SortableItem>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const Designer = () => {
|
|
32
|
-
const { t } = useTranslation();
|
|
33
|
-
const fieldSchema = useFieldSchema();
|
|
34
|
-
const { onUpdateComponentProps } = useSchemaPatch();
|
|
35
|
-
const field = useField();
|
|
36
|
-
const tabItems = Object.keys(fieldSchema.parent.properties).length;
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<GeneralSchemaDesigner>
|
|
40
|
-
<SchemaSettings.ModalItem
|
|
41
|
-
title={t('Edit info')}
|
|
42
|
-
initialValues={field.componentProps}
|
|
43
|
-
schema={tabItemSchema}
|
|
44
|
-
onSubmit={onUpdateComponentProps}
|
|
45
|
-
></SchemaSettings.ModalItem>
|
|
46
|
-
{tabItems > 1 ? (
|
|
47
|
-
<SchemaSettings.Remove
|
|
48
|
-
key="remove"
|
|
49
|
-
removeParentsIfNoChildren
|
|
50
|
-
confirm={{
|
|
51
|
-
title: t('Delete tab item?'),
|
|
52
|
-
}}
|
|
53
|
-
breakRemoveOn={{
|
|
54
|
-
'x-component': 'MTabBar',
|
|
55
|
-
}}
|
|
56
|
-
></SchemaSettings.Remove>
|
|
57
|
-
) : null}
|
|
58
|
-
</GeneralSchemaDesigner>
|
|
59
|
-
);
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
export const TabBarItem = InternalItem as unknown as typeof InternalItem & {
|
|
63
|
-
Designer: typeof Designer;
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
TabBarItem.Designer = Designer;
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { useFieldSchema } from '@formily/react';
|
|
2
|
-
import { uid } from '@formily/shared';
|
|
3
|
-
import {
|
|
4
|
-
css,
|
|
5
|
-
cx,
|
|
6
|
-
DndContext,
|
|
7
|
-
Icon,
|
|
8
|
-
SchemaComponent,
|
|
9
|
-
SchemaInitializer,
|
|
10
|
-
SortableItem,
|
|
11
|
-
useCompile,
|
|
12
|
-
useDesignable,
|
|
13
|
-
} from '@nocobase/client';
|
|
14
|
-
import { TabBar } from 'antd-mobile';
|
|
15
|
-
import React, { useCallback } from 'react';
|
|
16
|
-
import { useNavigate, useParams } from 'react-router-dom';
|
|
17
|
-
import { useTranslation } from '../../../../locale';
|
|
18
|
-
import { PageSchema } from '../../common';
|
|
19
|
-
import { tabItemSchema } from './schema';
|
|
20
|
-
import { TabBarItem } from './TabBar.Item';
|
|
21
|
-
|
|
22
|
-
export const InternalTabBar: React.FC = (props) => {
|
|
23
|
-
const fieldSchema = useFieldSchema();
|
|
24
|
-
const { designable } = useDesignable();
|
|
25
|
-
const { t } = useTranslation();
|
|
26
|
-
const { insertBeforeEnd } = useDesignable();
|
|
27
|
-
const navigate = useNavigate();
|
|
28
|
-
const params = useParams<{ name: string }>();
|
|
29
|
-
const compile = useCompile();
|
|
30
|
-
|
|
31
|
-
const onAddTab = useCallback((values: any) => {
|
|
32
|
-
return insertBeforeEnd({
|
|
33
|
-
type: 'void',
|
|
34
|
-
'x-component': 'MTabBar.Item',
|
|
35
|
-
'x-component-props': values,
|
|
36
|
-
'x-designer': 'MTabBar.Item.Designer',
|
|
37
|
-
properties: {
|
|
38
|
-
[uid()]: PageSchema,
|
|
39
|
-
},
|
|
40
|
-
'x-server-hooks': [
|
|
41
|
-
{
|
|
42
|
-
type: 'onSelfSave',
|
|
43
|
-
method: 'extractTextToLocale',
|
|
44
|
-
},
|
|
45
|
-
],
|
|
46
|
-
});
|
|
47
|
-
}, []);
|
|
48
|
-
|
|
49
|
-
return (
|
|
50
|
-
<SortableItem
|
|
51
|
-
className={cx(
|
|
52
|
-
'nb-mobile-tab-bar',
|
|
53
|
-
css`
|
|
54
|
-
position: relative;
|
|
55
|
-
width: 100%;
|
|
56
|
-
display: flex;
|
|
57
|
-
align-items: center;
|
|
58
|
-
`,
|
|
59
|
-
)}
|
|
60
|
-
>
|
|
61
|
-
<DndContext>
|
|
62
|
-
<TabBar
|
|
63
|
-
activeKey={params.name}
|
|
64
|
-
onChange={(key) => {
|
|
65
|
-
if (key === 'add-tab') {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
navigate(`/mobile/${key}`);
|
|
69
|
-
}}
|
|
70
|
-
safeArea
|
|
71
|
-
className={cx(
|
|
72
|
-
css`
|
|
73
|
-
width: 100%;
|
|
74
|
-
`,
|
|
75
|
-
)}
|
|
76
|
-
>
|
|
77
|
-
{fieldSchema.mapProperties((schema, name) => {
|
|
78
|
-
const cp = schema['x-component-props'];
|
|
79
|
-
return (
|
|
80
|
-
<TabBar.Item
|
|
81
|
-
{...cp}
|
|
82
|
-
key={`tab_${schema['x-uid']}`}
|
|
83
|
-
title={
|
|
84
|
-
<>
|
|
85
|
-
{t(compile(cp.title))}
|
|
86
|
-
<SchemaComponent schema={schema} name={name} />
|
|
87
|
-
</>
|
|
88
|
-
}
|
|
89
|
-
icon={cp.icon ? <Icon type={cp.icon} /> : undefined}
|
|
90
|
-
></TabBar.Item>
|
|
91
|
-
);
|
|
92
|
-
})}
|
|
93
|
-
{designable && (!fieldSchema.properties || Object.keys(fieldSchema.properties).length < 5) ? (
|
|
94
|
-
<TabBar.Item
|
|
95
|
-
className={css`
|
|
96
|
-
.adm-tab-bar-item-icon {
|
|
97
|
-
height: auto;
|
|
98
|
-
}
|
|
99
|
-
`}
|
|
100
|
-
icon={<SchemaInitializer.ActionModal title={t('Add tab')} onSubmit={onAddTab} schema={tabItemSchema} />}
|
|
101
|
-
key="add-tab"
|
|
102
|
-
></TabBar.Item>
|
|
103
|
-
) : null}
|
|
104
|
-
</TabBar>
|
|
105
|
-
</DndContext>
|
|
106
|
-
</SortableItem>
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const MTabBar = InternalTabBar as unknown as typeof InternalTabBar & {
|
|
111
|
-
Item: typeof TabBarItem;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
MTabBar.Item = TabBarItem;
|
|
115
|
-
MTabBar.displayName = 'MTabBar';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './TabBar';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export const tabItemSchema = {
|
|
2
|
-
properties: {
|
|
3
|
-
title: {
|
|
4
|
-
type: 'string',
|
|
5
|
-
title: `{{ t('Title') }}`,
|
|
6
|
-
required: true,
|
|
7
|
-
'x-component': 'Input',
|
|
8
|
-
'x-decorator': 'FormItem',
|
|
9
|
-
},
|
|
10
|
-
icon: {
|
|
11
|
-
required: true,
|
|
12
|
-
'x-decorator': 'FormItem',
|
|
13
|
-
'x-component': 'IconPicker',
|
|
14
|
-
title: `{{ t('Icon') }}`,
|
|
15
|
-
'x-component-props': {},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ISchema, Schema } from '@formily/react';
|
|
2
|
-
import { uid } from '@formily/shared';
|
|
3
|
-
export const gridItemWrap = (schema: ISchema) => {
|
|
4
|
-
return {
|
|
5
|
-
type: 'void',
|
|
6
|
-
'x-component': 'MGrid.Item',
|
|
7
|
-
properties: {
|
|
8
|
-
[schema.name || uid()]: schema,
|
|
9
|
-
},
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export const findSchema = (schema: Schema, component: string) => {
|
|
14
|
-
const gridSchema = schema.reduceProperties(
|
|
15
|
-
(schema, next) => schema || (next['x-component'] === component && next),
|
|
16
|
-
) as Schema;
|
|
17
|
-
return gridSchema;
|
|
18
|
-
};
|
|
19
|
-
export const findGridSchema = (schema: Schema) => {
|
|
20
|
-
return findSchema(schema, 'Grid');
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const allowComponents = ['Grid', 'Grid.Row'];
|
|
24
|
-
const plusComponent = ['Grid.Col'];
|
|
25
|
-
export const countGridCol = (schema: Schema, countToStop?: number) => {
|
|
26
|
-
if (!schema) return 0;
|
|
27
|
-
let count = 0;
|
|
28
|
-
if (plusComponent.includes(schema['x-component'])) {
|
|
29
|
-
count += 1;
|
|
30
|
-
}
|
|
31
|
-
if (typeof countToStop === 'number' && count >= countToStop) return count;
|
|
32
|
-
if (allowComponents.includes(schema['x-component'])) {
|
|
33
|
-
schema.mapProperties((schema) => {
|
|
34
|
-
count += countGridCol(schema, countToStop);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return count;
|
|
38
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './useSchemaPatch';
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { useField, useFieldSchema } from '@formily/react';
|
|
2
|
-
import { useDesignable } from '@nocobase/client';
|
|
3
|
-
import { lodash } from '@nocobase/utils/client';
|
|
4
|
-
import { useCallback } from 'react';
|
|
5
|
-
|
|
6
|
-
export const useSchemaPatch = () => {
|
|
7
|
-
const { dn } = useDesignable();
|
|
8
|
-
const fieldSchema = useFieldSchema();
|
|
9
|
-
const field = useField();
|
|
10
|
-
|
|
11
|
-
const onUpdateComponentProps = useCallback((data) => {
|
|
12
|
-
lodash.set(fieldSchema, 'x-component-props', data);
|
|
13
|
-
field.componentProps = { ...field.componentProps, ...data };
|
|
14
|
-
dn.emit('patch', {
|
|
15
|
-
schema: {
|
|
16
|
-
['x-uid']: fieldSchema['x-uid'],
|
|
17
|
-
'x-component-props': fieldSchema['x-component-props'],
|
|
18
|
-
'x-server-hooks': [
|
|
19
|
-
{
|
|
20
|
-
type: 'onSelfSave',
|
|
21
|
-
method: 'extractTextToLocale',
|
|
22
|
-
},
|
|
23
|
-
],
|
|
24
|
-
},
|
|
25
|
-
});
|
|
26
|
-
dn.refresh();
|
|
27
|
-
}, []);
|
|
28
|
-
|
|
29
|
-
return { onUpdateComponentProps };
|
|
30
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { gridRowColWrap } from '@nocobase/client';
|
|
2
|
-
import { generateNTemplate } from '../../../locale';
|
|
3
|
-
|
|
4
|
-
// 页面里添加区块
|
|
5
|
-
export const MBlockInitializers = {
|
|
6
|
-
title: '{{t("Add block")}}',
|
|
7
|
-
icon: 'PlusOutlined',
|
|
8
|
-
wrap: gridRowColWrap,
|
|
9
|
-
items: [
|
|
10
|
-
{
|
|
11
|
-
key: 'dataBlocks',
|
|
12
|
-
type: 'itemGroup',
|
|
13
|
-
title: '{{t("Data blocks")}}',
|
|
14
|
-
children: [
|
|
15
|
-
{
|
|
16
|
-
key: 'GridCard',
|
|
17
|
-
type: 'item',
|
|
18
|
-
title: '{{t("Grid Card")}}',
|
|
19
|
-
component: 'GridCardBlockInitializer',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
key: 'table',
|
|
23
|
-
type: 'item',
|
|
24
|
-
title: '{{t("Table")}}',
|
|
25
|
-
component: 'TableBlockInitializer',
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
key: 'form',
|
|
29
|
-
type: 'item',
|
|
30
|
-
title: '{{t("Form")}}',
|
|
31
|
-
component: 'FormBlockInitializer',
|
|
32
|
-
},
|
|
33
|
-
{
|
|
34
|
-
key: 'details',
|
|
35
|
-
type: 'item',
|
|
36
|
-
title: '{{t("Details")}}',
|
|
37
|
-
component: 'DetailsBlockInitializer',
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
key: 'calendar',
|
|
41
|
-
type: 'item',
|
|
42
|
-
title: '{{t("Calendar")}}',
|
|
43
|
-
component: 'CalendarBlockInitializer',
|
|
44
|
-
},
|
|
45
|
-
{
|
|
46
|
-
key: 'mapBlock',
|
|
47
|
-
type: 'item',
|
|
48
|
-
title: generateNTemplate('Map'),
|
|
49
|
-
component: 'MapBlockInitializer',
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
key: 'otherBlocks',
|
|
55
|
-
type: 'itemGroup',
|
|
56
|
-
title: '{{t("Other blocks")}}',
|
|
57
|
-
children: [
|
|
58
|
-
{
|
|
59
|
-
key: 'menu',
|
|
60
|
-
type: 'item',
|
|
61
|
-
title: generateNTemplate('Menu'),
|
|
62
|
-
component: 'MMenuBlockInitializer',
|
|
63
|
-
sort: 100,
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
key: 'markdown',
|
|
67
|
-
type: 'item',
|
|
68
|
-
title: '{{t("Markdown")}}',
|
|
69
|
-
component: 'MarkdownBlockInitializer',
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
key: 'settings',
|
|
73
|
-
type: 'item',
|
|
74
|
-
title: generateNTemplate('Settings'),
|
|
75
|
-
component: 'MSettingsBlockInitializer',
|
|
76
|
-
sort: 100,
|
|
77
|
-
},
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
],
|
|
81
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './BlockInitializers';
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { css } from '@nocobase/client';
|
|
2
|
-
import { useInterfaceContext } from '../../../router/InterfaceProvider';
|
|
3
|
-
import { PaginationProps } from 'antd';
|
|
4
|
-
|
|
5
|
-
const listCss = css`
|
|
6
|
-
padding: 0 var(--nb-spacing);
|
|
7
|
-
& > .nb-action-bar {
|
|
8
|
-
padding: unset !important;
|
|
9
|
-
background: unset !important;
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
export const useGridCardBlockItemProps = () => {
|
|
13
|
-
return {
|
|
14
|
-
className: listCss,
|
|
15
|
-
};
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const columnCountConfig = {
|
|
19
|
-
xs: 1,
|
|
20
|
-
sm: 1,
|
|
21
|
-
md: 1,
|
|
22
|
-
lg: 1,
|
|
23
|
-
xl: 1,
|
|
24
|
-
xxl: 1,
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export const useGridCardBlockProps = () => {
|
|
28
|
-
const isInterface = useInterfaceContext();
|
|
29
|
-
return {
|
|
30
|
-
columnCount: isInterface ? columnCountConfig : null,
|
|
31
|
-
pagination: {
|
|
32
|
-
simple: true,
|
|
33
|
-
} as PaginationProps,
|
|
34
|
-
};
|
|
35
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './grid-card';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { css, cx } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
|
|
4
|
-
const iOS6: React.FC<{
|
|
5
|
-
className: string;
|
|
6
|
-
}> = (props) => {
|
|
7
|
-
return (
|
|
8
|
-
<div
|
|
9
|
-
className={cx(
|
|
10
|
-
'nb-mobile-device-ios6',
|
|
11
|
-
css(`
|
|
12
|
-
display: flex;
|
|
13
|
-
width: 375px;
|
|
14
|
-
height: 667px;
|
|
15
|
-
`),
|
|
16
|
-
props.className,
|
|
17
|
-
)}
|
|
18
|
-
>
|
|
19
|
-
{props.children}
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default iOS6;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { css, cx } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import Device from './iOS6';
|
|
4
|
-
|
|
5
|
-
export const MobileDevice: React.FC = (props) => {
|
|
6
|
-
return (
|
|
7
|
-
<div
|
|
8
|
-
className={cx(
|
|
9
|
-
'nb-mobile-device-wrapper',
|
|
10
|
-
css`
|
|
11
|
-
width: 100%;
|
|
12
|
-
height: 100%;
|
|
13
|
-
display: flex;
|
|
14
|
-
justify-content: center;
|
|
15
|
-
align-items: center;
|
|
16
|
-
`,
|
|
17
|
-
)}
|
|
18
|
-
>
|
|
19
|
-
<Device
|
|
20
|
-
className={css`
|
|
21
|
-
box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
|
|
22
|
-
`}
|
|
23
|
-
{...props}
|
|
24
|
-
></Device>
|
|
25
|
-
</div>
|
|
26
|
-
);
|
|
27
|
-
};
|
package/src/client/index.tsx
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { createRouterManager, Plugin, RouterManager, RouteSchemaComponent } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { Navigate } from 'react-router-dom';
|
|
4
|
-
import { MobileClientProvider } from './MobileClientProvider';
|
|
5
|
-
import MApplication from './router/Application';
|
|
6
|
-
|
|
7
|
-
export class MobileClientPlugin extends Plugin {
|
|
8
|
-
public mobileRouter: RouterManager;
|
|
9
|
-
async load() {
|
|
10
|
-
this.setMobileRouter();
|
|
11
|
-
this.addRoutes();
|
|
12
|
-
this.app.use(MobileClientProvider);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
setMobileRouter() {
|
|
16
|
-
const router = createRouterManager({ type: 'hash' });
|
|
17
|
-
router.add('root', {
|
|
18
|
-
path: '/',
|
|
19
|
-
element: <Navigate replace to="/mobile" />,
|
|
20
|
-
});
|
|
21
|
-
router.add('mobile', {
|
|
22
|
-
path: '/mobile',
|
|
23
|
-
element: <MApplication />,
|
|
24
|
-
});
|
|
25
|
-
router.add('mobile.page', {
|
|
26
|
-
path: '/mobile/:name',
|
|
27
|
-
element: <RouteSchemaComponent />,
|
|
28
|
-
});
|
|
29
|
-
this.mobileRouter = router;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getMobileRouterComponent() {
|
|
33
|
-
return this.mobileRouter.getRouterComponent();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
addRoutes() {
|
|
37
|
-
this.app.router.add('mobile', {
|
|
38
|
-
path: '/mobile',
|
|
39
|
-
element: <MApplication />,
|
|
40
|
-
});
|
|
41
|
-
this.app.router.add('mobile.page', {
|
|
42
|
-
path: '/mobile/:name',
|
|
43
|
-
Component: 'RouteSchemaComponent',
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export default MobileClientPlugin;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { i18n } from '@nocobase/client';
|
|
2
|
-
import { useTranslation as useT } from 'react-i18next';
|
|
3
|
-
|
|
4
|
-
export const NAMESPACE = 'mobile-client';
|
|
5
|
-
|
|
6
|
-
// i18n.addResources('zh-CN', NAMESPACE, zhCN);
|
|
7
|
-
// i18n.addResources('en-US', NAMESPACE, enUS);
|
|
8
|
-
|
|
9
|
-
export function lang(key: string) {
|
|
10
|
-
return i18n.t(key, { ns: NAMESPACE });
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function generateNTemplate(key: string) {
|
|
14
|
-
return `{{t('${key}', { ns: '${NAMESPACE}', nsMode: 'fallback' })}}`;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function useTranslation() {
|
|
18
|
-
return useT([NAMESPACE, 'client'], {
|
|
19
|
-
nsMode: 'fallback',
|
|
20
|
-
});
|
|
21
|
-
}
|
|
@@ -1,128 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionContextProvider,
|
|
3
|
-
AdminProvider,
|
|
4
|
-
css,
|
|
5
|
-
cx,
|
|
6
|
-
RemoteSchemaComponent,
|
|
7
|
-
useSystemSettings,
|
|
8
|
-
useViewport,
|
|
9
|
-
} from '@nocobase/client';
|
|
10
|
-
import { DrawerProps, ModalProps } from 'antd';
|
|
11
|
-
import React, { useMemo } from 'react';
|
|
12
|
-
import { Outlet, useParams } from 'react-router-dom';
|
|
13
|
-
import { MobileCore } from '../core';
|
|
14
|
-
import { useInterfaceContext } from './InterfaceProvider';
|
|
15
|
-
|
|
16
|
-
const commonCSSVariables = css`
|
|
17
|
-
--nb-spacing: 14px;
|
|
18
|
-
`;
|
|
19
|
-
const commonCSSOverride = css``;
|
|
20
|
-
const commonDesignerCSS = css`
|
|
21
|
-
--nb-designer-top: 2px;
|
|
22
|
-
--nb-designer-right: 2px;
|
|
23
|
-
.nb-sortable-designer:hover {
|
|
24
|
-
position: relative;
|
|
25
|
-
> .general-schema-designer {
|
|
26
|
-
display: block;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
.general-schema-designer {
|
|
30
|
-
position: absolute;
|
|
31
|
-
z-index: 999;
|
|
32
|
-
top: 0;
|
|
33
|
-
bottom: 0;
|
|
34
|
-
left: 0;
|
|
35
|
-
right: 0;
|
|
36
|
-
display: none;
|
|
37
|
-
border: 0;
|
|
38
|
-
pointer-events: none;
|
|
39
|
-
> .general-schema-designer-icons {
|
|
40
|
-
position: absolute;
|
|
41
|
-
top: var(--nb-designer-top);
|
|
42
|
-
right: var(--nb-designer-right);
|
|
43
|
-
line-height: 16px;
|
|
44
|
-
pointer-events: all;
|
|
45
|
-
.ant-space-item {
|
|
46
|
-
background-color: var(--colorSettings);
|
|
47
|
-
color: #fff;
|
|
48
|
-
line-height: 16px;
|
|
49
|
-
width: 16px;
|
|
50
|
-
padding-left: 1px;
|
|
51
|
-
align-self: stretch;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
`;
|
|
56
|
-
|
|
57
|
-
const drawerProps: DrawerProps = {
|
|
58
|
-
getContainer: '.nb-mobile-application',
|
|
59
|
-
width: '90%',
|
|
60
|
-
style: {
|
|
61
|
-
position: 'absolute',
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
const modalProps = {
|
|
65
|
-
...drawerProps,
|
|
66
|
-
style: {
|
|
67
|
-
maxWidth: 'calc(100% - 16px)',
|
|
68
|
-
},
|
|
69
|
-
maskStyle: {
|
|
70
|
-
position: 'absolute',
|
|
71
|
-
},
|
|
72
|
-
wrapClassName: css`
|
|
73
|
-
position: absolute !important;
|
|
74
|
-
`,
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
const useMobileSchemaUid = () => {
|
|
78
|
-
const ctx = useSystemSettings();
|
|
79
|
-
return ctx?.data?.data?.options?.mobileSchemaUid;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
const MApplication: React.FC = (props) => {
|
|
83
|
-
const mobileSchemaUid = useMobileSchemaUid();
|
|
84
|
-
const params = useParams<{ name: string }>();
|
|
85
|
-
const interfaceContext = useInterfaceContext();
|
|
86
|
-
const Provider = useMemo(() => {
|
|
87
|
-
return interfaceContext ? React.Fragment : AdminProvider;
|
|
88
|
-
}, [interfaceContext]);
|
|
89
|
-
|
|
90
|
-
useViewport();
|
|
91
|
-
|
|
92
|
-
return (
|
|
93
|
-
<Provider>
|
|
94
|
-
<MobileCore>
|
|
95
|
-
<ActionContextProvider modalProps={modalProps as ModalProps} drawerProps={drawerProps}>
|
|
96
|
-
<div
|
|
97
|
-
className={cx(
|
|
98
|
-
'nb-mobile-application',
|
|
99
|
-
commonDesignerCSS,
|
|
100
|
-
commonCSSVariables,
|
|
101
|
-
commonCSSOverride,
|
|
102
|
-
css`
|
|
103
|
-
display: flex;
|
|
104
|
-
flex-direction: column;
|
|
105
|
-
width: 100%;
|
|
106
|
-
height: 100%;
|
|
107
|
-
position: relative;
|
|
108
|
-
overflow: hidden;
|
|
109
|
-
`,
|
|
110
|
-
)}
|
|
111
|
-
>
|
|
112
|
-
{params.name && !params.name.startsWith('tab_') ? (
|
|
113
|
-
<Outlet />
|
|
114
|
-
) : (
|
|
115
|
-
<RemoteSchemaComponent key={mobileSchemaUid} uid={mobileSchemaUid}>
|
|
116
|
-
{props.children}
|
|
117
|
-
</RemoteSchemaComponent>
|
|
118
|
-
)}
|
|
119
|
-
{/* Global action will insert here */}
|
|
120
|
-
<div id="nb-position-container"></div>
|
|
121
|
-
</div>
|
|
122
|
-
</ActionContextProvider>
|
|
123
|
-
</MobileCore>
|
|
124
|
-
</Provider>
|
|
125
|
-
);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
export default MApplication;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React, { useContext } from 'react';
|
|
2
|
-
|
|
3
|
-
export const InterfaceContext = React.createContext(null);
|
|
4
|
-
|
|
5
|
-
export const InterfaceProvider = (props) => {
|
|
6
|
-
return <InterfaceContext.Provider value={{ interface: true }}>{props.children}</InterfaceContext.Provider>;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
export const useInterfaceContext = () => {
|
|
10
|
-
return useContext(InterfaceContext);
|
|
11
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { usePlugin } from '@nocobase/client';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { MobileClientPlugin } from '../index';
|
|
4
|
-
import { InterfaceProvider } from './InterfaceProvider';
|
|
5
|
-
|
|
6
|
-
export const InterfaceRouter: React.FC = React.memo(() => {
|
|
7
|
-
const plugin = usePlugin(MobileClientPlugin);
|
|
8
|
-
const MobileRouter = plugin.getMobileRouterComponent();
|
|
9
|
-
|
|
10
|
-
return (
|
|
11
|
-
<InterfaceProvider>
|
|
12
|
-
<MobileRouter />
|
|
13
|
-
</InterfaceProvider>
|
|
14
|
-
);
|
|
15
|
-
});
|
|
16
|
-
InterfaceRouter.displayName = 'InterfaceRouter';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './InterfaceRouter';
|