@brand-map/primitives 0.0.0-broken.0 → 0.0.0-broken.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -9
- package/src/accordion/accordion.tsx +17 -17
- package/src/accordion/accordion.web.tsx +13 -13
- package/src/alert-dialog/alert-dialog.tsx +28 -28
- package/src/alert-dialog/alert-dialog.web.tsx +18 -18
- package/src/alert-dialog/types.ts +3 -3
- package/src/aspect-ratio/aspect-ratio.tsx +3 -3
- package/src/avatar/avatar.tsx +10 -10
- package/src/avatar/types.ts +2 -2
- package/src/checkbox/checkbox.tsx +9 -9
- package/src/checkbox/checkbox.web.tsx +8 -8
- package/src/collapsible/collapsible.tsx +33 -35
- package/src/collapsible/collapsible.web.tsx +9 -9
- package/src/context-menu/context-menu.tsx +45 -45
- package/src/context-menu/context-menu.web.tsx +44 -44
- package/src/dialog/dialog.tsx +11 -11
- package/src/dialog/dialog.web.tsx +15 -15
- package/src/dialog/types.ts +5 -5
- package/src/dropdown-menu/dropdown-menu.tsx +43 -43
- package/src/dropdown-menu/dropdown-menu.web.tsx +45 -45
- package/src/hooks/use-Isomorphic-layout-effect.tsx +1 -2
- package/src/hooks/use-relative-position.tsx +2 -2
- package/src/hover-card/hover-card.tsx +40 -42
- package/src/hover-card/hover-card.web.tsx +9 -9
- package/src/label/label.tsx +3 -4
- package/src/label/label.web.tsx +5 -5
- package/src/menubar/menubar.tsx +45 -45
- package/src/menubar/menubar.web.tsx +47 -47
- package/src/navigation-menu/navigation-menu.tsx +23 -23
- package/src/navigation-menu/navigation-menu.web.tsx +26 -26
- package/src/popover/popover.tsx +20 -20
- package/src/popover/popover.web.tsx +14 -14
- package/src/progress/progress.tsx +4 -4
- package/src/progress/progress.web.tsx +5 -5
- package/src/radio-group/radio-group.tsx +11 -11
- package/src/radio-group/radio-group.web.tsx +9 -9
- package/src/render/index.ts +1 -0
- package/src/{slot/slot.tsx → render/render.tsx} +26 -27
- package/src/select/select.tsx +28 -28
- package/src/select/select.web.tsx +22 -22
- package/src/separator/separator.tsx +3 -3
- package/src/slider/slider.tsx +8 -8
- package/src/slider/slider.web.tsx +6 -6
- package/src/switch/switch.context.ts +16 -0
- package/src/switch/switch.tsx +68 -38
- package/src/switch/switch.web.tsx +9 -9
- package/src/switch/types.ts +27 -6
- package/src/table/table.tsx +9 -9
- package/src/tabs/tabs.tsx +13 -13
- package/src/tabs/tabs.web.tsx +10 -10
- package/src/toast/toast.tsx +14 -14
- package/src/toggle/toggle.tsx +5 -5
- package/src/toggle/toggle.web.tsx +5 -5
- package/src/toggle-group/toggle-group.tsx +11 -11
- package/src/toggle-group/toggle-group.web.tsx +10 -10
- package/src/toolbar/toolbar.tsx +12 -12
- package/src/toolbar/toolbar.web.tsx +12 -12
- package/src/tooltip/tooltip.tsx +17 -17
- package/src/tooltip/tooltip.web.tsx +11 -11
- package/src/types/index.ts +5 -15
- package/tsconfig.json +1 -0
- package/.changeset/README.md +0 -8
- package/.changeset/config.json +0 -11
- package/.oxfmtrc.json +0 -35
- package/.oxlintrc.json +0 -166
- package/README.md +0 -78
- package/bun.lock +0 -904
- package/mise.toml +0 -3
- package/src/slot/index.ts +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useId, useState, useContext, useEffect } from "react";
|
|
2
2
|
import { BackHandler, Pressable, Text, View, type GestureResponderEvent, type LayoutChangeEvent, type LayoutRectangle } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useAugmentedRef, useControllableState, useRelativePosition, type LayoutPosition } from "../hooks";
|
|
5
5
|
import { Portal as RNPPortal } from "../portal";
|
|
6
|
-
import * as
|
|
6
|
+
import * as Render from "../render";
|
|
7
7
|
|
|
8
8
|
import type {
|
|
9
9
|
CheckboxItemProps,
|
|
@@ -49,13 +49,13 @@ interface RootContextInterface {
|
|
|
49
49
|
nativeID: string;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
const RootContext =
|
|
52
|
+
const RootContext = createContext<RootContextInterface | null>(null);
|
|
53
53
|
|
|
54
|
-
const Root =
|
|
55
|
-
const nativeID =
|
|
56
|
-
const [triggerPosition, setTriggerPosition] =
|
|
57
|
-
const [contentLayout, setContentLayout] =
|
|
58
|
-
const [open, setOpen] =
|
|
54
|
+
const Root = forwardRef<RootRef, RootProps>(({ onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
55
|
+
const nativeID = useId();
|
|
56
|
+
const [triggerPosition, setTriggerPosition] = useState<LayoutPosition | null>(null);
|
|
57
|
+
const [contentLayout, setContentLayout] = useState<LayoutRectangle | null>(null);
|
|
58
|
+
const [open, setOpen] = useState(false);
|
|
59
59
|
|
|
60
60
|
function onOpenChange(open: boolean) {
|
|
61
61
|
setOpen(open);
|
|
@@ -85,14 +85,14 @@ const Root = React.forwardRef<RootRef, RootProps>(({ onOpenChange: onOpenChangeP
|
|
|
85
85
|
Root.displayName = "RootNativeDropdownMenu";
|
|
86
86
|
|
|
87
87
|
function useRootContext() {
|
|
88
|
-
const context =
|
|
88
|
+
const context = useContext(RootContext);
|
|
89
89
|
if (!context) {
|
|
90
90
|
throw new Error("DropdownMenu compound components cannot be rendered outside the DropdownMenu component");
|
|
91
91
|
}
|
|
92
92
|
return context;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
const Trigger =
|
|
95
|
+
const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, disabled = false, ...props }, ref) => {
|
|
96
96
|
const { open, onOpenChange, setTriggerPosition } = useRootContext();
|
|
97
97
|
|
|
98
98
|
const augmentedRef = useAugmentedRef({
|
|
@@ -111,14 +111,14 @@ const Trigger = React.forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressPr
|
|
|
111
111
|
},
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
function onPress(
|
|
114
|
+
function onPress(event: GestureResponderEvent) {
|
|
115
115
|
if (disabled) return;
|
|
116
116
|
augmentedRef.current?.measure((_x, _y, width, height, pageX, pageY) => {
|
|
117
117
|
setTriggerPosition({ width, pageX, pageY: pageY, height });
|
|
118
118
|
});
|
|
119
119
|
const newValue = !open;
|
|
120
120
|
onOpenChange(newValue);
|
|
121
|
-
onPressProp?.(
|
|
121
|
+
onPressProp?.(event);
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
return (
|
|
@@ -162,16 +162,16 @@ function Portal({ keepMounted, hostName, children }: PortalProps) {
|
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
const Backdrop =
|
|
165
|
+
const Backdrop = forwardRef<BackdropRef, BackdropProps>(({ keepMounted, onPress: onPressProp, closeOnPress = true, ...props }, ref) => {
|
|
166
166
|
const { open, onOpenChange, setContentLayout, setTriggerPosition } = useRootContext();
|
|
167
167
|
|
|
168
|
-
function onPress(
|
|
168
|
+
function onPress(event: GestureResponderEvent) {
|
|
169
169
|
if (closeOnPress) {
|
|
170
170
|
setTriggerPosition(null);
|
|
171
171
|
setContentLayout(null);
|
|
172
172
|
onOpenChange(false);
|
|
173
173
|
}
|
|
174
|
-
|
|
174
|
+
onPressProp?.(event);
|
|
175
175
|
}
|
|
176
176
|
|
|
177
177
|
if (!keepMounted) {
|
|
@@ -194,7 +194,7 @@ Backdrop.displayName = "BackdropNativeDropdownMenu";
|
|
|
194
194
|
/**
|
|
195
195
|
* @info `position`, `top`, `left`, and `maxWidth` style properties are controlled internally. Opt out of this behavior by setting `disablePositioningStyle` to `true`.
|
|
196
196
|
*/
|
|
197
|
-
const Content =
|
|
197
|
+
const Content = forwardRef<ContentRef, ContentProps>(
|
|
198
198
|
(
|
|
199
199
|
{
|
|
200
200
|
render = false,
|
|
@@ -214,7 +214,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
214
214
|
) => {
|
|
215
215
|
const { open, onOpenChange, nativeID, triggerPosition, setTriggerPosition, contentLayout, setContentLayout } = useRootContext();
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
useEffect(() => {
|
|
218
218
|
const backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
219
219
|
setTriggerPosition(null);
|
|
220
220
|
setContentLayout(null);
|
|
@@ -267,16 +267,16 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
267
267
|
|
|
268
268
|
Content.displayName = "ContentNativeDropdownMenu";
|
|
269
269
|
|
|
270
|
-
const Item =
|
|
270
|
+
const Item = forwardRef<ItemRef, ItemProps>(({ textValue, onPress: onPressProp, disabled = false, closeOnPress = true, ...props }, ref) => {
|
|
271
271
|
const { onOpenChange, setTriggerPosition, setContentLayout } = useRootContext();
|
|
272
272
|
|
|
273
|
-
function onPress(
|
|
273
|
+
function onPress(event: GestureResponderEvent) {
|
|
274
274
|
if (closeOnPress) {
|
|
275
275
|
setTriggerPosition(null);
|
|
276
276
|
setContentLayout(null);
|
|
277
277
|
onOpenChange(false);
|
|
278
278
|
}
|
|
279
|
-
onPressProp?.(
|
|
279
|
+
onPressProp?.(event);
|
|
280
280
|
}
|
|
281
281
|
|
|
282
282
|
return (
|
|
@@ -295,7 +295,7 @@ const Item = React.forwardRef<ItemRef, ItemProps>(({ textValue, onPress: onPress
|
|
|
295
295
|
|
|
296
296
|
Item.displayName = "ItemNativeDropdownMenu";
|
|
297
297
|
|
|
298
|
-
const Group =
|
|
298
|
+
const Group = forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
|
|
299
299
|
return (
|
|
300
300
|
<Component
|
|
301
301
|
ref={ref}
|
|
@@ -307,7 +307,7 @@ const Group = React.forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
|
|
|
307
307
|
|
|
308
308
|
Group.displayName = "GroupNativeDropdownMenu";
|
|
309
309
|
|
|
310
|
-
const Label =
|
|
310
|
+
const Label = forwardRef<LabelRef, LabelProps>(({ ...props }, ref) => {
|
|
311
311
|
return (
|
|
312
312
|
<Component
|
|
313
313
|
ref={ref}
|
|
@@ -325,20 +325,20 @@ type FormItemContext =
|
|
|
325
325
|
onValueChange: (value: string) => void;
|
|
326
326
|
};
|
|
327
327
|
|
|
328
|
-
const FormItemContext =
|
|
328
|
+
const FormItemContext = createContext<FormItemContext | null>(null);
|
|
329
329
|
|
|
330
|
-
const CheckboxItem =
|
|
330
|
+
const CheckboxItem = forwardRef<CheckboxItemRef, CheckboxItemProps>(
|
|
331
331
|
({ render, checked, onCheckedChange, textValue, onPress: onPressProp, closeOnPress = true, disabled = false, ...props }, ref) => {
|
|
332
332
|
const { onOpenChange, setContentLayout, setTriggerPosition } = useRootContext();
|
|
333
333
|
|
|
334
|
-
function onPress(
|
|
334
|
+
function onPress(event: GestureResponderEvent) {
|
|
335
335
|
onCheckedChange(!checked);
|
|
336
336
|
if (closeOnPress) {
|
|
337
337
|
setTriggerPosition(null);
|
|
338
338
|
setContentLayout(null);
|
|
339
339
|
onOpenChange(false);
|
|
340
340
|
}
|
|
341
|
-
onPressProp?.(
|
|
341
|
+
onPressProp?.(event);
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
return (
|
|
@@ -362,14 +362,14 @@ const CheckboxItem = React.forwardRef<CheckboxItemRef, CheckboxItemProps>(
|
|
|
362
362
|
CheckboxItem.displayName = "CheckboxItemNativeDropdownMenu";
|
|
363
363
|
|
|
364
364
|
function useFormItemContext() {
|
|
365
|
-
const context =
|
|
365
|
+
const context = useContext(FormItemContext);
|
|
366
366
|
if (!context) {
|
|
367
367
|
throw new Error("CheckboxItem or RadioItem compound components cannot be rendered outside of a CheckboxItem or RadioItem component");
|
|
368
368
|
}
|
|
369
369
|
return context;
|
|
370
370
|
}
|
|
371
371
|
|
|
372
|
-
const RadioGroup =
|
|
372
|
+
const RadioGroup = forwardRef<RadioGroupRef, RadioGroupProps>(({ value, onValueChange, ...props }, ref) => {
|
|
373
373
|
return (
|
|
374
374
|
<FormItemContext.Provider value={{ value, onValueChange }}>
|
|
375
375
|
<Component
|
|
@@ -387,21 +387,21 @@ type BothFormItemContext = Exclude<FormItemContext, { checked: boolean }> & {
|
|
|
387
387
|
checked: boolean;
|
|
388
388
|
};
|
|
389
389
|
|
|
390
|
-
const RadioItemContext =
|
|
390
|
+
const RadioItemContext = createContext({} as { itemValue: string });
|
|
391
391
|
|
|
392
|
-
const RadioItem =
|
|
392
|
+
const RadioItem = forwardRef<RadioItemRef, RadioItemProps>(
|
|
393
393
|
({ render, value: itemValue, textValue, onPress: onPressProp, disabled = false, closeOnPress = true, ...props }, ref) => {
|
|
394
394
|
const { onOpenChange, setContentLayout, setTriggerPosition } = useRootContext();
|
|
395
395
|
|
|
396
396
|
const { value, onValueChange } = useFormItemContext() as BothFormItemContext;
|
|
397
|
-
function onPress(
|
|
397
|
+
function onPress(event: GestureResponderEvent) {
|
|
398
398
|
onValueChange(itemValue);
|
|
399
399
|
if (closeOnPress) {
|
|
400
400
|
setTriggerPosition(null);
|
|
401
401
|
setContentLayout(null);
|
|
402
402
|
onOpenChange(false);
|
|
403
403
|
}
|
|
404
|
-
onPressProp?.(
|
|
404
|
+
onPressProp?.(event);
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
return (
|
|
@@ -427,10 +427,10 @@ const RadioItem = React.forwardRef<RadioItemRef, RadioItemProps>(
|
|
|
427
427
|
RadioItem.displayName = "RadioItemNativeDropdownMenu";
|
|
428
428
|
|
|
429
429
|
function useItemIndicatorContext() {
|
|
430
|
-
return
|
|
430
|
+
return useContext(RadioItemContext);
|
|
431
431
|
}
|
|
432
432
|
|
|
433
|
-
const ItemIndicator =
|
|
433
|
+
const ItemIndicator = forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
434
434
|
const { itemValue } = useItemIndicatorContext();
|
|
435
435
|
const { checked, value } = useFormItemContext() as BothFormItemContext;
|
|
436
436
|
|
|
@@ -454,7 +454,7 @@ const ItemIndicator = React.forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({
|
|
|
454
454
|
|
|
455
455
|
ItemIndicator.displayName = "ItemIndicatorNativeDropdownMenu";
|
|
456
456
|
|
|
457
|
-
const Separator =
|
|
457
|
+
const Separator = forwardRef<SeparatorRef, SeparatorProps>(({ decorative, ...props }, ref) => {
|
|
458
458
|
return (
|
|
459
459
|
<Component
|
|
460
460
|
role={decorative ? "presentation" : "separator"}
|
|
@@ -466,14 +466,14 @@ const Separator = React.forwardRef<SeparatorRef, SeparatorProps>(({ decorative,
|
|
|
466
466
|
|
|
467
467
|
Separator.displayName = "SeparatorNativeDropdownMenu";
|
|
468
468
|
|
|
469
|
-
const SubContext =
|
|
469
|
+
const SubContext = createContext<{
|
|
470
470
|
nativeID: string;
|
|
471
471
|
open: boolean;
|
|
472
472
|
onOpenChange: (value: boolean) => void;
|
|
473
473
|
} | null>(null);
|
|
474
474
|
|
|
475
|
-
const Sub =
|
|
476
|
-
const nativeID =
|
|
475
|
+
const Sub = forwardRef<SubRef, SubProps>(({ defaultOpen, open: openProp, onOpenChange: onOpenChangeProp, ...props }, ref) => {
|
|
476
|
+
const nativeID = useId();
|
|
477
477
|
const [open = false, onOpenChange] = useControllableState({
|
|
478
478
|
prop: openProp,
|
|
479
479
|
defaultProp: defaultOpen,
|
|
@@ -499,19 +499,19 @@ const Sub = React.forwardRef<SubRef, SubProps>(({ defaultOpen, open: openProp, o
|
|
|
499
499
|
Sub.displayName = "SubNativeDropdownMenu";
|
|
500
500
|
|
|
501
501
|
function useSubContext() {
|
|
502
|
-
const context =
|
|
502
|
+
const context = useContext(SubContext);
|
|
503
503
|
if (!context) {
|
|
504
504
|
throw new Error("Sub compound components cannot be rendered outside of a Sub component");
|
|
505
505
|
}
|
|
506
506
|
return context;
|
|
507
507
|
}
|
|
508
508
|
|
|
509
|
-
const SubTrigger =
|
|
509
|
+
const SubTrigger = forwardRef<SubTriggerRef, SubTriggerProps>(({ textValue, onPress: onPressProp, disabled = false, ...props }, ref) => {
|
|
510
510
|
const { nativeID, open, onOpenChange } = useSubContext();
|
|
511
511
|
|
|
512
|
-
function onPress(
|
|
512
|
+
function onPress(event: GestureResponderEvent) {
|
|
513
513
|
onOpenChange(!open);
|
|
514
|
-
onPressProp?.(
|
|
514
|
+
onPressProp?.(event);
|
|
515
515
|
}
|
|
516
516
|
|
|
517
517
|
return (
|
|
@@ -532,7 +532,7 @@ const SubTrigger = React.forwardRef<SubTriggerRef, SubTriggerProps>(({ textValue
|
|
|
532
532
|
|
|
533
533
|
SubTrigger.displayName = "SubTriggerNativeDropdownMenu";
|
|
534
534
|
|
|
535
|
-
const SubContent =
|
|
535
|
+
const SubContent = forwardRef<SubContentRef, SubContentProps>(({ render = false, keepMounted, ...props }, ref) => {
|
|
536
536
|
const { open, nativeID } = useSubContext();
|
|
537
537
|
|
|
538
538
|
if (!keepMounted) {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { GestureResponderEvent, Pressable, Text, View } from "react-native";
|
|
4
4
|
|
|
5
5
|
// import { useAugmentedRef, useControllableState, useIsomorphicLayoutEffect } from "../hooks";
|
|
6
|
-
// import * as
|
|
6
|
+
// import * as Render from "../render";
|
|
7
7
|
// import { EmptyGestureResponderEvent } from "../utils";
|
|
8
8
|
|
|
9
9
|
// import type {
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
// TriggerRef,
|
|
41
41
|
// } from "./types";
|
|
42
42
|
|
|
43
|
-
// const DropdownMenuContext =
|
|
43
|
+
// const DropdownMenuContext = createContext<{
|
|
44
44
|
// open: boolean;
|
|
45
45
|
// onOpenChange: (open: boolean) => void;
|
|
46
46
|
// } | null>(null);
|
|
47
47
|
|
|
48
|
-
// const Root =
|
|
49
|
-
// const [open, setOpen] =
|
|
48
|
+
// const Root = forwardRef<RootRef, RootProps>(({ onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
49
|
+
// const [open, setOpen] = useState(false);
|
|
50
50
|
|
|
51
51
|
// function onOpenChange(open: boolean) {
|
|
52
52
|
// setOpen(open);
|
|
@@ -72,14 +72,14 @@
|
|
|
72
72
|
// Root.displayName = "RootWebDropdownMenu";
|
|
73
73
|
|
|
74
74
|
// function useRootContext() {
|
|
75
|
-
// const context =
|
|
75
|
+
// const context = useContext(DropdownMenuContext);
|
|
76
76
|
// if (!context) {
|
|
77
77
|
// throw new Error("DropdownMenu compound components cannot be rendered outside the DropdownMenu component");
|
|
78
78
|
// }
|
|
79
79
|
// return context;
|
|
80
80
|
// }
|
|
81
81
|
|
|
82
|
-
// const Trigger =
|
|
82
|
+
// const Trigger = forwardRef<TriggerRef, TriggerProps>(({ disabled = false, ...props }, ref) => {
|
|
83
83
|
// const { open, onOpenChange } = useRootContext();
|
|
84
84
|
// const augmentedRef = useAugmentedRef({
|
|
85
85
|
// ref,
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
// );
|
|
138
138
|
// }
|
|
139
139
|
|
|
140
|
-
// const Backdrop =
|
|
140
|
+
// const Backdrop = forwardRef<BackdropRef, BackdropProps>(({ ...props }, ref) => {
|
|
141
141
|
//
|
|
142
142
|
// return (
|
|
143
143
|
// <Component
|
|
@@ -149,11 +149,11 @@
|
|
|
149
149
|
|
|
150
150
|
// Backdrop.displayName = "BackdropWebDropdownMenu";
|
|
151
151
|
|
|
152
|
-
// const DropdownMenuContentContext =
|
|
152
|
+
// const DropdownMenuContentContext = createContext<{
|
|
153
153
|
// close: () => void;
|
|
154
154
|
// } | null>(null);
|
|
155
155
|
|
|
156
|
-
// const Content =
|
|
156
|
+
// const Content = forwardRef<ContentRef, ContentProps>(
|
|
157
157
|
// (
|
|
158
158
|
// {
|
|
159
159
|
// render = false,
|
|
@@ -224,20 +224,20 @@
|
|
|
224
224
|
// Content.displayName = "ContentWebDropdownMenu";
|
|
225
225
|
|
|
226
226
|
// function useDropdownMenuContentContext() {
|
|
227
|
-
// const context =
|
|
227
|
+
// const context = useContext(DropdownMenuContentContext);
|
|
228
228
|
// if (!context) {
|
|
229
229
|
// throw new Error("DropdownMenu compound components cannot be rendered outside the DropdownMenu component");
|
|
230
230
|
// }
|
|
231
231
|
// return context;
|
|
232
232
|
// }
|
|
233
233
|
|
|
234
|
-
// const Item =
|
|
234
|
+
// const Item = forwardRef<ItemRef, ItemProps>(
|
|
235
235
|
// ({ render, textValue, closeOnPress = true, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
236
236
|
// const { close } = useDropdownMenuContentContext();
|
|
237
237
|
|
|
238
|
-
// function onKeyDown(
|
|
239
|
-
// onKeyDownProp?.(
|
|
240
|
-
// if (
|
|
238
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
239
|
+
// onKeyDownProp?.(event);
|
|
240
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
241
241
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
242
242
|
// if (closeOnPress) {
|
|
243
243
|
// close();
|
|
@@ -245,8 +245,8 @@
|
|
|
245
245
|
// }
|
|
246
246
|
// }
|
|
247
247
|
|
|
248
|
-
// function onPress(
|
|
249
|
-
// onPressProp?.(
|
|
248
|
+
// function onPress(event: GestureResponderEvent) {
|
|
249
|
+
// onPressProp?.(event);
|
|
250
250
|
// if (closeOnPress) {
|
|
251
251
|
// close();
|
|
252
252
|
// }
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
|
|
275
275
|
// Item.displayName = "ItemWebDropdownMenu";
|
|
276
276
|
|
|
277
|
-
// const Group =
|
|
277
|
+
// const Group = forwardRef<GroupRef, GroupProps>(({ ...props }, ref) => {
|
|
278
278
|
//
|
|
279
279
|
// return (
|
|
280
280
|
// <DropdownMenu.Group render>
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
|
|
289
289
|
// Group.displayName = "GroupWebDropdownMenu";
|
|
290
290
|
|
|
291
|
-
// const Label =
|
|
291
|
+
// const Label = forwardRef<LabelRef, LabelProps>(({ ...props }, ref) => {
|
|
292
292
|
//
|
|
293
293
|
// return (
|
|
294
294
|
// <DropdownMenu.Label render>
|
|
@@ -302,13 +302,13 @@
|
|
|
302
302
|
|
|
303
303
|
// Label.displayName = "LabelWebDropdownMenu";
|
|
304
304
|
|
|
305
|
-
// const CheckboxItem =
|
|
305
|
+
// const CheckboxItem = forwardRef<CheckboxItemRef, CheckboxItemProps>(
|
|
306
306
|
// ({ render, checked, onCheckedChange, textValue, disabled = false, closeOnPress = true, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
307
307
|
// const { close } = useDropdownMenuContentContext();
|
|
308
308
|
|
|
309
|
-
// function onKeyDown(
|
|
310
|
-
// onKeyDownProp?.(
|
|
311
|
-
// if (
|
|
309
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
310
|
+
// onKeyDownProp?.(event);
|
|
311
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
312
312
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
313
313
|
// onCheckedChange?.(!checked);
|
|
314
314
|
// if (closeOnPress) {
|
|
@@ -317,8 +317,8 @@
|
|
|
317
317
|
// }
|
|
318
318
|
// }
|
|
319
319
|
|
|
320
|
-
// function onPress(
|
|
321
|
-
// onPressProp?.(
|
|
320
|
+
// function onPress(event: GestureResponderEvent) {
|
|
321
|
+
// onPressProp?.(event);
|
|
322
322
|
// onCheckedChange?.(!checked);
|
|
323
323
|
// if (closeOnPress) {
|
|
324
324
|
// close();
|
|
@@ -349,12 +349,12 @@
|
|
|
349
349
|
|
|
350
350
|
// CheckboxItem.displayName = "CheckboxItemWebDropdownMenu";
|
|
351
351
|
|
|
352
|
-
// const DropdownMenuRadioGroupContext =
|
|
352
|
+
// const DropdownMenuRadioGroupContext = createContext<{
|
|
353
353
|
// value?: string;
|
|
354
354
|
// onValueChange?: (value: string) => void;
|
|
355
355
|
// } | null>(null);
|
|
356
356
|
|
|
357
|
-
// const RadioGroup =
|
|
357
|
+
// const RadioGroup = forwardRef<RadioGroupRef, RadioGroupProps>(({ value, onValueChange, ...props }, ref) => {
|
|
358
358
|
//
|
|
359
359
|
// return (
|
|
360
360
|
// <DropdownMenuRadioGroupContext.Provider value={{ value, onValueChange }}>
|
|
@@ -375,21 +375,21 @@
|
|
|
375
375
|
// RadioGroup.displayName = "RadioGroupWebDropdownMenu";
|
|
376
376
|
|
|
377
377
|
// function useDropdownMenuRadioGroupContext() {
|
|
378
|
-
// const context =
|
|
378
|
+
// const context = useContext(DropdownMenuRadioGroupContext);
|
|
379
379
|
// if (!context) {
|
|
380
380
|
// throw new Error("DropdownMenuRadioGroup compound components cannot be rendered outside the DropdownMenuRadioGroup component");
|
|
381
381
|
// }
|
|
382
382
|
// return context;
|
|
383
383
|
// }
|
|
384
384
|
|
|
385
|
-
// const RadioItem =
|
|
385
|
+
// const RadioItem = forwardRef<RadioItemRef, RadioItemProps>(
|
|
386
386
|
// ({ render, value, textValue, closeOnPress = true, onPress: onPressProp, onKeyDown: onKeyDownProp, ...props }, ref) => {
|
|
387
387
|
// const { onValueChange } = useDropdownMenuRadioGroupContext();
|
|
388
388
|
// const { close } = useDropdownMenuContentContext();
|
|
389
389
|
|
|
390
|
-
// function onKeyDown(
|
|
391
|
-
// onKeyDownProp?.(
|
|
392
|
-
// if (
|
|
390
|
+
// function onKeyDown(event: React.KeyboardEvent) {
|
|
391
|
+
// onKeyDownProp?.(event);
|
|
392
|
+
// if (event.key === "Enter" || event.key === " ") {
|
|
393
393
|
// onValueChange?.(value);
|
|
394
394
|
// onPressProp?.(EmptyGestureResponderEvent);
|
|
395
395
|
// if (closeOnPress) {
|
|
@@ -398,9 +398,9 @@
|
|
|
398
398
|
// }
|
|
399
399
|
// }
|
|
400
400
|
|
|
401
|
-
// function onPress(
|
|
401
|
+
// function onPress(event: GestureResponderEvent) {
|
|
402
402
|
// onValueChange?.(value);
|
|
403
|
-
// onPressProp?.(
|
|
403
|
+
// onPressProp?.(event);
|
|
404
404
|
// if (closeOnPress) {
|
|
405
405
|
// close();
|
|
406
406
|
// }
|
|
@@ -428,7 +428,7 @@
|
|
|
428
428
|
|
|
429
429
|
// RadioItem.displayName = "RadioItemWebDropdownMenu";
|
|
430
430
|
|
|
431
|
-
// const ItemIndicator =
|
|
431
|
+
// const ItemIndicator = forwardRef<ItemIndicatorRef, ItemIndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
432
432
|
//
|
|
433
433
|
// return (
|
|
434
434
|
// <DropdownMenu.ItemIndicator
|
|
@@ -445,7 +445,7 @@
|
|
|
445
445
|
|
|
446
446
|
// ItemIndicator.displayName = "ItemIndicatorWebDropdownMenu";
|
|
447
447
|
|
|
448
|
-
// const Separator =
|
|
448
|
+
// const Separator = forwardRef<SeparatorRef, SeparatorProps>(({ decorative, ...props }, ref) => {
|
|
449
449
|
//
|
|
450
450
|
// return (
|
|
451
451
|
// <DropdownMenu.Separator render>
|
|
@@ -459,12 +459,12 @@
|
|
|
459
459
|
|
|
460
460
|
// Separator.displayName = "SeparatorWebDropdownMenu";
|
|
461
461
|
|
|
462
|
-
// const DropdownMenuSubContext =
|
|
462
|
+
// const DropdownMenuSubContext = createContext<{
|
|
463
463
|
// open: boolean;
|
|
464
464
|
// onOpenChange: (open: boolean) => void;
|
|
465
465
|
// } | null>(null);
|
|
466
466
|
|
|
467
|
-
// const Sub =
|
|
467
|
+
// const Sub = forwardRef<SubRef, SubProps>(({ defaultOpen, open: openProp, onOpenChange: onOpenChangeProp, ...props }, ref) => {
|
|
468
468
|
// const [open = false, onOpenChange] = useControllableState({
|
|
469
469
|
// prop: openProp,
|
|
470
470
|
// defaultProp: defaultOpen,
|
|
@@ -490,19 +490,19 @@
|
|
|
490
490
|
// Sub.displayName = "SubWebDropdownMenu";
|
|
491
491
|
|
|
492
492
|
// function useSubContext() {
|
|
493
|
-
// const context =
|
|
493
|
+
// const context = useContext(DropdownMenuSubContext);
|
|
494
494
|
// if (!context) {
|
|
495
495
|
// throw new Error("DropdownMenu compound components cannot be rendered outside the DropdownMenu component");
|
|
496
496
|
// }
|
|
497
497
|
// return context;
|
|
498
498
|
// }
|
|
499
499
|
|
|
500
|
-
// const SubTrigger =
|
|
500
|
+
// const SubTrigger = forwardRef<SubTriggerRef, SubTriggerProps>(({ textValue, disabled = false, onPress: onPressProp, ...props }, ref) => {
|
|
501
501
|
// const { onOpenChange } = useSubContext();
|
|
502
502
|
|
|
503
|
-
// function onPress(
|
|
503
|
+
// function onPress(event: GestureResponderEvent) {
|
|
504
504
|
// onOpenChange(true);
|
|
505
|
-
// onPressProp?.(
|
|
505
|
+
// onPressProp?.(event);
|
|
506
506
|
// }
|
|
507
507
|
|
|
508
508
|
//
|
|
@@ -523,7 +523,7 @@
|
|
|
523
523
|
|
|
524
524
|
// SubTrigger.displayName = "SubTriggerWebDropdownMenu";
|
|
525
525
|
|
|
526
|
-
// const SubContent =
|
|
526
|
+
// const SubContent = forwardRef<SubContentRef, SubContentProps>(({ render = false, keepMounted, ...props }, ref) => {
|
|
527
527
|
//
|
|
528
528
|
// return (
|
|
529
529
|
// <DropdownMenu.Portal>
|
|
@@ -560,6 +560,6 @@
|
|
|
560
560
|
// useSubContext,
|
|
561
561
|
// };
|
|
562
562
|
|
|
563
|
-
// function onSelected(
|
|
564
|
-
//
|
|
563
|
+
// function onSelected(event: Event) {
|
|
564
|
+
// event.preventDefault();
|
|
565
565
|
// }
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { Platform } from "react-native";
|
|
3
2
|
|
|
4
3
|
function useIsomorphicLayoutEffect(effect: React.EffectCallback, dependencies?: React.DependencyList) {
|
|
5
4
|
if (Platform.OS === "web" && typeof window === "undefined") {
|
|
6
|
-
|
|
5
|
+
useEffect(effect, dependencies);
|
|
7
6
|
} else {
|
|
8
7
|
React.useLayoutEffect(effect, dependencies);
|
|
9
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { useMemo } from "react";
|
|
2
2
|
import { Dimensions, type LayoutRectangle, type ScaledSize } from "react-native";
|
|
3
3
|
|
|
4
4
|
import type { Insets } from "../types";
|
|
@@ -22,7 +22,7 @@ export function useRelativePosition({
|
|
|
22
22
|
}: UseRelativePositionArgs) {
|
|
23
23
|
const dimensions = Dimensions.get("screen");
|
|
24
24
|
|
|
25
|
-
return
|
|
25
|
+
return useMemo(() => {
|
|
26
26
|
if (disablePositioningStyle) {
|
|
27
27
|
return {};
|
|
28
28
|
}
|