diff --git a/frontend/package.json b/frontend/package.json index eb3cfe90..0cb2e764 100755 --- a/frontend/package.json +++ b/frontend/package.json @@ -60,6 +60,7 @@ "react-driftjs": "^1.2.2", "react-dropzone": "^14.2.3", "react-ga4": "^2.0.0", + "react-hotkeys": "^2.0.0", "react-instantsearch-dom": "^6.28.0", "react-json-pretty": "^2.2.0", "react-json-view": "^1.21.3", @@ -76,10 +77,10 @@ "shellwords": "^0.1.1", "simplebar": "^4.2.3", "styled-components": "^4.4.0", + "webpack": "^5.88.2", "yaml": "^1.7.2", "yamljs": "^0.3.0", - "zone.js": "^0.13.1", - "webpack": "^5.88.2" + "zone.js": "^0.13.1" }, "scripts": { "start": "HTTPS=false&&PORT=3000 GENERATE_SOURCEMAP=false react-scripts --openssl-legacy-provider start", diff --git a/frontend/src/components/SearchData.jsx b/frontend/src/components/SearchData.jsx new file mode 100644 index 00000000..cc9c1551 --- /dev/null +++ b/frontend/src/components/SearchData.jsx @@ -0,0 +1,800 @@ +import React, { useState, useEffect, useRef } from 'react'; + +import theme from '../theme.jsx'; +import { useNavigate, Link, useParams } from "react-router-dom"; + +import { + Chip, + IconButton, + TextField, + InputAdornment, + List, + Card, + ListItem, + ListItemAvatar, + ListItemText, + Avatar, + Grid, + Typography, + Tooltip, + Divider, + Button, +} from '@mui/material'; +import ArticleIcon from '@mui/icons-material/Article'; +import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight'; +import ManageSearchIcon from '@mui/icons-material/ManageSearch'; +import { + AvatarGroup, +} from "@mui/material" + +import { Search as SearchIcon, Close as CloseIcon, Folder as FolderIcon, Code as CodeIcon, LibraryBooks as LibraryBooksIcon } from '@mui/icons-material' + +import algoliasearch from 'algoliasearch/lite'; +import aa from 'search-insights' +import { InstantSearch, Configure, connectSearchBox, connectHits, Index } from 'react-instantsearch-dom'; +//import { InstantSearch, SearchBox, Hits, connectSearchBox, connectHits, Index } from 'react-instantsearch-dom'; + +// https://www.algolia.com/doc/api-reference/widgets/search-box/react/ +const chipStyle = { + backgroundColor: "#3d3f43", height: 30, marginRight: 5, paddingLeft: 5, paddingRight: 5, height: 28, cursor: "pointer", borderColor: "#3d3f43", color: "white", +} + +const searchClient = algoliasearch("JNSS5CFDZZ", "db08e40265e2941b9a7d8f644b6e5240") +const SearchData = props => { + const { serverside, userdata, setModalOpen, modalOpen } = props + + let navigate = useNavigate(); + const borderRadius = 3 + const node = useRef() + const [searchOpen, setSearchOpen] = useState(true) + const [value, setValue] = useState(""); + const [userTyped, setUserTyped] = useState(false) + + if (serverside === true) { + return null + } + + //if (window !== undefined && window.location !== undefined && window.location.pathname === "/search") { + // return null + //} + + const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; + + //if (window.location.pathname !== oldPath) { + // setSearchOpen(false) + // setOldPath(window.location.pathname) + //} + + //if (window.location.pathname === "/search") { + // setModalOpen(true) + //} + // if (window.location.pathname === "/docs" || window.location.pathname === "/apps" || window.location.pathname === "/usecases" ) { + // setModalOpen(false) + // } + + //useEffect(() => { + // if (searchOpen) { + // var tarfield = document.getElementById("shuffle_search_field") + // tarfield.focus() + // } + //}, searchOpen) + + const SearchBox = ({ currentRefinement, refine, isSearchStalled, }) => { + const keyPressHandler = (e) => { + // e.preventDefault(); + if (e.which === 13) { + // alert("You pressed enter!"); + navigate("/search?q=" + currentRefinement, { state: value, replace: true }); + setSearchOpen(false) + setModalOpen(false) + return + } + }; + /* + endAdornment: ( + { + event.preventDefault() + }}> + { + setSearchOpen(false) + }} /> + + ), + */ + + return ( +