feat(wizard): autocomplete barrios desde geo_paraguay_full.json [4F]

- BarrioAutocompleteField: carga JSON estático, filtra por depto/ciudad (2.1/2.2), mín 2 chars, máx 10 sugerencias, texto libre permitido, teclado (↑↓ Enter Escape), ARIA listbox
- QuestionRenderer: branch code === '2.3' → BarrioAutocompleteField; prop answers? pasado desde WizardForm para contexto depto/ciudad
- globals.css: clases .barrio-autocomplete-* (wrapper, list, item, item--active)
- Incluye public/data/geo_paraguay_full.json (202 KB, sin commitear hasta ahora)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
markosbenitez
2026-06-26 19:41:55 -03:00
parent dbcc60ad95
commit 3ec5da0e54
5 changed files with 8881 additions and 2 deletions

View File

@@ -1,15 +1,17 @@
'use client'
import type { AnswerValue, Question, QuestionOption } from '@/lib/form-engine.types'
import type { AnswerValue, FormAnswers, Question, QuestionOption } from '@/lib/form-engine.types'
import { RadioGroup } from './widgets/radio-group'
import { CheckboxGroup } from './widgets/checkbox-group'
import { TextAreaField } from './widgets/text-area-field'
import { TextShortField } from './widgets/text-short-field'
import { BarrioAutocompleteField } from './widgets/barrio-autocomplete-field'
interface QuestionRendererProps {
question: Question
value: AnswerValue
onChange: (value: AnswerValue) => void
error?: string
answers?: FormAnswers
}
const YES_NO_OPTIONS: QuestionOption[] = [
@@ -17,7 +19,7 @@ const YES_NO_OPTIONS: QuestionOption[] = [
{ value: 'false', label: 'No' },
]
export function QuestionRenderer({ question, value, onChange, error }: QuestionRendererProps) {
export function QuestionRenderer({ question, value, onChange, error, answers }: QuestionRendererProps) {
const { code, type, prompt, required, max_select, options } = question
const legend = (
<>
@@ -70,6 +72,20 @@ export function QuestionRenderer({ question, value, onChange, error }: QuestionR
}
if (type === 'text_short') {
if (code === '2.3') {
return (
<BarrioAutocompleteField
name={code}
label={legend}
value={(value as string) ?? ''}
required={required}
departamento={(answers?.['2.1:default'] as string) ?? null}
ciudad={(answers?.['2.2:default'] as string) ?? null}
onChange={onChange}
error={error}
/>
)
}
return (
<TextShortField
name={code}