@headless-adminapp/app 0.0.17-alpha.54 → 0.0.17-alpha.55
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.js +24 -32
- package/app/AuthWrapper.js +13 -9
- package/app/LayoutProvider.js +34 -39
- package/app/context.js +5 -2
- package/app/hooks/index.js +17 -1
- package/app/hooks/useAppContext.js +7 -4
- package/app/index.js +11 -4
- package/auth/AuthProvider.js +27 -36
- package/auth/context.d.ts +1 -1
- package/auth/context.js +5 -2
- package/auth/hooks/index.js +18 -2
- package/auth/hooks/useAuthSession.js +7 -4
- package/auth/hooks/useIsSkipAuthCheck.js +7 -4
- package/auth/hooks/useLogout.js +11 -8
- package/auth/index.js +23 -4
- package/auth/types.js +2 -1
- package/board/BoardColumnDataResolver.js +23 -20
- package/board/BoardColumnProvider.js +14 -10
- package/board/context.d.ts +2 -2
- package/board/context.js +6 -3
- package/board/hooks/index.js +15 -6
- package/board/hooks/useBoardColumnConfig.js +7 -4
- package/board/hooks/useBoardColumnData.d.ts +3 -1
- package/board/hooks/useBoardColumnData.js +7 -4
- package/board/hooks/useBoardColumnDataState.js +7 -4
- package/board/hooks/useBoardConfig.js +7 -4
- package/board/hooks/useBoardSchema.js +6 -3
- package/board/hooks/useSearchText.js +10 -7
- package/board/types.js +2 -1
- package/board/utils.js +4 -1
- package/builders/CommandBuilder/CommandBuilder.js +13 -10
- package/builders/CommandBuilder/DefaultCommandBuilder.js +30 -23
- package/builders/CommandBuilder/FormCommandBuilder.js +29 -38
- package/builders/CommandBuilder/SubgridCommandBuilder.js +27 -36
- package/builders/CommandBuilder/ViewCommandBuilder.js +29 -38
- package/builders/CommandBuilder/index.js +5 -1
- package/builders/CommandBuilder/utils.js +7 -3
- package/builders/SchemaExperienceBuilder.js +55 -31
- package/builders/index.js +7 -2
- package/builders/utils.js +59 -44
- package/command/hooks/index.js +18 -2
- package/command/hooks/useBaseCommandHandlerContext.js +29 -25
- package/command/hooks/useCommands.js +9 -6
- package/command/index.js +18 -2
- package/command/types.js +2 -1
- package/command/utils/index.js +41 -13
- package/components/ScrollView/index.js +11 -4
- package/components/ScrollbarWithMoreDataRequest/index.js +14 -11
- package/dataform/DataFormProvider/DataResolver.js +81 -89
- package/dataform/DataFormProvider/InitialValueResolver.js +22 -20
- package/dataform/DataFormProvider/ReadonlyInfoResolver.js +14 -12
- package/dataform/DataFormProvider/index.js +26 -32
- package/dataform/context.js +5 -2
- package/dataform/hooks/index.js +29 -13
- package/dataform/hooks/useFormInstance.js +6 -3
- package/dataform/hooks/useFormIsDirty.js +6 -3
- package/dataform/hooks/useFormIsReadonly.js +7 -4
- package/dataform/hooks/useFormNotifications.js +12 -9
- package/dataform/hooks/useFormRecord.js +7 -4
- package/dataform/hooks/useFormSave.js +40 -46
- package/dataform/hooks/useFormSchema.js +7 -4
- package/dataform/hooks/useLoadFormGridPage.js +19 -25
- package/dataform/hooks/useMainFormCommands.js +37 -30
- package/dataform/hooks/useProcessFlowSteps.js +27 -23
- package/dataform/hooks/useRecordId.js +7 -4
- package/dataform/hooks/useRecordTitle.js +12 -9
- package/dataform/hooks/useSelectedForm.js +7 -4
- package/dataform/index.js +23 -4
- package/dataform/utils/defaultParameters.js +16 -6
- package/dataform/utils/index.js +90 -56
- package/dataform/utils/saveRecord.js +99 -104
- package/datagrid/DataGridProvider/DataResolver.js +36 -34
- package/datagrid/DataGridProvider/index.js +31 -32
- package/datagrid/DataGridProvider/transformViewColumns.js +17 -6
- package/datagrid/DataGridProvider/utils.js +13 -5
- package/datagrid/column-filter/constants.js +5 -2
- package/datagrid/column-filter/index.js +7 -2
- package/datagrid/column-filter/types.js +2 -1
- package/datagrid/column-filter/utils.js +13 -3
- package/datagrid/context.d.ts +1 -1
- package/datagrid/context.js +5 -2
- package/datagrid/hooks/index.js +36 -20
- package/datagrid/hooks/useChangeView.js +10 -7
- package/datagrid/hooks/useGridColumnFilter.js +14 -8
- package/datagrid/hooks/useGridColumns.js +7 -4
- package/datagrid/hooks/useGridCommands.js +7 -4
- package/datagrid/hooks/useGridData.js +7 -4
- package/datagrid/hooks/useGridDataState.js +7 -4
- package/datagrid/hooks/useGridExtraFilter.js +7 -4
- package/datagrid/hooks/useGridOptions.js +4 -1
- package/datagrid/hooks/useGridPagination.js +4 -1
- package/datagrid/hooks/useGridRefresh.js +10 -7
- package/datagrid/hooks/useGridSchema.js +7 -4
- package/datagrid/hooks/useGridSelection.js +10 -7
- package/datagrid/hooks/useGridSorting.js +10 -7
- package/datagrid/hooks/useGridViewLookupData.js +7 -4
- package/datagrid/hooks/useLoadMainGridPage.js +12 -9
- package/datagrid/hooks/useMainGridCommands.js +62 -54
- package/datagrid/hooks/useMaxRecords.js +7 -4
- package/datagrid/hooks/useOpenRecord.js +20 -17
- package/datagrid/hooks/useSearchText.js +10 -7
- package/datagrid/hooks/useSelectedView.js +7 -4
- package/datagrid/hooks/useSubGridCommands.js +34 -23
- package/datagrid/index.js +27 -5
- package/defaults.js +5 -2
- package/dialog/DialogProvider.js +10 -6
- package/dialog/context.d.ts +1 -1
- package/dialog/context.js +5 -2
- package/dialog/hooks/index.js +24 -8
- package/dialog/hooks/useCloseDialog.js +10 -7
- package/dialog/hooks/useDialogItem.d.ts +1 -1
- package/dialog/hooks/useDialogItem.js +7 -4
- package/dialog/hooks/useDialogItems.d.ts +1 -1
- package/dialog/hooks/useDialogItems.js +7 -4
- package/dialog/hooks/useOpenAlertDialog.js +16 -8
- package/dialog/hooks/useOpenConfirmDialog.js +18 -9
- package/dialog/hooks/useOpenDialog.js +18 -11
- package/dialog/hooks/useOpenErrorDialog.js +16 -8
- package/dialog/hooks/useOpenPromptDialog.js +18 -9
- package/dialog/index.js +22 -3
- package/form/FormValidationStringContext.js +9 -5
- package/form/index.js +7 -1
- package/hooks/index.js +24 -6
- package/hooks/useDebouncedValue.js +11 -8
- package/hooks/useElementLayout.js +7 -4
- package/hooks/useIsMobile.js +12 -6
- package/hooks/useItemsWithKey.js +8 -5
- package/hooks/useStorageState.js +7 -5
- package/hooks/useSystemColorScheme.js +7 -4
- package/insights/InsightsProvider.js +13 -10
- package/insights/context.d.ts +1 -1
- package/insights/context.js +5 -2
- package/insights/hooks/index.js +7 -4
- package/insights/index.js +20 -2
- package/locale/LocaleProvider.js +12 -8
- package/locale/context.js +5 -2
- package/locale/index.js +23 -4
- package/locale/useCurrencySymbol.js +10 -8
- package/locale/useLocale.js +7 -4
- package/locale/utils.js +8 -3
- package/metadata/MetadataProvider.js +21 -17
- package/metadata/context.d.ts +1 -1
- package/metadata/context.js +5 -2
- package/metadata/hooks/index.js +24 -8
- package/metadata/hooks/useAppStore.js +7 -4
- package/metadata/hooks/useExperienceStore.js +7 -4
- package/metadata/hooks/useExperienceView.js +11 -17
- package/metadata/hooks/useExperienceViewCommands.js +14 -20
- package/metadata/hooks/useExperienceViewLookup.js +10 -16
- package/metadata/hooks/useExperienceViewSubgridCommands.js +14 -20
- package/metadata/hooks/useMetadata.js +11 -8
- package/metadata/hooks/useSchema.js +6 -3
- package/metadata/index.js +22 -3
- package/mutable/context.js +25 -17
- package/mutable/index.js +27 -3
- package/mutable/state.js +10 -6
- package/mutable/type.js +2 -1
- package/mutable/utils.js +12 -8
- package/navigation/hooks/index.js +17 -1
- package/navigation/hooks/useOpenForm.js +14 -11
- package/navigation/index.js +17 -1
- package/package.json +4 -12
- package/progress-indicator/ProgressIndicatorProvider.js +16 -12
- package/progress-indicator/context.js +5 -2
- package/progress-indicator/hooks/index.js +17 -1
- package/progress-indicator/hooks/useProgressIndicator.d.ts +1 -1
- package/progress-indicator/hooks/useProgressIndicator.js +7 -4
- package/progress-indicator/index.js +22 -3
- package/providers/PageEntityFormProvider/index.js +7 -4
- package/providers/PageEntityViewProvider/index.js +7 -4
- package/recordset/RecordSetProvider.js +16 -12
- package/recordset/context.d.ts +1 -1
- package/recordset/context.js +5 -2
- package/recordset/hooks/index.js +19 -3
- package/recordset/hooks/useRecordSetResult.js +22 -29
- package/recordset/hooks/useRecordSetSetter.js +9 -6
- package/recordset/hooks/useRecordSetVisibility.js +10 -7
- package/recordset/index.js +22 -3
- package/route/RouteProvider.js +18 -14
- package/route/context.js +9 -6
- package/route/hooks/index.js +22 -6
- package/route/hooks/useBasePath.js +7 -4
- package/route/hooks/useIsRouteActive.js +7 -4
- package/route/hooks/usePathname.js +7 -4
- package/route/hooks/useRouteResolver.js +7 -4
- package/route/hooks/useRouter.js +7 -4
- package/route/hooks/useSearchParams.js +7 -4
- package/route/index.js +20 -2
- package/route/types.js +2 -1
- package/store/ClientAppStore.js +12 -21
- package/store/ComponentStore.js +6 -4
- package/store/EventManager.js +20 -32
- package/store/SchemaExperienceStore.js +186 -217
- package/store/index.js +20 -4
- package/toast-notification/ToastNotificationProvider.js +10 -6
- package/toast-notification/context.d.ts +1 -1
- package/toast-notification/context.js +5 -2
- package/toast-notification/hooks/index.js +19 -3
- package/toast-notification/hooks/useCloseToastNotification.js +10 -7
- package/toast-notification/hooks/useOpenToastNotification.js +18 -11
- package/toast-notification/hooks/useToastNotificationItems.d.ts +1 -1
- package/toast-notification/hooks/useToastNotificationItems.js +7 -4
- package/toast-notification/index.js +22 -3
- package/transport/InMemoryDataService/index.js +59 -78
- package/transport/RestDataService/index.d.ts +2 -2
- package/transport/RestDataService/index.js +72 -91
- package/transport/context.js +9 -15
- package/transport/hooks/index.js +18 -2
- package/transport/hooks/useDataService.js +7 -4
- package/transport/hooks/useFileService.js +7 -4
- package/transport/hooks/useRetriveRecords.d.ts +1 -1
- package/transport/hooks/useRetriveRecords.js +25 -31
- package/transport/index.js +20 -2
- package/utils/calculateColumnWidths.js +5 -2
- package/utils/color.js +4 -1
- package/utils/getAttributeFormattedValue.js +38 -40
- package/utils/index.js +18 -2
- package/widget/context.js +5 -2
- package/widget/hooks/index.js +7 -4
- package/widget/index.js +5 -1
package/builders/utils.js
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
9
24
|
};
|
|
10
|
-
|
|
11
|
-
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.exportRecordsXLS = exports.exportRecordsCSV = void 0;
|
|
27
|
+
exports.retriveRecords = retriveRecords;
|
|
28
|
+
const utils_1 = require("../datagrid/DataGridProvider/utils");
|
|
29
|
+
const utils_2 = require("../utils");
|
|
12
30
|
const getHeaders = (schema, gridColumns, schemaStore) => {
|
|
13
31
|
const headers = gridColumns.map((column) => {
|
|
14
|
-
var _a, _b, _c;
|
|
15
32
|
if (column.name.indexOf('.') !== -1) {
|
|
16
33
|
const [lookup, field] = column.name.split('.');
|
|
17
34
|
const entity = schema.attributes[lookup].entity;
|
|
18
35
|
const lookupSchema = schemaStore.getSchema(entity);
|
|
19
|
-
return `${
|
|
36
|
+
return `${lookupSchema.attributes[field]?.label} (${schema.attributes[lookup]?.label})`;
|
|
20
37
|
}
|
|
21
|
-
return
|
|
38
|
+
return schema.attributes[column.name]?.label;
|
|
22
39
|
});
|
|
23
40
|
return headers;
|
|
24
41
|
};
|
|
@@ -37,13 +54,12 @@ function getAttribute({ column, schema, schemaStore, }) {
|
|
|
37
54
|
return attribute;
|
|
38
55
|
}
|
|
39
56
|
function extractAttributeData({ column, record, schema, schemaStore, }) {
|
|
40
|
-
var _a, _b;
|
|
41
57
|
const attribute = getAttribute({ column, schema, schemaStore });
|
|
42
58
|
let value;
|
|
43
59
|
if (column.expandedKey) {
|
|
44
60
|
const lookup = column.name;
|
|
45
61
|
const field = column.expandedKey;
|
|
46
|
-
value =
|
|
62
|
+
value = record.$expand?.[lookup]?.[field];
|
|
47
63
|
}
|
|
48
64
|
else {
|
|
49
65
|
value = record[column.name];
|
|
@@ -53,12 +69,11 @@ function extractAttributeData({ column, record, schema, schemaStore, }) {
|
|
|
53
69
|
value,
|
|
54
70
|
};
|
|
55
71
|
}
|
|
56
|
-
|
|
57
|
-
const csvDownload =
|
|
72
|
+
const exportRecordsCSV = async ({ schema, records, gridColumns, schemaStore, fileName, }) => {
|
|
73
|
+
const csvDownload = await Promise.resolve().then(() => __importStar(require('json-to-csv-export')));
|
|
58
74
|
const headers = getHeaders(schema, gridColumns, schemaStore);
|
|
59
75
|
const cellData = records.map((record) => {
|
|
60
76
|
return gridColumns.map((column) => {
|
|
61
|
-
var _a, _b;
|
|
62
77
|
const { attribute, value } = extractAttributeData({
|
|
63
78
|
column,
|
|
64
79
|
record,
|
|
@@ -66,9 +81,9 @@ export const exportRecordsCSV = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
66
81
|
schemaStore,
|
|
67
82
|
});
|
|
68
83
|
if (attribute.type === 'money' || attribute.type === 'number') {
|
|
69
|
-
return
|
|
84
|
+
return value?.toString() ?? '';
|
|
70
85
|
}
|
|
71
|
-
return (
|
|
86
|
+
return (0, utils_2.getAttributeFormattedValue)(attribute, value) ?? '';
|
|
72
87
|
});
|
|
73
88
|
});
|
|
74
89
|
csvDownload.default({
|
|
@@ -77,9 +92,10 @@ export const exportRecordsCSV = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
77
92
|
delimiter: ',',
|
|
78
93
|
filename: fileName,
|
|
79
94
|
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
|
|
95
|
+
};
|
|
96
|
+
exports.exportRecordsCSV = exportRecordsCSV;
|
|
97
|
+
const exportRecordsXLS = async ({ fileName, gridColumns, records, schema, schemaStore, }) => {
|
|
98
|
+
const ExcelJS = await Promise.resolve().then(() => __importStar(require('exceljs')));
|
|
83
99
|
const headers = getHeaders(schema, gridColumns, schemaStore);
|
|
84
100
|
const cellData = records.map((item) => {
|
|
85
101
|
return gridColumns.map((column) => {
|
|
@@ -92,14 +108,14 @@ export const exportRecordsXLS = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
92
108
|
if (!value) {
|
|
93
109
|
return '';
|
|
94
110
|
}
|
|
95
|
-
switch (attribute
|
|
111
|
+
switch (attribute?.type) {
|
|
96
112
|
case 'money':
|
|
97
113
|
case 'number':
|
|
98
114
|
return value;
|
|
99
115
|
case 'date':
|
|
100
116
|
return value ? new Date(value) : undefined;
|
|
101
117
|
default:
|
|
102
|
-
return getAttributeFormattedValue(attribute, value);
|
|
118
|
+
return (0, utils_2.getAttributeFormattedValue)(attribute, value);
|
|
103
119
|
}
|
|
104
120
|
});
|
|
105
121
|
});
|
|
@@ -114,8 +130,8 @@ export const exportRecordsXLS = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
114
130
|
gridColumns.forEach((column, index) => {
|
|
115
131
|
const attribute = getAttribute({ column, schema, schemaStore });
|
|
116
132
|
const sheetColumn = worksheet.getColumn(index + 1);
|
|
117
|
-
let formatFn = (value) =>
|
|
118
|
-
if (
|
|
133
|
+
let formatFn = (value) => (0, utils_2.getAttributeFormattedValue)(attribute, value) ?? '';
|
|
134
|
+
if (attribute?.type === 'money') {
|
|
119
135
|
sheetColumn.numFmt = '"₹" #,##0.00';
|
|
120
136
|
}
|
|
121
137
|
let maxLength = 0;
|
|
@@ -128,7 +144,7 @@ export const exportRecordsXLS = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
128
144
|
sheetColumn.width = Math.max(maxLength, 10) * 1.2;
|
|
129
145
|
});
|
|
130
146
|
// Generate the Excel file
|
|
131
|
-
const buffer =
|
|
147
|
+
const buffer = await workbook.xlsx.writeBuffer();
|
|
132
148
|
const blob = new Blob([buffer], {
|
|
133
149
|
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
134
150
|
});
|
|
@@ -136,21 +152,20 @@ export const exportRecordsXLS = (_a) => __awaiter(void 0, [_a], void 0, function
|
|
|
136
152
|
link.href = window.URL.createObjectURL(blob);
|
|
137
153
|
link.download = fileName;
|
|
138
154
|
link.click();
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
});
|
|
154
|
-
return result;
|
|
155
|
+
};
|
|
156
|
+
exports.exportRecordsXLS = exportRecordsXLS;
|
|
157
|
+
async function retriveRecords({ gridColumns, dataService, schema, search, view, extraFilter, columnFilters, schemaStore, sorting, skip, limit, }) {
|
|
158
|
+
const expand = (0, utils_1.collectExpandedKeys)(gridColumns);
|
|
159
|
+
const columns = Array.from(new Set([...gridColumns.filter((x) => !x.expandedKey).map((x) => x.name)]));
|
|
160
|
+
const result = await dataService.retriveRecords({
|
|
161
|
+
logicalName: schema.logicalName,
|
|
162
|
+
search,
|
|
163
|
+
columns: columns,
|
|
164
|
+
expand,
|
|
165
|
+
filter: (0, utils_1.mergeConditions)(schema, view.experience.filter, extraFilter, columnFilters, schemaStore),
|
|
166
|
+
skip,
|
|
167
|
+
limit,
|
|
168
|
+
sort: sorting,
|
|
155
169
|
});
|
|
170
|
+
return result;
|
|
156
171
|
}
|
package/command/hooks/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./useBaseCommandHandlerContext"), exports);
|
|
18
|
+
__exportStar(require("./useCommands"), exports);
|
|
@@ -1,20 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useUtility = useUtility;
|
|
4
|
+
exports.useBaseCommandHandlerContext = useBaseCommandHandlerContext;
|
|
5
|
+
const navigation_1 = require("@headless-adminapp/app/navigation");
|
|
6
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
7
|
+
const react_1 = require("react");
|
|
8
|
+
const hooks_1 = require("../../dialog/hooks");
|
|
9
|
+
const locale_1 = require("../../locale");
|
|
10
|
+
const hooks_2 = require("../../metadata/hooks");
|
|
11
|
+
const hooks_3 = require("../../progress-indicator/hooks");
|
|
12
|
+
const useOpenToastNotification_1 = require("../../toast-notification/hooks/useOpenToastNotification");
|
|
13
|
+
const transport_1 = require("../../transport");
|
|
14
|
+
function useUtility() {
|
|
15
|
+
const { hideProgressIndicator, showProgressIndicator } = (0, hooks_3.useProgressIndicator)();
|
|
16
|
+
const openAlertDialog = (0, hooks_1.useOpenAlertDialog)();
|
|
17
|
+
const openConfirmDialog = (0, hooks_1.useOpenConfirmDialog)();
|
|
18
|
+
const openErrorDialog = (0, hooks_1.useOpenErrorDialog)();
|
|
19
|
+
const openPromptDialog = (0, hooks_1.useOpenPromptDialog)();
|
|
20
|
+
const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
|
|
21
|
+
return (0, react_1.useMemo)(() => ({
|
|
18
22
|
hideProgressIndicator,
|
|
19
23
|
showProgressIndicator,
|
|
20
24
|
openAlertDialog,
|
|
@@ -33,19 +37,19 @@ export function useUtility() {
|
|
|
33
37
|
]);
|
|
34
38
|
}
|
|
35
39
|
function useNavigation() {
|
|
36
|
-
const openForm = useOpenForm();
|
|
37
|
-
return useMemo(() => ({
|
|
40
|
+
const openForm = (0, navigation_1.useOpenForm)();
|
|
41
|
+
return (0, react_1.useMemo)(() => ({
|
|
38
42
|
openForm,
|
|
39
43
|
}), [openForm]);
|
|
40
44
|
}
|
|
41
|
-
|
|
42
|
-
const dataService = useDataService();
|
|
43
|
-
const queryClient = useQueryClient();
|
|
44
|
-
const stores = useMetadata();
|
|
45
|
+
function useBaseCommandHandlerContext() {
|
|
46
|
+
const dataService = (0, transport_1.useDataService)();
|
|
47
|
+
const queryClient = (0, react_query_1.useQueryClient)();
|
|
48
|
+
const stores = (0, hooks_2.useMetadata)();
|
|
45
49
|
const utility = useUtility();
|
|
46
|
-
const locale = useLocale();
|
|
50
|
+
const locale = (0, locale_1.useLocale)();
|
|
47
51
|
const navigation = useNavigation();
|
|
48
|
-
return useMemo(() => ({
|
|
52
|
+
return (0, react_1.useMemo)(() => ({
|
|
49
53
|
dataService,
|
|
50
54
|
queryClient,
|
|
51
55
|
utility,
|
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCommands = useCommands;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
3
6
|
/***
|
|
4
7
|
* @description Transforms the command configuration into a format that can be used by the CommandBar component
|
|
5
8
|
* and apply the necessary conditions to the commands (disabled, hidden, etc.)
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
const selectorRef = useRef(selector);
|
|
10
|
+
function useCommands(commands, handlerContext, selector) {
|
|
11
|
+
const selectorRef = (0, react_1.useRef)(selector);
|
|
9
12
|
selectorRef.current = selector;
|
|
10
|
-
return useMemo(() => {
|
|
11
|
-
return
|
|
13
|
+
return (0, react_1.useMemo)(() => {
|
|
14
|
+
return (0, utils_1.transformCommadnGroups)(commands ?? [], handlerContext, selectorRef.current);
|
|
12
15
|
}, [commands, handlerContext]);
|
|
13
16
|
}
|
package/command/index.js
CHANGED
|
@@ -1,2 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./types"), exports);
|
|
18
|
+
__exportStar(require("./hooks"), exports);
|
package/command/types.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/command/utils/index.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.transformCommadnGroups = transformCommadnGroups;
|
|
4
|
+
const utils_1 = require("@headless-adminapp/core/experience/command/utils");
|
|
2
5
|
function transformedProperties(command, handlerContext) {
|
|
3
6
|
const IconComponent = command.Icon;
|
|
4
|
-
const hidden = checkCommandCondition(handlerContext, command.hidden);
|
|
5
|
-
const disabled = checkCommandCondition(handlerContext, command.disabled);
|
|
7
|
+
const hidden = (0, utils_1.checkCommandCondition)(handlerContext, command.hidden);
|
|
8
|
+
const disabled = (0, utils_1.checkCommandCondition)(handlerContext, command.disabled);
|
|
6
9
|
const onClick = command.onClick
|
|
7
10
|
? () => {
|
|
8
|
-
|
|
9
|
-
(_a = command.onClick(handlerContext)) === null || _a === void 0 ? void 0 : _a.catch(console.error);
|
|
11
|
+
command.onClick(handlerContext)?.catch(console.error);
|
|
10
12
|
}
|
|
11
13
|
: undefined;
|
|
12
14
|
return {
|
|
@@ -20,11 +22,33 @@ function transformCommand(command, handlerContext) {
|
|
|
20
22
|
const commandType = command.type;
|
|
21
23
|
switch (command.type) {
|
|
22
24
|
case 'icon':
|
|
23
|
-
return
|
|
25
|
+
return {
|
|
26
|
+
type: command.type,
|
|
27
|
+
isQuickAction: command.isQuickAction,
|
|
28
|
+
danger: command.danger,
|
|
29
|
+
iconPosition: command.iconPosition,
|
|
30
|
+
...transformedProperties(command, handlerContext),
|
|
31
|
+
};
|
|
24
32
|
case 'button':
|
|
25
|
-
return
|
|
33
|
+
return {
|
|
34
|
+
type: command.type,
|
|
35
|
+
isQuickAction: command.isQuickAction,
|
|
36
|
+
text: command.text,
|
|
37
|
+
danger: command.danger,
|
|
38
|
+
iconPosition: command.iconPosition,
|
|
39
|
+
localizedTexts: command.localizedText,
|
|
40
|
+
...transformedProperties(command, handlerContext),
|
|
41
|
+
};
|
|
26
42
|
case 'menu':
|
|
27
|
-
return
|
|
43
|
+
return {
|
|
44
|
+
type: command.type,
|
|
45
|
+
text: command.text,
|
|
46
|
+
danger: command.danger,
|
|
47
|
+
localizedTexts: command.localizedTexts,
|
|
48
|
+
iconPosition: command.iconPosition,
|
|
49
|
+
...transformedProperties(command, handlerContext),
|
|
50
|
+
items: command.items.map((item) => transformMenuItems(item, handlerContext)),
|
|
51
|
+
};
|
|
28
52
|
default:
|
|
29
53
|
throw new Error(`Unknown command type: ${commandType}`);
|
|
30
54
|
}
|
|
@@ -33,14 +57,18 @@ function transformMenuItems(items, handlerContext) {
|
|
|
33
57
|
return items.map((item) => transformMenuItem(item, handlerContext));
|
|
34
58
|
}
|
|
35
59
|
function transformMenuItem(item, handlerContext) {
|
|
36
|
-
|
|
37
|
-
|
|
60
|
+
return {
|
|
61
|
+
danger: item.danger,
|
|
62
|
+
text: item.text,
|
|
63
|
+
localizedTexts: item.localizedTexts,
|
|
64
|
+
...transformedProperties(item, handlerContext),
|
|
65
|
+
items: item.items?.map((item) => transformMenuItems(item, handlerContext)),
|
|
66
|
+
};
|
|
38
67
|
}
|
|
39
68
|
function transformCommandGroup(group, handlerContext, selector) {
|
|
40
69
|
return group
|
|
41
70
|
.map((command) => {
|
|
42
|
-
|
|
43
|
-
if (!((_a = selector === null || selector === void 0 ? void 0 : selector(command)) !== null && _a !== void 0 ? _a : true)) {
|
|
71
|
+
if (!(selector?.(command) ?? true)) {
|
|
44
72
|
return false; // Skip command
|
|
45
73
|
}
|
|
46
74
|
const transformedCommand = transformCommand(command, handlerContext);
|
|
@@ -51,7 +79,7 @@ function transformCommandGroup(group, handlerContext, selector) {
|
|
|
51
79
|
})
|
|
52
80
|
.filter(Boolean);
|
|
53
81
|
}
|
|
54
|
-
|
|
82
|
+
function transformCommadnGroups(groups, handlerContext, selector) {
|
|
55
83
|
return groups
|
|
56
84
|
.map((group) => {
|
|
57
85
|
return transformCommandGroup(group, handlerContext, selector);
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ScrollView = void 0;
|
|
7
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
+
const clsx_1 = __importDefault(require("clsx"));
|
|
9
|
+
const react_custom_scrollbars_2_1 = require("react-custom-scrollbars-2");
|
|
10
|
+
const ScrollView = ({ children, className, rtl, autoHide, onScroll, }) => ((0, jsx_runtime_1.jsx)(react_custom_scrollbars_2_1.Scrollbars, { autoHide: autoHide, className: (0, clsx_1.default)(className, 'hdl-scrollbar', rtl && 'rtl'), onScroll: onScroll, children: children }));
|
|
11
|
+
exports.ScrollView = ScrollView;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScrollbarWithMoreDataRequest = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ScrollView_1 = require("../ScrollView");
|
|
4
7
|
function getReaminingSpace(div) {
|
|
5
8
|
return div.scrollHeight - div.scrollTop - div.clientHeight;
|
|
6
9
|
}
|
|
7
|
-
|
|
8
|
-
const divRef = useRef(null);
|
|
9
|
-
const onRequestMoreRef = useRef(onRequestMore);
|
|
10
|
+
const ScrollbarWithMoreDataRequest = ({ data, onRequestMore, hasMore, children, rtl }) => {
|
|
11
|
+
const divRef = (0, react_1.useRef)(null);
|
|
12
|
+
const onRequestMoreRef = (0, react_1.useRef)(onRequestMore);
|
|
10
13
|
onRequestMoreRef.current = onRequestMore;
|
|
11
|
-
useEffect(() => {
|
|
12
|
-
|
|
13
|
-
const div = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
const div = divRef.current?.parentElement;
|
|
14
16
|
if (!div) {
|
|
15
17
|
return;
|
|
16
18
|
}
|
|
@@ -19,11 +21,12 @@ export const ScrollbarWithMoreDataRequest = ({ data, onRequestMore, hasMore, chi
|
|
|
19
21
|
onRequestMoreRef.current();
|
|
20
22
|
}
|
|
21
23
|
}, [data, hasMore]);
|
|
22
|
-
return (
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { autoHide: true, rtl: rtl, onScroll: (e) => {
|
|
23
25
|
const div = e.target;
|
|
24
26
|
const remainingSpace = getReaminingSpace(div);
|
|
25
27
|
if (remainingSpace <= 0 && hasMore) {
|
|
26
28
|
onRequestMoreRef.current();
|
|
27
29
|
}
|
|
28
|
-
}, children:
|
|
30
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, children: children }) }));
|
|
29
31
|
};
|
|
32
|
+
exports.ScrollbarWithMoreDataRequest = ScrollbarWithMoreDataRequest;
|