@k8slens/lds 0.2.8 → 0.2.12
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/web/{lds-v0-2-8 → lds-v0-2-12}/index.css +0 -0
- package/lib/web/{lds-v0-2-8 → lds-v0-2-12}/index.js +0 -0
- package/package.json +2 -2
- package/lib/.temp/packages/core/src/components.d.ts +0 -7
- package/lib/.temp/packages/core/src/index.d.ts +0 -2
- package/lib/.temp/packages/core/src/index.electron.d.ts +0 -2
- package/lib/.temp/packages/form/src/FormErrorMessage/FormErrorMessage.d.ts +0 -11
- package/lib/.temp/packages/form/src/FormField/FormField.d.ts +0 -23
- package/lib/.temp/packages/form/src/FormInput/FormInput.d.ts +0 -27
- package/lib/.temp/packages/form/src/FormInput/stories-common.d.ts +0 -6
- package/lib/.temp/packages/form/src/FormLabel/FormLabel.d.ts +0 -12
- package/lib/.temp/packages/form/src/common/helpers.d.ts +0 -3
- package/lib/.temp/packages/form/src/common/useFieldIds.d.ts +0 -13
- package/lib/.temp/packages/form/src/common/useFormComponentData.d.ts +0 -27
- package/lib/.temp/packages/form/src/common/useInputErrorProps.d.ts +0 -17
- package/lib/.temp/packages/form/src/common/usePrevious.d.ts +0 -1
- package/lib/.temp/packages/form/src/common/validation.d.ts +0 -31
- package/lib/.temp/packages/form/src/components.d.ts +0 -4
- package/lib/.temp/packages/form/src/index.d.ts +0 -2
|
File without changes
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k8slens/lds",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Lens Design System – Core React Component Library",
|
|
5
5
|
"author": "Mirantis Inc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"dependencies": {},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@k8slens/eslint-config": ">=0.1.0 <1.0.0",
|
|
29
|
-
"@k8slens/lds-tokens": ">=0.
|
|
29
|
+
"@k8slens/lds-tokens": ">=0.3.0 <1.0.0",
|
|
30
30
|
"@rollup/plugin-node-resolve": "14.0.1",
|
|
31
31
|
"@storybook/react": "6.5.13",
|
|
32
32
|
"@svgr/rollup": "6.3.1",
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export { default as Button } from "./Button/Button";
|
|
2
|
-
export { default as ButtonBar } from "./ButtonBar/ButtonBar";
|
|
3
|
-
export { default as Input } from "./Input/Input";
|
|
4
|
-
export { default as LoadingIndicator } from "./LoadingIndicator/LoadingIndicator";
|
|
5
|
-
export { default as Modal } from "./Modal/Modal";
|
|
6
|
-
export { default as Panel } from "./Panel/Panel";
|
|
7
|
-
export { Switch } from "./Switch/Switch";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface FormErrorMessageProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "id" | "htmlFor"> {
|
|
3
|
-
id: string;
|
|
4
|
-
forId: string;
|
|
5
|
-
errors: Array<string>;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Form error message
|
|
9
|
-
*/
|
|
10
|
-
declare const FormErrorMessage: ({ id, forId, errors, ...props }: FormErrorMessageProps) => JSX.Element;
|
|
11
|
-
export default FormErrorMessage;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { FormLabelProps } from "../FormLabel/FormLabel";
|
|
3
|
-
import { FormErrorMessageProps } from "../FormErrorMessage/FormErrorMessage";
|
|
4
|
-
export interface FormFieldProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "id"> {
|
|
5
|
-
/** the `id` of the child form component (e.g. `input`) */
|
|
6
|
-
id: string | undefined;
|
|
7
|
-
/** the label text to be rendered in `<label>{label}</label>` */
|
|
8
|
-
label: string;
|
|
9
|
-
/** the identifier of the `<ErrorMessage id={labelId} />` of the child form component, should not be the same as `props.id` */
|
|
10
|
-
errorId: string;
|
|
11
|
-
/** the identifier of the `<label id={labelId} />` of the child form component, should not be the same as `props.id` */
|
|
12
|
-
labelId: string;
|
|
13
|
-
required?: boolean;
|
|
14
|
-
errors?: Array<string>;
|
|
15
|
-
labelProps?: Partial<FormLabelProps>;
|
|
16
|
-
errorProps?: Partial<Omit<FormErrorMessageProps, "forId" | "id">>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Generic form field component with label and error message.
|
|
20
|
-
*
|
|
21
|
-
* See `FormComponent`for individual form components.
|
|
22
|
-
*/
|
|
23
|
-
export default function FormField({ id, label, labelId, errorId, required, errors, children, labelProps, errorProps, ...props }: PropsWithChildren<FormFieldProps>): JSX.Element;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import React, { PropsWithChildren } from "react";
|
|
2
|
-
import { type InputProps } from "@k8slens/lds/lib/es/Input/Input.d";
|
|
3
|
-
import { type FormFieldComponentProps } from "../common/FormComponent.d";
|
|
4
|
-
export declare const defaultErrorParser: import("../common/useFormComponentData").ErrorParser<unknown, string>;
|
|
5
|
-
declare type CustomInputProps = Omit<InputProps, "onChange" | "value" | "type" | "name"> & {
|
|
6
|
-
name: string;
|
|
7
|
-
};
|
|
8
|
-
interface Props extends CustomInputProps {
|
|
9
|
-
id?: string;
|
|
10
|
-
wrapperProps?: React.HTMLAttributes<HTMLDivElement>;
|
|
11
|
-
}
|
|
12
|
-
export interface TextFormInputProps<CustomError extends string> extends FormFieldComponentProps<string, CustomError>, Props {
|
|
13
|
-
type?: "search" | "time" | "text" | "color" | "password" | "email" | "tel" | "url" | "date" | "datetime-local";
|
|
14
|
-
value: string;
|
|
15
|
-
}
|
|
16
|
-
export interface NumberFormInputProps<CustomError extends string> extends FormFieldComponentProps<number, CustomError>, Props {
|
|
17
|
-
type: "number";
|
|
18
|
-
value: number;
|
|
19
|
-
}
|
|
20
|
-
export declare type FormInputProps<CustomError extends string> = NumberFormInputProps<CustomError> | TextFormInputProps<CustomError>;
|
|
21
|
-
/**
|
|
22
|
-
* Input wrapped in Form Field
|
|
23
|
-
*
|
|
24
|
-
* Handles validation and errors with accessible label and error notifications.
|
|
25
|
-
*/
|
|
26
|
-
declare function FormInput<CustomError extends string>({ id: _id, label, wrapperProps, labelProps, validate, errorParser, errorProps: errorComponentProps, value, onChange, type, ...inputProps }: PropsWithChildren<NumberFormInputProps<CustomError> | TextFormInputProps<CustomError>>): JSX.Element;
|
|
27
|
-
export default FormInput;
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { TextFormInputProps, NumberFormInputProps } from "./FormInput";
|
|
2
|
-
export declare const inputTestId = "form-input";
|
|
3
|
-
export declare const labelTestId = "form-input-label";
|
|
4
|
-
export declare const errorTestId = "form-input-error";
|
|
5
|
-
export declare const StringInputTemplate: <CustomError extends string>({ label, name, id, ...props }: TextFormInputProps<CustomError>) => JSX.Element;
|
|
6
|
-
export declare const NumberInputTemplate: <CustomError extends string>({ label, name, id, value: initialValue, ...props }: NumberFormInputProps<CustomError>) => JSX.Element;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
export interface FormLabelProps extends Omit<React.LabelHTMLAttributes<HTMLLabelElement>, "id" | "htmlFor"> {
|
|
3
|
-
id: string;
|
|
4
|
-
forId: string;
|
|
5
|
-
label: string;
|
|
6
|
-
required?: boolean;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Form label
|
|
10
|
-
*/
|
|
11
|
-
declare const FormLabel: ({ id, forId, label, required, ...props }: FormLabelProps) => JSX.Element;
|
|
12
|
-
export default FormLabel;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { CustomValidityState } from "./validation";
|
|
2
|
-
export declare const setNativeValue: (element: Pick<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement, "value">, value: any) => void;
|
|
3
|
-
export declare const getInputValidity: <CustomError extends string>(input: Pick<HTMLObjectElement, "validity">) => CustomValidityState<CustomError>;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
declare type FieldIds = {
|
|
2
|
-
id: string;
|
|
3
|
-
labelId: string;
|
|
4
|
-
errorId: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Create IDs for form field label and error message. Generate ID for form field component if not provided.
|
|
8
|
-
*
|
|
9
|
-
* @param _id ID for form field component
|
|
10
|
-
* @returns Form Field IDs
|
|
11
|
-
*/
|
|
12
|
-
export declare const useFieldIds: (_id?: string) => FieldIds;
|
|
13
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CustomValidityState, PartialValidityState, ValidationConstraints } from "./validation";
|
|
2
|
-
export interface FormFieldData<T, CustomError extends string> {
|
|
3
|
-
value: T;
|
|
4
|
-
validity?: CustomValidityState<CustomError>;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Error parser
|
|
8
|
-
*
|
|
9
|
-
* Returns error message for a given error key or `undefined | ""` in case no error should be shown.
|
|
10
|
-
*/
|
|
11
|
-
export declare type ErrorParser<T, CustomError extends string> = (value: T, error: keyof PartialValidityState | CustomError | "unknown", constraints: ValidationConstraints, label: string) => string | undefined | "";
|
|
12
|
-
/**
|
|
13
|
-
* Error parser
|
|
14
|
-
*
|
|
15
|
-
* Returns error message for a given error key for known errors or "Value is invalid" if key is unkown.
|
|
16
|
-
*/
|
|
17
|
-
export declare const defaultErrorParser: ErrorParser<unknown, string>;
|
|
18
|
-
export declare const useFormComponentData: <T, CustomError extends string>({ value, errorParser, constraints, label }: {
|
|
19
|
-
value: T;
|
|
20
|
-
errorParser: ErrorParser<T, CustomError>;
|
|
21
|
-
constraints: ValidationConstraints;
|
|
22
|
-
label: string;
|
|
23
|
-
}) => {
|
|
24
|
-
currentValue: FormFieldData<T, CustomError>;
|
|
25
|
-
setCurrentValue: import("react").Dispatch<import("react").SetStateAction<FormFieldData<T, CustomError>>>;
|
|
26
|
-
errors: string[];
|
|
27
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
declare type Props = {
|
|
2
|
-
id: string;
|
|
3
|
-
errors?: Array<string>;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* Get accessible input props in case of validation errors
|
|
7
|
-
*/
|
|
8
|
-
export declare const useInputErrorProps: ({ id, errors }: Props) => {
|
|
9
|
-
"aria-invalid": boolean;
|
|
10
|
-
"aria-errormessage": string;
|
|
11
|
-
"aria-describedby": string;
|
|
12
|
-
} | {
|
|
13
|
-
"aria-invalid"?: undefined;
|
|
14
|
-
"aria-errormessage"?: undefined;
|
|
15
|
-
"aria-describedby"?: undefined;
|
|
16
|
-
};
|
|
17
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function usePrevious<T>(value: T): T | undefined;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { AllHTMLAttributes } from "react";
|
|
2
|
-
export declare type ValidationConstraints = Partial<Pick<AllHTMLAttributes<any>, "pattern" | "minLength" | "maxLength" | "min" | "max" | "required" | "step">>;
|
|
3
|
-
/**
|
|
4
|
-
* ValidityStates with optional keys
|
|
5
|
-
*/
|
|
6
|
-
declare type PartialRecord<K extends keyof any, T> = {
|
|
7
|
-
[P in K]?: T;
|
|
8
|
-
};
|
|
9
|
-
export declare type PartialWritableValidityState = {
|
|
10
|
-
-readonly [K in keyof ValidityState]?: ValidityState[K];
|
|
11
|
-
};
|
|
12
|
-
export declare type PartialValidityState = {
|
|
13
|
-
readonly [K in keyof ValidityState]?: ValidityState[K];
|
|
14
|
-
};
|
|
15
|
-
export declare type CustomValidityState<CustomError extends string> = PartialRecord<CustomError | keyof PartialWritableValidityState | "unknown", boolean>;
|
|
16
|
-
export declare const validityKeys: Array<keyof ValidityState>;
|
|
17
|
-
/**
|
|
18
|
-
* Validator function.
|
|
19
|
-
*
|
|
20
|
-
* If value is valid returns `undefined`. Else returns a key or array of keys to be used in error parser.
|
|
21
|
-
*/
|
|
22
|
-
export declare type Validator<T, CustomError extends string> = (
|
|
23
|
-
/** Current value */
|
|
24
|
-
value: T,
|
|
25
|
-
/** Current validity state */
|
|
26
|
-
validity: PartialValidityState | undefined,
|
|
27
|
-
/** Name of the form element */
|
|
28
|
-
name: string,
|
|
29
|
-
/** HTML element validity constrain properties (eg. `required`, `minLength`) */
|
|
30
|
-
constraints: ValidationConstraints) => keyof PartialValidityState | CustomError | Array<keyof PartialValidityState | CustomError> | undefined;
|
|
31
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export { default as FormField } from "./FormField/FormField";
|
|
2
|
-
export { default as FormErrorMessage } from "./FormErrorMessage/FormErrorMessage";
|
|
3
|
-
export { default as FormLabel } from "./FormLabel/FormLabel";
|
|
4
|
-
export { default as FormInput } from "./FormInput/FormInput";
|