@vvedantb/native-ui 0.35.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.
Files changed (42) hide show
  1. package/README.md +16 -1
  2. package/dist/Button.jsx +29 -18
  3. package/dist/DropdownMenu.jsx +89 -39
  4. package/dist/ExpoWebRoot.jsx +42 -21
  5. package/dist/Field.jsx +309 -0
  6. package/dist/FloatingTabBar.jsx +98 -94
  7. package/dist/IconButton.jsx +74 -51
  8. package/dist/ai/conversation.jsx +1 -1
  9. package/dist/ai/icon-button.jsx +67 -60
  10. package/dist/ai/prompt-input.jsx +9 -8
  11. package/dist/blur.js +6 -0
  12. package/dist/controlStyles.js +24 -2
  13. package/dist/entries/primitives.js +1 -0
  14. package/dist/examples/ParityGallery.jsx +488 -475
  15. package/dist/glassBlur.jsx +1 -1
  16. package/dist/index.js +1 -0
  17. package/dist/primitives/window-layer.jsx +35 -28
  18. package/package.json +27 -3
  19. package/src/Button.tsx +18 -7
  20. package/src/DropdownMenu.tsx +53 -7
  21. package/src/ExpoWebRoot.tsx +18 -3
  22. package/src/Field.tsx +105 -0
  23. package/src/FloatingTabBar.tsx +17 -12
  24. package/src/IconButton.tsx +7 -4
  25. package/src/Spinner.tsx +2 -2
  26. package/src/ai/conversation.tsx +1 -1
  27. package/src/ai/icon-button.tsx +5 -4
  28. package/src/ai/message.tsx +2 -2
  29. package/src/ai/prompt-input.tsx +6 -4
  30. package/src/auth/AccountScreens.tsx +4 -4
  31. package/src/auth/SignInScreen.tsx +4 -4
  32. package/src/blur.ts +8 -0
  33. package/src/controlStyles.ts +29 -2
  34. package/src/entries/primitives.ts +2 -0
  35. package/src/examples/ParityGallery.tsx +22 -1
  36. package/src/glassBlur.tsx +5 -7
  37. package/src/index.ts +2 -0
  38. package/src/primitives/sheet-gesture.tsx +1 -2
  39. package/src/primitives/web-click-guard.ts +3 -3
  40. package/src/primitives/window-layer.tsx +8 -6
  41. package/src/tabBarRoutes.ts +4 -3
  42. package/src/webview/HtmlView.tsx +5 -2
@@ -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(35);
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] !== disabled) {
101
+ if ($[9] !== diameter) {
100
102
  t7 = {
101
- disabled
103
+ width: diameter,
104
+ height: diameter
102
105
  };
103
- $[9] = disabled;
106
+ $[9] = diameter;
104
107
  $[10] = t7;
105
108
  } else {
106
109
  t7 = $[10];
107
110
  }
108
111
  let t8;
109
- if ($[11] !== diameter) {
110
- t8 = touchSlop(diameter);
111
- $[11] = diameter;
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
- const t9 = diameter / 2;
117
- let t10;
118
- if ($[13] !== diameter || $[14] !== frame || $[15] !== t9) {
119
- t10 = {
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: t9,
135
+ borderRadius: t10,
123
136
  borderWidth: 1,
124
137
  ...frame
125
138
  };
126
- $[13] = diameter;
127
- $[14] = frame;
128
- $[15] = t9;
129
- $[16] = t10;
139
+ $[15] = diameter;
140
+ $[16] = frame;
141
+ $[17] = t10;
142
+ $[18] = t11;
130
143
  } else {
131
- t10 = $[16];
144
+ t11 = $[18];
132
145
  }
133
- let t11;
134
- if ($[17] !== press.style || $[18] !== t10) {
135
- t11 = [t10, press.style];
136
- $[17] = press.style;
137
- $[18] = t10;
138
- $[19] = t11;
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
- t11 = $[19];
153
+ t12 = $[21];
141
154
  }
142
- const t12 = iconColor ?? color;
143
- let t13;
144
- if ($[20] !== Icon || $[21] !== iconSize || $[22] !== t12) {
145
- t13 = <Icon size={iconSize} color={t12} />;
146
- $[20] = Icon;
147
- $[21] = iconSize;
148
- $[22] = t12;
149
- $[23] = t13;
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
- t13 = $[23];
164
+ t14 = $[25];
152
165
  }
153
- let t14;
154
- if ($[24] !== disabled || $[25] !== label || $[26] !== onPress || $[27] !== press.onPressIn || $[28] !== press.onPressOut || $[29] !== t11 || $[30] !== t13 || $[31] !== t7 || $[32] !== t8 || $[33] !== testID) {
155
- t14 = <AnimatedPressable testID={testID} accessibilityRole="button" accessibilityLabel={label} accessibilityState={t7} hitSlop={t8} disabled={disabled} onPress={onPress} onPressIn={press.onPressIn} onPressOut={press.onPressOut} className="items-center justify-center" style={t11}>{t13}</AnimatedPressable>;
156
- $[24] = disabled;
157
- $[25] = label;
158
- $[26] = onPress;
159
- $[27] = press.onPressIn;
160
- $[28] = press.onPressOut;
161
- $[29] = t11;
162
- $[30] = t13;
163
- $[31] = t7;
164
- $[32] = t8;
165
- $[33] = testID;
166
- $[34] = t14;
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
- t14 = $[34];
181
+ t15 = $[36];
169
182
  }
170
- return t14;
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
+ });
@@ -399,7 +399,7 @@ export function ConversationList({
399
399
  // only if the element takes a `style`: draw it the right way up instead.
400
400
  if (inverted && !hasRows) {
401
401
  const Empty = props.ListEmptyComponent;
402
- return <View style={styles.fill}>{isValidElement(Empty) ? Empty : Empty ? <Empty /> : null}</View>;
402
+ return <View style={styles.fill}>{isValidElement(Empty) ? Empty : typeof Empty === "function" ? <Empty /> : null}</View>;
403
403
  }
404
404
  // The newest message's offset: inverted, 0 less the space before it.
405
405
  const end = () => inverted ? size.current.inset > 0 ? -size.current.inset : 0 : Math.max(0, size.current.content + size.current.inset - size.current.view);
@@ -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(42);
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
- if ($[9] !== className || $[10] !== iconColor || $[11] !== label || $[12] !== largerText || $[13] !== scheme || $[14] !== size || $[15] !== slop || $[16] !== variant) {
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 t9;
108
- if ($[25] !== iconColor || $[26] !== scheme || $[27] !== variant) {
109
- t9 = iconColor ?? buttonColors(variant, scheme)?.color ?? tokens.color.foreground[scheme];
110
- $[25] = iconColor;
111
- $[26] = scheme;
112
- $[27] = variant;
113
- $[28] = t9;
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
- t9 = $[28];
117
+ t10 = $[30];
116
118
  }
117
- color = t9;
119
+ color = t10;
118
120
  T0 = Button;
119
- t4 = variant;
120
- t5 = "icon";
121
- t6 = label;
122
- t7 = slop === "square" ? touchSlop(metrics.side) : {
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
- t8 = cn(metrics.className, className);
129
+ t9 = cn(metrics.className, className);
127
130
  $[9] = className;
128
131
  $[10] = iconColor;
129
132
  $[11] = label;
130
133
  $[12] = largerText;
131
- $[13] = scheme;
132
- $[14] = size;
133
- $[15] = slop;
134
- $[16] = variant;
135
- $[17] = T0;
136
- $[18] = color;
137
- $[19] = metrics;
138
- $[20] = t4;
139
- $[21] = t5;
140
- $[22] = t6;
141
- $[23] = t7;
142
- $[24] = t8;
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 = $[17];
145
- color = $[18];
146
- metrics = $[19];
147
- t4 = $[20];
148
- t5 = $[21];
149
- t6 = $[22];
150
- t7 = $[23];
151
- t8 = $[24];
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 t9;
154
- if ($[29] !== Icon || $[30] !== color || $[31] !== metrics.icon) {
155
- t9 = <Icon size={metrics.icon} color={color} />;
156
- $[29] = Icon;
157
- $[30] = color;
158
- $[31] = metrics.icon;
159
- $[32] = t9;
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
- t9 = $[32];
167
+ t10 = $[34];
162
168
  }
163
- let t10;
164
- if ($[33] !== T0 || $[34] !== props || $[35] !== t4 || $[36] !== t5 || $[37] !== t6 || $[38] !== t7 || $[39] !== t8 || $[40] !== t9) {
165
- t10 = <T0 variant={t4} size={t5} accessibilityLabel={t6} hitSlop={t7} className={t8} {...props}>{t9}</T0>;
166
- $[33] = T0;
167
- $[34] = props;
168
- $[35] = t4;
169
- $[36] = t5;
170
- $[37] = t6;
171
- $[38] = t7;
172
- $[39] = t8;
173
- $[40] = t9;
174
- $[41] = t10;
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
- t10 = $[41];
183
+ t11 = $[44];
177
184
  }
178
- return t10;
179
- }
185
+ return t11;
186
+ });
@@ -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(2);
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] = t0;
84
+ $[1] = ref;
85
+ $[2] = t0;
85
86
  } else {
86
- t0 = $[1];
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/dist/blur.js CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * The ref an expo-blur `BlurView` blurs (its `blurTarget` prop, and the ref a
3
+ * `BlurTargetView` takes). Derived from expo-blur's own type so the two match
4
+ * under any React Native version.
5
+ */
6
+
1
7
  let expoBlur;
2
8
 
3
9
  /**
@@ -12,8 +12,15 @@ import { tokens } from "./tokens";
12
12
 
13
13
  /**
14
14
  * `primary` and `default` are the same (`default` is the web name). `outline`
15
- * is the web bordered neutral button. `tinted` is the pink tint that `outline`
16
- * drew before 0.3.0.
15
+ * is the web bordered neutral button. `tertiary` is the web name for `ghost`
16
+ * and `danger` for `destructive`. `success`, `warning` and `flat` match the web
17
+ * variants. `tinted` is a legacy alias: the pink tint that `outline` drew
18
+ * before 0.3.0 (it keeps its NativeWind classes).
19
+ *
20
+ * Hierarchy: `primary`/`default` is the one main action, `secondary` an
21
+ * alternative, `tertiary`/`ghost` a dismissive action, `destructive`/`danger`
22
+ * a destructive action, `success` and `warning` show status, and `outline`,
23
+ * `link` and `flat` are visual.
17
24
  */
18
25
 
19
26
  /**
@@ -37,17 +44,32 @@ export function buttonColors(variant, scheme) {
37
44
  color: tokens.color.foreground[scheme]
38
45
  };
39
46
  case "destructive":
47
+ case "danger":
40
48
  return {
41
49
  backgroundColor: palette.destructive,
42
50
  borderColor: none,
43
51
  color: tokens.color.white
44
52
  };
45
53
  case "ghost":
54
+ case "tertiary":
55
+ case "flat":
46
56
  return {
47
57
  backgroundColor: none,
48
58
  borderColor: none,
49
59
  color: tokens.color.muted[scheme]
50
60
  };
61
+ case "success":
62
+ return {
63
+ backgroundColor: palette.success[scheme],
64
+ borderColor: none,
65
+ color: palette.successForeground[scheme]
66
+ };
67
+ case "warning":
68
+ return {
69
+ backgroundColor: palette.warning[scheme],
70
+ borderColor: none,
71
+ color: palette.warningForeground[scheme]
72
+ };
51
73
  case "link":
52
74
  return {
53
75
  backgroundColor: none,
@@ -9,6 +9,7 @@ export { SearchInput } from "../SearchInput";
9
9
  export { PasswordInput } from "../PasswordInput";
10
10
  export { Textarea } from "../Textarea";
11
11
  export { Label } from "../Label";
12
+ export { Field, FieldControl, FieldDescription, FieldError, FieldLabel } from "../Field";
12
13
  export { Select } from "../Select";
13
14
  export { Switch } from "../Switch";
14
15
  export { LabeledSwitchRow } from "../LabeledSwitchRow";