@webiny/app-admin 6.1.0 → 6.2.0-beta.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.
- package/base/Admin.js +2 -0
- package/base/Admin.js.map +1 -1
- package/base/Base/DefaultFieldRenderers.d.ts +2 -0
- package/base/Base/DefaultFieldRenderers.js +15 -0
- package/base/Base/DefaultFieldRenderers.js.map +1 -0
- package/base/Base/FieldRenderers/SelectRenderer.d.ts +5 -0
- package/base/Base/FieldRenderers/SelectRenderer.js +24 -0
- package/base/Base/FieldRenderers/SelectRenderer.js.map +1 -0
- package/base/Base/FieldRenderers/TextRenderer.d.ts +5 -0
- package/base/Base/FieldRenderers/TextRenderer.js +21 -0
- package/base/Base/FieldRenderers/TextRenderer.js.map +1 -0
- package/base/Base/Menus.js +7 -0
- package/base/Base/Menus.js.map +1 -1
- package/base/Base.js +2 -1
- package/base/Base.js.map +1 -1
- package/base/createRootContainer.js +2 -0
- package/base/createRootContainer.js.map +1 -1
- package/components/Dialogs/DialogParamsContext.d.ts +6 -0
- package/components/Dialogs/DialogParamsContext.js +11 -0
- package/components/Dialogs/DialogParamsContext.js.map +1 -0
- package/components/Dialogs/DialogsContext.d.ts +2 -0
- package/components/Dialogs/DialogsContext.js +32 -4
- package/components/Dialogs/DialogsContext.js.map +1 -1
- package/components/OptionsMenu/OptionsMenu.d.ts +6 -0
- package/components/OptionsMenu/OptionsMenu.js +3 -3
- package/components/OptionsMenu/OptionsMenu.js.map +1 -1
- package/components/RegisterFeature.js +5 -5
- package/components/RegisterFeature.js.map +1 -1
- package/components/Wcp.d.ts +2 -0
- package/components/Wcp.js +7 -0
- package/components/Wcp.js.map +1 -1
- package/config/AdminConfig/Dialog.d.ts +10 -0
- package/config/AdminConfig/Dialog.js +21 -0
- package/config/AdminConfig/Dialog.js.map +1 -0
- package/config/AdminConfig/FieldRenderer.d.ts +11 -0
- package/config/AdminConfig/FieldRenderer.js +21 -0
- package/config/AdminConfig/FieldRenderer.js.map +1 -0
- package/config/AdminConfig/Form.d.ts +3 -0
- package/config/AdminConfig/Form.js +6 -0
- package/config/AdminConfig/Form.js.map +1 -0
- package/config/AdminConfig.d.ts +10 -0
- package/config/AdminConfig.js +7 -1
- package/config/AdminConfig.js.map +1 -1
- package/exports/admin/security.d.ts +6 -0
- package/exports/admin/security.js +5 -0
- package/exports/admin/security.js.map +1 -1
- package/exports/admin/ui.d.ts +2 -0
- package/exports/admin/ui.js +2 -0
- package/exports/admin/ui.js.map +1 -1
- package/exports/admin.d.ts +0 -3
- package/exports/admin.js +0 -3
- package/exports/admin.js.map +1 -1
- package/features/formModel/Field.d.ts +52 -0
- package/features/formModel/Field.js +201 -0
- package/features/formModel/Field.js.map +1 -0
- package/features/formModel/FieldBuilder.d.ts +45 -0
- package/features/formModel/FieldBuilder.js +158 -0
- package/features/formModel/FieldBuilder.js.map +1 -0
- package/features/formModel/FieldBuilder.test.js +106 -0
- package/features/formModel/FieldBuilder.test.js.map +1 -0
- package/features/formModel/FormModel.d.ts +61 -0
- package/features/formModel/FormModel.js +573 -0
- package/features/formModel/FormModel.js.map +1 -0
- package/features/formModel/FormModel.test.d.ts +1 -0
- package/features/formModel/FormModel.test.js +1140 -0
- package/features/formModel/FormModel.test.js.map +1 -0
- package/features/formModel/FormModelFactory.d.ts +9 -0
- package/features/formModel/FormModelFactory.js +13 -0
- package/features/formModel/FormModelFactory.js.map +1 -0
- package/features/formModel/FormView.d.ts +23 -0
- package/features/formModel/FormView.js +138 -0
- package/features/formModel/FormView.js.map +1 -0
- package/features/formModel/abstractions.d.ts +286 -0
- package/features/formModel/abstractions.js +54 -0
- package/features/formModel/abstractions.js.map +1 -0
- package/features/formModel/feature.d.ts +3 -0
- package/features/formModel/feature.js +16 -0
- package/features/formModel/feature.js.map +1 -0
- package/features/formModel/index.d.ts +10 -0
- package/features/formModel/index.js +14 -0
- package/features/formModel/index.js.map +1 -0
- package/features/formModel/useFieldRenderers.d.ts +2 -0
- package/features/formModel/useFieldRenderers.js +19 -0
- package/features/formModel/useFieldRenderers.js.map +1 -0
- package/features/security/LogIn/LogInGateway.d.ts +2 -2
- package/features/security/LogIn/LogInGateway.js +2 -2
- package/features/security/LogIn/LogInGateway.js.map +1 -1
- package/features/wcp/WcpGateway.d.ts +2 -2
- package/features/wcp/WcpGateway.js +2 -2
- package/features/wcp/WcpGateway.js.map +1 -1
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +1 -0
- package/hooks/index.js.map +1 -1
- package/hooks/useDialog.d.ts +9 -29
- package/hooks/useDialog.js +16 -24
- package/hooks/useDialog.js.map +1 -1
- package/hooks/useOpenDialog.d.ts +7 -0
- package/hooks/useOpenDialog.js +18 -0
- package/hooks/useOpenDialog.js.map +1 -0
- package/index.d.ts +5 -0
- package/index.js +5 -0
- package/index.js.map +1 -1
- package/package.json +30 -30
- package/permissions/createHasPermission.d.ts +3 -2
- package/permissions/createHasPermission.js +4 -8
- package/permissions/createHasPermission.js.map +1 -1
- package/permissions/createPermissions.d.ts +6 -0
- package/permissions/createPermissions.js +201 -0
- package/permissions/createPermissions.js.map +1 -0
- package/permissions/createPermissions.test.d.ts +1 -0
- package/permissions/createPermissions.test.js +177 -0
- package/permissions/createPermissions.test.js.map +1 -0
- package/permissions/index.d.ts +1 -0
- package/permissions/index.js +1 -0
- package/permissions/index.js.map +1 -1
- package/permissions/types.d.ts +5 -0
- package/permissions/types.js.map +1 -1
- package/permissions/usePermissions.d.ts +2 -1
- package/permissions/usePermissions.js +4 -175
- package/permissions/usePermissions.js.map +1 -1
- package/presentation/installation/presenters/SystemInstaller/SystemInstallerGateway.d.ts +2 -2
- package/presentation/installation/presenters/SystemInstaller/SystemInstallerGateway.js +2 -2
- package/presentation/installation/presenters/SystemInstaller/SystemInstallerGateway.js.map +1 -1
- package/permissions/createHasPermission.test.js +0 -206
- package/permissions/createHasPermission.test.js.map +0 -1
- /package/{permissions/createHasPermission.test.d.ts → features/formModel/FieldBuilder.test.d.ts} +0 -0
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export interface IFieldConfig {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
label?: string;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
defaultValue?: unknown;
|
|
8
|
+
renderer?: string;
|
|
9
|
+
hidden: boolean;
|
|
10
|
+
required: boolean;
|
|
11
|
+
requiredMessage?: string;
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
schema?: z.ZodTypeAny;
|
|
14
|
+
options?: IValueOption[] | ((form: IFormModel) => IValueOption[]);
|
|
15
|
+
beforeChangeCallbacks?: BeforeChangeCallback[];
|
|
16
|
+
afterChangeCallbacks?: AfterChangeCallback[];
|
|
17
|
+
afterSetValueCallbacks?: AfterSetValueCallback[];
|
|
18
|
+
onBlurCallbacks?: OnBlurCallback[];
|
|
19
|
+
}
|
|
20
|
+
export interface IValueOption {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
}
|
|
25
|
+
export interface IFieldValidation {
|
|
26
|
+
isValid: boolean | null;
|
|
27
|
+
message?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface IFieldVM {
|
|
30
|
+
name: string;
|
|
31
|
+
type: string;
|
|
32
|
+
label?: string;
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
value: unknown;
|
|
35
|
+
validation: IFieldValidation;
|
|
36
|
+
required: boolean;
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
renderer?: string;
|
|
39
|
+
options?: IValueOption[];
|
|
40
|
+
onChange: (value: unknown) => void;
|
|
41
|
+
onBlur: () => void;
|
|
42
|
+
}
|
|
43
|
+
export interface IField {
|
|
44
|
+
readonly name: string;
|
|
45
|
+
readonly type: string;
|
|
46
|
+
getValue<T = unknown>(): T;
|
|
47
|
+
setValue(value: unknown): void;
|
|
48
|
+
setDisabled(value: boolean): void;
|
|
49
|
+
setVisible(value: boolean): void;
|
|
50
|
+
remove(): void;
|
|
51
|
+
addBeforeChange(cb: BeforeChangeCallback): void;
|
|
52
|
+
addAfterChange(cb: AfterChangeCallback): void;
|
|
53
|
+
addAfterSetValue(cb: AfterSetValueCallback): void;
|
|
54
|
+
addOnBlur(cb: OnBlurCallback): void;
|
|
55
|
+
blur(): void;
|
|
56
|
+
as<T extends keyof FieldTypeMap>(type: T): FieldTypeMap[T];
|
|
57
|
+
readonly vm: IFieldVM;
|
|
58
|
+
readonly config: IFieldConfig;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Maps field type strings to their typed field interfaces.
|
|
62
|
+
* Extended via module augmentation when new field types are registered.
|
|
63
|
+
*/
|
|
64
|
+
export interface FieldTypeMap {
|
|
65
|
+
text: IField;
|
|
66
|
+
select: ISelectField;
|
|
67
|
+
}
|
|
68
|
+
export interface ISelectField extends IField {
|
|
69
|
+
readonly config: IFieldConfig & {
|
|
70
|
+
options?: IValueOption[] | ((form: IFormModel) => IValueOption[]);
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export type BeforeChangeCallback = (value: unknown, form: IFormModel) => unknown;
|
|
74
|
+
export type AfterChangeCallback = (value: unknown, form: IFormModel) => void;
|
|
75
|
+
export type AfterSetValueCallback = (value: unknown, form: IFormModel) => void;
|
|
76
|
+
export type OnBlurCallback = (value: unknown, form: IFormModel) => void;
|
|
77
|
+
export type LayoutNode = IRowNode | ISeparatorNode | ITabsNode | IElementNode | IObjectNode;
|
|
78
|
+
export interface IRowNode {
|
|
79
|
+
type: "row";
|
|
80
|
+
fieldIds: string[];
|
|
81
|
+
}
|
|
82
|
+
export interface ISeparatorNode {
|
|
83
|
+
type: "separator";
|
|
84
|
+
}
|
|
85
|
+
export interface ITabDefinition {
|
|
86
|
+
id: string;
|
|
87
|
+
label: string;
|
|
88
|
+
description?: string;
|
|
89
|
+
icon?: string;
|
|
90
|
+
layout: LayoutNode[];
|
|
91
|
+
}
|
|
92
|
+
export interface ITabsNode {
|
|
93
|
+
type: "tabs";
|
|
94
|
+
id?: string;
|
|
95
|
+
tabs: ITabDefinition[];
|
|
96
|
+
}
|
|
97
|
+
export interface IElementNode {
|
|
98
|
+
type: "element";
|
|
99
|
+
id?: string;
|
|
100
|
+
renderer: string;
|
|
101
|
+
props?: Record<string, unknown>;
|
|
102
|
+
}
|
|
103
|
+
export interface IObjectNode {
|
|
104
|
+
type: "object";
|
|
105
|
+
fieldId: string;
|
|
106
|
+
layout?: LayoutNode[];
|
|
107
|
+
templates?: Record<string, LayoutNode[]>;
|
|
108
|
+
}
|
|
109
|
+
export type LayoutNodeVM = IRowNodeVM | ISeparatorNodeVM | ITabsNodeVM | IElementNodeVM;
|
|
110
|
+
export interface IRowNodeVM {
|
|
111
|
+
type: "row";
|
|
112
|
+
fields: IFieldVM[];
|
|
113
|
+
}
|
|
114
|
+
export interface ISeparatorNodeVM {
|
|
115
|
+
type: "separator";
|
|
116
|
+
}
|
|
117
|
+
export interface ITabDefinitionVM {
|
|
118
|
+
id: string;
|
|
119
|
+
label: string;
|
|
120
|
+
description?: string;
|
|
121
|
+
icon?: string;
|
|
122
|
+
hasErrors: boolean;
|
|
123
|
+
layout: LayoutNodeVM[];
|
|
124
|
+
}
|
|
125
|
+
export interface ITabsNodeVM {
|
|
126
|
+
type: "tabs";
|
|
127
|
+
id?: string;
|
|
128
|
+
tabs: ITabDefinitionVM[];
|
|
129
|
+
activeTabId: string;
|
|
130
|
+
setActiveTab: (id: string) => void;
|
|
131
|
+
}
|
|
132
|
+
export interface IElementNodeVM {
|
|
133
|
+
type: "element";
|
|
134
|
+
renderer: string;
|
|
135
|
+
props?: Record<string, unknown>;
|
|
136
|
+
}
|
|
137
|
+
export type LayoutPosition = {
|
|
138
|
+
type: "before";
|
|
139
|
+
target: string;
|
|
140
|
+
} | {
|
|
141
|
+
type: "after";
|
|
142
|
+
target: string;
|
|
143
|
+
} | {
|
|
144
|
+
type: "replace";
|
|
145
|
+
target: string;
|
|
146
|
+
};
|
|
147
|
+
export interface IPositionedLayoutNode {
|
|
148
|
+
node: LayoutNode;
|
|
149
|
+
position?: LayoutPosition;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Chainable handle returned by modifier layout.row().
|
|
153
|
+
* Can be used as-is (appended) or positioned via .before()/.after()/.replace().
|
|
154
|
+
*/
|
|
155
|
+
export interface ILayoutNodeHandle extends IPositionedLayoutNode {
|
|
156
|
+
before(target: string): IPositionedLayoutNode;
|
|
157
|
+
after(target: string): IPositionedLayoutNode;
|
|
158
|
+
replace(target: string): IPositionedLayoutNode;
|
|
159
|
+
}
|
|
160
|
+
export interface ITabsHandle {
|
|
161
|
+
tab(definition: ITabDefinition): ITabHandle;
|
|
162
|
+
tab(id: string): ITabHandle;
|
|
163
|
+
}
|
|
164
|
+
export interface ITabHandle {
|
|
165
|
+
layout(factory: (layout: ILayoutBuilder) => LayoutNode[]): void;
|
|
166
|
+
before(target: string): void;
|
|
167
|
+
after(target: string): void;
|
|
168
|
+
}
|
|
169
|
+
export interface ILayoutNodeAccessHandle {
|
|
170
|
+
as(type: "tabs"): ITabsHandle;
|
|
171
|
+
}
|
|
172
|
+
export interface IFormModifier {
|
|
173
|
+
modify(form: IFormModel): void;
|
|
174
|
+
}
|
|
175
|
+
export interface ILayoutModifier {
|
|
176
|
+
row(...fieldIds: string[]): ILayoutNodeHandle;
|
|
177
|
+
separator(): ILayoutNodeHandle;
|
|
178
|
+
tabs(config: {
|
|
179
|
+
id?: string;
|
|
180
|
+
tabs: ITabDefinition[];
|
|
181
|
+
}): ILayoutNodeHandle;
|
|
182
|
+
element(renderer: string, props?: Record<string, unknown>): ILayoutNodeHandle;
|
|
183
|
+
remove(target: string): void;
|
|
184
|
+
}
|
|
185
|
+
export interface IFormError {
|
|
186
|
+
path: string;
|
|
187
|
+
label?: string;
|
|
188
|
+
message: string;
|
|
189
|
+
}
|
|
190
|
+
export interface IFormVM {
|
|
191
|
+
layout: LayoutNodeVM[];
|
|
192
|
+
errors: IFormError[];
|
|
193
|
+
isDirty: boolean;
|
|
194
|
+
isValid: boolean | null;
|
|
195
|
+
}
|
|
196
|
+
export interface IFormModel {
|
|
197
|
+
field(name: string): IField;
|
|
198
|
+
fields(factory: (registry: IFieldBuilderRegistry) => Record<string, IFieldBuilder | undefined>): void;
|
|
199
|
+
layout(factory: (layout: ILayoutModifier) => (LayoutNode | IPositionedLayoutNode)[]): void;
|
|
200
|
+
layout(nodeId: string): ILayoutNodeAccessHandle;
|
|
201
|
+
getData(): Record<string, unknown>;
|
|
202
|
+
setData(data: Record<string, unknown>): void;
|
|
203
|
+
reset(): void;
|
|
204
|
+
validate(): Promise<boolean>;
|
|
205
|
+
submit<T = Record<string, unknown>>(): Promise<T | false>;
|
|
206
|
+
readonly isDirty: boolean;
|
|
207
|
+
readonly isValid: boolean | null;
|
|
208
|
+
readonly errors: IFormError[];
|
|
209
|
+
readonly vm: IFormVM;
|
|
210
|
+
}
|
|
211
|
+
export declare namespace FormModel {
|
|
212
|
+
type FieldConfig = IFieldConfig;
|
|
213
|
+
type ValueOption = IValueOption;
|
|
214
|
+
type FieldValidation = IFieldValidation;
|
|
215
|
+
type FieldVM = IFieldVM;
|
|
216
|
+
type Field = IField;
|
|
217
|
+
type SelectField = ISelectField;
|
|
218
|
+
type BeforeChange = BeforeChangeCallback;
|
|
219
|
+
type AfterChange = AfterChangeCallback;
|
|
220
|
+
type AfterSetValue = AfterSetValueCallback;
|
|
221
|
+
type OnBlur = OnBlurCallback;
|
|
222
|
+
type RowNode = IRowNode;
|
|
223
|
+
type RowNodeVM = IRowNodeVM;
|
|
224
|
+
type SeparatorNode = ISeparatorNode;
|
|
225
|
+
type SeparatorNodeVM = ISeparatorNodeVM;
|
|
226
|
+
type TabsNode = ITabsNode;
|
|
227
|
+
type TabDefinition = ITabDefinition;
|
|
228
|
+
type TabsNodeVM = ITabsNodeVM;
|
|
229
|
+
type TabDefinitionVM = ITabDefinitionVM;
|
|
230
|
+
type ElementNode = IElementNode;
|
|
231
|
+
type ElementNodeVM = IElementNodeVM;
|
|
232
|
+
type ObjectNode = IObjectNode;
|
|
233
|
+
type FormError = IFormError;
|
|
234
|
+
type FormVM = IFormVM;
|
|
235
|
+
type Interface = IFormModel;
|
|
236
|
+
type Modifier = IFormModifier;
|
|
237
|
+
type LayoutModifier = ILayoutModifier;
|
|
238
|
+
}
|
|
239
|
+
export interface IFormModelFactory {
|
|
240
|
+
create(config: IFormModelConfig): IFormModel;
|
|
241
|
+
}
|
|
242
|
+
export interface IFormModelConfig {
|
|
243
|
+
fields: (registry: IFieldBuilderRegistry) => Record<string, IFieldBuilder>;
|
|
244
|
+
layout?: (layout: ILayoutBuilder) => LayoutNode[];
|
|
245
|
+
validateOnSubmit?: boolean;
|
|
246
|
+
}
|
|
247
|
+
export interface ILayoutBuilder {
|
|
248
|
+
row(...fieldIds: string[]): IRowNode;
|
|
249
|
+
separator(): ISeparatorNode;
|
|
250
|
+
tabs(config: {
|
|
251
|
+
id?: string;
|
|
252
|
+
tabs: ITabDefinition[];
|
|
253
|
+
}): ITabsNode;
|
|
254
|
+
element(renderer: string, props?: Record<string, unknown>): IElementNode;
|
|
255
|
+
}
|
|
256
|
+
export interface IFieldBuilder {
|
|
257
|
+
label(text: string): this;
|
|
258
|
+
placeholder(text: string): this;
|
|
259
|
+
schema(zodSchema: z.ZodTypeAny): this;
|
|
260
|
+
defaultValue(value: unknown): this;
|
|
261
|
+
renderer(name: string): this;
|
|
262
|
+
hidden(): this;
|
|
263
|
+
required(message?: string): this;
|
|
264
|
+
disabled(value?: boolean): this;
|
|
265
|
+
beforeChange(fn: BeforeChangeCallback): this;
|
|
266
|
+
afterChange(fn: AfterChangeCallback): this;
|
|
267
|
+
afterSetValue(fn: AfterSetValueCallback): this;
|
|
268
|
+
onBlur(fn: OnBlurCallback): this;
|
|
269
|
+
build(name: string): IFieldConfig;
|
|
270
|
+
}
|
|
271
|
+
export interface ISelectFieldBuilder extends IFieldBuilder {
|
|
272
|
+
options(opts: IValueOption[] | ((form: IFormModel) => IValueOption[])): this;
|
|
273
|
+
}
|
|
274
|
+
export interface IFieldBuilderRegistry {
|
|
275
|
+
text(): IFieldBuilder;
|
|
276
|
+
select(): ISelectFieldBuilder;
|
|
277
|
+
}
|
|
278
|
+
export declare const FormModelFactory: import("@webiny/di").Abstraction<IFormModelFactory>;
|
|
279
|
+
export declare namespace FormModelFactory {
|
|
280
|
+
type Interface = IFormModelFactory;
|
|
281
|
+
type Config = IFormModelConfig;
|
|
282
|
+
type LayoutBuilder = ILayoutBuilder;
|
|
283
|
+
type FieldBuilder = IFieldBuilder;
|
|
284
|
+
type SelectFieldBuilder = ISelectFieldBuilder;
|
|
285
|
+
type FieldBuilderRegistry = IFieldBuilderRegistry;
|
|
286
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createAbstraction } from "@webiny/feature/admin";
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Field types
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Maps field type strings to their typed field interfaces.
|
|
9
|
+
* Extended via module augmentation when new field types are registered.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// ---------------------------------------------------------------------------
|
|
13
|
+
// Callback types
|
|
14
|
+
// ---------------------------------------------------------------------------
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Layout types
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
// Layout VM types
|
|
22
|
+
// ---------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
// ---------------------------------------------------------------------------
|
|
25
|
+
// Layout modifier types
|
|
26
|
+
// ---------------------------------------------------------------------------
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Chainable handle returned by modifier layout.row().
|
|
30
|
+
* Can be used as-is (appended) or positioned via .before()/.after()/.replace().
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Named layout node access types
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Modifier types
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
// ---------------------------------------------------------------------------
|
|
42
|
+
// Form types
|
|
43
|
+
// ---------------------------------------------------------------------------
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
// FormModel namespace — groups all public types under one import
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
export let FormModel;
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
// FormModelFactory abstraction
|
|
50
|
+
// ---------------------------------------------------------------------------
|
|
51
|
+
|
|
52
|
+
export const FormModelFactory = createAbstraction("FormModelFactory");
|
|
53
|
+
|
|
54
|
+
//# sourceMappingURL=abstractions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createAbstraction","FormModel","FormModelFactory"],"sources":["abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { z } from \"zod\";\n\n// ---------------------------------------------------------------------------\n// Field types\n// ---------------------------------------------------------------------------\n\nexport interface IFieldConfig {\n name: string;\n type: string;\n label?: string;\n placeholder?: string;\n defaultValue?: unknown;\n renderer?: string;\n hidden: boolean;\n required: boolean;\n requiredMessage?: string;\n disabled: boolean;\n schema?: z.ZodTypeAny;\n options?: IValueOption[] | ((form: IFormModel) => IValueOption[]);\n beforeChangeCallbacks?: BeforeChangeCallback[];\n afterChangeCallbacks?: AfterChangeCallback[];\n afterSetValueCallbacks?: AfterSetValueCallback[];\n onBlurCallbacks?: OnBlurCallback[];\n}\n\nexport interface IValueOption {\n label: string;\n value: string;\n disabled?: boolean;\n}\n\nexport interface IFieldValidation {\n isValid: boolean | null;\n message?: string;\n}\n\nexport interface IFieldVM {\n name: string;\n type: string;\n label?: string;\n placeholder?: string;\n value: unknown;\n validation: IFieldValidation;\n required: boolean;\n disabled: boolean;\n renderer?: string;\n options?: IValueOption[];\n onChange: (value: unknown) => void;\n onBlur: () => void;\n}\n\nexport interface IField {\n readonly name: string;\n readonly type: string;\n getValue<T = unknown>(): T;\n setValue(value: unknown): void;\n setDisabled(value: boolean): void;\n setVisible(value: boolean): void;\n remove(): void;\n addBeforeChange(cb: BeforeChangeCallback): void;\n addAfterChange(cb: AfterChangeCallback): void;\n addAfterSetValue(cb: AfterSetValueCallback): void;\n addOnBlur(cb: OnBlurCallback): void;\n blur(): void;\n as<T extends keyof FieldTypeMap>(type: T): FieldTypeMap[T];\n readonly vm: IFieldVM;\n readonly config: IFieldConfig;\n}\n\n/**\n * Maps field type strings to their typed field interfaces.\n * Extended via module augmentation when new field types are registered.\n */\nexport interface FieldTypeMap {\n text: IField;\n select: ISelectField;\n}\n\nexport interface ISelectField extends IField {\n readonly config: IFieldConfig & {\n options?: IValueOption[] | ((form: IFormModel) => IValueOption[]);\n };\n}\n\n// ---------------------------------------------------------------------------\n// Callback types\n// ---------------------------------------------------------------------------\n\nexport type BeforeChangeCallback = (value: unknown, form: IFormModel) => unknown;\nexport type AfterChangeCallback = (value: unknown, form: IFormModel) => void;\nexport type AfterSetValueCallback = (value: unknown, form: IFormModel) => void;\nexport type OnBlurCallback = (value: unknown, form: IFormModel) => void;\n\n// ---------------------------------------------------------------------------\n// Layout types\n// ---------------------------------------------------------------------------\n\nexport type LayoutNode = IRowNode | ISeparatorNode | ITabsNode | IElementNode | IObjectNode;\n\nexport interface IRowNode {\n type: \"row\";\n fieldIds: string[];\n}\n\nexport interface ISeparatorNode {\n type: \"separator\";\n}\n\nexport interface ITabDefinition {\n id: string;\n label: string;\n description?: string;\n icon?: string;\n layout: LayoutNode[];\n}\n\nexport interface ITabsNode {\n type: \"tabs\";\n id?: string;\n tabs: ITabDefinition[];\n}\n\nexport interface IElementNode {\n type: \"element\";\n id?: string;\n renderer: string;\n props?: Record<string, unknown>;\n}\n\nexport interface IObjectNode {\n type: \"object\";\n fieldId: string;\n layout?: LayoutNode[];\n templates?: Record<string, LayoutNode[]>;\n}\n\n// ---------------------------------------------------------------------------\n// Layout VM types\n// ---------------------------------------------------------------------------\n\nexport type LayoutNodeVM = IRowNodeVM | ISeparatorNodeVM | ITabsNodeVM | IElementNodeVM;\n\nexport interface IRowNodeVM {\n type: \"row\";\n fields: IFieldVM[];\n}\n\nexport interface ISeparatorNodeVM {\n type: \"separator\";\n}\n\nexport interface ITabDefinitionVM {\n id: string;\n label: string;\n description?: string;\n icon?: string;\n hasErrors: boolean;\n layout: LayoutNodeVM[];\n}\n\nexport interface ITabsNodeVM {\n type: \"tabs\";\n id?: string;\n tabs: ITabDefinitionVM[];\n activeTabId: string;\n setActiveTab: (id: string) => void;\n}\n\nexport interface IElementNodeVM {\n type: \"element\";\n renderer: string;\n props?: Record<string, unknown>;\n}\n\n// ---------------------------------------------------------------------------\n// Layout modifier types\n// ---------------------------------------------------------------------------\n\nexport type LayoutPosition =\n | { type: \"before\"; target: string }\n | { type: \"after\"; target: string }\n | { type: \"replace\"; target: string };\n\nexport interface IPositionedLayoutNode {\n node: LayoutNode;\n position?: LayoutPosition;\n}\n\n/**\n * Chainable handle returned by modifier layout.row().\n * Can be used as-is (appended) or positioned via .before()/.after()/.replace().\n */\nexport interface ILayoutNodeHandle extends IPositionedLayoutNode {\n before(target: string): IPositionedLayoutNode;\n after(target: string): IPositionedLayoutNode;\n replace(target: string): IPositionedLayoutNode;\n}\n\n// ---------------------------------------------------------------------------\n// Named layout node access types\n// ---------------------------------------------------------------------------\n\nexport interface ITabsHandle {\n tab(definition: ITabDefinition): ITabHandle;\n tab(id: string): ITabHandle;\n}\n\nexport interface ITabHandle {\n layout(factory: (layout: ILayoutBuilder) => LayoutNode[]): void;\n before(target: string): void;\n after(target: string): void;\n}\n\nexport interface ILayoutNodeAccessHandle {\n as(type: \"tabs\"): ITabsHandle;\n}\n\n// ---------------------------------------------------------------------------\n// Modifier types\n// ---------------------------------------------------------------------------\n\nexport interface IFormModifier {\n modify(form: IFormModel): void;\n}\n\nexport interface ILayoutModifier {\n row(...fieldIds: string[]): ILayoutNodeHandle;\n separator(): ILayoutNodeHandle;\n tabs(config: { id?: string; tabs: ITabDefinition[] }): ILayoutNodeHandle;\n element(renderer: string, props?: Record<string, unknown>): ILayoutNodeHandle;\n remove(target: string): void;\n}\n\n// ---------------------------------------------------------------------------\n// Form types\n// ---------------------------------------------------------------------------\n\nexport interface IFormError {\n path: string;\n label?: string;\n message: string;\n}\n\nexport interface IFormVM {\n layout: LayoutNodeVM[];\n errors: IFormError[];\n isDirty: boolean;\n isValid: boolean | null;\n}\n\nexport interface IFormModel {\n field(name: string): IField;\n fields(\n factory: (registry: IFieldBuilderRegistry) => Record<string, IFieldBuilder | undefined>\n ): void;\n layout(factory: (layout: ILayoutModifier) => (LayoutNode | IPositionedLayoutNode)[]): void;\n layout(nodeId: string): ILayoutNodeAccessHandle;\n getData(): Record<string, unknown>;\n setData(data: Record<string, unknown>): void;\n reset(): void;\n validate(): Promise<boolean>;\n submit<T = Record<string, unknown>>(): Promise<T | false>;\n readonly isDirty: boolean;\n readonly isValid: boolean | null;\n readonly errors: IFormError[];\n readonly vm: IFormVM;\n}\n\n// ---------------------------------------------------------------------------\n// FormModel namespace — groups all public types under one import\n// ---------------------------------------------------------------------------\n\nexport namespace FormModel {\n export type FieldConfig = IFieldConfig;\n export type ValueOption = IValueOption;\n export type FieldValidation = IFieldValidation;\n export type FieldVM = IFieldVM;\n export type Field = IField;\n export type SelectField = ISelectField;\n export type BeforeChange = BeforeChangeCallback;\n export type AfterChange = AfterChangeCallback;\n export type AfterSetValue = AfterSetValueCallback;\n export type OnBlur = OnBlurCallback;\n export type RowNode = IRowNode;\n export type RowNodeVM = IRowNodeVM;\n export type SeparatorNode = ISeparatorNode;\n export type SeparatorNodeVM = ISeparatorNodeVM;\n export type TabsNode = ITabsNode;\n export type TabDefinition = ITabDefinition;\n export type TabsNodeVM = ITabsNodeVM;\n export type TabDefinitionVM = ITabDefinitionVM;\n export type ElementNode = IElementNode;\n export type ElementNodeVM = IElementNodeVM;\n export type ObjectNode = IObjectNode;\n export type FormError = IFormError;\n export type FormVM = IFormVM;\n export type Interface = IFormModel;\n export type Modifier = IFormModifier;\n export type LayoutModifier = ILayoutModifier;\n}\n\n// ---------------------------------------------------------------------------\n// FormModelFactory abstraction\n// ---------------------------------------------------------------------------\n\nexport interface IFormModelFactory {\n create(config: IFormModelConfig): IFormModel;\n}\n\nexport interface IFormModelConfig {\n fields: (registry: IFieldBuilderRegistry) => Record<string, IFieldBuilder>;\n layout?: (layout: ILayoutBuilder) => LayoutNode[];\n validateOnSubmit?: boolean;\n}\n\nexport interface ILayoutBuilder {\n row(...fieldIds: string[]): IRowNode;\n separator(): ISeparatorNode;\n tabs(config: { id?: string; tabs: ITabDefinition[] }): ITabsNode;\n element(renderer: string, props?: Record<string, unknown>): IElementNode;\n}\n\nexport interface IFieldBuilder {\n label(text: string): this;\n placeholder(text: string): this;\n schema(zodSchema: z.ZodTypeAny): this;\n defaultValue(value: unknown): this;\n renderer(name: string): this;\n hidden(): this;\n required(message?: string): this;\n disabled(value?: boolean): this;\n beforeChange(fn: BeforeChangeCallback): this;\n afterChange(fn: AfterChangeCallback): this;\n afterSetValue(fn: AfterSetValueCallback): this;\n onBlur(fn: OnBlurCallback): this;\n build(name: string): IFieldConfig;\n}\n\nexport interface ISelectFieldBuilder extends IFieldBuilder {\n options(opts: IValueOption[] | ((form: IFormModel) => IValueOption[])): this;\n}\n\nexport interface IFieldBuilderRegistry {\n text(): IFieldBuilder;\n select(): ISelectFieldBuilder;\n}\n\nexport const FormModelFactory = createAbstraction<IFormModelFactory>(\"FormModelFactory\");\n\nexport namespace FormModelFactory {\n export type Interface = IFormModelFactory;\n export type Config = IFormModelConfig;\n export type LayoutBuilder = ILayoutBuilder;\n export type FieldBuilder = IFieldBuilder;\n export type SelectFieldBuilder = ISelectFieldBuilder;\n export type FieldBuilderRegistry = IFieldBuilderRegistry;\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,uBAAuB;;AAGzD;AACA;AACA;;AAiEA;AACA;AACA;AACA;;AAYA;AACA;AACA;;AAOA;AACA;AACA;;AAyCA;AACA;AACA;;AAoCA;AACA;AACA;;AAYA;AACA;AACA;AACA;;AAOA;AACA;AACA;;AAiBA;AACA;AACA;;AAcA;AACA;AACA;AAiCA;AACA;AACA;AAAA,WAEiBC,SAAS;AA6B1B;AACA;AACA;;AA4CA,OAAO,MAAMC,gBAAgB,GAAGF,iBAAiB,CAAoB,kBAAkB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createFeature } from "@webiny/feature/admin";
|
|
2
|
+
import { FormModelFactory as Abstraction } from "./abstractions.js";
|
|
3
|
+
import { FormModelFactory } from "./FormModelFactory.js";
|
|
4
|
+
export const FormModelFeature = createFeature({
|
|
5
|
+
name: "FormModel",
|
|
6
|
+
register(container) {
|
|
7
|
+
container.register(FormModelFactory).inSingletonScope();
|
|
8
|
+
},
|
|
9
|
+
resolve(container) {
|
|
10
|
+
return {
|
|
11
|
+
formModelFactory: container.resolve(Abstraction)
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=feature.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["createFeature","FormModelFactory","Abstraction","FormModelFeature","name","register","container","inSingletonScope","resolve","formModelFactory"],"sources":["feature.ts"],"sourcesContent":["import { createFeature } from \"@webiny/feature/admin\";\nimport { FormModelFactory as Abstraction } from \"./abstractions.js\";\nimport { FormModelFactory } from \"./FormModelFactory.js\";\n\nexport const FormModelFeature = createFeature({\n name: \"FormModel\",\n register(container) {\n container.register(FormModelFactory).inSingletonScope();\n },\n resolve(container) {\n return {\n formModelFactory: container.resolve(Abstraction)\n };\n }\n});\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,uBAAuB;AACrD,SAASC,gBAAgB,IAAIC,WAAW;AACxC,SAASD,gBAAgB;AAEzB,OAAO,MAAME,gBAAgB,GAAGH,aAAa,CAAC;EAC1CI,IAAI,EAAE,WAAW;EACjBC,QAAQA,CAACC,SAAS,EAAE;IAChBA,SAAS,CAACD,QAAQ,CAACJ,gBAAgB,CAAC,CAACM,gBAAgB,CAAC,CAAC;EAC3D,CAAC;EACDC,OAAOA,CAACF,SAAS,EAAE;IACf,OAAO;MACHG,gBAAgB,EAAEH,SAAS,CAACE,OAAO,CAACN,WAAW;IACnD,CAAC;EACL;AACJ,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { FormModelFeature } from "./feature.js";
|
|
2
|
+
export { FormModelFactory, FormModel } from "./abstractions.js";
|
|
3
|
+
export type { IFormModelFactory, IFormModelConfig, ILayoutBuilder, IFieldBuilder, ISelectFieldBuilder, IFieldBuilderRegistry, IFormModel, IField, ISelectField, FieldTypeMap, IFieldConfig, IFieldVM, IFieldValidation, IFormVM, IFormError, IValueOption, IRowNode, IRowNodeVM, ISeparatorNode, ISeparatorNodeVM, ITabsNode, ITabDefinition, ITabsNodeVM, ITabDefinitionVM, IElementNode, IElementNodeVM, IObjectNode, ILayoutNodeAccessHandle, ITabsHandle, ITabHandle, LayoutNode, LayoutNodeVM, LayoutPosition, IPositionedLayoutNode, ILayoutNodeHandle, ILayoutModifier, IFormModifier, BeforeChangeCallback, AfterChangeCallback, AfterSetValueCallback, OnBlurCallback } from "./abstractions.js";
|
|
4
|
+
export { FormModel as FormModelImpl } from "./FormModel.js";
|
|
5
|
+
export { Field } from "./Field.js";
|
|
6
|
+
export { FieldBuilder, TextFieldBuilder, SelectFieldBuilder, createFieldBuilderRegistry } from "./FieldBuilder.js";
|
|
7
|
+
export type { IFieldTypeFactory } from "./FieldBuilder.js";
|
|
8
|
+
export { FormView } from "./FormView.js";
|
|
9
|
+
export { useFieldRenderers } from "./useFieldRenderers.js";
|
|
10
|
+
export type { FieldRenderers, FieldRendererComponent } from "./FormView.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Feature
|
|
2
|
+
export { FormModelFeature } from "./feature.js";
|
|
3
|
+
|
|
4
|
+
// Abstractions (types + DI tokens)
|
|
5
|
+
export { FormModelFactory, FormModel } from "./abstractions.js";
|
|
6
|
+
// Implementations
|
|
7
|
+
export { FormModel as FormModelImpl } from "./FormModel.js";
|
|
8
|
+
export { Field } from "./Field.js";
|
|
9
|
+
export { FieldBuilder, TextFieldBuilder, SelectFieldBuilder, createFieldBuilderRegistry } from "./FieldBuilder.js";
|
|
10
|
+
// View
|
|
11
|
+
export { FormView } from "./FormView.js";
|
|
12
|
+
export { useFieldRenderers } from "./useFieldRenderers.js";
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["FormModelFeature","FormModelFactory","FormModel","FormModelImpl","Field","FieldBuilder","TextFieldBuilder","SelectFieldBuilder","createFieldBuilderRegistry","FormView","useFieldRenderers"],"sources":["index.ts"],"sourcesContent":["// Feature\nexport { FormModelFeature } from \"./feature.js\";\n\n// Abstractions (types + DI tokens)\nexport { FormModelFactory, FormModel } from \"./abstractions.js\";\nexport type {\n IFormModelFactory,\n IFormModelConfig,\n ILayoutBuilder,\n IFieldBuilder,\n ISelectFieldBuilder,\n IFieldBuilderRegistry,\n IFormModel,\n IField,\n ISelectField,\n FieldTypeMap,\n IFieldConfig,\n IFieldVM,\n IFieldValidation,\n IFormVM,\n IFormError,\n IValueOption,\n IRowNode,\n IRowNodeVM,\n ISeparatorNode,\n ISeparatorNodeVM,\n ITabsNode,\n ITabDefinition,\n ITabsNodeVM,\n ITabDefinitionVM,\n IElementNode,\n IElementNodeVM,\n IObjectNode,\n ILayoutNodeAccessHandle,\n ITabsHandle,\n ITabHandle,\n LayoutNode,\n LayoutNodeVM,\n LayoutPosition,\n IPositionedLayoutNode,\n ILayoutNodeHandle,\n ILayoutModifier,\n IFormModifier,\n BeforeChangeCallback,\n AfterChangeCallback,\n AfterSetValueCallback,\n OnBlurCallback\n} from \"./abstractions.js\";\n\n// Implementations\nexport { FormModel as FormModelImpl } from \"./FormModel.js\";\nexport { Field } from \"./Field.js\";\nexport {\n FieldBuilder,\n TextFieldBuilder,\n SelectFieldBuilder,\n createFieldBuilderRegistry\n} from \"./FieldBuilder.js\";\nexport type { IFieldTypeFactory } from \"./FieldBuilder.js\";\n\n// View\nexport { FormView } from \"./FormView.js\";\nexport { useFieldRenderers } from \"./useFieldRenderers.js\";\nexport type { FieldRenderers, FieldRendererComponent } from \"./FormView.js\";\n"],"mappings":"AAAA;AACA,SAASA,gBAAgB;;AAEzB;AACA,SAASC,gBAAgB,EAAEC,SAAS;AA6CpC;AACA,SAASA,SAAS,IAAIC,aAAa;AACnC,SAASC,KAAK;AACd,SACIC,YAAY,EACZC,gBAAgB,EAChBC,kBAAkB,EAClBC,0BAA0B;AAI9B;AACA,SAASC,QAAQ;AACjB,SAASC,iBAAiB","ignoreList":[]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { useAdminConfig } from "../../config/AdminConfig.js";
|
|
3
|
+
export const useFieldRenderers = () => {
|
|
4
|
+
const {
|
|
5
|
+
fieldRenderers
|
|
6
|
+
} = useAdminConfig();
|
|
7
|
+
return useMemo(() => {
|
|
8
|
+
const map = {};
|
|
9
|
+
for (const {
|
|
10
|
+
name,
|
|
11
|
+
component
|
|
12
|
+
} of fieldRenderers) {
|
|
13
|
+
map[name] = component;
|
|
14
|
+
}
|
|
15
|
+
return map;
|
|
16
|
+
}, [fieldRenderers]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
//# sourceMappingURL=useFieldRenderers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["useMemo","useAdminConfig","useFieldRenderers","fieldRenderers","map","name","component"],"sources":["useFieldRenderers.ts"],"sourcesContent":["import { useMemo } from \"react\";\nimport { useAdminConfig } from \"../../config/AdminConfig.js\";\nimport type { FieldRenderers } from \"./FormView.js\";\n\nexport const useFieldRenderers = (): FieldRenderers => {\n const { fieldRenderers } = useAdminConfig();\n\n return useMemo(() => {\n const map: FieldRenderers = {};\n for (const { name, component } of fieldRenderers) {\n map[name] = component;\n }\n return map;\n }, [fieldRenderers]);\n};\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,cAAc;AAGvB,OAAO,MAAMC,iBAAiB,GAAGA,CAAA,KAAsB;EACnD,MAAM;IAAEC;EAAe,CAAC,GAAGF,cAAc,CAAC,CAAC;EAE3C,OAAOD,OAAO,CAAC,MAAM;IACjB,MAAMI,GAAmB,GAAG,CAAC,CAAC;IAC9B,KAAK,MAAM;MAAEC,IAAI;MAAEC;IAAU,CAAC,IAAIH,cAAc,EAAE;MAC9CC,GAAG,CAACC,IAAI,CAAC,GAAGC,SAAS;IACzB;IACA,OAAOF,GAAG;EACd,CAAC,EAAE,CAACD,cAAc,CAAC,CAAC;AACxB,CAAC","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
|
|
2
2
|
import { LogInGateway as Abstraction, LogInRepository } from "./abstractions.js";
|
|
3
3
|
declare class LogInGatewayImpl implements Abstraction.Interface {
|
|
4
4
|
private graphqlClient;
|
|
5
|
-
constructor(graphqlClient:
|
|
5
|
+
constructor(graphqlClient: MainGraphQLClient.Interface);
|
|
6
6
|
execute(): Promise<LogInRepository.IdentityDTO>;
|
|
7
7
|
}
|
|
8
8
|
export declare const LogInGateway: typeof LogInGatewayImpl & {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
|
|
2
2
|
import { LogInGateway as Abstraction } from "./abstractions.js";
|
|
3
3
|
import { createLoginMutation } from "./createLoginMutation.js";
|
|
4
4
|
class LogInGatewayImpl {
|
|
@@ -21,7 +21,7 @@ class LogInGatewayImpl {
|
|
|
21
21
|
}
|
|
22
22
|
export const LogInGateway = Abstraction.createImplementation({
|
|
23
23
|
implementation: LogInGatewayImpl,
|
|
24
|
-
dependencies: [
|
|
24
|
+
dependencies: [MainGraphQLClient]
|
|
25
25
|
});
|
|
26
26
|
|
|
27
27
|
//# sourceMappingURL=LogInGateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["MainGraphQLClient","LogInGateway","Abstraction","createLoginMutation","LogInGatewayImpl","constructor","graphqlClient","execute","response","query","data","error","security","login","Error","message","createImplementation","implementation","dependencies"],"sources":["LogInGateway.ts"],"sourcesContent":["import { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport { LogInGateway as Abstraction, LogInRepository } from \"./abstractions.js\";\nimport { createLoginMutation } from \"./createLoginMutation.js\";\n\ninterface LoginMutationResponse {\n security: {\n login: {\n data: LogInRepository.IdentityDTO;\n error: {\n message: string;\n };\n };\n };\n}\n\nclass LogInGatewayImpl implements Abstraction.Interface {\n constructor(private graphqlClient: MainGraphQLClient.Interface) {}\n\n async execute(): Promise<LogInRepository.IdentityDTO> {\n const response = await this.graphqlClient.execute<LoginMutationResponse>({\n query: createLoginMutation()\n });\n\n const { data, error } = response.security.login;\n\n if (error) {\n throw new Error(error.message);\n }\n\n return data;\n }\n}\n\nexport const LogInGateway = Abstraction.createImplementation({\n implementation: LogInGatewayImpl,\n dependencies: [MainGraphQLClient]\n});\n"],"mappings":"AAAA,SAASA,iBAAiB,QAAQ,iDAAiD;AACnF,SAASC,YAAY,IAAIC,WAAW;AACpC,SAASC,mBAAmB;AAa5B,MAAMC,gBAAgB,CAAkC;EACpDC,WAAWA,CAASC,aAA0C,EAAE;IAAA,KAA5CA,aAA0C,GAA1CA,aAA0C;EAAG;EAEjE,MAAMC,OAAOA,CAAA,EAAyC;IAClD,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,aAAa,CAACC,OAAO,CAAwB;MACrEE,KAAK,EAAEN,mBAAmB,CAAC;IAC/B,CAAC,CAAC;IAEF,MAAM;MAAEO,IAAI;MAAEC;IAAM,CAAC,GAAGH,QAAQ,CAACI,QAAQ,CAACC,KAAK;IAE/C,IAAIF,KAAK,EAAE;MACP,MAAM,IAAIG,KAAK,CAACH,KAAK,CAACI,OAAO,CAAC;IAClC;IAEA,OAAOL,IAAI;EACf;AACJ;AAEA,OAAO,MAAMT,YAAY,GAAGC,WAAW,CAACc,oBAAoB,CAAC;EACzDC,cAAc,EAAEb,gBAAgB;EAChCc,YAAY,EAAE,CAAClB,iBAAiB;AACpC,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { WcpGateway as WcpGatewayAbstraction } from "./abstractions.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
|
|
3
3
|
import type { WcpProjectData } from "./types.js";
|
|
4
4
|
declare class WcpGraphQLGateway implements WcpGatewayAbstraction.Interface {
|
|
5
5
|
private client;
|
|
6
|
-
constructor(client:
|
|
6
|
+
constructor(client: MainGraphQLClient.Interface);
|
|
7
7
|
fetchProject(): Promise<WcpProjectData | null>;
|
|
8
8
|
}
|
|
9
9
|
export declare const WcpGateway: import("@webiny/di").Implementation<typeof WcpGraphQLGateway>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createImplementation } from "@webiny/di";
|
|
2
2
|
import { WcpGateway as WcpGatewayAbstraction } from "./abstractions.js";
|
|
3
|
-
import {
|
|
3
|
+
import { MainGraphQLClient } from "@webiny/app/features/mainGraphQLClient/index.js";
|
|
4
4
|
const GET_WCP_PROJECT = /* GraphQL */`
|
|
5
5
|
query GetWcpProject {
|
|
6
6
|
wcp {
|
|
@@ -67,7 +67,7 @@ class WcpGraphQLGateway {
|
|
|
67
67
|
export const WcpGateway = createImplementation({
|
|
68
68
|
abstraction: WcpGatewayAbstraction,
|
|
69
69
|
implementation: WcpGraphQLGateway,
|
|
70
|
-
dependencies: [
|
|
70
|
+
dependencies: [MainGraphQLClient]
|
|
71
71
|
});
|
|
72
72
|
|
|
73
73
|
//# sourceMappingURL=WcpGateway.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createImplementation","WcpGateway","WcpGatewayAbstraction","
|
|
1
|
+
{"version":3,"names":["createImplementation","WcpGateway","WcpGatewayAbstraction","MainGraphQLClient","GET_WCP_PROJECT","WcpGraphQLGateway","constructor","client","fetchProject","response","execute","query","headers","wcp","getProject","error","Error","message","data","abstraction","implementation","dependencies"],"sources":["WcpGateway.ts"],"sourcesContent":["import { createImplementation } from \"@webiny/di\";\nimport { WcpGateway as WcpGatewayAbstraction } from \"./abstractions.js\";\nimport { MainGraphQLClient } from \"@webiny/app/features/mainGraphQLClient/index.js\";\nimport type { GetWcpProjectResponse, WcpProjectData } from \"./types.js\";\n\nconst GET_WCP_PROJECT = /* GraphQL */ `\n query GetWcpProject {\n wcp {\n getProject {\n data {\n orgId\n projectId\n package {\n features {\n seats {\n enabled\n options\n }\n multiTenancy {\n enabled\n options\n }\n advancedPublishingWorkflow {\n enabled\n }\n advancedAccessControlLayer {\n enabled\n options\n }\n auditLogs {\n enabled\n }\n recordLocking {\n enabled\n }\n fileManager {\n enabled\n options\n }\n }\n }\n }\n error {\n message\n code\n data\n }\n }\n }\n }\n`;\n\nclass WcpGraphQLGateway implements WcpGatewayAbstraction.Interface {\n constructor(private client: MainGraphQLClient.Interface) {}\n\n async fetchProject(): Promise<WcpProjectData | null> {\n const response = await this.client.execute<GetWcpProjectResponse>({\n query: GET_WCP_PROJECT,\n headers: {\n \"x-tenant\": \"root\"\n }\n });\n\n if (response.wcp.getProject.error) {\n throw new Error(response.wcp.getProject.error.message);\n }\n\n return response.wcp.getProject.data;\n }\n}\n\nexport const WcpGateway = createImplementation({\n abstraction: WcpGatewayAbstraction,\n implementation: WcpGraphQLGateway,\n dependencies: [MainGraphQLClient]\n});\n"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,YAAY;AACjD,SAASC,UAAU,IAAIC,qBAAqB;AAC5C,SAASC,iBAAiB,QAAQ,iDAAiD;AAGnF,MAAMC,eAAe,GAAG,aAAc;AACtC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,CAAC;AAED,MAAMC,iBAAiB,CAA4C;EAC/DC,WAAWA,CAASC,MAAmC,EAAE;IAAA,KAArCA,MAAmC,GAAnCA,MAAmC;EAAG;EAE1D,MAAMC,YAAYA,CAAA,EAAmC;IACjD,MAAMC,QAAQ,GAAG,MAAM,IAAI,CAACF,MAAM,CAACG,OAAO,CAAwB;MAC9DC,KAAK,EAAEP,eAAe;MACtBQ,OAAO,EAAE;QACL,UAAU,EAAE;MAChB;IACJ,CAAC,CAAC;IAEF,IAAIH,QAAQ,CAACI,GAAG,CAACC,UAAU,CAACC,KAAK,EAAE;MAC/B,MAAM,IAAIC,KAAK,CAACP,QAAQ,CAACI,GAAG,CAACC,UAAU,CAACC,KAAK,CAACE,OAAO,CAAC;IAC1D;IAEA,OAAOR,QAAQ,CAACI,GAAG,CAACC,UAAU,CAACI,IAAI;EACvC;AACJ;AAEA,OAAO,MAAMjB,UAAU,GAAGD,oBAAoB,CAAC;EAC3CmB,WAAW,EAAEjB,qBAAqB;EAClCkB,cAAc,EAAEf,iBAAiB;EACjCgB,YAAY,EAAE,CAAClB,iBAAiB;AACpC,CAAC,CAAC","ignoreList":[]}
|
package/hooks/index.d.ts
CHANGED
package/hooks/index.js
CHANGED
package/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useConfirmationDialog.js\";\nexport * from \"./useDialog.js\";\nexport * from \"../components/Dialogs/useDialogs.js\";\nexport * from \"./useSnackbar.js\";\nexport * from \"./useKeyHandler.js\";\nexport * from \"./useShiftKey.js\";\nexport * from \"./useStateWithCallback.js\";\nexport * from \"./useModKey.js\";\nexport * from \"./useIsMounted.js\";\nexport * from \"./useStateIfMounted.js\";\nexport * from \"./useToggler.js\";\nexport * from \"./useHotkeys.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from \"./useConfirmationDialog.js\";\nexport * from \"./useDialog.js\";\nexport * from \"./useOpenDialog.js\";\nexport * from \"../components/Dialogs/useDialogs.js\";\nexport * from \"./useSnackbar.js\";\nexport * from \"./useKeyHandler.js\";\nexport * from \"./useShiftKey.js\";\nexport * from \"./useStateWithCallback.js\";\nexport * from \"./useModKey.js\";\nexport * from \"./useIsMounted.js\";\nexport * from \"./useStateIfMounted.js\";\nexport * from \"./useToggler.js\";\nexport * from \"./useHotkeys.js\";\n"],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","ignoreList":[]}
|
package/hooks/useDialog.d.ts
CHANGED
|
@@ -1,29 +1,9 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
export interface UseDialogResponseShowDialogOptions {
|
|
11
|
-
dataTestId?: string;
|
|
12
|
-
title: string;
|
|
13
|
-
loading?: boolean;
|
|
14
|
-
actions?: {
|
|
15
|
-
accept?: AcceptAction;
|
|
16
|
-
cancel?: CancelAction;
|
|
17
|
-
};
|
|
18
|
-
style?: {
|
|
19
|
-
[key: string]: any;
|
|
20
|
-
};
|
|
21
|
-
onClose?: () => void;
|
|
22
|
-
[key: string]: any;
|
|
23
|
-
}
|
|
24
|
-
interface UseDialogResponse {
|
|
25
|
-
showDialog: (message: React.ReactNode, options?: UseDialogResponseShowDialogOptions) => void;
|
|
26
|
-
hideDialog: () => void;
|
|
27
|
-
}
|
|
28
|
-
declare const useDialog: () => UseDialogResponse;
|
|
29
|
-
export { useDialog };
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
export declare function useDialog<T extends z.ZodTypeAny>(schema: T): {
|
|
3
|
+
params: z.infer<T>;
|
|
4
|
+
closeDialog: () => void;
|
|
5
|
+
};
|
|
6
|
+
export declare function useDialog(): {
|
|
7
|
+
params: Record<string, unknown>;
|
|
8
|
+
closeDialog: () => void;
|
|
9
|
+
};
|