elseware-ui 2.40.4 → 3.0.1

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,904 @@
1
+ import { Pressable, View, ActivityIndicator, Text, Animated, Easing, TextInput } from 'react-native';
2
+ import { twMerge } from 'tailwind-merge';
3
+ import { createContext, useState, useContext, useRef, useEffect } from 'react';
4
+ import { jsx } from 'react/jsx-runtime';
5
+ import { jsx as jsx$1, jsxs } from 'nativewind/jsx-runtime';
6
+ import { ErrorMessage, useField } from 'formik';
7
+
8
+ // src/components/data-entry/button/native/Button.native.tsx
9
+
10
+ // node_modules/clsx/dist/clsx.mjs
11
+ function r(e) {
12
+ var t, f, n = "";
13
+ if ("string" == typeof e || "number" == typeof e) n += e;
14
+ else if ("object" == typeof e) if (Array.isArray(e)) {
15
+ var o = e.length;
16
+ for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
17
+ } else for (f in e) e[f] && (n && (n += " "), n += f);
18
+ return n;
19
+ }
20
+ function clsx() {
21
+ for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
22
+ return n;
23
+ }
24
+ var clsx_default = clsx;
25
+ function cn(...inputs) {
26
+ return twMerge(clsx_default(inputs));
27
+ }
28
+
29
+ // src/utils/styles.ts
30
+ function resolveAppearanceStyles({
31
+ appearance = "solid",
32
+ variant = "default",
33
+ solid,
34
+ lite,
35
+ ghost
36
+ }) {
37
+ switch (appearance) {
38
+ case "ghost":
39
+ return ghost[variant];
40
+ case "lite":
41
+ return lite[variant];
42
+ default:
43
+ return solid[variant];
44
+ }
45
+ }
46
+ var EUIContext = createContext(null);
47
+ var EUIProvider = ({
48
+ config,
49
+ children
50
+ }) => {
51
+ const [state, setState] = useState(config);
52
+ return /* @__PURE__ */ jsx(EUIContext.Provider, { value: { config: state, setConfig: setState }, children });
53
+ };
54
+ var useEUIConfig = () => {
55
+ const ctx = useContext(EUIContext);
56
+ if (!ctx) {
57
+ throw new Error("useEUIConfig must be used inside EUIProvider");
58
+ }
59
+ return ctx;
60
+ };
61
+
62
+ // src/components/eui/resolveGlobalConfigs.tsx
63
+ function resolveWithGlobal(config, props, defaults) {
64
+ return {
65
+ ...defaults,
66
+ ...config?.global ?? {},
67
+ ...props
68
+ };
69
+ }
70
+
71
+ // src/components/data-entry/button/base/Button.config.ts
72
+ var buttonModeAppearance = {
73
+ contained: "solid",
74
+ "contained-tonal": "lite",
75
+ outlined: "ghost",
76
+ text: "ghost"
77
+ };
78
+ function useResolvedButtonConfig({
79
+ compact = false,
80
+ mode,
81
+ variant,
82
+ appearance,
83
+ shape,
84
+ size
85
+ }) {
86
+ const eui = useEUIConfig();
87
+ const configuredSize = size ?? eui?.config?.global?.size ?? "md";
88
+ return {
89
+ shape: shape ?? eui?.config?.global?.shape ?? "square",
90
+ size: compact && configuredSize === "md" ? "sm" : configuredSize,
91
+ variant: variant ?? eui?.config?.global?.variant ?? "success",
92
+ appearance: appearance ?? (mode ? buttonModeAppearance[mode] : "solid")
93
+ };
94
+ }
95
+
96
+ // src/data/styles.tsx
97
+ var variantsSolid = {
98
+ ["default" /* default */]: "bg-gray-300 text-gray-900 hover:bg-gray-200 dark:bg-gray-700 dark:text-gray-100 dark:hover:bg-gray-600",
99
+ ["primary" /* primary */]: "bg-eui-primary-500 text-white hover:bg-eui-primary-600",
100
+ ["secondary" /* secondary */]: "bg-eui-secondary-500 text-white hover:bg-eui-secondary-600",
101
+ ["success" /* success */]: "bg-eui-success-500 text-white hover:bg-eui-success-600",
102
+ ["danger" /* danger */]: "bg-eui-danger-500 text-white hover:bg-eui-danger-600",
103
+ ["warning" /* warning */]: "bg-eui-warning-500 text-black hover:bg-eui-warning-400",
104
+ ["info" /* info */]: "bg-eui-info-500 text-white hover:bg-eui-info-600",
105
+ ["light" /* light */]: "bg-eui-light-400 text-gray-900 hover:bg-eui-light-300 dark:bg-gray-200 dark:text-gray-900 dark:hover:bg-gray-100",
106
+ ["dark" /* dark */]: "bg-eui-dark-500 text-white hover:bg-eui-dark-400 dark:bg-eui-dark-400 dark:hover:bg-eui-dark-300"
107
+ };
108
+ var variantsLite = {
109
+ ["default" /* default */]: "bg-gray-500/10 border border-gray-300 text-gray-700 dark:bg-gray-400/10 dark:border-gray-700 dark:text-gray-200",
110
+ ["primary" /* primary */]: "bg-eui-primary-500/10 border border-eui-primary-500/30 text-eui-primary-400 dark:text-eui-primary-300",
111
+ ["secondary" /* secondary */]: "bg-eui-secondary-500/10 border border-eui-secondary-500/30 text-eui-secondary-500 dark:text-eui-secondary-400",
112
+ ["success" /* success */]: "bg-eui-success-500/10 border border-eui-success-500/30 text-eui-success-500 dark:text-eui-success-400",
113
+ ["danger" /* danger */]: "bg-eui-danger-500/10 border border-eui-danger-500/30 text-eui-danger-500 dark:text-eui-danger-400",
114
+ ["warning" /* warning */]: "bg-eui-warning-500/10 border border-eui-warning-500/30 text-eui-warning-600 dark:text-eui-warning-400",
115
+ ["info" /* info */]: "bg-eui-info-500/10 border border-eui-info-500/30 text-eui-info-500 dark:text-eui-info-400",
116
+ ["light" /* light */]: "bg-white/40 border border-white/30 text-gray-800 dark:bg-white/10 dark:border-white/10 dark:text-gray-100",
117
+ ["dark" /* dark */]: "bg-eui-dark-500/10 border border-eui-dark-500/30 text-eui-dark-500 dark:text-eui-dark-300"
118
+ };
119
+ var variantsGhost = {
120
+ ["default" /* default */]: "bg-transparent border border-gray-300 text-gray-700 hover:bg-gray-100 dark:border-gray-700 dark:text-gray-200 dark:hover:bg-gray-800",
121
+ ["primary" /* primary */]: "bg-transparent border border-eui-primary-500 text-eui-primary-500 hover:bg-eui-primary-500/10 dark:text-eui-primary-300 dark:border-eui-primary-400",
122
+ ["secondary" /* secondary */]: "bg-transparent border border-eui-secondary-500 text-eui-secondary-500 hover:bg-eui-secondary-500/10 dark:text-eui-secondary-400 dark:border-eui-secondary-400",
123
+ ["success" /* success */]: "bg-transparent border border-eui-success-500 text-eui-success-500 hover:bg-eui-success-500/10 dark:text-eui-success-400 dark:border-eui-success-400",
124
+ ["danger" /* danger */]: "bg-transparent border border-eui-danger-500 text-eui-danger-500 hover:bg-eui-danger-500/10 dark:text-eui-danger-400 dark:border-eui-danger-400",
125
+ ["warning" /* warning */]: "bg-transparent border border-eui-warning-500 text-eui-warning-600 hover:bg-eui-warning-500/10 dark:text-eui-warning-400 dark:border-eui-warning-400",
126
+ ["info" /* info */]: "bg-transparent border border-eui-info-500 text-eui-info-500 hover:bg-eui-info-500/10 dark:text-eui-info-400 dark:border-eui-info-400",
127
+ ["light" /* light */]: "bg-transparent border border-gray-300 text-gray-700 hover:bg-white/10 dark:border-gray-500 dark:text-gray-100 dark:hover:bg-white/5",
128
+ ["dark" /* dark */]: "bg-transparent border border-eui-dark-500 text-eui-dark-500 hover:bg-eui-dark-500/10 dark:text-eui-dark-300 dark:border-eui-dark-300"
129
+ };
130
+ var textVariants = {
131
+ ["default" /* default */]: "eui-text-md",
132
+ ["primary" /* primary */]: "text-blue-500",
133
+ ["secondary" /* secondary */]: "text-gray-500",
134
+ ["success" /* success */]: "text-green-500",
135
+ ["danger" /* danger */]: "text-red-500",
136
+ ["warning" /* warning */]: "text-yellow-500",
137
+ ["info" /* info */]: "text-blue-400",
138
+ ["light" /* light */]: "text-gray-300",
139
+ ["dark" /* dark */]: "text-gray-900"
140
+ };
141
+ var shapes = {
142
+ ["square" /* square */]: "rounded-none",
143
+ ["roundedSquare" /* roundedSquare */]: "rounded-md",
144
+ ["softRoundedSquare" /* softRoundedSquare */]: "rounded-lg",
145
+ ["circle" /* circle */]: "rounded-full"
146
+ };
147
+
148
+ // src/components/data-entry/button/base/Button.styles.ts
149
+ var buttonShapes = shapes;
150
+ var buttonIconSizes = {
151
+ xs: 14,
152
+ sm: 16,
153
+ md: 18,
154
+ lg: 20,
155
+ xl: 22
156
+ };
157
+ function resolveButtonVariantStyles({
158
+ appearance,
159
+ variant
160
+ }) {
161
+ return resolveAppearanceStyles({
162
+ appearance,
163
+ variant,
164
+ solid: variantsSolid,
165
+ lite: variantsLite,
166
+ ghost: variantsGhost
167
+ });
168
+ }
169
+ function getButtonLabelColorClassName(className) {
170
+ return className.split(/\s+/).filter(
171
+ (token) => token.startsWith("text-") || token.startsWith("dark:text-") || token.startsWith("disabled:text-")
172
+ ).join(" ");
173
+ }
174
+
175
+ // src/components/data-entry/button/native/Button.native.styles.ts
176
+ var nativeButtonSizes = {
177
+ xs: {
178
+ rootClassName: "min-h-[30px] px-2.5 py-1",
179
+ labelClassName: "text-xs leading-[14px]",
180
+ slotClassName: "h-[14px] w-[14px]"
181
+ },
182
+ sm: {
183
+ rootClassName: "min-h-9 px-3 py-1.5",
184
+ labelClassName: "text-sm leading-4",
185
+ slotClassName: "h-4 w-4"
186
+ },
187
+ md: {
188
+ rootClassName: "min-h-11 px-4 py-2",
189
+ labelClassName: "text-[15px] leading-[18px]",
190
+ slotClassName: "h-[18px] w-[18px]"
191
+ },
192
+ lg: {
193
+ rootClassName: "min-h-[50px] px-[18px] py-3",
194
+ labelClassName: "text-[17px] leading-5",
195
+ slotClassName: "h-5 w-5"
196
+ },
197
+ xl: {
198
+ rootClassName: "min-h-14 px-[22px] py-4",
199
+ labelClassName: "text-[19px] leading-[22px]",
200
+ slotClassName: "h-[22px] w-[22px]"
201
+ }
202
+ };
203
+ var nativeLabelBaseStyle = {
204
+ includeFontPadding: false,
205
+ textAlignVertical: "center"
206
+ };
207
+ function Button({
208
+ icon,
209
+ text,
210
+ children,
211
+ loading = false,
212
+ disabled = false,
213
+ block = false,
214
+ compact = false,
215
+ mode,
216
+ contentClassName,
217
+ labelClassName,
218
+ className,
219
+ variant,
220
+ appearance,
221
+ shape,
222
+ size,
223
+ accessibilityRole = "button",
224
+ accessibilityState,
225
+ type: _type,
226
+ onClick: _onClick,
227
+ onMouseMove: _onMouseMove,
228
+ onPress,
229
+ ...rest
230
+ }) {
231
+ const {
232
+ shape: resolvedShape,
233
+ size: resolvedSize,
234
+ variant: resolvedVariant,
235
+ appearance: resolvedAppearance
236
+ } = useResolvedButtonConfig({
237
+ compact,
238
+ mode,
239
+ variant,
240
+ appearance,
241
+ shape,
242
+ size
243
+ });
244
+ const metrics = nativeButtonSizes[resolvedSize];
245
+ const iconSize = buttonIconSizes[resolvedSize];
246
+ const variantStyles = resolveButtonVariantStyles({
247
+ appearance: resolvedAppearance,
248
+ variant: resolvedVariant
249
+ });
250
+ const labelColorClassName = getButtonLabelColorClassName(variantStyles);
251
+ const content = text ?? children;
252
+ const resolvedIcon = typeof icon === "function" ? icon({ color: "currentColor", size: iconSize }) : icon;
253
+ return /* @__PURE__ */ jsx$1(
254
+ Pressable,
255
+ {
256
+ ...rest,
257
+ accessibilityRole,
258
+ accessibilityState: {
259
+ disabled: disabled || loading,
260
+ ...accessibilityState
261
+ },
262
+ className: cn(
263
+ "relative items-center justify-center overflow-hidden",
264
+ variantStyles,
265
+ buttonShapes[resolvedShape],
266
+ metrics.rootClassName,
267
+ block && "w-full",
268
+ mode === "text" && "border-transparent bg-transparent",
269
+ (disabled || loading) && "opacity-55",
270
+ !disabled && !loading && "active:opacity-80",
271
+ className
272
+ ),
273
+ disabled: disabled || loading,
274
+ onPress,
275
+ style: ({ pressed }) => [
276
+ pressed && !disabled && !loading ? { opacity: 0.82 } : null,
277
+ disabled || loading ? { opacity: 0.55 } : null
278
+ ],
279
+ children: /* @__PURE__ */ jsxs(
280
+ View,
281
+ {
282
+ className: cn(
283
+ "z-10 flex-row items-center justify-center gap-2",
284
+ contentClassName
285
+ ),
286
+ children: [
287
+ loading ? /* @__PURE__ */ jsx$1(
288
+ View,
289
+ {
290
+ className: cn(
291
+ "shrink-0 items-center justify-center",
292
+ metrics.slotClassName
293
+ ),
294
+ children: /* @__PURE__ */ jsx$1(ActivityIndicator, { className: labelColorClassName, size: "small" })
295
+ }
296
+ ) : null,
297
+ !loading && resolvedIcon ? /* @__PURE__ */ jsx$1(
298
+ View,
299
+ {
300
+ className: cn(
301
+ "shrink-0 items-center justify-center",
302
+ metrics.slotClassName
303
+ ),
304
+ children: resolvedIcon
305
+ }
306
+ ) : null,
307
+ typeof content === "string" || typeof content === "number" ? /* @__PURE__ */ jsx$1(View, { className: "items-center justify-center", children: /* @__PURE__ */ jsx$1(
308
+ Text,
309
+ {
310
+ className: cn(
311
+ "font-bold",
312
+ metrics.labelClassName,
313
+ labelColorClassName,
314
+ labelClassName
315
+ ),
316
+ numberOfLines: 1,
317
+ style: nativeLabelBaseStyle,
318
+ children: content
319
+ }
320
+ ) }) : content
321
+ ]
322
+ }
323
+ )
324
+ }
325
+ );
326
+ }
327
+ var Button_native_default = Button;
328
+ function isMultiCheckbox(props) {
329
+ return Array.isArray(props.options);
330
+ }
331
+ function useResolvedCheckboxConfig({
332
+ label,
333
+ placeholder,
334
+ variant,
335
+ shape
336
+ }) {
337
+ const eui = useEUIConfig();
338
+ return {
339
+ shape: shape ?? eui?.config?.global?.shape ?? "roundedSquare",
340
+ variant: variant ?? "secondary",
341
+ label: label ?? placeholder
342
+ };
343
+ }
344
+ function useCheckboxFieldState(props) {
345
+ const isMulti = isMultiCheckbox(props);
346
+ const [multiField, multiMeta, multiHelpers] = useField(
347
+ props
348
+ );
349
+ const [singleField, singleMeta, singleHelpers] = useField(
350
+ props
351
+ );
352
+ return {
353
+ isMulti,
354
+ multiField,
355
+ multiMeta,
356
+ multiHelpers,
357
+ singleField,
358
+ singleMeta,
359
+ singleHelpers
360
+ };
361
+ }
362
+
363
+ // src/components/data-entry/checkbox/base/Checkbox.styles.ts
364
+ var checkboxShapes = shapes;
365
+ var checkboxGroupClassName = "flex flex-col gap-2";
366
+ var checkboxOptionRowClassName = "flex flex-row items-start gap-3";
367
+ var checkboxLabelClassName = "cursor-pointer select-none text-sm leading-relaxed text-gray-800 dark:text-gray-200";
368
+ var checkboxIndicatorDisabledClassName = "cursor-not-allowed opacity-50";
369
+
370
+ // src/components/data-entry/checkbox/native/Checkbox.native.styles.ts
371
+ var nativeCheckboxVariants = {
372
+ default: {
373
+ checkedClassName: "border-eui-secondary-600 bg-eui-secondary-600 dark:border-eui-secondary-500 dark:bg-eui-secondary-500",
374
+ iconClassName: "text-white"
375
+ },
376
+ primary: {
377
+ checkedClassName: "border-eui-primary-600 bg-eui-primary-600 dark:border-eui-primary-500 dark:bg-eui-primary-500",
378
+ iconClassName: "text-white"
379
+ },
380
+ secondary: {
381
+ checkedClassName: "border-eui-secondary-600 bg-eui-secondary-600 dark:border-eui-secondary-500 dark:bg-eui-secondary-500",
382
+ iconClassName: "text-white"
383
+ },
384
+ success: {
385
+ checkedClassName: "border-eui-success-600 bg-eui-success-600 dark:border-eui-success-500 dark:bg-eui-success-500",
386
+ iconClassName: "text-white"
387
+ },
388
+ danger: {
389
+ checkedClassName: "border-eui-danger-600 bg-eui-danger-600 dark:border-eui-danger-500 dark:bg-eui-danger-500",
390
+ iconClassName: "text-white"
391
+ },
392
+ warning: {
393
+ checkedClassName: "border-eui-warning-500 bg-eui-warning-500 dark:border-eui-warning-400 dark:bg-eui-warning-400",
394
+ iconClassName: "text-black"
395
+ },
396
+ info: {
397
+ checkedClassName: "border-eui-info-600 bg-eui-info-600 dark:border-eui-info-500 dark:bg-eui-info-500",
398
+ iconClassName: "text-white"
399
+ },
400
+ light: {
401
+ checkedClassName: "border-eui-light-400 bg-eui-light-400 dark:border-gray-200 dark:bg-gray-200",
402
+ iconClassName: "text-gray-900"
403
+ },
404
+ dark: {
405
+ checkedClassName: "border-eui-dark-500 bg-eui-dark-500 dark:border-eui-dark-300 dark:bg-eui-dark-300",
406
+ iconClassName: "text-white"
407
+ }
408
+ };
409
+ function resolveNativeCheckboxVariantStyles(variant) {
410
+ return nativeCheckboxVariants[variant];
411
+ }
412
+ function getIndicatorClassName({
413
+ checked,
414
+ className,
415
+ disabled,
416
+ indicatorClassName,
417
+ checkedIndicatorClassName,
418
+ resolvedShape,
419
+ variantCheckedClassName
420
+ }) {
421
+ return cn(
422
+ "h-5 w-5 shrink-0 items-center justify-center border-2 border-gray-300 bg-white dark:border-neutral-600 dark:bg-neutral-900",
423
+ checkboxShapes[resolvedShape],
424
+ indicatorClassName,
425
+ className,
426
+ checked && variantCheckedClassName,
427
+ checked && checkedIndicatorClassName,
428
+ disabled && checkboxIndicatorDisabledClassName
429
+ );
430
+ }
431
+ function Tick({
432
+ checkedIconClassName,
433
+ iconClassName
434
+ }) {
435
+ return /* @__PURE__ */ jsx$1(
436
+ Text,
437
+ {
438
+ className: cn(
439
+ "text-sm font-bold leading-none",
440
+ iconClassName,
441
+ checkedIconClassName
442
+ ),
443
+ children: "\u2713"
444
+ }
445
+ );
446
+ }
447
+ function Checkbox(checkboxProps) {
448
+ const {
449
+ label,
450
+ placeholder,
451
+ variant,
452
+ shape,
453
+ disabled = false,
454
+ className,
455
+ groupClassName,
456
+ optionClassName,
457
+ indicatorClassName,
458
+ checkedIndicatorClassName,
459
+ checkedIconClassName,
460
+ labelClassName
461
+ } = checkboxProps;
462
+ const { shape: resolvedShape, variant: resolvedVariant, label: resolvedLabel } = useResolvedCheckboxConfig({
463
+ label,
464
+ placeholder,
465
+ variant,
466
+ shape
467
+ });
468
+ const {
469
+ isMulti,
470
+ multiField,
471
+ multiMeta,
472
+ multiHelpers,
473
+ singleField,
474
+ singleMeta,
475
+ singleHelpers
476
+ } = useCheckboxFieldState(checkboxProps);
477
+ const variantStyles = resolveNativeCheckboxVariantStyles(resolvedVariant);
478
+ const activeMeta = isMulti ? multiMeta : singleMeta;
479
+ const multiProps = isMultiCheckbox(checkboxProps) ? checkboxProps : null;
480
+ const singleChecked = singleField.value;
481
+ const errorText = activeMeta.touched && typeof activeMeta.error === "string" ? activeMeta.error : null;
482
+ return /* @__PURE__ */ jsxs(View, { className: cn(checkboxGroupClassName, groupClassName), children: [
483
+ !isMulti && /* @__PURE__ */ jsxs(
484
+ Pressable,
485
+ {
486
+ accessibilityRole: "checkbox",
487
+ accessibilityState: {
488
+ checked: singleChecked,
489
+ disabled
490
+ },
491
+ className: cn(checkboxOptionRowClassName, optionClassName),
492
+ disabled,
493
+ onPress: () => singleHelpers.setValue(!singleChecked),
494
+ children: [
495
+ /* @__PURE__ */ jsx$1(
496
+ View,
497
+ {
498
+ className: getIndicatorClassName({
499
+ checked: singleChecked,
500
+ className,
501
+ disabled,
502
+ indicatorClassName,
503
+ checkedIndicatorClassName,
504
+ resolvedShape,
505
+ variantCheckedClassName: variantStyles.checkedClassName
506
+ }),
507
+ children: singleChecked ? /* @__PURE__ */ jsx$1(
508
+ Tick,
509
+ {
510
+ checkedIconClassName,
511
+ iconClassName: variantStyles.iconClassName
512
+ }
513
+ ) : null
514
+ }
515
+ ),
516
+ resolvedLabel ? /* @__PURE__ */ jsx$1(Text, { className: cn(checkboxLabelClassName, labelClassName), children: resolvedLabel }) : null
517
+ ]
518
+ }
519
+ ),
520
+ isMulti && multiProps?.options.map((option) => {
521
+ const values = multiField.value ?? [];
522
+ const checked = values.includes(option.value);
523
+ const optionDisabled = disabled || option.disabled === true;
524
+ return /* @__PURE__ */ jsxs(
525
+ Pressable,
526
+ {
527
+ accessibilityRole: "checkbox",
528
+ accessibilityState: {
529
+ checked,
530
+ disabled: optionDisabled
531
+ },
532
+ className: cn(checkboxOptionRowClassName, optionClassName),
533
+ disabled: optionDisabled,
534
+ onPress: () => multiHelpers.setValue(
535
+ checked ? values.filter((value) => value !== option.value) : [...values, option.value]
536
+ ),
537
+ children: [
538
+ /* @__PURE__ */ jsx$1(
539
+ View,
540
+ {
541
+ className: getIndicatorClassName({
542
+ checked,
543
+ className,
544
+ disabled: optionDisabled,
545
+ indicatorClassName,
546
+ checkedIndicatorClassName,
547
+ resolvedShape,
548
+ variantCheckedClassName: variantStyles.checkedClassName
549
+ }),
550
+ children: checked ? /* @__PURE__ */ jsx$1(
551
+ Tick,
552
+ {
553
+ checkedIconClassName,
554
+ iconClassName: variantStyles.iconClassName
555
+ }
556
+ ) : null
557
+ }
558
+ ),
559
+ /* @__PURE__ */ jsx$1(
560
+ Text,
561
+ {
562
+ className: cn(
563
+ checkboxLabelClassName,
564
+ optionDisabled && "opacity-60",
565
+ labelClassName
566
+ ),
567
+ children: option.label
568
+ }
569
+ )
570
+ ]
571
+ },
572
+ option.value
573
+ );
574
+ }),
575
+ errorText ? /* @__PURE__ */ jsx$1(Text, { className: "px-2 py-1 text-sm font-medium text-eui-danger-500", children: errorText }) : null
576
+ ] });
577
+ }
578
+
579
+ // src/components/data-entry/input/input-label/base/InputLabel.styles.ts
580
+ var inputLabelStaticClassName = "pointer-events-none select-none px-0 text-[13.5px] leading-none text-[#6B7280]";
581
+ var inputLabelBaseClassName = "pointer-events-none absolute left-3 z-10 select-none bg-white/95 px-1 font-medium leading-none dark:bg-eui-dark-800";
582
+ var inputLabelErrorClassName = "text-[#6B7280]";
583
+ var inputLabelDisabledClassName = "opacity-60";
584
+ var nativeInputLabelColors = {
585
+ default: "#6B7280",
586
+ disabled: "#9CA3AF"
587
+ };
588
+ var nativeInputLabelStyle = {
589
+ left: 12,
590
+ position: "absolute",
591
+ zIndex: 10
592
+ };
593
+ var nativeInputLabelMetrics = {
594
+ floatingFontSize: 12,
595
+ floatingTop: 6,
596
+ restingFontSize: 16,
597
+ restingTop: 18
598
+ };
599
+ function getLabelColor({ disabled }) {
600
+ if (disabled) {
601
+ return nativeInputLabelColors.disabled;
602
+ }
603
+ return nativeInputLabelColors.default;
604
+ }
605
+ function InputLabel({
606
+ text,
607
+ children,
608
+ className,
609
+ floating,
610
+ errored = false,
611
+ disabled = false,
612
+ animatedValue
613
+ }) {
614
+ const isFloatingLabel = typeof floating === "boolean";
615
+ const progress = animatedValue;
616
+ const animatedStyle = progress ? {
617
+ fontSize: progress.interpolate({
618
+ inputRange: [0, 1],
619
+ outputRange: [
620
+ nativeInputLabelMetrics.restingFontSize,
621
+ nativeInputLabelMetrics.floatingFontSize
622
+ ]
623
+ }),
624
+ lineHeight: progress.interpolate({
625
+ inputRange: [0, 1],
626
+ outputRange: [
627
+ nativeInputLabelMetrics.restingFontSize,
628
+ nativeInputLabelMetrics.floatingFontSize
629
+ ]
630
+ }),
631
+ top: progress.interpolate({
632
+ inputRange: [0, 1],
633
+ outputRange: [
634
+ nativeInputLabelMetrics.restingTop,
635
+ nativeInputLabelMetrics.floatingTop
636
+ ]
637
+ })
638
+ } : {
639
+ fontSize: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
640
+ lineHeight: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
641
+ top: floating === true ? nativeInputLabelMetrics.floatingTop : nativeInputLabelMetrics.restingTop
642
+ };
643
+ return /* @__PURE__ */ jsx$1(
644
+ Animated.Text,
645
+ {
646
+ className: cn(
647
+ isFloatingLabel ? inputLabelBaseClassName : inputLabelStaticClassName,
648
+ isFloatingLabel && "bg-transparent px-0 dark:bg-transparent",
649
+ errored && inputLabelErrorClassName,
650
+ disabled && inputLabelDisabledClassName,
651
+ className
652
+ ),
653
+ style: [
654
+ isFloatingLabel ? nativeInputLabelStyle : null,
655
+ isFloatingLabel ? animatedStyle : null,
656
+ {
657
+ color: getLabelColor({ disabled }),
658
+ includeFontPadding: false
659
+ }
660
+ ],
661
+ children: text || children
662
+ }
663
+ );
664
+ }
665
+
666
+ // src/components/data-entry/input/input-response/base/InputResponse.styles.ts
667
+ var inputResponseBaseClassName = "px-2 pt-1.5 text-sm font-medium";
668
+ var inputResponseVariants = textVariants;
669
+ function InputResponse({
670
+ name,
671
+ visibility = false,
672
+ variant = "default",
673
+ className,
674
+ message
675
+ }) {
676
+ const [mounted, setMounted] = useState(Boolean(visibility));
677
+ const progress = useRef(new Animated.Value(visibility ? 1 : 0)).current;
678
+ useEffect(() => {
679
+ if (visibility) {
680
+ setMounted(true);
681
+ }
682
+ Animated.timing(progress, {
683
+ duration: visibility ? 180 : 120,
684
+ easing: visibility ? Easing.out(Easing.cubic) : Easing.in(Easing.cubic),
685
+ toValue: visibility ? 1 : 0,
686
+ useNativeDriver: true
687
+ }).start(() => {
688
+ if (!visibility) {
689
+ setMounted(false);
690
+ }
691
+ });
692
+ }, [progress, visibility]);
693
+ if (!mounted) {
694
+ return null;
695
+ }
696
+ const animatedStyle = {
697
+ opacity: progress,
698
+ transform: [
699
+ {
700
+ translateY: progress.interpolate({
701
+ inputRange: [0, 1],
702
+ outputRange: [6, 0]
703
+ })
704
+ }
705
+ ]
706
+ };
707
+ const content = message ?? /* @__PURE__ */ jsx$1(ErrorMessage, { name, children: (errorMessage) => String(errorMessage) });
708
+ return /* @__PURE__ */ jsx$1(Animated.View, { className: "w-full", style: animatedStyle, children: /* @__PURE__ */ jsx$1(
709
+ Text,
710
+ {
711
+ className: cn(
712
+ inputResponseBaseClassName,
713
+ inputResponseVariants[variant],
714
+ className
715
+ ),
716
+ style: { includeFontPadding: false },
717
+ children: content
718
+ }
719
+ ) });
720
+ }
721
+ function resolveInputType({
722
+ passwordVisible,
723
+ type
724
+ }) {
725
+ return type === "password" && passwordVisible ? "text" : type;
726
+ }
727
+ function useResolvedInputConfig({
728
+ label,
729
+ placeholder,
730
+ shape,
731
+ type = "text"
732
+ }) {
733
+ const eui = useEUIConfig();
734
+ return {
735
+ shape: shape ?? eui?.config?.global?.shape ?? "square",
736
+ type,
737
+ label: label ?? placeholder
738
+ };
739
+ }
740
+ function useInputFieldState(props) {
741
+ const [field, meta, helpers] = useField(props);
742
+ return {
743
+ field,
744
+ meta,
745
+ helpers
746
+ };
747
+ }
748
+
749
+ // src/components/data-entry/input/input/base/Input.styles.ts
750
+ var inputShapes = shapes;
751
+ var inputRootClassName = "relative w-full";
752
+ var inputFrameClassName = "relative h-14 w-full overflow-hidden border bg-white/95 px-3 dark:bg-eui-dark-800";
753
+ var inputFrameIdleClassName = "border-gray-300 hover:border-gray-400 dark:border-eui-dark-300 dark:hover:border-eui-dark-200";
754
+ var inputFrameActiveClassName = "border-eui-secondary-600";
755
+ var inputFrameErrorClassName = "border-eui-danger-500";
756
+ var inputFrameDisabledClassName = "cursor-not-allowed opacity-60";
757
+ var inputControlClassName = "w-full bg-transparent pt-5 pb-2 text-base font-medium text-gray-950 dark:text-gray-50";
758
+
759
+ // src/components/data-entry/input/input/native/Input.native.styles.ts
760
+ var nativeInputControlClassName = "h-full";
761
+ var nativePasswordInputClassName = "pr-16";
762
+ var nativePasswordToggleClassName = "absolute right-3 top-[18px] h-5 items-center justify-center";
763
+ var nativePasswordToggleTextClassName = "text-xs font-semibold text-eui-dark-200";
764
+ var nativeInputControlStyle = {
765
+ backgroundColor: "transparent",
766
+ borderBottomWidth: 0,
767
+ borderColor: "transparent",
768
+ borderWidth: 0,
769
+ includeFontPadding: false,
770
+ outlineColor: "transparent",
771
+ outlineStyle: "none",
772
+ textAlignVertical: "center"
773
+ };
774
+ function Input(inputProps) {
775
+ const {
776
+ type = "text",
777
+ label,
778
+ placeholder,
779
+ inputClassName,
780
+ labelClassName,
781
+ responseClassName,
782
+ step: _step,
783
+ shape,
784
+ disabled = false,
785
+ className,
786
+ onBlur,
787
+ onFocus,
788
+ onChange: _onChange,
789
+ ..._props
790
+ } = inputProps;
791
+ const { field, helpers, meta } = useInputFieldState(inputProps);
792
+ const [focused, setFocused] = useState(false);
793
+ const [passwordVisible, setPasswordVisible] = useState(false);
794
+ const labelProgress = useRef(
795
+ new Animated.Value(String(field.value ?? "").length > 0 ? 1 : 0)
796
+ ).current;
797
+ const {
798
+ shape: resolvedShape,
799
+ type: resolvedType,
800
+ label: resolvedLabel
801
+ } = useResolvedInputConfig({
802
+ label,
803
+ placeholder,
804
+ shape,
805
+ type
806
+ });
807
+ const inputType = resolveInputType({
808
+ passwordVisible,
809
+ type: resolvedType
810
+ });
811
+ const hasError = Boolean(meta.touched && meta.error);
812
+ const errorText = hasError && typeof meta.error === "string" ? meta.error : null;
813
+ const hasValue = String(field.value ?? "").length > 0;
814
+ const floating = focused || hasValue;
815
+ useEffect(() => {
816
+ Animated.timing(labelProgress, {
817
+ duration: 190,
818
+ easing: Easing.out(Easing.cubic),
819
+ toValue: floating ? 1 : 0,
820
+ useNativeDriver: false
821
+ }).start();
822
+ }, [floating, labelProgress]);
823
+ const handleBlur = (event) => {
824
+ setFocused(false);
825
+ helpers.setTouched(true);
826
+ onBlur?.(event);
827
+ };
828
+ const handleFocus = (event) => {
829
+ setFocused(true);
830
+ onFocus?.(event);
831
+ };
832
+ return /* @__PURE__ */ jsxs(View, { className: inputRootClassName, children: [
833
+ /* @__PURE__ */ jsx$1(
834
+ View,
835
+ {
836
+ className: cn(
837
+ inputFrameClassName,
838
+ hasError ? inputFrameErrorClassName : focused ? inputFrameActiveClassName : inputFrameIdleClassName,
839
+ inputShapes[resolvedShape],
840
+ disabled && inputFrameDisabledClassName,
841
+ className
842
+ ),
843
+ children: /* @__PURE__ */ jsx$1(
844
+ TextInput,
845
+ {
846
+ accessibilityLabel: resolvedLabel,
847
+ className: cn(
848
+ inputControlClassName,
849
+ nativeInputControlClassName,
850
+ type === "password" && nativePasswordInputClassName,
851
+ inputClassName
852
+ ),
853
+ editable: !disabled,
854
+ keyboardType: inputType === "number" ? "numeric" : "default",
855
+ onBlur: handleBlur,
856
+ onChangeText: (value) => helpers.setValue(value),
857
+ onFocus: handleFocus,
858
+ placeholder: "",
859
+ secureTextEntry: type === "password" && !passwordVisible,
860
+ style: nativeInputControlStyle,
861
+ underlineColorAndroid: "transparent",
862
+ value: field.value ?? ""
863
+ }
864
+ )
865
+ }
866
+ ),
867
+ /* @__PURE__ */ jsx$1(
868
+ InputLabel,
869
+ {
870
+ animatedValue: labelProgress,
871
+ disabled,
872
+ errored: hasError,
873
+ floating,
874
+ text: resolvedLabel,
875
+ className: labelClassName
876
+ }
877
+ ),
878
+ type === "password" ? /* @__PURE__ */ jsx$1(
879
+ Pressable,
880
+ {
881
+ accessibilityRole: "button",
882
+ accessibilityLabel: passwordVisible ? "Hide password" : "Show password",
883
+ className: nativePasswordToggleClassName,
884
+ disabled,
885
+ onPress: () => setPasswordVisible((current) => !current),
886
+ children: /* @__PURE__ */ jsx$1(Text, { className: nativePasswordToggleTextClassName, children: passwordVisible ? "Hide" : "Show" })
887
+ }
888
+ ) : null,
889
+ /* @__PURE__ */ jsx$1(
890
+ InputResponse,
891
+ {
892
+ message: errorText,
893
+ name: field.name,
894
+ visibility: Boolean(errorText),
895
+ variant: "danger",
896
+ className: responseClassName
897
+ }
898
+ )
899
+ ] });
900
+ }
901
+
902
+ export { Button_native_default as Button, Checkbox, EUIProvider, Input, InputLabel, InputResponse, resolveWithGlobal, useEUIConfig };
903
+ //# sourceMappingURL=index.native.mjs.map
904
+ //# sourceMappingURL=index.native.mjs.map