@axdspub/axiom-ui-forms 0.2.4 → 0.2.6

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 (42) hide show
  1. package/library/axiom-ui-forms.d.ts +17 -29
  2. package/library/esm/_virtual/index2.js +2 -2
  3. package/library/esm/_virtual/index3.js +2 -2
  4. package/library/esm/_virtual/index8.js +2 -2
  5. package/library/esm/_virtual/index9.js +2 -2
  6. package/library/esm/node_modules/ajv/dist/compile/codegen/index.js +1 -1
  7. package/library/esm/node_modules/ajv/dist/compile/validate/index.js +1 -1
  8. package/library/esm/node_modules/ajv/dist/vocabularies/applicator/index.js +1 -1
  9. package/library/esm/node_modules/ajv/dist/vocabularies/format/index.js +1 -1
  10. package/library/esm/src/Form/Components/FieldCreator.js +16 -21
  11. package/library/esm/src/Form/Components/FieldCreator.js.map +1 -1
  12. package/library/esm/src/Form/Components/FieldLabel.js +6 -6
  13. package/library/esm/src/Form/Components/FieldLabel.js.map +1 -1
  14. package/library/esm/src/Form/Components/Inputs/Date.js +8 -12
  15. package/library/esm/src/Form/Components/Inputs/Date.js.map +1 -1
  16. package/library/esm/src/Form/Components/Inputs/GeoJSON.js +49 -48
  17. package/library/esm/src/Form/Components/Inputs/GeoJSON.js.map +1 -1
  18. package/library/esm/src/Form/Components/Inputs/Geometry.js +81 -59
  19. package/library/esm/src/Form/Components/Inputs/Geometry.js.map +1 -1
  20. package/library/esm/src/Form/Components/Inputs/Object.js +3 -3
  21. package/library/esm/src/Form/Components/Inputs/Object.js.map +1 -1
  22. package/library/esm/src/Form/Creator/FormContextProvider.js +17 -0
  23. package/library/esm/src/Form/Creator/FormContextProvider.js.map +1 -0
  24. package/library/esm/src/Form/Creator/FormCreator.js +39 -22
  25. package/library/esm/src/Form/Creator/FormCreator.js.map +1 -1
  26. package/library/esm/src/Form/Creator/FormFields.js +2 -2
  27. package/library/esm/src/Form/Creator/FormFields.js.map +1 -1
  28. package/library/esm/src/Form/Creator/FormSection.js +4 -4
  29. package/library/esm/src/Form/Creator/FormSection.js.map +1 -1
  30. package/library/esm/src/Form/Creator/FormSectionContextProvider.js +23 -0
  31. package/library/esm/src/Form/Creator/FormSectionContextProvider.js.map +1 -0
  32. package/library/esm/src/Form/Creator/Page.js +23 -34
  33. package/library/esm/src/Form/Creator/Page.js.map +1 -1
  34. package/library/esm/src/Form/Creator/Wizard.js +38 -48
  35. package/library/esm/src/Form/Creator/Wizard.js.map +1 -1
  36. package/library/esm/src/Form/helpers.js +25 -8
  37. package/library/esm/src/Form/helpers.js.map +1 -1
  38. package/library/esm/src/Form/resolveRefs.js.map +1 -1
  39. package/library/esm/src/Form/schemaToFormHelpers.js +45 -25
  40. package/library/esm/src/Form/schemaToFormHelpers.js.map +1 -1
  41. package/library/esm/src/library.js +1 -1
  42. package/package.json +14 -7
@@ -1 +1 @@
1
- {"version":3,"file":"Geometry.js","sources":["../../../../../../src/Form/Components/Inputs/Geometry.tsx"],"sourcesContent":["import { Button, TextArea } from '@axdspub/axiom-ui-utilities'\nimport FieldLabel from '@/Form/Components/FieldLabel'\nimport { type IFieldInputProps } from '@/Form/Creator/FormCreatorTypes'\n\nimport { EMapShape, type IMap, type IMapDrawEvent, type IStyleableMapProps } from '@axdspub/axiom-maps'\nimport { OpenLayersMap as Map } from '@axdspub/axiom-maps/library/openlayers'\nimport { type Feature, type GeoJSON } from 'geojson'\nimport React, { useEffect, useState, type ReactElement } from 'react'\nimport { TrashIcon, SquareIcon, BorderSolidIcon, DrawingPinFilledIcon } from '@radix-ui/react-icons'\n\n/*\nList of coordinates for testing. Around Anchorage.\n61.44480592425796, -150.3785489314675\n61.26059021199541, -150.7356022485971\n61.05235501381105, -150.61435734866856\n61.06014246374005, -149.9221328461051\n61.441517540302925, -149.16102284579276\n61.44480592425796, -150.3785489314675\n*/\n\nconst calculateCenterFromGeoJSON = (geo: GeoJSON | undefined): { lat: number, lon: number, zoom: number } => {\n if (!geo || !('features' in geo) || !Array.isArray(geo.features) || geo.features.length === 0) {\n return { lat: 61.2181, lon: -149.9003, zoom: 8 } // Default to Anchorage\n }\n\n const feature = geo.features[0]\n if (!feature?.geometry) {\n return { lat: 61.2181, lon: -149.9003, zoom: 8 }\n }\n\n const geometry = feature.geometry\n let coordinates: GeoJSON.Position[] = []\n\n switch (geometry.type) {\n case 'Polygon':\n coordinates = geometry.coordinates[0] // Get first ring (ignore holes)\n break\n case 'LineString':\n coordinates = geometry.coordinates\n break\n case 'Point':\n coordinates = [geometry.coordinates]\n break\n default:\n return { lat: 61.2181, lon: -149.9003, zoom: 8 }\n }\n\n if (!Array.isArray(coordinates) || coordinates.length === 0) {\n return { lat: 61.2181, lon: -149.9003, zoom: 8 }\n }\n\n // Calculate bounds\n let minLat = Infinity\n let maxLat = -Infinity\n let minLon = Infinity\n let maxLon = -Infinity\n let sumLat = 0\n let sumLon = 0\n let count = 0\n\n coordinates.forEach((coord: GeoJSON.Position) => {\n const [lon, lat] = coord\n minLat = Math.min(minLat, lat)\n maxLat = Math.max(maxLat, lat)\n minLon = Math.min(minLon, lon)\n maxLon = Math.max(maxLon, lon)\n sumLat += lat\n sumLon += lon\n count++\n })\n\n // Calculate center\n const centerLat = sumLat / count\n const centerLon = sumLon / count\n\n // Calculate zoom level based on bounds\n const latDiff = maxLat - minLat\n const lonDiff = maxLon - minLon\n const maxDiff = Math.max(latDiff, lonDiff)\n\n // Adjust zoom based on the size of the shape\n let zoom = 8 // default zoom\n if (maxDiff < 0.1) zoom = 12 // very small shape\n else if (maxDiff < 0.5) zoom = 10 // small shape\n else if (maxDiff < 1) zoom = 9 // medium shape\n else if (maxDiff < 2) zoom = 8 // large shape\n else if (maxDiff < 5) zoom = 7 // very large shape\n else zoom = 6 // huge shape\n\n return {\n lat: centerLat,\n lon: centerLon,\n zoom\n }\n}\n\nexport const GeoJSONInput = ({ field, onChange, value }: IFieldInputProps): ReactElement => {\n console.log('INITIAL VALUE', value)\n const initialGeoJSON = value as unknown as GeoJSON\n const initialMapConfig = calculateCenterFromGeoJSON(initialGeoJSON)\n const [currentDrawType, setCurrentDrawType] = useState<EMapShape>(EMapShape.polygon)\n const [isDrawing, setIsDrawing] = useState<boolean>(false)\n\n const MAP_CONFIG: IStyleableMapProps = {\n baseLayerKey: 'hybrid',\n height: '500px',\n width: '100%',\n style: {\n left: '0px',\n top: '0px',\n right: '0px',\n bottom: '0px',\n padding: '0'\n },\n center: { lat: initialMapConfig.lat, lon: initialMapConfig.lon },\n zoom: initialMapConfig.zoom,\n tools: {\n draw: {\n shape: currentDrawType,\n enabled: true\n }\n }\n }\n\n const [map, setMapState] = useState<IMap | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [geojson, setGeojson] = useState<Feature | undefined>(() => {\n if (!value) return undefined\n return value as unknown as Feature\n })\n const [showGeoJSONInput] = useState<boolean>(false) // For debugging purposes\n const [coordinates, setCoordinates] = useState<string>(() => {\n if (!value) return ''\n const geoValue = value as unknown as GeoJSON.FeatureCollection\n if (geoValue?.type === 'FeatureCollection' && Array.isArray(geoValue.features) && geoValue.features.length > 0) {\n const feature = geoValue.features[0]\n const geometry = feature?.geometry\n if (!geometry) return ''\n\n if (geometry.type === 'Polygon') {\n const coords = geometry.coordinates[0]\n return coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'LineString') {\n const coords = geometry.coordinates\n return coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'Point') {\n const coords = geometry.coordinates\n return `${coords[1]}, ${coords[0]}`\n }\n }\n return ''\n })\n\n const getValue = (): string => {\n return geojson !== undefined && geojson !== null\n ? typeof geojson === 'object'\n ? JSON.stringify(geojson, null, 2)\n : String(geojson)\n : ''\n }\n\n const createGeoJSONFromCoordinates = (coordString: string, forceType?: EMapShape): Feature | undefined => {\n if (!coordString.trim()) {\n setError(undefined)\n return undefined\n }\n\n try {\n const points = coordString\n .split('\\n')\n .map(line => line.trim())\n .filter(line => line.length > 0)\n .map(line => {\n const [lat, lon] = line.split(',').map(coord => parseFloat(coord.trim()))\n if (isNaN(lat) || isNaN(lon)) {\n throw new Error('Invalid coordinate format')\n }\n return [lon, lat]\n })\n\n if (points.length === 0) {\n throw new Error('No valid coordinates found')\n }\n\n // Single point\n if (points.length === 1) {\n return {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Point',\n coordinates: points[0]\n }\n }\n }\n\n // For polygon or line, based on forceType or number of points\n if (forceType === EMapShape.polygon || (!forceType && points.length >= 3)) {\n // Close the polygon by adding the first point at the end if not already closed\n if (JSON.stringify(points[0]) !== JSON.stringify(points[points.length - 1])) {\n points.push(points[0])\n }\n return {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Polygon',\n coordinates: [points]\n }\n }\n }\n\n // LineString\n return {\n\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'LineString',\n coordinates: points\n }\n\n }\n } catch (e) {\n setError('Invalid coordinate format. Use \"lat, lon\" format, one per line')\n return undefined\n }\n }\n\n const [showShapeTypeButtons, setShowShapeTypeButtons] = useState<boolean>(() => {\n // Show buttons if initial value has 2+ coordinates\n if (!value) return false\n const geoValue = value as unknown as GeoJSON.FeatureCollection\n if (geoValue?.type === 'FeatureCollection' && Array.isArray(geoValue.features) && geoValue.features.length > 0) {\n const feature = geoValue.features[0]\n const geometry = feature?.geometry\n if (!geometry) return false\n\n if (geometry.type === 'Polygon' || geometry.type === 'LineString') {\n return geometry.coordinates.length >= 2\n }\n }\n return false\n })\n\n const updateCoordinatesFromGeoJSON = (geo: GeoJSON | undefined): void => {\n if (!geo || geo.type !== 'FeatureCollection' || !geo.features?.[0]?.geometry) return\n\n const feature = geo.features[0]\n const geometry = feature.geometry\n let newCoords = ''\n\n if (geometry.type === 'Polygon') {\n const coords = geometry.coordinates[0]\n newCoords = coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'LineString') {\n const coords = geometry.coordinates\n newCoords = coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'Point') {\n const coords = geometry.coordinates\n newCoords = `${coords[1]}, ${coords[0]}`\n }\n\n setCoordinates(newCoords)\n setShowShapeTypeButtons(shouldShowShapeButtons(newCoords))\n }\n\n useEffect(() => {\n if (map === undefined) return\n\n map.onDrawComplete((e: IMapDrawEvent) => {\n console.log('draw complete', e)\n setGeojson(e.data?.geojson.features?.[0])\n updateCoordinatesFromGeoJSON(e.data?.geojson)\n setIsDrawing(false)\n // Disable drawing after shape is completed\n map.disableDraw(currentDrawType)\n })\n\n // On modify drawing\n map.onDrawUpdate((e: IMapDrawEvent) => {\n console.log('draw update', e)\n setGeojson(e.data?.geojson?.features?.[0])\n updateCoordinatesFromGeoJSON(e.data?.geojson)\n })\n }, [map])\n\n useEffect(() => {\n if (geojson !== undefined) {\n onChange(geojson.geometry)\n }\n }, [geojson])\n\n const hasValidShape = (geo: GeoJSON | undefined): boolean => {\n return geo !== undefined &&\n 'features' in geo &&\n Array.isArray(geo.features) &&\n geo.features.length > 0\n }\n\n const clearShape = (): void => {\n setGeojson(undefined)\n onChange(undefined)\n setCoordinates('')\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n map.enableDraw(currentDrawType) // Re-enable drawing when shape is cleared\n setIsDrawing(true)\n }\n }\n\n const handleDrawTypeChange = (shapeType: EMapShape): void => {\n if (map) {\n // Clear existing shape if any\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n setGeojson(undefined)\n onChange(undefined)\n setCoordinates('')\n setShowShapeTypeButtons(false)\n setCurrentDrawType(shapeType)\n map.enableDraw(shapeType)\n setIsDrawing(true)\n }\n }\n\n const shouldShowShapeButtons = (coords: string): boolean => {\n const validLines = coords.trim().split('\\n')\n .map(line => line.trim())\n .filter(line => line.length > 0)\n .filter(line => {\n try {\n const [lat, lon] = line.split(',').map(coord => parseFloat(coord.trim()))\n return !isNaN(lat) && !isNaN(lon)\n } catch {\n return false\n }\n })\n return validLines.length >= 3\n }\n\n const handleCoordinatesChange = (e: string | undefined): void => {\n const newCoords = e ?? ''\n setCoordinates(newCoords)\n setShowShapeTypeButtons(shouldShowShapeButtons(newCoords))\n\n try {\n const newGeoJSON = createGeoJSONFromCoordinates(newCoords)\n if (newGeoJSON) {\n setGeojson(newGeoJSON)\n setError(undefined)\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n map.setDrawGeojson({ type: 'FeatureCollection', features: [newGeoJSON] } satisfies GeoJSON.FeatureCollection)\n map.disableDraw(currentDrawType) // Disable drawing when coordinates are entered\n }\n } else {\n setGeojson(undefined)\n onChange(undefined)\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n }\n }\n } catch (e) {\n setError('Invalid coordinate format')\n }\n }\n\n // Reload shape on the map\n useEffect(() => {\n if (map === undefined) return\n\n if (geojson !== undefined && 'features' in geojson) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: [geojson]\n } satisfies GeoJSON.FeatureCollection)\n map.disableDraw(currentDrawType) // Disable drawing when there's a shape\n setIsDrawing(false)\n // Update coordinates display and shape type buttons\n updateCoordinatesFromGeoJSON(geojson)\n setShowShapeTypeButtons(shouldShowShapeButtons(coordinates))\n } else {\n map.enableDraw(currentDrawType)\n setIsDrawing(true)\n }\n }, [map, currentDrawType])\n\n const applyShapeType = (shapeType: EMapShape): void => {\n const newGeoJSON = createGeoJSONFromCoordinates(coordinates, shapeType)\n if (newGeoJSON) {\n setGeojson(newGeoJSON)\n setError(undefined)\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n map.setDrawGeojson({ type: 'FeatureCollection', features: [newGeoJSON] } satisfies GeoJSON.FeatureCollection)\n }\n }\n // Don't hide the buttons anymore\n // setShowShapeTypeButtons(false)\n }\n\n return <div className=\"relative\">\n <FieldLabel {...field} />\n <div className=\"absolute z-20 top-12 right-4 flex flex-col gap-2\">\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={() => { handleDrawTypeChange(EMapShape.polygon) }}\n className={`p-2 rounded-lg shadow-lg ${\n currentDrawType === EMapShape.polygon && isDrawing\n ? 'bg-white hover:bg-gray-50 ring-2 ring-yellow-200 shadow-[0_0_10px_rgba(253,224,71,0.5)]'\n : 'bg-gray-100 hover:bg-gray-50'\n } text-black w-10 h-10 flex items-center justify-center`}\n >\n <SquareIcon className=\"w-5 h-5 rotate-45\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Draw Polygon\n </span>\n </Button>\n </div>\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={() => { handleDrawTypeChange(EMapShape.linestring) }}\n className={`p-2 rounded-lg shadow-lg ${\n currentDrawType === EMapShape.linestring && isDrawing\n ? 'bg-white hover:bg-gray-50 ring-2 ring-yellow-200 shadow-[0_0_10px_rgba(253,224,71,0.5)]'\n : 'bg-gray-100 hover:bg-gray-50'\n } text-black w-10 h-10 flex items-center justify-center`}\n >\n <BorderSolidIcon className=\"w-5 h-5\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Draw Path\n </span>\n </Button>\n </div>\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={() => { handleDrawTypeChange(EMapShape.point) }}\n className={`p-2 rounded-lg shadow-lg ${\n currentDrawType === EMapShape.point && isDrawing\n ? 'bg-white hover:bg-gray-50 ring-2 ring-yellow-200 shadow-[0_0_10px_rgba(253,224,71,0.5)]'\n : 'bg-gray-100 hover:bg-gray-50'\n } text-black w-10 h-10 flex items-center justify-center`}\n >\n <DrawingPinFilledIcon className=\"w-5 h-5\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Draw Point\n </span>\n </Button>\n </div>\n {hasValidShape(geojson) && (\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={clearShape}\n className=\"p-2 rounded-lg shadow-lg bg-red-500 hover:bg-red-600 text-white w-10 h-10 flex items-center justify-center\"\n >\n <TrashIcon className=\"w-5 h-5\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Clear Shape\n </span>\n </Button>\n </div>\n )}\n </div>\n <Map {...MAP_CONFIG} setState={setMapState} />\n <div className=\"mt-4\">\n <div className=\"flex justify-between items-center mb-2\">\n <span>Draw on map or enter coordinates <pre className=\"inline-block text-sm\">(latitude, longitude)</pre></span>\n {showShapeTypeButtons && (\n <div className=\"flex gap-2\">\n <Button\n onClick={() => { applyShapeType(EMapShape.linestring) }}\n className=\"px-4 py-1 bg-white hover:bg-gray-50 text-black rounded-lg shadow-sm border border-gray-200 text-sm flex items-center gap-2\"\n >\n <BorderSolidIcon className=\"w-4 h-4\" />\n Create Path\n </Button>\n <Button\n onClick={() => { applyShapeType(EMapShape.polygon) }}\n className=\"px-4 py-1 bg-white hover:bg-gray-50 text-black rounded-lg shadow-sm border border-gray-200 text-sm flex items-center gap-2\"\n >\n <SquareIcon className=\"w-4 h-4 rotate-45\" />\n Create Polygon\n </Button>\n </div>\n )}\n </div>\n <TextArea\n error={error}\n className='min-h-[100px] bg-slate-50 rounded-lg shadow-inner'\n id={`${field.id}-coordinates`}\n testId={`${field.id}-coordinates`}\n value={coordinates}\n onChange={handleCoordinatesChange}\n placeholder=\"61.2181, -149.9003&#10;61.2182, -149.9004&#10;61.2183, -149.9005\"\n />\n </div>\n {showGeoJSONInput && <TextArea\n error={error}\n className='min-h-[500px] bg-slate-50 rounded-lg shadow-inner'\n id={field.id}\n testId={field.id}\n label={<FieldLabel {...field} />}\n value={getValue()}\n onChange={(e) => {\n try {\n JSON.parse(e ?? '')\n onChange(JSON.parse(e ?? ''))\n setError(undefined)\n } catch (e) {\n setError('Invalid JSON')\n }\n }} />}\n </div>\n}\n\nexport default GeoJSONInput\n"],"names":["React","Map"],"mappings":";;;;;;;;AAUA;;;;;;;;AAQE;AAEF,IAAM,0BAA0B,GAAG,UAAC,GAAwB,EAAA;AAC1D,IAAA,IAAI,CAAC,GAAG,IAAI,EAAE,UAAU,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,GAAG,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE;AAC7F,QAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE,CAAA;;IAGlD,IAAM,OAAO,GAAG,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/B,IAAI,EAAC,OAAO,KAAP,IAAA,IAAA,OAAO,KAAP,MAAA,GAAA,MAAA,GAAA,OAAO,CAAE,QAAQ,CAAA,EAAE;AACtB,QAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,EAAE;;AAGlD,IAAA,IAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ;IACjC,IAAI,WAAW,GAAuB,EAAE;AAExC,IAAA,QAAQ,QAAQ,CAAC,IAAI;AACnB,QAAA,KAAK,SAAS;YACZ,WAAW,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;YACrC;AACF,QAAA,KAAK,YAAY;AACf,YAAA,WAAW,GAAG,QAAQ,CAAC,WAAW;YAClC;AACF,QAAA,KAAK,OAAO;AACV,YAAA,WAAW,GAAG,CAAC,QAAQ,CAAC,WAAW,CAAC;YACpC;AACF,QAAA;AACE,YAAA,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,I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C9E,CACE;AACL,QAAA,gBAAgB,IAAIA,cAAC,CAAA,aAAA,CAAA,QAAQ,IAC5B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,mDAAmD,EAC7D,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,MAAM,EAAE,KAAK,CAAC,EAAE,EAChB,KAAK,EAAEA,cAAC,CAAA,aAAA,CAAA,UAAU,eAAK,KAAK,CAAA,CAAI,EAChC,KAAK,EAAE,QAAQ,EAAE,EACjB,QAAQ,EAAE,UAAC,CAAC,EAAA;AACV,gBAAA,IAAI;oBACF,IAAI,CAAC,KAAK,CAAC,CAAC,KAAA,IAAA,IAAD,CAAC,KAAA,KAAA,CAAA,GAAD,CAAC,GAAI,EAAE,CAAC;AACnB,oBAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAA,IAAA,IAAD,CAAC,KAAA,KAAA,CAAA,GAAD,CAAC,GAAI,EAAE,CAAC,CAAC;oBAC7B,QAAQ,CAAC,SAAS,CAAC;;gBACnB,OAAO,CAAC,EAAE;oBACV,QAAQ,CAAC,cAAc,CAAC;;aAE3B,EAAA,CAAI,CACH;AACV;;;;"}
1
+ {"version":3,"file":"Geometry.js","sources":["../../../../../../src/Form/Components/Inputs/Geometry.tsx"],"sourcesContent":["import { Button, TextArea } from '@axdspub/axiom-ui-utilities'\nimport FieldLabel from '@/Form/Components/FieldLabel'\nimport { type IFieldInputProps } from '@/Form/Creator/FormCreatorTypes'\n\nimport { EMapShape, type IMap, type IMapDrawEvent, type IStyleableMapProps } from '@axdspub/axiom-maps'\nimport { OpenLayersMap as Map } from '@axdspub/axiom-maps/library/openlayers'\nimport { type Feature, type GeoJSON } from 'geojson'\nimport React, { useEffect, useState, type ReactElement } from 'react'\nimport { TrashIcon, SquareIcon, BorderSolidIcon, DrawingPinFilledIcon } from '@radix-ui/react-icons'\n\n/*\nList of coordinates for testing. Around Anchorage.\n61.44480592425796, -150.3785489314675\n61.26059021199541, -150.7356022485971\n61.05235501381105, -150.61435734866856\n61.06014246374005, -149.9221328461051\n61.441517540302925, -149.16102284579276\n61.44480592425796, -150.3785489314675\n*/\n\nconst calculateCenterFromGeoJSON = (geo: GeoJSON | undefined): { lat: number, lon: number, zoom: number } => {\n if (!geo || !('features' in geo) || !Array.isArray(geo.features) || geo.features.length === 0) {\n return { lat: 61.2181, lon: -149.9003, zoom: 8 } // Default to Anchorage\n }\n\n const feature = geo.features[0]\n if (!feature?.geometry) {\n return { lat: 61.2181, lon: -149.9003, zoom: 8 }\n }\n\n const geometry = feature.geometry\n let coordinates: GeoJSON.Position[] = []\n\n switch (geometry.type) {\n case 'Polygon':\n coordinates = geometry.coordinates[0] // Get first ring (ignore holes)\n break\n case 'LineString':\n coordinates = geometry.coordinates\n break\n case 'Point':\n coordinates = [geometry.coordinates]\n break\n default:\n return { lat: 61.2181, lon: -149.9003, zoom: 8 }\n }\n\n if (!Array.isArray(coordinates) || coordinates.length === 0) {\n return { lat: 61.2181, lon: -149.9003, zoom: 8 }\n }\n\n // Calculate bounds\n let minLat = Infinity\n let maxLat = -Infinity\n let minLon = Infinity\n let maxLon = -Infinity\n let sumLat = 0\n let sumLon = 0\n let count = 0\n\n coordinates.forEach((coord: GeoJSON.Position) => {\n const [lon, lat] = coord\n minLat = Math.min(minLat, lat)\n maxLat = Math.max(maxLat, lat)\n minLon = Math.min(minLon, lon)\n maxLon = Math.max(maxLon, lon)\n sumLat += lat\n sumLon += lon\n count++\n })\n\n // Calculate center\n const centerLat = sumLat / count\n const centerLon = sumLon / count\n\n // Calculate zoom level based on bounds\n const latDiff = maxLat - minLat\n const lonDiff = maxLon - minLon\n const maxDiff = Math.max(latDiff, lonDiff)\n\n // Adjust zoom based on the size of the shape\n let zoom = 8 // default zoom\n if (maxDiff < 0.1) zoom = 12 // very small shape\n else if (maxDiff < 0.5) zoom = 10 // small shape\n else if (maxDiff < 1) zoom = 9 // medium shape\n else if (maxDiff < 2) zoom = 8 // large shape\n else if (maxDiff < 5) zoom = 7 // very large shape\n else zoom = 6 // huge shape\n\n return {\n lat: centerLat,\n lon: centerLon,\n zoom\n }\n}\n\nexport const GeoJSONInput = ({ field, onChange, value }: IFieldInputProps): ReactElement => {\n console.log('INITIAL VALUE', value)\n const initialGeoJSON = value as unknown as GeoJSON\n const initialMapConfig = calculateCenterFromGeoJSON(initialGeoJSON)\n const [currentDrawType, setCurrentDrawType] = useState<EMapShape>(EMapShape.polygon)\n const [isDrawing, setIsDrawing] = useState<boolean>(false)\n\n // Draw settings\n const drawEnabled = field.settings?.drawEnabled !== false // Default to true if not specified\n const drawPolygonEnabled = field.settings?.drawPolygonEnabled !== false && drawEnabled // Default to true if drawEnabled and not specified\n const drawPathEnabled = field.settings?.drawPathEnabled !== false && drawEnabled // Default to true if drawEnabled and not specified\n const drawPointEnabled = field.settings?.drawPointEnabled !== false && drawEnabled // Default to true if drawEnabled and not specified\n const showCoordinateInput = field.settings?.showCoordinateInput !== false // Default to true if not specified\n\n // Set initial draw type based on enabled tools\n useEffect(() => {\n if (drawPolygonEnabled) {\n setCurrentDrawType(EMapShape.polygon)\n } else if (drawPathEnabled) {\n setCurrentDrawType(EMapShape.linestring)\n } else if (drawPointEnabled) {\n setCurrentDrawType(EMapShape.point)\n }\n }, [drawPolygonEnabled, drawPathEnabled, drawPointEnabled])\n\n const MAP_CONFIG: IStyleableMapProps = {\n baseLayerKey: 'hybrid',\n height: '500px',\n width: '100%',\n style: {\n left: '0px',\n top: '0px',\n right: '0px',\n bottom: '0px',\n padding: '0'\n },\n center: { lat: initialMapConfig.lat, lon: initialMapConfig.lon },\n zoom: initialMapConfig.zoom,\n tools: {\n draw: {\n shape: currentDrawType,\n enabled: drawEnabled && (drawPolygonEnabled || drawPathEnabled || drawPointEnabled)\n }\n }\n }\n\n const [map, setMapState] = useState<IMap | undefined>(undefined)\n const [error, setError] = useState<string | undefined>(undefined)\n const [geojson, setGeojson] = useState<Feature | undefined>(() => {\n if (!value) return undefined\n return value as unknown as Feature\n })\n const [showGeoJSONInput] = useState<boolean>(false) // For debugging purposes\n const [coordinates, setCoordinates] = useState<string>(() => {\n if (!value) return ''\n const geoValue = value as unknown as GeoJSON.FeatureCollection\n if (geoValue?.type === 'FeatureCollection' && Array.isArray(geoValue.features) && geoValue.features.length > 0) {\n const feature = geoValue.features[0]\n const geometry = feature?.geometry\n if (!geometry) return ''\n\n if (geometry.type === 'Polygon') {\n const coords = geometry.coordinates[0]\n return coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'LineString') {\n const coords = geometry.coordinates\n return coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'Point') {\n const coords = geometry.coordinates\n return `${coords[1]}, ${coords[0]}`\n }\n }\n return ''\n })\n\n const getValue = (): string => {\n return geojson !== undefined && geojson !== null\n ? typeof geojson === 'object'\n ? JSON.stringify(geojson, null, 2)\n : String(geojson)\n : ''\n }\n\n const createGeoJSONFromCoordinates = (coordString: string, forceType?: EMapShape): Feature | undefined => {\n if (!coordString.trim()) {\n setError(undefined)\n return undefined\n }\n\n try {\n const points = coordString\n .split('\\n')\n .map(line => line.trim())\n .filter(line => line.length > 0)\n .map(line => {\n const [lat, lon] = line.split(',').map(coord => parseFloat(coord.trim()))\n if (isNaN(lat) || isNaN(lon)) {\n throw new Error('Invalid coordinate format')\n }\n return [lon, lat]\n })\n\n if (points.length === 0) {\n throw new Error('No valid coordinates found')\n }\n\n // Single point\n if (points.length === 1) {\n return {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Point',\n coordinates: points[0]\n }\n }\n }\n\n // For polygon or line, based on forceType or number of points\n if (forceType === EMapShape.polygon || (!forceType && points.length >= 3)) {\n // Close the polygon by adding the first point at the end if not already closed\n if (JSON.stringify(points[0]) !== JSON.stringify(points[points.length - 1])) {\n points.push(points[0])\n }\n return {\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'Polygon',\n coordinates: [points]\n }\n }\n }\n\n // LineString\n return {\n\n type: 'Feature',\n properties: {},\n geometry: {\n type: 'LineString',\n coordinates: points\n }\n\n }\n } catch (e) {\n setError('Invalid coordinate format. Use \"lat, lon\" format, one per line')\n return undefined\n }\n }\n\n const [showShapeTypeButtons, setShowShapeTypeButtons] = useState<boolean>(() => {\n // Show buttons if initial value has 2+ coordinates\n if (!value) return false\n const geoValue = value as unknown as GeoJSON.FeatureCollection\n if (geoValue?.type === 'FeatureCollection' && Array.isArray(geoValue.features) && geoValue.features.length > 0) {\n const feature = geoValue.features[0]\n const geometry = feature?.geometry\n if (!geometry) return false\n\n if (geometry.type === 'Polygon' || geometry.type === 'LineString') {\n return geometry.coordinates.length >= 2\n }\n }\n return false\n })\n\n const updateCoordinatesFromGeoJSON = (geo: GeoJSON | undefined): void => {\n if (!geo || geo.type !== 'FeatureCollection' || !geo.features?.[0]?.geometry) return\n\n const feature = geo.features[0]\n const geometry = feature.geometry\n let newCoords = ''\n\n if (geometry.type === 'Polygon') {\n const coords = geometry.coordinates[0]\n newCoords = coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'LineString') {\n const coords = geometry.coordinates\n newCoords = coords.map((pos: GeoJSON.Position) => `${pos[1]}, ${pos[0]}`).join('\\n')\n } else if (geometry.type === 'Point') {\n const coords = geometry.coordinates\n newCoords = `${coords[1]}, ${coords[0]}`\n }\n\n setCoordinates(newCoords)\n setShowShapeTypeButtons(shouldShowShapeButtons(newCoords))\n }\n\n // i think this has to stay - we're basically staying in sync with dom element outside of react\n useEffect(() => {\n if (map === undefined) return\n\n map.onDrawComplete((e: IMapDrawEvent) => {\n console.log('draw complete', e)\n setGeojson(e.data?.geojson.features?.[0])\n updateCoordinatesFromGeoJSON(e.data?.geojson)\n setIsDrawing(false)\n // Disable drawing after shape is completed\n map.disableDraw(currentDrawType)\n })\n\n // On modify drawing\n map.onDrawUpdate((e: IMapDrawEvent) => {\n console.log('draw update', e)\n setGeojson(e.data?.geojson?.features?.[0])\n updateCoordinatesFromGeoJSON(e.data?.geojson)\n })\n }, [map])\n\n // can we get rid of this?\n useEffect(() => {\n if (geojson !== undefined) {\n onChange(geojson.geometry)\n }\n }, [geojson])\n\n const hasValidShape = (geo: GeoJSON | undefined): boolean => {\n return geo !== undefined &&\n 'features' in geo &&\n Array.isArray(geo.features) &&\n geo.features.length > 0\n }\n\n const clearShape = (): void => {\n setGeojson(undefined)\n onChange(undefined)\n setCoordinates('')\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n map.enableDraw(currentDrawType) // Re-enable drawing when shape is cleared\n setIsDrawing(true)\n }\n }\n\n const handleDrawTypeChange = (shapeType: EMapShape): void => {\n if (map) {\n // Clear existing shape if any\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n setGeojson(undefined)\n onChange(undefined)\n setCoordinates('')\n setShowShapeTypeButtons(false)\n setCurrentDrawType(shapeType)\n map.enableDraw(shapeType)\n setIsDrawing(true)\n }\n }\n\n const shouldShowShapeButtons = (coords: string): boolean => {\n const validLines = coords.trim().split('\\n')\n .map(line => line.trim())\n .filter(line => line.length > 0)\n .filter(line => {\n try {\n const [lat, lon] = line.split(',').map(coord => parseFloat(coord.trim()))\n return !isNaN(lat) && !isNaN(lon)\n } catch {\n return false\n }\n })\n return validLines.length >= 3\n }\n\n const handleCoordinatesChange = (e: string | undefined): void => {\n const newCoords = e ?? ''\n setCoordinates(newCoords)\n setShowShapeTypeButtons(shouldShowShapeButtons(newCoords))\n\n try {\n const newGeoJSON = createGeoJSONFromCoordinates(newCoords)\n if (newGeoJSON) {\n setGeojson(newGeoJSON)\n setError(undefined)\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n map.setDrawGeojson({ type: 'FeatureCollection', features: [newGeoJSON] } satisfies GeoJSON.FeatureCollection)\n map.disableDraw(currentDrawType) // Disable drawing when coordinates are entered\n }\n } else {\n setGeojson(undefined)\n onChange(undefined)\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n }\n }\n } catch (e) {\n setError('Invalid coordinate format')\n }\n }\n\n // Reload shape on the map\n useEffect(() => {\n if (map === undefined) return\n\n if (geojson !== undefined && 'features' in geojson) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: [geojson]\n } satisfies GeoJSON.FeatureCollection)\n map.disableDraw(currentDrawType) // Disable drawing when there's a shape\n setIsDrawing(false)\n // Update coordinates display and shape type buttons\n updateCoordinatesFromGeoJSON(geojson)\n setShowShapeTypeButtons(shouldShowShapeButtons(coordinates))\n } else {\n map.enableDraw(currentDrawType)\n setIsDrawing(true)\n }\n }, [map, currentDrawType])\n\n const applyShapeType = (shapeType: EMapShape): void => {\n const newGeoJSON = createGeoJSONFromCoordinates(coordinates, shapeType)\n if (newGeoJSON) {\n setGeojson(newGeoJSON)\n setError(undefined)\n if (map) {\n map.setDrawGeojson({\n type: 'FeatureCollection',\n features: []\n })\n map.setDrawGeojson({ type: 'FeatureCollection', features: [newGeoJSON] } satisfies GeoJSON.FeatureCollection)\n }\n }\n // Don't hide the buttons anymore\n // setShowShapeTypeButtons(false)\n }\n\n return <div>\n <FieldLabel {...field} />\n <div className=\"relative\">\n {drawEnabled && (drawPolygonEnabled || drawPathEnabled || drawPointEnabled) && (\n <div className=\"absolute z-20 top-12 right-4 flex flex-col gap-2\">\n {drawPolygonEnabled && (\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={() => { handleDrawTypeChange(EMapShape.polygon) }}\n className={`p-2 rounded-lg shadow-lg ${\n currentDrawType === EMapShape.polygon && isDrawing\n ? 'bg-white hover:bg-gray-50 ring-2 ring-yellow-200 shadow-[0_0_10px_rgba(253,224,71,0.5)]'\n : 'bg-gray-100 hover:bg-gray-50'\n } text-black w-10 h-10 flex items-center justify-center`}\n >\n <SquareIcon className=\"w-5 h-5 rotate-45\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Draw Polygon\n </span>\n </Button>\n </div>\n )}\n {drawPathEnabled && (\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={() => { handleDrawTypeChange(EMapShape.linestring) }}\n className={`p-2 rounded-lg shadow-lg ${\n currentDrawType === EMapShape.linestring && isDrawing\n ? 'bg-white hover:bg-gray-50 ring-2 ring-yellow-200 shadow-[0_0_10px_rgba(253,224,71,0.5)]'\n : 'bg-gray-100 hover:bg-gray-50'\n } text-black w-10 h-10 flex items-center justify-center`}\n >\n <BorderSolidIcon className=\"w-5 h-5\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Draw Path\n </span>\n </Button>\n </div>\n )}\n {drawPointEnabled && (\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={() => { handleDrawTypeChange(EMapShape.point) }}\n className={`p-2 rounded-lg shadow-lg ${\n currentDrawType === EMapShape.point && isDrawing\n ? 'bg-white hover:bg-gray-50 ring-2 ring-yellow-200 shadow-[0_0_10px_rgba(253,224,71,0.5)]'\n : 'bg-gray-100 hover:bg-gray-50'\n } text-black w-10 h-10 flex items-center justify-center`}\n >\n <DrawingPinFilledIcon className=\"w-5 h-5\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Draw Point\n </span>\n </Button>\n </div>\n )}\n {hasValidShape(geojson) && (\n <div className=\"tooltip-container relative group\">\n <Button\n onClick={clearShape}\n className=\"p-2 rounded-lg shadow-lg bg-red-500 hover:bg-red-600 text-white w-10 h-10 flex items-center justify-center\"\n >\n <TrashIcon className=\"w-5 h-5\" />\n <span className=\"tooltip absolute right-full mr-2 px-2 py-1 bg-gray-800 text-white text-sm rounded whitespace-nowrap opacity-0 group-hover:opacity-100 pointer-events-none\">\n Clear Shape\n </span>\n </Button>\n </div>\n )}\n </div>\n )}\n <Map {...MAP_CONFIG} setState={setMapState} />\n {showCoordinateInput && (\n <div className=\"mt-4\">\n <div className=\"flex justify-between items-center mb-2\">\n <span>Draw on map or enter coordinates <pre className=\"inline-block text-sm\">(latitude, longitude)</pre></span>\n {drawEnabled && showShapeTypeButtons && (\n <div className=\"flex gap-2\">\n {drawPathEnabled && (\n <Button\n onClick={() => { applyShapeType(EMapShape.linestring) }}\n className=\"px-4 py-1 bg-white hover:bg-gray-50 text-black rounded-lg shadow-sm border border-gray-200 text-sm flex items-center gap-2\"\n >\n <BorderSolidIcon className=\"w-4 h-4\" />\n Create Path\n </Button>\n )}\n {drawPolygonEnabled && (\n <Button\n onClick={() => { applyShapeType(EMapShape.polygon) }}\n className=\"px-4 py-1 bg-white hover:bg-gray-50 text-black rounded-lg shadow-sm border border-gray-200 text-sm flex items-center gap-2\"\n >\n <SquareIcon className=\"w-4 h-4 rotate-45\" />\n Create Polygon\n </Button>\n )}\n </div>\n )}\n </div>\n <TextArea\n error={error}\n className='min-h-[100px] bg-slate-50 rounded-lg shadow-inner'\n id={`${field.id}-coordinates`}\n testId={`${field.id}-coordinates`}\n value={coordinates}\n onChange={handleCoordinatesChange}\n placeholder=\"61.2181, -149.9003&#10;61.2182, -149.9004&#10;61.2183, -149.9005\"\n />\n </div>\n )}\n {showGeoJSONInput && <TextArea\n error={error}\n className='min-h-[500px] bg-slate-50 rounded-lg shadow-inner'\n id={field.id}\n testId={field.id}\n label={<FieldLabel {...field} />}\n value={getValue()}\n onChange={(e) => {\n try {\n JSON.parse(e ?? '')\n onChange(JSON.parse(e ?? ''))\n setError(undefined)\n } catch (e) {\n setError('Invalid JSON')\n }\n }} />}\n </div>\n </div>\n}\n\nexport default GeoJSONInput\n"],"names":["React","Map"],"mappings":";;;;;;;;AAUA;;;;;;;;AAQE;AAEF,IAAM,0BAA0B,GAAG,UAAC,GAAwB,EAAA;AAC1D,IAAA,IAAI,CAAC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,IAAIA,cAAC,CAAA,aAAA,CAAA,QAAQ,IAC5B,KAAK,EAAE,KAAK,EACZ,SAAS,EAAC,mDAAmD,EAC7D,EAAE,EAAE,KAAK,CAAC,EAAE,EACZ,MAAM,EAAE,KAAK,CAAC,EAAE,EAChB,KAAK,EAAEA,cAAC,CAAA,aAAA,CAAA,UAAU,eAAK,KAAK,CAAA,CAAI,EAChC,KAAK,EAAE,QAAQ,EAAE,EACjB,QAAQ,EAAE,UAAC,CAAC,EAAA;AACV,oBAAA,IAAI;wBACF,IAAI,CAAC,KAAK,CAAC,CAAC,KAAA,IAAA,IAAD,CAAC,KAAA,KAAA,CAAA,GAAD,CAAC,GAAI,EAAE,CAAC;AACnB,wBAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,KAAA,IAAA,IAAD,CAAC,KAAA,KAAA,CAAA,GAAD,CAAC,GAAI,EAAE,CAAC,CAAC;wBAC7B,QAAQ,CAAC,SAAS,CAAC;;oBACnB,OAAO,CAAC,EAAE;wBACV,QAAQ,CAAC,cAAc,CAAC;;iBAE3B,EAAA,CAAI,CACH,CACF;AACR;;;;"}
@@ -5,7 +5,7 @@ import { utils as index$1 } from '../../../../node_modules/@axdspub/axiom-ui-uti
5
5
  import React__default from 'react';
6
6
 
7
7
  var ObjectInput = function (_a) {
8
- var form = _a.form, field = _a.field, onChange = _a.onChange, value = _a.value, formValueState = _a.formValueState;
8
+ var field = _a.field, onChange = _a.onChange, value = _a.value;
9
9
  var initialValue = (typeof value === 'object' ? value !== null && value !== void 0 ? value : {} : {});
10
10
  if (field.type === 'object' && field.fields !== undefined) {
11
11
  var cl = "".concat(field.layout === 'horizontal' ? "flex flex-row gap-4 ".concat(field.label !== undefined ? 'px-0' : '') : 'flex flex-col gap-4');
@@ -17,7 +17,7 @@ var ObjectInput = function (_a) {
17
17
  React__default.createElement("div", { className: "p-4 bg-slate-100 ".concat(cl) }, field.fields.map(function (childField) {
18
18
  var _a;
19
19
  var key = ((_a = field.path) !== null && _a !== void 0 ? _a : [field.id]).concat(childField.id).join('.');
20
- return (React__default.createElement(FieldCreator, { formValueState: formValueState, onChange: function (e) {
20
+ return (React__default.createElement(FieldCreator, { onChange: function (e) {
21
21
  if (childField.type === 'object' && childField.skip_path === true) {
22
22
  onChange(e);
23
23
  }
@@ -28,7 +28,7 @@ var ObjectInput = function (_a) {
28
28
  }, className: index$1.makeClassName({
29
29
  defaultClassName: 'p-0',
30
30
  className: fc_1
31
- }), value: initialValue[childField.id], field: childField, form: form, key: key }));
31
+ }), value: initialValue[childField.id], field: childField, key: key }));
32
32
  }))));
33
33
  }
34
34
  return React__default.createElement("p", null,
@@ -1 +1 @@
1
- {"version":3,"file":"Object.js","sources":["../../../../../../src/Form/Components/Inputs/Object.tsx"],"sourcesContent":["import FieldCreator from '@/Form/Components/FieldCreator'\nimport FieldLabel from '@/Form/Components/FieldLabel'\nimport { type ICompositeValueType, type IFieldInputProps } from '@/Form/Creator/FormCreatorTypes'\nimport { utils } from '@axdspub/axiom-ui-utilities'\nimport React, { type ReactElement } from 'react'\n\nconst ObjectInput = ({ form, field, onChange, value, formValueState }: IFieldInputProps): ReactElement => {\n const initialValue = (typeof value === 'object' ? value ?? {} : {}) as ICompositeValueType\n if (field.type === 'object' && field.fields !== undefined) {\n const cl = `${field.layout === 'horizontal' ? `flex flex-row gap-4 ${field.label !== undefined ? 'px-0' : ''}` : 'flex flex-col gap-4'}`\n const fc = field.layout === 'horizontal' ? 'flex-1' : ''\n return (\n <div>\n {\n field.label !== undefined\n ? <FieldLabel {...field} />\n : null\n }\n <div className={`p-4 bg-slate-100 ${cl}`}>\n {\n field.fields.map((childField) => {\n const key = (field.path ?? [field.id]).concat(childField.id).join('.')\n\n return (\n <FieldCreator\n formValueState={formValueState}\n onChange={(e) => {\n if (childField.type === 'object' && childField.skip_path === true) {\n onChange(e)\n } else {\n initialValue[childField.id] = e\n onChange({ ...initialValue })\n }\n }}\n className={utils.makeClassName({\n defaultClassName: 'p-0',\n className: fc\n })}\n value={initialValue[childField.id]}\n field={childField}\n form={form}\n key={key}\n />\n )\n })\n }\n </div>\n </div>\n )\n }\n return <p>Field config for {field.id} is missing &apos;fields&apos;</p>\n}\n\nexport default ObjectInput\n"],"names":["React","utils"],"mappings":";;;;;;AAMM,IAAA,WAAW,GAAG,UAAC,EAAkE,EAAA;AAAhE,IAAA,IAAA,IAAI,GAAA,EAAA,CAAA,IAAA,EAAE,KAAK,GAAA,EAAA,CAAA,KAAA,EAAE,QAAQ,GAAA,EAAA,CAAA,QAAA,EAAE,KAAK,GAAA,EAAA,CAAA,KAAA,EAAE,cAAc,GAAA,EAAA,CAAA,cAAA;IACjE,IAAM,YAAY,IAAI,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,aAAL,KAAK,KAAA,MAAA,GAAL,KAAK,GAAI,EAAE,GAAG,EAAE,CAAwB;AAC1F,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;AACzD,QAAA,IAAM,EAAE,GAAG,EAAG,CAAA,MAAA,CAAA,KAAK,CAAC,MAAM,KAAK,YAAY,GAAG,uBAAA,CAAA,MAAA,CAAwB,KAAK,CAAC,KAAK,KAAK,SAAS,GAAG,MAAM,GAAG,EAAE,CAAE,GAAG,qBAAqB,CAAE;AACzI,QAAA,IAAM,IAAE,GAAG,KAAK,CAAC,MAAM,KAAK,YAAY,GAAG,QAAQ,GAAG,EAAE;AACxD,QAAA,QACIA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA;YAEE,KAAK,CAAC,KAAK,KAAK;AACd,kBAAEA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,QAAA,CAAA,EAAA,EAAK,KAAK,CAAI;AAC3B,kBAAE,IAAI;AAEV,YAAAA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,oBAAqB,CAAA,MAAA,CAAA,EAAE,CAAE,EAAA,EAEvC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,UAAU,EAAA;;gBAC1B,IAAM,GAAG,GAAG,CAAC,CAAA,EAAA,GAAA,KAAK,CAAC,IAAI,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC;gBAEtE,QACEA,cAAC,CAAA,aAAA,CAAA,YAAY,EACX,EAAA,cAAc,EAAE,cAAc,EAC9B,QAAQ,EAAE,UAAC,CAAC,EAAA;AACV,wBAAA,IAAI,UAAU,CAAC,IAAI,KAAK,QAAQ,IAAI,UAAU,CAAC,SAAS,KAAK,IAAI,EAAE;4BACjE,QAAQ,CAAC,CAAC,CAAC;;6BACN;AACL,4BAAA,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC;4BAC/B,QAAQ,CAAA,QAAA,CAAA,EAAA,EAAM,YAAY,CAAA,CAAG;;AAEjC,qBAAC,EACD,SAAS,EAAEC,OAAK,CAAC,aAAa,CAAC;AAC7B,wBAAA,gBAAgB,EAAE,KAAK;AACvB,wBAAA,SAAS,EAAE;qBACZ,CAAC,EACF,KAAK,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,EAClC,KAAK,EAAE,UAAU,EACjB,IAAI,EAAE,IAAI,EACV,GAAG,EAAE,GAAG,EACR,CAAA;AAEN,aAAC,CAAC,CAEA,CACA;;IAGV,OAAOD,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA;;AAAqB,QAAA,KAAK,CAAC,EAAE;+BAAmC;AACzE;;;;"}
1
+ {"version":3,"file":"Object.js","sources":["../../../../../../src/Form/Components/Inputs/Object.tsx"],"sourcesContent":["import FieldCreator from '@/Form/Components/FieldCreator'\nimport FieldLabel from '@/Form/Components/FieldLabel'\nimport { type ICompositeValueType, type IFieldInputProps } from '@/Form/Creator/FormCreatorTypes'\nimport { utils } from '@axdspub/axiom-ui-utilities'\nimport React, { type ReactElement } from 'react'\n\nconst ObjectInput = ({ field, onChange, value }: IFieldInputProps): ReactElement => {\n const initialValue = (typeof value === 'object' ? value ?? {} : {}) as ICompositeValueType\n if (field.type === 'object' && field.fields !== undefined) {\n const cl = `${field.layout === 'horizontal' ? `flex flex-row gap-4 ${field.label !== undefined ? 'px-0' : ''}` : 'flex flex-col gap-4'}`\n const fc = field.layout === 'horizontal' ? 'flex-1' : ''\n return (\n <div>\n {\n field.label !== undefined\n ? <FieldLabel {...field} />\n : null\n }\n <div className={`p-4 bg-slate-100 ${cl}`}>\n {\n field.fields.map((childField) => {\n const key = (field.path ?? [field.id]).concat(childField.id).join('.')\n\n return (\n <FieldCreator\n onChange={(e) => {\n if (childField.type === 'object' && childField.skip_path === true) {\n onChange(e)\n } else {\n initialValue[childField.id] = e\n onChange({ ...initialValue })\n }\n }}\n className={utils.makeClassName({\n defaultClassName: 'p-0',\n className: fc\n })}\n value={initialValue[childField.id]}\n field={childField}\n key={key}\n />\n )\n })\n }\n </div>\n </div>\n )\n }\n return <p>Field config for {field.id} is missing &apos;fields&apos;</p>\n}\n\nexport default ObjectInput\n"],"names":["React","utils"],"mappings":";;;;;;AAMM,IAAA,WAAW,GAAG,UAAC,EAA4C,EAAA;AAA1C,IAAA,IAAA,KAAK,WAAA,EAAE,QAAQ,GAAA,EAAA,CAAA,QAAA,EAAE,KAAK,GAAA,EAAA,CAAA,KAAA;IAC3C,IAAM,YAAY,IAAI,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,aAAL,KAAK,KAAA,MAAA,GAAL,KAAK,GAAI,EAAE,GAAG,EAAE,CAAwB;AAC1F,IAAA,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE;AACzD,QAAA,IAAM,EAAE,GAAG,EAAG,CAAA,MAAA,CAAA,KAAK,CAAC,MAAM,KAAK,YAAY,GAAG,uB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,SAAS,EAAE;AACZ,qBAAA,CAAC,EACF,KAAK,EAAE,YAAY,CAAC,UAAU,CAAC,EAAE,CAAC,EAClC,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,GAAG,EAAA,CACR;AAEN,aAAC,CAAC,CAEA,CACA;;IAGV,OAAOD,cAAA,CAAA,aAAA,CAAA,GAAA,EAAA,IAAA;;AAAqB,QAAA,KAAK,CAAC,EAAE;+BAAmC;AACzE;;;;"}
@@ -0,0 +1,17 @@
1
+ import '../../../node_modules/tslib/tslib.es6.js';
2
+ import React__default, { createContext } from 'react';
3
+
4
+ var FormContext = createContext({
5
+ form: { id: '', label: '' },
6
+ formValues: {},
7
+ setFormValues: function (v) { }
8
+ });
9
+ var useFormContext = function () {
10
+ var ctx = React__default.useContext(FormContext);
11
+ if (!ctx)
12
+ throw new Error('useFormSectionContext must be used within FormSectionContextProvider');
13
+ return ctx;
14
+ };
15
+
16
+ export { FormContext, useFormContext };
17
+ //# sourceMappingURL=FormContextProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormContextProvider.js","sources":["../../../../../src/Form/Creator/FormContextProvider.tsx"],"sourcesContent":["import { type IFieldInputProps, type IForm, type IFormValues } from '@/Form/Creator/FormCreatorTypes'\nimport { type JSONSchema6 } from 'json-schema'\nimport React, { createContext, type ReactElement, type PropsWithChildren } from 'react'\n\nexport interface IFormContextValue {\n form: IForm\n formValues: IFormValues\n setFormValues: (v: IFormValues) => void\n inputOverrides?: Record<string, React.FC<IFieldInputProps>>\n urlNavigable?: boolean\n schema?: JSONSchema6\n}\n\nexport const FormContext = createContext<IFormContextValue>({\n form: { id: '', label: '' },\n formValues: {},\n setFormValues: (v) => {}\n})\n\nexport const FormContextProvider = ({ children, ...props }: IFormContextValue & PropsWithChildren): ReactElement => {\n return (\n <FormContext.Provider value={{ ...props }}>\n {children}\n </FormContext.Provider>\n )\n}\n\nexport const useFormContext = (): IFormContextValue => {\n const ctx = React.useContext(FormContext)\n if (!ctx) throw new Error('useFormSectionContext must be used within FormSectionContextProvider')\n return ctx\n}\n"],"names":["React"],"mappings":";;;AAaO,IAAM,WAAW,GAAG,aAAa,CAAoB;IAC1D,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;AAC3B,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,aAAa,EAAE,UAAC,CAAC,EAAA;AAClB,CAAA;AAUY,IAAA,cAAc,GAAG,YAAA;IAC5B,IAAM,GAAG,GAAGA,cAAK,CAAC,UAAU,CAAC,WAAW,CAAC;AACzC,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC;AACjG,IAAA,OAAO,GAAG;AACZ;;;;"}
@@ -1,17 +1,15 @@
1
1
  import { __assign } from '../../../node_modules/tslib/tslib.es6.js';
2
+ import { FormContext } from './FormContextProvider.js';
2
3
  import FormHeader from './FormHeader.js';
3
4
  import FormSection from './FormSection.js';
4
- import { copyAndAddPathToFields, calculateSectionStatus } from '../helpers.js';
5
- import { utils as index$1 } from '../../../node_modules/@axdspub/axiom-ui-utilities/library/index.js';
5
+ import { copyAndAddPathToFields, getFieldsFromFormSection, getFieldValue, updateFormValuesWithFieldValueInPlace, calculateSectionStatus } from '../helpers.js';
6
+ import { Loader, utils as index$1 } from '../../../node_modules/@axdspub/axiom-ui-utilities/library/index.js';
6
7
  import React__default, { useState, useEffect } from 'react';
7
8
 
8
9
  var FormStatus = function (_a) {
9
10
  var _b, _c, _d, _e;
10
11
  var form = _a.form, formValueState = _a.formValueState;
11
- var _f = useState(calculateSectionStatus([form], formValueState)), status = _f[0], setStatus = _f[1];
12
- useEffect(function () {
13
- setStatus(calculateSectionStatus([form], formValueState));
14
- }, [formValueState, form]);
12
+ var status = calculateSectionStatus([form], formValueState);
15
13
  return (React__default.createElement(React__default.Fragment, null,
16
14
  React__default.createElement("p", { className: 'text-xs mt-4' }, (_b = status[form.id]) === null || _b === void 0 ? void 0 :
17
15
  _b.completed,
@@ -26,25 +24,44 @@ var FormStatus = function (_a) {
26
24
  };
27
25
  var FormCreator = function (_a) {
28
26
  var _b;
29
- var form = _a.form, formValueState = _a.formValueState, note = _a.note, error = _a.error, onChange = _a.onChange, className = _a.className, _c = _a.urlNavigable, urlNavigable = _c === void 0 ? true : _c, inputOverrides = _a.inputOverrides;
30
- var _d = useState(null), activeForm = _d[0], setActiveForm = _d[1];
27
+ var form = _a.form, formValueState = _a.formValueState, note = _a.note, error = _a.error, onChange = _a.onChange, className = _a.className, _c = _a.urlNavigable, urlNavigable = _c === void 0 ? true : _c, inputOverrides = _a.inputOverrides, schema = _a.schema;
28
+ var activeForm = copyAndAddPathToFields(form);
29
+ activeForm.settings = __assign({ url_navigable: urlNavigable }, activeForm.settings);
30
+ var formValues = formValueState[0], setFormValues = formValueState[1];
31
+ var _d = useState(false), isReady = _d[0], setIsReady = _d[1];
31
32
  useEffect(function () {
32
- var newForm = copyAndAddPathToFields(form);
33
- setActiveForm(newForm);
33
+ var formValuesCopy = structuredClone(formValues);
34
+ getFieldsFromFormSection(activeForm).forEach(function (field) {
35
+ if (field.defaultValue !== undefined && getFieldValue(field, formValues) === undefined) {
36
+ updateFormValuesWithFieldValueInPlace(field, field.defaultValue, formValuesCopy);
37
+ }
38
+ });
39
+ setFormValues(formValuesCopy);
40
+ setIsReady(true);
34
41
  }, [form]);
35
- if (activeForm === null) {
36
- return React__default.createElement("p", null, "Processing");
42
+ console.log('isReady', isReady);
43
+ if (isReady) {
44
+ console.log('formValues', formValues);
37
45
  }
38
- activeForm.settings = __assign({ url_navigable: urlNavigable }, activeForm.settings);
39
- return (React__default.createElement("div", { className: index$1.makeClassName({
40
- className: (_b = activeForm === null || activeForm === void 0 ? void 0 : activeForm.settings) === null || _b === void 0 ? void 0 : _b.class_name,
41
- defaultClassName: className
42
- }) },
43
- React__default.createElement(FormHeader, { form: activeForm, note: note, error: error }),
44
- (activeForm === null || activeForm === void 0 ? void 0 : activeForm.fields) !== undefined && activeForm.fields.length > 0 && activeForm.pages === undefined && activeForm.wizard_steps === undefined
45
- ? React__default.createElement(FormStatus, { form: activeForm, formValueState: formValueState })
46
- : '',
47
- React__default.createElement(FormSection, { formSection: activeForm, formValueState: formValueState, form: activeForm, onChange: onChange, inputOverrides: inputOverrides })));
46
+ return (React__default.createElement(React__default.Fragment, null, !isReady
47
+ ? React__default.createElement(Loader, { className: 'pt-20' })
48
+ : React__default.createElement(FormContext.Provider, { value: {
49
+ form: activeForm,
50
+ formValues: formValues,
51
+ setFormValues: setFormValues,
52
+ inputOverrides: inputOverrides,
53
+ schema: schema,
54
+ urlNavigable: activeForm.settings.url_navigable
55
+ } },
56
+ React__default.createElement("div", { className: index$1.makeClassName({
57
+ className: (_b = activeForm === null || activeForm === void 0 ? void 0 : activeForm.settings) === null || _b === void 0 ? void 0 : _b.class_name,
58
+ defaultClassName: className
59
+ }) },
60
+ React__default.createElement(FormHeader, { form: activeForm, note: note, error: error }),
61
+ (activeForm === null || activeForm === void 0 ? void 0 : activeForm.fields) !== undefined && activeForm.fields.length > 0 && activeForm.pages === undefined && activeForm.wizard_steps === undefined
62
+ ? React__default.createElement(FormStatus, { form: activeForm, formValueState: formValueState })
63
+ : '',
64
+ React__default.createElement(FormSection, { formSection: activeForm, onChange: onChange })))));
48
65
  };
49
66
 
50
67
  export { FormCreator as default };
@@ -1 +1 @@
1
- {"version":3,"file":"FormCreator.js","sources":["../../../../../src/Form/Creator/FormCreator.tsx"],"sourcesContent":["import { type IFormValues, type IForm, type IValueChangeFn, type IFieldInputProps, type IFormValueState } from '@/Form/Creator/FormCreatorTypes'\nimport FormHeader from '@/Form/Creator/FormHeader'\nimport FormSection from '@/Form/Creator/FormSection'\nimport { calculateSectionStatus, copyAndAddPathToFields } from '@/Form/helpers'\nimport { utils } from '@axdspub/axiom-ui-utilities'\nimport { type JSONSchema7 } from 'json-schema'\nimport React, { useEffect, useState, type ReactElement } from 'react'\n\nexport interface IFormCreatorProps {\n form: IForm\n schema?: JSONSchema7\n formValueState: [IFormValues, (v: IFormValues) => void]\n note?: string\n error?: string\n onChange?: IValueChangeFn\n className?: string\n urlNavigable?: boolean\n inputOverrides?: Record<string, React.FC<IFieldInputProps>>\n}\n\nconst FormStatus = ({ form, formValueState }: { form: IForm, formValueState: IFormValueState }): ReactElement => {\n const [status, setStatus] = useState<IFormSectionStatus>(calculateSectionStatus([form], formValueState))\n useEffect(() => {\n setStatus(calculateSectionStatus([form], formValueState))\n }, [formValueState, form])\n\n return (\n <>\n <p className='text-xs mt-4'>{status[form.id]?.completed} of {status[form.id]?.total} total</p>\n <p className='text-xs mt-2'>{status[form.id]?.requiredCompleted} of {status[form.id]?.requiredTotal} required</p>\n </>\n )\n}\n\nconst FormCreator = ({\n form,\n formValueState,\n note,\n error,\n onChange,\n className,\n urlNavigable = true,\n inputOverrides\n}: IFormCreatorProps): ReactElement => {\n const [activeForm, setActiveForm] = useState<IForm | null>(null)\n useEffect(() => {\n const newForm = copyAndAddPathToFields(form)\n setActiveForm(newForm)\n }, [form])\n if (activeForm === null) {\n return <p>Processing</p>\n }\n\n activeForm.settings = {\n url_navigable: urlNavigable,\n ...activeForm.settings\n }\n\n return (\n\n <div className={utils.makeClassName({\n className: activeForm?.settings?.class_name,\n defaultClassName: className\n })}>\n <FormHeader form={activeForm} note={note} error={error} />\n {\n activeForm?.fields !== undefined && activeForm.fields.length > 0 && activeForm.pages === undefined && activeForm.wizard_steps === undefined\n ? <FormStatus form={activeForm} formValueState={formValueState} />\n : ''\n }\n <FormSection\n formSection={activeForm}\n formValueState={formValueState}\n form={activeForm}\n onChange={onChange}\n inputOverrides={inputOverrides}\n />\n </div>\n )\n}\n\nexport type IFormSectionStatus = Record<string, {\n completed: number\n total: number\n requiredTotal: number\n requiredCompleted: number\n valid: boolean\n}>\n\nexport default FormCreator\n"],"names":["React","utils"],"mappings":";;;;;;;AAoBA,IAAM,UAAU,GAAG,UAAC,EAA0E,EAAA;;QAAxE,IAAI,GAAA,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AAA,IAAA,IAAV,UAAU,KAAA,MAAA,GAAA,MAAA,GAAV,UAAU,CAAE,MAAM,MAAK,SAAS,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,IAAI,UAAU,CAAC,KAAK,KAAK,SAAS,IAAI,UAAU,CAAC,YAAY,KAAK;cAC9HA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,cAAc,EAAI;AAClE,cAAE,EAAE;QAERA,cAAC,CAAA,aAAA,CAAA,WAAW,EACV,EAAA,WAAW,EAAE,UAAU,EACvB,cAAc,EAAE,cAAc,EAC9B,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,QAAQ,EAClB,cAAc,EAAE,cAAc,EAAA,CAC5B,CACF;AAEV;;;;"}
1
+ {"version":3,"file":"FormCreator.js","sources":["../../../../../src/Form/Creator/FormCreator.tsx"],"sourcesContent":["import { FormContext } from '@/Form/Creator/FormContextProvider'\nimport { type IFormValues, type IForm, type IValueChangeFn, type IFieldInputProps, type IFormValueState } from '@/Form/Creator/FormCreatorTypes'\nimport FormHeader from '@/Form/Creator/FormHeader'\nimport FormSection from '@/Form/Creator/FormSection'\nimport { calculateSectionStatus, copyAndAddPathToFields, getFieldsFromFormSection, getFieldValue, updateFormValuesWithFieldValueInPlace } from '@/Form/helpers'\nimport { Loader, utils } from '@axdspub/axiom-ui-utilities'\nimport { type JSONSchema6 } from 'json-schema'\nimport React, { useEffect, useState, type ReactElement } from 'react'\n\nexport interface IFormCreatorProps {\n form: IForm\n schema?: JSONSchema6\n formValueState: [IFormValues, (v: IFormValues) => void]\n note?: string\n error?: string\n onChange?: IValueChangeFn\n className?: string\n urlNavigable?: boolean\n inputOverrides?: Record<string, React.FC<IFieldInputProps>>\n}\n\nconst FormStatus = ({ form, formValueState }: { form: IForm, formValueState: IFormValueState }): ReactElement => {\n const status = calculateSectionStatus([form], formValueState)\n\n return (\n <>\n <p className='text-xs mt-4'>{status[form.id]?.completed} of {status[form.id]?.total} total</p>\n <p className='text-xs mt-2'>{status[form.id]?.requiredCompleted} of {status[form.id]?.requiredTotal} required</p>\n </>\n )\n}\n\nconst FormCreator = ({\n form,\n formValueState,\n note,\n error,\n onChange,\n className,\n urlNavigable = true,\n inputOverrides,\n schema\n}: IFormCreatorProps): ReactElement => {\n const activeForm = copyAndAddPathToFields(form)\n\n activeForm.settings = {\n url_navigable: urlNavigable,\n ...activeForm.settings\n }\n\n const [formValues, setFormValues] = formValueState\n const [isReady, setIsReady] = useState(false)\n useEffect(() => {\n const formValuesCopy = structuredClone(formValues)\n getFieldsFromFormSection(activeForm).forEach(field => {\n if (field.defaultValue !== undefined && getFieldValue(field, formValues) === undefined) {\n updateFormValuesWithFieldValueInPlace(field, field.defaultValue, formValuesCopy)\n }\n })\n setFormValues(formValuesCopy)\n setIsReady(true)\n }, [form])\n\n console.log('isReady', isReady)\n if (isReady) {\n console.log('formValues', formValues)\n }\n\n return (\n <>\n {\n !isReady\n ? <Loader className='pt-20' />\n : <FormContext.Provider value={{\n form: activeForm,\n formValues,\n setFormValues,\n inputOverrides,\n schema,\n urlNavigable: activeForm.settings.url_navigable\n }}>\n <div className={utils.makeClassName({\n className: activeForm?.settings?.class_name,\n defaultClassName: className\n })}>\n <FormHeader form={activeForm} note={note} error={error} />\n {\n activeForm?.fields !== undefined && activeForm.fields.length > 0 && activeForm.pages === undefined && activeForm.wizard_steps === undefined\n ? <FormStatus form={activeForm} formValueState={formValueState} />\n : ''\n }\n <FormSection\n formSection={activeForm}\n onChange={onChange}\n />\n </div>\n </FormContext.Provider>\n }\n </>\n )\n}\n\nexport type IFormSectionStatus = Record<string, {\n completed: number\n total: number\n requiredTotal: number\n requiredCompleted: number\n valid: boolean\n}>\n\nexport default FormCreator\n"],"names":["React","utils"],"mappings":";;;;;;;;AAqBA,IAAM,UAAU,GAAG,UAAC,EAA0E,EAAA;;QAAxE,IAAI,GAAA,EAAA,CAAA,IAAA,EAAE,cAA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CACF,CACe,CAE1B;AAEP;;;;"}
@@ -2,11 +2,11 @@ import FieldCreator from '../Components/FieldCreator.js';
2
2
  import React__default from 'react';
3
3
 
4
4
  var FormFields = function (_a) {
5
- var form = _a.form, fields = _a.fields, formValueState = _a.formValueState, onChange = _a.onChange, _b = _a.className, className = _b === void 0 ? 'flex flex-col gap-2' : _b, inputOverrides = _a.inputOverrides;
5
+ var fields = _a.fields, onChange = _a.onChange, _b = _a.className, className = _b === void 0 ? 'flex flex-col gap-2' : _b;
6
6
  return (React__default.createElement(React__default.Fragment, null, fields === undefined || fields.length < 1
7
7
  ? ''
8
8
  : React__default.createElement("div", { className: className }, fields === null || fields === void 0 ? void 0 : fields.map(function (field) {
9
- return (React__default.createElement(FieldCreator, { onChange: onChange, form: form, field: field, key: field.id, formValueState: formValueState, inputOverrides: inputOverrides }));
9
+ return (React__default.createElement(FieldCreator, { onChange: onChange, field: field, key: field.id }));
10
10
  }))));
11
11
  };
12
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"FormFields.js","sources":["../../../../../src/Form/Creator/FormFields.tsx"],"sourcesContent":["import FieldCreator from '@/Form/Components/FieldCreator'\nimport { type IFieldInputProps, type IForm, type IFormField, type IFormValues, type IValueChangeFn } from '@/Form/Creator/FormCreatorTypes'\nimport React, { type ReactElement } from 'react'\n\nconst FormFields = ({\n form,\n fields,\n formValueState,\n onChange,\n className = 'flex flex-col gap-2',\n inputOverrides\n}: {\n form: IForm\n fields?: IFormField[]\n formValueState: [IFormValues, (v: IFormValues) => void]\n onChange?: IValueChangeFn\n className?: string\n inputOverrides?: Record<string, React.FC<IFieldInputProps>>\n}): ReactElement => {\n return (\n <>\n {\n fields === undefined || fields.length < 1\n ? ''\n : <div className={className}>\n {\n fields?.map((field) => {\n return (\n <FieldCreator onChange={onChange} form={form} field={field} key={field.id} formValueState={formValueState} inputOverrides={inputOverrides}/>\n )\n })\n }\n </div>\n }\n </>\n )\n}\n\nexport default FormFields\n"],"names":["React"],"mappings":";;;AAIM,IAAA,UAAU,GAAG,UAAC,EAcnB,EAAA;AAbC,IAAA,IAAA,IAAI,UAAA,EACJ,MAAM,YAAA,EACN,cAAc,oBAAA,EACd,QAAQ,cAAA,EACR,EAAA,GAAA,EAAA,CAAA,SAAiC,EAAjC,SAAS,GAAA,EAAA,KAAA,MAAA,GAAG,qBAAqB,GAAA,EAAA,EACjC,cAAc,GAAA,EAAA,CAAA,cAAA;IASd,QACIA,cAEE,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EAAA,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG;AACtC,UAAE;AACF,UAAEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,SAAS,EAEvB,EAAA,MAAM,KAAN,IAAA,IAAA,MAAM,uBAAN,MAAM,CAAE,GAAG,CAAC,UAAC,KAAK,EAAA;AAChB,YAAA,QACEA,cAAA,CAAA,aAAA,CAAC,YAAY,EAAA,EAAC,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,cAAc,EAAA,CAAG;AAEhJ,SAAC,CAAC,CAEF,CAEL;AAET;;;;"}
1
+ {"version":3,"file":"FormFields.js","sources":["../../../../../src/Form/Creator/FormFields.tsx"],"sourcesContent":["import FieldCreator from '@/Form/Components/FieldCreator'\nimport { type IFormField, type IValueChangeFn } from '@/Form/Creator/FormCreatorTypes'\nimport React, { type ReactElement } from 'react'\n\nconst FormFields = ({\n fields,\n onChange,\n className = 'flex flex-col gap-2'\n}: {\n fields?: IFormField[]\n onChange?: IValueChangeFn\n className?: string\n}): ReactElement => {\n return (\n <>\n {\n fields === undefined || fields.length < 1\n ? ''\n : <div className={className}>\n {\n fields?.map((field) => {\n return (\n <FieldCreator onChange={onChange} field={field} key={field.id} />\n )\n })\n }\n </div>\n }\n </>\n )\n}\n\nexport default FormFields\n"],"names":["React"],"mappings":";;;AAIM,IAAA,UAAU,GAAG,UAAC,EAQnB,EAAA;QAPC,MAAM,GAAA,EAAA,CAAA,MAAA,EACN,QAAQ,GAAA,EAAA,CAAA,QAAA,EACR,iBAAiC,EAAjC,SAAS,GAAG,EAAA,KAAA,MAAA,GAAA,qBAAqB,GAAA,EAAA;IAMjC,QACIA,cAEE,CAAA,aAAA,CAAAA,cAAA,CAAA,QAAA,EAAA,IAAA,EAAA,MAAM,KAAK,SAAS,IAAI,MAAM,CAAC,MAAM,GAAG;AACtC,UAAE;AACF,UAAEA,cAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,SAAS,EAEvB,EAAA,MAAM,KAAN,IAAA,IAAA,MAAM,uBAAN,MAAM,CAAE,GAAG,CAAC,UAAC,KAAK,EAAA;AAChB,YAAA,QACEA,cAAC,CAAA,aAAA,CAAA,YAAY,IAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,CAAC,EAAE,EAAA,CAAI;AAErE,SAAC,CAAC,CAEF,CAEL;AAET;;;;"}
@@ -5,7 +5,7 @@ import React__default from 'react';
5
5
 
6
6
  var FormSection = function (_a) {
7
7
  var _b, _c, _d;
8
- var formSection = _a.formSection, formValueState = _a.formValueState, form = _a.form, onChange = _a.onChange, _e = _a.level, level = _e === void 0 ? 0 : _e, inputOverrides = _a.inputOverrides;
8
+ var formSection = _a.formSection, onChange = _a.onChange, _e = _a.level, level = _e === void 0 ? 0 : _e; _a.inputOverrides;
9
9
  if (formSection === undefined) {
10
10
  return React__default.createElement(React__default.Fragment, null);
11
11
  }
@@ -32,10 +32,10 @@ var FormSection = function (_a) {
32
32
  });
33
33
  }
34
34
  return (React__default.createElement(React__default.Fragment, null, hasWizardSteps
35
- ? React__default.createElement(WizardLayout, { form: form, sections: wizardSteps, formValueState: formValueState, onChange: onChange, level: level, inputOverrides: inputOverrides })
35
+ ? React__default.createElement(WizardLayout, { sections: wizardSteps, onChange: onChange, level: level })
36
36
  : hasPages
37
- ? React__default.createElement(PageLayout, { form: form, sections: pages, formValueState: formValueState, onChange: onChange, level: level, inputOverrides: inputOverrides })
38
- : React__default.createElement(FormFields, { form: form, fields: fields, formValueState: formValueState, onChange: onChange, inputOverrides: inputOverrides })));
37
+ ? React__default.createElement(PageLayout, { sections: pages, onChange: onChange, level: level })
38
+ : React__default.createElement(FormFields, { fields: fields, onChange: onChange })));
39
39
  };
40
40
 
41
41
  export { FormSection as default };
@@ -1 +1 @@
1
- {"version":3,"file":"FormSection.js","sources":["../../../../../src/Form/Creator/FormSection.tsx"],"sourcesContent":["import { type IFieldInputProps, type IForm, type IFormSection, type IFormValueState, type IValueChangeFn } from '@/Form/Creator/FormCreatorTypes'\nimport FormFields from '@/Form/Creator/FormFields'\nimport PageLayout from '@/Form/Creator/Page'\nimport WizardLayout from '@/Form/Creator/Wizard'\nimport React, { type ReactElement } from 'react'\n\nconst FormSection = ({\n formSection,\n formValueState,\n form,\n onChange,\n level = 0,\n inputOverrides\n}: {\n formSection?: IFormSection\n formValueState: IFormValueState\n form: IForm\n onChange?: IValueChangeFn\n level?: number\n inputOverrides?: Record<string, React.FC<IFieldInputProps>>\n\n}): ReactElement => {\n if (formSection === undefined) {\n return <></>\n }\n const pages = (formSection?.pages ?? []).slice()\n const fields = (formSection?.fields ?? []).slice()\n const wizardSteps = (formSection?.wizard_steps ?? []).slice()\n const hasPages = pages.length > 0\n const hasFields = fields.length > 0\n const hasWizardSteps = wizardSteps.length > 0\n if (hasPages && hasFields) {\n pages.unshift({\n id: 'default',\n label: 'Default',\n fields\n })\n }\n if ((hasPages || hasFields) && hasWizardSteps) {\n wizardSteps.unshift({\n id: 'default',\n order: -10,\n label: 'Default',\n pages,\n fields\n })\n }\n return (\n <>\n {\n hasWizardSteps\n ? <WizardLayout form={form} sections={wizardSteps} formValueState={formValueState} onChange={onChange} level={level} inputOverrides={inputOverrides} />\n\n : hasPages\n ? <PageLayout form={form} sections={pages} formValueState={formValueState} onChange={onChange} level={level} inputOverrides={inputOverrides} />\n : <FormFields form={form} fields={fields} formValueState={formValueState} onChange={onChange} inputOverrides={inputOverrides} />\n }\n </>\n )\n}\n\nexport default FormSection\n"],"names":["React"],"mappings":";;;;;AAMM,IAAA,WAAW,GAAG,UAAC,EAepB,EAAA;;AAdC,IAAA,IAAA,WAAW,iBAAA,EACX,cAAc,oBAAA,EACd,IAAI,UAAA,EACJ,QAAQ,cAAA,EACR,EAAA,GAAA,EAAA,CAAA,KAAS,EAAT,KAAK,GAAA,EAAA,KAAA,MAAA,GAAG,CAAC,GAAA,EAAA,EACT,cAAc,GAAA,EAAA,CAAA,cAAA;AAUd,IAAA,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,QAAA,OAAOA,2DAAK;;AAEd,IAAA,IAAM,KAAK,GAAG,CAAC,CAAA,EAAA,GAAA,WAAW,aAAX,WAAW,KAAA,MAAA,GAAA,MAAA,GAAX,WAAW,CAAE,KAAK,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,EAAE,EAAE,KAAK,EAAE;AAChD,IAAA,IAAM,MAAM,GAAG,CAAC,CAAA,EAAA,GAAA,WAAW,aAAX,WAAW,KAAA,MAAA,GAAA,MAAA,GAAX,WAAW,CAAE,MAAM,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,EAAE,EAAE,KAAK,EAAE;AAClD,IAAA,IAAM,WAAW,GAAG,CAAC,CAAA,EAAA,GAAA,WAAW,aAAX,WAAW,KAAA,MAAA,GAAA,MAAA,GAAX,WAAW,CAAE,YAAY,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,EAAE,EAAE,KAAK,EAAE;AAC7D,IAAA,IAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC;AACjC,IAAA,IAAM,SAAS,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;AACnC,IAAA,IAAM,cAAc,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC;AAC7C,IAAA,IAAI,QAAQ,IAAI,SAAS,EAAE;QACzB,KAAK,CAAC,OAAO,CAAC;AACZ,YAAA,EAAE,EAAE,SAAS;AACb,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,MAAM,EAAA;AACP,SAAA,CAAC;;IAEJ,IAAI,CAAC,QAAQ,IAAI,SAAS,KAAK,cAAc,EAAE;QAC7C,WAAW,CAAC,OAAO,CAAC;AAClB,YAAA,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,GAAG;AACV,YAAA,KAAK,EAAE,SAAS;AAChB,YAAA,KAAK,EAAA,KAAA;AACL,YAAA,MAAM,EAAA;AACP,SAAA,CAAC;;IAEJ,QACMA,4DAEI;UACIA,cAAC,CAAA,aAAA,CAAA,YAAY,EAAC,EAAA,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAI;AAEvJ,UAAE;cACEA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,cAAc,EAAI;cAC7IA,cAAC,CAAA,aAAA,CAAA,UAAU,EAAC,EAAA,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAA,CAAI,CAErI;AAEX;;;;"}
1
+ {"version":3,"file":"FormSection.js","sources":["../../../../../src/Form/Creator/FormSection.tsx"],"sourcesContent":["import { type IFieldInputProps, type IFormSection, type IValueChangeFn } from '@/Form/Creator/FormCreatorTypes'\nimport FormFields from '@/Form/Creator/FormFields'\nimport PageLayout from '@/Form/Creator/Page'\nimport WizardLayout from '@/Form/Creator/Wizard'\nimport React, { type ReactElement } from 'react'\n\nconst FormSection = ({\n formSection,\n onChange,\n level = 0,\n inputOverrides\n}: {\n formSection?: IFormSection\n onChange?: IValueChangeFn\n level?: number\n inputOverrides?: Record<string, React.FC<IFieldInputProps>>\n\n}): ReactElement => {\n if (formSection === undefined) {\n return <></>\n }\n const pages = (formSection?.pages ?? []).slice()\n const fields = (formSection?.fields ?? []).slice()\n const wizardSteps = (formSection?.wizard_steps ?? []).slice()\n const hasPages = pages.length > 0\n const hasFields = fields.length > 0\n const hasWizardSteps = wizardSteps.length > 0\n if (hasPages && hasFields) {\n pages.unshift({\n id: 'default',\n label: 'Default',\n fields\n })\n }\n if ((hasPages || hasFields) && hasWizardSteps) {\n wizardSteps.unshift({\n id: 'default',\n order: -10,\n label: 'Default',\n pages,\n fields\n })\n }\n return (\n <>\n {\n hasWizardSteps\n ? <WizardLayout sections={wizardSteps} onChange={onChange} level={level} />\n\n : hasPages\n ? <PageLayout sections={pages} onChange={onChange} level={level} />\n : <FormFields fields={fields} onChange={onChange} />\n }\n </>\n )\n}\n\nexport default FormSection\n"],"names":["React"],"mappings":";;;;;AAMM,IAAA,WAAW,GAAG,UAAC,EAWpB,EAAA;;AAVC,IAAA,IAAA,WAAW,GAAA,EAAA,CAAA,WAAA,CAAA,CACX,QAAQ,GAAA,EAAA,CAAA,QAAA,CACR,CAAA,EAAA,GAAA,EAAA,CAAA,KAAS,CAAT,CAAA,KAAK,GAAG,EAAA,KAAA,MAAA,GAAA,CAAC,GAAA,EAAA,CAAA,CACK,EAAA,CAAA;AAQd,IAAA,IAAI,WAAW,KAAK,SAAS,EAAE;AAC7B,QAAA,OAAOA,2DAAK;;AAEd,IAAA,IAAM,KAAK,GAAG,CAAC,CAAA,EAAA,GAAA,WAAW,aAAX,WAAW,KAAA,MAAA,GAAA,M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AK,EAAE,KAAK,EAAI;AAE3E,UAAE;AACA,cAAEA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAI;AACnE,cAAEA,cAAA,CAAA,aAAA,CAAC,UAAU,EAAA,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAI,CAAA,CAEzD;AAEX;;;;"}
@@ -0,0 +1,23 @@
1
+ import React__default, { createContext, useState, useMemo } from 'react';
2
+
3
+ var FormSectionContext = createContext({
4
+ path: '',
5
+ setActiveId: function () { }
6
+ });
7
+ var FormSectionContextProvider = function (props) {
8
+ var _a;
9
+ var _b = useState(props.id), activeId = _b[0], setActiveId = _b[1];
10
+ useMemo(function () {
11
+ setActiveId(props.id);
12
+ }, [props.id]);
13
+ return (React__default.createElement(FormSectionContext.Provider, { value: { activeId: activeId, setActiveId: setActiveId, path: (_a = props.path) !== null && _a !== void 0 ? _a : '' } }, props.children));
14
+ };
15
+ var useFormSectionContext = function () {
16
+ var ctx = React__default.useContext(FormSectionContext);
17
+ if (!ctx)
18
+ throw new Error('useFormSectionContext must be used within FormSectionContextProvider');
19
+ return ctx;
20
+ };
21
+
22
+ export { FormSectionContext, FormSectionContextProvider, useFormSectionContext };
23
+ //# sourceMappingURL=FormSectionContextProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FormSectionContextProvider.js","sources":["../../../../../src/Form/Creator/FormSectionContextProvider.tsx"],"sourcesContent":["import React, { createContext, type PropsWithChildren, type ReactElement, useMemo, useState } from 'react'\n\nexport interface IFormSectionContextValue {\n activeId?: string\n setActiveId: (v: string | undefined) => void\n path: string\n}\nexport const FormSectionContext = createContext<IFormSectionContextValue>({\n path: '',\n setActiveId: () => {}\n})\nexport const FormSectionContextProvider = (props: PropsWithChildren & { id?: string, path?: string }): ReactElement => {\n const [activeId, setActiveId] = useState<string | undefined>(props.id)\n useMemo(() => {\n setActiveId(props.id)\n }, [props.id])\n return (\n <FormSectionContext.Provider value={{ activeId, setActiveId, path: props.path ?? '' }}>\n {props.children}\n </FormSectionContext.Provider>\n )\n}\n\nexport const useFormSectionContext = (): IFormSectionContextValue => {\n const ctx = React.useContext(FormSectionContext)\n if (!ctx) throw new Error('useFormSectionContext must be used within FormSectionContextProvider')\n return ctx\n}\n"],"names":["React"],"mappings":";;AAOO,IAAM,kBAAkB,GAAG,aAAa,CAA2B;AACxE,IAAA,IAAI,EAAE,EAAE;IACR,WAAW,EAAE;AACd,CAAA;AACM,IAAM,0BAA0B,GAAG,UAAC,KAAyD,EAAA;;AAC5F,IAAA,IAAA,EAA0B,GAAA,QAAQ,CAAqB,KAAK,CAAC,EAAE,CAAC,EAA/D,QAAQ,GAAA,EAAA,CAAA,CAAA,CAAA,EAAE,WAAW,QAA0C;AACtE,IAAA,OAAO,CAAC,YAAA;AACN,QAAA,WAAW,CAAC,KAAK,CAAC,EAAE,CAAC;AACvB,KAAC,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;AACd,IAAA,QACEA,cAAA,CAAA,aAAA,CAAC,kBAAkB,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,EAAE,QAAQ,EAAA,QAAA,EAAE,WAAW,EAAA,WAAA,EAAE,IAAI,EAAE,CAAA,EAAA,GAAA,KAAK,CAAC,IAAI,MAAI,IAAA,IAAA,EAAA,KAAA,MAAA,GAAA,EAAA,GAAA,EAAE,EAAE,EAAA,EAClF,KAAK,CAAC,QAAQ,CACa;AAElC;AAEa,IAAA,qBAAqB,GAAG,YAAA;IACnC,IAAM,GAAG,GAAGA,cAAK,CAAC,UAAU,CAAC,kBAAkB,CAAC;AAChD,IAAA,IAAI,CAAC,GAAG;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC;AACjG,IAAA,OAAO,GAAG;AACZ;;;;"}
@@ -1,23 +1,22 @@
1
+ import { FormSectionContextProvider, useFormSectionContext } from './FormSectionContextProvider.js';
1
2
  import FormSection from './FormSection.js';
2
3
  import NavElement from './NavElement.js';
3
4
  import { calculateSectionStatus } from '../helpers.js';
4
5
  import { InfoCircledIcon } from '../../../node_modules/@radix-ui/react-icons/dist/react-icons.esm.js';
5
- import React__default, { useState, useEffect } from 'react';
6
+ import React__default from 'react';
7
+ import { useFormContext } from './FormContextProvider.js';
6
8
  import { useParams } from '../../../node_modules/react-router/dist/development/chunk-HA7DTUK3.js';
7
9
 
8
10
  var PageNav = function (_a) {
9
- var _b;
10
- var form = _a.form, sections = _a.sections, activeIdState = _a.activeIdState, level = _a.level;
11
- var activeId = activeIdState[0], setActiveState = activeIdState[1];
12
- var params = ((_b = useParams()['*']) !== null && _b !== void 0 ? _b : '').split('/');
13
- var path = params.slice(0, level).join('/');
11
+ var sections = _a.sections; _a.level;
12
+ var urlNavigable = useFormContext().urlNavigable;
13
+ var _b = useFormSectionContext(), activeId = _b.activeId, setActiveId = _b.setActiveId, path = _b.path;
14
14
  return (React__default.createElement("div", { className: 'flex flex-col w-[200px] border-slate-200' }, sections === null || sections === void 0 ? void 0 : sections.map(function (p) {
15
- var _a, _b;
16
- return (React__default.createElement(NavElement, { key: p.id, path: path, id: p.id, navigable: (_b = (_a = form === null || form === void 0 ? void 0 : form.settings) === null || _a === void 0 ? void 0 : _a.url_navigable) !== null && _b !== void 0 ? _b : true, onClick: function () { setActiveState(p.id); }, className: "border-none rounded-none bg-slate-100 text-sm font-normal text-left ".concat(activeId === p.id ? 'bg-slate-700 text-white' : 'hover:bg-slate-200') }, p.label));
15
+ return (React__default.createElement(NavElement, { key: p.id, path: path, id: p.id, navigable: urlNavigable !== null && urlNavigable !== void 0 ? urlNavigable : true, onClick: function () { setActiveId(p.id); }, className: "border-none rounded-none bg-slate-100 text-sm font-normal text-left ".concat(activeId === p.id ? 'bg-slate-700 text-white' : 'hover:bg-slate-200') }, p.label));
17
16
  })));
18
17
  };
19
18
  var ActivePage = function (_a) {
20
- _a.activeIdState; var form = _a.form, formValueState = _a.formValueState, formSection = _a.formSection, inputOverrides = _a.inputOverrides, onChange = _a.onChange, _b = _a.className, className = _b === void 0 ? 'flex flex-col gap-2 flex-grow' : _b, level = _a.level;
19
+ var formSection = _a.formSection, onChange = _a.onChange, _b = _a.className, className = _b === void 0 ? 'flex flex-col gap-2 flex-grow' : _b, level = _a.level;
21
20
  return (React__default.createElement("div", { className: className },
22
21
  (formSection === null || formSection === void 0 ? void 0 : formSection.description) !== undefined
23
22
  ? React__default.createElement("p", { className: 'pb-4 border-b border-slate-200 text-sm' },
@@ -25,36 +24,26 @@ var ActivePage = function (_a) {
25
24
  " ",
26
25
  formSection.description)
27
26
  : '',
28
- React__default.createElement(FormSection, { formSection: formSection, formValueState: formValueState, inputOverrides: inputOverrides, form: form, onChange: onChange, level: level + 1 })));
27
+ React__default.createElement(FormSection, { formSection: formSection, onChange: onChange, level: level + 1 })));
29
28
  };
30
29
  var PageLayout = function (_a) {
31
- var _b, _c, _d, _e, _f, _g, _h, _j, _k;
32
- var form = _a.form, sections = _a.sections, formValueState = _a.formValueState, onChange = _a.onChange, inputOverrides = _a.inputOverrides, _l = _a.ContentComponent, ContentComponent = _l === void 0 ? ActivePage : _l, _m = _a.NavComponent, NavComponent = _m === void 0 ? PageNav : _m, _o = _a.className, className = _o === void 0 ? 'flex flex-row gap-8' : _o, level = _a.level;
30
+ var _b, _c, _d, _e, _f, _g;
31
+ var sections = _a.sections, onChange = _a.onChange; _a.inputOverrides; var _h = _a.ContentComponent, ContentComponent = _h === void 0 ? ActivePage : _h, _j = _a.NavComponent, NavComponent = _j === void 0 ? PageNav : _j, _k = _a.className, className = _k === void 0 ? 'flex flex-row gap-8' : _k, level = _a.level;
33
32
  if (sections === undefined) {
34
33
  return React__default.createElement(React__default.Fragment, null);
35
34
  }
36
- var params = (_c = (_b = useParams()['*']) === null || _b === void 0 ? void 0 : _b.split('/')) !== null && _c !== void 0 ? _c : [];
37
- var activeIdState = useState(((_d = form === null || form === void 0 ? void 0 : form.settings) === null || _d === void 0 ? void 0 : _d.url_navigable)
38
- ? (_g = (_e = params[level]) !== null && _e !== void 0 ? _e : (_f = sections[0]) === null || _f === void 0 ? void 0 : _f.id) !== null && _g !== void 0 ? _g : null
39
- : (_j = (_h = sections[0]) === null || _h === void 0 ? void 0 : _h.id) !== null && _j !== void 0 ? _j : null);
40
- var _p = useState(calculateSectionStatus(sections, formValueState)), sectionStatus = _p[0], setSectionStatus = _p[1];
41
- useEffect(function () {
42
- setSectionStatus(calculateSectionStatus(sections, formValueState));
43
- }, [formValueState, sections]);
44
- var _q = useState((_k = sections === null || sections === void 0 ? void 0 : sections.find(function (s) { return s.id === activeIdState[0]; })) !== null && _k !== void 0 ? _k : sections === null || sections === void 0 ? void 0 : sections[0]), formSection = _q[0], setFormSection = _q[1];
45
- useEffect(function () {
46
- var _a;
47
- setFormSection((_a = sections === null || sections === void 0 ? void 0 : sections.find(function (s) { return s.id === activeIdState[0]; })) !== null && _a !== void 0 ? _a : sections === null || sections === void 0 ? void 0 : sections[0]);
48
- }, [activeIdState[0]]);
49
- useEffect(function () {
50
- var _a, _b, _c, _d;
51
- if (((_a = form === null || form === void 0 ? void 0 : form.settings) === null || _a === void 0 ? void 0 : _a.url_navigable) === true && params[level] !== activeIdState[0]) {
52
- activeIdState[1]((_d = (_b = params[level]) !== null && _b !== void 0 ? _b : (_c = sections[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null);
53
- }
54
- }, [useParams()['*']]);
55
- return (React__default.createElement("div", { className: className },
56
- React__default.createElement(NavComponent, { form: form, sections: sections, sectionStatus: sectionStatus, activeIdState: activeIdState, level: level }),
57
- React__default.createElement(ContentComponent, { activeIdState: activeIdState, formSection: formSection, inputOverrides: inputOverrides, form: form, formValueState: formValueState, onChange: onChange, sectionStatus: sectionStatus, level: level })));
35
+ var _l = useFormContext(), urlNavigable = _l.urlNavigable, setFormValues = _l.setFormValues, formValues = _l.formValues;
36
+ var params = ((_b = useParams()['*']) !== null && _b !== void 0 ? _b : '').split('/');
37
+ var path = params.slice(0, level).join('/');
38
+ var id = urlNavigable
39
+ ? (params[level] && params[level] !== '') ? params[level] : ((_d = (_c = sections[0]) === null || _c === void 0 ? void 0 : _c.id) !== null && _d !== void 0 ? _d : null)
40
+ : (_f = (_e = sections[0]) === null || _e === void 0 ? void 0 : _e.id) !== null && _f !== void 0 ? _f : null;
41
+ var sectionStatus = calculateSectionStatus(sections, [formValues, setFormValues]);
42
+ var formSection = (_g = sections === null || sections === void 0 ? void 0 : sections.find(function (s) { return s.id === id; })) !== null && _g !== void 0 ? _g : sections === null || sections === void 0 ? void 0 : sections[0];
43
+ return (React__default.createElement(FormSectionContextProvider, { path: path, id: id },
44
+ React__default.createElement("div", { className: className },
45
+ React__default.createElement(NavComponent, { sections: sections, sectionStatus: sectionStatus, level: level }),
46
+ React__default.createElement(ContentComponent, { formSection: formSection, onChange: onChange, sectionStatus: sectionStatus, level: level }))));
58
47
  };
59
48
 
60
49
  export { ActivePage, PageLayout as default };