@k8slens/lds-form 0.52.0 → 0.53.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/README.md CHANGED
@@ -1,29 +1,88 @@
1
- # Lens Design System – React Form components
1
+ # @k8slens/lds-form
2
2
 
3
- ## Documentation
4
- Browse the documentation at [lens-design-system.k8slens.dev](https://lens-design-system.k8slens.dev/?path=/docs/form).
3
+ Form components for the Lens Design System – structured form fields with built-in validation.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @k8slens/lds-form @k8slens/lds @k8slens/lds-tokens
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ ```tsx
14
+ import "@k8slens/lds-tokens/lib/electron/font-face.css";
15
+ import "@k8slens/lds/lib/es/index.css";
16
+ import "@k8slens/lds/lib/es/typography.css";
17
+ import "@k8slens/lds-form/lib/es/index.css";
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### FormInput (with built-in validation)
5
23
 
6
- ## What is included?
24
+ `FormInput` is a complete form field that includes label, input, and error message handling:
7
25
 
8
- ### ES Modules
9
- - `./lib/es/index.js` - Main ES module
10
- - `./lib/es/ComponentName/ComponentName.js` - Individual ES modules
26
+ ```tsx
27
+ import { FormInput } from "@k8slens/lds-form";
28
+
29
+ export const MyForm = () => {
30
+ const [email, setEmail] = useState("");
31
+
32
+ return (
33
+ <FormInput
34
+ name="email"
35
+ type="email"
36
+ label="Email Address"
37
+ value={email}
38
+ onChange={setEmail}
39
+ required
40
+ />
41
+ );
42
+ };
43
+ ```
11
44
 
12
- ### CommonJS modules
13
- - `./lib/cjs/index.js` - Main CommonJS module
14
- - `./lib/cjs/ComponentName/ComponentName.js` - Individual CommonJS modules
45
+ ### Building Custom Fields
15
46
 
16
- ## Usage with React apps
17
- - run `npm i -s @k8slens/lds @k8slens/lds-tokens`
18
- - import `@k8slens/lds-tokens/lib/web/font-imports.css` in your React app to include fonts
19
- - import `@k8slens/lds/index.css` in your React app to include core styles
20
- - import `@k8slens/lds-form/index.css` in your React app to include form styles
21
- - Use in a component:
47
+ For custom layouts, compose with individual components:
22
48
 
23
- ```jsx
24
- import { FormErrorComponent } from "@k8slens/lds-form";
49
+ ```tsx
50
+ import { FormField, FormLabel, FormInput, FormErrorMessage } from "@k8slens/lds-form";
25
51
 
26
- export const Component = () => (
27
- <FormErrorComponent label="My Button" />
52
+ export const CustomField = () => (
53
+ <FormField>
54
+ <FormLabel>Username</FormLabel>
55
+ <FormInput name="username" type="text" />
56
+ <FormErrorMessage>Username is required</FormErrorMessage>
57
+ </FormField>
28
58
  );
29
59
  ```
60
+
61
+ ### FormSwitchGroup
62
+
63
+ ```tsx
64
+ import { FormSwitchGroup } from "@k8slens/lds-form";
65
+
66
+ <FormSwitchGroup
67
+ options={[
68
+ { id: "email", label: "Email notifications" },
69
+ { id: "sms", label: "SMS notifications" },
70
+ ]}
71
+ value={selected}
72
+ onChange={setSelected}
73
+ />;
74
+ ```
75
+
76
+ ## Documentation
77
+
78
+ Browse components at [lens-design-system.k8slens.dev](https://lens-design-system.k8slens.dev/?path=/docs/form).
79
+
80
+ ## AI Assistance
81
+
82
+ This package includes an `llms.txt` file with API documentation optimized for LLMs. Add to your project's AI configuration (e.g., `AGENTS.md` or `CLAUDE.md`):
83
+
84
+ ```markdown
85
+ Read node_modules/@k8slens/lds-form/llms.txt for form components reference.
86
+
87
+ Always use LDS form components and tokens. Search llms.txt before creating custom form fields.
88
+ ```
@@ -20,9 +20,13 @@ export interface NumberFormInputProps<CustomError extends string> extends FormFi
20
20
  }
21
21
  export declare type FormInputProps<CustomError extends string> = NumberFormInputProps<CustomError> | TextFormInputProps<CustomError>;
22
22
  /**
23
- * Input wrapped in Form Field
23
+ * Input with label, validation, and error handling. Wraps core Input in FormField.
24
24
  *
25
- * Handles validation and errors with accessible label and error notifications.
25
+ * Usage: `import { FormInput } from "@k8slens/lds-form"`
26
+ *
27
+ * ```tsx
28
+ * <FormInput name="email" type="email" label="Email" value={email} onChange={setEmail} />
29
+ * ```
26
30
  */
27
31
  declare function FormInput<CustomError extends string>({ id: _id, label, wrapperProps, labelProps, validate, errorParser, errorProps: errorComponentProps, value, onChange, type, ...inputProps }: PropsWithChildren<NumberFormInputProps<CustomError> | TextFormInputProps<CustomError>>): React.JSX.Element;
28
32
  export default FormInput;
@@ -16,9 +16,13 @@ export interface FormSwitchGroupProps<CustomError extends string> extends Omit<F
16
16
  errors?: Array<string>;
17
17
  }
18
18
  /**
19
- * Group of switches wrapped in a Form Field
19
+ * Multiple toggle switches with shared label and error handling.
20
20
  *
21
- * Displays errors with accessible label and error notifications.
21
+ * Usage: `import { FormSwitchGroup } from "@k8slens/lds-form"`
22
+ *
23
+ * ```tsx
24
+ * <FormSwitchGroup label="Notifications" values={options} onChange={setOptions} />
25
+ * ```
22
26
  */
23
27
  declare function FormSwitchGroup<CustomError extends string>({ id: _id, label, wrapperProps, labelProps, validate, errorProps: errorComponentProps, values, onChange, type, errors, disabled: allDisabled, ...switchProps }: PropsWithChildren<FormSwitchGroupProps<CustomError>>): React.JSX.Element;
24
28
  export default FormSwitchGroup;
@@ -20,9 +20,13 @@ export interface NumberFormInputProps<CustomError extends string> extends FormFi
20
20
  }
21
21
  export declare type FormInputProps<CustomError extends string> = NumberFormInputProps<CustomError> | TextFormInputProps<CustomError>;
22
22
  /**
23
- * Input wrapped in Form Field
23
+ * Input with label, validation, and error handling. Wraps core Input in FormField.
24
24
  *
25
- * Handles validation and errors with accessible label and error notifications.
25
+ * Usage: `import { FormInput } from "@k8slens/lds-form"`
26
+ *
27
+ * ```tsx
28
+ * <FormInput name="email" type="email" label="Email" value={email} onChange={setEmail} />
29
+ * ```
26
30
  */
27
31
  declare function FormInput<CustomError extends string>({ id: _id, label, wrapperProps, labelProps, validate, errorParser, errorProps: errorComponentProps, value, onChange, type, ...inputProps }: PropsWithChildren<NumberFormInputProps<CustomError> | TextFormInputProps<CustomError>>): React.JSX.Element;
28
32
  export default FormInput;
@@ -16,9 +16,13 @@ export interface FormSwitchGroupProps<CustomError extends string> extends Omit<F
16
16
  errors?: Array<string>;
17
17
  }
18
18
  /**
19
- * Group of switches wrapped in a Form Field
19
+ * Multiple toggle switches with shared label and error handling.
20
20
  *
21
- * Displays errors with accessible label and error notifications.
21
+ * Usage: `import { FormSwitchGroup } from "@k8slens/lds-form"`
22
+ *
23
+ * ```tsx
24
+ * <FormSwitchGroup label="Notifications" values={options} onChange={setOptions} />
25
+ * ```
22
26
  */
23
27
  declare function FormSwitchGroup<CustomError extends string>({ id: _id, label, wrapperProps, labelProps, validate, errorProps: errorComponentProps, values, onChange, type, errors, disabled: allDisabled, ...switchProps }: PropsWithChildren<FormSwitchGroupProps<CustomError>>): React.JSX.Element;
24
28
  export default FormSwitchGroup;
package/llms.txt ADDED
@@ -0,0 +1,98 @@
1
+ # @k8slens/lds-form
2
+
3
+ > Form components for the Lens Design System - structured form fields with validation support.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @k8slens/lds-form @k8slens/lds @k8slens/lds-tokens
9
+ ```
10
+
11
+ ### Peer Dependencies
12
+
13
+ ```bash
14
+ npm install react react-dom clsx lodash
15
+ ```
16
+
17
+ ## Setup
18
+
19
+ Import required styles in your app entry point:
20
+
21
+ ```tsx
22
+ import "@k8slens/lds-tokens/lib/electron/font-face.css";
23
+ import "@k8slens/lds/lib/es/index.css";
24
+ import "@k8slens/lds/lib/es/typography.css";
25
+ import "@k8slens/lds-form/lib/es/index.css";
26
+ ```
27
+
28
+ ## Components
29
+
30
+ ### FormField
31
+
32
+ Wrapper component that groups label, input, and error message.
33
+
34
+ ```tsx
35
+ import { FormField, FormLabel, FormInput, FormErrorMessage } from "@k8slens/lds-form";
36
+
37
+ <FormField>
38
+ <FormLabel>Email</FormLabel>
39
+ <FormInput type="email" />
40
+ <FormErrorMessage>Please enter a valid email</FormErrorMessage>
41
+ </FormField>
42
+ ```
43
+
44
+ ### FormInput
45
+
46
+ Input with label, validation, and error handling. Wraps core Input in FormField.
47
+
48
+ ```tsx
49
+ import { FormInput } from "@k8slens/lds-form";
50
+
51
+ <FormInput name="email" type="email" label="Email" value={email} onChange={setEmail} />
52
+ ```
53
+
54
+ ### FormLabel
55
+
56
+ Label component for form fields.
57
+
58
+ ### FormErrorMessage
59
+
60
+ Displays validation error messages.
61
+
62
+ ### FormSwitchGroup
63
+
64
+ Multiple toggle switches with shared label and error handling.
65
+
66
+ ```tsx
67
+ import { FormSwitchGroup } from "@k8slens/lds-form";
68
+
69
+ <FormSwitchGroup label="Notifications" values={options} onChange={setOptions} />
70
+ ```
71
+
72
+ ## Hooks
73
+
74
+ Available via `common` export:
75
+
76
+ ```tsx
77
+ import { common } from "@k8slens/lds-form";
78
+
79
+ const { useFieldIds, useInputErrorProps, useFormComponentData, usePrevious, defaultErrorParser } = common;
80
+ ```
81
+
82
+ - `useFieldIds` - Generate consistent IDs for form fields
83
+ - `useInputErrorProps` - Handle error state props
84
+ - `useFormComponentData` - Form state management
85
+ - `usePrevious` - Track previous values
86
+ - `defaultErrorParser` - Parse validation errors
87
+
88
+ ## Dependencies
89
+
90
+ This package depends on `@k8slens/lds` core components.
91
+
92
+ ## Documentation
93
+
94
+ - [Lens Design System](https://lens-design-system.k8slens.dev/)
95
+
96
+ ## Optional
97
+
98
+ - [npm Package](https://www.npmjs.com/package/@k8slens/lds-form)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@k8slens/lds-form",
3
- "version": "0.52.0",
3
+ "version": "0.53.0",
4
4
  "description": "Lens Design System – React Form components",
5
5
  "author": "Mirantis Inc",
6
6
  "license": "MIT",
@@ -15,7 +15,8 @@
15
15
  "types": "./lib/es/index.d.ts",
16
16
  "type": "module",
17
17
  "files": [
18
- "lib/"
18
+ "lib/",
19
+ "llms.txt"
19
20
  ],
20
21
  "scripts": {
21
22
  "start": "npm run rollup-watch",
@@ -24,14 +25,14 @@
24
25
  "rollup": "rollup -c",
25
26
  "clean": "rimraf lib",
26
27
  "test": "jest",
27
- "lint": "eslint .",
28
- "format": "eslint --fix ."
28
+ "lint": "oxlint .",
29
+ "format": "oxlint --fix . && prettier --write ."
29
30
  },
30
31
  "dependencies": {
31
- "@k8slens/lds": "^0.57.0"
32
+ "@k8slens/lds": "^0.58.0"
32
33
  },
33
34
  "devDependencies": {
34
- "@k8slens/lds-tokens": "^0.58.0",
35
+ "@k8slens/lds-tokens": "^0.59.0",
35
36
  "@rollup/plugin-node-resolve": "15.0.2",
36
37
  "@storybook/react": "6.5.16",
37
38
  "@testing-library/react": "14.0.0",
@@ -55,5 +56,5 @@
55
56
  "\\.svg": "<rootDir>/../../__mocks__/SVGStub.js"
56
57
  }
57
58
  },
58
- "gitHead": "dc375594fe63bf08745b6cfa09c4dc8437a4dc03"
59
+ "gitHead": "e41693e45edd36a94e34ab286d4ededba24f5daf"
59
60
  }