diff --git a/src/Components/AppShell/DialogModal.tsx b/src/Components/AppShell/DialogModal.tsx index c9577806..f1cf2091 100644 --- a/src/Components/AppShell/DialogModal.tsx +++ b/src/Components/AppShell/DialogModal.tsx @@ -26,6 +26,7 @@ const DialogModal = ({ onClose, children, }: Props) => { + const ref = useRef(null); useEffect(() => { diff --git a/src/Components/Input/TextInput.tsx b/src/Components/Input/TextInput.tsx index 2732fb85..4370da9d 100644 --- a/src/Components/Input/TextInput.tsx +++ b/src/Components/Input/TextInput.tsx @@ -7,13 +7,14 @@ type InputTextProps = { type?: string; dataField?: string; containerStyle?: string; + inputStyle?: string; defaultValue?: string; placeholder?: string; updateFormValue?: (value: string ) => void; } -export function TextInput({labelTitle, labelStyle, type, dataField, containerStyle, defaultValue, placeholder, updateFormValue} : InputTextProps){ +export function TextInput({labelTitle, labelStyle, type, dataField, containerStyle, inputStyle, defaultValue, placeholder, updateFormValue} : InputTextProps){ return(
@@ -21,7 +22,7 @@ export function TextInput({labelTitle, labelStyle, type, dataField, containerSty {labelTitle} : " "} - updateFormValue&& updateFormValue(e.target.value)}className="tw-input tw-input-bordered tw-w-full " /> + updateFormValue&& updateFormValue(e.target.value)}className={`tw-input tw-input-bordered tw-w-full ${inputStyle ? inputStyle : ""}`} />
) } diff --git a/src/Components/Map/ItemForm.tsx b/src/Components/Map/ItemForm.tsx index a1142370..6a161a37 100644 --- a/src/Components/Map/ItemForm.tsx +++ b/src/Components/Map/ItemForm.tsx @@ -1,7 +1,14 @@ import * as React from 'react' +import { Item } from '../../types' -export const ItemForm = ({ children }:{children?: React.ReactNode}) => { - return ( -
{children}
- ) +export const ItemForm = ({ children, item }: { children?: React.ReactNode, item?: Item }) => { + return ( +
{ + children ? + React.Children.toArray(children).map((child) => + React.isValidElement<{ item: Item, test: string }>(child) ? + React.cloneElement(child, { item: item, test: "test" }) : "" + ) : "" + }
+ ) } diff --git a/src/Components/Map/ItemView.tsx b/src/Components/Map/ItemView.tsx index 5442d155..600071ce 100644 --- a/src/Components/Map/ItemView.tsx +++ b/src/Components/Map/ItemView.tsx @@ -1,7 +1,14 @@ import * as React from 'react' +import { Item } from '../../types' -export const ItemView = ({ children }:{children?: React.ReactNode}) => { +export const ItemView = ({ children, item }: { children?: React.ReactNode, item?: Item }) => { return ( -
{children}
+
+ {children ? + React.Children.toArray(children).map((child) => + React.isValidElement<{ item: Item, test: string }>(child) ? + React.cloneElement(child, { item: item, test: "test" }) : "" + ) : ""} +
) } diff --git a/src/Components/Map/Layer.tsx b/src/Components/Map/Layer.tsx index 0ec057c2..0907c6d0 100644 --- a/src/Components/Map/Layer.tsx +++ b/src/Components/Map/Layer.tsx @@ -88,12 +88,12 @@ export const Layer = (props: LayerProps) => { - + { - (props.children && React.Children.toArray(props.children).some(e => React.isValidElement(e) && typeof e.type !== "string" && e.type.name === "ItemForm") ? + (props.children && React.Children.toArray(props.children).some(e => React.isValidElement(e) && typeof e.type !== "string" && e.type.name === "ItemView") ? React.Children.toArray(props.children).map((child) => React.isValidElement(child) && typeof child.type !== "string" && child.type.name === "ItemView" ? - {child} + {child} : "" ) : @@ -106,7 +106,8 @@ export const Layer = (props: LayerProps) => { ); }) } - {props.children} + {//{props.children}} + } {props.itemFormPopup && props.itemFormPopup.layer!.name == props.name && (props.children && React.Children.toArray(props.children).some(e => React.isValidElement(e) && typeof e.type !== "string" && e.type.name === "ItemForm") ? React.Children.toArray(props.children).map((child) => diff --git a/src/Components/Map/Subcomponents/ItemFormPopup.tsx b/src/Components/Map/Subcomponents/ItemFormPopup.tsx index 0ee85394..a9b3ea9b 100644 --- a/src/Components/Map/Subcomponents/ItemFormPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemFormPopup.tsx @@ -85,9 +85,17 @@ export function ItemFormPopup(props: ItemFormPopupProps) { position={props.position}>
handleSubmit(e)}>
New {props.layer.name}
- {props.children ? props.children : + + + {props.children ? + + React.Children.toArray(props.children).map((child) => + React.isValidElement<{ item: Item, test: string }>(child) ? + React.cloneElement(child, { item: props.item}) : "" + ) + + : <> - } diff --git a/src/Components/Map/Subcomponents/HeaderView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx similarity index 93% rename from src/Components/Map/Subcomponents/HeaderView.tsx rename to src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx index dfd661fc..132a7b3d 100644 --- a/src/Components/Map/Subcomponents/HeaderView.tsx +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/HeaderView.tsx @@ -1,9 +1,9 @@ import * as React from "react" -import { useRemoveItem } from "../hooks/useItems"; +import { useRemoveItem } from "../../hooks/useItems"; import { useMap } from "react-leaflet"; -import { ItemFormPopupProps } from "./ItemFormPopup"; +import { ItemFormPopupProps } from "../ItemFormPopup"; import { LatLng } from "leaflet"; -import { Item } from "../../../types"; +import { Item } from "../../../../types"; @@ -33,7 +33,7 @@ export function HeaderView({item, setItemFormPopup}: { } return ( -
+
{item.name}
diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx new file mode 100644 index 00000000..3c4cae9c --- /dev/null +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupStartEndInput.tsx @@ -0,0 +1,12 @@ +import * as React from 'react' +import { TextInput } from '../../../Input' +import { Item } from '../../../../types' + +export const PopupStartEndInput = ({item}:{item?:Item}) => { + return ( +
+ + +
+ ) +} diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextAreaInput.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextAreaInput.tsx new file mode 100644 index 00000000..693220cc --- /dev/null +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextAreaInput.tsx @@ -0,0 +1,16 @@ +import * as React from 'react' +import { TextAreaInput } from '../../../Input' +import { Item } from '../../../../types' + +export const PopupTextAreaInput = ({ dataField, placeholder, style, item }: + { + dataField: string, + placeholder: string, + style?: string, + item?: Item + }) => { + + return ( + + ) +} diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx new file mode 100644 index 00000000..66fa5d9f --- /dev/null +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/PopupTextInput.tsx @@ -0,0 +1,7 @@ +import * as React from 'react' + +export const PopupTextInput = () => { + return ( +
PopupTextInput
+ ) +} diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx new file mode 100644 index 00000000..a08f1ba9 --- /dev/null +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/StartEndView.tsx @@ -0,0 +1,25 @@ +import * as React from 'react' +import { Item } from '../../../../types' + +export const StartEndView = ({item} : {item?:Item}) => { + return ( +
+
+ + + + +
+
+ - +
+
+ + + + +
+
+ ) +} + diff --git a/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx new file mode 100644 index 00000000..ef581209 --- /dev/null +++ b/src/Components/Map/Subcomponents/ItemPopupComponents/TextView.tsx @@ -0,0 +1,14 @@ +import * as React from 'react' +import { Item } from '../../../../types' +import { useTags } from '../../hooks/useTags'; +import { replaceURLs } from '../../../../Utils/ReplaceURLs'; +import { heighlightTags } from '../../../../Utils/HeighlightTags'; + +export const TextView = ({item} : {item?: Item}) => { + const all_tags = useTags(); + + return ( +

+ + ) +} diff --git a/src/Components/Map/Subcomponents/ItemViewPopup.tsx b/src/Components/Map/Subcomponents/ItemViewPopup.tsx index 044ae844..b6dbe2df 100644 --- a/src/Components/Map/Subcomponents/ItemViewPopup.tsx +++ b/src/Components/Map/Subcomponents/ItemViewPopup.tsx @@ -2,9 +2,9 @@ import * as React from 'react' import { Popup as LeafletPopup, useMap } from 'react-leaflet' import { Item } from '../../../types' import { ItemFormPopupProps } from './ItemFormPopup' -import { HeaderView } from './HeaderView' -import StartEndView from './StartEndView' -import { TextView } from './TextView' +import { HeaderView } from './ItemPopupComponents/HeaderView' +import { StartEndView } from './ItemPopupComponents/StartEndView' +import { TextView } from './ItemPopupComponents/TextView' export interface ItemViewPopupProps { item: Item, @@ -21,13 +21,20 @@ export const ItemViewPopup = (props: ItemViewPopupProps) => {

- {props.children ? props.children : -
- {item.start && item.end && - } +
+ {props.children ? + + React.Children.toArray(props.children).map((child) => + React.isValidElement<{ item: Item, test: string }>(child) ? + React.cloneElement(child, { item: props.item }) : "" + ) + + : + -
- } + + } +
) diff --git a/src/Components/Map/Subcomponents/StartEndView.tsx b/src/Components/Map/Subcomponents/StartEndView.tsx deleted file mode 100644 index f798cb67..00000000 --- a/src/Components/Map/Subcomponents/StartEndView.tsx +++ /dev/null @@ -1,26 +0,0 @@ -import * as React from 'react' -import { Item } from '../../../types' - -const StartEndView = ({item} : {item:Item}) => { - return ( -
-
- - - - {new Date(item.start!).toISOString().substring(0, 10) || ""} -
-
- - -
-
- - - - {new Date(item.end!).toISOString().substring(0, 10) || ""} -
-
- ) -} - -export default StartEndView \ No newline at end of file diff --git a/src/Components/Map/Subcomponents/TextView.tsx b/src/Components/Map/Subcomponents/TextView.tsx deleted file mode 100644 index 67529477..00000000 --- a/src/Components/Map/Subcomponents/TextView.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import * as React from 'react' -import { Item } from '../../../types' -import { useTags } from '../hooks/useTags'; -import { replaceURLs } from '../../../Utils/ReplaceURLs'; -import { heighlightTags } from '../../../Utils/HeighlightTags'; - -export const TextView = ({item} : {item: Item}) => { - const all_tags = useTags(); - - return ( -

- - ) -} diff --git a/src/Components/Map/UtopiaMap.tsx b/src/Components/Map/UtopiaMap.tsx index d948e724..15e812ae 100644 --- a/src/Components/Map/UtopiaMap.tsx +++ b/src/Components/Map/UtopiaMap.tsx @@ -31,7 +31,7 @@ function MapEventListener(props: MapEventListenerProps) { }, resize: () => { console.log("resize"); - + } }) return null @@ -57,14 +57,15 @@ function UtopiaMap({

- + { React.Children.toArray(children).map((child) => - React.isValidElement<{ setItemFormPopup: React.Dispatch>, itemFormPopup: ItemFormPopupProps | null }>(child) ? React.cloneElement(child, { setItemFormPopup: setItemFormPopup, itemFormPopup: itemFormPopup }) : child + React.isValidElement<{ setItemFormPopup: React.Dispatch>, itemFormPopup: ItemFormPopupProps | null }>(child) && typeof child.type !== "string" && child.type.name === "Layer" ? + React.cloneElement(child, { setItemFormPopup: setItemFormPopup, itemFormPopup: itemFormPopup }) : child ) } diff --git a/src/Components/Map/index.tsx b/src/Components/Map/index.tsx index 8e7abc0e..69c0ea01 100644 --- a/src/Components/Map/index.tsx +++ b/src/Components/Map/index.tsx @@ -1,6 +1,9 @@ export { UtopiaMap } from './UtopiaMap'; export { Layer } from './Layer'; export { Tags } from "./Tags"; -export {ItemViewPopup} from './Subcomponents/ItemViewPopup'; export {ItemForm} from './ItemForm'; -export {ItemView} from './ItemView'; \ No newline at end of file +export {ItemView} from './ItemView'; +export {PopupTextAreaInput} from './Subcomponents/ItemPopupComponents/PopupTextAreaInput'; +export {PopupStartEndInput} from './Subcomponents/ItemPopupComponents/PopupStartEndInput'; +export {TextView} from './Subcomponents/ItemPopupComponents/TextView'; +export {StartEndView} from './Subcomponents/ItemPopupComponents/StartEndView' \ No newline at end of file diff --git a/src/index.tsx b/src/index.tsx index 4b34ee22..e072b3bf 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,4 +1,4 @@ -export { UtopiaMap, Layer, Tags, ItemViewPopup, ItemForm, ItemView } from './Components/Map/index'; +export { UtopiaMap, Layer, Tags, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, TextView, StartEndView } from './Components/Map/index'; export {AppShell, Content, SideBar} from "./Components/AppShell" export {AuthProvider, useAuth, LoginPage, SignupPage} from "./Components/Auth" export {Settings} from './Components/Profile'