@luscii-healthtech/web-ui 60.3.2 → 60.4.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.
- package/dist/esm/components/Textarea/LabeledTextarea.js +21 -0
- package/dist/esm/components/Textarea/LabeledTextarea.js.map +1 -0
- package/dist/esm/components/Textarea/Textarea.js +9 -10
- package/dist/esm/components/Textarea/Textarea.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/index.development.js +86 -77
- package/dist/index.development.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/components/Textarea/LabeledTextarea.d.ts +42 -0
- package/dist/src/components/Textarea/Textarea.d.ts +11 -2
- package/dist/src/generated/components/Textarea/LabeledTextarea.d.ts +42 -0
- package/dist/src/generated/components/Textarea/Textarea.d.ts +11 -2
- package/dist/src/generated/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/stories/LabeledTextarea.stories.d.ts +89 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FormFieldSize } from "../../types/general.types.js";
|
|
3
|
+
import { type TextareaProps } from "./Textarea";
|
|
4
|
+
export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "isDisabled" | "isError"> & {
|
|
5
|
+
/**
|
|
6
|
+
* The visible label, linked to the textarea with `htmlFor`. When omitted, give
|
|
7
|
+
* the textarea an accessible name with `aria-label` or `aria-labelledby`.
|
|
8
|
+
*
|
|
9
|
+
* Besides a string, this can be a node, for example to add an icon next to
|
|
10
|
+
* the text. It's rendered inside a `<label>`, so keep it phrasing content
|
|
11
|
+
* (no headings or blocks) and non-interactive: interactive content would
|
|
12
|
+
* become part of the field's accessible name.
|
|
13
|
+
*/
|
|
14
|
+
label?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Any additional information to show underneath the textarea.
|
|
17
|
+
*
|
|
18
|
+
* When given as a string, it is rendered as sanitized HTML (DOMPurify),
|
|
19
|
+
* so translated copy can contain markup such as links.
|
|
20
|
+
*/
|
|
21
|
+
helperText?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* An error message that should be shown when there's something wrong
|
|
24
|
+
* with the user's input.
|
|
25
|
+
*/
|
|
26
|
+
errorText?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* The width of the whole field: label, textarea and helper/error text.
|
|
29
|
+
* Accepts the same sizes as `LabeledInput`'s `width`, including a tuple of
|
|
30
|
+
* sizes per breakpoint. The textarea stretches to fill this width.
|
|
31
|
+
*
|
|
32
|
+
* By default the field only takes its intrinsic width.
|
|
33
|
+
*/
|
|
34
|
+
width?: FormFieldSize | [FormFieldSize, FormFieldSize?, FormFieldSize?, FormFieldSize?, FormFieldSize?];
|
|
35
|
+
/**
|
|
36
|
+
* When true, the field stretches to fill the full width of its container,
|
|
37
|
+
* also when the container aligns its children to the start.
|
|
38
|
+
*
|
|
39
|
+
* Shorthand for `width="full"`. When both are given, `width` wins.
|
|
40
|
+
*/
|
|
41
|
+
fullWidth?: boolean;
|
|
42
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -7,7 +7,12 @@ declare const resizeTypes: {
|
|
|
7
7
|
readonly VERTICAL: "vertical";
|
|
8
8
|
};
|
|
9
9
|
export type ResizeTypes = (typeof resizeTypes)[keyof typeof resizeTypes];
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Besides its own props, the textarea takes any native `<textarea>`
|
|
12
|
+
* attribute (e.g. `id`, `required`, `aria-describedby`), which is spread onto
|
|
13
|
+
* the element.
|
|
14
|
+
*/
|
|
15
|
+
export interface TextareaProps extends React.ComponentPropsWithoutRef<"textarea"> {
|
|
11
16
|
className?: string;
|
|
12
17
|
value?: string;
|
|
13
18
|
name?: string;
|
|
@@ -15,9 +20,13 @@ export interface TextareaProps {
|
|
|
15
20
|
maxLength?: number;
|
|
16
21
|
rows?: number;
|
|
17
22
|
resizable?: ResizeTypes;
|
|
23
|
+
/**
|
|
24
|
+
* Disables the textarea. Equivalent to the native `disabled` attribute;
|
|
25
|
+
* the textarea is disabled when either is true.
|
|
26
|
+
*/
|
|
18
27
|
isDisabled?: boolean;
|
|
19
28
|
icon?: string;
|
|
20
|
-
onChange
|
|
29
|
+
onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
21
30
|
onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
22
31
|
onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
23
32
|
onKeyPress?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { type FormFieldSize } from "../../../types/general.types.js";
|
|
3
|
+
import { type TextareaProps } from "./Textarea";
|
|
4
|
+
export declare const LabeledTextarea: React.ForwardRefExoticComponent<Omit<TextareaProps, "isDisabled" | "isError"> & {
|
|
5
|
+
/**
|
|
6
|
+
* The visible label, linked to the textarea with `htmlFor`. When omitted, give
|
|
7
|
+
* the textarea an accessible name with `aria-label` or `aria-labelledby`.
|
|
8
|
+
*
|
|
9
|
+
* Besides a string, this can be a node, for example to add an icon next to
|
|
10
|
+
* the text. It's rendered inside a `<label>`, so keep it phrasing content
|
|
11
|
+
* (no headings or blocks) and non-interactive: interactive content would
|
|
12
|
+
* become part of the field's accessible name.
|
|
13
|
+
*/
|
|
14
|
+
label?: React.ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Any additional information to show underneath the textarea.
|
|
17
|
+
*
|
|
18
|
+
* When given as a string, it is rendered as sanitized HTML (DOMPurify),
|
|
19
|
+
* so translated copy can contain markup such as links.
|
|
20
|
+
*/
|
|
21
|
+
helperText?: React.ReactNode;
|
|
22
|
+
/**
|
|
23
|
+
* An error message that should be shown when there's something wrong
|
|
24
|
+
* with the user's input.
|
|
25
|
+
*/
|
|
26
|
+
errorText?: React.ReactNode;
|
|
27
|
+
/**
|
|
28
|
+
* The width of the whole field: label, textarea and helper/error text.
|
|
29
|
+
* Accepts the same sizes as `LabeledInput`'s `width`, including a tuple of
|
|
30
|
+
* sizes per breakpoint. The textarea stretches to fill this width.
|
|
31
|
+
*
|
|
32
|
+
* By default the field only takes its intrinsic width.
|
|
33
|
+
*/
|
|
34
|
+
width?: FormFieldSize | [FormFieldSize, FormFieldSize?, FormFieldSize?, FormFieldSize?, FormFieldSize?];
|
|
35
|
+
/**
|
|
36
|
+
* When true, the field stretches to fill the full width of its container,
|
|
37
|
+
* also when the container aligns its children to the start.
|
|
38
|
+
*
|
|
39
|
+
* Shorthand for `width="full"`. When both are given, `width` wins.
|
|
40
|
+
*/
|
|
41
|
+
fullWidth?: boolean;
|
|
42
|
+
} & React.RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -7,7 +7,12 @@ declare const resizeTypes: {
|
|
|
7
7
|
readonly VERTICAL: "vertical";
|
|
8
8
|
};
|
|
9
9
|
export type ResizeTypes = (typeof resizeTypes)[keyof typeof resizeTypes];
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Besides its own props, the textarea takes any native `<textarea>`
|
|
12
|
+
* attribute (e.g. `id`, `required`, `aria-describedby`), which is spread onto
|
|
13
|
+
* the element.
|
|
14
|
+
*/
|
|
15
|
+
export interface TextareaProps extends React.ComponentPropsWithoutRef<"textarea"> {
|
|
11
16
|
className?: string;
|
|
12
17
|
value?: string;
|
|
13
18
|
name?: string;
|
|
@@ -15,9 +20,13 @@ export interface TextareaProps {
|
|
|
15
20
|
maxLength?: number;
|
|
16
21
|
rows?: number;
|
|
17
22
|
resizable?: ResizeTypes;
|
|
23
|
+
/**
|
|
24
|
+
* Disables the textarea. Equivalent to the native `disabled` attribute;
|
|
25
|
+
* the textarea is disabled when either is true.
|
|
26
|
+
*/
|
|
18
27
|
isDisabled?: boolean;
|
|
19
28
|
icon?: string;
|
|
20
|
-
onChange
|
|
29
|
+
onChange?: (event: ChangeEvent<HTMLTextAreaElement>) => void;
|
|
21
30
|
onBlur?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
22
31
|
onFocus?: (event: FocusEvent<HTMLTextAreaElement>) => void;
|
|
23
32
|
onKeyPress?: (event: KeyboardEvent<HTMLTextAreaElement>) => void;
|
|
@@ -46,6 +46,7 @@ export { StyledInput } from "./components/Input/StyledInput";
|
|
|
46
46
|
export { StyledRadio } from "./components/Radio/StyledRadio";
|
|
47
47
|
export { LabeledDatePicker } from "./components/DatePicker/LabeledDatePicker";
|
|
48
48
|
export { LabeledInput } from "./components/Input/LabeledInput";
|
|
49
|
+
export { LabeledTextarea } from "./components/Textarea/LabeledTextarea";
|
|
49
50
|
export { LabeledRadio } from "./components/Radio/LabeledRadio";
|
|
50
51
|
export { LabeledRadioGroup } from "./components/Radio/LabeledRadioGroup";
|
|
51
52
|
export { LabelText } from "./components/forms/shared/LabelText";
|
package/dist/src/index.d.ts
CHANGED
|
@@ -46,6 +46,7 @@ export { StyledInput } from "./components/Input/StyledInput";
|
|
|
46
46
|
export { StyledRadio } from "./components/Radio/StyledRadio";
|
|
47
47
|
export { LabeledDatePicker } from "./components/DatePicker/LabeledDatePicker";
|
|
48
48
|
export { LabeledInput } from "./components/Input/LabeledInput";
|
|
49
|
+
export { LabeledTextarea } from "./components/Textarea/LabeledTextarea";
|
|
49
50
|
export { LabeledRadio } from "./components/Radio/LabeledRadio";
|
|
50
51
|
export { LabeledRadioGroup } from "./components/Radio/LabeledRadioGroup";
|
|
51
52
|
export { LabelText } from "./components/forms/shared/LabelText";
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react-vite";
|
|
2
|
+
declare const meta: {
|
|
3
|
+
title: string;
|
|
4
|
+
component: import("react").ForwardRefExoticComponent<Omit<import("../src").TextareaProps, "isDisabled" | "isError"> & {
|
|
5
|
+
label?: React.ReactNode;
|
|
6
|
+
helperText?: React.ReactNode;
|
|
7
|
+
errorText?: React.ReactNode;
|
|
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
|
+
fullWidth?: boolean;
|
|
10
|
+
} & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
11
|
+
args: {
|
|
12
|
+
onChange: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
13
|
+
onBlur: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
14
|
+
onFocus: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
15
|
+
onKeyDown: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
16
|
+
onKeyPress: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
17
|
+
onCtrlEnter: import("@vitest/spy").Mock<(...args: any[]) => any>;
|
|
18
|
+
};
|
|
19
|
+
argTypes: {
|
|
20
|
+
helperText: {
|
|
21
|
+
control: {
|
|
22
|
+
type: "text";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
errorText: {
|
|
26
|
+
control: {
|
|
27
|
+
type: "text";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
parameters: {
|
|
32
|
+
backgrounds: {
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
tags: "new"[];
|
|
37
|
+
};
|
|
38
|
+
export default meta;
|
|
39
|
+
type Story = StoryObj<typeof meta>;
|
|
40
|
+
export declare const Base: Story;
|
|
41
|
+
export declare const Disabled: Story;
|
|
42
|
+
export declare const Placeholder: Story;
|
|
43
|
+
/**
|
|
44
|
+
* `onCtrlEnter` is called when the user presses Ctrl+Enter (or Cmd+Enter),
|
|
45
|
+
* for example to submit a message.
|
|
46
|
+
*/
|
|
47
|
+
export declare const CtrlEnter: Story;
|
|
48
|
+
/**
|
|
49
|
+
* Use `rows` to set the initial height of the textarea.
|
|
50
|
+
*/
|
|
51
|
+
export declare const Rows: Story;
|
|
52
|
+
/**
|
|
53
|
+
* By default the textarea can be resized vertically. Use `resizable` to
|
|
54
|
+
* change that.
|
|
55
|
+
*/
|
|
56
|
+
export declare const Resizable: Story;
|
|
57
|
+
export declare const HelperText: Story;
|
|
58
|
+
/**
|
|
59
|
+
* Helper text given as a string is rendered as sanitized HTML, so translated
|
|
60
|
+
* copy can contain markup such as links.
|
|
61
|
+
*/
|
|
62
|
+
export declare const HelperTextWithHtml: Story;
|
|
63
|
+
/**
|
|
64
|
+
* When `errorText` is given, it replaces the helper text, the textarea gets
|
|
65
|
+
* error styling and it is marked `aria-invalid`.
|
|
66
|
+
*/
|
|
67
|
+
export declare const ErrorText: Story;
|
|
68
|
+
/**
|
|
69
|
+
* Besides a string, `label` takes a node, for example to add a muted
|
|
70
|
+
* "(optional)" next to the text. It's rendered inside the `<label>`, so keep
|
|
71
|
+
* it phrasing content and non-interactive: all of its text becomes the
|
|
72
|
+
* textarea's accessible name.
|
|
73
|
+
*/
|
|
74
|
+
export declare const LabelAsNode: Story;
|
|
75
|
+
/**
|
|
76
|
+
* Demonstrates the `fullWidth` prop. The textarea, helper text, and error text
|
|
77
|
+
* stretch to fill the container width instead of taking their intrinsic size.
|
|
78
|
+
* `fullWidth` is a shorthand for `width="full"`.
|
|
79
|
+
*/
|
|
80
|
+
export declare const FullWidth: Story;
|
|
81
|
+
/**
|
|
82
|
+
* The `width` prop sizes the whole field, like `width` on `LabeledInput`. The
|
|
83
|
+
* textarea, helper text and error text fill that width.
|
|
84
|
+
*/
|
|
85
|
+
export declare const Widths: Story;
|
|
86
|
+
/**
|
|
87
|
+
* `width` also accepts a tuple of sizes per breakpoint.
|
|
88
|
+
*/
|
|
89
|
+
export declare const ResponsiveWidth: Story;
|