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

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.
@@ -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 = ExtendableProps<{
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
- indeterminate: boolean | undefined;
47
- error: boolean;
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>;
@@ -2,23 +2,10 @@
2
2
  import { useToggleState, useHover, useFocusRing, mergeProps } from "@koobiq/react-core";
3
3
  import { useCheckbox as useCheckbox$1 } from "@react-aria/checkbox";
4
4
  function useCheckbox(props, inputRef) {
5
- const {
6
- error,
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
- });
5
+ const { isDisabled: isDisabledProp, isIndeterminate: isIndeterminateProp } = props;
6
+ const state = useToggleState(props);
20
7
  const { hoverProps, isHovered } = useHover({
21
- isDisabled: disabled
8
+ isDisabled: isDisabledProp
22
9
  });
23
10
  const { focusProps, isFocused, isFocusVisible } = useFocusRing();
24
11
  const {
@@ -30,34 +17,23 @@ function useCheckbox(props, inputRef) {
30
17
  isReadOnly,
31
18
  isPressed,
32
19
  ...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
- );
20
+ } = useCheckbox$1(props, state, inputRef);
45
21
  const labelProps = mergeProps(hoverProps, commonLabelProps);
46
22
  const inputProps = mergeProps(focusProps, commonInputProps, {
47
23
  ref: inputRef
48
24
  });
49
25
  return {
26
+ isInvalid,
27
+ isPressed,
28
+ isHovered,
29
+ isFocused,
30
+ isSelected,
31
+ isDisabled,
32
+ isReadOnly,
50
33
  labelProps,
51
34
  inputProps,
52
- indeterminate,
53
- error: isInvalid,
54
- pressed: isPressed,
55
- hovered: isHovered,
56
- focused: isFocused,
57
- checked: isSelected,
58
- disabled: isDisabled,
59
- readonly: isReadOnly,
60
- focusVisible: isFocusVisible,
35
+ isFocusVisible,
36
+ isIndeterminate: isIndeterminateProp,
61
37
  ...other
62
38
  };
63
39
  }
@@ -1,3 +1,3 @@
1
- export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<import("../..").UseCheckboxProps, keyof import("../..").RenderProps<import("./types").CheckboxRenderProps> | "inputRef"> & import("../..").RenderProps<import("./types").CheckboxRenderProps> & {
1
+ export declare const Checkbox: import("react").ForwardRefExoticComponent<Omit<import("@react-types/checkbox").AriaCheckboxProps, keyof import("../..").RenderProps<import("./types").CheckboxRenderProps> | "inputRef"> & import("../..").RenderProps<import("./types").CheckboxRenderProps> & {
2
2
  inputRef?: import("react").RefObject<HTMLInputElement | null>;
3
3
  } & import("react").RefAttributes<HTMLLabelElement>>;
@@ -10,13 +10,15 @@ const Checkbox = forwardRef(
10
10
  const { children, inputRef } = props;
11
11
  const domRef = useDOMRef(inputRef);
12
12
  const {
13
- hovered,
14
- error,
15
- checked,
16
- focused,
17
- pressed,
18
- focusVisible,
19
- indeterminate,
13
+ isHovered,
14
+ isInvalid,
15
+ isSelected,
16
+ isFocused,
17
+ isPressed,
18
+ isReadOnly,
19
+ isDisabled,
20
+ isFocusVisible,
21
+ isIndeterminate,
20
22
  labelProps,
21
23
  inputProps
22
24
  } = useCheckbox(
@@ -27,14 +29,14 @@ const Checkbox = forwardRef(
27
29
  domRef
28
30
  );
29
31
  const renderValues = {
30
- hovered,
31
- error,
32
- checked,
33
- focused,
34
- pressed,
35
- focusVisible,
36
- indeterminate,
37
- disabled: props.disabled || false
32
+ isHovered,
33
+ isInvalid,
34
+ isSelected,
35
+ isFocused,
36
+ isPressed,
37
+ isFocusVisible,
38
+ isIndeterminate,
39
+ isDisabled: props.isDisabled || false
38
40
  };
39
41
  const renderProps = useRenderProps({
40
42
  ...props,
@@ -42,10 +44,25 @@ const Checkbox = forwardRef(
42
44
  });
43
45
  const DOMProps = filterDOMProps(props);
44
46
  delete DOMProps.id;
45
- return /* @__PURE__ */ jsxs("label", { ...mergeProps(DOMProps, labelProps, renderProps), ref, children: [
46
- /* @__PURE__ */ jsx(VisuallyHidden, { elementType: "span", children: /* @__PURE__ */ jsx("input", { ...inputProps, ref: domRef }) }),
47
- renderProps.children
48
- ] });
47
+ return /* @__PURE__ */ jsxs(
48
+ "label",
49
+ {
50
+ "data-hovered": isHovered,
51
+ "data-pressed": isPressed,
52
+ "data-focused": isFocused,
53
+ "data-invalid": isInvalid,
54
+ "data-selected": isSelected,
55
+ "data-disabled": isDisabled,
56
+ "data-read-only": isReadOnly,
57
+ "data-focus-visible": isFocusVisible,
58
+ ...mergeProps(DOMProps, labelProps, renderProps),
59
+ ref,
60
+ children: [
61
+ /* @__PURE__ */ jsx(VisuallyHidden, { elementType: "span", children: /* @__PURE__ */ jsx("input", { ...inputProps, ref: domRef }) }),
62
+ renderProps.children
63
+ ]
64
+ }
65
+ );
49
66
  }
50
67
  );
51
68
  Checkbox.displayName = "Checkbox";
@@ -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
- error?: boolean;
7
- pressed?: boolean;
8
- checked?: boolean;
9
- hovered?: boolean;
10
- focused?: boolean;
11
- disabled?: boolean;
12
- focusVisible?: boolean;
13
- indeterminate?: boolean;
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>;
package/dist/index.d.ts CHANGED
@@ -6,14 +6,17 @@ 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 { useTable, useTableCell, useTableRow, useTableHeaderRow, useTableSelectAllCheckbox, useTableSelectionCheckbox, useTableColumnHeader, useTableRowGroup, type AriaTableProps, type AriaTableCellProps, type GridRowProps, type AriaTableColumnHeaderProps } from '@react-aria/table';
9
10
  import { useTag, useTagGroup, type AriaTagGroupProps, type AriaTagProps } from '@react-aria/tag';
10
11
  import { useTooltip, useTooltipTrigger } from '@react-aria/tooltip';
12
+ import { VisuallyHidden } from '@react-aria/visually-hidden';
11
13
  import { Item, Section } from '@react-stately/collections';
12
14
  import { useListData } from '@react-stately/data';
13
15
  import { useListState, type ListState } from '@react-stately/list';
14
16
  import { useMenuTriggerState } from '@react-stately/menu';
15
17
  import { useOverlayTriggerState, type OverlayTriggerState } from '@react-stately/overlays';
16
18
  import { useSelectState } from '@react-stately/select';
19
+ 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';
17
20
  import { useToggleGroupState, type ToggleGroupState } from '@react-stately/toggle';
18
21
  import type { TooltipTriggerProps } from '@react-stately/tooltip';
19
22
  import { useTooltipTriggerState } from '@react-stately/tooltip';
@@ -21,6 +24,6 @@ import { useTreeState, type TreeState } from '@react-stately/tree';
21
24
  import type { Node, PressEvent, HoverEvent, ItemProps, SectionProps, LinkDOMProps, FocusableElement } from '@react-types/shared';
22
25
  export * from './behaviors/index.js';
23
26
  export * from './components/index.js';
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, };
27
+ 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, useTreeState, useSeparator, useTableState, useMenuSection, useMenuTrigger, useSelectState, useModalOverlay, useOverlayTrigger, useTooltipTrigger, useListBoxSection, useOverlayPosition, useTableCell, useTableRow, useTableHeaderRow, useTableColumnHeader, useTableSelectAllCheckbox, useTableSelectionCheckbox, useTableRowGroup, useMenuTriggerState, useToggleGroupState, useToggleButtonGroup, useOverlayTriggerState, useTooltipTriggerState, useToggleButtonGroupItem, useLocalizedStringFormatter, VisuallyHidden, type Node, type TableState, type TreeState, type TableHeaderProps, type TableBodyProps, type ItemProps, type CellProps, type ColumnProps, type RowProps, type GridRowProps, type AriaTableColumnHeaderProps, type AriaTableCellProps, type AriaTableProps, type TableStateProps, 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, };
25
28
  export * from './types';
26
29
  export * from './utils';
package/dist/index.js CHANGED
@@ -6,14 +6,17 @@ 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 { useTable, useTableCell, useTableColumnHeader, useTableHeaderRow, useTableRow, useTableRowGroup, useTableSelectAllCheckbox, useTableSelectionCheckbox } from "@react-aria/table";
9
10
  import { useTag, useTagGroup } from "@react-aria/tag";
10
11
  import { useTooltip, useTooltipTrigger } from "@react-aria/tooltip";
12
+ import { VisuallyHidden } from "@react-aria/visually-hidden";
11
13
  import { Item, Section } from "@react-stately/collections";
12
14
  import { useListData } from "@react-stately/data";
13
15
  import { useListState } from "@react-stately/list";
14
16
  import { useMenuTriggerState } from "@react-stately/menu";
15
17
  import { useOverlayTriggerState } from "@react-stately/overlays";
16
18
  import { useSelectState } from "@react-stately/select";
19
+ import { Cell, Column, Row, TableBody, TableHeader, useTableState } from "@react-stately/table";
17
20
  import { useToggleGroupState } from "@react-stately/toggle";
18
21
  import { useTooltipTriggerState } from "@react-stately/tooltip";
19
22
  import { useTreeState } from "@react-stately/tree";
@@ -53,7 +56,9 @@ import { NumberField } from "./components/NumberField/NumberField.js";
53
56
  export {
54
57
  Button,
55
58
  ButtonContext,
59
+ Cell,
56
60
  Checkbox,
61
+ Column,
57
62
  Group,
58
63
  GroupContext,
59
64
  HiddenSelect,
@@ -71,13 +76,17 @@ export {
71
76
  Radio,
72
77
  RadioContext,
73
78
  RadioGroup,
79
+ Row,
74
80
  Section,
81
+ TableBody,
82
+ TableHeader,
75
83
  Text,
76
84
  TextContext,
77
85
  TextField,
78
86
  Textarea,
79
87
  TextareaContext,
80
88
  Toggle,
89
+ VisuallyHidden,
81
90
  removeDataAttributes,
82
91
  useButton,
83
92
  useCheckbox,
@@ -112,6 +121,15 @@ export {
112
121
  useSelect,
113
122
  useSelectState,
114
123
  useSeparator,
124
+ useTable,
125
+ useTableCell,
126
+ useTableColumnHeader,
127
+ useTableHeaderRow,
128
+ useTableRow,
129
+ useTableRowGroup,
130
+ useTableSelectAllCheckbox,
131
+ useTableSelectionCheckbox,
132
+ useTableState,
115
133
  useTag,
116
134
  useTagGroup,
117
135
  useTextField,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@koobiq/react-primitives",
3
- "version": "0.0.1-beta.23",
3
+ "version": "0.0.1-beta.25",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -36,6 +36,7 @@
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/table": "^3.17.3",
39
40
  "@react-aria/tag": "^3.6.0",
40
41
  "@react-aria/textfield": "^3.14.0",
41
42
  "@react-aria/toggle": "^3.10.10",
@@ -49,11 +50,12 @@
49
50
  "@react-stately/overlays": "^3.6.11",
50
51
  "@react-stately/radio": "^3.10.8",
51
52
  "@react-stately/select": "^3.6.11",
53
+ "@react-stately/table": "^3.14.2",
52
54
  "@react-stately/toggle": "^3.7.0",
53
55
  "@react-stately/tooltip": "^3.4.13",
54
56
  "@react-stately/tree": "^3.8.9",
55
- "@koobiq/logger": "0.0.1-beta.23",
56
- "@koobiq/react-core": "0.0.1-beta.23"
57
+ "@koobiq/react-core": "0.0.1-beta.25",
58
+ "@koobiq/logger": "0.0.1-beta.25"
57
59
  },
58
60
  "peerDependencies": {
59
61
  "react": "18.x || 19.x",