@luscii-healthtech/web-ui 62.0.0 → 62.0.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.
@@ -1,7 +1,34 @@
1
1
  import React from "react";
2
2
  import { type FormFieldSize } from "../../types/general.types.js";
3
3
  import { type TextareaProps } from "./Textarea";
4
- export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "isDisabled" | "isError"> & {
4
+ /**
5
+ * Form-ready textarea component that wraps {@link Textarea} with a label, helper text,
6
+ * and error text. This is the **recommended component for multi-line text in forms**.
7
+ *
8
+ * Features:
9
+ * - Renders a native `<textarea>` — compatible with `react-hook-form` `register()` directly.
10
+ * - Displays a label above the textarea when provided, linked to the textarea with `htmlFor`.
11
+ * - Shows helper text or error text below the textarea with proper `aria-describedby` wiring.
12
+ * - Automatically toggles error styling and `aria-invalid` when `errorText` is provided.
13
+ * A consumer-supplied `aria-invalid` is kept when there's no `errorText`.
14
+ *
15
+ * When to use:
16
+ * - Use `LabeledTextarea` for notes, messages, descriptions and other free text that can
17
+ * span multiple lines.
18
+ * - For single-line text, use {@link LabeledInput} instead.
19
+ * - If you need a bare textarea without label/helper/error, use {@link Textarea} directly.
20
+ *
21
+ * @example
22
+ * // With react-hook-form
23
+ * <LabeledTextarea
24
+ * label="Message"
25
+ * helperText="The patient will see this message in the app"
26
+ * {...register("message")}
27
+ * />
28
+ *
29
+ * @see {@link Textarea} for the low-level building block without form wiring.
30
+ */
31
+ type Props = Omit<TextareaProps, "isError" | "isDisabled"> & {
5
32
  /**
6
33
  * The visible label, linked to the textarea with `htmlFor`. When omitted, give
7
34
  * the textarea an accessible name with `aria-label` or `aria-labelledby`.
@@ -31,7 +58,13 @@ export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<Texta
31
58
  *
32
59
  * By default the field only takes its intrinsic width.
33
60
  */
34
- width?: FormFieldSize | [FormFieldSize, FormFieldSize?, FormFieldSize?, FormFieldSize?, FormFieldSize?];
61
+ width?: FormFieldSize | [
62
+ FormFieldSize,
63
+ FormFieldSize?,
64
+ FormFieldSize?,
65
+ FormFieldSize?,
66
+ FormFieldSize?
67
+ ];
35
68
  /**
36
69
  * When true, the field stretches to fill the full width of its container,
37
70
  * also when the container aligns its children to the start.
@@ -39,4 +72,8 @@ export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<Texta
39
72
  * Shorthand for `width="full"`. When both are given, `width` wins.
40
73
  */
41
74
  fullWidth?: boolean;
42
- } & React.RefAttributes<HTMLTextAreaElement>>;
75
+ };
76
+ export declare const LabeledTextarea: (props: Props & {
77
+ ref?: React.Ref<HTMLTextAreaElement>;
78
+ }) => React.JSX.Element;
79
+ export {};
@@ -1,7 +1,34 @@
1
1
  import React from "react";
2
2
  import { type FormFieldSize } from "../../../types/general.types.js";
3
3
  import { type TextareaProps } from "./Textarea";
4
- export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "isDisabled" | "isError"> & {
4
+ /**
5
+ * Form-ready textarea component that wraps {@link Textarea} with a label, helper text,
6
+ * and error text. This is the **recommended component for multi-line text in forms**.
7
+ *
8
+ * Features:
9
+ * - Renders a native `<textarea>` — compatible with `react-hook-form` `register()` directly.
10
+ * - Displays a label above the textarea when provided, linked to the textarea with `htmlFor`.
11
+ * - Shows helper text or error text below the textarea with proper `aria-describedby` wiring.
12
+ * - Automatically toggles error styling and `aria-invalid` when `errorText` is provided.
13
+ * A consumer-supplied `aria-invalid` is kept when there's no `errorText`.
14
+ *
15
+ * When to use:
16
+ * - Use `LabeledTextarea` for notes, messages, descriptions and other free text that can
17
+ * span multiple lines.
18
+ * - For single-line text, use {@link LabeledInput} instead.
19
+ * - If you need a bare textarea without label/helper/error, use {@link Textarea} directly.
20
+ *
21
+ * @example
22
+ * // With react-hook-form
23
+ * <LabeledTextarea
24
+ * label="Message"
25
+ * helperText="The patient will see this message in the app"
26
+ * {...register("message")}
27
+ * />
28
+ *
29
+ * @see {@link Textarea} for the low-level building block without form wiring.
30
+ */
31
+ type Props = Omit<TextareaProps, "isError" | "isDisabled"> & {
5
32
  /**
6
33
  * The visible label, linked to the textarea with `htmlFor`. When omitted, give
7
34
  * the textarea an accessible name with `aria-label` or `aria-labelledby`.
@@ -31,7 +58,13 @@ export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<Texta
31
58
  *
32
59
  * By default the field only takes its intrinsic width.
33
60
  */
34
- width?: FormFieldSize | [FormFieldSize, FormFieldSize?, FormFieldSize?, FormFieldSize?, FormFieldSize?];
61
+ width?: FormFieldSize | [
62
+ FormFieldSize,
63
+ FormFieldSize?,
64
+ FormFieldSize?,
65
+ FormFieldSize?,
66
+ FormFieldSize?
67
+ ];
35
68
  /**
36
69
  * When true, the field stretches to fill the full width of its container,
37
70
  * also when the container aligns its children to the start.
@@ -39,4 +72,8 @@ export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<Texta
39
72
  * Shorthand for `width="full"`. When both are given, `width` wins.
40
73
  */
41
74
  fullWidth?: boolean;
42
- } & React.RefAttributes<HTMLTextAreaElement>>;
75
+ };
76
+ export declare const LabeledTextarea: (props: Props & {
77
+ ref?: React.Ref<HTMLTextAreaElement>;
78
+ }) => React.JSX.Element;
79
+ export {};
@@ -1,13 +1,15 @@
1
1
  import type { StoryObj } from "@storybook/react-vite";
2
2
  declare const meta: {
3
3
  title: string;
4
- component: import("react").ForwardRefExoticComponent<Omit<import("../src").TextareaProps, "isDisabled" | "isError"> & {
4
+ component: (props: (Omit<import("../src").TextareaProps, "isDisabled" | "isError"> & {
5
5
  label?: React.ReactNode;
6
6
  helperText?: React.ReactNode;
7
7
  errorText?: React.ReactNode;
8
8
  width?: import("../src/types/general.types").FormFieldSize | [import("../src/types/general.types").FormFieldSize, import("../src/types/general.types").FormFieldSize?, import("../src/types/general.types").FormFieldSize?, import("../src/types/general.types").FormFieldSize?, import("../src/types/general.types").FormFieldSize?];
9
9
  fullWidth?: boolean;
10
- } & import("react").RefAttributes<HTMLTextAreaElement>>;
10
+ }) & {
11
+ ref?: React.Ref<HTMLTextAreaElement>;
12
+ }) => import("react").JSX.Element;
11
13
  args: {
12
14
  onChange: import("@vitest/spy").Mock<(...args: any[]) => any>;
13
15
  onBlur: import("@vitest/spy").Mock<(...args: any[]) => any>;
@@ -87,3 +89,8 @@ export declare const Widths: Story;
87
89
  * `width` also accepts a tuple of sizes per breakpoint.
88
90
  */
89
91
  export declare const ResponsiveWidth: Story;
92
+ /**
93
+ * `LabeledTextarea` accepts a `ref`, which points to its native `<textarea>`.
94
+ * Form libraries such as react-hook-form's `register()` rely on this.
95
+ */
96
+ export declare const WithRef: Story;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luscii-healthtech/web-ui",
3
- "version": "62.0.0",
3
+ "version": "62.0.2",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Joris Janssen"
@@ -146,7 +146,7 @@
146
146
  "rollup-plugin-visualizer": "^5.9.2",
147
147
  "sass": "^1.105.1",
148
148
  "sass-loader": "^17.0.1",
149
- "storybook": "^10.6.2",
149
+ "storybook": "^10.6.5",
150
150
  "storybook-addon-tag-badges": "^3.1.0",
151
151
  "style-inject": "^0.3.0",
152
152
  "tailwindcss": "^4.3.3",