@nocobase/client-v2 2.2.0-alpha.3 → 2.2.0-alpha.4

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 (36) hide show
  1. package/es/RouteRepository.d.ts +8 -0
  2. package/es/authRedirect.d.ts +1 -0
  3. package/es/components/form/TypedVariableInput.d.ts +9 -1
  4. package/es/components/form/filter/CollectionFilter.d.ts +2 -0
  5. package/es/components/form/filter/CollectionFilterPanel.d.ts +2 -0
  6. package/es/components/form/filter/useFilterActionProps.d.ts +2 -0
  7. package/es/index.d.ts +2 -0
  8. package/es/index.mjs +146 -114
  9. package/es/utils/getRouteRuntimeVersion.d.ts +23 -0
  10. package/es/utils/index.d.ts +1 -0
  11. package/lib/index.js +147 -115
  12. package/package.json +7 -7
  13. package/src/RouteRepository.ts +25 -0
  14. package/src/__tests__/RouteRepository.test.ts +23 -0
  15. package/src/__tests__/authRedirect.test.ts +17 -0
  16. package/src/__tests__/getRouteRuntimeVersion.test.ts +68 -0
  17. package/src/authRedirect.ts +38 -0
  18. package/src/components/form/JsonTextArea.tsx +4 -0
  19. package/src/components/form/TypedVariableInput.tsx +58 -34
  20. package/src/components/form/__tests__/TypedVariableInput.test.tsx +52 -0
  21. package/src/components/form/filter/CollectionFilter.tsx +4 -0
  22. package/src/components/form/filter/CollectionFilterPanel.tsx +4 -0
  23. package/src/components/form/filter/__tests__/useFilterActionProps.test.tsx +95 -0
  24. package/src/components/form/filter/useFilterActionProps.ts +37 -6
  25. package/src/flow/actions/dateTimeFormat.tsx +2 -2
  26. package/src/flow/admin-shell/BaseLayoutModel.tsx +13 -0
  27. package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.test.tsx +177 -1
  28. package/src/flow/admin-shell/admin-layout/AdminLayoutEntryGuard.tsx +20 -0
  29. package/src/flow/admin-shell/admin-layout/__tests__/AdminLayoutModel.test.tsx +77 -0
  30. package/src/flow/models/blocks/table/TableColumnModel.tsx +6 -2
  31. package/src/flow/models/blocks/table/__tests__/TableColumnModel.test.tsx +51 -0
  32. package/src/flow/models/fields/AssociationFieldModel/RecordSelectFieldModel.tsx +45 -13
  33. package/src/flow/utils/__tests__/dateTimeFormat.test.ts +42 -0
  34. package/src/index.ts +2 -0
  35. package/src/utils/getRouteRuntimeVersion.ts +185 -0
  36. package/src/utils/index.tsx +1 -0
@@ -43,6 +43,14 @@ const isCondition = (item: FilterGroupItem): item is CollectionFilterItemValue =
43
43
  typeof (item as CollectionFilterItemValue).path === 'string' &&
44
44
  Object.prototype.hasOwnProperty.call(item, 'operator');
45
45
 
46
+ const cloneFilterGroupItem = (item: FilterGroupItem): FilterGroupItem =>
47
+ isGroup(item) ? { logic: item.logic, items: item.items.map((child) => cloneFilterGroupItem(child)) } : { ...item };
48
+
49
+ const cloneFilterGroup = (group: FilterGroupValue): FilterGroupValue => ({
50
+ logic: group.logic,
51
+ items: group.items.map((item) => cloneFilterGroupItem(item)),
52
+ });
53
+
46
54
  /**
47
55
  * `true` when the rhs of a condition is "no real value yet" — covers `undefined` / `null` / empty string / empty array / empty plain object. Mirrors v1's `removeNullCondition` `isEmpty` predicate so half-filled rows ("Locked time → is → (no date picked yet)") get dropped on Submit instead of being sent to the server as `{lockedTs:{}}` and triggering a 500.
48
56
  */
@@ -164,6 +172,8 @@ export interface UseFilterActionPropsArgs extends UseFilterOptionsArgs {
164
172
  collection: Collection | undefined;
165
173
  /** Previously compiled filter param used to seed the editable filter group. */
166
174
  initialValue?: CompiledFilter;
175
+ /** Default compiled filter used both for initial empty state and Reset. */
176
+ defaultValue?: CompiledFilter;
167
177
  /**
168
178
  * Called when the user submits or resets the filter popover. Receives the compiled filter param (`undefined` when cleared) and which footer button triggered the call. Typical implementation: `(filter, action) => { listRequest.run(filter); if (action === 'submit') closePopover(); }`.
169
179
  */
@@ -216,12 +226,23 @@ export interface UseFilterActionPropsResult {
216
226
  * ```
217
227
  */
218
228
  export function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterActionPropsResult {
219
- const { collection, initialValue, onApply, filterableFieldNames, nonfilterableFieldNames, noIgnore, t } = args;
229
+ const {
230
+ collection,
231
+ initialValue,
232
+ defaultValue,
233
+ onApply,
234
+ filterableFieldNames,
235
+ nonfilterableFieldNames,
236
+ noIgnore,
237
+ t,
238
+ } = args;
239
+ const seedValue = initialValue ?? defaultValue;
240
+ const defaultGroup = decompileFilterGroup(defaultValue) || createEmptyGroup();
220
241
 
221
242
  // Held in a ref so the group object identity is stable for the lifetime of the host component — `<FilterContent>` mutates this object directly (push/splice on `items`, swap `logic`), and a fresh observable on every render would reset that internal state.
222
243
  const valueRef = useRef<FilterGroupValue>();
223
244
  if (!valueRef.current) {
224
- valueRef.current = observable(decompileFilterGroup(initialValue) || createEmptyGroup()) as FilterGroupValue;
245
+ valueRef.current = observable(decompileFilterGroup(seedValue) || createEmptyGroup()) as FilterGroupValue;
225
246
  }
226
247
  const value = valueRef.current;
227
248
 
@@ -240,9 +261,10 @@ export function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterA
240
261
  });
241
262
 
242
263
  const onReset = useMemoizedFn(() => {
243
- value.logic = '$and';
244
- value.items = [];
245
- onApply(undefined, 'reset');
264
+ const next = cloneFilterGroup(defaultGroup);
265
+ value.logic = next.logic;
266
+ value.items = next.items;
267
+ onApply(compileFilterGroup(value), 'reset');
246
268
  });
247
269
 
248
270
  const translate = useMemoizedFn((key: string) => (t ? t(key) : key));
@@ -261,7 +283,16 @@ export function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterA
261
283
  );
262
284
 
263
285
  // Re-read on each render so `observer`-wrapped hosts re-render when the reactive `items` array length changes. No useMemo needed — the `value` object's identity is stable (held in a ref), but its observable `items.length` is what we actually care about, and the eslint exhaustive-deps rule rightly complains about depending on a mutable property of a stable ref.
264
- const conditionCount = value.items.length;
286
+ const conditionCount = (() => {
287
+ const compiled = compileFilterGroup(value);
288
+ if (compiled?.$and && Array.isArray(compiled.$and)) {
289
+ return compiled.$and.length;
290
+ }
291
+ if (compiled?.$or && Array.isArray(compiled.$or)) {
292
+ return compiled.$or.length;
293
+ }
294
+ return 0;
295
+ })();
265
296
 
266
297
  return { value, options, FilterItem, ctx, onSubmit, onReset, conditionCount };
267
298
  }
@@ -28,11 +28,11 @@ const isTableColumnFieldSubModel = (model) => {
28
28
 
29
29
  const syncTableColumnDateTimeFormatProps = (ctx, props) => {
30
30
  const model = ctx.model;
31
- if (!isTableColumnFieldSubModel(model) || !model?.parent?.collectionField?.isAssociationField?.()) {
31
+ if (!isTableColumnFieldSubModel(model)) {
32
32
  return;
33
33
  }
34
34
 
35
- model.parent.setProps(props);
35
+ model.parent?.setProps?.(props);
36
36
  };
37
37
 
38
38
  export const dateTimeFormat = defineAction({
@@ -20,6 +20,7 @@ import {
20
20
  type BaseLayoutRouteCoordinatorOptions,
21
21
  type RoutePageMeta,
22
22
  } from './BaseLayoutRouteCoordinator';
23
+ import { NocoBaseDesktopRouteType } from '../../flow-compat';
23
24
  import type { LayoutDefinition } from '../../layout-manager/types';
24
25
  import { isLayoutContentRouteName } from '../../layout-manager/utils';
25
26
 
@@ -322,6 +323,18 @@ export class BaseLayoutModel<
322
323
  };
323
324
  }
324
325
 
326
+ const routeRepository = this.flowEngine.context.routeRepository;
327
+ const schemaRoute = routeRepository?.getRouteBySchemaUid?.(pageUid);
328
+ const route = schemaRoute ? undefined : routeRepository?.getRouteById?.(pageUid);
329
+ if (!schemaRoute && route?.type === NocoBaseDesktopRouteType.group) {
330
+ return {
331
+ type: 'root',
332
+ pathname,
333
+ basePathname,
334
+ relativePath,
335
+ };
336
+ }
337
+
325
338
  return {
326
339
  type: 'page',
327
340
  pathname,
@@ -10,8 +10,9 @@
10
10
  import { FlowEngine, FlowEngineProvider } from '@nocobase/flow-engine';
11
11
  import { act, render, screen, waitFor } from '@testing-library/react';
12
12
  import React from 'react';
13
- import { createMemoryRouter, RouterProvider } from 'react-router-dom';
13
+ import { createMemoryRouter, Outlet, RouterProvider } from 'react-router-dom';
14
14
  import { describe, expect, it, vi } from 'vitest';
15
+ import { NocoBaseDesktopRouteType } from '../../../flow-compat';
15
16
  import { RouteRepository } from '../../../RouteRepository';
16
17
  import { AdminLayoutEntryGuard } from './AdminLayoutEntryGuard';
17
18
  import type { AdminLayoutModel } from './AdminLayoutModel';
@@ -307,4 +308,179 @@ describe('AdminLayoutEntryGuard', () => {
307
308
  expect(activateLayout).toHaveBeenCalledTimes(2);
308
309
  expect(activateLayout).toHaveBeenLastCalledWith(expect.objectContaining({ uid: 'admin-layout-next' }));
309
310
  });
311
+
312
+ it('should redirect group id paths to the first v2 landing route', async () => {
313
+ const modernWindow = window as Window & { __nocobase_modern_client_prefix__?: string };
314
+ modernWindow.__nocobase_modern_client_prefix__ = 'v2';
315
+ const engine = new FlowEngine();
316
+ const request = vi.fn().mockResolvedValue({
317
+ data: {
318
+ data: [],
319
+ },
320
+ });
321
+ const routeRepository = new RouteRepository({
322
+ api: {
323
+ request,
324
+ resource: vi.fn(),
325
+ },
326
+ } as never);
327
+ routeRepository.setRoutes([
328
+ {
329
+ id: 1,
330
+ title: 'Group',
331
+ type: NocoBaseDesktopRouteType.group,
332
+ children: [
333
+ {
334
+ id: 11,
335
+ title: 'Flow page',
336
+ schemaUid: 'flow-page-1',
337
+ type: NocoBaseDesktopRouteType.flowPage,
338
+ },
339
+ ],
340
+ },
341
+ ]);
342
+ engine.context.defineProperty('routeRepository', {
343
+ value: routeRepository,
344
+ });
345
+ engine.context.defineProperty('app', {
346
+ value: {
347
+ getPublicPath: () => '/apps/demo/v2/',
348
+ router: {
349
+ getBasename: () => '/apps/demo/v2',
350
+ },
351
+ },
352
+ });
353
+
354
+ const model = {
355
+ layout: {
356
+ routeName: 'admin',
357
+ routePath: '/admin',
358
+ uid: 'admin-layout-model',
359
+ },
360
+ } as AdminLayoutModel;
361
+ const router = createMemoryRouter(
362
+ [
363
+ {
364
+ path: '/admin',
365
+ id: 'admin',
366
+ element: (
367
+ <FlowEngineProvider engine={engine}>
368
+ <AdminLayoutEntryGuard model={model}>
369
+ <Outlet />
370
+ </AdminLayoutEntryGuard>
371
+ </FlowEngineProvider>
372
+ ),
373
+ children: [
374
+ {
375
+ path: ':name',
376
+ id: 'admin.__page',
377
+ element: <div>Admin page shell</div>,
378
+ },
379
+ ],
380
+ },
381
+ ],
382
+ {
383
+ initialEntries: ['/admin/1'],
384
+ },
385
+ );
386
+
387
+ try {
388
+ render(<RouterProvider router={router} />);
389
+
390
+ await waitFor(() => {
391
+ expect(router.state.location.pathname).toBe('/admin/flow-page-1');
392
+ });
393
+ expect(await screen.findByText('Admin page shell')).toBeInTheDocument();
394
+ } finally {
395
+ delete modernWindow.__nocobase_modern_client_prefix__;
396
+ }
397
+ });
398
+
399
+ it('should prefer schema uid routes before resolving numeric group ids', async () => {
400
+ const modernWindow = window as Window & { __nocobase_modern_client_prefix__?: string };
401
+ modernWindow.__nocobase_modern_client_prefix__ = 'v2';
402
+ const engine = new FlowEngine();
403
+ const routeRepository = {
404
+ activateLayout: vi.fn(() => vi.fn()),
405
+ ensureAccessibleLoaded: vi.fn().mockResolvedValue([]),
406
+ isAccessibleLoaded: vi.fn(() => true),
407
+ getRouteBySchemaUid: vi.fn((pageUid: string) =>
408
+ pageUid === '1'
409
+ ? {
410
+ schemaUid: '1',
411
+ type: NocoBaseDesktopRouteType.flowPage,
412
+ }
413
+ : undefined,
414
+ ),
415
+ getRouteById: vi.fn((routeId: string) =>
416
+ routeId === '1'
417
+ ? {
418
+ id: 1,
419
+ type: NocoBaseDesktopRouteType.group,
420
+ children: [
421
+ {
422
+ schemaUid: 'flow-page-1',
423
+ type: NocoBaseDesktopRouteType.flowPage,
424
+ },
425
+ ],
426
+ }
427
+ : undefined,
428
+ ),
429
+ listAccessible: vi.fn(() => []),
430
+ };
431
+ engine.context.defineProperty('routeRepository', {
432
+ value: routeRepository,
433
+ });
434
+ engine.context.defineProperty('app', {
435
+ value: {
436
+ getPublicPath: () => '/apps/demo/v2/',
437
+ router: {
438
+ getBasename: () => '/apps/demo/v2',
439
+ },
440
+ },
441
+ });
442
+
443
+ const model = {
444
+ layout: {
445
+ routeName: 'admin',
446
+ routePath: '/admin',
447
+ uid: 'admin-layout-model',
448
+ },
449
+ } as AdminLayoutModel;
450
+ const router = createMemoryRouter(
451
+ [
452
+ {
453
+ path: '/admin',
454
+ id: 'admin',
455
+ element: (
456
+ <FlowEngineProvider engine={engine}>
457
+ <AdminLayoutEntryGuard model={model}>
458
+ <Outlet />
459
+ </AdminLayoutEntryGuard>
460
+ </FlowEngineProvider>
461
+ ),
462
+ children: [
463
+ {
464
+ path: ':name',
465
+ id: 'admin.__page',
466
+ element: <div>Admin page shell</div>,
467
+ },
468
+ ],
469
+ },
470
+ ],
471
+ {
472
+ initialEntries: ['/admin/1'],
473
+ },
474
+ );
475
+
476
+ try {
477
+ render(<RouterProvider router={router} />);
478
+
479
+ await screen.findByText('Admin page shell');
480
+ expect(router.state.location.pathname).toBe('/admin/1');
481
+ expect(routeRepository.getRouteById).not.toHaveBeenCalled();
482
+ } finally {
483
+ delete modernWindow.__nocobase_modern_client_prefix__;
484
+ }
485
+ });
310
486
  });
@@ -132,6 +132,26 @@ export const AdminLayoutEntryGuard: FC<{ children: React.ReactNode; model?: Admi
132
132
  }
133
133
  }
134
134
 
135
+ const groupRoute = currentRoute ? undefined : routeRepository?.getRouteById?.(pageUid);
136
+ if (!currentRoute && groupRoute?.type === NocoBaseDesktopRouteType.group) {
137
+ const target = resolveAdminRouteRuntimeTarget({
138
+ app,
139
+ route: groupRoute,
140
+ layout: layoutRuntime,
141
+ });
142
+
143
+ if (target.runtimePath) {
144
+ replaceTriggeredRef.current = true;
145
+ if (target.navigationMode === 'document') {
146
+ window.location.replace(target.runtimePath);
147
+ return;
148
+ }
149
+
150
+ navigate(toRouterNavigationPath(target.runtimePath, app.router.getBasename()), { replace: true });
151
+ return;
152
+ }
153
+ }
154
+
135
155
  if (active) {
136
156
  setReady(true);
137
157
  }
@@ -44,6 +44,7 @@ import {
44
44
  type FlowModel,
45
45
  } from '@nocobase/flow-engine';
46
46
  import { AdminLayoutModel, getAdminLayoutModel } from '..';
47
+ import { NocoBaseDesktopRouteType } from '../../../../flow-compat';
47
48
  import { getLayoutPageRouteName, getLayoutPageViewRouteName } from '../../../../layout-manager/utils';
48
49
  import { TopbarActionModel } from '../../../models/topbar/TopbarActionModel';
49
50
  import { UserCenterTopbarActionModel } from '../../../models/topbar/UserCenterTopbarActionModel';
@@ -295,6 +296,82 @@ describe('AdminLayoutModel runtime', () => {
295
296
  });
296
297
  });
297
298
 
299
+ it('should resolve group id paths as blank root routes', async () => {
300
+ const engine = new FlowEngine();
301
+ engine.context.defineProperty('routeRepository', {
302
+ value: {
303
+ getRouteById: (routeId: string) =>
304
+ routeId === '1'
305
+ ? {
306
+ id: 1,
307
+ type: NocoBaseDesktopRouteType.group,
308
+ }
309
+ : undefined,
310
+ },
311
+ });
312
+
313
+ render(
314
+ <FlowEngineProvider engine={engine}>
315
+ <TestAdminLayoutHost />
316
+ </FlowEngineProvider>,
317
+ );
318
+ const model = engine.getModel<TestAdminLayoutModel>('admin-layout-model');
319
+ expect(model).toBeTruthy();
320
+
321
+ expect(
322
+ model.resolveLayoutRoute({
323
+ name: getLayoutPageRouteName('admin'),
324
+ pathname: '/admin/1',
325
+ layoutBasePathname: '/admin',
326
+ }),
327
+ ).toMatchObject({
328
+ type: 'root',
329
+ pathname: '/admin/1',
330
+ relativePath: '1',
331
+ });
332
+ });
333
+
334
+ it('should prefer schema uid routes before treating numeric paths as group ids', async () => {
335
+ const engine = new FlowEngine();
336
+ engine.context.defineProperty('routeRepository', {
337
+ value: {
338
+ getRouteBySchemaUid: (pageUid: string) =>
339
+ pageUid === '1'
340
+ ? {
341
+ schemaUid: '1',
342
+ type: NocoBaseDesktopRouteType.flowPage,
343
+ }
344
+ : undefined,
345
+ getRouteById: (routeId: string) =>
346
+ routeId === '1'
347
+ ? {
348
+ id: 1,
349
+ type: NocoBaseDesktopRouteType.group,
350
+ }
351
+ : undefined,
352
+ },
353
+ });
354
+
355
+ render(
356
+ <FlowEngineProvider engine={engine}>
357
+ <TestAdminLayoutHost />
358
+ </FlowEngineProvider>,
359
+ );
360
+ const model = engine.getModel<TestAdminLayoutModel>('admin-layout-model');
361
+ expect(model).toBeTruthy();
362
+
363
+ expect(
364
+ model.resolveLayoutRoute({
365
+ name: getLayoutPageRouteName('admin'),
366
+ pathname: '/admin/1',
367
+ layoutBasePathname: '/admin',
368
+ }),
369
+ ).toMatchObject({
370
+ type: 'page',
371
+ pageUid: '1',
372
+ });
373
+ });
374
+
298
375
  it('should not consume global routes that belong to nested layouts', async () => {
299
376
  const engine = new FlowEngine();
300
377
  const routeRef = observable.ref({
@@ -373,14 +373,18 @@ TableColumnModel.registerFlow({
373
373
  currentProps: ctx.model.props,
374
374
  })
375
375
  : undefined;
376
+ const collectionFieldComponentProps = collectionField.getComponentProps();
376
377
  const componentProps =
377
378
  collectionField.isAssociationField() && titleField
378
379
  ? {
379
- ...collectionField.getComponentProps(),
380
+ ...collectionFieldComponentProps,
380
381
  ...targetCollectionField?.getComponentProps?.(),
381
382
  ...savedDateTimeDisplayProps,
382
383
  }
383
- : collectionField.getComponentProps();
384
+ : {
385
+ ...collectionFieldComponentProps,
386
+ ...savedDateTimeDisplayProps,
387
+ };
384
388
  ctx.model.setProps('title', collectionField.title);
385
389
  ctx.model.setProps('dataIndex', collectionField.name);
386
390
  // for quick edit
@@ -327,6 +327,57 @@ describe('TableColumnModel sorter settings', () => {
327
327
  );
328
328
  });
329
329
 
330
+ it('keeps saved ordinary datetime format when table column initializes again', async () => {
331
+ const engine = new FlowEngine();
332
+ const model = new TableColumnModel({
333
+ uid: 'table-column-saved-datetime-format',
334
+ flowEngine: engine,
335
+ } as any);
336
+ const initStep = model.getFlow('tableColumnSettings')?.steps?.init as any;
337
+ const setProps = vi.fn();
338
+
339
+ await initStep.handler({
340
+ model: {
341
+ context: {
342
+ collectionField: {
343
+ title: 'Datetime',
344
+ name: 'datetime',
345
+ isAssociationField: () => false,
346
+ getComponentProps: () => ({
347
+ dateFormat: 'YYYY-MM-DD',
348
+ showTime: false,
349
+ }),
350
+ },
351
+ },
352
+ props: {},
353
+ subModels: {
354
+ field: {
355
+ getStepParams: (flowKey, stepKey) =>
356
+ flowKey === 'datetimeSettings' && stepKey === 'dateFormat'
357
+ ? {
358
+ picker: 'date',
359
+ dateFormat: 'YYYY-MM-DD',
360
+ showTime: true,
361
+ timeFormat: 'HH:mm:ss',
362
+ }
363
+ : undefined,
364
+ },
365
+ },
366
+ applySubModelsBeforeRenderFlows: vi.fn(),
367
+ setProps,
368
+ },
369
+ });
370
+
371
+ expect(setProps).toHaveBeenCalledWith(
372
+ expect.objectContaining({
373
+ dateFormat: 'YYYY-MM-DD',
374
+ format: 'YYYY-MM-DD HH:mm:ss',
375
+ showTime: true,
376
+ timeFormat: 'HH:mm:ss',
377
+ }),
378
+ );
379
+ });
380
+
330
381
  it('does not update field component setting when title field refresh fails', async () => {
331
382
  const engine = new FlowEngine();
332
383
  const model = new TableColumnModel({ uid: 'table-column-title-field-component-failed', flowEngine: engine } as any);
@@ -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);
@@ -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
@@ -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';