@k8slens/lds-form 0.53.2 → 0.53.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.
- package/lib/cjs/FormErrorMessage/FormErrorMessage.d.ts +6 -2
- package/lib/cjs/FormField/FormField.d.ts +13 -8
- package/lib/cjs/FormLabel/FormLabel.d.ts +11 -3
- package/lib/cjs/FormSwitchGroup/FormSwitchGroup.d.ts +12 -0
- package/lib/es/FormErrorMessage/FormErrorMessage.d.ts +6 -2
- package/lib/es/FormField/FormField.d.ts +13 -8
- package/lib/es/FormLabel/FormLabel.d.ts +11 -3
- package/lib/es/FormSwitchGroup/FormSwitchGroup.d.ts +12 -0
- package/llms.txt +79 -28
- package/package.json +4 -4
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/** Props for the FormErrorMessage component. */
|
|
2
3
|
export interface FormErrorMessageProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "id" | "htmlFor"> {
|
|
4
|
+
/** HTML `id` for the error message element. */
|
|
3
5
|
id: string;
|
|
6
|
+
/** `id` of the form control this error message describes. */
|
|
4
7
|
forId: string;
|
|
8
|
+
/** List of error strings to display. */
|
|
5
9
|
errors: Array<string>;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* Displays validation errors as a list associated with a form control.
|
|
9
13
|
*
|
|
10
|
-
* `import { FormErrorMessage } from @k8slens/lds-form`
|
|
14
|
+
* Usage: `import { FormErrorMessage } from "@k8slens/lds-form"`
|
|
11
15
|
*/
|
|
12
16
|
declare const FormErrorMessage: ({ id, forId, errors, ...props }: FormErrorMessageProps) => React.JSX.Element;
|
|
13
17
|
export default FormErrorMessage;
|
|
@@ -3,20 +3,26 @@ import { FormLabelProps } from "../FormLabel/FormLabel";
|
|
|
3
3
|
import { FormErrorMessageProps } from "../FormErrorMessage/FormErrorMessage";
|
|
4
4
|
import { ErrorParser } from "../common/useFormComponentData";
|
|
5
5
|
import { Validator } from "../common/validation";
|
|
6
|
+
/** Props for the FormField component. */
|
|
6
7
|
export interface FormFieldProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "id"> {
|
|
7
|
-
/**
|
|
8
|
+
/** The `id` of the child form control (e.g. `<input>`). Optional because HeadlessUI Combobox omits it on first render. */
|
|
8
9
|
id: string | undefined;
|
|
9
|
-
/**
|
|
10
|
+
/** Label text rendered inside a `<label>` element. */
|
|
10
11
|
label: string;
|
|
11
|
-
/**
|
|
12
|
+
/** Unique `id` for the error message element. Must differ from `id`. */
|
|
12
13
|
errorId: string;
|
|
13
|
-
/**
|
|
14
|
+
/** Unique `id` for the label element. Must differ from `id`. */
|
|
14
15
|
labelId: string;
|
|
16
|
+
/** Whether the field is required. */
|
|
15
17
|
required?: boolean;
|
|
18
|
+
/** Validation error strings to display. */
|
|
16
19
|
errors?: Array<string>;
|
|
20
|
+
/** Props forwarded to the `FormLabel` component. */
|
|
17
21
|
labelProps?: Partial<FormLabelProps>;
|
|
22
|
+
/** Props forwarded to the `FormErrorMessage` component. */
|
|
18
23
|
errorProps?: Partial<Omit<FormErrorMessageProps, "forId" | "id">>;
|
|
19
24
|
}
|
|
25
|
+
/** Shared props for form components that combine a field with validation and error display. */
|
|
20
26
|
export interface FormFieldComponentProps<T,
|
|
21
27
|
/** Custom error string(s) to be used in validation & error parser */
|
|
22
28
|
CustomError extends string> extends Pick<FormFieldProps, "label" | "labelProps" | "errorProps"> {
|
|
@@ -24,13 +30,12 @@ CustomError extends string> extends Pick<FormFieldProps, "label" | "labelProps"
|
|
|
24
30
|
validate?: Validator<T, CustomError>;
|
|
25
31
|
/** Return error message for given error key. */
|
|
26
32
|
errorParser?: ErrorParser<T, CustomError>;
|
|
33
|
+
/** Called when the value changes with the new value and its validity. */
|
|
27
34
|
onChange?: (value: T, isValid: boolean) => void;
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
|
-
* Generic form field
|
|
37
|
+
* Generic form field wrapper that renders a label, child control, and error messages.
|
|
31
38
|
*
|
|
32
|
-
* `import { FormField } from @k8slens/lds-form`
|
|
33
|
-
*
|
|
34
|
-
* See `FormComponent`for individual form components.
|
|
39
|
+
* Usage: `import { FormField } from "@k8slens/lds-form"`
|
|
35
40
|
*/
|
|
36
41
|
export default function FormField({ id, label, labelId, errorId, required, errors, children, labelProps, errorProps, ...props }: PropsWithChildren<FormFieldProps>): React.JSX.Element;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import React, { type ReactElement } from "react";
|
|
2
|
+
/** Props for the FormLabel component. */
|
|
2
3
|
export interface FormLabelProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "id" | "htmlFor"> {
|
|
4
|
+
/** HTML `id` for the label element. */
|
|
3
5
|
id: string;
|
|
6
|
+
/** `id` of the form control this label is for. */
|
|
4
7
|
forId: string;
|
|
8
|
+
/** Label content — a string or React element. */
|
|
5
9
|
label: ReactElement | string;
|
|
10
|
+
/** Whether the associated field is required (used together with `showRequired`). */
|
|
6
11
|
required?: boolean;
|
|
7
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Show required asterisk and visually hidden "required" text.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
8
16
|
showRequired?: boolean;
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
11
|
-
*
|
|
19
|
+
* A `<label>` element with optional required indicator. Used internally by `FormField`.
|
|
12
20
|
*
|
|
13
|
-
* `import { FormLabel } from @k8slens/lds-form`
|
|
21
|
+
* Usage: `import { FormLabel } from "@k8slens/lds-form"`
|
|
14
22
|
*/
|
|
15
23
|
declare const FormLabel: ({ id, forId, label, showRequired, required, ...props }: FormLabelProps) => React.JSX.Element;
|
|
16
24
|
export default FormLabel;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import React, { PropsWithChildren, ReactNode } from "react";
|
|
2
2
|
import { type SwitchProps } from "@k8slens/lds/lib/es/Switch/Switch.d";
|
|
3
3
|
import { FormFieldComponentProps } from "../FormField/FormField";
|
|
4
|
+
/** Describes a single switch within a `FormSwitchGroup`. */
|
|
4
5
|
export declare type SwitchValue = {
|
|
6
|
+
/** Unique identifier for this switch. */
|
|
5
7
|
id: string;
|
|
8
|
+
/** Label displayed next to the switch. */
|
|
6
9
|
label: string;
|
|
10
|
+
/** Whether the switch is on. */
|
|
7
11
|
checked: boolean | undefined;
|
|
12
|
+
/** Whether this individual switch is disabled. */
|
|
8
13
|
disabled?: boolean;
|
|
14
|
+
/** Optional description rendered below the label. */
|
|
9
15
|
description?: string | ReactNode;
|
|
10
16
|
};
|
|
17
|
+
/** Props for the FormSwitchGroup component. */
|
|
11
18
|
export interface FormSwitchGroupProps<CustomError extends string> extends Omit<FormFieldComponentProps<number, CustomError>, "onChange" | "value">, Omit<SwitchProps, "value" | "onChange" | "label"> {
|
|
19
|
+
/** HTML `id` attribute for the field. */
|
|
12
20
|
id?: string;
|
|
21
|
+
/** Props forwarded to the wrapper div. */
|
|
13
22
|
wrapperProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
23
|
+
/** Array of switch items to render. */
|
|
14
24
|
values: Array<SwitchValue>;
|
|
25
|
+
/** Called when any switch changes with the full array and the IDs that changed. */
|
|
15
26
|
onChange(values: Array<SwitchValue>, updatedKeys: Array<string>): void;
|
|
27
|
+
/** Validation error strings to display. */
|
|
16
28
|
errors?: Array<string>;
|
|
17
29
|
}
|
|
18
30
|
/**
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
/** Props for the FormErrorMessage component. */
|
|
2
3
|
export interface FormErrorMessageProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "id" | "htmlFor"> {
|
|
4
|
+
/** HTML `id` for the error message element. */
|
|
3
5
|
id: string;
|
|
6
|
+
/** `id` of the form control this error message describes. */
|
|
4
7
|
forId: string;
|
|
8
|
+
/** List of error strings to display. */
|
|
5
9
|
errors: Array<string>;
|
|
6
10
|
}
|
|
7
11
|
/**
|
|
8
|
-
*
|
|
12
|
+
* Displays validation errors as a list associated with a form control.
|
|
9
13
|
*
|
|
10
|
-
* `import { FormErrorMessage } from @k8slens/lds-form`
|
|
14
|
+
* Usage: `import { FormErrorMessage } from "@k8slens/lds-form"`
|
|
11
15
|
*/
|
|
12
16
|
declare const FormErrorMessage: ({ id, forId, errors, ...props }: FormErrorMessageProps) => React.JSX.Element;
|
|
13
17
|
export default FormErrorMessage;
|
|
@@ -3,20 +3,26 @@ import { FormLabelProps } from "../FormLabel/FormLabel";
|
|
|
3
3
|
import { FormErrorMessageProps } from "../FormErrorMessage/FormErrorMessage";
|
|
4
4
|
import { ErrorParser } from "../common/useFormComponentData";
|
|
5
5
|
import { Validator } from "../common/validation";
|
|
6
|
+
/** Props for the FormField component. */
|
|
6
7
|
export interface FormFieldProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "id"> {
|
|
7
|
-
/**
|
|
8
|
+
/** The `id` of the child form control (e.g. `<input>`). Optional because HeadlessUI Combobox omits it on first render. */
|
|
8
9
|
id: string | undefined;
|
|
9
|
-
/**
|
|
10
|
+
/** Label text rendered inside a `<label>` element. */
|
|
10
11
|
label: string;
|
|
11
|
-
/**
|
|
12
|
+
/** Unique `id` for the error message element. Must differ from `id`. */
|
|
12
13
|
errorId: string;
|
|
13
|
-
/**
|
|
14
|
+
/** Unique `id` for the label element. Must differ from `id`. */
|
|
14
15
|
labelId: string;
|
|
16
|
+
/** Whether the field is required. */
|
|
15
17
|
required?: boolean;
|
|
18
|
+
/** Validation error strings to display. */
|
|
16
19
|
errors?: Array<string>;
|
|
20
|
+
/** Props forwarded to the `FormLabel` component. */
|
|
17
21
|
labelProps?: Partial<FormLabelProps>;
|
|
22
|
+
/** Props forwarded to the `FormErrorMessage` component. */
|
|
18
23
|
errorProps?: Partial<Omit<FormErrorMessageProps, "forId" | "id">>;
|
|
19
24
|
}
|
|
25
|
+
/** Shared props for form components that combine a field with validation and error display. */
|
|
20
26
|
export interface FormFieldComponentProps<T,
|
|
21
27
|
/** Custom error string(s) to be used in validation & error parser */
|
|
22
28
|
CustomError extends string> extends Pick<FormFieldProps, "label" | "labelProps" | "errorProps"> {
|
|
@@ -24,13 +30,12 @@ CustomError extends string> extends Pick<FormFieldProps, "label" | "labelProps"
|
|
|
24
30
|
validate?: Validator<T, CustomError>;
|
|
25
31
|
/** Return error message for given error key. */
|
|
26
32
|
errorParser?: ErrorParser<T, CustomError>;
|
|
33
|
+
/** Called when the value changes with the new value and its validity. */
|
|
27
34
|
onChange?: (value: T, isValid: boolean) => void;
|
|
28
35
|
}
|
|
29
36
|
/**
|
|
30
|
-
* Generic form field
|
|
37
|
+
* Generic form field wrapper that renders a label, child control, and error messages.
|
|
31
38
|
*
|
|
32
|
-
* `import { FormField } from @k8slens/lds-form`
|
|
33
|
-
*
|
|
34
|
-
* See `FormComponent`for individual form components.
|
|
39
|
+
* Usage: `import { FormField } from "@k8slens/lds-form"`
|
|
35
40
|
*/
|
|
36
41
|
export default function FormField({ id, label, labelId, errorId, required, errors, children, labelProps, errorProps, ...props }: PropsWithChildren<FormFieldProps>): React.JSX.Element;
|
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
import React, { type ReactElement } from "react";
|
|
2
|
+
/** Props for the FormLabel component. */
|
|
2
3
|
export interface FormLabelProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "id" | "htmlFor"> {
|
|
4
|
+
/** HTML `id` for the label element. */
|
|
3
5
|
id: string;
|
|
6
|
+
/** `id` of the form control this label is for. */
|
|
4
7
|
forId: string;
|
|
8
|
+
/** Label content — a string or React element. */
|
|
5
9
|
label: ReactElement | string;
|
|
10
|
+
/** Whether the associated field is required (used together with `showRequired`). */
|
|
6
11
|
required?: boolean;
|
|
7
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Show required asterisk and visually hidden "required" text.
|
|
14
|
+
* @default false
|
|
15
|
+
*/
|
|
8
16
|
showRequired?: boolean;
|
|
9
17
|
}
|
|
10
18
|
/**
|
|
11
|
-
*
|
|
19
|
+
* A `<label>` element with optional required indicator. Used internally by `FormField`.
|
|
12
20
|
*
|
|
13
|
-
* `import { FormLabel } from @k8slens/lds-form`
|
|
21
|
+
* Usage: `import { FormLabel } from "@k8slens/lds-form"`
|
|
14
22
|
*/
|
|
15
23
|
declare const FormLabel: ({ id, forId, label, showRequired, required, ...props }: FormLabelProps) => React.JSX.Element;
|
|
16
24
|
export default FormLabel;
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
import React, { PropsWithChildren, ReactNode } from "react";
|
|
2
2
|
import { type SwitchProps } from "@k8slens/lds/lib/es/Switch/Switch.d";
|
|
3
3
|
import { FormFieldComponentProps } from "../FormField/FormField";
|
|
4
|
+
/** Describes a single switch within a `FormSwitchGroup`. */
|
|
4
5
|
export declare type SwitchValue = {
|
|
6
|
+
/** Unique identifier for this switch. */
|
|
5
7
|
id: string;
|
|
8
|
+
/** Label displayed next to the switch. */
|
|
6
9
|
label: string;
|
|
10
|
+
/** Whether the switch is on. */
|
|
7
11
|
checked: boolean | undefined;
|
|
12
|
+
/** Whether this individual switch is disabled. */
|
|
8
13
|
disabled?: boolean;
|
|
14
|
+
/** Optional description rendered below the label. */
|
|
9
15
|
description?: string | ReactNode;
|
|
10
16
|
};
|
|
17
|
+
/** Props for the FormSwitchGroup component. */
|
|
11
18
|
export interface FormSwitchGroupProps<CustomError extends string> extends Omit<FormFieldComponentProps<number, CustomError>, "onChange" | "value">, Omit<SwitchProps, "value" | "onChange" | "label"> {
|
|
19
|
+
/** HTML `id` attribute for the field. */
|
|
12
20
|
id?: string;
|
|
21
|
+
/** Props forwarded to the wrapper div. */
|
|
13
22
|
wrapperProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
23
|
+
/** Array of switch items to render. */
|
|
14
24
|
values: Array<SwitchValue>;
|
|
25
|
+
/** Called when any switch changes with the full array and the IDs that changed. */
|
|
15
26
|
onChange(values: Array<SwitchValue>, updatedKeys: Array<string>): void;
|
|
27
|
+
/** Validation error strings to display. */
|
|
16
28
|
errors?: Array<string>;
|
|
17
29
|
}
|
|
18
30
|
/**
|
package/llms.txt
CHANGED
|
@@ -29,53 +29,87 @@ import "@k8slens/lds-form/lib/es/index.css";
|
|
|
29
29
|
|
|
30
30
|
### FormField
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Generic form field wrapper that renders a label, child control, and error messages.
|
|
33
33
|
|
|
34
34
|
```tsx
|
|
35
35
|
import { FormField, FormLabel, FormInput, FormErrorMessage } from "@k8slens/lds-form";
|
|
36
36
|
|
|
37
|
-
<FormField>
|
|
38
|
-
<
|
|
39
|
-
<FormInput type="email" />
|
|
40
|
-
<FormErrorMessage>Please enter a valid email</FormErrorMessage>
|
|
37
|
+
<FormField id="email" label="Email" labelId="email-label" errorId="email-error">
|
|
38
|
+
<input id="email" type="email" />
|
|
41
39
|
</FormField>
|
|
42
40
|
```
|
|
43
41
|
|
|
42
|
+
**FormFieldProps**
|
|
43
|
+
|
|
44
|
+
| Prop | Type | Default | Description |
|
|
45
|
+
|------|------|---------|-------------|
|
|
46
|
+
| `id` | `string \| undefined` | — | The `id` of the child form control. Optional because HeadlessUI Combobox omits it on first render. |
|
|
47
|
+
| `label` | `string` | — | Label text rendered inside a `<label>` element. |
|
|
48
|
+
| `errorId` | `string` | — | Unique `id` for the error message element. Must differ from `id`. |
|
|
49
|
+
| `labelId` | `string` | — | Unique `id` for the label element. Must differ from `id`. |
|
|
50
|
+
| `required` | `boolean` | — | Whether the field is required. |
|
|
51
|
+
| `errors` | `Array<string>` | — | Validation error strings to display. |
|
|
52
|
+
| `labelProps` | `Partial<FormLabelProps>` | — | Props forwarded to the `FormLabel` component. |
|
|
53
|
+
| `errorProps` | `Partial<Omit<FormErrorMessageProps, "forId" \| "id">>` | — | Props forwarded to the `FormErrorMessage` component. |
|
|
54
|
+
|
|
55
|
+
**FormFieldComponentProps** — shared props for form components combining a field with validation:
|
|
56
|
+
|
|
57
|
+
| Prop | Type | Description |
|
|
58
|
+
|------|------|-------------|
|
|
59
|
+
| `label` | `string` | Label text. |
|
|
60
|
+
| `labelProps` | `Partial<FormLabelProps>` | Props forwarded to `FormLabel`. |
|
|
61
|
+
| `errorProps` | `Partial<...>` | Props forwarded to `FormErrorMessage`. |
|
|
62
|
+
| `validate` | `Validator<T, CustomError>` | Validation function — return `undefined` if valid, error key(s) if invalid. |
|
|
63
|
+
| `errorParser` | `ErrorParser<T, CustomError>` | Return error message string for a given error key. |
|
|
64
|
+
| `onChange` | `(value: T, isValid: boolean) => void` | Called when value changes with new value and validity. |
|
|
65
|
+
|
|
44
66
|
### FormInput
|
|
45
67
|
|
|
46
|
-
Input with label, validation, and error handling. Wraps core Input in FormField
|
|
68
|
+
Input with label, validation, and error handling. Wraps core `Input` in `FormField`.
|
|
47
69
|
|
|
48
70
|
```tsx
|
|
49
|
-
import { FormInput } from "@k8slens/lds-form";
|
|
50
|
-
|
|
51
71
|
<FormInput name="email" type="email" label="Email" value={email} onChange={setEmail} />
|
|
52
72
|
```
|
|
53
73
|
|
|
54
74
|
### FormLabel
|
|
55
75
|
|
|
56
|
-
|
|
76
|
+
A `<label>` element with optional required indicator. Used internally by `FormField`.
|
|
57
77
|
|
|
58
|
-
|
|
78
|
+
```tsx
|
|
79
|
+
<FormLabel id="email-label" forId="email" label="Email" required showRequired />
|
|
80
|
+
```
|
|
59
81
|
|
|
60
|
-
|
|
82
|
+
**FormLabelProps**
|
|
61
83
|
|
|
62
|
-
|
|
84
|
+
| Prop | Type | Default | Description |
|
|
85
|
+
|------|------|---------|-------------|
|
|
86
|
+
| `id` | `string` | — | HTML `id` for the label element. |
|
|
87
|
+
| `forId` | `string` | — | `id` of the form control this label is for. |
|
|
88
|
+
| `label` | `ReactElement \| string` | — | Label content — a string or React element. |
|
|
89
|
+
| `required` | `boolean` | — | Whether the associated field is required (used together with `showRequired`). |
|
|
90
|
+
| `showRequired` | `boolean` | `false` | Show required asterisk and visually hidden "required" text. |
|
|
63
91
|
|
|
64
|
-
|
|
92
|
+
### FormErrorMessage
|
|
65
93
|
|
|
66
|
-
|
|
67
|
-
import { FormSwitchGroup } from "@k8slens/lds-form";
|
|
94
|
+
Displays validation errors as a list associated with a form control.
|
|
68
95
|
|
|
69
|
-
|
|
96
|
+
```tsx
|
|
97
|
+
<FormErrorMessage id="email-error" forId="email" errors={["Please enter a valid email"]} />
|
|
70
98
|
```
|
|
71
99
|
|
|
100
|
+
**FormErrorMessageProps**
|
|
101
|
+
|
|
102
|
+
| Prop | Type | Description |
|
|
103
|
+
|------|------|-------------|
|
|
104
|
+
| `id` | `string` | HTML `id` for the error message element. |
|
|
105
|
+
| `forId` | `string` | `id` of the form control this error message describes. |
|
|
106
|
+
| `errors` | `Array<string>` | List of error strings to display. |
|
|
107
|
+
|
|
72
108
|
### FormTextarea
|
|
73
109
|
|
|
74
110
|
Textarea wrapped in a FormField with label and error handling. Combines FormField + Textarea from @k8slens/lds.
|
|
75
111
|
|
|
76
112
|
```tsx
|
|
77
|
-
import { FormTextarea } from "@k8slens/lds-form";
|
|
78
|
-
|
|
79
113
|
<FormTextarea
|
|
80
114
|
name="description"
|
|
81
115
|
label="Description"
|
|
@@ -86,16 +120,33 @@ import { FormTextarea } from "@k8slens/lds-form";
|
|
|
86
120
|
/>
|
|
87
121
|
```
|
|
88
122
|
|
|
89
|
-
**
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
123
|
+
**Props:** Extends `TextareaProps` from @k8slens/lds + `FormFieldComponentProps`. Adds `name` (required) for form submission. Accepts all Textarea props (`maxLength`, `autoResize`, `icon`, `placeholder`, etc.).
|
|
124
|
+
|
|
125
|
+
### FormSwitchGroup
|
|
126
|
+
|
|
127
|
+
Multiple toggle switches with shared label and error handling.
|
|
128
|
+
|
|
129
|
+
```tsx
|
|
130
|
+
<FormSwitchGroup label="Notifications" values={options} onChange={setOptions} />
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**SwitchValue** — describes a single switch item:
|
|
134
|
+
|
|
135
|
+
| Field | Type | Description |
|
|
136
|
+
|-------|------|-------------|
|
|
137
|
+
| `id` | `string` | Unique identifier for this switch. |
|
|
138
|
+
| `label` | `string` | Label displayed next to the switch. |
|
|
139
|
+
| `checked` | `boolean \| undefined` | Whether the switch is on. |
|
|
140
|
+
| `disabled` | `boolean` | Whether this individual switch is disabled. |
|
|
141
|
+
| `description` | `string \| ReactNode` | Optional description rendered below the label. |
|
|
142
|
+
|
|
143
|
+
**FormSwitchGroupProps** — extends `FormFieldComponentProps`:
|
|
144
|
+
|
|
145
|
+
| Prop | Type | Description |
|
|
146
|
+
|------|------|-------------|
|
|
147
|
+
| `values` | `Array<SwitchValue>` | Array of switch items to render. |
|
|
148
|
+
| `onChange` | `(values: Array<SwitchValue>, updatedKeys: Array<string>) => void` | Called when any switch changes with the full array and the IDs that changed. |
|
|
149
|
+
| `wrapperProps` | `React.HTMLAttributes<HTMLDivElement>` | Props forwarded to the wrapper div. |
|
|
99
150
|
|
|
100
151
|
## Hooks
|
|
101
152
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k8slens/lds-form",
|
|
3
|
-
"version": "0.53.
|
|
3
|
+
"version": "0.53.3",
|
|
4
4
|
"description": "Lens Design System – React Form components",
|
|
5
5
|
"author": "Mirantis Inc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"format": "oxlint --fix . && prettier --write ."
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@k8slens/lds": "^0.58.
|
|
32
|
+
"@k8slens/lds": "^0.58.3"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"@k8slens/lds-tokens": "^0.59.
|
|
35
|
+
"@k8slens/lds-tokens": "^0.59.3",
|
|
36
36
|
"@rollup/plugin-node-resolve": "15.0.2",
|
|
37
37
|
"@storybook/react": "6.5.16",
|
|
38
38
|
"@testing-library/react": "14.0.0",
|
|
@@ -56,5 +56,5 @@
|
|
|
56
56
|
"\\.svg": "<rootDir>/../../__mocks__/SVGStub.js"
|
|
57
57
|
}
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "9897b4ea31cc01ec39bdd3200b0bacbdd760e351"
|
|
60
60
|
}
|