@nocobase/client-v2 2.2.0-beta.13 → 2.2.0-beta.15

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 (91) hide show
  1. package/es/APIClient.d.ts +1 -3
  2. package/es/components/category-tabs/SortableCategoryTabs.d.ts +55 -0
  3. package/es/components/category-tabs/index.d.ts +9 -0
  4. package/es/components/form/ScanInput/useCodeScanner.d.ts +2 -1
  5. package/es/components/form/TypedVariableInput.d.ts +31 -5
  6. package/es/components/form/filter/CollectionFilter.d.ts +2 -0
  7. package/es/components/form/filter/CollectionFilterItem.d.ts +11 -1
  8. package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
  9. package/es/components/form/filter/index.d.ts +2 -0
  10. package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
  11. package/es/components/index.d.ts +1 -0
  12. package/es/flow/actions/index.d.ts +1 -1
  13. package/es/flow/actions/linkageRules.d.ts +2 -0
  14. package/es/flow/admin-shell/admin-layout/AdminLayoutMenuModels.d.ts +1 -0
  15. package/es/flow/components/FieldAssignExactDatePicker.d.ts +1 -0
  16. package/es/flow/components/FieldAssignValueInput.d.ts +9 -0
  17. package/es/flow/components/RunJSValueEditor.d.ts +1 -0
  18. package/es/flow/components/filter/FilterGroup.d.ts +1 -0
  19. package/es/flow/components/filter/VariableFilterItem.d.ts +6 -1
  20. package/es/flow/index.d.ts +1 -0
  21. package/es/flow/models/base/PageModel/PageModel.d.ts +12 -0
  22. package/es/flow/models/base/PageModel/PageModelTabBar.d.ts +22 -0
  23. package/es/flow/models/base/PageModel/PageTabModel.d.ts +12 -0
  24. package/es/flow-compat/fieldValidationConstants.d.ts +1 -1
  25. package/es/flow-compat/routeTypes.d.ts +1 -0
  26. package/es/index.d.ts +4 -0
  27. package/es/index.mjs +144 -109
  28. package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
  29. package/es/utils/index.d.ts +1 -0
  30. package/lib/index.js +153 -118
  31. package/lib/locale/languageCodes.js +2 -1
  32. package/package.json +7 -7
  33. package/src/APIClient.ts +1 -10
  34. package/src/Application.tsx +4 -0
  35. package/src/BaseApplication.tsx +1 -1
  36. package/src/__tests__/app.test.tsx +18 -0
  37. package/src/__tests__/browserChecker.test.ts +61 -0
  38. package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
  39. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +28 -0
  40. package/src/collection-manager/field-validation.ts +1 -1
  41. package/src/components/README.md +7 -1
  42. package/src/components/README.zh-CN.md +6 -1
  43. package/src/components/category-tabs/SortableCategoryTabs.tsx +210 -0
  44. package/src/components/category-tabs/index.ts +10 -0
  45. package/src/components/form/JsonTextArea.tsx +4 -0
  46. package/src/components/form/ScanInput/CodeScanner.tsx +23 -6
  47. package/src/components/form/ScanInput/__tests__/useCodeScanner.test.tsx +35 -1
  48. package/src/components/form/ScanInput/useCodeScanner.ts +16 -3
  49. package/src/components/form/TypedVariableInput.tsx +452 -101
  50. package/src/components/form/__tests__/TypedVariableInput.test.tsx +364 -12
  51. package/src/components/form/filter/CollectionFilter.tsx +4 -0
  52. package/src/components/form/filter/CollectionFilterItem.tsx +32 -7
  53. package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
  54. package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +38 -0
  55. package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
  56. package/src/components/form/filter/index.ts +2 -0
  57. package/src/components/form/filter/useFilterActionProps.ts +37 -6
  58. package/src/components/index.ts +1 -0
  59. package/src/flow/actions/__tests__/linkageRules.tab.test.ts +171 -0
  60. package/src/flow/actions/index.ts +2 -0
  61. package/src/flow/actions/linkageRules.tsx +86 -11
  62. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +0 -1
  63. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutComponent.test.tsx +253 -6
  64. package/src/flow/components/FieldAssignExactDatePicker.tsx +25 -11
  65. package/src/flow/components/FieldAssignValueInput.tsx +76 -9
  66. package/src/flow/components/RunJSValueEditor.tsx +9 -1
  67. package/src/flow/components/__tests__/FieldAssignValueInput.context.test.tsx +84 -2
  68. package/src/flow/components/filter/FilterGroup.tsx +33 -5
  69. package/src/flow/components/filter/VariableFilterItem.tsx +158 -10
  70. package/src/flow/components/filter/__tests__/FilterGroup.test.tsx +45 -0
  71. package/src/flow/components/filter/__tests__/VariableFilterItem.leftMetaTree.test.tsx +9 -0
  72. package/src/flow/components/filter/__tests__/VariableFilterItem.test.tsx +70 -1
  73. package/src/flow/index.ts +1 -0
  74. package/src/flow/models/base/PageModel/PageModel.tsx +387 -53
  75. package/src/flow/models/base/PageModel/PageModelTabBar.tsx +114 -0
  76. package/src/flow/models/base/PageModel/PageTabModel.tsx +184 -3
  77. package/src/flow/models/base/PageModel/__tests__/PageModel.test.ts +790 -10
  78. package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.module-isolation.test.tsx +130 -0
  79. package/src/flow/models/base/PageModel/__tests__/PageModelTabBar.test.tsx +118 -0
  80. package/src/flow/models/base/PageModel/__tests__/PageTabModel.test.ts +572 -1
  81. package/src/flow/models/blocks/table/TableBlockModel.tsx +1 -1
  82. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +1 -1
  83. package/src/flow/models/fields/VariableFieldFormModel.tsx +3 -3
  84. package/src/flow/models/fields/__tests__/VariableFieldFormModel.test.tsx +51 -0
  85. package/src/flow-compat/fieldValidationConstants.ts +1 -1
  86. package/src/flow-compat/routeTypes.ts +1 -0
  87. package/src/index.ts +4 -0
  88. package/src/locale/languageCodes.ts +2 -1
  89. package/src/nocobase-buildin-plugin/index.tsx +12 -0
  90. package/src/utils/getRouteRuntimeVersion.ts +185 -0
  91. package/src/utils/index.tsx +1 -0
@@ -231,7 +231,7 @@ export const FIELDS_VALIDATION_OPTIONS = {
231
231
  },
232
232
  {
233
233
  key: 'multiple',
234
- label: 'Multiple',
234
+ label: 'Multiple of',
235
235
  hasValue: true,
236
236
  params: [{ key: 'base', label: 'Base', componentType: 'inputNumber', required: true }],
237
237
  },
@@ -18,6 +18,7 @@ export enum NocoBaseDesktopRouteType {
18
18
 
19
19
  export interface NocoBaseDesktopRouteOptions {
20
20
  hasPersistedMenuInstanceFlow?: boolean;
21
+ hasPersistedPageTabFlowModel?: boolean;
21
22
  [key: string]: any;
22
23
  }
23
24
 
package/src/index.ts CHANGED
@@ -30,6 +30,8 @@ export * from './layout-manager';
30
30
  export * from './hooks';
31
31
  export { default as languageCodes } from './locale/languageCodes';
32
32
  export * from './nocobase-buildin-plugin';
33
+ export { getRouteRuntimeVersion } from './utils/getRouteRuntimeVersion';
34
+ export type { RouteRuntimeVersion } from './utils/getRouteRuntimeVersion';
33
35
  export * from './collection-field-interface/CollectionFieldInterface';
34
36
  export * from './collection-field-interface/CollectionFieldInterfaceManager';
35
37
  export * from './collection-manager/field-configure';
@@ -40,6 +42,8 @@ export * from './collection-manager/template-fields';
40
42
  export * from './data-source';
41
43
  export * from './entry-actions';
42
44
  export * from './flow';
45
+ export { CodeEditorExtension } from './flow/components/code-editor/extension';
46
+ export type { CodeEditorExtra, CodeEditorExtraRegistry, EditorRef } from './flow/components/code-editor/types';
43
47
  export {
44
48
  DEFAULT_DATA_SOURCE_KEY,
45
49
  IconPicker,
@@ -73,7 +73,8 @@ export const languageCodes: Record<string, LocaleOptions> = {
73
73
  'tk-TK': { label: 'Turkmen' },
74
74
  'tr-TR': { label: 'Türkçe' },
75
75
  'uk-UA': { label: 'Українська' },
76
- 'ur-PK': { label: 'Oʻzbekcha' },
76
+ 'ur-PK': { label: 'اردو' },
77
+ 'uz-UZ': { label: 'Oʻzbekcha' },
77
78
  'vi-VN': { label: 'Tiếng Việt' },
78
79
  'zh-CN': { label: '简体中文' },
79
80
  'zh-HK': { label: '繁體中文(香港)' },
@@ -240,6 +240,16 @@ const CurrentUserProvider: FC = ({ children }) => {
240
240
  return;
241
241
  }
242
242
 
243
+ try {
244
+ await app.apiClient.auth.syncCookies();
245
+ } catch {
246
+ // Cookie bootstrap is best-effort; auth:check remains the source of truth for the current page load.
247
+ }
248
+
249
+ if (!mounted) {
250
+ return;
251
+ }
252
+
243
253
  const userMeta = createCollectionContextMeta(
244
254
  () => app.flowEngine.context.dataSourceManager?.getDataSource('main')?.getCollection('users') || null,
245
255
  app.flowEngine.translate('Current user'),
@@ -298,6 +308,8 @@ const CurrentUserProvider: FC = ({ children }) => {
298
308
  return <CurrentUserContext.Provider value={contextValue}>{children}</CurrentUserContext.Provider>;
299
309
  };
300
310
 
311
+ CurrentUserProvider.displayName = 'CurrentUserProvider';
312
+
301
313
  const RootRedirect: FC = () => {
302
314
  const app = useApp<Application>();
303
315
  const hasToken = !!app?.apiClient?.auth?.token;
@@ -0,0 +1,185 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ export type RouteRuntimeVersion = 'legacy' | 'modern';
11
+
12
+ declare global {
13
+ interface Window {
14
+ __nocobase_modern_client_prefix__?: string;
15
+ __nocobase_public_path__?: string;
16
+ }
17
+ }
18
+
19
+ function hasModernClientPrefix() {
20
+ return (
21
+ typeof window !== 'undefined' &&
22
+ typeof window.__nocobase_modern_client_prefix__ === 'string' &&
23
+ window.__nocobase_modern_client_prefix__.trim().length > 0
24
+ );
25
+ }
26
+
27
+ function hasConfiguredPublicPath() {
28
+ return typeof window !== 'undefined' && typeof window.__nocobase_public_path__ === 'string';
29
+ }
30
+
31
+ /** Normalize any app/public-path-like input into a root-relative pathname:
32
+ *
33
+ * - `nocobase//v/` -> `/nocobase/v`
34
+ * - `/` -> `/`
35
+ */
36
+ function normalizeRootRelativePath(value = '/') {
37
+ const normalized = `/${String(value || '/').trim() || '/'}`.replace(/\/{2,}/g, '/');
38
+ if (normalized !== '/' && normalized.endsWith('/')) {
39
+ return normalized.replace(/\/+$/g, '');
40
+ }
41
+ return normalized;
42
+ }
43
+
44
+ /** Public-path form always ends with `/`, so it can be compared as a base path:
45
+ *
46
+ * - `/nocobase/v` -> `/nocobase/v/`
47
+ * - `/` -> `/`
48
+ */
49
+ function normalizePublicPath(value = '/') {
50
+ const normalized = normalizeRootRelativePath(value);
51
+ return normalized.endsWith('/') ? normalized : `${normalized}/`;
52
+ }
53
+
54
+ /** Check whether a concrete pathname is rendered under a runtime base path:
55
+ *
56
+ * - pathname `/nocobase/v/admin/workflow/workflows/1`
57
+ * basePath `/nocobase/v/`
58
+ * => true
59
+ *
60
+ * - pathname `/nocobase/admin/settings/workflow/workflows/1`
61
+ * basePath `/nocobase/v/`
62
+ * => false
63
+ */
64
+ function isPathnameInsideBasePath(pathname: string, basePath: string) {
65
+ const normalizedPathname = normalizeRootRelativePath(pathname);
66
+ const normalizedBasePath = normalizePublicPath(basePath);
67
+ const trimmedBasePath = normalizedBasePath.replace(/\/+$/g, '') || '/';
68
+
69
+ if (trimmedBasePath === '/') {
70
+ return true;
71
+ }
72
+
73
+ return normalizedPathname === trimmedBasePath || normalizedPathname.startsWith(`${trimmedBasePath}/`);
74
+ }
75
+
76
+ function getNormalizedModernClientPrefix() {
77
+ if (typeof window === 'undefined') {
78
+ return '';
79
+ }
80
+
81
+ const prefix = window.__nocobase_modern_client_prefix__?.trim();
82
+ return prefix ? prefix.replace(/^\/+|\/+$/g, '') : '';
83
+ }
84
+
85
+ /** Derive the actual modern-client base path from injected globals.
86
+ *
87
+ * Only returns a value when `__nocobase_public_path__` itself already points to
88
+ * the modern client shell:
89
+ *
90
+ * - legacy shell:
91
+ * `__nocobase_public_path__ = "/nocobase/"`
92
+ * `__nocobase_modern_client_prefix__ = "v"`
93
+ * => `""`
94
+ *
95
+ * - modern shell:
96
+ * `__nocobase_public_path__ = "/nocobase/v/"`
97
+ * `__nocobase_modern_client_prefix__ = "v"`
98
+ * => `"/nocobase/v/"`
99
+ */
100
+ function getModernClientBasePath() {
101
+ const normalizedPrefix = getNormalizedModernClientPrefix();
102
+ if (!normalizedPrefix) {
103
+ return '';
104
+ }
105
+
106
+ if (typeof window === 'undefined') {
107
+ return '';
108
+ }
109
+
110
+ const publicPath = window.__nocobase_public_path__?.trim();
111
+ if (publicPath && normalizePublicPath(publicPath).endsWith(`/${normalizedPrefix}/`)) {
112
+ return normalizePublicPath(publicPath);
113
+ }
114
+
115
+ return '';
116
+ }
117
+
118
+ /** True only when the current page is actually running under the resolved
119
+ * modern-client base path.
120
+ *
121
+ * Example:
122
+ * - pathname `/v/admin/workflow/workflows/1`, modern base `/v/` => true
123
+ * - pathname `/admin/settings/workflow/workflows/1`, modern base `/v/` => false
124
+ */
125
+ function isPathnameInModernClientRuntime() {
126
+ if (typeof window === 'undefined') {
127
+ return false;
128
+ }
129
+
130
+ const pathname = window.location?.pathname ?? '';
131
+ const modernClientBasePath = getModernClientBasePath();
132
+ if (!pathname || !modernClientBasePath) {
133
+ return false;
134
+ }
135
+
136
+ return isPathnameInsideBasePath(pathname, modernClientBasePath);
137
+ }
138
+
139
+ /** Fallback for incomplete/mocked environments where public path was not
140
+ * injected but the modern prefix still exists.
141
+ *
142
+ * Example:
143
+ * - pathname `/v/admin/workflow/workflows/1`
144
+ * `__nocobase_modern_client_prefix__ = "v"`
145
+ * `__nocobase_public_path__` missing
146
+ * => true
147
+ */
148
+ function isPathnameInModernClientRuntimeByPrefix() {
149
+ if (typeof window === 'undefined') {
150
+ return false;
151
+ }
152
+
153
+ const normalizedPrefix = getNormalizedModernClientPrefix();
154
+ const pathname = window.location?.pathname ?? '';
155
+ if (!normalizedPrefix || !pathname) {
156
+ return false;
157
+ }
158
+
159
+ return isPathnameInsideBasePath(pathname, normalizePublicPath(normalizedPrefix));
160
+ }
161
+
162
+ /** Resolve which client shell currently owns the route.
163
+ *
164
+ * - returns `modern` when the current page is actually mounted under the modern
165
+ * client base path (`/v/`, `/nocobase/v/`, ...)
166
+ * - returns `legacy` when the route is still under the legacy shell, even if the
167
+ * modern prefix global has been injected into the page
168
+ */
169
+ export function getRouteRuntimeVersion(): RouteRuntimeVersion {
170
+ if (typeof window === 'undefined') {
171
+ return hasModernClientPrefix() ? 'modern' : 'legacy';
172
+ }
173
+
174
+ if (hasConfiguredPublicPath()) {
175
+ return isPathnameInModernClientRuntime() ? 'modern' : 'legacy';
176
+ }
177
+
178
+ // Defensive fallback for incomplete test/mocked environments where public
179
+ // path was not injected but the modern prefix still exists.
180
+ if (isPathnameInModernClientRuntimeByPrefix()) {
181
+ return 'modern';
182
+ }
183
+
184
+ return 'legacy';
185
+ }
@@ -11,6 +11,7 @@ import React, { ComponentType, FC } from 'react';
11
11
  import { BlankComponent } from '../components';
12
12
 
13
13
  export * from './appVersionHTML';
14
+ export * from './getRouteRuntimeVersion';
14
15
 
15
16
  export function normalizeContainer(container: Element | ShadowRoot | string): Element | null {
16
17
  if (!container) {