@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
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext } from '../create-context.mjs';
|
|
3
|
+
|
|
4
|
+
const [PresenceProvider, usePresenceContext] = createContext({
|
|
5
|
+
name: "PresenceContext",
|
|
6
|
+
hookName: "usePresenceContext",
|
|
7
|
+
providerName: "<PresenceProvider />"
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { PresenceProvider, usePresenceContext };
|
|
@@ -0,0 +1,17 @@
|
|
|
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 [PresencePropsProvider, usePresencePropsContext] = createContext.createContext(
|
|
9
|
+
{
|
|
10
|
+
name: "PresencePropsContext",
|
|
11
|
+
hookName: "usePresencePropsContext",
|
|
12
|
+
providerName: "<PresencePropsProvider />"
|
|
13
|
+
}
|
|
14
|
+
);
|
|
15
|
+
|
|
16
|
+
exports.PresencePropsProvider = PresencePropsProvider;
|
|
17
|
+
exports.usePresencePropsContext = usePresencePropsContext;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Provider } from 'react';
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import type { UsePresenceProps } from './use-presence';
|
|
4
|
+
export interface PresencePropsContext extends UsePresenceProps {
|
|
5
|
+
}
|
|
6
|
+
export declare const PresencePropsProvider: Provider<PresencePropsContext>, usePresencePropsContext: () => PresencePropsContext;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { createContext } from '../create-context.mjs';
|
|
3
|
+
|
|
4
|
+
const [PresencePropsProvider, usePresencePropsContext] = createContext(
|
|
5
|
+
{
|
|
6
|
+
name: "PresencePropsContext",
|
|
7
|
+
hookName: "usePresencePropsContext",
|
|
8
|
+
providerName: "<PresencePropsProvider />"
|
|
9
|
+
}
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export { PresencePropsProvider, usePresencePropsContext };
|
package/presence/presence.cjs
CHANGED
|
@@ -3,29 +3,28 @@
|
|
|
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
|
-
const
|
|
8
|
-
const
|
|
8
|
+
const factory = require('../factory.cjs');
|
|
9
|
+
const splitPresenceProps = require('./split-presence-props.cjs');
|
|
9
10
|
const usePresence = require('./use-presence.cjs');
|
|
10
11
|
|
|
11
|
-
const Presence = (props) => {
|
|
12
|
-
const [presenceProps,
|
|
12
|
+
const Presence = react.forwardRef((props, ref) => {
|
|
13
|
+
const [presenceProps, localProps] = splitPresenceProps.splitPresenceProps(props);
|
|
13
14
|
const api = usePresence.usePresence(presenceProps);
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
wasEverPresent.current = true;
|
|
15
|
+
if (api.isUnmounted) {
|
|
16
|
+
return null;
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
};
|
|
18
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
19
|
+
factory.ark.div,
|
|
20
|
+
{
|
|
21
|
+
...localProps,
|
|
22
|
+
...api.getPresenceProps(ref),
|
|
23
|
+
"data-scope": "presence",
|
|
24
|
+
"data-part": "root"
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
});
|
|
28
|
+
Presence.displayName = "Presence";
|
|
30
29
|
|
|
31
30
|
exports.Presence = Presence;
|
package/presence/presence.d.ts
CHANGED
|
@@ -1,23 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
/// <reference types="react" />
|
|
3
|
+
import { type HTMLArkProps } from '../factory';
|
|
4
|
+
import type { Assign } from '../types';
|
|
2
5
|
import { type UsePresenceProps } from './use-presence';
|
|
3
|
-
export interface PresenceProps extends UsePresenceProps {
|
|
4
|
-
/**
|
|
5
|
-
* Only a single child is allowed.
|
|
6
|
-
*/
|
|
7
|
-
children: ReactElement;
|
|
8
|
-
/**
|
|
9
|
-
* Whether to enable lazy mounting
|
|
10
|
-
* @default false
|
|
11
|
-
*/
|
|
12
|
-
lazyMount?: boolean;
|
|
13
|
-
/**
|
|
14
|
-
* Whether to unmount on exit.
|
|
15
|
-
* @default false
|
|
16
|
-
*/
|
|
17
|
-
unmountOnExit?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
* A fallback to render the component is not present.
|
|
20
|
-
*/
|
|
21
|
-
fallback?: ReactElement;
|
|
6
|
+
export interface PresenceProps extends Assign<HTMLArkProps<'div'>, UsePresenceProps> {
|
|
22
7
|
}
|
|
23
|
-
export declare const Presence:
|
|
8
|
+
export declare const Presence: ForwardRefExoticComponent<PresenceProps & RefAttributes<HTMLDivElement>>;
|
package/presence/presence.mjs
CHANGED
|
@@ -1,27 +1,26 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { forwardRef } from 'react';
|
|
4
|
+
import { ark } from '../factory.mjs';
|
|
5
|
+
import { splitPresenceProps } from './split-presence-props.mjs';
|
|
5
6
|
import { usePresence } from './use-presence.mjs';
|
|
6
7
|
|
|
7
|
-
const Presence = (props) => {
|
|
8
|
-
const [presenceProps,
|
|
8
|
+
const Presence = forwardRef((props, ref) => {
|
|
9
|
+
const [presenceProps, localProps] = splitPresenceProps(props);
|
|
9
10
|
const api = usePresence(presenceProps);
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
wasEverPresent.current = true;
|
|
11
|
+
if (api.isUnmounted) {
|
|
12
|
+
return null;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
};
|
|
14
|
+
return /* @__PURE__ */ jsx(
|
|
15
|
+
ark.div,
|
|
16
|
+
{
|
|
17
|
+
...localProps,
|
|
18
|
+
...api.getPresenceProps(ref),
|
|
19
|
+
"data-scope": "presence",
|
|
20
|
+
"data-part": "root"
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
});
|
|
24
|
+
Presence.displayName = "Presence";
|
|
26
25
|
|
|
27
26
|
export { Presence };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function splitPresenceProps<T>(props: T &
|
|
1
|
+
import type { UsePresenceProps } from './use-presence';
|
|
2
|
+
export declare function splitPresenceProps<T>(props: T & UsePresenceProps): [UsePresenceProps, Omit<T & UsePresenceProps, "present" | "onExitComplete" | "lazyMount" | "unmountOnExit">];
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
5
5
|
|
|
6
6
|
const presence = require('@zag-js/presence');
|
|
7
|
-
const react = require('@zag-js/react');
|
|
7
|
+
const react$1 = require('@zag-js/react');
|
|
8
|
+
const react = require('react');
|
|
9
|
+
const composeRefs = require('../compose-refs.cjs');
|
|
8
10
|
const useEvent = require('../use-event.cjs');
|
|
9
11
|
|
|
10
12
|
function _interopNamespaceDefault(e) {
|
|
@@ -27,12 +29,28 @@ function _interopNamespaceDefault(e) {
|
|
|
27
29
|
const presence__namespace = /*#__PURE__*/_interopNamespaceDefault(presence);
|
|
28
30
|
|
|
29
31
|
const usePresence = (props) => {
|
|
32
|
+
const { lazyMount, unmountOnExit, ...rest } = props;
|
|
33
|
+
const wasEverPresent = react.useRef(false);
|
|
30
34
|
const context = {
|
|
31
|
-
...
|
|
35
|
+
...rest,
|
|
32
36
|
onExitComplete: useEvent.useEvent(props.onExitComplete)
|
|
33
37
|
};
|
|
34
|
-
const [state, send] = react.useMachine(presence__namespace.machine(context), { context });
|
|
35
|
-
|
|
38
|
+
const [state, send] = react$1.useMachine(presence__namespace.machine(context), { context });
|
|
39
|
+
const api = presence__namespace.connect(state, send, react$1.normalizeProps);
|
|
40
|
+
if (api.isPresent) {
|
|
41
|
+
wasEverPresent.current = true;
|
|
42
|
+
}
|
|
43
|
+
const isUnmounted = !api.isPresent && !wasEverPresent.current && lazyMount || unmountOnExit && !api.isPresent && wasEverPresent.current;
|
|
44
|
+
const getPresenceProps = (ref) => ({
|
|
45
|
+
ref: composeRefs.composeRefs(api.setNode, ref),
|
|
46
|
+
"data-state": props.present ? "open" : "closed",
|
|
47
|
+
hidden: !api.isPresent
|
|
48
|
+
});
|
|
49
|
+
return {
|
|
50
|
+
getPresenceProps,
|
|
51
|
+
isPresent: api.isPresent,
|
|
52
|
+
isUnmounted
|
|
53
|
+
};
|
|
36
54
|
};
|
|
37
55
|
|
|
38
56
|
exports.usePresence = usePresence;
|
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
import * as presence from '@zag-js/presence';
|
|
2
|
+
import { type ForwardedRef } from 'react';
|
|
2
3
|
import type { Optional } from '../types';
|
|
3
4
|
export interface UsePresenceProps extends Optional<presence.Context, 'present'> {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to enable lazy mounting
|
|
7
|
+
* @default false
|
|
8
|
+
*/
|
|
9
|
+
lazyMount?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Whether to unmount on exit.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
unmountOnExit?: boolean;
|
|
4
15
|
}
|
|
5
|
-
export
|
|
16
|
+
export type UsePresenceReturn = ReturnType<typeof usePresence>;
|
|
17
|
+
export declare const usePresence: (props: UsePresenceProps) => {
|
|
18
|
+
getPresenceProps: <T extends HTMLElement>(ref: ForwardedRef<T>) => {
|
|
19
|
+
ref: ForwardedRef<T>;
|
|
20
|
+
'data-state': string;
|
|
21
|
+
hidden: boolean;
|
|
22
|
+
};
|
|
23
|
+
isPresent: boolean;
|
|
24
|
+
isUnmounted: boolean | undefined;
|
|
25
|
+
};
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import * as presence from '@zag-js/presence';
|
|
3
3
|
import { useMachine, normalizeProps } from '@zag-js/react';
|
|
4
|
+
import { useRef } from 'react';
|
|
5
|
+
import { composeRefs } from '../compose-refs.mjs';
|
|
4
6
|
import { useEvent } from '../use-event.mjs';
|
|
5
7
|
|
|
6
8
|
const usePresence = (props) => {
|
|
9
|
+
const { lazyMount, unmountOnExit, ...rest } = props;
|
|
10
|
+
const wasEverPresent = useRef(false);
|
|
7
11
|
const context = {
|
|
8
|
-
...
|
|
12
|
+
...rest,
|
|
9
13
|
onExitComplete: useEvent(props.onExitComplete)
|
|
10
14
|
};
|
|
11
15
|
const [state, send] = useMachine(presence.machine(context), { context });
|
|
12
|
-
|
|
16
|
+
const api = presence.connect(state, send, normalizeProps);
|
|
17
|
+
if (api.isPresent) {
|
|
18
|
+
wasEverPresent.current = true;
|
|
19
|
+
}
|
|
20
|
+
const isUnmounted = !api.isPresent && !wasEverPresent.current && lazyMount || unmountOnExit && !api.isPresent && wasEverPresent.current;
|
|
21
|
+
const getPresenceProps = (ref) => ({
|
|
22
|
+
ref: composeRefs(api.setNode, ref),
|
|
23
|
+
"data-state": props.present ? "open" : "closed",
|
|
24
|
+
hidden: !api.isPresent
|
|
25
|
+
});
|
|
26
|
+
return {
|
|
27
|
+
getPresenceProps,
|
|
28
|
+
isPresent: api.isPresent,
|
|
29
|
+
isUnmounted
|
|
30
|
+
};
|
|
13
31
|
};
|
|
14
32
|
|
|
15
33
|
export { usePresence };
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
-
/// <reference types="react" />
|
|
3
1
|
import type { ItemProps, ItemState } from '@zag-js/radio-group';
|
|
2
|
+
import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react';
|
|
4
3
|
import { type HTMLArkProps } from '../factory';
|
|
5
4
|
import type { Assign } from '../types';
|
|
6
5
|
export interface RadioGroupItemProps extends Assign<HTMLArkProps<'label'>, {
|
|
7
|
-
children?:
|
|
6
|
+
children?: ReactNode | ((state: ItemState) => ReactNode);
|
|
8
7
|
}>, ItemProps {
|
|
9
8
|
}
|
|
10
9
|
export declare const RadioGroupItem: ForwardRefExoticComponent<RadioGroupItemProps & RefAttributes<HTMLLabelElement>>;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react';
|
|
2
2
|
import { type HTMLArkProps } from '../factory';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
import type { Assign } from '../types';
|
|
4
|
+
import type { UseRatingGroupReturn } from './use-rating-group';
|
|
5
|
+
export interface RatingGroupControlProps extends Assign<HTMLArkProps<'div'>, {
|
|
6
|
+
children?: ReactNode | ((api: UseRatingGroupReturn) => ReactNode);
|
|
7
|
+
}> {
|
|
6
8
|
}
|
|
7
9
|
export declare const RatingGroupControl: ForwardRefExoticComponent<RatingGroupControlProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { ItemProps } from '@zag-js/rating-group';
|
|
1
|
+
import type { ItemProps, ItemState } from '@zag-js/rating-group';
|
|
2
2
|
import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react';
|
|
3
3
|
import { type HTMLArkProps } from '../factory';
|
|
4
4
|
import type { Assign } from '../types';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}> {
|
|
5
|
+
export interface RatingGroupItemProps extends Assign<HTMLArkProps<'span'>, {
|
|
6
|
+
children?: ReactNode | ((state: ItemState) => ReactNode);
|
|
7
|
+
}>, ItemProps {
|
|
9
8
|
}
|
|
10
9
|
export declare const RatingGroupItem: ForwardRefExoticComponent<RatingGroupItemProps & RefAttributes<HTMLSpanElement>>;
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
-
/// <reference types="react" />
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react';
|
|
3
2
|
import { type HTMLArkProps } from '../factory';
|
|
4
3
|
import type { Assign } from '../types';
|
|
5
4
|
import { type ItemState, type SegmentGroupItemContext } from './segment-group-item-context';
|
|
6
5
|
export interface SegmentGroupItemProps extends Assign<HTMLArkProps<'label'>, {
|
|
7
|
-
children?:
|
|
6
|
+
children?: ReactNode | ((state: ItemState) => ReactNode);
|
|
8
7
|
}>, SegmentGroupItemContext {
|
|
9
8
|
}
|
|
10
9
|
export declare const SegmentGroupItem: ForwardRefExoticComponent<SegmentGroupItemProps & RefAttributes<HTMLLabelElement>>;
|
|
@@ -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 selectContext = require('./select-context.cjs');
|
|
12
|
-
const
|
|
12
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
13
13
|
|
|
14
14
|
const SelectContent = react.forwardRef((props, ref) => {
|
|
15
|
-
const [presenceProps, localProps] = splitPresenceProps.splitPresenceProps(props);
|
|
16
15
|
const api = selectContext.useSelectContext();
|
|
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
|
SelectContent.displayName = "SelectContent";
|
|
20
|
-
const SelectInnerContent = react.forwardRef(
|
|
21
|
-
function SelectInnerContent2(props, ref) {
|
|
22
|
-
const api = selectContext.useSelectContext();
|
|
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.SelectContent = SelectContent;
|
|
@@ -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 SelectContentProps extends Assign<HTMLArkProps<'div'>, Omit<PresenceProps, 'children' | 'fallback'>> {
|
|
4
|
+
export interface SelectContentProps extends HTMLArkProps<'div'> {
|
|
7
5
|
}
|
|
8
6
|
export declare const SelectContent: ForwardRefExoticComponent<SelectContentProps & 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 { useSelectContext } from './select-context.mjs';
|
|
8
|
-
import {
|
|
8
|
+
import { usePresenceContext } from '../presence/presence-context.mjs';
|
|
9
9
|
|
|
10
10
|
const SelectContent = forwardRef((props, ref) => {
|
|
11
|
-
const [presenceProps, localProps] = splitPresenceProps(props);
|
|
12
11
|
const api = useSelectContext();
|
|
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
|
SelectContent.displayName = "SelectContent";
|
|
16
|
-
const SelectInnerContent = forwardRef(
|
|
17
|
-
function SelectInnerContent2(props, ref) {
|
|
18
|
-
const api = useSelectContext();
|
|
19
|
-
const mergedProps = mergeProps(api.contentProps, props);
|
|
20
|
-
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
21
|
-
}
|
|
22
|
-
);
|
|
23
20
|
|
|
24
21
|
export { SelectContent };
|
package/select/select-item.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
-
/// <reference types="react" />
|
|
3
1
|
import type { ItemProps, ItemState } from '@zag-js/select';
|
|
2
|
+
import { ForwardRefExoticComponent, RefAttributes, type ReactNode } from 'react';
|
|
4
3
|
import { type HTMLArkProps } from '../factory';
|
|
5
4
|
import type { Assign } from '../types';
|
|
6
5
|
export interface SelectItemProps extends Assign<HTMLArkProps<'div'>, {
|
|
7
|
-
children?:
|
|
6
|
+
children?: ReactNode | ((state: ItemState) => ReactNode);
|
|
8
7
|
}>, ItemProps {
|
|
9
8
|
}
|
|
10
9
|
export declare const SelectItem: ForwardRefExoticComponent<SelectItemProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -7,11 +7,17 @@ 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 selectContext = require('./select-context.cjs');
|
|
12
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
11
13
|
|
|
12
14
|
const SelectPositioner = react.forwardRef((props, ref) => {
|
|
13
15
|
const api = selectContext.useSelectContext();
|
|
14
16
|
const mergedProps = react$1.mergeProps(api.positionerProps, props);
|
|
17
|
+
const presenceApi = presenceContext.usePresenceContext();
|
|
18
|
+
if (presenceApi.isUnmounted) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
15
21
|
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref });
|
|
16
22
|
});
|
|
17
23
|
SelectPositioner.displayName = "SelectPositioner";
|
|
@@ -3,11 +3,17 @@ 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 { useSelectContext } from './select-context.mjs';
|
|
8
|
+
import { usePresenceContext } from '../presence/presence-context.mjs';
|
|
7
9
|
|
|
8
10
|
const SelectPositioner = forwardRef((props, ref) => {
|
|
9
11
|
const api = useSelectContext();
|
|
10
12
|
const mergedProps = mergeProps(api.positionerProps, props);
|
|
13
|
+
const presenceApi = usePresenceContext();
|
|
14
|
+
if (presenceApi.isUnmounted) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
11
17
|
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref });
|
|
12
18
|
});
|
|
13
19
|
SelectPositioner.displayName = "SelectPositioner";
|
package/select/select.cjs
CHANGED
|
@@ -8,13 +8,18 @@ const react$1 = require('@zag-js/react');
|
|
|
8
8
|
const react = require('react');
|
|
9
9
|
const createSplitProps = require('../create-split-props.cjs');
|
|
10
10
|
const factory = require('../factory.cjs');
|
|
11
|
+
require('../presence/index.cjs');
|
|
11
12
|
const runIfFn = require('../run-if-fn.cjs');
|
|
12
13
|
const selectContext = require('./select-context.cjs');
|
|
13
14
|
const useSelect = require('./use-select.cjs');
|
|
15
|
+
const splitPresenceProps = require('../presence/split-presence-props.cjs');
|
|
16
|
+
const usePresence = require('../presence/use-presence.cjs');
|
|
17
|
+
const presenceContext = require('../presence/presence-context.cjs');
|
|
14
18
|
|
|
15
19
|
const SelectImpl = (props, ref) => {
|
|
20
|
+
const [presenceProps, selectProps] = splitPresenceProps.splitPresenceProps(props);
|
|
16
21
|
const [useSelectProps, { children, ...localProps }] = createSplitProps.createSplitProps()(
|
|
17
|
-
|
|
22
|
+
selectProps,
|
|
18
23
|
[
|
|
19
24
|
"closeOnSelect",
|
|
20
25
|
"defaultValue",
|
|
@@ -47,9 +52,10 @@ const SelectImpl = (props, ref) => {
|
|
|
47
52
|
]
|
|
48
53
|
);
|
|
49
54
|
const api = useSelect.useSelect(useSelectProps);
|
|
55
|
+
const presenceApi = usePresence.usePresence({ ...presenceProps, present: api.isOpen });
|
|
50
56
|
const view = runIfFn.runIfFn(children, api);
|
|
51
57
|
const mergedProps = react$1.mergeProps(api.rootProps, localProps);
|
|
52
|
-
return /* @__PURE__ */ jsxRuntime.jsx(selectContext.SelectProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: view }) });
|
|
58
|
+
return /* @__PURE__ */ jsxRuntime.jsx(selectContext.SelectProvider, { value: api, children: /* @__PURE__ */ jsxRuntime.jsx(presenceContext.PresenceProvider, { value: presenceApi, children: /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: view }) }) });
|
|
53
59
|
};
|
|
54
60
|
const Select = react.forwardRef(SelectImpl);
|
|
55
61
|
|
package/select/select.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import { type HTMLArkProps } from '../factory';
|
|
3
|
+
import { type UsePresenceProps } from '../presence';
|
|
3
4
|
import { type Assign, type CollectionItem } from '../types';
|
|
4
5
|
import { type UseSelectProps, type UseSelectReturn } from './use-select';
|
|
5
|
-
export interface SelectProps<T extends CollectionItem> extends Assign<HTMLArkProps<'div'>,
|
|
6
|
-
children?: ReactNode | ((
|
|
7
|
-
}
|
|
6
|
+
export interface SelectProps<T extends CollectionItem> extends Assign<Assign<HTMLArkProps<'div'>, {
|
|
7
|
+
children?: ReactNode | ((api: UseSelectReturn<T>) => ReactNode);
|
|
8
|
+
}>, UseSelectProps<T>>, UsePresenceProps {
|
|
8
9
|
}
|
|
9
10
|
export interface SelectComponent {
|
|
10
11
|
<T extends CollectionItem>(props: SelectProps<T> & React.RefAttributes<HTMLDivElement>): JSX.Element;
|
package/select/select.mjs
CHANGED
|
@@ -4,13 +4,18 @@ import { mergeProps } from '@zag-js/react';
|
|
|
4
4
|
import { forwardRef } from 'react';
|
|
5
5
|
import { createSplitProps } from '../create-split-props.mjs';
|
|
6
6
|
import { ark } from '../factory.mjs';
|
|
7
|
+
import '../presence/index.mjs';
|
|
7
8
|
import { runIfFn } from '../run-if-fn.mjs';
|
|
8
9
|
import { SelectProvider } from './select-context.mjs';
|
|
9
10
|
import { useSelect } from './use-select.mjs';
|
|
11
|
+
import { splitPresenceProps } from '../presence/split-presence-props.mjs';
|
|
12
|
+
import { usePresence } from '../presence/use-presence.mjs';
|
|
13
|
+
import { PresenceProvider } from '../presence/presence-context.mjs';
|
|
10
14
|
|
|
11
15
|
const SelectImpl = (props, ref) => {
|
|
16
|
+
const [presenceProps, selectProps] = splitPresenceProps(props);
|
|
12
17
|
const [useSelectProps, { children, ...localProps }] = createSplitProps()(
|
|
13
|
-
|
|
18
|
+
selectProps,
|
|
14
19
|
[
|
|
15
20
|
"closeOnSelect",
|
|
16
21
|
"defaultValue",
|
|
@@ -43,9 +48,10 @@ const SelectImpl = (props, ref) => {
|
|
|
43
48
|
]
|
|
44
49
|
);
|
|
45
50
|
const api = useSelect(useSelectProps);
|
|
51
|
+
const presenceApi = usePresence({ ...presenceProps, present: api.isOpen });
|
|
46
52
|
const view = runIfFn(children, api);
|
|
47
53
|
const mergedProps = mergeProps(api.rootProps, localProps);
|
|
48
|
-
return /* @__PURE__ */ jsx(SelectProvider, { value: api, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: view }) });
|
|
54
|
+
return /* @__PURE__ */ jsx(SelectProvider, { value: api, children: /* @__PURE__ */ jsx(PresenceProvider, { value: presenceApi, children: /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: view }) }) });
|
|
49
55
|
};
|
|
50
56
|
const Select = forwardRef(SelectImpl);
|
|
51
57
|
|
|
@@ -7,15 +7,13 @@ 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
|
-
const runIfFn = require('../run-if-fn.cjs');
|
|
11
10
|
const sliderContext = require('./slider-context.cjs');
|
|
12
11
|
|
|
13
12
|
const SliderValueText = react.forwardRef((props, ref) => {
|
|
14
13
|
const { children, ...rest } = props;
|
|
15
14
|
const api = sliderContext.useSliderContext();
|
|
16
15
|
const mergedProps = react$1.mergeProps(api.valueTextProps, rest);
|
|
17
|
-
|
|
18
|
-
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.div, { ...mergedProps, ref, children: view });
|
|
16
|
+
return /* @__PURE__ */ jsxRuntime.jsx(factory.ark.span, { ...mergedProps, ref, children: children || api.value.join(", ") });
|
|
19
17
|
});
|
|
20
18
|
SliderValueText.displayName = "SliderValueText";
|
|
21
19
|
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import { ForwardRefExoticComponent, RefAttributes
|
|
1
|
+
import { ForwardRefExoticComponent, RefAttributes } from 'react';
|
|
2
|
+
/// <reference types="react" />
|
|
2
3
|
import { type HTMLArkProps } from '../factory';
|
|
3
|
-
|
|
4
|
-
import { type UseSliderReturn } from './use-slider';
|
|
5
|
-
export interface SliderValueTextProps extends Assign<HTMLArkProps<'output'>, {
|
|
6
|
-
children?: ((api: UseSliderReturn) => ReactNode) | ReactNode;
|
|
7
|
-
}> {
|
|
4
|
+
export interface SliderValueTextProps extends HTMLArkProps<'span'> {
|
|
8
5
|
}
|
|
9
6
|
export declare const SliderValueText: ForwardRefExoticComponent<SliderValueTextProps & RefAttributes<HTMLDivElement>>;
|
|
@@ -3,15 +3,13 @@ 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 { runIfFn } from '../run-if-fn.mjs';
|
|
7
6
|
import { useSliderContext } from './slider-context.mjs';
|
|
8
7
|
|
|
9
8
|
const SliderValueText = forwardRef((props, ref) => {
|
|
10
9
|
const { children, ...rest } = props;
|
|
11
10
|
const api = useSliderContext();
|
|
12
11
|
const mergedProps = mergeProps(api.valueTextProps, rest);
|
|
13
|
-
|
|
14
|
-
return /* @__PURE__ */ jsx(ark.div, { ...mergedProps, ref, children: view });
|
|
12
|
+
return /* @__PURE__ */ jsx(ark.span, { ...mergedProps, ref, children: children || api.value.join(", ") });
|
|
15
13
|
});
|
|
16
14
|
SliderValueText.displayName = "SliderValueText";
|
|
17
15
|
|
package/slider/slider.d.ts
CHANGED
|
@@ -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 UseSliderProps, type UseSliderReturn } from './use-slider';
|
|
5
|
-
export interface SliderProps extends Assign<HTMLArkProps<'div'>,
|
|
6
|
-
children?: ((api: UseSliderReturn) => ReactNode)
|
|
7
|
-
}> {
|
|
5
|
+
export interface SliderProps extends Assign<Assign<HTMLArkProps<'div'>, {
|
|
6
|
+
children?: ReactNode | ((api: UseSliderReturn) => ReactNode);
|
|
7
|
+
}>, UseSliderProps> {
|
|
8
8
|
}
|
|
9
9
|
export declare const Slider: ForwardRefExoticComponent<SliderProps & RefAttributes<HTMLDivElement>>;
|