@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.
package/dist/input.d.ts CHANGED
@@ -1,7 +1,9 @@
1
+ import * as react from 'react';
1
2
  import { FC, ComponentType, ReactNode } from 'react';
2
- import { TextInputProps } from 'react-native';
3
+ import { TextInputProps, TextInput } from 'react-native';
3
4
  import { I as InputSize, a as InputType } from './select-native-C3ctbnUG.js';
4
5
  export { N as NativeSelect, c as NativeSelectOption, b as NativeSelectProps } from './select-native-C3ctbnUG.js';
6
+ import * as react_jsx_runtime from 'react/jsx-runtime';
5
7
 
6
8
  interface LabelProps {
7
9
  children: ReactNode;
@@ -27,6 +29,7 @@ interface InputBaseProps {
27
29
  icon?: ComponentType<{
28
30
  className?: string;
29
31
  size?: number;
32
+ color?: string;
30
33
  }>;
31
34
  autoCapitalize?: "none" | "sentences" | "words" | "characters";
32
35
  keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "url";
@@ -35,6 +38,8 @@ interface InputBaseProps {
35
38
  /** Android autofill hint. */
36
39
  autoComplete?: TextInputProps["autoComplete"];
37
40
  autoCorrect?: boolean;
41
+ autoFocus?: boolean;
42
+ returnKeyType?: TextInputProps["returnKeyType"];
38
43
  editable?: boolean;
39
44
  className?: string;
40
45
  inputClassName?: string;
@@ -54,7 +59,7 @@ interface InputProps extends InputBaseProps {
54
59
  }
55
60
  declare const Label: FC<LabelProps>;
56
61
  declare const HintText: FC<HintTextProps>;
57
- declare const InputBase: FC<InputBaseProps>;
62
+ declare const InputBase: react.ForwardRefExoticComponent<InputBaseProps & react.RefAttributes<TextInput>>;
58
63
  declare const Input: FC<InputProps>;
59
64
 
60
65
  interface InputPrefixProps {
@@ -294,4 +299,50 @@ interface InputTagsOuterProps {
294
299
  }
295
300
  declare const InputTagsOuter: FC<InputTagsOuterProps>;
296
301
 
297
- export { ContactInput, type ContactInputProps, type ContactMode, type ContactValue, EmailInput, type EmailInputProps, HintText, Input, InputBase, type InputBaseProps, InputDate, type InputDateProps, InputFile, type InputFileProps, InputGroup, type InputGroupProps, InputNumber, type InputNumberProps, InputPrefix, type InputPrefixProps, type InputProps, InputSize, InputTags, InputTagsOuter, type InputTagsOuterProps, type InputTagsProps, InputType, Label, PaymentInput, type PaymentInputProps, PhoneInput, type PhoneInputProps, emptyContactValue };
302
+ interface InputClearButtonProps {
303
+ /** Accessible label for the clear control. */
304
+ label: string;
305
+ onClear: () => void;
306
+ className?: string;
307
+ size?: number;
308
+ }
309
+ /** Clear control for search / filter fields (X-in-circle). */
310
+ declare const InputClearButton: {
311
+ ({ label, onClear, className, size }: InputClearButtonProps): react_jsx_runtime.JSX.Element;
312
+ displayName: string;
313
+ };
314
+ interface SearchInputProps extends Omit<InputBaseProps, "type" | "icon" | "className"> {
315
+ /** Leading icon. Defaults to magnifying glass. */
316
+ icon?: ComponentType<{
317
+ className?: string;
318
+ size?: number;
319
+ color?: string;
320
+ }>;
321
+ label?: string;
322
+ hint?: ReactNode;
323
+ isRequired?: boolean;
324
+ hideRequiredIndicator?: boolean;
325
+ /** Accessible label for the clear button. */
326
+ clearLabel: string;
327
+ /**
328
+ * Called when the clear button is pressed. Defaults to `onChangeText("")`.
329
+ */
330
+ onClear?: () => void;
331
+ /**
332
+ * Show the clear button when `value` is non-empty.
333
+ * @default true
334
+ */
335
+ isClearable?: boolean;
336
+ /** Outer stack class (label + field + hint). */
337
+ className?: string;
338
+ /** Class name for the input field group (radius, border chrome). */
339
+ fieldClassName?: string;
340
+ size?: InputSize;
341
+ }
342
+ /**
343
+ * Search field: leading magnifying glass + clear button when filled.
344
+ * Matches the mobile discover / organizer sheet search chrome.
345
+ */
346
+ declare const SearchInput: react.ForwardRefExoticComponent<SearchInputProps & react.RefAttributes<TextInput>>;
347
+
348
+ export { ContactInput, type ContactInputProps, type ContactMode, type ContactValue, EmailInput, type EmailInputProps, HintText, Input, InputBase, type InputBaseProps, InputClearButton, type InputClearButtonProps, InputDate, type InputDateProps, InputFile, type InputFileProps, InputGroup, type InputGroupProps, InputNumber, type InputNumberProps, InputPrefix, type InputPrefixProps, type InputProps, InputSize, InputTags, InputTagsOuter, type InputTagsOuterProps, type InputTagsProps, InputType, Label, PaymentInput, type PaymentInputProps, PhoneInput, type PhoneInputProps, SearchInput, type SearchInputProps, emptyContactValue };
package/dist/input.js CHANGED
@@ -1,7 +1,7 @@
1
- import { createContext, useContext, useState, useCallback, useEffect, useMemo, useRef, isValidElement } from 'react';
2
- import { StyleSheet, useColorScheme, Platform, Modal, View as View$1, Pressable as Pressable$1, StatusBar, Linking } from 'react-native';
1
+ import { createContext, forwardRef, useContext, useState, useRef, useCallback, useEffect, useMemo, isValidElement } from 'react';
2
+ import { StyleSheet, Platform, useColorScheme, Modal, View as View$1, Pressable as Pressable$1, StatusBar, Linking } from 'react-native';
3
3
  import { useNativeVariable } from 'react-native-css';
4
- import { View, Text, TextInput, Pressable, FlatList } from 'react-native-css/components';
4
+ import { View, TextInput, Pressable, Text, FlatList } from 'react-native-css/components';
5
5
  import { EyeIcon } from 'phosphor-react-native/src/icons/Eye';
6
6
  import { EyeSlashIcon } from 'phosphor-react-native/src/icons/EyeSlash';
7
7
  import { InfoIcon } from 'phosphor-react-native/src/icons/Info';
@@ -24,6 +24,7 @@ import { CalendarBlankIcon } from 'phosphor-react-native/src/icons/CalendarBlank
24
24
  import { CaretUpIcon } from 'phosphor-react-native/src/icons/CaretUp';
25
25
  import { MinusIcon } from 'phosphor-react-native/src/icons/Minus';
26
26
  import { PlusIcon } from 'phosphor-react-native/src/icons/Plus';
27
+ import { XCircleIcon } from 'phosphor-react-native/src/icons/XCircle';
27
28
 
28
29
  // ../../native/components/base/input/input.tsx
29
30
  var twMerge = extendTailwindMerge({
@@ -342,7 +343,7 @@ var HintText = ({ children, isInvalid, size, className }) => {
342
343
  }
343
344
  );
344
345
  };
345
- var InputBase = ({
346
+ var InputBase = forwardRef(function InputBase2({
346
347
  size: sizeProp = "md",
347
348
  type = "text",
348
349
  placeholder,
@@ -357,6 +358,8 @@ var InputBase = ({
357
358
  textContentType: textContentTypeProp,
358
359
  autoComplete: autoCompleteProp,
359
360
  autoCorrect: autoCorrectProp,
361
+ autoFocus,
362
+ returnKeyType,
360
363
  editable,
361
364
  className,
362
365
  inputClassName,
@@ -367,7 +370,7 @@ var InputBase = ({
367
370
  onBlur,
368
371
  onPress,
369
372
  onSubmitEditing
370
- }) => {
373
+ }, ref) {
371
374
  const group = useInputGroupContext();
372
375
  const setShellFocus = useShellFocus();
373
376
  const size = group?.size ?? sizeProp;
@@ -414,12 +417,13 @@ var InputBase = ({
414
417
  {
415
418
  pointerEvents: "none",
416
419
  className: cx(inputStyles.iconLeading, iconClassName ?? sizeStyles.iconLeading),
417
- children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx })
420
+ children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx, color: fgQuaternary })
418
421
  }
419
422
  ),
420
423
  /* @__PURE__ */ jsx(
421
424
  TextInput,
422
425
  {
426
+ ref,
423
427
  accessibilityLabel: placeholder,
424
428
  editable: editable ?? !isDisabled,
425
429
  placeholder,
@@ -428,6 +432,8 @@ var InputBase = ({
428
432
  secureTextEntry: isPassword && !isPasswordVisible,
429
433
  autoCapitalize: autoCapitalize ?? (type === "email" ? "none" : void 0),
430
434
  autoCorrect: autoCorrectProp ?? type !== "email",
435
+ autoFocus,
436
+ returnKeyType,
431
437
  keyboardType: keyboardType ?? (type === "email" ? "email-address" : "default"),
432
438
  textContentType: textContentTypeProp ?? (isPassword ? "password" : type === "email" ? "emailAddress" : void 0),
433
439
  autoComplete: autoCompleteProp ?? (type === "email" ? "email" : isPassword ? "password" : void 0),
@@ -472,7 +478,7 @@ var InputBase = ({
472
478
  return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", disabled: isDisabled, onPress, className: "min-w-0 flex-1", children: field });
473
479
  }
474
480
  return field;
475
- };
481
+ });
476
482
  var Input = ({
477
483
  label,
478
484
  hint,
@@ -5868,135 +5874,35 @@ function resolveDetectedCountry(parsed) {
5868
5874
  if (mainCountry) return mainCountry;
5869
5875
  return void 0;
5870
5876
  }
5871
- function getLocalePhoneCountry() {
5872
- if (typeof navigator === "undefined") return void 0;
5873
- try {
5874
- const region = navigator.language.split("-").pop()?.toUpperCase();
5875
- if (region?.length === 2 && getCountryData().byIso.has(region)) return region;
5876
- } catch {
5877
- }
5878
- return void 0;
5879
- }
5880
- function getCountryDetectionCandidates(currentCountry) {
5881
- const ordered = [];
5882
- const seen = /* @__PURE__ */ new Set();
5883
- const add = (iso) => {
5884
- if (!iso || seen.has(iso)) return;
5885
- if (!getCountryData().byIso.has(iso)) return;
5886
- seen.add(iso);
5887
- ordered.push(iso);
5888
- };
5889
- add(getLocalePhoneCountry());
5890
- for (const iso of POPULAR_ISO) add(iso);
5891
- add(currentCountry);
5892
- for (const iso of getCountries2()) add(iso);
5893
- return ordered;
5894
- }
5895
- function isValidNationalNumber(digits, country) {
5896
- if (!digits.length) return false;
5897
- const parsed = parsePhoneNumber4(digits, country);
5898
- return parsed?.isValid() ?? false;
5899
- }
5900
- function parseScore(parsed) {
5901
- const type = parsed.getType();
5902
- if (type === "MOBILE") return 30;
5903
- if (type === "FIXED_LINE_OR_MOBILE") return 20;
5904
- if (type === "FIXED_LINE") return 10;
5905
- if (type === "TOLL_FREE" || type === "PREMIUM_RATE") return 5;
5906
- return 0;
5907
- }
5908
- function parseScoreWithContext(digits, parsed, iso, currentCountry) {
5909
- let score = parseScore(parsed);
5910
- if (iso === currentCountry) {
5911
- score += 15;
5912
- }
5913
- if (parsed.nationalNumber === digits && digits.length <= 10) {
5914
- score += 35;
5915
- }
5916
- if ((iso === "US" || iso === "CA") && digits.length === 10 && /^[2-9]\d{9}$/.test(digits)) {
5917
- score += 40;
5918
- }
5919
- if (iso === "IN" && digits.length === 10 && /^[6-9]\d{9}$/.test(digits)) {
5920
- score += 40;
5921
- }
5922
- return score;
5923
- }
5924
- function intlDigitMatchBonus(digits, parsed) {
5925
- if (`${parsed.countryCallingCode}${parsed.nationalNumber}` === digits) {
5926
- return 50;
5927
- }
5928
- return 0;
5929
- }
5930
5877
  function partsFromParsed(parsed) {
5931
5878
  const country = resolveDetectedCountry(parsed);
5932
5879
  if (!country) return null;
5933
5880
  return { digits: parsed.nationalNumber, country };
5934
5881
  }
5935
- function pickBestPhoneDetection(digits, currentCountry) {
5936
- const candidates = [];
5937
- let order = 0;
5938
- const consider = (parsed) => {
5939
- const iso = resolveDetectedCountry(parsed);
5940
- if (!iso) return;
5882
+ function detectPhoneCountryFromPlus(trimmed) {
5883
+ if (!trimmed.startsWith("+")) return null;
5884
+ const parsed = parsePhoneNumber4(trimmed);
5885
+ if (parsed?.isValid()) {
5941
5886
  const parts = partsFromParsed(parsed);
5942
- if (!parts) return;
5943
- const score = parseScoreWithContext(digits, parsed, iso, currentCountry) + intlDigitMatchBonus(digits, parsed);
5944
- candidates.push({ ...parts, score, order });
5945
- order += 1;
5946
- };
5947
- const intlParsed = parsePhoneNumber4(`+${digits}`);
5948
- if (intlParsed?.isValid()) {
5949
- consider(intlParsed);
5887
+ if (parts) return parts;
5950
5888
  }
5951
- for (const iso of getCountryDetectionCandidates(currentCountry)) {
5952
- const parsed = parsePhoneNumber4(digits, iso);
5953
- if (parsed?.isValid()) {
5954
- consider(parsed);
5955
- }
5956
- }
5957
- if (!candidates.length) return null;
5958
- const best = candidates.reduce((top, candidate) => {
5959
- if (candidate.score > top.score) return candidate;
5960
- if (candidate.score === top.score && candidate.order < top.order) return candidate;
5961
- return top;
5962
- });
5963
- return { digits: best.digits, country: best.country };
5964
- }
5965
- function detectPhoneCountryFromRaw(trimmed, digits, currentCountry) {
5966
- if (!digits.length) return null;
5967
- if (trimmed.startsWith("+")) {
5968
- const parsed = parsePhoneNumber4(trimmed);
5969
- if (parsed?.isValid()) {
5970
- const parts = partsFromParsed(parsed);
5971
- if (parts) return parts;
5972
- }
5973
- const formatter = new AsYouType2();
5974
- formatter.input(trimmed);
5975
- const detected = formatter.getNumber();
5976
- const country = resolveDetectedCountry(detected);
5977
- if (detected && country) {
5978
- return { digits: detected.nationalNumber, country };
5979
- }
5980
- }
5981
- const best = pickBestPhoneDetection(digits, currentCountry);
5982
- if (best) return best;
5983
- if (isValidNationalNumber(digits, currentCountry)) {
5984
- const parsed = parsePhoneNumber4(digits, currentCountry);
5985
- return partsFromParsed(parsed);
5889
+ const formatter = new AsYouType2();
5890
+ formatter.input(trimmed);
5891
+ const detected = formatter.getNumber();
5892
+ const country = resolveDetectedCountry(detected);
5893
+ if (detected && country) {
5894
+ return { digits: detected.nationalNumber, country };
5986
5895
  }
5987
5896
  return null;
5988
5897
  }
5989
- function processPhoneInput(rawInput, currentCountry, detectCountry = false) {
5898
+ function processPhoneInput(rawInput, currentCountry, _detectCountry = false) {
5990
5899
  const trimmed = rawInput.trim();
5991
5900
  const digits = rawInput.replace(/\D/g, "");
5992
5901
  if (!digits.length) {
5993
5902
  return { digits: "", country: currentCountry };
5994
5903
  }
5995
- const shouldDetectCountry = detectCountry || trimmed.startsWith("+");
5996
- if (shouldDetectCountry) {
5997
- const detected = detectPhoneCountryFromRaw(trimmed, digits, currentCountry);
5998
- if (detected?.country) return detected;
5999
- }
5904
+ const detected = detectPhoneCountryFromPlus(trimmed);
5905
+ if (detected) return detected;
6000
5906
  const formatter = new AsYouType2(currentCountry);
6001
5907
  formatter.input(digits);
6002
5908
  const national = formatter.getNumber();
@@ -7923,7 +7829,99 @@ var InputTagsOuter = ({
7923
7829
  ] });
7924
7830
  };
7925
7831
  InputTagsOuter.displayName = "InputTagsOuter";
7832
+ var InputClearButton = ({ label, onClear, className, size = 20 }) => {
7833
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
7834
+ return /* @__PURE__ */ jsx(
7835
+ Pressable,
7836
+ {
7837
+ accessibilityRole: "button",
7838
+ accessibilityLabel: label,
7839
+ onPress: onClear,
7840
+ className: cx(
7841
+ "flex size-7 shrink-0 items-center justify-center rounded-full active:opacity-80",
7842
+ className
7843
+ ),
7844
+ children: /* @__PURE__ */ jsx(XCircleIcon, { size, weight: "regular", color: fgQuaternary })
7845
+ }
7846
+ );
7847
+ };
7848
+ InputClearButton.displayName = "InputClearButton";
7849
+ var assignRef = (ref, value) => {
7850
+ if (!ref) return;
7851
+ if (typeof ref === "function") {
7852
+ ref(value);
7853
+ return;
7854
+ }
7855
+ ref.current = value;
7856
+ };
7857
+ var SearchInput = forwardRef(function SearchInput2({
7858
+ value,
7859
+ clearLabel,
7860
+ onClear,
7861
+ onChangeText,
7862
+ isClearable = true,
7863
+ icon = MagnifyingGlassIcon,
7864
+ size = "lg",
7865
+ label,
7866
+ hint,
7867
+ isRequired = false,
7868
+ hideRequiredIndicator = false,
7869
+ isInvalid = false,
7870
+ isDisabled = false,
7871
+ className,
7872
+ inputClassName,
7873
+ fieldClassName,
7874
+ wrapperClassName,
7875
+ ...baseProps
7876
+ }, ref) {
7877
+ const inputRef = useRef(null);
7878
+ const showClear = isClearable && typeof value === "string" && value.length > 0;
7879
+ const showRequired = Boolean(label) && isRequired && !hideRequiredIndicator;
7880
+ const handleClear = () => {
7881
+ if (onClear) {
7882
+ onClear();
7883
+ } else {
7884
+ onChangeText?.("");
7885
+ }
7886
+ inputRef.current?.focus();
7887
+ };
7888
+ return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.stack, className), children: [
7889
+ label && /* @__PURE__ */ jsx(Label, { isRequired: showRequired, isInvalid, children: label }),
7890
+ /* @__PURE__ */ jsxs(View, { className: "relative w-full", children: [
7891
+ /* @__PURE__ */ jsx(
7892
+ InputBase,
7893
+ {
7894
+ ...baseProps,
7895
+ ref: (node) => {
7896
+ inputRef.current = node;
7897
+ assignRef(ref, node);
7898
+ },
7899
+ size,
7900
+ icon,
7901
+ value,
7902
+ isInvalid,
7903
+ isDisabled,
7904
+ autoCapitalize: baseProps.autoCapitalize ?? "none",
7905
+ autoCorrect: baseProps.autoCorrect ?? false,
7906
+ onChangeText,
7907
+ wrapperClassName: cx(fieldClassName, wrapperClassName),
7908
+ inputClassName: cx(showClear && "pr-10", inputClassName)
7909
+ }
7910
+ ),
7911
+ showClear && /* @__PURE__ */ jsx(
7912
+ InputClearButton,
7913
+ {
7914
+ label: clearLabel,
7915
+ onClear: handleClear,
7916
+ className: "absolute top-1/2 right-3 z-20 -mt-3.5"
7917
+ }
7918
+ )
7919
+ ] }),
7920
+ hint != null && hint !== false && hint !== "" && /* @__PURE__ */ jsx(HintText, { isInvalid, size, children: hint })
7921
+ ] });
7922
+ });
7923
+ SearchInput.displayName = "SearchInput";
7926
7924
 
7927
- export { ContactInput, EmailInput, HintText, Input, InputBase, InputDate, InputFile, InputGroup, InputNumber, InputPrefix, InputTags, InputTagsOuter, Label, NativeSelect, PaymentInput, PhoneInput, emptyContactValue };
7925
+ export { ContactInput, EmailInput, HintText, Input, InputBase, InputClearButton, InputDate, InputFile, InputGroup, InputNumber, InputPrefix, InputTags, InputTagsOuter, Label, NativeSelect, PaymentInput, PhoneInput, SearchInput, emptyContactValue };
7928
7926
  //# sourceMappingURL=input.js.map
7929
7927
  //# sourceMappingURL=input.js.map