diff --git a/package-lock.json b/package-lock.json index 1237443..135f64d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@indec/form-builder", - "version": "5.1.0", + "version": "5.1.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@indec/form-builder", - "version": "5.1.0", + "version": "5.1.2", "license": "ISC", "dependencies": { "@storybook/test": "^8.4.7", diff --git a/package.json b/package.json index c68dae8..adc5023 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@indec/form-builder", - "version": "5.1.1", + "version": "5.1.2", "description": "Form builder", "main": "index.js", "private": false, diff --git a/src/components/Checkbox/Checkbox.stories.js b/src/components/Checkbox/Checkbox.stories.js index 1158545..f01a3d4 100644 --- a/src/components/Checkbox/Checkbox.stories.js +++ b/src/components/Checkbox/Checkbox.stories.js @@ -107,7 +107,7 @@ function Template(args) { diff --git a/src/components/DatePicker/DatePicker.js b/src/components/DatePicker/DatePicker.js index caa341d..227a749 100644 --- a/src/components/DatePicker/DatePicker.js +++ b/src/components/DatePicker/DatePicker.js @@ -19,7 +19,7 @@ function DatePicker({ return (
-
+
Click to validate form diff --git a/src/components/DatePicker/DateTimePickerSelector/DatePickerSelector.js b/src/components/DatePicker/DateTimePickerSelector/DatePickerSelector.js index 2c2dbfc..322e5d2 100644 --- a/src/components/DatePicker/DateTimePickerSelector/DatePickerSelector.js +++ b/src/components/DatePicker/DateTimePickerSelector/DatePickerSelector.js @@ -18,7 +18,7 @@ function DateTimePickerSelector({type, onChange, value, label, disabled, placeho locale, dateFormat: [dateTypes.DATE_WITH_HOUR, dateTypes.RANGE_WITH_HOUR].includes(type) ? 'dd/MM/yyyy HH:mm' : 'dd/MM/yyyy', className: - 'fb:w-full fb:px-3 fb:py-2 fb:border fb:border-gray-300 fb:rounded-md focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:border-transparent disabled:fb:bg-gray-100 disabled:fb:cursor-not-allowed', + 'fb:w-full fb:px-3 fb:py-2 fb:border fb:border-gray-300 fb:rounded-md fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-blue-500 fb:focus:border-transparent fb:disabled:bg-gray-100 fb:disabled:cursor-not-allowed', wrapperClassName: 'fb:w-full', ...props }; diff --git a/src/components/FormBuilder/FormBuilder.js b/src/components/FormBuilder/FormBuilder.js index a20dc91..19520e3 100644 --- a/src/components/FormBuilder/FormBuilder.js +++ b/src/components/FormBuilder/FormBuilder.js @@ -88,7 +88,7 @@ function FormBuilder({ name={section.name} render={sectionHelpers => values?.[section.name]?.map((currentSection, index) => ( -
+
handleShowSurvey(currentSection.id, true)} diff --git a/src/components/FormBuilder/SectionHeader/ActionButtons/ActionButtons.js b/src/components/FormBuilder/SectionHeader/ActionButtons/ActionButtons.js index 3aed825..6013c93 100644 --- a/src/components/FormBuilder/SectionHeader/ActionButtons/ActionButtons.js +++ b/src/components/FormBuilder/SectionHeader/ActionButtons/ActionButtons.js @@ -18,7 +18,7 @@ function ActionButtons({ type="button" data-testid="read-only-button" onClick={onView} - className="fb:p-2 fb:rounded-full fb:text-yellow-600 hover:fb:bg-yellow-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-yellow-500 focus:fb:ring-offset-2" + className="fb:p-2 fb:rounded-full fb:text-yellow-600 fb:hover:bg-yellow-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-yellow-500 fb:focus:ring-offset-2" aria-label="View" > @@ -32,7 +32,7 @@ function ActionButtons({ type="button" data-testid="move-up-button" onClick={onMoveUp} - className="fb:p-2 fb:rounded-full fb:text-blue-600 hover:fb:bg-blue-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:ring-offset-2" + className="fb:p-2 fb:rounded-full fb:text-blue-600 fb:hover:bg-blue-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-blue-500 fb:focus:ring-offset-2" aria-label="Move up" > @@ -43,7 +43,7 @@ function ActionButtons({ type="button" data-testid="move-down-button" onClick={onMoveDown} - className="fb:p-2 fb:rounded-full fb:text-blue-600 hover:fb:bg-blue-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:ring-offset-2" + className="fb:p-2 fb:rounded-full fb:text-blue-600 fb:hover:bg-blue-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-blue-500 fb:focus:ring-offset-2" aria-label="Move down" > @@ -56,7 +56,7 @@ function ActionButtons({ type="button" data-testid="edit-button" onClick={onEdit} - className="fb:p-2 fb:rounded-full fb:text-blue-600 hover:fb:bg-blue-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:ring-offset-2" + className="fb:p-2 fb:rounded-full fb:text-blue-600 fb:hover:bg-blue-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-blue-500 fb:focus:ring-offset-2" aria-label="Edit" > @@ -67,7 +67,7 @@ function ActionButtons({ type="button" data-testid="delete-button" onClick={onDelete} - className="fb:p-2 fb:rounded-full fb:text-red-600 hover:fb:bg-red-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-red-500 focus:fb:ring-offset-2" + className="fb:p-2 fb:rounded-full fb:text-red-600 fb:hover:bg-red-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-red-500 fb:focus:ring-offset-2" aria-label="Delete" > diff --git a/src/components/FormBuilder/useFormBuilder.js b/src/components/FormBuilder/useFormBuilder.js index f396f06..36af95b 100644 --- a/src/components/FormBuilder/useFormBuilder.js +++ b/src/components/FormBuilder/useFormBuilder.js @@ -19,6 +19,15 @@ const useFormBuilder = ({sections, initialValues, section}) => { setShowSurvey(sectionId); setReadOnlyMode(readOnly); setPosition(index); + + if (!readOnly) { + setTimeout(() => { + const element = document.getElementById(`section-${sectionId}`); + if (element) { + element.scrollIntoView({behavior: 'smooth', block: 'start'}); + } + }, 100); + } }; const handleOpenModal = (modal, sectionId) => { @@ -41,8 +50,16 @@ const useFormBuilder = ({sections, initialValues, section}) => { const newValues = values; const lastSection = getLastId(values[section.name]); const emptySection = buildQuestions(section)[section.name][0]; - newValues[section.name].push({...emptySection, id: lastSection + 1}); + const newId = lastSection + 1; + newValues[section.name].push({...emptySection, id: newId}); setValues(newValues); + + setTimeout(() => { + const element = document.getElementById(`section-${newId}`); + if (element) { + element.scrollIntoView({behavior: 'smooth', block: 'start'}); + } + }, 100); }; const transformedSection = useMemo(() => { diff --git a/src/components/Modal/Modal.js b/src/components/Modal/Modal.js index 81d4596..f585cb2 100644 --- a/src/components/Modal/Modal.js +++ b/src/components/Modal/Modal.js @@ -25,14 +25,14 @@ function Modal({ />
-
-
+
+
-
+
@@ -57,7 +57,7 @@ function Modal({ type="button" data-testid="accept-button" onClick={() => onAccept(modal)} - className="fb:inline-flex fb:justify-center fb:rounded-xl fb:bg-blue-600 fb:px-6 fb:py-3 fb:text-sm fb:font-medium fb:text-white fb:shadow-lg hover:fb:bg-blue-700 hover:fb:shadow-xl focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-blue-500 focus:fb:ring-offset-2 fb:transition-all fb:duration-200 fb:transform hover:fb:scale-105 sm:fb:w-auto" + className="fb:inline-flex fb:justify-center fb:rounded-xl fb:bg-blue-600 fb:px-6 fb:py-3 fb:text-sm fb:font-medium fb:text-white fb:shadow-lg fb:hover:bg-blue-700 fb:hover:shadow-xl fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-blue-500 fb:focus:ring-offset-2 fb:transition-all fb:duration-200 fb:transform fb:hover:scale-105 fb:sm:w-auto" > {acceptButtonLabel} diff --git a/src/components/NavigationButtons/NavigationButtons.js b/src/components/NavigationButtons/NavigationButtons.js index 60ef48c..63fd0f0 100644 --- a/src/components/NavigationButtons/NavigationButtons.js +++ b/src/components/NavigationButtons/NavigationButtons.js @@ -8,7 +8,7 @@ function NavigationButtons({onPrevious, disablePreviousButton = false, onAddNew, data-testid="back-button" onClick={onPrevious} disabled={disablePreviousButton} - className="fb:flex fb:items-center fb:justify-center fb:px-4 fb:py-2 fb:border fb:border-gray-300 fb:rounded-md fb:text-gray-700 fb:bg-white hover:fb:bg-gray-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-offset-2 focus:fb:ring-blue-500 disabled:fb:opacity-50 disabled:fb:cursor-not-allowed" + className="fb:flex fb:items-center fb:justify-center fb:px-4 fb:py-2 fb:border fb:border-gray-300 fb:rounded-md fb:text-gray-700 fb:bg-white fb:hover:bg-gray-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-offset-2 fb:focus:ring-blue-500 fb:disabled:opacity-50 fb:disabled:cursor-not-allowed" > Anterior @@ -20,7 +20,7 @@ function NavigationButtons({onPrevious, disablePreviousButton = false, onAddNew, type="button" data-testid="add-new" onClick={onAddNew} - className="fb:flex fb:items-center fb:justify-center fb:px-4 fb:py-2 fb:border fb:border-gray-300 fb:rounded-md fb:text-gray-700 fb:bg-white hover:fb:bg-gray-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-offset-2 focus:fb:ring-blue-500" + className="fb:flex fb:items-center fb:justify-center fb:px-4 fb:py-2 fb:border fb:border-gray-300 fb:rounded-md fb:text-gray-700 fb:bg-white fb:hover:bg-gray-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-offset-2 fb:focus:ring-blue-500" > Agregar nuevo @@ -31,7 +31,7 @@ function NavigationButtons({onPrevious, disablePreviousButton = false, onAddNew, type="button" data-testid="interrupt-survey" onClick={onInterrupt} - className="fb:flex fb:items-center fb:justify-center fb:px-4 fb:py-2 fb:border fb:border-red-300 fb:rounded-md fb:text-red-700 fb:bg-white hover:fb:bg-red-50 focus:fb:outline-none focus:fb:ring-2 focus:fb:ring-offset-2 focus:fb:ring-red-500" + className="fb:flex fb:items-center fb:justify-center fb:px-4 fb:py-2 fb:border fb:border-red-300 fb:rounded-md fb:text-red-700 fb:bg-white fb:hover:bg-red-50 fb:focus:outline-none fb:focus:ring-2 fb:focus:ring-offset-2 fb:focus:ring-red-500" > Interrumpir encuesta @@ -41,7 +41,7 @@ function NavigationButtons({onPrevious, disablePreviousButton = false, onAddNew, )} diff --git a/src/components/RadioTable/RadioTable.js b/src/components/RadioTable/RadioTable.js index 7cd60f8..0b9c3d8 100644 --- a/src/components/RadioTable/RadioTable.js +++ b/src/components/RadioTable/RadioTable.js @@ -36,8 +36,8 @@ function RadioTable({options, label, form, field, disabled = false, warnings = { {options.map(option => (
-
-
+
+

form.setFieldValue(`${field.name}.${option.name}`, undefined)} - className="fb:p-1 fb:text-red-600 hover:fb:text-red-800 hover:fb:bg-red-50 fb:rounded fb:transition-colors fb:duration-200" + className="fb:p-1 fb:text-red-600 fb:hover:text-red-800 fb:hover:bg-red-50 fb:rounded fb:transition-colors fb:duration-200" data-testid={`clean-option-${option.id}`} aria-label="Clear selection" > diff --git a/src/components/RadioTable/RadioTable.stories.js b/src/components/RadioTable/RadioTable.stories.js index 0faced8..7a5034f 100644 --- a/src/components/RadioTable/RadioTable.stories.js +++ b/src/components/RadioTable/RadioTable.stories.js @@ -158,7 +158,7 @@ function Template(args) { diff --git a/src/components/Select/Select.js b/src/components/Select/Select.js index 42dd19d..96f32d9 100644 --- a/src/components/Select/Select.js +++ b/src/components/Select/Select.js @@ -46,8 +46,8 @@ function Select({

diff --git a/src/components/TextField/TextField.js b/src/components/TextField/TextField.js index 2cb8cf8..0398058 100644 --- a/src/components/TextField/TextField.js +++ b/src/components/TextField/TextField.js @@ -27,7 +27,7 @@ function TextField({ }; const baseClassName = - 'fb:w-full fb:px-4 fb:py-2 fb:border-2 fb:border-gray-400 fb:rounded-lg fb:bg-white focus:fb:outline-none focus:fb:ring-blue-500 focus:fb:border-blue-500 disabled:fb:bg-gray-50 disabled:fb:opacity-50 disabled:fb:cursor-not-allowed fb:transition-colors fb:duration-200'; + 'fb:w-full fb:px-4 fb:py-2 fb:border-2 fb:border-gray-400 fb:rounded-lg fb:bg-white fb:focus:outline-none fb:focus:ring-blue-500 fb:focus:border-blue-500 fb:disabled:bg-gray-50 fb:disabled:opacity-50 fb:disabled:cursor-not-allowed fb:transition-colors fb:duration-200'; const textareaClassName = `${baseClassName} fb:resize-vertical`; const finalClassName = propClassName ? `${baseClassName} ${propClassName}` : baseClassName; const finalTextareaClassName = propClassName ? `${textareaClassName} ${propClassName}` : textareaClassName; @@ -74,7 +74,7 @@ function TextField({