@ark-ui/react 1.0.0-beta.4 → 1.0.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.
- package/CHANGELOG.md +18 -0
- package/accordion/accordion-context.d.ts +2 -1
- package/accordion/accordion-item-content.cjs +14 -21
- package/accordion/accordion-item-content.d.ts +1 -3
- package/accordion/accordion-item-content.mjs +14 -21
- package/accordion/accordion-item-context.d.ts +2 -2
- package/accordion/accordion-item-trigger.cjs +11 -1
- package/accordion/accordion-item-trigger.mjs +11 -1
- package/accordion/accordion-item.cjs +7 -1
- package/accordion/accordion-item.d.ts +4 -5
- package/accordion/accordion-item.mjs +7 -1
- package/accordion/accordion.cjs +7 -3
- package/accordion/accordion.d.ts +2 -1
- package/accordion/accordion.mjs +7 -3
- package/carousel/carousel.d.ts +4 -5
- package/checkbox/checkbox.cjs +2 -2
- package/checkbox/checkbox.d.ts +4 -5
- package/checkbox/checkbox.mjs +2 -2
- package/color-picker/color-picker-content.cjs +8 -11
- package/color-picker/color-picker-content.d.ts +1 -3
- package/color-picker/color-picker-content.mjs +8 -11
- package/color-picker/color-picker-positioner.cjs +6 -0
- package/color-picker/color-picker-positioner.mjs +6 -0
- package/color-picker/color-picker-view.cjs +29 -0
- package/color-picker/color-picker-view.d.ts +8 -0
- package/color-picker/color-picker-view.mjs +25 -0
- package/color-picker/color-picker.cjs +31 -28
- package/color-picker/color-picker.d.ts +6 -5
- package/color-picker/color-picker.mjs +32 -29
- package/color-picker/index.cjs +3 -1
- package/color-picker/index.d.ts +3 -1
- package/color-picker/index.mjs +3 -1
- package/combobox/combobox-content.cjs +8 -11
- package/combobox/combobox-content.d.ts +1 -3
- package/combobox/combobox-content.mjs +8 -11
- package/combobox/combobox-item.d.ts +6 -4
- package/combobox/combobox-positioner.cjs +6 -0
- package/combobox/combobox-positioner.mjs +6 -0
- package/combobox/combobox.cjs +8 -2
- package/combobox/combobox.d.ts +4 -3
- package/combobox/combobox.mjs +8 -2
- package/date-picker/date-picker-content.cjs +8 -11
- package/date-picker/date-picker-content.d.ts +1 -3
- package/date-picker/date-picker-content.mjs +8 -11
- package/date-picker/date-picker-positioner.cjs +6 -0
- package/date-picker/date-picker-positioner.mjs +6 -0
- package/date-picker/date-picker-view.d.ts +3 -3
- package/date-picker/date-picker.cjs +10 -4
- package/date-picker/date-picker.d.ts +6 -5
- package/date-picker/date-picker.mjs +10 -4
- package/dialog/dialog-backdrop.cjs +8 -11
- package/dialog/dialog-backdrop.d.ts +1 -3
- package/dialog/dialog-backdrop.mjs +8 -11
- package/dialog/dialog-content.cjs +8 -11
- package/dialog/dialog-content.d.ts +1 -3
- package/dialog/dialog-content.mjs +8 -11
- package/dialog/dialog-positioner.cjs +6 -0
- package/dialog/dialog-positioner.mjs +6 -0
- package/dialog/dialog-trigger.cjs +10 -1
- package/dialog/dialog-trigger.mjs +10 -1
- package/dialog/dialog.cjs +8 -3
- package/dialog/dialog.d.ts +4 -6
- package/dialog/dialog.mjs +8 -3
- package/editable/editable.d.ts +4 -5
- package/environment/environment-context.d.ts +1 -1
- package/hover-card/hover-card-content.cjs +8 -11
- package/hover-card/hover-card-content.d.ts +1 -3
- package/hover-card/hover-card-content.mjs +8 -11
- package/hover-card/hover-card-positioner.cjs +6 -0
- package/hover-card/hover-card-positioner.mjs +6 -0
- package/hover-card/hover-card.cjs +8 -3
- package/hover-card/hover-card.d.ts +4 -6
- package/hover-card/hover-card.mjs +8 -3
- package/index.cjs +8 -0
- package/index.mjs +3 -0
- package/menu/menu-content.cjs +8 -11
- package/menu/menu-content.d.ts +1 -3
- package/menu/menu-content.mjs +8 -11
- package/menu/menu-option-item.d.ts +2 -2
- package/menu/menu.cjs +11 -12
- package/menu/menu.d.ts +4 -11
- package/menu/menu.mjs +12 -13
- package/package.json +49 -50
- package/pagination/pagination.d.ts +3 -3
- package/popover/popover-content.cjs +8 -11
- package/popover/popover-content.d.ts +1 -3
- package/popover/popover-content.mjs +8 -11
- package/popover/popover-positioner.cjs +6 -0
- package/popover/popover-positioner.mjs +6 -0
- package/popover/popover-trigger.cjs +10 -1
- package/popover/popover-trigger.mjs +10 -1
- package/popover/popover.cjs +8 -3
- package/popover/popover.d.ts +4 -6
- package/popover/popover.mjs +8 -3
- package/presence/index.cjs +8 -0
- package/presence/index.d.ts +8 -5
- package/presence/index.mjs +3 -0
- package/presence/presence-context.cjs +15 -0
- package/presence/presence-context.d.ts +6 -0
- package/presence/presence-context.mjs +10 -0
- package/presence/presence-props-context.cjs +17 -0
- package/presence/presence-props-context.d.ts +6 -0
- package/presence/presence-props-context.mjs +12 -0
- package/presence/presence.cjs +18 -19
- package/presence/presence.d.ts +6 -21
- package/presence/presence.mjs +19 -20
- package/presence/split-presence-props.d.ts +2 -2
- package/presence/use-presence.cjs +22 -4
- package/presence/use-presence.d.ts +21 -1
- package/presence/use-presence.mjs +20 -2
- package/radio-group/radio-group-item.d.ts +2 -3
- package/rating-group/rating-group-control.d.ts +5 -3
- package/rating-group/rating-group-item.d.ts +4 -5
- package/segment-group/segment-group-item.d.ts +2 -3
- package/segment-group/segment-group.anatomy.d.ts +2 -0
- package/select/select-content.cjs +8 -11
- package/select/select-content.d.ts +1 -3
- package/select/select-content.mjs +8 -11
- package/select/select-item.d.ts +2 -3
- package/select/select-positioner.cjs +6 -0
- package/select/select-positioner.mjs +6 -0
- package/select/select.cjs +8 -2
- package/select/select.d.ts +4 -3
- package/select/select.mjs +8 -2
- package/slider/slider-value-text.cjs +1 -3
- package/slider/slider-value-text.d.ts +3 -6
- package/slider/slider-value-text.mjs +1 -3
- package/slider/slider.d.ts +3 -3
- package/splitter/splitter.d.ts +3 -3
- package/switch/switch.d.ts +3 -3
- package/switch/switch.stories.d.ts +1 -0
- package/tabs/tab-content.cjs +13 -12
- package/tabs/tab-content.d.ts +2 -4
- package/tabs/tab-content.mjs +13 -12
- package/tabs/tabs.cjs +7 -3
- package/tabs/tabs.d.ts +2 -1
- package/tabs/tabs.mjs +7 -3
- package/tags-input/tags-input-item.d.ts +4 -5
- package/tags-input/tags-input.d.ts +3 -3
- package/toast/toast.stories.d.ts +3 -1
- package/tooltip/tooltip-content.cjs +8 -11
- package/tooltip/tooltip-content.d.ts +1 -3
- package/tooltip/tooltip-content.mjs +8 -11
- package/tooltip/tooltip-positioner.cjs +6 -0
- package/tooltip/tooltip-positioner.mjs +6 -0
- package/tooltip/tooltip.cjs +8 -3
- package/tooltip/tooltip.d.ts +4 -4
- package/tooltip/tooltip.mjs +8 -3
- package/types.d.ts +1 -3
- package/use-event.cjs +6 -2
- package/use-event.mjs +6 -2
- package/tabs/tab-presence.cjs +0 -17
- package/tabs/tab-presence.d.ts +0 -6
- package/tabs/tab-presence.mjs +0 -13
- package/use-latest-ref.cjs +0 -14
- package/use-latest-ref.d.ts +0 -3
- package/use-latest-ref.mjs +0 -10
package/menu/menu-content.mjs
CHANGED
|
@@ -3,22 +3,19 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.mjs';
|
|
6
|
-
import
|
|
6
|
+
import '../presence/index.mjs';
|
|
7
7
|
import { useMenuContext } from './menu-context.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { usePresenceContext } from '../presence/presence-context.mjs';
|
|
9
9
|
|
|
10
10
|
const MenuContent = forwardRef((props, ref) => {
|
|
11
|
-
const [presenceProps, localProps] = splitPresenceProps(props);
|
|
12
11
|
const api = useMenuContext();
|
|
13
|
-
|
|
12
|
+
const presenceApi = usePresenceContext();
|
|
13
|
+
const mergedProps = mergeProps(api?.contentProps ?? {}, presenceApi.getPresenceProps(ref), props);
|
|
14
|
+
if (presenceApi.isUnmounted) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps });
|
|
14
18
|
});
|
|
15
19
|
MenuContent.displayName = "MenuContent";
|
|
16
|
-
const MenuInnerContent = forwardRef(
|
|
17
|
-
function MenuInnerContent2(props, ref) {
|
|
18
|
-
const api = useMenuContext();
|
|
19
|
-
const mergedProps = mergeProps(api?.contentProps ?? {}, props);
|
|
20
|
-
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
20
|
|
|
24
21
|
export { MenuContent };
|
|
@@ -2,8 +2,8 @@ import type { OptionItemProps, OptionItemState } from '@zag-js/menu';
|
|
|
2
2
|
import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react';
|
|
3
3
|
import { type HTMLArkProps } from '../factory';
|
|
4
4
|
import { type Assign } from '../types';
|
|
5
|
-
export interface MenuOptionItemProps extends Assign<HTMLArkProps<'div'>,
|
|
5
|
+
export interface MenuOptionItemProps extends Assign<HTMLArkProps<'div'>, {
|
|
6
6
|
children?: ReactNode | ((state: OptionItemState) => ReactNode);
|
|
7
|
-
}
|
|
7
|
+
}>, OptionItemProps {
|
|
8
8
|
}
|
|
9
9
|
export declare const MenuOptionItem: ForwardRefExoticComponent<MenuOptionItemProps & RefAttributes<HTMLDivElement>>;
|
package/menu/menu.cjs
CHANGED
|
@@ -6,13 +6,18 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
const react = require('react');
|
|
8
8
|
const createSplitProps = require('../create-split-props.cjs');
|
|
9
|
+
require('../presence/index.cjs');
|
|
9
10
|
const runIfFn = require('../run-if-fn.cjs');
|
|
10
11
|
const useEffectOnce = require('../use-effect-once.cjs');
|
|
11
12
|
const menuContext = require('./menu-context.cjs');
|
|
12
13
|
const useMenu = require('./use-menu.cjs');
|
|
14
|
+
const splitPresenceProps = require('../presence/split-presence-props.cjs');
|
|
15
|
+
const usePresence = require('../presence/use-presence.cjs');
|
|
16
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
13
17
|
|
|
14
18
|
const Menu = (props) => {
|
|
15
|
-
const [
|
|
19
|
+
const [presenceProps, menuProps] = splitPresenceProps.splitPresenceProps(props);
|
|
20
|
+
const [useMenuProps, localProps] = createSplitProps.createSplitProps()(menuProps, [
|
|
16
21
|
"anchorPoint",
|
|
17
22
|
"aria-label",
|
|
18
23
|
"closeOnSelect",
|
|
@@ -28,32 +33,26 @@ const Menu = (props) => {
|
|
|
28
33
|
"onPointerDownOutside",
|
|
29
34
|
"onSelect",
|
|
30
35
|
"onValueChange",
|
|
36
|
+
"open",
|
|
31
37
|
"positioning",
|
|
32
38
|
"value"
|
|
33
39
|
]);
|
|
34
40
|
const parentApi = menuContext.useMenuContext();
|
|
35
41
|
const parentMachine = menuContext.useMenuMachineContext();
|
|
36
|
-
const { api, machine } = useMenu.useMenu(
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
onClose: api.close
|
|
40
|
-
});
|
|
42
|
+
const { api, machine } = useMenu.useMenu(useMenuProps);
|
|
43
|
+
const presenceApi = usePresence.usePresence({ ...presenceProps, present: api.isOpen });
|
|
44
|
+
const view = runIfFn.runIfFn(localProps.children, api);
|
|
41
45
|
useEffectOnce.useEffectOnce(() => {
|
|
42
46
|
if (!parentMachine)
|
|
43
47
|
return;
|
|
44
48
|
parentApi.setChild(machine);
|
|
45
49
|
api.setParent(parentMachine);
|
|
46
50
|
});
|
|
47
|
-
react.useEffect(() => {
|
|
48
|
-
if (isOpen && !api.isOpen) {
|
|
49
|
-
api.open();
|
|
50
|
-
}
|
|
51
|
-
}, [isOpen, api]);
|
|
52
51
|
const getTriggerItemProps = react.useCallback(
|
|
53
52
|
() => parentApi.getTriggerItemProps(api),
|
|
54
53
|
[api, parentApi]
|
|
55
54
|
);
|
|
56
|
-
return /* @__PURE__ */ jsxRuntime.jsx(menuContext.MenuTriggerItemProvider, { value: getTriggerItemProps, children: /* @__PURE__ */ jsxRuntime.jsx(menuContext.MenuMachineProvider, { value: machine, children: /* @__PURE__ */ jsxRuntime.jsx(menuContext.MenuProvider, { value: api, children: view }) }) });
|
|
55
|
+
return /* @__PURE__ */ jsxRuntime.jsx(menuContext.MenuTriggerItemProvider, { value: getTriggerItemProps, children: /* @__PURE__ */ jsxRuntime.jsx(menuContext.MenuMachineProvider, { value: machine, children: /* @__PURE__ */ jsxRuntime.jsx(menuContext.MenuProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: view }) }) }) });
|
|
57
56
|
};
|
|
58
57
|
|
|
59
58
|
exports.Menu = Menu;
|
package/menu/menu.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
1
|
import { JSX } from 'react/jsx-runtime';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import { type
|
|
4
|
-
import { type UseMenuProps } from './use-menu';
|
|
5
|
-
interface
|
|
6
|
-
|
|
7
|
-
onClose: () => void;
|
|
8
|
-
}
|
|
9
|
-
export interface MenuProps extends Assign<UseMenuProps, {
|
|
10
|
-
children?: ReactNode | ((state: MenuState) => ReactNode);
|
|
11
|
-
isOpen?: boolean;
|
|
12
|
-
}> {
|
|
3
|
+
import { type UsePresenceProps } from '../presence';
|
|
4
|
+
import { type UseMenuProps, type UseMenuReturn } from './use-menu';
|
|
5
|
+
export interface MenuProps extends UseMenuProps, UsePresenceProps {
|
|
6
|
+
children?: ReactNode | ((api: UseMenuReturn['api']) => ReactNode);
|
|
13
7
|
}
|
|
14
8
|
export declare const Menu: (props: MenuProps) => JSX.Element;
|
|
15
|
-
export {};
|
package/menu/menu.mjs
CHANGED
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
-
import {
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
4
|
import { createSplitProps } from '../create-split-props.mjs';
|
|
5
|
+
import '../presence/index.mjs';
|
|
5
6
|
import { runIfFn } from '../run-if-fn.mjs';
|
|
6
7
|
import { useEffectOnce } from '../use-effect-once.mjs';
|
|
7
8
|
import { useMenuContext, useMenuMachineContext, MenuTriggerItemProvider, MenuMachineProvider, MenuProvider } from './menu-context.mjs';
|
|
8
9
|
import { useMenu } from './use-menu.mjs';
|
|
10
|
+
import { splitPresenceProps } from '../presence/split-presence-props.mjs';
|
|
11
|
+
import { usePresence } from '../presence/use-presence.mjs';
|
|
12
|
+
import { PresenceProvider } from '../presence/presence-context.mjs';
|
|
9
13
|
|
|
10
14
|
const Menu = (props) => {
|
|
11
|
-
const [
|
|
15
|
+
const [presenceProps, menuProps] = splitPresenceProps(props);
|
|
16
|
+
const [useMenuProps, localProps] = createSplitProps()(menuProps, [
|
|
12
17
|
"anchorPoint",
|
|
13
18
|
"aria-label",
|
|
14
19
|
"closeOnSelect",
|
|
@@ -24,32 +29,26 @@ const Menu = (props) => {
|
|
|
24
29
|
"onPointerDownOutside",
|
|
25
30
|
"onSelect",
|
|
26
31
|
"onValueChange",
|
|
32
|
+
"open",
|
|
27
33
|
"positioning",
|
|
28
34
|
"value"
|
|
29
35
|
]);
|
|
30
36
|
const parentApi = useMenuContext();
|
|
31
37
|
const parentMachine = useMenuMachineContext();
|
|
32
|
-
const { api, machine } = useMenu(
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
onClose: api.close
|
|
36
|
-
});
|
|
38
|
+
const { api, machine } = useMenu(useMenuProps);
|
|
39
|
+
const presenceApi = usePresence({ ...presenceProps, present: api.isOpen });
|
|
40
|
+
const view = runIfFn(localProps.children, api);
|
|
37
41
|
useEffectOnce(() => {
|
|
38
42
|
if (!parentMachine)
|
|
39
43
|
return;
|
|
40
44
|
parentApi.setChild(machine);
|
|
41
45
|
api.setParent(parentMachine);
|
|
42
46
|
});
|
|
43
|
-
useEffect(() => {
|
|
44
|
-
if (isOpen && !api.isOpen) {
|
|
45
|
-
api.open();
|
|
46
|
-
}
|
|
47
|
-
}, [isOpen, api]);
|
|
48
47
|
const getTriggerItemProps = useCallback(
|
|
49
48
|
() => parentApi.getTriggerItemProps(api),
|
|
50
49
|
[api, parentApi]
|
|
51
50
|
);
|
|
52
|
-
return /* @__PURE__ */ jsx(MenuTriggerItemProvider, { value: getTriggerItemProps, children: /* @__PURE__ */ jsx(MenuMachineProvider, { value: machine, children: /* @__PURE__ */ jsx(MenuProvider, { value: api, children: view }) }) });
|
|
51
|
+
return /* @__PURE__ */ jsx(MenuTriggerItemProvider, { value: getTriggerItemProps, children: /* @__PURE__ */ jsx(MenuMachineProvider, { value: machine, children: /* @__PURE__ */ jsx(MenuProvider, { value: api, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presenceApi, children: view }) }) }) });
|
|
53
52
|
};
|
|
54
53
|
|
|
55
54
|
export { Menu };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ark-ui/react",
|
|
3
|
-
"version": "1.0.0
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "A collection of unstyled, accessible UI components for React, utilizing state machines for seamless interaction.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"accordion",
|
|
@@ -59,72 +59,71 @@
|
|
|
59
59
|
"release-it": "release-it --config ../../../release-it.json"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@ark-ui/anatomy": "1.0.0
|
|
63
|
-
"@zag-js/accordion": "0.
|
|
64
|
-
"@zag-js/
|
|
65
|
-
"@zag-js/
|
|
66
|
-
"@zag-js/
|
|
67
|
-
"@zag-js/
|
|
68
|
-
"@zag-js/color-
|
|
69
|
-
"@zag-js/
|
|
70
|
-
"@zag-js/
|
|
71
|
-
"@zag-js/
|
|
72
|
-
"@zag-js/date-
|
|
73
|
-
"@zag-js/
|
|
74
|
-
"@zag-js/
|
|
75
|
-
"@zag-js/
|
|
76
|
-
"@zag-js/
|
|
77
|
-
"@zag-js/
|
|
78
|
-
"@zag-js/
|
|
79
|
-
"@zag-js/
|
|
80
|
-
"@zag-js/
|
|
81
|
-
"@zag-js/
|
|
82
|
-
"@zag-js/
|
|
83
|
-
"@zag-js/
|
|
84
|
-
"@zag-js/
|
|
85
|
-
"@zag-js/
|
|
86
|
-
"@zag-js/
|
|
87
|
-
"@zag-js/
|
|
88
|
-
"@zag-js/
|
|
89
|
-
"@zag-js/
|
|
90
|
-
"@zag-js/
|
|
91
|
-
"@zag-js/
|
|
92
|
-
"@zag-js/
|
|
93
|
-
"@zag-js/
|
|
94
|
-
"@zag-js/
|
|
95
|
-
"@zag-js/types": "0.27.1"
|
|
62
|
+
"@ark-ui/anatomy": "1.0.0",
|
|
63
|
+
"@zag-js/accordion": "0.28.0",
|
|
64
|
+
"@zag-js/avatar": "0.28.0",
|
|
65
|
+
"@zag-js/carousel": "0.28.0",
|
|
66
|
+
"@zag-js/checkbox": "0.28.0",
|
|
67
|
+
"@zag-js/color-picker": "0.28.0",
|
|
68
|
+
"@zag-js/color-utils": "0.28.0",
|
|
69
|
+
"@zag-js/combobox": "0.28.0",
|
|
70
|
+
"@zag-js/core": "0.28.0",
|
|
71
|
+
"@zag-js/date-picker": "0.28.0",
|
|
72
|
+
"@zag-js/date-utils": "0.28.0",
|
|
73
|
+
"@zag-js/dialog": "0.28.0",
|
|
74
|
+
"@zag-js/editable": "0.28.0",
|
|
75
|
+
"@zag-js/hover-card": "0.28.0",
|
|
76
|
+
"@zag-js/menu": "0.28.0",
|
|
77
|
+
"@zag-js/number-input": "0.28.0",
|
|
78
|
+
"@zag-js/pagination": "0.28.0",
|
|
79
|
+
"@zag-js/pin-input": "0.28.0",
|
|
80
|
+
"@zag-js/popover": "0.28.0",
|
|
81
|
+
"@zag-js/presence": "0.28.0",
|
|
82
|
+
"@zag-js/radio-group": "0.28.0",
|
|
83
|
+
"@zag-js/rating-group": "0.28.0",
|
|
84
|
+
"@zag-js/react": "0.28.0",
|
|
85
|
+
"@zag-js/select": "0.28.0",
|
|
86
|
+
"@zag-js/slider": "0.28.0",
|
|
87
|
+
"@zag-js/splitter": "0.28.0",
|
|
88
|
+
"@zag-js/switch": "0.28.0",
|
|
89
|
+
"@zag-js/tabs": "0.28.0",
|
|
90
|
+
"@zag-js/tags-input": "0.28.0",
|
|
91
|
+
"@zag-js/toast": "0.28.0",
|
|
92
|
+
"@zag-js/toggle-group": "0.28.0",
|
|
93
|
+
"@zag-js/tooltip": "0.28.0",
|
|
94
|
+
"@zag-js/types": "0.28.0"
|
|
96
95
|
},
|
|
97
96
|
"devDependencies": {
|
|
98
97
|
"@release-it/keep-a-changelog": "4.0.0",
|
|
99
|
-
"@storybook/addon-a11y": "7.5.
|
|
100
|
-
"@storybook/addon-essentials": "7.5.
|
|
101
|
-
"@storybook/addons": "7.5.
|
|
102
|
-
"@storybook/react": "7.5.
|
|
103
|
-
"@storybook/react-vite": "7.5.
|
|
98
|
+
"@storybook/addon-a11y": "7.5.3",
|
|
99
|
+
"@storybook/addon-essentials": "7.5.3",
|
|
100
|
+
"@storybook/addons": "7.5.3",
|
|
101
|
+
"@storybook/react": "7.5.3",
|
|
102
|
+
"@storybook/react-vite": "7.5.3",
|
|
104
103
|
"@testing-library/dom": "9.3.3",
|
|
105
104
|
"@testing-library/jest-dom": "6.1.4",
|
|
106
|
-
"@testing-library/react": "14.
|
|
105
|
+
"@testing-library/react": "14.1.0",
|
|
107
106
|
"@testing-library/user-event": "14.5.1",
|
|
108
|
-
"@types/jsdom": "21.1.
|
|
109
|
-
"@types/react": "18.2.
|
|
110
|
-
"@types/react-dom": "18.2.
|
|
107
|
+
"@types/jsdom": "21.1.5",
|
|
108
|
+
"@types/react": "18.2.37",
|
|
109
|
+
"@types/react-dom": "18.2.15",
|
|
111
110
|
"@types/testing-library__jest-dom": "5.14.9",
|
|
112
|
-
"@typescript-eslint/eslint-plugin": "6.
|
|
113
|
-
"@typescript-eslint/parser": "6.
|
|
114
|
-
"@vitejs/plugin-react": "4.1.
|
|
111
|
+
"@typescript-eslint/eslint-plugin": "6.10.0",
|
|
112
|
+
"@typescript-eslint/parser": "6.10.0",
|
|
113
|
+
"@vitejs/plugin-react": "4.1.1",
|
|
115
114
|
"@vitest/coverage-v8": "0.34.6",
|
|
116
|
-
"eslint": "8.
|
|
115
|
+
"eslint": "8.53.0",
|
|
117
116
|
"eslint-plugin-react": "7.33.2",
|
|
118
117
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
119
118
|
"globby": "13.2.2",
|
|
120
119
|
"jsdom": "22.1.0",
|
|
121
|
-
"lucide-react": "0.
|
|
120
|
+
"lucide-react": "0.292.0",
|
|
122
121
|
"react": "18.2.0",
|
|
123
122
|
"react-dom": "18.2.0",
|
|
124
123
|
"react-frame-component": "5.2.6",
|
|
125
124
|
"release-it": "16.2.1",
|
|
126
125
|
"resize-observer-polyfill": "1.5.1",
|
|
127
|
-
"storybook": "7.5.
|
|
126
|
+
"storybook": "7.5.3",
|
|
128
127
|
"typescript": "5.2.2",
|
|
129
128
|
"vite": "4.5.0",
|
|
130
129
|
"vite-plugin-dts": "3.6.3",
|
|
@@ -2,8 +2,8 @@ import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react'
|
|
|
2
2
|
import { type HTMLArkProps } from '../factory';
|
|
3
3
|
import { type Assign } from '../types';
|
|
4
4
|
import { type UsePaginationProps, type UsePaginationReturn } from './use-pagination';
|
|
5
|
-
export interface PaginationProps extends Assign<Assign<HTMLArkProps<'nav'>,
|
|
6
|
-
children?: ReactNode | ((
|
|
7
|
-
}> {
|
|
5
|
+
export interface PaginationProps extends Assign<Assign<HTMLArkProps<'nav'>, {
|
|
6
|
+
children?: ReactNode | ((api: UsePaginationReturn) => ReactNode);
|
|
7
|
+
}>, UsePaginationProps> {
|
|
8
8
|
}
|
|
9
9
|
export declare const Pagination: ForwardRefExoticComponent<PaginationProps & RefAttributes<HTMLElement>>;
|
|
@@ -7,22 +7,19 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
const react$1 = require('@zag-js/react');
|
|
8
8
|
const react = require('react');
|
|
9
9
|
const factory = require('../factory.cjs');
|
|
10
|
-
|
|
10
|
+
require('../presence/index.cjs');
|
|
11
11
|
const popoverContext = require('./popover-context.cjs');
|
|
12
|
-
const
|
|
12
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
13
13
|
|
|
14
14
|
const PopoverContent = react.forwardRef((props, ref) => {
|
|
15
|
-
const [presenceProps, localProps] = splitPresenceProps.splitPresenceProps(props);
|
|
16
15
|
const api = popoverContext.usePopoverContext();
|
|
17
|
-
|
|
16
|
+
const presenceApi = presenceContext.usePresenceContext();
|
|
17
|
+
const mergedProps = react$1.mergeProps(api.contentProps, presenceApi.getPresenceProps(ref), props);
|
|
18
|
+
if (presenceApi.isUnmounted) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps });
|
|
18
22
|
});
|
|
19
23
|
PopoverContent.displayName = "PopoverContent";
|
|
20
|
-
const PopoverInnerContent = react.forwardRef(
|
|
21
|
-
function PopoverInnerContent2(props, ref) {
|
|
22
|
-
const api = popoverContext.usePopoverContext();
|
|
23
|
-
const mergedProps = react$1.mergeProps(api.contentProps, props);
|
|
24
|
-
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
24
|
|
|
28
25
|
exports.PopoverContent = PopoverContent;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
/// <reference types="react" />
|
|
3
3
|
import { type HTMLArkProps } from '../factory';
|
|
4
|
-
|
|
5
|
-
import type { Assign } from '../types';
|
|
6
|
-
export interface PopoverContentProps extends Assign<HTMLArkProps<'div'>, Omit<PresenceProps, 'children' | 'fallback'>> {
|
|
4
|
+
export interface PopoverContentProps extends HTMLArkProps<'div'> {
|
|
7
5
|
}
|
|
8
6
|
export declare const PopoverContent: ForwardRefExoticComponent<PopoverContentProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -3,22 +3,19 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.mjs';
|
|
6
|
-
import
|
|
6
|
+
import '../presence/index.mjs';
|
|
7
7
|
import { usePopoverContext } from './popover-context.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { usePresenceContext } from '../presence/presence-context.mjs';
|
|
9
9
|
|
|
10
10
|
const PopoverContent = forwardRef((props, ref) => {
|
|
11
|
-
const [presenceProps, localProps] = splitPresenceProps(props);
|
|
12
11
|
const api = usePopoverContext();
|
|
13
|
-
|
|
12
|
+
const presenceApi = usePresenceContext();
|
|
13
|
+
const mergedProps = mergeProps(api.contentProps, presenceApi.getPresenceProps(ref), props);
|
|
14
|
+
if (presenceApi.isUnmounted) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps });
|
|
14
18
|
});
|
|
15
19
|
PopoverContent.displayName = "PopoverContent";
|
|
16
|
-
const PopoverInnerContent = forwardRef(
|
|
17
|
-
function PopoverInnerContent2(props, ref) {
|
|
18
|
-
const api = usePopoverContext();
|
|
19
|
-
const mergedProps = mergeProps(api.contentProps, props);
|
|
20
|
-
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
20
|
|
|
24
21
|
export { PopoverContent };
|
|
@@ -7,12 +7,18 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
const react$1 = require('@zag-js/react');
|
|
8
8
|
const react = require('react');
|
|
9
9
|
const factory = require('../factory.cjs');
|
|
10
|
+
require('../presence/index.cjs');
|
|
10
11
|
const popoverContext = require('./popover-context.cjs');
|
|
12
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
11
13
|
|
|
12
14
|
const PopoverPositioner = react.forwardRef(
|
|
13
15
|
(props, ref) => {
|
|
14
16
|
const api = popoverContext.usePopoverContext();
|
|
17
|
+
const presenceApi = presenceContext.usePresenceContext();
|
|
15
18
|
const mergedProps = react$1.mergeProps(api.positionerProps, props);
|
|
19
|
+
if (presenceApi.isUnmounted) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
16
22
|
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
17
23
|
}
|
|
18
24
|
);
|
|
@@ -3,12 +3,18 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.mjs';
|
|
6
|
+
import '../presence/index.mjs';
|
|
6
7
|
import { usePopoverContext } from './popover-context.mjs';
|
|
8
|
+
import { usePresenceContext } from '../presence/presence-context.mjs';
|
|
7
9
|
|
|
8
10
|
const PopoverPositioner = forwardRef(
|
|
9
11
|
(props, ref) => {
|
|
10
12
|
const api = usePopoverContext();
|
|
13
|
+
const presenceApi = usePresenceContext();
|
|
11
14
|
const mergedProps = mergeProps(api.positionerProps, props);
|
|
15
|
+
if (presenceApi.isUnmounted) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
12
18
|
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
13
19
|
}
|
|
14
20
|
);
|
|
@@ -7,11 +7,20 @@ const jsxRuntime = require('react/jsx-runtime');
|
|
|
7
7
|
const react$1 = require('@zag-js/react');
|
|
8
8
|
const react = require('react');
|
|
9
9
|
const factory = require('../factory.cjs');
|
|
10
|
+
require('../presence/index.cjs');
|
|
10
11
|
const popoverContext = require('./popover-context.cjs');
|
|
12
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
11
13
|
|
|
12
14
|
const PopoverTrigger = react.forwardRef((props, ref) => {
|
|
13
15
|
const api = popoverContext.usePopoverContext();
|
|
14
|
-
const
|
|
16
|
+
const presenceApi = presenceContext.usePresenceContext();
|
|
17
|
+
const mergedProps = react$1.mergeProps(
|
|
18
|
+
{
|
|
19
|
+
...api.triggerProps,
|
|
20
|
+
"aria-controls": presenceApi.isUnmounted ? void 0 : api.triggerProps["aria-controls"]
|
|
21
|
+
},
|
|
22
|
+
props
|
|
23
|
+
);
|
|
15
24
|
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.button, { ...mergedProps, ref });
|
|
16
25
|
});
|
|
17
26
|
PopoverTrigger.displayName = "PopoverTrigger";
|
|
@@ -3,11 +3,20 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
3
3
|
import { mergeProps } from '@zag-js/react';
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { ark } from '../factory.mjs';
|
|
6
|
+
import '../presence/index.mjs';
|
|
6
7
|
import { usePopoverContext } from './popover-context.mjs';
|
|
8
|
+
import { usePresenceContext } from '../presence/presence-context.mjs';
|
|
7
9
|
|
|
8
10
|
const PopoverTrigger = forwardRef((props, ref) => {
|
|
9
11
|
const api = usePopoverContext();
|
|
10
|
-
const
|
|
12
|
+
const presenceApi = usePresenceContext();
|
|
13
|
+
const mergedProps = mergeProps(
|
|
14
|
+
{
|
|
15
|
+
...api.triggerProps,
|
|
16
|
+
"aria-controls": presenceApi.isUnmounted ? void 0 : api.triggerProps["aria-controls"]
|
|
17
|
+
},
|
|
18
|
+
props
|
|
19
|
+
);
|
|
11
20
|
return /* @__PURE__ */ jsx(ark.button, { ...mergedProps, ref });
|
|
12
21
|
});
|
|
13
22
|
PopoverTrigger.displayName = "PopoverTrigger";
|
package/popover/popover.cjs
CHANGED
|
@@ -5,15 +5,20 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
5
5
|
|
|
6
6
|
const jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
require('react');
|
|
8
|
+
require('../presence/index.cjs');
|
|
9
|
+
const splitPresenceProps = require('../presence/split-presence-props.cjs');
|
|
8
10
|
const runIfFn = require('../run-if-fn.cjs');
|
|
9
11
|
const popoverContext = require('./popover-context.cjs');
|
|
10
12
|
const usePopover = require('./use-popover.cjs');
|
|
13
|
+
const usePresence = require('../presence/use-presence.cjs');
|
|
14
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
11
15
|
|
|
12
16
|
const Popover = (props) => {
|
|
13
|
-
const { children, ...
|
|
14
|
-
const api = usePopover.usePopover(
|
|
17
|
+
const [presenceProps, { children, ...localProps }] = splitPresenceProps.splitPresenceProps(props);
|
|
18
|
+
const api = usePopover.usePopover(localProps);
|
|
19
|
+
const presenceApi = usePresence.usePresence({ ...presenceProps, present: api.isOpen });
|
|
15
20
|
const view = runIfFn.runIfFn(children, api);
|
|
16
|
-
return /* @__PURE__ */ jsxRuntime.jsx(popoverContext.PopoverProvider, { value: api, children: view });
|
|
21
|
+
return /* @__PURE__ */ jsxRuntime.jsx(popoverContext.PopoverProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: view }) });
|
|
17
22
|
};
|
|
18
23
|
|
|
19
24
|
exports.Popover = Popover;
|
package/popover/popover.d.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { JSX } from 'react/jsx-runtime';
|
|
2
2
|
import { type ReactNode } from 'react';
|
|
3
|
-
import type {
|
|
4
|
-
import { type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
children?: ReactNode | ((props: PopoverContext) => ReactNode);
|
|
8
|
-
}> {
|
|
3
|
+
import type { UsePresenceProps } from '../presence';
|
|
4
|
+
import { type UsePopoverProps, type UsePopoverReturn } from './use-popover';
|
|
5
|
+
export interface PopoverProps extends UsePopoverProps, UsePresenceProps {
|
|
6
|
+
children?: ReactNode | ((api: UsePopoverReturn) => ReactNode);
|
|
9
7
|
}
|
|
10
8
|
export declare const Popover: (props: PopoverProps) => JSX.Element;
|
package/popover/popover.mjs
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import 'react';
|
|
4
|
+
import '../presence/index.mjs';
|
|
5
|
+
import { splitPresenceProps } from '../presence/split-presence-props.mjs';
|
|
4
6
|
import { runIfFn } from '../run-if-fn.mjs';
|
|
5
7
|
import { PopoverProvider } from './popover-context.mjs';
|
|
6
8
|
import { usePopover } from './use-popover.mjs';
|
|
9
|
+
import { usePresence } from '../presence/use-presence.mjs';
|
|
10
|
+
import { PresenceProvider } from '../presence/presence-context.mjs';
|
|
7
11
|
|
|
8
12
|
const Popover = (props) => {
|
|
9
|
-
const { children, ...
|
|
10
|
-
const api = usePopover(
|
|
13
|
+
const [presenceProps, { children, ...localProps }] = splitPresenceProps(props);
|
|
14
|
+
const api = usePopover(localProps);
|
|
15
|
+
const presenceApi = usePresence({ ...presenceProps, present: api.isOpen });
|
|
11
16
|
const view = runIfFn(children, api);
|
|
12
|
-
return /* @__PURE__ */ jsx(PopoverProvider, { value: api, children: view });
|
|
17
|
+
return /* @__PURE__ */ jsx(PopoverProvider, { value: api, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presenceApi, children: view }) });
|
|
13
18
|
};
|
|
14
19
|
|
|
15
20
|
export { Popover };
|
package/presence/index.cjs
CHANGED
|
@@ -4,11 +4,19 @@
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
6
|
const presence = require('./presence.cjs');
|
|
7
|
+
const presenceContext = require('./presence-context.cjs');
|
|
8
|
+
const presencePropsContext = require('./presence-props-context.cjs');
|
|
7
9
|
const splitPresenceProps = require('./split-presence-props.cjs');
|
|
10
|
+
const usePresence = require('./use-presence.cjs');
|
|
8
11
|
|
|
9
12
|
const Presence = Object.assign(presence.Presence, {
|
|
10
13
|
Root: presence.Presence
|
|
11
14
|
});
|
|
12
15
|
|
|
16
|
+
exports.PresenceProvider = presenceContext.PresenceProvider;
|
|
17
|
+
exports.usePresenceContext = presenceContext.usePresenceContext;
|
|
18
|
+
exports.PresencePropsProvider = presencePropsContext.PresencePropsProvider;
|
|
19
|
+
exports.usePresencePropsContext = presencePropsContext.usePresencePropsContext;
|
|
13
20
|
exports.splitPresenceProps = splitPresenceProps.splitPresenceProps;
|
|
21
|
+
exports.usePresence = usePresence.usePresence;
|
|
14
22
|
exports.Presence = Presence;
|
package/presence/index.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
2
|
/// <reference types="react" />
|
|
3
3
|
import { type PresenceProps } from './presence';
|
|
4
|
+
import { PresenceProvider, usePresenceContext, type PresenceContext } from './presence-context';
|
|
5
|
+
import { PresencePropsProvider, usePresencePropsContext, type PresencePropsContext } from './presence-props-context';
|
|
4
6
|
import { splitPresenceProps } from './split-presence-props';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
import { usePresence, type UsePresenceProps, type UsePresenceReturn } from './use-presence';
|
|
8
|
+
declare const Presence: ForwardRefExoticComponent<PresenceProps & RefAttributes<HTMLDivElement>> & {
|
|
9
|
+
Root: ForwardRefExoticComponent<PresenceProps & RefAttributes<HTMLDivElement>>;
|
|
7
10
|
};
|
|
8
|
-
export { Presence, splitPresenceProps };
|
|
9
|
-
export type { PresenceProps };
|
|
11
|
+
export { Presence, PresencePropsProvider, PresenceProvider, splitPresenceProps, usePresence, usePresenceContext, usePresencePropsContext, };
|
|
12
|
+
export type { PresenceContext, PresenceProps, PresencePropsContext, UsePresenceProps, UsePresenceReturn, };
|
package/presence/index.mjs
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { Presence as Presence$1 } from './presence.mjs';
|
|
3
|
+
export { PresenceProvider, usePresenceContext } from './presence-context.mjs';
|
|
4
|
+
export { PresencePropsProvider, usePresencePropsContext } from './presence-props-context.mjs';
|
|
3
5
|
export { splitPresenceProps } from './split-presence-props.mjs';
|
|
6
|
+
export { usePresence } from './use-presence.mjs';
|
|
4
7
|
|
|
5
8
|
const Presence = Object.assign(Presence$1, {
|
|
6
9
|
Root: Presence$1
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
|
+
|
|
6
|
+
const createContext = require('../create-context.cjs');
|
|
7
|
+
|
|
8
|
+
const [PresenceProvider, usePresenceContext] = createContext.createContext({
|
|
9
|
+
name: "PresenceContext",
|
|
10
|
+
hookName: "usePresenceContext",
|
|
11
|
+
providerName: "<PresenceProvider />"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
exports.PresenceProvider = PresenceProvider;
|
|
15
|
+
exports.usePresenceContext = usePresenceContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Provider } from 'react';
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import type { UsePresenceReturn } from './use-presence';
|
|
4
|
+
export interface PresenceContext extends UsePresenceReturn {
|
|
5
|
+
}
|
|
6
|
+
export declare const PresenceProvider: Provider<PresenceContext>, usePresenceContext: () => PresenceContext;
|