@koobiq/react-components 0.0.1-beta.30 → 0.0.1-beta.32
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/components/FieldComponents/FieldAddon/FieldAddon.d.ts +1 -1
- package/dist/components/FieldComponents/FieldAddon/FieldAddon.js +7 -2
- package/dist/components/FieldComponents/FieldAddon/FieldAddon.module.css.js +3 -3
- package/dist/components/FieldComponents/FieldControl/FieldControl.d.ts +2 -1
- package/dist/components/FieldComponents/FieldError/FieldError.d.ts +1 -1
- package/dist/components/FieldComponents/FieldError/FieldError.js +1 -1
- package/dist/components/FieldComponents/FieldInput/FieldInput.d.ts +2 -2
- package/dist/components/FieldComponents/FieldInput/FieldInput.js +4 -4
- package/dist/components/FieldComponents/FieldInput/FieldInput.module.css.js +3 -3
- package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroup.d.ts +2 -2
- package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroup.js +29 -5
- package/dist/components/FieldComponents/FieldInputGroup/FieldInputGroupContext.d.ts +3 -3
- package/dist/components/FieldComponents/FieldLabel/FieldLabel.d.ts +2 -2
- package/dist/components/FieldComponents/FieldLabel/FieldLabel.js +3 -3
- package/dist/components/FieldComponents/FieldSelect/FieldSelect.d.ts +5 -4
- package/dist/components/FieldComponents/FieldSelect/FieldSelect.js +5 -5
- package/dist/components/FieldComponents/FieldSelect/FieldSelect.module.css.js +4 -4
- package/dist/components/Input/Input.d.ts +32 -12
- package/dist/components/Input/Input.js +58 -13
- package/dist/components/Input/types.d.ts +68 -11
- package/dist/components/InputNumber/InputNumber.d.ts +27 -11
- package/dist/components/InputNumber/InputNumber.js +75 -25
- package/dist/components/InputNumber/components/InputNumberCounterControls.js +2 -2
- package/dist/components/InputNumber/types.d.ts +54 -9
- package/dist/components/Provider/Provider.d.ts +1 -1
- package/dist/components/Provider/Provider.js +8 -4
- package/dist/components/Provider/types.d.ts +3 -1
- package/dist/components/Select/Select.js +87 -64
- package/dist/components/Select/types.d.ts +50 -8
- package/dist/components/Textarea/Textarea.d.ts +16 -8
- package/dist/components/Textarea/Textarea.js +46 -2
- package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.d.ts +4 -4
- package/dist/components/Textarea/components/TextareaContextConsumer/TextareaContextConsumer.js +15 -12
- package/dist/components/Textarea/types.d.ts +59 -9
- package/dist/components/Textarea/utils/useTextareaAutosize.d.ts +1 -1
- package/dist/components/Textarea/utils/useTextareaAutosize.js +2 -2
- package/dist/style.css +6 -4
- package/package.json +5 -5
|
@@ -3,7 +3,7 @@ import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
|
|
|
3
3
|
export declare const fieldAddonPropPlacement: readonly ["start", "end"];
|
|
4
4
|
export type FieldAddonPlacement = (typeof fieldAddonPropPlacement)[number];
|
|
5
5
|
export type FieldAddonProps = ExtendableComponentPropsWithRef<{
|
|
6
|
-
|
|
6
|
+
isInvalid?: boolean;
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
placement?: FieldAddonPlacement;
|
|
9
9
|
}, 'div'>;
|
|
@@ -3,10 +3,15 @@ import { forwardRef } from "react";
|
|
|
3
3
|
import { isNotNil, clsx } from "@koobiq/react-core";
|
|
4
4
|
import s from "./FieldAddon.module.css.js";
|
|
5
5
|
const FieldAddon = forwardRef(
|
|
6
|
-
({ placement = "start",
|
|
6
|
+
({ placement = "start", isInvalid = false, className, children, ...other }, ref) => isNotNil(children) ? /* @__PURE__ */ jsx(
|
|
7
7
|
"div",
|
|
8
8
|
{
|
|
9
|
-
className: clsx(
|
|
9
|
+
className: clsx(
|
|
10
|
+
s.base,
|
|
11
|
+
s[placement],
|
|
12
|
+
isInvalid && s.invalid,
|
|
13
|
+
className
|
|
14
|
+
),
|
|
10
15
|
...other,
|
|
11
16
|
ref,
|
|
12
17
|
children
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
const base = "kbq-fieldaddon-3388d3";
|
|
2
2
|
const start = "kbq-fieldaddon-start-83aa84";
|
|
3
3
|
const end = "kbq-fieldaddon-end-f314bf";
|
|
4
|
-
const
|
|
4
|
+
const invalid = "kbq-fieldaddon-invalid-08b1fe";
|
|
5
5
|
const s = {
|
|
6
6
|
base,
|
|
7
7
|
start,
|
|
8
8
|
end,
|
|
9
|
-
|
|
9
|
+
invalid
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
12
|
base,
|
|
13
13
|
s as default,
|
|
14
14
|
end,
|
|
15
|
-
|
|
15
|
+
invalid,
|
|
16
16
|
start
|
|
17
17
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef, ElementType } from 'react';
|
|
2
|
+
import { type DataAttributeProps } from '@koobiq/react-core';
|
|
2
3
|
export type FieldControlBaseProps = {
|
|
3
4
|
fullWidth?: boolean;
|
|
4
5
|
className?: string;
|
|
5
|
-
};
|
|
6
|
+
} & DataAttributeProps;
|
|
6
7
|
export declare const FieldControl: import("@koobiq/react-core").PolyForwardComponent<"div", FieldControlBaseProps, ElementType>;
|
|
7
8
|
export type FieldControlProps<As extends ElementType = 'div'> = ComponentPropsWithRef<typeof FieldControl<As>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type TextProps, type TextRef } from '@koobiq/react-primitives';
|
|
2
2
|
export type FieldErrorProps = TextProps & {
|
|
3
|
-
|
|
3
|
+
isInvalid?: boolean;
|
|
4
4
|
};
|
|
5
5
|
export type FieldErrorRef = TextRef;
|
|
6
6
|
export declare const FieldError: import("react").ForwardRefExoticComponent<Omit<FieldErrorProps, "ref"> & import("react").RefAttributes<HTMLParagraphElement>>;
|
|
@@ -4,7 +4,7 @@ import { isNotNil, clsx } from "@koobiq/react-core";
|
|
|
4
4
|
import { Text } from "@koobiq/react-primitives";
|
|
5
5
|
import s from "./FieldError.module.css.js";
|
|
6
6
|
const FieldError = forwardRef(
|
|
7
|
-
({ children, className,
|
|
7
|
+
({ children, className, isInvalid = false, ...other }, ref) => isNotNil(children) && isInvalid ? /* @__PURE__ */ jsx(
|
|
8
8
|
Text,
|
|
9
9
|
{
|
|
10
10
|
className: clsx(s.base, className),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ComponentPropsWithRef } from 'react';
|
|
2
2
|
import type { InputPropVariant } from '../../Input';
|
|
3
3
|
export type FieldInputBaseProps = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
isInvalid?: boolean;
|
|
5
|
+
isDisabled?: boolean;
|
|
6
6
|
className?: string;
|
|
7
7
|
'data-testid'?: string;
|
|
8
8
|
as?: 'input' | 'textarea';
|
|
@@ -4,9 +4,9 @@ import { Input, Textarea } from "@koobiq/react-primitives";
|
|
|
4
4
|
import s from "./FieldInput.module.css.js";
|
|
5
5
|
const FieldInput = polymorphicForwardRef(
|
|
6
6
|
({
|
|
7
|
-
|
|
7
|
+
isInvalid = false,
|
|
8
8
|
as = "input",
|
|
9
|
-
|
|
9
|
+
isDisabled = false,
|
|
10
10
|
variant = "filled",
|
|
11
11
|
className,
|
|
12
12
|
...other
|
|
@@ -19,8 +19,8 @@ const FieldInput = polymorphicForwardRef(
|
|
|
19
19
|
className: clsx(
|
|
20
20
|
s.base,
|
|
21
21
|
s[variant],
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
isInvalid && s.invalid,
|
|
23
|
+
isDisabled && s.disabled,
|
|
24
24
|
className
|
|
25
25
|
),
|
|
26
26
|
ref
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
const base = "kbq-fieldinput-77b90b";
|
|
2
2
|
const transparent = "kbq-fieldinput-transparent-ed7263";
|
|
3
3
|
const filled = "kbq-fieldinput-filled-abb632";
|
|
4
|
-
const
|
|
4
|
+
const invalid = "kbq-fieldinput-invalid-2af82b";
|
|
5
5
|
const disabled = "kbq-fieldinput-disabled-59285a";
|
|
6
6
|
const s = {
|
|
7
7
|
base,
|
|
8
8
|
transparent,
|
|
9
9
|
filled,
|
|
10
|
-
|
|
10
|
+
invalid,
|
|
11
11
|
disabled
|
|
12
12
|
};
|
|
13
13
|
export {
|
|
14
14
|
base,
|
|
15
15
|
s as default,
|
|
16
16
|
disabled,
|
|
17
|
-
error,
|
|
18
17
|
filled,
|
|
18
|
+
invalid,
|
|
19
19
|
transparent
|
|
20
20
|
};
|
|
@@ -5,9 +5,9 @@ export type FieldInputGroupProps = ExtendableComponentPropsWithRef<{
|
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
startAddon?: ReactNode;
|
|
7
7
|
endAddon?: ReactNode;
|
|
8
|
-
|
|
8
|
+
isDisabled?: boolean;
|
|
9
9
|
className?: string;
|
|
10
|
-
|
|
10
|
+
isInvalid?: boolean;
|
|
11
11
|
/** The props used for each slot inside. */
|
|
12
12
|
slotProps?: {
|
|
13
13
|
start?: FieldAddonProps;
|
|
@@ -6,7 +6,15 @@ import s from "./FieldInputGroup.module.css.js";
|
|
|
6
6
|
import { FieldInputGroupContext } from "./FieldInputGroupContext.js";
|
|
7
7
|
import { FieldAddon } from "../FieldAddon/FieldAddon.js";
|
|
8
8
|
const FieldInputGroup = forwardRef(
|
|
9
|
-
({
|
|
9
|
+
({
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
startAddon,
|
|
13
|
+
endAddon,
|
|
14
|
+
isInvalid,
|
|
15
|
+
slotProps,
|
|
16
|
+
...other
|
|
17
|
+
}, ref) => {
|
|
10
18
|
const { value } = useInputContext();
|
|
11
19
|
const hasStartAddon = !!startAddon;
|
|
12
20
|
const hasEndAddon = !!endAddon;
|
|
@@ -22,14 +30,30 @@ const FieldInputGroup = forwardRef(
|
|
|
22
30
|
),
|
|
23
31
|
...other,
|
|
24
32
|
ref,
|
|
25
|
-
children: ({
|
|
33
|
+
children: ({ isHovered, isFocusWithin, isDisabled }) => /* @__PURE__ */ jsxs(
|
|
26
34
|
FieldInputGroupContext.Provider,
|
|
27
35
|
{
|
|
28
|
-
value: {
|
|
36
|
+
value: { isDisabled, isHovered, hasValue, isFocusWithin },
|
|
29
37
|
children: [
|
|
30
|
-
/* @__PURE__ */ jsx(
|
|
38
|
+
/* @__PURE__ */ jsx(
|
|
39
|
+
FieldAddon,
|
|
40
|
+
{
|
|
41
|
+
placement: "start",
|
|
42
|
+
isInvalid,
|
|
43
|
+
...slotProps?.start,
|
|
44
|
+
children: startAddon
|
|
45
|
+
}
|
|
46
|
+
),
|
|
31
47
|
children,
|
|
32
|
-
/* @__PURE__ */ jsx(
|
|
48
|
+
/* @__PURE__ */ jsx(
|
|
49
|
+
FieldAddon,
|
|
50
|
+
{
|
|
51
|
+
placement: "end",
|
|
52
|
+
isInvalid,
|
|
53
|
+
...slotProps?.end,
|
|
54
|
+
children: endAddon
|
|
55
|
+
}
|
|
56
|
+
)
|
|
33
57
|
]
|
|
34
58
|
}
|
|
35
59
|
)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export type FieldInputGroupContextProps = {
|
|
2
|
-
|
|
2
|
+
isDisabled?: boolean;
|
|
3
3
|
hasValue?: boolean;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
isHovered?: boolean;
|
|
5
|
+
isFocusWithin?: boolean;
|
|
6
6
|
};
|
|
7
7
|
export declare const FieldInputGroupContext: import("react").Context<FieldInputGroupContextProps>;
|
|
8
8
|
export declare const useFieldInputGroup: () => FieldInputGroupContextProps;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { ExtendableComponentPropsWithRef } from '@koobiq/react-core';
|
|
3
3
|
export type FieldLabelProps = ExtendableComponentPropsWithRef<{
|
|
4
|
-
|
|
4
|
+
isHidden?: boolean;
|
|
5
5
|
className?: string;
|
|
6
|
-
|
|
6
|
+
isRequired?: boolean;
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
}, 'label'>;
|
|
9
9
|
export declare const FieldLabel: import("react").ForwardRefExoticComponent<Omit<FieldLabelProps, "ref"> & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -4,16 +4,16 @@ import { isNotNil, clsx } from "@koobiq/react-core";
|
|
|
4
4
|
import { Label } from "@koobiq/react-primitives";
|
|
5
5
|
import s from "./FieldLabel.module.css.js";
|
|
6
6
|
const FieldLabel = forwardRef(
|
|
7
|
-
({ children, className,
|
|
7
|
+
({ children, className, isHidden = false, isRequired = false, ...other }, ref) => isNotNil(children) ? /* @__PURE__ */ jsxs(
|
|
8
8
|
Label,
|
|
9
9
|
{
|
|
10
|
-
className: clsx(s.base,
|
|
10
|
+
className: clsx(s.base, isHidden && s.hidden, className),
|
|
11
11
|
...other,
|
|
12
12
|
ref,
|
|
13
13
|
children: [
|
|
14
14
|
children,
|
|
15
15
|
" ",
|
|
16
|
-
|
|
16
|
+
isRequired && /* @__PURE__ */ jsx("sup", { className: s.sup, children: "*" })
|
|
17
17
|
]
|
|
18
18
|
}
|
|
19
19
|
) : null
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { type ReactNode } from 'react';
|
|
1
|
+
import { type ReactNode, type Ref } from 'react';
|
|
2
2
|
import type { InputPropVariant } from '../../Input';
|
|
3
3
|
export type FieldSelectProps = {
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
isInvalid?: boolean;
|
|
5
|
+
isDisabled?: boolean;
|
|
6
6
|
className?: string;
|
|
7
7
|
children?: ReactNode;
|
|
8
8
|
'data-testid'?: string;
|
|
9
9
|
variant?: InputPropVariant;
|
|
10
10
|
placeholder?: string | number;
|
|
11
|
+
ref?: Ref<HTMLButtonElement>;
|
|
11
12
|
};
|
|
12
|
-
export declare const FieldSelect: import("react").ForwardRefExoticComponent<FieldSelectProps & import("react").RefAttributes<HTMLButtonElement>>;
|
|
13
|
+
export declare const FieldSelect: import("react").ForwardRefExoticComponent<Omit<FieldSelectProps, "ref"> & import("react").RefAttributes<HTMLButtonElement>>;
|
|
@@ -5,8 +5,8 @@ import { Button } from "@koobiq/react-primitives";
|
|
|
5
5
|
import s from "./FieldSelect.module.css.js";
|
|
6
6
|
const FieldSelect = forwardRef(
|
|
7
7
|
({
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
isInvalid = false,
|
|
9
|
+
isDisabled = false,
|
|
10
10
|
variant = "filled",
|
|
11
11
|
placeholder,
|
|
12
12
|
children,
|
|
@@ -16,13 +16,13 @@ const FieldSelect = forwardRef(
|
|
|
16
16
|
Button,
|
|
17
17
|
{
|
|
18
18
|
...other,
|
|
19
|
-
|
|
19
|
+
isDisabled,
|
|
20
20
|
"data-slot": "select-value",
|
|
21
21
|
className: clsx(
|
|
22
22
|
s.base,
|
|
23
23
|
s[variant],
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
isInvalid && s.invalid,
|
|
25
|
+
isDisabled && s.disabled,
|
|
26
26
|
!isNotNil(children) && s.hasPlaceholder,
|
|
27
27
|
className
|
|
28
28
|
),
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const base = "kbq-fieldselect-0f0f5e";
|
|
2
2
|
const content = "kbq-fieldselect-content-c36142";
|
|
3
|
-
const
|
|
3
|
+
const invalid = "kbq-fieldselect-invalid-db8152";
|
|
4
4
|
const disabled = "kbq-fieldselect-disabled-f0efd4";
|
|
5
5
|
const hasPlaceholder = "kbq-fieldselect-hasPlaceholder-7b7518";
|
|
6
6
|
const s = {
|
|
7
7
|
base,
|
|
8
8
|
content,
|
|
9
|
-
|
|
9
|
+
invalid,
|
|
10
10
|
disabled,
|
|
11
11
|
hasPlaceholder
|
|
12
12
|
};
|
|
@@ -15,6 +15,6 @@ export {
|
|
|
15
15
|
content,
|
|
16
16
|
s as default,
|
|
17
17
|
disabled,
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
hasPlaceholder,
|
|
19
|
+
invalid
|
|
20
20
|
};
|
|
@@ -1,23 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
import { TextField } from '@koobiq/react-primitives';
|
|
2
|
+
import { type FieldLabelProps, type FieldInputGroupProps, type FieldCaptionProps, type FieldErrorProps, type FieldInputProps, type FieldControlProps } from '../FieldComponents';
|
|
3
|
+
export declare const Input: import("react").ForwardRefExoticComponent<Omit<Omit<import("@koobiq/react-primitives").TextFieldProps<HTMLInputElement>, "children" | "style" | "className" | "validationBehavior" | "validate" | "description" | "inputElementType">, "value" | "caption" | "label" | "style" | "className" | "defaultValue" | "onChange" | "placeholder" | "isDisabled" | "variant" | "slotProps" | "fullWidth" | "data-testid" | "isInvalid" | "isReadOnly" | "isRequired" | "errorMessage" | "startAddon" | "endAddon" | "isLabelHidden" | keyof {
|
|
4
|
+
disabled?: boolean;
|
|
5
|
+
error?: boolean;
|
|
6
|
+
required?: boolean;
|
|
7
|
+
readonly?: boolean;
|
|
8
|
+
hiddenLabel?: boolean;
|
|
9
|
+
}> & {
|
|
2
10
|
label?: import("react").ReactNode;
|
|
3
11
|
className?: string;
|
|
12
|
+
placeholder?: import("@koobiq/react-primitives").TextFieldProps["placeholder"];
|
|
13
|
+
value?: import("@koobiq/react-primitives").TextFieldProps["value"];
|
|
14
|
+
defaultValue?: import("@koobiq/react-primitives").TextFieldProps["defaultValue"];
|
|
15
|
+
onChange?: import("@koobiq/react-primitives").TextFieldProps["onChange"];
|
|
4
16
|
startAddon?: import("react").ReactNode;
|
|
5
17
|
endAddon?: import("react").ReactNode;
|
|
6
18
|
variant?: import("./types").InputPropVariant;
|
|
7
|
-
|
|
8
|
-
errorMessage?:
|
|
19
|
+
isInvalid?: boolean;
|
|
20
|
+
errorMessage?: import("react").ReactNode;
|
|
9
21
|
fullWidth?: boolean;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
22
|
+
isDisabled?: boolean;
|
|
23
|
+
isReadOnly?: boolean;
|
|
24
|
+
isLabelHidden?: boolean;
|
|
25
|
+
caption?: import("react").ReactNode;
|
|
26
|
+
isRequired?: boolean;
|
|
14
27
|
style?: import("react").CSSProperties;
|
|
15
28
|
'data-testid'?: string | number;
|
|
16
29
|
slotProps?: {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
caption?:
|
|
20
|
-
group?:
|
|
21
|
-
errorMessage?:
|
|
30
|
+
root?: FieldControlProps<typeof TextField<HTMLInputElement>>;
|
|
31
|
+
label?: FieldLabelProps;
|
|
32
|
+
caption?: FieldCaptionProps;
|
|
33
|
+
group?: FieldInputGroupProps;
|
|
34
|
+
errorMessage?: FieldErrorProps;
|
|
35
|
+
input?: FieldInputProps<"input">;
|
|
22
36
|
};
|
|
37
|
+
} & {
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
error?: boolean;
|
|
40
|
+
required?: boolean;
|
|
41
|
+
readonly?: boolean;
|
|
42
|
+
hiddenLabel?: boolean;
|
|
23
43
|
} & import("react").RefAttributes<HTMLInputElement>>;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
+
import { deprecate } from "@koobiq/logger";
|
|
4
5
|
import { useDOMRef, mergeProps } from "@koobiq/react-core";
|
|
5
6
|
import { TextField } from "@koobiq/react-primitives";
|
|
6
7
|
import { FieldControl } from "../FieldComponents/FieldControl/FieldControl.js";
|
|
@@ -13,7 +14,16 @@ const Input = forwardRef((props, ref) => {
|
|
|
13
14
|
const {
|
|
14
15
|
variant = "filled",
|
|
15
16
|
fullWidth = false,
|
|
16
|
-
hiddenLabel
|
|
17
|
+
hiddenLabel,
|
|
18
|
+
isLabelHidden: isLabelHiddenProp,
|
|
19
|
+
disabled,
|
|
20
|
+
isDisabled: isDisabledProp,
|
|
21
|
+
error,
|
|
22
|
+
isInvalid: isInvalidProp,
|
|
23
|
+
required,
|
|
24
|
+
isRequired: isRequiredProp,
|
|
25
|
+
readonly,
|
|
26
|
+
isReadOnly: isReadOnlyProp,
|
|
17
27
|
label,
|
|
18
28
|
startAddon,
|
|
19
29
|
endAddon,
|
|
@@ -22,46 +32,81 @@ const Input = forwardRef((props, ref) => {
|
|
|
22
32
|
caption,
|
|
23
33
|
...other
|
|
24
34
|
} = props;
|
|
35
|
+
const isDisabled = isDisabledProp ?? disabled ?? false;
|
|
36
|
+
const isRequired = isRequiredProp ?? required ?? false;
|
|
37
|
+
const isReadOnly = isReadOnlyProp ?? readonly ?? false;
|
|
38
|
+
const isInvalid = isInvalidProp ?? error ?? false;
|
|
39
|
+
const isLabelHidden = isLabelHiddenProp ?? hiddenLabel ?? false;
|
|
40
|
+
if (process.env.NODE_ENV !== "production" && "disabled" in props) {
|
|
41
|
+
deprecate(
|
|
42
|
+
'Input: the "disabled" prop is deprecated. Use "isDisabled" prop to replace it.'
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
if (process.env.NODE_ENV !== "production" && "required" in props) {
|
|
46
|
+
deprecate(
|
|
47
|
+
'Input: the "required" prop is deprecated. Use "isRequired" prop to replace it.'
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
if (process.env.NODE_ENV !== "production" && "error" in props) {
|
|
51
|
+
deprecate(
|
|
52
|
+
'Input: the "error" prop is deprecated. Use "isInvalid" prop to replace it.'
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (process.env.NODE_ENV !== "production" && "readonly" in props) {
|
|
56
|
+
deprecate(
|
|
57
|
+
'Input: the "readonly" prop is deprecated. Use "isReadOnly" prop to replace it.'
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
if (process.env.NODE_ENV !== "production" && "hiddenLabel" in props) {
|
|
61
|
+
deprecate(
|
|
62
|
+
'Input: the "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.'
|
|
63
|
+
);
|
|
64
|
+
}
|
|
25
65
|
const inputRef = useDOMRef(ref);
|
|
26
66
|
const rootProps = mergeProps(
|
|
27
67
|
{
|
|
28
68
|
label,
|
|
29
69
|
fullWidth,
|
|
70
|
+
isDisabled,
|
|
71
|
+
isRequired,
|
|
72
|
+
isReadOnly,
|
|
73
|
+
isInvalid,
|
|
30
74
|
errorMessage,
|
|
31
75
|
"data-variant": variant,
|
|
32
|
-
"data-fullwidth": fullWidth
|
|
76
|
+
"data-fullwidth": fullWidth,
|
|
77
|
+
...other
|
|
33
78
|
},
|
|
34
|
-
|
|
79
|
+
slotProps?.root
|
|
35
80
|
);
|
|
36
|
-
return /* @__PURE__ */ jsx(FieldControl, { as: TextField, ...rootProps, children: ({
|
|
81
|
+
return /* @__PURE__ */ jsx(FieldControl, { as: TextField, inputElementType: "input", ...rootProps, children: ({ isInvalid: isInvalid2, isRequired: isRequired2, isDisabled: isDisabled2 }) => {
|
|
37
82
|
const labelProps = mergeProps(
|
|
38
|
-
{
|
|
83
|
+
{ isHidden: isLabelHidden, isRequired: isRequired2, children: label },
|
|
39
84
|
slotProps?.label
|
|
40
85
|
);
|
|
41
86
|
const inputProps = mergeProps(
|
|
42
87
|
{
|
|
43
|
-
error,
|
|
44
88
|
variant,
|
|
45
|
-
|
|
89
|
+
isInvalid: isInvalid2,
|
|
90
|
+
isDisabled: isDisabled2,
|
|
46
91
|
ref: inputRef
|
|
47
92
|
},
|
|
48
93
|
slotProps?.input
|
|
49
94
|
);
|
|
50
95
|
const groupProps = mergeProps(
|
|
51
96
|
{
|
|
52
|
-
error,
|
|
53
97
|
endAddon,
|
|
98
|
+
isInvalid: isInvalid2,
|
|
54
99
|
startAddon
|
|
55
100
|
},
|
|
56
101
|
slotProps?.group
|
|
57
102
|
);
|
|
58
|
-
const captionProps = slotProps?.caption;
|
|
59
|
-
const errorProps = mergeProps({
|
|
103
|
+
const captionProps = mergeProps({ children: caption }, slotProps?.caption);
|
|
104
|
+
const errorProps = mergeProps({ isInvalid: isInvalid2, children: errorMessage }, slotProps?.errorMessage);
|
|
60
105
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
61
|
-
/* @__PURE__ */ jsx(FieldLabel, { ...labelProps
|
|
106
|
+
/* @__PURE__ */ jsx(FieldLabel, { ...labelProps }),
|
|
62
107
|
/* @__PURE__ */ jsx(FieldInputGroup, { ...groupProps, children: /* @__PURE__ */ jsx(FieldInput, { ...inputProps }) }),
|
|
63
|
-
/* @__PURE__ */ jsx(FieldCaption, { ...captionProps
|
|
64
|
-
/* @__PURE__ */ jsx(FieldError, { ...errorProps
|
|
108
|
+
/* @__PURE__ */ jsx(FieldCaption, { ...captionProps }),
|
|
109
|
+
/* @__PURE__ */ jsx(FieldError, { ...errorProps })
|
|
65
110
|
] });
|
|
66
111
|
} });
|
|
67
112
|
});
|
|
@@ -1,14 +1,64 @@
|
|
|
1
1
|
import type { ComponentRef, CSSProperties, ReactNode } from 'react';
|
|
2
2
|
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
|
-
import type {
|
|
4
|
-
import type { FieldCaptionProps, FieldErrorProps, FieldInputProps, FieldLabelProps, FieldInputGroupProps } from '../FieldComponents';
|
|
3
|
+
import type { TextField, TextFieldProps } from '@koobiq/react-primitives';
|
|
4
|
+
import type { FieldCaptionProps, FieldErrorProps, FieldInputProps, FieldLabelProps, FieldInputGroupProps, FieldControlProps } from '../FieldComponents';
|
|
5
5
|
export declare const inputPropVariant: readonly ["filled", "transparent"];
|
|
6
6
|
export type InputPropVariant = (typeof inputPropVariant)[number];
|
|
7
|
+
type InputDeprecatedProps = {
|
|
8
|
+
/**
|
|
9
|
+
* If `true`, the component is disabled.
|
|
10
|
+
* @default false
|
|
11
|
+
*
|
|
12
|
+
* @deprecated
|
|
13
|
+
* The "disabled" prop is deprecated. Use "isDisabled" prop to replace it.
|
|
14
|
+
*/
|
|
15
|
+
disabled?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* If `true`, the input will indicate an error.
|
|
18
|
+
* @default false
|
|
19
|
+
*
|
|
20
|
+
* @deprecated
|
|
21
|
+
* The "error" prop is deprecated. Use "isInvalid" prop to replace it.
|
|
22
|
+
*/
|
|
23
|
+
error?: boolean;
|
|
24
|
+
/**
|
|
25
|
+
* If `true`, the label is displayed as required and the input element is required.
|
|
26
|
+
* @default false
|
|
27
|
+
*
|
|
28
|
+
* @deprecated
|
|
29
|
+
* The "required" prop is deprecated. Use "isRequired" prop to replace it.
|
|
30
|
+
*/
|
|
31
|
+
required?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* If `true`, the input can be selected but not changed by the user.
|
|
34
|
+
* @default false
|
|
35
|
+
*
|
|
36
|
+
* @deprecated
|
|
37
|
+
* The "readonly" prop is deprecated. Use "isReadOnly" prop to replace it.
|
|
38
|
+
*/
|
|
39
|
+
readonly?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* If `true`, the label is hidden. Be sure to add aria-label to the input element.
|
|
42
|
+
* @default false
|
|
43
|
+
*
|
|
44
|
+
* @deprecated
|
|
45
|
+
* The "hiddenLabel" prop is deprecated. Use "isLabelHidden" prop to replace it.
|
|
46
|
+
*/
|
|
47
|
+
hiddenLabel?: boolean;
|
|
48
|
+
};
|
|
7
49
|
export type InputProps = ExtendableProps<{
|
|
8
50
|
/** The content to display as the label. */
|
|
9
51
|
label?: ReactNode;
|
|
10
52
|
/** Additional CSS-classes. */
|
|
11
53
|
className?: string;
|
|
54
|
+
/** Temporary text that occupies the text input when it is empty. */
|
|
55
|
+
placeholder?: TextFieldProps['placeholder'];
|
|
56
|
+
/** The current value (controlled). */
|
|
57
|
+
value?: TextFieldProps['value'];
|
|
58
|
+
/** The default value (uncontrolled). */
|
|
59
|
+
defaultValue?: TextFieldProps['defaultValue'];
|
|
60
|
+
/** Handler that is called when the value changes. */
|
|
61
|
+
onChange?: TextFieldProps['onChange'];
|
|
12
62
|
/** Addon placed before the children. */
|
|
13
63
|
startAddon?: ReactNode;
|
|
14
64
|
/** Addon placed after the children. */
|
|
@@ -22,9 +72,9 @@ export type InputProps = ExtendableProps<{
|
|
|
22
72
|
* If `true`, the input will indicate an error.
|
|
23
73
|
* @default false
|
|
24
74
|
*/
|
|
25
|
-
|
|
26
|
-
/** Message for the error state
|
|
27
|
-
errorMessage?:
|
|
75
|
+
isInvalid?: boolean;
|
|
76
|
+
/** Message for the error state */
|
|
77
|
+
errorMessage?: ReactNode;
|
|
28
78
|
/**
|
|
29
79
|
* If true, the input will take up the full width of its container.
|
|
30
80
|
* @default false
|
|
@@ -34,30 +84,37 @@ export type InputProps = ExtendableProps<{
|
|
|
34
84
|
* If `true`, the component is disabled.
|
|
35
85
|
* @default false
|
|
36
86
|
*/
|
|
37
|
-
|
|
87
|
+
isDisabled?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* If `true`, the input can be selected but not changed by the user.
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
isReadOnly?: boolean;
|
|
38
93
|
/**
|
|
39
94
|
* If `true`, the label is hidden. Be sure to add aria-label to the input element.
|
|
40
95
|
* @default false
|
|
41
96
|
*/
|
|
42
|
-
|
|
97
|
+
isLabelHidden?: boolean;
|
|
43
98
|
/** The helper text content. */
|
|
44
|
-
caption?:
|
|
99
|
+
caption?: ReactNode;
|
|
45
100
|
/**
|
|
46
101
|
* If `true`, the label is displayed as required and the input element is required.
|
|
47
102
|
* @default false
|
|
48
103
|
*/
|
|
49
|
-
|
|
104
|
+
isRequired?: boolean;
|
|
50
105
|
/** Inline styles. */
|
|
51
106
|
style?: CSSProperties;
|
|
52
107
|
/** Unique identifier for testing purposes. */
|
|
53
108
|
'data-testid'?: string | number;
|
|
54
109
|
/** The props used for each slot inside. */
|
|
55
110
|
slotProps?: {
|
|
111
|
+
root?: FieldControlProps<typeof TextField<HTMLInputElement>>;
|
|
56
112
|
label?: FieldLabelProps;
|
|
57
|
-
input?: FieldInputProps;
|
|
58
113
|
caption?: FieldCaptionProps;
|
|
59
114
|
group?: FieldInputGroupProps;
|
|
60
115
|
errorMessage?: FieldErrorProps;
|
|
116
|
+
input?: FieldInputProps<'input'>;
|
|
61
117
|
};
|
|
62
|
-
}, Omit<
|
|
118
|
+
} & InputDeprecatedProps, Omit<TextFieldProps<HTMLInputElement>, 'description' | 'validationBehavior' | 'validate' | 'children' | 'style' | 'className' | 'inputElementType'>>;
|
|
63
119
|
export type InputRef = ComponentRef<'input'>;
|
|
120
|
+
export {};
|