@koobiq/react-primitives 0.27.1 → 0.28.0

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.
Files changed (34) hide show
  1. package/dist/behaviors/useButton.d.ts +4 -2
  2. package/dist/behaviors/useButton.js +17 -2
  3. package/dist/behaviors/useNumberField.d.ts +1 -1
  4. package/dist/components/Button/Button.js +1 -2
  5. package/dist/components/Button/index.d.ts +0 -1
  6. package/dist/components/Checkbox/Checkbox.d.ts +3 -2
  7. package/dist/components/Checkbox/Checkbox.js +4 -2
  8. package/dist/components/Checkbox/types.d.ts +1 -0
  9. package/dist/components/FieldError/FieldError.d.ts +2 -2
  10. package/dist/components/FieldError/FieldError.js +1 -1
  11. package/dist/components/Form/Form.d.ts +2 -1
  12. package/dist/components/Form/Form.js +1 -1
  13. package/dist/components/Group/Group.d.ts +1 -1
  14. package/dist/components/Group/Group.js +1 -1
  15. package/dist/components/Label/Label.js +1 -1
  16. package/dist/components/Link/Link.js +1 -1
  17. package/dist/components/NumberField/NumberField.d.ts +1 -1
  18. package/dist/components/NumberField/NumberField.js +3 -3
  19. package/dist/components/ProgressBar/ProgressBar.js +1 -1
  20. package/dist/components/Radio/Radio.d.ts +1 -1
  21. package/dist/components/Radio/Radio.js +2 -1
  22. package/dist/components/Radio/RadioGroup.d.ts +1 -1
  23. package/dist/components/Radio/RadioGroup.js +3 -2
  24. package/dist/components/Switch/Switch.d.ts +1 -1
  25. package/dist/components/Switch/Switch.js +2 -1
  26. package/dist/components/Text/Text.js +1 -1
  27. package/dist/components/TextField/TextField.js +3 -4
  28. package/dist/index.d.ts +3 -1
  29. package/dist/index.js +10 -3
  30. package/dist/utils/index.d.ts +2 -32
  31. package/dist/utils/index.js +1 -104
  32. package/package.json +4 -3
  33. package/dist/components/Button/ButtonContext.d.ts +0 -3
  34. package/dist/components/Button/ButtonContext.js +0 -6
@@ -1,7 +1,9 @@
1
1
  import type { ElementType, RefObject } from 'react';
2
- import type { DOMAttributes, HoverEvents } from '@koobiq/react-core';
2
+ import type { DOMAttributes, HoverEvents, RouterOptions } from '@koobiq/react-core';
3
3
  import type { AriaButtonOptions, ButtonAria } from '@react-aria/button';
4
- export type UseButtonProps<E extends ElementType> = AriaButtonOptions<E> & HoverEvents;
4
+ export type UseButtonProps<E extends ElementType> = AriaButtonOptions<E> & HoverEvents & {
5
+ routerOptions?: RouterOptions;
6
+ };
5
7
  export type ButtonOptions = AriaButtonOptions<ElementType>;
6
8
  export type UseButtonReturn = {
7
9
  isPressed: boolean;
@@ -1,8 +1,9 @@
1
1
  "use client";
2
- import { useFocusRing, useHover, mergeProps } from "@koobiq/react-core";
2
+ import { useFocusRing, useHover, useRouter, useLinkProps, mergeProps, handleLinkClick } from "@koobiq/react-core";
3
3
  import { useButton as useButton$1 } from "@react-aria/button";
4
4
  function useButton(props, ref) {
5
5
  const { isDisabled } = props;
6
+ const isLink = (props.elementType === "a" || !props.elementType && !!props.href) && !props.isDisabled;
6
7
  const { focusProps, isFocused, isFocusVisible } = useFocusRing({
7
8
  within: true
8
9
  });
@@ -14,7 +15,21 @@ function useButton(props, ref) {
14
15
  props,
15
16
  ref
16
17
  );
17
- const buttonProps = mergeProps(buttonPropsAria, focusProps, hoverProps);
18
+ const router = useRouter();
19
+ const routerLinkProps = useLinkProps(props);
20
+ const buttonProps = mergeProps(
21
+ buttonPropsAria,
22
+ focusProps,
23
+ hoverProps,
24
+ isLink ? routerLinkProps : void 0
25
+ );
26
+ const { onClick } = buttonProps;
27
+ buttonProps.onClick = (e) => {
28
+ onClick?.(e);
29
+ if (isLink) {
30
+ handleLinkClick(e, router, props.href, props.routerOptions);
31
+ }
32
+ };
18
33
  return {
19
34
  isPressed,
20
35
  isHovered,
@@ -1,5 +1,5 @@
1
1
  import type { RefObject } from 'react';
2
2
  import type { AriaNumberFieldProps } from '@react-aria/numberfield';
3
3
  export type UseNumberFieldProps = AriaNumberFieldProps;
4
- export declare function useNumberField(props: UseNumberFieldProps, ref: RefObject<HTMLInputElement | null>): import("@react-aria/numberfield").NumberFieldAria;
4
+ export declare function useNumberField(props: UseNumberFieldProps, ref: RefObject<HTMLInputElement | null>): import("react-aria").NumberFieldAria;
5
5
  export type UseNumberFieldReturn = ReturnType<typeof useNumberField>;
@@ -1,8 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { polymorphicForwardRef, useDOMRef, filterDOMProps, mergeProps } from "@koobiq/react-core";
4
- import { useContextProps, useRenderProps } from "../../utils/index.js";
5
- import { ButtonContext } from "./ButtonContext.js";
4
+ import { useContextProps, ButtonContext, useRenderProps } from "react-aria-components";
6
5
  import { useButton } from "../../behaviors/useButton.js";
7
6
  const Button = polymorphicForwardRef(
8
7
  (props, ref) => {
@@ -1,3 +1,2 @@
1
1
  export * from './Button.js';
2
2
  export * from './types.js';
3
- export * from './ButtonContext';
@@ -1,4 +1,5 @@
1
- import { type CheckboxRenderProps } from './index';
2
- export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<import("@react-types/checkbox").AriaCheckboxProps, keyof import("../..").RenderProps<CheckboxRenderProps> | "inputRef"> & import("../..").RenderProps<CheckboxRenderProps> & {
1
+ import type { CheckboxRenderProps } from './index';
2
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<import("react-aria").AriaCheckboxProps, "slot" | keyof import("../../utils").RenderProps<CheckboxRenderProps> | "inputRef"> & import("../../utils").RenderProps<CheckboxRenderProps> & {
3
3
  inputRef?: import("react").RefObject<HTMLInputElement | null>;
4
+ slot?: string;
4
5
  } & import("react").RefAttributes<HTMLLabelElement>>;
@@ -4,12 +4,14 @@ import { forwardRef, useContext } from "react";
4
4
  import { useDOMRef, filterDOMProps, mergeProps } from "@koobiq/react-core";
5
5
  import { VisuallyHidden } from "@react-aria/visually-hidden";
6
6
  import { useToggleState } from "@react-stately/toggle";
7
- import { removeDataAttributes, useRenderProps } from "../../utils/index.js";
7
+ import { useContextProps, CheckboxContext, useRenderProps } from "react-aria-components";
8
+ import { removeDataAttributes } from "../../utils/index.js";
8
9
  import { CheckboxGroupContext } from "./CheckboxGroupContext.js";
9
10
  import { useCheckboxGroupItem } from "../../behaviors/useCheckboxGroupItem.js";
10
11
  import { useCheckbox } from "../../behaviors/useCheckbox.js";
11
12
  const Checkbox = forwardRef(
12
- (props, ref) => {
13
+ (inProps, inRef) => {
14
+ const [props, ref] = useContextProps(inProps, inRef, CheckboxContext);
13
15
  const { children, inputRef } = props;
14
16
  const groupState = useContext(CheckboxGroupContext);
15
17
  const domRef = useDOMRef(inputRef);
@@ -15,6 +15,7 @@ export type CheckboxRenderProps = {
15
15
  };
16
16
  type CheckboxBaseProps = RenderProps<CheckboxRenderProps> & {
17
17
  inputRef?: RefObject<HTMLInputElement | null>;
18
+ slot?: string;
18
19
  };
19
20
  export type CheckboxProps = ExtendableProps<CheckboxBaseProps, UseCheckboxProps>;
20
21
  export {};
@@ -1,6 +1,6 @@
1
- import { type ComponentPropsWithRef, type ElementType } from 'react';
1
+ import type { ComponentPropsWithRef, ElementType } from 'react';
2
2
  import type { ValidationResult } from '@koobiq/react-core';
3
- import { type RenderProps } from '../../utils';
3
+ import type { RenderProps } from 'react-aria-components';
4
4
  export declare const FieldErrorContext: import("react").Context<ValidationResult | null>;
5
5
  export type FieldErrorRenderProps = ValidationResult;
6
6
  export type FieldErrorBaseProps = RenderProps<FieldErrorRenderProps>;
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { createContext, useContext } from "react";
3
3
  import { polymorphicForwardRef, isNotNil } from "@koobiq/react-core";
4
- import { useRenderProps } from "../../utils/index.js";
4
+ import { useRenderProps } from "react-aria-components";
5
5
  import { Text } from "../Text/Text.js";
6
6
  const FieldErrorContext = createContext(null);
7
7
  const FieldError = polymorphicForwardRef(
@@ -1,5 +1,6 @@
1
1
  import type { GlobalDOMAttributes, FormProps as SharedFormProps } from '@koobiq/react-core';
2
- import type { ContextValue, DOMProps } from '../../utils';
2
+ import type { ContextValue } from 'react-aria-components';
3
+ import type { DOMProps } from '../../utils';
3
4
  export interface FormProps extends SharedFormProps, DOMProps, GlobalDOMAttributes<HTMLFormElement> {
4
5
  /**
5
6
  * Whether to use native HTML form validation to prevent form submission
@@ -1,7 +1,7 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { createContext, forwardRef } from "react";
3
3
  import { FormValidationContext } from "@react-stately/form";
4
- import { useContextProps } from "../../utils/index.js";
4
+ import { useContextProps } from "react-aria-components";
5
5
  const FormContext = createContext(null);
6
6
  const Form = forwardRef(function Form2(props, ref) {
7
7
  [props, ref] = useContextProps(props, ref, FormContext);
@@ -1,2 +1,2 @@
1
- import { type GroupProps } from './index';
1
+ import type { GroupProps } from './index';
2
2
  export declare const Group: import("react").ForwardRefExoticComponent<Omit<GroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
@@ -2,7 +2,7 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
4
  import { mergeProps, useHover, useFocusRing, useMultiRef } from "@koobiq/react-core";
5
- import { useRenderProps } from "../../utils/index.js";
5
+ import { useRenderProps } from "react-aria-components";
6
6
  import { useGroupContext } from "./GroupContext.js";
7
7
  const Group = forwardRef((props, ref) => {
8
8
  const defaultProps = useGroupContext();
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { polymorphicForwardRef } from "@koobiq/react-core";
4
- import { useContextProps } from "../../utils/index.js";
4
+ import { useContextProps } from "react-aria-components";
5
5
  import { LabelContext } from "./LabelContext.js";
6
6
  const Label = polymorphicForwardRef(
7
7
  (props, ref) => {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { polymorphicForwardRef, useObjectRef, filterDOMProps, mergeProps } from "@koobiq/react-core";
4
- import { useRenderProps } from "../../utils/index.js";
4
+ import { useRenderProps } from "react-aria-components";
5
5
  import { useLink } from "../../behaviors/useLink.js";
6
6
  const Link = polymorphicForwardRef((props, ref) => {
7
7
  const { as: Tag = "a", ...other } = props;
@@ -1 +1 @@
1
- export declare const NumberField: import("react").ForwardRefExoticComponent<Omit<import("@react-types/numberfield").AriaNumberFieldProps & Pick<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "form" | "name" | "disabled">, keyof import("../..").RenderProps<import("./types").NumberFieldRenderProps>> & import("../..").RenderProps<import("./types").NumberFieldRenderProps> & import("react").RefAttributes<HTMLDivElement>>;
1
+ export declare const NumberField: import("react").ForwardRefExoticComponent<Omit<import("react-aria").AriaNumberFieldProps & Pick<Omit<import("react").DetailedHTMLProps<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>, "ref">, "form" | "name" | "disabled">, keyof import("../../utils").RenderProps<import("./types").NumberFieldRenderProps>> & import("../../utils").RenderProps<import("./types").NumberFieldRenderProps> & import("react").RefAttributes<HTMLDivElement>>;
@@ -5,14 +5,14 @@ import { filterDOMProps } from "@koobiq/react-core";
5
5
  import { useLocale } from "@react-aria/i18n";
6
6
  import { useNumberField } from "@react-aria/numberfield";
7
7
  import { useNumberFieldState } from "@react-stately/numberfield";
8
- import { useSlottedContext, removeDataAttributes, useRenderProps, Provider, DEFAULT_SLOT } from "../../utils/index.js";
8
+ import { useSlottedContext, useRenderProps, Provider, ButtonContext, DEFAULT_SLOT } from "react-aria-components";
9
+ import { removeDataAttributes } from "../../utils/index.js";
9
10
  import { GroupContext } from "../Group/GroupContext.js";
11
+ import { FormContext } from "../Form/Form.js";
10
12
  import { LabelContext } from "../Label/LabelContext.js";
11
13
  import { InputContext } from "../Input/InputContext.js";
12
- import { ButtonContext } from "../Button/ButtonContext.js";
13
14
  import { TextContext } from "../Text/TextContext.js";
14
15
  import { FieldErrorContext } from "../FieldError/FieldError.js";
15
- import { FormContext } from "../Form/Form.js";
16
16
  const NumberField = forwardRef(
17
17
  (props, ref) => {
18
18
  const { isDisabled, isReadOnly, isRequired } = props;
@@ -2,7 +2,7 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { polymorphicForwardRef, mergeProps } from "@koobiq/react-core";
4
4
  import { useProgressBar } from "@react-aria/progress";
5
- import { useRenderProps, Provider } from "../../utils/index.js";
5
+ import { useRenderProps, Provider } from "react-aria-components";
6
6
  import { LabelContext } from "../Label/LabelContext.js";
7
7
  const ProgressBar = polymorphicForwardRef(
8
8
  (props, ref) => {
@@ -1,4 +1,4 @@
1
1
  import type { RadioRenderProps } from './index';
2
- export declare const Radio: import("react").ForwardRefExoticComponent<Omit<import("@react-types/radio").AriaRadioProps, "inputRef" | keyof import("../..").RenderProps<RadioRenderProps>> & import("../..").RenderProps<RadioRenderProps> & {
2
+ export declare const Radio: import("react").ForwardRefExoticComponent<Omit<import("react-aria").AriaRadioProps, "inputRef" | keyof import("../../utils").RenderProps<RadioRenderProps>> & import("../../utils").RenderProps<RadioRenderProps> & {
3
3
  inputRef?: import("react").RefObject<HTMLInputElement | null>;
4
4
  } & import("react").RefAttributes<HTMLLabelElement>>;
@@ -3,7 +3,8 @@ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import { forwardRef, useContext } from "react";
4
4
  import { useDOMRef, filterDOMProps, mergeProps } from "@koobiq/react-core";
5
5
  import { VisuallyHidden } from "@react-aria/visually-hidden";
6
- import { removeDataAttributes, useRenderProps } from "../../utils/index.js";
6
+ import { useRenderProps } from "react-aria-components";
7
+ import { removeDataAttributes } from "../../utils/index.js";
7
8
  import { RadioContext } from "./RadioContext.js";
8
9
  import { useRadio } from "../../behaviors/useRadio.js";
9
10
  const Radio = forwardRef(
@@ -1 +1 @@
1
- export declare const RadioGroup: import("react").ForwardRefExoticComponent<Omit<import("@react-types/radio").AriaRadioGroupProps, keyof import("../..").RenderProps<import("./types").RadioGroupRenderProps>> & import("../..").RenderProps<import("./types").RadioGroupRenderProps> & import("react").RefAttributes<HTMLDivElement>>;
1
+ export declare const RadioGroup: import("react").ForwardRefExoticComponent<Omit<import("react-aria").AriaRadioGroupProps, keyof import("../../utils").RenderProps<import("./types").RadioGroupRenderProps>> & import("../../utils").RenderProps<import("./types").RadioGroupRenderProps> & import("react").RefAttributes<HTMLDivElement>>;
@@ -2,11 +2,12 @@
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
4
  import { filterDOMProps } from "@koobiq/react-core";
5
- import { useSlottedContext, removeDataAttributes, useRenderProps, Provider, DEFAULT_SLOT } from "../../utils/index.js";
5
+ import { useSlottedContext, useRenderProps, Provider } from "react-aria-components";
6
+ import { removeDataAttributes, DEFAULT_SLOT } from "../../utils/index.js";
6
7
  import { useRadioGroupState } from "../../behaviors/useRadioGroupState.js";
8
+ import { FormContext } from "../Form/Form.js";
7
9
  import { useRadioGroup } from "../../behaviors/useRadioGroup.js";
8
10
  import { FieldErrorContext } from "../FieldError/FieldError.js";
9
- import { FormContext } from "../Form/Form.js";
10
11
  import { RadioContext } from "./RadioContext.js";
11
12
  import { LabelContext } from "../Label/LabelContext.js";
12
13
  import { TextContext } from "../Text/TextContext.js";
@@ -1,4 +1,4 @@
1
1
  import type { SwitchRenderProps } from './index';
2
- export declare const Switch: import("react").ForwardRefExoticComponent<Omit<import("../..").UseSwitchProps, "inputRef" | keyof import("../..").RenderProps<SwitchRenderProps>> & import("../..").RenderProps<SwitchRenderProps> & {
2
+ export declare const Switch: import("react").ForwardRefExoticComponent<Omit<import("../..").UseSwitchProps, "inputRef" | keyof import("../../utils").RenderProps<SwitchRenderProps>> & import("../../utils").RenderProps<SwitchRenderProps> & {
3
3
  inputRef?: import("react").RefObject<HTMLInputElement | null>;
4
4
  } & import("react").RefAttributes<HTMLLabelElement>>;
@@ -3,7 +3,8 @@ import { jsxs, jsx } from "react/jsx-runtime";
3
3
  import { forwardRef } from "react";
4
4
  import { useDOMRef, filterDOMProps, mergeProps } from "@koobiq/react-core";
5
5
  import { VisuallyHidden } from "@react-aria/visually-hidden";
6
- import { removeDataAttributes, useRenderProps } from "../../utils/index.js";
6
+ import { useRenderProps } from "react-aria-components";
7
+ import { removeDataAttributes } from "../../utils/index.js";
7
8
  import { useSwitch } from "../../behaviors/useSwitch.js";
8
9
  const Switch = forwardRef(
9
10
  (props, ref) => {
@@ -1,7 +1,7 @@
1
1
  "use client";
2
2
  import { jsx } from "react/jsx-runtime";
3
3
  import { polymorphicForwardRef } from "@koobiq/react-core";
4
- import { useContextProps } from "../../utils/index.js";
4
+ import { useContextProps } from "react-aria-components";
5
5
  import { TextContext } from "./TextContext.js";
6
6
  const Text = polymorphicForwardRef((props, ref) => {
7
7
  const [ctxProps, ctxRef] = useContextProps(props, ref, TextContext);
@@ -3,11 +3,11 @@ import { jsx } from "react/jsx-runtime";
3
3
  import { forwardRef, useRef, useCallback } from "react";
4
4
  import { useLocalizedStringFormatter, useControlledState, useIsomorphicEffect, filterDOMProps } from "@koobiq/react-core";
5
5
  import { useTextField } from "@react-aria/textfield";
6
- import { useSlottedContext, removeDataAttributes, useRenderProps, Provider, DEFAULT_SLOT } from "../../utils/index.js";
6
+ import { useSlottedContext, useRenderProps, Provider, ButtonContext, DEFAULT_SLOT } from "react-aria-components";
7
+ import { removeDataAttributes } from "../../utils/index.js";
7
8
  import intlMessages from "./intl.json.js";
8
9
  import { InputContext } from "../Input/InputContext.js";
9
10
  import { TextareaContext } from "../Textarea/TextareaContext.js";
10
- import { ButtonContext } from "../Button/ButtonContext.js";
11
11
  import { FormContext } from "../Form/Form.js";
12
12
  import { LabelContext } from "../Label/LabelContext.js";
13
13
  import { TextContext } from "../Text/TextContext.js";
@@ -113,8 +113,7 @@ function TextFieldRender(props, ref) {
113
113
  "clear-button": {
114
114
  "aria-label": stringFormatter.format("clear"),
115
115
  preventFocusOnPress: true,
116
- onPress: handleClear,
117
- tabIndex: -1
116
+ onPress: handleClear
118
117
  }
119
118
  }
120
119
  }
package/dist/index.d.ts CHANGED
@@ -47,6 +47,8 @@ export { useCalendar, useCalendarCell, useCalendarGrid, } from '@react-aria/cale
47
47
  export * from '@react-stately/calendar';
48
48
  export * from '@react-stately/form';
49
49
  export * from '@react-aria/selection';
50
+ export type { ContextValue, TreeProps, TreeRenderProps, TreeItemProps, TreeItemRenderProps, TreeItemContentProps, TreeItemContentRenderProps, TreeLoadMoreItemProps, TreeLoadMoreItemRenderProps, } from 'react-aria-components';
51
+ export { Tree, Provider, TreeItem, TreeContext, Collection, TreeItemContent, ButtonContext, TreeStateContext, TreeLoadMoreItem, useContextProps, DEFAULT_SLOT, useSlottedContext, composeRenderProps, } from 'react-aria-components';
50
52
  export * from './behaviors';
51
53
  export * from './components';
52
- export * from './utils';
54
+ export { removeDataAttributes } from './utils';
package/dist/index.js CHANGED
@@ -45,7 +45,8 @@ import { useCalendar, useCalendarCell, useCalendarGrid } from "@react-aria/calen
45
45
  export * from "@react-stately/calendar";
46
46
  export * from "@react-stately/form";
47
47
  export * from "@react-aria/selection";
48
- import { DEFAULT_SLOT, Provider, removeDataAttributes, useContextProps, useRenderProps, useSlottedContext } from "./utils/index.js";
48
+ import { ButtonContext, Collection, DEFAULT_SLOT, Provider, Tree, TreeContext, TreeItem, TreeItemContent, TreeLoadMoreItem, TreeStateContext, composeRenderProps, useContextProps, useSlottedContext } from "react-aria-components";
49
+ import { removeDataAttributes } from "./utils/index.js";
49
50
  import { useButton } from "./behaviors/useButton.js";
50
51
  import { useCheckbox } from "./behaviors/useCheckbox.js";
51
52
  import { useCheckboxGroupItem } from "./behaviors/useCheckboxGroupItem.js";
@@ -63,7 +64,6 @@ import { TextContext } from "./components/Text/TextContext.js";
63
64
  import { Group } from "./components/Group/Group.js";
64
65
  import { GroupContext, useGroupContext } from "./components/Group/GroupContext.js";
65
66
  import { Button } from "./components/Button/Button.js";
66
- import { ButtonContext } from "./components/Button/ButtonContext.js";
67
67
  import { Checkbox } from "./components/Checkbox/Checkbox.js";
68
68
  import { CheckboxGroupContext } from "./components/Checkbox/CheckboxGroupContext.js";
69
69
  import { Link } from "./components/Link/Link.js";
@@ -87,6 +87,7 @@ export {
87
87
  ButtonContext,
88
88
  Checkbox,
89
89
  CheckboxGroupContext,
90
+ Collection,
90
91
  DEFAULT_SLOT,
91
92
  FieldError,
92
93
  FieldErrorContext,
@@ -112,6 +113,13 @@ export {
112
113
  TextField,
113
114
  Textarea,
114
115
  TextareaContext,
116
+ Tree,
117
+ TreeContext,
118
+ TreeItem,
119
+ TreeItemContent,
120
+ TreeLoadMoreItem,
121
+ TreeStateContext,
122
+ composeRenderProps,
115
123
  removeDataAttributes,
116
124
  useAutocomplete,
117
125
  useAutocompleteState,
@@ -135,7 +143,6 @@ export {
135
143
  useRadio,
136
144
  useRadioGroup,
137
145
  useRadioGroupState,
138
- useRenderProps,
139
146
  useSlottedContext,
140
147
  useSwitch,
141
148
  useTextareaContext,
@@ -1,16 +1,9 @@
1
- import type { JSX, CSSProperties, ReactNode, Context, ForwardedRef } from 'react';
2
- import type { AriaLabelingProps, DOMProps as SharedDOMProps, RefObject } from '@koobiq/react-core';
1
+ import type { CSSProperties, ReactNode, ForwardedRef } from 'react';
2
+ import type { DOMProps as SharedDOMProps } from '@koobiq/react-core';
3
3
  export declare const DEFAULT_SLOT: unique symbol;
4
4
  interface SlottedValue<T> {
5
5
  slots?: Record<string | symbol, T>;
6
6
  }
7
- export interface SlotProps {
8
- /**
9
- * A slot name for the component. Slots allow the component to receive props from a parent component.
10
- * An explicit `null` value indicates that the local props completely override all props received from a parent.
11
- */
12
- slot?: string | null;
13
- }
14
7
  export type WithRef<T, E> = T & {
15
8
  ref?: ForwardedRef<E>;
16
9
  };
@@ -42,28 +35,5 @@ export interface RenderProps<T> extends StyleRenderProps<T> {
42
35
  defaultChildren: ReactNode | undefined;
43
36
  }) => ReactNode);
44
37
  }
45
- interface RenderPropsHookOptions<T> extends RenderProps<T>, SharedDOMProps, AriaLabelingProps {
46
- values: T;
47
- defaultChildren?: ReactNode;
48
- defaultClassName?: string;
49
- defaultStyle?: CSSProperties;
50
- }
51
- export type UserRenderPropsReturn = {
52
- className: string | undefined;
53
- style: CSSProperties | undefined;
54
- children: ReactNode | undefined;
55
- };
56
- export declare function useRenderProps<T>(props: RenderPropsHookOptions<T>): UserRenderPropsReturn;
57
- type ProviderValue<T> = [Context<T>, T];
58
- type ProviderValues<T extends unknown[]> = {
59
- [K in keyof T]: ProviderValue<T[K]>;
60
- };
61
- interface ProviderProps<T extends unknown[]> {
62
- values: ProviderValues<T>;
63
- children: ReactNode;
64
- }
65
- export declare function Provider<T extends unknown[]>({ values, children, }: ProviderProps<T>): JSX.Element;
66
38
  export declare function removeDataAttributes<T>(props: T): T;
67
- export declare function useSlottedContext<T>(context: Context<SlottedContextValue<T>>, slot?: string | null): T | null | undefined;
68
- export declare function useContextProps<T, U extends SlotProps, E extends Element>(props: T & SlotProps, ref: ForwardedRef<E> | undefined, context: Context<ContextValue<U, E>>): [T, RefObject<E | null>];
69
39
  export {};
@@ -1,62 +1,4 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { useMemo, useContext } from "react";
3
- import { useObjectRef, mergeRefs, mergeProps } from "@koobiq/react-core";
4
1
  const DEFAULT_SLOT = Symbol("default");
5
- function useRenderProps(props) {
6
- const {
7
- className,
8
- style,
9
- children,
10
- defaultClassName = void 0,
11
- defaultChildren = void 0,
12
- defaultStyle,
13
- values
14
- } = props;
15
- return useMemo(() => {
16
- let computedClassName;
17
- let computedStyle;
18
- let computedChildren;
19
- if (typeof className === "function") {
20
- computedClassName = className({ ...values, defaultClassName });
21
- } else {
22
- computedClassName = className;
23
- }
24
- if (typeof style === "function") {
25
- computedStyle = style({ ...values, defaultStyle: defaultStyle || {} });
26
- } else {
27
- computedStyle = style;
28
- }
29
- if (typeof children === "function") {
30
- computedChildren = children({ ...values, defaultChildren });
31
- } else if (children == null) {
32
- computedChildren = defaultChildren;
33
- } else {
34
- computedChildren = children;
35
- }
36
- return {
37
- className: computedClassName ?? defaultClassName,
38
- style: computedStyle || defaultStyle ? { ...defaultStyle, ...computedStyle } : void 0,
39
- children: computedChildren ?? defaultChildren
40
- };
41
- }, [
42
- className,
43
- style,
44
- children,
45
- defaultClassName,
46
- defaultChildren,
47
- defaultStyle,
48
- values
49
- ]);
50
- }
51
- function Provider({
52
- values,
53
- children
54
- }) {
55
- return values.reduceRight(
56
- (acc, [Context, value]) => /* @__PURE__ */ jsx(Context.Provider, { value, children: acc }),
57
- children
58
- );
59
- }
60
2
  function removeDataAttributes(props) {
61
3
  const prefix = /^(data-.*)$/;
62
4
  const filteredProps = {};
@@ -67,52 +9,7 @@ function removeDataAttributes(props) {
67
9
  }
68
10
  return filteredProps;
69
11
  }
70
- function useSlottedContext(context, slot) {
71
- const ctx = useContext(context);
72
- if (slot === null) {
73
- return null;
74
- }
75
- if (ctx && typeof ctx === "object" && "slots" in ctx && ctx.slots) {
76
- const slotKey = slot || DEFAULT_SLOT;
77
- if (!ctx.slots[slotKey]) {
78
- const availableSlots = new Intl.ListFormat().format(
79
- Object.keys(ctx.slots).map((p) => `"${p}"`)
80
- );
81
- const errorMessage = slot ? `Invalid slot "${slot}".` : "A slot prop is required.";
82
- throw new Error(
83
- `${errorMessage} Valid slot names are ${availableSlots}.`
84
- );
85
- }
86
- return ctx.slots[slotKey];
87
- }
88
- return ctx;
89
- }
90
- function useContextProps(props, ref, context) {
91
- const ctx = useSlottedContext(context, props.slot) || {};
92
- const { ref: contextRef, ...contextProps } = ctx;
93
- const mergedRef = useObjectRef(
94
- useMemo(() => mergeRefs(ref, contextRef), [ref, contextRef])
95
- );
96
- const mergedProps = mergeProps(contextProps, props);
97
- if ("style" in contextProps && contextProps.style && "style" in props && props.style) {
98
- if (typeof contextProps.style === "function" || typeof props.style === "function") {
99
- mergedProps.style = (renderProps) => {
100
- const contextStyle = typeof contextProps.style === "function" ? contextProps.style(renderProps) : contextProps.style;
101
- const defaultStyle = { ...renderProps.defaultStyle, ...contextStyle };
102
- const style = typeof props.style === "function" ? props.style({ ...renderProps, defaultStyle }) : props.style;
103
- return { ...defaultStyle, ...style };
104
- };
105
- } else {
106
- mergedProps.style = { ...contextProps.style, ...props.style };
107
- }
108
- }
109
- return [mergedProps, mergedRef];
110
- }
111
12
  export {
112
13
  DEFAULT_SLOT,
113
- Provider,
114
- removeDataAttributes,
115
- useContextProps,
116
- useRenderProps,
117
- useSlottedContext
14
+ removeDataAttributes
118
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-primitives",
3
- "version": "0.27.1",
3
+ "version": "0.28.0",
4
4
  "license": "MIT",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -77,8 +77,9 @@
77
77
  "@react-stately/toggle": "^3.9.4",
78
78
  "@react-stately/tooltip": "^3.5.10",
79
79
  "@react-stately/tree": "^3.9.5",
80
- "@koobiq/react-core": "0.27.1",
81
- "@koobiq/logger": "0.27.1"
80
+ "react-aria-components": "^1.15.1",
81
+ "@koobiq/logger": "0.28.0",
82
+ "@koobiq/react-core": "0.28.0"
82
83
  },
83
84
  "peerDependencies": {
84
85
  "react": "18.x || 19.x",
@@ -1,3 +0,0 @@
1
- import type { ContextValue } from '../../utils';
2
- import type { ButtonProps } from './index';
3
- export declare const ButtonContext: import("react").Context<ContextValue<ButtonProps, HTMLElement>>;
@@ -1,6 +0,0 @@
1
- "use client";
2
- import { createContext } from "react";
3
- const ButtonContext = createContext({});
4
- export {
5
- ButtonContext
6
- };