pixelon 0.3.81 → 0.3.82
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/molecules/chat/StructuredContent/components/ReactiveCrud/optionsLoader.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { SelectOption } from '../../../../../organisms/lumi/DynamicForm/types';
|
|
2
2
|
import type { ChatEventBus } from '../../../../../../core/eventBus/chatEventBus';
|
|
3
3
|
import type { CrudFieldOptionsEndpoint } from './types';
|
|
4
|
+
export declare const OPTIONS_LOAD_ERROR = "No se pudieron cargar las opciones. Int\u00E9ntalo de nuevo.";
|
|
4
5
|
export declare function unwrap(raw: unknown): unknown;
|
|
5
6
|
export declare function resolveBody(body: Record<string, unknown> | undefined, ctx?: Record<string, unknown>): Record<string, unknown>;
|
|
6
7
|
export declare function loadOptions(eventBus: ChatEventBus, ep: CrudFieldOptionsEndpoint, ctx?: Record<string, unknown>): Promise<SelectOption[]>;
|
package/dist/index.esm.js
CHANGED
|
@@ -14111,6 +14111,7 @@ function getFormatter(key) {
|
|
|
14111
14111
|
return key ? CRUD_FORMATTERS[key] : void 0;
|
|
14112
14112
|
}
|
|
14113
14113
|
|
|
14114
|
+
const OPTIONS_LOAD_ERROR = "No se pudieron cargar las opciones. Int\xE9ntalo de nuevo.";
|
|
14114
14115
|
function unwrap$3(raw) {
|
|
14115
14116
|
if (raw && typeof raw === "object" && "response" in raw) {
|
|
14116
14117
|
return raw.response;
|
|
@@ -14448,6 +14449,7 @@ function ActionFormDrawer({ action, row, idField, eventBus, onExecute, onClose }
|
|
|
14448
14449
|
const fileFields = useMemo(() => formFields.filter((f) => f.moleculeType === "FILE"), [formFields]);
|
|
14449
14450
|
const normalFields = useMemo(() => formFields.filter((f) => f.moleculeType !== "FILE"), [formFields]);
|
|
14450
14451
|
const [optionsByField, setOptionsByField] = useState({});
|
|
14452
|
+
const [optionsErrorByField, setOptionsErrorByField] = useState({});
|
|
14451
14453
|
const [loadingOptions, setLoadingOptions] = useState(false);
|
|
14452
14454
|
const [submitting, setSubmitting] = useState(false);
|
|
14453
14455
|
const [fileEntries, setFileEntries] = useState({});
|
|
@@ -14461,14 +14463,17 @@ function ActionFormDrawer({ action, row, idField, eventBus, onExecute, onClose }
|
|
|
14461
14463
|
toLoad.map(async (f) => {
|
|
14462
14464
|
try {
|
|
14463
14465
|
const opts = await loadOptions(eventBus, f.optionsEndpoint, { ...row, id: row[idField] });
|
|
14464
|
-
return [f.name, opts];
|
|
14466
|
+
return [f.name, opts, null];
|
|
14465
14467
|
} catch {
|
|
14466
|
-
return [f.name, []];
|
|
14468
|
+
return [f.name, [], OPTIONS_LOAD_ERROR];
|
|
14467
14469
|
}
|
|
14468
14470
|
})
|
|
14469
14471
|
).then((entries) => {
|
|
14470
14472
|
if (!alive) return;
|
|
14471
|
-
setOptionsByField(Object.fromEntries(entries));
|
|
14473
|
+
setOptionsByField(Object.fromEntries(entries.map(([n, o]) => [n, o])));
|
|
14474
|
+
setOptionsErrorByField(
|
|
14475
|
+
Object.fromEntries(entries.filter(([, , e]) => e).map(([n, , e]) => [n, e]))
|
|
14476
|
+
);
|
|
14472
14477
|
setLoadingOptions(false);
|
|
14473
14478
|
});
|
|
14474
14479
|
return () => {
|
|
@@ -14482,9 +14487,12 @@ function ActionFormDrawer({ action, row, idField, eventBus, onExecute, onClose }
|
|
|
14482
14487
|
moleculeType: CRUD_TO_FORM_MOLECULE[f.moleculeType] ?? "INPUT",
|
|
14483
14488
|
required: f.required,
|
|
14484
14489
|
placeholder: f.placeholder,
|
|
14485
|
-
options: f.options ?? optionsByField[f.name]
|
|
14490
|
+
options: f.options ?? optionsByField[f.name],
|
|
14491
|
+
// SPEC-106 T8 — `uiProps` llega tal cual a la molécula, así que el desplegable dice lo
|
|
14492
|
+
// que pasó de verdad en vez del «no hay» de siempre. Sin error, se queda el de siempre.
|
|
14493
|
+
...optionsErrorByField[f.name] ? { uiProps: { notFoundContent: optionsErrorByField[f.name] } } : {}
|
|
14486
14494
|
})),
|
|
14487
|
-
[normalFields, optionsByField]
|
|
14495
|
+
[normalFields, optionsByField, optionsErrorByField]
|
|
14488
14496
|
);
|
|
14489
14497
|
const validationSchema = useMemo(() => buildCrudYupSchema(normalFields), [normalFields]);
|
|
14490
14498
|
const uploadOne = async (f, file, idx) => {
|
|
@@ -15919,7 +15927,7 @@ function chatLinkFormatter(field, eventBus) {
|
|
|
15919
15927
|
return createElement(ChatLinkCell, { targets, eventBus });
|
|
15920
15928
|
};
|
|
15921
15929
|
}
|
|
15922
|
-
function toRenderField(f, loaded, eventBus, mapsApiKey) {
|
|
15930
|
+
function toRenderField(f, loaded, eventBus, mapsApiKey, loadError) {
|
|
15923
15931
|
const fmt = getFormatter(f.format);
|
|
15924
15932
|
const options = f.options ?? loaded[f.name];
|
|
15925
15933
|
if (f.moleculeType === "LOCATION") {
|
|
@@ -15964,7 +15972,9 @@ function toRenderField(f, loaded, eventBus, mapsApiKey) {
|
|
|
15964
15972
|
columnWidth: f.columnWidth,
|
|
15965
15973
|
fixed: f.fixed,
|
|
15966
15974
|
align: f.align,
|
|
15967
|
-
|
|
15975
|
+
// SPEC-106 T8 — con un fallo de carga, el desplegable dice que no se pudo preguntar en vez
|
|
15976
|
+
// de «no hay opciones disponibles», que es una respuesta y no la tenemos.
|
|
15977
|
+
uiProps: loadError ? { options: options ?? [], notFoundContent: loadError } : options ? { options } : void 0,
|
|
15968
15978
|
formatValue
|
|
15969
15979
|
};
|
|
15970
15980
|
}
|
|
@@ -16014,6 +16024,7 @@ function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, on
|
|
|
16014
16024
|
const [activeAction, setActiveAction] = useState(null);
|
|
16015
16025
|
const [detailRow, setDetailRow] = useState(null);
|
|
16016
16026
|
const [optionsByField, setOptionsByField] = useState({});
|
|
16027
|
+
const [optionsErrorByField, setOptionsErrorByField] = useState({});
|
|
16017
16028
|
useEffect(() => {
|
|
16018
16029
|
let alive = true;
|
|
16019
16030
|
const toLoad = config.fields.filter((f) => f.optionsEndpoint);
|
|
@@ -16021,21 +16032,25 @@ function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, on
|
|
|
16021
16032
|
void Promise.all(
|
|
16022
16033
|
toLoad.map(async (f) => {
|
|
16023
16034
|
try {
|
|
16024
|
-
return [f.name, await loadOptions(eventBus, f.optionsEndpoint)];
|
|
16035
|
+
return [f.name, await loadOptions(eventBus, f.optionsEndpoint), null];
|
|
16025
16036
|
} catch {
|
|
16026
|
-
return [f.name, []];
|
|
16037
|
+
return [f.name, [], OPTIONS_LOAD_ERROR];
|
|
16027
16038
|
}
|
|
16028
16039
|
})
|
|
16029
16040
|
).then((entries) => {
|
|
16030
|
-
if (alive)
|
|
16041
|
+
if (!alive) return;
|
|
16042
|
+
setOptionsByField(Object.fromEntries(entries.map(([n, o]) => [n, o])));
|
|
16043
|
+
setOptionsErrorByField(
|
|
16044
|
+
Object.fromEntries(entries.filter(([, , e]) => e).map(([n, , e]) => [n, e]))
|
|
16045
|
+
);
|
|
16031
16046
|
});
|
|
16032
16047
|
return () => {
|
|
16033
16048
|
alive = false;
|
|
16034
16049
|
};
|
|
16035
16050
|
}, [eventBus, config.fields]);
|
|
16036
16051
|
const renderByFields = useMemo(
|
|
16037
|
-
() => config.fields.map((f) => toRenderField(f, optionsByField, eventBus, googleMapsApiKey)),
|
|
16038
|
-
[config.fields, optionsByField, eventBus]
|
|
16052
|
+
() => config.fields.map((f) => toRenderField(f, optionsByField, eventBus, googleMapsApiKey, optionsErrorByField[f.name])),
|
|
16053
|
+
[config.fields, optionsByField, optionsErrorByField, eventBus]
|
|
16039
16054
|
);
|
|
16040
16055
|
const validationSchema = useMemo(() => buildCrudYupSchema(config.fields), [config.fields]);
|
|
16041
16056
|
const rowActions = useMemo(() => {
|
package/dist/index.js
CHANGED
|
@@ -14132,6 +14132,7 @@ function getFormatter(key) {
|
|
|
14132
14132
|
return key ? CRUD_FORMATTERS[key] : void 0;
|
|
14133
14133
|
}
|
|
14134
14134
|
|
|
14135
|
+
const OPTIONS_LOAD_ERROR = "No se pudieron cargar las opciones. Int\xE9ntalo de nuevo.";
|
|
14135
14136
|
function unwrap$3(raw) {
|
|
14136
14137
|
if (raw && typeof raw === "object" && "response" in raw) {
|
|
14137
14138
|
return raw.response;
|
|
@@ -14469,6 +14470,7 @@ function ActionFormDrawer({ action, row, idField, eventBus, onExecute, onClose }
|
|
|
14469
14470
|
const fileFields = React.useMemo(() => formFields.filter((f) => f.moleculeType === "FILE"), [formFields]);
|
|
14470
14471
|
const normalFields = React.useMemo(() => formFields.filter((f) => f.moleculeType !== "FILE"), [formFields]);
|
|
14471
14472
|
const [optionsByField, setOptionsByField] = React.useState({});
|
|
14473
|
+
const [optionsErrorByField, setOptionsErrorByField] = React.useState({});
|
|
14472
14474
|
const [loadingOptions, setLoadingOptions] = React.useState(false);
|
|
14473
14475
|
const [submitting, setSubmitting] = React.useState(false);
|
|
14474
14476
|
const [fileEntries, setFileEntries] = React.useState({});
|
|
@@ -14482,14 +14484,17 @@ function ActionFormDrawer({ action, row, idField, eventBus, onExecute, onClose }
|
|
|
14482
14484
|
toLoad.map(async (f) => {
|
|
14483
14485
|
try {
|
|
14484
14486
|
const opts = await loadOptions(eventBus, f.optionsEndpoint, { ...row, id: row[idField] });
|
|
14485
|
-
return [f.name, opts];
|
|
14487
|
+
return [f.name, opts, null];
|
|
14486
14488
|
} catch {
|
|
14487
|
-
return [f.name, []];
|
|
14489
|
+
return [f.name, [], OPTIONS_LOAD_ERROR];
|
|
14488
14490
|
}
|
|
14489
14491
|
})
|
|
14490
14492
|
).then((entries) => {
|
|
14491
14493
|
if (!alive) return;
|
|
14492
|
-
setOptionsByField(Object.fromEntries(entries));
|
|
14494
|
+
setOptionsByField(Object.fromEntries(entries.map(([n, o]) => [n, o])));
|
|
14495
|
+
setOptionsErrorByField(
|
|
14496
|
+
Object.fromEntries(entries.filter(([, , e]) => e).map(([n, , e]) => [n, e]))
|
|
14497
|
+
);
|
|
14493
14498
|
setLoadingOptions(false);
|
|
14494
14499
|
});
|
|
14495
14500
|
return () => {
|
|
@@ -14503,9 +14508,12 @@ function ActionFormDrawer({ action, row, idField, eventBus, onExecute, onClose }
|
|
|
14503
14508
|
moleculeType: CRUD_TO_FORM_MOLECULE[f.moleculeType] ?? "INPUT",
|
|
14504
14509
|
required: f.required,
|
|
14505
14510
|
placeholder: f.placeholder,
|
|
14506
|
-
options: f.options ?? optionsByField[f.name]
|
|
14511
|
+
options: f.options ?? optionsByField[f.name],
|
|
14512
|
+
// SPEC-106 T8 — `uiProps` llega tal cual a la molécula, así que el desplegable dice lo
|
|
14513
|
+
// que pasó de verdad en vez del «no hay» de siempre. Sin error, se queda el de siempre.
|
|
14514
|
+
...optionsErrorByField[f.name] ? { uiProps: { notFoundContent: optionsErrorByField[f.name] } } : {}
|
|
14507
14515
|
})),
|
|
14508
|
-
[normalFields, optionsByField]
|
|
14516
|
+
[normalFields, optionsByField, optionsErrorByField]
|
|
14509
14517
|
);
|
|
14510
14518
|
const validationSchema = React.useMemo(() => buildCrudYupSchema(normalFields), [normalFields]);
|
|
14511
14519
|
const uploadOne = async (f, file, idx) => {
|
|
@@ -15940,7 +15948,7 @@ function chatLinkFormatter(field, eventBus) {
|
|
|
15940
15948
|
return React.createElement(ChatLinkCell, { targets, eventBus });
|
|
15941
15949
|
};
|
|
15942
15950
|
}
|
|
15943
|
-
function toRenderField(f, loaded, eventBus, mapsApiKey) {
|
|
15951
|
+
function toRenderField(f, loaded, eventBus, mapsApiKey, loadError) {
|
|
15944
15952
|
const fmt = getFormatter(f.format);
|
|
15945
15953
|
const options = f.options ?? loaded[f.name];
|
|
15946
15954
|
if (f.moleculeType === "LOCATION") {
|
|
@@ -15985,7 +15993,9 @@ function toRenderField(f, loaded, eventBus, mapsApiKey) {
|
|
|
15985
15993
|
columnWidth: f.columnWidth,
|
|
15986
15994
|
fixed: f.fixed,
|
|
15987
15995
|
align: f.align,
|
|
15988
|
-
|
|
15996
|
+
// SPEC-106 T8 — con un fallo de carga, el desplegable dice que no se pudo preguntar en vez
|
|
15997
|
+
// de «no hay opciones disponibles», que es una respuesta y no la tenemos.
|
|
15998
|
+
uiProps: loadError ? { options: options ?? [], notFoundContent: loadError } : options ? { options } : void 0,
|
|
15989
15999
|
formatValue
|
|
15990
16000
|
};
|
|
15991
16001
|
}
|
|
@@ -16035,6 +16045,7 @@ function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, on
|
|
|
16035
16045
|
const [activeAction, setActiveAction] = React.useState(null);
|
|
16036
16046
|
const [detailRow, setDetailRow] = React.useState(null);
|
|
16037
16047
|
const [optionsByField, setOptionsByField] = React.useState({});
|
|
16048
|
+
const [optionsErrorByField, setOptionsErrorByField] = React.useState({});
|
|
16038
16049
|
React.useEffect(() => {
|
|
16039
16050
|
let alive = true;
|
|
16040
16051
|
const toLoad = config.fields.filter((f) => f.optionsEndpoint);
|
|
@@ -16042,21 +16053,25 @@ function ReactiveCrud({ config, eventBus, autoOpenCreate, prefill, onCreated, on
|
|
|
16042
16053
|
void Promise.all(
|
|
16043
16054
|
toLoad.map(async (f) => {
|
|
16044
16055
|
try {
|
|
16045
|
-
return [f.name, await loadOptions(eventBus, f.optionsEndpoint)];
|
|
16056
|
+
return [f.name, await loadOptions(eventBus, f.optionsEndpoint), null];
|
|
16046
16057
|
} catch {
|
|
16047
|
-
return [f.name, []];
|
|
16058
|
+
return [f.name, [], OPTIONS_LOAD_ERROR];
|
|
16048
16059
|
}
|
|
16049
16060
|
})
|
|
16050
16061
|
).then((entries) => {
|
|
16051
|
-
if (alive)
|
|
16062
|
+
if (!alive) return;
|
|
16063
|
+
setOptionsByField(Object.fromEntries(entries.map(([n, o]) => [n, o])));
|
|
16064
|
+
setOptionsErrorByField(
|
|
16065
|
+
Object.fromEntries(entries.filter(([, , e]) => e).map(([n, , e]) => [n, e]))
|
|
16066
|
+
);
|
|
16052
16067
|
});
|
|
16053
16068
|
return () => {
|
|
16054
16069
|
alive = false;
|
|
16055
16070
|
};
|
|
16056
16071
|
}, [eventBus, config.fields]);
|
|
16057
16072
|
const renderByFields = React.useMemo(
|
|
16058
|
-
() => config.fields.map((f) => toRenderField(f, optionsByField, eventBus, googleMapsApiKey)),
|
|
16059
|
-
[config.fields, optionsByField, eventBus]
|
|
16073
|
+
() => config.fields.map((f) => toRenderField(f, optionsByField, eventBus, googleMapsApiKey, optionsErrorByField[f.name])),
|
|
16074
|
+
[config.fields, optionsByField, optionsErrorByField, eventBus]
|
|
16060
16075
|
);
|
|
16061
16076
|
const validationSchema = React.useMemo(() => buildCrudYupSchema(config.fields), [config.fields]);
|
|
16062
16077
|
const rowActions = React.useMemo(() => {
|