@headless-adminapp/app 0.0.17-alpha.1 → 0.0.17-alpha.4
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/AuthWrapper.d.ts +7 -0
- package/app/AuthWrapper.js +23 -0
- package/app/LayoutProvider.d.ts +22 -0
- package/app/LayoutProvider.js +19 -0
- package/app/index.d.ts +1 -0
- package/app/index.js +3 -1
- package/builders/SchemaExperienceBuilder.js +0 -10
- package/dataform/DataFormProvider/InitialValueResolver.js +0 -1
- package/dataform/utils/index.js +0 -5
- package/datagrid/hooks/useMainGridCommands.js +0 -122
- package/datagrid/hooks/useSubGridCommands.js +0 -3
- package/package.json +2 -2
- package/recordset/hooks/useRecordSetResult.js +0 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
import { AuthProviderPlaceholderProps } from '../auth';
|
|
3
|
+
interface AuthWrapperProps {
|
|
4
|
+
Placeholder: FC<AuthProviderPlaceholderProps>;
|
|
5
|
+
}
|
|
6
|
+
export declare const AuthWrapper: FC<PropsWithChildren<AuthWrapperProps>>;
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AuthWrapper = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const auth_1 = require("../auth");
|
|
6
|
+
const mutable_1 = require("../mutable");
|
|
7
|
+
const AuthWrapper = ({ children, Placeholder, }) => {
|
|
8
|
+
const state = (0, mutable_1.useContextSelector)(auth_1.AuthContext, (state) => state);
|
|
9
|
+
if (state.loadError) {
|
|
10
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { loadingError: true, retry: state.loadSession });
|
|
11
|
+
}
|
|
12
|
+
if (!state.initialized || state.loading) {
|
|
13
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { loading: true, retry: state.loadSession });
|
|
14
|
+
}
|
|
15
|
+
if (!state.authenticated) {
|
|
16
|
+
if (state.sessionExpired) {
|
|
17
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { sessionExpired: true, retry: state.loadSession });
|
|
18
|
+
}
|
|
19
|
+
return (0, jsx_runtime_1.jsx)(Placeholder, { unauthorized: true, retry: state.loadSession });
|
|
20
|
+
}
|
|
21
|
+
return children;
|
|
22
|
+
};
|
|
23
|
+
exports.AuthWrapper = AuthWrapper;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IDataService } from '@headless-adminapp/core/transport';
|
|
2
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
3
|
+
import { FC, PropsWithChildren } from 'react';
|
|
4
|
+
import { AuthProviderPlaceholderProps, AuthProviderProps } from '../auth';
|
|
5
|
+
import { LocaleProviderProps } from '../locale';
|
|
6
|
+
import { MetadataProviderProps } from '../metadata/MetadataProvider';
|
|
7
|
+
import { RouteProviderProps } from '../route/RouteProvider';
|
|
8
|
+
export interface LayoutProviderProps {
|
|
9
|
+
routeProps: RouteProviderProps;
|
|
10
|
+
queryClient: QueryClient;
|
|
11
|
+
localeProps: LocaleProviderProps;
|
|
12
|
+
dataService: IDataService;
|
|
13
|
+
authProps: AuthProviderProps;
|
|
14
|
+
authPlaceholder: FC<AuthProviderPlaceholderProps>;
|
|
15
|
+
metadataProps: MetadataProviderProps;
|
|
16
|
+
containers: {
|
|
17
|
+
DialogContainer: FC;
|
|
18
|
+
ProgressIndicatorContainer: FC;
|
|
19
|
+
ToastNotificationContainer: FC;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export declare const LayoutProvider: FC<PropsWithChildren<LayoutProviderProps>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LayoutProvider = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
6
|
+
const auth_1 = require("../auth");
|
|
7
|
+
const dialog_1 = require("../dialog");
|
|
8
|
+
const locale_1 = require("../locale");
|
|
9
|
+
const metadata_1 = require("../metadata");
|
|
10
|
+
const progress_indicator_1 = require("../progress-indicator");
|
|
11
|
+
const recordset_1 = require("../recordset");
|
|
12
|
+
const route_1 = require("../route");
|
|
13
|
+
const toast_notification_1 = require("../toast-notification");
|
|
14
|
+
const transport_1 = require("../transport");
|
|
15
|
+
const AuthWrapper_1 = require("./AuthWrapper");
|
|
16
|
+
const LayoutProvider = ({ authPlaceholder, authProps, dataService, localeProps, metadataProps, queryClient, routeProps, children, containers: { DialogContainer, ProgressIndicatorContainer, ToastNotificationContainer, }, }) => {
|
|
17
|
+
return ((0, jsx_runtime_1.jsx)(route_1.RouteProvider, Object.assign({}, routeProps, { children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: queryClient, children: (0, jsx_runtime_1.jsx)(locale_1.LocaleProvider, Object.assign({}, localeProps, { children: (0, jsx_runtime_1.jsx)(metadata_1.MetadataProvider, Object.assign({}, metadataProps, { children: (0, jsx_runtime_1.jsx)(transport_1.DataServiceContext.Provider, { value: dataService, children: (0, jsx_runtime_1.jsx)(dialog_1.DialogProvider, { children: (0, jsx_runtime_1.jsx)(progress_indicator_1.ProgressIndicatorProvider, { children: (0, jsx_runtime_1.jsxs)(toast_notification_1.ToastNotificationProvider, { children: [(0, jsx_runtime_1.jsx)(DialogContainer, {}), (0, jsx_runtime_1.jsx)(ProgressIndicatorContainer, {}), (0, jsx_runtime_1.jsx)(ToastNotificationContainer, {}), (0, jsx_runtime_1.jsx)(auth_1.AuthProvider, Object.assign({}, authProps, { children: (0, jsx_runtime_1.jsx)(AuthWrapper_1.AuthWrapper, { Placeholder: authPlaceholder, children: (0, jsx_runtime_1.jsx)(recordset_1.RecordSetProvider, { children: children }) }) }))] }) }) }) }) })) })) }) })));
|
|
18
|
+
};
|
|
19
|
+
exports.LayoutProvider = LayoutProvider;
|
package/app/index.d.ts
CHANGED
package/app/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
|
|
3
|
+
exports.LayoutProvider = exports.AppProvider = exports.useAppContext = exports.AppContext = void 0;
|
|
4
4
|
var context_1 = require("./context");
|
|
5
5
|
Object.defineProperty(exports, "AppContext", { enumerable: true, get: function () { return context_1.AppContext; } });
|
|
6
6
|
var hooks_1 = require("./hooks");
|
|
7
7
|
Object.defineProperty(exports, "useAppContext", { enumerable: true, get: function () { return hooks_1.useAppContext; } });
|
|
8
8
|
var AppProvider_1 = require("./AppProvider");
|
|
9
9
|
Object.defineProperty(exports, "AppProvider", { enumerable: true, get: function () { return AppProvider_1.AppProvider; } });
|
|
10
|
+
var LayoutProvider_1 = require("./LayoutProvider");
|
|
11
|
+
Object.defineProperty(exports, "LayoutProvider", { enumerable: true, get: function () { return LayoutProvider_1.LayoutProvider; } });
|
|
@@ -61,12 +61,6 @@ class BaseSchemaExperienceBuilder {
|
|
|
61
61
|
quickCreateForms: this.quickCreateForms,
|
|
62
62
|
};
|
|
63
63
|
}
|
|
64
|
-
// public createView(view: Omit<View<S>, 'logicalName'>): View<S> {
|
|
65
|
-
// return {
|
|
66
|
-
// logicalName: this.logicalName,
|
|
67
|
-
// ...view,
|
|
68
|
-
// };
|
|
69
|
-
// }
|
|
70
64
|
defineFormExperience(formExperience) {
|
|
71
65
|
return formExperience;
|
|
72
66
|
}
|
|
@@ -190,11 +184,7 @@ class SchemaExperienceBuilder extends BaseSchemaExperienceBuilder {
|
|
|
190
184
|
return defaultId;
|
|
191
185
|
}
|
|
192
186
|
defineExperience(experience) {
|
|
193
|
-
// if (!experience.defaultFormId) {
|
|
194
|
-
// throw new Error('Default form is required');
|
|
195
|
-
// }
|
|
196
187
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
197
|
-
// console.log('experience', experience);
|
|
198
188
|
let lookups = experience.lookups;
|
|
199
189
|
let views = experience.views;
|
|
200
190
|
let forms = experience.forms;
|
|
@@ -33,7 +33,6 @@ function InitialValueResolver() {
|
|
|
33
33
|
formInstanceRef.current = formInstance;
|
|
34
34
|
(0, react_1.useEffect)(() => {
|
|
35
35
|
const timer = setTimeout(() => {
|
|
36
|
-
// console.log('resetting form', initialValues);
|
|
37
36
|
formInstanceRef.current.reset(initialValues);
|
|
38
37
|
});
|
|
39
38
|
return () => {
|
package/dataform/utils/index.js
CHANGED
|
@@ -121,9 +121,6 @@ function saveRecord(_a) {
|
|
|
121
121
|
isError: false,
|
|
122
122
|
};
|
|
123
123
|
}
|
|
124
|
-
if (operations.length > 0) {
|
|
125
|
-
console.log('operations', operations);
|
|
126
|
-
}
|
|
127
124
|
for (const operation of operations) {
|
|
128
125
|
switch (operation.type) {
|
|
129
126
|
case 'create':
|
|
@@ -217,7 +214,6 @@ function getInitialValues({ cloneRecord, form, record, recordId, defaultParamete
|
|
|
217
214
|
}
|
|
218
215
|
exports.formValidator = (0, lodash_1.memoize)(function formValidator({ form, schema, readonlyAttributes, formReadOnly, getSchema, language, strings, }) {
|
|
219
216
|
return (values, context, options) => __awaiter(this, void 0, void 0, function* () {
|
|
220
|
-
// console.log('formValidator', values);
|
|
221
217
|
let validator = yup.object().shape({});
|
|
222
218
|
if (!formReadOnly) {
|
|
223
219
|
const activeControls = form.experience.tabs
|
|
@@ -264,7 +260,6 @@ exports.formValidator = (0, lodash_1.memoize)(function formValidator({ form, sch
|
|
|
264
260
|
}
|
|
265
261
|
const resolver = (0, yup_1.yupResolver)(validator);
|
|
266
262
|
const result = yield resolver(values, context, options);
|
|
267
|
-
// console.log(result);
|
|
268
263
|
return result;
|
|
269
264
|
});
|
|
270
265
|
}, ({ form, language, schema, strings, readonlyAttributes, formReadOnly }) => JSON.stringify({
|
|
@@ -97,129 +97,7 @@ function useMainGridCommandHandlerContext() {
|
|
|
97
97
|
function useMainGridCommands() {
|
|
98
98
|
const commands = (0, useGridCommands_1.useGridCommands)();
|
|
99
99
|
const handlerContext = useMainGridCommandHandlerContext();
|
|
100
|
-
// console.log('temp. gc', commands);
|
|
101
100
|
return (0, command_1.useCommands)(commands, handlerContext);
|
|
102
|
-
// return [
|
|
103
|
-
// [
|
|
104
|
-
// {
|
|
105
|
-
// type: 'button',
|
|
106
|
-
// icon: 'Add',
|
|
107
|
-
// text: 'Add',
|
|
108
|
-
// },
|
|
109
|
-
// {
|
|
110
|
-
// type: 'button',
|
|
111
|
-
// icon: 'Delete',
|
|
112
|
-
// text: 'Delete',
|
|
113
|
-
// danger: true,
|
|
114
|
-
// },
|
|
115
|
-
// {
|
|
116
|
-
// type: 'button',
|
|
117
|
-
// icon: 'Add',
|
|
118
|
-
// text: 'Add',
|
|
119
|
-
// },
|
|
120
|
-
// {
|
|
121
|
-
// type: 'button',
|
|
122
|
-
// icon: 'Add',
|
|
123
|
-
// text: 'Add',
|
|
124
|
-
// },
|
|
125
|
-
// ],
|
|
126
|
-
// [
|
|
127
|
-
// {
|
|
128
|
-
// type: 'button',
|
|
129
|
-
// icon: 'Add',
|
|
130
|
-
// text: 'Add',
|
|
131
|
-
// },
|
|
132
|
-
// {
|
|
133
|
-
// type: 'button',
|
|
134
|
-
// icon: 'Add',
|
|
135
|
-
// text: 'Add',
|
|
136
|
-
// },
|
|
137
|
-
// {
|
|
138
|
-
// type: 'button',
|
|
139
|
-
// icon: 'Add',
|
|
140
|
-
// text: 'Add',
|
|
141
|
-
// },
|
|
142
|
-
// {
|
|
143
|
-
// type: 'button',
|
|
144
|
-
// icon: 'Add',
|
|
145
|
-
// text: 'Add',
|
|
146
|
-
// },
|
|
147
|
-
// {
|
|
148
|
-
// type: 'button',
|
|
149
|
-
// icon: 'Add',
|
|
150
|
-
// text: 'Add',
|
|
151
|
-
// },
|
|
152
|
-
// {
|
|
153
|
-
// type: 'button',
|
|
154
|
-
// icon: 'Add',
|
|
155
|
-
// text: 'Add',
|
|
156
|
-
// },
|
|
157
|
-
// {
|
|
158
|
-
// type: 'menu',
|
|
159
|
-
// icon: 'Add',
|
|
160
|
-
// text: 'Report',
|
|
161
|
-
// danger: true,
|
|
162
|
-
// handlerId: 'report',
|
|
163
|
-
// items: [
|
|
164
|
-
// {
|
|
165
|
-
// icon: 'Add',
|
|
166
|
-
// text: 'Export',
|
|
167
|
-
// danger: true,
|
|
168
|
-
// },
|
|
169
|
-
// ],
|
|
170
|
-
// },
|
|
171
|
-
// {
|
|
172
|
-
// type: 'menu',
|
|
173
|
-
// icon: 'Add',
|
|
174
|
-
// text: 'Report',
|
|
175
|
-
// danger: true,
|
|
176
|
-
// items: [
|
|
177
|
-
// {
|
|
178
|
-
// icon: 'Add',
|
|
179
|
-
// text: 'Export',
|
|
180
|
-
// danger: true,
|
|
181
|
-
// },
|
|
182
|
-
// ],
|
|
183
|
-
// },
|
|
184
|
-
// ],
|
|
185
|
-
// [
|
|
186
|
-
// {
|
|
187
|
-
// type: 'button',
|
|
188
|
-
// icon: 'Add',
|
|
189
|
-
// text: 'Add',
|
|
190
|
-
// },
|
|
191
|
-
// {
|
|
192
|
-
// type: 'button',
|
|
193
|
-
// icon: 'Add',
|
|
194
|
-
// text: 'Add',
|
|
195
|
-
// },
|
|
196
|
-
// {
|
|
197
|
-
// type: 'button',
|
|
198
|
-
// icon: 'Add',
|
|
199
|
-
// text: 'Add',
|
|
200
|
-
// },
|
|
201
|
-
// {
|
|
202
|
-
// type: 'button',
|
|
203
|
-
// icon: 'Add',
|
|
204
|
-
// text: 'Add',
|
|
205
|
-
// },
|
|
206
|
-
// {
|
|
207
|
-
// type: 'button',
|
|
208
|
-
// icon: 'Add',
|
|
209
|
-
// text: 'Add',
|
|
210
|
-
// },
|
|
211
|
-
// {
|
|
212
|
-
// type: 'button',
|
|
213
|
-
// icon: 'Add',
|
|
214
|
-
// text: 'Add',
|
|
215
|
-
// },
|
|
216
|
-
// {
|
|
217
|
-
// type: 'button',
|
|
218
|
-
// icon: 'Add',
|
|
219
|
-
// text: 'Add',
|
|
220
|
-
// },
|
|
221
|
-
// ],
|
|
222
|
-
// ];
|
|
223
101
|
}
|
|
224
102
|
function useMainGridContextCommands() {
|
|
225
103
|
const commands = (0, useGridCommands_1.useGridCommands)();
|
|
@@ -46,7 +46,6 @@ function useSubGridCommandHandlerContext() {
|
|
|
46
46
|
const utility = (0, useMainGridCommands_1.useUtility)();
|
|
47
47
|
const locale = (0, useLocale_1.useLocale)();
|
|
48
48
|
const mainFormHandlerContext = (0, useMainFormCommands_1.useMainFormCommandHandlerContext)();
|
|
49
|
-
// console.log('mainFormHandlerContext', mainFormHandlerContext);
|
|
50
49
|
return {
|
|
51
50
|
dataService,
|
|
52
51
|
queryClient,
|
|
@@ -76,8 +75,6 @@ function useSubGridCommandHandlerContext() {
|
|
|
76
75
|
function useSubGridCommands() {
|
|
77
76
|
const commands = (0, useGridCommands_1.useGridCommands)();
|
|
78
77
|
const handlerContext = useSubGridCommandHandlerContext();
|
|
79
|
-
console.log('temp. commands (s)', commands);
|
|
80
|
-
console.log('temp. handlerContext (s)', handlerContext);
|
|
81
78
|
return (0, command_1.useCommands)(commands, handlerContext);
|
|
82
79
|
}
|
|
83
80
|
function useSubGridContextCommands() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@headless-adminapp/app",
|
|
3
|
-
"version": "0.0.17-alpha.
|
|
3
|
+
"version": "0.0.17-alpha.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -30,5 +30,5 @@
|
|
|
30
30
|
"clsx": "2.1.1",
|
|
31
31
|
"react-custom-scrollbars-2": "^4.5.0"
|
|
32
32
|
},
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "2166288d663adfdd5f7428474b4f55ebbcad772c"
|
|
34
34
|
}
|
|
@@ -44,7 +44,6 @@ function useRecordSetResult() {
|
|
|
44
44
|
const { isPending, data, error } = (0, react_query_1.useQuery)({
|
|
45
45
|
queryKey: ['data', 'recordset', context.logicalName, context.ids, columns],
|
|
46
46
|
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
console.log('fetching data', context.ids, !context.logicalName, !context.ids.length, !cardView);
|
|
48
47
|
if (!context.logicalName || !context.ids.length || !cardView) {
|
|
49
48
|
return [];
|
|
50
49
|
}
|