@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/combobox.js +200 -9
- package/dist/combobox.js.map +1 -1
- package/dist/input.d.ts +11 -4
- package/dist/input.js +28 -9
- package/dist/input.js.map +1 -1
- package/dist/multi-select.js +200 -9
- package/dist/multi-select.js.map +1 -1
- package/dist/select-native.js +262 -15
- package/dist/select-native.js.map +1 -1
- package/dist/select.js +201 -10
- package/dist/select.js.map +1 -1
- package/dist/tag-select.js +201 -10
- package/dist/tag-select.js.map +1 -1
- package/dist/textarea.js +201 -10
- package/dist/textarea.js.map +1 -1
- package/package.json +1 -1
package/dist/multi-select.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { createContext, useState, useMemo,
|
|
2
|
-
import { View, Pressable, Text,
|
|
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 { CaretDownIcon } from 'phosphor-react-native/src/icons/CaretDown';
|
|
5
5
|
import { MagnifyingGlassIcon } from 'phosphor-react-native/src/icons/MagnifyingGlass';
|
|
6
6
|
import { extendTailwindMerge } from 'tailwind-merge';
|
|
7
|
-
import { useWindowDimensions, Modal, Linking, Image } from 'react-native';
|
|
7
|
+
import { Platform, useWindowDimensions, Modal, Linking, Image } from 'react-native';
|
|
8
8
|
import { IconContext } from 'phosphor-react-native/src/lib';
|
|
9
9
|
import { useInputGroupAddon } from '@avenue-ticketing/native/input-group-addon-context';
|
|
10
10
|
import Animated2, { Easing, FadeIn, FadeOut, FadeInDown, FadeOutDown, useSharedValue, withRepeat, withTiming, useAnimatedStyle, withDelay, useAnimatedProps } from 'react-native-reanimated';
|
|
11
11
|
import Svg, { Path } from 'react-native-svg';
|
|
12
12
|
import { styled } from 'nativewind';
|
|
13
13
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
14
|
-
import 'phosphor-react-native/src/icons/Eye';
|
|
15
|
-
import 'phosphor-react-native/src/icons/EyeSlash';
|
|
16
|
-
import 'phosphor-react-native/src/icons/Info';
|
|
17
|
-
import 'phosphor-react-native/src/icons/Question';
|
|
14
|
+
import { EyeIcon } from 'phosphor-react-native/src/icons/Eye';
|
|
15
|
+
import { EyeSlashIcon } from 'phosphor-react-native/src/icons/EyeSlash';
|
|
16
|
+
import { InfoIcon } from 'phosphor-react-native/src/icons/Info';
|
|
17
|
+
import { QuestionIcon } from 'phosphor-react-native/src/icons/Question';
|
|
18
18
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
19
19
|
import { XIcon } from 'phosphor-react-native/src/icons/X';
|
|
20
20
|
import { CheckIcon } from 'phosphor-react-native/src/icons/Check';
|
|
@@ -90,6 +90,50 @@ var inputStyles = sortCx({
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
});
|
|
93
|
+
var inputGroupStyles = sortCx({
|
|
94
|
+
/** Single outer shell — select/button addons only (Figma 85:1269). */
|
|
95
|
+
shell: "w-full flex-row items-stretch overflow-hidden rounded-lg border border-solid border-primary bg-primary shadow-xs",
|
|
96
|
+
shellFocus: inputFocusRingShadow,
|
|
97
|
+
shellInvalid: "border-error_subtle",
|
|
98
|
+
shellInvalidFocus: inputErrorFocusRingShadow,
|
|
99
|
+
shellDisabled: "opacity-50",
|
|
100
|
+
row: "w-full min-h-0 flex-row items-stretch",
|
|
101
|
+
/** Leading select/button segment — compact, flush (no divider). */
|
|
102
|
+
addonLeading: "shrink-0 flex-row items-stretch self-stretch",
|
|
103
|
+
/** Trailing button segment — left divider; trailing select stays flush. */
|
|
104
|
+
addonTrailing: "shrink-0 flex-row items-stretch self-stretch",
|
|
105
|
+
addonTrailingDivider: "border-l border-solid border-primary",
|
|
106
|
+
prefixInline: "shrink-0 flex-row items-center self-stretch text-tertiary",
|
|
107
|
+
fieldSlot: "min-w-0 flex-1 flex-row items-stretch",
|
|
108
|
+
sizes: {
|
|
109
|
+
sm: {
|
|
110
|
+
shellMinH: "min-h-9",
|
|
111
|
+
prefixInline: "pl-3 pr-1.5 text-sm",
|
|
112
|
+
/** Input padding when leading select is present. */
|
|
113
|
+
inputLeadingSelect: "pl-2 pr-3 py-2 text-sm",
|
|
114
|
+
/** Input padding when trailing select + optional $ prefix. */
|
|
115
|
+
inputTrailingSelect: "pl-0 pr-2 py-2 text-sm",
|
|
116
|
+
inputTrailingSelectNoPrefix: "pl-3 pr-2 py-2 text-sm",
|
|
117
|
+
inputTrailingButton: "pl-3 pr-3 py-2 text-sm"
|
|
118
|
+
},
|
|
119
|
+
md: {
|
|
120
|
+
shellMinH: "min-h-10",
|
|
121
|
+
prefixInline: "pl-3 pr-2 text-md",
|
|
122
|
+
inputLeadingSelect: "pl-2.5 pr-3 py-2 text-md",
|
|
123
|
+
inputTrailingSelect: "pl-0 pr-2 py-2 text-md",
|
|
124
|
+
inputTrailingSelectNoPrefix: "pl-3 pr-2 py-2 text-md",
|
|
125
|
+
inputTrailingButton: "pl-3 pr-3 py-2 text-md"
|
|
126
|
+
},
|
|
127
|
+
lg: {
|
|
128
|
+
shellMinH: "min-h-11",
|
|
129
|
+
prefixInline: "pl-3.5 pr-2 text-md",
|
|
130
|
+
inputLeadingSelect: "pl-3 pr-3.5 py-2.5 text-md",
|
|
131
|
+
inputTrailingSelect: "pl-0 pr-2 py-2.5 text-md",
|
|
132
|
+
inputTrailingSelectNoPrefix: "pl-3.5 pr-2 py-2.5 text-md",
|
|
133
|
+
inputTrailingButton: "pl-3.5 pr-3.5 py-2.5 text-md"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
93
137
|
|
|
94
138
|
// ../core/src/button.ts
|
|
95
139
|
function isLinkButtonColor(color) {
|
|
@@ -438,8 +482,18 @@ var Button = ({
|
|
|
438
482
|
);
|
|
439
483
|
};
|
|
440
484
|
Button.displayName = "Button";
|
|
441
|
-
createContext(null);
|
|
442
|
-
|
|
485
|
+
var InputGroupContext = createContext(null);
|
|
486
|
+
var useInputGroupContext = () => useContext(InputGroupContext);
|
|
487
|
+
var ShellFocusContext = createContext(null);
|
|
488
|
+
var useShellFocus = () => useContext(ShellFocusContext);
|
|
489
|
+
var androidInputPad = (size, leading, trailing) => {
|
|
490
|
+
if (Platform.OS !== "android") return void 0;
|
|
491
|
+
const x = size === "lg" ? 14 : 12;
|
|
492
|
+
return {
|
|
493
|
+
paddingStart: leading ? size === "sm" ? 36 : size === "lg" ? 42 : 40 : x,
|
|
494
|
+
paddingEnd: trailing ? size === "lg" ? 38 : 36 : x
|
|
495
|
+
};
|
|
496
|
+
};
|
|
443
497
|
var Label = ({ children, isRequired, isInvalid, className }) => {
|
|
444
498
|
return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.labelRow, className), children: [
|
|
445
499
|
/* @__PURE__ */ jsx(Text, { className: inputStyles.label, children }),
|
|
@@ -464,6 +518,143 @@ var HintText = ({ children, isInvalid, size, className }) => {
|
|
|
464
518
|
}
|
|
465
519
|
);
|
|
466
520
|
};
|
|
521
|
+
var InputBase = forwardRef(function InputBase2({
|
|
522
|
+
size: sizeProp = "md",
|
|
523
|
+
type = "text",
|
|
524
|
+
placeholder,
|
|
525
|
+
value,
|
|
526
|
+
defaultValue,
|
|
527
|
+
isDisabled: isDisabledProp = false,
|
|
528
|
+
isInvalid: isInvalidProp = false,
|
|
529
|
+
tooltip,
|
|
530
|
+
icon: Icon,
|
|
531
|
+
autoCapitalize,
|
|
532
|
+
keyboardType,
|
|
533
|
+
textContentType: textContentTypeProp,
|
|
534
|
+
autoComplete: autoCompleteProp,
|
|
535
|
+
autoCorrect: autoCorrectProp,
|
|
536
|
+
autoFocus,
|
|
537
|
+
returnKeyType,
|
|
538
|
+
editable,
|
|
539
|
+
className,
|
|
540
|
+
inputClassName,
|
|
541
|
+
wrapperClassName,
|
|
542
|
+
iconClassName,
|
|
543
|
+
onChangeText,
|
|
544
|
+
onFocus,
|
|
545
|
+
onBlur,
|
|
546
|
+
onPress,
|
|
547
|
+
onSubmitEditing
|
|
548
|
+
}, ref) {
|
|
549
|
+
const group = useInputGroupContext();
|
|
550
|
+
const setShellFocus = useShellFocus();
|
|
551
|
+
const size = group?.size ?? sizeProp;
|
|
552
|
+
const isDisabled = Boolean(group?.isDisabled || isDisabledProp);
|
|
553
|
+
const isInvalid = Boolean(group?.isInvalid || isInvalidProp);
|
|
554
|
+
const shellOwnsChrome = Boolean(group?.shellOwnsChrome);
|
|
555
|
+
const joinLeadingPrefix = Boolean(group?.joinLeadingPrefix);
|
|
556
|
+
const groupPad = group ? inputGroupStyles.sizes[size] : null;
|
|
557
|
+
const groupInputPad = groupPad && group?.hasLeadingSelect ? groupPad.inputLeadingSelect : groupPad && group?.hasTrailingSelect ? group?.hasPrefix ? groupPad.inputTrailingSelect : groupPad.inputTrailingSelectNoPrefix : groupPad && group?.hasTrailingButton ? groupPad.inputTrailingButton : null;
|
|
558
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
559
|
+
const [isPasswordVisible, setIsPasswordVisible] = useState(false);
|
|
560
|
+
const isPassword = type === "password";
|
|
561
|
+
const hasLeadingIcon = Boolean(Icon);
|
|
562
|
+
const hasTrailingIcon = Boolean(tooltip) || isInvalid || isPassword;
|
|
563
|
+
const sizeStyles = inputStyles.sizes[size];
|
|
564
|
+
const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
|
|
565
|
+
const fgErrorSecondary = useNativeVariable("--color-fg-error-secondary") ?? "#f04438";
|
|
566
|
+
const handleFocus = () => {
|
|
567
|
+
setIsFocused(true);
|
|
568
|
+
setShellFocus?.(true);
|
|
569
|
+
onFocus?.();
|
|
570
|
+
};
|
|
571
|
+
const handleBlur = () => {
|
|
572
|
+
setIsFocused(false);
|
|
573
|
+
setShellFocus?.(false);
|
|
574
|
+
onBlur?.();
|
|
575
|
+
};
|
|
576
|
+
const field = /* @__PURE__ */ jsxs(
|
|
577
|
+
View,
|
|
578
|
+
{
|
|
579
|
+
className: cx(
|
|
580
|
+
shellOwnsChrome ? "relative isolate min-w-0 flex-1 flex-row items-center self-stretch bg-transparent" : cx(inputStyles.field.root, sizeStyles.field),
|
|
581
|
+
joinLeadingPrefix && !shellOwnsChrome && "rounded-l-none",
|
|
582
|
+
!shellOwnsChrome && isFocused && !isInvalid && inputStyles.field.focus,
|
|
583
|
+
!shellOwnsChrome && isInvalid && inputStyles.field.invalid,
|
|
584
|
+
!shellOwnsChrome && isInvalid && isFocused && inputStyles.field.invalidFocus,
|
|
585
|
+
!shellOwnsChrome && isDisabled && inputStyles.field.disabled,
|
|
586
|
+
wrapperClassName,
|
|
587
|
+
className
|
|
588
|
+
),
|
|
589
|
+
children: [
|
|
590
|
+
Icon && /* @__PURE__ */ jsx(
|
|
591
|
+
View,
|
|
592
|
+
{
|
|
593
|
+
pointerEvents: "none",
|
|
594
|
+
className: cx(inputStyles.iconLeading, iconClassName ?? sizeStyles.iconLeading),
|
|
595
|
+
children: /* @__PURE__ */ jsx(Icon, { className: "text-fg-quaternary", size: sizeStyles.iconPx, color: fgQuaternary })
|
|
596
|
+
}
|
|
597
|
+
),
|
|
598
|
+
/* @__PURE__ */ jsx(
|
|
599
|
+
TextInput,
|
|
600
|
+
{
|
|
601
|
+
ref,
|
|
602
|
+
accessibilityLabel: placeholder,
|
|
603
|
+
editable: editable ?? !isDisabled,
|
|
604
|
+
placeholder,
|
|
605
|
+
value,
|
|
606
|
+
defaultValue,
|
|
607
|
+
secureTextEntry: isPassword && !isPasswordVisible,
|
|
608
|
+
autoCapitalize: autoCapitalize ?? (type === "email" ? "none" : void 0),
|
|
609
|
+
autoCorrect: autoCorrectProp ?? type !== "email",
|
|
610
|
+
autoFocus,
|
|
611
|
+
returnKeyType,
|
|
612
|
+
keyboardType: keyboardType ?? (type === "email" ? "email-address" : "default"),
|
|
613
|
+
textContentType: textContentTypeProp ?? (isPassword ? "password" : type === "email" ? "emailAddress" : void 0),
|
|
614
|
+
autoComplete: autoCompleteProp ?? (type === "email" ? "email" : isPassword ? "password" : void 0),
|
|
615
|
+
onChangeText,
|
|
616
|
+
onFocus: handleFocus,
|
|
617
|
+
onBlur: handleBlur,
|
|
618
|
+
onSubmitEditing,
|
|
619
|
+
blurOnSubmit: onSubmitEditing ? false : void 0,
|
|
620
|
+
style: {
|
|
621
|
+
includeFontPadding: false,
|
|
622
|
+
paddingVertical: 0,
|
|
623
|
+
...androidInputPad(size, hasLeadingIcon, hasTrailingIcon)
|
|
624
|
+
},
|
|
625
|
+
className: cx(
|
|
626
|
+
inputStyles.input,
|
|
627
|
+
groupInputPad ?? sizeStyles.input,
|
|
628
|
+
!groupInputPad && hasLeadingIcon && sizeStyles.inputLeading,
|
|
629
|
+
!groupInputPad && hasTrailingIcon && sizeStyles.inputTrailing,
|
|
630
|
+
// Tooltip / invalid icon still need trailing room inside a group shell.
|
|
631
|
+
groupInputPad && hasTrailingIcon && "pr-9",
|
|
632
|
+
inputClassName
|
|
633
|
+
)
|
|
634
|
+
}
|
|
635
|
+
),
|
|
636
|
+
isPassword && /* @__PURE__ */ jsx(
|
|
637
|
+
Pressable,
|
|
638
|
+
{
|
|
639
|
+
accessibilityRole: "button",
|
|
640
|
+
accessibilityLabel: "Toggle password visibility",
|
|
641
|
+
disabled: isDisabled,
|
|
642
|
+
onPress: () => setIsPasswordVisible((visible) => !visible),
|
|
643
|
+
className: cx(inputStyles.iconTrailing, sizeStyles.iconTrailing),
|
|
644
|
+
children: isPasswordVisible ? /* @__PURE__ */ jsx(EyeSlashIcon, { size: sizeStyles.iconPx, weight: "bold", color: fgQuaternary }) : /* @__PURE__ */ jsx(EyeIcon, { size: sizeStyles.iconPx, weight: "bold", color: fgQuaternary })
|
|
645
|
+
}
|
|
646
|
+
),
|
|
647
|
+
!isPassword && isInvalid && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: cx(inputStyles.iconInvalid, sizeStyles.iconTrailing), children: /* @__PURE__ */ jsx(InfoIcon, { size: 16, weight: "bold", color: fgErrorSecondary }) }),
|
|
648
|
+
!isPassword && tooltip && !isInvalid && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: cx(inputStyles.iconTrailing, sizeStyles.iconTrailing), children: /* @__PURE__ */ jsx(QuestionIcon, { size: 16, weight: "bold", color: fgQuaternary }) })
|
|
649
|
+
]
|
|
650
|
+
}
|
|
651
|
+
);
|
|
652
|
+
if (onPress) {
|
|
653
|
+
return /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", disabled: isDisabled, onPress, className: "min-w-0 flex-1", children: field });
|
|
654
|
+
}
|
|
655
|
+
return field;
|
|
656
|
+
});
|
|
657
|
+
InputBase.displayName = "InputBase";
|
|
467
658
|
|
|
468
659
|
// ../core/src/dialog.ts
|
|
469
660
|
var DIALOG_SHEET_MOTION_MS = 175;
|