@limonify/zest-ui 0.1.5 → 0.3.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/lib/avatar/root/AvatarRoot.d.ts.map +1 -1
- package/lib/avatar/root/AvatarRoot.js +1 -1
- package/lib/avatar/root/AvatarRoot.js.map +1 -1
- package/lib/button/Button.d.ts.map +1 -1
- package/lib/button/Button.js +1 -1
- package/lib/button/Button.js.map +1 -1
- package/lib/checkbox/index.d.ts +1 -0
- package/lib/checkbox/index.d.ts.map +1 -1
- package/lib/checkbox/index.js +3 -1
- package/lib/checkbox/index.js.map +1 -1
- package/lib/checkbox-group/CheckboxGroup.d.ts.map +1 -1
- package/lib/checkbox-group/CheckboxGroup.js +1 -1
- package/lib/checkbox-group/CheckboxGroup.js.map +1 -1
- package/lib/collapsible/panel/useCollapsiblePanel.d.ts.map +1 -1
- package/lib/collapsible/panel/useCollapsiblePanel.js +2 -0
- package/lib/collapsible/panel/useCollapsiblePanel.js.map +1 -1
- package/lib/dialog/index.d.ts +1 -0
- package/lib/dialog/index.d.ts.map +1 -1
- package/lib/dialog/index.js +3 -1
- package/lib/dialog/index.js.map +1 -1
- package/lib/dialog/popup/DialogPopup.d.ts +6 -0
- package/lib/dialog/popup/DialogPopup.d.ts.map +1 -1
- package/lib/dialog/popup/DialogPopup.js +2 -2
- package/lib/dialog/popup/DialogPopup.js.map +1 -1
- package/lib/dialog/popup/useDialogPopupProps.d.ts +1 -0
- package/lib/dialog/popup/useDialogPopupProps.d.ts.map +1 -1
- package/lib/dialog/popup/useDialogPopupProps.js +3 -0
- package/lib/dialog/popup/useDialogPopupProps.js.map +1 -1
- package/lib/dialog/root/DialogTransitionContext.d.ts +8 -0
- package/lib/dialog/root/DialogTransitionContext.d.ts.map +1 -0
- package/lib/dialog/root/DialogTransitionContext.js +44 -0
- package/lib/dialog/root/DialogTransitionContext.js.map +1 -0
- package/lib/dialog/root/useRenderDialogRoot.d.ts.map +1 -1
- package/lib/dialog/root/useRenderDialogRoot.js +40 -1
- package/lib/dialog/root/useRenderDialogRoot.js.map +1 -1
- package/lib/drawer/popup/DrawerPopup.d.ts +6 -0
- package/lib/drawer/popup/DrawerPopup.d.ts.map +1 -1
- package/lib/drawer/popup/DrawerPopup.js +2 -1
- package/lib/drawer/popup/DrawerPopup.js.map +1 -1
- package/lib/input/Input.d.ts +2 -1
- package/lib/input/Input.d.ts.map +1 -1
- package/lib/input/Input.js +35 -2
- package/lib/input/Input.js.map +1 -1
- package/lib/menu/item/MenuItem.d.ts.map +1 -1
- package/lib/menu/item/MenuItem.js +1 -1
- package/lib/menu/item/MenuItem.js.map +1 -1
- package/lib/menu/popup/MenuPopup.d.ts +15 -0
- package/lib/menu/popup/MenuPopup.d.ts.map +1 -1
- package/lib/menu/popup/MenuPopup.js +4 -1
- package/lib/menu/popup/MenuPopup.js.map +1 -1
- package/lib/menu/root/MenuRoot.d.ts +1 -1
- package/lib/menu/root/MenuRoot.d.ts.map +1 -1
- package/lib/menu/root/MenuRoot.js +40 -1
- package/lib/menu/root/MenuRoot.js.map +1 -1
- package/lib/menu/root/MenuTransitionContext.d.ts +8 -0
- package/lib/menu/root/MenuTransitionContext.d.ts.map +1 -0
- package/lib/menu/root/MenuTransitionContext.js +44 -0
- package/lib/menu/root/MenuTransitionContext.js.map +1 -0
- package/lib/popover/popup/PopoverPopup.d.ts +6 -0
- package/lib/popover/popup/PopoverPopup.d.ts.map +1 -1
- package/lib/popover/popup/PopoverPopup.js +4 -1
- package/lib/popover/popup/PopoverPopup.js.map +1 -1
- package/lib/popover/root/PopoverRoot.d.ts +1 -1
- package/lib/popover/root/PopoverRoot.d.ts.map +1 -1
- package/lib/popover/root/PopoverRoot.js +40 -1
- package/lib/popover/root/PopoverRoot.js.map +1 -1
- package/lib/popover/root/PopoverTransitionContext.d.ts +8 -0
- package/lib/popover/root/PopoverTransitionContext.d.ts.map +1 -0
- package/lib/popover/root/PopoverTransitionContext.js +44 -0
- package/lib/popover/root/PopoverTransitionContext.js.map +1 -0
- package/lib/radio/index.d.ts +1 -0
- package/lib/radio/index.d.ts.map +1 -1
- package/lib/radio/index.js +3 -1
- package/lib/radio/index.js.map +1 -1
- package/lib/radio-group/RadioGroup.d.ts.map +1 -1
- package/lib/radio-group/RadioGroup.js +1 -1
- package/lib/radio-group/RadioGroup.js.map +1 -1
- package/lib/select/list/SelectList.d.ts.map +1 -1
- package/lib/select/list/SelectList.js +9 -1
- package/lib/select/list/SelectList.js.map +1 -1
- package/lib/select/popup/SelectPopup.d.ts +15 -0
- package/lib/select/popup/SelectPopup.d.ts.map +1 -1
- package/lib/select/popup/SelectPopup.js +4 -1
- package/lib/select/popup/SelectPopup.js.map +1 -1
- package/lib/select/root/SelectRoot.d.ts +1 -1
- package/lib/select/root/SelectRoot.d.ts.map +1 -1
- package/lib/select/root/SelectRoot.js +40 -1
- package/lib/select/root/SelectRoot.js.map +1 -1
- package/lib/select/root/SelectTransitionContext.d.ts +8 -0
- package/lib/select/root/SelectTransitionContext.d.ts.map +1 -0
- package/lib/select/root/SelectTransitionContext.js +44 -0
- package/lib/select/root/SelectTransitionContext.js.map +1 -0
- package/lib/separator/Separator.d.ts +2 -1
- package/lib/separator/Separator.d.ts.map +1 -1
- package/lib/separator/Separator.js +35 -1
- package/lib/separator/Separator.js.map +1 -1
- package/lib/slider/thumb/SliderThumb.d.ts +4 -0
- package/lib/slider/thumb/SliderThumb.d.ts.map +1 -1
- package/lib/slider/thumb/SliderThumb.js +1 -1
- package/lib/slider/thumb/SliderThumb.js.map +1 -1
- package/lib/switch/index.d.ts +1 -0
- package/lib/switch/index.d.ts.map +1 -1
- package/lib/switch/index.js +3 -1
- package/lib/switch/index.js.map +1 -1
- package/lib/tabs/tab/TabsTab.d.ts.map +1 -1
- package/lib/tabs/tab/TabsTab.js +1 -1
- package/lib/tabs/tab/TabsTab.js.map +1 -1
- package/lib/toggle/Toggle.d.ts +2 -1
- package/lib/toggle/Toggle.d.ts.map +1 -1
- package/lib/toggle/Toggle.js +35 -1
- package/lib/toggle/Toggle.js.map +1 -1
- package/lib/toggle-group/ToggleGroup.d.ts.map +1 -1
- package/lib/toggle-group/ToggleGroup.js +1 -1
- package/lib/toggle-group/ToggleGroup.js.map +1 -1
- package/lib/tooltip/popup/TooltipPopup.d.ts +15 -0
- package/lib/tooltip/popup/TooltipPopup.d.ts.map +1 -1
- package/lib/tooltip/popup/TooltipPopup.js +5 -1
- package/lib/tooltip/popup/TooltipPopup.js.map +1 -1
- package/lib/tooltip/root/TooltipRoot.d.ts +1 -1
- package/lib/tooltip/root/TooltipRoot.d.ts.map +1 -1
- package/lib/tooltip/root/TooltipRoot.js +40 -1
- package/lib/tooltip/root/TooltipRoot.js.map +1 -1
- package/lib/tooltip/root/TooltipTransitionContext.d.ts +8 -0
- package/lib/tooltip/root/TooltipTransitionContext.d.ts.map +1 -0
- package/lib/tooltip/root/TooltipTransitionContext.js +44 -0
- package/lib/tooltip/root/TooltipTransitionContext.js.map +1 -0
- package/package.json +182 -2
- package/src/avatar/root/AvatarRoot.tsx +4 -1
- package/src/button/Button.tsx +4 -1
- package/src/checkbox/index.ts +1 -0
- package/src/checkbox-group/CheckboxGroup.tsx +4 -1
- package/src/collapsible/panel/useCollapsiblePanel.tsx +1 -0
- package/src/dialog/index.ts +1 -0
- package/src/dialog/popup/DialogPopup.tsx +8 -2
- package/src/dialog/popup/useDialogPopupProps.ts +3 -0
- package/src/dialog/root/DialogTransitionContext.ts +15 -0
- package/src/dialog/root/useRenderDialogRoot.tsx +13 -1
- package/src/drawer/popup/DrawerPopup.tsx +8 -1
- package/src/input/Input.tsx +5 -1
- package/src/menu/item/MenuItem.tsx +4 -1
- package/src/menu/popup/MenuPopup.tsx +18 -1
- package/src/menu/root/MenuRoot.tsx +14 -2
- package/src/menu/root/MenuTransitionContext.ts +15 -0
- package/src/popover/popup/PopoverPopup.tsx +9 -1
- package/src/popover/root/PopoverRoot.tsx +14 -2
- package/src/popover/root/PopoverTransitionContext.ts +15 -0
- package/src/radio/index.ts +1 -0
- package/src/radio-group/RadioGroup.tsx +4 -1
- package/src/select/list/SelectList.tsx +9 -1
- package/src/select/popup/SelectPopup.tsx +18 -1
- package/src/select/root/SelectRoot.tsx +18 -2
- package/src/select/root/SelectTransitionContext.ts +15 -0
- package/src/separator/Separator.tsx +5 -1
- package/src/slider/thumb/SliderThumb.tsx +5 -1
- package/src/switch/index.ts +1 -0
- package/src/tabs/tab/TabsTab.tsx +4 -1
- package/src/toggle/Toggle.tsx +5 -1
- package/src/toggle-group/ToggleGroup.tsx +4 -1
- package/src/tooltip/popup/TooltipPopup.tsx +19 -1
- package/src/tooltip/root/TooltipRoot.tsx +18 -2
- package/src/tooltip/root/TooltipTransitionContext.ts +15 -0
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { usePopoverRootContext } from '../root/PopoverRootContext';
|
|
4
4
|
import { usePopoverPositionerContext } from '../positioner/PopoverPositionerContext';
|
|
5
|
+
import { usePopoverTransitionContext } from '../root/PopoverTransitionContext';
|
|
5
6
|
import { useRenderElement } from '../../use-render/useRenderElement';
|
|
6
7
|
import type { Align, Side } from '../../utils/useAnchorPositioning';
|
|
8
|
+
import type { TransitionStatus } from '../../internals/useTransitionStatus';
|
|
7
9
|
import type { ZestUIComponentProps } from '../../types';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -15,12 +17,13 @@ export function PopoverPopup(componentProps: PopoverPopup.Props) {
|
|
|
15
17
|
|
|
16
18
|
const store = usePopoverRootContext();
|
|
17
19
|
const { side, align } = usePopoverPositionerContext();
|
|
20
|
+
const { transitionStatus } = usePopoverTransitionContext() ?? { transitionStatus: undefined };
|
|
18
21
|
|
|
19
22
|
const open = store.useState('open');
|
|
20
23
|
const titleElementId = store.useState('titleElementId');
|
|
21
24
|
const descriptionElementId = store.useState('descriptionElementId');
|
|
22
25
|
|
|
23
|
-
const state: PopoverPopupState = { open, side, align };
|
|
26
|
+
const state: PopoverPopupState = { open, transitionStatus, side, align };
|
|
24
27
|
|
|
25
28
|
return useRenderElement(View, componentProps, {
|
|
26
29
|
state,
|
|
@@ -45,6 +48,11 @@ export interface PopoverPopupState {
|
|
|
45
48
|
* Whether the popover is currently open.
|
|
46
49
|
*/
|
|
47
50
|
open: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* The transition status of the popover: `'starting'` as it opens (auto-clears
|
|
53
|
+
* to `undefined` after one frame), `'ending'` once it is closing.
|
|
54
|
+
*/
|
|
55
|
+
transitionStatus: TransitionStatus;
|
|
48
56
|
/**
|
|
49
57
|
* The side the popup was actually placed on, after collision handling.
|
|
50
58
|
*/
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { useRefWithInit } from '../../hooks/useRefWithInit';
|
|
4
|
+
import { useTransitionStatus } from '../../internals/useTransitionStatus';
|
|
4
5
|
import { usePopupRootHandle } from '../../utils/popups/usePopupRootHandle';
|
|
5
6
|
import type { ZestChangeEventDetails } from '../../utils/createChangeEventDetails';
|
|
6
7
|
import type { REASONS } from '../../utils/reasons';
|
|
7
8
|
import { PopoverStore } from '../store/PopoverStore';
|
|
8
9
|
import type { PopoverHandle } from '../store/PopoverHandle';
|
|
9
10
|
import { PopoverRootContext } from './PopoverRootContext';
|
|
11
|
+
import { PopoverTransitionContext } from './PopoverTransitionContext';
|
|
10
12
|
|
|
11
13
|
/**
|
|
12
14
|
* Groups all parts of the popover.
|
|
@@ -43,11 +45,21 @@ export function PopoverRoot<Payload = unknown>(props: PopoverRoot.Props<Payload>
|
|
|
43
45
|
|
|
44
46
|
usePopupRootHandle({ store, handle, actionsRef });
|
|
45
47
|
|
|
48
|
+
const resolvedOpen = store.useState('open');
|
|
49
|
+
const { transitionStatus } = useTransitionStatus(resolvedOpen, false, true);
|
|
50
|
+
|
|
46
51
|
const payload = store.useState('payload') as Payload;
|
|
47
52
|
|
|
53
|
+
const transitionContextValue = React.useMemo(
|
|
54
|
+
() => ({ transitionStatus }),
|
|
55
|
+
[transitionStatus],
|
|
56
|
+
);
|
|
57
|
+
|
|
48
58
|
return (
|
|
49
59
|
<PopoverRootContext.Provider value={store}>
|
|
50
|
-
{
|
|
60
|
+
<PopoverTransitionContext.Provider value={transitionContextValue}>
|
|
61
|
+
{typeof children === 'function' ? children(payload) : children}
|
|
62
|
+
</PopoverTransitionContext.Provider>
|
|
51
63
|
</PopoverRootContext.Provider>
|
|
52
64
|
);
|
|
53
65
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { TransitionStatus } from '../../internals/useTransitionStatus';
|
|
4
|
+
|
|
5
|
+
export interface PopoverTransitionContext {
|
|
6
|
+
transitionStatus: TransitionStatus;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const PopoverTransitionContext = React.createContext<PopoverTransitionContext | undefined>(
|
|
10
|
+
undefined,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export function usePopoverTransitionContext() {
|
|
14
|
+
return React.useContext(PopoverTransitionContext);
|
|
15
|
+
}
|
package/src/radio/index.ts
CHANGED
|
@@ -53,7 +53,10 @@ export function RadioGroup<Value = any>(componentProps: RadioGroup.Props<Value>)
|
|
|
53
53
|
},
|
|
54
54
|
);
|
|
55
55
|
|
|
56
|
-
const state: RadioGroupState =
|
|
56
|
+
const state: RadioGroupState = React.useMemo(
|
|
57
|
+
() => ({ disabled, readOnly, required }),
|
|
58
|
+
[disabled, readOnly, required],
|
|
59
|
+
);
|
|
57
60
|
|
|
58
61
|
const contextValue: RadioGroupContext<Value> = React.useMemo(
|
|
59
62
|
() => ({
|
|
@@ -18,7 +18,15 @@ export function SelectList(componentProps: SelectList.Props) {
|
|
|
18
18
|
return useRenderElement(ScrollView, componentProps, {
|
|
19
19
|
state,
|
|
20
20
|
ref,
|
|
21
|
-
props: [
|
|
21
|
+
props: [
|
|
22
|
+
{
|
|
23
|
+
accessibilityRole: 'list' as const,
|
|
24
|
+
role: 'listbox' as const,
|
|
25
|
+
keyboardShouldPersistTaps: 'handled' as const,
|
|
26
|
+
keyboardDismissMode: 'on-drag' as const,
|
|
27
|
+
},
|
|
28
|
+
elementProps,
|
|
29
|
+
],
|
|
22
30
|
});
|
|
23
31
|
}
|
|
24
32
|
|
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useSelectRootContext } from '../root/SelectRootContext';
|
|
4
4
|
import { useSelectPositionerContext } from '../positioner/SelectPositionerContext';
|
|
5
|
+
import { useSelectTransitionContext } from '../root/SelectTransitionContext';
|
|
5
6
|
import { useRenderElement } from '../../use-render/useRenderElement';
|
|
6
7
|
import { CompositeList } from '../../internals/composite/list/CompositeList';
|
|
7
8
|
import type { Align, Side } from '../../utils/useAnchorPositioning';
|
|
9
|
+
import type { TransitionStatus } from '../../internals/useTransitionStatus';
|
|
8
10
|
import type { ZestUIComponentProps } from '../../types';
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -16,10 +18,11 @@ export function SelectPopup(componentProps: SelectPopup.Props) {
|
|
|
16
18
|
|
|
17
19
|
const store = useSelectRootContext();
|
|
18
20
|
const { side, align } = useSelectPositionerContext();
|
|
21
|
+
const { transitionStatus } = useSelectTransitionContext() ?? { transitionStatus: undefined };
|
|
19
22
|
|
|
20
23
|
const open = store.useState('open');
|
|
21
24
|
|
|
22
|
-
const state: SelectPopupState = { open, side, align };
|
|
25
|
+
const state: SelectPopupState = { open, transitionStatus, side, align };
|
|
23
26
|
|
|
24
27
|
const element = useRenderElement(View, componentProps, {
|
|
25
28
|
state,
|
|
@@ -39,8 +42,22 @@ export function SelectPopup(componentProps: SelectPopup.Props) {
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
export interface SelectPopupState {
|
|
45
|
+
/**
|
|
46
|
+
* Whether the select is currently open.
|
|
47
|
+
*/
|
|
42
48
|
open: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The transition status of the select: `'starting'` as it opens (auto-clears
|
|
51
|
+
* to `undefined` after one frame), `'ending'` once it is closing.
|
|
52
|
+
*/
|
|
53
|
+
transitionStatus: TransitionStatus;
|
|
54
|
+
/**
|
|
55
|
+
* The side the popup was actually placed on, after collision handling.
|
|
56
|
+
*/
|
|
43
57
|
side: Side;
|
|
58
|
+
/**
|
|
59
|
+
* The alignment the popup was actually placed with.
|
|
60
|
+
*/
|
|
44
61
|
align: Align;
|
|
45
62
|
}
|
|
46
63
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { useRefWithInit } from '../../hooks/useRefWithInit';
|
|
4
|
+
import { useTransitionStatus } from '../../internals/useTransitionStatus';
|
|
4
5
|
import type { ZestChangeEventDetails } from '../../utils/createChangeEventDetails';
|
|
5
6
|
import type { REASONS } from '../../utils/reasons';
|
|
6
7
|
import { SelectStore, type SelectItems } from '../store/SelectStore';
|
|
7
8
|
import { SelectRootContext } from './SelectRootContext';
|
|
9
|
+
import { SelectTransitionContext } from './SelectTransitionContext';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Groups all parts of the select.
|
|
@@ -52,7 +54,21 @@ export function SelectRoot<Value = any>(props: SelectRoot.Props<Value>) {
|
|
|
52
54
|
store.useContextCallback('onValueChange', onValueChange);
|
|
53
55
|
store.useSyncedValues({ disabled, readOnly, required, items, multiple });
|
|
54
56
|
|
|
55
|
-
|
|
57
|
+
const resolvedOpen = store.useState('open');
|
|
58
|
+
const { transitionStatus } = useTransitionStatus(resolvedOpen, false, true);
|
|
59
|
+
|
|
60
|
+
const transitionContextValue = React.useMemo(
|
|
61
|
+
() => ({ transitionStatus }),
|
|
62
|
+
[transitionStatus],
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<SelectRootContext.Provider value={store}>
|
|
67
|
+
<SelectTransitionContext.Provider value={transitionContextValue}>
|
|
68
|
+
{children}
|
|
69
|
+
</SelectTransitionContext.Provider>
|
|
70
|
+
</SelectRootContext.Provider>
|
|
71
|
+
);
|
|
56
72
|
}
|
|
57
73
|
|
|
58
74
|
export interface SelectRootState {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { TransitionStatus } from '../../internals/useTransitionStatus';
|
|
4
|
+
|
|
5
|
+
export interface SelectTransitionContext {
|
|
6
|
+
transitionStatus: TransitionStatus;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const SelectTransitionContext = React.createContext<SelectTransitionContext | undefined>(
|
|
10
|
+
undefined,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export function useSelectTransitionContext() {
|
|
14
|
+
return React.useContext(SelectTransitionContext);
|
|
15
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { View } from 'react-native';
|
|
3
4
|
import type { ZestUIComponentProps, Orientation } from '../types';
|
|
4
5
|
import { useRenderElement } from '../use-render/useRenderElement';
|
|
@@ -17,7 +18,10 @@ export function Separator(componentProps: Separator.Props) {
|
|
|
17
18
|
...elementProps
|
|
18
19
|
} = componentProps;
|
|
19
20
|
|
|
20
|
-
const state: SeparatorState =
|
|
21
|
+
const state: SeparatorState = React.useMemo(
|
|
22
|
+
() => ({ orientation }),
|
|
23
|
+
[orientation],
|
|
24
|
+
);
|
|
21
25
|
|
|
22
26
|
const element = useRenderElement(View, componentProps, {
|
|
23
27
|
state,
|
|
@@ -28,7 +28,7 @@ export function SliderThumb(componentProps: SliderThumb.Props) {
|
|
|
28
28
|
? { position: 'absolute' as const, bottom: `${percent}%` as const }
|
|
29
29
|
: { position: 'absolute' as const, left: `${percent}%` as const };
|
|
30
30
|
|
|
31
|
-
const thumbState: SliderThumbState = { ...state, index, value };
|
|
31
|
+
const thumbState: SliderThumbState = { ...state, index, value, percent };
|
|
32
32
|
|
|
33
33
|
return useRenderElement(View, componentProps, {
|
|
34
34
|
state: thumbState,
|
|
@@ -73,6 +73,10 @@ export interface SliderThumbState extends SliderRootState {
|
|
|
73
73
|
* This thumb's value.
|
|
74
74
|
*/
|
|
75
75
|
value: number;
|
|
76
|
+
/**
|
|
77
|
+
* This thumb's position as a percentage (0-100) of the track.
|
|
78
|
+
*/
|
|
79
|
+
percent: number;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
export interface SliderThumbProps extends ZestUIComponentProps<typeof View, SliderThumbState> {
|
package/src/switch/index.ts
CHANGED
package/src/tabs/tab/TabsTab.tsx
CHANGED
|
@@ -41,7 +41,10 @@ export function TabsTab(componentProps: TabsTab.Props) {
|
|
|
41
41
|
|
|
42
42
|
const tabPanelId = getTabPanelIdByValue(value);
|
|
43
43
|
|
|
44
|
-
const state: TabsTabState =
|
|
44
|
+
const state: TabsTabState = React.useMemo(
|
|
45
|
+
() => ({ disabled, active, orientation, tabActivationDirection, pressed }),
|
|
46
|
+
[disabled, active, orientation, tabActivationDirection, pressed],
|
|
47
|
+
);
|
|
45
48
|
|
|
46
49
|
return useRenderElement(Pressable, componentProps, {
|
|
47
50
|
state,
|
package/src/toggle/Toggle.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
2
3
|
import { Pressable, type GestureResponderEvent } from 'react-native';
|
|
3
4
|
import { useControlled } from '../hooks/useControlled';
|
|
4
5
|
import { useId } from '../hooks/useId';
|
|
@@ -65,7 +66,10 @@ export function Toggle<Value extends string = string>(componentProps: Toggle.Pro
|
|
|
65
66
|
|
|
66
67
|
const { getButtonProps } = useButton({ disabled });
|
|
67
68
|
|
|
68
|
-
const state: ToggleState =
|
|
69
|
+
const state: ToggleState = React.useMemo(
|
|
70
|
+
() => ({ disabled, pressed }),
|
|
71
|
+
[disabled, pressed],
|
|
72
|
+
);
|
|
69
73
|
|
|
70
74
|
return useRenderElement(Pressable, componentProps, {
|
|
71
75
|
state,
|
|
@@ -69,7 +69,10 @@ export function ToggleGroup<Value extends string = string>(
|
|
|
69
69
|
},
|
|
70
70
|
);
|
|
71
71
|
|
|
72
|
-
const state: ToggleGroupState =
|
|
72
|
+
const state: ToggleGroupState = React.useMemo(
|
|
73
|
+
() => ({ disabled, multiple, orientation }),
|
|
74
|
+
[disabled, multiple, orientation],
|
|
75
|
+
);
|
|
73
76
|
|
|
74
77
|
const contextValue: ToggleGroupContext<Value> = React.useMemo(
|
|
75
78
|
() => ({
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
import { View } from 'react-native';
|
|
3
3
|
import { useTooltipRootContext } from '../root/TooltipRootContext';
|
|
4
4
|
import { useTooltipPositionerContext } from '../positioner/TooltipPositionerContext';
|
|
5
|
+
import { useTooltipTransitionContext } from '../root/TooltipTransitionContext';
|
|
5
6
|
import { useRenderElement } from '../../use-render/useRenderElement';
|
|
6
7
|
import type { Align, Side } from '../../utils/useAnchorPositioning';
|
|
8
|
+
import type { TransitionStatus } from '../../internals/useTransitionStatus';
|
|
7
9
|
import type { ZestUIComponentProps } from '../../types';
|
|
8
10
|
|
|
9
11
|
/**
|
|
@@ -15,10 +17,11 @@ export function TooltipPopup(componentProps: TooltipPopup.Props) {
|
|
|
15
17
|
|
|
16
18
|
const store = useTooltipRootContext();
|
|
17
19
|
const { side, align } = useTooltipPositionerContext();
|
|
20
|
+
const { transitionStatus } = useTooltipTransitionContext() ?? { transitionStatus: undefined };
|
|
18
21
|
|
|
19
22
|
const open = store.useState('open');
|
|
20
23
|
|
|
21
|
-
const state: TooltipPopupState = { open, side, align };
|
|
24
|
+
const state: TooltipPopupState = { open, transitionStatus, side, align };
|
|
22
25
|
|
|
23
26
|
return useRenderElement(View, componentProps, {
|
|
24
27
|
state,
|
|
@@ -26,6 +29,7 @@ export function TooltipPopup(componentProps: TooltipPopup.Props) {
|
|
|
26
29
|
props: [
|
|
27
30
|
{
|
|
28
31
|
role: 'tooltip' as const,
|
|
32
|
+
accessibilityRole: 'tooltip' as const,
|
|
29
33
|
// Claim the touch responder so presses inside the popup don't reach the
|
|
30
34
|
// portal's dismissal surface.
|
|
31
35
|
onStartShouldSetResponder: () => true,
|
|
@@ -36,8 +40,22 @@ export function TooltipPopup(componentProps: TooltipPopup.Props) {
|
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
export interface TooltipPopupState {
|
|
43
|
+
/**
|
|
44
|
+
* Whether the tooltip is currently open.
|
|
45
|
+
*/
|
|
39
46
|
open: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* The transition status of the tooltip: `'starting'` as it opens (auto-clears
|
|
49
|
+
* to `undefined` after one frame), `'ending'` once it is closing.
|
|
50
|
+
*/
|
|
51
|
+
transitionStatus: TransitionStatus;
|
|
52
|
+
/**
|
|
53
|
+
* The side the popup was actually placed on, after collision handling.
|
|
54
|
+
*/
|
|
40
55
|
side: Side;
|
|
56
|
+
/**
|
|
57
|
+
* The alignment the popup was actually placed with.
|
|
58
|
+
*/
|
|
41
59
|
align: Align;
|
|
42
60
|
}
|
|
43
61
|
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import
|
|
2
|
+
import * as React from 'react';
|
|
3
3
|
import { useRefWithInit } from '../../hooks/useRefWithInit';
|
|
4
|
+
import { useTransitionStatus } from '../../internals/useTransitionStatus';
|
|
4
5
|
import type { ZestChangeEventDetails } from '../../utils/createChangeEventDetails';
|
|
5
6
|
import type { REASONS } from '../../utils/reasons';
|
|
6
7
|
import { TooltipStore } from '../store/TooltipStore';
|
|
7
8
|
import { TooltipRootContext } from './TooltipRootContext';
|
|
9
|
+
import { TooltipTransitionContext } from './TooltipTransitionContext';
|
|
8
10
|
|
|
9
11
|
/**
|
|
10
12
|
* Groups all parts of the tooltip.
|
|
@@ -26,7 +28,21 @@ export function TooltipRoot(props: TooltipRoot.Props) {
|
|
|
26
28
|
store.useControlledProp('openProp', open);
|
|
27
29
|
store.useContextCallback('onOpenChange', onOpenChange);
|
|
28
30
|
|
|
29
|
-
|
|
31
|
+
const resolvedOpen = store.useState('open');
|
|
32
|
+
const { transitionStatus } = useTransitionStatus(resolvedOpen, false, true);
|
|
33
|
+
|
|
34
|
+
const transitionContextValue = React.useMemo(
|
|
35
|
+
() => ({ transitionStatus }),
|
|
36
|
+
[transitionStatus],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<TooltipRootContext.Provider value={store}>
|
|
41
|
+
<TooltipTransitionContext.Provider value={transitionContextValue}>
|
|
42
|
+
{children}
|
|
43
|
+
</TooltipTransitionContext.Provider>
|
|
44
|
+
</TooltipRootContext.Provider>
|
|
45
|
+
);
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
export interface TooltipRootState {}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import * as React from 'react';
|
|
3
|
+
import type { TransitionStatus } from '../../internals/useTransitionStatus';
|
|
4
|
+
|
|
5
|
+
export interface TooltipTransitionContext {
|
|
6
|
+
transitionStatus: TransitionStatus;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const TooltipTransitionContext = React.createContext<TooltipTransitionContext | undefined>(
|
|
10
|
+
undefined,
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export function useTooltipTransitionContext() {
|
|
14
|
+
return React.useContext(TooltipTransitionContext);
|
|
15
|
+
}
|