@avenue-ticketing/native 0.1.4 → 0.1.5
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.d.ts +37 -0
- package/dist/combobox.js +584 -0
- package/dist/combobox.js.map +1 -0
- package/dist/input.d.ts +3 -31
- package/dist/multi-select.d.ts +54 -0
- package/dist/multi-select.js +1251 -0
- package/dist/multi-select.js.map +1 -0
- package/dist/popover.d.ts +21 -0
- package/dist/popover.js +231 -0
- package/dist/popover.js.map +1 -0
- package/dist/select-BJtrES5I.d.ts +23 -0
- package/dist/select-item.d.ts +17 -0
- package/dist/select-item.js +465 -0
- package/dist/select-item.js.map +1 -0
- package/dist/select-native-C3ctbnUG.d.ts +33 -0
- package/dist/select-native.d.ts +2 -0
- package/dist/select-native.js +406 -0
- package/dist/select-native.js.map +1 -0
- package/dist/select-shared-Ah_SqhzA.d.ts +24 -0
- package/dist/select.d.ts +26 -0
- package/dist/select.js +1063 -0
- package/dist/select.js.map +1 -0
- package/dist/tag-select.d.ts +37 -0
- package/dist/tag-select.js +905 -0
- package/dist/tag-select.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,905 @@
|
|
|
1
|
+
import { createContext, useState, useMemo, useContext, isValidElement, useEffect } from 'react';
|
|
2
|
+
import { View, Text, Pressable, TextInput, ScrollView } from 'react-native-css/components';
|
|
3
|
+
import { useNativeVariable } from 'react-native-css';
|
|
4
|
+
import { MagnifyingGlassIcon } from 'phosphor-react-native/src/icons/MagnifyingGlass';
|
|
5
|
+
import { XIcon } from 'phosphor-react-native/src/icons/X';
|
|
6
|
+
import { extendTailwindMerge } from 'tailwind-merge';
|
|
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';
|
|
12
|
+
import { Image, useWindowDimensions, Modal } from 'react-native';
|
|
13
|
+
import Svg, { Path } from 'react-native-svg';
|
|
14
|
+
import { styled } from 'nativewind';
|
|
15
|
+
import { UserIcon } from 'phosphor-react-native/src/icons/User';
|
|
16
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
17
|
+
import Animated, { Easing, FadeIn, FadeOut, FadeInDown, FadeOutDown, useSharedValue, withDelay, withTiming, useAnimatedProps } from 'react-native-reanimated';
|
|
18
|
+
import { CheckIcon } from 'phosphor-react-native/src/icons/Check';
|
|
19
|
+
|
|
20
|
+
// ../../native/components/base/select/tag-select.tsx
|
|
21
|
+
var twMerge = extendTailwindMerge({
|
|
22
|
+
extend: {
|
|
23
|
+
theme: {
|
|
24
|
+
text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
var cx = twMerge;
|
|
29
|
+
function sortCx(classes) {
|
|
30
|
+
return classes;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ../core/src/input.ts
|
|
34
|
+
var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
|
|
35
|
+
var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
|
|
36
|
+
var inputStyles = sortCx({
|
|
37
|
+
stack: "w-full flex-col items-start justify-start gap-1.5",
|
|
38
|
+
labelRow: "flex-row items-center gap-0.5",
|
|
39
|
+
label: "text-sm font-medium text-secondary",
|
|
40
|
+
required: "text-brand-tertiary",
|
|
41
|
+
requiredInvalid: "text-error-primary",
|
|
42
|
+
hint: "text-sm text-tertiary",
|
|
43
|
+
hintSm: "text-xs",
|
|
44
|
+
hintInvalid: "text-error-primary",
|
|
45
|
+
field: {
|
|
46
|
+
root: "relative isolate w-full flex-row items-center rounded-lg border border-solid border-primary bg-primary shadow-xs",
|
|
47
|
+
/** Web: focus-within:border-brand + inset ring-1 ring-brand (2px visual, no layout shift). */
|
|
48
|
+
focus: inputFocusRingShadow,
|
|
49
|
+
invalid: "border-error_subtle",
|
|
50
|
+
invalidFocus: inputErrorFocusRingShadow,
|
|
51
|
+
disabled: "opacity-50"
|
|
52
|
+
},
|
|
53
|
+
input: "m-0 min-w-0 flex-1 bg-transparent text-primary placeholder:text-placeholder",
|
|
54
|
+
iconLeading: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
|
|
55
|
+
iconTrailing: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
|
|
56
|
+
iconInvalid: "absolute inset-y-0 items-center justify-center text-fg-error-secondary",
|
|
57
|
+
sizes: {
|
|
58
|
+
sm: {
|
|
59
|
+
field: "min-h-9",
|
|
60
|
+
input: "px-3 py-2 text-sm",
|
|
61
|
+
inputLeading: "pl-9",
|
|
62
|
+
inputTrailing: "pr-9",
|
|
63
|
+
iconLeading: "left-3 w-4",
|
|
64
|
+
iconTrailing: "right-3 w-4",
|
|
65
|
+
iconPx: 16,
|
|
66
|
+
shortcut: "pr-1.5"
|
|
67
|
+
},
|
|
68
|
+
md: {
|
|
69
|
+
field: "min-h-10",
|
|
70
|
+
input: "px-3 py-2 text-md",
|
|
71
|
+
inputLeading: "pl-10",
|
|
72
|
+
inputTrailing: "pr-9",
|
|
73
|
+
iconLeading: "left-3 w-5",
|
|
74
|
+
iconTrailing: "right-3 w-4",
|
|
75
|
+
iconPx: 20,
|
|
76
|
+
shortcut: "pr-2"
|
|
77
|
+
},
|
|
78
|
+
lg: {
|
|
79
|
+
field: "min-h-11",
|
|
80
|
+
input: "px-3.5 py-2.5 text-md",
|
|
81
|
+
inputLeading: "pl-10.5",
|
|
82
|
+
inputTrailing: "pr-9.5",
|
|
83
|
+
iconLeading: "left-3.5 w-5",
|
|
84
|
+
iconTrailing: "right-3.5 w-4",
|
|
85
|
+
iconPx: 20,
|
|
86
|
+
shortcut: "pr-2.5"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
createContext(null);
|
|
91
|
+
createContext(null);
|
|
92
|
+
var Label = ({ children, isRequired, isInvalid, className }) => {
|
|
93
|
+
return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.labelRow, className), children: [
|
|
94
|
+
/* @__PURE__ */ jsx(Text, { className: inputStyles.label, children }),
|
|
95
|
+
isRequired && /* @__PURE__ */ jsx(Text, { className: isInvalid ? inputStyles.requiredInvalid : inputStyles.required, children: "*" })
|
|
96
|
+
] });
|
|
97
|
+
};
|
|
98
|
+
var HintText = ({ children, isInvalid, size, className }) => {
|
|
99
|
+
if (children == null || children === false) return null;
|
|
100
|
+
if (typeof children !== "string" && typeof children !== "number") {
|
|
101
|
+
return /* @__PURE__ */ jsx(Fragment, { children });
|
|
102
|
+
}
|
|
103
|
+
return /* @__PURE__ */ jsx(
|
|
104
|
+
Text,
|
|
105
|
+
{
|
|
106
|
+
className: cx(
|
|
107
|
+
inputStyles.hint,
|
|
108
|
+
size === "sm" && inputStyles.hintSm,
|
|
109
|
+
isInvalid && inputStyles.hintInvalid,
|
|
110
|
+
className
|
|
111
|
+
),
|
|
112
|
+
children
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// ../core/src/avatar.ts
|
|
118
|
+
var avatarStyles = sortCx({
|
|
119
|
+
root: "relative shrink-0 rounded-[7px]",
|
|
120
|
+
rootRounded: "rounded-full",
|
|
121
|
+
rootBorder: "ring-1 ring-secondary_alt",
|
|
122
|
+
content: "relative size-full shrink-0 items-center justify-center overflow-hidden rounded-md bg-tertiary",
|
|
123
|
+
contentRounded: "rounded-full",
|
|
124
|
+
initials: "text-quaternary",
|
|
125
|
+
icon: "text-fg-quaternary",
|
|
126
|
+
sizes: {
|
|
127
|
+
xs: { root: "size-6", rootWithBorder: "p-px", initials: "text-xs font-semibold", icon: "size-4" },
|
|
128
|
+
sm: { root: "size-8", rootWithBorder: "p-px", initials: "text-sm font-semibold", icon: "size-5" },
|
|
129
|
+
md: { root: "size-10", rootWithBorder: "p-px", initials: "text-md font-semibold", icon: "size-6" },
|
|
130
|
+
lg: { root: "size-12", rootWithBorder: "p-[1.5px]", initials: "text-lg font-semibold", icon: "size-7" },
|
|
131
|
+
xl: { root: "size-14", rootWithBorder: "p-0.5", initials: "text-xl font-semibold", icon: "size-8" },
|
|
132
|
+
"2xl": { root: "size-16", rootWithBorder: "p-0.5", initials: "text-display-xs font-semibold", icon: "size-8" }
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
var AVATAR_SIZE_PX = {
|
|
136
|
+
xs: 24,
|
|
137
|
+
sm: 32,
|
|
138
|
+
md: 40,
|
|
139
|
+
lg: 48,
|
|
140
|
+
xl: 56,
|
|
141
|
+
"2xl": 64
|
|
142
|
+
};
|
|
143
|
+
var AVATAR_ICON_SIZE_PX = {
|
|
144
|
+
xs: 16,
|
|
145
|
+
sm: 20,
|
|
146
|
+
md: 24,
|
|
147
|
+
lg: 28,
|
|
148
|
+
xl: 32,
|
|
149
|
+
"2xl": 32
|
|
150
|
+
};
|
|
151
|
+
var AVATAR_INITIALS_LINE_HEIGHT_PX = {
|
|
152
|
+
xs: 18,
|
|
153
|
+
sm: 20,
|
|
154
|
+
md: 24,
|
|
155
|
+
lg: 28,
|
|
156
|
+
xl: 30,
|
|
157
|
+
"2xl": 32
|
|
158
|
+
};
|
|
159
|
+
var avatarOnlineIndicatorStyles = sortCx({
|
|
160
|
+
root: "absolute right-0 bottom-0 rounded-full ring-[1.5px] ring-bg-primary",
|
|
161
|
+
online: "bg-fg-success-secondary",
|
|
162
|
+
offline: "bg-utility-neutral-300",
|
|
163
|
+
sizes: {
|
|
164
|
+
xs: "size-1.5",
|
|
165
|
+
sm: "size-2",
|
|
166
|
+
md: "size-2.5",
|
|
167
|
+
lg: "size-3",
|
|
168
|
+
xl: "size-3.5",
|
|
169
|
+
"2xl": "size-4"
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
var avatarVerifiedStyles = sortCx({
|
|
173
|
+
root: "absolute right-0 bottom-0 z-10 text-utility-blue-500",
|
|
174
|
+
xsOffset: "-right-px -bottom-px",
|
|
175
|
+
sizes: {
|
|
176
|
+
xs: "size-2.5",
|
|
177
|
+
sm: "size-3",
|
|
178
|
+
md: "size-3.5",
|
|
179
|
+
lg: "size-4",
|
|
180
|
+
xl: "size-4.5",
|
|
181
|
+
"2xl": "size-5"
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
var AVATAR_VERIFIED_SIZE_PX = {
|
|
185
|
+
xs: 10,
|
|
186
|
+
sm: 12,
|
|
187
|
+
md: 14,
|
|
188
|
+
lg: 16,
|
|
189
|
+
xl: 18,
|
|
190
|
+
"2xl": 20
|
|
191
|
+
};
|
|
192
|
+
var avatarCountStyles = sortCx({
|
|
193
|
+
root: "absolute right-0 bottom-0 p-px",
|
|
194
|
+
badge: "size-3.5 items-center justify-center rounded-full bg-fg-error-primary",
|
|
195
|
+
label: "text-center text-[10px] font-bold text-white"
|
|
196
|
+
});
|
|
197
|
+
var AVATAR_COUNT_LABEL_LINE_HEIGHT_PX = 13;
|
|
198
|
+
var StyledSvg = styled(Svg);
|
|
199
|
+
var AvatarOnlineIndicator = ({ size, status, className }) => {
|
|
200
|
+
return /* @__PURE__ */ jsx(
|
|
201
|
+
View,
|
|
202
|
+
{
|
|
203
|
+
className: cx(
|
|
204
|
+
avatarOnlineIndicatorStyles.root,
|
|
205
|
+
status === "online" ? avatarOnlineIndicatorStyles.online : avatarOnlineIndicatorStyles.offline,
|
|
206
|
+
avatarOnlineIndicatorStyles.sizes[size],
|
|
207
|
+
className
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
);
|
|
211
|
+
};
|
|
212
|
+
var VerifiedTick = ({ size, className }) => {
|
|
213
|
+
const px = AVATAR_VERIFIED_SIZE_PX[size];
|
|
214
|
+
return /* @__PURE__ */ jsxs(
|
|
215
|
+
StyledSvg,
|
|
216
|
+
{
|
|
217
|
+
width: px,
|
|
218
|
+
height: px,
|
|
219
|
+
viewBox: "0 0 10 10",
|
|
220
|
+
className: cx(avatarVerifiedStyles.root, size === "xs" && avatarVerifiedStyles.xsOffset, avatarVerifiedStyles.sizes[size], className),
|
|
221
|
+
children: [
|
|
222
|
+
/* @__PURE__ */ jsx(
|
|
223
|
+
Path,
|
|
224
|
+
{
|
|
225
|
+
d: "M7.72237 1.77098C7.81734 2.00068 7.99965 2.18326 8.2292 2.27858L9.03413 2.61199C9.26384 2.70714 9.44635 2.88965 9.5415 3.11936C9.63665 3.34908 9.63665 3.60718 9.5415 3.83689L9.20833 4.64125C9.11313 4.87106 9.113 5.12943 9.20863 5.35913L9.54122 6.16325C9.58839 6.27702 9.61268 6.39897 9.6127 6.52214C9.61272 6.6453 9.58847 6.76726 9.54134 6.88105C9.4942 6.99484 9.42511 7.09823 9.33801 7.18531C9.2509 7.27238 9.14749 7.34144 9.03369 7.38854L8.22934 7.72171C7.99964 7.81669 7.81706 7.99899 7.72174 8.22855L7.38833 9.03348C7.29318 9.26319 7.11067 9.4457 6.88096 9.54085C6.65124 9.636 6.39314 9.636 6.16343 9.54085L5.35907 9.20767C5.12935 9.11276 4.87134 9.11295 4.64177 9.20821L3.83684 9.54115C3.60725 9.63608 3.34937 9.636 3.11984 9.54092C2.89032 9.44585 2.70791 9.26356 2.6127 9.03409L2.27918 8.22892C2.18421 7.99923 2.0019 7.81665 1.77235 7.72133L0.967421 7.38792C0.737807 7.29281 0.555355 7.11041 0.460169 6.88083C0.364983 6.65125 0.364854 6.39327 0.45981 6.16359L0.792984 5.35924C0.8879 5.12952 0.887707 4.87151 0.792445 4.64193L0.459749 3.83642C0.41258 3.72265 0.388291 3.60069 0.388272 3.47753C0.388252 3.35436 0.412501 3.2324 0.459634 3.11861C0.506767 3.00482 0.57586 2.90144 0.662965 2.81436C0.75007 2.72728 0.853479 2.65822 0.967283 2.61113L1.77164 2.27795C2.00113 2.18306 2.1836 2.00099 2.27899 1.7717L2.6124 0.966768C2.70755 0.737054 2.89006 0.554547 3.11978 0.459397C3.34949 0.364246 3.60759 0.364246 3.83731 0.459397L4.64166 0.792571C4.87138 0.887487 5.12939 0.887293 5.35897 0.792031L6.16424 0.459913C6.39392 0.364816 6.65197 0.364836 6.88164 0.459968C7.11131 0.555099 7.29379 0.737554 7.38895 0.967208L7.72247 1.77238L7.72237 1.77098Z",
|
|
226
|
+
fill: "currentColor"
|
|
227
|
+
}
|
|
228
|
+
),
|
|
229
|
+
/* @__PURE__ */ jsx(
|
|
230
|
+
Path,
|
|
231
|
+
{
|
|
232
|
+
fillRule: "evenodd",
|
|
233
|
+
clipRule: "evenodd",
|
|
234
|
+
d: "M6.95829 3.68932C7.02509 3.58439 7.04747 3.45723 7.02051 3.3358C6.99356 3.21437 6.91946 3.10862 6.81454 3.04182C6.70961 2.97502 6.58245 2.95264 6.46102 2.97959C6.33959 3.00655 6.23384 3.08064 6.16704 3.18557L4.33141 6.06995L3.49141 5.01995C3.41375 4.92281 3.30069 4.8605 3.17709 4.84673C3.05349 4.83296 2.92949 4.86885 2.83235 4.94651C2.73522 5.02417 2.67291 5.13723 2.65914 5.26083C2.64536 5.38443 2.68125 5.50843 2.75891 5.60557L4.00891 7.16807C4.0555 7.22638 4.11533 7.27271 4.18344 7.30323C4.25154 7.33375 4.32595 7.34757 4.40047 7.34353C4.47499 7.3395 4.54747 7.31773 4.61188 7.28004C4.67629 7.24234 4.73077 7.18981 4.77079 7.12682L6.95829 3.68932Z",
|
|
235
|
+
fill: "white"
|
|
236
|
+
}
|
|
237
|
+
)
|
|
238
|
+
]
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
};
|
|
242
|
+
var AvatarCount = ({ count, className }) => {
|
|
243
|
+
return /* @__PURE__ */ jsx(View, { className: cx(avatarCountStyles.root, className), children: /* @__PURE__ */ jsx(View, { className: cx("flex-row", avatarCountStyles.badge), children: /* @__PURE__ */ jsx(
|
|
244
|
+
Text,
|
|
245
|
+
{
|
|
246
|
+
style: { includeFontPadding: false, lineHeight: AVATAR_COUNT_LABEL_LINE_HEIGHT_PX },
|
|
247
|
+
className: avatarCountStyles.label,
|
|
248
|
+
children: count
|
|
249
|
+
}
|
|
250
|
+
) }) });
|
|
251
|
+
};
|
|
252
|
+
var Avatar = ({
|
|
253
|
+
size = "md",
|
|
254
|
+
src,
|
|
255
|
+
alt,
|
|
256
|
+
initials,
|
|
257
|
+
placeholder,
|
|
258
|
+
placeholderIcon: PlaceholderIcon,
|
|
259
|
+
border,
|
|
260
|
+
badge,
|
|
261
|
+
status,
|
|
262
|
+
verified,
|
|
263
|
+
count,
|
|
264
|
+
rounded = true,
|
|
265
|
+
className,
|
|
266
|
+
contentClassName
|
|
267
|
+
}) => {
|
|
268
|
+
const [isFailed, setIsFailed] = useState(false);
|
|
269
|
+
const canShowImage = Boolean(src && !isFailed);
|
|
270
|
+
const sizeStyles = avatarStyles.sizes[size];
|
|
271
|
+
const px = AVATAR_SIZE_PX[size];
|
|
272
|
+
const iconPx = AVATAR_ICON_SIZE_PX[size];
|
|
273
|
+
const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
|
|
274
|
+
const renderMainContent = () => {
|
|
275
|
+
if (canShowImage && src) {
|
|
276
|
+
return /* @__PURE__ */ jsx(
|
|
277
|
+
Image,
|
|
278
|
+
{
|
|
279
|
+
source: { uri: src },
|
|
280
|
+
accessibilityLabel: alt,
|
|
281
|
+
onError: () => setIsFailed(true),
|
|
282
|
+
style: { width: "100%", height: "100%" },
|
|
283
|
+
resizeMode: "cover"
|
|
284
|
+
}
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
if (initials) {
|
|
288
|
+
return /* @__PURE__ */ jsx(
|
|
289
|
+
Text,
|
|
290
|
+
{
|
|
291
|
+
style: { includeFontPadding: false, lineHeight: AVATAR_INITIALS_LINE_HEIGHT_PX[size] },
|
|
292
|
+
className: cx(avatarStyles.initials, sizeStyles.initials),
|
|
293
|
+
children: initials
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
if (PlaceholderIcon) {
|
|
298
|
+
return /* @__PURE__ */ jsx(PlaceholderIcon, { size: iconPx, color: fgQuaternary });
|
|
299
|
+
}
|
|
300
|
+
if (placeholder) return /* @__PURE__ */ jsx(Fragment, { children: placeholder });
|
|
301
|
+
return /* @__PURE__ */ jsx(UserIcon, { size: iconPx, color: fgQuaternary });
|
|
302
|
+
};
|
|
303
|
+
const renderBadgeContent = () => {
|
|
304
|
+
if (status) return /* @__PURE__ */ jsx(AvatarOnlineIndicator, { status, size });
|
|
305
|
+
if (verified) return /* @__PURE__ */ jsx(VerifiedTick, { size });
|
|
306
|
+
if (count) return /* @__PURE__ */ jsx(AvatarCount, { count });
|
|
307
|
+
return badge ?? null;
|
|
308
|
+
};
|
|
309
|
+
return /* @__PURE__ */ jsxs(
|
|
310
|
+
View,
|
|
311
|
+
{
|
|
312
|
+
className: cx(
|
|
313
|
+
avatarStyles.root,
|
|
314
|
+
rounded && avatarStyles.rootRounded,
|
|
315
|
+
border && avatarStyles.rootBorder,
|
|
316
|
+
border && sizeStyles.rootWithBorder,
|
|
317
|
+
sizeStyles.root,
|
|
318
|
+
className
|
|
319
|
+
),
|
|
320
|
+
style: { width: px, height: px },
|
|
321
|
+
children: [
|
|
322
|
+
/* @__PURE__ */ jsx(
|
|
323
|
+
View,
|
|
324
|
+
{
|
|
325
|
+
className: cx(
|
|
326
|
+
"flex-row",
|
|
327
|
+
avatarStyles.content,
|
|
328
|
+
rounded && avatarStyles.contentRounded,
|
|
329
|
+
contentClassName
|
|
330
|
+
),
|
|
331
|
+
children: renderMainContent()
|
|
332
|
+
}
|
|
333
|
+
),
|
|
334
|
+
renderBadgeContent()
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
);
|
|
338
|
+
};
|
|
339
|
+
|
|
340
|
+
// ../core/src/dialog.ts
|
|
341
|
+
var DIALOG_SHEET_MOTION_MS = 175;
|
|
342
|
+
var DIALOG_SLIDE_OFFSET_PX = 120;
|
|
343
|
+
var DIALOG_ENTRY_EASING_BEZIER = [0.85, 0, 0.15, 1];
|
|
344
|
+
var DIALOG_EXIT_EASING_BEZIER = [0.85, 0, 1, 0.15];
|
|
345
|
+
var DIALOG_SHEET_RADIUS_PX = 16;
|
|
346
|
+
var dialogStyles = sortCx({
|
|
347
|
+
root: "flex",
|
|
348
|
+
rootFull: "h-full w-full flex-col bg-primary",
|
|
349
|
+
rootSheet: "flex-col justify-end",
|
|
350
|
+
rootModal: "flex-col items-center justify-center p-4",
|
|
351
|
+
overlay: "absolute inset-0 bg-overlay/70",
|
|
352
|
+
panel: "relative z-10 w-full overflow-hidden bg-primary",
|
|
353
|
+
panelElevated: "shadow-xl",
|
|
354
|
+
panelFull: "flex min-h-0 flex-1 flex-col",
|
|
355
|
+
/**
|
|
356
|
+
* Web sheet chrome (≤1024). Native pins the same chrome with RN layout styles
|
|
357
|
+
* (`DIALOG_SHEET_RADIUS_PX` + token colors) because NativeWind border/radius
|
|
358
|
+
* on sheets leave side gaps and bottom transparency.
|
|
359
|
+
*/
|
|
360
|
+
panelSheet: "w-full max-h-[90%] rounded-t-2xl rounded-b-none border border-solid border-secondary border-x-0 border-b-0 border-t",
|
|
361
|
+
panelModal: "w-full rounded-2xl border border-solid border-secondary",
|
|
362
|
+
sizes: {
|
|
363
|
+
sm: "max-w-sm",
|
|
364
|
+
md: "max-w-md",
|
|
365
|
+
lg: "max-w-lg",
|
|
366
|
+
xl: "max-w-xl"
|
|
367
|
+
},
|
|
368
|
+
sizesLgOnly: {
|
|
369
|
+
sm: "lg:max-w-sm",
|
|
370
|
+
md: "lg:max-w-md",
|
|
371
|
+
lg: "lg:max-w-lg",
|
|
372
|
+
xl: "lg:max-w-xl"
|
|
373
|
+
},
|
|
374
|
+
sizesSmUp: {
|
|
375
|
+
sm: "sm:max-w-sm",
|
|
376
|
+
md: "sm:max-w-md",
|
|
377
|
+
lg: "sm:max-w-lg",
|
|
378
|
+
xl: "sm:max-w-xl"
|
|
379
|
+
},
|
|
380
|
+
header: "flex-col gap-1.5 p-6 pr-14",
|
|
381
|
+
headerFixed: "border-b border-solid border-secondary bg-primary",
|
|
382
|
+
footer: "flex-col-reverse gap-2 p-6",
|
|
383
|
+
footerFixed: "border-t border-solid border-secondary bg-primary",
|
|
384
|
+
title: "text-xl font-semibold text-primary",
|
|
385
|
+
description: "text-sm text-tertiary",
|
|
386
|
+
close: "size-12 items-center justify-center rounded-full bg-primary active:scale-[0.96] active:bg-primary_hover",
|
|
387
|
+
closePosition: "absolute top-4 right-4 z-20"
|
|
388
|
+
});
|
|
389
|
+
|
|
390
|
+
// ../core/src/select.ts
|
|
391
|
+
var sizes = {
|
|
392
|
+
sm: { root: "gap-2 py-2 pr-2.5 pl-3", text: "text-sm", icon: 16, textGap: "gap-x-1.5" },
|
|
393
|
+
md: { root: "gap-2 px-3 py-2", text: "text-md", icon: 20, textGap: "gap-x-1.5" },
|
|
394
|
+
lg: { root: "gap-2 px-3.5 py-2.5", text: "text-md", icon: 20, textGap: "gap-x-1.5" }
|
|
395
|
+
};
|
|
396
|
+
var itemSizes = {
|
|
397
|
+
sm: { root: "gap-2 p-2 pr-2.5", text: "text-sm", icon: 16, textGap: "gap-x-1.5", check: 16, checkbox: "sm" },
|
|
398
|
+
md: { root: "gap-2 p-2 pr-2.5", text: "text-md", icon: 20, textGap: "gap-x-2", check: 20, checkbox: "sm" },
|
|
399
|
+
lg: { root: "gap-2 py-2.5 pr-2.5 pl-2", text: "text-md", icon: 20, textGap: "gap-x-2", check: 20, checkbox: "md" }
|
|
400
|
+
};
|
|
401
|
+
var menuMaxHeight = {
|
|
402
|
+
sm: "max-h-56",
|
|
403
|
+
md: "max-h-64",
|
|
404
|
+
lg: "max-h-80"
|
|
405
|
+
};
|
|
406
|
+
function resolveSelectMobileOptions(mobileOptions) {
|
|
407
|
+
const fullScreen = mobileOptions?.fullScreen ?? false;
|
|
408
|
+
return {
|
|
409
|
+
sheet: mobileOptions?.sheet ?? true,
|
|
410
|
+
fullScreen,
|
|
411
|
+
overlay: fullScreen ? false : mobileOptions?.overlay ?? true,
|
|
412
|
+
title: mobileOptions?.title,
|
|
413
|
+
sheetClassName: mobileOptions?.className,
|
|
414
|
+
contentClassName: mobileOptions?.contentClassName
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
function selectIdKey(id) {
|
|
418
|
+
return String(id);
|
|
419
|
+
}
|
|
420
|
+
function itemText(item) {
|
|
421
|
+
return item.supportingText ? `${item.label ?? ""} ${item.supportingText}` : item.label ?? "";
|
|
422
|
+
}
|
|
423
|
+
function itemMatches(item, query) {
|
|
424
|
+
const needle = query.trim().toLowerCase();
|
|
425
|
+
if (!needle) return true;
|
|
426
|
+
return itemText(item).toLowerCase().includes(needle);
|
|
427
|
+
}
|
|
428
|
+
function selectFieldClassName(options) {
|
|
429
|
+
return cx(
|
|
430
|
+
"bg-primary w-full flex-row items-center rounded-lg border border-solid shadow-xs",
|
|
431
|
+
sizes[options.size].root,
|
|
432
|
+
options.isDisabled && "opacity-50",
|
|
433
|
+
options.isInvalid && options.focused && inputErrorFocusRingShadow,
|
|
434
|
+
options.isInvalid && !options.focused && "border-error_subtle",
|
|
435
|
+
!options.isInvalid && options.focused && inputFocusRingShadow,
|
|
436
|
+
!options.isInvalid && !options.focused && "border-primary",
|
|
437
|
+
options.className
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
// ../core/src/is-react-component.ts
|
|
442
|
+
var isFunctionComponent = (component) => {
|
|
443
|
+
return typeof component === "function";
|
|
444
|
+
};
|
|
445
|
+
var isClassComponent = (component) => {
|
|
446
|
+
return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
|
|
447
|
+
};
|
|
448
|
+
var isForwardRefComponent = (component) => {
|
|
449
|
+
return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
|
|
450
|
+
};
|
|
451
|
+
var isReactComponent = (component) => {
|
|
452
|
+
return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
|
|
453
|
+
};
|
|
454
|
+
var SelectMenuContext = createContext(null);
|
|
455
|
+
var SelectContext = createContext({ size: "md" });
|
|
456
|
+
var SelectGlyph = ({ icon, size, color }) => {
|
|
457
|
+
if (isReactComponent(icon)) {
|
|
458
|
+
const Icon = icon;
|
|
459
|
+
return /* @__PURE__ */ jsx(Icon, { size, color });
|
|
460
|
+
}
|
|
461
|
+
if (isValidElement(icon)) return icon;
|
|
462
|
+
return null;
|
|
463
|
+
};
|
|
464
|
+
var ENTRY = Easing.bezier(...DIALOG_ENTRY_EASING_BEZIER);
|
|
465
|
+
var EXIT = Easing.bezier(...DIALOG_EXIT_EASING_BEZIER);
|
|
466
|
+
var overlayEntering = FadeIn.duration(DIALOG_SHEET_MOTION_MS).easing(ENTRY);
|
|
467
|
+
var overlayExiting = FadeOut.duration(DIALOG_SHEET_MOTION_MS).easing(EXIT);
|
|
468
|
+
var panelEntering = FadeInDown.duration(DIALOG_SHEET_MOTION_MS).easing(ENTRY).withInitialValues({ opacity: 0, transform: [{ translateY: DIALOG_SLIDE_OFFSET_PX }] });
|
|
469
|
+
var panelExiting = FadeOutDown.duration(DIALOG_SHEET_MOTION_MS).easing(EXIT).withTargetValues({ opacity: 0, transform: [{ translateY: DIALOG_SLIDE_OFFSET_PX }] });
|
|
470
|
+
function useSheetPresence(open) {
|
|
471
|
+
const [shouldRender, setShouldRender] = useState(open);
|
|
472
|
+
useEffect(() => {
|
|
473
|
+
if (open) {
|
|
474
|
+
setShouldRender(true);
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
const hide = setTimeout(() => setShouldRender(false), DIALOG_SHEET_MOTION_MS);
|
|
478
|
+
return () => clearTimeout(hide);
|
|
479
|
+
}, [open]);
|
|
480
|
+
return shouldRender;
|
|
481
|
+
}
|
|
482
|
+
function overlayFill(color) {
|
|
483
|
+
const hex = /^#([\da-f]{6})$/i.exec(color);
|
|
484
|
+
if (!hex) return "rgba(10, 13, 18, 0.7)";
|
|
485
|
+
const value = parseInt(hex[1], 16);
|
|
486
|
+
return `rgba(${value >> 16 & 255}, ${value >> 8 & 255}, ${value & 255}, 0.7)`;
|
|
487
|
+
}
|
|
488
|
+
var HEADER_HEIGHT = 56;
|
|
489
|
+
var Popover = ({
|
|
490
|
+
open,
|
|
491
|
+
onClose,
|
|
492
|
+
size = "md",
|
|
493
|
+
mobileOptions,
|
|
494
|
+
compound = false,
|
|
495
|
+
className,
|
|
496
|
+
children
|
|
497
|
+
}) => {
|
|
498
|
+
const resolved = resolveSelectMobileOptions(mobileOptions);
|
|
499
|
+
if (!resolved.sheet) {
|
|
500
|
+
if (!open) return null;
|
|
501
|
+
return /* @__PURE__ */ jsx(
|
|
502
|
+
View,
|
|
503
|
+
{
|
|
504
|
+
className: cx(
|
|
505
|
+
"bg-primary overflow-hidden rounded-lg shadow-lg ring-1 ring-secondary_alt",
|
|
506
|
+
!compound && "py-1",
|
|
507
|
+
!compound && menuMaxHeight[size],
|
|
508
|
+
className
|
|
509
|
+
),
|
|
510
|
+
children: compound ? children : /* @__PURE__ */ jsx(ScrollView, { keyboardShouldPersistTaps: "handled", nestedScrollEnabled: true, children })
|
|
511
|
+
}
|
|
512
|
+
);
|
|
513
|
+
}
|
|
514
|
+
return /* @__PURE__ */ jsx(
|
|
515
|
+
SelectSheet,
|
|
516
|
+
{
|
|
517
|
+
open,
|
|
518
|
+
onClose,
|
|
519
|
+
title: resolved.title,
|
|
520
|
+
fullScreen: resolved.fullScreen,
|
|
521
|
+
overlay: resolved.overlay,
|
|
522
|
+
className: cx(resolved.sheetClassName, resolved.contentClassName, className),
|
|
523
|
+
children
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
};
|
|
527
|
+
var SelectSheet = ({ open, onClose, title, fullScreen, overlay, className, children }) => {
|
|
528
|
+
const insets = useSafeAreaInsets();
|
|
529
|
+
const { width: windowWidth, height: windowHeight } = useWindowDimensions();
|
|
530
|
+
const shouldRender = useSheetPresence(open);
|
|
531
|
+
const fgPrimary = useNativeVariable("--color-fg-primary") ?? "#181d27";
|
|
532
|
+
const bgPrimary = useNativeVariable("--color-bg-primary") ?? "#ffffff";
|
|
533
|
+
const borderSecondary = useNativeVariable("--color-border-secondary") ?? "#e9eaeb";
|
|
534
|
+
const overlayColor = useNativeVariable("--color-bg-overlay") ?? "#0a0d12";
|
|
535
|
+
const sheetMax = fullScreen ? windowHeight : Math.round(windowHeight * 0.9);
|
|
536
|
+
const listMax = Math.max(0, sheetMax - HEADER_HEIGHT - (fullScreen ? insets.top : insets.bottom));
|
|
537
|
+
return /* @__PURE__ */ jsx(Modal, { visible: shouldRender, transparent: true, animationType: "none", presentationStyle: "overFullScreen", statusBarTranslucent: true, onRequestClose: onClose, children: /* @__PURE__ */ jsxs(View, { className: cx(dialogStyles.root, "h-full w-full flex-1", fullScreen ? dialogStyles.rootFull : dialogStyles.rootSheet), children: [
|
|
538
|
+
open && overlay ? /* @__PURE__ */ jsx(View, { className: dialogStyles.overlay, children: /* @__PURE__ */ jsx(Animated.View, { entering: overlayEntering, exiting: overlayExiting, style: { flex: 1, backgroundColor: overlayFill(overlayColor) }, children: /* @__PURE__ */ jsx(Pressable, { accessibilityRole: "button", accessibilityLabel: "Dismiss", onPress: onClose, className: "flex-1" }) }) }) : null,
|
|
539
|
+
open ? /* @__PURE__ */ jsxs(
|
|
540
|
+
Animated.View,
|
|
541
|
+
{
|
|
542
|
+
collapsable: false,
|
|
543
|
+
entering: panelEntering,
|
|
544
|
+
exiting: panelExiting,
|
|
545
|
+
style: fullScreen ? {
|
|
546
|
+
flex: 1,
|
|
547
|
+
width: windowWidth,
|
|
548
|
+
backgroundColor: bgPrimary,
|
|
549
|
+
paddingBottom: 12
|
|
550
|
+
} : {
|
|
551
|
+
position: "absolute",
|
|
552
|
+
left: 0,
|
|
553
|
+
right: 0,
|
|
554
|
+
bottom: 0,
|
|
555
|
+
width: windowWidth,
|
|
556
|
+
maxHeight: sheetMax,
|
|
557
|
+
zIndex: 10,
|
|
558
|
+
overflow: "hidden",
|
|
559
|
+
backgroundColor: bgPrimary,
|
|
560
|
+
borderTopLeftRadius: DIALOG_SHEET_RADIUS_PX,
|
|
561
|
+
borderTopRightRadius: DIALOG_SHEET_RADIUS_PX,
|
|
562
|
+
borderBottomLeftRadius: 0,
|
|
563
|
+
borderBottomRightRadius: 0,
|
|
564
|
+
borderTopWidth: 1,
|
|
565
|
+
borderLeftWidth: 0,
|
|
566
|
+
borderRightWidth: 0,
|
|
567
|
+
borderBottomWidth: 0,
|
|
568
|
+
borderTopColor: borderSecondary,
|
|
569
|
+
paddingBottom: insets.bottom
|
|
570
|
+
},
|
|
571
|
+
children: [
|
|
572
|
+
fullScreen ? /* @__PURE__ */ jsx(View, { style: { height: insets.top } }) : null,
|
|
573
|
+
/* @__PURE__ */ jsxs(View, { className: cx("w-full flex-row items-center pr-2 pl-4", title ? "justify-between" : "justify-end"), style: { height: HEADER_HEIGHT }, children: [
|
|
574
|
+
title ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: "text-primary min-w-0 flex-1 text-base font-semibold", children: title }) : null,
|
|
575
|
+
/* @__PURE__ */ jsx(
|
|
576
|
+
Pressable,
|
|
577
|
+
{
|
|
578
|
+
accessibilityRole: "button",
|
|
579
|
+
accessibilityLabel: "Close",
|
|
580
|
+
onPress: onClose,
|
|
581
|
+
className: "size-12 items-center justify-center rounded-full active:bg-primary_hover",
|
|
582
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: 20, color: fgPrimary })
|
|
583
|
+
}
|
|
584
|
+
)
|
|
585
|
+
] }),
|
|
586
|
+
/* @__PURE__ */ jsx(
|
|
587
|
+
ScrollView,
|
|
588
|
+
{
|
|
589
|
+
keyboardShouldPersistTaps: "handled",
|
|
590
|
+
style: fullScreen ? { flex: 1 } : { flexGrow: 0, flexShrink: 0, maxHeight: listMax },
|
|
591
|
+
children: /* @__PURE__ */ jsx(View, { className: cx("py-1", className), children })
|
|
592
|
+
}
|
|
593
|
+
)
|
|
594
|
+
]
|
|
595
|
+
}
|
|
596
|
+
) : null
|
|
597
|
+
] }) });
|
|
598
|
+
};
|
|
599
|
+
|
|
600
|
+
// ../core/src/checkbox.ts
|
|
601
|
+
var checkboxStyles = sortCx({
|
|
602
|
+
base: {
|
|
603
|
+
root: "relative shrink-0 items-center justify-center overflow-hidden border border-solid border-primary",
|
|
604
|
+
rootUnchecked: "bg-primary",
|
|
605
|
+
rootChecked: "border-transparent bg-brand-solid",
|
|
606
|
+
rootDisabled: "opacity-50",
|
|
607
|
+
rootDisabledUnchecked: "bg-tertiary",
|
|
608
|
+
icon: "text-fg-white"
|
|
609
|
+
},
|
|
610
|
+
sizes: {
|
|
611
|
+
sm: {
|
|
612
|
+
root: "size-4 rounded-xs",
|
|
613
|
+
stack: "gap-2",
|
|
614
|
+
textWrapper: "",
|
|
615
|
+
label: "text-sm font-medium",
|
|
616
|
+
hint: "text-sm",
|
|
617
|
+
baseOffset: "mt-0.5"
|
|
618
|
+
},
|
|
619
|
+
md: {
|
|
620
|
+
root: "size-5 rounded-sm",
|
|
621
|
+
stack: "gap-3",
|
|
622
|
+
textWrapper: "gap-0.5",
|
|
623
|
+
label: "text-md font-medium",
|
|
624
|
+
hint: "text-md",
|
|
625
|
+
baseOffset: "mt-0.5"
|
|
626
|
+
}
|
|
627
|
+
},
|
|
628
|
+
/** Label + hint stack beside the control. */
|
|
629
|
+
stack: "relative flex-row items-start",
|
|
630
|
+
label: "text-secondary",
|
|
631
|
+
hint: "text-tertiary"
|
|
632
|
+
});
|
|
633
|
+
var CHECKBOX_ICON_PX = {
|
|
634
|
+
sm: 10,
|
|
635
|
+
md: 14
|
|
636
|
+
};
|
|
637
|
+
function resolveCheckboxIconPx(size) {
|
|
638
|
+
return CHECKBOX_ICON_PX[size];
|
|
639
|
+
}
|
|
640
|
+
var CHECKBOX_TICK_DELAY_MS = 60;
|
|
641
|
+
var CHECKBOX_TICK_DRAW_MS = 100;
|
|
642
|
+
var CHECKBOX_CHECK_PATH = "M2.33325 7L5.24992 9.91667L11.6666 3.5";
|
|
643
|
+
var CHECKBOX_CHECK_PATH_LENGTH = 13.21;
|
|
644
|
+
var CHECKBOX_INDETERMINATE_PATH = "M2.91675 7H11.0834";
|
|
645
|
+
var CHECKBOX_TICK_EASING = [0.45, 0, 0.2, 1];
|
|
646
|
+
var StyledSvg2 = styled(Svg);
|
|
647
|
+
var AnimatedPath = Animated.createAnimatedComponent(Path);
|
|
648
|
+
var tickEasing = Easing.bezier(
|
|
649
|
+
CHECKBOX_TICK_EASING[0],
|
|
650
|
+
CHECKBOX_TICK_EASING[1],
|
|
651
|
+
CHECKBOX_TICK_EASING[2],
|
|
652
|
+
CHECKBOX_TICK_EASING[3]
|
|
653
|
+
);
|
|
654
|
+
var CheckboxAnimatedCheckMark = ({
|
|
655
|
+
pixelSize,
|
|
656
|
+
className
|
|
657
|
+
}) => {
|
|
658
|
+
const dashOffset = useSharedValue(CHECKBOX_CHECK_PATH_LENGTH);
|
|
659
|
+
useEffect(() => {
|
|
660
|
+
dashOffset.value = CHECKBOX_CHECK_PATH_LENGTH;
|
|
661
|
+
dashOffset.value = withDelay(
|
|
662
|
+
CHECKBOX_TICK_DELAY_MS,
|
|
663
|
+
withTiming(0, {
|
|
664
|
+
duration: CHECKBOX_TICK_DRAW_MS,
|
|
665
|
+
easing: tickEasing
|
|
666
|
+
})
|
|
667
|
+
);
|
|
668
|
+
}, [dashOffset]);
|
|
669
|
+
const animatedProps = useAnimatedProps(() => ({
|
|
670
|
+
strokeDashoffset: dashOffset.value
|
|
671
|
+
}));
|
|
672
|
+
return /* @__PURE__ */ jsx(StyledSvg2, { width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", className, children: /* @__PURE__ */ jsx(
|
|
673
|
+
AnimatedPath,
|
|
674
|
+
{
|
|
675
|
+
d: CHECKBOX_CHECK_PATH,
|
|
676
|
+
stroke: "currentColor",
|
|
677
|
+
strokeWidth: 2,
|
|
678
|
+
strokeLinecap: "round",
|
|
679
|
+
strokeLinejoin: "round",
|
|
680
|
+
fill: "none",
|
|
681
|
+
strokeDasharray: CHECKBOX_CHECK_PATH_LENGTH,
|
|
682
|
+
animatedProps
|
|
683
|
+
}
|
|
684
|
+
) });
|
|
685
|
+
};
|
|
686
|
+
var IndeterminateMark = ({ pixelSize, className }) => {
|
|
687
|
+
return /* @__PURE__ */ jsx(StyledSvg2, { width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", className, children: /* @__PURE__ */ jsx(
|
|
688
|
+
Path,
|
|
689
|
+
{
|
|
690
|
+
d: CHECKBOX_INDETERMINATE_PATH,
|
|
691
|
+
stroke: "currentColor",
|
|
692
|
+
strokeWidth: 2,
|
|
693
|
+
strokeLinecap: "round",
|
|
694
|
+
strokeLinejoin: "round",
|
|
695
|
+
fill: "none"
|
|
696
|
+
}
|
|
697
|
+
) });
|
|
698
|
+
};
|
|
699
|
+
var CheckboxBase = ({
|
|
700
|
+
className,
|
|
701
|
+
isSelected,
|
|
702
|
+
isDisabled,
|
|
703
|
+
isIndeterminate,
|
|
704
|
+
size = "sm"
|
|
705
|
+
}) => {
|
|
706
|
+
const isChecked = Boolean(isSelected || isIndeterminate);
|
|
707
|
+
const iconPixelSize = resolveCheckboxIconPx(size);
|
|
708
|
+
return /* @__PURE__ */ jsxs(
|
|
709
|
+
View,
|
|
710
|
+
{
|
|
711
|
+
className: cx(
|
|
712
|
+
"flex-row",
|
|
713
|
+
checkboxStyles.base.root,
|
|
714
|
+
checkboxStyles.sizes[size].root,
|
|
715
|
+
isChecked ? checkboxStyles.base.rootChecked : checkboxStyles.base.rootUnchecked,
|
|
716
|
+
isDisabled && checkboxStyles.base.rootDisabled,
|
|
717
|
+
isDisabled && !isChecked && checkboxStyles.base.rootDisabledUnchecked,
|
|
718
|
+
className
|
|
719
|
+
),
|
|
720
|
+
children: [
|
|
721
|
+
isIndeterminate && /* @__PURE__ */ jsx(IndeterminateMark, { pixelSize: iconPixelSize, className: checkboxStyles.base.icon }),
|
|
722
|
+
isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: checkboxStyles.base.icon })
|
|
723
|
+
]
|
|
724
|
+
}
|
|
725
|
+
);
|
|
726
|
+
};
|
|
727
|
+
CheckboxBase.displayName = "CheckboxBase";
|
|
728
|
+
var SelectItem = ({
|
|
729
|
+
id,
|
|
730
|
+
label,
|
|
731
|
+
supportingText,
|
|
732
|
+
avatarUrl,
|
|
733
|
+
isDisabled,
|
|
734
|
+
icon,
|
|
735
|
+
selectionIndicator = "checkmark",
|
|
736
|
+
selectionIndicatorAlign = "right",
|
|
737
|
+
className,
|
|
738
|
+
children
|
|
739
|
+
}) => {
|
|
740
|
+
const menu = useContext(SelectMenuContext);
|
|
741
|
+
const select = useContext(SelectContext);
|
|
742
|
+
const size = menu?.size ?? select.size;
|
|
743
|
+
const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
|
|
744
|
+
const fgBrand = useNativeVariable("--color-fg-brand-primary") ?? "#7f56d9";
|
|
745
|
+
const title = label || (typeof children === "string" ? children : "");
|
|
746
|
+
const selected = menu?.isSelected(id) ?? false;
|
|
747
|
+
const showCheck = selected && selectionIndicator === "checkmark";
|
|
748
|
+
const showCheckbox = selectionIndicator === "checkbox";
|
|
749
|
+
const checkboxOnLeft = showCheckbox && selectionIndicatorAlign === "left";
|
|
750
|
+
const brandRow = selected && selectionIndicator !== "checkbox";
|
|
751
|
+
return /* @__PURE__ */ jsx(View, { className: cx("w-full py-px", size === "sm" ? "px-1" : "px-1.5", className), children: /* @__PURE__ */ jsxs(
|
|
752
|
+
Pressable,
|
|
753
|
+
{
|
|
754
|
+
accessibilityRole: "button",
|
|
755
|
+
accessibilityState: { disabled: isDisabled, selected },
|
|
756
|
+
disabled: isDisabled,
|
|
757
|
+
onPress: menu?.selectOnPressIn ? void 0 : () => {
|
|
758
|
+
if (!isDisabled) menu?.onSelect(id);
|
|
759
|
+
},
|
|
760
|
+
onPressIn: menu?.selectOnPressIn ? () => {
|
|
761
|
+
if (!isDisabled) menu?.onSelect(id);
|
|
762
|
+
} : void 0,
|
|
763
|
+
className: cx(
|
|
764
|
+
"flex-row items-center rounded-md",
|
|
765
|
+
itemSizes[size].root,
|
|
766
|
+
brandRow ? "bg-brand-primary_alt" : "active:bg-primary_hover",
|
|
767
|
+
isDisabled && "opacity-50"
|
|
768
|
+
),
|
|
769
|
+
children: [
|
|
770
|
+
checkboxOnLeft ? /* @__PURE__ */ jsx(CheckboxBase, { size: itemSizes[size].checkbox, isSelected: selected, isDisabled }) : null,
|
|
771
|
+
avatarUrl ? /* @__PURE__ */ jsx(Avatar, { size: "xs", src: avatarUrl, alt: title, className: size === "sm" ? "size-5" : void 0 }) : /* @__PURE__ */ jsx(SelectGlyph, { icon, size: itemSizes[size].icon, color: fgQuaternary }),
|
|
772
|
+
/* @__PURE__ */ jsxs(View, { className: cx("min-w-0 flex-1 flex-row flex-wrap", itemSizes[size].textGap), children: [
|
|
773
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-primary font-medium", itemSizes[size].text), children: title }),
|
|
774
|
+
supportingText ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-tertiary", itemSizes[size].text), children: supportingText }) : null
|
|
775
|
+
] }),
|
|
776
|
+
showCheck ? /* @__PURE__ */ jsx(CheckIcon, { size: itemSizes[size].check, color: fgBrand }) : null,
|
|
777
|
+
showCheckbox && !checkboxOnLeft ? /* @__PURE__ */ jsx(CheckboxBase, { size: itemSizes[size].checkbox, isSelected: selected, isDisabled }) : null
|
|
778
|
+
]
|
|
779
|
+
}
|
|
780
|
+
) });
|
|
781
|
+
};
|
|
782
|
+
var TagSelectRoot = ({
|
|
783
|
+
items = [],
|
|
784
|
+
selectedItems,
|
|
785
|
+
label,
|
|
786
|
+
hint,
|
|
787
|
+
size = "sm",
|
|
788
|
+
placeholder = "Search",
|
|
789
|
+
icon,
|
|
790
|
+
isDisabled,
|
|
791
|
+
isInvalid,
|
|
792
|
+
isRequired,
|
|
793
|
+
hideRequiredIndicator,
|
|
794
|
+
popoverClassName,
|
|
795
|
+
mobileOptions,
|
|
796
|
+
className,
|
|
797
|
+
valueFormatter,
|
|
798
|
+
onItemCleared,
|
|
799
|
+
onItemInserted,
|
|
800
|
+
children
|
|
801
|
+
}) => {
|
|
802
|
+
const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
|
|
803
|
+
const fgSecondary = useNativeVariable("--color-fg-secondary") ?? "#535862";
|
|
804
|
+
const [query, setQuery] = useState("");
|
|
805
|
+
const [focused, setFocused] = useState(false);
|
|
806
|
+
const selectedIds = useMemo(() => new Set(selectedItems.items.map((item) => selectIdKey(item.id))), [selectedItems.items]);
|
|
807
|
+
const rows = useMemo(
|
|
808
|
+
() => items.filter((item) => !selectedIds.has(selectIdKey(item.id)) && itemMatches(item, query)),
|
|
809
|
+
[items, selectedIds, query]
|
|
810
|
+
);
|
|
811
|
+
const insert = (id) => {
|
|
812
|
+
const item = items.find((entry) => selectIdKey(entry.id) === selectIdKey(id));
|
|
813
|
+
if (!item || selectedIds.has(selectIdKey(item.id))) return;
|
|
814
|
+
selectedItems.append(item);
|
|
815
|
+
onItemInserted?.(item.id);
|
|
816
|
+
setQuery("");
|
|
817
|
+
};
|
|
818
|
+
const menuValue = useMemo(
|
|
819
|
+
() => ({ size, isSelected: () => false, onSelect: insert }),
|
|
820
|
+
[size, items, selectedItems]
|
|
821
|
+
);
|
|
822
|
+
return /* @__PURE__ */ jsx(SelectContext.Provider, { value: { size }, children: /* @__PURE__ */ jsx(SelectMenuContext.Provider, { value: menuValue, children: /* @__PURE__ */ jsxs(View, { className: cx("w-full gap-1.5", className), children: [
|
|
823
|
+
label ? /* @__PURE__ */ jsx(Label, { isRequired: Boolean(isRequired && !hideRequiredIndicator), isInvalid, children: label }) : null,
|
|
824
|
+
/* @__PURE__ */ jsxs(
|
|
825
|
+
View,
|
|
826
|
+
{
|
|
827
|
+
className: selectFieldClassName({
|
|
828
|
+
size,
|
|
829
|
+
focused,
|
|
830
|
+
isInvalid,
|
|
831
|
+
isDisabled,
|
|
832
|
+
className: cx("flex-wrap", size === "sm" && selectedItems.items.length > 0 && "py-1.5")
|
|
833
|
+
}),
|
|
834
|
+
children: [
|
|
835
|
+
icon !== null ? /* @__PURE__ */ jsx(SelectGlyph, { icon: icon ?? MagnifyingGlassIcon, size: sizes[size].icon, color: fgQuaternary }) : null,
|
|
836
|
+
/* @__PURE__ */ jsxs(View, { className: "min-w-0 flex-1 flex-row flex-wrap items-center gap-1.5", children: [
|
|
837
|
+
selectedItems.items.map((item) => /* @__PURE__ */ jsxs(
|
|
838
|
+
View,
|
|
839
|
+
{
|
|
840
|
+
className: cx(
|
|
841
|
+
"border-primary bg-primary max-w-full flex-row items-center rounded-md border",
|
|
842
|
+
size === "sm" ? "px-1 py-0.5" : "py-0.5 pr-1 pl-1.25"
|
|
843
|
+
),
|
|
844
|
+
children: [
|
|
845
|
+
/* @__PURE__ */ jsx(Avatar, { size: "xs", src: item.avatarUrl, alt: item.label, className: "size-4" }),
|
|
846
|
+
/* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-secondary font-medium", size === "sm" ? "ml-1 text-xs" : "ml-1.25 text-sm"), children: valueFormatter ? valueFormatter(item) : item.label }),
|
|
847
|
+
/* @__PURE__ */ jsx(
|
|
848
|
+
Pressable,
|
|
849
|
+
{
|
|
850
|
+
accessibilityRole: "button",
|
|
851
|
+
accessibilityLabel: "Remove",
|
|
852
|
+
disabled: isDisabled,
|
|
853
|
+
onPress: () => {
|
|
854
|
+
selectedItems.remove(item.id);
|
|
855
|
+
onItemCleared?.(item.id);
|
|
856
|
+
},
|
|
857
|
+
className: "ml-0.5 p-0.5",
|
|
858
|
+
children: /* @__PURE__ */ jsx(XIcon, { size: size === "sm" ? 12 : 14, color: fgSecondary })
|
|
859
|
+
}
|
|
860
|
+
)
|
|
861
|
+
]
|
|
862
|
+
},
|
|
863
|
+
selectIdKey(item.id)
|
|
864
|
+
)),
|
|
865
|
+
/* @__PURE__ */ jsx(
|
|
866
|
+
TextInput,
|
|
867
|
+
{
|
|
868
|
+
editable: !isDisabled,
|
|
869
|
+
value: query,
|
|
870
|
+
placeholder: selectedItems.items.length === 0 ? placeholder : "",
|
|
871
|
+
onChangeText: setQuery,
|
|
872
|
+
onFocus: () => setFocused(true),
|
|
873
|
+
onBlur: () => {
|
|
874
|
+
setTimeout(() => setFocused(false), 300);
|
|
875
|
+
},
|
|
876
|
+
placeholderTextColor: "#737373",
|
|
877
|
+
className: cx("text-primary min-w-12 flex-1", inputStyles.input, sizes[size].text),
|
|
878
|
+
style: { includeFontPadding: false, paddingVertical: 0 }
|
|
879
|
+
}
|
|
880
|
+
)
|
|
881
|
+
] })
|
|
882
|
+
]
|
|
883
|
+
}
|
|
884
|
+
),
|
|
885
|
+
/* @__PURE__ */ jsx(
|
|
886
|
+
Popover,
|
|
887
|
+
{
|
|
888
|
+
open: focused && rows.length > 0,
|
|
889
|
+
onClose: () => setFocused(false),
|
|
890
|
+
size,
|
|
891
|
+
mobileOptions: { title: label, ...mobileOptions, sheet: mobileOptions?.sheet ?? false },
|
|
892
|
+
className: popoverClassName,
|
|
893
|
+
children: rows.map((item) => /* @__PURE__ */ jsx(View, { children: children(item) }, selectIdKey(item.id)))
|
|
894
|
+
}
|
|
895
|
+
),
|
|
896
|
+
hint ? /* @__PURE__ */ jsx(HintText, { isInvalid, size, children: hint }) : null
|
|
897
|
+
] }) }) });
|
|
898
|
+
};
|
|
899
|
+
var TagSelect = Object.assign(TagSelectRoot, {
|
|
900
|
+
Item: SelectItem
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
export { TagSelect };
|
|
904
|
+
//# sourceMappingURL=tag-select.js.map
|
|
905
|
+
//# sourceMappingURL=tag-select.js.map
|