@vvedantb/native-ui 0.36.0 → 0.36.1
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/dist/Button.jsx +20 -15
- package/dist/DropdownMenu.jsx +89 -39
- package/dist/IconButton.jsx +74 -51
- package/dist/ai/icon-button.jsx +67 -60
- package/dist/ai/prompt-input.jsx +9 -8
- package/package.json +1 -1
- package/src/Button.tsx +8 -3
- package/src/DropdownMenu.tsx +43 -6
- package/src/IconButton.tsx +7 -4
- package/src/ai/icon-button.tsx +5 -4
- package/src/ai/prompt-input.tsx +6 -4
package/dist/Button.jsx
CHANGED
|
@@ -126,8 +126,12 @@ const PRIMITIVE_VARIANT = {
|
|
|
126
126
|
link: "link",
|
|
127
127
|
tinted: "secondary"
|
|
128
128
|
};
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
/**
|
|
130
|
+
* Forwards `ref` to the native view, so a parent (such as `DropdownMenuTrigger
|
|
131
|
+
* asChild`) can measure it.
|
|
132
|
+
*/
|
|
133
|
+
export const Button = React.forwardRef(function Button(t0, ref) {
|
|
134
|
+
const $ = _c(68);
|
|
131
135
|
let children;
|
|
132
136
|
let className;
|
|
133
137
|
let endContent;
|
|
@@ -330,21 +334,22 @@ export function Button(t0) {
|
|
|
330
334
|
t27 = $[55];
|
|
331
335
|
}
|
|
332
336
|
let t28;
|
|
333
|
-
if ($[56] !== onPress || $[57] !== props || $[58] !==
|
|
334
|
-
t28 = <PrimitiveButton onPress={onPress} variant={t13} shape={shape} hitSlop={t14} accessibilityRole="button" className={t19} {...props} disabled={t20} accessibilityState={t24} style={t25}>{t27}</PrimitiveButton>;
|
|
337
|
+
if ($[56] !== onPress || $[57] !== props || $[58] !== ref || $[59] !== shape || $[60] !== t13 || $[61] !== t14 || $[62] !== t19 || $[63] !== t20 || $[64] !== t24 || $[65] !== t25 || $[66] !== t27) {
|
|
338
|
+
t28 = <PrimitiveButton ref={ref} onPress={onPress} variant={t13} shape={shape} hitSlop={t14} accessibilityRole="button" className={t19} {...props} disabled={t20} accessibilityState={t24} style={t25}>{t27}</PrimitiveButton>;
|
|
335
339
|
$[56] = onPress;
|
|
336
340
|
$[57] = props;
|
|
337
|
-
$[58] =
|
|
338
|
-
$[59] =
|
|
339
|
-
$[60] =
|
|
340
|
-
$[61] =
|
|
341
|
-
$[62] =
|
|
342
|
-
$[63] =
|
|
343
|
-
$[64] =
|
|
344
|
-
$[65] =
|
|
345
|
-
$[66] =
|
|
341
|
+
$[58] = ref;
|
|
342
|
+
$[59] = shape;
|
|
343
|
+
$[60] = t13;
|
|
344
|
+
$[61] = t14;
|
|
345
|
+
$[62] = t19;
|
|
346
|
+
$[63] = t20;
|
|
347
|
+
$[64] = t24;
|
|
348
|
+
$[65] = t25;
|
|
349
|
+
$[66] = t27;
|
|
350
|
+
$[67] = t28;
|
|
346
351
|
} else {
|
|
347
|
-
t28 = $[
|
|
352
|
+
t28 = $[67];
|
|
348
353
|
}
|
|
349
354
|
return t28;
|
|
350
|
-
}
|
|
355
|
+
});
|
package/dist/DropdownMenu.jsx
CHANGED
|
@@ -109,14 +109,46 @@ export function DropdownMenu(t0) {
|
|
|
109
109
|
}
|
|
110
110
|
return t4;
|
|
111
111
|
}
|
|
112
|
+
/** A measured box is usable when it has a size: Android reports 0, 0, 0, 0 for a view it has not laid out. */
|
|
113
|
+
export function isMeasuredRect(rect) {
|
|
114
|
+
return rect.width > 0 && rect.height > 0;
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The view's box in window coordinates, or `null` when it cannot be measured.
|
|
118
|
+
* `measureInWindow` first; when it returns an empty box, `measure` (its
|
|
119
|
+
* `pageX` and `pageY` are window coordinates too) as a second reading.
|
|
120
|
+
*/
|
|
121
|
+
export function measureAnchor(view, done) {
|
|
122
|
+
view.measureInWindow((x, y, width, height) => {
|
|
123
|
+
const rect = {
|
|
124
|
+
x,
|
|
125
|
+
y,
|
|
126
|
+
width,
|
|
127
|
+
height
|
|
128
|
+
};
|
|
129
|
+
if (isMeasuredRect(rect)) return done(rect);
|
|
130
|
+
view.measure((_x, _y, w, h, pageX, pageY) => {
|
|
131
|
+
const second = {
|
|
132
|
+
x: pageX,
|
|
133
|
+
y: pageY,
|
|
134
|
+
width: w,
|
|
135
|
+
height: h
|
|
136
|
+
};
|
|
137
|
+
done(isMeasuredRect(second) ? second : null);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
112
142
|
/**
|
|
113
143
|
* Opens the menu, or closes it when open. On press it measures itself
|
|
114
|
-
* (`measureInWindow`) and the menu opens under it. Reports `expanded`.
|
|
144
|
+
* (`measureInWindow`) and the menu opens under it. Reports `expanded`. A
|
|
145
|
+
* caller `ref` is kept: the menu's own handle never replaces it.
|
|
115
146
|
*/
|
|
116
147
|
export function DropdownMenuTrigger(t0) {
|
|
117
|
-
const $ = _c(
|
|
148
|
+
const $ = _c(22);
|
|
118
149
|
let accessibilityState;
|
|
119
150
|
let asChild;
|
|
151
|
+
let callerRef;
|
|
120
152
|
let onPress;
|
|
121
153
|
let props;
|
|
122
154
|
if ($[0] !== t0) {
|
|
@@ -124,18 +156,21 @@ export function DropdownMenuTrigger(t0) {
|
|
|
124
156
|
asChild,
|
|
125
157
|
onPress,
|
|
126
158
|
accessibilityState,
|
|
159
|
+
ref: callerRef,
|
|
127
160
|
...props
|
|
128
161
|
} = t0);
|
|
129
162
|
$[0] = t0;
|
|
130
163
|
$[1] = accessibilityState;
|
|
131
164
|
$[2] = asChild;
|
|
132
|
-
$[3] =
|
|
133
|
-
$[4] =
|
|
165
|
+
$[3] = callerRef;
|
|
166
|
+
$[4] = onPress;
|
|
167
|
+
$[5] = props;
|
|
134
168
|
} else {
|
|
135
169
|
accessibilityState = $[1];
|
|
136
170
|
asChild = $[2];
|
|
137
|
-
|
|
138
|
-
|
|
171
|
+
callerRef = $[3];
|
|
172
|
+
onPress = $[4];
|
|
173
|
+
props = $[5];
|
|
139
174
|
}
|
|
140
175
|
const {
|
|
141
176
|
open,
|
|
@@ -145,58 +180,73 @@ export function DropdownMenuTrigger(t0) {
|
|
|
145
180
|
const ref = useRef(null);
|
|
146
181
|
const Component = asChild ? Slot.Pressable : Pressable;
|
|
147
182
|
let t1;
|
|
148
|
-
if ($[
|
|
149
|
-
t1 = {
|
|
150
|
-
|
|
151
|
-
|
|
183
|
+
if ($[6] !== callerRef) {
|
|
184
|
+
t1 = view => {
|
|
185
|
+
ref.current = view;
|
|
186
|
+
if (typeof callerRef === "function") {
|
|
187
|
+
callerRef(view);
|
|
188
|
+
} else {
|
|
189
|
+
if (callerRef) {
|
|
190
|
+
callerRef.current = view;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
152
193
|
};
|
|
153
|
-
$[
|
|
154
|
-
$[6] = open;
|
|
194
|
+
$[6] = callerRef;
|
|
155
195
|
$[7] = t1;
|
|
156
196
|
} else {
|
|
157
197
|
t1 = $[7];
|
|
158
198
|
}
|
|
159
199
|
let t2;
|
|
160
|
-
if ($[8] !==
|
|
161
|
-
t2 =
|
|
200
|
+
if ($[8] !== accessibilityState || $[9] !== open) {
|
|
201
|
+
t2 = {
|
|
202
|
+
...accessibilityState,
|
|
203
|
+
expanded: open
|
|
204
|
+
};
|
|
205
|
+
$[8] = accessibilityState;
|
|
206
|
+
$[9] = open;
|
|
207
|
+
$[10] = t2;
|
|
208
|
+
} else {
|
|
209
|
+
t2 = $[10];
|
|
210
|
+
}
|
|
211
|
+
let t3;
|
|
212
|
+
if ($[11] !== onPress || $[12] !== open || $[13] !== setOpen || $[14] !== setTrigger) {
|
|
213
|
+
t3 = event => {
|
|
162
214
|
onPress?.(event);
|
|
163
215
|
if (open) {
|
|
164
216
|
return setOpen(false);
|
|
165
217
|
}
|
|
166
|
-
const
|
|
167
|
-
if (!
|
|
218
|
+
const view_0 = ref.current;
|
|
219
|
+
if (!view_0) {
|
|
168
220
|
return setOpen(true);
|
|
169
221
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
width,
|
|
175
|
-
height
|
|
176
|
-
});
|
|
222
|
+
measureAnchor(view_0, rect => {
|
|
223
|
+
if (rect) {
|
|
224
|
+
setTrigger(rect);
|
|
225
|
+
}
|
|
177
226
|
setOpen(true);
|
|
178
227
|
});
|
|
179
228
|
};
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
$[
|
|
183
|
-
$[
|
|
184
|
-
$[
|
|
229
|
+
$[11] = onPress;
|
|
230
|
+
$[12] = open;
|
|
231
|
+
$[13] = setOpen;
|
|
232
|
+
$[14] = setTrigger;
|
|
233
|
+
$[15] = t3;
|
|
185
234
|
} else {
|
|
186
|
-
|
|
235
|
+
t3 = $[15];
|
|
187
236
|
}
|
|
188
|
-
let
|
|
189
|
-
if ($[
|
|
190
|
-
|
|
191
|
-
$[
|
|
192
|
-
$[
|
|
193
|
-
$[
|
|
194
|
-
$[
|
|
195
|
-
$[
|
|
237
|
+
let t4;
|
|
238
|
+
if ($[16] !== Component || $[17] !== props || $[18] !== t1 || $[19] !== t2 || $[20] !== t3) {
|
|
239
|
+
t4 = <Component ref={t1} accessibilityRole="button" {...props} accessibilityState={t2} onPress={t3} />;
|
|
240
|
+
$[16] = Component;
|
|
241
|
+
$[17] = props;
|
|
242
|
+
$[18] = t1;
|
|
243
|
+
$[19] = t2;
|
|
244
|
+
$[20] = t3;
|
|
245
|
+
$[21] = t4;
|
|
196
246
|
} else {
|
|
197
|
-
|
|
247
|
+
t4 = $[21];
|
|
198
248
|
}
|
|
199
|
-
return
|
|
249
|
+
return t4;
|
|
200
250
|
}
|
|
201
251
|
/**
|
|
202
252
|
* Where the menu goes: under the trigger, `sideOffset` away, its start edge on
|
package/dist/IconButton.jsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
3
|
+
import { View } from "react-native";
|
|
2
4
|
import { touchSlop } from "./controlStyles";
|
|
3
5
|
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
4
6
|
import { withAlpha } from "./palette";
|
|
@@ -40,8 +42,8 @@ export function iconButtonColors(variant, scheme) {
|
|
|
40
42
|
* 32, `md` 40) and 48, each reaching 44 with its hit slop. Not the AI chat
|
|
41
43
|
* `ChatIconButton`.
|
|
42
44
|
*/
|
|
43
|
-
export function IconButton(t0) {
|
|
44
|
-
const $ = _c(
|
|
45
|
+
export const IconButton = forwardRef(function IconButton(t0, ref) {
|
|
46
|
+
const $ = _c(41);
|
|
45
47
|
const {
|
|
46
48
|
icon: Icon,
|
|
47
49
|
label,
|
|
@@ -96,76 +98,97 @@ export function IconButton(t0) {
|
|
|
96
98
|
}
|
|
97
99
|
const press = usePressScale(t6);
|
|
98
100
|
let t7;
|
|
99
|
-
if ($[9] !==
|
|
101
|
+
if ($[9] !== diameter) {
|
|
100
102
|
t7 = {
|
|
101
|
-
|
|
103
|
+
width: diameter,
|
|
104
|
+
height: diameter
|
|
102
105
|
};
|
|
103
|
-
$[9] =
|
|
106
|
+
$[9] = diameter;
|
|
104
107
|
$[10] = t7;
|
|
105
108
|
} else {
|
|
106
109
|
t7 = $[10];
|
|
107
110
|
}
|
|
108
111
|
let t8;
|
|
109
|
-
if ($[11] !==
|
|
110
|
-
t8 =
|
|
111
|
-
|
|
112
|
+
if ($[11] !== disabled) {
|
|
113
|
+
t8 = {
|
|
114
|
+
disabled
|
|
115
|
+
};
|
|
116
|
+
$[11] = disabled;
|
|
112
117
|
$[12] = t8;
|
|
113
118
|
} else {
|
|
114
119
|
t8 = $[12];
|
|
115
120
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
121
|
+
let t9;
|
|
122
|
+
if ($[13] !== diameter) {
|
|
123
|
+
t9 = touchSlop(diameter);
|
|
124
|
+
$[13] = diameter;
|
|
125
|
+
$[14] = t9;
|
|
126
|
+
} else {
|
|
127
|
+
t9 = $[14];
|
|
128
|
+
}
|
|
129
|
+
const t10 = diameter / 2;
|
|
130
|
+
let t11;
|
|
131
|
+
if ($[15] !== diameter || $[16] !== frame || $[17] !== t10) {
|
|
132
|
+
t11 = {
|
|
120
133
|
width: diameter,
|
|
121
134
|
height: diameter,
|
|
122
|
-
borderRadius:
|
|
135
|
+
borderRadius: t10,
|
|
123
136
|
borderWidth: 1,
|
|
124
137
|
...frame
|
|
125
138
|
};
|
|
126
|
-
$[
|
|
127
|
-
$[
|
|
128
|
-
$[
|
|
129
|
-
$[
|
|
139
|
+
$[15] = diameter;
|
|
140
|
+
$[16] = frame;
|
|
141
|
+
$[17] = t10;
|
|
142
|
+
$[18] = t11;
|
|
130
143
|
} else {
|
|
131
|
-
|
|
144
|
+
t11 = $[18];
|
|
132
145
|
}
|
|
133
|
-
let
|
|
134
|
-
if ($[
|
|
135
|
-
|
|
136
|
-
$[
|
|
137
|
-
$[
|
|
138
|
-
$[
|
|
146
|
+
let t12;
|
|
147
|
+
if ($[19] !== press.style || $[20] !== t11) {
|
|
148
|
+
t12 = [t11, press.style];
|
|
149
|
+
$[19] = press.style;
|
|
150
|
+
$[20] = t11;
|
|
151
|
+
$[21] = t12;
|
|
139
152
|
} else {
|
|
140
|
-
|
|
153
|
+
t12 = $[21];
|
|
141
154
|
}
|
|
142
|
-
const
|
|
143
|
-
let
|
|
144
|
-
if ($[
|
|
145
|
-
|
|
146
|
-
$[
|
|
147
|
-
$[
|
|
148
|
-
$[
|
|
149
|
-
$[
|
|
155
|
+
const t13 = iconColor ?? color;
|
|
156
|
+
let t14;
|
|
157
|
+
if ($[22] !== Icon || $[23] !== iconSize || $[24] !== t13) {
|
|
158
|
+
t14 = <Icon size={iconSize} color={t13} />;
|
|
159
|
+
$[22] = Icon;
|
|
160
|
+
$[23] = iconSize;
|
|
161
|
+
$[24] = t13;
|
|
162
|
+
$[25] = t14;
|
|
150
163
|
} else {
|
|
151
|
-
|
|
164
|
+
t14 = $[25];
|
|
152
165
|
}
|
|
153
|
-
let
|
|
154
|
-
if ($[
|
|
155
|
-
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
160
|
-
$[
|
|
161
|
-
$[
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
166
|
+
let t15;
|
|
167
|
+
if ($[26] !== disabled || $[27] !== label || $[28] !== onPress || $[29] !== press.onPressIn || $[30] !== press.onPressOut || $[31] !== t12 || $[32] !== t14 || $[33] !== t8 || $[34] !== t9 || $[35] !== testID) {
|
|
168
|
+
t15 = <AnimatedPressable testID={testID} accessibilityRole="button" accessibilityLabel={label} accessibilityState={t8} hitSlop={t9} disabled={disabled} onPress={onPress} onPressIn={press.onPressIn} onPressOut={press.onPressOut} className="items-center justify-center" style={t12}>{t14}</AnimatedPressable>;
|
|
169
|
+
$[26] = disabled;
|
|
170
|
+
$[27] = label;
|
|
171
|
+
$[28] = onPress;
|
|
172
|
+
$[29] = press.onPressIn;
|
|
173
|
+
$[30] = press.onPressOut;
|
|
174
|
+
$[31] = t12;
|
|
175
|
+
$[32] = t14;
|
|
176
|
+
$[33] = t8;
|
|
177
|
+
$[34] = t9;
|
|
178
|
+
$[35] = testID;
|
|
179
|
+
$[36] = t15;
|
|
167
180
|
} else {
|
|
168
|
-
|
|
181
|
+
t15 = $[36];
|
|
169
182
|
}
|
|
170
|
-
|
|
171
|
-
|
|
183
|
+
let t16;
|
|
184
|
+
if ($[37] !== ref || $[38] !== t15 || $[39] !== t7) {
|
|
185
|
+
t16 = <View ref={ref} collapsable={false} style={t7}>{t15}</View>;
|
|
186
|
+
$[37] = ref;
|
|
187
|
+
$[38] = t15;
|
|
188
|
+
$[39] = t7;
|
|
189
|
+
$[40] = t16;
|
|
190
|
+
} else {
|
|
191
|
+
t16 = $[40];
|
|
192
|
+
}
|
|
193
|
+
return t16;
|
|
194
|
+
});
|
package/dist/ai/icon-button.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
+
import { forwardRef } from "react";
|
|
2
3
|
import { Button } from "../Button";
|
|
3
4
|
import { cn } from "../cn";
|
|
4
5
|
import { MIN_TOUCH_TARGET, buttonColors, touchSlop } from "../controlStyles";
|
|
@@ -45,8 +46,8 @@ const CHAT_ICON_BUTTON = {
|
|
|
45
46
|
* actions, the composer tools and its send button, and the code copy button.
|
|
46
47
|
* Round from the `Button` pill default; `shape="rounded"` gives radius 16.
|
|
47
48
|
*/
|
|
48
|
-
export function ChatIconButton(t0) {
|
|
49
|
-
const $ = _c(
|
|
49
|
+
export const ChatIconButton = forwardRef(function ChatIconButton(t0, ref) {
|
|
50
|
+
const $ = _c(45);
|
|
50
51
|
let Icon;
|
|
51
52
|
let className;
|
|
52
53
|
let iconColor;
|
|
@@ -98,82 +99,88 @@ export function ChatIconButton(t0) {
|
|
|
98
99
|
let t6;
|
|
99
100
|
let t7;
|
|
100
101
|
let t8;
|
|
101
|
-
|
|
102
|
+
let t9;
|
|
103
|
+
if ($[9] !== className || $[10] !== iconColor || $[11] !== label || $[12] !== largerText || $[13] !== ref || $[14] !== scheme || $[15] !== size || $[16] !== slop || $[17] !== variant) {
|
|
102
104
|
metrics = largerText ? {
|
|
103
105
|
side: MIN_TOUCH_TARGET,
|
|
104
106
|
icon: 20,
|
|
105
107
|
className: "h-11 w-11"
|
|
106
108
|
} : CHAT_ICON_BUTTON[size];
|
|
107
|
-
let
|
|
108
|
-
if ($[
|
|
109
|
-
|
|
110
|
-
$[
|
|
111
|
-
$[
|
|
112
|
-
$[
|
|
113
|
-
$[
|
|
109
|
+
let t10;
|
|
110
|
+
if ($[27] !== iconColor || $[28] !== scheme || $[29] !== variant) {
|
|
111
|
+
t10 = iconColor ?? buttonColors(variant, scheme)?.color ?? tokens.color.foreground[scheme];
|
|
112
|
+
$[27] = iconColor;
|
|
113
|
+
$[28] = scheme;
|
|
114
|
+
$[29] = variant;
|
|
115
|
+
$[30] = t10;
|
|
114
116
|
} else {
|
|
115
|
-
|
|
117
|
+
t10 = $[30];
|
|
116
118
|
}
|
|
117
|
-
color =
|
|
119
|
+
color = t10;
|
|
118
120
|
T0 = Button;
|
|
119
|
-
t4 =
|
|
120
|
-
t5 =
|
|
121
|
-
t6 =
|
|
122
|
-
t7 =
|
|
121
|
+
t4 = ref;
|
|
122
|
+
t5 = variant;
|
|
123
|
+
t6 = "icon";
|
|
124
|
+
t7 = label;
|
|
125
|
+
t8 = slop === "square" ? touchSlop(metrics.side) : {
|
|
123
126
|
...touchSlop(MIN_TOUCH_TARGET, metrics.side),
|
|
124
127
|
...(slop === "vertical" ? null : slop)
|
|
125
128
|
};
|
|
126
|
-
|
|
129
|
+
t9 = cn(metrics.className, className);
|
|
127
130
|
$[9] = className;
|
|
128
131
|
$[10] = iconColor;
|
|
129
132
|
$[11] = label;
|
|
130
133
|
$[12] = largerText;
|
|
131
|
-
$[13] =
|
|
132
|
-
$[14] =
|
|
133
|
-
$[15] =
|
|
134
|
-
$[16] =
|
|
135
|
-
$[17] =
|
|
136
|
-
$[18] =
|
|
137
|
-
$[19] =
|
|
138
|
-
$[20] =
|
|
139
|
-
$[21] =
|
|
140
|
-
$[22] =
|
|
141
|
-
$[23] =
|
|
142
|
-
$[24] =
|
|
134
|
+
$[13] = ref;
|
|
135
|
+
$[14] = scheme;
|
|
136
|
+
$[15] = size;
|
|
137
|
+
$[16] = slop;
|
|
138
|
+
$[17] = variant;
|
|
139
|
+
$[18] = T0;
|
|
140
|
+
$[19] = color;
|
|
141
|
+
$[20] = metrics;
|
|
142
|
+
$[21] = t4;
|
|
143
|
+
$[22] = t5;
|
|
144
|
+
$[23] = t6;
|
|
145
|
+
$[24] = t7;
|
|
146
|
+
$[25] = t8;
|
|
147
|
+
$[26] = t9;
|
|
143
148
|
} else {
|
|
144
|
-
T0 = $[
|
|
145
|
-
color = $[
|
|
146
|
-
metrics = $[
|
|
147
|
-
t4 = $[
|
|
148
|
-
t5 = $[
|
|
149
|
-
t6 = $[
|
|
150
|
-
t7 = $[
|
|
151
|
-
t8 = $[
|
|
149
|
+
T0 = $[18];
|
|
150
|
+
color = $[19];
|
|
151
|
+
metrics = $[20];
|
|
152
|
+
t4 = $[21];
|
|
153
|
+
t5 = $[22];
|
|
154
|
+
t6 = $[23];
|
|
155
|
+
t7 = $[24];
|
|
156
|
+
t8 = $[25];
|
|
157
|
+
t9 = $[26];
|
|
152
158
|
}
|
|
153
|
-
let
|
|
154
|
-
if ($[
|
|
155
|
-
|
|
156
|
-
$[
|
|
157
|
-
$[
|
|
158
|
-
$[
|
|
159
|
-
$[
|
|
159
|
+
let t10;
|
|
160
|
+
if ($[31] !== Icon || $[32] !== color || $[33] !== metrics.icon) {
|
|
161
|
+
t10 = <Icon size={metrics.icon} color={color} />;
|
|
162
|
+
$[31] = Icon;
|
|
163
|
+
$[32] = color;
|
|
164
|
+
$[33] = metrics.icon;
|
|
165
|
+
$[34] = t10;
|
|
160
166
|
} else {
|
|
161
|
-
|
|
167
|
+
t10 = $[34];
|
|
162
168
|
}
|
|
163
|
-
let
|
|
164
|
-
if ($[
|
|
165
|
-
|
|
166
|
-
$[
|
|
167
|
-
$[
|
|
168
|
-
$[
|
|
169
|
-
$[
|
|
170
|
-
$[
|
|
171
|
-
$[
|
|
172
|
-
$[
|
|
173
|
-
$[
|
|
174
|
-
$[
|
|
169
|
+
let t11;
|
|
170
|
+
if ($[35] !== T0 || $[36] !== props || $[37] !== t10 || $[38] !== t4 || $[39] !== t5 || $[40] !== t6 || $[41] !== t7 || $[42] !== t8 || $[43] !== t9) {
|
|
171
|
+
t11 = <T0 ref={t4} variant={t5} size={t6} accessibilityLabel={t7} hitSlop={t8} className={t9} {...props}>{t10}</T0>;
|
|
172
|
+
$[35] = T0;
|
|
173
|
+
$[36] = props;
|
|
174
|
+
$[37] = t10;
|
|
175
|
+
$[38] = t4;
|
|
176
|
+
$[39] = t5;
|
|
177
|
+
$[40] = t6;
|
|
178
|
+
$[41] = t7;
|
|
179
|
+
$[42] = t8;
|
|
180
|
+
$[43] = t9;
|
|
181
|
+
$[44] = t11;
|
|
175
182
|
} else {
|
|
176
|
-
|
|
183
|
+
t11 = $[44];
|
|
177
184
|
}
|
|
178
|
-
return
|
|
179
|
-
}
|
|
185
|
+
return t11;
|
|
186
|
+
});
|
package/dist/ai/prompt-input.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { c as _c } from "react/compiler-runtime";
|
|
2
|
-
import { useContext, useState } from "react";
|
|
2
|
+
import { forwardRef, useContext, useState } from "react";
|
|
3
3
|
import { Platform, Pressable, Text, View, useWindowDimensions } from "react-native";
|
|
4
4
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
5
5
|
import { IconArrowUp, IconChevronDown, IconPlayerStopFilled } from "@tabler/icons-react-native";
|
|
@@ -75,18 +75,19 @@ export function PromptInputSubmit(t0) {
|
|
|
75
75
|
return t3;
|
|
76
76
|
}
|
|
77
77
|
/** A ghost tool button for the composer `toolbar`, such as attach (web `PromptInputButton`). Give it `icon` and `label`. */
|
|
78
|
-
export function PromptInputButton(props) {
|
|
79
|
-
const $ = _c(
|
|
78
|
+
export const PromptInputButton = forwardRef(function PromptInputButton(props, ref) {
|
|
79
|
+
const $ = _c(3);
|
|
80
80
|
let t0;
|
|
81
|
-
if ($[0] !== props) {
|
|
82
|
-
t0 = <ChatIconButton variant="ghost" {...props} />;
|
|
81
|
+
if ($[0] !== props || $[1] !== ref) {
|
|
82
|
+
t0 = <ChatIconButton ref={ref} variant="ghost" {...props} />;
|
|
83
83
|
$[0] = props;
|
|
84
|
-
$[1] =
|
|
84
|
+
$[1] = ref;
|
|
85
|
+
$[2] = t0;
|
|
85
86
|
} else {
|
|
86
|
-
t0 = $[
|
|
87
|
+
t0 = $[2];
|
|
87
88
|
}
|
|
88
89
|
return t0;
|
|
89
|
-
}
|
|
90
|
+
});
|
|
90
91
|
|
|
91
92
|
/**
|
|
92
93
|
* The web `ModelPicker` trigger (`model-picker.tsx` `TRIGGER_CLASS`), the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/native-ui",
|
|
3
|
-
"version": "0.36.
|
|
3
|
+
"version": "0.36.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React Native / Expo UI primitives. Floating surfaces, forms, overlays, toasts, settings chrome, tab bar, AI chat parts, the family app marks, a NativeWind preset, the Expo web root and Clerk + Convex auth screens.",
|
|
6
6
|
"type": "module",
|
package/src/Button.tsx
CHANGED
|
@@ -140,7 +140,11 @@ const PRIMITIVE_VARIANT = {
|
|
|
140
140
|
|
|
141
141
|
export type { ButtonProps, ButtonShape, ButtonSize, ButtonVariant };
|
|
142
142
|
|
|
143
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Forwards `ref` to the native view, so a parent (such as `DropdownMenuTrigger
|
|
145
|
+
* asChild`) can measure it.
|
|
146
|
+
*/
|
|
147
|
+
export const Button = React.forwardRef<React.ElementRef<typeof PrimitiveButton>, ButtonProps>(function Button({
|
|
144
148
|
onPress,
|
|
145
149
|
variant = "primary",
|
|
146
150
|
icon,
|
|
@@ -155,7 +159,7 @@ export function Button({
|
|
|
155
159
|
shadowType = "flat",
|
|
156
160
|
className,
|
|
157
161
|
...props
|
|
158
|
-
}
|
|
162
|
+
}, ref) {
|
|
159
163
|
const scale = useLargerText() ? "larger" : "regular";
|
|
160
164
|
const scheme = useScheme();
|
|
161
165
|
const dialog = useDialogLayout();
|
|
@@ -186,6 +190,7 @@ export function Button({
|
|
|
186
190
|
|
|
187
191
|
return (
|
|
188
192
|
<PrimitiveButton
|
|
193
|
+
ref={ref}
|
|
189
194
|
onPress={onPress}
|
|
190
195
|
variant={PRIMITIVE_VARIANT[variant]}
|
|
191
196
|
shape={shape}
|
|
@@ -239,4 +244,4 @@ export function Button({
|
|
|
239
244
|
</View>
|
|
240
245
|
</PrimitiveButton>
|
|
241
246
|
);
|
|
242
|
-
}
|
|
247
|
+
});
|
package/src/DropdownMenu.tsx
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type ComponentRef,
|
|
9
9
|
type ComponentType,
|
|
10
10
|
type ReactNode,
|
|
11
|
+
type Ref,
|
|
11
12
|
} from "react";
|
|
12
13
|
import {
|
|
13
14
|
Pressable,
|
|
@@ -111,19 +112,55 @@ export type DropdownMenuTriggerProps = PressableProps & {
|
|
|
111
112
|
* native view, so the menu can measure it.
|
|
112
113
|
*/
|
|
113
114
|
asChild?: boolean;
|
|
115
|
+
/** Also receives the native view; the menu keeps its own handle. */
|
|
116
|
+
ref?: Ref<ComponentRef<typeof View>>;
|
|
114
117
|
};
|
|
115
118
|
|
|
119
|
+
/** A measured box is usable when it has a size: Android reports 0, 0, 0, 0 for a view it has not laid out. */
|
|
120
|
+
export function isMeasuredRect(rect: DropdownMenuRect): boolean {
|
|
121
|
+
return rect.width > 0 && rect.height > 0;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
type Measurable = Pick<ComponentRef<typeof View>, "measureInWindow" | "measure">;
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* The view's box in window coordinates, or `null` when it cannot be measured.
|
|
128
|
+
* `measureInWindow` first; when it returns an empty box, `measure` (its
|
|
129
|
+
* `pageX` and `pageY` are window coordinates too) as a second reading.
|
|
130
|
+
*/
|
|
131
|
+
export function measureAnchor(view: Measurable, done: (rect: DropdownMenuRect | null) => void) {
|
|
132
|
+
view.measureInWindow((x, y, width, height) => {
|
|
133
|
+
const rect = { x, y, width, height };
|
|
134
|
+
if (isMeasuredRect(rect)) return done(rect);
|
|
135
|
+
view.measure((_x, _y, w, h, pageX, pageY) => {
|
|
136
|
+
const second = { x: pageX, y: pageY, width: w, height: h };
|
|
137
|
+
done(isMeasuredRect(second) ? second : null);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
|
|
116
142
|
/**
|
|
117
143
|
* Opens the menu, or closes it when open. On press it measures itself
|
|
118
|
-
* (`measureInWindow`) and the menu opens under it. Reports `expanded`.
|
|
144
|
+
* (`measureInWindow`) and the menu opens under it. Reports `expanded`. A
|
|
145
|
+
* caller `ref` is kept: the menu's own handle never replaces it.
|
|
119
146
|
*/
|
|
120
|
-
export function DropdownMenuTrigger({
|
|
147
|
+
export function DropdownMenuTrigger({
|
|
148
|
+
asChild,
|
|
149
|
+
onPress,
|
|
150
|
+
accessibilityState,
|
|
151
|
+
ref: callerRef,
|
|
152
|
+
...props
|
|
153
|
+
}: DropdownMenuTriggerProps) {
|
|
121
154
|
const { open, setOpen, setTrigger } = useMenu("DropdownMenuTrigger");
|
|
122
|
-
const ref = useRef<ComponentRef<typeof View
|
|
155
|
+
const ref = useRef<ComponentRef<typeof View> | null>(null);
|
|
123
156
|
const Component = asChild ? Slot.Pressable : Pressable;
|
|
124
157
|
return (
|
|
125
158
|
<Component
|
|
126
|
-
ref={
|
|
159
|
+
ref={(view: ComponentRef<typeof View> | null) => {
|
|
160
|
+
ref.current = view;
|
|
161
|
+
if (typeof callerRef === "function") callerRef(view);
|
|
162
|
+
else if (callerRef) callerRef.current = view;
|
|
163
|
+
}}
|
|
127
164
|
accessibilityRole="button"
|
|
128
165
|
{...props}
|
|
129
166
|
accessibilityState={{ ...accessibilityState, expanded: open }}
|
|
@@ -132,8 +169,8 @@ export function DropdownMenuTrigger({ asChild, onPress, accessibilityState, ...p
|
|
|
132
169
|
if (open) return setOpen(false);
|
|
133
170
|
const view = ref.current;
|
|
134
171
|
if (!view) return setOpen(true);
|
|
135
|
-
view
|
|
136
|
-
setTrigger(
|
|
172
|
+
measureAnchor(view, (rect) => {
|
|
173
|
+
if (rect) setTrigger(rect);
|
|
137
174
|
setOpen(true);
|
|
138
175
|
});
|
|
139
176
|
}}
|
package/src/IconButton.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { forwardRef, type ComponentRef, type ComponentType } from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
2
3
|
import type { IconProps } from "@tabler/icons-react-native";
|
|
3
4
|
import { touchSlop } from "./controlStyles";
|
|
4
5
|
import { AnimatedPressable, usePressScale } from "./pressScale";
|
|
@@ -54,7 +55,7 @@ export function iconButtonColors(variant: IconButtonVariant, scheme: "light" | "
|
|
|
54
55
|
* 32, `md` 40) and 48, each reaching 44 with its hit slop. Not the AI chat
|
|
55
56
|
* `ChatIconButton`.
|
|
56
57
|
*/
|
|
57
|
-
export function IconButton({
|
|
58
|
+
export const IconButton = forwardRef<ComponentRef<typeof View>, IconButtonProps>(function IconButton({
|
|
58
59
|
icon: Icon,
|
|
59
60
|
label,
|
|
60
61
|
onPress,
|
|
@@ -63,13 +64,14 @@ export function IconButton({
|
|
|
63
64
|
size = "md",
|
|
64
65
|
testID,
|
|
65
66
|
iconColor,
|
|
66
|
-
}
|
|
67
|
+
}, ref) {
|
|
67
68
|
const scheme = useScheme();
|
|
68
69
|
const largerText = useLargerText();
|
|
69
70
|
const [diameter, iconSize] = METRICS[largerText ? "larger" : "regular"][size];
|
|
70
71
|
const { color, ...frame } = iconButtonColors(variant, scheme);
|
|
71
72
|
const press = usePressScale({ restOpacity: disabled ? 0.5 : 1, disabled });
|
|
72
73
|
return (
|
|
74
|
+
<View ref={ref} collapsable={false} style={{ width: diameter, height: diameter }}>
|
|
73
75
|
<AnimatedPressable
|
|
74
76
|
testID={testID}
|
|
75
77
|
accessibilityRole="button"
|
|
@@ -85,5 +87,6 @@ export function IconButton({
|
|
|
85
87
|
>
|
|
86
88
|
<Icon size={iconSize} color={iconColor ?? color} />
|
|
87
89
|
</AnimatedPressable>
|
|
90
|
+
</View>
|
|
88
91
|
);
|
|
89
|
-
}
|
|
92
|
+
});
|
package/src/ai/icon-button.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { forwardRef, type ComponentType, type ElementRef } from "react";
|
|
2
2
|
import type { IconProps } from "@tabler/icons-react-native";
|
|
3
3
|
import { Button, type ButtonProps } from "../Button";
|
|
4
4
|
import { cn } from "../cn";
|
|
@@ -51,7 +51,7 @@ export type ChatIconButtonProps = Omit<ButtonProps, "children" | "size" | "icon"
|
|
|
51
51
|
* actions, the composer tools and its send button, and the code copy button.
|
|
52
52
|
* Round from the `Button` pill default; `shape="rounded"` gives radius 16.
|
|
53
53
|
*/
|
|
54
|
-
export function ChatIconButton({
|
|
54
|
+
export const ChatIconButton = forwardRef<ElementRef<typeof Button>, ChatIconButtonProps>(function ChatIconButton({
|
|
55
55
|
icon: Icon,
|
|
56
56
|
label,
|
|
57
57
|
iconColor,
|
|
@@ -60,7 +60,7 @@ export function ChatIconButton({
|
|
|
60
60
|
slop = "square",
|
|
61
61
|
className,
|
|
62
62
|
...props
|
|
63
|
-
}
|
|
63
|
+
}, ref) {
|
|
64
64
|
const scheme = useScheme();
|
|
65
65
|
const largerText = useLargerText();
|
|
66
66
|
const metrics = largerText
|
|
@@ -69,6 +69,7 @@ export function ChatIconButton({
|
|
|
69
69
|
const color = iconColor ?? buttonColors(variant, scheme)?.color ?? tokens.color.foreground[scheme];
|
|
70
70
|
return (
|
|
71
71
|
<Button
|
|
72
|
+
ref={ref}
|
|
72
73
|
variant={variant}
|
|
73
74
|
size="icon"
|
|
74
75
|
accessibilityLabel={label}
|
|
@@ -83,4 +84,4 @@ export function ChatIconButton({
|
|
|
83
84
|
<Icon size={metrics.icon} color={color} />
|
|
84
85
|
</Button>
|
|
85
86
|
);
|
|
86
|
-
}
|
|
87
|
+
});
|
package/src/ai/prompt-input.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useContext, useState, type ReactNode } from "react";
|
|
1
|
+
import { forwardRef, useContext, useState, type ElementRef, type ReactNode } from "react";
|
|
2
2
|
import { Platform, Pressable, Text, View, useWindowDimensions } from "react-native";
|
|
3
3
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
4
4
|
import { IconArrowUp, IconChevronDown, IconPlayerStopFilled } from "@tabler/icons-react-native";
|
|
@@ -83,9 +83,11 @@ export function PromptInputSubmit({
|
|
|
83
83
|
export type PromptInputButtonProps = ChatIconButtonProps;
|
|
84
84
|
|
|
85
85
|
/** A ghost tool button for the composer `toolbar`, such as attach (web `PromptInputButton`). Give it `icon` and `label`. */
|
|
86
|
-
export
|
|
87
|
-
|
|
88
|
-
}
|
|
86
|
+
export const PromptInputButton = forwardRef<ElementRef<typeof ChatIconButton>, PromptInputButtonProps>(
|
|
87
|
+
function PromptInputButton(props, ref) {
|
|
88
|
+
return <ChatIconButton ref={ref} variant="ghost" {...props} />;
|
|
89
|
+
},
|
|
90
|
+
);
|
|
89
91
|
|
|
90
92
|
/**
|
|
91
93
|
* The web `ModelPicker` trigger (`model-picker.tsx` `TRIGGER_CLASS`), the
|