@openg2p/registry-widgets 1.1.0-dev.3 → 1.1.0-dev.5
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/SectionRenderer.d.ts.map +1 -1
- package/dist/components/SectionsContainer.d.ts.map +1 -1
- package/dist/index.esm.js +110 -25
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +110 -25
- package/dist/index.js.map +1 -1
- package/dist/utils/buildSectionChanges.d.ts.map +1 -1
- package/dist/utils/extractTableRecordsFromSnapshot.d.ts +11 -0
- package/dist/utils/extractTableRecordsFromSnapshot.d.ts.map +1 -0
- package/dist/widgets/DialogTableWidget.d.ts.map +1 -1
- package/dist/widgets/HeaderSectionWidget.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionRenderer.d.ts","sourceRoot":"","sources":["../../src/components/SectionRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAyC,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQ9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"SectionRenderer.d.ts","sourceRoot":"","sources":["../../src/components/SectionRenderer.tsx"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAyC,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQ9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AA2ClD,MAAM,WAAW,cAAc;IAC7B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC;IAClB,KAAK,CAAC,EAAE,IAAI,GAAG,IAAI,C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B,CAAC,YAAY,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;IACtD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAClE,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,wGAAwG;IACxG,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,CAAC;IAEpE,wHAAwH;IACxH,oBAAoB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrE,0JAA0J;IAC1J,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAC;CACpD;AAoFD;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,yMAa/B,sBAAsB,4CAwSxB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -3848,6 +3848,52 @@ const sectionValidate = (section, currentSchemaData, dispatch) => {
|
|
|
3848
3848
|
return isValid;
|
|
3849
3849
|
};
|
|
3850
3850
|
|
|
3851
|
+
/** Table-style widgets that bind to an array path in the store / schema. */
|
|
3852
|
+
function isTableLikeWidget(widget) {
|
|
3853
|
+
const w = widget.widget;
|
|
3854
|
+
/** widget-type union in types omits legacy values like simple-table still used at runtime */
|
|
3855
|
+
const t = widget['widget-type'];
|
|
3856
|
+
return (w === 'table' ||
|
|
3857
|
+
w === 'dialog-table' ||
|
|
3858
|
+
w === 'simple-table' ||
|
|
3859
|
+
t === 'table' ||
|
|
3860
|
+
t === 'simple-table');
|
|
3861
|
+
}
|
|
3862
|
+
/**
|
|
3863
|
+
* Resolve `records` for section save payloads.
|
|
3864
|
+
* - Back-compat: path ending in `.records` (e.g. `regId.records`)
|
|
3865
|
+
* - Else: first array snapshot at a string `widget-data-path` on a table-like widget
|
|
3866
|
+
* (e.g. `household.members` for dialog-table)
|
|
3867
|
+
*/
|
|
3868
|
+
function extractTableRecordsFromSnapshot(snapshot, sectionWidgets) {
|
|
3869
|
+
const convention = Object.entries(snapshot).find(([key, value]) => key.endsWith('.records') && Array.isArray(value));
|
|
3870
|
+
if (convention) {
|
|
3871
|
+
return convention[1];
|
|
3872
|
+
}
|
|
3873
|
+
const tablePaths = [];
|
|
3874
|
+
sectionWidgets.forEach((widget) => {
|
|
3875
|
+
if (!isTableLikeWidget(widget))
|
|
3876
|
+
return;
|
|
3877
|
+
const p = widget['widget-data-path'];
|
|
3878
|
+
if (typeof p === 'string' && p.length > 0) {
|
|
3879
|
+
tablePaths.push(p);
|
|
3880
|
+
}
|
|
3881
|
+
else if (p && typeof p === 'object') {
|
|
3882
|
+
Object.values(p).forEach((sub) => {
|
|
3883
|
+
if (typeof sub === 'string' && sub.length > 0)
|
|
3884
|
+
tablePaths.push(sub);
|
|
3885
|
+
});
|
|
3886
|
+
}
|
|
3887
|
+
});
|
|
3888
|
+
for (const path of tablePaths) {
|
|
3889
|
+
const val = snapshot[path];
|
|
3890
|
+
if (Array.isArray(val)) {
|
|
3891
|
+
return val;
|
|
3892
|
+
}
|
|
3893
|
+
}
|
|
3894
|
+
return [];
|
|
3895
|
+
}
|
|
3896
|
+
|
|
3851
3897
|
/** Root class on readonly label/value rows; SectionRenderer scopes overflow/ellipsis rules here. */
|
|
3852
3898
|
const READONLY_VALUE_ROW_ROOT_CLASSES = [
|
|
3853
3899
|
'TextDisplayWidget',
|
|
@@ -4213,9 +4259,7 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
4213
4259
|
const widgetPath = widget['widget-data-path'];
|
|
4214
4260
|
if (!widgetPath)
|
|
4215
4261
|
return;
|
|
4216
|
-
if (widget
|
|
4217
|
-
widget['widget-type'] === 'simple-table' ||
|
|
4218
|
-
widget['widget'] === 'table') {
|
|
4262
|
+
if (isTableLikeWidget(widget)) {
|
|
4219
4263
|
hasTable = true;
|
|
4220
4264
|
}
|
|
4221
4265
|
if (typeof widgetPath === 'object') {
|
|
@@ -4250,8 +4294,7 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
4250
4294
|
},
|
|
4251
4295
|
];
|
|
4252
4296
|
}
|
|
4253
|
-
|
|
4254
|
-
return tableEntry ? tableEntry[1] : [];
|
|
4297
|
+
return extractTableRecordsFromSnapshot(snapshot, widgets);
|
|
4255
4298
|
};
|
|
4256
4299
|
// Get original section (without namespace) for building snapshots
|
|
4257
4300
|
// This ensures we use the original data paths when saving
|
|
@@ -4961,10 +5004,7 @@ function buildSectionChanges(section, storeValues, namespace, options) {
|
|
|
4961
5004
|
const widgetPath = widget['widget-data-path'];
|
|
4962
5005
|
if (!widgetPath)
|
|
4963
5006
|
return;
|
|
4964
|
-
|
|
4965
|
-
if (widgetType === 'table' ||
|
|
4966
|
-
widgetType === 'simple-table' ||
|
|
4967
|
-
widget.widget === 'table') {
|
|
5007
|
+
if (isTableLikeWidget(widget)) {
|
|
4968
5008
|
hasTable = true;
|
|
4969
5009
|
}
|
|
4970
5010
|
if (typeof widgetPath === 'object') {
|
|
@@ -5002,8 +5042,7 @@ function buildSectionChanges(section, storeValues, namespace, options) {
|
|
|
5002
5042
|
];
|
|
5003
5043
|
}
|
|
5004
5044
|
else {
|
|
5005
|
-
|
|
5006
|
-
records = tableEntry ? tableEntry[1] : [];
|
|
5045
|
+
records = extractTableRecordsFromSnapshot(snapshot, sectionWidgets);
|
|
5007
5046
|
}
|
|
5008
5047
|
const files = [];
|
|
5009
5048
|
const supportingDocs = section['section-supporting-documents'] || [];
|
|
@@ -5029,7 +5068,9 @@ const hasTableWidget = (panels) => {
|
|
|
5029
5068
|
// Check widgets in this panel
|
|
5030
5069
|
if (panel.widgets) {
|
|
5031
5070
|
for (const widget of panel.widgets) {
|
|
5032
|
-
if (widget.widget === 'table' ||
|
|
5071
|
+
if (widget.widget === 'table' ||
|
|
5072
|
+
widget.widget === 'dialog-table' ||
|
|
5073
|
+
widget['widget-type'] === 'table') {
|
|
5033
5074
|
return true;
|
|
5034
5075
|
}
|
|
5035
5076
|
}
|
|
@@ -5051,7 +5092,9 @@ const getTableWidgetColumnSpan = (panels) => {
|
|
|
5051
5092
|
// Check widgets in this panel
|
|
5052
5093
|
if (panel.widgets) {
|
|
5053
5094
|
for (const widget of panel.widgets) {
|
|
5054
|
-
if (widget.widget === 'table' ||
|
|
5095
|
+
if (widget.widget === 'table' ||
|
|
5096
|
+
widget.widget === 'dialog-table' ||
|
|
5097
|
+
widget['widget-type'] === 'table') {
|
|
5055
5098
|
// Return the widget's column span if specified, otherwise null
|
|
5056
5099
|
return widget['widget-column-span'] || null;
|
|
5057
5100
|
}
|
|
@@ -9188,6 +9231,8 @@ const SelectDisplayValue = ({ config, value }) => {
|
|
|
9188
9231
|
const DialogTableWidget = ({ config }) => {
|
|
9189
9232
|
const { value, error, touched, isEnabled, onChange, config: widgetConfig } = useBaseWidget({ config });
|
|
9190
9233
|
const { translate, translateConfig } = useWidgetTranslation();
|
|
9234
|
+
const dispatch = useDispatch();
|
|
9235
|
+
const storeValues = useSelector((state) => state.widget?.values ?? {});
|
|
9191
9236
|
const rows = Array.isArray(value) ? value : [];
|
|
9192
9237
|
const columns = widgetConfig['widget-data-columns'] || [];
|
|
9193
9238
|
const operations = widgetConfig['widget-data-operations'] || {};
|
|
@@ -9206,6 +9251,9 @@ const DialogTableWidget = ({ config }) => {
|
|
|
9206
9251
|
const [dialogMode, setDialogMode] = useState('add');
|
|
9207
9252
|
const [activeRowIndex, setActiveRowIndex] = useState(null);
|
|
9208
9253
|
const [formData, setFormData] = useState({});
|
|
9254
|
+
/** Unique per dialog open so Redux widget ids don't reuse stale values across rows/add sessions */
|
|
9255
|
+
const dialogSessionRef = useRef(0);
|
|
9256
|
+
const [dialogSessionId, setDialogSessionId] = useState(0);
|
|
9209
9257
|
const addDialogTitle = translateConfig(widgetConfig['widget-data-dialog-title-add']) ||
|
|
9210
9258
|
translate('table.addRecordDialog') ||
|
|
9211
9259
|
'Add record';
|
|
@@ -9220,13 +9268,32 @@ const DialogTableWidget = ({ config }) => {
|
|
|
9220
9268
|
});
|
|
9221
9269
|
return emptyRow;
|
|
9222
9270
|
}, [columns]);
|
|
9271
|
+
const dialogFieldWidgetId = useCallback((columnKey) => `${widgetConfig['widget-id']}-dlg-${dialogSessionId}-${columnKey}`, [widgetConfig, dialogSessionId]);
|
|
9272
|
+
const resetDialogWidgets = useCallback((sessionId) => {
|
|
9273
|
+
if (sessionId <= 0)
|
|
9274
|
+
return;
|
|
9275
|
+
columns.forEach((col) => {
|
|
9276
|
+
const wid = `${widgetConfig['widget-id']}-dlg-${sessionId}-${col['column-key']}`;
|
|
9277
|
+
dispatch(resetWidget(wid));
|
|
9278
|
+
});
|
|
9279
|
+
}, [columns, widgetConfig, dispatch]);
|
|
9280
|
+
const beginDialogSession = useCallback(() => {
|
|
9281
|
+
dialogSessionRef.current += 1;
|
|
9282
|
+
const nextSession = dialogSessionRef.current;
|
|
9283
|
+
setDialogSessionId(nextSession);
|
|
9284
|
+
return nextSession;
|
|
9285
|
+
}, []);
|
|
9223
9286
|
const openAddDialog = useCallback(() => {
|
|
9287
|
+
resetDialogWidgets(dialogSessionId);
|
|
9288
|
+
beginDialogSession();
|
|
9224
9289
|
setDialogMode('add');
|
|
9225
9290
|
setActiveRowIndex(null);
|
|
9226
9291
|
setFormData(buildEmptyRow());
|
|
9227
9292
|
setDialogOpen(true);
|
|
9228
|
-
}, [buildEmptyRow]);
|
|
9293
|
+
}, [buildEmptyRow, beginDialogSession, resetDialogWidgets, dialogSessionId]);
|
|
9229
9294
|
const openEditDialog = useCallback((rowIndex) => {
|
|
9295
|
+
resetDialogWidgets(dialogSessionId);
|
|
9296
|
+
beginDialogSession();
|
|
9230
9297
|
const row = rows[rowIndex] || {};
|
|
9231
9298
|
const nextFormData = buildEmptyRow();
|
|
9232
9299
|
columns.forEach((col) => {
|
|
@@ -9238,18 +9305,33 @@ const DialogTableWidget = ({ config }) => {
|
|
|
9238
9305
|
setActiveRowIndex(rowIndex);
|
|
9239
9306
|
setFormData(nextFormData);
|
|
9240
9307
|
setDialogOpen(true);
|
|
9241
|
-
}, [rows, columns, buildEmptyRow]);
|
|
9308
|
+
}, [rows, columns, buildEmptyRow, resetDialogWidgets, dialogSessionId, beginDialogSession]);
|
|
9242
9309
|
const closeDialog = useCallback(() => {
|
|
9310
|
+
const sessionToClear = dialogSessionId;
|
|
9243
9311
|
setDialogOpen(false);
|
|
9244
9312
|
setActiveRowIndex(null);
|
|
9245
9313
|
setFormData({});
|
|
9246
|
-
|
|
9314
|
+
resetDialogWidgets(sessionToClear);
|
|
9315
|
+
setDialogSessionId(0);
|
|
9316
|
+
}, [dialogSessionId, resetDialogWidgets]);
|
|
9247
9317
|
const updateField = useCallback((columnKey, newValue) => {
|
|
9248
9318
|
setFormData((prev) => ({ ...prev, [columnKey]: newValue }));
|
|
9249
9319
|
}, []);
|
|
9320
|
+
const collectMergedRowPayload = useCallback(() => {
|
|
9321
|
+
const merged = { ...formData };
|
|
9322
|
+
columns.forEach((col) => {
|
|
9323
|
+
const k = col['column-key'];
|
|
9324
|
+
const wid = dialogFieldWidgetId(k);
|
|
9325
|
+
const fromStore = storeValues[wid];
|
|
9326
|
+
if (fromStore !== undefined)
|
|
9327
|
+
merged[k] = fromStore;
|
|
9328
|
+
});
|
|
9329
|
+
return merged;
|
|
9330
|
+
}, [formData, columns, storeValues, dialogFieldWidgetId]);
|
|
9250
9331
|
const saveDialog = useCallback(() => {
|
|
9332
|
+
const payload = collectMergedRowPayload();
|
|
9251
9333
|
if (dialogMode === 'add') {
|
|
9252
|
-
const savedRow = { ...
|
|
9334
|
+
const savedRow = { ...payload, edit_action: 'ADD' };
|
|
9253
9335
|
onChange([...rows, savedRow]);
|
|
9254
9336
|
closeDialog();
|
|
9255
9337
|
return;
|
|
@@ -9259,11 +9341,11 @@ const DialogTableWidget = ({ config }) => {
|
|
|
9259
9341
|
const currentRow = newRows[activeRowIndex] || {};
|
|
9260
9342
|
const wasDeleted = currentRow.edit_action === 'DELETE';
|
|
9261
9343
|
const editAction = wasDeleted ? 'UPDATE' : (currentRow.edit_action ?? 'UPDATE');
|
|
9262
|
-
newRows[activeRowIndex] = { ...currentRow, ...
|
|
9344
|
+
newRows[activeRowIndex] = { ...currentRow, ...payload, edit_action: editAction };
|
|
9263
9345
|
onChange(newRows);
|
|
9264
9346
|
closeDialog();
|
|
9265
9347
|
}
|
|
9266
|
-
}, [
|
|
9348
|
+
}, [collectMergedRowPayload, dialogMode, onChange, rows, closeDialog, activeRowIndex]);
|
|
9267
9349
|
const deleteRow = useCallback((rowIndex) => {
|
|
9268
9350
|
const newRows = rows.filter((_, i) => i !== rowIndex);
|
|
9269
9351
|
onChange(newRows);
|
|
@@ -9351,7 +9433,8 @@ const DialogTableWidget = ({ config }) => {
|
|
|
9351
9433
|
}, "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: columns.map((col) => {
|
|
9352
9434
|
const key = col['column-key'];
|
|
9353
9435
|
const widgetType = col.widget || 'text';
|
|
9354
|
-
const cellWidgetId =
|
|
9436
|
+
const cellWidgetId = dialogFieldWidgetId(key);
|
|
9437
|
+
const initialValue = formData[key] ?? col['widget-data-default'] ?? '';
|
|
9355
9438
|
const fieldConfig = {
|
|
9356
9439
|
...col,
|
|
9357
9440
|
widget: widgetType,
|
|
@@ -9360,10 +9443,10 @@ const DialogTableWidget = ({ config }) => {
|
|
|
9360
9443
|
'widget-label': col['widget-label'],
|
|
9361
9444
|
'widget-readonly': isReadonly || col['widget-readonly'] === true,
|
|
9362
9445
|
'widget-data-path': undefined,
|
|
9363
|
-
'widget-data-default':
|
|
9446
|
+
'widget-data-default': initialValue,
|
|
9364
9447
|
};
|
|
9365
|
-
return (jsxRuntimeExports.jsx("div", { className: "min-w-0", children: jsxRuntimeExports.jsx(WidgetRenderer, { config: fieldConfig, schemaData: { [cellWidgetId]:
|
|
9366
|
-
}) }), 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: {
|
|
9448
|
+
return (jsxRuntimeExports.jsx("div", { className: "min-w-0", children: jsxRuntimeExports.jsx(WidgetRenderer, { config: fieldConfig, schemaData: { [cellWidgetId]: initialValue }, onValueChange: (_widgetId, newValue) => updateField(key, newValue) }) }, `${dialogSessionId}-${key}`));
|
|
9449
|
+
}) }, `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: {
|
|
9367
9450
|
borderRadius: 'var(--owt-btn-border-radius, 10px)',
|
|
9368
9451
|
border: '1px solid var(--owt-btn-secondary-border, #C4C4C4)',
|
|
9369
9452
|
backgroundColor: 'var(--owt-btn-secondary-bg, #FFFFFF)',
|
|
@@ -9864,7 +9947,9 @@ const HeaderSectionWidget = ({ config }) => {
|
|
|
9864
9947
|
return null;
|
|
9865
9948
|
const ratio = completion / ideal;
|
|
9866
9949
|
const percent = Math.max(0, Math.min(100, Math.round(ratio * 100)));
|
|
9867
|
-
|
|
9950
|
+
const completionDisplay = Number.isInteger(completion) ? completion : Math.round(completion);
|
|
9951
|
+
const idealDisplay = Number.isInteger(ideal) ? ideal : Math.round(ideal);
|
|
9952
|
+
return { completion, ideal, completionDisplay, idealDisplay, percent };
|
|
9868
9953
|
}, [completionScoreRaw, idealScoreRaw]);
|
|
9869
9954
|
// ── Format options ────────────────────────────────────────────
|
|
9870
9955
|
const format = (widgetConfig['widget-data-format'] || {});
|
|
@@ -10195,7 +10280,7 @@ const HeaderSectionWidget = ({ config }) => {
|
|
|
10195
10280
|
if (showReasonRequired && String(e.target.value || '').trim().length > 0) {
|
|
10196
10281
|
setShowReasonRequired(false);
|
|
10197
10282
|
}
|
|
10198
|
-
} }), !isReadonly && (showReasonRequired || isReasonMissing) && isReasonMissing ? (jsxRuntimeExports.jsx("div", { className: "hdr-error-text", children: getLabel('enterReason') })) : null] }))] })] })] }), jsxRuntimeExports.jsx("div", { className: "hdr-right", children: jsxRuntimeExports.jsxs("div", { className: "hdr-right-top", children: [jsxRuntimeExports.jsxs("div", { className: "hdr-meta-col", children: [jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('createdBy'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: createdBy || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('createdAt'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: createdAt || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('lastApprovedBy'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: lastApprovedBy || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('lastApprovedAt'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: lastApprovedAt || '-' })] })] }), score ? (jsxRuntimeExports.jsx("div", { className: "hdr-score-ring", style: { ['--pct']: score.percent }, "aria-label": `Completion score ${score.
|
|
10283
|
+
} }), !isReadonly && (showReasonRequired || isReasonMissing) && isReasonMissing ? (jsxRuntimeExports.jsx("div", { className: "hdr-error-text", children: getLabel('enterReason') })) : null] }))] })] })] }), jsxRuntimeExports.jsx("div", { className: "hdr-right", children: jsxRuntimeExports.jsxs("div", { className: "hdr-right-top", children: [jsxRuntimeExports.jsxs("div", { className: "hdr-meta-col", children: [jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('createdBy'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: createdBy || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('createdAt'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: createdAt || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('lastApprovedBy'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: lastApprovedBy || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-meta-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-meta-label", children: [getLabel('lastApprovedAt'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-meta-value", children: lastApprovedAt || '-' })] })] }), score ? (jsxRuntimeExports.jsx("div", { className: "hdr-score-ring", style: { ['--pct']: score.percent }, "aria-label": `Completion score ${score.completionDisplay} of ${score.idealDisplay} (${score.percent}%)`, title: `${score.completionDisplay} / ${score.idealDisplay} (${score.percent}%)`, children: jsxRuntimeExports.jsx("div", { className: "hdr-score-value", children: String(score.completionDisplay) }) })) : null] }) })] })] }));
|
|
10199
10284
|
};
|
|
10200
10285
|
|
|
10201
10286
|
function getValueByPathOrKey(obj, path) {
|