@archbiz/core-v3 0.0.0-stage → 0.1.0

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 (41) hide show
  1. package/README.md +4 -2
  2. package/dist/components/ab-form.d.ts +177 -0
  3. package/dist/components/fragment.d.ts +6 -0
  4. package/dist/factory/context.d.ts +51 -0
  5. package/dist/factory/creator.d.ts +29 -0
  6. package/dist/factory/maker.d.ts +6 -0
  7. package/dist/factory/manager.d.ts +86 -0
  8. package/dist/factory/node.d.ts +34 -0
  9. package/dist/factory/parser.d.ts +28 -0
  10. package/dist/frame/api.d.ts +39 -0
  11. package/dist/frame/attrs.d.ts +6 -0
  12. package/dist/frame/data-driver.d.ts +6 -0
  13. package/dist/frame/fetch.d.ts +29 -0
  14. package/dist/frame/index.d.ts +17 -0
  15. package/dist/frame/language.d.ts +1 -0
  16. package/dist/frame/provider.d.ts +106 -0
  17. package/dist/frame/util.d.ts +54 -0
  18. package/dist/handler/context.d.ts +5 -0
  19. package/dist/handler/effect.d.ts +5 -0
  20. package/dist/handler/index.d.ts +41 -0
  21. package/dist/handler/inject.d.ts +5 -0
  22. package/dist/handler/input.d.ts +5 -0
  23. package/dist/handler/lifecycle.d.ts +5 -0
  24. package/dist/handler/loader.d.ts +5 -0
  25. package/dist/handler/page.d.ts +5 -0
  26. package/dist/handler/render.d.ts +5 -0
  27. package/dist/index.cjs +1 -0
  28. package/dist/index.d.ts +9 -0
  29. package/dist/index.min.js +1 -0
  30. package/dist/index.umd.js +1 -0
  31. package/dist/locales/en.d.ts +25 -0
  32. package/dist/locales/index.d.ts +13 -0
  33. package/dist/locales/zh-cn.d.ts +25 -0
  34. package/dist/parser/html.d.ts +25 -0
  35. package/dist/render/cache.d.ts +3 -0
  36. package/dist/render/index.d.ts +31 -0
  37. package/dist/render/render.d.ts +3 -0
  38. package/dist/rule/load-pending.d.ts +21 -0
  39. package/dist/rule/options.d.ts +7 -0
  40. package/package.json +36 -3
  41. package/types/ab-form/index.d.ts +1215 -0
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
- # Temporary Holding Version
1
+ # @archbiz/core-v3
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Shared runtime used by Archbiz environment adapters. This package contains no ready-to-use UI components; install an adapter such as `@archbiz/element-plus`, `@archbiz/vant`, or `@archbiz/uniapp` in an application.
4
+
5
+ Framework-independent component logic lives under `src`. The form creator and rule helpers are re-exported from the core package; its type declarations are available at `@archbiz/core-v3/ab-form/types`.
@@ -0,0 +1,177 @@
1
+ import { type Component, type ComponentInternalInstance, type Directive, type PropType, type VNodeChild } from 'vue';
2
+ interface AbFormOptions {
3
+ globalClass?: Record<string, {
4
+ content?: string;
5
+ style?: Record<string, string>;
6
+ }>;
7
+ style?: string;
8
+ [key: string]: unknown;
9
+ }
10
+ interface AbFormApi {
11
+ top: AbFormApi;
12
+ scope: AbFormApi;
13
+ bus: AbFormEventBus;
14
+ config: {
15
+ forceCoverValue?: boolean;
16
+ };
17
+ refresh(): void;
18
+ coverValue(value: Record<string, unknown>): void;
19
+ setValue(value: Record<string, unknown>): void;
20
+ clearValidateState(): void;
21
+ }
22
+ interface AbFormEventBus {
23
+ $emit(event: string, ...args: unknown[]): void;
24
+ $on(event: string, callback: (...args: unknown[]) => void): void;
25
+ $off(event: string, callback: (...args: unknown[]) => void): void;
26
+ }
27
+ interface AbFormRuntime {
28
+ bus: AbFormEventBus;
29
+ $handle: {
30
+ isBreakWatch(): boolean;
31
+ updateAppendData(): void;
32
+ reloadRule(rules: unknown[]): void;
33
+ };
34
+ api(): AbFormApi;
35
+ render(): VNodeChild;
36
+ mounted(): void;
37
+ unmount(): void;
38
+ updated(): void;
39
+ initOptions(): void;
40
+ init(): void;
41
+ }
42
+ interface AbFormConstructor {
43
+ new (vm: AbFormComponentInstance): AbFormRuntime;
44
+ isMobile?: boolean;
45
+ }
46
+ interface AbFormGroupInjection {
47
+ getSubForm(): AbFormApi | AbFormApi[] | null | undefined;
48
+ subForm(value?: AbFormApi | AbFormApi[]): void;
49
+ }
50
+ interface AbFormSetupState {
51
+ parent: AbFormComponentInstance | null;
52
+ fc: AbFormRuntime;
53
+ fapi: AbFormApi;
54
+ renderRule(): void;
55
+ }
56
+ type AbFormComponentInstance = ComponentInternalInstance & {
57
+ props: Record<string, unknown>;
58
+ setupState: AbFormSetupState;
59
+ emit(event: string, ...args: unknown[]): void;
60
+ };
61
+ export default function $AbForm(AbForm: AbFormConstructor, components: Record<string, Component>, directives: Record<string, Directive>): import("vue").DefineComponent<import("vue").ExtractPropTypes<{
62
+ rule: {
63
+ type: PropType<unknown[]>;
64
+ required: true;
65
+ default: () => unknown[];
66
+ };
67
+ option: {
68
+ type: PropType<AbFormOptions>;
69
+ default: () => AbFormOptions;
70
+ };
71
+ extendOption: BooleanConstructor;
72
+ driver: PropType<string | object>;
73
+ modelValue: PropType<Record<string, unknown> | undefined>;
74
+ idField: StringConstructor;
75
+ idFieldTable: StringConstructor;
76
+ disabled: {
77
+ type: BooleanConstructor;
78
+ default: undefined;
79
+ };
80
+ readonly: {
81
+ type: BooleanConstructor;
82
+ default: undefined;
83
+ };
84
+ preview: {
85
+ type: BooleanConstructor;
86
+ default: undefined;
87
+ };
88
+ index: PropType<string | number | undefined>;
89
+ api: PropType<AbFormApi>;
90
+ locale: PropType<string | object>;
91
+ t: PropType<(...args: unknown[]) => unknown>;
92
+ name: StringConstructor;
93
+ subForm: {
94
+ type: BooleanConstructor;
95
+ default: boolean;
96
+ };
97
+ inFor: BooleanConstructor;
98
+ }>, {
99
+ ctxInject: import("vue").Ref<{}, {}>;
100
+ destroyed: import("vue").Ref<boolean, boolean>;
101
+ isShow: import("vue").Ref<boolean, boolean>;
102
+ unique: import("vue").Ref<number, number>;
103
+ fc: import("vue").Raw<AbFormRuntime>;
104
+ parent: import("vue").Raw<AbFormComponentInstance> | null;
105
+ top: import("vue").Raw<AbFormComponentInstance>;
106
+ fapi: import("vue").Raw<AbFormApi>;
107
+ getGroupInject: () => AbFormGroupInjection | undefined;
108
+ refresh(): void;
109
+ renderRule(): void;
110
+ updateValue(value: Record<string, unknown>): void;
111
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, ("beforeUnmount" | "change" | "control" | "created" | "emit-event" | "mounted" | "reload" | "remove-field" | "remove-rule" | "repeat-field" | "reset" | "submit" | "sync" | "update" | "update:api" | "update:modelValue" | "validate-fail" | "validate-field-fail")[], "beforeUnmount" | "change" | "control" | "created" | "emit-event" | "mounted" | "reload" | "remove-field" | "remove-rule" | "repeat-field" | "reset" | "submit" | "sync" | "update" | "update:api" | "update:modelValue" | "validate-fail" | "validate-field-fail", import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
112
+ rule: {
113
+ type: PropType<unknown[]>;
114
+ required: true;
115
+ default: () => unknown[];
116
+ };
117
+ option: {
118
+ type: PropType<AbFormOptions>;
119
+ default: () => AbFormOptions;
120
+ };
121
+ extendOption: BooleanConstructor;
122
+ driver: PropType<string | object>;
123
+ modelValue: PropType<Record<string, unknown> | undefined>;
124
+ idField: StringConstructor;
125
+ idFieldTable: StringConstructor;
126
+ disabled: {
127
+ type: BooleanConstructor;
128
+ default: undefined;
129
+ };
130
+ readonly: {
131
+ type: BooleanConstructor;
132
+ default: undefined;
133
+ };
134
+ preview: {
135
+ type: BooleanConstructor;
136
+ default: undefined;
137
+ };
138
+ index: PropType<string | number | undefined>;
139
+ api: PropType<AbFormApi>;
140
+ locale: PropType<string | object>;
141
+ t: PropType<(...args: unknown[]) => unknown>;
142
+ name: StringConstructor;
143
+ subForm: {
144
+ type: BooleanConstructor;
145
+ default: boolean;
146
+ };
147
+ inFor: BooleanConstructor;
148
+ }>> & Readonly<{
149
+ onBeforeUnmount?: ((...args: any[]) => any) | undefined;
150
+ onChange?: ((...args: any[]) => any) | undefined;
151
+ onControl?: ((...args: any[]) => any) | undefined;
152
+ onCreated?: ((...args: any[]) => any) | undefined;
153
+ "onEmit-event"?: ((...args: any[]) => any) | undefined;
154
+ onMounted?: ((...args: any[]) => any) | undefined;
155
+ onReload?: ((...args: any[]) => any) | undefined;
156
+ "onRemove-field"?: ((...args: any[]) => any) | undefined;
157
+ "onRemove-rule"?: ((...args: any[]) => any) | undefined;
158
+ "onRepeat-field"?: ((...args: any[]) => any) | undefined;
159
+ onReset?: ((...args: any[]) => any) | undefined;
160
+ onSubmit?: ((...args: any[]) => any) | undefined;
161
+ onSync?: ((...args: any[]) => any) | undefined;
162
+ onUpdate?: ((...args: any[]) => any) | undefined;
163
+ "onUpdate:api"?: ((...args: any[]) => any) | undefined;
164
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
165
+ "onValidate-fail"?: ((...args: any[]) => any) | undefined;
166
+ "onValidate-field-fail"?: ((...args: any[]) => any) | undefined;
167
+ }>, {
168
+ rule: unknown[];
169
+ option: AbFormOptions;
170
+ extendOption: boolean;
171
+ disabled: boolean;
172
+ readonly: boolean;
173
+ preview: boolean;
174
+ subForm: boolean;
175
+ inFor: boolean;
176
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
177
+ export {};
@@ -0,0 +1,6 @@
1
+ declare const _default: import("vue").DefineComponent<{
2
+ vnode?: any;
3
+ }, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{
4
+ vnode?: any;
5
+ }> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
6
+ export default _default;
@@ -0,0 +1,51 @@
1
+ type RuntimeRecord = Record<string, any>;
2
+ type RuleData = RuntimeRecord & {
3
+ field?: string;
4
+ name?: string;
5
+ type?: string;
6
+ value?: unknown;
7
+ subRule?: unknown;
8
+ children?: unknown;
9
+ __origin__?: RuleData;
10
+ __fc__?: RuleContext;
11
+ };
12
+ type RuleHandle = RuntimeRecord & {
13
+ $render: RuntimeRecord;
14
+ api: RuntimeRecord;
15
+ vm: RuntimeRecord;
16
+ loadChildren(data: unknown, ctx: RuleContext): void;
17
+ updateChildren(ctx: RuleContext, value: unknown, oldValue: unknown): void;
18
+ getType(type?: string): string | undefined;
19
+ appendLink(ctx: RuleContext): void;
20
+ watchCtx(ctx: RuleContext): void;
21
+ noWatch(fn: () => unknown): void;
22
+ deferSyncValue(fn: () => unknown, sync?: boolean): void;
23
+ rmCtx(ctx: RuleContext): void;
24
+ refresh(): void;
25
+ };
26
+ type RuleContext = RuntimeRecord & {
27
+ id: string;
28
+ ref: string;
29
+ wrapRef: string;
30
+ getPending(key: string, def?: unknown): any;
31
+ setPending(key: string, origin: unknown, value: unknown): void;
32
+ rule: RuleData;
33
+ origin: RuleData;
34
+ parent: RuleContext | null;
35
+ children: RuleContext[];
36
+ root: RuleData[];
37
+ ctrlRule: RuntimeRecord[];
38
+ watch: Array<() => void>;
39
+ linkOn: Array<() => void>;
40
+ pending: Record<string, {
41
+ origin: unknown;
42
+ value: any;
43
+ }>;
44
+ input: boolean;
45
+ field?: string;
46
+ group: RuleContext | null;
47
+ $handle?: RuleHandle;
48
+ [key: string]: any;
49
+ };
50
+ export default function RuleContext(this: RuleContext, handle: RuleHandle, rule: RuleData, defaultValue?: unknown): void;
51
+ export {};
@@ -0,0 +1,29 @@
1
+ type RuleData = {
2
+ type?: string;
3
+ title?: any;
4
+ field?: string;
5
+ value?: any;
6
+ props: Record<string, any>;
7
+ on: Record<string, any>;
8
+ options: any[];
9
+ children: any[];
10
+ hidden: boolean;
11
+ display: boolean;
12
+ [key: string]: any;
13
+ };
14
+ type CreatorInit = Record<string, any> | ((maker: Creator) => void);
15
+ export declare function baseRule(): RuleData;
16
+ export declare class Creator {
17
+ _data: RuleData;
18
+ event: Creator['on'];
19
+ constructor(type?: string, title?: any, field?: string, value?: any, props?: Record<string, any> | null);
20
+ getRule(): RuleData;
21
+ setProp(key: string, value: any): this;
22
+ modelField(field: string): this;
23
+ on(key: any, value?: any): this;
24
+ setAttribute(name: string, key: any, value?: any, hasValue?: boolean): this;
25
+ _clone(): Creator;
26
+ }
27
+ export declare function appendProto(names: string[]): void;
28
+ export declare function creatorFactory(type: string, init?: CreatorInit): (title?: any, field?: string, value?: any, props?: Record<string, any>) => Creator;
29
+ export {};
@@ -0,0 +1,6 @@
1
+ import { creatorFactory } from "./creator";
2
+ export declare function create(type?: string, field?: string, title?: string): import("./creator").Creator;
3
+ export default function makerFactory(): {
4
+ create: typeof create;
5
+ factory: typeof creatorFactory;
6
+ };
@@ -0,0 +1,86 @@
1
+ import type { ComponentInternalInstance, VNodeChild } from 'vue';
2
+ type ManagerOptions = Record<string, unknown>;
3
+ type ManagerRuleContext = Record<string, unknown>;
4
+ type ManagerSlot = (...args: unknown[]) => VNodeChild | VNodeChild[];
5
+ type ManagerVm = Pick<ComponentInternalInstance, 'refs' | 'slots'> & {
6
+ setupState: {
7
+ parent?: ManagerVm | null;
8
+ };
9
+ };
10
+ type ManagerHandler = {
11
+ vm: ManagerVm;
12
+ $render: {
13
+ renderRule(rule: unknown, children?: unknown): VNodeChild;
14
+ };
15
+ fc: {
16
+ targeabFormDriver(method: string, options: ManagerOptions, context: ManagerOptions): unknown;
17
+ };
18
+ api: unknown;
19
+ };
20
+ type ManagerMergeRule = {
21
+ normal?: string[];
22
+ array?: string[];
23
+ functional?: string[];
24
+ props?: string[];
25
+ };
26
+ type Validator = (value: unknown, callback: unknown) => unknown;
27
+ type ValidationRule = {
28
+ validator?: (rule: unknown, value: unknown, callback: unknown) => unknown;
29
+ };
30
+ type ManagerOverrides = Record<string, unknown>;
31
+ export declare function createManager<Overrides extends ManagerOverrides>(proto: Overrides): {
32
+ new (handler: ManagerHandler): {
33
+ readonly $handle: ManagerHandler;
34
+ readonly vm: ManagerVm;
35
+ $render: ManagerHandler['$render'];
36
+ $r: ManagerHandler['$render']['renderRule'];
37
+ options: ManagerOptions;
38
+ ref: string;
39
+ mergeOptionsRule: ManagerMergeRule;
40
+ key: string;
41
+ __init(): void;
42
+ updateKey(): void;
43
+ init(): void;
44
+ update(): void;
45
+ beforeRender(): void;
46
+ form(): unknown;
47
+ adapterValidate(validate: ValidationRule, validator: Validator): ValidationRule;
48
+ getSlot(name: string): ManagerSlot | undefined;
49
+ mergeOptions(args: ManagerOptions[], options: ManagerOptions): ManagerOptions;
50
+ updateOptions(options: ManagerOptions): void;
51
+ tidyOptions(options: ManagerOptions): ManagerOptions;
52
+ tidyRule(_ctx: ManagerRuleContext): void;
53
+ mergeProp(_ctx: ManagerRuleContext): void;
54
+ getDefaultOptions(): ManagerOptions;
55
+ fieldChange(_ctx: ManagerRuleContext, _value: unknown, _formValue: unknown, _setFlag: unknown): void;
56
+ render(_children: unknown): VNodeChild | VNodeChild[] | undefined;
57
+ };
58
+ };
59
+ export default class Manager {
60
+ readonly $handle: ManagerHandler;
61
+ readonly vm: ManagerVm;
62
+ $render: ManagerHandler['$render'];
63
+ $r: ManagerHandler['$render']['renderRule'];
64
+ options: ManagerOptions;
65
+ ref: string;
66
+ mergeOptionsRule: ManagerMergeRule;
67
+ key: string;
68
+ constructor(handler: ManagerHandler);
69
+ __init(): void;
70
+ updateKey(): void;
71
+ init(): void;
72
+ update(): void;
73
+ beforeRender(): void;
74
+ form(): unknown;
75
+ adapterValidate(validate: ValidationRule, validator: Validator): ValidationRule;
76
+ getSlot(name: string): ManagerSlot | undefined;
77
+ mergeOptions(args: ManagerOptions[], options: ManagerOptions): ManagerOptions;
78
+ updateOptions(options: ManagerOptions): void;
79
+ tidyOptions(options: ManagerOptions): ManagerOptions;
80
+ tidyRule(_ctx: ManagerRuleContext): void;
81
+ mergeProp(_ctx: ManagerRuleContext): void;
82
+ getDefaultOptions(): ManagerOptions;
83
+ fieldChange(_ctx: ManagerRuleContext, _value: unknown, _formValue: unknown, _setFlag: unknown): void;
84
+ render(_children: unknown): VNodeChild | VNodeChild[] | undefined;
85
+ }
86
+ export {};
@@ -0,0 +1,34 @@
1
+ import { withDirectives, type Component, type ComponentInternalInstance, type Slots, type VNode, type VNodeChild } from 'vue';
2
+ type DirectiveEntry = Parameters<typeof withDirectives>[1][number];
3
+ type DirectiveData = {
4
+ value?: DirectiveEntry[1];
5
+ arg?: DirectiveEntry[2];
6
+ modifiers?: DirectiveEntry[3];
7
+ };
8
+ type DirectiveGroup = Record<string, DirectiveData>;
9
+ type NodeChildren = VNodeChild | Slots;
10
+ type NodeData = Record<string, unknown> & {
11
+ directives?: DirectiveGroup | DirectiveGroup[];
12
+ };
13
+ type NodeHandle = {
14
+ vm?: Pick<ComponentInternalInstance, 'appContext'> | null;
15
+ fc: {
16
+ prop: {
17
+ components: Record<string, Component>;
18
+ };
19
+ };
20
+ };
21
+ export declare function CreateNodeFactory(): {
22
+ new (handle: NodeHandle): {
23
+ readonly aliasMap: Record<string, string>;
24
+ readonly vm: NodeHandle['vm'];
25
+ readonly handle: NodeHandle;
26
+ make(tag: string, data: NodeData, children?: NodeChildren): VNode;
27
+ makeComponent(type: Component, data: NodeData, children?: NodeChildren): VNode;
28
+ h(tag: string, data: Record<string, unknown>, children?: NodeChildren): VNode;
29
+ };
30
+ aliasMap: Record<string, string>;
31
+ alias(alias: string, name: string): void;
32
+ use(nodes: Record<string, string>): void;
33
+ };
34
+ export {};
@@ -0,0 +1,28 @@
1
+ import type { VNodeChild } from "vue";
2
+ type ParserSlots = Record<string, () => VNodeChild | VNodeChild[]>;
3
+ interface ParserRenderContext {
4
+ defaultRender(ctx: ParserContext, children: ParserSlots): VNodeChild | VNodeChild[];
5
+ }
6
+ interface ParserRenderDriver {
7
+ defaultRender?: ParserRenderContext["defaultRender"];
8
+ defaultPreview?: ParserRenderContext["defaultRender"];
9
+ }
10
+ interface ParserContext {
11
+ $handle: {
12
+ fc: {
13
+ renderDriver?: ParserRenderDriver | null;
14
+ };
15
+ };
16
+ $render: ParserRenderContext;
17
+ }
18
+ interface BaseParserDefinition {
19
+ init(ctx: ParserContext): void;
20
+ toFormValue(value: unknown, ctx: ParserContext): unknown;
21
+ toValue(formValue: unknown, ctx: ParserContext): unknown;
22
+ mounted(ctx: ParserContext): void;
23
+ render(children: ParserSlots, ctx: ParserContext): VNodeChild | VNodeChild[];
24
+ preview(children: ParserSlots, ctx: ParserContext): VNodeChild | VNodeChild[];
25
+ mergeProp(ctx: ParserContext): void;
26
+ }
27
+ declare const BaseParser: BaseParserDefinition;
28
+ export default BaseParser;
@@ -0,0 +1,39 @@
1
+ type RuntimeRecord = Record<string, any>;
2
+ type ApiRule = RuntimeRecord & {
3
+ field?: any;
4
+ value?: unknown;
5
+ children?: ApiRule[];
6
+ ignore?: boolean;
7
+ };
8
+ type ApiMethodName = 'formData' | 'getValue' | 'coverValue' | 'setValue' | 'removeField' | 'removeRule' | 'fields' | 'append' | 'prepend' | 'hidden' | 'hiddenStatus' | 'display' | 'displayStatus' | 'disabled' | 'all' | 'model' | 'component' | 'bind' | 'reload' | 'updateOptions' | 'onSubmit' | 'sync' | 'refresh' | 'refreshOptions' | 'hideForm' | 'changeStatus' | 'clearChangeStatus' | 'updateRule' | 'updateRules' | 'mergeRule' | 'mergeRules' | 'getRule' | 'findType' | 'findTypes' | 'getRenderRule' | 'getRefRule' | 'setEffect' | 'clearEffectData' | 'updateValidate' | 'updateValidates' | 'refreshValidate' | 'resetFields' | 'method' | 'exec' | 'toJson' | 'trigger' | 'el' | 'scrollTo' | 'focus' | 'closeModal' | 'getSubForm' | 'getChildrenRuleList' | 'getParentRule' | 'getParentSubRule' | 'getChildrenFormData' | 'setChildrenFormData' | 'getGlobalEvent' | 'getGlobalData' | 'emitGlobalEvent' | 'setGlobalData' | 'setGlobalVar' | 'renderRule' | 'renderChildren' | 'nextTick' | 'nextRefresh' | 'deferSyncValue' | 'emit' | 'getCurrenabFormRule' | 'fetch' | 'watchFetch' | 'getData' | 'watchData' | 'setData' | 'refreshData' | 't' | 'getLocale';
9
+ type ApiRuntime = {
10
+ [K in ApiMethodName]: (...args: any[]) => any;
11
+ } & {
12
+ isScope: boolean;
13
+ isPreview: boolean;
14
+ config: RuntimeRecord;
15
+ options: RuntimeRecord;
16
+ form: RuntimeRecord | undefined;
17
+ rule: ApiRule[];
18
+ parent: ApiRuntime | undefined;
19
+ top: ApiRuntime;
20
+ scope: ApiRuntime;
21
+ children: RuntimeRecord[];
22
+ siblings: RuntimeRecord[] | undefined;
23
+ index: number | undefined;
24
+ formulas: RuntimeRecord;
25
+ bus: RuntimeRecord;
26
+ helper: {
27
+ tidyFields(fields: ApiFields): string[];
28
+ props(fields: ApiFields, key: string, value: unknown): void;
29
+ };
30
+ clearValidateState?: (...args: any[]) => any;
31
+ on?: (...args: any[]) => any;
32
+ once?: (...args: any[]) => any;
33
+ off?: (...args: any[]) => any;
34
+ changeValue?: (...args: any[]) => any;
35
+ changeField?: (...args: any[]) => any;
36
+ } & ThisType<ApiRuntime>;
37
+ type ApiFields = string | string[] | null | undefined;
38
+ export default function Api(h: RuntimeRecord): ApiRuntime;
39
+ export {};
@@ -0,0 +1,6 @@
1
+ import { functionalMerge, normalMerge, toArrayMerge } from '@archbiz/utils';
2
+ export { functionalMerge, normalMerge, toArrayMerge };
3
+ export declare const keyAttrs: string[];
4
+ export declare const arrayAttrs: string[];
5
+ export declare const normalAttrs: string[];
6
+ export declare function attrs(): string[];
@@ -0,0 +1,6 @@
1
+ type DataDriver = (name: string) => unknown;
2
+ export declare function baseDriver(driver: DataDriver, name: string | null | undefined): unknown;
3
+ export declare function cookieDriver(name: string | null | undefined): unknown;
4
+ export declare function localStorageDriver(name: string | null | undefined): unknown;
5
+ export declare function sessionStorageDriver(name: string | null | undefined): unknown;
6
+ export {};
@@ -0,0 +1,29 @@
1
+ type QueryValue = string | number | boolean | null | undefined;
2
+ type Query = string | Record<string, QueryValue>;
3
+ type FetchError = Error | ProgressEvent;
4
+ type FetchProgressEvent = ProgressEvent<XMLHttpRequestUpload> & {
5
+ percent: number;
6
+ };
7
+ type ParseHandler = (value: unknown, targetRule: unknown, api: unknown) => unknown;
8
+ export interface FetchRequestOptions {
9
+ action?: string;
10
+ method?: string;
11
+ query?: Query;
12
+ data?: Record<string, unknown>;
13
+ dataType?: string;
14
+ file?: File;
15
+ filename?: string;
16
+ headers?: Record<string, string>;
17
+ withCredentials?: boolean;
18
+ onProgress?: (event: FetchProgressEvent) => void;
19
+ onSuccess: (body: unknown) => void;
20
+ onError?: (error: FetchError, body?: unknown) => void;
21
+ }
22
+ interface AsyncFetchConfig extends Omit<FetchRequestOptions, 'onSuccess' | 'onError'> {
23
+ parse?: string | ParseHandler;
24
+ targetRule?: unknown;
25
+ }
26
+ type FetchImplementation = (option: FetchRequestOptions) => void;
27
+ export default function fetch(option: FetchRequestOptions): void;
28
+ export declare function asyncFetch(config: AsyncFetchConfig, fetcher: FetchImplementation | undefined, api: unknown): Promise<unknown>;
29
+ export {};
@@ -0,0 +1,17 @@
1
+ type RuntimeRecord = Record<string, any>;
2
+ type AbFormConfig = RuntimeRecord & {
3
+ attrs?: {
4
+ key?: string[];
5
+ array?: string[];
6
+ normal?: string[];
7
+ };
8
+ extendApi?: (...args: any[]) => unknown;
9
+ isMobile?: boolean;
10
+ manager?: RuntimeRecord;
11
+ ui?: string;
12
+ version?: string;
13
+ install?: (create: RuntimeRecord, options?: unknown) => void;
14
+ inherit?: RuntimeRecord;
15
+ };
16
+ export default function AbFormFactory(config: AbFormConfig): RuntimeRecord;
17
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,106 @@
1
+ type ProviderRule = Record<string, unknown> & {
2
+ field?: string;
3
+ children?: unknown[];
4
+ __fc__?: {
5
+ getParentGroup(): {
6
+ id: string;
7
+ } | undefined;
8
+ };
9
+ };
10
+ type DataGetter = (id: string, defaultValue?: unknown) => unknown;
11
+ type Unwatch = () => void;
12
+ type IndexedArray<T> = T[];
13
+ type ProviderApi = {
14
+ sync(rule: ProviderRule): void;
15
+ clearValidateState(fields: Array<string | undefined>): void;
16
+ exec(id: unknown, method: string, ...args: unknown[]): unknown;
17
+ };
18
+ type ProviderInject = {
19
+ id: string;
20
+ value: unknown;
21
+ getValue(): unknown;
22
+ getProp(): ProviderRule;
23
+ clearProp(): void;
24
+ };
25
+ type ProviderFetchConfig = {
26
+ action?: string | ((rule: ProviderRule, api: ProviderApi) => unknown);
27
+ key?: string;
28
+ to?: string;
29
+ watch?: boolean;
30
+ wait?: number;
31
+ parse?: string | ((body: unknown, rule: ProviderRule, api: ProviderApi) => unknown);
32
+ headers?: Record<string, string>;
33
+ onError?: (error: unknown, rule: ProviderRule, api: ProviderApi) => void;
34
+ [key: string]: unknown;
35
+ };
36
+ type ProviderFetchResult = {
37
+ status: true;
38
+ data: unknown;
39
+ };
40
+ type ProviderFrame = {
41
+ $handle: {
42
+ loadStrVar(template: string, get: DataGetter, context?: {
43
+ rule: ProviderRule;
44
+ value: Record<string, unknown>;
45
+ } | null): unknown;
46
+ loadFetchVar(option: ProviderFetchConfig, get: DataGetter, rule: ProviderRule): ProviderFetchConfig;
47
+ subRuleData: Record<string, Record<string, unknown> | undefined>;
48
+ options: {
49
+ globalData: Record<string, object | undefined>;
50
+ };
51
+ beforeFetch(config: ProviderFetchConfig, context: {
52
+ rule: ProviderRule;
53
+ api: ProviderApi;
54
+ }): Promise<unknown>;
55
+ };
56
+ watchLoadData(callback: (get: DataGetter, change: boolean) => void): Unwatch;
57
+ fetchCache: WeakMap<object, ProviderFetchResult>;
58
+ targetRule?: ProviderRule;
59
+ t(key: string | undefined, params: Record<string, unknown> | null, get: DataGetter): unknown;
60
+ create: {
61
+ fetch(config: ProviderFetchConfig & {
62
+ onSuccess(body: unknown, raw?: boolean): void;
63
+ onError(error: unknown): void;
64
+ }, context: {
65
+ inject: ProviderInject;
66
+ rule: ProviderRule;
67
+ api: ProviderApi;
68
+ }): void;
69
+ };
70
+ };
71
+ type LoadDataProvider = {
72
+ name: string;
73
+ _fn: IndexedArray<Unwatch[] | undefined>;
74
+ loaded(this: LoadDataProvider, inject: ProviderInject, rule: ProviderRule, api: ProviderApi): void;
75
+ watch: LoadDataProvider['loaded'];
76
+ deleted(this: LoadDataProvider, inject: ProviderInject): void;
77
+ };
78
+ type TranslationProvider = {
79
+ name: string;
80
+ _fn: IndexedArray<Unwatch[] | undefined>;
81
+ loaded(this: TranslationProvider, inject: ProviderInject, rule: ProviderRule, api: ProviderApi): void;
82
+ watch: TranslationProvider['loaded'];
83
+ deleted(this: TranslationProvider, inject: ProviderInject): void;
84
+ };
85
+ type ComponentValidateProvider = {
86
+ name: string;
87
+ load(attr: ProviderInject, rule: ProviderRule, api: ProviderApi): void;
88
+ watch(attr: ProviderInject, rule: ProviderRule, api: ProviderApi): void;
89
+ };
90
+ type FetchProvider = {
91
+ name: string;
92
+ _fn: IndexedArray<Unwatch | undefined>;
93
+ loaded(this: FetchProvider, inject: ProviderInject, rule: ProviderRule, api: ProviderApi): void;
94
+ watch: FetchProvider['loaded'];
95
+ deleted(this: FetchProvider, inject: ProviderInject): void;
96
+ };
97
+ declare const loadData: (fc: ProviderFrame) => LoadDataProvider;
98
+ declare const t: (fc: ProviderFrame) => TranslationProvider;
99
+ declare const fetch: (fc: ProviderFrame) => FetchProvider;
100
+ declare const _default: {
101
+ fetch: typeof fetch;
102
+ loadData: typeof loadData;
103
+ t: typeof t;
104
+ componentValidate: ComponentValidateProvider;
105
+ };
106
+ export default _default;