The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { Checkbox as CheckboxPrimitive } from "@base-ui/react/checkbox"; |
| 2 | |
| 3 | import { cn } from "~/lib/utils"; |
| 4 | |
| 5 | const rootClassName = |
| 6 | "relative inline-flex size-4.5 shrink-0 items-center justify-center rounded-[.25rem] border border-input bg-background not-dark:bg-clip-padding shadow-xs/5 outline-none transition-shadow before:pointer-events-none before:absolute before:inset-0 before:rounded-[3px] not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_1px_--theme(--color-black/4%)] focus-visible:outline-2 focus-visible:outline-solid focus-visible:-outline-offset-2 focus-visible:outline-ring aria-invalid:border-destructive/36 focus-visible:aria-invalid:border-destructive/64 focus-visible:aria-invalid:outline-destructive/48 data-disabled:opacity-64 sm:size-4 dark:not-data-checked:bg-input/32 dark:focus-visible:aria-invalid:outline-destructive/24 dark:not-data-disabled:not-data-checked:not-aria-invalid:before:shadow-[0_-1px_--theme(--color-white/6%)] [[data-disabled],[data-checked],[aria-invalid]]:shadow-none"; |
| 7 | |
| 8 | const indicatorClassName = |
| 9 | "-inset-px absolute flex items-center justify-center rounded-[.25rem] text-primary-foreground data-unchecked:hidden data-checked:bg-primary data-indeterminate:text-foreground in-[[data-slot=checkbox]:focus-visible]:inset-shadow-[0_0_0_3px_var(--background)] in-[[data-slot=checkbox]:focus-visible]:outline-2 in-[[data-slot=checkbox]:focus-visible]:outline-solid in-[[data-slot=checkbox]:focus-visible]:-outline-offset-2 in-[[data-slot=checkbox]:focus-visible]:outline-inherit"; |
| 10 | |
| 11 | const variantClassNames = { |
| 12 | default: "", |
| 13 | contrast: "border-foreground/55", |
| 14 | }; |
| 15 | |
| 16 | type CheckboxVariant = keyof typeof variantClassNames; |
| 17 | |
| 18 | function Checkbox({ |
| 19 | className, |
| 20 | variant = "default", |
| 21 | ...props |
| 22 | }: CheckboxPrimitive.Root.Props & { variant?: CheckboxVariant }) { |
| 23 | return ( |
| 24 | <CheckboxPrimitive.Root |
| 25 | className={cn(rootClassName, variantClassNames[variant], className)} |
| 26 | data-slot="checkbox" |
| 27 | {...props} |
| 28 | > |
| 29 | {/* Keep an inner gap in the focus outline. Explicit glyph colors resist row icon-muting rules. */} |
| 30 | <CheckboxPrimitive.Indicator |
| 31 | className={indicatorClassName} |
| 32 | data-slot="checkbox-indicator" |
| 33 | render={(props, state) => ( |
| 34 | <span {...props}> |
| 35 | {state.indeterminate ? ( |
| 36 | <svg |
| 37 | className="size-3.5 text-current sm:size-3" |
| 38 | fill="none" |
| 39 | height="24" |
| 40 | stroke="currentColor" |
| 41 | strokeLinecap="round" |
| 42 | strokeLinejoin="round" |
| 43 | strokeWidth="3" |
| 44 | viewBox="0 0 24 24" |
| 45 | width="24" |
| 46 | xmlns="http://www.w3.org/2000/svg" |
| 47 | > |
| 48 | <path d="M5.252 12h13.496" /> |
| 49 | </svg> |
| 50 | ) : ( |
| 51 | <svg |
| 52 | className="size-3.5 text-current sm:size-3" |
| 53 | fill="none" |
| 54 | height="24" |
| 55 | stroke="currentColor" |
| 56 | strokeLinecap="round" |
| 57 | strokeLinejoin="round" |
| 58 | strokeWidth="3" |
| 59 | viewBox="0 0 24 24" |
| 60 | width="24" |
| 61 | xmlns="http://www.w3.org/2000/svg" |
| 62 | > |
| 63 | <path d="M5.252 12.7 10.2 18.63 18.748 5.37" /> |
| 64 | </svg> |
| 65 | )} |
| 66 | </span> |
| 67 | )} |
| 68 | /> |
| 69 | </CheckboxPrimitive.Root> |
| 70 | ); |
| 71 | } |
| 72 | |
| 73 | // Checkbox's look without its hidden input, for a row that is itself the button. |
| 74 | function CheckboxMark({ |
| 75 | checked, |
| 76 | variant = "default", |
| 77 | }: { |
| 78 | checked: boolean; |
| 79 | variant?: CheckboxVariant; |
| 80 | }) { |
| 81 | const state = checked ? { "data-checked": "" } : { "data-unchecked": "" }; |
| 82 | return ( |
| 83 | <span |
| 84 | aria-hidden |
| 85 | className={cn(rootClassName, variantClassNames[variant])} |
| 86 | data-slot="checkbox" |
| 87 | {...state} |
| 88 | > |
| 89 | <span className={indicatorClassName} data-slot="checkbox-indicator" {...state}> |
| 90 | <svg |
| 91 | className="size-3.5 text-current sm:size-3" |
| 92 | fill="none" |
| 93 | height="24" |
| 94 | stroke="currentColor" |
| 95 | strokeLinecap="round" |
| 96 | strokeLinejoin="round" |
| 97 | strokeWidth="3" |
| 98 | viewBox="0 0 24 24" |
| 99 | width="24" |
| 100 | xmlns="http://www.w3.org/2000/svg" |
| 101 | > |
| 102 | <path d="M5.252 12.7 10.2 18.63 18.748 5.37" /> |
| 103 | </svg> |
| 104 | </span> |
| 105 | </span> |
| 106 | ); |
| 107 | } |
| 108 | |
| 109 | export { Checkbox, CheckboxMark }; |