@openg2p/registry-widgets 1.1.2-dev.7 → 1.1.2-dev.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/dist/hooks/useBaseWidget.d.ts.map +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.esm.js +119 -115
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +119 -114
- package/dist/index.js.map +1 -1
- package/dist/utils/dataSource.d.ts +6 -0
- package/dist/utils/dataSource.d.ts.map +1 -1
- package/dist/widgets/DialogTableWidget.d.ts.map +1 -1
- package/dist/widgets/SelectWidget.d.ts.map +1 -1
- package/dist/widgets/TableWidget.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseWidget.d.ts","sourceRoot":"","sources":["../../src/hooks/useBaseWidget.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"useBaseWidget.d.ts","sourceRoot":"","sources":["../../src/hooks/useBaseWidget.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAwBtE,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB,wBAAwB,CAAC,EAAE,wBAAwB,CAAC;IACpD,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,CAAC;CACxD;AAMD,eAAO,MAAM,aAAa,GAAI,SAAS,oBAAoB;;;;;;;;;;;yBAyO5C,GAAG,aAAY,OAAO;;uBAkWd,MAAM,EAAE;;;;;;;0BA1OpB,MAAM;;;CA+OhB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ options?: {
|
|
|
40
40
|
/**
|
|
41
41
|
* API data source configuration
|
|
42
42
|
*/
|
|
43
|
-
interface ApiDataSource {
|
|
43
|
+
interface ApiDataSource$1 {
|
|
44
44
|
type: 'api';
|
|
45
45
|
service: string;
|
|
46
46
|
endpoint: string;
|
|
@@ -61,7 +61,7 @@ interface SchemaDataSource {
|
|
|
61
61
|
valueKey?: string;
|
|
62
62
|
labelKey?: string;
|
|
63
63
|
}
|
|
64
|
-
type DataSource = StaticDataSource | ApiDataSource | SchemaDataSource;
|
|
64
|
+
type DataSource = StaticDataSource | ApiDataSource$1 | SchemaDataSource;
|
|
65
65
|
/**
|
|
66
66
|
* Allowed character types for text input
|
|
67
67
|
*/
|
|
@@ -1622,6 +1622,11 @@ declare const shouldShowWidget: (options: WidgetOptions | undefined, allValues:
|
|
|
1622
1622
|
declare const shouldEnableWidget: (options: WidgetOptions | undefined, allValues: Record<string, any>) => boolean;
|
|
1623
1623
|
declare const shouldRequireWidget: (options: WidgetOptions | undefined, allValues: Record<string, any>, baseRequired?: boolean) => boolean;
|
|
1624
1624
|
|
|
1625
|
+
type ApiDataSource = Extract<DataSource, {
|
|
1626
|
+
type: 'api';
|
|
1627
|
+
}>;
|
|
1628
|
+
/** Return cached API options when already fetched (e.g. duplicate table cells). */
|
|
1629
|
+
declare function getCachedApiDataSource(dataSource: ApiDataSource, allValues: Record<string, any>, levelId?: string): any[] | undefined;
|
|
1625
1630
|
/**
|
|
1626
1631
|
* Get static data source options
|
|
1627
1632
|
*/
|
|
@@ -1852,5 +1857,5 @@ declare const translatePanelConfig: (panel: PanelConfig, translate: (key: string
|
|
|
1852
1857
|
*/
|
|
1853
1858
|
declare const translateUISchema: (schema: UISchema, translate: (key: string, options?: any) => string) => UISchema;
|
|
1854
1859
|
|
|
1855
|
-
export { ArrayWidget, BooleanWidget, CheckboxWidget, CurrencyInputWidget, DateInputWidget, DateTimeInputWidget, DialogTableWidget, DisplayWidget, FileInputWidget, GEO_LEVEL_CLEARED, HeaderSectionWidget, IdAuthenticationWidget, IterableAccordionWidget, JSONEditorPanel, MultiSelectWidget, NumberInputWidget, PanelRenderer, PhoneInputWidget, ProfileWidget, PropertyEditor, RadioWidget, RegisterLookupWidget, ScoresDisplayWidget, SectionBuilder, SectionRenderer, SectionTree, SectionsContainer, SelectWidget, SimpleTableWidget, TableWidget, TextAreaWidget, TextInputWidget, VisualBuilderPanel, WidgetEventBus, WidgetProvider, WidgetRenderer, applyCaseControl, applyDecimalPrecision, applyMask, applySharedGeoHierarchyToValues, createWidgetStore, createZodSchema, defaultTheme, evaluateCondition, evaluateWidgetConditions, filterByCharacterType, formatCurrency, formatDate, formatNumber, formatPhone, formatValue, geoHierarchyBuilder, getApiDataSource, getFormattedNumberLength, getGeoDescendantWidgetIds, getGeoGroupId, getSchemaDataSource, getStaticDataSource, getValueByPath, getWidgetValue, hasVisibilityRules, initI18n, isAllowedKey, isUpstreamGeoAncestor, normalizeNumericDefault, normalizeOptionRules, parseDataPath, parseNumber, registerDefaultWidgets, registerGeoWidgetParent, removeMask, resetAll, resetAndSeedGeoHierarchyFromValues, resetWidget, resolveGeoWidgetLevelLabel, resolveGeoWidgetLevelValue, resolveTheme, resolveWidgetIdValue, seedGeoHierarchyFromValues, setDataSource, setError, setLoading, setTouched, setValue, setValueByPath, setValues, setWidgetValue, shouldEnableWidget, shouldRequireWidget, shouldShowWidget, transformDataSourceOptions, translatePanelConfig, translateUISchema, translateWidgetConfig, unregisterGeoWidgetParent, useBaseWidget, useGeoWidgetCascade, useWidgetCascade, useWidgetContext, useWidgetEventBus, useWidgetTheme, useWidgetTranslation, validateNumericValue, validateWidget, widgetRegistry };
|
|
1856
|
-
export type { ApiAdapter, ApiDataSource, BaseWidgetConfig, BooleanControlType, BooleanRepresentation, CaseControl, CharacterType, ConditionOperator, DataSource, DataSourceRequestHandler, DataSourceType, GeoLevelConfig, GeoLevelData, InputMask, NumericType, PanelConfig, RoundingMode, SchemaDataSource, SectionBuilderProps, SectionChanges, SectionConfig, SectionMode, SectionRendererProps, SectionsContainerProps, SectionsFormHandle, StaticDataSource, SupportingDocumentConfig, TextAlign, TreeNode, TreeNodeType, UISchema, UseBaseWidgetOptions, ValidationType, WidgetCascadeConfig, WidgetCondition, WidgetConditionState, WidgetContextValue, WidgetDataPath, WidgetDispatch, WidgetEvent, WidgetEventType, WidgetFormat, WidgetGeoConfig, WidgetOptionRule, WidgetOptions, WidgetRegistryEntry, WidgetRenderFunction, WidgetRootState, WidgetState, WidgetStore, WidgetTheme, WidgetThemeButton, WidgetThemeColors, WidgetThemePanel, WidgetThemeSection, WidgetThemeWidget, WidgetValidation, WidgetValue };
|
|
1860
|
+
export { ArrayWidget, BooleanWidget, CheckboxWidget, CurrencyInputWidget, DateInputWidget, DateTimeInputWidget, DialogTableWidget, DisplayWidget, FileInputWidget, GEO_LEVEL_CLEARED, HeaderSectionWidget, IdAuthenticationWidget, IterableAccordionWidget, JSONEditorPanel, MultiSelectWidget, NumberInputWidget, PanelRenderer, PhoneInputWidget, ProfileWidget, PropertyEditor, RadioWidget, RegisterLookupWidget, ScoresDisplayWidget, SectionBuilder, SectionRenderer, SectionTree, SectionsContainer, SelectWidget, SimpleTableWidget, TableWidget, TextAreaWidget, TextInputWidget, VisualBuilderPanel, WidgetEventBus, WidgetProvider, WidgetRenderer, applyCaseControl, applyDecimalPrecision, applyMask, applySharedGeoHierarchyToValues, createWidgetStore, createZodSchema, defaultTheme, evaluateCondition, evaluateWidgetConditions, filterByCharacterType, formatCurrency, formatDate, formatNumber, formatPhone, formatValue, geoHierarchyBuilder, getApiDataSource, getCachedApiDataSource, getFormattedNumberLength, getGeoDescendantWidgetIds, getGeoGroupId, getSchemaDataSource, getStaticDataSource, getValueByPath, getWidgetValue, hasVisibilityRules, initI18n, isAllowedKey, isUpstreamGeoAncestor, normalizeNumericDefault, normalizeOptionRules, parseDataPath, parseNumber, registerDefaultWidgets, registerGeoWidgetParent, removeMask, resetAll, resetAndSeedGeoHierarchyFromValues, resetWidget, resolveGeoWidgetLevelLabel, resolveGeoWidgetLevelValue, resolveTheme, resolveWidgetIdValue, seedGeoHierarchyFromValues, setDataSource, setError, setLoading, setTouched, setValue, setValueByPath, setValues, setWidgetValue, shouldEnableWidget, shouldRequireWidget, shouldShowWidget, transformDataSourceOptions, translatePanelConfig, translateUISchema, translateWidgetConfig, unregisterGeoWidgetParent, useBaseWidget, useGeoWidgetCascade, useWidgetCascade, useWidgetContext, useWidgetEventBus, useWidgetTheme, useWidgetTranslation, validateNumericValue, validateWidget, widgetRegistry };
|
|
1861
|
+
export type { ApiAdapter, ApiDataSource$1 as ApiDataSource, BaseWidgetConfig, BooleanControlType, BooleanRepresentation, CaseControl, CharacterType, ConditionOperator, DataSource, DataSourceRequestHandler, DataSourceType, GeoLevelConfig, GeoLevelData, InputMask, NumericType, PanelConfig, RoundingMode, SchemaDataSource, SectionBuilderProps, SectionChanges, SectionConfig, SectionMode, SectionRendererProps, SectionsContainerProps, SectionsFormHandle, StaticDataSource, SupportingDocumentConfig, TextAlign, TreeNode, TreeNodeType, UISchema, UseBaseWidgetOptions, ValidationType, WidgetCascadeConfig, WidgetCondition, WidgetConditionState, WidgetContextValue, WidgetDataPath, WidgetDispatch, WidgetEvent, WidgetEventType, WidgetFormat, WidgetGeoConfig, WidgetOptionRule, WidgetOptions, WidgetRegistryEntry, WidgetRenderFunction, WidgetRootState, WidgetState, WidgetStore, WidgetTheme, WidgetThemeButton, WidgetThemeColors, WidgetThemePanel, WidgetThemeSection, WidgetThemeWidget, WidgetValidation, WidgetValue };
|
package/dist/index.esm.js
CHANGED
|
@@ -1082,6 +1082,67 @@ const formatValue = (value, format, widgetType) => {
|
|
|
1082
1082
|
return value?.toString() || '';
|
|
1083
1083
|
};
|
|
1084
1084
|
|
|
1085
|
+
const apiDataSourceCache = new Map();
|
|
1086
|
+
const apiDataSourceInflight = new Map();
|
|
1087
|
+
function buildApiRequestContext(dataSource, allValues, levelId) {
|
|
1088
|
+
let depValue = null;
|
|
1089
|
+
if (dataSource.dependsOn) {
|
|
1090
|
+
if (dataSource.dependsOn.includes('.')) {
|
|
1091
|
+
depValue = getValueByPath(allValues, dataSource.dependsOn);
|
|
1092
|
+
}
|
|
1093
|
+
else {
|
|
1094
|
+
depValue = resolveWidgetIdValue(allValues, dataSource.dependsOn);
|
|
1095
|
+
}
|
|
1096
|
+
if (depValue === null || depValue === undefined || depValue === '') {
|
|
1097
|
+
return null;
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
const method = dataSource.method || 'GET';
|
|
1101
|
+
const staticParams = { ...dataSource.params };
|
|
1102
|
+
const standardFields = ['type', 'service', 'endpoint', 'url', 'method', 'dependsOn', 'valueKey', 'labelKey', 'headers', 'body', 'params', 'level_id'];
|
|
1103
|
+
for (const [key, value] of Object.entries(dataSource)) {
|
|
1104
|
+
if (!standardFields.includes(key) && value !== undefined && value !== null) {
|
|
1105
|
+
staticParams[key] = value;
|
|
1106
|
+
}
|
|
1107
|
+
}
|
|
1108
|
+
if (levelId) {
|
|
1109
|
+
staticParams.level_id = levelId;
|
|
1110
|
+
}
|
|
1111
|
+
const requestParams = { ...staticParams };
|
|
1112
|
+
if (dataSource.dependsOn && depValue !== null && depValue !== undefined) {
|
|
1113
|
+
const parentValueId = typeof depValue === 'object' && depValue !== null
|
|
1114
|
+
? (depValue.level_value_id || depValue.id || depValue.value || depValue)
|
|
1115
|
+
: depValue;
|
|
1116
|
+
if (staticParams.level_id) {
|
|
1117
|
+
requestParams.parent_level_value_id = parentValueId;
|
|
1118
|
+
}
|
|
1119
|
+
else {
|
|
1120
|
+
const paramKey = dataSource.dependsOn.split('.').pop() || 'filter';
|
|
1121
|
+
requestParams[paramKey] = parentValueId;
|
|
1122
|
+
}
|
|
1123
|
+
}
|
|
1124
|
+
else if (staticParams.level_id) {
|
|
1125
|
+
requestParams.parent_level_value_id = '';
|
|
1126
|
+
}
|
|
1127
|
+
const service = dataSource.service;
|
|
1128
|
+
const endpoint = dataSource.endpoint;
|
|
1129
|
+
if (!service || !endpoint) {
|
|
1130
|
+
return null;
|
|
1131
|
+
}
|
|
1132
|
+
return { service, endpoint, method, requestParams };
|
|
1133
|
+
}
|
|
1134
|
+
function buildApiDataSourceCacheKey(service, endpoint, method, requestParams) {
|
|
1135
|
+
return `${service}|${endpoint}|${method}|${JSON.stringify(requestParams)}`;
|
|
1136
|
+
}
|
|
1137
|
+
/** Return cached API options when already fetched (e.g. duplicate table cells). */
|
|
1138
|
+
function getCachedApiDataSource(dataSource, allValues, levelId) {
|
|
1139
|
+
const context = buildApiRequestContext(dataSource, allValues, levelId);
|
|
1140
|
+
if (!context) {
|
|
1141
|
+
return undefined;
|
|
1142
|
+
}
|
|
1143
|
+
const cacheKey = buildApiDataSourceCacheKey(context.service, context.endpoint, context.method, context.requestParams);
|
|
1144
|
+
return apiDataSourceCache.get(cacheKey);
|
|
1145
|
+
}
|
|
1085
1146
|
/**
|
|
1086
1147
|
* Get static data source options
|
|
1087
1148
|
*/
|
|
@@ -1099,98 +1160,33 @@ const getApiDataSource = async (dataSource, allValues, dataSourceRequestHandler,
|
|
|
1099
1160
|
return [];
|
|
1100
1161
|
}
|
|
1101
1162
|
try {
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
let depValue = null;
|
|
1105
|
-
if (dataSource.dependsOn) {
|
|
1106
|
-
if (dataSource.dependsOn.includes('.')) {
|
|
1107
|
-
depValue = getValueByPath(allValues, dataSource.dependsOn);
|
|
1108
|
-
}
|
|
1109
|
-
else {
|
|
1110
|
-
depValue = resolveWidgetIdValue(allValues, dataSource.dependsOn);
|
|
1111
|
-
}
|
|
1112
|
-
if (depValue === null || depValue === undefined || depValue === '') {
|
|
1113
|
-
// If dependency is empty, return empty array
|
|
1114
|
-
return [];
|
|
1115
|
-
}
|
|
1116
|
-
}
|
|
1117
|
-
// Build request parameters
|
|
1118
|
-
const method = dataSource.method || 'GET';
|
|
1119
|
-
// Extract static params from dataSource
|
|
1120
|
-
// Include explicit params object and any additional fields (like level_id)
|
|
1121
|
-
const staticParams = { ...dataSource.params };
|
|
1122
|
-
// Extract additional fields that aren't part of the standard ApiDataSource interface
|
|
1123
|
-
// These are fields like level_id that might be directly on the dataSource
|
|
1124
|
-
// BUT: level_id should come from widget-geo-config.level, not from dataSource
|
|
1125
|
-
const standardFields = ['type', 'service', 'endpoint', 'url', 'method', 'dependsOn', 'valueKey', 'labelKey', 'headers', 'body', 'params', 'level_id'];
|
|
1126
|
-
for (const [key, value] of Object.entries(dataSource)) {
|
|
1127
|
-
if (!standardFields.includes(key) && value !== undefined && value !== null) {
|
|
1128
|
-
staticParams[key] = value;
|
|
1129
|
-
}
|
|
1130
|
-
}
|
|
1131
|
-
// If levelId is provided (from widget-geo-config.level), use it instead of any level_id in dataSource
|
|
1132
|
-
if (levelId) {
|
|
1133
|
-
staticParams.level_id = levelId;
|
|
1134
|
-
}
|
|
1135
|
-
// Build request params object
|
|
1136
|
-
const requestParams = { ...staticParams };
|
|
1137
|
-
// Add dependency value to params
|
|
1138
|
-
if (dataSource.dependsOn && depValue !== null && depValue !== undefined) {
|
|
1139
|
-
// Extract the actual value ID if depValue is an object
|
|
1140
|
-
const parentValueId = typeof depValue === 'object' && depValue !== null
|
|
1141
|
-
? (depValue.level_value_id || depValue.id || depValue.value || depValue)
|
|
1142
|
-
: depValue;
|
|
1143
|
-
// For geo APIs, use parent_level_value_id
|
|
1144
|
-
if (staticParams.level_id) {
|
|
1145
|
-
requestParams.parent_level_value_id = parentValueId;
|
|
1146
|
-
}
|
|
1147
|
-
else {
|
|
1148
|
-
// For other APIs, use the dependency field name as param key
|
|
1149
|
-
const paramKey = dataSource.dependsOn.split('.').pop() || 'filter';
|
|
1150
|
-
requestParams[paramKey] = parentValueId;
|
|
1151
|
-
}
|
|
1152
|
-
}
|
|
1153
|
-
else if (staticParams.level_id) {
|
|
1154
|
-
// First level has no parent, send empty string as many OpenG2P APIs expect it
|
|
1155
|
-
requestParams.parent_level_value_id = "";
|
|
1156
|
-
}
|
|
1157
|
-
// Get service mnemonic and endpoint (required)
|
|
1158
|
-
const service = dataSource.service;
|
|
1159
|
-
const endpoint = dataSource.endpoint;
|
|
1160
|
-
if (!service) {
|
|
1161
|
-
console.error('[getApiDataSource] API data source missing service mnemonic. Use "service" field instead of "url"');
|
|
1162
|
-
return [];
|
|
1163
|
-
}
|
|
1164
|
-
if (!endpoint) {
|
|
1165
|
-
console.error('[getApiDataSource] API data source missing endpoint. Use "endpoint" field to specify the operation (e.g., "get_g2p_geo_level_values")');
|
|
1163
|
+
const context = buildApiRequestContext(dataSource, allValues, levelId);
|
|
1164
|
+
if (!context) {
|
|
1166
1165
|
return [];
|
|
1167
1166
|
}
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
}
|
|
1174
|
-
|
|
1175
|
-
if (
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
return
|
|
1167
|
+
const { service, endpoint, method, requestParams } = context;
|
|
1168
|
+
const cacheKey = buildApiDataSourceCacheKey(service, endpoint, method, requestParams);
|
|
1169
|
+
const cached = apiDataSourceCache.get(cacheKey);
|
|
1170
|
+
if (cached) {
|
|
1171
|
+
return cached;
|
|
1172
|
+
}
|
|
1173
|
+
const inflight = apiDataSourceInflight.get(cacheKey);
|
|
1174
|
+
if (inflight) {
|
|
1175
|
+
return inflight;
|
|
1176
|
+
}
|
|
1177
|
+
const fetchPromise = (async () => {
|
|
1178
|
+
const response = await dataSourceRequestHandler(service, endpoint, method, requestParams, { headers: dataSource.headers });
|
|
1179
|
+
const parsed = Array.isArray(response) ? response : [];
|
|
1180
|
+
apiDataSourceCache.set(cacheKey, parsed);
|
|
1181
|
+
return parsed;
|
|
1182
|
+
})();
|
|
1183
|
+
apiDataSourceInflight.set(cacheKey, fetchPromise);
|
|
1184
|
+
try {
|
|
1185
|
+
return await fetchPromise;
|
|
1183
1186
|
}
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
if (response.data && Array.isArray(response.data)) {
|
|
1187
|
-
return response.data;
|
|
1188
|
-
}
|
|
1189
|
-
if (response.results && Array.isArray(response.results)) {
|
|
1190
|
-
return response.results;
|
|
1191
|
-
}
|
|
1187
|
+
finally {
|
|
1188
|
+
apiDataSourceInflight.delete(cacheKey);
|
|
1192
1189
|
}
|
|
1193
|
-
return [];
|
|
1194
1190
|
}
|
|
1195
1191
|
catch (error) {
|
|
1196
1192
|
// Rethrow so useBaseWidget's catch can log it with full widget context
|
|
@@ -2700,9 +2696,9 @@ const useBaseWidget = (options) => {
|
|
|
2700
2696
|
if (!dataSource) {
|
|
2701
2697
|
return;
|
|
2702
2698
|
}
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
if (dataSource.type === 'api' && isReadonly && !
|
|
2699
|
+
const loadApiInReadonly = !!geoConfig ||
|
|
2700
|
+
['select', 'radio', 'checkbox', 'multi-select'].includes(config.widget);
|
|
2701
|
+
if (dataSource.type === 'api' && isReadonly && !loadApiInReadonly) {
|
|
2706
2702
|
return;
|
|
2707
2703
|
}
|
|
2708
2704
|
// For widgets with dependencies, check if dependency value exists
|
|
@@ -2744,6 +2740,30 @@ const useBaseWidget = (options) => {
|
|
|
2744
2740
|
// React will call this effect again when the handler is ready
|
|
2745
2741
|
return;
|
|
2746
2742
|
}
|
|
2743
|
+
const resolveOptionKeys = () => {
|
|
2744
|
+
if (dataSource.type === 'static') {
|
|
2745
|
+
return { valueKey: undefined, labelKey: undefined };
|
|
2746
|
+
}
|
|
2747
|
+
if (geoConfig) {
|
|
2748
|
+
return {
|
|
2749
|
+
valueKey: dataSource.valueKey || 'level_value_id',
|
|
2750
|
+
labelKey: dataSource.labelKey || 'level_value_mnemonic',
|
|
2751
|
+
};
|
|
2752
|
+
}
|
|
2753
|
+
return { valueKey: dataSource.valueKey, labelKey: dataSource.labelKey };
|
|
2754
|
+
};
|
|
2755
|
+
if (dataSource.type === 'api') {
|
|
2756
|
+
const levelId = geoConfig?.level;
|
|
2757
|
+
const cached = getCachedApiDataSource(dataSource, valuesRef.current, levelId);
|
|
2758
|
+
if (cached) {
|
|
2759
|
+
const { valueKey, labelKey } = resolveOptionKeys();
|
|
2760
|
+
dispatch(setDataSource({
|
|
2761
|
+
widgetId,
|
|
2762
|
+
data: transformDataSourceOptions(cached, valueKey, labelKey),
|
|
2763
|
+
}));
|
|
2764
|
+
return;
|
|
2765
|
+
}
|
|
2766
|
+
}
|
|
2747
2767
|
dispatch(setLoading({ widgetId, loading: true }));
|
|
2748
2768
|
let data = [];
|
|
2749
2769
|
if (dataSource.type === 'static') {
|
|
@@ -2756,31 +2776,13 @@ const useBaseWidget = (options) => {
|
|
|
2756
2776
|
dispatch(setDataSource({ widgetId, data: [] }));
|
|
2757
2777
|
return;
|
|
2758
2778
|
}
|
|
2759
|
-
// Extract level_id from widget-geo-config.level if available
|
|
2760
2779
|
const levelId = geoConfig?.level;
|
|
2761
2780
|
data = await getApiDataSource(dataSource, valuesRef.current, currentHandler, levelId);
|
|
2762
2781
|
}
|
|
2763
2782
|
else if (dataSource.type === 'schema') {
|
|
2764
2783
|
data = getSchemaDataSource(dataSource, schemaData || {});
|
|
2765
2784
|
}
|
|
2766
|
-
|
|
2767
|
-
// For geo widgets, default to level_value_id and level_value_mnemonic
|
|
2768
|
-
let valueKey;
|
|
2769
|
-
let labelKey;
|
|
2770
|
-
if (dataSource.type === 'static') {
|
|
2771
|
-
valueKey = undefined;
|
|
2772
|
-
labelKey = undefined;
|
|
2773
|
-
}
|
|
2774
|
-
else if (geoConfig) {
|
|
2775
|
-
// Geo widgets: default to level_value_id and level_value_mnemonic
|
|
2776
|
-
valueKey = dataSource.valueKey || 'level_value_id';
|
|
2777
|
-
labelKey = dataSource.labelKey || 'level_value_mnemonic';
|
|
2778
|
-
}
|
|
2779
|
-
else {
|
|
2780
|
-
// Non-geo widgets: use specified keys or undefined
|
|
2781
|
-
valueKey = dataSource.valueKey;
|
|
2782
|
-
labelKey = dataSource.labelKey;
|
|
2783
|
-
}
|
|
2785
|
+
const { valueKey, labelKey } = resolveOptionKeys();
|
|
2784
2786
|
const transformed = transformDataSourceOptions(data, valueKey, labelKey);
|
|
2785
2787
|
dispatch(setDataSource({ widgetId, data: transformed }));
|
|
2786
2788
|
}
|
|
@@ -8756,10 +8758,12 @@ const SelectWidget = ({ config }) => {
|
|
|
8756
8758
|
if (widgetConfig['widget-readonly']) {
|
|
8757
8759
|
const label = translateConfig(widgetConfig['widget-label']);
|
|
8758
8760
|
// Find the selected option's label
|
|
8759
|
-
const selectedOption = dataSourceOptions.find((option) => option.value === value);
|
|
8761
|
+
const selectedOption = dataSourceOptions.find((option) => option.value === value || String(option.value) === String(value));
|
|
8760
8762
|
const displayValue = selectedOption
|
|
8761
8763
|
? translateConfig(selectedOption.label)
|
|
8762
|
-
:
|
|
8764
|
+
: loading
|
|
8765
|
+
? (geoDisplayLabel || '-')
|
|
8766
|
+
: (geoDisplayLabel || (value != null && value !== '' ? translateConfig(String(value)) : '-'));
|
|
8763
8767
|
return (jsxRuntimeExports.jsxs("div", { className: "mb-[10px] SelectDisplayWidget flex flex-col sm:flex-row sm:items-start", children: [label && (jsxRuntimeExports.jsxs("div", { className: "text-base text-gray-600 font-medium md:min-w-[120px] sm:pr-4 mb-1 sm:mb-0", style: { fontFamily: 'Roboto, sans-serif' }, title: label, children: [label, ":"] })), jsxRuntimeExports.jsx("div", { className: "flex-1", children: jsxRuntimeExports.jsx("div", { className: "text-base text-gray-900 font-medium", title: String(displayValue ?? ''), children: displayValue }) })] }));
|
|
8764
8768
|
}
|
|
8765
8769
|
return (jsxRuntimeExports.jsx("div", { className: "mb-[10px]", children: jsxRuntimeExports.jsxs("div", { className: "flex flex-col sm:flex-row sm:items-start", children: [jsxRuntimeExports.jsx(WidgetFieldLabel, { className: "text-base font-medium text-gray-700 md:min-w-[120px] sm:pr-4 sm:pt-1 mb-1 sm:mb-0", label: translateConfig(widgetConfig['widget-label']), required: isRequired }), jsxRuntimeExports.jsxs("div", { className: "flex-1 min-w-0", children: [jsxRuntimeExports.jsxs("select", { value: value || '', onChange: (e) => onChange(e.target.value === '' ? undefined : e.target.value), onBlur: onBlur, disabled: !isEnabled || loading || widgetConfig['widget-readonly'], className: `w-full sm:w-[180px] max-w-full h-[30px] px-3 border shadow-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 ${(touched && error.length > 0) || (widgetConfig['widget-required'] && (!value || value === ''))
|
|
@@ -9258,7 +9262,7 @@ const SelectDisplayValue$1 = ({ config, value }) => {
|
|
|
9258
9262
|
if (value === null || value === undefined || value === '') {
|
|
9259
9263
|
return jsxRuntimeExports.jsx("span", { children: "-" });
|
|
9260
9264
|
}
|
|
9261
|
-
const selectedOption = dataSourceOptions.find((option) => option.value === value);
|
|
9265
|
+
const selectedOption = dataSourceOptions.find((option) => option.value === value || String(option.value) === String(value));
|
|
9262
9266
|
return jsxRuntimeExports.jsx("span", { children: selectedOption ? selectedOption.label : String(value) });
|
|
9263
9267
|
};
|
|
9264
9268
|
const TableCellText = ({ config, value, onValueChange }) => {
|
|
@@ -9989,7 +9993,7 @@ const SelectDisplayValue = ({ config, value }) => {
|
|
|
9989
9993
|
return jsxRuntimeExports.jsx("span", { children: "-" });
|
|
9990
9994
|
if (value === null || value === undefined || value === '')
|
|
9991
9995
|
return jsxRuntimeExports.jsx("span", { children: "-" });
|
|
9992
|
-
const selectedOption = dataSourceOptions.find((option) => option.value === value);
|
|
9996
|
+
const selectedOption = dataSourceOptions.find((option) => option.value === value || String(option.value) === String(value));
|
|
9993
9997
|
return jsxRuntimeExports.jsx("span", { children: selectedOption ? selectedOption.label : String(value) });
|
|
9994
9998
|
};
|
|
9995
9999
|
/**
|
|
@@ -12942,5 +12946,5 @@ const translateUISchema = (schema, translate) => {
|
|
|
12942
12946
|
};
|
|
12943
12947
|
};
|
|
12944
12948
|
|
|
12945
|
-
export { ArrayWidget, BooleanWidget, CheckboxWidget, CurrencyInputWidget, DateInputWidget, DateTimeInputWidget, DialogTableWidget, DisplayWidget, FileInputWidget, GEO_LEVEL_CLEARED, HeaderSectionWidget, IdAuthenticationWidget, IterableAccordionWidget, JSONEditorPanel, MultiSelectWidget, NumberInputWidget, PanelRenderer, PhoneInputWidget, ProfileWidget, PropertyEditor, RadioWidget, RegisterLookupWidget, ScoresDisplayWidget, SectionBuilder, SectionRenderer, SectionTree, SectionsContainer, SelectWidget, SimpleTableWidget, TableWidget, TextAreaWidget, TextInputWidget, VisualBuilderPanel, WidgetEventBus, WidgetProvider, WidgetRenderer, applyCaseControl, applyDecimalPrecision, applyMask, applySharedGeoHierarchyToValues, createWidgetStore, createZodSchema, defaultTheme, evaluateCondition, evaluateWidgetConditions, filterByCharacterType, formatCurrency, formatDate, formatNumber, formatPhone, formatValue, geoHierarchyBuilder, getApiDataSource, getFormattedNumberLength, getGeoDescendantWidgetIds, getGeoGroupId, getSchemaDataSource, getStaticDataSource, getValueByPath, getWidgetValue, hasVisibilityRules, initI18n, isAllowedKey, isUpstreamGeoAncestor, normalizeNumericDefault, normalizeOptionRules, parseDataPath, parseNumber, registerDefaultWidgets, registerGeoWidgetParent, removeMask, resetAll, resetAndSeedGeoHierarchyFromValues, resetWidget, resolveGeoWidgetLevelLabel, resolveGeoWidgetLevelValue, resolveTheme, resolveWidgetIdValue, seedGeoHierarchyFromValues, setDataSource, setError, setLoading, setTouched, setValue, setValueByPath, setValues, setWidgetValue, shouldEnableWidget, shouldRequireWidget, shouldShowWidget, transformDataSourceOptions, translatePanelConfig, translateUISchema, translateWidgetConfig, unregisterGeoWidgetParent, useBaseWidget, useGeoWidgetCascade, useWidgetCascade, useWidgetContext, useWidgetEventBus, useWidgetTheme, useWidgetTranslation, validateNumericValue, validateWidget, widgetRegistry };
|
|
12949
|
+
export { ArrayWidget, BooleanWidget, CheckboxWidget, CurrencyInputWidget, DateInputWidget, DateTimeInputWidget, DialogTableWidget, DisplayWidget, FileInputWidget, GEO_LEVEL_CLEARED, HeaderSectionWidget, IdAuthenticationWidget, IterableAccordionWidget, JSONEditorPanel, MultiSelectWidget, NumberInputWidget, PanelRenderer, PhoneInputWidget, ProfileWidget, PropertyEditor, RadioWidget, RegisterLookupWidget, ScoresDisplayWidget, SectionBuilder, SectionRenderer, SectionTree, SectionsContainer, SelectWidget, SimpleTableWidget, TableWidget, TextAreaWidget, TextInputWidget, VisualBuilderPanel, WidgetEventBus, WidgetProvider, WidgetRenderer, applyCaseControl, applyDecimalPrecision, applyMask, applySharedGeoHierarchyToValues, createWidgetStore, createZodSchema, defaultTheme, evaluateCondition, evaluateWidgetConditions, filterByCharacterType, formatCurrency, formatDate, formatNumber, formatPhone, formatValue, geoHierarchyBuilder, getApiDataSource, getCachedApiDataSource, getFormattedNumberLength, getGeoDescendantWidgetIds, getGeoGroupId, getSchemaDataSource, getStaticDataSource, getValueByPath, getWidgetValue, hasVisibilityRules, initI18n, isAllowedKey, isUpstreamGeoAncestor, normalizeNumericDefault, normalizeOptionRules, parseDataPath, parseNumber, registerDefaultWidgets, registerGeoWidgetParent, removeMask, resetAll, resetAndSeedGeoHierarchyFromValues, resetWidget, resolveGeoWidgetLevelLabel, resolveGeoWidgetLevelValue, resolveTheme, resolveWidgetIdValue, seedGeoHierarchyFromValues, setDataSource, setError, setLoading, setTouched, setValue, setValueByPath, setValues, setWidgetValue, shouldEnableWidget, shouldRequireWidget, shouldShowWidget, transformDataSourceOptions, translatePanelConfig, translateUISchema, translateWidgetConfig, unregisterGeoWidgetParent, useBaseWidget, useGeoWidgetCascade, useWidgetCascade, useWidgetContext, useWidgetEventBus, useWidgetTheme, useWidgetTranslation, validateNumericValue, validateWidget, widgetRegistry };
|
|
12946
12950
|
//# sourceMappingURL=index.esm.js.map
|