@avenue-ticketing/native 0.1.11 → 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,18 +1,18 @@
1
- import { createContext, useContext, useState, useCallback, useEffect } from 'react';
2
- import { StyleSheet, useColorScheme, Platform, Modal, View, Pressable as Pressable$1 } from 'react-native';
1
+ import { createContext, forwardRef, useContext, useState, useCallback, useEffect } from 'react';
2
+ import { StyleSheet, Platform, useColorScheme, Modal, View as View$1, Pressable as Pressable$1 } from 'react-native';
3
3
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
4
- import { Pressable, Text, View as View$1 } from 'react-native-css/components';
4
+ import { View, TextInput, Pressable, Text } from 'react-native-css/components';
5
5
  import { useNativeVariable } from 'react-native-css';
6
6
  import Animated, { Easing, FadeIn, FadeOut, FadeInDown, FadeOutDown } from 'react-native-reanimated';
7
7
  import { Picker } from '@react-native-picker/picker';
8
8
  import { CaretDownIcon } from 'phosphor-react-native/src/icons/CaretDown';
9
9
  import { CheckIcon } from 'phosphor-react-native/src/icons/Check';
10
10
  import { extendTailwindMerge } from 'tailwind-merge';
11
- import 'phosphor-react-native/src/icons/Eye';
12
- import 'phosphor-react-native/src/icons/EyeSlash';
13
- import 'phosphor-react-native/src/icons/Info';
14
- import 'phosphor-react-native/src/icons/Question';
15
- import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
11
+ import { EyeIcon } from 'phosphor-react-native/src/icons/Eye';
12
+ import { EyeSlashIcon } from 'phosphor-react-native/src/icons/EyeSlash';
13
+ import { InfoIcon } from 'phosphor-react-native/src/icons/Info';
14
+ import { QuestionIcon } from 'phosphor-react-native/src/icons/Question';
15
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
16
16
 
17
17
  // ../../native/components/base/input/select-native.tsx
18
18
  var twMerge = extendTailwindMerge({
@@ -26,6 +26,108 @@ var cx = twMerge;
26
26
  function sortCx(classes) {
27
27
  return classes;
28
28
  }
29
+
30
+ // ../core/src/input.ts
31
+ var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
32
+ var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
33
+ var inputStyles = sortCx({
34
+ stack: "w-full flex-col items-start justify-start gap-1.5",
35
+ labelRow: "flex-row items-center gap-0.5",
36
+ label: "text-sm font-medium text-secondary",
37
+ required: "text-brand-tertiary",
38
+ requiredInvalid: "text-error-primary",
39
+ hint: "text-sm text-tertiary",
40
+ hintSm: "text-xs",
41
+ hintInvalid: "text-error-primary",
42
+ field: {
43
+ root: "relative isolate w-full flex-row items-center rounded-lg border border-solid border-primary bg-primary shadow-xs",
44
+ /** Web: focus-within:border-brand + inset ring-1 ring-brand (2px visual, no layout shift). */
45
+ focus: inputFocusRingShadow,
46
+ invalid: "border-error_subtle",
47
+ invalidFocus: inputErrorFocusRingShadow,
48
+ disabled: "opacity-50"
49
+ },
50
+ input: "m-0 min-w-0 flex-1 bg-transparent text-primary placeholder:text-placeholder",
51
+ iconLeading: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
52
+ iconTrailing: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
53
+ iconInvalid: "absolute inset-y-0 items-center justify-center text-fg-error-secondary",
54
+ sizes: {
55
+ sm: {
56
+ field: "min-h-9",
57
+ input: "px-3 py-2 text-sm",
58
+ inputLeading: "pl-9",
59
+ inputTrailing: "pr-9",
60
+ iconLeading: "left-3 w-4",
61
+ iconTrailing: "right-3 w-4",
62
+ iconPx: 16,
63
+ shortcut: "pr-1.5"
64
+ },
65
+ md: {
66
+ field: "min-h-10",
67
+ input: "px-3 py-2 text-md",
68
+ inputLeading: "pl-10",
69
+ inputTrailing: "pr-9",
70
+ iconLeading: "left-3 w-5",
71
+ iconTrailing: "right-3 w-4",
72
+ iconPx: 20,
73
+ shortcut: "pr-2"
74
+ },
75
+ lg: {
76
+ field: "min-h-11",
77
+ input: "px-3.5 py-2.5 text-md",
78
+ inputLeading: "pl-10.5",
79
+ inputTrailing: "pr-9.5",
80
+ iconLeading: "left-3.5 w-5",
81
+ iconTrailing: "right-3.5 w-4",
82
+ iconPx: 20,
83
+ shortcut: "pr-2.5"
84
+ }
85
+ }
86
+ });
87
+ var inputGroupStyles = sortCx({
88
+ /** Single outer shell — select/button addons only (Figma 85:1269). */
89
+ shell: "w-full flex-row items-stretch overflow-hidden rounded-lg border border-solid border-primary bg-primary shadow-xs",
90
+ shellFocus: inputFocusRingShadow,
91
+ shellInvalid: "border-error_subtle",
92
+ shellInvalidFocus: inputErrorFocusRingShadow,
93
+ shellDisabled: "opacity-50",
94
+ row: "w-full min-h-0 flex-row items-stretch",
95
+ /** Leading select/button segment — compact, flush (no divider). */
96
+ addonLeading: "shrink-0 flex-row items-stretch self-stretch",
97
+ /** Trailing button segment — left divider; trailing select stays flush. */
98
+ addonTrailing: "shrink-0 flex-row items-stretch self-stretch",
99
+ addonTrailingDivider: "border-l border-solid border-primary",
100
+ prefixInline: "shrink-0 flex-row items-center self-stretch text-tertiary",
101
+ fieldSlot: "min-w-0 flex-1 flex-row items-stretch",
102
+ sizes: {
103
+ sm: {
104
+ shellMinH: "min-h-9",
105
+ prefixInline: "pl-3 pr-1.5 text-sm",
106
+ /** Input padding when leading select is present. */
107
+ inputLeadingSelect: "pl-2 pr-3 py-2 text-sm",
108
+ /** Input padding when trailing select + optional $ prefix. */
109
+ inputTrailingSelect: "pl-0 pr-2 py-2 text-sm",
110
+ inputTrailingSelectNoPrefix: "pl-3 pr-2 py-2 text-sm",
111
+ inputTrailingButton: "pl-3 pr-3 py-2 text-sm"
112
+ },
113
+ md: {
114
+ shellMinH: "min-h-10",
115
+ prefixInline: "pl-3 pr-2 text-md",
116
+ inputLeadingSelect: "pl-2.5 pr-3 py-2 text-md",
117
+ inputTrailingSelect: "pl-0 pr-2 py-2 text-md",
118
+ inputTrailingSelectNoPrefix: "pl-3 pr-2 py-2 text-md",
119
+ inputTrailingButton: "pl-3 pr-3 py-2 text-md"
120
+ },
121
+ lg: {
122
+ shellMinH: "min-h-11",
123
+ prefixInline: "pl-3.5 pr-2 text-md",
124
+ inputLeadingSelect: "pl-3 pr-3.5 py-2.5 text-md",
125
+ inputTrailingSelect: "pl-0 pr-2 py-2.5 text-md",
126
+ inputTrailingSelectNoPrefix: "pl-3.5 pr-2 py-2.5 text-md",
127
+ inputTrailingButton: "pl-3.5 pr-3.5 py-2.5 text-md"
128
+ }
129
+ }
130
+ });
29
131
  var nativeSelectStyles = sortCx({
30
132
  root: "relative flex-row items-center rounded-lg border border-solid border-primary bg-primary shadow-xs",
31
133
  /** Flex row + gap — avoid absolute chevron (unreliable height on RN). */
@@ -60,6 +162,151 @@ var InputGroupContext = createContext(null);
60
162
  var useInputGroupContext = () => useContext(InputGroupContext);
61
163
  var ShellFocusContext = createContext(null);
62
164
  var useShellFocus = () => useContext(ShellFocusContext);
165
+ var androidInputPad = (size, leading, trailing) => {
166
+ if (Platform.OS !== "android") return void 0;
167
+ const x = size === "lg" ? 14 : 12;
168
+ return {
169
+ paddingStart: leading ? size === "sm" ? 36 : size === "lg" ? 42 : 40 : x,
170
+ paddingEnd: trailing ? size === "lg" ? 38 : 36 : x
171
+ };
172
+ };
173
+ var InputBase = forwardRef(function InputBase2({
174
+ size: sizeProp = "md",
175
+ type = "text",
176
+ placeholder,
177
+ value,
178
+ defaultValue,
179
+ isDisabled: isDisabledProp = false,
180
+ isInvalid: isInvalidProp = false,
181
+ tooltip,
182
+ icon: Icon,
183
+ autoCapitalize,
184
+ keyboardType,
185
+ textContentType: textContentTypeProp,
186
+ autoComplete: autoCompleteProp,
187
+ autoCorrect: autoCorrectProp,
188
+ autoFocus,
189
+ returnKeyType,
190
+ editable,
191
+ className,
192
+ inputClassName,
193
+ wrapperClassName,
194
+ iconClassName,
195
+ onChangeText,
196
+ onFocus,
197
+ onBlur,
198
+ onPress,
199
+ onSubmitEditing
200
+ }, ref) {
201
+ const group = useInputGroupContext();
202
+ const setShellFocus = useShellFocus();
203
+ const size = group?.size ?? sizeProp;
204
+ const isDisabled = Boolean(group?.isDisabled || isDisabledProp);
205
+ const isInvalid = Boolean(group?.isInvalid || isInvalidProp);
206
+ const shellOwnsChrome = Boolean(group?.shellOwnsChrome);
207
+ const joinLeadingPrefix = Boolean(group?.joinLeadingPrefix);
208
+ const groupPad = group ? inputGroupStyles.sizes[size] : null;
209
+ const groupInputPad = groupPad && group?.hasLeadingSelect ? groupPad.inputLeadingSelect : groupPad && group?.hasTrailingSelect ? group?.hasPrefix ? groupPad.inputTrailingSelect : groupPad.inputTrailingSelectNoPrefix : groupPad && group?.hasTrailingButton ? groupPad.inputTrailingButton : null;
210
+ const [isFocused, setIsFocused] = useState(false);
211
+ const [isPasswordVisible, setIsPasswordVisible] = useState(false);
212
+ const isPassword = type === "password";
213
+ const hasLeadingIcon = Boolean(Icon);
214
+ const hasTrailingIcon = Boolean(tooltip) || isInvalid || isPassword;
215
+ const sizeStyles = inputStyles.sizes[size];
216
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
217
+ const fgErrorSecondary = useNativeVariable("--color-fg-error-secondary") ?? "#f04438";
218
+ const handleFocus = () => {
219
+ setIsFocused(true);
220
+ setShellFocus?.(true);
221
+ onFocus?.();
222
+ };
223
+ const handleBlur = () => {
224
+ setIsFocused(false);
225
+ setShellFocus?.(false);
226
+ onBlur?.();
227
+ };
228
+ const field = /* @__PURE__ */ jsxs(
229
+ View,
230
+ {
231
+ className: cx(
232
+ shellOwnsChrome ? "relative isolate min-w-0 flex-1 flex-row items-center self-stretch bg-transparent" : cx(inputStyles.field.root, sizeStyles.field),
233
+ joinLeadingPrefix && !shellOwnsChrome && "rounded-l-none",
234
+ !shellOwnsChrome && isFocused && !isInvalid && inputStyles.field.focus,
235
+ !shellOwnsChrome && isInvalid && inputStyles.field.invalid,
236
+ !shellOwnsChrome && isInvalid && isFocused && inputStyles.field.invalidFocus,
237
+ !shellOwnsChrome && isDisabled && inputStyles.field.disabled,
238
+ wrapperClassName,
239
+ className
240
+ ),
241
+ children: [
242
+ Icon && /* @__PURE__ */ jsx(
243
+ View,
244
+ {
245
+ pointerEvents: "none",
246
+ className: cx(inputStyles.iconLeading, iconClassName ?? sizeStyles.iconLeading),
247
+ children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx, color: fgQuaternary })
248
+ }
249
+ ),
250
+ /* @__PURE__ */ jsx(
251
+ TextInput,
252
+ {
253
+ ref,
254
+ accessibilityLabel: placeholder,
255
+ editable: editable ?? !isDisabled,
256
+ placeholder,
257
+ value,
258
+ defaultValue,
259
+ secureTextEntry: isPassword && !isPasswordVisible,
260
+ autoCapitalize: autoCapitalize ?? (type === "email" ? "none" : void 0),
261
+ autoCorrect: autoCorrectProp ?? type !== "email",
262
+ autoFocus,
263
+ returnKeyType,
264
+ keyboardType: keyboardType ?? (type === "email" ? "email-address" : "default"),
265
+ textContentType: textContentTypeProp ?? (isPassword ? "password" : type === "email" ? "emailAddress" : void 0),
266
+ autoComplete: autoCompleteProp ?? (type === "email" ? "email" : isPassword ? "password" : void 0),
267
+ onChangeText,
268
+ onFocus: handleFocus,
269
+ onBlur: handleBlur,
270
+ onSubmitEditing,
271
+ blurOnSubmit: onSubmitEditing ? false : void 0,
272
+ style: {
273
+ includeFontPadding: false,
274
+ paddingVertical: 0,
275
+ ...androidInputPad(size, hasLeadingIcon, hasTrailingIcon)
276
+ },
277
+ className: cx(
278
+ inputStyles.input,
279
+ groupInputPad ?? sizeStyles.input,
280
+ !groupInputPad && hasLeadingIcon && sizeStyles.inputLeading,
281
+ !groupInputPad && hasTrailingIcon && sizeStyles.inputTrailing,
282
+ // Tooltip / invalid icon still need trailing room inside a group shell.
283
+ groupInputPad && hasTrailingIcon && "pr-9",
284
+ inputClassName
285
+ )
286
+ }
287
+ ),
288
+ isPassword && /* @__PURE__ */ jsx(
289
+ Pressable,
290
+ {
291
+ accessibilityRole: "button",
292
+ accessibilityLabel: "Toggle password visibility",
293
+ disabled: isDisabled,
294
+ onPress: () => setIsPasswordVisible((visible) => !visible),
295
+ className: cx(inputStyles.iconTrailing, sizeStyles.iconTrailing),
296
+ children: isPasswordVisible ? /* @__PURE__ */ jsx(EyeSlashIcon, { size: sizeStyles.iconPx, weight: "bold", color: fgQuaternary }) : /* @__PURE__ */ jsx(EyeIcon, { size: sizeStyles.iconPx, weight: "bold", color: fgQuaternary })
297
+ }
298
+ ),
299
+ !isPassword && isInvalid && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: cx(inputStyles.iconInvalid, sizeStyles.iconTrailing), children: /* @__PURE__ */ jsx(InfoIcon, { size: 16, weight: "bold", color: fgErrorSecondary }) }),
300
+ !isPassword && tooltip && !isInvalid && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: cx(inputStyles.iconTrailing, sizeStyles.iconTrailing), children: /* @__PURE__ */ jsx(QuestionIcon, { size: 16, weight: "bold", color: fgQuaternary }) })
301
+ ]
302
+ }
303
+ );
304
+ if (onPress) {
305
+ return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", disabled: isDisabled, onPress, className: "min-w-0 flex-1", children: field });
306
+ }
307
+ return field;
308
+ });
309
+ InputBase.displayName = "InputBase";
63
310
  var IOS_BLUE = "#007AFF";
64
311
  var SELECT_SHEET_MS = 340;
65
312
  var SELECT_SCRIM_MS = 280;
@@ -185,7 +432,7 @@ var NativeSelect = ({
185
432
  animationType: "none",
186
433
  onRequestClose: close,
187
434
  statusBarTranslucent: true,
188
- children: /* @__PURE__ */ jsxs(View, { style: styles.iosRoot, pointerEvents: "box-none", children: [
435
+ children: /* @__PURE__ */ jsxs(View$1, { style: styles.iosRoot, pointerEvents: "box-none", children: [
189
436
  open && /* @__PURE__ */ jsx(
190
437
  Animated.View,
191
438
  {
@@ -216,9 +463,9 @@ var NativeSelect = ({
216
463
  }
217
464
  ],
218
465
  children: [
219
- /* @__PURE__ */ jsxs(View, { style: [styles.iosToolbar, { borderBottomColor: hairline }], children: [
466
+ /* @__PURE__ */ jsxs(View$1, { style: [styles.iosToolbar, { borderBottomColor: hairline }], children: [
220
467
  /* @__PURE__ */ jsx(Pressable$1, { onPress: close, hitSlop: 12, style: styles.iosToolbarBtn, children: /* @__PURE__ */ jsx(Text, { style: styles.iosCancel, children: "Cancel" }) }),
221
- /* @__PURE__ */ jsx(View, { style: styles.iosTitleWrap, children: ariaLabel ? /* @__PURE__ */ jsx(
468
+ /* @__PURE__ */ jsx(View$1, { style: styles.iosTitleWrap, children: ariaLabel ? /* @__PURE__ */ jsx(
222
469
  Text,
223
470
  {
224
471
  style: [styles.iosTitle, { color: secondaryLabel }],
@@ -283,8 +530,8 @@ var NativeSelect = ({
283
530
  style: StyleSheet.absoluteFill
284
531
  }
285
532
  ),
286
- /* @__PURE__ */ jsx(Animated.View, { entering: androidPanelEntering, exiting: androidPanelExiting, children: /* @__PURE__ */ jsx(Pressable$1, { onPress: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(View$1, { className: "mx-6 overflow-hidden rounded-xl bg-primary shadow-xl", children: [
287
- ariaLabel && /* @__PURE__ */ jsx(View$1, { className: "px-4 pb-2 pt-4", children: /* @__PURE__ */ jsx(Text, { className: "text-lg font-semibold text-primary", children: ariaLabel }) }),
533
+ /* @__PURE__ */ jsx(Animated.View, { entering: androidPanelEntering, exiting: androidPanelExiting, children: /* @__PURE__ */ jsx(Pressable$1, { onPress: (e) => e.stopPropagation(), children: /* @__PURE__ */ jsxs(View, { className: "mx-6 overflow-hidden rounded-xl bg-primary shadow-xl", children: [
534
+ ariaLabel && /* @__PURE__ */ jsx(View, { className: "px-4 pb-2 pt-4", children: /* @__PURE__ */ jsx(Text, { className: "text-lg font-semibold text-primary", children: ariaLabel }) }),
288
535
  options.map((opt) => {
289
536
  const isSelected = opt.value === (draft || value);
290
537
  return /* @__PURE__ */ jsxs(
@@ -301,7 +548,7 @@ var NativeSelect = ({
301
548
  opt.disabled && "opacity-50"
302
549
  ),
303
550
  children: [
304
- /* @__PURE__ */ jsx(View$1, { className: "w-6 items-center justify-center", children: isSelected && /* @__PURE__ */ jsx(
551
+ /* @__PURE__ */ jsx(View, { className: "w-6 items-center justify-center", children: isSelected && /* @__PURE__ */ jsx(
305
552
  CheckIcon,
306
553
  {
307
554
  size: 20,
@@ -324,7 +571,7 @@ var NativeSelect = ({
324
571
  opt.value
325
572
  );
326
573
  }),
327
- /* @__PURE__ */ jsx(View$1, { className: "flex-row justify-end border-t border-solid border-secondary px-2 py-2", children: /* @__PURE__ */ jsx(
574
+ /* @__PURE__ */ jsx(View, { className: "flex-row justify-end border-t border-solid border-secondary px-2 py-2", children: /* @__PURE__ */ jsx(
328
575
  Pressable,
329
576
  {
330
577
  accessibilityRole: "button",