@betterinternship/components 3.5.1 → 3.5.2

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;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterinternship/components",
3
- "version": "3.5.1",
3
+ "version": "3.5.2",
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);