@openg2p/registry-widgets 1.1.2 → 1.1.3-dev.1
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/dist/components/SectionBuilder/schemas.d.ts +16 -0
- package/dist/components/SectionBuilder/schemas.d.ts.map +1 -1
- package/dist/index.esm.js +76 -15
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +76 -15
- package/dist/index.js.map +1 -1
- package/dist/utils/conditions.d.ts.map +1 -1
- package/dist/widgets/DialogTableWidget.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -437,6 +437,10 @@ export declare const panelSchema: {
|
|
|
437
437
|
'column-key': {
|
|
438
438
|
type: "string";
|
|
439
439
|
};
|
|
440
|
+
'column-group': {
|
|
441
|
+
type: "string";
|
|
442
|
+
description: string;
|
|
443
|
+
};
|
|
440
444
|
'widget-label': {
|
|
441
445
|
type: "string";
|
|
442
446
|
};
|
|
@@ -964,6 +968,10 @@ export declare const panelSchema: {
|
|
|
964
968
|
'column-key': {
|
|
965
969
|
type: "string";
|
|
966
970
|
};
|
|
971
|
+
'column-group': {
|
|
972
|
+
type: "string";
|
|
973
|
+
description: string;
|
|
974
|
+
};
|
|
967
975
|
'widget-label': {
|
|
968
976
|
type: "string";
|
|
969
977
|
};
|
|
@@ -1554,6 +1562,10 @@ export declare const sectionSchema: {
|
|
|
1554
1562
|
'column-key': {
|
|
1555
1563
|
type: "string";
|
|
1556
1564
|
};
|
|
1565
|
+
'column-group': {
|
|
1566
|
+
type: "string";
|
|
1567
|
+
description: string;
|
|
1568
|
+
};
|
|
1557
1569
|
'widget-label': {
|
|
1558
1570
|
type: "string";
|
|
1559
1571
|
};
|
|
@@ -2081,6 +2093,10 @@ export declare const sectionSchema: {
|
|
|
2081
2093
|
'column-key': {
|
|
2082
2094
|
type: "string";
|
|
2083
2095
|
};
|
|
2096
|
+
'column-group': {
|
|
2097
|
+
type: "string";
|
|
2098
|
+
description: string;
|
|
2099
|
+
};
|
|
2084
2100
|
'widget-label': {
|
|
2085
2101
|
type: "string";
|
|
2086
2102
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/components/SectionBuilder/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,YAAY,yNAmBf,CAAC;AAEX,eAAO,MAAM,YAAY,qCAAsC,CAAC;AAEhE,eAAO,MAAM,mBAAmB,6GAStB,CAAC;AAEX,eAAO,MAAM,iBAAiB,sCAAuC,CAAC;AAEtE,eAAO,MAAM,gBAAgB,oCAAqC,CAAC;AAEnE,eAAO,MAAM,eAAe,wFAOlB,CAAC;AAEX,eAAO,MAAM,aAAa,2DAA4D,CAAC;AAEvF,eAAO,MAAM,aAAa,iCAAkC,CAAC;AAE7D,eAAO,MAAM,uBAAuB,uDAAwD,CAAC;AAE7F,eAAO,MAAM,qBAAqB,0CAA2C,CAAC;
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/components/SectionBuilder/schemas.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,eAAO,MAAM,YAAY,yNAmBf,CAAC;AAEX,eAAO,MAAM,YAAY,qCAAsC,CAAC;AAEhE,eAAO,MAAM,mBAAmB,6GAStB,CAAC;AAEX,eAAO,MAAM,iBAAiB,sCAAuC,CAAC;AAEtE,eAAO,MAAM,gBAAgB,oCAAqC,CAAC;AAEnE,eAAO,MAAM,eAAe,wFAOlB,CAAC;AAEX,eAAO,MAAM,aAAa,2DAA4D,CAAC;AAEvF,eAAO,MAAM,aAAa,iCAAkC,CAAC;AAE7D,eAAO,MAAM,uBAAuB,uDAAwD,CAAC;AAE7F,eAAO,MAAM,qBAAqB,0CAA2C,CAAC;AAoW9E;;GAEG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiDzB,CAAC;AAEF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,SAAS,GAAG,OAAO,GAAG,QAAQ,GAAG,GAAG,CAWhF"}
|
package/dist/index.esm.js
CHANGED
|
@@ -405,9 +405,8 @@ const createZodSchema = (validation, required = false) => {
|
|
|
405
405
|
const normalizeBooleanLike = (val) => {
|
|
406
406
|
if (val === true || val === 1)
|
|
407
407
|
return true;
|
|
408
|
-
if (val === false || val === 0
|
|
408
|
+
if (val === false || val === 0)
|
|
409
409
|
return false;
|
|
410
|
-
}
|
|
411
410
|
if (typeof val === 'string') {
|
|
412
411
|
const normalized = val.trim().toLowerCase();
|
|
413
412
|
return normalized === 'true' || normalized === 'yes' || normalized === '1';
|
|
@@ -422,8 +421,11 @@ const evaluateCondition = (condition, allValues) => {
|
|
|
422
421
|
const { operator, value } = condition;
|
|
423
422
|
switch (operator) {
|
|
424
423
|
case 'equals':
|
|
425
|
-
if (typeof value === 'boolean'
|
|
426
|
-
return
|
|
424
|
+
if (typeof value === 'boolean') {
|
|
425
|
+
return typeof fieldValue === 'boolean' && fieldValue === value;
|
|
426
|
+
}
|
|
427
|
+
if (typeof fieldValue === 'boolean') {
|
|
428
|
+
return fieldValue === normalizeBooleanLike(value);
|
|
427
429
|
}
|
|
428
430
|
return fieldValue === value;
|
|
429
431
|
case 'notEquals':
|
|
@@ -10088,6 +10090,40 @@ const TableWidget = ({ config }) => {
|
|
|
10088
10090
|
};
|
|
10089
10091
|
|
|
10090
10092
|
const isUnsetRowValue = (value) => value === null || value === undefined || value === '';
|
|
10093
|
+
const buildDialogConditionValues = (row, columns) => {
|
|
10094
|
+
let context = { ...row };
|
|
10095
|
+
columns.forEach((col) => {
|
|
10096
|
+
const columnKey = col['column-key'];
|
|
10097
|
+
if (!columnKey || row[columnKey] === undefined) {
|
|
10098
|
+
return;
|
|
10099
|
+
}
|
|
10100
|
+
const dataPath = col['widget-data-path'];
|
|
10101
|
+
if (typeof dataPath === 'string' && dataPath) {
|
|
10102
|
+
context = setValueByPath(context, dataPath, row[columnKey]);
|
|
10103
|
+
}
|
|
10104
|
+
});
|
|
10105
|
+
return context;
|
|
10106
|
+
};
|
|
10107
|
+
const buildDialogColumnSegments = (columns) => {
|
|
10108
|
+
const segments = [];
|
|
10109
|
+
let index = 0;
|
|
10110
|
+
while (index < columns.length) {
|
|
10111
|
+
const group = columns[index]['column-group'];
|
|
10112
|
+
if (group) {
|
|
10113
|
+
const groupCols = [];
|
|
10114
|
+
while (index < columns.length && columns[index]['column-group'] === group) {
|
|
10115
|
+
groupCols.push(columns[index]);
|
|
10116
|
+
index += 1;
|
|
10117
|
+
}
|
|
10118
|
+
segments.push({ type: 'group', group, cols: groupCols });
|
|
10119
|
+
}
|
|
10120
|
+
else {
|
|
10121
|
+
segments.push({ type: 'single', col: columns[index] });
|
|
10122
|
+
index += 1;
|
|
10123
|
+
}
|
|
10124
|
+
}
|
|
10125
|
+
return segments;
|
|
10126
|
+
};
|
|
10091
10127
|
/** Match TableWidget cell styling for add / update / delete rows */
|
|
10092
10128
|
const getRowCellStyle = (editAction) => {
|
|
10093
10129
|
if (editAction === 'ADD') {
|
|
@@ -10115,7 +10151,7 @@ const SelectDisplayValue = ({ config, value }) => {
|
|
|
10115
10151
|
return jsxRuntimeExports.jsx("span", { children: selectedOption ? selectedOption.label : String(value) });
|
|
10116
10152
|
};
|
|
10117
10153
|
/** Isolated dialog field — avoids re-running data-source effects when sibling fields update. */
|
|
10118
|
-
const DialogTableField = memo(function DialogTableField({ col, cellWidgetId,
|
|
10154
|
+
const DialogTableField = memo(function DialogTableField({ col, cellWidgetId, dialogConditionValues, isReadonly, }) {
|
|
10119
10155
|
const widgetType = col.widget || 'text';
|
|
10120
10156
|
const fieldConfig = useMemo(() => {
|
|
10121
10157
|
return {
|
|
@@ -10128,9 +10164,9 @@ const DialogTableField = memo(function DialogTableField({ col, cellWidgetId, dia
|
|
|
10128
10164
|
'widget-data-path': undefined,
|
|
10129
10165
|
'widget-data-default': col['widget-data-default'],
|
|
10130
10166
|
'widget-data-options': undefined,
|
|
10131
|
-
'widget-required': shouldRequireWidget(col['widget-data-options'],
|
|
10167
|
+
'widget-required': shouldRequireWidget(col['widget-data-options'], dialogConditionValues, col['widget-required']),
|
|
10132
10168
|
};
|
|
10133
|
-
}, [col, cellWidgetId,
|
|
10169
|
+
}, [col, cellWidgetId, dialogConditionValues, isReadonly, widgetType]);
|
|
10134
10170
|
return (jsxRuntimeExports.jsx("div", { className: "min-w-0", children: jsxRuntimeExports.jsx(WidgetRenderer, { config: fieldConfig }) }));
|
|
10135
10171
|
});
|
|
10136
10172
|
/**
|
|
@@ -10267,12 +10303,14 @@ const DialogTableWidget = ({ config }) => {
|
|
|
10267
10303
|
return row;
|
|
10268
10304
|
});
|
|
10269
10305
|
const dialogRowValues = dialogStoreValues;
|
|
10306
|
+
const dialogConditionValues = useMemo(() => buildDialogConditionValues(dialogRowValues, columns), [dialogRowValues, columns]);
|
|
10270
10307
|
const collectMergedRowPayload = useCallback(() => dialogStoreValues, [dialogStoreValues]);
|
|
10271
10308
|
const finalizeDialogRowPayload = useCallback((raw) => {
|
|
10309
|
+
const conditionValues = buildDialogConditionValues(raw, columns);
|
|
10272
10310
|
const result = {};
|
|
10273
10311
|
columns.forEach((col) => {
|
|
10274
10312
|
const key = col['column-key'];
|
|
10275
|
-
if (!shouldShowWidget(col['widget-data-options'],
|
|
10313
|
+
if (!shouldShowWidget(col['widget-data-options'], conditionValues)) {
|
|
10276
10314
|
return;
|
|
10277
10315
|
}
|
|
10278
10316
|
const val = raw[key];
|
|
@@ -10284,6 +10322,7 @@ const DialogTableWidget = ({ config }) => {
|
|
|
10284
10322
|
}, [columns]);
|
|
10285
10323
|
const saveDialog = useCallback(() => {
|
|
10286
10324
|
const payload = collectMergedRowPayload();
|
|
10325
|
+
const conditionValues = buildDialogConditionValues(payload, columns);
|
|
10287
10326
|
let hasErrors = false;
|
|
10288
10327
|
columns.forEach((col) => {
|
|
10289
10328
|
const key = col['column-key'];
|
|
@@ -10291,10 +10330,10 @@ const DialogTableWidget = ({ config }) => {
|
|
|
10291
10330
|
const isColReadonly = isReadonly || col['widget-readonly'] === true;
|
|
10292
10331
|
if (isColReadonly)
|
|
10293
10332
|
return;
|
|
10294
|
-
if (!shouldShowWidget(col['widget-data-options'],
|
|
10333
|
+
if (!shouldShowWidget(col['widget-data-options'], conditionValues))
|
|
10295
10334
|
return;
|
|
10296
10335
|
const cellValue = payload[key];
|
|
10297
|
-
const isRequired = shouldRequireWidget(col['widget-data-options'],
|
|
10336
|
+
const isRequired = shouldRequireWidget(col['widget-data-options'], conditionValues, col['widget-required']);
|
|
10298
10337
|
const validationErrors = validateWidget(cellValue, col['widget-data-validation'], isRequired);
|
|
10299
10338
|
if (validationErrors && validationErrors.length > 0) {
|
|
10300
10339
|
hasErrors = true;
|
|
@@ -10369,7 +10408,28 @@ const DialogTableWidget = ({ config }) => {
|
|
|
10369
10408
|
return formatValue(cellValue, column['widget-data-format'], column.widget);
|
|
10370
10409
|
return String(cellValue);
|
|
10371
10410
|
}, [rows]);
|
|
10372
|
-
const
|
|
10411
|
+
const dialogColumnSegments = useMemo(() => {
|
|
10412
|
+
return buildDialogColumnSegments(columns)
|
|
10413
|
+
.map((segment) => {
|
|
10414
|
+
if (segment.type === 'single') {
|
|
10415
|
+
if (!shouldShowWidget(segment.col['widget-data-options'], dialogConditionValues)) {
|
|
10416
|
+
return null;
|
|
10417
|
+
}
|
|
10418
|
+
return segment;
|
|
10419
|
+
}
|
|
10420
|
+
const visibleCols = segment.cols.filter((col) => shouldShowWidget(col['widget-data-options'], dialogConditionValues));
|
|
10421
|
+
if (visibleCols.length === 0) {
|
|
10422
|
+
return null;
|
|
10423
|
+
}
|
|
10424
|
+
return { type: 'group', group: segment.group, cols: visibleCols };
|
|
10425
|
+
})
|
|
10426
|
+
.filter((segment) => segment !== null);
|
|
10427
|
+
}, [columns, dialogConditionValues]);
|
|
10428
|
+
const renderDialogField = (col) => {
|
|
10429
|
+
const key = col['column-key'];
|
|
10430
|
+
const cellWidgetId = dialogFieldWidgetId(dialogSessionId, key);
|
|
10431
|
+
return (jsxRuntimeExports.jsx(DialogTableField, { col: col, cellWidgetId: cellWidgetId, dialogConditionValues: dialogConditionValues, isReadonly: isReadonly }, `${dialogSessionId}-${key}`));
|
|
10432
|
+
};
|
|
10373
10433
|
const tableWidgetId = `dialog-table-widget-${widgetConfig['widget-id']}`;
|
|
10374
10434
|
const columnSpan = widgetConfig['widget-column-span'] || 2;
|
|
10375
10435
|
const minWidth = columnSpan * 200;
|
|
@@ -10441,10 +10501,11 @@ const DialogTableWidget = ({ config }) => {
|
|
|
10441
10501
|
cursor: 'pointer',
|
|
10442
10502
|
fontSize: '20px',
|
|
10443
10503
|
lineHeight: 1,
|
|
10444
|
-
}, "aria-label": "Close", children: "\u00D7" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", style: { maxHeight: '70vh', overflow: 'auto' }, children:
|
|
10445
|
-
|
|
10446
|
-
|
|
10447
|
-
|
|
10504
|
+
}, "aria-label": "Close", children: "\u00D7" })] }), jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", style: { maxHeight: '70vh', overflow: 'auto' }, children: dialogColumnSegments.map((segment) => {
|
|
10505
|
+
if (segment.type === 'single') {
|
|
10506
|
+
return renderDialogField(segment.col);
|
|
10507
|
+
}
|
|
10508
|
+
return (jsxRuntimeExports.jsx("div", { className: "md:col-span-2 grid grid-cols-1 md:grid-cols-2 gap-4", children: segment.cols.map((col) => renderDialogField(col)) }, `${dialogSessionId}-group-${segment.group}`));
|
|
10448
10509
|
}) }, `dialog-fields-${dialogSessionId}`), jsxRuntimeExports.jsxs("div", { className: "flex justify-end gap-3 mt-6", children: [jsxRuntimeExports.jsx("button", { type: "button", onClick: closeDialog, className: "px-4 py-2 text-sm font-medium", style: {
|
|
10449
10510
|
borderRadius: 'var(--owt-btn-border-radius, 10px)',
|
|
10450
10511
|
border: '1px solid var(--owt-btn-secondary-border, #C4C4C4)',
|