@nocobase/client-v2 3.0.0-alpha.7 → 3.0.0-alpha.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 (40) hide show
  1. package/es/flow/actions/linkageRules.d.ts +24 -0
  2. package/es/flow/components/FieldAssignValueInput.d.ts +4 -30
  3. package/es/flow/components/field-value-variable/DateVariableEditor.d.ts +24 -0
  4. package/es/flow/components/field-value-variable/FieldValueVariableInput.d.ts +31 -0
  5. package/es/flow/components/field-value-variable/dateValue.d.ts +36 -0
  6. package/es/flow/components/field-value-variable/index.d.ts +11 -0
  7. package/es/flow/models/blocks/form/FormBlockModel.d.ts +7 -0
  8. package/es/flow/models/blocks/form/FormGridModel.d.ts +6 -0
  9. package/es/flow/models/blocks/form/value-runtime/rules.d.ts +1 -0
  10. package/es/index.mjs +125 -134
  11. package/lib/index.js +119 -128
  12. package/package.json +7 -7
  13. package/src/__tests__/app.test.tsx +15 -6
  14. package/src/__tests__/settings-center.test.tsx +222 -21
  15. package/src/components/AppComponents.tsx +4 -4
  16. package/src/flow/actions/__tests__/linkageRules.actionStates.test.ts +33 -0
  17. package/src/flow/actions/linkageRules.tsx +25 -7
  18. package/src/flow/components/FieldAssignValueInput.tsx +38 -621
  19. package/src/flow/components/field-value-variable/DateVariableEditor.tsx +181 -0
  20. package/src/flow/components/field-value-variable/FieldValueVariableInput.tsx +326 -0
  21. package/src/flow/components/field-value-variable/__tests__/FieldValueVariableInput.test.tsx +380 -0
  22. package/src/flow/components/field-value-variable/dateValue.ts +223 -0
  23. package/src/flow/components/field-value-variable/index.ts +12 -0
  24. package/src/flow/models/blocks/assign-form/AssignFormItemModel.tsx +28 -53
  25. package/src/flow/models/blocks/form/FormBlockModel.tsx +47 -0
  26. package/src/flow/models/blocks/form/FormGridModel.tsx +4 -0
  27. package/src/flow/models/blocks/form/__tests__/runJsFormSubmit.test.ts +131 -0
  28. package/src/flow/models/blocks/form/value-runtime/__tests__/runtime.test.ts +435 -0
  29. package/src/flow/models/blocks/form/value-runtime/rules.ts +67 -14
  30. package/src/flow/models/blocks/form/value-runtime/runtime.ts +43 -19
  31. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/PopupSubTableFieldModel.tsx +8 -0
  32. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/__tests__/popupContext.test.ts +120 -0
  33. package/src/flow/models/fields/AssociationFieldModel/PopupSubTableFieldModel/actions/PopupSubTableEditActionModel.tsx +10 -2
  34. package/src/flow/models/fields/DisplayNumberFieldModel.tsx +1 -1
  35. package/src/flow/models/fields/NumberFieldModel.tsx +1 -1
  36. package/src/flow/models/fields/__tests__/DisplayNumberFieldModel.test.ts +33 -0
  37. package/src/flow/models/fields/__tests__/NumberFieldModel.test.tsx +47 -0
  38. package/src/flow/models/fields/mobile-components/MobileLazySelect.tsx +1 -0
  39. package/src/flow/models/fields/mobile-components/__tests__/MobileSelect.test.tsx +20 -2
  40. package/src/settings-center/AdminSettingsLayout.tsx +38 -3
@@ -9,6 +9,29 @@
9
9
  import { FlowContext, FlowModel } from '@nocobase/flow-engine';
10
10
  export declare function updateLinkageRules<T>(rules: T[], updater: (nextRules: T[]) => void): T[];
11
11
  export declare const linkageSetBlockProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
12
+ declare const ACTION_LINKAGE_STATE_OPTIONS: readonly [{
13
+ readonly label: "Visible";
14
+ readonly value: "visible";
15
+ }, {
16
+ readonly label: "Hidden";
17
+ readonly value: "hidden";
18
+ }, {
19
+ readonly label: "Hidden text";
20
+ readonly value: "hiddenText";
21
+ }, {
22
+ readonly label: "Enabled";
23
+ readonly value: "enabled";
24
+ }, {
25
+ readonly label: "Disabled";
26
+ readonly value: "disabled";
27
+ }];
28
+ type ActionLinkageState = (typeof ACTION_LINKAGE_STATE_OPTIONS)[number]['value'];
29
+ export declare function getActionLinkageStateOptions(model: {
30
+ supportedActionLinkageStates?: readonly ActionLinkageState[];
31
+ }, t: (key: string) => string): {
32
+ label: string;
33
+ value: "hidden" | "visible" | "disabled" | "enabled" | "hiddenText";
34
+ }[];
12
35
  export declare const linkageSetActionProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
13
36
  export declare const linkageSetMenuItemProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
14
37
  export declare const linkageSetTabProps: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
@@ -26,3 +49,4 @@ export declare const tabLinkageRules: import("@nocobase/flow-engine").ActionDefi
26
49
  export declare const fieldLinkageRules: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
27
50
  export declare const subFormFieldLinkageRules: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
28
51
  export declare const detailsFieldLinkageRules: import("@nocobase/flow-engine").ActionDefinition<FlowModel<import("@nocobase/flow-engine").DefaultStructure>, FlowContext>;
52
+ export {};
@@ -7,32 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- import { dayjs } from '@nocobase/utils/client';
11
- import { type CollectionField, type MetaTreeNode } from '@nocobase/flow-engine';
12
- import { type ExactDatePickerMode } from './FieldAssignExactDatePicker';
13
- type VariableInputConverters = {
14
- renderInputComponent?: (metaTreeNode: MetaTreeNode | null) => React.ComponentType<any> | null;
15
- resolvePathFromValue?: (value: any) => string[] | undefined;
16
- resolveValueFromPath?: (metaTreeNode: MetaTreeNode) => any;
17
- };
18
- export type DateVariableExactNormalizeMode = 'none' | 'date' | 'datetimeNoTz' | 'iso';
19
- export declare function toExactPickerDisplayValue(rawValue: unknown, options: {
20
- format: string;
21
- isRange: boolean;
22
- }): dayjs.Dayjs | [dayjs.Dayjs, dayjs.Dayjs] | null;
23
- export declare function normalizeDateVariableExactValue(rawValue: any, options: {
24
- exactNormalizeMode: DateVariableExactNormalizeMode;
25
- format: string;
26
- showTime: boolean;
27
- }): any;
28
- type DateVariableComponentProps = {
29
- picker: ExactDatePickerMode;
30
- showTime: boolean;
31
- timeFormat: string;
32
- format: string;
33
- exactNormalizeMode: DateVariableExactNormalizeMode;
34
- };
35
- export declare function normalizeDateVariableOutput(rawValue: any, options: DateVariableComponentProps): any;
10
+ import { type CollectionField, type MetaTreeNode, type VariableInputProps } from '@nocobase/flow-engine';
11
+ export { normalizeDateVariableExactValue, normalizeDateVariableOutput, toExactPickerDisplayValue, type DateVariableExactNormalizeMode, } from './field-value-variable';
36
12
  interface Props {
37
13
  /** 赋值目标路径,例如 `title` / `users.nickname` / `user.name` */
38
14
  targetPath: string;
@@ -53,15 +29,14 @@ interface Props {
53
29
  value?: string;
54
30
  };
55
31
  /**
56
- * 在日期字段场景下,用日期变量编辑器替换 Constant 位。
57
- * 默认 false,保持历史行为。
32
+ * @deprecated Date 已作为独立一级变量提供,此参数仅为调用兼容保留。
58
33
  */
59
34
  enableDateVariableAsConstant?: boolean;
60
35
  /** 是否允许在变量选择器中使用 RunJS。默认 true,保持历史行为。 */
61
36
  allowRunJS?: boolean;
62
37
  maxAssociationFieldDepth?: number;
63
38
  disabled?: boolean;
64
- variableConverters?: VariableInputConverters;
39
+ variableConverters?: VariableInputProps['converters'];
65
40
  }
66
41
  export declare function mergeItemMetaTreeForAssignValue(baseTree: MetaTreeNode[], extraTree: MetaTreeNode[]): MetaTreeNode[];
67
42
  export declare function resolveAssignValueFieldPath(itemModel: any): string | undefined;
@@ -95,4 +70,3 @@ export declare function resolveAssignValueFieldModelConfig(options: {
95
70
  * - 支持变量引用,并提供 Constant / Null 两种快捷项
96
71
  */
97
72
  export declare const FieldAssignValueInput: React.FC<Props>;
98
- export {};
@@ -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 CtxDateExpressionConfig } from '@nocobase/flow-engine';
10
+ import React from 'react';
11
+ import { type ExactDatePickerValue } from '../FieldAssignExactDatePicker';
12
+ import { type DateVariableComponentProps } from './dateValue';
13
+ export declare function getDefaultDateVariableFormat(config: CtxDateExpressionConfig): string;
14
+ export declare function serializeExactDatePickerValue(value: ExactDatePickerValue, showTime: boolean): string | [string, string];
15
+ type DateVariableEditorProps = {
16
+ value?: CtxDateExpressionConfig;
17
+ onChange?: (value: CtxDateExpressionConfig) => void;
18
+ isDateLikeField: boolean;
19
+ dateComponentProps: DateVariableComponentProps;
20
+ style?: React.CSSProperties;
21
+ disabled?: boolean;
22
+ };
23
+ export declare const DateVariableEditor: React.FC<DateVariableEditorProps>;
24
+ export {};
@@ -0,0 +1,31 @@
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 MetaTreeNode, type VariableInputProps } from '@nocobase/flow-engine';
10
+ import React from 'react';
11
+ import { type DateVariableComponentProps } from './dateValue';
12
+ type ValueEditorComponent = React.ComponentType<{
13
+ value?: unknown;
14
+ onChange?: (value: unknown) => void;
15
+ style?: React.CSSProperties;
16
+ disabled?: boolean;
17
+ }>;
18
+ export type FieldValueVariableInputProps = Omit<VariableInputProps, 'value' | 'onChange' | 'metaTree' | 'converters'> & {
19
+ value?: unknown;
20
+ onChange: (value: unknown) => void;
21
+ baseMetaTree: MetaTreeNode[] | (() => MetaTreeNode[] | Promise<MetaTreeNode[]>);
22
+ constantComponent: ValueEditorComponent;
23
+ nullComponent: ValueEditorComponent;
24
+ runJSComponent: ValueEditorComponent;
25
+ isDateLikeField: boolean;
26
+ dateComponentProps: DateVariableComponentProps;
27
+ allowRunJS?: boolean;
28
+ converters?: VariableInputProps['converters'];
29
+ };
30
+ export declare const FieldValueVariableInput: React.FC<FieldValueVariableInputProps>;
31
+ export {};
@@ -0,0 +1,36 @@
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 { dayjs } from '@nocobase/utils/client';
10
+ import type { ExactDatePickerMode } from '../FieldAssignExactDatePicker';
11
+ type DateFieldLike = {
12
+ interface?: unknown;
13
+ type?: unknown;
14
+ getComponentProps?: () => unknown;
15
+ uiSchema?: Record<string, unknown>;
16
+ };
17
+ export type DateVariableExactNormalizeMode = 'none' | 'date' | 'datetimeNoTz' | 'iso';
18
+ export type DateVariableComponentProps = {
19
+ picker: ExactDatePickerMode;
20
+ showTime: boolean;
21
+ timeFormat: string;
22
+ format: string;
23
+ exactNormalizeMode: DateVariableExactNormalizeMode;
24
+ };
25
+ export declare const DEFAULT_DATE_VARIABLE_COMPONENT_PROPS: DateVariableComponentProps;
26
+ export declare function getFieldInterface(field: DateFieldLike | null | undefined): string;
27
+ export declare function isDateLikeField(field: DateFieldLike | null | undefined, fallbackFieldName?: string, fallbackFieldInterface?: string): boolean;
28
+ export declare function resolveDateVariableComponentProps(field: DateFieldLike | null | undefined, fieldInterface?: string): DateVariableComponentProps;
29
+ export declare function normalizeDateVariableExactValue(rawValue: unknown, options: Pick<DateVariableComponentProps, 'format' | 'showTime' | 'exactNormalizeMode'>): unknown;
30
+ export declare function toExactPickerDisplayValue(rawValue: unknown, options: {
31
+ format: string;
32
+ isRange: boolean;
33
+ }): dayjs.Dayjs | [dayjs.Dayjs, dayjs.Dayjs] | null;
34
+ /** Compatibility helper retained for existing callers and tests. */
35
+ export declare function normalizeDateVariableOutput(rawValue: unknown, options: DateVariableComponentProps): unknown;
36
+ export {};
@@ -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 * from './dateValue';
10
+ export * from './DateVariableEditor';
11
+ export * from './FieldValueVariableInput';
@@ -24,8 +24,15 @@ type DefaultCollectionBlockModelStructure = {
24
24
  type CustomFormBlockModelClassesEnum = {};
25
25
  export declare class FormBlockModel<T extends DefaultCollectionBlockModelStructure = DefaultCollectionBlockModelStructure> extends CollectionBlockModel<T> {
26
26
  formValueRuntime?: FormValueRuntime;
27
+ serialize(): {
28
+ variableContractType: {
29
+ type: string;
30
+ use: string;
31
+ };
32
+ };
27
33
  private userModifiedTopLevelFields;
28
34
  get form(): FormInstance<any>;
35
+ submitFromRunJs(): void;
29
36
  _defaultCustomModelClasses: {
30
37
  FormActionGroupModel: string;
31
38
  FormItemModel: string;
@@ -18,6 +18,12 @@ export type DefaultFormGridStructure = {
18
18
  };
19
19
  };
20
20
  export declare class FormGridModel<T extends DefaultFormGridStructure = DefaultFormGridStructure> extends GridModel<T> {
21
+ serialize(): {
22
+ variableContractType: {
23
+ type: string;
24
+ use: string;
25
+ };
26
+ };
21
27
  itemFallback: React.JSX.Element;
22
28
  itemSettingsMenuLevel: number;
23
29
  itemFlowSettings: {
@@ -16,6 +16,7 @@ type ObservableBinding = {
16
16
  };
17
17
  export type RuleEngineOptions = {
18
18
  getBlockModelUid: () => string;
19
+ getAssignRulesModelUid: () => string | undefined;
19
20
  getActionName: () => string | undefined;
20
21
  getBlockContext: () => any;
21
22
  getEngine: () => any;