@nocobase/plugin-mobile-client 0.11.1-alpha.5 → 0.12.0-alpha.2

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.
Files changed (206) hide show
  1. package/client.d.ts +2 -3
  2. package/client.js +1 -1
  3. package/dist/client/index.js +2465 -0
  4. package/{lib → dist}/index.d.ts +1 -0
  5. package/dist/index.js +18 -0
  6. package/dist/locale/en-US.js +6 -0
  7. package/dist/locale/fr-FR.js +6 -0
  8. package/dist/locale/zh-CN.js +36 -0
  9. package/dist/server/index.js +11 -0
  10. package/dist/server/migrations/20230620203218-mobile-ui-schema-uid.js +33 -0
  11. package/dist/server/plugin.js +68 -0
  12. package/dist/server/routes.js +42 -0
  13. package/docs/en-US/index.md +7 -0
  14. package/docs/en-US/installation.md +13 -0
  15. package/docs/en-US/tabs.json +14 -0
  16. package/docs/en-US/usage.md +1 -0
  17. package/docs/zh-CN/index.md +7 -0
  18. package/docs/zh-CN/installation.md +13 -0
  19. package/docs/zh-CN/tabs.json +14 -0
  20. package/docs/zh-CN/usage.md +2 -0
  21. package/package.json +16 -27
  22. package/server.d.ts +2 -3
  23. package/server.js +1 -1
  24. package/lib/client/MobileClientProvider.js +0 -64
  25. package/lib/client/configuration/App.js +0 -40
  26. package/lib/client/configuration/Interface.js +0 -20
  27. package/lib/client/configuration/index.js +0 -27
  28. package/lib/client/core/bridge/index.js +0 -17
  29. package/lib/client/core/bridge/injects.js +0 -13
  30. package/lib/client/core/bridge/native-call.js +0 -24
  31. package/lib/client/core/index.js +0 -46
  32. package/lib/client/core/schema/common/index.js +0 -16
  33. package/lib/client/core/schema/common/page.js +0 -23
  34. package/lib/client/core/schema/components/container/Container.Designer.js +0 -139
  35. package/lib/client/core/schema/components/container/Container.js +0 -119
  36. package/lib/client/core/schema/components/container/index.js +0 -16
  37. package/lib/client/core/schema/components/container/style.js +0 -48
  38. package/lib/client/core/schema/components/header/Header.Designer.js +0 -72
  39. package/lib/client/core/schema/components/header/Header.js +0 -86
  40. package/lib/client/core/schema/components/header/index.js +0 -16
  41. package/lib/client/core/schema/components/index.js +0 -71
  42. package/lib/client/core/schema/components/menu/Menu.Designer.js +0 -81
  43. package/lib/client/core/schema/components/menu/Menu.Item.js +0 -106
  44. package/lib/client/core/schema/components/menu/Menu.js +0 -80
  45. package/lib/client/core/schema/components/menu/MenuBlockInitializer.js +0 -51
  46. package/lib/client/core/schema/components/menu/index.js +0 -27
  47. package/lib/client/core/schema/components/menu/schema.js +0 -25
  48. package/lib/client/core/schema/components/menu/style.js +0 -34
  49. package/lib/client/core/schema/components/page/Page.Designer.js +0 -161
  50. package/lib/client/core/schema/components/page/Page.js +0 -130
  51. package/lib/client/core/schema/components/page/index.js +0 -16
  52. package/lib/client/core/schema/components/page/style.js +0 -55
  53. package/lib/client/core/schema/components/settings/Settings.Designer.js +0 -37
  54. package/lib/client/core/schema/components/settings/Settings.js +0 -36
  55. package/lib/client/core/schema/components/settings/SettingsBlockInitializer.js +0 -51
  56. package/lib/client/core/schema/components/settings/index.js +0 -27
  57. package/lib/client/core/schema/components/tab-bar/TabBar.Item.js +0 -73
  58. package/lib/client/core/schema/components/tab-bar/TabBar.js +0 -135
  59. package/lib/client/core/schema/components/tab-bar/index.js +0 -16
  60. package/lib/client/core/schema/components/tab-bar/schema.js +0 -25
  61. package/lib/client/core/schema/helpers/index.js +0 -49
  62. package/lib/client/core/schema/hooks/index.js +0 -16
  63. package/lib/client/core/schema/hooks/useSchemaPatch.js +0 -64
  64. package/lib/client/core/schema/index.js +0 -38
  65. package/lib/client/core/schema/initializers/BlockInitializers.js +0 -79
  66. package/lib/client/core/schema/initializers/index.js +0 -16
  67. package/lib/client/core/schema/scopes/grid-card.js +0 -45
  68. package/lib/client/core/schema/scopes/index.js +0 -16
  69. package/lib/client/devices/iOS6.js +0 -32
  70. package/lib/client/devices/index.js +0 -43
  71. package/lib/client/index.js +0 -83
  72. package/lib/client/locale/index.js +0 -40
  73. package/lib/client/router/Application.js +0 -128
  74. package/lib/client/router/InterfaceProvider.js +0 -29
  75. package/lib/client/router/InterfaceRouter.js +0 -30
  76. package/lib/client/router/index.js +0 -16
  77. package/lib/index.js +0 -13
  78. package/lib/locale/en-US.js +0 -9
  79. package/lib/locale/fr-FR.js +0 -9
  80. package/lib/locale/zh-CN.js +0 -39
  81. package/lib/server/index.js +0 -13
  82. package/lib/server/migrations/20230620203218-mobile-ui-schema-uid.js +0 -59
  83. package/lib/server/plugin.js +0 -102
  84. package/lib/server/routes.js +0 -41
  85. package/src/client/MobileClientProvider.tsx +0 -41
  86. package/src/client/configuration/App.tsx +0 -23
  87. package/src/client/configuration/Interface.tsx +0 -11
  88. package/src/client/configuration/index.ts +0 -2
  89. package/src/client/core/bridge/index.ts +0 -2
  90. package/src/client/core/bridge/injects.ts +0 -15
  91. package/src/client/core/bridge/native-call.ts +0 -23
  92. package/src/client/core/index.tsx +0 -45
  93. package/src/client/core/schema/common/index.ts +0 -1
  94. package/src/client/core/schema/common/page.ts +0 -16
  95. package/src/client/core/schema/components/container/Container.Designer.tsx +0 -89
  96. package/src/client/core/schema/components/container/Container.tsx +0 -89
  97. package/src/client/core/schema/components/container/index.ts +0 -1
  98. package/src/client/core/schema/components/container/style.ts +0 -35
  99. package/src/client/core/schema/components/header/Header.Designer.tsx +0 -39
  100. package/src/client/core/schema/components/header/Header.tsx +0 -49
  101. package/src/client/core/schema/components/header/index.ts +0 -1
  102. package/src/client/core/schema/components/index.ts +0 -6
  103. package/src/client/core/schema/components/menu/Menu.Designer.tsx +0 -46
  104. package/src/client/core/schema/components/menu/Menu.Item.tsx +0 -89
  105. package/src/client/core/schema/components/menu/Menu.tsx +0 -75
  106. package/src/client/core/schema/components/menu/MenuBlockInitializer.tsx +0 -20
  107. package/src/client/core/schema/components/menu/index.ts +0 -2
  108. package/src/client/core/schema/components/menu/schema.ts +0 -19
  109. package/src/client/core/schema/components/menu/style.ts +0 -20
  110. package/src/client/core/schema/components/page/Page.Designer.tsx +0 -107
  111. package/src/client/core/schema/components/page/Page.tsx +0 -115
  112. package/src/client/core/schema/components/page/index.ts +0 -1
  113. package/src/client/core/schema/components/page/style.ts +0 -43
  114. package/src/client/core/schema/components/settings/Settings.Designer.tsx +0 -22
  115. package/src/client/core/schema/components/settings/Settings.tsx +0 -24
  116. package/src/client/core/schema/components/settings/SettingsBlockInitializer.tsx +0 -20
  117. package/src/client/core/schema/components/settings/index.ts +0 -2
  118. package/src/client/core/schema/components/tab-bar/TabBar.Item.tsx +0 -66
  119. package/src/client/core/schema/components/tab-bar/TabBar.tsx +0 -115
  120. package/src/client/core/schema/components/tab-bar/index.ts +0 -1
  121. package/src/client/core/schema/components/tab-bar/schema.ts +0 -18
  122. package/src/client/core/schema/helpers/index.ts +0 -38
  123. package/src/client/core/schema/hooks/index.ts +0 -1
  124. package/src/client/core/schema/hooks/useSchemaPatch.ts +0 -30
  125. package/src/client/core/schema/index.ts +0 -3
  126. package/src/client/core/schema/initializers/BlockInitializers.ts +0 -81
  127. package/src/client/core/schema/initializers/index.ts +0 -1
  128. package/src/client/core/schema/scopes/grid-card.ts +0 -35
  129. package/src/client/core/schema/scopes/index.ts +0 -1
  130. package/src/client/devices/iOS6.tsx +0 -24
  131. package/src/client/devices/index.tsx +0 -27
  132. package/src/client/index.tsx +0 -48
  133. package/src/client/locale/index.ts +0 -21
  134. package/src/client/router/Application.tsx +0 -128
  135. package/src/client/router/InterfaceProvider.tsx +0 -11
  136. package/src/client/router/InterfaceRouter.tsx +0 -16
  137. package/src/client/router/index.ts +0 -1
  138. package/src/index.ts +0 -1
  139. package/src/locale/en-US.ts +0 -3
  140. package/src/locale/fr-FR.ts +0 -3
  141. package/src/locale/zh-CN.ts +0 -33
  142. package/src/server/collections/.gitkeep +0 -0
  143. package/src/server/index.ts +0 -1
  144. package/src/server/migrations/20230620203218-mobile-ui-schema-uid.ts +0 -29
  145. package/src/server/plugin.ts +0 -63
  146. package/src/server/routes.ts +0 -38
  147. /package/{lib → dist}/client/MobileClientProvider.d.ts +0 -0
  148. /package/{lib → dist}/client/configuration/App.d.ts +0 -0
  149. /package/{lib → dist}/client/configuration/Interface.d.ts +0 -0
  150. /package/{lib → dist}/client/configuration/index.d.ts +0 -0
  151. /package/{lib → dist}/client/core/bridge/index.d.ts +0 -0
  152. /package/{lib → dist}/client/core/bridge/injects.d.ts +0 -0
  153. /package/{lib → dist}/client/core/bridge/native-call.d.ts +0 -0
  154. /package/{lib → dist}/client/core/index.d.ts +0 -0
  155. /package/{lib → dist}/client/core/schema/common/index.d.ts +0 -0
  156. /package/{lib → dist}/client/core/schema/common/page.d.ts +0 -0
  157. /package/{lib → dist}/client/core/schema/components/container/Container.Designer.d.ts +0 -0
  158. /package/{lib → dist}/client/core/schema/components/container/Container.d.ts +0 -0
  159. /package/{lib → dist}/client/core/schema/components/container/index.d.ts +0 -0
  160. /package/{lib → dist}/client/core/schema/components/container/style.d.ts +0 -0
  161. /package/{lib → dist}/client/core/schema/components/header/Header.Designer.d.ts +0 -0
  162. /package/{lib → dist}/client/core/schema/components/header/Header.d.ts +0 -0
  163. /package/{lib → dist}/client/core/schema/components/header/index.d.ts +0 -0
  164. /package/{lib → dist}/client/core/schema/components/index.d.ts +0 -0
  165. /package/{lib → dist}/client/core/schema/components/menu/Menu.Designer.d.ts +0 -0
  166. /package/{lib → dist}/client/core/schema/components/menu/Menu.Item.d.ts +0 -0
  167. /package/{lib → dist}/client/core/schema/components/menu/Menu.d.ts +0 -0
  168. /package/{lib → dist}/client/core/schema/components/menu/MenuBlockInitializer.d.ts +0 -0
  169. /package/{lib → dist}/client/core/schema/components/menu/index.d.ts +0 -0
  170. /package/{lib → dist}/client/core/schema/components/menu/schema.d.ts +0 -0
  171. /package/{lib → dist}/client/core/schema/components/menu/style.d.ts +0 -0
  172. /package/{lib → dist}/client/core/schema/components/page/Page.Designer.d.ts +0 -0
  173. /package/{lib → dist}/client/core/schema/components/page/Page.d.ts +0 -0
  174. /package/{lib → dist}/client/core/schema/components/page/index.d.ts +0 -0
  175. /package/{lib → dist}/client/core/schema/components/page/style.d.ts +0 -0
  176. /package/{lib → dist}/client/core/schema/components/settings/Settings.Designer.d.ts +0 -0
  177. /package/{lib → dist}/client/core/schema/components/settings/Settings.d.ts +0 -0
  178. /package/{lib → dist}/client/core/schema/components/settings/SettingsBlockInitializer.d.ts +0 -0
  179. /package/{lib → dist}/client/core/schema/components/settings/index.d.ts +0 -0
  180. /package/{lib → dist}/client/core/schema/components/tab-bar/TabBar.Item.d.ts +0 -0
  181. /package/{lib → dist}/client/core/schema/components/tab-bar/TabBar.d.ts +0 -0
  182. /package/{lib → dist}/client/core/schema/components/tab-bar/index.d.ts +0 -0
  183. /package/{lib → dist}/client/core/schema/components/tab-bar/schema.d.ts +0 -0
  184. /package/{lib → dist}/client/core/schema/helpers/index.d.ts +0 -0
  185. /package/{lib → dist}/client/core/schema/hooks/index.d.ts +0 -0
  186. /package/{lib → dist}/client/core/schema/hooks/useSchemaPatch.d.ts +0 -0
  187. /package/{lib → dist}/client/core/schema/index.d.ts +0 -0
  188. /package/{lib → dist}/client/core/schema/initializers/BlockInitializers.d.ts +0 -0
  189. /package/{lib → dist}/client/core/schema/initializers/index.d.ts +0 -0
  190. /package/{lib → dist}/client/core/schema/scopes/grid-card.d.ts +0 -0
  191. /package/{lib → dist}/client/core/schema/scopes/index.d.ts +0 -0
  192. /package/{lib → dist}/client/devices/iOS6.d.ts +0 -0
  193. /package/{lib → dist}/client/devices/index.d.ts +0 -0
  194. /package/{lib → dist}/client/index.d.ts +0 -0
  195. /package/{lib → dist}/client/locale/index.d.ts +0 -0
  196. /package/{lib → dist}/client/router/Application.d.ts +0 -0
  197. /package/{lib → dist}/client/router/InterfaceProvider.d.ts +0 -0
  198. /package/{lib → dist}/client/router/InterfaceRouter.d.ts +0 -0
  199. /package/{lib → dist}/client/router/index.d.ts +0 -0
  200. /package/{lib → dist}/locale/en-US.d.ts +0 -0
  201. /package/{lib → dist}/locale/fr-FR.d.ts +0 -0
  202. /package/{lib → dist}/locale/zh-CN.d.ts +0 -0
  203. /package/{lib → dist}/server/index.d.ts +0 -0
  204. /package/{lib → dist}/server/migrations/20230620203218-mobile-ui-schema-uid.d.ts +0 -0
  205. /package/{lib → dist}/server/plugin.d.ts +0 -0
  206. /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,3 +0,0 @@
1
- export * from './initializers';
2
- export * from './components';
3
- export * from './scopes';
@@ -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
- };
@@ -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';