@nocobase/client-v2 2.2.0-beta.7 → 2.2.0-beta.9

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 (113) hide show
  1. package/es/BaseApplication.d.ts +2 -0
  2. package/es/RouteRepository.d.ts +8 -0
  3. package/es/RouterManager.d.ts +15 -0
  4. package/es/authRedirect.d.ts +1 -0
  5. package/es/entry-actions/EntryActionManager.d.ts +24 -0
  6. package/es/entry-actions/index.d.ts +9 -0
  7. package/es/flow/actions/afterSuccess.d.ts +8 -1
  8. package/es/flow/actions/index.d.ts +1 -1
  9. package/es/flow/admin-shell/BaseLayoutModel.d.ts +6 -0
  10. package/es/flow/admin-shell/BaseLayoutRouteCoordinator.d.ts +7 -0
  11. package/es/flow/admin-shell/admin-layout/AdminLayoutSlotModels.d.ts +1 -0
  12. package/es/flow/admin-shell/admin-layout/AppListRender.d.ts +2 -1
  13. package/es/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.d.ts +24 -0
  14. package/es/flow/admin-shell/admin-layout/index.d.ts +1 -0
  15. package/es/flow/admin-shell/admin-layout/useApplications.d.ts +7 -2
  16. package/es/flow/models/base/ActionModelCore.d.ts +2 -0
  17. package/es/flow/models/blocks/form/submitHandler.d.ts +1 -1
  18. package/es/flow/models/blocks/form/value-runtime/runtime.d.ts +9 -0
  19. package/es/flow/models/blocks/js-block/JSBlock.d.ts +1 -0
  20. package/es/flow/models/blocks/table/TableActionsColumnModel.d.ts +1 -0
  21. package/es/flow/models/blocks/table/TableBlockModel.d.ts +1 -0
  22. package/es/flow/models/blocks/table/dragSort/dragSortHooks.d.ts +1 -1
  23. package/es/flow/models/blocks/table/dragSort/dragSortSettings.d.ts +2 -1
  24. package/es/flow/models/blocks/table/dragSort/dragSortUtils.d.ts +6 -4
  25. package/es/flow/resolveViewParamsToViewList.d.ts +1 -1
  26. package/es/flow/routeTransientInputArgs.d.ts +14 -0
  27. package/es/index.d.ts +2 -0
  28. package/es/index.mjs +243 -141
  29. package/es/utils/markdownSanitize.d.ts +11 -0
  30. package/lib/index.js +232 -130
  31. package/package.json +7 -7
  32. package/src/BaseApplication.tsx +2 -0
  33. package/src/RouteRepository.ts +25 -0
  34. package/src/RouterManager.tsx +142 -1
  35. package/src/__tests__/RouteRepository.test.ts +23 -0
  36. package/src/__tests__/RouterManager.test.ts +125 -0
  37. package/src/__tests__/authRedirect.test.ts +17 -0
  38. package/src/authRedirect.ts +38 -0
  39. package/src/collection-manager/field-configure.ts +1 -1
  40. package/src/collection-manager/interfaces/id.ts +1 -1
  41. package/src/collection-manager/interfaces/m2m.tsx +2 -2
  42. package/src/collection-manager/interfaces/m2o.tsx +2 -2
  43. package/src/collection-manager/interfaces/nanoid.ts +1 -1
  44. package/src/collection-manager/interfaces/o2m.tsx +2 -2
  45. package/src/collection-manager/interfaces/obo.tsx +2 -2
  46. package/src/collection-manager/interfaces/oho.tsx +2 -2
  47. package/src/collection-manager/interfaces/properties/index.ts +2 -2
  48. package/src/collection-manager/interfaces/uuid.ts +1 -1
  49. package/src/entry-actions/EntryActionManager.ts +76 -0
  50. package/src/entry-actions/index.ts +10 -0
  51. package/src/flow/FlowPage.tsx +29 -2
  52. package/src/flow/__tests__/FlowPage.test.tsx +152 -25
  53. package/src/flow/__tests__/FlowRoute.test.tsx +547 -2
  54. package/src/flow/__tests__/getKey.test.ts +7 -0
  55. package/src/flow/__tests__/resolveViewParamsToViewList.test.ts +34 -0
  56. package/src/flow/actions/__tests__/afterSuccess.test.ts +73 -0
  57. package/src/flow/actions/__tests__/dataScopeFilter.test.ts +62 -0
  58. package/src/flow/actions/__tests__/openView.defineProps.route.test.tsx +164 -0
  59. package/src/flow/actions/afterSuccess.tsx +142 -3
  60. package/src/flow/actions/dataScopeFilter.ts +10 -1
  61. package/src/flow/actions/dateTimeFormat.tsx +2 -2
  62. package/src/flow/actions/index.ts +1 -1
  63. package/src/flow/actions/openView.tsx +59 -5
  64. package/src/flow/admin-shell/BaseLayoutModel.tsx +149 -3
  65. package/src/flow/admin-shell/BaseLayoutRouteCoordinator.ts +187 -42
  66. package/src/flow/admin-shell/__tests__/AdminLayoutRouteCoordinator.test.ts +1020 -110
  67. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +42 -4
  68. package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +177 -1
  69. package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +20 -0
  70. package/src/flow/admin-shell/admin-layout/AdminLayoutSlotModels.tsx +5 -4
  71. package/src/flow/admin-shell/admin-layout/AppListRender.tsx +13 -2
  72. package/src/flow/admin-shell/admin-layout/AppSwitcherActionPanelModel.tsx +289 -0
  73. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +518 -2
  74. package/src/flow/admin-shell/admin-layout/__tests__/TopbarActionsBar.test.tsx +48 -0
  75. package/src/flow/admin-shell/admin-layout/index.ts +1 -0
  76. package/src/flow/admin-shell/admin-layout/useApplications.tsx +81 -12
  77. package/src/flow/common/Markdown/Display.tsx +14 -3
  78. package/src/flow/common/Markdown/Edit.tsx +19 -7
  79. package/src/flow/components/FlowRoute.tsx +128 -16
  80. package/src/flow/getViewDiffAndUpdateHidden.tsx +1 -0
  81. package/src/flow/internal/components/Markdown/util.ts +2 -1
  82. package/src/flow/models/base/ActionModel.tsx +10 -8
  83. package/src/flow/models/base/ActionModelCore.tsx +11 -4
  84. package/src/flow/models/base/__tests__/ActionModelCore.render.test.tsx +37 -0
  85. package/src/flow/models/blocks/filter-form/fields/FilterFormCustomFieldModel.tsx +1 -1
  86. package/src/flow/models/blocks/form/FormActionModel.tsx +1 -1
  87. package/src/flow/models/blocks/form/__tests__/submitHandler.test.ts +54 -1
  88. package/src/flow/models/blocks/form/submitHandler.ts +17 -3
  89. package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +87 -0
  90. package/src/flow/models/blocks/form/value-runtime/runtime.ts +91 -0
  91. package/src/flow/models/blocks/js-block/JSBlock.tsx +223 -2
  92. package/src/flow/models/blocks/js-block/__tests__/JSBlockModel.test.tsx +150 -0
  93. package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +35 -12
  94. package/src/flow/models/blocks/table/TableBlockModel.tsx +25 -14
  95. package/src/flow/models/blocks/table/TableColumnModel.tsx +6 -2
  96. package/src/flow/models/blocks/table/__tests__/TableActionsColumnModel.test.tsx +57 -1
  97. package/src/flow/models/blocks/table/__tests__/TableBlockModel.dragSort.test.ts +127 -0
  98. package/src/flow/models/blocks/table/__tests__/TableBlockModel.rowSelection.test.tsx +1 -0
  99. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +51 -0
  100. package/src/flow/models/blocks/table/dragSort/dragSortHooks.tsx +28 -17
  101. package/src/flow/models/blocks/table/dragSort/dragSortSettings.ts +13 -6
  102. package/src/flow/models/blocks/table/dragSort/dragSortUtils.ts +15 -2
  103. package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +45 -13
  104. package/src/flow/models/fields/TextareaFieldModel.tsx +42 -19
  105. package/src/flow/models/fields/__tests__/TextareaFieldModel.test.tsx +32 -1
  106. package/src/flow/models/topbar/TopbarActionModel.tsx +78 -3
  107. package/src/flow/resolveViewParamsToViewList.tsx +11 -3
  108. package/src/flow/routeTransientInputArgs.ts +27 -0
  109. package/src/flow/utils/__tests__/dateTimeFormat.test.ts +42 -0
  110. package/src/index.ts +2 -0
  111. package/src/nocobase-buildin-plugin/index.tsx +7 -1
  112. package/src/settings-center/SystemSettingsPage.tsx +1 -1
  113. package/src/utils/markdownSanitize.ts +88 -0
@@ -19,16 +19,23 @@ export function useDragSortBodyWrapper(
19
19
  model: TableBlockModel,
20
20
  dataSourceRef: React.MutableRefObject<any>,
21
21
  getRowKeyFunc: (record: any) => string | number,
22
+ dragSortFieldName?: string,
22
23
  ) {
24
+ const expandedRowKeys = model.props.expandedRowKeys;
25
+ const defaultExpandAllRows = model.props.defaultExpandAllRows;
26
+ const resource = model.resource;
27
+ const filterTargetKey = model.collection.filterTargetKey;
28
+ const message = (model as { ctx?: { message?: { error?: (content: string) => void } } }).ctx?.message;
29
+
23
30
  return useMemo(() => {
24
- if (!model.props.dragSort) {
31
+ if (!dragSortFieldName) {
25
32
  return (props) => <tbody {...props} />;
26
33
  }
27
34
 
28
35
  const flattenTreeData = (data: any[]) => {
29
36
  const result: any[] = [];
30
- const expandedKeys = new Set((model.props.expandedRowKeys || []).map((key) => (key == null ? key : String(key))));
31
- const includeAll = !!model.props.defaultExpandAllRows;
37
+ const expandedKeys = new Set((expandedRowKeys || []).map((key) => (key == null ? key : String(key))));
38
+ const includeAll = !!defaultExpandAllRows;
32
39
 
33
40
  const walk = (nodes: any[]) => {
34
41
  if (!nodes?.length) return;
@@ -73,22 +80,22 @@ export function useDragSortBodyWrapper(
73
80
  }
74
81
 
75
82
  if (from && to) {
76
- model.resource
83
+ resource
77
84
  .runAction('move', {
78
85
  method: 'post',
79
86
  params: {
80
- sourceId: getRowKey(from, model.collection.filterTargetKey),
81
- targetId: getRowKey(to, model.collection.filterTargetKey),
82
- sortField: model.props.dragSort ? model.props.dragSortBy : undefined,
87
+ sourceId: getRowKey(from, filterTargetKey),
88
+ targetId: getRowKey(to, filterTargetKey),
89
+ sortField: dragSortFieldName,
83
90
  },
84
91
  })
85
92
  .then(() => {
86
- model.resource.refresh();
93
+ resource.refresh();
87
94
  })
88
95
  .catch((error) => {
89
96
  console.error('Move failed:', error);
90
97
  // Show a user-facing error message if the message system is available
91
- (model as any)?.ctx?.message?.error?.(error?.message || 'Move failed');
98
+ message?.error?.(error?.message || 'Move failed');
92
99
  });
93
100
  }
94
101
  };
@@ -104,13 +111,14 @@ export function useDragSortBodyWrapper(
104
111
  );
105
112
  };
106
113
  }, [
107
- model.props.dragSort,
108
- model.props.dragSortBy,
109
- model.props.expandedRowKeys,
110
- model.props.defaultExpandAllRows,
111
- model.resource,
112
- model.collection.filterTargetKey,
114
+ dataSourceRef,
115
+ defaultExpandAllRows,
116
+ dragSortFieldName,
117
+ expandedRowKeys,
118
+ filterTargetKey,
113
119
  getRowKeyFunc,
120
+ message,
121
+ resource,
114
122
  ]);
115
123
  }
116
124
 
@@ -124,7 +132,10 @@ export function useDragSortRowComponent(dragSort: boolean) {
124
132
  }
125
133
 
126
134
  export function initDragSortParams(model: TableBlockModel) {
127
- if (model.props.dragSort && model.props.dragSortBy) {
128
- model.resource.setSort([model.props.dragSortBy]);
135
+ const dragSortFieldName = model.getDragSortFieldName();
136
+ if (dragSortFieldName) {
137
+ model.resource.setSort([dragSortFieldName]);
138
+ } else if (model.props.dragSort && model.props.dragSortBy) {
139
+ model.resource.setSort(Array.isArray(model.props.globalSort) ? model.props.globalSort : []);
129
140
  }
130
141
  }
@@ -9,7 +9,11 @@
9
9
 
10
10
  import { tExpr } from '@nocobase/flow-engine';
11
11
  import type { TableBlockModel } from '../TableBlockModel';
12
- import { convertFieldsToOptions, getSortFields } from './dragSortUtils';
12
+ import { convertFieldsToOptions, getSortFields, hasSortField } from './dragSortUtils';
13
+
14
+ function getFallbackSort(model: TableBlockModel): string[] {
15
+ return Array.isArray(model.props.globalSort) ? model.props.globalSort : [];
16
+ }
13
17
 
14
18
  export const dragSortSettings = {
15
19
  title: tExpr('Enable drag and drop sorting'),
@@ -17,9 +21,12 @@ export const dragSortSettings = {
17
21
  defaultParams: {
18
22
  dragSort: false,
19
23
  },
20
- async handler(ctx, params) {
24
+ handler(ctx, params) {
21
25
  const model = ctx.model as TableBlockModel;
22
26
  model.setProps('dragSort', params.dragSort);
27
+ if (!params.dragSort) {
28
+ model.resource.setSort(getFallbackSort(model));
29
+ }
23
30
 
24
31
  // Note: automatic configuration of the drag sort field has been removed;
25
32
  // users now configure `dragSortBy` explicitly via `dragSortBySettings`.
@@ -45,6 +52,7 @@ export const dragSortBySettings = {
45
52
  key: 'dragSortBy',
46
53
  props: {
47
54
  options,
55
+ allowClear: true,
48
56
  placeholder: ctx.t('Select field'),
49
57
  },
50
58
  };
@@ -54,9 +62,8 @@ export const dragSortBySettings = {
54
62
  },
55
63
  handler(ctx, params) {
56
64
  const model = ctx.model as TableBlockModel;
57
- model.setProps('dragSortBy', params.dragSortBy);
58
- if (params.dragSortBy) {
59
- model.resource.setSort([params.dragSortBy]);
60
- }
65
+ const dragSortBy = hasSortField(model.collection, params.dragSortBy) ? params.dragSortBy : null;
66
+ model.setProps('dragSortBy', dragSortBy);
67
+ model.resource.setSort(dragSortBy ? [dragSortBy] : getFallbackSort(model));
61
68
  },
62
69
  };
@@ -7,7 +7,7 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import type { Collection } from '@nocobase/flow-engine';
10
+ import type { Collection, CollectionField } from '@nocobase/flow-engine';
11
11
 
12
12
  /**
13
13
  * 从 collection 中获取所有 sort 类型的字段
@@ -24,6 +24,19 @@ export function getSortFields(collection: Collection | undefined) {
24
24
  });
25
25
  }
26
26
 
27
+ export function getSortField(
28
+ collection: Collection | undefined,
29
+ fieldName?: string | null,
30
+ ): CollectionField | undefined {
31
+ if (!collection || !fieldName) return undefined;
32
+
33
+ return getSortFields(collection).find((field) => field.name === fieldName);
34
+ }
35
+
36
+ export function hasSortField(collection: Collection | undefined, fieldName?: string | null): boolean {
37
+ return !!getSortField(collection, fieldName);
38
+ }
39
+
27
40
  /**
28
41
  * 获取 collection 中第一个可用的 sort 字段
29
42
  * @param collection - 集合对象
@@ -39,7 +52,7 @@ export function getFirstSortField(collection: Collection | undefined) {
39
52
  * @param fields - 字段数组
40
53
  * @returns 选项数组
41
54
  */
42
- export function convertFieldsToOptions(fields: any[]) {
55
+ export function convertFieldsToOptions(fields: CollectionField[]) {
43
56
  return fields.map((field) => ({
44
57
  label: field?.uiSchema?.title || field?.name,
45
58
  value: field?.name,
@@ -198,6 +198,48 @@ const useFieldPermissionMessage = (model, allowEdit) => {
198
198
  return messageValue;
199
199
  };
200
200
 
201
+ const recordSelectClassName = css`
202
+ min-width: 0;
203
+
204
+ .ant-select-selector {
205
+ min-width: 0;
206
+ overflow: hidden;
207
+ }
208
+
209
+ .ant-select-selection-search,
210
+ .ant-select-selection-item,
211
+ .ant-select-selection-placeholder,
212
+ .ant-select-selection-overflow,
213
+ .ant-select-selection-overflow-item {
214
+ min-width: 0;
215
+ max-width: 100%;
216
+ }
217
+
218
+ .ant-select-selection-item,
219
+ .ant-select-selection-item-content {
220
+ overflow: hidden;
221
+ text-overflow: ellipsis;
222
+ white-space: nowrap;
223
+ }
224
+ `;
225
+
226
+ const recordSelectLabelClassName = css`
227
+ display: block;
228
+ min-width: 0;
229
+ max-width: 100%;
230
+ overflow: hidden;
231
+ text-overflow: ellipsis;
232
+ white-space: nowrap;
233
+
234
+ * {
235
+ min-width: 0;
236
+ max-width: 100%;
237
+ overflow: hidden;
238
+ text-overflow: ellipsis;
239
+ white-space: nowrap !important;
240
+ }
241
+ `;
242
+
201
243
  const LazySelect = (props: Readonly<LazySelectProps>) => {
202
244
  const {
203
245
  fieldNames,
@@ -210,6 +252,7 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
210
252
  onChange,
211
253
  allowCreate = true,
212
254
  allowEdit = true,
255
+ className,
213
256
  ...others
214
257
  } = props;
215
258
  const model: any = useFlowModel();
@@ -317,6 +360,7 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
317
360
  <Select
318
361
  style={{ width: '100%' }}
319
362
  {...others}
363
+ className={[recordSelectClassName, className].filter(Boolean).join(' ')}
320
364
  allowClear
321
365
  showSearch
322
366
  maxTagCount="responsive"
@@ -409,19 +453,7 @@ const LazySelect = (props: Readonly<LazySelectProps>) => {
409
453
  }}
410
454
  popupMatchSelectWidth
411
455
  labelRender={(data) => {
412
- return (
413
- <div
414
- className={css`
415
- div {
416
- white-space: nowrap !important;
417
- overflow: hidden;
418
- text-overflow: ellipsis;
419
- }
420
- `}
421
- >
422
- {data.label}
423
- </div>
424
- );
456
+ return <div className={recordSelectLabelClassName}>{data.label}</div>;
425
457
  }}
426
458
  dropdownRender={(menu) => {
427
459
  const isFullMatch = realOptions.some((v) => v[normalizedFieldNames.label] === others.searchText);
@@ -9,56 +9,79 @@
9
9
 
10
10
  import { Input } from 'antd';
11
11
  import type { TextAreaProps } from 'antd/es/input';
12
- import type { TextAreaRef } from 'antd/es/input/TextArea';
13
- import React, { useEffect, useRef } from 'react';
12
+ import React, { useEffect, useRef, useState } from 'react';
14
13
  import { largeField, EditableItemModel } from '@nocobase/flow-engine';
15
14
  import { FieldModel } from '../base/FieldModel';
16
15
 
17
16
  function IMESafeTextArea(props: TextAreaProps) {
18
17
  const { value, onChange, onCompositionStart, onCompositionEnd, ...rest } = props;
19
- const textAreaRef = useRef<TextAreaRef>(null);
20
- const previousValueRef = useRef(value);
21
- const defaultValue = typeof value === 'bigint' ? String(value) : value;
18
+ const [textAreaValue, setTextAreaValue] = useState<TextAreaProps['value']>(() => normalizeTextAreaValue(value));
19
+ const textAreaValueRef = useRef<TextAreaProps['value']>(textAreaValue);
20
+ const pendingLocalValuesRef = useRef<TextAreaProps['value'][]>([]);
22
21
 
23
22
  useEffect(() => {
24
- if (Object.is(previousValueRef.current, value)) {
25
- return;
26
- }
27
- previousValueRef.current = value;
23
+ const nextValue = normalizeTextAreaValue(value);
24
+ const pendingValues = pendingLocalValuesRef.current;
25
+ const pendingIndex = pendingValues.findIndex((item) => Object.is(item, nextValue));
28
26
 
29
- const textArea = textAreaRef.current?.resizableTextArea?.textArea;
30
- if (textArea) {
31
- const nextValue = value == null ? '' : String(value);
32
- if (textArea.value !== nextValue) {
33
- textArea.value = nextValue;
27
+ if (pendingIndex >= 0) {
28
+ pendingValues.splice(0, pendingIndex + 1);
29
+ if (!Object.is(textAreaValueRef.current, nextValue)) {
30
+ return;
34
31
  }
35
32
  }
33
+
34
+ pendingValues.length = 0;
35
+ if (Object.is(textAreaValueRef.current, nextValue)) {
36
+ return;
37
+ }
38
+
39
+ textAreaValueRef.current = nextValue;
40
+ setTextAreaValue(nextValue);
36
41
  }, [value]);
37
42
 
38
43
  const getEventValue = (event: React.ChangeEvent<HTMLTextAreaElement> | React.CompositionEvent<HTMLTextAreaElement>) =>
39
44
  event.currentTarget.value;
40
45
 
46
+ const recordLocalValue = (
47
+ event: React.ChangeEvent<HTMLTextAreaElement> | React.CompositionEvent<HTMLTextAreaElement>,
48
+ ) => {
49
+ const nextValue = getEventValue(event);
50
+ const pendingValues = pendingLocalValuesRef.current;
51
+ pendingValues.push(nextValue);
52
+ if (pendingValues.length > 20) {
53
+ pendingValues.shift();
54
+ }
55
+ textAreaValueRef.current = nextValue;
56
+ setTextAreaValue(nextValue);
57
+ };
58
+
41
59
  return (
42
60
  <Input.TextArea
43
61
  {...rest}
44
- ref={textAreaRef}
45
- defaultValue={defaultValue}
62
+ value={textAreaValue}
46
63
  onChange={(event) => {
47
- previousValueRef.current = getEventValue(event);
64
+ recordLocalValue(event);
48
65
  onChange?.(event);
49
66
  }}
50
67
  onCompositionStart={(event) => {
51
- previousValueRef.current = getEventValue(event);
68
+ recordLocalValue(event);
52
69
  onCompositionStart?.(event);
53
70
  }}
54
71
  onCompositionEnd={(event) => {
55
- previousValueRef.current = getEventValue(event);
72
+ recordLocalValue(event);
56
73
  onCompositionEnd?.(event);
57
74
  }}
58
75
  />
59
76
  );
60
77
  }
61
78
 
79
+ function normalizeTextAreaValue(nextValue: unknown): TextAreaProps['value'] {
80
+ if (typeof nextValue === 'bigint') return String(nextValue);
81
+ if (nextValue == null) return '';
82
+ return nextValue as TextAreaProps['value'];
83
+ }
84
+
62
85
  @largeField()
63
86
  export class TextareaFieldModel extends FieldModel {
64
87
  render() {
@@ -7,8 +7,9 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- import { FlowEngine } from '@nocobase/flow-engine';
10
+ import { FieldModelRenderer, FlowEngine, FlowEngineProvider } from '@nocobase/flow-engine';
11
11
  import { fireEvent, render, screen, waitFor } from '@testing-library/react';
12
+ import { Form } from 'antd';
12
13
  import React from 'react';
13
14
  import { describe, expect, it, vi } from 'vitest';
14
15
  import { TextareaFieldModel } from '../TextareaFieldModel';
@@ -23,6 +24,36 @@ function createTextareaFieldModel(props?: Record<string, unknown>) {
23
24
  }
24
25
 
25
26
  describe('TextareaFieldModel', () => {
27
+ it('syncs multiline values assigned through the form renderer', async () => {
28
+ const flowEngine = new FlowEngine();
29
+ const model = createTextareaFieldModel();
30
+ model.dispatchEvent = vi.fn().mockResolvedValue([]);
31
+
32
+ function FormHost() {
33
+ const [form] = Form.useForm();
34
+
35
+ React.useEffect(() => {
36
+ form.setFieldsValue({ address: 'aaaaaa\nbbbbbb' });
37
+ }, [form]);
38
+
39
+ return (
40
+ <FlowEngineProvider engine={flowEngine}>
41
+ <Form form={form}>
42
+ <Form.Item name="address">
43
+ <FieldModelRenderer model={model} />
44
+ </Form.Item>
45
+ </Form>
46
+ </FlowEngineProvider>
47
+ );
48
+ }
49
+
50
+ render(<FormHost />);
51
+
52
+ await waitFor(() => {
53
+ expect((screen.getByRole('textbox') as HTMLTextAreaElement).value).toBe('aaaaaa\nbbbbbb');
54
+ });
55
+ });
56
+
26
57
  it('keeps IME composition text visible before the parent value is committed', () => {
27
58
  const onChange = vi.fn();
28
59
  const onCompositionStart = vi.fn();
@@ -18,6 +18,7 @@ import { Link, useLocation } from 'react-router-dom';
18
18
  import { useACLRoleContext } from '../../../acl';
19
19
  import type { BaseApplication } from '../../../BaseApplication';
20
20
  import type { PluginSettingsPageType } from '../../../PluginSettingsManager';
21
+ import { shouldOpenAdminRouteInNewWindow } from '../../../RouterManager';
21
22
  import { useApp } from '../../../hooks/useApp';
22
23
  import {
23
24
  filterRenderableSettings,
@@ -65,7 +66,10 @@ const topbarActionTriggerClassName = css`
65
66
  height: 100%;
66
67
  `;
67
68
 
68
- type TopbarSettingsAppLike = Pick<BaseApplication<any>, 'router' | 'getPublicPath'>;
69
+ type TopbarSettingsAppLike = Pick<
70
+ BaseApplication<any>,
71
+ 'name' | 'router' | 'getPublicPath' | 'getHref' | 'layoutManager'
72
+ >;
69
73
 
70
74
  const normalizeTopbarPath = (pathname?: string) => {
71
75
  const trimmed = pathname?.trim();
@@ -103,10 +107,57 @@ const stripTopbarRouterBasePath = (pathname: string, basename?: string) => {
103
107
  return normalizedPath;
104
108
  };
105
109
 
110
+ const getTopbarAppPath = (pathname: string) => {
111
+ const normalizedPath = normalizeTopbarPath(pathname);
112
+ const match = /^(.*?\/(?:apps|_app)\/[^/]+)(?=\/|$)/.exec(normalizedPath);
113
+ const appPath = match?.[1] || '';
114
+
115
+ return {
116
+ appPath,
117
+ routePath: appPath ? normalizeTopbarPath(normalizedPath.slice(appPath.length)) : normalizedPath,
118
+ };
119
+ };
120
+
121
+ const getTopbarContextAppPath = (app: TopbarSettingsAppLike | undefined, basename?: string) => {
122
+ const basenameAppPath = getTopbarAppPath(basename || '').appPath;
123
+ if (basenameAppPath) {
124
+ return basenameAppPath;
125
+ }
126
+
127
+ const publicPathAppPath = getTopbarAppPath(app?.getPublicPath?.() || '').appPath;
128
+ if (publicPathAppPath) {
129
+ return publicPathAppPath;
130
+ }
131
+
132
+ if (app?.name && app.name !== 'main' && app.getHref) {
133
+ return normalizeTopbarBasePath(app.getHref('/'));
134
+ }
135
+
136
+ return '';
137
+ };
138
+
139
+ const prependTopbarAppPath = (pathname: string, appPath: string) => {
140
+ const normalizedPath = normalizeTopbarPath(pathname);
141
+
142
+ if (!appPath || normalizedPath === appPath || normalizedPath.startsWith(`${appPath}/`)) {
143
+ return normalizedPath;
144
+ }
145
+
146
+ return `${appPath}${normalizedPath}`;
147
+ };
148
+
106
149
  const isAdminRuntimePath = (pathname: string) => {
107
150
  return pathname === '/admin' || pathname.startsWith('/admin/');
108
151
  };
109
152
 
153
+ const getTopbarAdminRoutePath = (app: TopbarSettingsAppLike | undefined) => {
154
+ try {
155
+ return app?.layoutManager?.getLayout?.('admin')?.routePath;
156
+ } catch {
157
+ return undefined;
158
+ }
159
+ };
160
+
110
161
  const buildTopbarDocumentHref = (targetPath: string, basename?: string) => {
111
162
  const normalizedTarget = normalizeTopbarPath(targetPath);
112
163
  const normalizedBase = normalizeTopbarBasePath(basename);
@@ -136,9 +187,33 @@ function TopbarInternalSettingsLabel(props: { title: React.ReactNode; path?: str
136
187
  const targetPath = props.path || '/admin/settings';
137
188
  const basename = getTopbarRouterBasePath(app);
138
189
  const currentPath = stripTopbarRouterBasePath(location.pathname, basename);
190
+ const currentLocationAppPath = getTopbarAppPath(currentPath);
191
+ const currentAppPath = currentLocationAppPath.appPath || getTopbarContextAppPath(app, basename);
192
+ const currentRoutePath = currentLocationAppPath.appPath ? currentLocationAppPath.routePath : currentPath;
193
+ const targetPathInCurrentApp = prependTopbarAppPath(stripTopbarRouterBasePath(targetPath, basename), currentAppPath);
194
+
195
+ if (currentAppPath) {
196
+ const href = buildTopbarDocumentHref(targetPathInCurrentApp, basename);
197
+ const shouldOpenInNewWindow = shouldOpenAdminRouteInNewWindow({
198
+ currentPathname: currentPath,
199
+ targetPathname: targetPathInCurrentApp,
200
+ basePath: basename,
201
+ adminRoutePath: getTopbarAdminRoutePath(app),
202
+ });
203
+
204
+ return (
205
+ <a
206
+ href={href}
207
+ target={shouldOpenInNewWindow ? '_blank' : undefined}
208
+ rel={shouldOpenInNewWindow ? 'noopener noreferrer' : undefined}
209
+ >
210
+ {props.title}
211
+ </a>
212
+ );
213
+ }
139
214
 
140
- if (isAdminRuntimePath(currentPath)) {
141
- return <Link to={targetPath}>{props.title}</Link>;
215
+ if (isAdminRuntimePath(currentRoutePath)) {
216
+ return <Link to={targetPathInCurrentApp}>{props.title}</Link>;
142
217
  }
143
218
 
144
219
  return (
@@ -49,12 +49,12 @@ export function resolveViewParamsToViewList(
49
49
  return viewItems;
50
50
  }
51
51
 
52
- export function updateViewListHidden(viewItems: ViewItem[]) {
52
+ export function updateViewListHidden(viewItems: ViewItem[], isMobileLayout = false) {
53
53
  // Calculate hidden values based on view types and positions
54
54
  let hasEmbedAfter = false;
55
55
  for (let i = viewItems.length - 1; i >= 0; i--) {
56
56
  const viewItem = viewItems[i];
57
- const viewType = getViewType(viewItem);
57
+ const viewType = getViewType(viewItem, isMobileLayout);
58
58
 
59
59
  if (viewType === 'embed' && !hasEmbedAfter) {
60
60
  hasEmbedAfter = true;
@@ -65,15 +65,23 @@ export function updateViewListHidden(viewItems: ViewItem[]) {
65
65
  }
66
66
  }
67
67
 
68
- function getViewType(viewItem: ViewItem): string {
68
+ function getViewType(viewItem: ViewItem, isMobileLayout = false): string {
69
69
  if (viewItem.model instanceof RouteModel) {
70
70
  return 'embed';
71
71
  }
72
72
 
73
+ if (isMobileLayout && viewItem.index > 0) {
74
+ return 'embed';
75
+ }
76
+
73
77
  if (!viewItem.model) {
74
78
  return 'drawer';
75
79
  }
76
80
 
81
+ if (viewItem.params.openViewRouteState?.mode) {
82
+ return viewItem.params.openViewRouteState.mode;
83
+ }
84
+
77
85
  const params = viewItem.model.getStepParams('popupSettings', 'openView');
78
86
  return params?.mode || 'drawer';
79
87
  }
@@ -0,0 +1,27 @@
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 const ROUTE_TRANSIENT_INPUT_ARGS_KEY = '__nocobaseOpenViewInputArgs';
11
+
12
+ export type RouteTransientInputArgsState = {
13
+ [ROUTE_TRANSIENT_INPUT_ARGS_KEY]?: Record<string, Record<string, unknown>>;
14
+ usr?: RouteTransientInputArgsState;
15
+ };
16
+
17
+ export const getRouteTransientInputArgs = (state: unknown, viewUid?: string) => {
18
+ if (!viewUid || !state || typeof state !== 'object') {
19
+ return {};
20
+ }
21
+
22
+ const stateValue = state as RouteTransientInputArgsState;
23
+ const values = (stateValue[ROUTE_TRANSIENT_INPUT_ARGS_KEY] || stateValue.usr?.[ROUTE_TRANSIENT_INPUT_ARGS_KEY])?.[
24
+ viewUid
25
+ ];
26
+ return values && typeof values === 'object' ? values : {};
27
+ };
@@ -207,6 +207,48 @@ describe('dateTimeFormat', () => {
207
207
  expect(save).toHaveBeenCalled();
208
208
  });
209
209
 
210
+ it('syncs ordinary table column props when date time format settings are saved', async () => {
211
+ const setProps = vi.fn();
212
+ const save = vi.fn();
213
+ const setParentProps = vi.fn();
214
+ const model = {
215
+ context: {
216
+ collectionField: {
217
+ type: 'datetime',
218
+ interface: 'datetime',
219
+ },
220
+ },
221
+ setProps,
222
+ save,
223
+ parent: {
224
+ use: 'TableColumnModel',
225
+ setProps: setParentProps,
226
+ },
227
+ };
228
+ model.parent['subModels'] = {
229
+ field: model,
230
+ };
231
+
232
+ await dateTimeFormat.beforeParamsSave(
233
+ { model },
234
+ {
235
+ picker: 'date',
236
+ dateFormat: 'YYYY-MM-DD',
237
+ showTime: true,
238
+ timeFormat: 'HH:mm:ss',
239
+ },
240
+ );
241
+
242
+ expect(setParentProps).toHaveBeenCalledWith({
243
+ picker: 'date',
244
+ dateFormat: 'YYYY-MM-DD',
245
+ showTime: true,
246
+ timeFormat: 'HH:mm:ss',
247
+ format: 'YYYY-MM-DD HH:mm:ss',
248
+ });
249
+ expect(save).toHaveBeenCalled();
250
+ });
251
+
210
252
  it('hides time format for association title date-only fields', () => {
211
253
  const ctx = {
212
254
  model: {
package/src/index.ts CHANGED
@@ -38,6 +38,7 @@ export * from './collection-manager/filter-operators';
38
38
  export * from './collection-manager/interfaces';
39
39
  export * from './collection-manager/template-fields';
40
40
  export * from './data-source';
41
+ export * from './entry-actions';
41
42
  export * from './flow';
42
43
  export {
43
44
  DEFAULT_DATA_SOURCE_KEY,
@@ -47,4 +48,5 @@ export {
47
48
  NocoBaseDesktopRouteType,
48
49
  } from './flow-compat';
49
50
  export type { NocoBaseDesktopRoute } from './flow-compat';
51
+ export * from './utils/markdownSanitize';
50
52
  export { default as AntdAppProvider } from './theme/AntdAppProvider';
@@ -15,7 +15,12 @@ import type { Application } from '../Application';
15
15
  import { getCurrentV2RedirectPath, getDefaultV2AdminRedirectPath } from '../authRedirect';
16
16
  import { AppNotFound } from '../components';
17
17
  import { PluginFlowEngine } from '../flow';
18
- import { ADMIN_LAYOUT_MODEL_UID, AdminLayoutMenuItemModel, AdminLayoutModel } from '../flow/admin-shell/admin-layout';
18
+ import {
19
+ ADMIN_LAYOUT_MODEL_UID,
20
+ AdminLayoutMenuItemModel,
21
+ AdminLayoutModel,
22
+ AppSwitcherActionPanelModel,
23
+ } from '../flow/admin-shell/admin-layout';
19
24
  import { useApp } from '../hooks/useApp';
20
25
  import { Plugin } from '../Plugin';
21
26
  import { AdminSettingsLayoutModel } from '../settings-center';
@@ -326,6 +331,7 @@ export class NocoBaseBuildInPlugin extends Plugin<any, Application> {
326
331
  this.app.flowEngine.registerModels({
327
332
  AdminLayoutModel,
328
333
  AdminLayoutMenuItemModel,
334
+ AppSwitcherActionPanelModel,
329
335
  AdminSettingsLayoutModel,
330
336
  });
331
337
  this.app.layoutManager.registerLayout({