@avenue-ticketing/native 0.1.4 → 0.1.6

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 ADDED
@@ -0,0 +1,1063 @@
1
+ import { createContext, useState, useContext, useRef, useMemo, isValidElement, useEffect } from 'react';
2
+ import { View, Pressable, Text, TextInput, ScrollView } from 'react-native-css/components';
3
+ import { useNativeVariable } from 'react-native-css';
4
+ import { CaretDownIcon } from 'phosphor-react-native/src/icons/CaretDown';
5
+ import { extendTailwindMerge } from 'tailwind-merge';
6
+ import 'phosphor-react-native/src/icons/Eye';
7
+ import 'phosphor-react-native/src/icons/EyeSlash';
8
+ import 'phosphor-react-native/src/icons/Info';
9
+ import 'phosphor-react-native/src/icons/Question';
10
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
11
+ import { Image, useWindowDimensions, Modal } from 'react-native';
12
+ import Svg, { Path } from 'react-native-svg';
13
+ import { styled } from 'nativewind';
14
+ import { UserIcon } from 'phosphor-react-native/src/icons/User';
15
+ import { MagnifyingGlassIcon } from 'phosphor-react-native/src/icons/MagnifyingGlass';
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 { XIcon } from 'phosphor-react-native/src/icons/X';
19
+ import { CheckIcon } from 'phosphor-react-native/src/icons/Check';
20
+
21
+ // ../../native/components/base/select/select.tsx
22
+ var twMerge = extendTailwindMerge({
23
+ extend: {
24
+ theme: {
25
+ text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
26
+ }
27
+ }
28
+ });
29
+ var cx = twMerge;
30
+ function sortCx(classes) {
31
+ return classes;
32
+ }
33
+
34
+ // ../core/src/input.ts
35
+ var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
36
+ var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
37
+ var inputStyles = sortCx({
38
+ stack: "w-full flex-col items-start justify-start gap-1.5",
39
+ labelRow: "flex-row items-center gap-0.5",
40
+ label: "text-sm font-medium text-secondary",
41
+ required: "text-brand-tertiary",
42
+ requiredInvalid: "text-error-primary",
43
+ hint: "text-sm text-tertiary",
44
+ hintSm: "text-xs",
45
+ hintInvalid: "text-error-primary",
46
+ field: {
47
+ root: "relative isolate w-full flex-row items-center rounded-lg border border-solid border-primary bg-primary shadow-xs",
48
+ /** Web: focus-within:border-brand + inset ring-1 ring-brand (2px visual, no layout shift). */
49
+ focus: inputFocusRingShadow,
50
+ invalid: "border-error_subtle",
51
+ invalidFocus: inputErrorFocusRingShadow,
52
+ disabled: "opacity-50"
53
+ },
54
+ input: "m-0 min-w-0 flex-1 bg-transparent text-primary placeholder:text-placeholder",
55
+ iconLeading: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
56
+ iconTrailing: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
57
+ iconInvalid: "absolute inset-y-0 items-center justify-center text-fg-error-secondary",
58
+ sizes: {
59
+ sm: {
60
+ field: "min-h-9",
61
+ input: "px-3 py-2 text-sm",
62
+ inputLeading: "pl-9",
63
+ inputTrailing: "pr-9",
64
+ iconLeading: "left-3 w-4",
65
+ iconTrailing: "right-3 w-4",
66
+ iconPx: 16,
67
+ shortcut: "pr-1.5"
68
+ },
69
+ md: {
70
+ field: "min-h-10",
71
+ input: "px-3 py-2 text-md",
72
+ inputLeading: "pl-10",
73
+ inputTrailing: "pr-9",
74
+ iconLeading: "left-3 w-5",
75
+ iconTrailing: "right-3 w-4",
76
+ iconPx: 20,
77
+ shortcut: "pr-2"
78
+ },
79
+ lg: {
80
+ field: "min-h-11",
81
+ input: "px-3.5 py-2.5 text-md",
82
+ inputLeading: "pl-10.5",
83
+ inputTrailing: "pr-9.5",
84
+ iconLeading: "left-3.5 w-5",
85
+ iconTrailing: "right-3.5 w-4",
86
+ iconPx: 20,
87
+ shortcut: "pr-2.5"
88
+ }
89
+ }
90
+ });
91
+ createContext(null);
92
+ createContext(null);
93
+ var Label = ({ children, isRequired, isInvalid, className }) => {
94
+ return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.labelRow, className), children: [
95
+ /* @__PURE__ */ jsx(Text, { className: inputStyles.label, children }),
96
+ isRequired && /* @__PURE__ */ jsx(Text, { className: isInvalid ? inputStyles.requiredInvalid : inputStyles.required, children: "*" })
97
+ ] });
98
+ };
99
+ var HintText = ({ children, isInvalid, size, className }) => {
100
+ if (children == null || children === false) return null;
101
+ if (typeof children !== "string" && typeof children !== "number") {
102
+ return /* @__PURE__ */ jsx(Fragment, { children });
103
+ }
104
+ return /* @__PURE__ */ jsx(
105
+ Text,
106
+ {
107
+ className: cx(
108
+ inputStyles.hint,
109
+ size === "sm" && inputStyles.hintSm,
110
+ isInvalid && inputStyles.hintInvalid,
111
+ className
112
+ ),
113
+ children
114
+ }
115
+ );
116
+ };
117
+
118
+ // ../core/src/avatar.ts
119
+ var avatarStyles = sortCx({
120
+ root: "relative shrink-0 rounded-[7px]",
121
+ rootRounded: "rounded-full",
122
+ rootBorder: "ring-1 ring-secondary_alt",
123
+ content: "relative size-full shrink-0 items-center justify-center overflow-hidden rounded-md bg-tertiary",
124
+ contentRounded: "rounded-full",
125
+ initials: "text-quaternary",
126
+ icon: "text-fg-quaternary",
127
+ sizes: {
128
+ xs: { root: "size-6", rootWithBorder: "p-px", initials: "text-xs font-semibold", icon: "size-4" },
129
+ sm: { root: "size-8", rootWithBorder: "p-px", initials: "text-sm font-semibold", icon: "size-5" },
130
+ md: { root: "size-10", rootWithBorder: "p-px", initials: "text-md font-semibold", icon: "size-6" },
131
+ lg: { root: "size-12", rootWithBorder: "p-[1.5px]", initials: "text-lg font-semibold", icon: "size-7" },
132
+ xl: { root: "size-14", rootWithBorder: "p-0.5", initials: "text-xl font-semibold", icon: "size-8" },
133
+ "2xl": { root: "size-16", rootWithBorder: "p-0.5", initials: "text-display-xs font-semibold", icon: "size-8" }
134
+ }
135
+ });
136
+ var AVATAR_SIZE_PX = {
137
+ xs: 24,
138
+ sm: 32,
139
+ md: 40,
140
+ lg: 48,
141
+ xl: 56,
142
+ "2xl": 64
143
+ };
144
+ var AVATAR_ICON_SIZE_PX = {
145
+ xs: 16,
146
+ sm: 20,
147
+ md: 24,
148
+ lg: 28,
149
+ xl: 32,
150
+ "2xl": 32
151
+ };
152
+ var AVATAR_INITIALS_LINE_HEIGHT_PX = {
153
+ xs: 18,
154
+ sm: 20,
155
+ md: 24,
156
+ lg: 28,
157
+ xl: 30,
158
+ "2xl": 32
159
+ };
160
+ var avatarOnlineIndicatorStyles = sortCx({
161
+ root: "absolute right-0 bottom-0 rounded-full ring-[1.5px] ring-bg-primary",
162
+ online: "bg-fg-success-secondary",
163
+ offline: "bg-utility-neutral-300",
164
+ sizes: {
165
+ xs: "size-1.5",
166
+ sm: "size-2",
167
+ md: "size-2.5",
168
+ lg: "size-3",
169
+ xl: "size-3.5",
170
+ "2xl": "size-4"
171
+ }
172
+ });
173
+ var avatarVerifiedStyles = sortCx({
174
+ root: "absolute right-0 bottom-0 z-10 text-utility-blue-500",
175
+ xsOffset: "-right-px -bottom-px",
176
+ sizes: {
177
+ xs: "size-2.5",
178
+ sm: "size-3",
179
+ md: "size-3.5",
180
+ lg: "size-4",
181
+ xl: "size-4.5",
182
+ "2xl": "size-5"
183
+ }
184
+ });
185
+ var AVATAR_VERIFIED_SIZE_PX = {
186
+ xs: 10,
187
+ sm: 12,
188
+ md: 14,
189
+ lg: 16,
190
+ xl: 18,
191
+ "2xl": 20
192
+ };
193
+ var avatarCountStyles = sortCx({
194
+ root: "absolute right-0 bottom-0 p-px",
195
+ badge: "size-3.5 items-center justify-center rounded-full bg-fg-error-primary",
196
+ label: "text-center text-[10px] font-bold text-white"
197
+ });
198
+ var AVATAR_COUNT_LABEL_LINE_HEIGHT_PX = 13;
199
+ var StyledSvg = styled(Svg);
200
+ var AvatarOnlineIndicator = ({ size, status, className }) => {
201
+ return /* @__PURE__ */ jsx(
202
+ View,
203
+ {
204
+ className: cx(
205
+ avatarOnlineIndicatorStyles.root,
206
+ status === "online" ? avatarOnlineIndicatorStyles.online : avatarOnlineIndicatorStyles.offline,
207
+ avatarOnlineIndicatorStyles.sizes[size],
208
+ className
209
+ )
210
+ }
211
+ );
212
+ };
213
+ var VerifiedTick = ({ size, className }) => {
214
+ const px = AVATAR_VERIFIED_SIZE_PX[size];
215
+ return /* @__PURE__ */ jsxs(
216
+ StyledSvg,
217
+ {
218
+ width: px,
219
+ height: px,
220
+ viewBox: "0 0 10 10",
221
+ className: cx(avatarVerifiedStyles.root, size === "xs" && avatarVerifiedStyles.xsOffset, avatarVerifiedStyles.sizes[size], className),
222
+ children: [
223
+ /* @__PURE__ */ jsx(
224
+ Path,
225
+ {
226
+ 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",
227
+ fill: "currentColor"
228
+ }
229
+ ),
230
+ /* @__PURE__ */ jsx(
231
+ Path,
232
+ {
233
+ fillRule: "evenodd",
234
+ clipRule: "evenodd",
235
+ 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",
236
+ fill: "white"
237
+ }
238
+ )
239
+ ]
240
+ }
241
+ );
242
+ };
243
+ var AvatarCount = ({ count, className }) => {
244
+ return /* @__PURE__ */ jsx(View, { className: cx(avatarCountStyles.root, className), children: /* @__PURE__ */ jsx(View, { className: cx("flex-row", avatarCountStyles.badge), children: /* @__PURE__ */ jsx(
245
+ Text,
246
+ {
247
+ style: { includeFontPadding: false, lineHeight: AVATAR_COUNT_LABEL_LINE_HEIGHT_PX },
248
+ className: avatarCountStyles.label,
249
+ children: count
250
+ }
251
+ ) }) });
252
+ };
253
+ var Avatar = ({
254
+ size = "md",
255
+ src,
256
+ alt,
257
+ initials,
258
+ placeholder,
259
+ placeholderIcon: PlaceholderIcon,
260
+ border,
261
+ badge,
262
+ status,
263
+ verified,
264
+ count,
265
+ rounded = true,
266
+ className,
267
+ contentClassName
268
+ }) => {
269
+ const [isFailed, setIsFailed] = useState(false);
270
+ const canShowImage = Boolean(src && !isFailed);
271
+ const sizeStyles = avatarStyles.sizes[size];
272
+ const px = AVATAR_SIZE_PX[size];
273
+ const iconPx = AVATAR_ICON_SIZE_PX[size];
274
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
275
+ const renderMainContent = () => {
276
+ if (canShowImage && src) {
277
+ return /* @__PURE__ */ jsx(
278
+ Image,
279
+ {
280
+ source: { uri: src },
281
+ accessibilityLabel: alt,
282
+ onError: () => setIsFailed(true),
283
+ style: { width: "100%", height: "100%" },
284
+ resizeMode: "cover"
285
+ }
286
+ );
287
+ }
288
+ if (initials) {
289
+ return /* @__PURE__ */ jsx(
290
+ Text,
291
+ {
292
+ style: { includeFontPadding: false, lineHeight: AVATAR_INITIALS_LINE_HEIGHT_PX[size] },
293
+ className: cx(avatarStyles.initials, sizeStyles.initials),
294
+ children: initials
295
+ }
296
+ );
297
+ }
298
+ if (PlaceholderIcon) {
299
+ return /* @__PURE__ */ jsx(PlaceholderIcon, { size: iconPx, color: fgQuaternary });
300
+ }
301
+ if (placeholder) return /* @__PURE__ */ jsx(Fragment, { children: placeholder });
302
+ return /* @__PURE__ */ jsx(UserIcon, { size: iconPx, color: fgQuaternary });
303
+ };
304
+ const renderBadgeContent = () => {
305
+ if (status) return /* @__PURE__ */ jsx(AvatarOnlineIndicator, { status, size });
306
+ if (verified) return /* @__PURE__ */ jsx(VerifiedTick, { size });
307
+ if (count) return /* @__PURE__ */ jsx(AvatarCount, { count });
308
+ return badge ?? null;
309
+ };
310
+ return /* @__PURE__ */ jsxs(
311
+ View,
312
+ {
313
+ className: cx(
314
+ avatarStyles.root,
315
+ rounded && avatarStyles.rootRounded,
316
+ border && avatarStyles.rootBorder,
317
+ border && sizeStyles.rootWithBorder,
318
+ sizeStyles.root,
319
+ className
320
+ ),
321
+ style: { width: px, height: px },
322
+ children: [
323
+ /* @__PURE__ */ jsx(
324
+ View,
325
+ {
326
+ className: cx(
327
+ "flex-row",
328
+ avatarStyles.content,
329
+ rounded && avatarStyles.contentRounded,
330
+ contentClassName
331
+ ),
332
+ children: renderMainContent()
333
+ }
334
+ ),
335
+ renderBadgeContent()
336
+ ]
337
+ }
338
+ );
339
+ };
340
+
341
+ // ../core/src/dialog.ts
342
+ var DIALOG_SHEET_MOTION_MS = 175;
343
+ var DIALOG_SLIDE_OFFSET_PX = 120;
344
+ var DIALOG_ENTRY_EASING_BEZIER = [0.85, 0, 0.15, 1];
345
+ var DIALOG_EXIT_EASING_BEZIER = [0.85, 0, 1, 0.15];
346
+ var DIALOG_SHEET_RADIUS_PX = 16;
347
+ var dialogStyles = sortCx({
348
+ root: "flex",
349
+ rootFull: "h-full w-full flex-col bg-primary",
350
+ rootSheet: "flex-col justify-end",
351
+ rootModal: "flex-col items-center justify-center p-4",
352
+ overlay: "absolute inset-0 bg-overlay/70",
353
+ panel: "relative z-10 w-full overflow-hidden bg-primary",
354
+ panelElevated: "shadow-xl",
355
+ panelFull: "flex min-h-0 flex-1 flex-col",
356
+ /**
357
+ * Web sheet chrome (≤1024). Native pins the same chrome with RN layout styles
358
+ * (`DIALOG_SHEET_RADIUS_PX` + token colors) because NativeWind border/radius
359
+ * on sheets leave side gaps and bottom transparency.
360
+ */
361
+ 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",
362
+ panelModal: "w-full rounded-2xl border border-solid border-secondary",
363
+ sizes: {
364
+ sm: "max-w-sm",
365
+ md: "max-w-md",
366
+ lg: "max-w-lg",
367
+ xl: "max-w-xl"
368
+ },
369
+ sizesLgOnly: {
370
+ sm: "lg:max-w-sm",
371
+ md: "lg:max-w-md",
372
+ lg: "lg:max-w-lg",
373
+ xl: "lg:max-w-xl"
374
+ },
375
+ sizesSmUp: {
376
+ sm: "sm:max-w-sm",
377
+ md: "sm:max-w-md",
378
+ lg: "sm:max-w-lg",
379
+ xl: "sm:max-w-xl"
380
+ },
381
+ header: "flex-col gap-1.5 p-6 pr-14",
382
+ headerFixed: "border-b border-solid border-secondary bg-primary",
383
+ footer: "flex-col-reverse gap-2 p-6",
384
+ footerFixed: "border-t border-solid border-secondary bg-primary",
385
+ title: "text-xl font-semibold text-primary",
386
+ description: "text-sm text-tertiary",
387
+ close: "size-12 items-center justify-center rounded-full bg-primary active:scale-[0.96] active:bg-primary_hover",
388
+ closePosition: "absolute top-4 right-4 z-20"
389
+ });
390
+
391
+ // ../core/src/select.ts
392
+ var sizes = {
393
+ sm: { root: "gap-2 py-2 pr-2.5 pl-3", text: "text-sm", icon: 16, textGap: "gap-x-1.5" },
394
+ md: { root: "gap-2 px-3 py-2", text: "text-md", icon: 20, textGap: "gap-x-1.5" },
395
+ lg: { root: "gap-2 px-3.5 py-2.5", text: "text-md", icon: 20, textGap: "gap-x-1.5" }
396
+ };
397
+ var itemSizes = {
398
+ sm: { root: "gap-2 p-2 pr-2.5", text: "text-sm", icon: 16, textGap: "gap-x-1.5", check: 16, checkbox: "sm" },
399
+ md: { root: "gap-2 p-2 pr-2.5", text: "text-md", icon: 20, textGap: "gap-x-2", check: 20, checkbox: "sm" },
400
+ 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" }
401
+ };
402
+ var searchSizes = {
403
+ sm: { wrapper: "py-1", root: "gap-2 px-3 py-2", text: "text-sm" },
404
+ md: { wrapper: "py-0.5", root: "gap-2 px-3 py-2", text: "text-md" },
405
+ lg: { wrapper: "py-0.5", root: "gap-2 px-3.5 py-2.5", text: "text-md" }
406
+ };
407
+ var menuMaxHeight = {
408
+ sm: "max-h-56",
409
+ md: "max-h-64",
410
+ lg: "max-h-80"
411
+ };
412
+ function resolveSelectMobileOptions(mobileOptions) {
413
+ const fullScreen = mobileOptions?.fullScreen ?? false;
414
+ return {
415
+ sheet: mobileOptions?.sheet ?? true,
416
+ fullScreen,
417
+ overlay: fullScreen ? false : mobileOptions?.overlay ?? true,
418
+ title: mobileOptions?.title,
419
+ sheetClassName: mobileOptions?.className,
420
+ contentClassName: mobileOptions?.contentClassName
421
+ };
422
+ }
423
+ function selectIdKey(id) {
424
+ return String(id);
425
+ }
426
+ function itemText(item) {
427
+ return item.supportingText ? `${item.label ?? ""} ${item.supportingText}` : item.label ?? "";
428
+ }
429
+ function itemMatches(item, query) {
430
+ const needle = query.trim().toLowerCase();
431
+ if (!needle) return true;
432
+ return itemText(item).toLowerCase().includes(needle);
433
+ }
434
+ function selectFieldClassName(options) {
435
+ return cx(
436
+ "bg-primary w-full flex-row items-center rounded-lg border border-solid shadow-xs",
437
+ sizes[options.size].root,
438
+ options.isDisabled && "opacity-50",
439
+ options.isInvalid && options.focused && inputErrorFocusRingShadow,
440
+ options.isInvalid && !options.focused && "border-error_subtle",
441
+ !options.isInvalid && options.focused && inputFocusRingShadow,
442
+ !options.isInvalid && !options.focused && "border-primary",
443
+ options.className
444
+ );
445
+ }
446
+
447
+ // ../core/src/is-react-component.ts
448
+ var isFunctionComponent = (component) => {
449
+ return typeof component === "function";
450
+ };
451
+ var isClassComponent = (component) => {
452
+ return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
453
+ };
454
+ var isForwardRefComponent = (component) => {
455
+ return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
456
+ };
457
+ var isReactComponent = (component) => {
458
+ return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
459
+ };
460
+ var SelectMenuContext = createContext(null);
461
+ var SelectContext = createContext({ size: "md" });
462
+ var SelectGlyph = ({ icon, size, color }) => {
463
+ if (isReactComponent(icon)) {
464
+ const Icon = icon;
465
+ return /* @__PURE__ */ jsx(Icon, { size, color });
466
+ }
467
+ if (isValidElement(icon)) return icon;
468
+ return null;
469
+ };
470
+ var ENTRY = Easing.bezier(...DIALOG_ENTRY_EASING_BEZIER);
471
+ var EXIT = Easing.bezier(...DIALOG_EXIT_EASING_BEZIER);
472
+ var overlayEntering = FadeIn.duration(DIALOG_SHEET_MOTION_MS).easing(ENTRY);
473
+ var overlayExiting = FadeOut.duration(DIALOG_SHEET_MOTION_MS).easing(EXIT);
474
+ var panelEntering = FadeInDown.duration(DIALOG_SHEET_MOTION_MS).easing(ENTRY).withInitialValues({ opacity: 0, transform: [{ translateY: DIALOG_SLIDE_OFFSET_PX }] });
475
+ var panelExiting = FadeOutDown.duration(DIALOG_SHEET_MOTION_MS).easing(EXIT).withTargetValues({ opacity: 0, transform: [{ translateY: DIALOG_SLIDE_OFFSET_PX }] });
476
+ function useSheetPresence(open) {
477
+ const [shouldRender, setShouldRender] = useState(open);
478
+ useEffect(() => {
479
+ if (open) {
480
+ setShouldRender(true);
481
+ return;
482
+ }
483
+ const hide = setTimeout(() => setShouldRender(false), DIALOG_SHEET_MOTION_MS);
484
+ return () => clearTimeout(hide);
485
+ }, [open]);
486
+ return shouldRender;
487
+ }
488
+ function overlayFill(color) {
489
+ const hex = /^#([\da-f]{6})$/i.exec(color);
490
+ if (!hex) return "rgba(10, 13, 18, 0.7)";
491
+ const value = parseInt(hex[1], 16);
492
+ return `rgba(${value >> 16 & 255}, ${value >> 8 & 255}, ${value & 255}, 0.7)`;
493
+ }
494
+ var HEADER_HEIGHT = 56;
495
+ var Popover = ({
496
+ open,
497
+ onClose,
498
+ size = "md",
499
+ mobileOptions,
500
+ compound = false,
501
+ className,
502
+ children
503
+ }) => {
504
+ const resolved = resolveSelectMobileOptions(mobileOptions);
505
+ if (!resolved.sheet) {
506
+ if (!open) return null;
507
+ return /* @__PURE__ */ jsx(
508
+ View,
509
+ {
510
+ className: cx(
511
+ "bg-primary overflow-hidden rounded-lg shadow-lg ring-1 ring-secondary_alt",
512
+ !compound && "py-1",
513
+ !compound && menuMaxHeight[size],
514
+ className
515
+ ),
516
+ children: compound ? children : /* @__PURE__ */ jsx(ScrollView, { keyboardShouldPersistTaps: "handled", nestedScrollEnabled: true, children })
517
+ }
518
+ );
519
+ }
520
+ return /* @__PURE__ */ jsx(
521
+ SelectSheet,
522
+ {
523
+ open,
524
+ onClose,
525
+ title: resolved.title,
526
+ fullScreen: resolved.fullScreen,
527
+ overlay: resolved.overlay,
528
+ className: cx(resolved.sheetClassName, resolved.contentClassName, className),
529
+ children
530
+ }
531
+ );
532
+ };
533
+ var SelectSheet = ({ open, onClose, title, fullScreen, overlay, className, children }) => {
534
+ const insets = useSafeAreaInsets();
535
+ const { width: windowWidth, height: windowHeight } = useWindowDimensions();
536
+ const shouldRender = useSheetPresence(open);
537
+ const fgPrimary = useNativeVariable("--color-fg-primary") ?? "#181d27";
538
+ const bgPrimary = useNativeVariable("--color-bg-primary") ?? "#ffffff";
539
+ const borderSecondary = useNativeVariable("--color-border-secondary") ?? "#e9eaeb";
540
+ const overlayColor = useNativeVariable("--color-bg-overlay") ?? "#0a0d12";
541
+ const sheetMax = fullScreen ? windowHeight : Math.round(windowHeight * 0.9);
542
+ const listMax = Math.max(0, sheetMax - HEADER_HEIGHT - (fullScreen ? insets.top : insets.bottom));
543
+ 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: [
544
+ 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,
545
+ open ? /* @__PURE__ */ jsxs(
546
+ Animated.View,
547
+ {
548
+ collapsable: false,
549
+ entering: panelEntering,
550
+ exiting: panelExiting,
551
+ style: fullScreen ? {
552
+ flex: 1,
553
+ width: windowWidth,
554
+ backgroundColor: bgPrimary,
555
+ paddingBottom: 12
556
+ } : {
557
+ position: "absolute",
558
+ left: 0,
559
+ right: 0,
560
+ bottom: 0,
561
+ width: windowWidth,
562
+ maxHeight: sheetMax,
563
+ zIndex: 10,
564
+ overflow: "hidden",
565
+ backgroundColor: bgPrimary,
566
+ borderTopLeftRadius: DIALOG_SHEET_RADIUS_PX,
567
+ borderTopRightRadius: DIALOG_SHEET_RADIUS_PX,
568
+ borderBottomLeftRadius: 0,
569
+ borderBottomRightRadius: 0,
570
+ borderTopWidth: 1,
571
+ borderLeftWidth: 0,
572
+ borderRightWidth: 0,
573
+ borderBottomWidth: 0,
574
+ borderTopColor: borderSecondary,
575
+ paddingBottom: insets.bottom
576
+ },
577
+ children: [
578
+ fullScreen ? /* @__PURE__ */ jsx(View, { style: { height: insets.top } }) : null,
579
+ /* @__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: [
580
+ title ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: "text-primary min-w-0 flex-1 text-base font-semibold", children: title }) : null,
581
+ /* @__PURE__ */ jsx(
582
+ Pressable,
583
+ {
584
+ accessibilityRole: "button",
585
+ accessibilityLabel: "Close",
586
+ onPress: onClose,
587
+ className: "size-12 items-center justify-center rounded-full active:bg-primary_hover",
588
+ children: /* @__PURE__ */ jsx(XIcon, { size: 20, color: fgPrimary })
589
+ }
590
+ )
591
+ ] }),
592
+ /* @__PURE__ */ jsx(
593
+ ScrollView,
594
+ {
595
+ keyboardShouldPersistTaps: "handled",
596
+ style: fullScreen ? { flex: 1 } : { flexGrow: 0, flexShrink: 0, maxHeight: listMax },
597
+ children: /* @__PURE__ */ jsx(View, { className: cx("py-1", className), children })
598
+ }
599
+ )
600
+ ]
601
+ }
602
+ ) : null
603
+ ] }) });
604
+ };
605
+ function visibleItems(items, query, defaultFilter) {
606
+ if (!defaultFilter) return items.filter((item) => itemMatches(item, query));
607
+ return items.filter((item) => defaultFilter(itemText(item), query));
608
+ }
609
+ var ComboBox = ({
610
+ size = "md",
611
+ label,
612
+ placeholder = "Search",
613
+ hint,
614
+ icon,
615
+ items = [],
616
+ inputValue = "",
617
+ allowsCustomValue = false,
618
+ isDisabled,
619
+ isInvalid,
620
+ isRequired,
621
+ hideRequiredIndicator,
622
+ autoComplete,
623
+ textContentType,
624
+ inputClassName,
625
+ popoverClassName,
626
+ mobileOptions,
627
+ defaultFilter,
628
+ onInputChange,
629
+ onSelectionChange,
630
+ onFocus,
631
+ onBlur,
632
+ children
633
+ }) => {
634
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
635
+ const resolved = resolveSelectMobileOptions({ title: label, ...mobileOptions });
636
+ const blurTimer = useRef(null);
637
+ const [focused, setFocused] = useState(false);
638
+ const [open, setOpen] = useState(false);
639
+ const [pickedId, setPickedId] = useState(null);
640
+ const [pickedValue, setPickedValue] = useState(null);
641
+ const [sheetQuery, setSheetQuery] = useState(inputValue);
642
+ const query = resolved.sheet ? sheetQuery : inputValue;
643
+ const rows = useMemo(() => visibleItems(items, query, defaultFilter), [items, query, defaultFilter]);
644
+ const picked = items.find((item) => item.id === pickedId) ?? null;
645
+ const showFloating = !resolved.sheet && open && focused && rows.length > 0 && inputValue.trim() !== pickedValue;
646
+ const selectItem = (id) => {
647
+ const item = items.find((entry) => selectIdKey(entry.id) === selectIdKey(id));
648
+ const next = item?.label ?? query;
649
+ setPickedId(id);
650
+ setPickedValue(next.trim());
651
+ setOpen(false);
652
+ setFocused(false);
653
+ if (resolved.sheet) setSheetQuery(next);
654
+ if (next !== inputValue) onInputChange?.(next);
655
+ onSelectionChange?.(id);
656
+ };
657
+ const menuValue = {
658
+ size,
659
+ isSelected: (id) => pickedId != null && selectIdKey(pickedId) === selectIdKey(id),
660
+ onSelect: selectItem,
661
+ selectOnPressIn: !resolved.sheet
662
+ };
663
+ const list = rows.map((item) => /* @__PURE__ */ jsx(View, { children: children(item) }, selectIdKey(item.id)));
664
+ return /* @__PURE__ */ jsx(SelectContext.Provider, { value: { size }, children: /* @__PURE__ */ jsx(SelectMenuContext.Provider, { value: menuValue, children: /* @__PURE__ */ jsxs(View, { className: "w-full gap-1.5", children: [
665
+ label ? /* @__PURE__ */ jsx(Label, { isRequired: Boolean(isRequired && !hideRequiredIndicator), isInvalid, children: label }) : null,
666
+ resolved.sheet ? /* @__PURE__ */ jsx(
667
+ SheetTrigger,
668
+ {
669
+ size,
670
+ placeholder,
671
+ icon,
672
+ item: picked,
673
+ customValue: allowsCustomValue ? inputValue : "",
674
+ isDisabled,
675
+ isInvalid,
676
+ focused: open,
677
+ color: fgQuaternary,
678
+ onPress: () => {
679
+ if (isDisabled) return;
680
+ setSheetQuery(inputValue);
681
+ setOpen(true);
682
+ onFocus?.();
683
+ }
684
+ }
685
+ ) : /* @__PURE__ */ jsx(
686
+ FloatingField,
687
+ {
688
+ size,
689
+ placeholder,
690
+ icon,
691
+ value: inputValue,
692
+ isDisabled,
693
+ isInvalid,
694
+ focused,
695
+ autoComplete,
696
+ textContentType,
697
+ inputClassName,
698
+ color: fgQuaternary,
699
+ onChangeText: (next) => {
700
+ if (next.trim() !== pickedValue) {
701
+ setPickedValue(null);
702
+ setPickedId(null);
703
+ }
704
+ setOpen(true);
705
+ onInputChange?.(next);
706
+ },
707
+ onFocus: () => {
708
+ if (blurTimer.current) clearTimeout(blurTimer.current);
709
+ setFocused(true);
710
+ setOpen(true);
711
+ onFocus?.();
712
+ },
713
+ onBlur: () => {
714
+ onBlur?.();
715
+ blurTimer.current = setTimeout(() => {
716
+ setFocused(false);
717
+ setOpen(false);
718
+ if (!allowsCustomValue && pickedValue != null && inputValue.trim() !== pickedValue) {
719
+ onInputChange?.(pickedValue);
720
+ }
721
+ }, 300);
722
+ }
723
+ }
724
+ ),
725
+ /* @__PURE__ */ jsx(
726
+ Popover,
727
+ {
728
+ open: resolved.sheet ? open : showFloating,
729
+ onClose: () => {
730
+ setOpen(false);
731
+ onBlur?.();
732
+ },
733
+ size,
734
+ mobileOptions: { title: label, ...mobileOptions, sheet: resolved.sheet },
735
+ className: popoverClassName,
736
+ compound: resolved.sheet,
737
+ children: resolved.sheet ? /* @__PURE__ */ jsxs(View, { children: [
738
+ /* @__PURE__ */ jsx(View, { className: cx("border-secondary border-b", searchSizes[size].wrapper), children: /* @__PURE__ */ jsxs(View, { className: cx("flex-row items-center", searchSizes[size].root), children: [
739
+ /* @__PURE__ */ jsx(SelectGlyph, { icon: icon ?? MagnifyingGlassIcon, size: sizes[size].icon, color: fgQuaternary }),
740
+ /* @__PURE__ */ jsx(
741
+ TextInput,
742
+ {
743
+ value: sheetQuery,
744
+ placeholder,
745
+ onChangeText: (next) => {
746
+ setSheetQuery(next);
747
+ onInputChange?.(next);
748
+ },
749
+ placeholderTextColor: "#737373",
750
+ className: cx("text-primary min-w-0 flex-1", inputStyles.input, searchSizes[size].text),
751
+ style: { includeFontPadding: false, paddingVertical: 0 }
752
+ }
753
+ )
754
+ ] }) }),
755
+ list
756
+ ] }) : list
757
+ }
758
+ ),
759
+ hint ? /* @__PURE__ */ jsx(HintText, { isInvalid, size, children: hint }) : null
760
+ ] }) }) });
761
+ };
762
+ var FloatingField = ({
763
+ size,
764
+ placeholder,
765
+ icon,
766
+ value,
767
+ isDisabled,
768
+ isInvalid,
769
+ focused,
770
+ autoComplete,
771
+ textContentType,
772
+ inputClassName,
773
+ color,
774
+ onChangeText,
775
+ onFocus,
776
+ onBlur
777
+ }) => /* @__PURE__ */ jsxs(View, { className: selectFieldClassName({ size, focused, isInvalid, isDisabled }), children: [
778
+ /* @__PURE__ */ jsx(SelectGlyph, { icon: icon ?? MagnifyingGlassIcon, size: sizes[size].icon, color }),
779
+ /* @__PURE__ */ jsx(
780
+ TextInput,
781
+ {
782
+ editable: !isDisabled,
783
+ value,
784
+ placeholder,
785
+ autoComplete,
786
+ textContentType,
787
+ onChangeText,
788
+ onFocus,
789
+ onBlur,
790
+ placeholderTextColor: "#737373",
791
+ className: cx("text-primary min-w-0 flex-1 font-medium", inputStyles.input, sizes[size].text, inputClassName),
792
+ style: { includeFontPadding: false, paddingVertical: 0 }
793
+ }
794
+ )
795
+ ] });
796
+ var SheetTrigger = ({ size, placeholder, icon, item, customValue, isDisabled, isInvalid, focused, color, onPress }) => /* @__PURE__ */ jsxs(
797
+ Pressable,
798
+ {
799
+ accessibilityRole: "button",
800
+ disabled: isDisabled,
801
+ onPress,
802
+ className: selectFieldClassName({ size, focused, isInvalid, isDisabled }),
803
+ children: [
804
+ /* @__PURE__ */ jsx(SelectGlyph, { icon: item?.icon ?? icon ?? MagnifyingGlassIcon, size: sizes[size].icon, color }),
805
+ /* @__PURE__ */ jsx(View, { className: cx("min-w-0 flex-1 flex-row flex-wrap", sizes[size].textGap), children: item?.label || customValue ? /* @__PURE__ */ jsxs(Fragment, { children: [
806
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-primary font-medium", sizes[size].text), children: item?.label || customValue }),
807
+ item?.supportingText ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-tertiary", sizes[size].text), children: item.supportingText }) : null
808
+ ] }) : /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-placeholder", sizes[size].text), children: placeholder }) }),
809
+ /* @__PURE__ */ jsx(CaretDownIcon, { size: size === "lg" ? 20 : 16, color })
810
+ ]
811
+ }
812
+ );
813
+
814
+ // ../core/src/checkbox.ts
815
+ var checkboxStyles = sortCx({
816
+ base: {
817
+ root: "relative shrink-0 items-center justify-center overflow-hidden border border-solid border-primary",
818
+ rootUnchecked: "bg-primary",
819
+ rootChecked: "border-transparent bg-brand-solid",
820
+ rootDisabled: "opacity-50",
821
+ rootDisabledUnchecked: "bg-tertiary",
822
+ icon: "text-fg-white"
823
+ },
824
+ sizes: {
825
+ sm: {
826
+ root: "size-4 rounded-xs",
827
+ stack: "gap-2",
828
+ textWrapper: "",
829
+ label: "text-sm font-medium",
830
+ hint: "text-sm",
831
+ baseOffset: "mt-0.5"
832
+ },
833
+ md: {
834
+ root: "size-5 rounded-sm",
835
+ stack: "gap-3",
836
+ textWrapper: "gap-0.5",
837
+ label: "text-md font-medium",
838
+ hint: "text-md",
839
+ baseOffset: "mt-0.5"
840
+ }
841
+ },
842
+ /** Label + hint stack beside the control. */
843
+ stack: "relative flex-row items-start",
844
+ label: "text-secondary",
845
+ hint: "text-tertiary"
846
+ });
847
+ var CHECKBOX_ICON_PX = {
848
+ sm: 10,
849
+ md: 14
850
+ };
851
+ function resolveCheckboxIconPx(size) {
852
+ return CHECKBOX_ICON_PX[size];
853
+ }
854
+ var CHECKBOX_TICK_DELAY_MS = 60;
855
+ var CHECKBOX_TICK_DRAW_MS = 100;
856
+ var CHECKBOX_CHECK_PATH = "M2.33325 7L5.24992 9.91667L11.6666 3.5";
857
+ var CHECKBOX_CHECK_PATH_LENGTH = 13.21;
858
+ var CHECKBOX_INDETERMINATE_PATH = "M2.91675 7H11.0834";
859
+ var CHECKBOX_TICK_EASING = [0.45, 0, 0.2, 1];
860
+ var StyledSvg2 = styled(Svg);
861
+ var AnimatedPath = Animated.createAnimatedComponent(Path);
862
+ var tickEasing = Easing.bezier(
863
+ CHECKBOX_TICK_EASING[0],
864
+ CHECKBOX_TICK_EASING[1],
865
+ CHECKBOX_TICK_EASING[2],
866
+ CHECKBOX_TICK_EASING[3]
867
+ );
868
+ var CheckboxAnimatedCheckMark = ({
869
+ pixelSize,
870
+ className
871
+ }) => {
872
+ const dashOffset = useSharedValue(CHECKBOX_CHECK_PATH_LENGTH);
873
+ useEffect(() => {
874
+ dashOffset.value = CHECKBOX_CHECK_PATH_LENGTH;
875
+ dashOffset.value = withDelay(
876
+ CHECKBOX_TICK_DELAY_MS,
877
+ withTiming(0, {
878
+ duration: CHECKBOX_TICK_DRAW_MS,
879
+ easing: tickEasing
880
+ })
881
+ );
882
+ }, [dashOffset]);
883
+ const animatedProps = useAnimatedProps(() => ({
884
+ strokeDashoffset: dashOffset.value
885
+ }));
886
+ return /* @__PURE__ */ jsx(StyledSvg2, { width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", className, children: /* @__PURE__ */ jsx(
887
+ AnimatedPath,
888
+ {
889
+ d: CHECKBOX_CHECK_PATH,
890
+ stroke: "currentColor",
891
+ strokeWidth: 2,
892
+ strokeLinecap: "round",
893
+ strokeLinejoin: "round",
894
+ fill: "none",
895
+ strokeDasharray: CHECKBOX_CHECK_PATH_LENGTH,
896
+ animatedProps
897
+ }
898
+ ) });
899
+ };
900
+ var IndeterminateMark = ({ pixelSize, className }) => {
901
+ return /* @__PURE__ */ jsx(StyledSvg2, { width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", className, children: /* @__PURE__ */ jsx(
902
+ Path,
903
+ {
904
+ d: CHECKBOX_INDETERMINATE_PATH,
905
+ stroke: "currentColor",
906
+ strokeWidth: 2,
907
+ strokeLinecap: "round",
908
+ strokeLinejoin: "round",
909
+ fill: "none"
910
+ }
911
+ ) });
912
+ };
913
+ var CheckboxBase = ({
914
+ className,
915
+ isSelected,
916
+ isDisabled,
917
+ isIndeterminate,
918
+ size = "sm"
919
+ }) => {
920
+ const isChecked = Boolean(isSelected || isIndeterminate);
921
+ const iconPixelSize = resolveCheckboxIconPx(size);
922
+ return /* @__PURE__ */ jsxs(
923
+ View,
924
+ {
925
+ className: cx(
926
+ "flex-row",
927
+ checkboxStyles.base.root,
928
+ checkboxStyles.sizes[size].root,
929
+ isChecked ? checkboxStyles.base.rootChecked : checkboxStyles.base.rootUnchecked,
930
+ isDisabled && checkboxStyles.base.rootDisabled,
931
+ isDisabled && !isChecked && checkboxStyles.base.rootDisabledUnchecked,
932
+ className
933
+ ),
934
+ children: [
935
+ isIndeterminate && /* @__PURE__ */ jsx(IndeterminateMark, { pixelSize: iconPixelSize, className: checkboxStyles.base.icon }),
936
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: checkboxStyles.base.icon })
937
+ ]
938
+ }
939
+ );
940
+ };
941
+ CheckboxBase.displayName = "CheckboxBase";
942
+ var SelectItem = ({
943
+ id,
944
+ label,
945
+ supportingText,
946
+ avatarUrl,
947
+ isDisabled,
948
+ icon,
949
+ selectionIndicator = "checkmark",
950
+ selectionIndicatorAlign = "right",
951
+ className,
952
+ children
953
+ }) => {
954
+ const menu = useContext(SelectMenuContext);
955
+ const select = useContext(SelectContext);
956
+ const size = menu?.size ?? select.size;
957
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
958
+ const fgBrand = useNativeVariable("--color-fg-brand-primary") ?? "#7f56d9";
959
+ const title = label || (typeof children === "string" ? children : "");
960
+ const selected = menu?.isSelected(id) ?? false;
961
+ const showCheck = selected && selectionIndicator === "checkmark";
962
+ const showCheckbox = selectionIndicator === "checkbox";
963
+ const checkboxOnLeft = showCheckbox && selectionIndicatorAlign === "left";
964
+ const brandRow = selected && selectionIndicator !== "checkbox";
965
+ return /* @__PURE__ */ jsx(View, { className: cx("w-full py-px", size === "sm" ? "px-1" : "px-1.5", className), children: /* @__PURE__ */ jsxs(
966
+ Pressable,
967
+ {
968
+ accessibilityRole: "button",
969
+ accessibilityState: { disabled: isDisabled, selected },
970
+ disabled: isDisabled,
971
+ onPress: menu?.selectOnPressIn ? void 0 : () => {
972
+ if (!isDisabled) menu?.onSelect(id);
973
+ },
974
+ onPressIn: menu?.selectOnPressIn ? () => {
975
+ if (!isDisabled) menu?.onSelect(id);
976
+ } : void 0,
977
+ className: cx(
978
+ "flex-row items-center rounded-md",
979
+ itemSizes[size].root,
980
+ brandRow ? "bg-brand-primary_alt" : "active:bg-primary_hover",
981
+ isDisabled && "opacity-50"
982
+ ),
983
+ children: [
984
+ checkboxOnLeft ? /* @__PURE__ */ jsx(CheckboxBase, { size: itemSizes[size].checkbox, isSelected: selected, isDisabled }) : null,
985
+ 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 }),
986
+ /* @__PURE__ */ jsxs(View, { className: cx("min-w-0 flex-1 flex-row flex-wrap", itemSizes[size].textGap), children: [
987
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-primary font-medium", itemSizes[size].text), children: title }),
988
+ supportingText ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-tertiary", itemSizes[size].text), children: supportingText }) : null
989
+ ] }),
990
+ showCheck ? /* @__PURE__ */ jsx(CheckIcon, { size: itemSizes[size].check, color: fgBrand }) : null,
991
+ showCheckbox && !checkboxOnLeft ? /* @__PURE__ */ jsx(CheckboxBase, { size: itemSizes[size].checkbox, isSelected: selected, isDisabled }) : null
992
+ ]
993
+ }
994
+ ) });
995
+ };
996
+ var SelectRoot = ({
997
+ placeholder = "Select",
998
+ icon,
999
+ size = "md",
1000
+ children,
1001
+ items = [],
1002
+ label,
1003
+ hint,
1004
+ hideRequiredIndicator,
1005
+ mobileOptions,
1006
+ className,
1007
+ selectedKey: selectedKeyProp,
1008
+ defaultSelectedKey = null,
1009
+ isDisabled,
1010
+ isInvalid,
1011
+ isRequired,
1012
+ popoverClassName,
1013
+ onSelectionChange
1014
+ }) => {
1015
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
1016
+ const [open, setOpen] = useState(false);
1017
+ const [uncontrolledKey, setUncontrolledKey] = useState(defaultSelectedKey);
1018
+ const selectedKey = selectedKeyProp !== void 0 ? selectedKeyProp : uncontrolledKey;
1019
+ const selected = items.find((item) => selectedKey != null && selectIdKey(item.id) === selectIdKey(selectedKey)) ?? null;
1020
+ const selectItem = (id) => {
1021
+ if (selectedKeyProp === void 0) setUncontrolledKey(id);
1022
+ onSelectionChange?.(id);
1023
+ setOpen(false);
1024
+ };
1025
+ const menuValue = {
1026
+ size,
1027
+ isSelected: (id) => selectedKey != null && selectIdKey(selectedKey) === selectIdKey(id),
1028
+ onSelect: selectItem
1029
+ };
1030
+ const rows = typeof children === "function" ? items.map((item) => /* @__PURE__ */ jsx(View, { children: children(item) }, selectIdKey(item.id))) : children;
1031
+ 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: [
1032
+ label ? /* @__PURE__ */ jsx(Label, { isRequired: Boolean(isRequired && !hideRequiredIndicator), isInvalid, children: label }) : null,
1033
+ /* @__PURE__ */ jsxs(
1034
+ Pressable,
1035
+ {
1036
+ accessibilityRole: "button",
1037
+ disabled: isDisabled,
1038
+ onPress: () => {
1039
+ if (!isDisabled) setOpen(true);
1040
+ },
1041
+ className: selectFieldClassName({ size, focused: open, isInvalid, isDisabled }),
1042
+ children: [
1043
+ selected?.avatarUrl ? /* @__PURE__ */ jsx(Avatar, { size: "xs", src: selected.avatarUrl, alt: selected.label, className: size === "sm" ? "size-5" : void 0 }) : /* @__PURE__ */ jsx(SelectGlyph, { icon: selected?.icon ?? icon, size: sizes[size].icon, color: fgQuaternary }),
1044
+ /* @__PURE__ */ jsx(View, { className: cx("min-w-0 flex-1 flex-row flex-wrap", sizes[size].textGap), children: selected ? /* @__PURE__ */ jsxs(Fragment, { children: [
1045
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-primary font-medium", sizes[size].text), children: selected.label }),
1046
+ selected.supportingText ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-tertiary", sizes[size].text), children: selected.supportingText }) : null
1047
+ ] }) : /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-placeholder", sizes[size].text), children: placeholder }) }),
1048
+ /* @__PURE__ */ jsx(CaretDownIcon, { size: size === "lg" ? 20 : 16, color: fgQuaternary })
1049
+ ]
1050
+ }
1051
+ ),
1052
+ /* @__PURE__ */ jsx(Popover, { open, onClose: () => setOpen(false), size, mobileOptions: { title: label, ...mobileOptions }, className: popoverClassName, children: rows }),
1053
+ hint ? /* @__PURE__ */ jsx(HintText, { isInvalid, size, children: hint }) : null
1054
+ ] }) }) });
1055
+ };
1056
+ var Select = Object.assign(SelectRoot, {
1057
+ ComboBox,
1058
+ Item: SelectItem
1059
+ });
1060
+
1061
+ export { Select };
1062
+ //# sourceMappingURL=select.js.map
1063
+ //# sourceMappingURL=select.js.map