Skip to content

Commit

Permalink
resolve merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
pyshx committed Nov 1, 2023
2 parents 600c0e9 + 12eddc8 commit a0ddad4
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 29 deletions.
6 changes: 3 additions & 3 deletions web/src/beta/components/Popover/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
useInteractions,
useRole,
} from "@floating-ui/react";
import * as React from "react";
import { useState, useMemo } from "react";

import { PopoverOptions } from "./types";

Expand All @@ -21,7 +21,7 @@ export default function usePopover({
open: controlledOpen,
onOpenChange: setControlledOpen,
}: PopoverOptions = {}) {
const [uncontrolledOpen, setUncontrolledOpen] = React.useState(initialOpen);
const [uncontrolledOpen, setUncontrolledOpen] = useState(initialOpen);

const open = controlledOpen ?? uncontrolledOpen;
const setOpen = setControlledOpen ?? setUncontrolledOpen;
Expand Down Expand Up @@ -52,7 +52,7 @@ export default function usePopover({

const interactions = useInteractions([click, dismiss, role]);

return React.useMemo(
return useMemo(
() => ({
open,
setOpen,
Expand Down
4 changes: 2 additions & 2 deletions web/src/beta/components/Portal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { ReactNode, useLayoutEffect } from "react";
import { ReactNode, useLayoutEffect, useState } from "react";
import ReactDOM from "react-dom";

const Portal: React.FC<{ children?: ReactNode }> = ({ children }) => {
const [node, setNode] = React.useState<HTMLElement>();
const [node, setNode] = useState<HTMLElement>();

useLayoutEffect(() => {
setNode(document.body);
Expand Down
31 changes: 20 additions & 11 deletions web/src/beta/features/Editor/DataSourceManager/Common/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from "react";
import { useCallback, useMemo, useState } from "react";

import Button from "@reearth/beta/components/Button";
import SelectField from "@reearth/beta/components/fields/SelectField";
Expand Down Expand Up @@ -39,11 +39,11 @@ const SelectDataType: React.FC<{ fileFormat: string; setFileFormat: (k: string)

const Asset: React.FC<DataProps> = ({ sceneId, onSubmit, onClose }) => {
const t = useT();
const [sourceType, setSourceType] = React.useState<SourceType>("local");
const [fileFormat, setFileFormat] = React.useState<FileFormatType>("GeoJSON");
const [value, setValue] = React.useState("");
const [layerName, setLayerName] = React.useState("");
const [prioritizePerformance, setPrioritizePerformance] = React.useState(false);
const [sourceType, setSourceType] = useState<SourceType>("local");
const [fileFormat, setFileFormat] = useState<FileFormatType>("GeoJSON");
const [value, setValue] = useState("");
const [layerName, setLayerName] = useState("");
const [prioritizePerformance, setPrioritizePerformance] = useState(false);
const DataSourceOptions: DataSourceOptType = useMemo(
() => [
{ label: t("From Assets"), keyValue: "local" },
Expand All @@ -57,10 +57,14 @@ const Asset: React.FC<DataProps> = ({ sceneId, onSubmit, onClose }) => {
let parsedValue = null;

if (sourceType === "value" && value !== "") {
try {
parsedValue = JSON.parse(value);
} catch (error) {
parsedValue = value;
if (fileFormat === "GeoJSON") {
try {
parsedValue = JSON.parse(value);
} catch (error) {
parsedValue = value;
}
} else {
parsedValue = "data:text/plain;charset=UTF-8," + encodeURIComponent(value);
}
}

Expand All @@ -71,7 +75,12 @@ const Asset: React.FC<DataProps> = ({ sceneId, onSubmit, onClose }) => {
visible: true,
config: {
data: {
url: (sourceType === "url" || sourceType === "local") && value !== "" ? value : undefined,
url:
(sourceType === "url" || sourceType === "local") && value !== ""
? value
: fileFormat === "CZML" || fileFormat === "KML"
? parsedValue
: undefined,
type: fileFormat.toLowerCase() as DataType,
value: parsedValue,
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useCallback, useMemo } from "react";
import { useCallback, useMemo, useState } from "react";

import Button from "@reearth/beta/components/Button";
import URLField from "@reearth/beta/components/fields/URLField";
Expand All @@ -20,11 +20,11 @@ import {
const DelimitedText: React.FC<DataProps> = ({ sceneId, onSubmit, onClose }) => {
const t = useT();

const [sourceType, setSourceType] = React.useState<SourceType>("local");
const [value, setValue] = React.useState("");
const [layerName, setLayerName] = React.useState("");
const [lat, setLat] = React.useState("");
const [long, setLong] = React.useState("");
const [sourceType, setSourceType] = useState<SourceType>("local");
const [value, setValue] = useState("");
const [layerName, setLayerName] = useState("");
const [lat, setLat] = useState("");
const [long, setLong] = useState("");

const DataSourceOptions: DataSourceOptType = useMemo(
() => [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import { useState } from "react";

import Button from "@reearth/beta/components/Button";

Expand All @@ -13,7 +13,7 @@ import {
} from "../utils";

const ThreeDTiles: React.FC<DataProps> = ({ sceneId, onSubmit, onClose }) => {
const [value, setValue] = React.useState("");
const [value, setValue] = useState("");

const handleSubmit = () => {
onSubmit({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const VectorTiles: FC<DataProps> = ({ sceneId, onSubmit, onClose }) => {
data: {
url: urlValue !== "" ? urlValue : undefined,
type: "mvt",
layers: layers.length === 1 ? layers[0] : layers,
layers: updatedLayers.length === 1 ? updatedLayers[0] : updatedLayers,
},
},
});
Expand Down
16 changes: 12 additions & 4 deletions web/src/beta/lib/lexical/RichTextEditor/ui/DropDown.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import * as React from "react";
import { ReactNode, useCallback, useEffect, useMemo, useRef, useState } from "react";
import {
useContext,
createContext,
ReactNode,
useCallback,
useEffect,
useMemo,
useRef,
useState,
} from "react";
import { createPortal } from "react-dom";

type DropDownContextType = {
registerItem: (ref: React.RefObject<HTMLButtonElement>) => void;
};

const DropDownContext = React.createContext<DropDownContextType | null>(null);
const DropDownContext = createContext<DropDownContextType | null>(null);

const dropDownPadding = 4;

Expand All @@ -23,7 +31,7 @@ export function DropDownItem({
}) {
const ref = useRef<HTMLButtonElement>(null);

const dropDownContext = React.useContext(DropDownContext);
const dropDownContext = useContext(DropDownContext);

if (dropDownContext === null) {
throw new Error("DropDownItem must be used within a DropDown");
Expand Down

0 comments on commit a0ddad4

Please sign in to comment.