@koobiq/react-primitives 0.0.1-beta.21 → 0.0.1-beta.23

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.
@@ -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
- pressed: boolean;
6
- hovered: boolean;
7
- focused: boolean;
8
- disabled: boolean | undefined;
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
- focusVisible: boolean;
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 { disabled, ...otherProps } = props;
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: hovered } = useHover({
14
- ...props,
15
- isDisabled: disabled
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
- pressed,
27
- hovered,
28
- focused,
29
- disabled,
16
+ isPressed,
17
+ isHovered,
18
+ isFocused,
19
+ isDisabled,
30
20
  buttonProps,
31
- focusVisible
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 = ExtendableProps<{
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
- pressed: boolean;
10
- hovered: boolean;
11
- focused: boolean;
12
- focusVisible: boolean;
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 { disabled, ...otherProps } = props;
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
- { disabled },
12
+ commonLinkProps,
20
13
  focusProps,
21
- hoverProps,
22
- commonLinkProps
14
+ hoverProps
23
15
  );
24
16
  return {
25
17
  linkProps,
26
- pressed: isPressed,
27
- hovered: isHovered,
28
- focused: isFocused,
29
- focusVisible: isFocusVisible
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
- loading,
15
- disabled,
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 { hovered, pressed, focused, focusVisible, buttonProps } = useButton(
26
+ const { isHovered, isPressed, isFocused, isFocusVisible, buttonProps } = useButton(
27
27
  {
28
28
  ...commonProps,
29
- ...(loading || disabled) && {
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
- hovered,
47
- pressed,
48
- focused,
49
- focusVisible,
50
- loading: loading || false,
51
- disabled: disabled || false
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": hovered,
73
- "data-pressed": pressed,
74
- "data-focused": focused,
75
- "data-disabled": disabled,
76
- "data-focus-visible": focusVisible,
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": loading ? "true" : buttonProps["aria-disabled"],
79
- "aria-busy": loading,
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
- hovered: boolean;
7
- focused: boolean;
8
- pressed: boolean;
9
- loading: boolean;
10
- disabled: boolean;
11
- focusVisible: boolean;
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
- loading?: boolean;
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", ...commonProps } = props;
8
- const { disabled } = commonProps;
7
+ const { as: Tag = "a", ...other } = props;
9
8
  const domRef = useDOMRef(ref);
10
- const { hovered, pressed, focused, focusVisible, linkProps } = useLink(
9
+ const { isHovered, isPressed, isFocusVisible, isFocused, linkProps } = useLink(
11
10
  {
12
- ...commonProps,
13
- ...disabled && {
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
- hovered,
30
- pressed,
31
- focused,
32
- focusVisible,
33
- disabled: props.disabled || false
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
- hovered: boolean;
6
- focused: boolean;
7
- pressed: boolean;
8
- disabled: boolean;
9
- focusVisible: boolean;
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/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 = Omit<AriaButtonOptions<ElementType>, 'isDisabled'> & {
5
- /** Whether the button is disabled. */
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.21",
3
+ "version": "0.0.1-beta.23",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -52,8 +52,8 @@
52
52
  "@react-stately/toggle": "^3.7.0",
53
53
  "@react-stately/tooltip": "^3.4.13",
54
54
  "@react-stately/tree": "^3.8.9",
55
- "@koobiq/logger": "0.0.1-beta.21",
56
- "@koobiq/react-core": "0.0.1-beta.21"
55
+ "@koobiq/logger": "0.0.1-beta.23",
56
+ "@koobiq/react-core": "0.0.1-beta.23"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": "18.x || 19.x",