@betterinternship/components 3.5.1 → 3.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,7 +35,7 @@ const CheckboxGroup = ({ options, values, setter, className, hint = null, column
35
35
  ? 'border-primary bg-primary-selected'
36
36
  : 'border-border hover:border-input hover:bg-muted'), children: [jsx(FormFieldReset, { children: jsx(Checkbox, { checked: isChecked, tabIndex: -1, "aria-hidden": "true",
37
37
  // A 16px box centred on the title's first line (2px padding + 20px line).
38
- className: "pointer-events-none mt-1" }) }), jsxs("div", { className: "min-w-0 flex-1 space-y-1 pt-0.5", children: [jsx("span", { className: "block text-field-label font-field-label text-foreground", children: option.label }), option.description && (jsx("p", { className: "text-sm text-muted-foreground", children: option.description }))] })] }, option.value));
38
+ className: "pointer-events-none mt-1" }) }), jsxs("div", { className: "min-w-0 flex-1 space-y-1 pt-0.5", children: [jsx("span", { className: "block text-field-label font-medium text-foreground", children: option.label }), option.description && (jsx("p", { className: "text-sm text-muted-foreground", children: option.description }))] })] }, option.value));
39
39
  }) })] }));
40
40
  };
41
41
 
@@ -1 +1 @@
1
- {"version":3,"file":"checkbox-group.js","sources":["../../src/components/checkbox-group.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '@/utils';\nimport { Checkbox } from '@/components/checkbox';\nimport { FormFieldReset, useFormFieldControl } from './form-field';\n\nexport interface CheckboxGroupProps {\n options: { value: string | number; label: string; description?: string }[];\n values: (string | number)[];\n setter: (values: (string | number)[]) => void;\n className?: string;\n /** Multi-select hint shown above the options. */\n hint?: React.ReactNode;\n /** Columns on md+ screens. Defaults to 3. */\n columns?: 1 | 2 | 3;\n /** Fired when a single option is toggled, before the setter runs. */\n onToggle?: (value: string | number, checked: boolean) => void;\n id?: string;\n /** Names the group when it has no visible label. Inside a FormField the field label names it. */\n 'aria-label'?: string;\n /** Id of the element naming the group. A surrounding FormField with `group` sets it. */\n 'aria-labelledby'?: string;\n /** Ids of help or error text. A surrounding FormField sets it from `description` and `error`. */\n 'aria-describedby'?: string;\n /** Marks the group invalid. A surrounding FormField sets it when it shows an error. */\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Marks the group required. A surrounding FormField sets it from `required`. */\n 'aria-required'?: React.AriaAttributes['aria-required'];\n}\n\nconst GRID_COLS: Record<1 | 2 | 3, string> = {\n 1: '',\n 2: 'md:grid-cols-2',\n 3: 'md:grid-cols-3',\n};\n\n/**\n * Multi-select option cards. Unlabelled: put it in a `FormField` with `group`\n * for a label that names the whole group.\n */\nexport const CheckboxGroup = ({\n options,\n values,\n setter,\n className,\n hint = null,\n columns = 3,\n onToggle,\n ...ownAria\n}: CheckboxGroupProps) => {\n const aria = useFormFieldControl(ownAria, 'group');\n const handleValueChange = (optionValue: string | number) => {\n const willBeChecked = !values.includes(optionValue);\n onToggle?.(optionValue, willBeChecked);\n setter(\n willBeChecked\n ? [...values, optionValue]\n : values.filter((v) => v !== optionValue),\n );\n };\n\n return (\n <div role=\"group\" {...aria} className={className}>\n {hint && <p className=\"text-xs text-muted-foreground\">{hint}</p>}\n\n <div className={cn('grid grid-cols-1 gap-4', GRID_COLS[columns])}>\n {options.map((option) => {\n const isChecked = values.includes(option.value);\n\n return (\n // The card is the control: focusable, toggled by click, Space or Enter.\n <div\n key={option.value}\n role=\"checkbox\"\n aria-checked={isChecked}\n tabIndex={0}\n onClick={() => handleValueChange(option.value)}\n onKeyDown={(event) => {\n if (event.key !== ' ' && event.key !== 'Enter') return;\n event.preventDefault();\n handleValueChange(option.value);\n }}\n className={cn(\n 'group flex h-fit cursor-pointer items-start gap-3 rounded-control-lg border p-3 transition-colors duration-state ease-out-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none',\n isChecked\n ? 'border-primary bg-primary-selected'\n : 'border-border hover:border-input hover:bg-muted',\n )}\n >\n <FormFieldReset>\n <Checkbox\n checked={isChecked}\n tabIndex={-1}\n aria-hidden=\"true\"\n // A 16px box centred on the title's first line (2px padding + 20px line).\n className=\"pointer-events-none mt-1\"\n />\n </FormFieldReset>\n <div className=\"min-w-0 flex-1 space-y-1 pt-0.5\">\n {/* Same size as a field label, but the main text colour: it's the option, not a caption. */}\n <span className=\"block text-field-label font-field-label text-foreground\">\n {option.label}\n </span>\n {option.description && (\n <p className=\"text-sm text-muted-foreground\">{option.description}</p>\n )}\n </div>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAgCA;AACE;AACA;AACA;;AAGF;;;AAGG;AACI;;AAWL;;AAEE;AACA;AAEI;AACA;AAEN;AAEA;;;;;;;;AAmBc;AACF;AAII;AACA;;AASA;AAcV;AAIR;;"}
1
+ {"version":3,"file":"checkbox-group.js","sources":["../../src/components/checkbox-group.tsx"],"sourcesContent":["'use client';\n\nimport * as React from 'react';\n\nimport { cn } from '@/utils';\nimport { Checkbox } from '@/components/checkbox';\nimport { FormFieldReset, useFormFieldControl } from './form-field';\n\nexport interface CheckboxGroupProps {\n options: { value: string | number; label: string; description?: string }[];\n values: (string | number)[];\n setter: (values: (string | number)[]) => void;\n className?: string;\n /** Multi-select hint shown above the options. */\n hint?: React.ReactNode;\n /** Columns on md+ screens. Defaults to 3. */\n columns?: 1 | 2 | 3;\n /** Fired when a single option is toggled, before the setter runs. */\n onToggle?: (value: string | number, checked: boolean) => void;\n id?: string;\n /** Names the group when it has no visible label. Inside a FormField the field label names it. */\n 'aria-label'?: string;\n /** Id of the element naming the group. A surrounding FormField with `group` sets it. */\n 'aria-labelledby'?: string;\n /** Ids of help or error text. A surrounding FormField sets it from `description` and `error`. */\n 'aria-describedby'?: string;\n /** Marks the group invalid. A surrounding FormField sets it when it shows an error. */\n 'aria-invalid'?: React.AriaAttributes['aria-invalid'];\n /** Marks the group required. A surrounding FormField sets it from `required`. */\n 'aria-required'?: React.AriaAttributes['aria-required'];\n}\n\nconst GRID_COLS: Record<1 | 2 | 3, string> = {\n 1: '',\n 2: 'md:grid-cols-2',\n 3: 'md:grid-cols-3',\n};\n\n/**\n * Multi-select option cards. Unlabelled: put it in a `FormField` with `group`\n * for a label that names the whole group.\n */\nexport const CheckboxGroup = ({\n options,\n values,\n setter,\n className,\n hint = null,\n columns = 3,\n onToggle,\n ...ownAria\n}: CheckboxGroupProps) => {\n const aria = useFormFieldControl(ownAria, 'group');\n const handleValueChange = (optionValue: string | number) => {\n const willBeChecked = !values.includes(optionValue);\n onToggle?.(optionValue, willBeChecked);\n setter(\n willBeChecked\n ? [...values, optionValue]\n : values.filter((v) => v !== optionValue),\n );\n };\n\n return (\n <div role=\"group\" {...aria} className={className}>\n {hint && <p className=\"text-xs text-muted-foreground\">{hint}</p>}\n\n <div className={cn('grid grid-cols-1 gap-4', GRID_COLS[columns])}>\n {options.map((option) => {\n const isChecked = values.includes(option.value);\n\n return (\n // The card is the control: focusable, toggled by click, Space or Enter.\n <div\n key={option.value}\n role=\"checkbox\"\n aria-checked={isChecked}\n tabIndex={0}\n onClick={() => handleValueChange(option.value)}\n onKeyDown={(event) => {\n if (event.key !== ' ' && event.key !== 'Enter') return;\n event.preventDefault();\n handleValueChange(option.value);\n }}\n className={cn(\n 'group flex h-fit cursor-pointer items-start gap-3 rounded-control-lg border p-3 transition-colors duration-state ease-out-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-reduce:transition-none',\n isChecked\n ? 'border-primary bg-primary-selected'\n : 'border-border hover:border-input hover:bg-muted',\n )}\n >\n <FormFieldReset>\n <Checkbox\n checked={isChecked}\n tabIndex={-1}\n aria-hidden=\"true\"\n // A 16px box centred on the title's first line (2px padding + 20px line).\n className=\"pointer-events-none mt-1\"\n />\n </FormFieldReset>\n <div className=\"min-w-0 flex-1 space-y-1 pt-0.5\">\n {/* Same size as a field label, but the main text colour: it's the option, not a caption. */}\n <span className=\"block text-field-label font-medium text-foreground\">\n {option.label}\n </span>\n {option.description && (\n <p className=\"text-sm text-muted-foreground\">{option.description}</p>\n )}\n </div>\n </div>\n );\n })}\n </div>\n </div>\n );\n};\n"],"names":[],"mappings":";;;;;;AAgCA;AACE;AACA;AACA;;AAGF;;;AAGG;AACI;;AAWL;;AAEE;AACA;AAEI;AACA;AAEN;AAEA;;;;;;;;AAmBc;AACF;AAII;AACA;;AASA;AAcV;AAIR;;"}
@@ -54,7 +54,9 @@ const SelectTrigger = React.forwardRef(({ className, children, onPointerDown, on
54
54
  pressedRef.current = false;
55
55
  if (fromLabel && !event.defaultPrevented && !open && !props.disabled)
56
56
  setOpen(true);
57
- }, className: cn('group bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue', fieldInteractionClassName, className), ...props, children: [children, jsx(SelectPrimitive.Icon, { asChild: true, children: jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none" }) })] }));
57
+ }, className: cn(
58
+ // text-left: a <button> centres its text, which pushes a cut-off value right.
59
+ 'group text-left bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1', 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue', fieldInteractionClassName, className), ...props, children: [children, jsx(SelectPrimitive.Icon, { asChild: true, children: jsx(ChevronDown, { className: "h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none" }) })] }));
58
60
  });
59
61
  SelectTrigger.displayName = SelectPrimitive.Trigger.displayName;
60
62
  const SelectScrollUpButton = React.forwardRef(({ className, ...props }, ref) => (jsx(SelectPrimitive.ScrollUpButton, { ref: ref, className: cn('flex cursor-default items-center justify-center py-1', className), ...props, children: jsx(ChevronUp, { className: "h-4 w-4" }) })));
@@ -1 +1 @@
1
- {"version":3,"file":"select.js","sources":["../../src/components/select.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport * as SelectPrimitive from '@radix-ui/react-select';\r\nimport { Check, ChevronDown, ChevronUp, X } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { fieldInteractionClassName } from '@/hooks/use-field-focus';\r\nimport { useMobile } from '@/hooks/use-mobile';\r\nimport { useMobileSheetViewport } from '@/hooks/use-mobile-sheet-viewport';\r\nimport { useFormField, useFormFieldControl } from './form-field';\r\n\r\nconst SelectContext = React.createContext({ open: false, setOpen: (_open: boolean) => {} });\r\n\r\nfunction Select({ open: controlledOpen, defaultOpen = false, onOpenChange, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {\r\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\r\n const open = controlledOpen ?? internalOpen;\r\n const setOpen = (next: boolean) => {\r\n if (controlledOpen === undefined) setInternalOpen(next);\r\n onOpenChange?.(next);\r\n };\r\n\r\n return (\r\n <SelectContext.Provider value={{ open, setOpen }}>\r\n <SelectPrimitive.Root {...props} open={open} onOpenChange={setOpen}>\r\n {children}\r\n </SelectPrimitive.Root>\r\n </SelectContext.Provider>\r\n );\r\n}\r\n\r\nconst SelectGroup = SelectPrimitive.Group;\r\n\r\nconst SelectValue = SelectPrimitive.Value;\r\n\r\nconst SelectTrigger = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Trigger>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\r\n>(({ className, children, onPointerDown, onClick, ...ownProps }, ref) => {\r\n const props = useFormFieldControl(ownProps);\r\n const { open, setOpen } = React.useContext(SelectContext);\r\n // Radix opens on a mouse press on the trigger itself, so a click that arrives\r\n // without one (from the field's label) would only focus it. Open it here.\r\n // A press on the trigger stops counting once anything else is pressed: when\r\n // Radix opens on the press, the release lands on the menu, not the trigger.\r\n const pressedRef = React.useRef(false);\r\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\r\n React.useEffect(() => {\r\n const onPointerDownAnywhere = (event: PointerEvent) => {\r\n if (!(event.target instanceof Node) || !triggerRef.current?.contains(event.target)) pressedRef.current = false;\r\n };\r\n document.addEventListener('pointerdown', onPointerDownAnywhere, true);\r\n return () => document.removeEventListener('pointerdown', onPointerDownAnywhere, true);\r\n }, []);\r\n return (\r\n <SelectPrimitive.Trigger\r\n ref={(node) => {\r\n triggerRef.current = node;\r\n if (typeof ref === 'function') ref(node);\r\n else if (ref) ref.current = node;\r\n }}\r\n onPointerDown={(event) => {\r\n pressedRef.current = true;\r\n onPointerDown?.(event);\r\n }}\r\n onClick={(event) => {\r\n onClick?.(event);\r\n const fromLabel = !pressedRef.current;\r\n pressedRef.current = false;\r\n if (fromLabel && !event.defaultPrevented && !open && !props.disabled) setOpen(true);\r\n }}\r\n className={cn(\r\n 'group bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\r\n 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue',\r\n fieldInteractionClassName,\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <SelectPrimitive.Icon asChild>\r\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none\" />\r\n </SelectPrimitive.Icon>\r\n </SelectPrimitive.Trigger>\r\n );\r\n});\r\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\r\n\r\nconst SelectScrollUpButton = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.ScrollUpButton\r\n ref={ref}\r\n className={cn(\r\n 'flex cursor-default items-center justify-center py-1',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <ChevronUp className=\"h-4 w-4\" />\r\n </SelectPrimitive.ScrollUpButton>\r\n));\r\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\r\n\r\nconst SelectScrollDownButton = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.ScrollDownButton\r\n ref={ref}\r\n className={cn(\r\n 'flex cursor-default items-center justify-center py-1',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <ChevronDown className=\"h-4 w-4\" />\r\n </SelectPrimitive.ScrollDownButton>\r\n));\r\nSelectScrollDownButton.displayName =\r\n SelectPrimitive.ScrollDownButton.displayName;\r\n\r\nconst SelectContent = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & { title?: string }\r\n>(({ className, children, position = 'popper', title: ownTitle, style, ...props }, ref) => {\r\n // The phone sheet's title: an explicit title, else the field's label.\r\n const title = ownTitle ?? useFormField()?.labelText ?? 'Choose an option';\r\n const mobile = useMobile();\r\n const { open, setOpen } = React.useContext(SelectContext);\r\n const viewport = useMobileSheetViewport(open && mobile);\r\n\r\n return (\r\n <SelectPrimitive.Portal>\r\n <div\r\n className={mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-(--z-popover) [&>[data-radix-popper-content-wrapper]]:!min-w-0' : undefined}\r\n style={{ '--select-sheet-bottom': `${viewport?.bottom ?? 0}px` } as React.CSSProperties}\r\n >\r\n {mobile && open && (\r\n <div aria-hidden=\"true\" className=\"fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]\" />\r\n )}\r\n <SelectPrimitive.Content\r\n ref={ref}\r\n className={cn(\r\n 'relative flex flex-col overflow-hidden border border-border bg-background text-sm text-foreground shadow-card duration-interactive ease-out-strong motion-reduce:animate-none',\r\n mobile\r\n ? 'w-full rounded-t-control-lg border-b-0 pb-[env(safe-area-inset-bottom)]'\r\n : 'z-(--z-popover) max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\r\n className,\r\n )}\r\n position={mobile ? 'popper' : position}\r\n sideOffset={4}\r\n style={{\r\n ...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),\r\n ...style,\r\n }}\r\n {...props}\r\n >\r\n {mobile && (\r\n <div role=\"presentation\" className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4\">\r\n <h2 className=\"text-base font-semibold text-foreground\">{title}</h2>\r\n <button\r\n type=\"button\"\r\n aria-label=\"Close options\"\r\n className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\r\n onPointerDown={(event) => event.stopPropagation()}\r\n onClick={() => setOpen(false)}\r\n >\r\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\r\n </button>\r\n </div>\r\n )}\r\n {!mobile && <SelectScrollUpButton />}\r\n <SelectPrimitive.Viewport\r\n className={cn(\r\n 'flex min-h-0 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset',\r\n mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]',\r\n )}\r\n >\r\n {children}\r\n </SelectPrimitive.Viewport>\r\n {!mobile && <SelectScrollDownButton />}\r\n </SelectPrimitive.Content>\r\n </div>\r\n </SelectPrimitive.Portal>\r\n );\r\n});\r\nSelectContent.displayName = SelectPrimitive.Content.displayName;\r\n\r\nconst SelectLabel = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Label>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.Label\r\n ref={ref}\r\n className={cn('px-option-x py-2 text-sm font-semibold text-foreground', className)}\r\n {...props}\r\n />\r\n));\r\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\r\n\r\nconst SelectItem = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Item>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\r\n>(({ className, children, ...props }, ref) => (\r\n <SelectPrimitive.Item\r\n ref={ref}\r\n className={cn(\r\n 'relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pr-9 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <span className=\"absolute right-option-x flex h-4 w-4 items-center justify-center\">\r\n <SelectPrimitive.ItemIndicator>\r\n <Check className=\"h-4 w-4\" />\r\n </SelectPrimitive.ItemIndicator>\r\n </span>\r\n\r\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\r\n </SelectPrimitive.Item>\r\n));\r\nSelectItem.displayName = SelectPrimitive.Item.displayName;\r\n\r\nconst SelectSeparator = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Separator>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.Separator\r\n ref={ref}\r\n className={cn('bg-border h-px', className)}\r\n {...props}\r\n />\r\n));\r\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\r\n\r\nexport {\r\n Select,\r\n SelectGroup,\r\n SelectValue,\r\n SelectTrigger,\r\n SelectContent,\r\n SelectLabel,\r\n SelectItem,\r\n SelectSeparator,\r\n SelectScrollUpButton,\r\n SelectScrollDownButton,\r\n};\r\n"],"names":[],"mappings":";;;;;;;;;;;AAYA;AAEA;AACE;AACA;AACA;;;AAEE;AACF;AAEA;AAOF;AAEA;AAEA;AAEA;AAIE;AACA;;;;;;;AAOA;AACE;AACE;AAAoF;AACtF;;AAEA;;;AAKE;;;AAEK;AAAS;AAChB;AAEE;AACA;AACF;AAEE;AACA;AACA;AACA;;AACF;AAeJ;AACA;AAEA;AAeA;AAEA;AAeA;AACE;AAEF;;;AAME;AACA;;AAGA;AAcQ;;AAOF;AACA;;AAgCR;AACA;AAEA;AAUA;AAEA;AAqBA;AAEA;AAUA;;"}
1
+ {"version":3,"file":"select.js","sources":["../../src/components/select.tsx"],"sourcesContent":["'use client';\r\n\r\nimport * as React from 'react';\r\nimport * as SelectPrimitive from '@radix-ui/react-select';\r\nimport { Check, ChevronDown, ChevronUp, X } from 'lucide-react';\r\n\r\nimport { cn } from '@/utils';\r\nimport { fieldInteractionClassName } from '@/hooks/use-field-focus';\r\nimport { useMobile } from '@/hooks/use-mobile';\r\nimport { useMobileSheetViewport } from '@/hooks/use-mobile-sheet-viewport';\r\nimport { useFormField, useFormFieldControl } from './form-field';\r\n\r\nconst SelectContext = React.createContext({ open: false, setOpen: (_open: boolean) => {} });\r\n\r\nfunction Select({ open: controlledOpen, defaultOpen = false, onOpenChange, children, ...props }: React.ComponentProps<typeof SelectPrimitive.Root>) {\r\n const [internalOpen, setInternalOpen] = React.useState(defaultOpen);\r\n const open = controlledOpen ?? internalOpen;\r\n const setOpen = (next: boolean) => {\r\n if (controlledOpen === undefined) setInternalOpen(next);\r\n onOpenChange?.(next);\r\n };\r\n\r\n return (\r\n <SelectContext.Provider value={{ open, setOpen }}>\r\n <SelectPrimitive.Root {...props} open={open} onOpenChange={setOpen}>\r\n {children}\r\n </SelectPrimitive.Root>\r\n </SelectContext.Provider>\r\n );\r\n}\r\n\r\nconst SelectGroup = SelectPrimitive.Group;\r\n\r\nconst SelectValue = SelectPrimitive.Value;\r\n\r\nconst SelectTrigger = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Trigger>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>\r\n>(({ className, children, onPointerDown, onClick, ...ownProps }, ref) => {\r\n const props = useFormFieldControl(ownProps);\r\n const { open, setOpen } = React.useContext(SelectContext);\r\n // Radix opens on a mouse press on the trigger itself, so a click that arrives\r\n // without one (from the field's label) would only focus it. Open it here.\r\n // A press on the trigger stops counting once anything else is pressed: when\r\n // Radix opens on the press, the release lands on the menu, not the trigger.\r\n const pressedRef = React.useRef(false);\r\n const triggerRef = React.useRef<HTMLButtonElement | null>(null);\r\n React.useEffect(() => {\r\n const onPointerDownAnywhere = (event: PointerEvent) => {\r\n if (!(event.target instanceof Node) || !triggerRef.current?.contains(event.target)) pressedRef.current = false;\r\n };\r\n document.addEventListener('pointerdown', onPointerDownAnywhere, true);\r\n return () => document.removeEventListener('pointerdown', onPointerDownAnywhere, true);\r\n }, []);\r\n return (\r\n <SelectPrimitive.Trigger\r\n ref={(node) => {\r\n triggerRef.current = node;\r\n if (typeof ref === 'function') ref(node);\r\n else if (ref) ref.current = node;\r\n }}\r\n onPointerDown={(event) => {\r\n pressedRef.current = true;\r\n onPointerDown?.(event);\r\n }}\r\n onClick={(event) => {\r\n onClick?.(event);\r\n const fromLabel = !pressedRef.current;\r\n pressedRef.current = false;\r\n if (fromLabel && !event.defaultPrevented && !open && !props.disabled) setOpen(true);\r\n }}\r\n className={cn(\r\n // text-left: a <button> centres its text, which pushes a cut-off value right.\r\n 'group text-left bg-background text-foreground placeholder:text-muted-foreground/40 data-[placeholder]:text-muted-foreground/40 border-input enabled:hover:border-input-hover flex h-form-control min-h-form-control max-h-form-control w-full cursor-pointer items-center justify-between gap-2 rounded-control-lg border px-field-padding-x py-0 text-base font-normal outline-none aria-invalid:border-destructive disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1',\r\n 'focus-visible:outline-3 focus-visible:outline-offset-4 focus-visible:outline-landing-blue',\r\n fieldInteractionClassName,\r\n className,\r\n )}\r\n {...props}\r\n >\r\n {children}\r\n <SelectPrimitive.Icon asChild>\r\n <ChevronDown className=\"h-4 w-4 shrink-0 text-muted-foreground transition-transform duration-interactive ease-out-strong group-data-[state=open]:rotate-180 motion-reduce:transition-none\" />\r\n </SelectPrimitive.Icon>\r\n </SelectPrimitive.Trigger>\r\n );\r\n});\r\nSelectTrigger.displayName = SelectPrimitive.Trigger.displayName;\r\n\r\nconst SelectScrollUpButton = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.ScrollUpButton>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollUpButton>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.ScrollUpButton\r\n ref={ref}\r\n className={cn(\r\n 'flex cursor-default items-center justify-center py-1',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <ChevronUp className=\"h-4 w-4\" />\r\n </SelectPrimitive.ScrollUpButton>\r\n));\r\nSelectScrollUpButton.displayName = SelectPrimitive.ScrollUpButton.displayName;\r\n\r\nconst SelectScrollDownButton = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.ScrollDownButton>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.ScrollDownButton>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.ScrollDownButton\r\n ref={ref}\r\n className={cn(\r\n 'flex cursor-default items-center justify-center py-1',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <ChevronDown className=\"h-4 w-4\" />\r\n </SelectPrimitive.ScrollDownButton>\r\n));\r\nSelectScrollDownButton.displayName =\r\n SelectPrimitive.ScrollDownButton.displayName;\r\n\r\nconst SelectContent = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Content>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Content> & { title?: string }\r\n>(({ className, children, position = 'popper', title: ownTitle, style, ...props }, ref) => {\r\n // The phone sheet's title: an explicit title, else the field's label.\r\n const title = ownTitle ?? useFormField()?.labelText ?? 'Choose an option';\r\n const mobile = useMobile();\r\n const { open, setOpen } = React.useContext(SelectContext);\r\n const viewport = useMobileSheetViewport(open && mobile);\r\n\r\n return (\r\n <SelectPrimitive.Portal>\r\n <div\r\n className={mobile ? '[&>[data-radix-popper-content-wrapper]]:!fixed [&>[data-radix-popper-content-wrapper]]:!inset-x-0 [&>[data-radix-popper-content-wrapper]]:!top-auto [&>[data-radix-popper-content-wrapper]]:!bottom-[var(--select-sheet-bottom)] [&>[data-radix-popper-content-wrapper]]:!transform-none [&>[data-radix-popper-content-wrapper]]:!z-(--z-popover) [&>[data-radix-popper-content-wrapper]]:!min-w-0' : undefined}\r\n style={{ '--select-sheet-bottom': `${viewport?.bottom ?? 0}px` } as React.CSSProperties}\r\n >\r\n {mobile && open && (\r\n <div aria-hidden=\"true\" className=\"fixed inset-0 z-(--z-popover-overlay) bg-black/25 backdrop-blur-[1px]\" />\r\n )}\r\n <SelectPrimitive.Content\r\n ref={ref}\r\n className={cn(\r\n 'relative flex flex-col overflow-hidden border border-border bg-background text-sm text-foreground shadow-card duration-interactive ease-out-strong motion-reduce:animate-none',\r\n mobile\r\n ? 'w-full rounded-t-control-lg border-b-0 pb-[env(safe-area-inset-bottom)]'\r\n : 'z-(--z-popover) max-h-[400px] min-w-[8rem] rounded-control-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95',\r\n className,\r\n )}\r\n position={mobile ? 'popper' : position}\r\n sideOffset={4}\r\n style={{\r\n ...(mobile ? { maxHeight: viewport ? Math.min(viewport.height, 640) : '80dvh' } : {}),\r\n ...style,\r\n }}\r\n {...props}\r\n >\r\n {mobile && (\r\n <div role=\"presentation\" className=\"flex shrink-0 items-center justify-between gap-4 px-4 pb-3 pt-4\">\r\n <h2 className=\"text-base font-semibold text-foreground\">{title}</h2>\r\n <button\r\n type=\"button\"\r\n aria-label=\"Close options\"\r\n className=\"-mr-3 flex h-11 w-11 shrink-0 items-center justify-center rounded-control-lg text-muted-foreground hover:bg-muted\"\r\n onPointerDown={(event) => event.stopPropagation()}\r\n onClick={() => setOpen(false)}\r\n >\r\n <X className=\"h-5 w-5\" aria-hidden=\"true\" />\r\n </button>\r\n </div>\r\n )}\r\n {!mobile && <SelectScrollUpButton />}\r\n <SelectPrimitive.Viewport\r\n className={cn(\r\n 'flex min-h-0 flex-col gap-option-gap overflow-y-auto overscroll-contain p-option-inset',\r\n mobile ? 'w-full flex-1' : position === 'popper' && 'w-full min-w-[var(--radix-select-trigger-width)]',\r\n )}\r\n >\r\n {children}\r\n </SelectPrimitive.Viewport>\r\n {!mobile && <SelectScrollDownButton />}\r\n </SelectPrimitive.Content>\r\n </div>\r\n </SelectPrimitive.Portal>\r\n );\r\n});\r\nSelectContent.displayName = SelectPrimitive.Content.displayName;\r\n\r\nconst SelectLabel = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Label>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Label>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.Label\r\n ref={ref}\r\n className={cn('px-option-x py-2 text-sm font-semibold text-foreground', className)}\r\n {...props}\r\n />\r\n));\r\nSelectLabel.displayName = SelectPrimitive.Label.displayName;\r\n\r\nconst SelectItem = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Item>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Item>\r\n>(({ className, children, ...props }, ref) => (\r\n <SelectPrimitive.Item\r\n ref={ref}\r\n className={cn(\r\n 'relative flex min-h-option-row w-full cursor-pointer items-center gap-2 rounded-control-sm px-option-x py-2 pr-9 text-sm text-muted-foreground outline-none select-none transition-colors duration-interactive ease-out-strong focus:bg-muted data-[state=checked]:bg-primary-tint data-[disabled]:pointer-events-none data-[disabled]:opacity-50 motion-reduce:transition-none max-md:min-h-12',\r\n className,\r\n )}\r\n {...props}\r\n >\r\n <span className=\"absolute right-option-x flex h-4 w-4 items-center justify-center\">\r\n <SelectPrimitive.ItemIndicator>\r\n <Check className=\"h-4 w-4\" />\r\n </SelectPrimitive.ItemIndicator>\r\n </span>\r\n\r\n <SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>\r\n </SelectPrimitive.Item>\r\n));\r\nSelectItem.displayName = SelectPrimitive.Item.displayName;\r\n\r\nconst SelectSeparator = React.forwardRef<\r\n React.ElementRef<typeof SelectPrimitive.Separator>,\r\n React.ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>\r\n>(({ className, ...props }, ref) => (\r\n <SelectPrimitive.Separator\r\n ref={ref}\r\n className={cn('bg-border h-px', className)}\r\n {...props}\r\n />\r\n));\r\nSelectSeparator.displayName = SelectPrimitive.Separator.displayName;\r\n\r\nexport {\r\n Select,\r\n SelectGroup,\r\n SelectValue,\r\n SelectTrigger,\r\n SelectContent,\r\n SelectLabel,\r\n SelectItem,\r\n SelectSeparator,\r\n SelectScrollUpButton,\r\n SelectScrollDownButton,\r\n};\r\n"],"names":[],"mappings":";;;;;;;;;;;AAYA;AAEA;AACE;AACA;AACA;;;AAEE;AACF;AAEA;AAOF;AAEA;AAEA;AAEA;AAIE;AACA;;;;;;;AAOA;AACE;AACE;AAAoF;AACtF;;AAEA;;;AAKE;;;AAEK;AAAS;AAChB;AAEE;AACA;AACF;AAEE;AACA;AACA;AACA;;;;AAIA;AAaN;AACA;AAEA;AAeA;AAEA;AAeA;AACE;AAEF;;;AAME;AACA;;AAGA;AAcQ;;AAOF;AACA;;AAgCR;AACA;AAEA;AAUA;AAEA;AAqBA;AAEA;AAUA;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterinternship/components",
3
- "version": "3.5.1",
3
+ "version": "3.5.3",
4
4
  "workspaces": [
5
5
  "playground"
6
6
  ],
package/theme.css CHANGED
@@ -139,7 +139,7 @@
139
139
  --spacing-field-padding-x: 0.75rem;
140
140
  --text-field-label: var(--text-sm);
141
141
  --text-field-label--line-height: var(--text-sm--line-height);
142
- --font-weight-field-label: 500;
142
+ --font-weight-field-label: 400;
143
143
  /* Named -foreground, not field-label: a --color-field-label would make
144
144
  `text-field-label` a colour class and hide the label size. */
145
145
  --color-label-foreground: var(--muted-foreground);