elseware-ui 3.0.0 → 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.
@@ -1,8 +1,9 @@
1
- import { Pressable, View, ActivityIndicator, Text } from 'react-native';
1
+ import { Pressable, View, ActivityIndicator, Text, Animated, Easing, TextInput } from 'react-native';
2
2
  import { twMerge } from 'tailwind-merge';
3
- import { createContext, useState, useContext } from 'react';
3
+ import { createContext, useState, useContext, useRef, useEffect } from 'react';
4
4
  import { jsx } from 'react/jsx-runtime';
5
5
  import { jsx as jsx$1, jsxs } from 'nativewind/jsx-runtime';
6
+ import { ErrorMessage, useField } from 'formik';
6
7
 
7
8
  // src/components/data-entry/button/native/Button.native.tsx
8
9
 
@@ -95,14 +96,14 @@ function useResolvedButtonConfig({
95
96
  // src/data/styles.tsx
96
97
  var variantsSolid = {
97
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",
98
- ["primary" /* primary */]: "bg-gradient-to-r from-eui-primary-500 to-eui-primary-600 text-white hover:brightness-110",
99
- ["secondary" /* secondary */]: "bg-gradient-to-r from-eui-secondary-600 to-eui-secondary-500 text-white hover:brightness-110",
100
- ["success" /* success */]: "bg-gradient-to-r from-eui-success-600 to-eui-success-500 text-white hover:brightness-110",
101
- ["danger" /* danger */]: "bg-gradient-to-r from-eui-danger-600 to-eui-danger-500 text-white hover:brightness-110",
102
- ["warning" /* warning */]: "bg-gradient-to-r from-eui-warning-500 to-eui-warning-400 text-black hover:brightness-105",
103
- ["info" /* info */]: "bg-gradient-to-r from-eui-info-600 to-eui-info-500 text-white hover:brightness-110",
104
- ["light" /* light */]: "bg-gradient-to-r from-eui-light-400 to-eui-light-300 text-gray-900 hover:brightness-105 dark:from-gray-200 dark:to-gray-100 dark:text-gray-900",
105
- ["dark" /* dark */]: "bg-gradient-to-r from-eui-dark-400 to-eui-dark-500 text-white hover:brightness-110 dark:from-eui-dark-300 dark:to-eui-dark-400"
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"
106
107
  };
107
108
  var variantsLite = {
108
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",
@@ -126,6 +127,17 @@ var variantsGhost = {
126
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",
127
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"
128
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
+ };
129
141
  var shapes = {
130
142
  ["square" /* square */]: "rounded-none",
131
143
  ["roundedSquare" /* roundedSquare */]: "rounded-md",
@@ -154,7 +166,7 @@ function resolveButtonVariantStyles({
154
166
  ghost: variantsGhost
155
167
  });
156
168
  }
157
- function getButtonTextColorClassName(className) {
169
+ function getButtonLabelColorClassName(className) {
158
170
  return className.split(/\s+/).filter(
159
171
  (token) => token.startsWith("text-") || token.startsWith("dark:text-") || token.startsWith("disabled:text-")
160
172
  ).join(" ");
@@ -201,8 +213,6 @@ function Button({
201
213
  block = false,
202
214
  compact = false,
203
215
  mode,
204
- buttonColor,
205
- textColor,
206
216
  contentClassName,
207
217
  labelClassName,
208
218
  className,
@@ -210,9 +220,6 @@ function Button({
210
220
  appearance,
211
221
  shape,
212
222
  size,
213
- style,
214
- contentStyle,
215
- labelStyle,
216
223
  accessibilityRole = "button",
217
224
  accessibilityState,
218
225
  type: _type,
@@ -240,21 +247,9 @@ function Button({
240
247
  appearance: resolvedAppearance,
241
248
  variant: resolvedVariant
242
249
  });
243
- const textColorClassName = getButtonTextColorClassName(variantStyles);
244
- const rootStyle = {
245
- ...mode === "text" ? {
246
- backgroundColor: "transparent",
247
- borderColor: "transparent"
248
- } : null,
249
- ...buttonColor && mode !== "text" ? {
250
- backgroundColor: buttonColor,
251
- borderColor: buttonColor
252
- } : null,
253
- ...!buttonColor && textColor && resolvedAppearance !== "solid" ? { borderColor: textColor } : null
254
- };
255
- const labelTextStyle = textColor ? { color: textColor } : null;
250
+ const labelColorClassName = getButtonLabelColorClassName(variantStyles);
256
251
  const content = text ?? children;
257
- const resolvedIcon = typeof icon === "function" ? icon({ color: textColor ?? "currentColor", size: iconSize }) : icon;
252
+ const resolvedIcon = typeof icon === "function" ? icon({ color: "currentColor", size: iconSize }) : icon;
258
253
  return /* @__PURE__ */ jsx$1(
259
254
  Pressable,
260
255
  {
@@ -278,10 +273,8 @@ function Button({
278
273
  disabled: disabled || loading,
279
274
  onPress,
280
275
  style: ({ pressed }) => [
281
- rootStyle,
282
276
  pressed && !disabled && !loading ? { opacity: 0.82 } : null,
283
- disabled || loading ? { opacity: 0.55 } : null,
284
- style
277
+ disabled || loading ? { opacity: 0.55 } : null
285
278
  ],
286
279
  children: /* @__PURE__ */ jsxs(
287
280
  View,
@@ -290,7 +283,6 @@ function Button({
290
283
  "z-10 flex-row items-center justify-center gap-2",
291
284
  contentClassName
292
285
  ),
293
- style: contentStyle,
294
286
  children: [
295
287
  loading ? /* @__PURE__ */ jsx$1(
296
288
  View,
@@ -299,14 +291,7 @@ function Button({
299
291
  "shrink-0 items-center justify-center",
300
292
  metrics.slotClassName
301
293
  ),
302
- children: /* @__PURE__ */ jsx$1(
303
- ActivityIndicator,
304
- {
305
- className: textColorClassName,
306
- color: textColor,
307
- size: "small"
308
- }
309
- )
294
+ children: /* @__PURE__ */ jsx$1(ActivityIndicator, { className: labelColorClassName, size: "small" })
310
295
  }
311
296
  ) : null,
312
297
  !loading && resolvedIcon ? /* @__PURE__ */ jsx$1(
@@ -325,11 +310,11 @@ function Button({
325
310
  className: cn(
326
311
  "font-bold",
327
312
  metrics.labelClassName,
328
- textColorClassName,
313
+ labelColorClassName,
329
314
  labelClassName
330
315
  ),
331
316
  numberOfLines: 1,
332
- style: [nativeLabelBaseStyle, labelTextStyle, labelStyle],
317
+ style: nativeLabelBaseStyle,
333
318
  children: content
334
319
  }
335
320
  ) }) : content
@@ -340,7 +325,580 @@ function Button({
340
325
  );
341
326
  }
342
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
+ }
343
901
 
344
- export { Button_native_default as Button, EUIProvider, resolveWithGlobal, useEUIConfig };
902
+ export { Button_native_default as Button, Checkbox, EUIProvider, Input, InputLabel, InputResponse, resolveWithGlobal, useEUIConfig };
345
903
  //# sourceMappingURL=index.native.mjs.map
346
904
  //# sourceMappingURL=index.native.mjs.map