@m4l/components 9.4.15 → 9.4.16
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.
|
@@ -2,6 +2,7 @@ import * as Yup from "yup";
|
|
|
2
2
|
import { B as BOOLEAN_OPERATORS } from "../../../constants.js";
|
|
3
3
|
import { B as BooleanFilter } from "./index.js";
|
|
4
4
|
import { D as DYNAMIC_FILTER_DICTIONARY_ID, a as DICCTIONARY } from "../../../dictionary.js";
|
|
5
|
+
import { g as getFormatBoolean } from "../../../../formatters/BooleanFormatter/BooleanFormatter.js";
|
|
5
6
|
import { c as createValidationSchema, a as createValidationFullObject, b as createValidationPartialObject } from "../../../../hook-form/RHFormProvider/schema.js";
|
|
6
7
|
class BooleanFilterHelpers {
|
|
7
8
|
getComponent() {
|
|
@@ -67,7 +68,15 @@ class BooleanFilterHelpers {
|
|
|
67
68
|
* getLabel devuelve las etiquetas para el filtro booleano.
|
|
68
69
|
*/
|
|
69
70
|
getLabels(filter, getLabel, _formatters, _field) {
|
|
70
|
-
const
|
|
71
|
+
const presentationType = filter.field.presentationType;
|
|
72
|
+
const value = filter.operand1;
|
|
73
|
+
let labelOperands;
|
|
74
|
+
if (presentationType && typeof presentationType === "object" && "trueLabel" in presentationType) {
|
|
75
|
+
labelOperands = value ? presentationType.trueLabel : presentationType.falseLabel;
|
|
76
|
+
} else {
|
|
77
|
+
const preset = presentationType ?? "string_true_false";
|
|
78
|
+
labelOperands = getFormatBoolean(preset, value, getLabel);
|
|
79
|
+
}
|
|
71
80
|
return {
|
|
72
81
|
labelField: filter.field.label ?? getLabel(filter.field.dictionaryId),
|
|
73
82
|
labelOperator: getLabel(
|
|
@@ -5,6 +5,19 @@ import { M4LOverridesStyleRules } from '../../@types/augmentations';
|
|
|
5
5
|
import { RHFAutocompleteAsyncProps } from '../hook-form/RHFAutocompleteAsync/types';
|
|
6
6
|
import { RHFSelectProps } from '../hook-form/RHFSelect';
|
|
7
7
|
import { DynamicFilterSlots } from './slots';
|
|
8
|
+
import { PresentationType } from '../formatters/BooleanFormatter/types';
|
|
9
|
+
/**
|
|
10
|
+
* Labels personalizados para valores booleanos
|
|
11
|
+
*/
|
|
12
|
+
export interface BooleanCustomLabels {
|
|
13
|
+
trueLabel: string;
|
|
14
|
+
falseLabel: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Tipo de presentación para campos booleanos en DynamicFilter.
|
|
18
|
+
* Solo incluye las presentaciones de texto del BooleanFormatter más labels personalizados.
|
|
19
|
+
*/
|
|
20
|
+
export type BooleanPresentationType = Extract<PresentationType, 'string_true_false' | 'string_yes_no'> | BooleanCustomLabels;
|
|
8
21
|
export type FieldType = 'number' | 'string' | 'boolean' | 'datetime' | 'select' | 'selectAsync';
|
|
9
22
|
export type OperandType = number | string | boolean | Date | [] | object;
|
|
10
23
|
export type OperandInitialFilterType = number | string | boolean | [] | object;
|
|
@@ -47,6 +60,15 @@ export interface FieldBase<T extends FieldType = FieldType, TOption = any> {
|
|
|
47
60
|
selectOptions?: SelectOptions;
|
|
48
61
|
selectAsyncOptions?: SelectAsyncOptions<TOption>;
|
|
49
62
|
skipColumnValidation?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Tipo de presentación para campos booleanos.
|
|
65
|
+
* Solo aplica cuando type es 'boolean'.
|
|
66
|
+
* - 'string_true_false': "Verdadero" / "Falso" (default)
|
|
67
|
+
* - 'string_yes_no': "Sí" / "No"
|
|
68
|
+
* - { trueLabel: string, falseLabel: string }: Labels personalizados
|
|
69
|
+
* @default 'string_true_false'
|
|
70
|
+
*/
|
|
71
|
+
presentationType?: BooleanPresentationType;
|
|
50
72
|
}
|
|
51
73
|
export interface FieldWithSelectAsync<T extends 'selectAsync', TOption = any> extends FieldBase<T, TOption> {
|
|
52
74
|
selectAsyncOptions: SelectAsyncOptions<TOption>;
|