@koobiq/react-primitives 0.0.1-beta.20 → 0.0.1-beta.22
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 +5 -5
- package/dist/behaviors/useButton.js +10 -20
- package/dist/behaviors/useLink.d.ts +5 -8
- package/dist/behaviors/useLink.js +8 -16
- package/dist/components/Button/Button.js +17 -18
- package/dist/components/Button/types.d.ts +7 -7
- package/dist/components/Link/Link.js +10 -12
- package/dist/components/Link/types.d.ts +5 -5
- package/dist/index.d.ts +3 -1
- package/dist/index.js +5 -0
- package/dist/types.d.ts +2 -8
- package/package.json +5 -3
|
@@ -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
|
-
|
|
5
|
+
isPressed: boolean;
|
|
6
|
+
isHovered: boolean;
|
|
7
|
+
isFocused: boolean;
|
|
8
|
+
isDisabled: boolean | undefined;
|
|
9
9
|
buttonProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
|
|
10
|
-
|
|
10
|
+
isFocusVisible: boolean;
|
|
11
11
|
};
|
|
12
12
|
export type UseButtonReturn = ReturnType<typeof useButton>;
|
|
@@ -2,33 +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
|
-
isDisabled: disabled
|
|
21
|
-
},
|
|
9
|
+
const { hoverProps, isHovered } = useHover(props);
|
|
10
|
+
const { buttonProps: commonButtonProps, isPressed } = useButton$1(
|
|
11
|
+
props,
|
|
22
12
|
ref
|
|
23
13
|
);
|
|
24
14
|
const buttonProps = mergeProps(commonButtonProps, focusProps, hoverProps);
|
|
25
15
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
16
|
+
isPressed,
|
|
17
|
+
isHovered,
|
|
18
|
+
isFocused,
|
|
19
|
+
isDisabled,
|
|
30
20
|
buttonProps,
|
|
31
|
-
|
|
21
|
+
isFocusVisible
|
|
32
22
|
};
|
|
33
23
|
}
|
|
34
24
|
export {
|
|
@@ -1,14 +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
|
-
}, Omit<AriaLinkOptions, 'isDisabled'>>;
|
|
3
|
+
export type UseLinkProps = AriaLinkOptions;
|
|
7
4
|
export declare function useLink(props: UseLinkProps, ref: RefObject<HTMLElement | null>): {
|
|
8
5
|
linkProps: import("@react-types/shared").DOMAttributes<import("@react-types/shared").FocusableElement>;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
6
|
+
isPressed: boolean;
|
|
7
|
+
isHovered: boolean;
|
|
8
|
+
isFocused: boolean;
|
|
9
|
+
isFocusVisible: boolean;
|
|
13
10
|
};
|
|
14
11
|
export type UseLinkReturn = ReturnType<typeof useLink>;
|
|
@@ -2,31 +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
|
-
isDisabled: disabled
|
|
15
|
-
},
|
|
8
|
+
props,
|
|
16
9
|
ref
|
|
17
10
|
);
|
|
18
11
|
const linkProps = mergeProps(
|
|
19
|
-
|
|
12
|
+
commonLinkProps,
|
|
20
13
|
focusProps,
|
|
21
|
-
hoverProps
|
|
22
|
-
commonLinkProps
|
|
14
|
+
hoverProps
|
|
23
15
|
);
|
|
24
16
|
return {
|
|
25
17
|
linkProps,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
18
|
+
isPressed,
|
|
19
|
+
isHovered,
|
|
20
|
+
isFocused,
|
|
21
|
+
isFocusVisible
|
|
30
22
|
};
|
|
31
23
|
}
|
|
32
24
|
export {
|
|
@@ -11,8 +11,8 @@ const Button = polymorphicForwardRef(
|
|
|
11
11
|
const Tag = as || "button";
|
|
12
12
|
const commonProps = useSlottedContext(props, ButtonContext, slot);
|
|
13
13
|
const {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
isLoading,
|
|
15
|
+
isDisabled,
|
|
16
16
|
value,
|
|
17
17
|
name,
|
|
18
18
|
form,
|
|
@@ -23,10 +23,10 @@ const Button = polymorphicForwardRef(
|
|
|
23
23
|
formTarget
|
|
24
24
|
} = commonProps;
|
|
25
25
|
const domRef = useDOMRef(ref);
|
|
26
|
-
const {
|
|
26
|
+
const { isHovered, isPressed, isFocused, isFocusVisible, buttonProps } = useButton(
|
|
27
27
|
{
|
|
28
28
|
...commonProps,
|
|
29
|
-
...(
|
|
29
|
+
...(isLoading || isDisabled) && {
|
|
30
30
|
onPress: void 0,
|
|
31
31
|
onPressStart: void 0,
|
|
32
32
|
onPressEnd: void 0,
|
|
@@ -37,18 +37,17 @@ const Button = polymorphicForwardRef(
|
|
|
37
37
|
onClick: void 0,
|
|
38
38
|
href: void 0
|
|
39
39
|
},
|
|
40
|
-
disabled,
|
|
41
40
|
elementType: as
|
|
42
41
|
},
|
|
43
42
|
domRef
|
|
44
43
|
);
|
|
45
44
|
const renderValues = {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
isHovered,
|
|
46
|
+
isPressed,
|
|
47
|
+
isFocused,
|
|
48
|
+
isFocusVisible,
|
|
49
|
+
isLoading: isLoading || false,
|
|
50
|
+
isDisabled: isDisabled || false
|
|
52
51
|
};
|
|
53
52
|
const renderProps = useRenderProps({
|
|
54
53
|
...props,
|
|
@@ -69,14 +68,14 @@ const Button = polymorphicForwardRef(
|
|
|
69
68
|
},
|
|
70
69
|
...buttonProps,
|
|
71
70
|
...renderProps,
|
|
72
|
-
"data-hovered":
|
|
73
|
-
"data-pressed":
|
|
74
|
-
"data-focused":
|
|
75
|
-
"data-disabled":
|
|
76
|
-
"data-focus-visible":
|
|
71
|
+
"data-hovered": isHovered,
|
|
72
|
+
"data-pressed": isPressed,
|
|
73
|
+
"data-focused": isFocused,
|
|
74
|
+
"data-disabled": isDisabled,
|
|
75
|
+
"data-focus-visible": isFocusVisible,
|
|
77
76
|
tabIndex: tabIndex || buttonProps.tabIndex,
|
|
78
|
-
"aria-disabled":
|
|
79
|
-
"aria-busy":
|
|
77
|
+
"aria-disabled": isLoading ? "true" : buttonProps["aria-disabled"],
|
|
78
|
+
"aria-busy": isLoading,
|
|
80
79
|
ref: domRef,
|
|
81
80
|
children: renderProps.children
|
|
82
81
|
}
|
|
@@ -3,12 +3,12 @@ import type { HoverEvent } from '@react-types/shared';
|
|
|
3
3
|
import type { ButtonOptions } from '../../types';
|
|
4
4
|
import type { RenderProps } from '../../utils';
|
|
5
5
|
export type ButtonRenderProps = {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
isHovered: boolean;
|
|
7
|
+
isFocused: boolean;
|
|
8
|
+
isPressed: boolean;
|
|
9
|
+
isLoading: boolean;
|
|
10
|
+
isDisabled: boolean;
|
|
11
|
+
isFocusVisible: boolean;
|
|
12
12
|
};
|
|
13
13
|
export type ButtonBaseProps = ExtendableProps<RenderProps<ButtonRenderProps>, ButtonOptions & {
|
|
14
14
|
/** Handler that is called when a hover interaction starts. */
|
|
@@ -39,5 +39,5 @@ export type ButtonBaseProps = ExtendableProps<RenderProps<ButtonRenderProps>, Bu
|
|
|
39
39
|
formTarget?: string;
|
|
40
40
|
tabIndex?: number;
|
|
41
41
|
slot?: string;
|
|
42
|
-
|
|
42
|
+
isLoading?: boolean;
|
|
43
43
|
}>;
|
|
@@ -4,13 +4,12 @@ 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", ...
|
|
8
|
-
const { disabled } = commonProps;
|
|
7
|
+
const { as: Tag = "a", ...other } = props;
|
|
9
8
|
const domRef = useDOMRef(ref);
|
|
10
|
-
const {
|
|
9
|
+
const { isHovered, isPressed, isFocusVisible, isFocused, linkProps } = useLink(
|
|
11
10
|
{
|
|
12
|
-
...
|
|
13
|
-
...
|
|
11
|
+
...other,
|
|
12
|
+
...other.isDisabled && {
|
|
14
13
|
onPress: void 0,
|
|
15
14
|
onPressStart: void 0,
|
|
16
15
|
onPressEnd: void 0,
|
|
@@ -20,17 +19,16 @@ const Link = polymorphicForwardRef((props, ref) => {
|
|
|
20
19
|
onKeyUp: void 0,
|
|
21
20
|
onClick: void 0,
|
|
22
21
|
href: void 0
|
|
23
|
-
}
|
|
24
|
-
disabled
|
|
22
|
+
}
|
|
25
23
|
},
|
|
26
24
|
domRef
|
|
27
25
|
);
|
|
28
26
|
const renderValues = {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
isHovered,
|
|
28
|
+
isPressed,
|
|
29
|
+
isFocused,
|
|
30
|
+
isFocusVisible,
|
|
31
|
+
isDisabled: props.isDisabled || false
|
|
34
32
|
};
|
|
35
33
|
const renderProps = useRenderProps({
|
|
36
34
|
...props,
|
|
@@ -2,11 +2,11 @@ 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
11
|
export type LinkBaseProps = ExtendableProps<RenderProps<LinkRenderProps> & {
|
|
12
12
|
tabIndex?: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ import { useMenu, useMenuItem, useMenuSection, useMenuTrigger, type AriaMenuOpti
|
|
|
6
6
|
import { Overlay, usePopover, useModalOverlay, useOverlayTrigger, useOverlayPosition, type AriaModalOverlayProps } from '@react-aria/overlays';
|
|
7
7
|
import { useSelect, HiddenSelect } from '@react-aria/select';
|
|
8
8
|
import { useSeparator } from '@react-aria/separator';
|
|
9
|
+
import { useTag, useTagGroup, type AriaTagGroupProps, type AriaTagProps } from '@react-aria/tag';
|
|
9
10
|
import { useTooltip, useTooltipTrigger } from '@react-aria/tooltip';
|
|
10
11
|
import { Item, Section } from '@react-stately/collections';
|
|
12
|
+
import { useListData } from '@react-stately/data';
|
|
11
13
|
import { useListState, type ListState } from '@react-stately/list';
|
|
12
14
|
import { useMenuTriggerState } from '@react-stately/menu';
|
|
13
15
|
import { useOverlayTriggerState, type OverlayTriggerState } from '@react-stately/overlays';
|
|
@@ -19,6 +21,6 @@ import { useTreeState, type TreeState } from '@react-stately/tree';
|
|
|
19
21
|
import type { Node, PressEvent, HoverEvent, ItemProps, SectionProps, LinkDOMProps, FocusableElement } from '@react-types/shared';
|
|
20
22
|
export * from './behaviors/index.js';
|
|
21
23
|
export * from './components/index.js';
|
|
22
|
-
export { Item, Overlay, Section, useMenu, useLocale, useDialog, useOption, useSelect, usePopover, useListBox, useTooltip, useListState, HiddenSelect, I18nProvider, useMenuItem, useTreeState, useSeparator, useMenuSection, useMenuTrigger, useSelectState, useModalOverlay, useOverlayTrigger, useTooltipTrigger, useListBoxSection, useOverlayPosition, useMenuTriggerState, useToggleGroupState, useToggleButtonGroup, useOverlayTriggerState, useTooltipTriggerState, useToggleButtonGroupItem, useLocalizedStringFormatter, type Node, type TreeState, type ItemProps, type ListState, type PressEvent, type HoverEvent, 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, };
|
|
24
|
+
export { Item, Overlay, Section, useMenu, useLocale, useDialog, useOption, useSelect, usePopover, useListBox, useTooltip, useTag, useTagGroup, useListState, HiddenSelect, I18nProvider, useMenuItem, useListData, useTreeState, useSeparator, useMenuSection, useMenuTrigger, useSelectState, useModalOverlay, useOverlayTrigger, useTooltipTrigger, useListBoxSection, useOverlayPosition, useMenuTriggerState, useToggleGroupState, useToggleButtonGroup, useOverlayTriggerState, useTooltipTriggerState, useToggleButtonGroupItem, useLocalizedStringFormatter, type Node, type TreeState, type ItemProps, type AriaTagGroupProps, type AriaTagProps, type ListState, type PressEvent, type HoverEvent, 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, };
|
|
23
25
|
export * from './types';
|
|
24
26
|
export * from './utils';
|
package/dist/index.js
CHANGED
|
@@ -6,8 +6,10 @@ import { useMenu, useMenuItem, useMenuSection, useMenuTrigger } from "@react-ari
|
|
|
6
6
|
import { Overlay, useModalOverlay, useOverlayPosition, useOverlayTrigger, usePopover } from "@react-aria/overlays";
|
|
7
7
|
import { HiddenSelect, useSelect } from "@react-aria/select";
|
|
8
8
|
import { useSeparator } from "@react-aria/separator";
|
|
9
|
+
import { useTag, useTagGroup } from "@react-aria/tag";
|
|
9
10
|
import { useTooltip, useTooltipTrigger } from "@react-aria/tooltip";
|
|
10
11
|
import { Item, Section } from "@react-stately/collections";
|
|
12
|
+
import { useListData } from "@react-stately/data";
|
|
11
13
|
import { useListState } from "@react-stately/list";
|
|
12
14
|
import { useMenuTriggerState } from "@react-stately/menu";
|
|
13
15
|
import { useOverlayTriggerState } from "@react-stately/overlays";
|
|
@@ -85,6 +87,7 @@ export {
|
|
|
85
87
|
useLink,
|
|
86
88
|
useListBox,
|
|
87
89
|
useListBoxSection,
|
|
90
|
+
useListData,
|
|
88
91
|
useListState,
|
|
89
92
|
useLocale,
|
|
90
93
|
useLocalizedStringFormatter,
|
|
@@ -109,6 +112,8 @@ export {
|
|
|
109
112
|
useSelect,
|
|
110
113
|
useSelectState,
|
|
111
114
|
useSeparator,
|
|
115
|
+
useTag,
|
|
116
|
+
useTagGroup,
|
|
112
117
|
useTextField,
|
|
113
118
|
useTextareaContext,
|
|
114
119
|
useToggle,
|
package/dist/types.d.ts
CHANGED
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import type { ElementType } from 'react';
|
|
2
2
|
import type { AriaButtonOptions } from '@react-aria/button';
|
|
3
3
|
import type { AriaLinkOptions } from '@react-aria/link';
|
|
4
|
-
export type ButtonOptions =
|
|
5
|
-
|
|
6
|
-
disabled?: boolean;
|
|
7
|
-
};
|
|
8
|
-
export type LinkOptions = Omit<AriaLinkOptions, 'isDisabled'> & {
|
|
9
|
-
/** Whether the button is disabled. */
|
|
10
|
-
disabled?: boolean;
|
|
11
|
-
};
|
|
4
|
+
export type ButtonOptions = AriaButtonOptions<ElementType>;
|
|
5
|
+
export type LinkOptions = AriaLinkOptions;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@koobiq/react-primitives",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.22",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -36,11 +36,13 @@
|
|
|
36
36
|
"@react-aria/radio": "^3.10.9",
|
|
37
37
|
"@react-aria/select": "^3.15.3",
|
|
38
38
|
"@react-aria/separator": "^3.4.8",
|
|
39
|
+
"@react-aria/tag": "^3.6.0",
|
|
39
40
|
"@react-aria/textfield": "^3.14.0",
|
|
40
41
|
"@react-aria/toggle": "^3.10.10",
|
|
41
42
|
"@react-aria/tooltip": "^3.7.9",
|
|
42
43
|
"@react-aria/visually-hidden": "^3.8.0",
|
|
43
44
|
"@react-stately/collections": "^3.12.2",
|
|
45
|
+
"@react-stately/data": "^3.13.0",
|
|
44
46
|
"@react-stately/list": "^3.12.0",
|
|
45
47
|
"@react-stately/menu": "^3.9.3",
|
|
46
48
|
"@react-stately/numberfield": "^3.9.7",
|
|
@@ -50,8 +52,8 @@
|
|
|
50
52
|
"@react-stately/toggle": "^3.7.0",
|
|
51
53
|
"@react-stately/tooltip": "^3.4.13",
|
|
52
54
|
"@react-stately/tree": "^3.8.9",
|
|
53
|
-
"@koobiq/logger": "0.0.1-beta.
|
|
54
|
-
"@koobiq/react-core": "0.0.1-beta.
|
|
55
|
+
"@koobiq/logger": "0.0.1-beta.22",
|
|
56
|
+
"@koobiq/react-core": "0.0.1-beta.22"
|
|
55
57
|
},
|
|
56
58
|
"peerDependencies": {
|
|
57
59
|
"react": "18.x || 19.x",
|