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