update implied volatility component

This commit is contained in:
MuslemRahimi 2024-08-02 17:07:12 +02:00
parent 184b437f56
commit 383d8e93a5
51 changed files with 242 additions and 80 deletions

View File

@ -5,23 +5,19 @@
import { formatDateRange } from "$lib/utils"; import { formatDateRange } from "$lib/utils";
import Lazy from 'svelte-lazy'; import Lazy from 'svelte-lazy';
export let data; export let data;
let isLoaded = false; let isLoaded = false;
let displayIV = 'iv60';
let rawData = []; let rawData = [];
let optionsData; let optionsData;
let avgFee;
let lowestIV; let lowestIV;
let highestIV; let highestIV;
let lowestRV; let lowestRV;
let highestRV; let highestRV;
let ivRank; let ivRank;
let totalAvailableShares;
function findLowestAndhighestIV(data, lastDateStr) { function findLowestAndhighestIV(data, lastDateStr) {
// Convert lastDateStr to Date object // Convert lastDateStr to Date object
const lastDate = new Date(lastDateStr); const lastDate = new Date(lastDateStr);
@ -49,27 +45,16 @@ function findLowestAndhighestIV(data, lastDateStr) {
} }
function normalizer(value) { function changeStatement(event)
if (Math?.abs(value) >= 1e18) { {
return { unit: 'Q', denominator: 1e18 }; displayIV = event.target.value;
} else if (Math?.abs(value) >= 1e12) { optionsData = getPlotOptions()
return { unit: 'T', denominator: 1e12 }; }
} else if (Math?.abs(value) >= 1e9) {
return { unit: 'B', denominator: 1e9 };
} else if (Math?.abs(value) >= 1e6) {
return { unit: 'M', denominator: 1e6 };
} else if (Math?.abs(value) >= 1e5) {
return { unit: 'K', denominator: 1e5 };
} else {
return { unit: '', denominator: 1 };
}
}
function getPlotOptions() { function getPlotOptions() {
let dates = []; let dates = [];
let priceList = []; let priceList = [];
let iv60List = []; let ivList = [];
let realizedVolatility = []; let realizedVolatility = [];
// Iterate over the data and extract required information // Iterate over the data and extract required information
@ -77,7 +62,7 @@ function findLowestAndhighestIV(data, lastDateStr) {
dates?.push(item?.date); dates?.push(item?.date);
priceList?.push(item?.stockpx); priceList?.push(item?.stockpx);
iv60List?.push(item?.iv60) ivList?.push(item[displayIV])
realizedVolatility?.push(item['60dorhv']) realizedVolatility?.push(item['60dorhv'])
}); });
@ -86,16 +71,10 @@ function findLowestAndhighestIV(data, lastDateStr) {
findLowestAndhighestIV(rawData, rawData?.slice(-1)?.at(0)?.date) findLowestAndhighestIV(rawData, rawData?.slice(-1)?.at(0)?.date)
// Calculate IV Rank // Calculate IV Rank
const lowestIV = Math.min(...iv60List); // Find the lowest IV in the past const lowestIV = Math.min(...ivList); // Find the lowest IV in the past
const highestIV = Math.max(...iv60List); // Find the highest IV in the past const highestIV = Math.max(...ivList); // Find the highest IV in the past
ivRank = ((iv60List?.slice(-1) - lowestIV) / (highestIV - lowestIV) * 100).toFixed(2); // Compute IV Rank ivRank = ((ivList?.slice(-1) - lowestIV) / (highestIV - lowestIV) * 100).toFixed(2); // Compute IV Rank
// Compute the average of item?.traded
const totalNumber = iv60List?.reduce((acc, item) => acc + item, 0);
avgFee = (totalNumber / iv60List?.length)?.toFixed(1);
totalAvailableShares = priceList?.reduce((accumulator, sum) => {
return accumulator + sum;
}, 0);
const option = { const option = {
@ -104,7 +83,7 @@ function findLowestAndhighestIV(data, lastDateStr) {
trigger: 'axis', trigger: 'axis',
hideDelay: 100, // Set the delay in milliseconds hideDelay: 100, // Set the delay in milliseconds
}, },
animation: $screenWidth < 640 ? false: true, animation: false,
grid: { grid: {
left: '0%', left: '0%',
right: '0%', right: '0%',
@ -166,7 +145,7 @@ function findLowestAndhighestIV(data, lastDateStr) {
}, },
{ {
name: 'IV', name: 'IV',
data: iv60List, data: ivList,
type: 'line', type: 'line',
areaStyle: {opacity: 0.3}, areaStyle: {opacity: 0.3},
stack: 'ImpliedVolatility', stack: 'ImpliedVolatility',
@ -231,6 +210,7 @@ function findLowestAndhighestIV(data, lastDateStr) {
$: { $: {
if($assetType === 'stock' ? $stockTicker : $etfTicker && typeof window !== 'undefined') { if($assetType === 'stock' ? $stockTicker : $etfTicker && typeof window !== 'undefined') {
isLoaded=false; isLoaded=false;
displayIV = 'iv60';
const ticker = $assetType === 'stock' ? $stockTicker : $etfTicker const ticker = $assetType === 'stock' ? $stockTicker : $etfTicker
const asyncFunctions = [ const asyncFunctions = [
getImpliedVolatility(ticker) getImpliedVolatility(ticker)
@ -273,12 +253,27 @@ function findLowestAndhighestIV(data, lastDateStr) {
{#if rawData?.length !== 0} {#if rawData?.length !== 0}
<div class="w-full flex flex-col items-start"> <div class="w-full flex flex-col items-start mb-2">
<div class="text-white text-[1rem] mt-2 mb-2 w-full"> <div class="text-white text-[1rem] mt-2 mb-2 w-full">
Based on the past 12 months of historical data, {$displayCompanyName} has an IV Rank of <span class="font-semibold">{ivRank}%</span>, with the current implied volatility standing at <span class="font-semibold">{rawData?.slice(-1)?.at(0)?.iv60}%</span>. Based on the past 12 months of historical data, {$displayCompanyName} has an IV Rank of <span class="font-semibold">{ivRank}%</span>, with the current implied volatility standing at <span class="font-semibold">{rawData?.slice(-1)?.at(0)?.iv60}%</span>.
</div> </div>
</div> </div>
<select class="mt-5 mb-5 sm:mb-0 sm:mt-3 ml-1 w-44 select select-bordered select-sm p-0 pl-5 overflow-y-auto bg-[#2A303C]" on:change={changeStatement}>
<option disabled>Choose IV Period</option>
<option selected value="iv60">
60 Day IV
</option>
<option value="iv90">
90 Day IV
</option>
<option value="252dclshv">
1 Year historical volatility
</option>
</select>
<div class="pb-2 rounded-lg bg-[#09090B]"> <div class="pb-2 rounded-lg bg-[#09090B]">

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLTableAttributes } from "svelte/elements"; import type { HTMLTableAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils
type $$Props = HTMLTableAttributes; type $$Props = HTMLTableAttributes;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Accordion as AccordionPrimitive } from "bits-ui"; import { Accordion as AccordionPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = AccordionPrimitive.ItemProps; type $$Props = AccordionPrimitive.ItemProps;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { Accordion as AccordionPrimitive } from "bits-ui"; import { Accordion as AccordionPrimitive } from "bits-ui";
import ChevronDown from "lucide-svelte/icons/chevron-down"; import ChevronDown from "lucide-svelte/icons/chevron-down";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = AccordionPrimitive.TriggerProps; type $$Props = AccordionPrimitive.TriggerProps;
type $$Events = AccordionPrimitive.TriggerEvents; type $$Events = AccordionPrimitive.TriggerEvents;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { Button as ButtonPrimitive } from "bits-ui"; import { Button as ButtonPrimitive } from "bits-ui";
import { type Events, type Props, buttonVariants } from "./index.ts"; import { type Events, type Props, buttonVariants } from "./index.ts";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = Props; type $$Props = Props;
type $$Events = Events; type $$Events = Events;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLDivElement>; type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLParagraphElement>; type $$Props = HTMLAttributes<HTMLParagraphElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLDivElement>; type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLDivElement>; type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import type { HeadingLevel } from "./index.ts"; import type { HeadingLevel } from "./index.ts";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLHeadingElement> & { type $$Props = HTMLAttributes<HTMLHeadingElement> & {
tag?: HeadingLevel; tag?: HeadingLevel;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLDivElement>; type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.EmptyProps; type $$Props = CommandPrimitive.EmptyProps;
let className: string | undefined | null = undefined; let className: string | undefined | null = undefined;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.GroupProps; type $$Props = CommandPrimitive.GroupProps;
let className: string | undefined | null = undefined; let className: string | undefined | null = undefined;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import Search from "lucide-svelte/icons/search"; import Search from "lucide-svelte/icons/search";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.InputProps; type $$Props = CommandPrimitive.InputProps;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.ItemProps; type $$Props = CommandPrimitive.ItemProps;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.ListProps; type $$Props = CommandPrimitive.ListProps;
let className: string | undefined | null = undefined; let className: string | undefined | null = undefined;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.SeparatorProps; type $$Props = CommandPrimitive.SeparatorProps;
let className: string | undefined | null = undefined; let className: string | undefined | null = undefined;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLSpanElement>; type $$Props = HTMLAttributes<HTMLSpanElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Command as CommandPrimitive } from "cmdk-sv"; import { Command as CommandPrimitive } from "cmdk-sv";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = CommandPrimitive.CommandProps; type $$Props = CommandPrimitive.CommandProps;

View File

@ -2,7 +2,7 @@
import { Dialog as DialogPrimitive } from "bits-ui"; import { Dialog as DialogPrimitive } from "bits-ui";
import X from "lucide-svelte/icons/x"; import X from "lucide-svelte/icons/x";
import * as Dialog from "./index.js"; import * as Dialog from "./index.js";
import { cn, flyAndScale } from "$lib/utils.js"; import { cn, flyAndScale } from "$lib/utils";
type $$Props = DialogPrimitive.ContentProps; type $$Props = DialogPrimitive.ContentProps;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Dialog as DialogPrimitive } from "bits-ui"; import { Dialog as DialogPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DialogPrimitive.DescriptionProps; type $$Props = DialogPrimitive.DescriptionProps;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLDivElement>; type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLDivElement>; type $$Props = HTMLAttributes<HTMLDivElement>;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { Dialog as DialogPrimitive } from "bits-ui"; import { Dialog as DialogPrimitive } from "bits-ui";
import { fade } from "svelte/transition"; import { fade } from "svelte/transition";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DialogPrimitive.OverlayProps; type $$Props = DialogPrimitive.OverlayProps;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Dialog as DialogPrimitive } from "bits-ui"; import { Dialog as DialogPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DialogPrimitive.TitleProps; type $$Props = DialogPrimitive.TitleProps;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import Check from "lucide-svelte/icons/check"; import Check from "lucide-svelte/icons/check";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.CheckboxItemProps; type $$Props = DropdownMenuPrimitive.CheckboxItemProps;
type $$Events = DropdownMenuPrimitive.CheckboxItemEvents; type $$Events = DropdownMenuPrimitive.CheckboxItemEvents;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js"; import { cn, flyAndScale } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.ContentProps; type $$Props = DropdownMenuPrimitive.ContentProps;
type $$Events = DropdownMenuPrimitive.ContentEvents; type $$Events = DropdownMenuPrimitive.ContentEvents;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.ItemProps & { type $$Props = DropdownMenuPrimitive.ItemProps & {
inset?: boolean; inset?: boolean;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.LabelProps & { type $$Props = DropdownMenuPrimitive.LabelProps & {
inset?: boolean; inset?: boolean;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import Circle from "lucide-svelte/icons/circle"; import Circle from "lucide-svelte/icons/circle";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.RadioItemProps; type $$Props = DropdownMenuPrimitive.RadioItemProps;
type $$Events = DropdownMenuPrimitive.RadioItemEvents; type $$Events = DropdownMenuPrimitive.RadioItemEvents;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.SeparatorProps; type $$Props = DropdownMenuPrimitive.SeparatorProps;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLSpanElement>; type $$Props = HTMLAttributes<HTMLSpanElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js"; import { cn, flyAndScale } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.SubContentProps; type $$Props = DropdownMenuPrimitive.SubContentProps;
type $$Events = DropdownMenuPrimitive.SubContentEvents; type $$Events = DropdownMenuPrimitive.SubContentEvents;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui"; import { DropdownMenu as DropdownMenuPrimitive } from "bits-ui";
import ChevronRight from "lucide-svelte/icons/chevron-right"; import ChevronRight from "lucide-svelte/icons/chevron-right";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = DropdownMenuPrimitive.SubTriggerProps & { type $$Props = DropdownMenuPrimitive.SubTriggerProps & {
inset?: boolean; inset?: boolean;

View File

@ -1,7 +1,7 @@
<script lang="ts"> <script lang="ts">
import type { HTMLInputAttributes } from "svelte/elements"; import type { HTMLInputAttributes } from "svelte/elements";
import type { InputEvents } from "./index.ts"; import type { InputEvents } from "./index.ts";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLInputAttributes; type $$Props = HTMLInputAttributes;
type $$Events = InputEvents; type $$Events = InputEvents;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Progress as ProgressPrimitive } from "bits-ui"; import { Progress as ProgressPrimitive } from "bits-ui";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = ProgressPrimitive.Props; type $$Props = ProgressPrimitive.Props;

View File

@ -0,0 +1,34 @@
import { Select as SelectPrimitive } from "bits-ui";
import Label from "./select-label.svelte";
import Item from "./select-item.svelte";
import Content from "./select-content.svelte";
import Trigger from "./select-trigger.svelte";
import Separator from "./select-separator.svelte";
const Root = SelectPrimitive.Root;
const Group = SelectPrimitive.Group;
const Input = SelectPrimitive.Input;
const Value = SelectPrimitive.Value;
export {
Root,
Group,
Input,
Label,
Item,
Value,
Content,
Trigger,
Separator,
//
Root as Select,
Group as SelectGroup,
Input as SelectInput,
Label as SelectLabel,
Item as SelectItem,
Value as SelectValue,
Content as SelectContent,
Trigger as SelectTrigger,
Separator as SelectSeparator,
};

View File

@ -0,0 +1,39 @@
<script lang="ts">
import { Select as SelectPrimitive } from "bits-ui";
import { scale } from "svelte/transition";
import { cn, flyAndScale } from "$lib/utils";
type $$Props = SelectPrimitive.ContentProps;
type $$Events = SelectPrimitive.ContentEvents;
export let sideOffset: $$Props["sideOffset"] = 4;
export let inTransition: $$Props["inTransition"] = flyAndScale;
export let inTransitionConfig: $$Props["inTransitionConfig"] = undefined;
export let outTransition: $$Props["outTransition"] = scale;
export let outTransitionConfig: $$Props["outTransitionConfig"] = {
start: 0.95,
opacity: 0,
duration: 50,
};
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<SelectPrimitive.Content
{inTransition}
{inTransitionConfig}
{outTransition}
{outTransitionConfig}
{sideOffset}
class={cn(
"bg-[#09090B] text-white relative z-50 min-w-[8rem] overflow-hidden rounded-md border border-gray-800 shadow-md outline-none",
className
)}
{...$$restProps}
on:keydown
>
<div class="w-full p-1">
<slot />
</div>
</SelectPrimitive.Content>

View File

@ -0,0 +1,40 @@
<script lang="ts">
import Check from "lucide-svelte/icons/check";
import { Select as SelectPrimitive } from "bits-ui";
import { cn } from "$lib/utils";
type $$Props = SelectPrimitive.ItemProps;
type $$Events = SelectPrimitive.ItemEvents;
let className: $$Props["class"] = undefined;
export let value: $$Props["value"];
export let label: $$Props["label"] = undefined;
export let disabled: $$Props["disabled"] = undefined;
export { className as class };
</script>
<SelectPrimitive.Item
{value}
{disabled}
{label}
class={cn(
"data-[highlighted]:bg-[#27272A] data-[highlighted]:text-white relative flex w-full cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
className
)}
{...$$restProps}
on:click
on:keydown
on:focusin
on:focusout
on:pointerleave
on:pointermove
>
<span class="absolute left-2 flex h-3.5 w-3.5 items-center justify-center">
<SelectPrimitive.ItemIndicator>
<Check class="h-4 w-4" />
</SelectPrimitive.ItemIndicator>
</span>
<slot>
{label || value}
</slot>
</SelectPrimitive.Item>

View File

@ -0,0 +1,16 @@
<script lang="ts">
import { Select as SelectPrimitive } from "bits-ui";
import { cn } from "$lib/utils";
type $$Props = SelectPrimitive.LabelProps;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<SelectPrimitive.Label
class={cn("py-1.5 pl-8 pr-2 text-sm font-semibold", className)}
{...$$restProps}
>
<slot />
</SelectPrimitive.Label>

View File

@ -0,0 +1,11 @@
<script lang="ts">
import { Select as SelectPrimitive } from "bits-ui";
import { cn } from "$lib/utils";
type $$Props = SelectPrimitive.SeparatorProps;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<SelectPrimitive.Separator class={cn("bg-muted -mx-1 my-1 h-px", className)} {...$$restProps} />

View File

@ -0,0 +1,27 @@
<script lang="ts">
import { Select as SelectPrimitive } from "bits-ui";
import ChevronDown from "lucide-svelte/icons/chevron-down";
import { cn } from "$lib/utils";
type $$Props = SelectPrimitive.TriggerProps;
type $$Events = SelectPrimitive.TriggerEvents;
let className: $$Props["class"] = undefined;
export { className as class };
</script>
<SelectPrimitive.Trigger
class={cn(
"border-input bg-[#09090B] ring-offset-background focus-visible:ring-ring aria-[invalid]:border-destructive data-[placeholder]:[&>span]:text-white flex h-10 w-full items-center justify-between rounded-md border border-gray-800 px-3 py-2 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",
className
)}
{...$$restProps}
let:builder
on:click
on:keydown
>
<slot {builder} />
<div>
<ChevronDown class="h-4 w-4 opacity-50" />
</div>
</SelectPrimitive.Trigger>

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLTableSectionElement>; type $$Props = HTMLAttributes<HTMLTableSectionElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLTableCaptionElement>; type $$Props = HTMLAttributes<HTMLTableCaptionElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLTdAttributes } from "svelte/elements"; import type { HTMLTdAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLTdAttributes; type $$Props = HTMLTdAttributes;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLTableSectionElement>; type $$Props = HTMLAttributes<HTMLTableSectionElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLThAttributes } from "svelte/elements"; import type { HTMLThAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLThAttributes; type $$Props = HTMLThAttributes;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLTableSectionElement>; type $$Props = HTMLAttributes<HTMLTableSectionElement>;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import type { HTMLAttributes } from "svelte/elements"; import type { HTMLAttributes } from "svelte/elements";
import { cn } from "$lib/utils.js"; import { cn } from "$lib/utils";
type $$Props = HTMLAttributes<HTMLTableRowElement> & { type $$Props = HTMLAttributes<HTMLTableRowElement> & {
"data-state"?: unknown; "data-state"?: unknown;

View File

@ -1,6 +1,6 @@
<script lang="ts"> <script lang="ts">
import { Tooltip as TooltipPrimitive } from "bits-ui"; import { Tooltip as TooltipPrimitive } from "bits-ui";
import { cn, flyAndScale } from "$lib/utils.js"; import { cn, flyAndScale } from "$lib/utils";
type $$Props = TooltipPrimitive.ContentProps; type $$Props = TooltipPrimitive.ContentProps;

View File

@ -2,7 +2,7 @@
import { numberOfUnreadNotification, screenWidth, isOpen } from '$lib/store'; import { numberOfUnreadNotification, screenWidth, isOpen } from '$lib/store';
import { onMount, onDestroy } from 'svelte'; import { onMount, onDestroy } from 'svelte';
import UpgradeToPro from '$lib/components/UpgradeToPro.svelte'; import UpgradeToPro from '$lib/components/UpgradeToPro.svelte';
import { abbreviateNumber } from '$lib/utils.js'; import { abbreviateNumber } from '$lib/utils';
import { goto } from '$app/navigation'; import { goto } from '$app/navigation';
export let data; export let data;