diff --git a/.changeset/stupid-avocados-dream.md b/.changeset/stupid-avocados-dream.md new file mode 100644 index 0000000..91d8159 --- /dev/null +++ b/.changeset/stupid-avocados-dream.md @@ -0,0 +1,5 @@ +--- +"solidui-cli": patch +--- + +add option for custom prev/next children diff --git a/apps/docs/public/registry/ui/pagination.json b/apps/docs/public/registry/ui/pagination.json index 9ac4510..250ef59 100644 --- a/apps/docs/public/registry/ui/pagination.json +++ b/apps/docs/public/registry/ui/pagination.json @@ -6,7 +6,7 @@ "files": [ { "name": "pagination.tsx", - "content": "import type { ValidComponent } from \"solid-js\"\nimport { splitProps } from \"solid-js\"\n\nimport * as PaginationPrimitive from \"@kobalte/core/pagination\"\nimport type { PolymorphicProps } from \"@kobalte/core/polymorphic\"\n\nimport { cn } from \"~/lib/utils\"\nimport { buttonVariants } from \"~/registry/ui/button\"\n\nconst PaginationItems = PaginationPrimitive.Items\n\ntype PaginationRootProps =\n PaginationPrimitive.PaginationRootProps & { class?: string | undefined }\n\nconst Pagination = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationRootProps, [\"class\"])\n return (\n *]:flex [&>*]:flex-row [&>*]:items-center [&>*]:gap-1\", local.class)}\n {...others}\n />\n )\n}\n\ntype PaginationItemProps =\n PaginationPrimitive.PaginationItemProps & { class?: string | undefined }\n\nconst PaginationItem = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationItemProps, [\"class\"])\n return (\n \n )\n}\n\ntype PaginationEllipsisProps =\n PaginationPrimitive.PaginationEllipsisProps & {\n class?: string | undefined\n }\n\nconst PaginationEllipsis = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationEllipsisProps, [\"class\"])\n return (\n \n \n \n \n \n \n More pages\n \n )\n}\n\ntype PaginationPreviousProps =\n PaginationPrimitive.PaginationPreviousProps & {\n class?: string | undefined\n }\n\nconst PaginationPrevious = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationPreviousProps, [\"class\"])\n return (\n \n \n \n \n Previous\n \n )\n}\n\ntype PaginationNextProps =\n PaginationPrimitive.PaginationNextProps & {\n class?: string | undefined\n }\n\nconst PaginationNext = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationNextProps, [\"class\"])\n return (\n \n Next\n \n \n \n \n )\n}\n\nexport {\n Pagination,\n PaginationItems,\n PaginationItem,\n PaginationEllipsis,\n PaginationPrevious,\n PaginationNext\n}\n" + "content": "import type { JSX, ValidComponent } from \"solid-js\"\nimport { splitProps } from \"solid-js\"\n\nimport * as PaginationPrimitive from \"@kobalte/core/pagination\"\nimport type { PolymorphicProps } from \"@kobalte/core/polymorphic\"\n\nimport { cn } from \"~/lib/utils\"\nimport { buttonVariants } from \"~/registry/ui/button\"\n\nconst PaginationItems = PaginationPrimitive.Items\n\ntype PaginationRootProps =\n PaginationPrimitive.PaginationRootProps & { class?: string | undefined }\n\nconst Pagination = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationRootProps, [\"class\"])\n return (\n *]:flex [&>*]:flex-row [&>*]:items-center [&>*]:gap-1\", local.class)}\n {...others}\n />\n )\n}\n\ntype PaginationItemProps =\n PaginationPrimitive.PaginationItemProps & { class?: string | undefined }\n\nconst PaginationItem = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationItemProps, [\"class\"])\n return (\n \n )\n}\n\ntype PaginationEllipsisProps =\n PaginationPrimitive.PaginationEllipsisProps & {\n class?: string | undefined\n }\n\nconst PaginationEllipsis = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationEllipsisProps, [\"class\"])\n return (\n \n \n \n \n \n \n More pages\n \n )\n}\n\ntype PaginationPreviousProps =\n PaginationPrimitive.PaginationPreviousProps & {\n class?: string | undefined\n children?: JSX.Element\n }\n\nconst PaginationPrevious = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationPreviousProps, [\"class\", \"children\"])\n return (\n \n {local.children ?? (\n <>\n \n \n \n Previous\n \n )}\n \n )\n}\n\ntype PaginationNextProps =\n PaginationPrimitive.PaginationNextProps & {\n class?: string | undefined\n children?: JSX.Element\n }\n\nconst PaginationNext = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as PaginationNextProps, [\"class\", \"children\"])\n return (\n \n {local.children ?? (\n <>\n Next\n \n \n \n \n )}\n \n )\n}\n\nexport {\n Pagination,\n PaginationItems,\n PaginationItem,\n PaginationEllipsis,\n PaginationPrevious,\n PaginationNext\n}\n" } ], "type": "ui" diff --git a/apps/docs/src/registry/ui/pagination.tsx b/apps/docs/src/registry/ui/pagination.tsx index 3858175..4808ac5 100644 --- a/apps/docs/src/registry/ui/pagination.tsx +++ b/apps/docs/src/registry/ui/pagination.tsx @@ -1,4 +1,4 @@ -import type { ValidComponent } from "solid-js" +import type { JSX, ValidComponent } from "solid-js" import { splitProps } from "solid-js" import * as PaginationPrimitive from "@kobalte/core/pagination" @@ -81,12 +81,13 @@ const PaginationEllipsis = ( type PaginationPreviousProps = PaginationPrimitive.PaginationPreviousProps & { class?: string | undefined + children?: JSX.Element } const PaginationPrevious = ( props: PolymorphicProps> ) => { - const [local, others] = splitProps(props as PaginationPreviousProps, ["class"]) + const [local, others] = splitProps(props as PaginationPreviousProps, ["class", "children"]) return ( ( )} {...others} > - - - - Previous + {local.children ?? ( + <> + + + + Previous + + )} ) } @@ -118,12 +123,13 @@ const PaginationPrevious = ( type PaginationNextProps = PaginationPrimitive.PaginationNextProps & { class?: string | undefined + children?: JSX.Element } const PaginationNext = ( props: PolymorphicProps> ) => { - const [local, others] = splitProps(props as PaginationNextProps, ["class"]) + const [local, others] = splitProps(props as PaginationNextProps, ["class", "children"]) return ( ( )} {...others} > - Next - - - + {local.children ?? ( + <> + Next + + + + + )} ) }