docs: fix error related to Key type (#5178)
* docs: fix error related to Key type * fix styling issue
This commit is contained in:
1 parent
25dad081b7
commit
27d74cb399
4 files changed
+17
-6
No files matched your search
@@ -3,16 +3,18 @@
|
|||||||
import { clx } from "@medusajs/ui"
|
import { clx } from "@medusajs/ui"
|
||||||
import * as Primitives from "@radix-ui/react-scroll-area"
|
import * as Primitives from "@radix-ui/react-scroll-area"
|
||||||
import clsx from "clsx"
|
import clsx from "clsx"
|
||||||
|
import { Key } from "@/types/props"
|
||||||
|
|
||||||
type ScrollbarProps = React.ComponentProps<typeof Primitives.Scrollbar>
|
type ScrollbarProps = React.ComponentProps<typeof Primitives.Scrollbar>
|
||||||
|
|
||||||
const Scrollbar = (props: ScrollbarProps) => {
|
const Scrollbar = ({ key, ...props }: ScrollbarProps) => {
|
||||||
return (
|
return (
|
||||||
<Primitives.Scrollbar
|
<Primitives.Scrollbar
|
||||||
className={clsx(
|
className={clsx(
|
||||||
"bg-medusa-bg-base dark:bg-medusa-bg-base-dark flex touch-none select-none p-0.5 transition-colors ease-out",
|
"bg-medusa-bg-base dark:bg-medusa-bg-base-dark flex touch-none select-none p-0.5 transition-colors ease-out",
|
||||||
"data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5 data-[orientation=horizontal]:flex-col"
|
"data-[orientation=horizontal]:h-2.5 data-[orientation=vertical]:w-2.5 data-[orientation=horizontal]:flex-col"
|
||||||
)}
|
)}
|
||||||
|
key={key as Key}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
@@ -20,7 +22,7 @@ const Scrollbar = (props: ScrollbarProps) => {
|
|||||||
|
|
||||||
type ThumbProps = React.ComponentProps<typeof Primitives.Thumb>
|
type ThumbProps = React.ComponentProps<typeof Primitives.Thumb>
|
||||||
|
|
||||||
const Thumb = ({ className, ...props }: ThumbProps) => {
|
const Thumb = ({ className, key, ...props }: ThumbProps) => {
|
||||||
return (
|
return (
|
||||||
<Primitives.Thumb
|
<Primitives.Thumb
|
||||||
className={clx(
|
className={clx(
|
||||||
@@ -28,6 +30,7 @@ const Thumb = ({ className, ...props }: ThumbProps) => {
|
|||||||
"before:min-h-[44px] before:w-full before:min-w-[44px] before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']",
|
"before:min-h-[44px] before:w-full before:min-w-[44px] before:-translate-x-1/2 before:-translate-y-1/2 before:content-['']",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
key={key as Key}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import { clx } from "@medusajs/ui"
|
import { clx } from "@medusajs/ui"
|
||||||
import * as Primitives from "@radix-ui/react-tabs"
|
import * as Primitives from "@radix-ui/react-tabs"
|
||||||
import * as React from "react"
|
import * as React from "react"
|
||||||
|
import { Key } from "@/types/props"
|
||||||
|
|
||||||
const Tabs = Primitives.Root
|
const Tabs = Primitives.Root
|
||||||
|
|
||||||
@@ -10,13 +11,14 @@ const TabsList = React.forwardRef<
|
|||||||
React.ElementRef<typeof Primitives.List>,
|
React.ElementRef<typeof Primitives.List>,
|
||||||
React.ComponentPropsWithoutRef<typeof Primitives.List>
|
React.ComponentPropsWithoutRef<typeof Primitives.List>
|
||||||
// eslint-disable-next-line react/prop-types
|
// eslint-disable-next-line react/prop-types
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, key, ...props }, ref) => (
|
||||||
<Primitives.List
|
<Primitives.List
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clx(
|
className={clx(
|
||||||
"inline-flex h-10 w-full items-end justify-start rounded-none bg-transparent p-0",
|
"inline-flex h-10 w-full items-end justify-start rounded-none bg-transparent p-0",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
key={key as Key}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
@@ -26,7 +28,7 @@ const TabsTrigger = React.forwardRef<
|
|||||||
React.ElementRef<typeof Primitives.Trigger>,
|
React.ElementRef<typeof Primitives.Trigger>,
|
||||||
React.ComponentPropsWithoutRef<typeof Primitives.Trigger>
|
React.ComponentPropsWithoutRef<typeof Primitives.Trigger>
|
||||||
// eslint-disable-next-line react/prop-types
|
// eslint-disable-next-line react/prop-types
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, key, ...props }, ref) => (
|
||||||
<Primitives.Trigger
|
<Primitives.Trigger
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clx(
|
className={clx(
|
||||||
@@ -35,6 +37,7 @@ const TabsTrigger = React.forwardRef<
|
|||||||
"dark:text-medusa-fg-subtle-dark dark:data-[state=active]:text-medusa-fg-base-dark",
|
"dark:text-medusa-fg-subtle-dark dark:data-[state=active]:text-medusa-fg-base-dark",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
key={key as Key}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
@@ -44,13 +47,14 @@ const TabsContent = React.forwardRef<
|
|||||||
React.ElementRef<typeof Primitives.Content>,
|
React.ElementRef<typeof Primitives.Content>,
|
||||||
React.ComponentPropsWithoutRef<typeof Primitives.Content>
|
React.ComponentPropsWithoutRef<typeof Primitives.Content>
|
||||||
// eslint-disable-next-line react/prop-types
|
// eslint-disable-next-line react/prop-types
|
||||||
>(({ className, ...props }, ref) => (
|
>(({ className, key, ...props }, ref) => (
|
||||||
<Primitives.Content
|
<Primitives.Content
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={clx(
|
className={clx(
|
||||||
"w-full rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 data-[state=active]:mt-4",
|
"w-full rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-offset-2 data-[state=active]:mt-4",
|
||||||
className
|
className
|
||||||
)}
|
)}
|
||||||
|
key={key as Key}
|
||||||
{...props}
|
{...props}
|
||||||
/>
|
/>
|
||||||
))
|
))
|
||||||
|
|||||||
@@ -37,3 +37,7 @@ export type PropDataMap = PropData[]
|
|||||||
export type PropRegistryItem = {
|
export type PropRegistryItem = {
|
||||||
table: LazyExoticComponent<ComponentType>
|
table: LazyExoticComponent<ComponentType>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// resolve type errors related to
|
||||||
|
// key with radix components
|
||||||
|
export type Key = string | number | null | undefined
|
||||||
@@ -64,7 +64,7 @@ export const CodeBlock = ({
|
|||||||
className={clsx(
|
className={clsx(
|
||||||
"text-code-body font-monospace table min-w-full pb-docs_1.5 print:whitespace-pre-wrap",
|
"text-code-body font-monospace table min-w-full pb-docs_1.5 print:whitespace-pre-wrap",
|
||||||
tokens.length > 1 && "pt-docs_1 pr-docs_1",
|
tokens.length > 1 && "pt-docs_1 pr-docs_1",
|
||||||
tokens.length <= 1 && "py-docs_0.5 px-docs_1"
|
tokens.length <= 1 && "!py-docs_0.5 px-docs_1"
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{tokens.map((line, i) => {
|
{tokens.map((line, i) => {
|
||||||
|
|||||||
Reference in new issue
Block a user