@avenue-ticketing/native 0.1.10 → 0.1.11

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
@@ -27,6 +27,7 @@ interface InputBaseProps {
27
27
  icon?: ComponentType<{
28
28
  className?: string;
29
29
  size?: number;
30
+ color?: string;
30
31
  }>;
31
32
  autoCapitalize?: "none" | "sentences" | "words" | "characters";
32
33
  keyboardType?: "default" | "email-address" | "numeric" | "phone-pad" | "url";
@@ -294,4 +295,47 @@ interface InputTagsOuterProps {
294
295
  }
295
296
  declare const InputTagsOuter: FC<InputTagsOuterProps>;
296
297
 
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 };
298
+ interface InputClearButtonProps {
299
+ /** Accessible label for the clear control. */
300
+ label: string;
301
+ onClear: () => void;
302
+ className?: string;
303
+ size?: number;
304
+ }
305
+ /** Clear control for search / filter fields (X-in-circle). */
306
+ declare const InputClearButton: FC<InputClearButtonProps>;
307
+ interface SearchInputProps extends Omit<InputBaseProps, "type" | "icon" | "className"> {
308
+ /** Leading icon. Defaults to magnifying glass. */
309
+ icon?: ComponentType<{
310
+ className?: string;
311
+ size?: number;
312
+ color?: string;
313
+ }>;
314
+ label?: string;
315
+ hint?: ReactNode;
316
+ isRequired?: boolean;
317
+ hideRequiredIndicator?: boolean;
318
+ /** Accessible label for the clear button. */
319
+ clearLabel: string;
320
+ /**
321
+ * Called when the clear button is pressed. Defaults to `onChangeText("")`.
322
+ */
323
+ onClear?: () => void;
324
+ /**
325
+ * Show the clear button when `value` is non-empty.
326
+ * @default true
327
+ */
328
+ isClearable?: boolean;
329
+ /** Outer stack class (label + field + hint). */
330
+ className?: string;
331
+ /** Class name for the input field group (radius, border chrome). */
332
+ fieldClassName?: string;
333
+ size?: InputSize;
334
+ }
335
+ /**
336
+ * Search field: leading magnifying glass + clear button when filled.
337
+ * Matches the mobile discover / organizer sheet search chrome.
338
+ */
339
+ declare const SearchInput: FC<SearchInputProps>;
340
+
341
+ 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
@@ -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({
@@ -414,7 +415,7 @@ var InputBase = ({
414
415
  {
415
416
  pointerEvents: "none",
416
417
  className: cx(inputStyles.iconLeading, iconClassName ?? sizeStyles.iconLeading),
417
- children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx })
418
+ children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx, color: fgQuaternary })
418
419
  }
419
420
  ),
420
421
  /* @__PURE__ */ jsx(
@@ -5868,135 +5869,35 @@ function resolveDetectedCountry(parsed) {
5868
5869
  if (mainCountry) return mainCountry;
5869
5870
  return void 0;
5870
5871
  }
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
5872
  function partsFromParsed(parsed) {
5931
5873
  const country = resolveDetectedCountry(parsed);
5932
5874
  if (!country) return null;
5933
5875
  return { digits: parsed.nationalNumber, country };
5934
5876
  }
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;
5877
+ function detectPhoneCountryFromPlus(trimmed) {
5878
+ if (!trimmed.startsWith("+")) return null;
5879
+ const parsed = parsePhoneNumber4(trimmed);
5880
+ if (parsed?.isValid()) {
5941
5881
  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);
5950
- }
5951
- for (const iso of getCountryDetectionCandidates(currentCountry)) {
5952
- const parsed = parsePhoneNumber4(digits, iso);
5953
- if (parsed?.isValid()) {
5954
- consider(parsed);
5955
- }
5882
+ if (parts) return parts;
5956
5883
  }
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);
5884
+ const formatter = new AsYouType2();
5885
+ formatter.input(trimmed);
5886
+ const detected = formatter.getNumber();
5887
+ const country = resolveDetectedCountry(detected);
5888
+ if (detected && country) {
5889
+ return { digits: detected.nationalNumber, country };
5986
5890
  }
5987
5891
  return null;
5988
5892
  }
5989
- function processPhoneInput(rawInput, currentCountry, detectCountry = false) {
5893
+ function processPhoneInput(rawInput, currentCountry, _detectCountry = false) {
5990
5894
  const trimmed = rawInput.trim();
5991
5895
  const digits = rawInput.replace(/\D/g, "");
5992
5896
  if (!digits.length) {
5993
5897
  return { digits: "", country: currentCountry };
5994
5898
  }
5995
- const shouldDetectCountry = detectCountry || trimmed.startsWith("+");
5996
- if (shouldDetectCountry) {
5997
- const detected = detectPhoneCountryFromRaw(trimmed, digits, currentCountry);
5998
- if (detected?.country) return detected;
5999
- }
5899
+ const detected = detectPhoneCountryFromPlus(trimmed);
5900
+ if (detected) return detected;
6000
5901
  const formatter = new AsYouType2(currentCountry);
6001
5902
  formatter.input(digits);
6002
5903
  const national = formatter.getNumber();
@@ -7923,7 +7824,85 @@ var InputTagsOuter = ({
7923
7824
  ] });
7924
7825
  };
7925
7826
  InputTagsOuter.displayName = "InputTagsOuter";
7827
+ var InputClearButton = ({ label, onClear, className, size = 20 }) => {
7828
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
7829
+ return /* @__PURE__ */ jsx(
7830
+ Pressable,
7831
+ {
7832
+ accessibilityRole: "button",
7833
+ accessibilityLabel: label,
7834
+ onPress: onClear,
7835
+ className: cx(
7836
+ "flex size-7 shrink-0 items-center justify-center rounded-full active:opacity-80",
7837
+ className
7838
+ ),
7839
+ children: /* @__PURE__ */ jsx(XCircleIcon, { size, weight: "regular", color: fgQuaternary })
7840
+ }
7841
+ );
7842
+ };
7843
+ InputClearButton.displayName = "InputClearButton";
7844
+ var SearchInput = ({
7845
+ value,
7846
+ clearLabel,
7847
+ onClear,
7848
+ onChangeText,
7849
+ isClearable = true,
7850
+ icon = MagnifyingGlassIcon,
7851
+ size = "lg",
7852
+ label,
7853
+ hint,
7854
+ isRequired = false,
7855
+ hideRequiredIndicator = false,
7856
+ isInvalid = false,
7857
+ isDisabled = false,
7858
+ className,
7859
+ inputClassName,
7860
+ fieldClassName,
7861
+ wrapperClassName,
7862
+ ...baseProps
7863
+ }) => {
7864
+ const showClear = isClearable && typeof value === "string" && value.length > 0;
7865
+ const showRequired = Boolean(label) && isRequired && !hideRequiredIndicator;
7866
+ const handleClear = () => {
7867
+ if (onClear) {
7868
+ onClear();
7869
+ } else {
7870
+ onChangeText?.("");
7871
+ }
7872
+ };
7873
+ return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.stack, className), children: [
7874
+ label && /* @__PURE__ */ jsx(Label, { isRequired: showRequired, isInvalid, children: label }),
7875
+ /* @__PURE__ */ jsxs(View, { className: "relative w-full", children: [
7876
+ /* @__PURE__ */ jsx(
7877
+ InputBase,
7878
+ {
7879
+ ...baseProps,
7880
+ size,
7881
+ icon,
7882
+ value,
7883
+ isInvalid,
7884
+ isDisabled,
7885
+ autoCapitalize: baseProps.autoCapitalize ?? "none",
7886
+ autoCorrect: baseProps.autoCorrect ?? false,
7887
+ onChangeText,
7888
+ wrapperClassName: cx(fieldClassName, wrapperClassName),
7889
+ inputClassName: cx(showClear && "pr-10", inputClassName)
7890
+ }
7891
+ ),
7892
+ showClear && /* @__PURE__ */ jsx(
7893
+ InputClearButton,
7894
+ {
7895
+ label: clearLabel,
7896
+ onClear: handleClear,
7897
+ className: "absolute top-1/2 right-3 z-20 -mt-3.5"
7898
+ }
7899
+ )
7900
+ ] }),
7901
+ hint != null && hint !== false && hint !== "" && /* @__PURE__ */ jsx(HintText, { isInvalid, size, children: hint })
7902
+ ] });
7903
+ };
7904
+ SearchInput.displayName = "SearchInput";
7926
7905
 
7927
- export { ContactInput, EmailInput, HintText, Input, InputBase, InputDate, InputFile, InputGroup, InputNumber, InputPrefix, InputTags, InputTagsOuter, Label, NativeSelect, PaymentInput, PhoneInput, emptyContactValue };
7906
+ export { ContactInput, EmailInput, HintText, Input, InputBase, InputClearButton, InputDate, InputFile, InputGroup, InputNumber, InputPrefix, InputTags, InputTagsOuter, Label, NativeSelect, PaymentInput, PhoneInput, SearchInput, emptyContactValue };
7928
7907
  //# sourceMappingURL=input.js.map
7929
7908
  //# sourceMappingURL=input.js.map