@nocobase/client-v2 2.1.0-beta.35 → 2.1.0-beta.37

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 (94) hide show
  1. package/es/BaseApplication.d.ts +2 -1
  2. package/es/components/PoweredBy.d.ts +18 -0
  3. package/es/components/SwitchLanguage.d.ts +11 -0
  4. package/es/components/form/DialogFormLayout.d.ts +51 -0
  5. package/es/components/form/DrawerFormLayout.d.ts +11 -11
  6. package/es/components/form/PasswordInput.d.ts +40 -0
  7. package/es/components/form/RemoteSelect.d.ts +79 -0
  8. package/es/components/form/filter/CollectionFilter.d.ts +41 -0
  9. package/es/components/form/filter/CollectionFilterItem.d.ts +41 -0
  10. package/es/components/form/filter/DateFilterDynamicComponent.d.ts +57 -0
  11. package/es/components/form/filter/FilterValueInput.d.ts +29 -0
  12. package/es/components/form/filter/index.d.ts +11 -0
  13. package/es/components/form/filter/useFilterActionProps.d.ts +96 -0
  14. package/es/components/form/index.d.ts +4 -0
  15. package/es/components/form/table/styles.d.ts +10 -0
  16. package/es/components/index.d.ts +2 -0
  17. package/es/data-source/ExtendCollectionsProvider.d.ts +24 -0
  18. package/es/data-source/index.d.ts +9 -0
  19. package/es/flow/components/filter/index.d.ts +2 -0
  20. package/es/flow/components/filter/useFilterOptions.d.ts +54 -0
  21. package/es/flow/models/base/ActionModelCore.d.ts +6 -0
  22. package/es/flow/models/base/GridModel.d.ts +2 -0
  23. package/es/flow/utils/dataScopeFormValueClear.d.ts +14 -0
  24. package/es/flow-compat/passwordUtils.d.ts +1 -1
  25. package/es/hooks/index.d.ts +2 -0
  26. package/es/hooks/useCurrentAppInfo.d.ts +9 -0
  27. package/es/index.d.ts +1 -0
  28. package/es/index.mjs +109 -92
  29. package/es/nocobase-buildin-plugin/index.d.ts +20 -2
  30. package/es/utils/appVersionHTML.d.ts +10 -0
  31. package/es/utils/index.d.ts +1 -0
  32. package/es/utils/remotePlugins.d.ts +4 -1
  33. package/lib/index.js +115 -98
  34. package/package.json +7 -7
  35. package/src/BaseApplication.tsx +16 -3
  36. package/src/PluginSettingsManager.ts +2 -1
  37. package/src/__tests__/PluginSettingsManager.test.ts +19 -0
  38. package/src/__tests__/PoweredBy.test.tsx +130 -0
  39. package/src/__tests__/app.test.tsx +40 -0
  40. package/src/__tests__/nocobase-buildin-plugin-auth.test.tsx +39 -72
  41. package/src/__tests__/remotePlugins.test.ts +55 -0
  42. package/src/__tests__/useCurrentRoles.test.tsx +100 -0
  43. package/src/components/PoweredBy.tsx +71 -0
  44. package/src/components/README.md +397 -0
  45. package/src/components/README.zh-CN.md +394 -0
  46. package/src/components/SwitchLanguage.tsx +48 -0
  47. package/src/components/form/DialogFormLayout.tsx +87 -0
  48. package/src/components/form/DrawerFormLayout.tsx +13 -32
  49. package/src/components/form/PasswordInput.tsx +211 -0
  50. package/src/components/form/RemoteSelect.tsx +137 -0
  51. package/src/components/form/filter/CollectionFilter.tsx +101 -0
  52. package/src/components/form/filter/CollectionFilterItem.tsx +176 -0
  53. package/src/components/form/filter/DateFilterDynamicComponent.tsx +283 -0
  54. package/src/components/form/filter/FilterValueInput.tsx +198 -0
  55. package/src/components/form/filter/__tests__/CollectionFilterItem.test.tsx +205 -0
  56. package/src/components/form/filter/__tests__/DateFilterDynamicComponent.test.tsx +148 -0
  57. package/src/components/form/filter/__tests__/FilterValueInput.test.tsx +243 -0
  58. package/src/components/form/filter/__tests__/compileFilterGroup.test.ts +146 -0
  59. package/src/components/form/filter/index.ts +13 -0
  60. package/src/components/form/filter/useFilterActionProps.ts +200 -0
  61. package/src/components/form/index.tsx +4 -0
  62. package/src/components/form/table/Table.tsx +2 -1
  63. package/src/components/form/table/styles.ts +19 -0
  64. package/src/components/index.ts +2 -0
  65. package/src/css-variable/CSSVariableProvider.tsx +10 -1
  66. package/src/data-source/ExtendCollectionsProvider.tsx +70 -0
  67. package/src/data-source/index.ts +10 -0
  68. package/src/flow/actions/__tests__/dataScopeFormValueClear.test.ts +96 -0
  69. package/src/flow/actions/dataScope.tsx +3 -0
  70. package/src/flow/admin-shell/admin-layout/AdminLayoutComponent.tsx +1 -4
  71. package/src/flow/admin-shell/admin-layout/HelpLite.tsx +7 -33
  72. package/src/flow/components/BlockItemCard.tsx +2 -2
  73. package/src/flow/components/filter/index.ts +3 -0
  74. package/src/flow/components/filter/useFilterOptions.ts +80 -0
  75. package/src/flow/models/base/ActionModel.tsx +8 -7
  76. package/src/flow/models/base/ActionModelCore.tsx +15 -7
  77. package/src/flow/models/base/GridModel.tsx +93 -36
  78. package/src/flow/models/base/__tests__/GridModel.visibleLayout.test.ts +83 -11
  79. package/src/flow/models/blocks/details/DetailsItemModel.tsx +2 -0
  80. package/src/flow/models/blocks/form/FormItemModel.tsx +5 -3
  81. package/src/flow/models/blocks/form/__tests__/FormItemModel.defineChildren.test.ts +108 -0
  82. package/src/flow/models/blocks/table/TableActionsColumnModel.tsx +5 -0
  83. package/src/flow/models/blocks/table/TableColumnModel.tsx +2 -0
  84. package/src/flow/models/fields/AssociationFieldModel/SubTableFieldModel/SubTableColumnModel.tsx +2 -0
  85. package/src/flow/utils/dataScopeFormValueClear.ts +278 -0
  86. package/src/hooks/index.ts +2 -0
  87. package/src/hooks/useCurrentAppInfo.ts +36 -0
  88. package/src/index.ts +1 -0
  89. package/src/nocobase-buildin-plugin/index.tsx +66 -18
  90. package/src/nocobase-buildin-plugin/plugins/LocalePlugin.ts +1 -0
  91. package/src/utils/appVersionHTML.ts +28 -0
  92. package/src/utils/globalDeps.ts +2 -2
  93. package/src/utils/index.tsx +2 -0
  94. package/src/utils/remotePlugins.ts +12 -7
@@ -106,6 +106,7 @@ export declare abstract class BaseApplication<TOptions extends BaseApplicationOp
106
106
  get pm(): TPluginManager;
107
107
  get disableAcl(): boolean;
108
108
  get isWsAuthorized(): boolean;
109
+ setDocumentLanguage(language?: string | null): void;
109
110
  constructor(options?: TOptions);
110
111
  /**
111
112
  * 注册共享 observable 状态。
@@ -130,7 +131,7 @@ export declare abstract class BaseApplication<TOptions extends BaseApplicationOp
130
131
  protected addFinalProviders(): void;
131
132
  addReactRouterComponents(): void;
132
133
  addRoutes(): void;
133
- updateFavicon(favicon?: string): void;
134
+ updateFavicon(favicon?: string | null): void;
134
135
  setWsAuthorized(authorized: boolean): void;
135
136
  setMaintaining(maintaining: boolean): void;
136
137
  getOptions(): TOptions;
@@ -0,0 +1,18 @@
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
+ import React from 'react';
10
+ /**
11
+ * Footer brand rendered on auth pages and other layout entry points. Falls
12
+ * back to "Powered by NocoBase" when `@nocobase/plugin-custom-brand` is not
13
+ * installed; otherwise renders the plugin's HTML template with the
14
+ * `{{appVersion}}` placeholder substituted. The version is escaped via
15
+ * `getAppVersionHTML` so a malicious app version cannot inject script tags.
16
+ */
17
+ export declare function PoweredBy(): React.JSX.Element;
18
+ export default PoweredBy;
@@ -0,0 +1,11 @@
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
+ import React from 'react';
10
+ export declare function SwitchLanguage(): React.JSX.Element;
11
+ export default SwitchLanguage;
@@ -0,0 +1,51 @@
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
+ import React from 'react';
10
+ export interface DialogFormLayoutProps {
11
+ /** Header title rendered in the dialog's title slot. */
12
+ title: React.ReactNode;
13
+ /** Form body — typically a `<Form>` wrapping `<Form.Item>` fields. */
14
+ children: React.ReactNode;
15
+ /** Called before the dialog is closed by the Cancel button or the top-right close (X) icon. Use for "discard changes" confirmations. */
16
+ onCancel?: () => void | Promise<void>;
17
+ /** Called when the Submit button is clicked. Caller owns validation + the actual API call; the dialog is closed automatically when `onSubmit` resolves. Throw from `onSubmit` to keep the dialog open (e.g. on a validation error). */
18
+ onSubmit?: () => void | Promise<void>;
19
+ /** Drives the Submit button's loading state. */
20
+ submitting?: boolean;
21
+ /** Override the Submit button label. Defaults to "Submit". */
22
+ submitText?: React.ReactNode;
23
+ /** Override the Cancel button label. Defaults to "Cancel". */
24
+ cancelText?: React.ReactNode;
25
+ /** Full override of the footer content. When provided, the default Cancel + Submit buttons are replaced. Useful for forms that need extra actions (e.g. Preview, Save draft). */
26
+ footer?: React.ReactNode;
27
+ }
28
+ /**
29
+ * Standard layout for dialog-hosted forms — the dialog counterpart of `DrawerFormLayout`. Title sits left-aligned in the dialog's native header, the form body fills the middle, and a Cancel + Submit footer sits at the bottom. Neither this layout nor `DrawerFormLayout` renders a close icon — both rely on the caller passing `closable: true` at the `viewer.dialog` / `viewer.drawer` call site to surface antd Modal's native top-right X (Dialog) or antd Drawer's native left-side X (Drawer).
30
+ *
31
+ * Callers own the `<Form>` instance, validation, and the actual API call. This component only handles the chrome and close behaviour.
32
+ *
33
+ * Example:
34
+ *
35
+ * ```tsx
36
+ * ctx.viewer.dialog({
37
+ * closable: true, // native top-right X
38
+ * content: () => (
39
+ * <DialogFormLayout
40
+ * title={t('Bind verifier')}
41
+ * onSubmit={handleSubmit}
42
+ * submitting={submitting}
43
+ * submitText={t('Bind')}
44
+ * >
45
+ * <Form form={form} layout="vertical">...</Form>
46
+ * </DialogFormLayout>
47
+ * ),
48
+ * });
49
+ * ```
50
+ */
51
+ export declare function DialogFormLayout(props: DialogFormLayoutProps): React.JSX.Element;
@@ -8,15 +8,10 @@
8
8
  */
9
9
  import React from 'react';
10
10
  export interface DrawerFormLayoutProps {
11
- /** Header title rendered next to the close (X) button. */
11
+ /** Header title rendered next to antd Drawer's native close (X) icon. */
12
12
  title: React.ReactNode;
13
13
  /** Form body — typically a `<Form>` wrapping `<Form.Item>` fields. */
14
14
  children: React.ReactNode;
15
- /**
16
- * Called before the drawer is closed by either the Cancel button or the
17
- * header's X icon. Use for "discard changes" confirmations.
18
- */
19
- onCancel?: () => void | Promise<void>;
20
15
  /**
21
16
  * Called when the Submit button is clicked. Caller owns validation + the
22
17
  * actual API call; the drawer is closed automatically when `onSubmit`
@@ -38,12 +33,17 @@ export interface DrawerFormLayoutProps {
38
33
  footer?: React.ReactNode;
39
34
  }
40
35
  /**
41
- * Standard layout for drawer-hosted forms: a close-icon + title header on
42
- * top, the caller-provided form body in the middle, and a Cancel + Submit
43
- * footer at the bottom. Wraps `useFlowView()`'s `Header` / `Footer` slots
44
- * so the drawer chrome stays consistent across plugins.
36
+ * Standard layout for drawer-hosted forms: a title-only header on top
37
+ * (caller must open the drawer with `viewer.drawer({ closable: true })`
38
+ * so antd Drawer renders its native left-side X next to the title),
39
+ * the caller-provided form body in the middle, and a Cancel + Submit
40
+ * footer at the bottom. Wraps `useFlowView()`'s `Header` / `Footer`
41
+ * slots so the drawer chrome stays consistent across plugins.
42
+ *
43
+ * To intercept close (e.g. dirty-form confirmation), use the lower-level
44
+ * `viewer.drawer({ preventClose, beforeClose, ... })` hooks — this
45
+ * layout no longer wraps a custom close handler.
45
46
  *
46
47
  * Callers own the `<Form>` instance, validation, and the actual API call.
47
- * This component only handles the chrome and the close behaviour.
48
48
  */
49
49
  export declare function DrawerFormLayout(props: DrawerFormLayoutProps): React.JSX.Element;
@@ -0,0 +1,40 @@
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
+ import type { PasswordProps as AntdPasswordProps } from 'antd/es/input';
10
+ import React from 'react';
11
+ export interface PasswordInputProps extends AntdPasswordProps {
12
+ /**
13
+ * Render a visual strength bar beneath the input. Defaults to `false`. The
14
+ * score is computed locally — opting in does NOT add any form validation;
15
+ * use a separate `Form.Item.rules` entry for that (or wire the entry up to
16
+ * a cross-plugin password-validator extension point if your project
17
+ * provides one).
18
+ */
19
+ checkStrength?: boolean;
20
+ }
21
+ /**
22
+ * `Input.Password` plus an optional strength meter, ported from the v1
23
+ * `Password` component. The strength scoring and bar UI are identical to v1,
24
+ * so users who switch from a v1 page to a v2 page see the same visual signal.
25
+ *
26
+ * The component is value-shape compatible with antd `Input.Password` — drop
27
+ * it into any existing `Form.Item<password>` and toggle the meter with
28
+ * `checkStrength`.
29
+ *
30
+ * Caveats:
31
+ *
32
+ * - Strength scoring is purely a UX hint, not validation. Submitting a weak
33
+ * password is still allowed unless the server (or a separately installed
34
+ * password-policy plugin) rejects it.
35
+ * - The meter swallows the gap between `<Input.Password>` and the next form
36
+ * element. If your `Form.Item` already adds vertical rhythm, the meter
37
+ * inherits it; no extra spacing is added.
38
+ */
39
+ export declare function PasswordInput(props: PasswordInputProps): React.JSX.Element;
40
+ export default PasswordInput;
@@ -0,0 +1,79 @@
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
+ import { type SelectProps } from 'antd';
10
+ import React from 'react';
11
+ export interface RemoteSelectFieldNames {
12
+ label?: string;
13
+ value?: string;
14
+ }
15
+ export interface RemoteSelectProps<RawItem = any, Resp = RawItem[], V = any> extends Omit<SelectProps<V>, 'options' | 'loading'> {
16
+ /**
17
+ * Fetch the option source. Receives no arguments; caller closes over the
18
+ * `ctx.api.resource(...)` (or any other source) it needs. May resolve
19
+ * with either an array of raw items (the common case) or an arbitrary
20
+ * envelope object — in the latter case, supply `selectItems` to pluck
21
+ * the array out.
22
+ */
23
+ request: () => Promise<Resp | undefined>;
24
+ /**
25
+ * When `request` returns an envelope (object with metadata around the
26
+ * list), use this to extract the array of items that drives the
27
+ * dropdown. Defaults to identity, i.e. `request` itself returns the
28
+ * array.
29
+ */
30
+ selectItems?: (response: Resp) => RawItem[] | undefined;
31
+ /**
32
+ * Names of the raw item properties that hold the display label and the
33
+ * persisted value. Defaults to `{ label: 'label', value: 'value' }`.
34
+ * Ignored when `mapOptions` is supplied.
35
+ */
36
+ fieldNames?: RemoteSelectFieldNames;
37
+ /**
38
+ * Full custom mapping from a raw item to an antd `OptionType`. When
39
+ * provided, overrides `fieldNames`.
40
+ */
41
+ mapOptions?: (item: RawItem, index: number) => {
42
+ label: React.ReactNode;
43
+ value: any;
44
+ };
45
+ /**
46
+ * Stable cache key for ahooks `useRequest` so the dropdown doesn't re-fetch
47
+ * on every re-mount. Pass a value tied to the request's effective inputs.
48
+ */
49
+ cacheKey?: string;
50
+ /**
51
+ * Re-run the request when any of these values changes. Forwarded to
52
+ * `useRequest`'s `refreshDeps`.
53
+ */
54
+ refreshDeps?: unknown[];
55
+ /**
56
+ * Skip the auto-fetch on mount when `false`. Defaults to `true`.
57
+ */
58
+ ready?: boolean;
59
+ /**
60
+ * Notified once the request resolves. Receives both the mapped item
61
+ * array and the raw response envelope — useful when callers need to
62
+ * read sibling metadata (counts, availability hints, etc.) without
63
+ * issuing a second request.
64
+ */
65
+ onLoaded?: (items: RawItem[], response: Resp) => void;
66
+ }
67
+ /**
68
+ * Generic settings-page Select bound to an async option source. The
69
+ * component itself stays framework-agnostic — it knows nothing about
70
+ * NocoBase resources, data sources, or Formily. Pass any async `request`
71
+ * that resolves with an array, and supply `fieldNames` (or `mapOptions`)
72
+ * to map raw items to antd option shape.
73
+ *
74
+ * Search is local-only (antd's default `optionFilterProp="label"`). For
75
+ * server-side search, drive `request` from external state and pass the
76
+ * search input via `refreshDeps`.
77
+ */
78
+ export declare function RemoteSelect<RawItem = any, Resp = RawItem[], V = any>(props: RemoteSelectProps<RawItem, Resp, V>): React.JSX.Element;
79
+ export default RemoteSelect;
@@ -0,0 +1,41 @@
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
+ import type { Collection } from '@nocobase/flow-engine';
10
+ import { type ButtonProps, type PopoverProps } from 'antd';
11
+ import React, { FC } from 'react';
12
+ import { CompiledFilter } from './useFilterActionProps';
13
+ export interface CollectionFilterProps {
14
+ /** Collection whose fields drive the filter row's field picker. */
15
+ collection: Collection | undefined;
16
+ /** Called on Submit or Reset with the compiled NocoBase filter param (`undefined` when cleared). */
17
+ onChange: (filter: CompiledFilter) => void;
18
+ /** Translator. Defaults to identity. */
19
+ t?: (key: string, options?: Record<string, any>) => string;
20
+ /** Whitelist of root-level field names to expose. */
21
+ filterableFieldNames?: string[];
22
+ /** Bypass the `filterableFieldNames` whitelist. */
23
+ noIgnore?: boolean;
24
+ /** Override the trigger button's label. Defaults to `t('Filter')`, or the v1-style `t('{{count}} filter items', { count })` when conditions are present. */
25
+ buttonText?: React.ReactNode;
26
+ /** Swap the default `t('Filter')` label for v1's `t('{{count}} filter items', { count })` when conditions are present. Defaults to `true`. */
27
+ showCount?: boolean;
28
+ /** Pass-through props for the antd `<Popover>`. */
29
+ popoverProps?: Omit<PopoverProps, 'open' | 'onOpenChange' | 'content' | 'children'>;
30
+ /** Pass-through props for the trigger `<Button>`. */
31
+ buttonProps?: Omit<ButtonProps, 'icon' | 'type' | 'children' | 'onClick'>;
32
+ /** Min-width applied to the popover body. Defaults to `520`. */
33
+ popoverMinWidth?: number;
34
+ }
35
+ /**
36
+ * Filter button bound to a collection. Renders an antd `<Popover>` over a `<Button>`; the popover hosts a multi-condition filter form (field picker, operator, value). Submit dismisses the popover and emits the compiled filter via `onChange`; Reset keeps the popover open and emits `undefined`.
37
+ *
38
+ * Pair with `<ExtendCollectionsProvider>` when the target collection is client-only (e.g. a `schema-only` server collection that isn't auto-published to the v2 data source).
39
+ */
40
+ export declare const CollectionFilter: FC<CollectionFilterProps>;
41
+ export default CollectionFilter;
@@ -0,0 +1,41 @@
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
+ import { Collection } from '@nocobase/flow-engine';
10
+ import React, { FC } from 'react';
11
+ export interface CollectionFilterItemValue {
12
+ path: string;
13
+ operator: string;
14
+ /** Operator-dependent — string for default ops, descriptor for $date*, etc. */
15
+ value: any;
16
+ }
17
+ export interface CollectionFilterItemProps {
18
+ /** Reactive filter row managed by the parent `FilterContainer`. */
19
+ value: CollectionFilterItemValue;
20
+ /** Target collection whose fields populate the field selector. */
21
+ collection: Collection;
22
+ /** Whitelist of field names to expose; empty/undefined means all filterable fields. */
23
+ filterableFieldNames?: string[];
24
+ /** Bypass the `filterableFieldNames` whitelist (matches the legacy FilterItem `noIgnore`). */
25
+ noIgnore?: boolean;
26
+ /** Translator; defaults to identity so callers can omit it. */
27
+ t?: (key: string) => string;
28
+ }
29
+ /**
30
+ * Filter row bound directly to a `Collection`, with no `FlowModel` dependency. Use this from settings pages or other surfaces that need a filter UI but don't have (and shouldn't synthesise) a block model just to satisfy `FilterItem`. Pair with `FilterContainer` via either an inline wrapper or `createCollectionFilterItem(collection)`.
31
+ *
32
+ * The field selector is an antd `Cascader`, mirroring v1's `Filter.Action` so association fields (belongsTo / m2o / etc.) can be drilled into — picking `user.username` is a first-class action. The value renderer is delegated to `FilterValueInput`, which dispatches to interface-specific controls (the smart date picker for `$date*` operators, tag-mode Select for array/enum, etc.) the same way v1's `DynamicComponent` did.
33
+ */
34
+ export declare const CollectionFilterItem: FC<CollectionFilterItemProps>;
35
+ /**
36
+ * Convenience factory returning a `FilterContainer`-compatible `FilterItem` component bound to a specific collection. Avoids creating an inline closure on every parent render, which would otherwise reset any focused inner antd control.
37
+ */
38
+ export declare function createCollectionFilterItem(collection: Collection, bound?: Pick<CollectionFilterItemProps, 'filterableFieldNames' | 'noIgnore' | 't'>): React.FC<{
39
+ value: CollectionFilterItemValue;
40
+ }>;
41
+ export default CollectionFilterItem;
@@ -0,0 +1,57 @@
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
+ import { type Dayjs } from 'dayjs';
10
+ import React from 'react';
11
+ /**
12
+ * Value shape used by NocoBase's `$date*` filter operators. Two flavours:
13
+ *
14
+ * - For "Exact day" mode: a **formatted string** at the granularity of the picker — `"2026-02-15"` (date), `"2026-02"` (month), `"2026"` (year), `"2026-Q1"` (quarter). For `$dateBetween` (`isRange`), a `[string, string]` tuple. Strings (not Dayjs) so the value serializes verbatim into the query string the same way v1 does (`filter=%7B%22$and%22:[%7B%22lockedTs%22:%7B%22$dateOn%22:%222026-02%22%7D%7D]%7D`).
15
+ * - For relative modes (Today / Past 3 days / This Week / …): a `{ type, number?, unit? }` descriptor that the server resolves to a concrete range at query time.
16
+ */
17
+ export type DateFilterValue = string | [string, string] | {
18
+ type: string;
19
+ number?: number;
20
+ unit?: 'day' | 'week' | 'month' | 'year';
21
+ } | null | undefined;
22
+ export interface DateFilterDynamicComponentProps {
23
+ value?: DateFilterValue;
24
+ onChange?: (value: DateFilterValue) => void;
25
+ /** `true` for `$dateBetween`; renders a `DatePicker.RangePicker`. */
26
+ isRange?: boolean;
27
+ /**
28
+ * Translator. Defaults to identity so callers can omit it when running outside a translation context (tests, storybook).
29
+ */
30
+ t?: (key: string) => string;
31
+ }
32
+ type PickerMode = 'date' | 'month' | 'quarter' | 'year';
33
+ /**
34
+ * The exact format strings NocoBase's `$date*` server operators expect per picker granularity. Mirrors v1's `getPickerFormat` output under `underFilter=true`, so the URL-encoded query stays identical.
35
+ *
36
+ * Exported for unit tests and for downstream callers that need to parse / format `$date*` values outside this component.
37
+ */
38
+ export declare const FORMAT_BY_PICKER: Record<PickerMode, string>;
39
+ /**
40
+ * Parse a granularity-formatted string back into a `Dayjs`. Returns `null` on missing or unparseable input so the DatePicker's controlled-value contract stays clean.
41
+ */
42
+ export declare const parseDateFilterValue: (value: string | undefined, picker: PickerMode) => Dayjs | null;
43
+ /**
44
+ * Format a `Dayjs` (typically from `DatePicker.onChange`) into the server-facing string at the active picker's granularity. Returns `undefined` for empty input so callers can drop the value entirely.
45
+ */
46
+ export declare const formatDateFilterValue: (value: Dayjs | null | undefined, picker: PickerMode) => string | undefined;
47
+ /**
48
+ * v2 port of v1's `DateFilterDynamicComponent` — a multi-mode value input for the `$date*` operator family. Three sub-controls glued in a `Space.Compact` row:
49
+ *
50
+ * 1. Mode select — `Exact day` / `Past` / `Next` / `Today` / `This Week` / … Picking a relative mode emits a `{ type, number?, unit? }` descriptor that the server resolves at query time; picking `Exact day` emits a raw `Dayjs` instead.
51
+ * 2. Picker granularity — only when mode is `Exact day`: `Date` / `Month` / `Quarter` / `Year`. Controls the antd `DatePicker`'s `picker` mode so admins can filter to e.g. "any day in 2026-03".
52
+ * 3. Date input — antd `DatePicker` for single dates, or `DatePicker.RangePicker` when `isRange` is true (used by `$dateBetween`).
53
+ *
54
+ * v1 wired its own `<DatePicker.FilterWithPicker>` for the third slot; v2 inlines the picker-granularity selector here so we don't have to fork antd's DatePicker. Drops v1's `@emotion/css` (uses antd token spacing) and the `useCompile` schema-template chain (call sites pass a plain `t` translator).
55
+ */
56
+ export declare const DateFilterDynamicComponent: React.FC<DateFilterDynamicComponentProps>;
57
+ export default DateFilterDynamicComponent;
@@ -0,0 +1,29 @@
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
+ import React from 'react';
10
+ import type { FilterOperator, FilterOption } from '../../../flow/components/filter/useFilterOptions';
11
+ export interface FilterValueInputProps {
12
+ /** The currently selected leaf field option from the field picker. */
13
+ field?: FilterOption;
14
+ /** The currently selected operator (full object, not just `.value`). */
15
+ operator?: FilterOperator;
16
+ /** Current value. Shape depends on operator/field. */
17
+ value: any;
18
+ /** Notify the parent when the user edits the value. */
19
+ onChange: (value: any) => void;
20
+ /** Translator used by sub-renderers. */
21
+ t?: (key: string) => string;
22
+ /** Optional placeholder for the fallback `Input`. */
23
+ placeholder?: string;
24
+ }
25
+ /**
26
+ * Interface-aware value renderer for filter rows. Returns `null` for `noValue` operators (`$empty`, `$notEmpty`). Otherwise dispatches the effective `x-component` (operator schema > field uiSchema > Input) to a small registry of antd controls.
27
+ */
28
+ export declare const FilterValueInput: React.FC<FilterValueInputProps>;
29
+ export default FilterValueInput;
@@ -0,0 +1,11 @@
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
+ export { CollectionFilter } from './CollectionFilter';
10
+ export type { CollectionFilterProps } from './CollectionFilter';
11
+ export type { CompiledFilter } from './useFilterActionProps';
@@ -0,0 +1,96 @@
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
+ import { Collection } from '@nocobase/flow-engine';
10
+ import { FilterOption, UseFilterOptionsArgs } from '../../../flow/components/filter/useFilterOptions';
11
+ import { CollectionFilterItemValue, createCollectionFilterItem } from './CollectionFilterItem';
12
+ /** A single condition row (`{ path, operator, value }`) or a nested group. */
13
+ export type FilterGroupItem = CollectionFilterItemValue | FilterGroupValue;
14
+ /**
15
+ * Reactive shape consumed by `FilterContainer` / `FilterGroup`. `logic` is the join (`$and` / `$or`) and `items` is a heterogeneous list of leaf conditions and nested groups.
16
+ */
17
+ export type FilterGroupValue = {
18
+ logic: '$and' | '$or';
19
+ items: FilterGroupItem[];
20
+ };
21
+ /** Compiled filter param accepted by NocoBase resource `list`. */
22
+ export type CompiledFilter = Record<string, unknown> | undefined;
23
+ interface FilterCtxModel {
24
+ translate: (key: string) => string;
25
+ dispatchEvent: (event: 'submit' | 'reset' | (string & {})) => void;
26
+ }
27
+ export interface FilterCtx {
28
+ model: FilterCtxModel;
29
+ }
30
+ /**
31
+ * Compile a reactive filter group into the `{ $and: [{ path: { op: val } }] }` envelope accepted by NocoBase's resource `list` filter param. Returns `undefined` when the group is empty so callers can drop the param.
32
+ *
33
+ * Mirrors v1's `removeNullCondition` + filter compile path, but works on the v2 `{ logic, items }` group structure rather than v1's Formily-bracketed `$and.0.path.$eq` shape:
34
+ *
35
+ * - Rows missing `path` or `operator` are dropped (still mid-edit).
36
+ * - Rows whose `value` is empty (`undefined`, `''`, `[]`, `{}`) are dropped — matches v1, which sends `filter={}` for a row with only a field/operator picked. Sending `{lockedTs:{}}` would 500.
37
+ * - Dotted association paths (`user.createdBy.password`) are expanded into nested objects — matches v1's payload shape, which the server resolves along the association chain rather than treating the dotted string as a single key.
38
+ * - Empty groups (after pruning) propagate as `undefined` so the outermost caller can drop the whole `filter` param.
39
+ */
40
+ export declare function compileFilterGroup(group: FilterGroupValue | undefined): CompiledFilter;
41
+ /** Which footer button triggered the apply — useful for closing a popover on Submit but keeping it open on Reset. */
42
+ export type FilterApplyAction = 'submit' | 'reset';
43
+ export interface UseFilterActionPropsArgs extends UseFilterOptionsArgs {
44
+ /** Collection whose fields populate the filter row's field picker. */
45
+ collection: Collection | undefined;
46
+ /**
47
+ * 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(); }`.
48
+ */
49
+ onApply: (filter: CompiledFilter, action: FilterApplyAction) => void;
50
+ }
51
+ export interface UseFilterActionPropsResult {
52
+ /**
53
+ * Reactive filter group state. Pass directly to `<FilterContent value={...}>`. Stable across renders.
54
+ */
55
+ value: FilterGroupValue;
56
+ /** Field-option tree (for inspection or custom badges). */
57
+ options: FilterOption[];
58
+ /** Bound `FilterItem` component to plug into `<FilterContent FilterItem={...}>`. */
59
+ FilterItem: ReturnType<typeof createCollectionFilterItem> | undefined;
60
+ /**
61
+ * Ready-to-use `ctx` for `<FilterContent ctx={...}>`. Wires Submit / Reset buttons to `onSubmit` / `onReset` below.
62
+ */
63
+ ctx: FilterCtx;
64
+ /** Imperative trigger — submit current group as a compiled filter. */
65
+ onSubmit: () => void;
66
+ /** Imperative trigger — clear the group and emit an empty filter. */
67
+ onReset: () => void;
68
+ /**
69
+ * Count of top-level condition rows. Useful for showing a badge like `Filter (3)` on the trigger button — matches v1's `field.title = t('{{count}} filter items', { count })`.
70
+ */
71
+ conditionCount: number;
72
+ }
73
+ /**
74
+ * v2 equivalent of v1's `useFilterActionProps` for non-schema surfaces (settings pages, panels, side drawers). Bundles three things v1's hook returned implicitly through schema:
75
+ *
76
+ * - A reactive `{ logic, items }` group state that `<FilterContent>` reads.
77
+ * - A bound `FilterItem` component (driven by `createCollectionFilterItem`).
78
+ * - A `ctx` object that turns `<FilterContent>`'s `dispatchEvent('submit' | 'reset')` into a compiled filter param passed to `onApply`.
79
+ *
80
+ * Pair with antd `Popover` to recreate the legacy `Filter.Action` UX:
81
+ *
82
+ * ```tsx
83
+ * const { value, ctx, FilterItem, onSubmit, conditionCount } = useFilterActionProps({
84
+ * collection,
85
+ * onApply: (filter) => listRequest.run(filter),
86
+ * t,
87
+ * });
88
+ * return (
89
+ * <Popover content={<FilterContent value={value} ctx={ctx} FilterItem={FilterItem} />}>
90
+ * <Button>{t('Filter')}{conditionCount ? ` (${conditionCount})` : ''}</Button>
91
+ * </Popover>
92
+ * );
93
+ * ```
94
+ */
95
+ export declare function useFilterActionProps(args: UseFilterActionPropsArgs): UseFilterActionPropsResult;
96
+ export {};
@@ -7,8 +7,12 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  export * from './createFormRegistry';
10
+ export * from './filter';
11
+ export * from './DialogFormLayout';
10
12
  export * from './DrawerFormLayout';
11
13
  export * from './EnvVariableInput';
12
14
  export * from './FileSizeInput';
13
15
  export * from './JsonTextArea';
16
+ export * from './PasswordInput';
17
+ export * from './RemoteSelect';
14
18
  export * from './VariableInput';
@@ -6,6 +6,16 @@
6
6
  * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
+ /**
10
+ * Restore horizontal scrolling on `.ant-table-content` so wide tables in
11
+ * narrow containers (drawer / settings panel) scroll their inner `<table>`
12
+ * instead of getting clipped or forcing the outer container to grow.
13
+ *
14
+ * `width: max-content` on the inner `<table>` lets columns size to their
15
+ * natural width; `min-width: 100%` keeps the table filling the viewport
16
+ * when total column width is smaller than the container.
17
+ */
18
+ export declare const tableScrollClassName: string;
9
19
  /**
10
20
  * Reserve a `SORT_HANDLE_GUTTER`-wide gap on the left of the rowSelection
11
21
  * column so the handle's `left:0` lands inside a `position:relative` cell.
@@ -11,5 +11,7 @@ export * from './BlankComponent';
11
11
  export * from './form/table/dnd';
12
12
  export * from './form';
13
13
  export * from './Icon';
14
+ export * from './PoweredBy';
14
15
  export * from './RouterContextCleaner';
16
+ export * from './SwitchLanguage';
15
17
  export * from './form/table';
@@ -0,0 +1,24 @@
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
+ import type { CollectionOptions } from '@nocobase/flow-engine';
10
+ import { FC, ReactNode } from 'react';
11
+ export interface ExtendCollectionsProviderProps {
12
+ /** Data source key to extend. Defaults to `'main'`. */
13
+ dataSource?: string;
14
+ /** Collections to surface for the lifetime of this provider's subtree. */
15
+ collections: CollectionOptions[];
16
+ children?: ReactNode;
17
+ }
18
+ /**
19
+ * Mount-scoped collection injector. Adds the given `collections` to the target data source on mount and removes them on unmount. Survives mid-session reloads via `dataSource:loaded` events.
20
+ *
21
+ * Use this for client-only collections — e.g. a `schema-only` server collection that isn't auto-published to the v2 data source, or a pure UI-side mirror — so downstream components (like `<CollectionFilter>`) can resolve the collection by name.
22
+ */
23
+ export declare const ExtendCollectionsProvider: FC<ExtendCollectionsProviderProps>;
24
+ export default ExtendCollectionsProvider;
@@ -0,0 +1,9 @@
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
+ export * from './ExtendCollectionsProvider';
@@ -14,3 +14,5 @@ export { VariableFilterItem } from './VariableFilterItem';
14
14
  export type { VariableFilterItemProps, VariableFilterItemValue } from './VariableFilterItem';
15
15
  export { LinkageFilterItem } from './LinkageFilterItem';
16
16
  export type { LinkageFilterItemProps, LinkageFilterItemValue } from './LinkageFilterItem';
17
+ export { useFilterOptions } from './useFilterOptions';
18
+ export type { FilterOption, UseFilterOptionsArgs } from './useFilterOptions';