@koobiq/react-primitives 0.0.1-beta.3 → 0.0.1-beta.30
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/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/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/GroupContext.js +1 -0
- 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/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 +1 -1
- package/dist/components/Textarea/TextareaContext.js +1 -0
- 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 -2
- package/dist/types.d.ts +3 -6
- package/package.json +28 -7
|
@@ -2,11 +2,11 @@ import type { RefObject } from 'react';
|
|
|
2
2
|
import type { ButtonOptions } from '../types';
|
|
3
3
|
export type UseButtonProps = ButtonOptions;
|
|
4
4
|
export declare function useButton(props: UseButtonProps, ref: RefObject<Element | null>): {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
buttonProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
|
|
10
|
-
|
|
5
|
+
isPressed: boolean;
|
|
6
|
+
isHovered: boolean;
|
|
7
|
+
isFocused: boolean;
|
|
8
|
+
isDisabled: boolean | undefined;
|
|
9
|
+
buttonProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement> & import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
|
|
10
|
+
isFocusVisible: boolean;
|
|
11
11
|
};
|
|
12
12
|
export type UseButtonReturn = ReturnType<typeof useButton>;
|
|
@@ -2,34 +2,23 @@
|
|
|
2
2
|
import { useFocusRing, useHover, mergeProps } from "@koobiq/react-core";
|
|
3
3
|
import { useButton as useButton$1 } from "@react-aria/button";
|
|
4
4
|
function useButton(props, ref) {
|
|
5
|
-
const {
|
|
6
|
-
const {
|
|
7
|
-
focusProps,
|
|
8
|
-
isFocused: focused,
|
|
9
|
-
isFocusVisible: focusVisible
|
|
10
|
-
} = useFocusRing({
|
|
5
|
+
const { isDisabled } = props;
|
|
6
|
+
const { focusProps, isFocused, isFocusVisible } = useFocusRing({
|
|
11
7
|
within: true
|
|
12
8
|
});
|
|
13
|
-
const { hoverProps, isHovered
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
});
|
|
17
|
-
const { buttonProps: commonButtonProps, isPressed: pressed } = useButton$1(
|
|
18
|
-
{
|
|
19
|
-
...otherProps,
|
|
20
|
-
onPress: onPress || onClick,
|
|
21
|
-
isDisabled: disabled
|
|
22
|
-
},
|
|
9
|
+
const { hoverProps, isHovered } = useHover(props);
|
|
10
|
+
const { buttonProps: commonButtonProps, isPressed } = useButton$1(
|
|
11
|
+
props,
|
|
23
12
|
ref
|
|
24
13
|
);
|
|
25
14
|
const buttonProps = mergeProps(commonButtonProps, focusProps, hoverProps);
|
|
26
15
|
return {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
16
|
+
isPressed,
|
|
17
|
+
isHovered,
|
|
18
|
+
isFocused,
|
|
19
|
+
isDisabled,
|
|
31
20
|
buttonProps,
|
|
32
|
-
|
|
21
|
+
isFocusVisible
|
|
33
22
|
};
|
|
34
23
|
}
|
|
35
24
|
export {
|
|
@@ -1,56 +1,21 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
2
|
import type { AriaCheckboxProps } from '@react-aria/checkbox';
|
|
4
|
-
export type UseCheckboxProps =
|
|
5
|
-
/**
|
|
6
|
-
* If `true`, the component will indicate an error.
|
|
7
|
-
* @default false
|
|
8
|
-
* */
|
|
9
|
-
error?: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* If `true`, the component is checked.
|
|
12
|
-
* @default false
|
|
13
|
-
* */
|
|
14
|
-
checked?: boolean;
|
|
15
|
-
/** It prevents the user from changing the value of the checkbox.
|
|
16
|
-
* @default false
|
|
17
|
-
*/
|
|
18
|
-
readonly?: boolean;
|
|
19
|
-
/**
|
|
20
|
-
* If `true`, the component is disabled.
|
|
21
|
-
* @default false
|
|
22
|
-
* */
|
|
23
|
-
disabled?: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* If `true`, the input element is required.
|
|
26
|
-
* @default false
|
|
27
|
-
* */
|
|
28
|
-
required?: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* If `true`, the component appears indeterminate.
|
|
31
|
-
* @default false
|
|
32
|
-
* */
|
|
33
|
-
indeterminate?: boolean;
|
|
34
|
-
/** The default checked state. Use when the component is not controlled. */
|
|
35
|
-
defaultChecked?: boolean;
|
|
36
|
-
/** Callback fired when the state is changed. */
|
|
37
|
-
onChange?: (checked: boolean) => void;
|
|
38
|
-
}, Omit<AriaCheckboxProps, 'onChange' | 'isRequired' | 'isInvalid' | 'isReadOnly' | 'isSelected' | 'isDisabled' | 'isIndeterminate' | 'defaultSelected'>>;
|
|
3
|
+
export type UseCheckboxProps = AriaCheckboxProps;
|
|
39
4
|
export declare function useCheckbox(props: UseCheckboxProps, inputRef: RefObject<HTMLInputElement | null>): {
|
|
40
5
|
validationErrors: string[];
|
|
41
6
|
validationDetails: ValidityState;
|
|
7
|
+
isInvalid: boolean;
|
|
8
|
+
isPressed: boolean;
|
|
9
|
+
isHovered: boolean;
|
|
10
|
+
isFocused: boolean;
|
|
11
|
+
isSelected: boolean;
|
|
12
|
+
isDisabled: boolean;
|
|
13
|
+
isReadOnly: boolean;
|
|
42
14
|
labelProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement> & import("react").LabelHTMLAttributes<HTMLLabelElement>;
|
|
43
15
|
inputProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement> & import("react").InputHTMLAttributes<HTMLInputElement> & {
|
|
44
16
|
ref: RefObject<HTMLInputElement | null>;
|
|
45
17
|
};
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
pressed: boolean;
|
|
49
|
-
hovered: boolean;
|
|
50
|
-
focused: boolean;
|
|
51
|
-
checked: boolean;
|
|
52
|
-
disabled: boolean;
|
|
53
|
-
readonly: boolean;
|
|
54
|
-
focusVisible: boolean;
|
|
18
|
+
isFocusVisible: boolean;
|
|
19
|
+
isIndeterminate: boolean | undefined;
|
|
55
20
|
};
|
|
56
21
|
export type UseCheckboxReturn = ReturnType<typeof useCheckbox>;
|
|
@@ -1,24 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
2
|
+
import { useHover, useFocusRing, mergeProps } from "@koobiq/react-core";
|
|
3
3
|
import { useCheckbox as useCheckbox$1 } from "@react-aria/checkbox";
|
|
4
|
+
import { useToggleState } from "@react-stately/toggle";
|
|
4
5
|
function useCheckbox(props, inputRef) {
|
|
5
|
-
const {
|
|
6
|
-
|
|
7
|
-
checked,
|
|
8
|
-
disabled,
|
|
9
|
-
readonly,
|
|
10
|
-
required,
|
|
11
|
-
indeterminate,
|
|
12
|
-
defaultChecked,
|
|
13
|
-
onChange
|
|
14
|
-
} = props;
|
|
15
|
-
const state = useToggleState({
|
|
16
|
-
isSelected: checked,
|
|
17
|
-
defaultSelected: defaultChecked,
|
|
18
|
-
onChange
|
|
19
|
-
});
|
|
6
|
+
const { isDisabled: isDisabledProp, isIndeterminate: isIndeterminateProp } = props;
|
|
7
|
+
const state = useToggleState(props);
|
|
20
8
|
const { hoverProps, isHovered } = useHover({
|
|
21
|
-
isDisabled:
|
|
9
|
+
isDisabled: isDisabledProp
|
|
22
10
|
});
|
|
23
11
|
const { focusProps, isFocused, isFocusVisible } = useFocusRing();
|
|
24
12
|
const {
|
|
@@ -30,34 +18,23 @@ function useCheckbox(props, inputRef) {
|
|
|
30
18
|
isReadOnly,
|
|
31
19
|
isPressed,
|
|
32
20
|
...other
|
|
33
|
-
} = useCheckbox$1(
|
|
34
|
-
{
|
|
35
|
-
...props,
|
|
36
|
-
isInvalid: error,
|
|
37
|
-
isDisabled: disabled,
|
|
38
|
-
isIndeterminate: indeterminate,
|
|
39
|
-
isReadOnly: readonly,
|
|
40
|
-
isRequired: required
|
|
41
|
-
},
|
|
42
|
-
state,
|
|
43
|
-
inputRef
|
|
44
|
-
);
|
|
21
|
+
} = useCheckbox$1(props, state, inputRef);
|
|
45
22
|
const labelProps = mergeProps(hoverProps, commonLabelProps);
|
|
46
23
|
const inputProps = mergeProps(focusProps, commonInputProps, {
|
|
47
24
|
ref: inputRef
|
|
48
25
|
});
|
|
49
26
|
return {
|
|
27
|
+
isInvalid,
|
|
28
|
+
isPressed,
|
|
29
|
+
isHovered,
|
|
30
|
+
isFocused,
|
|
31
|
+
isSelected,
|
|
32
|
+
isDisabled,
|
|
33
|
+
isReadOnly,
|
|
50
34
|
labelProps,
|
|
51
35
|
inputProps,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
pressed: isPressed,
|
|
55
|
-
hovered: isHovered,
|
|
56
|
-
focused: isFocused,
|
|
57
|
-
checked: isSelected,
|
|
58
|
-
disabled: isDisabled,
|
|
59
|
-
readonly: isReadOnly,
|
|
60
|
-
focusVisible: isFocusVisible,
|
|
36
|
+
isFocusVisible,
|
|
37
|
+
isIndeterminate: isIndeterminateProp,
|
|
61
38
|
...other
|
|
62
39
|
};
|
|
63
40
|
}
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
import type { RefObject } from 'react';
|
|
2
|
-
import type { ExtendableProps } from '@koobiq/react-core';
|
|
3
2
|
import type { AriaLinkOptions } from '@react-aria/link';
|
|
4
|
-
export type UseLinkProps =
|
|
5
|
-
disabled?: boolean;
|
|
6
|
-
onClick?: AriaLinkOptions['onPress'];
|
|
7
|
-
}, Omit<AriaLinkOptions, 'isDisabled'>>;
|
|
3
|
+
export type UseLinkProps = AriaLinkOptions;
|
|
8
4
|
export declare function useLink(props: UseLinkProps, ref: RefObject<HTMLElement | null>): {
|
|
9
5
|
linkProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
6
|
+
isPressed: boolean;
|
|
7
|
+
isHovered: boolean;
|
|
8
|
+
isFocused: boolean;
|
|
9
|
+
isFocusVisible: boolean;
|
|
14
10
|
};
|
|
15
11
|
export type UseLinkReturn = ReturnType<typeof useLink>;
|
|
@@ -2,32 +2,23 @@
|
|
|
2
2
|
import { useHover, useFocusRing, mergeProps } from "@koobiq/react-core";
|
|
3
3
|
import { useLink as useLink$1 } from "@react-aria/link";
|
|
4
4
|
function useLink(props, ref) {
|
|
5
|
-
const {
|
|
6
|
-
const { hoverProps, isHovered } = useHover({
|
|
7
|
-
...otherProps,
|
|
8
|
-
isDisabled: disabled
|
|
9
|
-
});
|
|
5
|
+
const { hoverProps, isHovered } = useHover(props);
|
|
10
6
|
const { focusProps, isFocused, isFocusVisible } = useFocusRing();
|
|
11
7
|
const { linkProps: commonLinkProps, isPressed } = useLink$1(
|
|
12
|
-
|
|
13
|
-
...otherProps,
|
|
14
|
-
onPress: onClick,
|
|
15
|
-
isDisabled: disabled
|
|
16
|
-
},
|
|
8
|
+
props,
|
|
17
9
|
ref
|
|
18
10
|
);
|
|
19
11
|
const linkProps = mergeProps(
|
|
20
|
-
|
|
12
|
+
commonLinkProps,
|
|
21
13
|
focusProps,
|
|
22
|
-
hoverProps
|
|
23
|
-
commonLinkProps
|
|
14
|
+
hoverProps
|
|
24
15
|
);
|
|
25
16
|
return {
|
|
26
17
|
linkProps,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
isPressed,
|
|
19
|
+
isHovered,
|
|
20
|
+
isFocused,
|
|
21
|
+
isFocusVisible
|
|
31
22
|
};
|
|
32
23
|
}
|
|
33
24
|
export {
|