@nubitio/devextreme 0.6.8
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/LICENSE +21 -0
- package/README.md +84 -0
- package/dist/index.cjs +1141 -0
- package/dist/index.d.cts +126 -0
- package/dist/index.d.mts +126 -0
- package/dist/index.mjs +1104 -0
- package/dist/style.css +184 -0
- package/package.json +61 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,1141 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
+
key = keys[i];
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
+
get: ((k) => from[k]).bind(null, key),
|
|
14
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
+
value: mod,
|
|
21
|
+
enumerable: true
|
|
22
|
+
}) : target, mod));
|
|
23
|
+
//#endregion
|
|
24
|
+
let react = require("react");
|
|
25
|
+
react = __toESM(react);
|
|
26
|
+
let _nubitio_crud = require("@nubitio/crud");
|
|
27
|
+
let devextreme_data_custom_store = require("devextreme/data/custom_store");
|
|
28
|
+
devextreme_data_custom_store = __toESM(devextreme_data_custom_store);
|
|
29
|
+
let devextreme_react_data_grid = require("devextreme-react/data-grid");
|
|
30
|
+
devextreme_react_data_grid = __toESM(devextreme_react_data_grid);
|
|
31
|
+
let _nubitio_core = require("@nubitio/core");
|
|
32
|
+
let _nubitio_ui = require("@nubitio/ui");
|
|
33
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
let devextreme_react_form = require("devextreme-react/form");
|
|
35
|
+
devextreme_react_form = __toESM(devextreme_react_form);
|
|
36
|
+
//#region packages/devextreme/convertDxFilterToNubit.ts
|
|
37
|
+
function isDxFilterTriplet(value) {
|
|
38
|
+
return Array.isArray(value) && value.length === 3 && typeof value[0] === "string" && typeof value[1] === "string";
|
|
39
|
+
}
|
|
40
|
+
function isLogicalOperator(value) {
|
|
41
|
+
return value === "and" || value === "or" || value === "!";
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Flattens a DevExtreme filter expression into leaf triplets.
|
|
45
|
+
* Compound `and` groups are fully expanded. `or` groups are also flattened
|
|
46
|
+
* (API Platform treats multiple filter[] params as conjunction).
|
|
47
|
+
*/
|
|
48
|
+
function flattenDxFilter(filter) {
|
|
49
|
+
if (filter == null || filter === "") return [];
|
|
50
|
+
if (isDxFilterTriplet(filter)) return [filter];
|
|
51
|
+
if (!Array.isArray(filter)) return [];
|
|
52
|
+
if (filter.length === 3 && typeof filter[0] === "string" && !isLogicalOperator(filter[1])) return [filter];
|
|
53
|
+
const leaves = [];
|
|
54
|
+
for (const item of filter) {
|
|
55
|
+
if (isLogicalOperator(item)) continue;
|
|
56
|
+
leaves.push(...flattenDxFilter(item));
|
|
57
|
+
}
|
|
58
|
+
return leaves;
|
|
59
|
+
}
|
|
60
|
+
function normalizeFilterValue(field, operator, value) {
|
|
61
|
+
if (operator === "between" && Array.isArray(value)) {
|
|
62
|
+
const [start = "", end = ""] = value.map((part) => String(part ?? ""));
|
|
63
|
+
return `${start}${_nubitio_crud.BETWEEN_VALUE_SEPARATOR}${end}`;
|
|
64
|
+
}
|
|
65
|
+
if (field?.type === _nubitio_crud.FieldType.CHECKBOX || field?.type === _nubitio_crud.FieldType.SWITCH) {
|
|
66
|
+
if (value === true || value === "true" || value === 1) return "true";
|
|
67
|
+
if (value === false || value === "false" || value === 0) return "false";
|
|
68
|
+
}
|
|
69
|
+
if (value instanceof Date) {
|
|
70
|
+
if (field?.type === _nubitio_crud.FieldType.DATETIME) return value.toISOString();
|
|
71
|
+
return value.toISOString().slice(0, 10);
|
|
72
|
+
}
|
|
73
|
+
return String(value ?? "");
|
|
74
|
+
}
|
|
75
|
+
const DX_TO_NUBIT_OPERATOR = {
|
|
76
|
+
"=": "=",
|
|
77
|
+
"<>": "<>",
|
|
78
|
+
">": ">",
|
|
79
|
+
">=": ">=",
|
|
80
|
+
"<": "<",
|
|
81
|
+
"<=": "<=",
|
|
82
|
+
contains: "contains",
|
|
83
|
+
notcontains: "notcontains",
|
|
84
|
+
startswith: "startswith",
|
|
85
|
+
endswith: "endswith",
|
|
86
|
+
between: "between"
|
|
87
|
+
};
|
|
88
|
+
function mapDxOperator(operator) {
|
|
89
|
+
return DX_TO_NUBIT_OPERATOR[operator] ?? operator;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Converts a DevExtreme filter expression into Nubit/Hydra filter tuples,
|
|
93
|
+
* applying per-field `buildFilterTerms` expansion (e.g. date `between`).
|
|
94
|
+
*/
|
|
95
|
+
function convertDxFilterToNubit(filter, fields) {
|
|
96
|
+
return flattenDxFilter(filter).flatMap(([fieldName, operator, rawValue]) => {
|
|
97
|
+
const field = fields.find((candidate) => candidate.name === fieldName);
|
|
98
|
+
const mappedOperator = mapDxOperator(operator);
|
|
99
|
+
const value = normalizeFilterValue(field, mappedOperator, rawValue);
|
|
100
|
+
if (value.trim() === "" && mappedOperator !== "=") return [];
|
|
101
|
+
if (!field) return [[
|
|
102
|
+
fieldName,
|
|
103
|
+
mappedOperator,
|
|
104
|
+
value
|
|
105
|
+
]];
|
|
106
|
+
return (0, _nubitio_crud.getFieldTypeModule)(field.type).buildFilterTerms(field, mappedOperator, value);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function mergeGridFilters(routingFilters, dxFilter, fields) {
|
|
110
|
+
const routingTerms = routingFilters?.flatMap((rule) => {
|
|
111
|
+
const field = fields.find((candidate) => candidate.name === rule.field);
|
|
112
|
+
const value = String(rule.value ?? "");
|
|
113
|
+
if (!field) return [[
|
|
114
|
+
rule.field,
|
|
115
|
+
rule.operator,
|
|
116
|
+
value
|
|
117
|
+
]];
|
|
118
|
+
return (0, _nubitio_crud.getFieldTypeModule)(field.type).buildFilterTerms(field, rule.operator, value);
|
|
119
|
+
}) ?? [];
|
|
120
|
+
const dxTerms = convertDxFilterToNubit(dxFilter, fields);
|
|
121
|
+
return [...routingTerms, ...dxTerms];
|
|
122
|
+
}
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region packages/devextreme/mapFieldsToDxColumns.ts
|
|
125
|
+
function resolveDataType(field) {
|
|
126
|
+
switch (field.type) {
|
|
127
|
+
case _nubitio_crud.FieldType.NUMBER:
|
|
128
|
+
case _nubitio_crud.FieldType.CURRENCY: return "number";
|
|
129
|
+
case _nubitio_crud.FieldType.DATE: return "date";
|
|
130
|
+
case _nubitio_crud.FieldType.DATETIME: return "datetime";
|
|
131
|
+
case _nubitio_crud.FieldType.CHECKBOX:
|
|
132
|
+
case _nubitio_crud.FieldType.SWITCH: return "boolean";
|
|
133
|
+
default: return field.valueType === "number" ? "number" : field.valueType === "date" ? "date" : field.valueType === "datetime" ? "datetime" : field.valueType === "boolean" ? "boolean" : "string";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function mapFieldsToDxColumns(fields, visibleColumns) {
|
|
137
|
+
return fields.filter((field) => field.visible && !field.hidden).filter((field) => visibleColumns == null || visibleColumns.includes(field.name)).sort((left, right) => (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER)).map((field) => ({
|
|
138
|
+
dataField: field.name,
|
|
139
|
+
caption: field.label || field.name,
|
|
140
|
+
dataType: resolveDataType(field),
|
|
141
|
+
allowSorting: field.sortable,
|
|
142
|
+
allowFiltering: field.filterable,
|
|
143
|
+
width: field.width,
|
|
144
|
+
format: field.format || void 0
|
|
145
|
+
}));
|
|
146
|
+
}
|
|
147
|
+
//#endregion
|
|
148
|
+
//#region packages/devextreme/DevExtremeDetailGridSection.tsx
|
|
149
|
+
/**
|
|
150
|
+
* Expanded-row detail grid for DevExtreme DataGrid master-detail.
|
|
151
|
+
* Loads related rows through ResourceStore and renders a read-only nested grid.
|
|
152
|
+
*/
|
|
153
|
+
function DevExtremeDetailGridSection({ fields, url }) {
|
|
154
|
+
const { t } = (0, _nubitio_core.useCoreTranslation)();
|
|
155
|
+
const resourceStoreFactory = (0, _nubitio_crud.useResourceStoreFactory)();
|
|
156
|
+
const [rows, setRows] = (0, react.useState)([]);
|
|
157
|
+
const [loading, setLoading] = (0, react.useState)(true);
|
|
158
|
+
const idField = (0, react.useMemo)(() => (0, _nubitio_crud.getIdField)(fields), [fields]);
|
|
159
|
+
const columns = (0, react.useMemo)(() => mapFieldsToDxColumns(fields), [fields]);
|
|
160
|
+
(0, react.useEffect)(() => {
|
|
161
|
+
const source = resourceStoreFactory({
|
|
162
|
+
url,
|
|
163
|
+
idField
|
|
164
|
+
});
|
|
165
|
+
setLoading(true);
|
|
166
|
+
source.load({}).then((result) => setRows(result.data)).finally(() => setLoading(false));
|
|
167
|
+
}, [
|
|
168
|
+
fields,
|
|
169
|
+
idField,
|
|
170
|
+
resourceStoreFactory,
|
|
171
|
+
url
|
|
172
|
+
]);
|
|
173
|
+
if (loading) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
174
|
+
className: "nb-dx-detail-grid__loading",
|
|
175
|
+
children: t("grid.loading")
|
|
176
|
+
});
|
|
177
|
+
if (rows.length === 0) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
178
|
+
className: "nb-dx-detail-grid__empty",
|
|
179
|
+
children: t("grid.noRecords")
|
|
180
|
+
});
|
|
181
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
182
|
+
className: "nb-dx-detail-grid",
|
|
183
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(devextreme_react_data_grid.default, {
|
|
184
|
+
dataSource: rows,
|
|
185
|
+
keyExpr: idField,
|
|
186
|
+
showBorders: true,
|
|
187
|
+
columnAutoWidth: true,
|
|
188
|
+
height: Math.min(360, 56 + rows.length * 36),
|
|
189
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.LoadPanel, { enabled: false }), columns.map((column) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Column, {
|
|
190
|
+
...column,
|
|
191
|
+
allowEditing: false
|
|
192
|
+
}, column.dataField))]
|
|
193
|
+
})
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
//#region packages/devextreme/DevExtremeDataGridView.tsx
|
|
198
|
+
function resolveDxEditMode(editMode) {
|
|
199
|
+
if (!editMode || editMode === "popup") return null;
|
|
200
|
+
return editMode;
|
|
201
|
+
}
|
|
202
|
+
const DX_PAGE_SIZE_OPTIONS = [
|
|
203
|
+
10,
|
|
204
|
+
20,
|
|
205
|
+
50
|
|
206
|
+
];
|
|
207
|
+
function resolveDxRemoteOperations(options) {
|
|
208
|
+
if (options.data) return false;
|
|
209
|
+
return {
|
|
210
|
+
filtering: options.filterRow ?? true,
|
|
211
|
+
grouping: false,
|
|
212
|
+
summary: false,
|
|
213
|
+
sorting: true,
|
|
214
|
+
paging: options.paging ?? true
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function isHeaderFilterLookup(loadOptions) {
|
|
218
|
+
return Array.isArray(loadOptions.group) || loadOptions.requireGroupCount === true;
|
|
219
|
+
}
|
|
220
|
+
const DevExtremeDataGridView = (0, react.forwardRef)((options, ref) => {
|
|
221
|
+
const { t } = (0, _nubitio_core.useCoreTranslation)();
|
|
222
|
+
const httpClient = (0, _nubitio_core.useCoreHttpClient)();
|
|
223
|
+
const resourceStoreFactory = (0, _nubitio_crud.useResourceStoreFactory)();
|
|
224
|
+
const gridRef = (0, react.useRef)(null);
|
|
225
|
+
const [activeFilter, setActiveFilter] = (0, react.useState)(null);
|
|
226
|
+
const [confirmRow, setConfirmRow] = (0, react.useState)(null);
|
|
227
|
+
const selectedRowsRef = (0, react.useRef)([]);
|
|
228
|
+
const selectedKeysRef = (0, react.useRef)([]);
|
|
229
|
+
const hasPendingEditsRef = (0, react.useRef)(false);
|
|
230
|
+
const idField = (0, react.useMemo)(() => (0, _nubitio_crud.getIdField)(options.fields), [options.fields]);
|
|
231
|
+
const adapter = options.adapter ?? _nubitio_crud.HydraAdapter;
|
|
232
|
+
const dxEditMode = resolveDxEditMode(options.editMode);
|
|
233
|
+
const inlineEditing = dxEditMode != null && (options.allowEdit ?? true);
|
|
234
|
+
const inlineToolbar = (0, react.useMemo)(() => inlineEditing && dxEditMode !== "row" ? (0, _nubitio_crud.resolveInlineEditToolbar)(dxEditMode, options.inlineEditToolbar) : null, [
|
|
235
|
+
dxEditMode,
|
|
236
|
+
inlineEditing,
|
|
237
|
+
options.inlineEditToolbar
|
|
238
|
+
]);
|
|
239
|
+
const columns = (0, react.useMemo)(() => mapFieldsToDxColumns(options.fields, options.visibleColumns).map((column) => ({
|
|
240
|
+
...column,
|
|
241
|
+
allowEditing: inlineEditing && options.fields.some((field) => field.name === column.dataField && (0, _nubitio_crud.canEditFieldInline)(field))
|
|
242
|
+
})), [
|
|
243
|
+
inlineEditing,
|
|
244
|
+
options.fields,
|
|
245
|
+
options.visibleColumns
|
|
246
|
+
]);
|
|
247
|
+
const url = options.url;
|
|
248
|
+
const httpClientRef = (0, react.useRef)(httpClient);
|
|
249
|
+
httpClientRef.current = httpClient;
|
|
250
|
+
const source = (0, react.useMemo)(() => resourceStoreFactory({
|
|
251
|
+
url,
|
|
252
|
+
idField,
|
|
253
|
+
byKeyUrl: null
|
|
254
|
+
}), [
|
|
255
|
+
idField,
|
|
256
|
+
resourceStoreFactory,
|
|
257
|
+
url
|
|
258
|
+
]);
|
|
259
|
+
const optionsRef = (0, react.useRef)(options);
|
|
260
|
+
optionsRef.current = options;
|
|
261
|
+
const fieldsRef = (0, react.useRef)(options.fields);
|
|
262
|
+
fieldsRef.current = options.fields;
|
|
263
|
+
const routingFilterRef = (0, react.useRef)(options.filter);
|
|
264
|
+
routingFilterRef.current = options.filter;
|
|
265
|
+
const activeFilterRef = (0, react.useRef)(activeFilter);
|
|
266
|
+
activeFilterRef.current = activeFilter;
|
|
267
|
+
const dataSource = (0, react.useMemo)(() => {
|
|
268
|
+
if (optionsRef.current.data) return optionsRef.current.data;
|
|
269
|
+
return new devextreme_data_custom_store.default({
|
|
270
|
+
key: idField,
|
|
271
|
+
load: async (loadOptions) => {
|
|
272
|
+
const current = optionsRef.current;
|
|
273
|
+
if (current.manualLoad) return {
|
|
274
|
+
data: [],
|
|
275
|
+
totalCount: 0
|
|
276
|
+
};
|
|
277
|
+
const request = {
|
|
278
|
+
skip: loadOptions.skip,
|
|
279
|
+
take: loadOptions.take
|
|
280
|
+
};
|
|
281
|
+
if (Array.isArray(loadOptions.sort) && loadOptions.sort.length > 0) request.sort = loadOptions.sort.map((rule) => {
|
|
282
|
+
const typedRule = rule;
|
|
283
|
+
return {
|
|
284
|
+
selector: typedRule.selector,
|
|
285
|
+
desc: !!typedRule.desc
|
|
286
|
+
};
|
|
287
|
+
});
|
|
288
|
+
else if (current.sort?.length) request.sort = current.sort;
|
|
289
|
+
const mergedFilter = mergeGridFilters(routingFilterRef.current, loadOptions.filter ?? activeFilterRef.current, fieldsRef.current);
|
|
290
|
+
if (mergedFilter.length > 0) request.filter = mergedFilter;
|
|
291
|
+
if (loadOptions.searchValue && loadOptions.searchExpr) {
|
|
292
|
+
request.searchExpr = loadOptions.searchExpr;
|
|
293
|
+
request.searchValue = loadOptions.searchValue;
|
|
294
|
+
}
|
|
295
|
+
if (isHeaderFilterLookup(loadOptions)) {
|
|
296
|
+
request.skip = 0;
|
|
297
|
+
request.take = 1e3;
|
|
298
|
+
}
|
|
299
|
+
const result = await source.load(request);
|
|
300
|
+
current.onContentReady?.();
|
|
301
|
+
return {
|
|
302
|
+
data: result.data,
|
|
303
|
+
totalCount: result.totalCount
|
|
304
|
+
};
|
|
305
|
+
},
|
|
306
|
+
update: async (key, values) => {
|
|
307
|
+
const current = optionsRef.current;
|
|
308
|
+
const currentAdapter = current.adapter ?? adapter;
|
|
309
|
+
const payload = (0, _nubitio_crud.serializeFormFields)(values, current.fields.filter((field) => (0, _nubitio_crud.canEditFieldInline)(field)), {
|
|
310
|
+
uploadedFiles: [],
|
|
311
|
+
getFieldValue: (name) => values[name],
|
|
312
|
+
adapter: currentAdapter
|
|
313
|
+
});
|
|
314
|
+
await httpClientRef.current.patch(currentAdapter.buildItemUrl(current.url, key), payload);
|
|
315
|
+
current.onContentReady?.();
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}, [
|
|
319
|
+
adapter,
|
|
320
|
+
idField,
|
|
321
|
+
source
|
|
322
|
+
]);
|
|
323
|
+
const refresh = (0, react.useCallback)(() => {
|
|
324
|
+
gridRef.current?.instance?.()?.refresh?.();
|
|
325
|
+
}, []);
|
|
326
|
+
(0, react.useImperativeHandle)(ref, () => ({
|
|
327
|
+
showLoading: () => gridRef.current?.instance?.()?.beginCustomLoading?.(t("grid.loading")),
|
|
328
|
+
hideLoading: () => gridRef.current?.instance?.()?.endCustomLoading?.(),
|
|
329
|
+
refresh,
|
|
330
|
+
reset: () => {
|
|
331
|
+
setActiveFilter(null);
|
|
332
|
+
gridRef.current?.instance?.()?.filter?.(null);
|
|
333
|
+
refresh();
|
|
334
|
+
},
|
|
335
|
+
loadData: async () => {
|
|
336
|
+
return (await source.load({})).data;
|
|
337
|
+
},
|
|
338
|
+
getSelectedRowKey: () => {
|
|
339
|
+
const key = selectedKeysRef.current[0];
|
|
340
|
+
return typeof key === "string" || typeof key === "number" ? key : void 0;
|
|
341
|
+
},
|
|
342
|
+
getSelectedRow: () => selectedRowsRef.current[0],
|
|
343
|
+
getSelectedRowKeys: () => selectedKeysRef.current,
|
|
344
|
+
getSelectedRows: () => selectedRowsRef.current,
|
|
345
|
+
getFilter: () => mergeGridFilters(routingFilterRef.current, activeFilter, fieldsRef.current),
|
|
346
|
+
filter: (filterRule) => {
|
|
347
|
+
const nextFilter = filterRule ? [
|
|
348
|
+
filterRule.field,
|
|
349
|
+
filterRule.operator,
|
|
350
|
+
filterRule.value
|
|
351
|
+
] : null;
|
|
352
|
+
setActiveFilter(nextFilter);
|
|
353
|
+
gridRef.current?.instance?.()?.filter?.(nextFilter);
|
|
354
|
+
refresh();
|
|
355
|
+
},
|
|
356
|
+
hasEditData: () => hasPendingEditsRef.current || !!gridRef.current?.instance?.()?.hasEditData?.(),
|
|
357
|
+
saveChanges: async () => {
|
|
358
|
+
if (options.onBatchSave) {
|
|
359
|
+
const instance = gridRef.current?.instance?.();
|
|
360
|
+
const selected = instance?.getSelectedRowsData?.() ?? selectedRowsRef.current;
|
|
361
|
+
await options.onBatchSave(selected);
|
|
362
|
+
instance?.cancelEditData?.();
|
|
363
|
+
hasPendingEditsRef.current = false;
|
|
364
|
+
refresh();
|
|
365
|
+
return true;
|
|
366
|
+
}
|
|
367
|
+
await gridRef.current?.instance?.()?.saveEditData?.();
|
|
368
|
+
hasPendingEditsRef.current = false;
|
|
369
|
+
refresh();
|
|
370
|
+
return true;
|
|
371
|
+
}
|
|
372
|
+
}), [
|
|
373
|
+
options.onBatchSave,
|
|
374
|
+
refresh,
|
|
375
|
+
source
|
|
376
|
+
]);
|
|
377
|
+
const handleSelectionChanged = (0, react.useCallback)((event) => {
|
|
378
|
+
const rows = event.selectedRowsData ?? [];
|
|
379
|
+
selectedRowsRef.current = rows;
|
|
380
|
+
selectedKeysRef.current = event.selectedRowKeys ?? rows.map((row) => row[idField]);
|
|
381
|
+
options.onSelectionChanged?.({ selectedRowsData: rows });
|
|
382
|
+
}, [idField, options]);
|
|
383
|
+
const handleRowDblClick = (0, react.useCallback)((event) => {
|
|
384
|
+
if (inlineEditing) return;
|
|
385
|
+
if (!event.data) return;
|
|
386
|
+
if (options.allowView) {
|
|
387
|
+
options.onView?.(event.data);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
if (options.allowEdit && options.canEditRow?.(event.data) !== false) options.onEdit?.(event.data);
|
|
391
|
+
}, [inlineEditing, options]);
|
|
392
|
+
const handleToolbarPreparing = (0, react.useCallback)((event) => {
|
|
393
|
+
const items = event.toolbarOptions?.items ?? [];
|
|
394
|
+
if (options.allowAdd) items.unshift({
|
|
395
|
+
location: "after",
|
|
396
|
+
widget: "dxButton",
|
|
397
|
+
options: {
|
|
398
|
+
text: t("grid.buttonNew"),
|
|
399
|
+
icon: "plus",
|
|
400
|
+
disabled: options.addDisabled,
|
|
401
|
+
onClick: () => options.onAdd?.()
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
if (inlineToolbar?.save) items.push({
|
|
405
|
+
location: "after",
|
|
406
|
+
widget: "dxButton",
|
|
407
|
+
options: {
|
|
408
|
+
text: t("grid.inlineSaveChanges"),
|
|
409
|
+
icon: "save",
|
|
410
|
+
onClick: () => void gridRef.current?.instance?.()?.saveEditData?.()
|
|
411
|
+
}
|
|
412
|
+
});
|
|
413
|
+
if (inlineToolbar?.revert) items.push({
|
|
414
|
+
location: "after",
|
|
415
|
+
widget: "dxButton",
|
|
416
|
+
options: {
|
|
417
|
+
text: t("grid.inlineRevertChanges"),
|
|
418
|
+
icon: "revert",
|
|
419
|
+
onClick: () => gridRef.current?.instance?.()?.cancelEditData?.()
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
if (event.toolbarOptions) event.toolbarOptions.items = items;
|
|
423
|
+
}, [
|
|
424
|
+
inlineToolbar,
|
|
425
|
+
options,
|
|
426
|
+
t
|
|
427
|
+
]);
|
|
428
|
+
const handleSaving = (0, react.useCallback)(async (event) => {
|
|
429
|
+
if (!options.onBatchSave) return;
|
|
430
|
+
event.cancel = true;
|
|
431
|
+
const changedRows = event.changes?.filter((change) => change.type === "update" && change.data).map((change) => change.data) ?? [];
|
|
432
|
+
if (changedRows.length > 0) await options.onBatchSave(changedRows);
|
|
433
|
+
hasPendingEditsRef.current = false;
|
|
434
|
+
refresh();
|
|
435
|
+
}, [options.onBatchSave, refresh]);
|
|
436
|
+
const handleEditCanceled = (0, react.useCallback)(() => {
|
|
437
|
+
hasPendingEditsRef.current = false;
|
|
438
|
+
}, []);
|
|
439
|
+
const handleEditingChange = (0, react.useCallback)(() => {
|
|
440
|
+
hasPendingEditsRef.current = true;
|
|
441
|
+
}, []);
|
|
442
|
+
const confirmDelete = (0, react.useCallback)(() => {
|
|
443
|
+
if (confirmRow) options.onDelete?.(confirmRow);
|
|
444
|
+
setConfirmRow(null);
|
|
445
|
+
}, [confirmRow, options]);
|
|
446
|
+
const requestDelete = (0, react.useCallback)((rowData) => {
|
|
447
|
+
if (!rowData || options.canDeleteRow?.(rowData) === false) return;
|
|
448
|
+
setConfirmRow(rowData);
|
|
449
|
+
}, [options.canDeleteRow]);
|
|
450
|
+
const renderRowActions = (0, react.useCallback)((cell) => {
|
|
451
|
+
const row = cell.data;
|
|
452
|
+
if (!row) return null;
|
|
453
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
454
|
+
className: "nb-dx-row-actions",
|
|
455
|
+
children: [options.allowEdit && options.canEditRow?.(row) !== false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
456
|
+
type: "button",
|
|
457
|
+
className: "nb-dx-row-actions__btn",
|
|
458
|
+
"aria-label": t("grid.buttonEdit"),
|
|
459
|
+
onClick: () => options.onEdit?.(row),
|
|
460
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
461
|
+
className: "dx-icon dx-icon-edit",
|
|
462
|
+
"aria-hidden": true
|
|
463
|
+
})
|
|
464
|
+
}) : null, options.allowDelete && options.canDeleteRow?.(row) !== false ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
465
|
+
type: "button",
|
|
466
|
+
className: "nb-dx-row-actions__btn nb-dx-row-actions__btn--delete",
|
|
467
|
+
"aria-label": t("grid.buttonDelete"),
|
|
468
|
+
onClick: () => requestDelete(row),
|
|
469
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("i", {
|
|
470
|
+
className: "dx-icon dx-icon-trash",
|
|
471
|
+
"aria-hidden": true
|
|
472
|
+
})
|
|
473
|
+
}) : null]
|
|
474
|
+
});
|
|
475
|
+
}, [
|
|
476
|
+
options.allowDelete,
|
|
477
|
+
options.allowEdit,
|
|
478
|
+
options.canDeleteRow,
|
|
479
|
+
options.canEditRow,
|
|
480
|
+
options.onEdit,
|
|
481
|
+
requestDelete,
|
|
482
|
+
t
|
|
483
|
+
]);
|
|
484
|
+
const remoteOperations = resolveDxRemoteOperations(options);
|
|
485
|
+
const hasMasterDetail = Boolean(options.detailFields && options.detailUrl);
|
|
486
|
+
const renderMasterDetail = (0, react.useCallback)((detailInfo) => {
|
|
487
|
+
const row = detailInfo.data;
|
|
488
|
+
if (!row) return null;
|
|
489
|
+
const detailFields = typeof options.detailFields === "function" ? options.detailFields(row) : options.detailFields;
|
|
490
|
+
const rowKey = row[idField];
|
|
491
|
+
const detailUrl = options.detailUrl?.replace("{id}", String(rowKey));
|
|
492
|
+
if (!detailFields?.length || !detailUrl) return null;
|
|
493
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DevExtremeDetailGridSection, {
|
|
494
|
+
fields: detailFields,
|
|
495
|
+
url: detailUrl
|
|
496
|
+
});
|
|
497
|
+
}, [
|
|
498
|
+
idField,
|
|
499
|
+
options.detailFields,
|
|
500
|
+
options.detailUrl
|
|
501
|
+
]);
|
|
502
|
+
const showToolbar = options.toolbarVisible !== false;
|
|
503
|
+
const showFilterRow = options.filterRow ?? true;
|
|
504
|
+
const showPaging = options.paging ?? true;
|
|
505
|
+
const pageSize = options.pageSize ?? 20;
|
|
506
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
507
|
+
className: "view datagrid-list data-grid-view",
|
|
508
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
509
|
+
className: "view-wrapper view-wrapper-datagrid-list list-page",
|
|
510
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
511
|
+
className: "nb-dx-datagrid",
|
|
512
|
+
children: [
|
|
513
|
+
options.aboveGrid ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
514
|
+
className: "nb-dx-datagrid__above-grid",
|
|
515
|
+
children: options.aboveGrid
|
|
516
|
+
}) : null,
|
|
517
|
+
showToolbar && options.title ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
518
|
+
className: "nb-dx-datagrid__toolbar",
|
|
519
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
520
|
+
className: "grid-header",
|
|
521
|
+
children: options.title
|
|
522
|
+
})
|
|
523
|
+
}) : null,
|
|
524
|
+
options.beforeToolbar?.(),
|
|
525
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
526
|
+
className: "nb-dx-datagrid__grid",
|
|
527
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(devextreme_react_data_grid.default, {
|
|
528
|
+
ref: gridRef,
|
|
529
|
+
dataSource,
|
|
530
|
+
keyExpr: idField,
|
|
531
|
+
height: "100%",
|
|
532
|
+
showBorders: true,
|
|
533
|
+
remoteOperations,
|
|
534
|
+
onSelectionChanged: handleSelectionChanged,
|
|
535
|
+
onRowDblClick: handleRowDblClick,
|
|
536
|
+
onToolbarPreparing: showToolbar ? handleToolbarPreparing : void 0,
|
|
537
|
+
onSaving: options.onBatchSave ? handleSaving : void 0,
|
|
538
|
+
onEditCanceled: handleEditCanceled,
|
|
539
|
+
onEditingChange: handleEditingChange,
|
|
540
|
+
children: [
|
|
541
|
+
typeof remoteOperations === "object" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.RemoteOperations, { ...remoteOperations }) : null,
|
|
542
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.LoadPanel, {
|
|
543
|
+
enabled: true,
|
|
544
|
+
showPane: true,
|
|
545
|
+
shading: false
|
|
546
|
+
}),
|
|
547
|
+
options.selectionMode === "multiple" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Selection, {
|
|
548
|
+
mode: "multiple",
|
|
549
|
+
showCheckBoxesMode: "always"
|
|
550
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Selection, { mode: "single" }),
|
|
551
|
+
showPaging ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Paging, {
|
|
552
|
+
enabled: true,
|
|
553
|
+
pageSize
|
|
554
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Pager, {
|
|
555
|
+
visible: true,
|
|
556
|
+
showInfo: true,
|
|
557
|
+
showPageSizeSelector: true,
|
|
558
|
+
allowedPageSizes: DX_PAGE_SIZE_OPTIONS,
|
|
559
|
+
displayMode: "full"
|
|
560
|
+
})] }) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Paging, { enabled: false }),
|
|
561
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Sorting, { mode: "single" }),
|
|
562
|
+
showFilterRow ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.FilterRow, {
|
|
563
|
+
visible: true,
|
|
564
|
+
applyFilter: "auto"
|
|
565
|
+
}) : null,
|
|
566
|
+
options.headerFilter ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.HeaderFilter, { visible: true }) : null,
|
|
567
|
+
showToolbar ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Toolbar, { visible: true }) : null,
|
|
568
|
+
hasMasterDetail ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.MasterDetail, {
|
|
569
|
+
enabled: true,
|
|
570
|
+
render: renderMasterDetail
|
|
571
|
+
}) : null,
|
|
572
|
+
inlineEditing && dxEditMode ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Editing, {
|
|
573
|
+
mode: dxEditMode,
|
|
574
|
+
allowUpdating: options.allowEdit !== false && options.fields.some((field) => field.type !== _nubitio_crud.FieldType.FILE && (0, _nubitio_crud.canEditFieldInline)(field)),
|
|
575
|
+
useIcons: true,
|
|
576
|
+
selectTextOnEditStart: true
|
|
577
|
+
}) : null,
|
|
578
|
+
columns.map((column) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Column, { ...column }, column.dataField)),
|
|
579
|
+
!inlineEditing && (options.allowDelete || options.allowEdit) ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Column, {
|
|
580
|
+
caption: "",
|
|
581
|
+
width: 110,
|
|
582
|
+
allowSorting: false,
|
|
583
|
+
allowFiltering: false,
|
|
584
|
+
allowEditing: false,
|
|
585
|
+
cellRender: renderRowActions
|
|
586
|
+
}) : null,
|
|
587
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Item, { name: "searchPanel" })
|
|
588
|
+
]
|
|
589
|
+
})
|
|
590
|
+
}),
|
|
591
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_ui.ConfirmDialog, {
|
|
592
|
+
open: Boolean(confirmRow),
|
|
593
|
+
title: t("dialog.confirmDeleteTitle"),
|
|
594
|
+
message: t("dialog.confirmDelete"),
|
|
595
|
+
variant: "danger",
|
|
596
|
+
cancelLabel: t("dialog.buttonCancel"),
|
|
597
|
+
confirmLabel: t("grid.buttonDelete"),
|
|
598
|
+
onCancel: () => setConfirmRow(null),
|
|
599
|
+
onConfirm: confirmDelete
|
|
600
|
+
})
|
|
601
|
+
]
|
|
602
|
+
})
|
|
603
|
+
})
|
|
604
|
+
});
|
|
605
|
+
});
|
|
606
|
+
DevExtremeDataGridView.displayName = "DevExtremeDataGridView";
|
|
607
|
+
//#endregion
|
|
608
|
+
//#region packages/devextreme/DevExtremeFormDetailGrid.tsx
|
|
609
|
+
function DevExtremeFormDetailGrid({ fields, rows, allowAdding = false, allowUpdating = false, allowDeleting = false, onRowsChange }) {
|
|
610
|
+
const { t } = (0, _nubitio_core.useCoreTranslation)();
|
|
611
|
+
const columns = (0, react.useMemo)(() => mapFieldsToDxColumns(fields), [fields]);
|
|
612
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
613
|
+
className: "nb-dx-form-detail",
|
|
614
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
615
|
+
className: "nb-dx-form-detail__heading",
|
|
616
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h3", {
|
|
617
|
+
className: "nb-dx-form-detail__title",
|
|
618
|
+
children: t("form.detailTitle")
|
|
619
|
+
})
|
|
620
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(devextreme_react_data_grid.default, {
|
|
621
|
+
dataSource: rows,
|
|
622
|
+
keyExpr: "__rowKey",
|
|
623
|
+
showBorders: true,
|
|
624
|
+
onInitNewRow: (event) => {
|
|
625
|
+
const data = event.data;
|
|
626
|
+
Object.assign(data, (0, _nubitio_crud.buildEmptyRow)(fields), { __rowKey: crypto.randomUUID() });
|
|
627
|
+
},
|
|
628
|
+
onRowInserted: (event) => {
|
|
629
|
+
onRowsChange([...rows, event.data]);
|
|
630
|
+
},
|
|
631
|
+
onRowRemoved: (event) => {
|
|
632
|
+
const key = event.data.__rowKey;
|
|
633
|
+
onRowsChange(rows.filter((row) => row.__rowKey !== key));
|
|
634
|
+
},
|
|
635
|
+
onRowUpdated: (event) => {
|
|
636
|
+
const key = event.data.__rowKey;
|
|
637
|
+
onRowsChange(rows.map((row) => row.__rowKey === key ? event.data : row));
|
|
638
|
+
},
|
|
639
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Editing, {
|
|
640
|
+
mode: "row",
|
|
641
|
+
allowAdding,
|
|
642
|
+
allowUpdating,
|
|
643
|
+
allowDeleting,
|
|
644
|
+
useIcons: true
|
|
645
|
+
}), columns.map((column) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_data_grid.Column, { ...column }, column.dataField))]
|
|
646
|
+
})]
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region packages/devextreme/mapFieldsToDxFormItems.ts
|
|
651
|
+
function resolveEditorType(field) {
|
|
652
|
+
switch (field.type) {
|
|
653
|
+
case _nubitio_crud.FieldType.TEXT:
|
|
654
|
+
case _nubitio_crud.FieldType.PASSWORD: return "dxTextBox";
|
|
655
|
+
case _nubitio_crud.FieldType.TEXTAREA: return "dxTextArea";
|
|
656
|
+
case _nubitio_crud.FieldType.NUMBER:
|
|
657
|
+
case _nubitio_crud.FieldType.CURRENCY: return "dxNumberBox";
|
|
658
|
+
case _nubitio_crud.FieldType.DATE: return "dxDateBox";
|
|
659
|
+
case _nubitio_crud.FieldType.DATETIME: return "dxDateBox";
|
|
660
|
+
case _nubitio_crud.FieldType.CHECKBOX: return "dxCheckBox";
|
|
661
|
+
case _nubitio_crud.FieldType.SWITCH: return "dxSwitch";
|
|
662
|
+
case _nubitio_crud.FieldType.SELECT:
|
|
663
|
+
case _nubitio_crud.FieldType.ENUM:
|
|
664
|
+
case _nubitio_crud.FieldType.ENTITY:
|
|
665
|
+
case _nubitio_crud.FieldType.RADIO:
|
|
666
|
+
case _nubitio_crud.FieldType.TAGS: return "dxSelectBox";
|
|
667
|
+
default: return "dxTextBox";
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
function resolveEditorOptions(field) {
|
|
671
|
+
const options = {};
|
|
672
|
+
if (field.type === _nubitio_crud.FieldType.PASSWORD) options.mode = "password";
|
|
673
|
+
if (field.type === _nubitio_crud.FieldType.TEXTAREA) options.height = field.height ?? 96;
|
|
674
|
+
if (field.maxLength != null) options.maxLength = field.maxLength;
|
|
675
|
+
if (field.type === _nubitio_crud.FieldType.SELECT || field.type === _nubitio_crud.FieldType.ENUM || field.type === _nubitio_crud.FieldType.ENTITY || field.type === _nubitio_crud.FieldType.RADIO || field.type === _nubitio_crud.FieldType.TAGS) {
|
|
676
|
+
options.dataSource = field.data ?? [];
|
|
677
|
+
options.displayExpr = field.textField || "label";
|
|
678
|
+
options.valueExpr = field.valueField || "value";
|
|
679
|
+
options.searchEnabled = field.searchEnabled;
|
|
680
|
+
}
|
|
681
|
+
if (field.format) options.format = field.format;
|
|
682
|
+
if (field.precision > 0 && (field.type === _nubitio_crud.FieldType.NUMBER || field.type === _nubitio_crud.FieldType.CURRENCY)) options.format = field.format || `#,##0.${"0".repeat(field.precision)}`;
|
|
683
|
+
return options;
|
|
684
|
+
}
|
|
685
|
+
function mapFieldsToDxFormItems(fields) {
|
|
686
|
+
return fields.filter((field) => !field.isIdentity && field.visibleOnForm && !field.hidden).sort((left, right) => (left.order ?? Number.MAX_SAFE_INTEGER) - (right.order ?? Number.MAX_SAFE_INTEGER)).map((field) => ({
|
|
687
|
+
dataField: field.name,
|
|
688
|
+
label: { text: field.label || field.name },
|
|
689
|
+
editorType: resolveEditorType(field),
|
|
690
|
+
editorOptions: resolveEditorOptions(field),
|
|
691
|
+
colSpan: field.col,
|
|
692
|
+
isRequired: field.required,
|
|
693
|
+
helpText: field.helpText
|
|
694
|
+
}));
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region packages/devextreme/DevExtremeFormView.tsx
|
|
698
|
+
function isEmptyValue(value) {
|
|
699
|
+
return value === null || value === void 0 || value === "" || Array.isArray(value) && value.length === 0;
|
|
700
|
+
}
|
|
701
|
+
function withDetailRowKeys(rows) {
|
|
702
|
+
return rows.map((row) => ({
|
|
703
|
+
...row,
|
|
704
|
+
__rowKey: typeof row.__rowKey === "string" ? row.__rowKey : crypto.randomUUID()
|
|
705
|
+
}));
|
|
706
|
+
}
|
|
707
|
+
function validateField(field, value, formData, t) {
|
|
708
|
+
if (field.required && isEmptyValue(value)) return t("form.fieldRequired", { label: field.label });
|
|
709
|
+
for (const rule of field.validators ?? []) {
|
|
710
|
+
if (rule.type === "required" && isEmptyValue(value)) return rule.options.message ?? t("form.fieldRequired", { label: field.label });
|
|
711
|
+
if (rule.type === "email" && typeof value === "string" && value !== "" && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value)) return rule.options.message ?? t("form.invalidEmail");
|
|
712
|
+
if (rule.type === "numeric" && value !== "" && value != null && Number.isNaN(Number(value))) return rule.options.message ?? t("form.invalidNumeric");
|
|
713
|
+
if (rule.type === "pattern" && typeof value === "string" && !new RegExp(rule.options.pattern).test(value)) return rule.options.message ?? t("form.invalidPattern");
|
|
714
|
+
if (rule.type === "stringLength" && typeof value === "string") {
|
|
715
|
+
if (rule.options.min !== void 0 && value.length < rule.options.min) return rule.options.message ?? t("form.stringTooShort");
|
|
716
|
+
if (rule.options.max !== void 0 && value.length > rule.options.max) return rule.options.message ?? t("form.stringTooLong");
|
|
717
|
+
}
|
|
718
|
+
if (rule.type === "range" && value !== "" && value != null) {
|
|
719
|
+
const numericValue = Number(value);
|
|
720
|
+
if (rule.options.min !== void 0 && numericValue < rule.options.min) return rule.options.message ?? t("form.outOfRange");
|
|
721
|
+
if (rule.options.max !== void 0 && numericValue > rule.options.max) return rule.options.message ?? t("form.outOfRange");
|
|
722
|
+
}
|
|
723
|
+
if (rule.type === "custom") {
|
|
724
|
+
if (!rule.options.validationCallback({
|
|
725
|
+
value,
|
|
726
|
+
data: formData
|
|
727
|
+
})) return rule.options.message ?? t("validation.defaultError");
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
return null;
|
|
731
|
+
}
|
|
732
|
+
const DevExtremeFormView = (0, react.forwardRef)((options, ref) => {
|
|
733
|
+
const { t } = (0, _nubitio_core.useCoreTranslation)();
|
|
734
|
+
const httpClient = (0, _nubitio_core.useCoreHttpClient)();
|
|
735
|
+
const [on, emit] = (0, _nubitio_core.useEvents)();
|
|
736
|
+
const scopedFormErrorsEvent = `${_nubitio_crud.FORM_ERRORS_EVENT}:${(0, react.useId)()}`;
|
|
737
|
+
const appliedOperationRef = (0, react.useRef)(null);
|
|
738
|
+
const [detailDirty, setDetailDirty] = (0, react.useState)(false);
|
|
739
|
+
const { isEdit, uploadedFiles, existingMediaByField, formData, formDataRef, detailRows, detailRowsRef, fieldState, setFieldState, errors, setErrors, detailErrors, setDetailErrors, prependDataRef, setNextFormData, setNextDetailRows, setFieldValue, setEditMode, resetUploadSession, resetPrependData, setExistingMedia, clearExistingMedia, upsertUploadedFile } = (0, _nubitio_crud.useFormState)({
|
|
740
|
+
fields: options.fields,
|
|
741
|
+
onFieldDataChanged: options.onFieldDataChanged
|
|
742
|
+
});
|
|
743
|
+
const detailPropertyName = options.detailPropertyName ?? "items";
|
|
744
|
+
const formItems = (0, react.useMemo)(() => mapFieldsToDxFormItems(options.fields), [options.fields]);
|
|
745
|
+
const detailRowsWithKeys = (0, react.useMemo)(() => withDetailRowKeys(detailRows), [detailRows]);
|
|
746
|
+
const validate = (0, _nubitio_crud.useFormValidation)({
|
|
747
|
+
accessors: {
|
|
748
|
+
getDetailRowCount: () => detailRowsRef.current.length,
|
|
749
|
+
getDetailRows: () => detailRowsRef.current,
|
|
750
|
+
hasPendingDetailEdits: () => detailDirty,
|
|
751
|
+
validateForm: (0, react.useCallback)(() => {
|
|
752
|
+
const nextErrors = {};
|
|
753
|
+
options.fields.forEach((field) => {
|
|
754
|
+
const state = fieldState[field.name];
|
|
755
|
+
if (field.isIdentity || state?.validationEnabled === false || state?.hidden === true || field.hidden || field.visibleOnForm === false) return;
|
|
756
|
+
let value = formDataRef.current[field.name];
|
|
757
|
+
if (field.type === _nubitio_crud.FieldType.FILE) {
|
|
758
|
+
const uploaded = uploadedFiles.current.find((file) => file.name === field.name);
|
|
759
|
+
const hasExisting = !!existingMediaByField.current[field.name];
|
|
760
|
+
value = uploaded?.iri != null || hasExisting && uploaded === void 0 ? "present" : null;
|
|
761
|
+
}
|
|
762
|
+
const error = validateField(field, value, formDataRef.current, t);
|
|
763
|
+
if (error) nextErrors[field.name] = error;
|
|
764
|
+
});
|
|
765
|
+
setErrors(nextErrors);
|
|
766
|
+
setDetailErrors({});
|
|
767
|
+
return Object.keys(nextErrors).length === 0;
|
|
768
|
+
}, [
|
|
769
|
+
existingMediaByField,
|
|
770
|
+
fieldState,
|
|
771
|
+
formDataRef,
|
|
772
|
+
options.fields,
|
|
773
|
+
setDetailErrors,
|
|
774
|
+
setErrors,
|
|
775
|
+
t,
|
|
776
|
+
uploadedFiles
|
|
777
|
+
])
|
|
778
|
+
},
|
|
779
|
+
detailFields: options.detailFields,
|
|
780
|
+
detailNoDataText: options.requiredDetail ? t("form.detailRequired") : t("form.detailEmpty"),
|
|
781
|
+
requiredDetail: options.requiredDetail,
|
|
782
|
+
validationErrorText: t("form.validationError")
|
|
783
|
+
});
|
|
784
|
+
const submitAccessors = (0, react.useMemo)(() => ({
|
|
785
|
+
getDetailRows: () => detailRowsRef.current,
|
|
786
|
+
getFieldValue: (field) => formDataRef.current[field],
|
|
787
|
+
getFormData: () => formDataRef.current,
|
|
788
|
+
getUploadedFiles: () => uploadedFiles.current,
|
|
789
|
+
isEditMode: () => isEdit.current
|
|
790
|
+
}), [
|
|
791
|
+
detailRowsRef,
|
|
792
|
+
formDataRef,
|
|
793
|
+
isEdit,
|
|
794
|
+
uploadedFiles
|
|
795
|
+
]);
|
|
796
|
+
const { handleSave, handleDelete } = (0, _nubitio_crud.useFormSubmit)({
|
|
797
|
+
url: options.url,
|
|
798
|
+
detailUrl: options.detailUrl,
|
|
799
|
+
fields: options.fields,
|
|
800
|
+
detailFields: options.detailFields,
|
|
801
|
+
detailPropertyName,
|
|
802
|
+
format: options.format,
|
|
803
|
+
events: options.events,
|
|
804
|
+
formErrorsEvent: scopedFormErrorsEvent,
|
|
805
|
+
httpClient,
|
|
806
|
+
adapter: options.adapter,
|
|
807
|
+
onSaveSuccess: options.onSaveSuccess,
|
|
808
|
+
onSaveError: options.onSaveError,
|
|
809
|
+
onDeleteSuccess: options.onDeleteSuccess,
|
|
810
|
+
onDeleteError: options.onDeleteError,
|
|
811
|
+
onLoadingChange: options.onLoadingChange
|
|
812
|
+
}, submitAccessors, emit, validate);
|
|
813
|
+
const handleSaveRef = (0, react.useRef)(handleSave);
|
|
814
|
+
handleSaveRef.current = handleSave;
|
|
815
|
+
const handleDeleteRef = (0, react.useRef)(handleDelete);
|
|
816
|
+
handleDeleteRef.current = handleDelete;
|
|
817
|
+
const captureExistingMedia = (0, react.useCallback)((row) => {
|
|
818
|
+
const nextMedia = {};
|
|
819
|
+
options.fields.forEach((field) => {
|
|
820
|
+
if (field.type !== _nubitio_crud.FieldType.FILE) return;
|
|
821
|
+
const raw = row[field.name];
|
|
822
|
+
if (raw && typeof raw === "object") nextMedia[field.name] = raw;
|
|
823
|
+
});
|
|
824
|
+
setExistingMedia(nextMedia);
|
|
825
|
+
}, [options.fields, setExistingMedia]);
|
|
826
|
+
const applyAddPayload = (0, react.useCallback)((payload) => {
|
|
827
|
+
resetUploadSession();
|
|
828
|
+
setExistingMedia({});
|
|
829
|
+
setErrors({});
|
|
830
|
+
setDetailErrors({});
|
|
831
|
+
setNextDetailRows([]);
|
|
832
|
+
setDetailDirty(false);
|
|
833
|
+
resetPrependData();
|
|
834
|
+
setNextFormData(payload ? (0, _nubitio_crud.normalizeFormData)(payload, options.fields, options.adapter, prependDataRef.current) : (0, _nubitio_crud.buildEmptyRow)(options.fields));
|
|
835
|
+
setEditMode(false);
|
|
836
|
+
}, [
|
|
837
|
+
options.adapter,
|
|
838
|
+
options.fields,
|
|
839
|
+
prependDataRef,
|
|
840
|
+
resetPrependData,
|
|
841
|
+
resetUploadSession,
|
|
842
|
+
setDetailErrors,
|
|
843
|
+
setEditMode,
|
|
844
|
+
setErrors,
|
|
845
|
+
setExistingMedia,
|
|
846
|
+
setNextDetailRows,
|
|
847
|
+
setNextFormData
|
|
848
|
+
]);
|
|
849
|
+
const applyEditPayload = (0, react.useCallback)((payload) => {
|
|
850
|
+
resetPrependData();
|
|
851
|
+
captureExistingMedia(payload.row);
|
|
852
|
+
const row = (0, _nubitio_crud.normalizeFormData)(payload.row, options.fields, options.adapter, prependDataRef.current);
|
|
853
|
+
resetUploadSession();
|
|
854
|
+
setErrors({});
|
|
855
|
+
setDetailErrors({});
|
|
856
|
+
setNextFormData(row);
|
|
857
|
+
setEditMode(true);
|
|
858
|
+
setDetailDirty(false);
|
|
859
|
+
const detailId = row[options.fields.find((field) => field.isIdentity)?.name ?? ""];
|
|
860
|
+
const detailUrl = typeof detailId === "string" || typeof detailId === "number" ? options.detailUrl?.replace("{id}", String(detailId)) : void 0;
|
|
861
|
+
if (!detailUrl) return;
|
|
862
|
+
emit(_nubitio_crud.FORM_EVENTS.LOADING, true);
|
|
863
|
+
(0, _nubitio_crud.loadDetailRows)(httpClient, detailUrl, options.adapter).then((rows) => setNextDetailRows(withDetailRowKeys(rows))).finally(() => emit(_nubitio_crud.FORM_EVENTS.LOADING, false));
|
|
864
|
+
}, [
|
|
865
|
+
captureExistingMedia,
|
|
866
|
+
emit,
|
|
867
|
+
httpClient,
|
|
868
|
+
options.adapter,
|
|
869
|
+
options.detailUrl,
|
|
870
|
+
options.fields,
|
|
871
|
+
prependDataRef,
|
|
872
|
+
resetPrependData,
|
|
873
|
+
resetUploadSession,
|
|
874
|
+
setDetailErrors,
|
|
875
|
+
setEditMode,
|
|
876
|
+
setErrors,
|
|
877
|
+
setNextDetailRows,
|
|
878
|
+
setNextFormData
|
|
879
|
+
]);
|
|
880
|
+
(0, react.useEffect)(() => {
|
|
881
|
+
if (!options.operation) {
|
|
882
|
+
appliedOperationRef.current = null;
|
|
883
|
+
return;
|
|
884
|
+
}
|
|
885
|
+
const operationKey = `${options.operation}:${options.operationVersion ?? 0}`;
|
|
886
|
+
if (appliedOperationRef.current === operationKey) return;
|
|
887
|
+
appliedOperationRef.current = operationKey;
|
|
888
|
+
if (options.operation === "add") {
|
|
889
|
+
applyAddPayload(options.rowData ?? void 0);
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
892
|
+
if (options.operation === "edit" && options.rowData) applyEditPayload({ row: options.rowData });
|
|
893
|
+
}, [
|
|
894
|
+
applyAddPayload,
|
|
895
|
+
applyEditPayload,
|
|
896
|
+
options.operation,
|
|
897
|
+
options.operationVersion,
|
|
898
|
+
options.rowData
|
|
899
|
+
]);
|
|
900
|
+
(0, react.useEffect)(() => {
|
|
901
|
+
const subs = [on(scopedFormErrorsEvent, (formErrors) => {
|
|
902
|
+
const mapped = (0, _nubitio_crud.mapApiViolations)(formErrors, detailPropertyName, t("validation.defaultError"));
|
|
903
|
+
setErrors((current) => ({
|
|
904
|
+
...current,
|
|
905
|
+
...mapped.fieldErrors
|
|
906
|
+
}));
|
|
907
|
+
setDetailErrors(mapped.detailErrors);
|
|
908
|
+
})];
|
|
909
|
+
if (options.events?.ADD) subs.push(on(options.events.ADD, (payload) => applyAddPayload(payload)));
|
|
910
|
+
if (options.events?.EDIT) subs.push(on(options.events.EDIT, (payload) => applyEditPayload(payload)));
|
|
911
|
+
if (options.events?.DELETE) subs.push(on(options.events.DELETE, (payload) => handleDeleteRef.current(payload)));
|
|
912
|
+
if (options.events?.SAVE) subs.push(on(options.events.SAVE, () => handleSaveRef.current()));
|
|
913
|
+
return () => subs.forEach((sub) => sub.unsubscribe());
|
|
914
|
+
}, [scopedFormErrorsEvent]);
|
|
915
|
+
const handleDetailRowsChange = (0, react.useCallback)((rows) => {
|
|
916
|
+
setNextDetailRows(withDetailRowKeys(rows).map(({ __rowKey, ...row }) => row));
|
|
917
|
+
setDetailDirty(true);
|
|
918
|
+
}, [setNextDetailRows]);
|
|
919
|
+
(0, react.useImperativeHandle)(ref, () => ({
|
|
920
|
+
getFormData: () => formDataRef.current,
|
|
921
|
+
getFieldValue: (name) => formDataRef.current[name],
|
|
922
|
+
setFieldValue,
|
|
923
|
+
getDetailData: () => detailRowsRef.current,
|
|
924
|
+
setDetailData: (data) => setNextDetailRows(data),
|
|
925
|
+
saveDetailData: () => void 0,
|
|
926
|
+
reloadDetailData: () => void 0,
|
|
927
|
+
setValues: (data) => {
|
|
928
|
+
resetPrependData();
|
|
929
|
+
setNextFormData((0, _nubitio_crud.normalizeFormData)(data, options.fields, void 0, prependDataRef.current));
|
|
930
|
+
},
|
|
931
|
+
save: () => handleSaveRef.current(),
|
|
932
|
+
deleteRow: (row) => handleDeleteRef.current({ row }),
|
|
933
|
+
setReadonly: (field, value) => setFieldState((current) => ({
|
|
934
|
+
...current,
|
|
935
|
+
[field]: {
|
|
936
|
+
...current[field],
|
|
937
|
+
readonly: value
|
|
938
|
+
}
|
|
939
|
+
})),
|
|
940
|
+
setDisabled: (field, value) => setFieldState((current) => ({
|
|
941
|
+
...current,
|
|
942
|
+
[field]: {
|
|
943
|
+
...current[field],
|
|
944
|
+
disabled: value
|
|
945
|
+
}
|
|
946
|
+
})),
|
|
947
|
+
enableValidation: (field) => setFieldState((current) => ({
|
|
948
|
+
...current,
|
|
949
|
+
[field]: {
|
|
950
|
+
...current[field],
|
|
951
|
+
validationEnabled: true
|
|
952
|
+
}
|
|
953
|
+
})),
|
|
954
|
+
disableValidation: (field) => setFieldState((current) => ({
|
|
955
|
+
...current,
|
|
956
|
+
[field]: {
|
|
957
|
+
...current[field],
|
|
958
|
+
validationEnabled: false
|
|
959
|
+
}
|
|
960
|
+
})),
|
|
961
|
+
setError: (field, message) => setErrors((current) => ({
|
|
962
|
+
...current,
|
|
963
|
+
[field]: message
|
|
964
|
+
})),
|
|
965
|
+
showField: (field) => setFieldState((current) => ({
|
|
966
|
+
...current,
|
|
967
|
+
[field]: {
|
|
968
|
+
...current[field],
|
|
969
|
+
hidden: false
|
|
970
|
+
}
|
|
971
|
+
})),
|
|
972
|
+
hideField: (field) => setFieldState((current) => ({
|
|
973
|
+
...current,
|
|
974
|
+
[field]: {
|
|
975
|
+
...current[field],
|
|
976
|
+
hidden: true
|
|
977
|
+
}
|
|
978
|
+
})),
|
|
979
|
+
validate,
|
|
980
|
+
setIsEdit: (value) => setEditMode(value)
|
|
981
|
+
}), [
|
|
982
|
+
detailRowsRef,
|
|
983
|
+
formDataRef,
|
|
984
|
+
options.fields,
|
|
985
|
+
prependDataRef,
|
|
986
|
+
resetPrependData,
|
|
987
|
+
setEditMode,
|
|
988
|
+
setErrors,
|
|
989
|
+
setFieldState,
|
|
990
|
+
setFieldValue,
|
|
991
|
+
setNextDetailRows,
|
|
992
|
+
setNextFormData,
|
|
993
|
+
validate
|
|
994
|
+
]);
|
|
995
|
+
const fileFields = options.fields.filter((field) => field.type === _nubitio_crud.FieldType.FILE && field.visibleOnForm && !field.hidden && !fieldState[field.name]?.hidden);
|
|
996
|
+
const visibleItems = formItems.filter((item) => {
|
|
997
|
+
const state = fieldState[item.dataField] ?? {};
|
|
998
|
+
const field = options.fields.find((candidate) => candidate.name === item.dataField);
|
|
999
|
+
return !state.hidden && field?.type !== _nubitio_crud.FieldType.FILE && field?.type !== _nubitio_crud.FieldType.HTML;
|
|
1000
|
+
});
|
|
1001
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1002
|
+
className: options.className ?? "nb-dx-form",
|
|
1003
|
+
children: [
|
|
1004
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_form.default, {
|
|
1005
|
+
formData,
|
|
1006
|
+
colCount: 2,
|
|
1007
|
+
labelLocation: "top",
|
|
1008
|
+
readOnly: options.editable === false,
|
|
1009
|
+
onFieldDataChanged: (event) => {
|
|
1010
|
+
if (!event.dataField) return;
|
|
1011
|
+
setFieldValue(event.dataField, event.value);
|
|
1012
|
+
},
|
|
1013
|
+
children: visibleItems.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(devextreme_react_form.SimpleItem, {
|
|
1014
|
+
dataField: item.dataField,
|
|
1015
|
+
label: item.label,
|
|
1016
|
+
editorType: item.editorType,
|
|
1017
|
+
editorOptions: {
|
|
1018
|
+
...item.editorOptions,
|
|
1019
|
+
readOnly: fieldState[item.dataField]?.readonly ?? options.fields.find((field) => field.name === item.dataField)?.readonly ?? options.editable === false,
|
|
1020
|
+
disabled: fieldState[item.dataField]?.disabled ?? options.fields.find((field) => field.name === item.dataField)?.disabled
|
|
1021
|
+
},
|
|
1022
|
+
colSpan: item.colSpan,
|
|
1023
|
+
isRequired: item.isRequired,
|
|
1024
|
+
helpText: item.helpText,
|
|
1025
|
+
validationError: errors[item.dataField]
|
|
1026
|
+
}, item.dataField))
|
|
1027
|
+
}),
|
|
1028
|
+
fileFields.map((field) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1029
|
+
className: "nb-dx-form__file-field",
|
|
1030
|
+
children: [
|
|
1031
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("label", {
|
|
1032
|
+
className: "nb-dx-form__file-label",
|
|
1033
|
+
children: field.label
|
|
1034
|
+
}),
|
|
1035
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_nubitio_crud.FileUploadField, {
|
|
1036
|
+
field,
|
|
1037
|
+
existingMedia: existingMediaByField.current[field.name] ?? null,
|
|
1038
|
+
disabled: fieldState[field.name]?.disabled ?? field.disabled ?? options.editable === false,
|
|
1039
|
+
readOnly: fieldState[field.name]?.readonly ?? field.readonly ?? options.editable === false,
|
|
1040
|
+
invalid: !!errors[field.name],
|
|
1041
|
+
uploadUrl: field.url ?? `${options.url}/upload`,
|
|
1042
|
+
httpClient,
|
|
1043
|
+
t,
|
|
1044
|
+
onUploaded: (entry) => upsertUploadedFile(entry),
|
|
1045
|
+
onCleared: (fieldName) => clearExistingMedia(fieldName)
|
|
1046
|
+
}),
|
|
1047
|
+
errors[field.name] ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
1048
|
+
className: "nb-dx-form__error",
|
|
1049
|
+
children: errors[field.name]
|
|
1050
|
+
}) : null
|
|
1051
|
+
]
|
|
1052
|
+
}, field.name)),
|
|
1053
|
+
options.detailFields?.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DevExtremeFormDetailGrid, {
|
|
1054
|
+
fields: options.detailFields,
|
|
1055
|
+
rows: detailRowsWithKeys,
|
|
1056
|
+
allowAdding: options.allowAdding,
|
|
1057
|
+
allowUpdating: options.allowUpdating,
|
|
1058
|
+
allowDeleting: options.allowDeleting,
|
|
1059
|
+
detailErrors,
|
|
1060
|
+
onRowsChange: handleDetailRowsChange
|
|
1061
|
+
}) : null
|
|
1062
|
+
]
|
|
1063
|
+
});
|
|
1064
|
+
});
|
|
1065
|
+
DevExtremeFormView.displayName = "DevExtremeFormView";
|
|
1066
|
+
//#endregion
|
|
1067
|
+
//#region packages/devextreme/DevExtremeThemeSync.tsx
|
|
1068
|
+
function readNubitTheme() {
|
|
1069
|
+
const theme = document.documentElement.dataset.theme;
|
|
1070
|
+
if (theme === "dark" || theme === "light") return theme;
|
|
1071
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
1072
|
+
}
|
|
1073
|
+
function applyDevExtremeTheme(theme, basePath) {
|
|
1074
|
+
const href = `${basePath}dx.${theme}.css`;
|
|
1075
|
+
const id = "nb-devextreme-theme-link";
|
|
1076
|
+
let link = document.getElementById(id);
|
|
1077
|
+
if (link?.getAttribute("data-dx-theme-href") === href) return;
|
|
1078
|
+
if (link) {
|
|
1079
|
+
link.href = href;
|
|
1080
|
+
link.setAttribute("data-dx-theme-href", href);
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
link = document.createElement("link");
|
|
1084
|
+
link.id = id;
|
|
1085
|
+
link.rel = "stylesheet";
|
|
1086
|
+
link.href = href;
|
|
1087
|
+
link.setAttribute("data-dx-theme-href", href);
|
|
1088
|
+
document.head.appendChild(link);
|
|
1089
|
+
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Swaps DevExtreme base theme CSS when Nubit `data-theme` changes.
|
|
1092
|
+
* Mount once inside `ThemeProvider` (typically via `DevExtremeCrudProvider`).
|
|
1093
|
+
*/
|
|
1094
|
+
function DevExtremeThemeSync({ basePath = "/devextreme-themes/" }) {
|
|
1095
|
+
(0, react.useEffect)(() => {
|
|
1096
|
+
const sync = () => applyDevExtremeTheme(readNubitTheme(), basePath);
|
|
1097
|
+
sync();
|
|
1098
|
+
const observer = new MutationObserver(sync);
|
|
1099
|
+
observer.observe(document.documentElement, {
|
|
1100
|
+
attributes: true,
|
|
1101
|
+
attributeFilter: ["data-theme", "class"]
|
|
1102
|
+
});
|
|
1103
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
1104
|
+
const onSystemChange = () => {
|
|
1105
|
+
if (!document.documentElement.dataset.theme) sync();
|
|
1106
|
+
};
|
|
1107
|
+
mq.addEventListener("change", onSystemChange);
|
|
1108
|
+
return () => {
|
|
1109
|
+
observer.disconnect();
|
|
1110
|
+
mq.removeEventListener("change", onSystemChange);
|
|
1111
|
+
};
|
|
1112
|
+
}, [basePath]);
|
|
1113
|
+
return null;
|
|
1114
|
+
}
|
|
1115
|
+
//#endregion
|
|
1116
|
+
//#region packages/devextreme/DevExtremeCrudProvider.tsx
|
|
1117
|
+
const defaultDevExtremeViews = {
|
|
1118
|
+
DataGridView: DevExtremeDataGridView,
|
|
1119
|
+
FormView: DevExtremeFormView
|
|
1120
|
+
};
|
|
1121
|
+
function DevExtremeCrudProvider({ children, views, basePath, syncTheme = true }) {
|
|
1122
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_nubitio_crud.CrudViewProvider, {
|
|
1123
|
+
views: (0, react.useMemo)(() => ({
|
|
1124
|
+
DataGridView: views?.DataGridView ?? defaultDevExtremeViews.DataGridView,
|
|
1125
|
+
FormView: views?.FormView ?? defaultDevExtremeViews.FormView
|
|
1126
|
+
}), [views?.DataGridView, views?.FormView]),
|
|
1127
|
+
children: [syncTheme ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(DevExtremeThemeSync, { basePath }) : null, children]
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
//#endregion
|
|
1131
|
+
exports.DevExtremeCrudProvider = DevExtremeCrudProvider;
|
|
1132
|
+
exports.DevExtremeDataGridView = DevExtremeDataGridView;
|
|
1133
|
+
exports.DevExtremeDetailGridSection = DevExtremeDetailGridSection;
|
|
1134
|
+
exports.DevExtremeFormDetailGrid = DevExtremeFormDetailGrid;
|
|
1135
|
+
exports.DevExtremeFormView = DevExtremeFormView;
|
|
1136
|
+
exports.DevExtremeThemeSync = DevExtremeThemeSync;
|
|
1137
|
+
exports.convertDxFilterToNubit = convertDxFilterToNubit;
|
|
1138
|
+
exports.flattenDxFilter = flattenDxFilter;
|
|
1139
|
+
exports.mapFieldsToDxColumns = mapFieldsToDxColumns;
|
|
1140
|
+
exports.mapFieldsToDxFormItems = mapFieldsToDxFormItems;
|
|
1141
|
+
exports.mergeGridFilters = mergeGridFilters;
|