@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
package/src/popover/popover.tsx
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useId, useState, useContext, useEffect } from "react";
|
|
2
2
|
import { BackHandler, Pressable, View, type GestureResponderEvent, type LayoutChangeEvent, type LayoutRectangle } from "react-native";
|
|
3
3
|
|
|
4
4
|
import { useAugmentedRef, 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
|
CloseProps,
|
|
@@ -29,13 +29,13 @@ interface RootContextInterface {
|
|
|
29
29
|
nativeID: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const RootContext =
|
|
32
|
+
const RootContext = createContext<RootContextInterface | null>(null);
|
|
33
33
|
|
|
34
|
-
const Root =
|
|
35
|
-
const nativeID =
|
|
36
|
-
const [triggerPosition, setTriggerPosition] =
|
|
37
|
-
const [contentLayout, setContentLayout] =
|
|
38
|
-
const [open, setOpen] =
|
|
34
|
+
const Root = forwardRef<RootRef, RootProps>(({ onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
35
|
+
const nativeID = useId();
|
|
36
|
+
const [triggerPosition, setTriggerPosition] = useState<LayoutPosition | null>(null);
|
|
37
|
+
const [contentLayout, setContentLayout] = useState<LayoutRectangle | null>(null);
|
|
38
|
+
const [open, setOpen] = useState(false);
|
|
39
39
|
|
|
40
40
|
function onOpenChange(value: boolean) {
|
|
41
41
|
setOpen(value);
|
|
@@ -65,14 +65,14 @@ const Root = React.forwardRef<RootRef, RootProps>(({ onOpenChange: onOpenChangeP
|
|
|
65
65
|
Root.displayName = "RootNativePopover";
|
|
66
66
|
|
|
67
67
|
function useRootContext() {
|
|
68
|
-
const context =
|
|
68
|
+
const context = useContext(RootContext);
|
|
69
69
|
if (!context) {
|
|
70
70
|
throw new Error("Popover compound components cannot be rendered outside the Popover component");
|
|
71
71
|
}
|
|
72
72
|
return context;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
const Trigger =
|
|
75
|
+
const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, disabled = false, ...props }, ref) => {
|
|
76
76
|
const { onOpenChange, open, setTriggerPosition } = useRootContext();
|
|
77
77
|
|
|
78
78
|
const augmentedRef = useAugmentedRef({
|
|
@@ -91,13 +91,13 @@ const Trigger = React.forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressPr
|
|
|
91
91
|
},
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
function onPress(
|
|
94
|
+
function onPress(event: GestureResponderEvent) {
|
|
95
95
|
if (disabled) return;
|
|
96
96
|
augmentedRef.current?.measure((_x, _y, width, height, pageX, pageY) => {
|
|
97
97
|
setTriggerPosition({ width, pageX, pageY: pageY, height });
|
|
98
98
|
});
|
|
99
99
|
onOpenChange(!open);
|
|
100
|
-
onPressProp?.(
|
|
100
|
+
onPressProp?.(event);
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
return (
|
|
@@ -140,16 +140,16 @@ function Portal({ keepMounted, hostName, children }: PortalProps) {
|
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
const Backdrop =
|
|
143
|
+
const Backdrop = forwardRef<BackdropRef, BackdropProps>(({ keepMounted, onPress: onPressProp, closeOnPress = true, ...props }, ref) => {
|
|
144
144
|
const { open, onOpenChange, setTriggerPosition, setContentLayout } = useRootContext();
|
|
145
145
|
|
|
146
|
-
function onPress(
|
|
146
|
+
function onPress(event: GestureResponderEvent) {
|
|
147
147
|
if (closeOnPress) {
|
|
148
148
|
setTriggerPosition(null);
|
|
149
149
|
setContentLayout(null);
|
|
150
150
|
onOpenChange(false);
|
|
151
151
|
}
|
|
152
|
-
|
|
152
|
+
onPressProp?.(event);
|
|
153
153
|
}
|
|
154
154
|
|
|
155
155
|
if (!keepMounted) {
|
|
@@ -172,7 +172,7 @@ Backdrop.displayName = "BackdropNativePopover";
|
|
|
172
172
|
/**
|
|
173
173
|
* @info `position`, `top`, `left`, and `maxWidth` style properties are controlled internally. Opt out of this behavior by setting `disablePositioningStyle` to `true`.
|
|
174
174
|
*/
|
|
175
|
-
const Content =
|
|
175
|
+
const Content = forwardRef<ContentRef, ContentProps>(
|
|
176
176
|
(
|
|
177
177
|
{
|
|
178
178
|
render = false,
|
|
@@ -193,7 +193,7 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
193
193
|
) => {
|
|
194
194
|
const { open, onOpenChange, contentLayout, nativeID, setContentLayout, setTriggerPosition, triggerPosition } = useRootContext();
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
useEffect(() => {
|
|
197
197
|
const backHandler = BackHandler.addEventListener("hardwareBackPress", () => {
|
|
198
198
|
setTriggerPosition(null);
|
|
199
199
|
setContentLayout(null);
|
|
@@ -247,15 +247,15 @@ const Content = React.forwardRef<ContentRef, ContentProps>(
|
|
|
247
247
|
|
|
248
248
|
Content.displayName = "ContentNativePopover";
|
|
249
249
|
|
|
250
|
-
const Close =
|
|
250
|
+
const Close = forwardRef<CloseRef, CloseProps>(({ onPress: onPressProp, disabled = false, ...props }, ref) => {
|
|
251
251
|
const { onOpenChange, setContentLayout, setTriggerPosition } = useRootContext();
|
|
252
252
|
|
|
253
|
-
function onPress(
|
|
253
|
+
function onPress(event: GestureResponderEvent) {
|
|
254
254
|
if (disabled) return;
|
|
255
255
|
setTriggerPosition(null);
|
|
256
256
|
setContentLayout(null);
|
|
257
257
|
onOpenChange(false);
|
|
258
|
-
onPressProp?.(
|
|
258
|
+
onPressProp?.(event);
|
|
259
259
|
}
|
|
260
260
|
|
|
261
261
|
return (
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// import * as Popover from "@radix-ui/react-popover";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { Pressable, View, type GestureResponderEvent } from "react-native";
|
|
4
4
|
|
|
5
5
|
// import { useAugmentedRef, useIsomorphicLayoutEffect } from "../hooks";
|
|
6
|
-
// import * as
|
|
6
|
+
// import * as Render from "../render";
|
|
7
7
|
|
|
8
8
|
// import type {
|
|
9
9
|
// CloseProps,
|
|
@@ -19,14 +19,14 @@
|
|
|
19
19
|
// TriggerRef,
|
|
20
20
|
// } from "./types";
|
|
21
21
|
|
|
22
|
-
// const RootContext =
|
|
22
|
+
// const RootContext = createContext<{
|
|
23
23
|
// open: boolean;
|
|
24
24
|
// onOpenChange: (open: boolean) => void;
|
|
25
25
|
// } | null>(null);
|
|
26
26
|
|
|
27
|
-
// const Root =
|
|
27
|
+
// const Root = forwardRef<RootRef, RootProps & { onOpenChange?: (open: boolean) => void }>(
|
|
28
28
|
// ({ render, onOpenChange: onOpenChangeProp, ...viewProps }, ref) => {
|
|
29
|
-
// const [open, setOpen] =
|
|
29
|
+
// const [open, setOpen] = useState(false);
|
|
30
30
|
|
|
31
31
|
// function onOpenChange(value: boolean) {
|
|
32
32
|
// setOpen(value);
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
// Root.displayName = "RootWebPopover";
|
|
53
53
|
|
|
54
54
|
// function useRootContext() {
|
|
55
|
-
// const context =
|
|
55
|
+
// const context = useContext(RootContext);
|
|
56
56
|
// if (!context) {
|
|
57
57
|
// throw new Error("Popover compound components cannot be rendered outside the Popover component");
|
|
58
58
|
// }
|
|
59
59
|
// return context;
|
|
60
60
|
// }
|
|
61
61
|
|
|
62
|
-
// const Trigger =
|
|
62
|
+
// const Trigger = forwardRef<TriggerRef, TriggerProps>(({ onPress: onPressProp, role: _role, disabled, ...props }, ref) => {
|
|
63
63
|
// const { onOpenChange, open } = useRootContext();
|
|
64
64
|
// const augmentedRef = useAugmentedRef({
|
|
65
65
|
// ref,
|
|
@@ -72,9 +72,9 @@
|
|
|
72
72
|
// },
|
|
73
73
|
// },
|
|
74
74
|
// });
|
|
75
|
-
// function onPress(
|
|
75
|
+
// function onPress(event: GestureResponderEvent) {
|
|
76
76
|
// if (onPressProp) {
|
|
77
|
-
// onPressProp(
|
|
77
|
+
// onPressProp(event);
|
|
78
78
|
// }
|
|
79
79
|
// onOpenChange(!open);
|
|
80
80
|
// }
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
// );
|
|
117
117
|
// }
|
|
118
118
|
|
|
119
|
-
// const Backdrop =
|
|
119
|
+
// const Backdrop = forwardRef<BackdropRef, BackdropProps>(({ keepMounted, ...props }, ref) => {
|
|
120
120
|
//
|
|
121
121
|
// return (
|
|
122
122
|
// <Component
|
|
@@ -128,7 +128,7 @@
|
|
|
128
128
|
|
|
129
129
|
// Backdrop.displayName = "BackdropWebPopover";
|
|
130
130
|
|
|
131
|
-
// const Content =
|
|
131
|
+
// const Content = forwardRef<ContentRef, ContentProps>(
|
|
132
132
|
// (
|
|
133
133
|
// {
|
|
134
134
|
// render = false,
|
|
@@ -175,13 +175,13 @@
|
|
|
175
175
|
|
|
176
176
|
// Content.displayName = "ContentWebPopover";
|
|
177
177
|
|
|
178
|
-
// const Close =
|
|
178
|
+
// const Close = forwardRef<CloseRef, CloseProps>(({ onPress: onPressProp, disabled, ...props }, ref) => {
|
|
179
179
|
// const augmentedRef = useAugmentedRef({ ref });
|
|
180
180
|
// const { onOpenChange, open } = useRootContext();
|
|
181
181
|
|
|
182
|
-
// function onPress(
|
|
182
|
+
// function onPress(event: GestureResponderEvent) {
|
|
183
183
|
// if (onPressProp) {
|
|
184
|
-
// onPressProp(
|
|
184
|
+
// onPressProp(event);
|
|
185
185
|
// }
|
|
186
186
|
// onOpenChange(!open);
|
|
187
187
|
// }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { forwardRef, Component } from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
|
|
4
|
-
import * as
|
|
4
|
+
import * as Render from "../render";
|
|
5
5
|
|
|
6
6
|
import type { IndicatorProps, IndicatorRef, RootProps, RootRef } from "./types";
|
|
7
7
|
|
|
@@ -11,7 +11,7 @@ import type { IndicatorProps, IndicatorRef, RootProps, RootRef } from "./types";
|
|
|
11
11
|
|
|
12
12
|
const DEFAULT_MAX = 100;
|
|
13
13
|
|
|
14
|
-
const Root =
|
|
14
|
+
const Root = forwardRef<RootRef, RootProps>(({ value: valueProp, max: maxProp, getValueLabel = defaultGetValueLabel, ...props }, ref) => {
|
|
15
15
|
const max = maxProp ?? DEFAULT_MAX;
|
|
16
16
|
const value = isValidValueNumber(valueProp, max) ? valueProp : 0;
|
|
17
17
|
|
|
@@ -36,7 +36,7 @@ const Root = React.forwardRef<RootRef, RootProps>(({ value: valueProp, max: maxP
|
|
|
36
36
|
|
|
37
37
|
Root.displayName = "RootProgress";
|
|
38
38
|
|
|
39
|
-
const Indicator =
|
|
39
|
+
const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ ...props }, ref) => {
|
|
40
40
|
return (
|
|
41
41
|
<Component
|
|
42
42
|
ref={ref}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// import * as Progress from "@radix-ui/react-progress";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { View } from "react-native";
|
|
4
4
|
|
|
5
|
-
// import * as
|
|
5
|
+
// import * as Render from "../render";
|
|
6
6
|
|
|
7
7
|
// import type { IndicatorProps, IndicatorRef, RootProps, RootRef } from "./types";
|
|
8
8
|
|
|
9
|
-
// const ProgressContext =
|
|
9
|
+
// const ProgressContext = createContext<RootProps | null>(null);
|
|
10
10
|
|
|
11
|
-
// const Root =
|
|
11
|
+
// const Root = forwardRef<RootRef, RootProps>(({ value, max, getValueLabel, ...props }, ref) => {
|
|
12
12
|
//
|
|
13
13
|
// return (
|
|
14
14
|
// <ProgressContext.Provider value={{ value, max }}>
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
|
|
30
30
|
// Root.displayName = "RootProgress";
|
|
31
31
|
|
|
32
|
-
// const Indicator =
|
|
32
|
+
// const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ ...props }, ref) => {
|
|
33
33
|
//
|
|
34
34
|
// return (
|
|
35
35
|
// <Progress.Indicator render>
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { createContext, forwardRef, useContext } from "react";
|
|
2
2
|
import { Pressable, View, type GestureResponderEvent } from "react-native";
|
|
3
3
|
|
|
4
|
-
import * as
|
|
4
|
+
import * as Render from "../render";
|
|
5
5
|
|
|
6
6
|
import type { IndicatorProps, IndicatorRef, ItemProps, ItemRef, RootProps, RootRef } from "./types";
|
|
7
7
|
|
|
8
|
-
const RadioGroupContext =
|
|
8
|
+
const RadioGroupContext = createContext<RootProps | null>(null);
|
|
9
9
|
|
|
10
|
-
const Root =
|
|
10
|
+
const Root = forwardRef<RootRef, RootProps>(({ value, onValueChange, disabled = false, ...viewProps }, ref) => {
|
|
11
11
|
return (
|
|
12
12
|
<RadioGroupContext.Provider
|
|
13
13
|
value={{
|
|
@@ -28,7 +28,7 @@ const Root = React.forwardRef<RootRef, RootProps>(({ value, onValueChange, disab
|
|
|
28
28
|
Root.displayName = "RootRadioGroup";
|
|
29
29
|
|
|
30
30
|
function useRadioGroupContext() {
|
|
31
|
-
const context =
|
|
31
|
+
const context = useContext(RadioGroupContext);
|
|
32
32
|
if (!context) {
|
|
33
33
|
throw new Error("RadioGroup compound components cannot be rendered outside the RadioGroup component");
|
|
34
34
|
}
|
|
@@ -39,15 +39,15 @@ interface RadioItemContext {
|
|
|
39
39
|
itemValue: string | undefined;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
const RadioItemContext =
|
|
42
|
+
const RadioItemContext = createContext<RadioItemContext | null>(null);
|
|
43
43
|
|
|
44
|
-
const Item =
|
|
44
|
+
const Item = forwardRef<ItemRef, ItemProps>(({ value: itemValue, disabled: disabledProp = false, onPress: onPressProp, ...props }, ref) => {
|
|
45
45
|
const { disabled, value, onValueChange } = useRadioGroupContext();
|
|
46
46
|
|
|
47
|
-
function onPress(
|
|
47
|
+
function onPress(event: GestureResponderEvent) {
|
|
48
48
|
if (disabled || disabledProp) return;
|
|
49
49
|
onValueChange(itemValue);
|
|
50
|
-
onPressProp?.(
|
|
50
|
+
onPressProp?.(event);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
return (
|
|
@@ -75,14 +75,14 @@ const Item = React.forwardRef<ItemRef, ItemProps>(({ value: itemValue, disabled:
|
|
|
75
75
|
Item.displayName = "ItemRadioGroup";
|
|
76
76
|
|
|
77
77
|
function useRadioItemContext() {
|
|
78
|
-
const context =
|
|
78
|
+
const context = useContext(RadioItemContext);
|
|
79
79
|
if (!context) {
|
|
80
80
|
throw new Error("RadioItem compound components cannot be rendered outside the RadioItem component");
|
|
81
81
|
}
|
|
82
82
|
return context;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const Indicator =
|
|
85
|
+
const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
86
86
|
const { value } = useRadioGroupContext();
|
|
87
87
|
const { itemValue } = useRadioItemContext();
|
|
88
88
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
// import * as RadioGroup from "@radix-ui/react-radio-group";
|
|
2
|
-
//
|
|
2
|
+
//
|
|
3
3
|
// import { GestureResponderEvent, Pressable, View } from "react-native";
|
|
4
4
|
|
|
5
|
-
// import * as
|
|
5
|
+
// import * as Render from "../render";
|
|
6
6
|
|
|
7
7
|
// import type { IndicatorProps, IndicatorRef, ItemProps, ItemRef, RootProps, RootRef } from "./types";
|
|
8
8
|
|
|
9
|
-
// const RadioGroupContext =
|
|
9
|
+
// const RadioGroupContext = createContext<RootProps | null>(null);
|
|
10
10
|
|
|
11
|
-
// const Root =
|
|
11
|
+
// const Root = forwardRef<RootRef, RootProps>(({ value, onValueChange, disabled = false, ...viewProps }, ref) => {
|
|
12
12
|
//
|
|
13
13
|
// return (
|
|
14
14
|
// <RadioGroupContext.Provider
|
|
@@ -35,18 +35,18 @@
|
|
|
35
35
|
|
|
36
36
|
// Root.displayName = "RootRadioGroup";
|
|
37
37
|
// function useRadioGroupContext() {
|
|
38
|
-
// const context =
|
|
38
|
+
// const context = useContext(RadioGroupContext);
|
|
39
39
|
// if (!context) {
|
|
40
40
|
// throw new Error("RadioGroup compound components cannot be rendered outside the RadioGroup component");
|
|
41
41
|
// }
|
|
42
42
|
// return context;
|
|
43
43
|
// }
|
|
44
|
-
// const Item =
|
|
44
|
+
// const Item = forwardRef<ItemRef, ItemProps>(({ value, onPress: onPressProps, ...props }, ref) => {
|
|
45
45
|
// const { onValueChange } = useRadioGroupContext();
|
|
46
46
|
|
|
47
|
-
// function onPress(
|
|
47
|
+
// function onPress(event: GestureResponderEvent) {
|
|
48
48
|
// if (onPressProps) {
|
|
49
|
-
// onPressProps(
|
|
49
|
+
// onPressProps(event);
|
|
50
50
|
// }
|
|
51
51
|
// onValueChange(value);
|
|
52
52
|
// }
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
|
|
69
69
|
// Item.displayName = "ItemRadioGroup";
|
|
70
70
|
|
|
71
|
-
// const Indicator =
|
|
71
|
+
// const Indicator = forwardRef<IndicatorRef, IndicatorProps>(({ keepMounted, ...props }, ref) => {
|
|
72
72
|
//
|
|
73
73
|
// return (
|
|
74
74
|
// <RadioGroup.Indicator render>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./render";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import * as React from "react";
|
|
2
1
|
import { cloneElement, isValidElement } from "react";
|
|
3
2
|
import {
|
|
4
3
|
Image as ReactNativeImage,
|
|
@@ -24,7 +23,7 @@ const Pressable = (props: BrandMapUIComponentProps<typeof ReactNativePressable>)
|
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
if (!isValidElement(render)) {
|
|
27
|
-
console.log("
|
|
26
|
+
console.log("Render.Pressable - Invalid render prop", render);
|
|
28
27
|
return <></>;
|
|
29
28
|
}
|
|
30
29
|
|
|
@@ -41,7 +40,7 @@ const Pressable = (props: BrandMapUIComponentProps<typeof ReactNativePressable>)
|
|
|
41
40
|
},
|
|
42
41
|
);
|
|
43
42
|
};
|
|
44
|
-
// Pressable.displayName = "
|
|
43
|
+
// Pressable.displayName = "RenderPressable";
|
|
45
44
|
|
|
46
45
|
const View = (props: BrandMapUIComponentProps<typeof ReactNativeView>): React.JSX.Element => {
|
|
47
46
|
const { children, render, ...rest } = props;
|
|
@@ -51,7 +50,7 @@ const View = (props: BrandMapUIComponentProps<typeof ReactNativeView>): React.JS
|
|
|
51
50
|
}
|
|
52
51
|
|
|
53
52
|
if (!isValidElement(render)) {
|
|
54
|
-
console.log("
|
|
53
|
+
console.log("Render.View - Invalid render prop", render);
|
|
55
54
|
return <></>;
|
|
56
55
|
}
|
|
57
56
|
|
|
@@ -68,7 +67,7 @@ const View = (props: BrandMapUIComponentProps<typeof ReactNativeView>): React.JS
|
|
|
68
67
|
},
|
|
69
68
|
);
|
|
70
69
|
};
|
|
71
|
-
// View.displayName = "
|
|
70
|
+
// View.displayName = "RenderView";
|
|
72
71
|
|
|
73
72
|
const Text = (props: BrandMapUIComponentProps<typeof ReactNativeText>): React.JSX.Element => {
|
|
74
73
|
const { children, render, ...rest } = props;
|
|
@@ -78,7 +77,7 @@ const Text = (props: BrandMapUIComponentProps<typeof ReactNativeText>): React.JS
|
|
|
78
77
|
}
|
|
79
78
|
|
|
80
79
|
if (!isValidElement(render)) {
|
|
81
|
-
console.log("
|
|
80
|
+
console.log("Render.Text - Invalid render prop", render);
|
|
82
81
|
return <></>;
|
|
83
82
|
}
|
|
84
83
|
|
|
@@ -95,7 +94,7 @@ const Text = (props: BrandMapUIComponentProps<typeof ReactNativeText>): React.JS
|
|
|
95
94
|
},
|
|
96
95
|
);
|
|
97
96
|
};
|
|
98
|
-
// Text.displayName = "
|
|
97
|
+
// Text.displayName = "RenderText";
|
|
99
98
|
|
|
100
99
|
const Image = (props: BrandMapUIComponentProps<typeof ReactNativeImage> /** & { children?: React.ReactNode } */): React.JSX.Element => {
|
|
101
100
|
const { render, ...rest } = props;
|
|
@@ -105,7 +104,7 @@ const Image = (props: BrandMapUIComponentProps<typeof ReactNativeImage> /** & {
|
|
|
105
104
|
}
|
|
106
105
|
|
|
107
106
|
if (!isValidElement(render)) {
|
|
108
|
-
console.log("
|
|
107
|
+
console.log("Render.Image - Invalid render prop", render);
|
|
109
108
|
return <></>;
|
|
110
109
|
}
|
|
111
110
|
|
|
@@ -118,7 +117,7 @@ const Image = (props: BrandMapUIComponentProps<typeof ReactNativeImage> /** & {
|
|
|
118
117
|
// children,
|
|
119
118
|
});
|
|
120
119
|
};
|
|
121
|
-
// Image.displayName = "
|
|
120
|
+
// Image.displayName = "RenderImage";
|
|
122
121
|
|
|
123
122
|
export { Image, Pressable, Text, View };
|
|
124
123
|
|
|
@@ -150,30 +149,30 @@ function composeRefs<T>(...refs: (React.Ref<T> | undefined)[]) {
|
|
|
150
149
|
|
|
151
150
|
type AnyProps = Record<string, any>;
|
|
152
151
|
|
|
153
|
-
function mergeProps(
|
|
152
|
+
function mergeProps(renderProps: AnyProps, childProps: AnyProps) {
|
|
154
153
|
// all child props should override
|
|
155
154
|
const overrideProps = { ...childProps };
|
|
156
155
|
|
|
157
156
|
for (const propName in childProps) {
|
|
158
|
-
const
|
|
157
|
+
const renderPropValue = renderProps[propName];
|
|
159
158
|
const childPropValue = childProps[propName];
|
|
160
159
|
|
|
161
160
|
if (propName.startsWith("on")) {
|
|
162
|
-
if (!childPropValue && !
|
|
161
|
+
if (!childPropValue && !renderPropValue) {
|
|
163
162
|
continue;
|
|
164
163
|
}
|
|
165
164
|
|
|
166
165
|
// if the handler exists on both, we compose them
|
|
167
|
-
if (
|
|
166
|
+
if (renderPropValue && childPropValue) {
|
|
168
167
|
overrideProps[propName] = (...args: any[]) => {
|
|
169
168
|
childPropValue(...args);
|
|
170
|
-
|
|
169
|
+
renderPropValue(...args);
|
|
171
170
|
};
|
|
172
171
|
}
|
|
173
172
|
|
|
174
|
-
// but if it exists only on the
|
|
175
|
-
if (
|
|
176
|
-
overrideProps[propName] =
|
|
173
|
+
// but if it exists only on the render, we use only this one
|
|
174
|
+
if (renderPropValue) {
|
|
175
|
+
overrideProps[propName] = renderPropValue;
|
|
177
176
|
}
|
|
178
177
|
|
|
179
178
|
continue;
|
|
@@ -181,42 +180,42 @@ function mergeProps(slotProps: AnyProps, childProps: AnyProps) {
|
|
|
181
180
|
|
|
182
181
|
// if it's `style`, we merge them
|
|
183
182
|
if (propName === "style") {
|
|
184
|
-
overrideProps[propName] = combineStyles(
|
|
183
|
+
overrideProps[propName] = combineStyles(renderPropValue, childPropValue);
|
|
185
184
|
}
|
|
186
185
|
|
|
187
186
|
// if it's `className`, we merge them
|
|
188
187
|
if (propName === "className") {
|
|
189
|
-
overrideProps[propName] = [
|
|
188
|
+
overrideProps[propName] = [renderPropValue, childPropValue].filter(Boolean).join(" ");
|
|
190
189
|
}
|
|
191
190
|
}
|
|
192
191
|
|
|
193
|
-
return { ...
|
|
192
|
+
return { ...renderProps, ...overrideProps };
|
|
194
193
|
}
|
|
195
194
|
|
|
196
195
|
type PressableStyle = ReactNativePressableProps["style"];
|
|
197
196
|
type ImageStyle = StyleProp<ReactNativeImageStyle>;
|
|
198
197
|
type Style = PressableStyle | ImageStyle;
|
|
199
198
|
|
|
200
|
-
function combineStyles(
|
|
201
|
-
if (typeof
|
|
199
|
+
function combineStyles(renderStyle?: Style, childValue?: Style) {
|
|
200
|
+
if (typeof renderStyle === "function" && typeof childValue === "function") {
|
|
202
201
|
return (state: PressableStateCallbackType) => {
|
|
203
|
-
return StyleSheet.flatten([
|
|
202
|
+
return StyleSheet.flatten([renderStyle(state), childValue(state)]);
|
|
204
203
|
};
|
|
205
204
|
}
|
|
206
205
|
|
|
207
|
-
if (typeof
|
|
206
|
+
if (typeof renderStyle === "function") {
|
|
208
207
|
return (state: PressableStateCallbackType) => {
|
|
209
|
-
return childValue ? StyleSheet.flatten([
|
|
208
|
+
return childValue ? StyleSheet.flatten([renderStyle(state), childValue]) : renderStyle(state);
|
|
210
209
|
};
|
|
211
210
|
}
|
|
212
211
|
|
|
213
212
|
if (typeof childValue === "function") {
|
|
214
213
|
return (state: PressableStateCallbackType) => {
|
|
215
|
-
return
|
|
214
|
+
return renderStyle ? StyleSheet.flatten([renderStyle, childValue(state)]) : childValue(state);
|
|
216
215
|
};
|
|
217
216
|
}
|
|
218
217
|
|
|
219
|
-
return StyleSheet.flatten([
|
|
218
|
+
return StyleSheet.flatten([renderStyle, childValue].filter(Boolean));
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
export function isTextChildren(children: React.ReactNode | ((state: PressableStateCallbackType) => React.ReactNode)): children is string | string[] {
|