@headless-adminapp/app 0.0.17-alpha.8 → 1.0.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/app/AppProvider.d.ts +0 -3
- package/app/AppProvider.js +10 -33
- package/app/AuthWrapper.d.ts +1 -1
- package/app/AuthWrapper.js +4 -1
- package/app/LayoutProvider.d.ts +8 -7
- package/app/LayoutProvider.js +28 -2
- package/app/context.d.ts +1 -1
- package/auth/AuthProvider.d.ts +1 -1
- package/auth/AuthProvider.js +30 -23
- package/auth/context.d.ts +2 -0
- package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
- package/auth/hooks/useIsSkipAuthCheck.js +8 -0
- package/auth/hooks/useLogout.js +1 -1
- package/board/BoardColumnDataResolver.d.ts +1 -0
- package/board/BoardColumnDataResolver.js +64 -0
- package/board/BoardColumnProvider.d.ts +7 -0
- package/board/BoardColumnProvider.js +36 -0
- package/board/context.d.ts +19 -0
- package/board/context.js +6 -0
- package/board/hooks/index.d.ts +6 -0
- package/board/hooks/index.js +15 -0
- package/board/hooks/useBoardColumnConfig.d.ts +2 -0
- package/board/hooks/useBoardColumnConfig.js +8 -0
- package/board/hooks/useBoardColumnData.d.ts +3 -0
- package/board/hooks/useBoardColumnData.js +9 -0
- package/board/hooks/useBoardColumnDataState.d.ts +5 -0
- package/board/hooks/useBoardColumnDataState.js +9 -0
- package/board/hooks/useBoardConfig.d.ts +3 -0
- package/board/hooks/useBoardConfig.js +8 -0
- package/board/hooks/useBoardSchema.d.ts +2 -0
- package/board/hooks/useBoardSchema.js +7 -0
- package/board/hooks/useSearchText.d.ts +1 -0
- package/board/hooks/useSearchText.js +14 -0
- package/board/types.d.ts +47 -0
- package/board/utils.d.ts +3 -0
- package/board/utils.js +6 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +15 -6
- package/builders/CommandBuilder/DefaultCommandBuilder.js +42 -20
- package/builders/CommandBuilder/FormCommandBuilder.d.ts +14 -13
- package/builders/CommandBuilder/FormCommandBuilder.js +66 -52
- package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +8 -27
- package/builders/CommandBuilder/SubgridCommandBuilder.js +115 -57
- package/builders/CommandBuilder/ViewCommandBuilder.js +32 -52
- package/builders/CommandBuilder/utils.js +1 -1
- package/builders/DefineFormExperience.d.ts +27 -0
- package/builders/DefineFormExperience.js +99 -0
- package/builders/DefineViewExperience.d.ts +13 -0
- package/builders/DefineViewExperience.js +33 -0
- package/builders/SchemaExperienceBuilder.d.ts +9 -7
- package/builders/SchemaExperienceBuilder.js +62 -40
- package/builders/utils.js +30 -44
- package/calendar/baseEventAttributes.d.ts +35 -0
- package/calendar/baseEventAttributes.js +38 -0
- package/calendar/context.d.ts +6 -0
- package/calendar/context.js +5 -0
- package/calendar/hooks/index.d.ts +1 -0
- package/{appearance → calendar}/hooks/index.js +1 -1
- package/calendar/hooks/useConfig.d.ts +3 -0
- package/calendar/hooks/useConfig.js +8 -0
- package/calendar/types.d.ts +41 -0
- package/calendar/types.js +2 -0
- package/calendar/utils.d.ts +3 -0
- package/calendar/utils.js +6 -0
- package/command/hooks/useBaseCommandHandlerContext.js +15 -6
- package/command/hooks/useCommands.js +1 -1
- package/command/utils/index.js +34 -9
- package/components/ScrollView/index.d.ts +1 -1
- package/components/ScrollView/index.js +2 -2
- package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
- package/components/ScrollbarWithMoreDataRequest/index.js +32 -0
- package/dataform/DataFormProvider/CustomHookExecuter.d.ts +5 -0
- package/dataform/DataFormProvider/CustomHookExecuter.js +14 -0
- package/dataform/DataFormProvider/DataResolver.d.ts +6 -4
- package/dataform/DataFormProvider/DataResolver.js +11 -94
- package/dataform/DataFormProvider/InitialValueResolver.js +3 -2
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +2 -3
- package/dataform/DataFormProvider/getRecord.d.ts +3 -0
- package/dataform/DataFormProvider/getRecord.js +56 -0
- package/dataform/DataFormProvider/index.d.ts +4 -0
- package/dataform/DataFormProvider/index.js +34 -12
- package/dataform/DataFormProvider/types.d.ts +13 -0
- package/dataform/DataFormProvider/types.js +2 -0
- package/dataform/DataFormProvider/utils.d.ts +23 -0
- package/dataform/DataFormProvider/utils.js +105 -0
- package/dataform/FormManager.d.ts +57 -0
- package/dataform/FormManager.js +247 -0
- package/dataform/constants.d.ts +1 -0
- package/dataform/constants.js +4 -0
- package/dataform/context.d.ts +26 -1
- package/dataform/hooks/index.d.ts +11 -0
- package/dataform/hooks/index.js +11 -0
- package/dataform/hooks/useContextKey.d.ts +1 -0
- package/dataform/hooks/useContextKey.js +8 -0
- package/dataform/hooks/useDisabledControlsManager.d.ts +6 -0
- package/dataform/hooks/useDisabledControlsManager.js +46 -0
- package/dataform/hooks/useEventManager.d.ts +1 -0
- package/dataform/hooks/useEventManager.js +8 -0
- package/dataform/hooks/useFormManager.d.ts +2 -0
- package/dataform/hooks/useFormManager.js +13 -0
- package/dataform/hooks/useFormNotifications.js +2 -2
- package/dataform/hooks/useFormSave.js +28 -31
- package/dataform/hooks/useHiddenControlsManager.d.ts +7 -0
- package/dataform/hooks/useHiddenControlsManager.js +50 -0
- package/dataform/hooks/useIsControlDisabled.d.ts +1 -0
- package/dataform/hooks/useIsControlDisabled.js +27 -0
- package/dataform/hooks/useIsControlHiddenByAttributeName.d.ts +1 -0
- package/dataform/hooks/useIsControlHiddenByAttributeName.js +17 -0
- package/dataform/hooks/useIsControlHiddenByKey.d.ts +1 -0
- package/dataform/hooks/useIsControlHiddenByKey.js +17 -0
- package/dataform/hooks/useIsFieldRequired.d.ts +1 -0
- package/dataform/hooks/useIsFieldRequired.js +25 -0
- package/dataform/hooks/useLoadFormGridPage.js +8 -17
- package/dataform/hooks/useMainFormCommands.d.ts +1 -12
- package/dataform/hooks/useMainFormCommands.js +13 -3
- package/dataform/hooks/useOnFieldValueChangeListener.d.ts +1 -0
- package/dataform/hooks/useOnFieldValueChangeListener.js +30 -0
- package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
- package/dataform/hooks/useProcessFlowSteps.js +45 -0
- package/dataform/hooks/useRecordTitle.d.ts +3 -1
- package/dataform/hooks/useRecordTitle.js +12 -5
- package/dataform/hooks/useRequiredFieldManager.d.ts +6 -0
- package/dataform/hooks/useRequiredFieldManager.js +49 -0
- package/dataform/test.d.ts +57 -0
- package/dataform/test.js +247 -0
- package/dataform/utils/defaultParameters.d.ts +6 -0
- package/dataform/utils/defaultParameters.js +54 -0
- package/dataform/utils/index.d.ts +6 -24
- package/dataform/utils/index.js +164 -190
- package/dataform/utils/saveRecord.d.ts +27 -0
- package/dataform/utils/saveRecord.js +163 -0
- package/datagrid/DataGridProvider/DataResolver.js +38 -109
- package/datagrid/DataGridProvider/index.d.ts +6 -0
- package/datagrid/DataGridProvider/index.js +18 -8
- package/datagrid/DataGridProvider/transformViewColumns.js +10 -2
- package/datagrid/DataGridProvider/utils.js +8 -8
- package/datagrid/column-filter/constants.js +38 -3
- package/datagrid/column-filter/utils.js +7 -1
- package/datagrid/context.d.ts +6 -0
- package/datagrid/hooks/useChangeView.js +1 -1
- package/datagrid/hooks/useGridColumnFilter.js +4 -1
- package/datagrid/hooks/useGridDisabled.d.ts +1 -0
- package/datagrid/hooks/useGridDisabled.js +8 -0
- package/datagrid/hooks/useLoadMainGridPage.js +1 -1
- package/datagrid/hooks/useMainGridCommands.js +23 -9
- package/datagrid/hooks/useOpenRecord.js +2 -2
- package/datagrid/hooks/useSubGridCommands.js +23 -45
- package/defaults.d.ts +2 -0
- package/defaults.js +5 -0
- package/dialog/hooks/useCloseDialog.js +17 -15
- package/dialog/hooks/useOpenAlertDialog.js +8 -3
- package/dialog/hooks/useOpenConfirmDialog.js +10 -4
- package/dialog/hooks/useOpenDialog.js +7 -5
- package/dialog/hooks/useOpenErrorDialog.js +8 -3
- package/dialog/hooks/useOpenPromptDialog.js +10 -4
- package/form/FormValidationStringContext.d.ts +1 -0
- package/form/FormValidationStringContext.js +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -0
- package/hooks/useDebouncedValue.js +0 -1
- package/hooks/useElementLayout.js +1 -1
- package/hooks/useIsMobile.js +0 -1
- package/hooks/useItemsWithKey.d.ts +7 -0
- package/hooks/useItemsWithKey.js +13 -0
- package/hooks/useStorageState.js +1 -2
- package/hooks/useSystemColorScheme.d.ts +1 -1
- package/hooks/useSystemColorScheme.js +0 -1
- package/insights/InsightsProvider.d.ts +8 -0
- package/insights/InsightsProvider.js +27 -0
- package/locale/LocaleProvider.d.ts +2 -1
- package/locale/LocaleProvider.js +3 -3
- package/locale/index.d.ts +1 -0
- package/locale/index.js +1 -0
- package/locale/useCurrencySymbol.d.ts +1 -0
- package/locale/useCurrencySymbol.js +12 -0
- package/locale/utils.js +4 -2
- package/metadata/MetadataProvider.d.ts +8 -4
- package/metadata/MetadataProvider.js +23 -17
- package/metadata/context.d.ts +3 -2
- package/metadata/hooks/index.d.ts +1 -1
- package/metadata/hooks/index.js +1 -1
- package/metadata/hooks/useAppExperience.d.ts +1 -0
- package/metadata/hooks/useAppExperience.js +8 -0
- package/metadata/hooks/useAppStore.d.ts +1 -1
- package/metadata/hooks/useAppStore.js +3 -3
- package/metadata/hooks/useExperienceView.js +2 -11
- package/metadata/hooks/useExperienceViewCommands.d.ts +1 -1
- package/metadata/hooks/useExperienceViewCommands.js +5 -14
- package/metadata/hooks/useExperienceViewLookup.js +2 -11
- package/metadata/hooks/useExperienceViewSubgridCommands.d.ts +1 -1
- package/metadata/hooks/useExperienceViewSubgridCommands.js +5 -14
- package/metadata/hooks/useMetadata.d.ts +11 -10
- package/metadata/hooks/useMetadata.js +4 -16
- package/metadata/hooks/useSchema.d.ts +1 -1
- package/metadata/hooks/useSchema.js +3 -0
- package/mutable/context.d.ts +3 -0
- package/mutable/context.js +8 -0
- package/mutable/utils.js +5 -12
- package/navigation/hooks/useOpenForm.js +4 -0
- package/package.json +6 -10
- package/providers/PageEntityFormProvider/index.d.ts +5 -1
- package/providers/PageEntityFormProvider/index.js +2 -2
- package/recordset/hooks/useRecordSetResult.js +4 -14
- package/route/RouteProvider.d.ts +2 -2
- package/route/RouteProvider.js +4 -1
- package/store/ClientAppStore.js +7 -20
- package/store/ComponentStore.d.ts +1 -1
- package/store/ComponentStore.js +6 -12
- package/store/EventManager.d.ts +2 -2
- package/store/EventManager.js +13 -29
- package/store/SchemaExperienceStore.js +179 -215
- package/store/index.d.ts +0 -1
- package/store/index.js +0 -1
- package/toast-notification/hooks/useCloseToastNotification.js +17 -15
- package/toast-notification/hooks/useOpenToastNotification.js +7 -5
- package/transport/InMemoryDataService/index.js +54 -77
- package/transport/RestDataService/index.d.ts +3 -3
- package/transport/RestDataService/index.js +68 -91
- package/transport/context.d.ts +2 -1
- package/transport/context.js +7 -1
- package/transport/hooks/index.d.ts +1 -0
- package/transport/hooks/index.js +1 -0
- package/transport/hooks/useFileService.d.ts +1 -0
- package/transport/hooks/useFileService.js +9 -0
- package/transport/hooks/useRetriveRecords.d.ts +33 -0
- package/transport/hooks/useRetriveRecords.js +110 -0
- package/utils/calculateColumnWidths.js +1 -1
- package/utils/color.d.ts +1 -0
- package/utils/color.js +14 -0
- package/utils/getAttributeFormattedValue.d.ts +4 -1
- package/utils/getAttributeFormattedValue.js +109 -54
- package/utils/phone.d.ts +13 -0
- package/utils/phone.js +33 -0
- package/appearance/context.d.ts +0 -7
- package/appearance/context.js +0 -5
- package/appearance/hooks/index.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.js +0 -12
- package/appearance/index.d.ts +0 -2
- package/appearance/index.js +0 -20
- package/builders/CommandBuilder.d.ts +0 -176
- package/builders/CommandBuilder.js +0 -567
- package/locale/types.d.ts +0 -2
- /package/{locale → board}/types.js +0 -0
package/dataform/test.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FormUiManager = void 0;
|
|
4
|
+
const utils_1 = require("./DataFormProvider/utils");
|
|
5
|
+
class FormUiManager {
|
|
6
|
+
contextState;
|
|
7
|
+
constructor(contextState) {
|
|
8
|
+
this.contextState = contextState;
|
|
9
|
+
}
|
|
10
|
+
get context() {
|
|
11
|
+
return this.contextState.value.current;
|
|
12
|
+
}
|
|
13
|
+
getAttribute(attributeName) {
|
|
14
|
+
return new FormAttribute(this.contextState, attributeName, this.context.schema.attributes[attributeName]);
|
|
15
|
+
}
|
|
16
|
+
getControl(name) {
|
|
17
|
+
const control = this.context.formInternal.controls.dict[name] ?? null;
|
|
18
|
+
if (!control) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return new Control(this.contextState, control);
|
|
22
|
+
}
|
|
23
|
+
getSection(name) {
|
|
24
|
+
const section = this.context.formInternal.sections.dict[name];
|
|
25
|
+
if (!section) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return new FormSection(this.contextState, section);
|
|
29
|
+
}
|
|
30
|
+
getTab(name) {
|
|
31
|
+
const tab = this.context.formInternal.tabs.dict[name];
|
|
32
|
+
if (!tab) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return new FormTab(this.contextState, tab);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.FormUiManager = FormUiManager;
|
|
39
|
+
class FormAttribute {
|
|
40
|
+
contextState;
|
|
41
|
+
attributeName;
|
|
42
|
+
attribute;
|
|
43
|
+
constructor(contextState, attributeName, attribute) {
|
|
44
|
+
this.contextState = contextState;
|
|
45
|
+
this.attributeName = attributeName;
|
|
46
|
+
this.attribute = attribute;
|
|
47
|
+
}
|
|
48
|
+
getInnerAttribute() {
|
|
49
|
+
return this.attribute;
|
|
50
|
+
}
|
|
51
|
+
setRequired(state) {
|
|
52
|
+
const control = this.contextState.value.current.formInternal.controls.dict[this.attributeName];
|
|
53
|
+
if (!control) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
if (control.type !== 'standard') {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
this.contextState.setValue((prev) => {
|
|
60
|
+
return {
|
|
61
|
+
requiredFields: {
|
|
62
|
+
...prev.requiredFields,
|
|
63
|
+
[this.attributeName]: state,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
getRequired() {
|
|
69
|
+
const attribute = this.attribute;
|
|
70
|
+
const control = this.contextState.value.current.formInternal.controls.dict[this.attributeName];
|
|
71
|
+
if (control.type !== 'standard') {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return (0, utils_1.getIsFieldRequired)({
|
|
75
|
+
attribute,
|
|
76
|
+
control,
|
|
77
|
+
requiredFields: this.contextState.value.current.requiredFields,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
resetRequired() {
|
|
81
|
+
this.contextState.setValue((prev) => {
|
|
82
|
+
const requiredFields = { ...prev.requiredFields };
|
|
83
|
+
delete requiredFields[this.attributeName];
|
|
84
|
+
return {
|
|
85
|
+
requiredFields,
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
getControls() {
|
|
90
|
+
return this.contextState.value.current.formInternal.controls.list
|
|
91
|
+
.filter((control) => control.type === 'standard' &&
|
|
92
|
+
control.attributeName === this.attributeName)
|
|
93
|
+
.map((control) => new Control(this.contextState, control));
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
class Control {
|
|
97
|
+
contextState;
|
|
98
|
+
control;
|
|
99
|
+
constructor(contextState, control) {
|
|
100
|
+
this.contextState = contextState;
|
|
101
|
+
this.control = control;
|
|
102
|
+
}
|
|
103
|
+
get context() {
|
|
104
|
+
return this.contextState.value.current;
|
|
105
|
+
}
|
|
106
|
+
getKey() {
|
|
107
|
+
let key = this.control.key;
|
|
108
|
+
if (!key && this.control.type === 'standard') {
|
|
109
|
+
key = this.control.attributeName;
|
|
110
|
+
}
|
|
111
|
+
return key;
|
|
112
|
+
}
|
|
113
|
+
getDisabled() {
|
|
114
|
+
if (this.control.type !== 'standard') {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const attributeName = this.control.attributeName;
|
|
118
|
+
return (0, utils_1.getIsFieldDisabled)({
|
|
119
|
+
control: this.control,
|
|
120
|
+
attribute: this.context.schema.attributes[attributeName],
|
|
121
|
+
disabledFields: this.context.disabledControls,
|
|
122
|
+
isFormReadonly: this.context.isReadonly,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
setDisabled(state) {
|
|
126
|
+
if (this.control.type !== 'standard') {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const key = this.control.attributeName;
|
|
130
|
+
this.contextState.setValue((prev) => {
|
|
131
|
+
return {
|
|
132
|
+
disabledControls: {
|
|
133
|
+
...prev.disabledControls,
|
|
134
|
+
[key]: state,
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
resetDisabled() {
|
|
140
|
+
if (this.control.type !== 'standard') {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
const key = this.control.attributeName;
|
|
144
|
+
this.contextState.setValue((prev) => {
|
|
145
|
+
const disabledFields = { ...prev.disabledControls };
|
|
146
|
+
delete disabledFields[key];
|
|
147
|
+
return {
|
|
148
|
+
disabledControls: disabledFields,
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
getHidden() {
|
|
153
|
+
return (0, utils_1.getIsControlHidden)({
|
|
154
|
+
control: this.control,
|
|
155
|
+
hiddenControls: this.context.hiddenControls,
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
setHidden(state) {
|
|
159
|
+
const key = this.getKey();
|
|
160
|
+
if (!key) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.contextState.setValue((prev) => {
|
|
164
|
+
return {
|
|
165
|
+
hiddenControls: {
|
|
166
|
+
...prev.hiddenControls,
|
|
167
|
+
[key]: state,
|
|
168
|
+
},
|
|
169
|
+
};
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
resetHidden() {
|
|
173
|
+
const key = this.getKey();
|
|
174
|
+
if (!key) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
this.contextState.setValue((prev) => {
|
|
178
|
+
const hiddenControls = { ...prev.hiddenControls };
|
|
179
|
+
delete hiddenControls[key];
|
|
180
|
+
return {
|
|
181
|
+
hiddenControls,
|
|
182
|
+
};
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
class FormSection {
|
|
187
|
+
contextState;
|
|
188
|
+
section;
|
|
189
|
+
constructor(contextState, section) {
|
|
190
|
+
this.contextState = contextState;
|
|
191
|
+
this.section = section;
|
|
192
|
+
}
|
|
193
|
+
setHidden(state) {
|
|
194
|
+
this.contextState.setValue((prev) => {
|
|
195
|
+
return {
|
|
196
|
+
hiddenSections: {
|
|
197
|
+
...prev.hiddenSections,
|
|
198
|
+
[this.section.name]: state,
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
getHidden() {
|
|
204
|
+
return (this.contextState.value.current.hiddenSections[this.section.name] ??
|
|
205
|
+
this.section.hidden ??
|
|
206
|
+
false);
|
|
207
|
+
}
|
|
208
|
+
resetHidden() {
|
|
209
|
+
this.contextState.setValue((prev) => {
|
|
210
|
+
const hiddenSections = { ...prev.hiddenSections };
|
|
211
|
+
delete hiddenSections[this.section.name];
|
|
212
|
+
return {
|
|
213
|
+
hiddenSections,
|
|
214
|
+
};
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
class FormTab {
|
|
219
|
+
contextState;
|
|
220
|
+
tab;
|
|
221
|
+
constructor(contextState, tab) {
|
|
222
|
+
this.contextState = contextState;
|
|
223
|
+
this.tab = tab;
|
|
224
|
+
}
|
|
225
|
+
setHidden(state) {
|
|
226
|
+
this.contextState.setValue((prev) => {
|
|
227
|
+
return {
|
|
228
|
+
hiddenTabs: {
|
|
229
|
+
...prev.hiddenTabs,
|
|
230
|
+
[this.tab.name]: state,
|
|
231
|
+
},
|
|
232
|
+
};
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
getHidden() {
|
|
236
|
+
return this.contextState.value.current.hiddenTabs[this.tab.name] ?? false;
|
|
237
|
+
}
|
|
238
|
+
resetHidden() {
|
|
239
|
+
this.contextState.setValue((prev) => {
|
|
240
|
+
const hiddenTabs = { ...prev.hiddenTabs };
|
|
241
|
+
delete hiddenTabs[this.tab.name];
|
|
242
|
+
return {
|
|
243
|
+
hiddenTabs,
|
|
244
|
+
};
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { FormExperience } from '@headless-adminapp/core/experience/form';
|
|
2
|
+
import { Schema } from '@headless-adminapp/core/schema';
|
|
3
|
+
export declare function getFormDefaultParameters(schema: Schema, formExperience: FormExperience): {
|
|
4
|
+
[x: string]: any;
|
|
5
|
+
};
|
|
6
|
+
export declare function setFormDefaultParameters(logicalName: string, values: Record<string, any>): void;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getFormDefaultParameters = getFormDefaultParameters;
|
|
4
|
+
exports.setFormDefaultParameters = setFormDefaultParameters;
|
|
5
|
+
let formDefaultParameters = null;
|
|
6
|
+
function getFormDefaultParameters(schema, formExperience) {
|
|
7
|
+
const _values = formDefaultParameters?.values;
|
|
8
|
+
const _logicalName = formDefaultParameters?.logicalName;
|
|
9
|
+
const schemaDefaultValues = Object.keys(schema.attributes).reduce((acc, key) => {
|
|
10
|
+
const attribute = schema.attributes[key];
|
|
11
|
+
let defaultValue = attribute.default;
|
|
12
|
+
if (typeof defaultValue === 'function') {
|
|
13
|
+
defaultValue = defaultValue();
|
|
14
|
+
}
|
|
15
|
+
if (defaultValue instanceof Date) {
|
|
16
|
+
defaultValue = defaultValue.toISOString();
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
...acc,
|
|
20
|
+
[key]: defaultValue,
|
|
21
|
+
};
|
|
22
|
+
}, {});
|
|
23
|
+
let formDefaultValues = {};
|
|
24
|
+
if (typeof formExperience.defaultValues === 'function') {
|
|
25
|
+
formDefaultValues = formExperience.defaultValues();
|
|
26
|
+
}
|
|
27
|
+
else if (typeof formExperience.defaultValues === 'object') {
|
|
28
|
+
formDefaultValues = formExperience.defaultValues;
|
|
29
|
+
}
|
|
30
|
+
let defaultValues = {
|
|
31
|
+
...schemaDefaultValues,
|
|
32
|
+
...formDefaultValues,
|
|
33
|
+
};
|
|
34
|
+
if (_logicalName === schema.logicalName) {
|
|
35
|
+
defaultValues = {
|
|
36
|
+
...defaultValues,
|
|
37
|
+
..._values,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return defaultValues;
|
|
41
|
+
}
|
|
42
|
+
let defaultParamsTimeout = null;
|
|
43
|
+
function setFormDefaultParameters(logicalName, values) {
|
|
44
|
+
formDefaultParameters = {
|
|
45
|
+
logicalName,
|
|
46
|
+
values,
|
|
47
|
+
};
|
|
48
|
+
if (defaultParamsTimeout) {
|
|
49
|
+
clearTimeout(defaultParamsTimeout);
|
|
50
|
+
}
|
|
51
|
+
defaultParamsTimeout = setTimeout(() => {
|
|
52
|
+
formDefaultParameters = null;
|
|
53
|
+
}, 5000);
|
|
54
|
+
}
|
|
@@ -2,32 +2,13 @@ import type { Attribute } from '@headless-adminapp/core/attributes';
|
|
|
2
2
|
import { Form } from '@headless-adminapp/core/experience/form';
|
|
3
3
|
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
4
4
|
import { ISchemaStore } from '@headless-adminapp/core/store';
|
|
5
|
-
import { IDataService } from '@headless-adminapp/core/transport';
|
|
6
5
|
import { Nullable } from '@headless-adminapp/core/types';
|
|
7
6
|
import { MemoizedFunction } from 'lodash';
|
|
8
7
|
import { ResolverResult } from 'react-hook-form';
|
|
9
8
|
import * as yup from 'yup';
|
|
10
9
|
import { FormValidationStringSet } from '../../form/FormValidationStringContext';
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
success: true;
|
|
14
|
-
recordId: string;
|
|
15
|
-
} | {
|
|
16
|
-
success: false;
|
|
17
|
-
title?: string;
|
|
18
|
-
message: string;
|
|
19
|
-
isError: boolean;
|
|
20
|
-
};
|
|
21
|
-
export declare function saveRecord({ values, form, schema, dataService, initialValues, record, schemaStore, }: {
|
|
22
|
-
values: any;
|
|
23
|
-
form: Form<SchemaAttributes>;
|
|
24
|
-
record: InferredSchemaType<SchemaAttributes> | undefined;
|
|
25
|
-
initialValues: Nullable<InferredSchemaType<SchemaAttributes>>;
|
|
26
|
-
schema: Schema<SchemaAttributes>;
|
|
27
|
-
dataService: IDataService;
|
|
28
|
-
schemaStore: ISchemaStore;
|
|
29
|
-
}): Promise<SaveRecordResult>;
|
|
30
|
-
export declare function getInitialValues({ cloneRecord, form, record, recordId, defaultParameters, }: {
|
|
10
|
+
export { saveRecord } from './saveRecord';
|
|
11
|
+
export declare function getInitialValues({ cloneRecord, form, record, recordId, schema, defaultParameters, }: {
|
|
31
12
|
cloneRecord: InferredSchemaType<SchemaAttributes> | undefined;
|
|
32
13
|
form: Form<SchemaAttributes>;
|
|
33
14
|
record: InferredSchemaType<SchemaAttributes> | undefined;
|
|
@@ -43,10 +24,11 @@ interface FormValidatorOptions<A extends SchemaAttributes = SchemaAttributes> {
|
|
|
43
24
|
readonlyAttributes?: string[];
|
|
44
25
|
strings: FormValidationStringSet;
|
|
45
26
|
schemaStore: ISchemaStore;
|
|
27
|
+
region: string;
|
|
46
28
|
}
|
|
47
29
|
type FormValidator = (<A extends SchemaAttributes = SchemaAttributes>(options: FormValidatorOptions<A>) => (values: Record<string, any>, context: any, options: any) => Promise<ResolverResult<{}>>) & MemoizedFunction;
|
|
48
30
|
export declare const formValidator: FormValidator;
|
|
49
|
-
export declare const generateValidationSchema: (<A extends SchemaAttributes = SchemaAttributes>({ columns, editableGrids, language, schema, strings, readonlyAttributes, }: {
|
|
31
|
+
export declare const generateValidationSchema: (<A extends SchemaAttributes = SchemaAttributes>({ columns, editableGrids, language, schema, strings, readonlyAttributes, region, }: {
|
|
50
32
|
schema: Schema<A>;
|
|
51
33
|
columns: string[];
|
|
52
34
|
readonlyAttributes?: string[];
|
|
@@ -58,10 +40,10 @@ export declare const generateValidationSchema: (<A extends SchemaAttributes = Sc
|
|
|
58
40
|
}> | undefined;
|
|
59
41
|
language: string;
|
|
60
42
|
strings: FormValidationStringSet;
|
|
43
|
+
region: string;
|
|
61
44
|
}) => yup.ObjectSchema<{
|
|
62
45
|
[x: string]: any;
|
|
63
46
|
}, yup.AnyObject, {
|
|
64
47
|
[x: string]: any;
|
|
65
48
|
}, "">) & MemoizedFunction;
|
|
66
|
-
export declare const generateAttributeValidationSchema: ((attribute: Attribute, language: string, strings: FormValidationStringSet) => yup.Schema<any, any, any, "">) & MemoizedFunction;
|
|
67
|
-
export {};
|
|
49
|
+
export declare const generateAttributeValidationSchema: ((attribute: Attribute, language: string, strings: FormValidationStringSet, region: string) => yup.Schema<any, any, any, "">) & MemoizedFunction;
|