@rsuci/shared-form-components 1.0.26 → 1.0.28

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.
Files changed (51) hide show
  1. package/dist/components/inputs/CheckboxInput.d.ts +1 -0
  2. package/dist/components/inputs/CheckboxInput.d.ts.map +1 -1
  3. package/dist/components/inputs/CheckboxInput.js +7 -3
  4. package/dist/components/inputs/ComboboxInput.d.ts +1 -0
  5. package/dist/components/inputs/ComboboxInput.d.ts.map +1 -1
  6. package/dist/components/inputs/ComboboxInput.js +6 -2
  7. package/dist/components/inputs/DatePicker.d.ts +1 -0
  8. package/dist/components/inputs/DatePicker.d.ts.map +1 -1
  9. package/dist/components/inputs/DatePicker.js +15 -2
  10. package/dist/components/inputs/EmailInput.d.ts +1 -0
  11. package/dist/components/inputs/EmailInput.d.ts.map +1 -1
  12. package/dist/components/inputs/EmailInput.js +15 -2
  13. package/dist/components/inputs/GPSInput.d.ts +1 -0
  14. package/dist/components/inputs/GPSInput.d.ts.map +1 -1
  15. package/dist/components/inputs/GPSInput.js +7 -3
  16. package/dist/components/inputs/GeographicCascadeInput.d.ts +1 -0
  17. package/dist/components/inputs/GeographicCascadeInput.d.ts.map +1 -1
  18. package/dist/components/inputs/GeographicCascadeInput.js +5 -3
  19. package/dist/components/inputs/HourInput.d.ts +1 -0
  20. package/dist/components/inputs/HourInput.d.ts.map +1 -1
  21. package/dist/components/inputs/HourInput.js +15 -2
  22. package/dist/components/inputs/NumberInput.d.ts +1 -0
  23. package/dist/components/inputs/NumberInput.d.ts.map +1 -1
  24. package/dist/components/inputs/NumberInput.js +17 -2
  25. package/dist/components/inputs/PhoneInput.d.ts +1 -0
  26. package/dist/components/inputs/PhoneInput.d.ts.map +1 -1
  27. package/dist/components/inputs/PhoneInput.js +15 -2
  28. package/dist/components/inputs/RadioInput.d.ts +1 -0
  29. package/dist/components/inputs/RadioInput.d.ts.map +1 -1
  30. package/dist/components/inputs/RadioInput.js +6 -2
  31. package/dist/components/inputs/SelectInput.d.ts +1 -0
  32. package/dist/components/inputs/SelectInput.d.ts.map +1 -1
  33. package/dist/components/inputs/SelectInput.js +7 -3
  34. package/dist/components/inputs/StringInput.d.ts +1 -0
  35. package/dist/components/inputs/StringInput.d.ts.map +1 -1
  36. package/dist/components/inputs/StringInput.js +18 -3
  37. package/dist/index.d.ts +1 -0
  38. package/dist/index.d.ts.map +1 -1
  39. package/dist/index.js +5 -0
  40. package/dist/lib/condition-engine.d.ts +19 -0
  41. package/dist/lib/condition-engine.d.ts.map +1 -1
  42. package/dist/lib/condition-engine.js +169 -2
  43. package/dist/lib/utils/date-functions.d.ts +35 -0
  44. package/dist/lib/utils/date-functions.d.ts.map +1 -0
  45. package/dist/lib/utils/date-functions.js +107 -0
  46. package/dist/types/enquete.d.ts +1 -0
  47. package/dist/types/enquete.d.ts.map +1 -1
  48. package/dist/utils/componentStateUtils.d.ts +57 -0
  49. package/dist/utils/componentStateUtils.d.ts.map +1 -0
  50. package/dist/utils/componentStateUtils.js +93 -0
  51. package/package.json +13 -11
@@ -13,6 +13,7 @@ export interface CheckboxInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const CheckboxInput: React.FC<CheckboxInputProps>;
18
19
  export default CheckboxInput;
@@ -1 +1 @@
1
- {"version":3,"file":"CheckboxInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/CheckboxInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,UAAU,CAAA;KAAE,CAAC;IACxD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAmF/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"CheckboxInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/CheckboxInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,UAAU,CAAA;KAAE,CAAC;IACxD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAuF/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -7,8 +7,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { VariableValueConverter } from '../../lib/utils/variableValueConverter';
8
8
  import { AlertCircle } from 'lucide-react';
9
9
  import { applyComponentStyle } from '../../utils/styleUtils';
10
- const CheckboxInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
10
+ import { isComponentReadonly } from '../../utils/componentStateUtils';
11
+ const CheckboxInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
11
12
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
13
+ // Déterminer si le composant est en lecture seule (checkbox ne supporte pas readonly, on utilise disabled)
14
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
15
+ const effectiveDisabled = disabled || isReadonly;
12
16
  // Récupérer les options depuis la propriété valeur OU valeurDefaut (format: "Code1#Designation1|Code2#Designation2")
13
17
  const optionsSource = variable.proprietes?.valeur || variable.valeurDefaut;
14
18
  const options = optionsSource && typeof optionsSource === 'string'
@@ -17,7 +21,7 @@ const CheckboxInput = ({ variable, value, onChange, onBlur, error, disabled }) =
17
21
  // Si pas d'options définies, utiliser le mode simple (boolean)
18
22
  if (options.length === 0) {
19
23
  const booleanValue = Boolean(value);
20
- return (_jsx("div", { style: containerStyle, children: _jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "checkbox", checked: booleanValue, onChange: (e) => onChange(e.target.checked ? 'true' : ''), onBlur: onBlur, disabled: disabled, className: `w-4 h-4 text-green-600 border-gray-300 rounded focus:ring-green-500 ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${disabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: variable.designation })] }) }));
24
+ return (_jsx("div", { style: containerStyle, children: _jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "checkbox", checked: booleanValue, onChange: (e) => onChange(e.target.checked ? 'true' : ''), onBlur: onBlur, disabled: effectiveDisabled, className: `w-4 h-4 text-green-600 border-gray-300 rounded focus:ring-green-500 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${effectiveDisabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: variable.designation })] }) }));
21
25
  }
22
26
  // Mode multiple avec options (format stockage: "CODE1|CODE2|CODE3")
23
27
  const selectedCodes = VariableValueConverter.parse(value, 'CHECKBOX') || [];
@@ -35,6 +39,6 @@ const CheckboxInput = ({ variable, value, onChange, onBlur, error, disabled }) =
35
39
  const serializedValue = VariableValueConverter.serialize(newSelectedCodes, 'CHECKBOX');
36
40
  onChange(serializedValue);
37
41
  };
38
- return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx("div", { className: "space-y-2", children: options.map((option) => (_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "checkbox", checked: selectedCodes.includes(option.code), onChange: (e) => handleOptionChange(option.code, e.target.checked), onBlur: onBlur, disabled: disabled, className: `w-4 h-4 text-green-600 border-gray-300 rounded focus:ring-green-500 ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${disabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: option.designation })] }, option.code))) }), error && (_jsxs("div", { className: "flex items-center space-x-1 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: error })] }))] }));
42
+ return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx("div", { className: "space-y-2", children: options.map((option) => (_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "checkbox", checked: selectedCodes.includes(option.code), onChange: (e) => handleOptionChange(option.code, e.target.checked), onBlur: onBlur, disabled: effectiveDisabled, className: `w-4 h-4 text-green-600 border-gray-300 rounded focus:ring-green-500 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${effectiveDisabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: option.designation })] }, option.code))) }), error && (_jsxs("div", { className: "flex items-center space-x-1 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: error })] }))] }));
39
43
  };
40
44
  export default CheckboxInput;
@@ -13,6 +13,7 @@ export interface ComboboxInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const ComboboxInput: React.FC<ComboboxInputProps>;
18
19
  export default ComboboxInput;
@@ -1 +1 @@
1
- {"version":3,"file":"ComboboxInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/ComboboxInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,UAAU,CAAA;KAAE,CAAC;IACxD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAiD/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"ComboboxInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/ComboboxInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,UAAU,CAAA;KAAE,CAAC;IACxD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CAoD/C,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -6,7 +6,11 @@
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { VariableValueConverter } from '../../lib/utils/variableValueConverter';
8
8
  import { AlertCircle } from 'lucide-react';
9
- const ComboboxInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
9
+ import { isComponentReadonly } from '../../utils/componentStateUtils';
10
+ const ComboboxInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
11
+ // Déterminer si le composant est en lecture seule (select ne supporte pas readonly, on utilise disabled)
12
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
13
+ const effectiveDisabled = disabled || isReadonly;
10
14
  // Récupérer les options depuis la propriété valeur OU valeurDefaut (format: "Code1#Designation1|Code2#Designation2")
11
15
  const optionsSource = variable.proprietes?.valeur || variable.valeurDefaut;
12
16
  const allOptions = optionsSource && typeof optionsSource === 'string'
@@ -16,6 +20,6 @@ const ComboboxInput = ({ variable, value, onChange, onBlur, error, disabled }) =
16
20
  designation: opt.label
17
21
  }));
18
22
  const selectedValue = value || '';
19
- return (_jsxs("div", { className: "space-y-2", children: [_jsxs("select", { value: selectedValue, onChange: (e) => onChange(e.target.value || ''), onBlur: onBlur, disabled: disabled, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}`, children: [_jsx("option", { value: "", children: "S\u00E9lectionner..." }), allOptions.map((option) => (_jsx("option", { value: option.code, children: option.designation }, option.code)))] }), selectedValue && (_jsx("div", { className: "p-2 bg-green-50 border border-green-200 rounded text-sm", children: _jsxs("span", { className: "text-green-800", children: ["S\u00E9lectionn\u00E9: ", allOptions.find(opt => opt.code === selectedValue)?.designation || selectedValue] }) })), error && (_jsxs("div", { className: "flex items-center space-x-1 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: error })] }))] }));
23
+ return (_jsxs("div", { className: "space-y-2", children: [_jsxs("select", { value: selectedValue, onChange: (e) => onChange(e.target.value || ''), onBlur: onBlur, disabled: effectiveDisabled, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${effectiveDisabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}`, children: [_jsx("option", { value: "", children: "S\u00E9lectionner..." }), allOptions.map((option) => (_jsx("option", { value: option.code, children: option.designation }, option.code)))] }), selectedValue && (_jsx("div", { className: "p-2 bg-green-50 border border-green-200 rounded text-sm", children: _jsxs("span", { className: "text-green-800", children: ["S\u00E9lectionn\u00E9: ", allOptions.find(opt => opt.code === selectedValue)?.designation || selectedValue] }) })), error && (_jsxs("div", { className: "flex items-center space-x-1 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: error })] }))] }));
20
24
  };
21
25
  export default ComboboxInput;
@@ -13,6 +13,7 @@ export interface DatePickerProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const DatePicker: React.FC<DatePickerProps>;
18
19
  export default DatePicker;
@@ -1 +1 @@
1
- {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/DatePicker.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC;IAClE,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoDzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"DatePicker.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/DatePicker.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,CAAA;KAAE,CAAC;IAClE,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+DzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -6,9 +6,22 @@
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { VariableValueConverter } from '../../lib/utils/variableValueConverter';
8
8
  import { applyComponentStyle } from '../../utils/styleUtils';
9
- const DatePicker = ({ variable, value, onChange, onBlur, error, disabled }) => {
9
+ import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
10
+ const DatePicker = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
10
11
  const props = variable.proprietes;
11
12
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
13
+ // Déterminer si le composant est en lecture seule
14
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
15
+ // Générer les classes CSS
16
+ const getInputClasses = () => {
17
+ const baseClasses = 'w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900';
18
+ const errorClasses = error ? 'border-red-500' : 'border-gray-300';
19
+ if (disabled)
20
+ return `${baseClasses} ${errorClasses} bg-gray-100 cursor-not-allowed text-gray-500`;
21
+ if (isReadonly)
22
+ return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
23
+ return `${baseClasses} ${errorClasses} bg-white`;
24
+ };
12
25
  // Conversion de la valeur string vers Date pour l'affichage
13
26
  const parsedDate = VariableValueConverter.parse(value, variable.typeCode);
14
27
  // Formatage pour l'input selon le type
@@ -36,6 +49,6 @@ const DatePicker = ({ variable, value, onChange, onBlur, error, disabled }) => {
36
49
  onChange(serializedValue);
37
50
  }
38
51
  };
39
- return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: inputType, value: inputValue, onChange: handleChange, onBlur: onBlur, min: props?.minDate ? VariableValueConverter.serialize(props.minDate, variable.typeCode) : undefined, max: props?.maxDate ? VariableValueConverter.serialize(props.maxDate, variable.typeCode) : undefined, disabled: disabled, style: textStyle, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }) }));
52
+ return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: inputType, value: inputValue, onChange: handleChange, onBlur: onBlur, min: props?.minDate ? VariableValueConverter.serialize(props.minDate, variable.typeCode) : undefined, max: props?.maxDate ? VariableValueConverter.serialize(props.maxDate, variable.typeCode) : undefined, disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
40
53
  };
41
54
  export default DatePicker;
@@ -13,6 +13,7 @@ export interface EmailInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const EmailInput: React.FC<EmailInputProps>;
18
19
  export default EmailInput;
@@ -1 +1 @@
1
- {"version":3,"file":"EmailInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/EmailInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAID,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAwCzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"EmailInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/EmailInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAID,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAmDzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -6,11 +6,24 @@
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { useState } from 'react';
8
8
  import { applyComponentStyle } from '../../utils/styleUtils';
9
+ import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
9
10
  const EMAIL_REGEX = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
10
- const EmailInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
11
+ const EmailInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
11
12
  const stringValue = value || '';
12
13
  const [localError, setLocalError] = useState(null);
13
14
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
15
+ // Déterminer si le composant est en lecture seule
16
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
17
+ // Générer les classes CSS
18
+ const getInputClasses = () => {
19
+ const baseClasses = 'w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900';
20
+ const errorClasses = displayError ? 'border-red-500' : 'border-gray-300';
21
+ if (disabled)
22
+ return `${baseClasses} ${errorClasses} bg-gray-100 cursor-not-allowed text-gray-500`;
23
+ if (isReadonly)
24
+ return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
25
+ return `${baseClasses} ${errorClasses} bg-white`;
26
+ };
14
27
  const handleBlur = () => {
15
28
  if (stringValue && !EMAIL_REGEX.test(stringValue)) {
16
29
  setLocalError('Veuillez saisir une adresse email valide');
@@ -28,6 +41,6 @@ const EmailInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
28
41
  }
29
42
  };
30
43
  const displayError = error || localError;
31
- return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "email", value: stringValue, onChange: handleChange, onBlur: handleBlur, placeholder: variable.proprietes?.placeholder || "exemple@domaine.com", disabled: disabled, style: textStyle, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${displayError ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }) }));
44
+ return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "email", value: stringValue, onChange: handleChange, onBlur: handleBlur, placeholder: variable.proprietes?.placeholder || "exemple@domaine.com", disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
32
45
  };
33
46
  export default EmailInput;
@@ -12,6 +12,7 @@ export interface GPSInputProps {
12
12
  onChange: (value: VariableValue) => void;
13
13
  error?: string;
14
14
  disabled?: boolean;
15
+ isConsultationMode?: boolean;
15
16
  }
16
17
  declare const GPSInput: React.FC<GPSInputProps>;
17
18
  export default GPSInput;
@@ -1 +1 @@
1
- {"version":3,"file":"GPSInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/GPSInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGxE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,CAAC;IACnD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CAuFrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"GPSInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/GPSInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,KAAK,CAAA;KAAE,CAAC;IACnD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,aAAa,CA2FrC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -6,12 +6,16 @@
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { useState } from 'react';
8
8
  import { AlertCircle } from 'lucide-react';
9
- const GPSInput = ({ variable, value, onChange, error, disabled }) => {
9
+ import { isComponentReadonly } from '../../utils/componentStateUtils';
10
+ const GPSInput = ({ variable, value, onChange, error, disabled, isConsultationMode = false }) => {
10
11
  const [isLoading, setIsLoading] = useState(false);
11
12
  const [gpsError, setGpsError] = useState(null);
13
+ // Déterminer si le composant est en lecture seule (GPS button ne supporte pas readonly, on utilise disabled)
14
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
15
+ const effectiveDisabled = disabled || isReadonly;
12
16
  const gpsValue = value;
13
17
  const getCurrentLocation = () => {
14
- if (disabled)
18
+ if (effectiveDisabled)
15
19
  return;
16
20
  setIsLoading(true);
17
21
  setGpsError(null);
@@ -39,6 +43,6 @@ const GPSInput = ({ variable, value, onChange, error, disabled }) => {
39
43
  setIsLoading(false);
40
44
  }, options);
41
45
  };
42
- return (_jsxs("div", { className: "space-y-3", children: [_jsx("button", { type: "button", onClick: getCurrentLocation, disabled: isLoading || disabled, className: `w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors ${isLoading || disabled ? 'opacity-50 cursor-not-allowed' : ''}`, children: isLoading ? 'Localisation en cours...' : 'Obtenir Position GPS' }), gpsValue && (_jsx("div", { className: "p-3 bg-gray-50 rounded-lg text-sm", children: _jsxs("div", { className: "grid grid-cols-2 gap-2", children: [_jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Latitude:" }), _jsx("p", { className: "font-semibold text-gray-900", children: gpsValue.latitude?.toFixed(6) })] }), _jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Longitude:" }), _jsx("p", { className: "font-semibold text-gray-900", children: gpsValue.longitude?.toFixed(6) })] }), _jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Pr\u00E9cision:" }), _jsxs("p", { className: "font-semibold text-gray-900", children: [gpsValue.precision?.toFixed(0), "m"] })] }), _jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Horodatage:" }), _jsx("p", { className: "font-semibold text-gray-900", children: new Date(gpsValue.timestamp).toLocaleTimeString() })] })] }) })), (gpsError || error) && (_jsxs("div", { className: "flex items-center space-x-2 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: gpsError || error })] }))] }));
46
+ return (_jsxs("div", { className: "space-y-3", children: [_jsx("button", { type: "button", onClick: getCurrentLocation, disabled: isLoading || effectiveDisabled, className: `w-full px-4 py-2 bg-blue-600 text-white rounded-lg hover:bg-blue-700 focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors ${isLoading || effectiveDisabled ? 'opacity-50 cursor-not-allowed' : ''}`, children: isLoading ? 'Localisation en cours...' : 'Obtenir Position GPS' }), gpsValue && (_jsx("div", { className: "p-3 bg-gray-50 rounded-lg text-sm", children: _jsxs("div", { className: "grid grid-cols-2 gap-2", children: [_jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Latitude:" }), _jsx("p", { className: "font-semibold text-gray-900", children: gpsValue.latitude?.toFixed(6) })] }), _jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Longitude:" }), _jsx("p", { className: "font-semibold text-gray-900", children: gpsValue.longitude?.toFixed(6) })] }), _jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Pr\u00E9cision:" }), _jsxs("p", { className: "font-semibold text-gray-900", children: [gpsValue.precision?.toFixed(0), "m"] })] }), _jsxs("div", { children: [_jsx("span", { className: "text-gray-700 font-medium", children: "Horodatage:" }), _jsx("p", { className: "font-semibold text-gray-900", children: new Date(gpsValue.timestamp).toLocaleTimeString() })] })] }) })), (gpsError || error) && (_jsxs("div", { className: "flex items-center space-x-2 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: gpsError || error })] }))] }));
43
47
  };
44
48
  export default GPSInput;
@@ -21,6 +21,7 @@ interface GeographicCascadeInputProps {
21
21
  disabled?: boolean;
22
22
  required?: boolean;
23
23
  className?: string;
24
+ isConsultationMode?: boolean;
24
25
  }
25
26
  export declare const GeographicCascadeInput: React.FC<GeographicCascadeInputProps>;
26
27
  export default GeographicCascadeInput;
@@ -1 +1 @@
1
- {"version":3,"file":"GeographicCascadeInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/GeographicCascadeInput.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAUxE;;GAEG;AACH,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD,UAAU,2BAA2B;IACnC,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CAwNxE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
1
+ {"version":3,"file":"GeographicCascadeInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/GeographicCascadeInput.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAmD,MAAM,OAAO,CAAC;AAWxE;;GAEG;AACH,UAAU,SAAS;IACjB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;CACrB;AAWD,UAAU,2BAA2B;IACnC,QAAQ,EAAE,GAAG,CAAC;IACd,KAAK,EAAE,GAAG,CAAC;IACX,QAAQ,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,KAAK,IAAI,CAAC;IAC5C,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,EAAE,CAAC,2BAA2B,CA0NxE,CAAC;AAEF,eAAe,sBAAsB,CAAC"}
@@ -8,7 +8,8 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  import { useEffect, useState, useCallback, useRef } from 'react';
9
9
  import SearchableSelect from './SearchableSelect';
10
10
  import { extractVariableCode, resolveParentValue, getApiEndpoint, getParentLabel, requiresParent } from '../../utils/variableDependencyResolver';
11
- export const GeographicCascadeInput = ({ variable, value, onChange, reponses, disabled = false, required = false, className = '' }) => {
11
+ import { isComponentReadonly } from '../../utils/componentStateUtils';
12
+ export const GeographicCascadeInput = ({ variable, value, onChange, reponses, disabled = false, required = false, className = '', isConsultationMode = false }) => {
12
13
  const [items, setItems] = useState([]);
13
14
  const [loading, setLoading] = useState(false);
14
15
  const [error, setError] = useState(null);
@@ -125,8 +126,9 @@ export const GeographicCascadeInput = ({ variable, value, onChange, reponses, di
125
126
  };
126
127
  onChange(selectDto);
127
128
  };
128
- // 8. Déterminer si le champ est désactivé
129
- const isDisabled = disabled || loading || (needsParent && !parentValue);
129
+ // 8. Déterminer si le champ est désactivé (select ne supporte pas readonly, on utilise disabled)
130
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
131
+ const isDisabled = disabled || isReadonly || loading || (needsParent && !parentValue);
130
132
  // 9. Déterminer le message du placeholder
131
133
  const getPlaceholder = () => {
132
134
  if (loading)
@@ -13,6 +13,7 @@ export interface HourInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const HourInput: React.FC<HourInputProps>;
18
19
  export default HourInput;
@@ -1 +1 @@
1
- {"version":3,"file":"HourInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/HourInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAqCvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"HourInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/HourInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKxE,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IACpD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAgDvC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -6,8 +6,21 @@
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { VariableValueConverter } from '../../lib/utils/variableValueConverter';
8
8
  import { AlertCircle } from 'lucide-react';
9
- const HourInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
9
+ import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
10
+ const HourInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
10
11
  const hourValue = value || '';
12
+ // Déterminer si le composant est en lecture seule
13
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
14
+ // Générer les classes CSS
15
+ const getInputClasses = () => {
16
+ const baseClasses = 'w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900';
17
+ const errorClasses = error ? 'border-red-500' : 'border-gray-300';
18
+ if (disabled)
19
+ return `${baseClasses} ${errorClasses} bg-gray-100 cursor-not-allowed text-gray-500`;
20
+ if (isReadonly)
21
+ return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
22
+ return `${baseClasses} ${errorClasses} bg-white`;
23
+ };
11
24
  const handleChange = (e) => {
12
25
  const newValue = e.target.value;
13
26
  // Validation du format HH:mm
@@ -15,6 +28,6 @@ const HourInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
15
28
  onChange(newValue);
16
29
  }
17
30
  };
18
- return (_jsxs("div", { className: "space-y-2", children: [_jsx("input", { type: "time", value: hourValue, onChange: handleChange, onBlur: onBlur, disabled: disabled, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }), variable.proprietes?.helpText && (_jsx("p", { className: "text-xs text-gray-500", children: variable.proprietes.helpText })), error && (_jsxs("div", { className: "flex items-center space-x-1 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: error })] }))] }));
31
+ return (_jsxs("div", { className: "space-y-2", children: [_jsx("input", { type: "time", value: hourValue, onChange: handleChange, onBlur: onBlur, disabled: disabled, readOnly: isReadonly, className: getInputClasses() }), variable.proprietes?.helpText && (_jsx("p", { className: "text-xs text-gray-500", children: variable.proprietes.helpText })), error && (_jsxs("div", { className: "flex items-center space-x-1 text-red-600 text-sm", children: [_jsx(AlertCircle, { className: "h-4 w-4" }), _jsx("span", { children: error })] }))] }));
19
32
  };
20
33
  export default HourInput;
@@ -14,6 +14,7 @@ export interface NumberInputProps {
14
14
  error?: string;
15
15
  disabled?: boolean;
16
16
  valeurMin?: number;
17
+ isConsultationMode?: boolean;
17
18
  }
18
19
  declare const NumberInput: React.FC<NumberInputProps>;
19
20
  export default NumberInput;
@@ -1 +1 @@
1
- {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/NumberInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,WAAW,CAAA;KAAE,CAAC;IACzD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6D3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"NumberInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/NumberInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,WAAW,CAAA;KAAE,CAAC;IACzD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA0E3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -5,10 +5,13 @@
5
5
  'use client';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { applyComponentStyle } from '../../utils/styleUtils';
8
- const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeurMin }) => {
8
+ import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
9
+ const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeurMin, isConsultationMode = false }) => {
9
10
  const props = variable.proprietes;
10
11
  const numericValue = value || '';
11
12
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
13
+ // Déterminer si le composant est en lecture seule
14
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
12
15
  // Calculer la valeur minimale effective : utiliser valeurMin si définie, sinon props.min
13
16
  const effectiveMin = valeurMin !== undefined ? valeurMin : props?.min;
14
17
  console.log('NumberInput - Contrainte de valeur minimale:', {
@@ -19,6 +22,8 @@ const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeu
19
22
  currentValue: numericValue
20
23
  });
21
24
  const handleChange = (e) => {
25
+ if (isReadonly)
26
+ return;
22
27
  const inputValue = e.target.value;
23
28
  if (inputValue === '') {
24
29
  onChange(null);
@@ -39,6 +44,16 @@ const NumberInput = ({ variable, value, onChange, onBlur, error, disabled, valeu
39
44
  }
40
45
  onChange(isNaN(parsedValue) ? null : parsedValue);
41
46
  };
42
- return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "number", value: numericValue, onChange: handleChange, onBlur: onBlur, min: effectiveMin, max: props?.max, step: props?.step || 1, disabled: disabled, style: textStyle, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }) }));
47
+ // Générer les classes CSS
48
+ const getInputClasses = () => {
49
+ const baseClasses = 'w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900';
50
+ const errorClasses = error ? 'border-red-500' : 'border-gray-300';
51
+ if (disabled)
52
+ return `${baseClasses} ${errorClasses} bg-gray-100 cursor-not-allowed text-gray-500`;
53
+ if (isReadonly)
54
+ return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
55
+ return `${baseClasses} ${errorClasses} bg-white`;
56
+ };
57
+ return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "number", value: numericValue, onChange: handleChange, onBlur: onBlur, min: effectiveMin, max: props?.max, step: props?.step || 1, disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
43
58
  };
44
59
  export default NumberInput;
@@ -13,6 +13,7 @@ export interface PhoneInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const PhoneInput: React.FC<PhoneInputProps>;
18
19
  export default PhoneInput;
@@ -1 +1 @@
1
- {"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/PhoneInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAoBzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"PhoneInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/PhoneInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA+BzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -5,9 +5,22 @@
5
5
  'use client';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { applyComponentStyle } from '../../utils/styleUtils';
8
- const PhoneInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
8
+ import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
9
+ const PhoneInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
9
10
  const stringValue = value || '';
10
11
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
11
- return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "tel", value: stringValue, onChange: (e) => onChange(e.target.value), onBlur: onBlur, placeholder: variable.proprietes?.placeholder || "+225 XX XX XX XX", disabled: disabled, style: textStyle, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }) }));
12
+ // Déterminer si le composant est en lecture seule
13
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
14
+ // Générer les classes CSS
15
+ const getInputClasses = () => {
16
+ const baseClasses = 'w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900';
17
+ const errorClasses = error ? 'border-red-500' : 'border-gray-300';
18
+ if (disabled)
19
+ return `${baseClasses} ${errorClasses} bg-gray-100 cursor-not-allowed text-gray-500`;
20
+ if (isReadonly)
21
+ return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
22
+ return `${baseClasses} ${errorClasses} bg-white`;
23
+ };
24
+ return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "tel", value: stringValue, onChange: (e) => onChange(e.target.value), onBlur: onBlur, placeholder: variable.proprietes?.placeholder || "+225 XX XX XX XX", disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
12
25
  };
13
26
  export default PhoneInput;
@@ -13,6 +13,7 @@ export interface RadioInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const RadioInput: React.FC<RadioInputProps>;
18
19
  export default RadioInput;
@@ -1 +1 @@
1
- {"version":3,"file":"RadioInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/RadioInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAIxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CA4CzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
1
+ {"version":3,"file":"RadioInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/RadioInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKxE,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAgDzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -6,8 +6,12 @@
6
6
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { VariableValueConverter } from '../../lib/utils/variableValueConverter';
8
8
  import { applyComponentStyle } from '../../utils/styleUtils';
9
- const RadioInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
9
+ import { isComponentReadonly } from '../../utils/componentStateUtils';
10
+ const RadioInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
10
11
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
12
+ // Déterminer si le composant est en lecture seule (radio ne supporte pas readonly, on utilise disabled)
13
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
14
+ const effectiveDisabled = disabled || isReadonly;
11
15
  // Récupérer les options depuis la propriété valeur OU valeurDefaut (format: "Code1#Designation1|Code2#Designation2")
12
16
  const optionsSource = variable.proprietes?.valeur || variable.valeurDefaut;
13
17
  const options = typeof optionsSource === 'string'
@@ -16,6 +20,6 @@ const RadioInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
16
20
  const handleChange = (selectedValue) => {
17
21
  onChange(selectedValue || null);
18
22
  };
19
- return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx("div", { className: "space-y-2", children: options.map((option) => (_jsxs("label", { className: "flex items-center space-x-3 cursor-pointer", children: [_jsx("input", { type: "radio", name: `radio-${variable.code}`, value: option.code, checked: value === option.code, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, disabled: disabled, className: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 disabled:opacity-50" }), _jsxs("span", { className: "text-sm text-gray-900", style: textStyle, children: [option.code, " - ", option.designation] })] }, option.code))) }), options.length === 0 && (_jsx("p", { className: "text-sm text-gray-500", children: "Aucune option disponible" })), error && (_jsx("p", { className: "text-sm text-red-600", children: error }))] }));
23
+ return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx("div", { className: "space-y-2", children: options.map((option) => (_jsxs("label", { className: `flex items-center space-x-3 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}`, children: [_jsx("input", { type: "radio", name: `radio-${variable.code}`, value: option.code, checked: value === option.code, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, disabled: effectiveDisabled, className: "h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 disabled:opacity-50" }), _jsxs("span", { className: `text-sm ${effectiveDisabled ? 'text-gray-400' : 'text-gray-900'}`, style: textStyle, children: [option.code, " - ", option.designation] })] }, option.code))) }), options.length === 0 && (_jsx("p", { className: "text-sm text-gray-500", children: "Aucune option disponible" })), error && (_jsx("p", { className: "text-sm text-red-600", children: error }))] }));
20
24
  };
21
25
  export default RadioInput;
@@ -13,6 +13,7 @@ export interface SelectInputProps {
13
13
  onBlur?: () => void;
14
14
  error?: string;
15
15
  disabled?: boolean;
16
+ isConsultationMode?: boolean;
16
17
  }
17
18
  declare const SelectInput: React.FC<SelectInputProps>;
18
19
  export default SelectInput;
@@ -1 +1 @@
1
- {"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/SelectInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAyF3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"SelectInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/SelectInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAMxE,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,OAAO,CAAA;KAAE,CAAC;IACrD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA6F3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -7,8 +7,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
7
7
  import { VariableValueConverter } from '../../lib/utils/variableValueConverter';
8
8
  import SearchableSelect from './SearchableSelect';
9
9
  import { applyComponentStyle } from '../../utils/styleUtils';
10
- const SelectInput = ({ variable, value, onChange, onBlur, error, disabled }) => {
10
+ import { isComponentReadonly } from '../../utils/componentStateUtils';
11
+ const SelectInput = ({ variable, value, onChange, onBlur, error, disabled, isConsultationMode = false }) => {
11
12
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
13
+ // Déterminer si le composant est en lecture seule (select ne supporte pas readonly, on utilise disabled)
14
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
15
+ const effectiveDisabled = disabled || isReadonly;
12
16
  // Récupérer les options depuis la propriété valeur OU valeurDefaut (format: "Code1#Designation1|Code2#Designation2")
13
17
  const optionsSource = variable.proprietes?.valeur || variable.valeurDefaut;
14
18
  const allOptions = optionsSource && typeof optionsSource === 'string'
@@ -20,7 +24,7 @@ const SelectInput = ({ variable, value, onChange, onBlur, error, disabled }) =>
20
24
  const selectedValue = value || '';
21
25
  // Affichage radio pour peu d'options (≤5)
22
26
  if (allOptions.length <= 5) {
23
- return (_jsx("div", { className: "space-y-2", style: containerStyle, children: allOptions.map((option) => (_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "radio", name: variable.code, value: option.code, checked: selectedValue === option.code, onChange: (e) => onChange(e.target.value), onBlur: onBlur, disabled: disabled, className: `w-4 h-4 text-green-600 border-gray-300 focus:ring-green-500 ${disabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${disabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: option.designation })] }, option.code))) }));
27
+ return (_jsx("div", { className: "space-y-2", style: containerStyle, children: allOptions.map((option) => (_jsxs("label", { className: "flex items-center space-x-2 cursor-pointer", children: [_jsx("input", { type: "radio", name: variable.code, value: option.code, checked: selectedValue === option.code, onChange: (e) => onChange(e.target.value), onBlur: onBlur, disabled: effectiveDisabled, className: `w-4 h-4 text-green-600 border-gray-300 focus:ring-green-500 ${effectiveDisabled ? 'cursor-not-allowed' : 'cursor-pointer'}` }), _jsx("span", { className: `text-sm ${effectiveDisabled ? 'text-gray-400' : 'text-gray-700'}`, style: textStyle, children: option.designation })] }, option.code))) }));
24
28
  }
25
29
  // Convertir les options au format SelectOption pour SearchableSelect
26
30
  const selectOptions = allOptions.map(opt => ({
@@ -41,6 +45,6 @@ const SelectInput = ({ variable, value, onChange, onBlur, error, disabled }) =>
41
45
  return `${option.code} - ${option.designation}`;
42
46
  };
43
47
  // Affichage avec SearchableSelect pour beaucoup d'options (>5)
44
- return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx(SearchableSelect, { options: selectOptions, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner...", searchPlaceholder: "Rechercher...", disabled: disabled, required: variable.estObligatoire, error: error, formatOptionLabel: formatOptionLabel, noOptionsMessage: "Aucune option trouv\u00E9e" }), selectedValue && selectedOption && (_jsx("div", { className: "p-2 bg-green-50 border border-green-200 rounded text-sm", children: _jsxs("span", { className: "text-green-800", style: textStyle, children: ["S\u00E9lectionn\u00E9: ", selectedOption.designation] }) }))] }));
48
+ return (_jsxs("div", { className: "space-y-2", style: containerStyle, children: [_jsx(SearchableSelect, { options: selectOptions, value: selectedOption, onChange: handleChange, placeholder: "S\u00E9lectionner...", searchPlaceholder: "Rechercher...", disabled: effectiveDisabled, required: variable.estObligatoire, error: error, formatOptionLabel: formatOptionLabel, noOptionsMessage: "Aucune option trouv\u00E9e" }), selectedValue && selectedOption && (_jsx("div", { className: "p-2 bg-green-50 border border-green-200 rounded text-sm", children: _jsxs("span", { className: "text-green-800", style: textStyle, children: ["S\u00E9lectionn\u00E9: ", selectedOption.designation] }) }))] }));
45
49
  };
46
50
  export default SelectInput;
@@ -15,6 +15,7 @@ export interface StringInputProps {
15
15
  error?: string;
16
16
  disabled?: boolean;
17
17
  services?: FormRendererServices;
18
+ isConsultationMode?: boolean;
18
19
  }
19
20
  declare const StringInput: React.FC<StringInputProps>;
20
21
  export default StringInput;
@@ -1 +1 @@
1
- {"version":3,"file":"StringInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/StringInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAG5D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;IACtD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;CACjC;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CAiD3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"StringInput.d.ts","sourceRoot":"","sources":["../../../src/components/inputs/StringInput.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAI5D,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,kBAAkB,GAAG;QAAE,QAAQ,EAAE,QAAQ,CAAA;KAAE,CAAC;IACtD,KAAK,EAAE,aAAa,CAAC;IACrB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,kBAAkB,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED,QAAA,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,gBAAgB,CA4D3C,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -5,18 +5,33 @@
5
5
  'use client';
6
6
  import { jsx as _jsx } from "react/jsx-runtime";
7
7
  import { applyComponentStyle } from '../../utils/styleUtils';
8
- const StringInput = ({ variable, value, onChange, onBlur, error, disabled, services }) => {
8
+ import { isComponentReadonly, readonlyClasses } from '../../utils/componentStateUtils';
9
+ const StringInput = ({ variable, value, onChange, onBlur, error, disabled, services, isConsultationMode = false }) => {
9
10
  const props = variable.proprietes;
10
11
  const stringValue = value || '';
11
12
  const forceUppercase = services?.forceUppercase ?? false;
12
13
  const { textStyle, containerStyle } = applyComponentStyle(variable.componentStyle);
14
+ // Déterminer si le composant est en lecture seule
15
+ const isReadonly = isComponentReadonly(variable, isConsultationMode);
13
16
  const handleChange = (newValue) => {
17
+ if (isReadonly)
18
+ return;
14
19
  const transformed = forceUppercase ? newValue.toLocaleUpperCase('fr-FR') : newValue;
15
20
  onChange(transformed);
16
21
  };
22
+ // Générer les classes CSS
23
+ const getInputClasses = () => {
24
+ const baseClasses = 'w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900';
25
+ const errorClasses = error ? 'border-red-500' : 'border-gray-300';
26
+ if (disabled)
27
+ return `${baseClasses} ${errorClasses} bg-gray-100 cursor-not-allowed text-gray-500`;
28
+ if (isReadonly)
29
+ return `${baseClasses} ${errorClasses} ${readonlyClasses.readonly}`;
30
+ return `${baseClasses} ${errorClasses} bg-white`;
31
+ };
17
32
  if (props?.displayAs === 'textarea') {
18
- return (_jsx("div", { style: containerStyle, children: _jsx("textarea", { value: stringValue, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, placeholder: props.placeholder, maxLength: props.maxLength, rows: props.rows || 3, disabled: disabled, style: textStyle, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent resize-vertical text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }) }));
33
+ return (_jsx("div", { style: containerStyle, children: _jsx("textarea", { value: stringValue, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, placeholder: props.placeholder, maxLength: props.maxLength, rows: props.rows || 3, disabled: disabled, readOnly: isReadonly, style: textStyle, className: `${getInputClasses()} resize-vertical` }) }));
19
34
  }
20
- return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "text", value: stringValue, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, placeholder: props?.placeholder, maxLength: props?.maxLength, pattern: props?.pattern, disabled: disabled, style: textStyle, className: `w-full px-3 py-2 border rounded-lg focus:ring-2 focus:ring-green-500 focus:border-transparent text-gray-900 ${error ? 'border-red-500' : 'border-gray-300'} ${disabled ? 'bg-gray-100 cursor-not-allowed text-gray-500' : 'bg-white'}` }) }));
35
+ return (_jsx("div", { style: containerStyle, children: _jsx("input", { type: "text", value: stringValue, onChange: (e) => handleChange(e.target.value), onBlur: onBlur, placeholder: props?.placeholder, maxLength: props?.maxLength, pattern: props?.pattern, disabled: disabled, readOnly: isReadonly, style: textStyle, className: getInputClasses() }) }));
21
36
  };
22
37
  export default StringInput;