@ark-ui/react 5.3.0 → 5.4.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.
@@ -5,7 +5,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
5
5
 
6
6
  const jsxRuntime = require('react/jsx-runtime');
7
7
  const fileUtils = require('@zag-js/file-utils');
8
- const index = require('../../node_modules/@zag-js/utils/dist/index.cjs');
8
+ const utils = require('@zag-js/utils');
9
9
  const react = require('react');
10
10
  const useEnvironmentContext = require('../../providers/environment/use-environment-context.cjs');
11
11
  const factory = require('../factory.cjs');
@@ -19,7 +19,7 @@ const DownloadTrigger = react.forwardRef((props, ref) => {
19
19
  const onClick = (e) => {
20
20
  props.onClick?.(e);
21
21
  if (e.defaultPrevented) return;
22
- if (index.isFunction(data)) {
22
+ if (utils.isFunction(data)) {
23
23
  const maybePromise = data();
24
24
  if (maybePromise instanceof Promise) {
25
25
  maybePromise.then((data2) => download(data2));
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { downloadFile } from '@zag-js/file-utils';
4
- import { isFunction } from '../../node_modules/@zag-js/utils/dist/index.js';
4
+ import { isFunction } from '@zag-js/utils';
5
5
  import { forwardRef } from 'react';
6
6
  import { useEnvironmentContext } from '../../providers/environment/use-environment-context.js';
7
7
  import { ark } from '../factory.js';
@@ -16,11 +16,15 @@ const MenuItem = react.forwardRef((props, ref) => {
16
16
  "closeOnSelect",
17
17
  "disabled",
18
18
  "value",
19
- "valueText"
19
+ "valueText",
20
+ "onSelect"
20
21
  ]);
21
22
  const menu = useMenuContext.useMenuContext();
22
23
  const mergedProps = react$1.mergeProps(menu.getItemProps(itemProps), localProps);
23
24
  const itemState = menu.getItemState(itemProps);
25
+ react.useEffect(() => {
26
+ return menu.addItemListener({ id: itemState.id, onSelect: itemProps.onSelect });
27
+ }, [itemState.id, itemProps.onSelect]);
24
28
  return /* @__PURE__ */ jsxRuntime.jsx(useMenuItemContext.MenuItemProvider, { value: itemState, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref }) });
25
29
  });
26
30
  MenuItem.displayName = "MenuItem";
@@ -1,8 +1,16 @@
1
1
  import { ItemProps } from '@zag-js/menu';
2
+ import { Assign } from '../../types';
2
3
  import { HTMLProps, PolymorphicProps } from '../factory';
3
4
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
4
- export interface MenuItemBaseProps extends ItemProps, PolymorphicProps {
5
+ interface ItemBaseProps extends ItemProps {
6
+ /**
7
+ * The function to call when the item is selected
8
+ */
9
+ onSelect?: VoidFunction;
5
10
  }
6
- export interface MenuItemProps extends HTMLProps<'div'>, MenuItemBaseProps {
11
+ export interface MenuItemBaseProps extends ItemBaseProps, PolymorphicProps {
12
+ }
13
+ export interface MenuItemProps extends Assign<HTMLProps<'div'>, MenuItemBaseProps> {
7
14
  }
8
15
  export declare const MenuItem: ForwardRefExoticComponent<MenuItemProps & RefAttributes<HTMLDivElement>>;
16
+ export {};
@@ -1,8 +1,16 @@
1
1
  import { ItemProps } from '@zag-js/menu';
2
+ import { Assign } from '../../types';
2
3
  import { HTMLProps, PolymorphicProps } from '../factory';
3
4
  import { ForwardRefExoticComponent, RefAttributes } from 'react';
4
- export interface MenuItemBaseProps extends ItemProps, PolymorphicProps {
5
+ interface ItemBaseProps extends ItemProps {
6
+ /**
7
+ * The function to call when the item is selected
8
+ */
9
+ onSelect?: VoidFunction;
5
10
  }
6
- export interface MenuItemProps extends HTMLProps<'div'>, MenuItemBaseProps {
11
+ export interface MenuItemBaseProps extends ItemBaseProps, PolymorphicProps {
12
+ }
13
+ export interface MenuItemProps extends Assign<HTMLProps<'div'>, MenuItemBaseProps> {
7
14
  }
8
15
  export declare const MenuItem: ForwardRefExoticComponent<MenuItemProps & RefAttributes<HTMLDivElement>>;
16
+ export {};
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
  import { jsx } from 'react/jsx-runtime';
3
3
  import { mergeProps } from '@zag-js/react';
4
- import { forwardRef } from 'react';
4
+ import { forwardRef, useEffect } from 'react';
5
5
  import { createSplitProps } from '../../utils/create-split-props.js';
6
6
  import { ark } from '../factory.js';
7
7
  import { useMenuContext } from './use-menu-context.js';
@@ -12,11 +12,15 @@ const MenuItem = forwardRef((props, ref) => {
12
12
  "closeOnSelect",
13
13
  "disabled",
14
14
  "value",
15
- "valueText"
15
+ "valueText",
16
+ "onSelect"
16
17
  ]);
17
18
  const menu = useMenuContext();
18
19
  const mergedProps = mergeProps(menu.getItemProps(itemProps), localProps);
19
20
  const itemState = menu.getItemState(itemProps);
21
+ useEffect(() => {
22
+ return menu.addItemListener({ id: itemState.id, onSelect: itemProps.onSelect });
23
+ }, [itemState.id, itemProps.onSelect]);
20
24
  return /* @__PURE__ */ jsx(MenuItemProvider, { value: itemState, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref }) });
21
25
  });
22
26
  MenuItem.displayName = "MenuItem";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ark-ui/react",
3
3
  "type": "module",
4
- "version": "5.3.0",
4
+ "version": "5.4.0",
5
5
  "description": "A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.",
6
6
  "keywords": [
7
7
  "accordion",
@@ -148,88 +148,89 @@
148
148
  "sideEffects": false,
149
149
  "dependencies": {
150
150
  "@internationalized/date": "3.7.0",
151
- "@zag-js/accordion": "1.6.0",
152
- "@zag-js/anatomy": "1.6.0",
153
- "@zag-js/auto-resize": "1.6.0",
154
- "@zag-js/avatar": "1.6.0",
155
- "@zag-js/carousel": "1.6.0",
156
- "@zag-js/checkbox": "1.6.0",
157
- "@zag-js/clipboard": "1.6.0",
158
- "@zag-js/collapsible": "1.6.0",
159
- "@zag-js/collection": "1.6.0",
160
- "@zag-js/color-picker": "1.6.0",
161
- "@zag-js/color-utils": "1.6.0",
162
- "@zag-js/combobox": "1.6.0",
163
- "@zag-js/core": "1.6.0",
164
- "@zag-js/date-picker": "1.6.0",
165
- "@zag-js/date-utils": "1.6.0",
166
- "@zag-js/dialog": "1.6.0",
167
- "@zag-js/dom-query": "1.6.0",
168
- "@zag-js/editable": "1.6.0",
169
- "@zag-js/file-upload": "1.6.0",
170
- "@zag-js/file-utils": "1.6.0",
171
- "@zag-js/focus-trap": "1.6.0",
172
- "@zag-js/highlight-word": "1.6.0",
173
- "@zag-js/hover-card": "1.6.0",
174
- "@zag-js/i18n-utils": "1.6.0",
175
- "@zag-js/menu": "1.6.0",
176
- "@zag-js/number-input": "1.6.0",
177
- "@zag-js/pagination": "1.6.0",
178
- "@zag-js/pin-input": "1.6.0",
179
- "@zag-js/popover": "1.6.0",
180
- "@zag-js/presence": "1.6.0",
181
- "@zag-js/progress": "1.6.0",
182
- "@zag-js/qr-code": "1.6.0",
183
- "@zag-js/radio-group": "1.6.0",
184
- "@zag-js/rating-group": "1.6.0",
185
- "@zag-js/react": "1.6.0",
186
- "@zag-js/select": "1.6.0",
187
- "@zag-js/signature-pad": "1.6.0",
188
- "@zag-js/slider": "1.6.0",
189
- "@zag-js/splitter": "1.6.0",
190
- "@zag-js/steps": "1.6.0",
191
- "@zag-js/switch": "1.6.0",
192
- "@zag-js/tabs": "1.6.0",
193
- "@zag-js/tags-input": "1.6.0",
194
- "@zag-js/time-picker": "1.6.0",
195
- "@zag-js/timer": "1.6.0",
196
- "@zag-js/toast": "1.6.0",
197
- "@zag-js/toggle": "1.6.0",
198
- "@zag-js/toggle-group": "1.6.0",
199
- "@zag-js/tooltip": "1.6.0",
200
- "@zag-js/tour": "1.6.0",
201
- "@zag-js/tree-view": "1.6.0",
202
- "@zag-js/types": "1.6.0"
151
+ "@zag-js/accordion": "1.7.0",
152
+ "@zag-js/anatomy": "1.7.0",
153
+ "@zag-js/auto-resize": "1.7.0",
154
+ "@zag-js/avatar": "1.7.0",
155
+ "@zag-js/carousel": "1.7.0",
156
+ "@zag-js/checkbox": "1.7.0",
157
+ "@zag-js/clipboard": "1.7.0",
158
+ "@zag-js/collapsible": "1.7.0",
159
+ "@zag-js/collection": "1.7.0",
160
+ "@zag-js/color-picker": "1.7.0",
161
+ "@zag-js/color-utils": "1.7.0",
162
+ "@zag-js/combobox": "1.7.0",
163
+ "@zag-js/core": "1.7.0",
164
+ "@zag-js/date-picker": "1.7.0",
165
+ "@zag-js/date-utils": "1.7.0",
166
+ "@zag-js/dialog": "1.7.0",
167
+ "@zag-js/dom-query": "1.7.0",
168
+ "@zag-js/editable": "1.7.0",
169
+ "@zag-js/file-upload": "1.7.0",
170
+ "@zag-js/file-utils": "1.7.0",
171
+ "@zag-js/focus-trap": "1.7.0",
172
+ "@zag-js/highlight-word": "1.7.0",
173
+ "@zag-js/hover-card": "1.7.0",
174
+ "@zag-js/i18n-utils": "1.7.0",
175
+ "@zag-js/menu": "1.7.0",
176
+ "@zag-js/number-input": "1.7.0",
177
+ "@zag-js/pagination": "1.7.0",
178
+ "@zag-js/pin-input": "1.7.0",
179
+ "@zag-js/popover": "1.7.0",
180
+ "@zag-js/presence": "1.7.0",
181
+ "@zag-js/progress": "1.7.0",
182
+ "@zag-js/qr-code": "1.7.0",
183
+ "@zag-js/radio-group": "1.7.0",
184
+ "@zag-js/rating-group": "1.7.0",
185
+ "@zag-js/react": "1.7.0",
186
+ "@zag-js/select": "1.7.0",
187
+ "@zag-js/signature-pad": "1.7.0",
188
+ "@zag-js/slider": "1.7.0",
189
+ "@zag-js/splitter": "1.7.0",
190
+ "@zag-js/steps": "1.7.0",
191
+ "@zag-js/switch": "1.7.0",
192
+ "@zag-js/tabs": "1.7.0",
193
+ "@zag-js/tags-input": "1.7.0",
194
+ "@zag-js/time-picker": "1.7.0",
195
+ "@zag-js/timer": "1.7.0",
196
+ "@zag-js/toast": "1.7.0",
197
+ "@zag-js/toggle": "1.7.0",
198
+ "@zag-js/toggle-group": "1.7.0",
199
+ "@zag-js/tooltip": "1.7.0",
200
+ "@zag-js/tour": "1.7.0",
201
+ "@zag-js/tree-view": "1.7.0",
202
+ "@zag-js/types": "1.7.0",
203
+ "@zag-js/utils": "1.7.0"
203
204
  },
204
205
  "devDependencies": {
205
206
  "@biomejs/biome": "1.9.4",
206
207
  "@release-it/keep-a-changelog": "6.0.0",
207
- "@storybook/addon-a11y": "8.6.7",
208
- "@storybook/addon-essentials": "8.6.7",
209
- "@storybook/react": "8.6.7",
210
- "@storybook/react-vite": "8.6.7",
208
+ "@storybook/addon-a11y": "8.6.11",
209
+ "@storybook/addon-essentials": "8.6.11",
210
+ "@storybook/react": "8.6.11",
211
+ "@storybook/react-vite": "8.6.11",
211
212
  "@testing-library/dom": "10.4.0",
212
213
  "@testing-library/jest-dom": "6.6.3",
213
214
  "@testing-library/react": "16.2.0",
214
215
  "@testing-library/user-event": "14.6.1",
215
216
  "@types/jsdom": "21.1.7",
216
- "@types/react": "19.0.10",
217
+ "@types/react": "19.0.12",
217
218
  "@types/react-dom": "19.0.4",
218
219
  "@vitejs/plugin-react": "4.3.4",
219
- "@zag-js/stringify-state": "1.6.0",
220
+ "@zag-js/stringify-state": "1.7.0",
220
221
  "clean-package": "2.2.0",
221
222
  "globby": "14.1.0",
222
223
  "happy-dom": "17.4.4",
223
- "lucide-react": "0.482.0",
224
+ "lucide-react": "0.484.0",
224
225
  "react": "19.0.0",
225
226
  "react-dom": "19.0.0",
226
227
  "react-frame-component": "5.2.7",
227
228
  "react-hook-form": "7.54.2",
228
229
  "release-it": "18.1.2",
229
230
  "resize-observer-polyfill": "1.5.1",
230
- "storybook": "8.6.7",
231
+ "storybook": "8.6.11",
231
232
  "typescript": "5.8.2",
232
- "vite": "6.2.2",
233
+ "vite": "6.2.3",
233
234
  "vite-plugin-dts": "4.5.3",
234
235
  "vitest": "3.0.9",
235
236
  "@vitest/coverage-v8": "3.0.9",
@@ -1,10 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
-
5
- // src/array.ts
6
- var isFunction = (v) => typeof v === "function";
7
- var fnToString = Function.prototype.toString;
8
- fnToString.call(Object);
9
-
10
- exports.isFunction = isFunction;
@@ -1,6 +0,0 @@
1
- // src/array.ts
2
- var isFunction = (v) => typeof v === "function";
3
- var fnToString = Function.prototype.toString;
4
- fnToString.call(Object);
5
-
6
- export { isFunction };