@avenue-ticketing/native 0.1.3 → 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.
@@ -0,0 +1,1251 @@
1
+ import { createContext, useState, useMemo, useContext, 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 { MagnifyingGlassIcon } from 'phosphor-react-native/src/icons/MagnifyingGlass';
6
+ import { extendTailwindMerge } from 'tailwind-merge';
7
+ import { useWindowDimensions, Modal, Linking, Image } from 'react-native';
8
+ import { IconContext } from 'phosphor-react-native/src/lib';
9
+ import { useInputGroupAddon } from '@avenue-ticketing/native/input-group-addon-context';
10
+ import Animated2, { Easing, FadeIn, FadeOut, FadeInDown, FadeOutDown, useSharedValue, withRepeat, withTiming, useAnimatedStyle, withDelay, useAnimatedProps } from 'react-native-reanimated';
11
+ import Svg, { Path } from 'react-native-svg';
12
+ import { styled } from 'nativewind';
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';
18
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
19
+ import { XIcon } from 'phosphor-react-native/src/icons/X';
20
+ import { CheckIcon } from 'phosphor-react-native/src/icons/Check';
21
+ import { UserIcon } from 'phosphor-react-native/src/icons/User';
22
+
23
+ // ../../native/components/base/select/multi-select.tsx
24
+ var twMerge = extendTailwindMerge({
25
+ extend: {
26
+ theme: {
27
+ text: ["display-xs", "display-sm", "display-md", "display-lg", "display-xl", "display-2xl"]
28
+ }
29
+ }
30
+ });
31
+ var cx = twMerge;
32
+ function sortCx(classes) {
33
+ return classes;
34
+ }
35
+
36
+ // ../core/src/input.ts
37
+ var inputFocusRingShadow = "border-brand ring-1 ring-inset ring-brand";
38
+ var inputErrorFocusRingShadow = "border-error ring-1 ring-inset ring-error";
39
+ var inputStyles = sortCx({
40
+ stack: "w-full flex-col items-start justify-start gap-1.5",
41
+ labelRow: "flex-row items-center gap-0.5",
42
+ label: "text-sm font-medium text-secondary",
43
+ required: "text-brand-tertiary",
44
+ requiredInvalid: "text-error-primary",
45
+ hint: "text-sm text-tertiary",
46
+ hintSm: "text-xs",
47
+ hintInvalid: "text-error-primary",
48
+ field: {
49
+ root: "relative isolate w-full flex-row items-center rounded-lg border border-solid border-primary bg-primary shadow-xs",
50
+ /** Web: focus-within:border-brand + inset ring-1 ring-brand (2px visual, no layout shift). */
51
+ focus: inputFocusRingShadow,
52
+ invalid: "border-error_subtle",
53
+ invalidFocus: inputErrorFocusRingShadow,
54
+ disabled: "opacity-50"
55
+ },
56
+ input: "m-0 min-w-0 flex-1 bg-transparent text-primary placeholder:text-placeholder",
57
+ iconLeading: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
58
+ iconTrailing: "absolute inset-y-0 items-center justify-center text-fg-quaternary",
59
+ iconInvalid: "absolute inset-y-0 items-center justify-center text-fg-error-secondary",
60
+ sizes: {
61
+ sm: {
62
+ field: "min-h-9",
63
+ input: "px-3 py-2 text-sm",
64
+ inputLeading: "pl-9",
65
+ inputTrailing: "pr-9",
66
+ iconLeading: "left-3 w-4",
67
+ iconTrailing: "right-3 w-4",
68
+ iconPx: 16,
69
+ shortcut: "pr-1.5"
70
+ },
71
+ md: {
72
+ field: "min-h-10",
73
+ input: "px-3 py-2 text-md",
74
+ inputLeading: "pl-10",
75
+ inputTrailing: "pr-9",
76
+ iconLeading: "left-3 w-5",
77
+ iconTrailing: "right-3 w-4",
78
+ iconPx: 20,
79
+ shortcut: "pr-2"
80
+ },
81
+ lg: {
82
+ field: "min-h-11",
83
+ input: "px-3.5 py-2.5 text-md",
84
+ inputLeading: "pl-10.5",
85
+ inputTrailing: "pr-9.5",
86
+ iconLeading: "left-3.5 w-5",
87
+ iconTrailing: "right-3.5 w-4",
88
+ iconPx: 20,
89
+ shortcut: "pr-2.5"
90
+ }
91
+ }
92
+ });
93
+
94
+ // ../core/src/button.ts
95
+ function isLinkButtonColor(color) {
96
+ return color === "link-gray" || color === "link-color" || color === "link-destructive";
97
+ }
98
+ function isSolidSkeuomorphic(color) {
99
+ return color === "primary" || color === "brand" || color === "primary-destructive";
100
+ }
101
+ function isSecondarySkeuomorphic(color) {
102
+ return color === "secondary" || color === "secondary-destructive";
103
+ }
104
+ var BUTTON_ICON_SIZE_PX = {
105
+ xs: 16,
106
+ sm: 20,
107
+ md: 20,
108
+ lg: 20,
109
+ xl: 20
110
+ };
111
+ function resolveButtonIconSizePx(size, isIconOnly = false) {
112
+ if (size === "xl" && isIconOnly) return 24;
113
+ return BUTTON_ICON_SIZE_PX[size];
114
+ }
115
+ function resolveButtonIconSizeClass(size, isIconOnly = false) {
116
+ if (size === "xl" && isIconOnly) return "size-6";
117
+ if (size === "xs") return "size-4";
118
+ return "size-5";
119
+ }
120
+ var BUTTON_LOADING_SPINNER_PATH = "M232,128a104,104,0,0,1-208,0c0-41,23.81-78.36,60.66-95.27a8,8,0,0,1,6.68,14.54C60,61.46,40,93.27,40,128a88,88,0,0,0,176,0c0-34.73-20-66.54-51.34-80.73a8,8,0,0,1,6.68-14.54C208.19,49.64,232,87,232,128Z";
121
+ var buttonStyles = sortCx({
122
+ common: {
123
+ // Avoid bare `flex` — NativeWind maps it like web (row) and can break parents.
124
+ root: "relative flex-row items-center justify-center overflow-visible rounded-full shrink-0",
125
+ icon: "shrink-0",
126
+ label: "shrink-0 font-semibold"
127
+ },
128
+ sizes: {
129
+ // Padding / height / gap match `buttonWebStyles.sizes` (web root).
130
+ xs: {
131
+ root: "h-8 min-h-8 gap-1 px-[0.625rem] py-1.5",
132
+ label: "text-sm",
133
+ iconOnly: "size-8 min-h-8 min-w-8 p-2"
134
+ },
135
+ sm: {
136
+ root: "h-9 min-h-9 gap-1 px-3 py-2",
137
+ label: "text-sm",
138
+ iconOnly: "size-9 min-h-9 min-w-9 p-2"
139
+ },
140
+ md: {
141
+ root: "h-10 min-h-10 gap-1 px-3.5 py-2.5",
142
+ label: "text-sm",
143
+ iconOnly: "size-10 min-h-10 min-w-10 p-2.5"
144
+ },
145
+ lg: {
146
+ root: "h-11 min-h-11 gap-1.5 px-4 py-2.5",
147
+ label: "text-md",
148
+ iconOnly: "size-11 min-h-11 min-w-11 p-3"
149
+ },
150
+ xl: {
151
+ root: "h-12 min-h-12 gap-1.5 px-[1.125rem] py-3",
152
+ label: "text-md",
153
+ iconOnly: "size-12 min-h-12 min-w-12 p-3"
154
+ }
155
+ },
156
+ /** Web `disabled:opacity-30` (primary) / `disabled:opacity-50` (others). */
157
+ disabledOpacity: {
158
+ primary: "opacity-30",
159
+ brand: "opacity-50",
160
+ secondary: "opacity-50",
161
+ tertiary: "opacity-50",
162
+ "link-color": "opacity-50",
163
+ "link-gray": "opacity-50",
164
+ "primary-destructive": "opacity-50",
165
+ "secondary-destructive": "opacity-50",
166
+ "tertiary-destructive": "opacity-50",
167
+ "link-destructive": "opacity-50"
168
+ },
169
+ /** Native InputGroup addon — shell owns border/height; button is a flush inner segment. */
170
+ inputGroup: {
171
+ root: "h-auto min-h-0 self-stretch rounded-none border-0 bg-primary shadow-none overflow-hidden",
172
+ sm: "gap-1 px-3 py-2",
173
+ md: "gap-1 px-3.5 py-2.5",
174
+ lg: "gap-1.5 px-4 py-2.5",
175
+ xs: "gap-1 px-3 py-2",
176
+ xl: "gap-1.5 px-4 py-2.5"
177
+ },
178
+ colors: {
179
+ primary: {
180
+ root: "bg-primary-solid",
181
+ label: "text-white",
182
+ /** Web `*:data-icon:not([data-icon=loading]):text-white/70` */
183
+ icon: "text-white/70",
184
+ /** Loading icon inherits root `text-white`. */
185
+ spinner: "text-white"
186
+ },
187
+ brand: {
188
+ root: "bg-brand-solid",
189
+ label: "text-primary_on-brand",
190
+ icon: "text-primary_on-brand",
191
+ spinner: "text-primary_on-brand"
192
+ },
193
+ secondary: {
194
+ root: "border border-solid border-primary bg-primary",
195
+ label: "text-secondary",
196
+ icon: "text-fg-secondary",
197
+ spinner: "text-fg-secondary"
198
+ },
199
+ tertiary: {
200
+ root: "border border-transparent bg-transparent",
201
+ label: "text-tertiary",
202
+ icon: "text-fg-tertiary",
203
+ spinner: "text-fg-tertiary"
204
+ },
205
+ "link-color": {
206
+ // Web: underline decoration transparent until hover — native uses press underline.
207
+ root: "h-auto min-h-0 bg-transparent px-0 py-0",
208
+ label: "text-brand-secondary",
209
+ icon: "text-brand-secondary",
210
+ spinner: "text-brand-secondary"
211
+ },
212
+ "link-gray": {
213
+ root: "h-auto min-h-0 bg-transparent px-0 py-0",
214
+ label: "text-tertiary",
215
+ icon: "text-fg-tertiary",
216
+ spinner: "text-fg-tertiary"
217
+ },
218
+ "primary-destructive": {
219
+ root: "bg-error-solid",
220
+ label: "text-white",
221
+ icon: "text-white/70",
222
+ spinner: "text-white"
223
+ },
224
+ "secondary-destructive": {
225
+ root: "border border-solid border-primary bg-primary",
226
+ label: "text-error-primary",
227
+ icon: "text-fg-error-secondary",
228
+ spinner: "text-fg-error-secondary"
229
+ },
230
+ "tertiary-destructive": {
231
+ root: "border border-transparent bg-transparent",
232
+ label: "text-error-primary",
233
+ icon: "text-fg-error-secondary",
234
+ spinner: "text-fg-error-secondary"
235
+ },
236
+ "link-destructive": {
237
+ root: "h-auto min-h-0 bg-transparent px-0 py-0",
238
+ label: "text-error-primary",
239
+ icon: "text-error-primary",
240
+ spinner: "text-error-primary"
241
+ }
242
+ }
243
+ });
244
+
245
+ // ../core/src/is-react-component.ts
246
+ var isFunctionComponent = (component) => {
247
+ return typeof component === "function";
248
+ };
249
+ var isClassComponent = (component) => {
250
+ return typeof component === "function" && component.prototype && (!!component.prototype.isReactComponent || !!component.prototype.render);
251
+ };
252
+ var isForwardRefComponent = (component) => {
253
+ return typeof component === "object" && component !== null && component.$$typeof.toString() === "Symbol(react.forward_ref)";
254
+ };
255
+ var isReactComponent = (component) => {
256
+ return isFunctionComponent(component) || isForwardRefComponent(component) || isClassComponent(component);
257
+ };
258
+
259
+ // ../../native/components/base/buttons/button.styles.ts
260
+ var nativeButtonInteraction = sortCx({
261
+ root: "active:scale-[0.985]",
262
+ drop: "shadow-xs",
263
+ clip: "absolute inset-0 overflow-hidden rounded-full",
264
+ insetRing: "absolute inset-0 rounded-full border border-solid border-[rgba(0,0,0,0.18)]",
265
+ bottomWeight: "absolute inset-x-0 bottom-0 h-0.5 bg-[rgba(0,0,0,0.05)]",
266
+ topHighlight: "absolute left-px right-px top-px h-px bg-[rgba(255,255,255,0.12)]",
267
+ secondaryBottom: "absolute inset-x-0 bottom-0 h-px bg-[rgba(0,0,0,0.05)]",
268
+ colors: {
269
+ primary: "active:bg-fg-tertiary_hover",
270
+ brand: "active:bg-brand-solid_hover",
271
+ secondary: "active:bg-primary_hover",
272
+ tertiary: "active:bg-primary_hover",
273
+ // Web link hover: underline + color shift. RN uses press = hover.
274
+ "link-color": "active:opacity-80",
275
+ "link-gray": "active:opacity-80",
276
+ "primary-destructive": "active:bg-error-solid_hover",
277
+ "secondary-destructive": "active:bg-error-primary",
278
+ "tertiary-destructive": "active:bg-error-primary",
279
+ "link-destructive": "active:opacity-80"
280
+ }
281
+ });
282
+ function hasPressScale(color) {
283
+ return !isLinkButtonColor(color);
284
+ }
285
+ var StyledSvg = styled(Svg);
286
+ var ButtonSpinner = ({ className, size, showTextWhileLoading }) => {
287
+ const rotation = useSharedValue(0);
288
+ useEffect(() => {
289
+ rotation.value = withRepeat(
290
+ withTiming(360, { duration: 1e3, easing: Easing.linear }),
291
+ -1,
292
+ false
293
+ );
294
+ }, [rotation]);
295
+ const spinStyle = useAnimatedStyle(() => ({
296
+ transform: [{ rotate: `${rotation.value}deg` }]
297
+ }));
298
+ return /* @__PURE__ */ jsx(
299
+ View,
300
+ {
301
+ pointerEvents: "none",
302
+ className: cx(
303
+ !showTextWhileLoading && "absolute inset-0 items-center justify-center"
304
+ ),
305
+ children: /* @__PURE__ */ jsx(Animated2.View, { style: spinStyle, children: /* @__PURE__ */ jsx(
306
+ StyledSvg,
307
+ {
308
+ width: size,
309
+ height: size,
310
+ viewBox: "0 0 256 256",
311
+ accessibilityElementsHidden: true,
312
+ className,
313
+ children: /* @__PURE__ */ jsx(Path, { fill: "currentColor", d: BUTTON_LOADING_SPINNER_PATH })
314
+ }
315
+ ) })
316
+ }
317
+ );
318
+ };
319
+ var Button = ({
320
+ size = "md",
321
+ color = "primary",
322
+ title,
323
+ children,
324
+ className,
325
+ noTextPadding,
326
+ iconLeading: IconLeading,
327
+ iconTrailing: IconTrailing,
328
+ isDisabled: disabled = false,
329
+ isLoading: loading = false,
330
+ showTextWhileLoading,
331
+ href,
332
+ onPress,
333
+ inInputGroup = false,
334
+ ...props
335
+ }) => {
336
+ const inAddon = useInputGroupAddon();
337
+ const flattenInGroup = inInputGroup || inAddon;
338
+ const titleFromChildren = typeof children === "string" || typeof children === "number" ? String(children) : null;
339
+ const titleText = title ?? titleFromChildren;
340
+ const customChildren = titleText == null ? children : null;
341
+ const isIcon = Boolean((IconLeading || IconTrailing) && !titleText && !customChildren);
342
+ const isLinkType = isLinkButtonColor(color);
343
+ const padText = !(isLinkType || noTextPadding);
344
+ const isInactive = disabled || loading;
345
+ const showTitle = Boolean(titleText) && (!loading || showTextWhileLoading);
346
+ const iconSizePx = resolveButtonIconSizePx(size, isIcon);
347
+ const iconToken = buttonStyles.colors[color].icon.replace(/^text-/, "");
348
+ const onSolid = iconToken.startsWith("white");
349
+ const resolvedIconColor = useNativeVariable(
350
+ onSolid ? "--color-white" : iconToken.startsWith("fg-") ? `--color-${iconToken}` : `--color-text-${iconToken}`
351
+ );
352
+ const iconColor = onSolid ? "rgba(255,255,255,0.7)" : typeof resolvedIconColor === "string" ? resolvedIconColor : void 0;
353
+ const iconClassName = cx(
354
+ buttonStyles.common.icon,
355
+ resolveButtonIconSizeClass(size, isIcon),
356
+ buttonStyles.colors[color].icon
357
+ );
358
+ const LeadingIcon = isReactComponent(IconLeading) ? IconLeading : null;
359
+ const TrailingIcon = isReactComponent(IconTrailing) ? IconTrailing : null;
360
+ const handlePress = (event) => {
361
+ if (isInactive) return;
362
+ if (href) {
363
+ void Linking.openURL(href);
364
+ return;
365
+ }
366
+ onPress?.(event);
367
+ };
368
+ return /* @__PURE__ */ jsx(
369
+ Pressable,
370
+ {
371
+ accessibilityRole: "button",
372
+ accessibilityLabel: titleText ?? void 0,
373
+ accessibilityState: { disabled: isInactive, busy: loading },
374
+ disabled: isInactive,
375
+ onPress: handlePress,
376
+ className: cx(
377
+ buttonStyles.common.root,
378
+ flattenInGroup ? cx(buttonStyles.inputGroup.root, buttonStyles.inputGroup[size]) : cx(buttonStyles.sizes[size].root, isIcon && buttonStyles.sizes[size].iconOnly),
379
+ flattenInGroup ? "bg-primary" : buttonStyles.colors[color].root,
380
+ !flattenInGroup && hasPressScale(color) && nativeButtonInteraction.root,
381
+ !flattenInGroup && (isSolidSkeuomorphic(color) || isSecondarySkeuomorphic(color)) && nativeButtonInteraction.drop,
382
+ nativeButtonInteraction.colors[color],
383
+ isLinkType && "h-auto min-h-0 px-0 py-0",
384
+ // Web applies disabled opacity only when disabled — not while loading.
385
+ disabled && buttonStyles.disabledOpacity[color],
386
+ className
387
+ ),
388
+ ...props,
389
+ children: ({ pressed }) => /* @__PURE__ */ jsxs(Fragment, { children: [
390
+ !flattenInGroup && isSolidSkeuomorphic(color) && /* @__PURE__ */ jsxs(View, { pointerEvents: "none", className: nativeButtonInteraction.clip, children: [
391
+ /* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.insetRing }),
392
+ /* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.bottomWeight }),
393
+ /* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.topHighlight })
394
+ ] }),
395
+ !flattenInGroup && isSecondarySkeuomorphic(color) && /* @__PURE__ */ jsx(View, { pointerEvents: "none", className: nativeButtonInteraction.clip, children: /* @__PURE__ */ jsx(View, { className: nativeButtonInteraction.secondaryBottom }) }),
396
+ /* @__PURE__ */ jsxs(IconContext.Provider, { value: iconColor ? { color: iconColor } : {}, children: [
397
+ isValidElement(IconLeading) && !loading && IconLeading,
398
+ LeadingIcon && !loading && /* @__PURE__ */ jsx(LeadingIcon, { className: iconClassName, size: iconSizePx })
399
+ ] }),
400
+ loading && /* @__PURE__ */ jsx(
401
+ ButtonSpinner,
402
+ {
403
+ className: buttonStyles.colors[color].spinner,
404
+ size: iconSizePx,
405
+ showTextWhileLoading
406
+ }
407
+ ),
408
+ showTitle && /* @__PURE__ */ jsx(
409
+ Text,
410
+ {
411
+ numberOfLines: 1,
412
+ className: cx(
413
+ buttonStyles.common.label,
414
+ buttonStyles.sizes[size].label,
415
+ buttonStyles.colors[color].label,
416
+ // Web link: transparent underline until hover — press ≈ hover on RN.
417
+ isLinkType && pressed && "underline",
418
+ padText && !isLinkType && "px-0.5",
419
+ loading && !showTextWhileLoading && "opacity-0"
420
+ ),
421
+ children: titleText
422
+ }
423
+ ),
424
+ !loading && customChildren,
425
+ /* @__PURE__ */ jsxs(IconContext.Provider, { value: iconColor ? { color: iconColor } : {}, children: [
426
+ isValidElement(IconTrailing) && !loading && IconTrailing,
427
+ TrailingIcon && !loading && /* @__PURE__ */ jsx(TrailingIcon, { className: iconClassName, size: iconSizePx })
428
+ ] })
429
+ ] })
430
+ }
431
+ );
432
+ };
433
+ Button.displayName = "Button";
434
+ createContext(null);
435
+ createContext(null);
436
+ var Label = ({ children, isRequired, isInvalid, className }) => {
437
+ return /* @__PURE__ */ jsxs(View, { className: cx(inputStyles.labelRow, className), children: [
438
+ /* @__PURE__ */ jsx(Text, { className: inputStyles.label, children }),
439
+ isRequired && /* @__PURE__ */ jsx(Text, { className: isInvalid ? inputStyles.requiredInvalid : inputStyles.required, children: "*" })
440
+ ] });
441
+ };
442
+ var HintText = ({ children, isInvalid, size, className }) => {
443
+ if (children == null || children === false) return null;
444
+ if (typeof children !== "string" && typeof children !== "number") {
445
+ return /* @__PURE__ */ jsx(Fragment, { children });
446
+ }
447
+ return /* @__PURE__ */ jsx(
448
+ Text,
449
+ {
450
+ className: cx(
451
+ inputStyles.hint,
452
+ size === "sm" && inputStyles.hintSm,
453
+ isInvalid && inputStyles.hintInvalid,
454
+ className
455
+ ),
456
+ children
457
+ }
458
+ );
459
+ };
460
+
461
+ // ../core/src/dialog.ts
462
+ var DIALOG_SHEET_MOTION_MS = 175;
463
+ var DIALOG_SLIDE_OFFSET_PX = 120;
464
+ var DIALOG_ENTRY_EASING_BEZIER = [0.85, 0, 0.15, 1];
465
+ var DIALOG_EXIT_EASING_BEZIER = [0.85, 0, 1, 0.15];
466
+ var DIALOG_SHEET_RADIUS_PX = 16;
467
+ var dialogStyles = sortCx({
468
+ root: "flex",
469
+ rootFull: "h-full w-full flex-col bg-primary",
470
+ rootSheet: "flex-col justify-end",
471
+ rootModal: "flex-col items-center justify-center p-4",
472
+ overlay: "absolute inset-0 bg-overlay/70",
473
+ panel: "relative z-10 w-full overflow-hidden bg-primary",
474
+ panelElevated: "shadow-xl",
475
+ panelFull: "flex min-h-0 flex-1 flex-col",
476
+ /**
477
+ * Web sheet chrome (≤1024). Native pins the same chrome with RN layout styles
478
+ * (`DIALOG_SHEET_RADIUS_PX` + token colors) because NativeWind border/radius
479
+ * on sheets leave side gaps and bottom transparency.
480
+ */
481
+ 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",
482
+ panelModal: "w-full rounded-2xl border border-solid border-secondary",
483
+ sizes: {
484
+ sm: "max-w-sm",
485
+ md: "max-w-md",
486
+ lg: "max-w-lg",
487
+ xl: "max-w-xl"
488
+ },
489
+ sizesLgOnly: {
490
+ sm: "lg:max-w-sm",
491
+ md: "lg:max-w-md",
492
+ lg: "lg:max-w-lg",
493
+ xl: "lg:max-w-xl"
494
+ },
495
+ sizesSmUp: {
496
+ sm: "sm:max-w-sm",
497
+ md: "sm:max-w-md",
498
+ lg: "sm:max-w-lg",
499
+ xl: "sm:max-w-xl"
500
+ },
501
+ header: "flex-col gap-1.5 p-6 pr-14",
502
+ headerFixed: "border-b border-solid border-secondary bg-primary",
503
+ footer: "flex-col-reverse gap-2 p-6",
504
+ footerFixed: "border-t border-solid border-secondary bg-primary",
505
+ title: "text-xl font-semibold text-primary",
506
+ description: "text-sm text-tertiary",
507
+ close: "size-12 items-center justify-center rounded-full bg-primary active:scale-[0.96] active:bg-primary_hover",
508
+ closePosition: "absolute top-4 right-4 z-20"
509
+ });
510
+
511
+ // ../core/src/select.ts
512
+ var sizes = {
513
+ sm: { root: "gap-2 py-2 pr-2.5 pl-3", text: "text-sm", icon: 16, textGap: "gap-x-1.5" },
514
+ md: { root: "gap-2 px-3 py-2", text: "text-md", icon: 20, textGap: "gap-x-1.5" },
515
+ lg: { root: "gap-2 px-3.5 py-2.5", text: "text-md", icon: 20, textGap: "gap-x-1.5" }
516
+ };
517
+ var itemSizes = {
518
+ sm: { root: "gap-2 p-2 pr-2.5", text: "text-sm", icon: 16, textGap: "gap-x-1.5", check: 16, checkbox: "sm" },
519
+ md: { root: "gap-2 p-2 pr-2.5", text: "text-md", icon: 20, textGap: "gap-x-2", check: 20, checkbox: "sm" },
520
+ 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" }
521
+ };
522
+ var searchSizes = {
523
+ sm: { wrapper: "py-1", root: "gap-2 px-3 py-2", text: "text-sm" },
524
+ md: { wrapper: "py-0.5", root: "gap-2 px-3 py-2", text: "text-md" },
525
+ lg: { wrapper: "py-0.5", root: "gap-2 px-3.5 py-2.5", text: "text-md" }
526
+ };
527
+ var menuMaxHeight = {
528
+ sm: "max-h-56",
529
+ md: "max-h-64",
530
+ lg: "max-h-80"
531
+ };
532
+ function resolveSelectMobileOptions(mobileOptions) {
533
+ const fullScreen = mobileOptions?.fullScreen ?? false;
534
+ return {
535
+ sheet: mobileOptions?.sheet ?? true,
536
+ fullScreen,
537
+ overlay: fullScreen ? false : mobileOptions?.overlay ?? true,
538
+ title: mobileOptions?.title,
539
+ sheetClassName: mobileOptions?.className,
540
+ contentClassName: mobileOptions?.contentClassName
541
+ };
542
+ }
543
+ function selectIdKey(id) {
544
+ return String(id);
545
+ }
546
+ function selectionSet(selection, items) {
547
+ if (selection === "all") return new Set(items.map((item) => selectIdKey(item.id)));
548
+ if (!selection) return /* @__PURE__ */ new Set();
549
+ return new Set([...selection].map((id) => selectIdKey(id)));
550
+ }
551
+ function itemText(item) {
552
+ return item.supportingText ? `${item.label ?? ""} ${item.supportingText}` : item.label ?? "";
553
+ }
554
+ function itemMatches(item, query) {
555
+ const needle = query.trim().toLowerCase();
556
+ if (!needle) return true;
557
+ return itemText(item).toLowerCase().includes(needle);
558
+ }
559
+ function selectFieldClassName(options) {
560
+ return cx(
561
+ "bg-primary w-full flex-row items-center rounded-lg border border-solid shadow-xs",
562
+ sizes[options.size].root,
563
+ options.isDisabled && "opacity-50",
564
+ options.isInvalid && options.focused && inputErrorFocusRingShadow,
565
+ options.isInvalid && !options.focused && "border-error_subtle",
566
+ !options.isInvalid && options.focused && inputFocusRingShadow,
567
+ !options.isInvalid && !options.focused && "border-primary",
568
+ options.className
569
+ );
570
+ }
571
+ var SelectMenuContext = createContext(null);
572
+ var SelectContext = createContext({ size: "md" });
573
+ var SelectGlyph = ({ icon, size, color }) => {
574
+ if (isReactComponent(icon)) {
575
+ const Icon = icon;
576
+ return /* @__PURE__ */ jsx(Icon, { size, color });
577
+ }
578
+ if (isValidElement(icon)) return icon;
579
+ return null;
580
+ };
581
+ var ENTRY = Easing.bezier(...DIALOG_ENTRY_EASING_BEZIER);
582
+ var EXIT = Easing.bezier(...DIALOG_EXIT_EASING_BEZIER);
583
+ var overlayEntering = FadeIn.duration(DIALOG_SHEET_MOTION_MS).easing(ENTRY);
584
+ var overlayExiting = FadeOut.duration(DIALOG_SHEET_MOTION_MS).easing(EXIT);
585
+ var panelEntering = FadeInDown.duration(DIALOG_SHEET_MOTION_MS).easing(ENTRY).withInitialValues({ opacity: 0, transform: [{ translateY: DIALOG_SLIDE_OFFSET_PX }] });
586
+ var panelExiting = FadeOutDown.duration(DIALOG_SHEET_MOTION_MS).easing(EXIT).withTargetValues({ opacity: 0, transform: [{ translateY: DIALOG_SLIDE_OFFSET_PX }] });
587
+ function useSheetPresence(open) {
588
+ const [shouldRender, setShouldRender] = useState(open);
589
+ useEffect(() => {
590
+ if (open) {
591
+ setShouldRender(true);
592
+ return;
593
+ }
594
+ const hide = setTimeout(() => setShouldRender(false), DIALOG_SHEET_MOTION_MS);
595
+ return () => clearTimeout(hide);
596
+ }, [open]);
597
+ return shouldRender;
598
+ }
599
+ function overlayFill(color) {
600
+ const hex = /^#([\da-f]{6})$/i.exec(color);
601
+ if (!hex) return "rgba(10, 13, 18, 0.7)";
602
+ const value = parseInt(hex[1], 16);
603
+ return `rgba(${value >> 16 & 255}, ${value >> 8 & 255}, ${value & 255}, 0.7)`;
604
+ }
605
+ var HEADER_HEIGHT = 56;
606
+ var Popover = ({
607
+ open,
608
+ onClose,
609
+ size = "md",
610
+ mobileOptions,
611
+ compound = false,
612
+ className,
613
+ children
614
+ }) => {
615
+ const resolved = resolveSelectMobileOptions(mobileOptions);
616
+ if (!resolved.sheet) {
617
+ if (!open) return null;
618
+ return /* @__PURE__ */ jsx(
619
+ View,
620
+ {
621
+ className: cx(
622
+ "bg-primary overflow-hidden rounded-lg shadow-lg ring-1 ring-secondary_alt",
623
+ !compound && "py-1",
624
+ !compound && menuMaxHeight[size],
625
+ className
626
+ ),
627
+ children: compound ? children : /* @__PURE__ */ jsx(ScrollView, { keyboardShouldPersistTaps: "handled", nestedScrollEnabled: true, children })
628
+ }
629
+ );
630
+ }
631
+ return /* @__PURE__ */ jsx(
632
+ SelectSheet,
633
+ {
634
+ open,
635
+ onClose,
636
+ title: resolved.title,
637
+ fullScreen: resolved.fullScreen,
638
+ overlay: resolved.overlay,
639
+ className: cx(resolved.sheetClassName, resolved.contentClassName, className),
640
+ children
641
+ }
642
+ );
643
+ };
644
+ var SelectSheet = ({ open, onClose, title, fullScreen, overlay, className, children }) => {
645
+ const insets = useSafeAreaInsets();
646
+ const { width: windowWidth, height: windowHeight } = useWindowDimensions();
647
+ const shouldRender = useSheetPresence(open);
648
+ const fgPrimary = useNativeVariable("--color-fg-primary") ?? "#181d27";
649
+ const bgPrimary = useNativeVariable("--color-bg-primary") ?? "#ffffff";
650
+ const borderSecondary = useNativeVariable("--color-border-secondary") ?? "#e9eaeb";
651
+ const overlayColor = useNativeVariable("--color-bg-overlay") ?? "#0a0d12";
652
+ const sheetMax = fullScreen ? windowHeight : Math.round(windowHeight * 0.9);
653
+ const listMax = Math.max(0, sheetMax - HEADER_HEIGHT - (fullScreen ? insets.top : insets.bottom));
654
+ 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: [
655
+ open && overlay ? /* @__PURE__ */ jsx(View, { className: dialogStyles.overlay, children: /* @__PURE__ */ jsx(Animated2.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,
656
+ open ? /* @__PURE__ */ jsxs(
657
+ Animated2.View,
658
+ {
659
+ collapsable: false,
660
+ entering: panelEntering,
661
+ exiting: panelExiting,
662
+ style: fullScreen ? {
663
+ flex: 1,
664
+ width: windowWidth,
665
+ backgroundColor: bgPrimary,
666
+ paddingBottom: 12
667
+ } : {
668
+ position: "absolute",
669
+ left: 0,
670
+ right: 0,
671
+ bottom: 0,
672
+ width: windowWidth,
673
+ maxHeight: sheetMax,
674
+ zIndex: 10,
675
+ overflow: "hidden",
676
+ backgroundColor: bgPrimary,
677
+ borderTopLeftRadius: DIALOG_SHEET_RADIUS_PX,
678
+ borderTopRightRadius: DIALOG_SHEET_RADIUS_PX,
679
+ borderBottomLeftRadius: 0,
680
+ borderBottomRightRadius: 0,
681
+ borderTopWidth: 1,
682
+ borderLeftWidth: 0,
683
+ borderRightWidth: 0,
684
+ borderBottomWidth: 0,
685
+ borderTopColor: borderSecondary,
686
+ paddingBottom: insets.bottom
687
+ },
688
+ children: [
689
+ fullScreen ? /* @__PURE__ */ jsx(View, { style: { height: insets.top } }) : null,
690
+ /* @__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: [
691
+ title ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: "text-primary min-w-0 flex-1 text-base font-semibold", children: title }) : null,
692
+ /* @__PURE__ */ jsx(
693
+ Pressable,
694
+ {
695
+ accessibilityRole: "button",
696
+ accessibilityLabel: "Close",
697
+ onPress: onClose,
698
+ className: "size-12 items-center justify-center rounded-full active:bg-primary_hover",
699
+ children: /* @__PURE__ */ jsx(XIcon, { size: 20, color: fgPrimary })
700
+ }
701
+ )
702
+ ] }),
703
+ /* @__PURE__ */ jsx(
704
+ ScrollView,
705
+ {
706
+ keyboardShouldPersistTaps: "handled",
707
+ style: fullScreen ? { flex: 1 } : { flexGrow: 0, flexShrink: 0, maxHeight: listMax },
708
+ children: /* @__PURE__ */ jsx(View, { className: cx("py-1", className), children })
709
+ }
710
+ )
711
+ ]
712
+ }
713
+ ) : null
714
+ ] }) });
715
+ };
716
+
717
+ // ../core/src/avatar.ts
718
+ var avatarStyles = sortCx({
719
+ root: "relative shrink-0 rounded-[7px]",
720
+ rootRounded: "rounded-full",
721
+ rootBorder: "ring-1 ring-secondary_alt",
722
+ content: "relative size-full shrink-0 items-center justify-center overflow-hidden rounded-md bg-tertiary",
723
+ contentRounded: "rounded-full",
724
+ initials: "text-quaternary",
725
+ icon: "text-fg-quaternary",
726
+ sizes: {
727
+ xs: { root: "size-6", rootWithBorder: "p-px", initials: "text-xs font-semibold", icon: "size-4" },
728
+ sm: { root: "size-8", rootWithBorder: "p-px", initials: "text-sm font-semibold", icon: "size-5" },
729
+ md: { root: "size-10", rootWithBorder: "p-px", initials: "text-md font-semibold", icon: "size-6" },
730
+ lg: { root: "size-12", rootWithBorder: "p-[1.5px]", initials: "text-lg font-semibold", icon: "size-7" },
731
+ xl: { root: "size-14", rootWithBorder: "p-0.5", initials: "text-xl font-semibold", icon: "size-8" },
732
+ "2xl": { root: "size-16", rootWithBorder: "p-0.5", initials: "text-display-xs font-semibold", icon: "size-8" }
733
+ }
734
+ });
735
+ var AVATAR_SIZE_PX = {
736
+ xs: 24,
737
+ sm: 32,
738
+ md: 40,
739
+ lg: 48,
740
+ xl: 56,
741
+ "2xl": 64
742
+ };
743
+ var AVATAR_ICON_SIZE_PX = {
744
+ xs: 16,
745
+ sm: 20,
746
+ md: 24,
747
+ lg: 28,
748
+ xl: 32,
749
+ "2xl": 32
750
+ };
751
+ var AVATAR_INITIALS_LINE_HEIGHT_PX = {
752
+ xs: 18,
753
+ sm: 20,
754
+ md: 24,
755
+ lg: 28,
756
+ xl: 30,
757
+ "2xl": 32
758
+ };
759
+ var avatarOnlineIndicatorStyles = sortCx({
760
+ root: "absolute right-0 bottom-0 rounded-full ring-[1.5px] ring-bg-primary",
761
+ online: "bg-fg-success-secondary",
762
+ offline: "bg-utility-neutral-300",
763
+ sizes: {
764
+ xs: "size-1.5",
765
+ sm: "size-2",
766
+ md: "size-2.5",
767
+ lg: "size-3",
768
+ xl: "size-3.5",
769
+ "2xl": "size-4"
770
+ }
771
+ });
772
+ var avatarVerifiedStyles = sortCx({
773
+ root: "absolute right-0 bottom-0 z-10 text-utility-blue-500",
774
+ xsOffset: "-right-px -bottom-px",
775
+ sizes: {
776
+ xs: "size-2.5",
777
+ sm: "size-3",
778
+ md: "size-3.5",
779
+ lg: "size-4",
780
+ xl: "size-4.5",
781
+ "2xl": "size-5"
782
+ }
783
+ });
784
+ var AVATAR_VERIFIED_SIZE_PX = {
785
+ xs: 10,
786
+ sm: 12,
787
+ md: 14,
788
+ lg: 16,
789
+ xl: 18,
790
+ "2xl": 20
791
+ };
792
+ var avatarCountStyles = sortCx({
793
+ root: "absolute right-0 bottom-0 p-px",
794
+ badge: "size-3.5 items-center justify-center rounded-full bg-fg-error-primary",
795
+ label: "text-center text-[10px] font-bold text-white"
796
+ });
797
+ var AVATAR_COUNT_LABEL_LINE_HEIGHT_PX = 13;
798
+ var StyledSvg2 = styled(Svg);
799
+ var AvatarOnlineIndicator = ({ size, status, className }) => {
800
+ return /* @__PURE__ */ jsx(
801
+ View,
802
+ {
803
+ className: cx(
804
+ avatarOnlineIndicatorStyles.root,
805
+ status === "online" ? avatarOnlineIndicatorStyles.online : avatarOnlineIndicatorStyles.offline,
806
+ avatarOnlineIndicatorStyles.sizes[size],
807
+ className
808
+ )
809
+ }
810
+ );
811
+ };
812
+ var VerifiedTick = ({ size, className }) => {
813
+ const px = AVATAR_VERIFIED_SIZE_PX[size];
814
+ return /* @__PURE__ */ jsxs(
815
+ StyledSvg2,
816
+ {
817
+ width: px,
818
+ height: px,
819
+ viewBox: "0 0 10 10",
820
+ className: cx(avatarVerifiedStyles.root, size === "xs" && avatarVerifiedStyles.xsOffset, avatarVerifiedStyles.sizes[size], className),
821
+ children: [
822
+ /* @__PURE__ */ jsx(
823
+ Path,
824
+ {
825
+ 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",
826
+ fill: "currentColor"
827
+ }
828
+ ),
829
+ /* @__PURE__ */ jsx(
830
+ Path,
831
+ {
832
+ fillRule: "evenodd",
833
+ clipRule: "evenodd",
834
+ 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",
835
+ fill: "white"
836
+ }
837
+ )
838
+ ]
839
+ }
840
+ );
841
+ };
842
+ var AvatarCount = ({ count, className }) => {
843
+ return /* @__PURE__ */ jsx(View, { className: cx(avatarCountStyles.root, className), children: /* @__PURE__ */ jsx(View, { className: cx("flex-row", avatarCountStyles.badge), children: /* @__PURE__ */ jsx(
844
+ Text,
845
+ {
846
+ style: { includeFontPadding: false, lineHeight: AVATAR_COUNT_LABEL_LINE_HEIGHT_PX },
847
+ className: avatarCountStyles.label,
848
+ children: count
849
+ }
850
+ ) }) });
851
+ };
852
+ var Avatar = ({
853
+ size = "md",
854
+ src,
855
+ alt,
856
+ initials,
857
+ placeholder,
858
+ placeholderIcon: PlaceholderIcon,
859
+ border,
860
+ badge,
861
+ status,
862
+ verified,
863
+ count,
864
+ rounded = true,
865
+ className,
866
+ contentClassName
867
+ }) => {
868
+ const [isFailed, setIsFailed] = useState(false);
869
+ const canShowImage = Boolean(src && !isFailed);
870
+ const sizeStyles = avatarStyles.sizes[size];
871
+ const px = AVATAR_SIZE_PX[size];
872
+ const iconPx = AVATAR_ICON_SIZE_PX[size];
873
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
874
+ const renderMainContent = () => {
875
+ if (canShowImage && src) {
876
+ return /* @__PURE__ */ jsx(
877
+ Image,
878
+ {
879
+ source: { uri: src },
880
+ accessibilityLabel: alt,
881
+ onError: () => setIsFailed(true),
882
+ style: { width: "100%", height: "100%" },
883
+ resizeMode: "cover"
884
+ }
885
+ );
886
+ }
887
+ if (initials) {
888
+ return /* @__PURE__ */ jsx(
889
+ Text,
890
+ {
891
+ style: { includeFontPadding: false, lineHeight: AVATAR_INITIALS_LINE_HEIGHT_PX[size] },
892
+ className: cx(avatarStyles.initials, sizeStyles.initials),
893
+ children: initials
894
+ }
895
+ );
896
+ }
897
+ if (PlaceholderIcon) {
898
+ return /* @__PURE__ */ jsx(PlaceholderIcon, { size: iconPx, color: fgQuaternary });
899
+ }
900
+ if (placeholder) return /* @__PURE__ */ jsx(Fragment, { children: placeholder });
901
+ return /* @__PURE__ */ jsx(UserIcon, { size: iconPx, color: fgQuaternary });
902
+ };
903
+ const renderBadgeContent = () => {
904
+ if (status) return /* @__PURE__ */ jsx(AvatarOnlineIndicator, { status, size });
905
+ if (verified) return /* @__PURE__ */ jsx(VerifiedTick, { size });
906
+ if (count) return /* @__PURE__ */ jsx(AvatarCount, { count });
907
+ return badge ?? null;
908
+ };
909
+ return /* @__PURE__ */ jsxs(
910
+ View,
911
+ {
912
+ className: cx(
913
+ avatarStyles.root,
914
+ rounded && avatarStyles.rootRounded,
915
+ border && avatarStyles.rootBorder,
916
+ border && sizeStyles.rootWithBorder,
917
+ sizeStyles.root,
918
+ className
919
+ ),
920
+ style: { width: px, height: px },
921
+ children: [
922
+ /* @__PURE__ */ jsx(
923
+ View,
924
+ {
925
+ className: cx(
926
+ "flex-row",
927
+ avatarStyles.content,
928
+ rounded && avatarStyles.contentRounded,
929
+ contentClassName
930
+ ),
931
+ children: renderMainContent()
932
+ }
933
+ ),
934
+ renderBadgeContent()
935
+ ]
936
+ }
937
+ );
938
+ };
939
+
940
+ // ../core/src/checkbox.ts
941
+ var checkboxStyles = sortCx({
942
+ base: {
943
+ root: "relative shrink-0 items-center justify-center overflow-hidden border border-solid border-primary",
944
+ rootUnchecked: "bg-primary",
945
+ rootChecked: "border-transparent bg-brand-solid",
946
+ rootDisabled: "opacity-50",
947
+ rootDisabledUnchecked: "bg-tertiary",
948
+ icon: "text-fg-white"
949
+ },
950
+ sizes: {
951
+ sm: {
952
+ root: "size-4 rounded-xs",
953
+ stack: "gap-2",
954
+ textWrapper: "",
955
+ label: "text-sm font-medium",
956
+ hint: "text-sm",
957
+ baseOffset: "mt-0.5"
958
+ },
959
+ md: {
960
+ root: "size-5 rounded-sm",
961
+ stack: "gap-3",
962
+ textWrapper: "gap-0.5",
963
+ label: "text-md font-medium",
964
+ hint: "text-md",
965
+ baseOffset: "mt-0.5"
966
+ }
967
+ },
968
+ /** Label + hint stack beside the control. */
969
+ stack: "relative flex-row items-start",
970
+ label: "text-secondary",
971
+ hint: "text-tertiary"
972
+ });
973
+ var CHECKBOX_ICON_PX = {
974
+ sm: 10,
975
+ md: 14
976
+ };
977
+ function resolveCheckboxIconPx(size) {
978
+ return CHECKBOX_ICON_PX[size];
979
+ }
980
+ var CHECKBOX_TICK_DELAY_MS = 60;
981
+ var CHECKBOX_TICK_DRAW_MS = 100;
982
+ var CHECKBOX_CHECK_PATH = "M2.33325 7L5.24992 9.91667L11.6666 3.5";
983
+ var CHECKBOX_CHECK_PATH_LENGTH = 13.21;
984
+ var CHECKBOX_INDETERMINATE_PATH = "M2.91675 7H11.0834";
985
+ var CHECKBOX_TICK_EASING = [0.45, 0, 0.2, 1];
986
+ var StyledSvg3 = styled(Svg);
987
+ var AnimatedPath = Animated2.createAnimatedComponent(Path);
988
+ var tickEasing = Easing.bezier(
989
+ CHECKBOX_TICK_EASING[0],
990
+ CHECKBOX_TICK_EASING[1],
991
+ CHECKBOX_TICK_EASING[2],
992
+ CHECKBOX_TICK_EASING[3]
993
+ );
994
+ var CheckboxAnimatedCheckMark = ({
995
+ pixelSize,
996
+ className
997
+ }) => {
998
+ const dashOffset = useSharedValue(CHECKBOX_CHECK_PATH_LENGTH);
999
+ useEffect(() => {
1000
+ dashOffset.value = CHECKBOX_CHECK_PATH_LENGTH;
1001
+ dashOffset.value = withDelay(
1002
+ CHECKBOX_TICK_DELAY_MS,
1003
+ withTiming(0, {
1004
+ duration: CHECKBOX_TICK_DRAW_MS,
1005
+ easing: tickEasing
1006
+ })
1007
+ );
1008
+ }, [dashOffset]);
1009
+ const animatedProps = useAnimatedProps(() => ({
1010
+ strokeDashoffset: dashOffset.value
1011
+ }));
1012
+ return /* @__PURE__ */ jsx(StyledSvg3, { width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", className, children: /* @__PURE__ */ jsx(
1013
+ AnimatedPath,
1014
+ {
1015
+ d: CHECKBOX_CHECK_PATH,
1016
+ stroke: "currentColor",
1017
+ strokeWidth: 2,
1018
+ strokeLinecap: "round",
1019
+ strokeLinejoin: "round",
1020
+ fill: "none",
1021
+ strokeDasharray: CHECKBOX_CHECK_PATH_LENGTH,
1022
+ animatedProps
1023
+ }
1024
+ ) });
1025
+ };
1026
+ var IndeterminateMark = ({ pixelSize, className }) => {
1027
+ return /* @__PURE__ */ jsx(StyledSvg3, { width: pixelSize, height: pixelSize, viewBox: "0 0 14 14", className, children: /* @__PURE__ */ jsx(
1028
+ Path,
1029
+ {
1030
+ d: CHECKBOX_INDETERMINATE_PATH,
1031
+ stroke: "currentColor",
1032
+ strokeWidth: 2,
1033
+ strokeLinecap: "round",
1034
+ strokeLinejoin: "round",
1035
+ fill: "none"
1036
+ }
1037
+ ) });
1038
+ };
1039
+ var CheckboxBase = ({
1040
+ className,
1041
+ isSelected,
1042
+ isDisabled,
1043
+ isIndeterminate,
1044
+ size = "sm"
1045
+ }) => {
1046
+ const isChecked = Boolean(isSelected || isIndeterminate);
1047
+ const iconPixelSize = resolveCheckboxIconPx(size);
1048
+ return /* @__PURE__ */ jsxs(
1049
+ View,
1050
+ {
1051
+ className: cx(
1052
+ "flex-row",
1053
+ checkboxStyles.base.root,
1054
+ checkboxStyles.sizes[size].root,
1055
+ isChecked ? checkboxStyles.base.rootChecked : checkboxStyles.base.rootUnchecked,
1056
+ isDisabled && checkboxStyles.base.rootDisabled,
1057
+ isDisabled && !isChecked && checkboxStyles.base.rootDisabledUnchecked,
1058
+ className
1059
+ ),
1060
+ children: [
1061
+ isIndeterminate && /* @__PURE__ */ jsx(IndeterminateMark, { pixelSize: iconPixelSize, className: checkboxStyles.base.icon }),
1062
+ isSelected && !isIndeterminate && /* @__PURE__ */ jsx(CheckboxAnimatedCheckMark, { pixelSize: iconPixelSize, className: checkboxStyles.base.icon })
1063
+ ]
1064
+ }
1065
+ );
1066
+ };
1067
+ CheckboxBase.displayName = "CheckboxBase";
1068
+ var SelectItem = ({
1069
+ id,
1070
+ label,
1071
+ supportingText,
1072
+ avatarUrl,
1073
+ isDisabled,
1074
+ icon,
1075
+ selectionIndicator = "checkmark",
1076
+ selectionIndicatorAlign = "right",
1077
+ className,
1078
+ children
1079
+ }) => {
1080
+ const menu = useContext(SelectMenuContext);
1081
+ const select = useContext(SelectContext);
1082
+ const size = menu?.size ?? select.size;
1083
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
1084
+ const fgBrand = useNativeVariable("--color-fg-brand-primary") ?? "#7f56d9";
1085
+ const title = label || (typeof children === "string" ? children : "");
1086
+ const selected = menu?.isSelected(id) ?? false;
1087
+ const showCheck = selected && selectionIndicator === "checkmark";
1088
+ const showCheckbox = selectionIndicator === "checkbox";
1089
+ const checkboxOnLeft = showCheckbox && selectionIndicatorAlign === "left";
1090
+ const brandRow = selected && selectionIndicator !== "checkbox";
1091
+ return /* @__PURE__ */ jsx(View, { className: cx("w-full py-px", size === "sm" ? "px-1" : "px-1.5", className), children: /* @__PURE__ */ jsxs(
1092
+ Pressable,
1093
+ {
1094
+ accessibilityRole: "button",
1095
+ accessibilityState: { disabled: isDisabled, selected },
1096
+ disabled: isDisabled,
1097
+ onPress: menu?.selectOnPressIn ? void 0 : () => {
1098
+ if (!isDisabled) menu?.onSelect(id);
1099
+ },
1100
+ onPressIn: menu?.selectOnPressIn ? () => {
1101
+ if (!isDisabled) menu?.onSelect(id);
1102
+ } : void 0,
1103
+ className: cx(
1104
+ "flex-row items-center rounded-md",
1105
+ itemSizes[size].root,
1106
+ brandRow ? "bg-brand-primary_alt" : "active:bg-primary_hover",
1107
+ isDisabled && "opacity-50"
1108
+ ),
1109
+ children: [
1110
+ checkboxOnLeft ? /* @__PURE__ */ jsx(CheckboxBase, { size: itemSizes[size].checkbox, isSelected: selected, isDisabled }) : null,
1111
+ 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 }),
1112
+ /* @__PURE__ */ jsxs(View, { className: cx("min-w-0 flex-1 flex-row flex-wrap", itemSizes[size].textGap), children: [
1113
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-primary font-medium", itemSizes[size].text), children: title }),
1114
+ supportingText ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-tertiary", itemSizes[size].text), children: supportingText }) : null
1115
+ ] }),
1116
+ showCheck ? /* @__PURE__ */ jsx(CheckIcon, { size: itemSizes[size].check, color: fgBrand }) : null,
1117
+ showCheckbox && !checkboxOnLeft ? /* @__PURE__ */ jsx(CheckboxBase, { size: itemSizes[size].checkbox, isSelected: selected, isDisabled }) : null
1118
+ ]
1119
+ }
1120
+ ) });
1121
+ };
1122
+ var footerButtonSize = {
1123
+ sm: "xs",
1124
+ md: "sm",
1125
+ lg: "sm"
1126
+ };
1127
+ var MultiSelectFooter = ({ size = "sm", onReset, onSelectAll, className }) => /* @__PURE__ */ jsxs(View, { className: cx("border-secondary flex-row items-center justify-between border-t p-3", className), children: [
1128
+ /* @__PURE__ */ jsx(Button, { size: footerButtonSize[size], color: "secondary", onPress: onReset, children: "Reset" }),
1129
+ /* @__PURE__ */ jsx(Button, { size: footerButtonSize[size], color: "secondary", onPress: onSelectAll, children: "Select all" })
1130
+ ] });
1131
+ var MultiSelectEmptyState = ({ title = "No results found", description = "Please try a different search term.", onClearSearch, className }) => {
1132
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
1133
+ return /* @__PURE__ */ jsxs(View, { className: cx("items-center gap-3 px-4 py-4", className), children: [
1134
+ /* @__PURE__ */ jsx(View, { className: "bg-secondary size-10 items-center justify-center rounded-lg", children: /* @__PURE__ */ jsx(MagnifyingGlassIcon, { size: 20, color: fgQuaternary }) }),
1135
+ /* @__PURE__ */ jsxs(View, { className: "items-center gap-0.5", children: [
1136
+ /* @__PURE__ */ jsx(Text, { className: "text-primary text-center text-sm font-semibold", children: title }),
1137
+ /* @__PURE__ */ jsx(Text, { className: "text-tertiary text-center text-sm", children: description })
1138
+ ] }),
1139
+ onClearSearch ? /* @__PURE__ */ jsx(Button, { size: "sm", color: "link-color", onPress: onClearSearch, children: "Clear search" }) : null
1140
+ ] });
1141
+ };
1142
+ var MultiSelectRoot = ({
1143
+ items = [],
1144
+ children,
1145
+ size = "md",
1146
+ selectedKeys: selectedKeysProp,
1147
+ defaultSelectedKeys,
1148
+ onSelectionChange,
1149
+ isDisabled,
1150
+ isInvalid,
1151
+ isRequired,
1152
+ placeholder = "Select",
1153
+ label,
1154
+ hint,
1155
+ hideRequiredIndicator,
1156
+ popoverClassName,
1157
+ mobileOptions,
1158
+ className,
1159
+ onReset,
1160
+ onSelectAll,
1161
+ showFooter = true,
1162
+ showSearch = true,
1163
+ emptyStateTitle,
1164
+ emptyStateDescription,
1165
+ selectedCountFormatter,
1166
+ supportingText
1167
+ }) => {
1168
+ const fgQuaternary = useNativeVariable("--color-fg-quaternary") ?? "#a4a7ae";
1169
+ const [open, setOpen] = useState(false);
1170
+ const [searchValue, setSearchValue] = useState("");
1171
+ const [uncontrolled, setUncontrolled] = useState(defaultSelectedKeys ?? /* @__PURE__ */ new Set());
1172
+ const selectedKeys = selectedKeysProp ?? uncontrolled;
1173
+ const selected = selectionSet(selectedKeys, items);
1174
+ const rows = useMemo(() => items.filter((item) => itemMatches(item, searchValue)), [items, searchValue]);
1175
+ const count = selected.size;
1176
+ const toggle = (id) => {
1177
+ const next = /* @__PURE__ */ new Set();
1178
+ items.forEach((item) => {
1179
+ const on = selectIdKey(item.id) === selectIdKey(id) ? !selected.has(selectIdKey(id)) : selected.has(selectIdKey(item.id));
1180
+ if (on) next.add(item.id);
1181
+ });
1182
+ if (selectedKeysProp === void 0) setUncontrolled(next);
1183
+ onSelectionChange?.(next);
1184
+ };
1185
+ const menuValue = useMemo(
1186
+ () => ({
1187
+ size,
1188
+ isSelected: (id) => selected.has(selectIdKey(id)),
1189
+ onSelect: toggle
1190
+ }),
1191
+ [size, selectedKeys, items]
1192
+ );
1193
+ const countLabel = selectedCountFormatter ? selectedCountFormatter(count) : `${count} selected`;
1194
+ const list = typeof children === "function" ? rows.map((item) => /* @__PURE__ */ jsx(View, { children: children(item) }, selectIdKey(item.id))) : children;
1195
+ 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: [
1196
+ label ? /* @__PURE__ */ jsx(Label, { isRequired: Boolean(isRequired && !hideRequiredIndicator), isInvalid, children: label }) : null,
1197
+ /* @__PURE__ */ jsxs(
1198
+ Pressable,
1199
+ {
1200
+ accessibilityRole: "button",
1201
+ disabled: isDisabled,
1202
+ onPress: () => {
1203
+ if (!isDisabled) setOpen(true);
1204
+ },
1205
+ className: selectFieldClassName({ size, focused: open, isInvalid, isDisabled }),
1206
+ children: [
1207
+ /* @__PURE__ */ jsx(View, { className: cx("min-w-0 flex-1 flex-row flex-wrap items-center", sizes[size].textGap), children: count > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
1208
+ typeof countLabel === "string" || typeof countLabel === "number" ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-primary font-medium", sizes[size].text), children: countLabel }) : countLabel,
1209
+ typeof supportingText === "string" || typeof supportingText === "number" ? /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-tertiary", sizes[size].text), children: supportingText }) : supportingText
1210
+ ] }) : /* @__PURE__ */ jsx(Text, { numberOfLines: 1, className: cx("text-placeholder", sizes[size].text), children: placeholder }) }),
1211
+ /* @__PURE__ */ jsx(CaretDownIcon, { size: size === "lg" ? 20 : 16, color: fgQuaternary })
1212
+ ]
1213
+ }
1214
+ ),
1215
+ /* @__PURE__ */ jsx(Popover, { open, onClose: () => setOpen(false), size, mobileOptions: { title: label, ...mobileOptions }, className: popoverClassName, children: /* @__PURE__ */ jsxs(View, { children: [
1216
+ showSearch ? /* @__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: [
1217
+ /* @__PURE__ */ jsx(MagnifyingGlassIcon, { size: sizes[size].icon, color: fgQuaternary }),
1218
+ /* @__PURE__ */ jsx(
1219
+ TextInput,
1220
+ {
1221
+ value: searchValue,
1222
+ placeholder: "Search",
1223
+ onChangeText: setSearchValue,
1224
+ placeholderTextColor: "#737373",
1225
+ className: cx("text-primary min-w-0 flex-1", inputStyles.input, searchSizes[size].text),
1226
+ style: { includeFontPadding: false, paddingVertical: 0 }
1227
+ }
1228
+ )
1229
+ ] }) }) : null,
1230
+ rows.length === 0 ? /* @__PURE__ */ jsx(
1231
+ MultiSelectEmptyState,
1232
+ {
1233
+ title: emptyStateTitle,
1234
+ description: emptyStateDescription,
1235
+ onClearSearch: searchValue ? () => setSearchValue("") : void 0
1236
+ }
1237
+ ) : list,
1238
+ showFooter ? /* @__PURE__ */ jsx(MultiSelectFooter, { size, onReset, onSelectAll }) : null
1239
+ ] }) }),
1240
+ hint ? /* @__PURE__ */ jsx(HintText, { isInvalid, size, children: hint }) : null
1241
+ ] }) }) });
1242
+ };
1243
+ var MultiSelect = Object.assign(MultiSelectRoot, {
1244
+ Item: SelectItem,
1245
+ Footer: MultiSelectFooter,
1246
+ EmptyState: MultiSelectEmptyState
1247
+ });
1248
+
1249
+ export { MultiSelect, MultiSelectEmptyState, MultiSelectFooter };
1250
+ //# sourceMappingURL=multi-select.js.map
1251
+ //# sourceMappingURL=multi-select.js.map