@nswds/ui 6.0.0 → 7.0.0

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.
@@ -1,17 +1,54 @@
1
+ "use client"
1
2
  import { jsx } from 'react/jsx-runtime';
3
+ import { Input } from '@base-ui/react/input';
2
4
  import { cn } from '../lib/utils.js';
3
5
 
4
- function Textarea({ className, ...props }) {
5
- return /* @__PURE__ */ jsx(
6
- "textarea",
7
- {
8
- "data-slot": "textarea",
9
- className: cn(
10
- "flex field-sizing-content min-h-16 w-full resize-none rounded-sm border border-input bg-input/20 px-2 py-2 transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 max-md:text-sm md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",
11
- className
12
- ),
13
- ...props
14
- }
6
+ function Textarea({ className, ref, ...props }) {
7
+ return (
8
+ // Base UI's Input IS `Field.Control`, so rendering it as a `<textarea>`
9
+ // buys the multi-line control the same Field wiring the single-line Input
10
+ // already has: inside a `<Field>` it is the registered control, so the
11
+ // label association, `aria-describedby` for the description/error and
12
+ // `aria-invalid` are handled for us. The primitive is typed for `<input>`,
13
+ // hence the cast on the otherwise-identical props.
14
+ /* @__PURE__ */ jsx(
15
+ Input,
16
+ {
17
+ ref,
18
+ render: /* @__PURE__ */ jsx("textarea", {}),
19
+ "data-slot": "textarea",
20
+ className: cn(
21
+ // No `outline-none` here: it sets `--tw-outline-style: none` globally
22
+ // on the element, which then suppresses the focus outline below
23
+ // (which reads `outline-style: var(--tw-outline-style)`).
24
+ //
25
+ // Sizing is the one deliberate departure from Input: `field-sizing-content`
26
+ // grows the box with its content from a three-line floor instead of
27
+ // pinning it to Input's single-line `h-12`. Everything else — padding,
28
+ // radius, type size, colour, state handling — is Input's.
29
+ "field-sizing-content min-h-24 w-full min-w-0 resize-none rounded-sm px-4 py-2 text-base motion-safe:transition-colors",
30
+ // Every colour routes through the --input-* semantic tokens (layer 3,
31
+ // theme.css / the registry theme item). Dark mode and brand themes
32
+ // restyle the control by remapping tokens — no dark: variants here.
33
+ "border border-(--input-border) bg-(--input-surface) text-(--input-foreground)",
34
+ // Hover
35
+ "hover:bg-(--input-surface-hover)",
36
+ // Focus — `focus-visible:` per the design-system policy (matches
37
+ // Button/Link/Input). For text fields this is behaviour-preserving:
38
+ // browsers flag keyboard-editable controls as :focus-visible even
39
+ // when focused by pointer, so the ring still shows on click.
40
+ "focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring)",
41
+ // Placeholder styles
42
+ "placeholder:text-(--input-placeholder)",
43
+ // Disabled
44
+ "disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
45
+ // Invalid — 2px danger border, danger hover surface (Figma error variants)
46
+ "aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus-visible:outline-(--input-invalid-ring)",
47
+ className
48
+ ),
49
+ ...props
50
+ }
51
+ )
15
52
  );
16
53
  }
17
54
 
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/textarea.tsx"],"names":[],"mappings":";;;AAIA,SAAS,QAAA,CAAS,EAAE,SAAA,EAAW,GAAG,OAAM,EAAqC;AAC3E,EAAA,uBACE,GAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAU,UAAA;AAAA,MACV,SAAA,EAAW,EAAA;AAAA,QACT,6fAAA;AAAA,QACA;AAAA,OACF;AAAA,MACC,GAAG;AAAA;AAAA,GACN;AAEJ","file":"textarea.js","sourcesContent":["import * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Textarea({ className, ...props }: React.ComponentProps<'textarea'>) {\n return (\n <textarea\n data-slot='textarea'\n className={cn(\n 'flex field-sizing-content min-h-16 w-full resize-none rounded-sm border border-input bg-input/20 px-2 py-2 transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-2 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-2 aria-invalid:ring-destructive/20 max-md:text-sm md:text-xs/relaxed dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40',\n className,\n )}\n {...props}\n />\n )\n}\n\nexport { Textarea }\n"]}
1
+ {"version":3,"sources":["../../src/components/textarea.tsx"],"names":["InputPrimitive"],"mappings":";;;;AAOA,SAAS,SAAS,EAAE,SAAA,EAAW,GAAA,EAAK,GAAG,OAAM,EAAqC;AAChF,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAOE,GAAA;AAAA,MAACA,KAAA;AAAA,MAAA;AAAA,QACC,GAAA;AAAA,QACA,MAAA,sBAAS,UAAA,EAAA,EAAS,CAAA;AAAA,QAClB,WAAA,EAAU,UAAA;AAAA,QACV,SAAA,EAAW,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAST,uHAAA;AAAA;AAAA;AAAA;AAAA,UAIA,+EAAA;AAAA;AAAA,UAEA,kCAAA;AAAA;AAAA;AAAA;AAAA;AAAA,UAKA,mHAAA;AAAA;AAAA,UAEA,wCAAA;AAAA;AAAA,UAEA,8EAAA;AAAA;AAAA,UAEA,oLAAA;AAAA,UACA;AAAA,SACF;AAAA,QAIC,GAAI;AAAA;AAAA;AACP;AAEJ","file":"textarea.js","sourcesContent":["'use client'\n\nimport { Input as InputPrimitive } from '@base-ui/react/input'\nimport * as React from 'react'\n\nimport { cn } from '../lib/utils.js'\n\nfunction Textarea({ className, ref, ...props }: React.ComponentProps<'textarea'>) {\n return (\n // Base UI's Input IS `Field.Control`, so rendering it as a `<textarea>`\n // buys the multi-line control the same Field wiring the single-line Input\n // already has: inside a `<Field>` it is the registered control, so the\n // label association, `aria-describedby` for the description/error and\n // `aria-invalid` are handled for us. The primitive is typed for `<input>`,\n // hence the cast on the otherwise-identical props.\n <InputPrimitive\n ref={ref as React.Ref<HTMLElement>}\n render={<textarea />}\n data-slot='textarea'\n className={cn(\n // No `outline-none` here: it sets `--tw-outline-style: none` globally\n // on the element, which then suppresses the focus outline below\n // (which reads `outline-style: var(--tw-outline-style)`).\n //\n // Sizing is the one deliberate departure from Input: `field-sizing-content`\n // grows the box with its content from a three-line floor instead of\n // pinning it to Input's single-line `h-12`. Everything else — padding,\n // radius, type size, colour, state handling — is Input's.\n 'field-sizing-content min-h-24 w-full min-w-0 resize-none rounded-sm px-4 py-2 text-base motion-safe:transition-colors',\n // Every colour routes through the --input-* semantic tokens (layer 3,\n // theme.css / the registry theme item). Dark mode and brand themes\n // restyle the control by remapping tokens — no dark: variants here.\n 'border border-(--input-border) bg-(--input-surface) text-(--input-foreground)',\n // Hover\n 'hover:bg-(--input-surface-hover)',\n // Focus — `focus-visible:` per the design-system policy (matches\n // Button/Link/Input). For text fields this is behaviour-preserving:\n // browsers flag keyboard-editable controls as :focus-visible even\n // when focused by pointer, so the ring still shows on click.\n 'focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--input-ring)',\n // Placeholder styles\n 'placeholder:text-(--input-placeholder)',\n // Disabled\n 'disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',\n // Invalid — 2px danger border, danger hover surface (Figma error variants)\n 'aria-invalid:border-2 aria-invalid:border-(--input-invalid-border) aria-invalid:hover:bg-(--input-invalid-surface-hover) aria-invalid:focus-visible:outline-(--input-invalid-ring)',\n className,\n )}\n // Spread last, mirroring Input: callers must be able to override\n // `data-slot` (InputGroupTextarea relabels it `input-group-control` so\n // the group's wrapper owns the focus treatment).\n {...(props as InputPrimitive.Props)}\n />\n )\n}\n\nexport { Textarea }\n\nexport type TextareaProps = React.ComponentProps<typeof Textarea>\n"]}
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ export { Field, FieldContent, FieldContentProps, FieldDescription, FieldDescript
20
20
  export { Footer, FooterAcknowledgement, FooterAcknowledgementProps, FooterColor, FooterLegalLinkItem, FooterLegalLinks, FooterLegalLinksProps, FooterLinkItem, FooterNav, FooterNavColumn, FooterNavColumnProps, FooterNavLink, FooterNavLinkProps, FooterNavProps, FooterProps, FooterSmallPrint, FooterSmallPrintProps, FooterSocialLink, FooterSocialLinkItem, FooterSocialLinkProps, footerColors, footerContainerVariants, footerLogoType, footerVariants } from './components/footer.js';
21
21
  export { Header, HeaderActions, HeaderActionsProps, HeaderBrand, HeaderBrandProps, HeaderColor, HeaderProps, headerColors, headerContainerVariants, headerVariants } from './components/header.js';
22
22
  export { HoverCard, HoverCardContent, HoverCardTrigger } from './components/hover-card.js';
23
- export { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea } from './components/input-group.js';
23
+ export { InputGroup, InputGroupAction, InputGroupAddon, InputGroupButton, InputGroupInput, InputGroupText, InputGroupTextarea, inputGroupActionVariants } from './components/input-group.js';
24
24
  export { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from './components/input-otp.js';
25
25
  export { Input, InputProps } from './components/input.js';
26
26
  export { Kbd, KbdGroup } from './components/kbd.js';
@@ -55,7 +55,7 @@ export { Switch } from './components/switch.js';
55
55
  export { TabNav, TabNavLink, TabNavLinkProps, TabNavProps, tabNavLinkVariants, tabNavListVariants } from './components/tab-nav.js';
56
56
  export { Table, TableBody, TableCaption, TableCell, TableFooter, TableHead, TableHeader, TableRow } from './components/table.js';
57
57
  export { Tabs, TabsContent, TabsList, TabsTrigger, tabsListVariants, tabsTriggerVariants } from './components/tabs.js';
58
- export { Textarea } from './components/textarea.js';
58
+ export { Textarea, TextareaProps } from './components/textarea.js';
59
59
  export { ThemeSwitcher, ThemeSwitcherProps, ThemeSwitcherTheme } from './components/theme-switcher.js';
60
60
  export { ToggleGroup, ToggleGroupItem } from './components/toggle-group.js';
61
61
  export { Toggle, toggleVariants } from './components/toggle.js';