@koobiq/react-primitives 0.0.1-beta.3 → 0.0.1-beta.31
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/behaviors/index.d.ts +0 -2
- package/dist/behaviors/useButton.d.ts +6 -6
- package/dist/behaviors/useButton.js +10 -21
- package/dist/behaviors/useCheckbox.d.ts +10 -45
- package/dist/behaviors/useCheckbox.js +15 -38
- package/dist/behaviors/useLink.d.ts +5 -9
- package/dist/behaviors/useLink.js +8 -17
- package/dist/behaviors/useNumberField.d.ts +1 -22
- package/dist/behaviors/useNumberField.js +2 -13
- package/dist/behaviors/useToggle.d.ts +309 -37
- package/dist/behaviors/useToggle.js +12 -33
- package/dist/components/Button/Button.js +17 -13
- package/dist/components/Button/ButtonContext.js +1 -0
- package/dist/components/Button/types.d.ts +7 -7
- package/dist/components/Checkbox/Checkbox.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.js +36 -19
- package/dist/components/Checkbox/types.d.ts +8 -8
- package/dist/components/Group/Group.js +7 -7
- package/dist/components/Group/GroupContext.js +1 -0
- package/dist/components/Group/types.d.ts +8 -8
- package/dist/components/Input/InputContext.js +1 -0
- package/dist/components/Label/LabelContext.js +1 -0
- package/dist/components/Link/Link.js +30 -9
- package/dist/components/Link/types.d.ts +8 -6
- package/dist/components/NumberField/NumberField.d.ts +1 -1
- package/dist/components/NumberField/NumberField.js +9 -9
- package/dist/components/NumberField/types.d.ts +4 -4
- package/dist/components/Radio/Radio.d.ts +1 -1
- package/dist/components/Radio/Radio.js +1 -1
- package/dist/components/Radio/RadioContext.js +1 -0
- package/dist/components/Radio/RadioGroup.d.ts +1 -1
- package/dist/components/Text/TextContext.js +1 -0
- package/dist/components/TextField/TextField.d.ts +2 -1
- package/dist/components/TextField/TextField.js +58 -57
- package/dist/components/TextField/types.d.ts +11 -8
- package/dist/components/Textarea/Textarea.d.ts +2 -4
- package/dist/components/Textarea/Textarea.js +6 -2
- package/dist/components/Textarea/TextareaContext.js +1 -0
- package/dist/components/Textarea/types.d.ts +2 -1
- package/dist/components/Toggle/Toggle.d.ts +1 -1
- package/dist/components/Toggle/Toggle.js +14 -14
- package/dist/components/Toggle/types.d.ts +7 -7
- package/dist/index.d.ts +21 -3
- package/dist/index.js +61 -6
- package/dist/types.d.ts +3 -6
- package/package.json +29 -8
- package/dist/behaviors/useNumberFieldState.d.ts +0 -25
- package/dist/behaviors/useNumberFieldState.js +0 -13
- package/dist/behaviors/useTextField.d.ts +0 -19
- package/dist/behaviors/useTextField.js +0 -24
|
@@ -3,14 +3,14 @@ import type { ExtendableProps } from '@koobiq/react-core';
|
|
|
3
3
|
import type { UseCheckboxProps } from '../../behaviors';
|
|
4
4
|
import type { RenderProps } from '../../utils';
|
|
5
5
|
export type CheckboxRenderProps = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
isInvalid?: boolean;
|
|
7
|
+
isPressed?: boolean;
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
isHovered?: boolean;
|
|
10
|
+
isFocused?: boolean;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isFocusVisible?: boolean;
|
|
13
|
+
isIndeterminate?: boolean;
|
|
14
14
|
};
|
|
15
15
|
type CheckboxBaseProps = RenderProps<CheckboxRenderProps> & {
|
|
16
16
|
inputRef?: RefObject<HTMLInputElement | null>;
|
|
@@ -7,19 +7,19 @@ import { useGroupContext } from "./GroupContext.js";
|
|
|
7
7
|
const Group = forwardRef((props, ref) => {
|
|
8
8
|
const defaultProps = useGroupContext();
|
|
9
9
|
const commonProps = mergeProps(defaultProps, props);
|
|
10
|
-
const {
|
|
11
|
-
const { hoverProps, isHovered } = useHover({ isDisabled
|
|
10
|
+
const { isInvalid = false, isDisabled = false, ...other } = commonProps;
|
|
11
|
+
const { hoverProps, isHovered } = useHover({ isDisabled });
|
|
12
12
|
const { isFocused, isFocusVisible, focusProps } = useFocusRing({
|
|
13
13
|
within: true
|
|
14
14
|
});
|
|
15
15
|
const renderProps = useRenderProps({
|
|
16
16
|
...props,
|
|
17
17
|
values: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
isHovered,
|
|
19
|
+
isFocusWithin: isFocused,
|
|
20
|
+
isFocusVisible,
|
|
21
|
+
isDisabled,
|
|
22
|
+
isInvalid
|
|
23
23
|
}
|
|
24
24
|
});
|
|
25
25
|
const innerRef = useMultiRef([
|
|
@@ -2,17 +2,17 @@ import type { ComponentRef } from 'react';
|
|
|
2
2
|
import type { ExtendableComponentPropsWithRef, ExtendableProps } from '@koobiq/react-core';
|
|
3
3
|
import type { RenderProps } from '../../utils';
|
|
4
4
|
export type GroupBaseProps = ExtendableComponentPropsWithRef<{
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
isDisabled?: boolean;
|
|
6
|
+
isInvalid?: boolean;
|
|
7
7
|
}, 'div'>;
|
|
8
8
|
export type GroupRef = ComponentRef<'div'>;
|
|
9
9
|
export type GroupRenderProps = {
|
|
10
|
-
|
|
10
|
+
isIndeterminate?: boolean;
|
|
11
11
|
percentage?: number;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
isHovered: boolean;
|
|
13
|
+
isFocusWithin: boolean;
|
|
14
|
+
isFocusVisible: boolean;
|
|
15
|
+
isDisabled: boolean;
|
|
16
|
+
isInvalid: boolean;
|
|
17
17
|
};
|
|
18
18
|
export type GroupProps = ExtendableProps<RenderProps<GroupRenderProps>, GroupBaseProps>;
|
|
@@ -4,24 +4,45 @@ import { polymorphicForwardRef, useDOMRef, mergeProps } from "@koobiq/react-core
|
|
|
4
4
|
import { useRenderProps } from "../../utils/index.js";
|
|
5
5
|
import { useLink } from "../../behaviors/useLink.js";
|
|
6
6
|
const Link = polymorphicForwardRef((props, ref) => {
|
|
7
|
-
const { as: Tag = "a", ...
|
|
7
|
+
const { as: Tag = "a", ...other } = props;
|
|
8
8
|
const domRef = useDOMRef(ref);
|
|
9
|
-
const {
|
|
10
|
-
|
|
9
|
+
const { isHovered, isPressed, isFocusVisible, isFocused, linkProps } = useLink(
|
|
10
|
+
{
|
|
11
|
+
...other,
|
|
12
|
+
...other.isDisabled && {
|
|
13
|
+
onPress: void 0,
|
|
14
|
+
onPressStart: void 0,
|
|
15
|
+
onPressEnd: void 0,
|
|
16
|
+
onPressChange: void 0,
|
|
17
|
+
onPressUp: void 0,
|
|
18
|
+
onKeyDown: void 0,
|
|
19
|
+
onKeyUp: void 0,
|
|
20
|
+
onClick: void 0,
|
|
21
|
+
href: void 0
|
|
22
|
+
}
|
|
23
|
+
},
|
|
11
24
|
domRef
|
|
12
25
|
);
|
|
13
26
|
const renderValues = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
27
|
+
isHovered,
|
|
28
|
+
isPressed,
|
|
29
|
+
isFocused,
|
|
30
|
+
isFocusVisible,
|
|
31
|
+
isDisabled: props.isDisabled || false
|
|
19
32
|
};
|
|
20
33
|
const renderProps = useRenderProps({
|
|
21
34
|
...props,
|
|
22
35
|
values: renderValues
|
|
23
36
|
});
|
|
24
|
-
return /* @__PURE__ */ jsx(
|
|
37
|
+
return /* @__PURE__ */ jsx(
|
|
38
|
+
Tag,
|
|
39
|
+
{
|
|
40
|
+
...mergeProps(linkProps, renderProps),
|
|
41
|
+
tabIndex: props.tabIndex || linkProps.tabIndex,
|
|
42
|
+
ref: domRef,
|
|
43
|
+
children: renderProps.children
|
|
44
|
+
}
|
|
45
|
+
);
|
|
25
46
|
});
|
|
26
47
|
Link.displayName = "Link";
|
|
27
48
|
export {
|
|
@@ -2,10 +2,12 @@ import type { ExtendableProps } from '@koobiq/react-core';
|
|
|
2
2
|
import type { UseLinkProps } from '../../behaviors';
|
|
3
3
|
import type { RenderProps } from '../../utils';
|
|
4
4
|
export type LinkRenderProps = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
isHovered: boolean;
|
|
6
|
+
isFocused: boolean;
|
|
7
|
+
isPressed: boolean;
|
|
8
|
+
isDisabled: boolean;
|
|
9
|
+
isFocusVisible: boolean;
|
|
10
10
|
};
|
|
11
|
-
export type LinkBaseProps = ExtendableProps<RenderProps<LinkRenderProps
|
|
11
|
+
export type LinkBaseProps = ExtendableProps<RenderProps<LinkRenderProps> & {
|
|
12
|
+
tabIndex?: number;
|
|
13
|
+
}, UseLinkProps>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const NumberField: import("react").ForwardRefExoticComponent<Omit<import("
|
|
1
|
+
export declare const NumberField: import("react").ForwardRefExoticComponent<Omit<import("@react-types/numberfield").AriaNumberFieldProps, keyof import("../..").RenderProps<import("./types").NumberFieldRenderProps>> & import("../..").RenderProps<import("./types").NumberFieldRenderProps> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -11,7 +11,7 @@ import { InputContext } from "../Input/InputContext.js";
|
|
|
11
11
|
import { TextContext } from "../Text/TextContext.js";
|
|
12
12
|
const NumberField = forwardRef(
|
|
13
13
|
(props, ref) => {
|
|
14
|
-
const {
|
|
14
|
+
const { isDisabled, isReadOnly, isRequired, isInvalid } = props;
|
|
15
15
|
const inputRef = useRef(null);
|
|
16
16
|
const {
|
|
17
17
|
labelProps,
|
|
@@ -27,10 +27,10 @@ const NumberField = forwardRef(
|
|
|
27
27
|
const renderProps = useRenderProps({
|
|
28
28
|
...props,
|
|
29
29
|
values: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
isInvalid: isInvalid || false,
|
|
31
|
+
isDisabled: isDisabled || false,
|
|
32
|
+
isReadonly: isReadOnly || false,
|
|
33
|
+
isRequired: isRequired || false
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
return /* @__PURE__ */ jsx(
|
|
@@ -38,10 +38,10 @@ const NumberField = forwardRef(
|
|
|
38
38
|
{
|
|
39
39
|
...DOMProps,
|
|
40
40
|
...renderProps,
|
|
41
|
-
"data-
|
|
42
|
-
"data-readonly":
|
|
43
|
-
"data-required":
|
|
44
|
-
"data-disabled":
|
|
41
|
+
"data-invalid": isInvalid || void 0,
|
|
42
|
+
"data-readonly": isReadOnly || void 0,
|
|
43
|
+
"data-required": isRequired || void 0,
|
|
44
|
+
"data-disabled": isDisabled || void 0,
|
|
45
45
|
ref,
|
|
46
46
|
children: /* @__PURE__ */ jsx(
|
|
47
47
|
Provider,
|
|
@@ -7,22 +7,22 @@ export type NumberFieldRenderProps = {
|
|
|
7
7
|
* Whether the text field is disabled.
|
|
8
8
|
* @selector [data-disabled]
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
isDisabled: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Whether the value is invalid.
|
|
13
13
|
* @selector [data-error]
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
isInvalid: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Whether the text field is read only.
|
|
18
18
|
* @selector [data-readonly]
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
isReadonly: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Whether the text field is required.
|
|
23
23
|
* @selector [data-required]
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
isRequired: boolean;
|
|
26
26
|
};
|
|
27
27
|
type NumberFieldBaseProps = RenderProps<NumberFieldRenderProps>;
|
|
28
28
|
export type NumberFieldProps = ExtendableProps<NumberFieldBaseProps, UseNumberFieldProps>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const Radio: import("react").ForwardRefExoticComponent<Omit<import("../..").UseRadioProps, "inputRef" | keyof import("
|
|
1
|
+
export declare const Radio: import("react").ForwardRefExoticComponent<Omit<import("../..").UseRadioProps, "inputRef" | keyof import("../..").RenderProps<import("./types").RadioRenderProps>> & import("../..").RenderProps<import("./types").RadioRenderProps> & {
|
|
2
2
|
inputRef?: import("react").RefObject<HTMLInputElement | null>;
|
|
3
3
|
} & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -38,7 +38,7 @@ const Radio = forwardRef(
|
|
|
38
38
|
const DOMProps = filterDOMProps(props);
|
|
39
39
|
delete DOMProps.id;
|
|
40
40
|
return /* @__PURE__ */ jsxs("label", { ...mergeProps(DOMProps, labelProps, renderProps), ref, children: [
|
|
41
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...inputProps, ref: domRef }) }),
|
|
41
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { elementType: "span", children: /* @__PURE__ */ jsx("input", { ...inputProps, ref: domRef }) }),
|
|
42
42
|
renderProps.children
|
|
43
43
|
] });
|
|
44
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const RadioGroup: import("react").ForwardRefExoticComponent<Omit<import("../..").UseRadioGroupProps, keyof import("
|
|
1
|
+
export declare const RadioGroup: import("react").ForwardRefExoticComponent<Omit<import("../..").UseRadioGroupProps, keyof import("../..").RenderProps<import("./types").RadioGroupRenderProps>> & import("../..").RenderProps<import("./types").RadioGroupRenderProps> & import("react").RefAttributes<HTMLDivElement>>;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { TextFieldComponentProps } from './index';
|
|
2
|
+
export declare const TextField: TextFieldComponentProps;
|
|
@@ -2,69 +2,70 @@
|
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef, useRef } from "react";
|
|
4
4
|
import { filterDOMProps } from "@koobiq/react-core";
|
|
5
|
+
import { useTextField } from "@react-aria/textfield";
|
|
5
6
|
import { removeDataAttributes, useRenderProps, Provider } from "../../utils/index.js";
|
|
6
|
-
import { useTextField } from "../../behaviors/useTextField.js";
|
|
7
7
|
import { InputContext } from "../Input/InputContext.js";
|
|
8
8
|
import { TextareaContext } from "../Textarea/TextareaContext.js";
|
|
9
9
|
import { LabelContext } from "../Label/LabelContext.js";
|
|
10
10
|
import { TextContext } from "../Text/TextContext.js";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
11
|
+
function TextFieldRender(props, ref) {
|
|
12
|
+
const { isDisabled, isReadOnly, isRequired } = props;
|
|
13
|
+
const inputRef = useRef(null);
|
|
14
|
+
const {
|
|
15
|
+
isInvalid,
|
|
16
|
+
labelProps,
|
|
17
|
+
inputProps,
|
|
18
|
+
descriptionProps,
|
|
19
|
+
errorMessageProps
|
|
20
|
+
} = useTextField(
|
|
21
|
+
{ ...removeDataAttributes(props) },
|
|
22
|
+
inputRef
|
|
23
|
+
);
|
|
24
|
+
const DOMProps = filterDOMProps(props);
|
|
25
|
+
delete DOMProps.id;
|
|
26
|
+
const renderProps = useRenderProps({
|
|
27
|
+
...props,
|
|
28
|
+
values: {
|
|
29
|
+
isInvalid: isInvalid || false,
|
|
30
|
+
isDisabled: isDisabled || false,
|
|
31
|
+
isReadOnly: isReadOnly || false,
|
|
32
|
+
isRequired: isRequired || false
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return /* @__PURE__ */ jsx(
|
|
36
|
+
"div",
|
|
37
|
+
{
|
|
38
|
+
...DOMProps,
|
|
39
|
+
...renderProps,
|
|
40
|
+
"data-invalid": isInvalid || void 0,
|
|
41
|
+
"data-readonly": isReadOnly || void 0,
|
|
42
|
+
"data-required": isRequired || void 0,
|
|
43
|
+
"data-disabled": isDisabled || void 0,
|
|
44
|
+
ref,
|
|
45
|
+
children: /* @__PURE__ */ jsx(
|
|
46
|
+
Provider,
|
|
47
|
+
{
|
|
48
|
+
values: [
|
|
49
|
+
[LabelContext, labelProps],
|
|
50
|
+
[InputContext, { ...inputProps, ref: inputRef }],
|
|
51
|
+
[TextareaContext, { ...inputProps, ref: inputRef }],
|
|
52
|
+
[
|
|
53
|
+
TextContext,
|
|
54
|
+
{
|
|
55
|
+
slots: {
|
|
56
|
+
description: descriptionProps,
|
|
57
|
+
errorMessage: errorMessageProps
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
]
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
TextField
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
],
|
|
62
|
+
children: renderProps.children
|
|
63
|
+
}
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const TextField = forwardRef(TextFieldRender);
|
|
68
69
|
export {
|
|
69
70
|
TextField
|
|
70
71
|
};
|
|
@@ -1,30 +1,33 @@
|
|
|
1
|
-
import type { ComponentRef } from 'react';
|
|
1
|
+
import type { ComponentRef, ReactElement } from 'react';
|
|
2
2
|
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AriaTextFieldProps } from '@react-aria/textfield';
|
|
4
4
|
import type { RenderProps } from '../../utils';
|
|
5
5
|
export type TextFieldRenderProps = {
|
|
6
6
|
/**
|
|
7
7
|
* Whether the text field is disabled.
|
|
8
8
|
* @selector [data-disabled]
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
isDisabled: boolean;
|
|
11
11
|
/**
|
|
12
12
|
* Whether the value is invalid.
|
|
13
13
|
* @selector [data-error]
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
isInvalid: boolean;
|
|
16
16
|
/**
|
|
17
17
|
* Whether the text field is read only.
|
|
18
18
|
* @selector [data-readonly]
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
isReadOnly: boolean;
|
|
21
21
|
/**
|
|
22
22
|
* Whether the text field is required.
|
|
23
23
|
* @selector [data-required]
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
isRequired: boolean;
|
|
26
26
|
};
|
|
27
|
-
type TextFieldBaseProps = RenderProps<TextFieldRenderProps
|
|
28
|
-
|
|
27
|
+
type TextFieldBaseProps = RenderProps<TextFieldRenderProps> & {
|
|
28
|
+
inputElementType?: 'input' | 'textarea';
|
|
29
|
+
};
|
|
30
|
+
export type TextFieldProps<T = HTMLInputElement> = ExtendableProps<TextFieldBaseProps, AriaTextFieldProps<T>>;
|
|
31
|
+
export type TextFieldComponentProps = <T = HTMLInputElement>(props: TextFieldProps<T>) => ReactElement | null;
|
|
29
32
|
export type TextFieldRef = ComponentRef<'div'>;
|
|
30
33
|
export {};
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
value?: string | number | readonly string[];
|
|
4
|
-
} & import("react").HTMLAttributes<HTMLInputElement | HTMLTextAreaElement> & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
1
|
+
import { type TextareaProps } from './index';
|
|
2
|
+
export declare const Textarea: import("react").ForwardRefExoticComponent<Omit<TextareaProps, "ref"> & import("react").RefAttributes<HTMLTextAreaElement>>;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
3
|
import { forwardRef } from "react";
|
|
4
|
-
import { mergeProps } from "@koobiq/react-core";
|
|
4
|
+
import { mergeProps, useMultiRef } from "@koobiq/react-core";
|
|
5
5
|
import { useTextareaContext } from "./TextareaContext.js";
|
|
6
6
|
const Textarea = forwardRef((props, ref) => {
|
|
7
7
|
const { children, ...other } = props;
|
|
8
8
|
const defaultProps = useTextareaContext();
|
|
9
9
|
const commonProps = mergeProps(defaultProps, other);
|
|
10
|
-
|
|
10
|
+
const innerRef = useMultiRef([
|
|
11
|
+
ref,
|
|
12
|
+
...defaultProps.ref ? [defaultProps.ref] : []
|
|
13
|
+
]);
|
|
14
|
+
return /* @__PURE__ */ jsx("textarea", { ...commonProps, ref: innerRef, children });
|
|
11
15
|
});
|
|
12
16
|
Textarea.displayName = "Textarea";
|
|
13
17
|
export {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ComponentRef, HTMLAttributes, ReactNode } from 'react';
|
|
1
|
+
import type { ComponentRef, HTMLAttributes, ReactNode, Ref } from 'react';
|
|
2
2
|
export type TextareaProps = {
|
|
3
3
|
children?: ReactNode;
|
|
4
4
|
value?: string | number | readonly string[];
|
|
5
|
+
ref?: Ref<HTMLTextAreaElement>;
|
|
5
6
|
} & HTMLAttributes<HTMLInputElement | HTMLTextAreaElement>;
|
|
6
7
|
export type TextareaRef = ComponentRef<'textarea'>;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const Toggle: import("react").ForwardRefExoticComponent<Omit<import("../..").UseToggleProps, "inputRef" | keyof import("
|
|
1
|
+
export declare const Toggle: import("react").ForwardRefExoticComponent<Omit<import("../..").UseToggleProps, "inputRef" | keyof import("../..").RenderProps<import("./types").ToggleRenderProps>> & import("../..").RenderProps<import("./types").ToggleRenderProps> & {
|
|
2
2
|
inputRef?: import("react").RefObject<HTMLInputElement | null>;
|
|
3
3
|
} & import("react").RefAttributes<HTMLLabelElement>>;
|
|
@@ -10,12 +10,12 @@ const Toggle = forwardRef(
|
|
|
10
10
|
const { children, inputRef } = props;
|
|
11
11
|
const domRef = useDOMRef(inputRef);
|
|
12
12
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
isHovered,
|
|
14
|
+
isInvalid,
|
|
15
|
+
isSelected,
|
|
16
|
+
isFocused,
|
|
17
|
+
isPressed,
|
|
18
|
+
isFocusVisible,
|
|
19
19
|
labelProps,
|
|
20
20
|
inputProps
|
|
21
21
|
} = useToggle(
|
|
@@ -26,13 +26,13 @@ const Toggle = forwardRef(
|
|
|
26
26
|
domRef
|
|
27
27
|
);
|
|
28
28
|
const renderValues = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
isHovered,
|
|
30
|
+
isInvalid,
|
|
31
|
+
isSelected,
|
|
32
|
+
isFocused,
|
|
33
|
+
isPressed,
|
|
34
|
+
isFocusVisible,
|
|
35
|
+
isDisabled: props.isDisabled || false
|
|
36
36
|
};
|
|
37
37
|
const renderProps = useRenderProps({
|
|
38
38
|
...props,
|
|
@@ -41,7 +41,7 @@ const Toggle = forwardRef(
|
|
|
41
41
|
const DOMProps = filterDOMProps(props);
|
|
42
42
|
delete DOMProps.id;
|
|
43
43
|
return /* @__PURE__ */ jsxs("label", { ...mergeProps(DOMProps, labelProps, renderProps), ref, children: [
|
|
44
|
-
/* @__PURE__ */ jsx(VisuallyHidden, { children: /* @__PURE__ */ jsx("input", { ...inputProps, ref: domRef }) }),
|
|
44
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { elementType: "span", children: /* @__PURE__ */ jsx("input", { ...inputProps, ref: domRef }) }),
|
|
45
45
|
renderProps.children
|
|
46
46
|
] });
|
|
47
47
|
}
|
|
@@ -3,13 +3,13 @@ import type { ExtendableProps } from '@koobiq/react-core';
|
|
|
3
3
|
import type { UseToggleProps } from '../../behaviors';
|
|
4
4
|
import type { RenderProps } from '../../utils';
|
|
5
5
|
export type ToggleRenderProps = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
isInvalid?: boolean;
|
|
7
|
+
isPressed?: boolean;
|
|
8
|
+
isSelected?: boolean;
|
|
9
|
+
isHovered?: boolean;
|
|
10
|
+
isFocused?: boolean;
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
isFocusVisible?: boolean;
|
|
13
13
|
};
|
|
14
14
|
type ToggleBaseProps = RenderProps<ToggleRenderProps> & {
|
|
15
15
|
inputRef?: RefObject<HTMLInputElement | null>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,33 @@
|
|
|
1
|
+
import { useToggleButtonGroup, useToggleButtonGroupItem, type AriaToggleButtonGroupProps, type AriaToggleButtonGroupItemProps } from '@react-aria/button';
|
|
2
|
+
import { useCalendar, useCalendarCell, useCalendarGrid, type AriaCalendarProps, type AriaCalendarCellProps, type AriaCalendarGridProps, type DateValue, type CalendarAria } from '@react-aria/calendar';
|
|
1
3
|
import { useDialog, type AriaDialogProps } from '@react-aria/dialog';
|
|
2
|
-
import { useLocale, I18nProvider, useLocalizedStringFormatter, type I18nProviderProps } from '@react-aria/i18n';
|
|
4
|
+
import { useLocale, I18nProvider, useDateFormatter, useLocalizedStringFormatter, type I18nProviderProps } from '@react-aria/i18n';
|
|
3
5
|
import { useListBox, useOption, useListBoxSection, type AriaListBoxProps } from '@react-aria/listbox';
|
|
6
|
+
import { useMenu, useMenuItem, useMenuSection, useMenuTrigger, type AriaMenuOptions, type AriaMenuProps } from '@react-aria/menu';
|
|
4
7
|
import { Overlay, usePopover, useModalOverlay, useOverlayTrigger, useOverlayPosition, type AriaModalOverlayProps } from '@react-aria/overlays';
|
|
8
|
+
import { useSelect, HiddenSelect } from '@react-aria/select';
|
|
9
|
+
import { useSeparator } from '@react-aria/separator';
|
|
10
|
+
import { useTable, useTableCell, useTableRow, useTableHeaderRow, useTableSelectAllCheckbox, useTableSelectionCheckbox, useTableColumnHeader, useTableRowGroup, type AriaTableProps, type AriaTableCellProps, type GridRowProps, type AriaTableColumnHeaderProps } from '@react-aria/table';
|
|
11
|
+
import { useTag, useTagGroup, type AriaTagGroupProps, type AriaTagProps } from '@react-aria/tag';
|
|
5
12
|
import { useTooltip, useTooltipTrigger } from '@react-aria/tooltip';
|
|
13
|
+
import { RouterProvider, useRouter } from '@react-aria/utils';
|
|
14
|
+
import { VisuallyHidden } from '@react-aria/visually-hidden';
|
|
15
|
+
import { useCalendarState, type CalendarState } from '@react-stately/calendar';
|
|
6
16
|
import { Item, Section } from '@react-stately/collections';
|
|
17
|
+
import { useListData } from '@react-stately/data';
|
|
7
18
|
import { useListState, type ListState } from '@react-stately/list';
|
|
19
|
+
import { useMenuTriggerState } from '@react-stately/menu';
|
|
8
20
|
import { useOverlayTriggerState, type OverlayTriggerState } from '@react-stately/overlays';
|
|
21
|
+
import { useSelectState } from '@react-stately/select';
|
|
22
|
+
import { Cell, Column, Row, TableBody, TableHeader, useTableState, type TableStateProps, type TableState, type CellProps, type ColumnProps, type RowProps, type TableHeaderProps, type TableBodyProps } from '@react-stately/table';
|
|
23
|
+
import { useToggleGroupState, type ToggleGroupState } from '@react-stately/toggle';
|
|
9
24
|
import type { TooltipTriggerProps } from '@react-stately/tooltip';
|
|
10
25
|
import { useTooltipTriggerState } from '@react-stately/tooltip';
|
|
11
|
-
import
|
|
26
|
+
import { useTreeState, type TreeState } from '@react-stately/tree';
|
|
27
|
+
import type { Node, PressEvent, HoverEvent, ItemProps, SectionProps, LinkDOMProps, FocusableElement } from '@react-types/shared';
|
|
28
|
+
export * from '@internationalized/date';
|
|
12
29
|
export * from './behaviors/index.js';
|
|
13
30
|
export * from './components/index.js';
|
|
14
|
-
export { Overlay, useLocale, useDialog, useOption, usePopover, useListBox, useTooltip,
|
|
31
|
+
export { Item, Overlay, Section, useMenu, Cell, Column, Row, TableBody, TableHeader, useLocale, useDialog, useOption, useSelect, usePopover, useListBox, useTooltip, useTag, useTable, useTagGroup, useListState, HiddenSelect, I18nProvider, useMenuItem, useListData, useCalendar, useCalendarCell, useCalendarGrid, useTreeState, useSeparator, useTableState, useMenuSection, useMenuTrigger, useSelectState, useModalOverlay, useOverlayTrigger, useTooltipTrigger, useListBoxSection, useOverlayPosition, useTableCell, useTableRow, useDateFormatter, useCalendarState, useTableHeaderRow, useTableColumnHeader, useTableSelectAllCheckbox, useTableSelectionCheckbox, useTableRowGroup, useMenuTriggerState, useToggleGroupState, useToggleButtonGroup, useOverlayTriggerState, useTooltipTriggerState, useToggleButtonGroupItem, useLocalizedStringFormatter, RouterProvider, useRouter, VisuallyHidden, type Node, type CalendarAria, type DateValue, type TableState, type TreeState, type TableHeaderProps, type TableBodyProps, type ItemProps, type CellProps, type ColumnProps, type RowProps, type GridRowProps, type AriaCalendarGridProps, type AriaCalendarCellProps, type AriaTableColumnHeaderProps, type AriaTableCellProps, type AriaTableProps, type TableStateProps, type AriaTagGroupProps, type AriaTagProps, type ListState, type PressEvent, type HoverEvent, type CalendarState, type AriaCalendarProps, type LinkDOMProps, type FocusableElement, type SectionProps, type ToggleGroupState, type AriaMenuProps, type AriaDialogProps, type AriaMenuOptions, type AriaListBoxProps, type I18nProviderProps, type TooltipTriggerProps, type OverlayTriggerState, type AriaModalOverlayProps, type AriaToggleButtonGroupProps, type AriaToggleButtonGroupItemProps, };
|
|
15
32
|
export * from './types';
|
|
33
|
+
export * from './utils';
|