@openg2p/registry-widgets 1.0.0 → 1.0.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/SectionRenderer.d.ts.map +1 -1
- package/dist/components/SectionsContainer.d.ts.map +1 -1
- package/dist/index.esm.js +92 -113
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +92 -113
- package/dist/index.js.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;AAM9D,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAMlD,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;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,aAAa,CAAC;IACvB,wBAAwB,CAAC,EAAE,oBAAoB,CAAC,0BAA0B,CAAC,CAAC;IAC5E,UAAU,CAAC,EAAE,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAChD,aAAa,CAAC,EAAE,oBAAoB,CAAC,eAAe,CAAC,CAAC;IACtD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,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,SAAS,CAAC,EAAE,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ACrF,kBAAkB,IAAI,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAClD;;;OAGG;IACD,iBAAiB,IAAI,cAAc,EAAE,CAAC;CACvC;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,UAAU,CAAC,EAAE,oBAAoB,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;AA4ED;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAAI,yMAa/B,sBAAsB,4CAqSxB,CAAC"}
|
package/dist/index.esm.js
CHANGED
|
@@ -3541,41 +3541,22 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
3541
3541
|
}
|
|
3542
3542
|
return section;
|
|
3543
3543
|
}, [section, namespace]);
|
|
3544
|
-
// Create namespaced schemaData if namespace is provided
|
|
3545
|
-
//
|
|
3544
|
+
// Create namespaced schemaData if namespace is provided.
|
|
3545
|
+
// Widgets with namespaced data-paths (e.g. "rv-section-0.a1a4d25a.birth_date")
|
|
3546
|
+
// need a nested object at values[namespace] so getValueByPath can traverse it.
|
|
3546
3547
|
const namespacedSchemaData = useMemo(() => {
|
|
3547
3548
|
if (!namespace || !currentSchemaData) {
|
|
3548
3549
|
return schemaData;
|
|
3549
3550
|
}
|
|
3550
|
-
|
|
3551
|
-
const namespaced = { ...currentSchemaData };
|
|
3552
|
-
// Copy all top-level keys to namespaced paths
|
|
3553
|
-
Object.keys(currentSchemaData).forEach(key => {
|
|
3554
|
-
const namespacedKey = `${namespace}.${key}`;
|
|
3555
|
-
if (!(namespacedKey in namespaced)) {
|
|
3556
|
-
namespaced[namespacedKey] = currentSchemaData[key];
|
|
3557
|
-
}
|
|
3558
|
-
});
|
|
3559
|
-
// Also handle nested objects - copy nested values to namespaced paths
|
|
3560
|
-
const copyNestedValues = (obj, prefix = '') => {
|
|
3561
|
-
if (obj && typeof obj === 'object' && !Array.isArray(obj)) {
|
|
3562
|
-
Object.keys(obj).forEach(key => {
|
|
3563
|
-
const fullPath = prefix ? `${prefix}.${key}` : key;
|
|
3564
|
-
const namespacedPath = `${namespace}.${fullPath}`;
|
|
3565
|
-
if (typeof obj[key] === 'object' && obj[key] !== null && !Array.isArray(obj[key])) {
|
|
3566
|
-
copyNestedValues(obj[key], fullPath);
|
|
3567
|
-
// Also set the nested object at the namespaced path
|
|
3568
|
-
setValueByPath(namespaced, namespacedPath, obj[key]);
|
|
3569
|
-
}
|
|
3570
|
-
else {
|
|
3571
|
-
setValueByPath(namespaced, namespacedPath, obj[key]);
|
|
3572
|
-
}
|
|
3573
|
-
});
|
|
3574
|
-
}
|
|
3575
|
-
};
|
|
3576
|
-
copyNestedValues(currentSchemaData);
|
|
3577
|
-
return namespaced;
|
|
3551
|
+
return { ...currentSchemaData, [namespace]: currentSchemaData };
|
|
3578
3552
|
}, [namespace, schemaData, currentSchemaData]);
|
|
3553
|
+
// Populate the store with namespaced schema data so that namespaced widgets
|
|
3554
|
+
// can read their initial values via getValueByPath on the namespaced paths.
|
|
3555
|
+
useEffect(() => {
|
|
3556
|
+
if (namespace && namespacedSchemaData) {
|
|
3557
|
+
dispatch(setValues(namespacedSchemaData));
|
|
3558
|
+
}
|
|
3559
|
+
}, [namespace, namespacedSchemaData, dispatch]);
|
|
3579
3560
|
const crViewData = useMemo(() => {
|
|
3580
3561
|
if (mode !== 'CRView')
|
|
3581
3562
|
return null;
|
|
@@ -3937,6 +3918,8 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
3937
3918
|
const baselineSnapshotRef = useRef(null);
|
|
3938
3919
|
// IntakeForm only: increment when baseline is updated after save - forces badge to update (refs don't trigger re-renders)
|
|
3939
3920
|
const [intakeFormBaselineTrigger, setIntakeFormBaselineTrigger] = useState(0);
|
|
3921
|
+
// IntakeForm only: tracks whether the user has actually saved this section (prevents "Saved" badge on initial load)
|
|
3922
|
+
const [hasBeenSavedByUser, setHasBeenSavedByUser] = useState(false);
|
|
3940
3923
|
// IntakeForm: treat as edit mode for dirty tracking when isDraft. RegistryView: use isEditMode.
|
|
3941
3924
|
const effectiveEditModeForDirty = mode === 'IntakeForm' ? (isDraft !== false) : isEditMode;
|
|
3942
3925
|
// Compute isDirty: compare current store state to baseline (only when in edit mode)
|
|
@@ -3979,18 +3962,68 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
3979
3962
|
const intakeFormSectionStatus = useMemo(() => {
|
|
3980
3963
|
if (mode !== 'IntakeForm' || isDraft === false)
|
|
3981
3964
|
return null;
|
|
3982
|
-
const hasValue = (v) => v !== undefined && v !== null && (typeof v !== 'string' || v.trim().length > 0);
|
|
3983
|
-
const currentSnapshot = buildSectionSnapshot(storeValues, namespace);
|
|
3984
|
-
const record = currentSnapshot.records?.[0];
|
|
3985
|
-
const hasData = record &&
|
|
3986
|
-
typeof record === 'object' &&
|
|
3987
|
-
Object.values(record).some((v) => hasValue(v));
|
|
3988
3965
|
if (isDirty)
|
|
3989
3966
|
return 'modified';
|
|
3990
|
-
if (
|
|
3967
|
+
if (hasBeenSavedByUser)
|
|
3991
3968
|
return 'saved';
|
|
3992
3969
|
return null;
|
|
3993
|
-
}, [mode, isDirty,
|
|
3970
|
+
}, [mode, isDirty, hasBeenSavedByUser]);
|
|
3971
|
+
// Revert store values to the original schemaData for this section's widgets.
|
|
3972
|
+
// Used by both handleSave (RegistryView raises a CR, so values should not persist)
|
|
3973
|
+
// and handleCancel.
|
|
3974
|
+
const revertToOriginalValues = useCallback(() => {
|
|
3975
|
+
const sectionWidgets = collectWidgets(originalSection.panels);
|
|
3976
|
+
const oldSchemaData = schemaData || contextSchemaData;
|
|
3977
|
+
const currentStoreValues = store.getState().widget.values;
|
|
3978
|
+
let newStoreValues = currentStoreValues;
|
|
3979
|
+
sectionWidgets.forEach(widget => {
|
|
3980
|
+
const originalWidgetId = widget['widget-id'];
|
|
3981
|
+
const namespacedWidgetId = namespace ? `${namespace}__${originalWidgetId}` : originalWidgetId;
|
|
3982
|
+
const widgetId = namespacedWidgetId;
|
|
3983
|
+
const originalDataPath = widget['widget-data-path'];
|
|
3984
|
+
const storeDataPath = namespace && originalDataPath
|
|
3985
|
+
? (typeof originalDataPath === 'string'
|
|
3986
|
+
? `${namespace}.${originalDataPath}`
|
|
3987
|
+
: Object.fromEntries(Object.entries(originalDataPath).map(([key, path]) => [key, `${namespace}.${path}`])))
|
|
3988
|
+
: originalDataPath;
|
|
3989
|
+
if (widgetId && originalDataPath) {
|
|
3990
|
+
let oldValue;
|
|
3991
|
+
if (typeof originalDataPath === 'object') {
|
|
3992
|
+
oldValue = {};
|
|
3993
|
+
Object.entries(originalDataPath).forEach(([key, path]) => {
|
|
3994
|
+
if (typeof path === 'string') {
|
|
3995
|
+
oldValue[key] = getValueByPath(oldSchemaData, path);
|
|
3996
|
+
}
|
|
3997
|
+
});
|
|
3998
|
+
}
|
|
3999
|
+
else if (typeof originalDataPath === 'string') {
|
|
4000
|
+
oldValue = getValueByPath(oldSchemaData, originalDataPath);
|
|
4001
|
+
}
|
|
4002
|
+
if (oldValue !== undefined) {
|
|
4003
|
+
newStoreValues = setWidgetValue(newStoreValues, storeDataPath, widgetId, oldValue);
|
|
4004
|
+
// Also revert the widgetId-based entry — useBaseWidget.handleChange
|
|
4005
|
+
// sets values[widgetId] during editing, and useBaseWidget.currentValue
|
|
4006
|
+
// reads values[widgetId] first before falling through to the dataPath.
|
|
4007
|
+
newStoreValues = { ...newStoreValues, [widgetId]: oldValue };
|
|
4008
|
+
}
|
|
4009
|
+
}
|
|
4010
|
+
});
|
|
4011
|
+
if (hasSupportingDocuments) {
|
|
4012
|
+
const originalSupportingDocuments = originalSection['section-supporting-documents'] || [];
|
|
4013
|
+
originalSupportingDocuments.forEach((doc, index) => {
|
|
4014
|
+
const widgetId = `supporting-doc-${sectionId}-${index}`;
|
|
4015
|
+
const originalDataPath = doc['document-data-path'];
|
|
4016
|
+
const storeDataPath = namespace && originalDataPath
|
|
4017
|
+
? `${namespace}.${originalDataPath}`
|
|
4018
|
+
: originalDataPath;
|
|
4019
|
+
const oldValue = getValueByPath(oldSchemaData, originalDataPath);
|
|
4020
|
+
newStoreValues = setWidgetValue(newStoreValues, storeDataPath, widgetId, oldValue);
|
|
4021
|
+
});
|
|
4022
|
+
}
|
|
4023
|
+
if (newStoreValues !== currentStoreValues) {
|
|
4024
|
+
dispatch(setValues(newStoreValues));
|
|
4025
|
+
}
|
|
4026
|
+
}, [originalSection, schemaData, contextSchemaData, store, namespace, hasSupportingDocuments, sectionId, dispatch]);
|
|
3994
4027
|
// Handle save button click
|
|
3995
4028
|
const handleSave = async () => {
|
|
3996
4029
|
if (!store || !onSectionSave) {
|
|
@@ -4040,6 +4073,12 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
4040
4073
|
console.error('Section Changes Save failed', error);
|
|
4041
4074
|
}
|
|
4042
4075
|
}
|
|
4076
|
+
// In RegistryView, save raises a CR — the actual data update follows a
|
|
4077
|
+
// separate approval workflow, so revert the displayed values to the
|
|
4078
|
+
// originals so the view doesn't show unapproved edits.
|
|
4079
|
+
if (mode === 'RegistryView') {
|
|
4080
|
+
revertToOriginalValues();
|
|
4081
|
+
}
|
|
4043
4082
|
setIsEditMode(false);
|
|
4044
4083
|
onEditModeChange?.(originalSectionId, false);
|
|
4045
4084
|
};
|
|
@@ -4085,6 +4124,7 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
4085
4124
|
if (mode === 'IntakeForm') {
|
|
4086
4125
|
baselineSnapshotRef.current = buildSectionSnapshot(currentSchemaData, namespace);
|
|
4087
4126
|
setIntakeFormBaselineTrigger((prev) => prev + 1);
|
|
4127
|
+
setHasBeenSavedByUser(true);
|
|
4088
4128
|
}
|
|
4089
4129
|
onSectionDirtyChange?.(sectionId, false);
|
|
4090
4130
|
}
|
|
@@ -4093,64 +4133,7 @@ const SectionRenderer = ({ section, dataSourceRequestHandler: propDataSourceRequ
|
|
|
4093
4133
|
}, [store, onSectionSave, onSectionSaveSuccess, sectionIndex, originalSection, schemaData, contextSchemaData, namespace, hasSupportingDocuments, dbSectionId, sectionRegisterId, dispatch, buildSectionSnapshot, sectionId, onSectionDirtyChange, mode, isDraft]);
|
|
4094
4134
|
// Handle cancel button click
|
|
4095
4135
|
const handleCancel = () => {
|
|
4096
|
-
|
|
4097
|
-
// Use original section (without namespace) for collecting widgets
|
|
4098
|
-
const sectionWidgets = collectWidgets(originalSection.panels);
|
|
4099
|
-
const oldSchemaData = schemaData || contextSchemaData;
|
|
4100
|
-
const currentStoreValues = store.getState().widget.values;
|
|
4101
|
-
let newStoreValues = currentStoreValues;
|
|
4102
|
-
sectionWidgets.forEach(widget => {
|
|
4103
|
-
const originalWidgetId = widget['widget-id'];
|
|
4104
|
-
// If namespace was used, we need to use namespaced widget ID and data path
|
|
4105
|
-
const namespacedWidgetId = namespace ? `${namespace}__${originalWidgetId}` : originalWidgetId;
|
|
4106
|
-
const widgetId = namespacedWidgetId;
|
|
4107
|
-
const originalDataPath = widget['widget-data-path'];
|
|
4108
|
-
// If namespace was used, data path in store is namespaced, but we read from original schema using original path
|
|
4109
|
-
const storeDataPath = namespace && originalDataPath
|
|
4110
|
-
? (typeof originalDataPath === 'string'
|
|
4111
|
-
? `${namespace}.${originalDataPath}`
|
|
4112
|
-
: Object.fromEntries(Object.entries(originalDataPath).map(([key, path]) => [key, `${namespace}.${path}`])))
|
|
4113
|
-
: originalDataPath;
|
|
4114
|
-
if (widgetId && originalDataPath) {
|
|
4115
|
-
// Handle multi-path (object) or single path (string)
|
|
4116
|
-
// Read from original schema data using original paths
|
|
4117
|
-
let oldValue;
|
|
4118
|
-
if (typeof originalDataPath === 'object') {
|
|
4119
|
-
// Multi-path: get values for each path
|
|
4120
|
-
oldValue = {};
|
|
4121
|
-
Object.entries(originalDataPath).forEach(([key, path]) => {
|
|
4122
|
-
if (typeof path === 'string') {
|
|
4123
|
-
oldValue[key] = getValueByPath(oldSchemaData, path);
|
|
4124
|
-
}
|
|
4125
|
-
});
|
|
4126
|
-
}
|
|
4127
|
-
else if (typeof originalDataPath === 'string') {
|
|
4128
|
-
oldValue = getValueByPath(oldSchemaData, originalDataPath);
|
|
4129
|
-
}
|
|
4130
|
-
// Set in store using namespaced data path (if namespace was used)
|
|
4131
|
-
if (oldValue !== undefined) {
|
|
4132
|
-
newStoreValues = setWidgetValue(newStoreValues, storeDataPath, widgetId, oldValue);
|
|
4133
|
-
}
|
|
4134
|
-
}
|
|
4135
|
-
});
|
|
4136
|
-
// Also revert supporting documents if any
|
|
4137
|
-
if (hasSupportingDocuments) {
|
|
4138
|
-
// Use original section's supporting documents to get original data paths
|
|
4139
|
-
const originalSupportingDocuments = originalSection['section-supporting-documents'] || [];
|
|
4140
|
-
originalSupportingDocuments.forEach((doc, index) => {
|
|
4141
|
-
const widgetId = `supporting-doc-${sectionId}-${index}`;
|
|
4142
|
-
const originalDataPath = doc['document-data-path'];
|
|
4143
|
-
// If namespace was used, data path in store is namespaced
|
|
4144
|
-
const storeDataPath = namespace && originalDataPath
|
|
4145
|
-
? `${namespace}.${originalDataPath}`
|
|
4146
|
-
: originalDataPath;
|
|
4147
|
-
const oldValue = getValueByPath(oldSchemaData, originalDataPath);
|
|
4148
|
-
newStoreValues = setWidgetValue(newStoreValues, storeDataPath, widgetId, oldValue);
|
|
4149
|
-
});
|
|
4150
|
-
}
|
|
4151
|
-
if (newStoreValues !== currentStoreValues) {
|
|
4152
|
-
dispatch(setValues(newStoreValues));
|
|
4153
|
-
}
|
|
4136
|
+
revertToOriginalValues();
|
|
4154
4137
|
setIsEditMode(false);
|
|
4155
4138
|
onEditModeChange?.(originalSectionId, false);
|
|
4156
4139
|
};
|
|
@@ -4716,6 +4699,9 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
|
|
|
4716
4699
|
}, []);
|
|
4717
4700
|
const safeSections = sections ?? [];
|
|
4718
4701
|
const prevSectionsLengthRef = useRef(safeSections.length);
|
|
4702
|
+
// Stable ref for namespace so formHandle useMemo doesn't depend on the (possibly inline) function identity
|
|
4703
|
+
const namespaceRef = useRef(namespace);
|
|
4704
|
+
namespaceRef.current = namespace;
|
|
4719
4705
|
// Track dirty (unsaved changes) per section for form handle validation
|
|
4720
4706
|
const sectionDirtyMapRef = useRef({});
|
|
4721
4707
|
const handleSectionDirtyChange = useCallback((sectionId, isDirty) => {
|
|
@@ -4761,11 +4747,14 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
|
|
|
4761
4747
|
// Form handle for onFormReady - allows host to validate and get all section data from its own Submit button
|
|
4762
4748
|
const formHandle = useMemo(() => {
|
|
4763
4749
|
const getValues = () => store.getState().widget?.values || {};
|
|
4764
|
-
const getNamespace = (section, index) =>
|
|
4765
|
-
|
|
4766
|
-
|
|
4767
|
-
|
|
4768
|
-
|
|
4750
|
+
const getNamespace = (section, index) => {
|
|
4751
|
+
const ns = namespaceRef.current;
|
|
4752
|
+
return ns
|
|
4753
|
+
? typeof ns === 'string'
|
|
4754
|
+
? ns
|
|
4755
|
+
: ns(section['section-id'], index)
|
|
4756
|
+
: undefined;
|
|
4757
|
+
};
|
|
4769
4758
|
const checkNoUnsavedChanges = () => {
|
|
4770
4759
|
const hasDirty = Object.values(sectionDirtyMapRef.current).some(Boolean);
|
|
4771
4760
|
if (hasDirty) {
|
|
@@ -4815,7 +4804,7 @@ const SectionsContainer = ({ sections, dataSourceRequestHandler: propDataSourceR
|
|
|
4815
4804
|
return results;
|
|
4816
4805
|
},
|
|
4817
4806
|
};
|
|
4818
|
-
}, [store, dispatch, safeSections
|
|
4807
|
+
}, [store, dispatch, safeSections]);
|
|
4819
4808
|
// Call onFormReady when form is ready (sections loaded)
|
|
4820
4809
|
useEffect(() => {
|
|
4821
4810
|
if (onFormReady && safeSections.length > 0) {
|
|
@@ -9104,16 +9093,6 @@ const HeaderSectionWidget = ({ config }) => {
|
|
|
9104
9093
|
const statusColor = statusColors[String(statusValue).toLowerCase()] || '#6B7280';
|
|
9105
9094
|
// ── Scoped class for CSS isolation ────────────────────────────
|
|
9106
9095
|
const cls = `header-section-widget-${widgetConfig['widget-id']}`;
|
|
9107
|
-
// ── Indicator dot component ───────────────────────────────────
|
|
9108
|
-
const Dot = ({ color }) => (jsxRuntimeExports.jsx("span", { style: {
|
|
9109
|
-
display: 'inline-block',
|
|
9110
|
-
width: 8,
|
|
9111
|
-
height: 8,
|
|
9112
|
-
borderRadius: '50%',
|
|
9113
|
-
backgroundColor: color,
|
|
9114
|
-
flexShrink: 0,
|
|
9115
|
-
marginTop: 6,
|
|
9116
|
-
} }));
|
|
9117
9096
|
// ── RENDER ────────────────────────────────────────────────────
|
|
9118
9097
|
return (jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [jsxRuntimeExports.jsx("style", { children: `
|
|
9119
9098
|
.${cls} {
|
|
@@ -9282,7 +9261,7 @@ const HeaderSectionWidget = ({ config }) => {
|
|
|
9282
9261
|
.parentElement?.querySelector('.hdr-avatar-placeholder');
|
|
9283
9262
|
if (placeholder)
|
|
9284
9263
|
placeholder.style.display = 'flex';
|
|
9285
|
-
} })) : null, jsxRuntimeExports.jsx("div", { className: "hdr-avatar-placeholder", style: { display: imageUrl ? 'none' : 'flex' }, children: jsxRuntimeExports.jsx("img", { src: img$f, alt: "Profile Placeholder" }) })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-info", children: [displayName && jsxRuntimeExports.jsx("div", { className: "hdr-name", children: displayName }), jsxRuntimeExports.jsxs("div", { className: "hdr-field-row", children: [jsxRuntimeExports.
|
|
9264
|
+
} })) : null, jsxRuntimeExports.jsx("div", { className: "hdr-avatar-placeholder", style: { display: imageUrl ? 'none' : 'flex' }, children: jsxRuntimeExports.jsx("img", { src: img$f, alt: "Profile Placeholder" }) })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-info", children: [displayName && jsxRuntimeExports.jsx("div", { className: "hdr-name", children: displayName }), jsxRuntimeExports.jsxs("div", { className: "hdr-field-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-field-label", children: [getLabel('functionalId'), " :"] }), jsxRuntimeExports.jsx("span", { className: "hdr-field-value", children: functionalId || '-' })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-field-row", children: [jsxRuntimeExports.jsx("span", { className: "hdr-field-label", children: getLabel('status') }), isReadonly ? (statusLabel ? (jsxRuntimeExports.jsx("span", { className: "hdr-status-badge", style: { backgroundColor: statusColor }, children: statusLabel })) : (jsxRuntimeExports.jsx("span", { className: "hdr-field-value", children: "-" }))) : (jsxRuntimeExports.jsxs("select", { className: "hdr-select", value: statusValue, onChange: (e) => updateFieldValue('status', e.target.value), children: [jsxRuntimeExports.jsx("option", { value: "", children: getLabel('select') }), statusOptions.map((opt) => (jsxRuntimeExports.jsx("option", { value: opt.value, children: opt.label }, opt.value)))] }))] }), jsxRuntimeExports.jsxs("div", { className: "hdr-field-row", children: [jsxRuntimeExports.jsxs("span", { className: "hdr-field-label", children: [getLabel('statusReason'), " :"] }), isReadonly ? (jsxRuntimeExports.jsx("span", { className: "hdr-field-value", children: statusReason || '-' })) : (jsxRuntimeExports.jsx("input", { type: "text", className: "hdr-input", value: statusReason, placeholder: getLabel('enterReason'), onChange: (e) => updateFieldValue('statusReason', e.target.value) }))] })] })] }), jsxRuntimeExports.jsxs("div", { className: "hdr-right", 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 || '-' })] })] })] })] }));
|
|
9286
9265
|
};
|
|
9287
9266
|
|
|
9288
9267
|
/**
|