@avenue-ticketing/native 0.1.10 → 0.1.12

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.
@@ -1,15 +1,15 @@
1
- import { createContext, useState, useMemo, isValidElement, useContext, useEffect } from 'react';
2
- import { View, Text, Pressable, TextInput, ScrollView } from 'react-native-css/components';
1
+ import { createContext, forwardRef, useContext, useState, useMemo, isValidElement, useEffect } from 'react';
2
+ import { View, TextInput, Pressable, Text, ScrollView } from 'react-native-css/components';
3
3
  import { useNativeVariable } from 'react-native-css';
4
4
  import { MagnifyingGlassIcon } from 'phosphor-react-native/src/icons/MagnifyingGlass';
5
5
  import { XIcon } from 'phosphor-react-native/src/icons/X';
6
6
  import { extendTailwindMerge } from 'tailwind-merge';
7
- import { Image, useWindowDimensions, Modal } from 'react-native';
8
- import 'phosphor-react-native/src/icons/Eye';
9
- import 'phosphor-react-native/src/icons/EyeSlash';
10
- import 'phosphor-react-native/src/icons/Info';
11
- import 'phosphor-react-native/src/icons/Question';
12
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
7
+ import { Platform, Image, useWindowDimensions, Modal } from 'react-native';
8
+ import { EyeIcon } from 'phosphor-react-native/src/icons/Eye';
9
+ import { EyeSlashIcon } from 'phosphor-react-native/src/icons/EyeSlash';
10
+ import { InfoIcon } from 'phosphor-react-native/src/icons/Info';
11
+ import { QuestionIcon } from 'phosphor-react-native/src/icons/Question';
12
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
13
13
  import { styled } from 'nativewind';
14
14
  import { UserIcon } from 'phosphor-react-native/src/icons/User';
15
15
  import Svg, { Path } from 'react-native-svg';
@@ -87,8 +87,62 @@ var inputStyles = sortCx({
87
87
  }
88
88
  }
89
89
  });
90
- createContext(null);
91
- createContext(null);
90
+ var inputGroupStyles = sortCx({
91
+ /** Single outer shell — select/button addons only (Figma 85:1269). */
92
+ shell: "w-full flex-row items-stretch overflow-hidden rounded-lg border border-solid border-primary bg-primary shadow-xs",
93
+ shellFocus: inputFocusRingShadow,
94
+ shellInvalid: "border-error_subtle",
95
+ shellInvalidFocus: inputErrorFocusRingShadow,
96
+ shellDisabled: "opacity-50",
97
+ row: "w-full min-h-0 flex-row items-stretch",
98
+ /** Leading select/button segment — compact, flush (no divider). */
99
+ addonLeading: "shrink-0 flex-row items-stretch self-stretch",
100
+ /** Trailing button segment — left divider; trailing select stays flush. */
101
+ addonTrailing: "shrink-0 flex-row items-stretch self-stretch",
102
+ addonTrailingDivider: "border-l border-solid border-primary",
103
+ prefixInline: "shrink-0 flex-row items-center self-stretch text-tertiary",
104
+ fieldSlot: "min-w-0 flex-1 flex-row items-stretch",
105
+ sizes: {
106
+ sm: {
107
+ shellMinH: "min-h-9",
108
+ prefixInline: "pl-3 pr-1.5 text-sm",
109
+ /** Input padding when leading select is present. */
110
+ inputLeadingSelect: "pl-2 pr-3 py-2 text-sm",
111
+ /** Input padding when trailing select + optional $ prefix. */
112
+ inputTrailingSelect: "pl-0 pr-2 py-2 text-sm",
113
+ inputTrailingSelectNoPrefix: "pl-3 pr-2 py-2 text-sm",
114
+ inputTrailingButton: "pl-3 pr-3 py-2 text-sm"
115
+ },
116
+ md: {
117
+ shellMinH: "min-h-10",
118
+ prefixInline: "pl-3 pr-2 text-md",
119
+ inputLeadingSelect: "pl-2.5 pr-3 py-2 text-md",
120
+ inputTrailingSelect: "pl-0 pr-2 py-2 text-md",
121
+ inputTrailingSelectNoPrefix: "pl-3 pr-2 py-2 text-md",
122
+ inputTrailingButton: "pl-3 pr-3 py-2 text-md"
123
+ },
124
+ lg: {
125
+ shellMinH: "min-h-11",
126
+ prefixInline: "pl-3.5 pr-2 text-md",
127
+ inputLeadingSelect: "pl-3 pr-3.5 py-2.5 text-md",
128
+ inputTrailingSelect: "pl-0 pr-2 py-2.5 text-md",
129
+ inputTrailingSelectNoPrefix: "pl-3.5 pr-2 py-2.5 text-md",
130
+ inputTrailingButton: "pl-3.5 pr-3.5 py-2.5 text-md"
131
+ }
132
+ }
133
+ });
134
+ var InputGroupContext = createContext(null);
135
+ var useInputGroupContext = () => useContext(InputGroupContext);
136
+ var ShellFocusContext = createContext(null);
137
+ var useShellFocus = () => useContext(ShellFocusContext);
138
+ var androidInputPad = (size, leading, trailing) => {
139
+ if (Platform.OS !== "android") return void 0;
140
+ const x = size === "lg" ? 14 : 12;
141
+ return {
142
+ paddingStart: leading ? size === "sm" ? 36 : size === "lg" ? 42 : 40 : x,
143
+ paddingEnd: trailing ? size === "lg" ? 38 : 36 : x
144
+ };
145
+ };
92
146
  var Label = ({ children, isRequired, isInvalid, className }) => {
93
147
  return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.labelRow, className), children: [
94
148
  /* @__PURE__ */ jsx(Text, { className: inputStyles.label, children }),
@@ -113,6 +167,143 @@ var HintText = ({ children, isInvalid, size, className }) => {
113
167
  }
114
168
  );
115
169
  };
170
+ var InputBase = forwardRef(function InputBase2({
171
+ size: sizeProp = "md",
172
+ type = "text",
173
+ placeholder,
174
+ value,
175
+ defaultValue,
176
+ isDisabled: isDisabledProp = false,
177
+ isInvalid: isInvalidProp = false,
178
+ tooltip,
179
+ icon: Icon,
180
+ autoCapitalize,
181
+ keyboardType,
182
+ textContentType: textContentTypeProp,
183
+ autoComplete: autoCompleteProp,
184
+ autoCorrect: autoCorrectProp,
185
+ autoFocus,
186
+ returnKeyType,
187
+ editable,
188
+ className,
189
+ inputClassName,
190
+ wrapperClassName,
191
+ iconClassName,
192
+ onChangeText,
193
+ onFocus,
194
+ onBlur,
195
+ onPress,
196
+ onSubmitEditing
197
+ }, ref) {
198
+ const group = useInputGroupContext();
199
+ const setShellFocus = useShellFocus();
200
+ const size = group?.size ?? sizeProp;
201
+ const isDisabled = Boolean(group?.isDisabled || isDisabledProp);
202
+ const isInvalid = Boolean(group?.isInvalid || isInvalidProp);
203
+ const shellOwnsChrome = Boolean(group?.shellOwnsChrome);
204
+ const joinLeadingPrefix = Boolean(group?.joinLeadingPrefix);
205
+ const groupPad = group ? inputGroupStyles.sizes[size] : null;
206
+ const groupInputPad = groupPad && group?.hasLeadingSelect ? groupPad.inputLeadingSelect : groupPad && group?.hasTrailingSelect ? group?.hasPrefix ? groupPad.inputTrailingSelect : groupPad.inputTrailingSelectNoPrefix : groupPad && group?.hasTrailingButton ? groupPad.inputTrailingButton : null;
207
+ const [isFocused, setIsFocused] = useState(false);
208
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
209
+ const isPassword = type === "password";
210
+ const hasLeadingIcon = Boolean(Icon);
211
+ const hasTrailingIcon = Boolean(tooltip) || isInvalid || isPassword;
212
+ const sizeStyles = inputStyles.sizes[size];
213
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
214
+ const fgErrorSecondary = useNativeVariable("--color-fg-error-secondary") ?? "#f04438";
215
+ const handleFocus = () => {
216
+ setIsFocused(true);
217
+ setShellFocus?.(true);
218
+ onFocus?.();
219
+ };
220
+ const handleBlur = () => {
221
+ setIsFocused(false);
222
+ setShellFocus?.(false);
223
+ onBlur?.();
224
+ };
225
+ const field = /* @__PURE__ */ jsxs(
226
+ View,
227
+ {
228
+ className: cx(
229
+ shellOwnsChrome ? "relative isolate min-w-0 flex-1 flex-row items-center self-stretch bg-transparent" : cx(inputStyles.field.root, sizeStyles.field),
230
+ joinLeadingPrefix && !shellOwnsChrome && "rounded-l-none",
231
+ !shellOwnsChrome && isFocused && !isInvalid && inputStyles.field.focus,
232
+ !shellOwnsChrome && isInvalid && inputStyles.field.invalid,
233
+ !shellOwnsChrome && isInvalid && isFocused && inputStyles.field.invalidFocus,
234
+ !shellOwnsChrome && isDisabled && inputStyles.field.disabled,
235
+ wrapperClassName,
236
+ className
237
+ ),
238
+ children: [
239
+ Icon && /* @__PURE__ */ jsx(
240
+ View,
241
+ {
242
+ pointerEvents: "none",
243
+ className: cx(inputStyles.iconLeading, iconClassName ?? sizeStyles.iconLeading),
244
+ children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx, color: fgQuaternary })
245
+ }
246
+ ),
247
+ /* @__PURE__ */ jsx(
248
+ TextInput,
249
+ {
250
+ ref,
251
+ accessibilityLabel: placeholder,
252
+ editable: editable ?? !isDisabled,
253
+ placeholder,
254
+ value,
255
+ defaultValue,
256
+ secureTextEntry: isPassword && !isPasswordVisible,
257
+ autoCapitalize: autoCapitalize ?? (type === "email" ? "none" : void 0),
258
+ autoCorrect: autoCorrectProp ?? type !== "email",
259
+ autoFocus,
260
+ returnKeyType,
261
+ keyboardType: keyboardType ?? (type === "email" ? "email-address" : "default"),
262
+ textContentType: textContentTypeProp ?? (isPassword ? "password" : type === "email" ? "emailAddress" : void 0),
263
+ autoComplete: autoCompleteProp ?? (type === "email" ? "email" : isPassword ? "password" : void 0),
264
+ onChangeText,
265
+ onFocus: handleFocus,
266
+ onBlur: handleBlur,
267
+ onSubmitEditing,
268
+ blurOnSubmit: onSubmitEditing ? false : void 0,
269
+ style: {
270
+ includeFontPadding: false,
271
+ paddingVertical: 0,
272
+ ...androidInputPad(size, hasLeadingIcon, hasTrailingIcon)
273
+ },
274
+ className: cx(
275
+ inputStyles.input,
276
+ groupInputPad ?? sizeStyles.input,
277
+ !groupInputPad && hasLeadingIcon && sizeStyles.inputLeading,
278
+ !groupInputPad && hasTrailingIcon && sizeStyles.inputTrailing,
279
+ // Tooltip / invalid icon still need trailing room inside a group shell.
280
+ groupInputPad && hasTrailingIcon && "pr-9",
281
+ inputClassName
282
+ )
283
+ }
284
+ ),
285
+ isPassword && /* @__PURE__ */ jsx(
286
+ Pressable,
287
+ {
288
+ accessibilityRole: "button",
289
+ accessibilityLabel: "Toggle password visibility",
290
+ disabled: isDisabled,
291
+ onPress: () => setIsPasswordVisible((visible) => !visible),
292
+ className: cx(inputStyles.iconTrailing, sizeStyles.iconTrailing),
293
+ children: isPasswordVisible ? /* @__PURE__ */ jsx(EyeSlashIcon, { size: sizeStyles.iconPx, weight: "bold", color: fgQuaternary }) : /* @__PURE__ */ jsx(EyeIcon, { size: sizeStyles.iconPx, weight: "bold", color: fgQuaternary })
294
+ }
295
+ ),
296
+ !isPassword && isInvalid && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: cx(inputStyles.iconInvalid, sizeStyles.iconTrailing), children: /* @__PURE__ */ jsx(InfoIcon, { size: 16, weight: "bold", color: fgErrorSecondary }) }),
297
+ !isPassword && tooltip && !isInvalid && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: cx(inputStyles.iconTrailing, sizeStyles.iconTrailing), children: /* @__PURE__ */ jsx(QuestionIcon, { size: 16, weight: "bold", color: fgQuaternary }) })
298
+ ]
299
+ }
300
+ );
301
+ if (onPress) {
302
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", disabled: isDisabled, onPress, className: "min-w-0 flex-1", children: field });
303
+ }
304
+ return field;
305
+ });
306
+ InputBase.displayName = "InputBase";
116
307
 
117
308
  // ../core/src/avatar.ts
118
309
  var avatarStyles = sortCx({