Files
OpenBB/frontend-components/tables/src/components/Select.tsx
teh_coderer 979930b9e8 feature / Refactor Interactive Charts to React (#4941)
* init

* fix tables

* add shortcuts

* handle svgs

* test

* test2

* test3

* Update loggers.py

* Update sdk_helpers.py

* Update loggers.py

* Update loggers.py

* updates

* updates

* update

* handle add text high/low for candlestick traces when updating

* adding save overlay to tables

* maybe fix

* prints

* asdf

* working

* working

* removing prints

* update

* fix no figure title text

* add trace labels space

* download finished popup for MacOS

* bump pywry

* update

* update table

* Update plotly_helper.py

* only format numbers over 10_000 on tables

* Delete generate_index.py

* turn off logs in generations

* update tables

* bump pywry, fix tables, added ichimoku ta indicator

* Update backend.py

* mypy

* update tables

* updates

* juan more

* tables

* test

* bump pywry

* bump pywry

* Update loggers.py

* test

* fixing some formatting

* add update button to indicators dashboard

* fix oecd dates to be full dates

* prepare charts/tables for pywry update

* Update poetry.lock

* Update finviz_view.py

* tests

* tests

* tests

* tests

* testss?

* tests

* Create test_call_func[call_sec-nasdaq_view.sec_filings-other_args37-called_with37].yaml

* testtss please

* Update loggers.py

* testss

* `with open(newline="\n")`

* tests

* tests -__-

* why

* Revert "`with open(newline="\n")`"

This reverts commit 554e0f53f4.

* Revert "why"

This reverts commit 89f1d9b823.

* Revert "tests -__-"

This reverts commit a9c694ae96.

* Revert "tests"

This reverts commit 5463249498.

* whelp

* .

* rename `streamlit.py` -> `streamlit_run.py`,  bump pywry/finviz/streamlit

* Update backend.py

* update

* Revert "update file"

---------

Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
2023-05-11 17:38:12 +00:00

121 lines
4.4 KiB
TypeScript
Vendored

import * as SelectPrimitive from "@radix-ui/react-select";
import {
CheckIcon,
ChevronDownIcon,
ChevronUpIcon,
} from "@radix-ui/react-icons";
import { forwardRef } from "react";
import clsx from "clsx";
const Select = ({
value,
onChange,
label = "Select",
placeholder = "Select a fruit…",
groups,
labelType = "col",
}: {
value: string;
onChange: (value: string) => void;
label?: string;
placeholder?: string;
labelType?: "col" | "row";
groups: {
label: string;
items: {
label: string;
value: string | number;
disabled?: boolean;
}[];
}[];
}) => {
const onlyOneGroup = groups?.length === 1;
return (
<SelectPrimitive.Root value={value} onValueChange={onChange}>
<SelectPrimitive.Group
className={clsx("flex gap-1", {
"flex-row items-center gap-2": labelType === "row",
"flex-col": labelType === "col",
})}
>
<SelectPrimitive.Label className="whitespace-nowrap">
{label}
</SelectPrimitive.Label>
<SelectPrimitive.Trigger
className="justify-between bg-white text-black dark:text-white dark:bg-grey-900 whitespace-nowrap h-[36px] border-[1.5px] border-grey-700 rounded p-3 inline-flex items-center leading-none gap-[5px] shadow-[0_2px_10px] shadow-black/10 focus:shadow-[0_0_0_2px] focus:shadow-black data-[placeholder]:text-white outline-none"
aria-label={label}
>
<SelectPrimitive.Value placeholder={placeholder} />
<SelectPrimitive.Icon>
<ChevronDownIcon />
</SelectPrimitive.Icon>
</SelectPrimitive.Trigger>
</SelectPrimitive.Group>
<SelectPrimitive.Portal>
<SelectPrimitive.Content className="z-50 bg-white/80 dark:bg-grey-900/80 backdrop-filter backdrop-blur overflow-hidden border-[1.5px] border-grey-700 rounded p-3 shadow-[0px_10px_38px_-10px_rgba(22,_23,_24,_0.35),0px_10px_20px_-15px_rgba(22,_23,_24,_0.2)]">
<SelectPrimitive.ScrollUpButton className="flex items-center justify-center h-[25px] cursor-default dark:text-white text-black">
<ChevronUpIcon />
</SelectPrimitive.ScrollUpButton>
<SelectPrimitive.Viewport className="p-[5px]">
{onlyOneGroup ? (
<SelectPrimitive.Group>
{groups[0].items.map((item) => (
//@ts-ignore
<SelectItem value={item.value} disabled={item.disabled}>
{item.label}
</SelectItem>
))}
</SelectPrimitive.Group>
) : (
groups.map((group, idx) => (
<SelectPrimitive.Group key={group.label}>
<SelectPrimitive.Label className="text-xs leading-[25px]">
{group.label}
</SelectPrimitive.Label>
{group.items.map((item) => (
//@ts-ignore
<SelectItem
key={item.value}
value={item.value}
disabled={item.disabled}
>
{item.label}
</SelectItem>
))}
</SelectPrimitive.Group>
))
)}
</SelectPrimitive.Viewport>
<SelectPrimitive.ScrollDownButton className="flex items-center justify-center h-[25px] cursor-default dark:text-white text-black">
<ChevronDownIcon />
</SelectPrimitive.ScrollDownButton>
</SelectPrimitive.Content>
</SelectPrimitive.Portal>
</SelectPrimitive.Root>
);
};
const SelectItem = forwardRef(
//@ts-ignore
({ children, className, ...props }, forwardedRef) => {
return (
<SelectPrimitive.Item
className={clsx(
"text-[13px] leading-none rounded-[3px] flex items-center h-[25px] pr-[35px] pl-[25px] relative select-none data-[disabled]:text-grey-400 data-[disabled]:pointer-events-none data-[highlighted]:outline-none data-[highlighted]:bg-grey-600 data-[highlighted]:text-white text-black dark:text-white",
className
)}
{...props}
//@ts-ignore
ref={forwardedRef}
>
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
<SelectPrimitive.ItemIndicator className="absolute left-0 w-[25px] inline-flex items-center justify-center">
<CheckIcon />
</SelectPrimitive.ItemIndicator>
</SelectPrimitive.Item>
);
}
);
export default Select;