@ark-ui/react 2.0.1 → 2.0.2

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/CHANGELOG.md CHANGED
@@ -6,6 +6,22 @@ description: All notable changes to this project will be documented in this file
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [2.0.2] - 2024-02-10
10
+
11
+ ### Added
12
+
13
+ - Exported `SelectionDetails` type for `Menu` component
14
+
15
+ ### Changed
16
+
17
+ - Changed `Dialog.Description` and `Popover.Description` from `p` to `div` to allow for multiple paragraphs.
18
+ - Changed `TreeView.BranchTrigger` from `button` to `div` for the accessibility reasons.
19
+
20
+ ### Fixed
21
+
22
+ - Fix issue where `@types/react@18.2.8` broke current typings in `Portal`
23
+ - Fix issue where `Select` component submits its first option when used in a form, even if there is no value selected.
24
+
9
25
  ## [2.0.1] - 2024-01-30
10
26
 
11
27
  ### Fixed
@@ -13,7 +13,7 @@ const DialogDescription = react.forwardRef(
13
13
  (props, ref) => {
14
14
  const api = dialogContext.useDialogContext();
15
15
  const mergedProps = react$1.mergeProps(api.descriptionProps, props);
16
- return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.p, { ...mergedProps, ref });
16
+ return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
17
17
  }
18
18
  );
19
19
  DialogDescription.displayName = "DialogDescription";
@@ -1,6 +1,6 @@
1
1
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
2
2
  /// <reference types="react" />
3
3
  import { type HTMLArkProps } from '../factory';
4
- export interface DialogDescriptionProps extends HTMLArkProps<'p'> {
4
+ export interface DialogDescriptionProps extends HTMLArkProps<'div'> {
5
5
  }
6
6
  export declare const DialogDescription: ForwardRefExoticComponent<DialogDescriptionProps & RefAttributes<HTMLParagraphElement>>;
@@ -9,7 +9,7 @@ const DialogDescription = forwardRef(
9
9
  (props, ref) => {
10
10
  const api = useDialogContext();
11
11
  const mergedProps = mergeProps(api.descriptionProps, props);
12
- return /* @__PURE__ */ jsx(ark.p, { ...mergedProps, ref });
12
+ return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
13
13
  }
14
14
  );
15
15
  DialogDescription.displayName = "DialogDescription";
package/menu/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { OpenChangeDetails as MenuOpenChangeDetails, ValueChangeDetails as MenuValueChangeDetails } from '@zag-js/menu';
1
+ import type { OpenChangeDetails as MenuOpenChangeDetails, SelectionDetails as MenuSelectionDetails, ValueChangeDetails as MenuValueChangeDetails } from '@zag-js/menu';
2
2
  import { MenuArrow, type MenuArrowProps } from './menu-arrow';
3
3
  import { MenuArrowTip, type MenuArrowTipProps } from './menu-arrow-tip';
4
4
  import { MenuContent, type MenuContentProps } from './menu-content';
@@ -15,4 +15,4 @@ import { MenuTrigger, type MenuTriggerProps } from './menu-trigger';
15
15
  import { MenuTriggerItem, type MenuTriggerItemProps } from './menu-trigger-item';
16
16
  export * as Menu from './menu';
17
17
  export { MenuArrow, MenuArrowTip, MenuContent, MenuContextTrigger, MenuItem, MenuItemGroup, MenuItemGroupLabel, MenuOptionItem, MenuPositioner, MenuRoot, MenuSeparator, MenuTrigger, MenuTriggerItem, useMenuContext, };
18
- export type { MenuArrowProps, MenuArrowTipProps, MenuContentProps, MenuContextTriggerProps, MenuItemGroupLabelProps, MenuItemGroupProps, MenuItemProps, MenuOpenChangeDetails, MenuOptionItemProps, MenuPositionerProps, MenuRootProps, MenuSeparatorProps, MenuTriggerItemProps, MenuTriggerProps, MenuValueChangeDetails, };
18
+ export type { MenuArrowProps, MenuArrowTipProps, MenuContentProps, MenuContextTriggerProps, MenuItemGroupLabelProps, MenuItemGroupProps, MenuItemProps, MenuOpenChangeDetails, MenuOptionItemProps, MenuPositionerProps, MenuRootProps, MenuSelectionDetails, MenuSeparatorProps, MenuTriggerItemProps, MenuTriggerProps, MenuValueChangeDetails, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ark-ui/react",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.",
5
5
  "keywords": [
6
6
  "accordion",
@@ -101,17 +101,17 @@
101
101
  },
102
102
  "devDependencies": {
103
103
  "@release-it/keep-a-changelog": "5.0.0",
104
- "@storybook/addon-a11y": "7.6.10",
105
- "@storybook/addon-essentials": "7.6.10",
106
- "@storybook/addons": "7.6.10",
107
- "@storybook/react": "7.6.10",
108
- "@storybook/react-vite": "7.6.10",
104
+ "@storybook/addon-a11y": "7.6.12",
105
+ "@storybook/addon-essentials": "7.6.12",
106
+ "@storybook/addons": "7.6.12",
107
+ "@storybook/react": "7.6.12",
108
+ "@storybook/react-vite": "7.6.12",
109
109
  "@testing-library/dom": "9.3.4",
110
- "@testing-library/jest-dom": "6.3.0",
111
- "@testing-library/react": "14.1.2",
110
+ "@testing-library/jest-dom": "6.4.1",
111
+ "@testing-library/react": "14.2.1",
112
112
  "@testing-library/user-event": "14.5.2",
113
113
  "@types/jsdom": "21.1.6",
114
- "@types/react": "18.2.48",
114
+ "@types/react": "18.2.52",
115
115
  "@types/react-dom": "18.2.18",
116
116
  "@types/testing-library__jest-dom": "5.14.9",
117
117
  "@typescript-eslint/eslint-plugin": "6.20.0",
@@ -128,10 +128,10 @@
128
128
  "react": "18.2.0",
129
129
  "react-dom": "18.2.0",
130
130
  "react-frame-component": "5.2.6",
131
- "react-hook-form": "7.49.3",
131
+ "react-hook-form": "7.50.0",
132
132
  "release-it": "17.0.3",
133
133
  "resize-observer-polyfill": "1.5.1",
134
- "storybook": "7.6.10",
134
+ "storybook": "7.6.12",
135
135
  "typescript": "5.3.3",
136
136
  "vite": "5.0.12",
137
137
  "vite-plugin-dts": "3.7.2",
@@ -13,7 +13,7 @@ const PopoverDescription = react.forwardRef(
13
13
  (props, ref) => {
14
14
  const api = popoverContext.usePopoverContext();
15
15
  const mergedProps = react$1.mergeProps(api.descriptionProps, props);
16
- return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.p, { ...mergedProps, ref });
16
+ return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
17
17
  }
18
18
  );
19
19
  PopoverDescription.displayName = "PopoverDescription";
@@ -1,6 +1,6 @@
1
1
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
2
2
  /// <reference types="react" />
3
3
  import { type HTMLArkProps } from '../factory';
4
- export interface PopoverDescriptionProps extends HTMLArkProps<'p'> {
4
+ export interface PopoverDescriptionProps extends HTMLArkProps<'div'> {
5
5
  }
6
6
  export declare const PopoverDescription: ForwardRefExoticComponent<PopoverDescriptionProps & RefAttributes<HTMLParagraphElement>>;
@@ -9,7 +9,7 @@ const PopoverDescription = forwardRef(
9
9
  (props, ref) => {
10
10
  const api = usePopoverContext();
11
11
  const mergedProps = mergeProps(api.descriptionProps, props);
12
- return /* @__PURE__ */ jsx(ark.p, { ...mergedProps, ref });
12
+ return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
13
13
  }
14
14
  );
15
15
  PopoverDescription.displayName = "PopoverDescription";
package/portal.cjs CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
 
6
+ const jsxRuntime = require('react/jsx-runtime');
6
7
  const react = require('react');
7
8
  const reactDom = require('react-dom');
8
9
  const environmentContext = require('./environment/environment-context.cjs');
@@ -13,10 +14,10 @@ const Portal = (props) => {
13
14
  const isServer = useIsServer.useIsServer();
14
15
  const getRootNode = environmentContext.useEnvironmentContext();
15
16
  if (isServer || disabled)
16
- return children;
17
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children });
17
18
  const doc = getRootNode?.().ownerDocument ?? document;
18
19
  const mountNode = container?.current ?? doc.body;
19
- return react.Children.map(children, (child) => reactDom.createPortal(child, mountNode));
20
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: react.Children.map(children, (child) => reactDom.createPortal(child, mountNode)) });
20
21
  };
21
22
 
22
23
  exports.Portal = Portal;
package/portal.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import { type PropsWithChildren, type ReactNode, type ReactPortal, type RefObject } from 'react';
1
+ import { JSX } from 'react/jsx-runtime';
2
+ import { type PropsWithChildren, type RefObject } from 'react';
2
3
  export interface PortalProps {
3
4
  disabled?: boolean;
4
5
  container?: RefObject<HTMLElement>;
5
6
  }
6
- export declare const Portal: (props: PropsWithChildren<PortalProps>) => ReactPortal[] | ReactNode | null | undefined;
7
+ export declare const Portal: (props: PropsWithChildren<PortalProps>) => JSX.Element;
package/portal.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  'use client';
2
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
3
  import { Children } from 'react';
3
4
  import { createPortal } from 'react-dom';
4
5
  import { useEnvironmentContext } from './environment/environment-context.mjs';
@@ -9,10 +10,10 @@ const Portal = (props) => {
9
10
  const isServer = useIsServer();
10
11
  const getRootNode = useEnvironmentContext();
11
12
  if (isServer || disabled)
12
- return children;
13
+ return /* @__PURE__ */ jsx(Fragment, { children });
13
14
  const doc = getRootNode?.().ownerDocument ?? document;
14
15
  const mountNode = container?.current ?? doc.body;
15
- return Children.map(children, (child) => createPortal(child, mountNode));
16
+ return /* @__PURE__ */ jsx(Fragment, { children: Children.map(children, (child) => createPortal(child, mountNode)) });
16
17
  };
17
18
 
18
19
  export { Portal };
@@ -12,9 +12,13 @@ const selectContext = require('./select-context.cjs');
12
12
  const SelectControl = react.forwardRef((props, ref) => {
13
13
  const api = selectContext.useSelectContext();
14
14
  const mergedProps = react$1.mergeProps(api.controlProps, props);
15
+ const isValueEmpty = api.value.length === 0;
15
16
  return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
16
17
  /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref }),
17
- /* @__PURE__ */ jsxRuntime.jsx("select", { ...api.hiddenSelectProps, children: api.collection.toArray().map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value)) })
18
+ /* @__PURE__ */ jsxRuntime.jsxs("select", { ...api.hiddenSelectProps, children: [
19
+ isValueEmpty && /* @__PURE__ */ jsxRuntime.jsx("option", { value: "" }),
20
+ api.collection.toArray().map((option) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: option.value, children: option.label }, option.value))
21
+ ] })
18
22
  ] });
19
23
  });
20
24
  SelectControl.displayName = "SelectControl";
@@ -8,9 +8,13 @@ import { useSelectContext } from './select-context.mjs';
8
8
  const SelectControl = forwardRef((props, ref) => {
9
9
  const api = useSelectContext();
10
10
  const mergedProps = mergeProps(api.controlProps, props);
11
+ const isValueEmpty = api.value.length === 0;
11
12
  return /* @__PURE__ */ jsxs(Fragment, { children: [
12
13
  /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }),
13
- /* @__PURE__ */ jsx("select", { ...api.hiddenSelectProps, children: api.collection.toArray().map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value)) })
14
+ /* @__PURE__ */ jsxs("select", { ...api.hiddenSelectProps, children: [
15
+ isValueEmpty && /* @__PURE__ */ jsx("option", { value: "" }),
16
+ api.collection.toArray().map((option) => /* @__PURE__ */ jsx("option", { value: option.value, children: option.label }, option.value))
17
+ ] })
14
18
  ] });
15
19
  });
16
20
  SelectControl.displayName = "SelectControl";
@@ -19,7 +19,7 @@ const TreeViewBranchTrigger = react.forwardRef(
19
19
  ]);
20
20
  const api = treeViewContext.useTreeViewContext();
21
21
  const mergedProps = react$1.mergeProps(api.getBranchTriggerProps(branchProps), localProps);
22
- return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.button, { ...mergedProps, ref });
22
+ return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
23
23
  }
24
24
  );
25
25
  TreeViewBranchTrigger.displayName = "TreeViewBranchTrigger";
@@ -3,6 +3,6 @@ import { ForwardRefExoticComponent, RefAttributes } from 'react';
3
3
  import { type HTMLArkProps } from '../factory';
4
4
  import type { Assign } from '../types';
5
5
  import { type BranchProps } from './tree-view-context';
6
- export interface TreeViewBranchTriggerProps extends Assign<HTMLArkProps<'button'>, BranchProps> {
6
+ export interface TreeViewBranchTriggerProps extends Assign<HTMLArkProps<'div'>, BranchProps> {
7
7
  }
8
- export declare const TreeViewBranchTrigger: ForwardRefExoticComponent<TreeViewBranchTriggerProps & RefAttributes<HTMLButtonElement>>;
8
+ export declare const TreeViewBranchTrigger: ForwardRefExoticComponent<TreeViewBranchTriggerProps & RefAttributes<HTMLDivElement>>;
@@ -15,7 +15,7 @@ const TreeViewBranchTrigger = forwardRef(
15
15
  ]);
16
16
  const api = useTreeViewContext();
17
17
  const mergedProps = mergeProps(api.getBranchTriggerProps(branchProps), localProps);
18
- return /* @__PURE__ */ jsx(ark.button, { ...mergedProps, ref });
18
+ return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
19
19
  }
20
20
  );
21
21
  TreeViewBranchTrigger.displayName = "TreeViewBranchTrigger";