From 9f688f61c1193dfcd4648e2fe6e0f2866c4cc502 Mon Sep 17 00:00:00 2001 From: Stefan E-K Date: Wed, 18 Sep 2024 14:14:35 +0200 Subject: [PATCH] fix(number-field): fixed blinking focus ring problems (#126) --- .changeset/fast-swans-cry.md | 5 +++++ apps/docs/public/registry/ui/number-field.json | 2 +- .../src/registry/example/number-field-demo.tsx | 5 +++-- apps/docs/src/registry/ui/number-field.tsx | 18 ++++++++++++++++-- .../routes/docs/components/number-field.mdx | 5 +++-- 5 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 .changeset/fast-swans-cry.md diff --git a/.changeset/fast-swans-cry.md b/.changeset/fast-swans-cry.md new file mode 100644 index 00000000..ed34f52b --- /dev/null +++ b/.changeset/fast-swans-cry.md @@ -0,0 +1,5 @@ +--- +"solidui-cli": patch +--- + +fix(number-field): fixed blinking focus ring problems (#126) diff --git a/apps/docs/public/registry/ui/number-field.json b/apps/docs/public/registry/ui/number-field.json index 01cdee20..7e2fd70e 100644 --- a/apps/docs/public/registry/ui/number-field.json +++ b/apps/docs/public/registry/ui/number-field.json @@ -6,7 +6,7 @@ "files": [ { "name": "number-field.tsx", - "content": "import type { JSX, ValidComponent } from \"solid-js\"\nimport { splitProps } from \"solid-js\"\n\nimport * as NumberFieldPrimitive from \"@kobalte/core/number-field\"\nimport type { PolymorphicProps } from \"@kobalte/core/polymorphic\"\n\nimport { cn } from \"~/lib/utils\"\n\nconst NumberField = NumberFieldPrimitive.Root\n\ntype NumberFieldLabelProps =\n NumberFieldPrimitive.NumberFieldLabelProps & {\n class?: string | undefined\n }\n\nconst NumberFieldLabel = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldLabelProps, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldInputProps =\n NumberFieldPrimitive.NumberFieldInputProps & {\n class?: string | undefined\n }\n\nconst NumberFieldInput = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldInputProps, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldIncrementTriggerProps =\n NumberFieldPrimitive.NumberFieldIncrementTriggerProps & {\n class?: string | undefined\n children?: JSX.Element\n }\n\nconst NumberFieldIncrementTrigger = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldIncrementTriggerProps, [\n \"class\",\n \"children\"\n ])\n return (\n \n {local.children ?? (\n \n \n \n )}\n \n )\n}\n\ntype NumberFieldDecrementTriggerProps =\n NumberFieldPrimitive.NumberFieldDecrementTriggerProps & {\n class?: string | undefined\n children?: JSX.Element\n }\n\nconst NumberFieldDecrementTrigger = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldDecrementTriggerProps, [\n \"class\",\n \"children\"\n ])\n return (\n \n {local.children ?? (\n \n \n \n )}\n \n )\n}\n\ntype NumberFieldDescriptionProps =\n NumberFieldPrimitive.NumberFieldDescriptionProps & {\n class?: string | undefined\n }\n\nconst NumberFieldDescription = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldDescriptionProps, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldErrorMessageProps =\n NumberFieldPrimitive.NumberFieldErrorMessageProps & {\n class?: string | undefined\n }\n\nconst NumberFieldErrorMessage = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldErrorMessageProps, [\"class\"])\n return (\n \n )\n}\n\nexport {\n NumberField,\n NumberFieldLabel,\n NumberFieldInput,\n NumberFieldIncrementTrigger,\n NumberFieldDecrementTrigger,\n NumberFieldDescription,\n NumberFieldErrorMessage\n}\n" + "content": "import type { Component, ComponentProps, JSX, ValidComponent } from \"solid-js\"\nimport { splitProps } from \"solid-js\"\n\nimport * as NumberFieldPrimitive from \"@kobalte/core/number-field\"\nimport type { PolymorphicProps } from \"@kobalte/core/polymorphic\"\n\nimport { cn } from \"~/lib/utils\"\n\nconst NumberField = NumberFieldPrimitive.Root\n\nconst NumberFieldGroup: Component> = (props) => {\n const [local, others] = splitProps(props, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldLabelProps =\n NumberFieldPrimitive.NumberFieldLabelProps & {\n class?: string | undefined\n }\n\nconst NumberFieldLabel = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldLabelProps, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldInputProps =\n NumberFieldPrimitive.NumberFieldInputProps & {\n class?: string | undefined\n }\n\nconst NumberFieldInput = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldInputProps, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldIncrementTriggerProps =\n NumberFieldPrimitive.NumberFieldIncrementTriggerProps & {\n class?: string | undefined\n children?: JSX.Element\n }\n\nconst NumberFieldIncrementTrigger = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldIncrementTriggerProps, [\n \"class\",\n \"children\"\n ])\n return (\n \n {local.children ?? (\n \n \n \n )}\n \n )\n}\n\ntype NumberFieldDecrementTriggerProps =\n NumberFieldPrimitive.NumberFieldDecrementTriggerProps & {\n class?: string | undefined\n children?: JSX.Element\n }\n\nconst NumberFieldDecrementTrigger = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldDecrementTriggerProps, [\n \"class\",\n \"children\"\n ])\n return (\n \n {local.children ?? (\n \n \n \n )}\n \n )\n}\n\ntype NumberFieldDescriptionProps =\n NumberFieldPrimitive.NumberFieldDescriptionProps & {\n class?: string | undefined\n }\n\nconst NumberFieldDescription = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldDescriptionProps, [\"class\"])\n return (\n \n )\n}\n\ntype NumberFieldErrorMessageProps =\n NumberFieldPrimitive.NumberFieldErrorMessageProps & {\n class?: string | undefined\n }\n\nconst NumberFieldErrorMessage = (\n props: PolymorphicProps>\n) => {\n const [local, others] = splitProps(props as NumberFieldErrorMessageProps, [\"class\"])\n return (\n \n )\n}\n\nexport {\n NumberField,\n NumberFieldGroup,\n NumberFieldLabel,\n NumberFieldInput,\n NumberFieldIncrementTrigger,\n NumberFieldDecrementTrigger,\n NumberFieldDescription,\n NumberFieldErrorMessage\n}\n" } ], "type": "ui" diff --git a/apps/docs/src/registry/example/number-field-demo.tsx b/apps/docs/src/registry/example/number-field-demo.tsx index 984cda3f..c5b70869 100644 --- a/apps/docs/src/registry/example/number-field-demo.tsx +++ b/apps/docs/src/registry/example/number-field-demo.tsx @@ -4,6 +4,7 @@ import { NumberField, NumberFieldDecrementTrigger, NumberFieldErrorMessage, + NumberFieldGroup, NumberFieldIncrementTrigger, NumberFieldInput } from "~/registry/ui/number-field" @@ -17,11 +18,11 @@ export default function NumberFieldDemo() { onRawValueChange={setRawValue} validationState={rawValue() !== 40 ? "invalid" : "valid"} > -
+ -
+ Hmm, I prefer 40. ) diff --git a/apps/docs/src/registry/ui/number-field.tsx b/apps/docs/src/registry/ui/number-field.tsx index c02de22e..51a1b8cd 100644 --- a/apps/docs/src/registry/ui/number-field.tsx +++ b/apps/docs/src/registry/ui/number-field.tsx @@ -1,4 +1,4 @@ -import type { JSX, ValidComponent } from "solid-js" +import type { Component, ComponentProps, JSX, ValidComponent } from "solid-js" import { splitProps } from "solid-js" import * as NumberFieldPrimitive from "@kobalte/core/number-field" @@ -8,6 +8,19 @@ import { cn } from "~/lib/utils" const NumberField = NumberFieldPrimitive.Root +const NumberFieldGroup: Component> = (props) => { + const [local, others] = splitProps(props, ["class"]) + return ( +
+ ) +} + type NumberFieldLabelProps = NumberFieldPrimitive.NumberFieldLabelProps & { class?: string | undefined @@ -40,7 +53,7 @@ const NumberFieldInput = ( return ( ( export { NumberField, + NumberFieldGroup, NumberFieldLabel, NumberFieldInput, NumberFieldIncrementTrigger, diff --git a/apps/docs/src/routes/docs/components/number-field.mdx b/apps/docs/src/routes/docs/components/number-field.mdx index eca93e99..1148dd5f 100644 --- a/apps/docs/src/routes/docs/components/number-field.mdx +++ b/apps/docs/src/routes/docs/components/number-field.mdx @@ -47,6 +47,7 @@ npm install @kobalte/core import { NumberField, NumberFieldDecrementTrigger, + NumberFieldGroup, NumberFieldIncrementTrigger, NumberFieldInput } from "~/registry/ui/number-field" @@ -54,11 +55,11 @@ import { export default function NumberFieldDemo() { return ( -
+ -
+
) }