dmencu 2.2.10 → 2.2.12

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.
@@ -136,7 +136,7 @@ export type LibreDespliegueType = (props: {
136
136
  var LibreDespliegue: LibreDespliegueType
137
137
 
138
138
  export const Button = ({ variant, onClick, disabled, children, className, color, size,
139
- disableElevation, disableFocusRipple, disableRipple,
139
+ disableElevation, disableFocusRipple, disableRipple, type,
140
140
  ...other
141
141
  }: {
142
142
  variant?: string,
@@ -146,11 +146,13 @@ export const Button = ({ variant, onClick, disabled, children, className, color,
146
146
  children: any,
147
147
  className?: string,
148
148
  size?: 'small',
149
+ type?: 'button' | 'submit' | 'reset',
149
150
  disableElevation?: any, disableFocusRipple?: any, disableRipple?: any,
150
151
  } & CommonAttributes) => <button
151
152
  {...other}
152
153
  className={`btn btn${variant == 'contained' ? '' : '-' + (variant == 'outlined' ? 'outline' : variant)}-${(color == 'default' || color == 'inherit' ? 'secondary' : color == 'secondary' ? 'danger' : color) || 'secondary'} ${className || ''} ${size == 'small' ? 'btn-sm' : ''}`}
153
154
  disabled={disabled}
155
+ type={type}
154
156
  onClick={onClick}
155
157
  >{children}</button>;
156
158
 
@@ -199,6 +201,7 @@ const TextField = (props: {
199
201
  // onKeyDown?:(event:KeyboardEvent)=>void // KeyboardEventHandler<HTMLInputElement>
200
202
  onKeyDown?: React.KeyboardEventHandler<HTMLInputElement>
201
203
  }) => <input
204
+ {...props.inputProps}
202
205
  id={props.id}
203
206
  disabled={props.disabled}
204
207
  className={props.className}
@@ -635,6 +638,7 @@ function Campo(props: { disabled: boolean, pregunta: PreguntaSimple | PreguntaCo
635
638
  // }, [props.valor]);
636
639
  const inputProps = {
637
640
  maxLength: longitud,
641
+ enterKeyHint: "next" as const,
638
642
  };
639
643
  const onChange = (nuevoValor: Valor | typeof NO_CAMBIAR__VERIFICAR_SI_ES_NECESARIO) => {
640
644
  var { siguienteVariable } = dispatchByPass(accion_registrar_respuesta, { forPk: props.forPk, variable: pregunta.var_name as IdVariable, respuesta: nuevoValor });
@@ -642,6 +646,20 @@ function Campo(props: { disabled: boolean, pregunta: PreguntaSimple | PreguntaCo
642
646
  (pregunta.especial?.noScroll == true) ? null : enfocarElementoDeVariable(pregunta.especial?.scrollTo ?? siguienteVariable);
643
647
  }
644
648
  };
649
+ const handleSubmit = ({ esBotonConfirmar }: { esBotonConfirmar: boolean }) => {
650
+ debeSaltar = esBotonConfirmar ? true : (saltoAutomatico || conCampoOpciones);
651
+
652
+ var isInputFocused = document.activeElement && (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA');
653
+ if (isInputFocused) {
654
+ if (document.activeElement instanceof HTMLElement) {
655
+ document.activeElement.blur();
656
+ }
657
+ } else {
658
+ var elementoInputVariable = document.getElementById(`var-${pregunta.var_name || ''}`) as HTMLInputElement;
659
+ onChange(elementoInputVariable ? elementoInputVariable.value : NO_CAMBIAR__VERIFICAR_SI_ES_NECESARIO);
660
+ }
661
+ };
662
+
645
663
  var nuestraLongitud = calcularNuestraLongitud(pregunta.longitud || longitud)
646
664
  return <div className="campo" nuestra-longitud={nuestraLongitud} style={props.hidden == 'quitar' ? { display: 'none' } : props.hidden ? { visibility: 'hidden' } : undefined}>
647
665
  {mini ? null : <BotonBorrar
@@ -649,47 +667,51 @@ function Campo(props: { disabled: boolean, pregunta: PreguntaSimple | PreguntaCo
649
667
  variable={pregunta.var_name}
650
668
  forPk={props.forPk}
651
669
  />}
652
- <div className="input-campo">
653
- <TextField
654
- id={`var-${pregunta.var_name || ''}`}
655
- disabled={disabled || pregunta.especial?.gps}
656
- className="variable"
657
- //var-length={pregunta.longitud}
658
- fullWidth={true}
659
- inputProps={inputProps}
660
- type={pregunta.despliegueTipoInput ?? adaptarTipoVarCasillero(pregunta.tipovar)}
661
- onKeyDown={(event: React.KeyboardEvent) => {
662
- var esEnter = (event.key == 'Enter' || event.keyCode == 13)
663
- debeSaltar = esEnter && (saltoAutomatico || conCampoOpciones);
664
- if (esEnter) {
665
- if (event.target instanceof HTMLElement) {
666
- event.target.blur();
670
+ <form
671
+ className="form-campo-wrapper"
672
+ style={{ display: 'contents' }}
673
+ onSubmit={(e) => {
674
+ e.preventDefault();
675
+ handleSubmit({ esBotonConfirmar: false });
676
+ }}
677
+ >
678
+ <div className="input-campo">
679
+ <TextField
680
+ id={`var-${pregunta.var_name || ''}`}
681
+ disabled={disabled || pregunta.especial?.gps}
682
+ className="variable"
683
+ //var-length={pregunta.longitud}
684
+ fullWidth={true}
685
+ inputProps={inputProps}
686
+ type={pregunta.despliegueTipoInput ?? adaptarTipoVarCasillero(pregunta.tipovar)}
687
+ onFocus={(_event) => setEditando(true)}
688
+ onBlur={(_event, valor) => {
689
+ onChange(valor);
690
+ setEditando(false);
691
+ }}
692
+ onKeyDown={(event) => {
693
+ var esEnter = (event.key == 'Enter' || event.keyCode == 13)
694
+ if (esEnter) {
695
+ event.preventDefault();
696
+ handleSubmit({ esBotonConfirmar: false });
667
697
  }
668
- event.preventDefault();
669
- }
670
- }}
671
- onFocus={(_event) => setEditando(true)}
672
- onBlur={(event, valor) => {
673
- if (event?.relatedTarget?.getAttribute('boton-confirmar')) {
674
- debeSaltar = true;
675
- }
676
- onChange(valor);
677
- setEditando(false)
678
- }}
679
- />
680
- </div>
681
- {disabled || pregunta.especial?.gps || mini ? null :
682
- <div className="boton-confirmar-campo">
683
- <Button variant={editando ? "contained" : 'outlined'} size="small" color={editando ? 'primary' : 'default'}
684
- boton-confirmar={pregunta.var_name}
685
- tabIndex={-1}
686
- onClick={() => {
687
- onChange(NO_CAMBIAR__VERIFICAR_SI_ES_NECESARIO);
688
- setEditando(false)
689
698
  }}
690
- ><ICON.Check /></Button>
699
+ />
691
700
  </div>
692
- }
701
+ {disabled || pregunta.especial?.gps || mini ? null :
702
+ <div className="boton-confirmar-campo">
703
+ <Button variant={editando ? "contained" : 'outlined'} size="small" color={editando ? 'primary' : 'default'}
704
+ boton-confirmar={pregunta.var_name}
705
+ tabIndex={-1}
706
+ type="button"
707
+ onClick={(e: React.MouseEvent) => {
708
+ e.preventDefault();
709
+ handleSubmit({ esBotonConfirmar: true });
710
+ }}
711
+ ><ICON.Check /></Button>
712
+ </div>
713
+ }
714
+ </form>
693
715
  </div>
694
716
  }
695
717
 
@@ -1446,7 +1468,7 @@ function BotonFormularioDespliegue(props: { casillero: BotonFormulario, formular
1446
1468
  <DialogTitle>Advertencia: Se perderán datos</DialogTitle>
1447
1469
  <DialogContent>
1448
1470
  <DialogContentText>
1449
- Está por borrar un formulario. Los datos del mismo y todos sus registros asociados se perderán. ¿Desea continuar?
1471
+ {`Está por borrar el formulario ${confirmacionBorrado.defBoton.forPk.formulario} (${estructura.unidades_analisis[estructura.formularios[confirmacionBorrado.defBoton.forPk.formulario].casilleros.unidad_analisis].pk_agregada}: ${confirmacionBorrado.defBoton.num}). Los datos del mismo y todos sus registros asociados se perderán. ¿Desea continuar?`}
1450
1472
  </DialogContentText>
1451
1473
 
1452
1474
  <div style={{ marginTop: '20px', marginBottom: '20px' }}>
@@ -19,7 +19,7 @@ export type LibreDespliegueType = (props: {
19
19
  formulario: Formulario;
20
20
  forPk: ForPk;
21
21
  }) => JSX.Element;
22
- export declare const Button: ({ variant, onClick, disabled, children, className, color, size, disableElevation, disableFocusRipple, disableRipple, ...other }: {
22
+ export declare const Button: ({ variant, onClick, disabled, children, className, color, size, disableElevation, disableFocusRipple, disableRipple, type, ...other }: {
23
23
  variant?: string;
24
24
  color?: ColorValues;
25
25
  onClick?: React.MouseEventHandler<HTMLButtonElement>;
@@ -27,6 +27,7 @@ export declare const Button: ({ variant, onClick, disabled, children, className,
27
27
  children: any;
28
28
  className?: string;
29
29
  size?: "small";
30
+ type?: "button" | "submit" | "reset";
30
31
  disableElevation?: any;
31
32
  disableFocusRipple?: any;
32
33
  disableRipple?: any;