elseware-ui 3.0.0 → 3.0.2

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 { Formik, 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,717 @@ 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 {
463
+ shape: resolvedShape,
464
+ variant: resolvedVariant,
465
+ label: resolvedLabel
466
+ } = useResolvedCheckboxConfig({
467
+ label,
468
+ placeholder,
469
+ variant,
470
+ shape
471
+ });
472
+ const {
473
+ isMulti,
474
+ multiField,
475
+ multiMeta,
476
+ multiHelpers,
477
+ singleField,
478
+ singleMeta,
479
+ singleHelpers
480
+ } = useCheckboxFieldState(checkboxProps);
481
+ const variantStyles = resolveNativeCheckboxVariantStyles(resolvedVariant);
482
+ const activeMeta = isMulti ? multiMeta : singleMeta;
483
+ const multiProps = isMultiCheckbox(checkboxProps) ? checkboxProps : null;
484
+ const singleChecked = singleField.value;
485
+ const errorText = activeMeta.touched && typeof activeMeta.error === "string" ? activeMeta.error : null;
486
+ return /* @__PURE__ */ jsxs(View, { className: cn(checkboxGroupClassName, groupClassName), children: [
487
+ !isMulti && /* @__PURE__ */ jsxs(
488
+ Pressable,
489
+ {
490
+ accessibilityRole: "checkbox",
491
+ accessibilityState: {
492
+ checked: singleChecked,
493
+ disabled
494
+ },
495
+ className: cn(checkboxOptionRowClassName, optionClassName),
496
+ disabled,
497
+ onPress: () => singleHelpers.setValue(!singleChecked),
498
+ children: [
499
+ /* @__PURE__ */ jsx$1(
500
+ View,
501
+ {
502
+ className: getIndicatorClassName({
503
+ checked: singleChecked,
504
+ className,
505
+ disabled,
506
+ indicatorClassName,
507
+ checkedIndicatorClassName,
508
+ resolvedShape,
509
+ variantCheckedClassName: variantStyles.checkedClassName
510
+ }),
511
+ children: singleChecked ? /* @__PURE__ */ jsx$1(
512
+ Tick,
513
+ {
514
+ checkedIconClassName,
515
+ iconClassName: variantStyles.iconClassName
516
+ }
517
+ ) : null
518
+ }
519
+ ),
520
+ resolvedLabel ? /* @__PURE__ */ jsx$1(Text, { className: cn(checkboxLabelClassName, labelClassName), children: resolvedLabel }) : null
521
+ ]
522
+ }
523
+ ),
524
+ isMulti && multiProps?.options.map((option) => {
525
+ const values = multiField.value ?? [];
526
+ const checked = values.includes(option.value);
527
+ const optionDisabled = disabled || option.disabled === true;
528
+ return /* @__PURE__ */ jsxs(
529
+ Pressable,
530
+ {
531
+ accessibilityRole: "checkbox",
532
+ accessibilityState: {
533
+ checked,
534
+ disabled: optionDisabled
535
+ },
536
+ className: cn(checkboxOptionRowClassName, optionClassName),
537
+ disabled: optionDisabled,
538
+ onPress: () => multiHelpers.setValue(
539
+ checked ? values.filter((value) => value !== option.value) : [...values, option.value]
540
+ ),
541
+ children: [
542
+ /* @__PURE__ */ jsx$1(
543
+ View,
544
+ {
545
+ className: getIndicatorClassName({
546
+ checked,
547
+ className,
548
+ disabled: optionDisabled,
549
+ indicatorClassName,
550
+ checkedIndicatorClassName,
551
+ resolvedShape,
552
+ variantCheckedClassName: variantStyles.checkedClassName
553
+ }),
554
+ children: checked ? /* @__PURE__ */ jsx$1(
555
+ Tick,
556
+ {
557
+ checkedIconClassName,
558
+ iconClassName: variantStyles.iconClassName
559
+ }
560
+ ) : null
561
+ }
562
+ ),
563
+ /* @__PURE__ */ jsx$1(
564
+ Text,
565
+ {
566
+ className: cn(
567
+ checkboxLabelClassName,
568
+ optionDisabled && "opacity-60",
569
+ labelClassName
570
+ ),
571
+ children: option.label
572
+ }
573
+ )
574
+ ]
575
+ },
576
+ option.value
577
+ );
578
+ }),
579
+ errorText ? /* @__PURE__ */ jsx$1(Text, { className: "px-2 py-1 text-sm font-medium text-eui-danger-500", children: errorText }) : null
580
+ ] });
581
+ }
582
+ function renderFormChildren(children, formik) {
583
+ return typeof children === "function" ? children(formik) : children;
584
+ }
585
+ function FormObservers({
586
+ formik,
587
+ onChange,
588
+ onDirtyChange
589
+ }) {
590
+ const prevValuesRef = useRef(formik.values);
591
+ useEffect(() => {
592
+ onDirtyChange?.(formik.dirty);
593
+ }, [formik.dirty, onDirtyChange]);
594
+ useEffect(() => {
595
+ if (!onChange) return;
596
+ const currentValues = formik.values;
597
+ const prevValues = prevValuesRef.current;
598
+ const changed = {};
599
+ Object.keys(currentValues).forEach((key) => {
600
+ if (currentValues[key] !== prevValues[key]) {
601
+ changed[key] = currentValues[key];
602
+ }
603
+ });
604
+ if (Object.keys(changed).length > 0) {
605
+ onChange(currentValues, { changed });
606
+ }
607
+ prevValuesRef.current = currentValues;
608
+ }, [formik.values, onChange]);
609
+ return null;
610
+ }
611
+ function Form({
612
+ initialValues = {},
613
+ validationSchema,
614
+ enableReinitialize,
615
+ children,
616
+ className,
617
+ contentClassName,
618
+ onSubmit,
619
+ onChange,
620
+ onDirtyChange
621
+ }) {
622
+ return /* @__PURE__ */ jsx$1(
623
+ Formik,
624
+ {
625
+ initialValues,
626
+ validationSchema,
627
+ enableReinitialize,
628
+ onSubmit: async (values, helpers) => {
629
+ await onSubmit(values, helpers);
630
+ },
631
+ children: (formik) => /* @__PURE__ */ jsxs(View, { className: cn(className), children: [
632
+ /* @__PURE__ */ jsx$1(
633
+ FormObservers,
634
+ {
635
+ formik,
636
+ onChange,
637
+ onDirtyChange
638
+ }
639
+ ),
640
+ /* @__PURE__ */ jsx$1(View, { className: cn(contentClassName), children: renderFormChildren(children, formik) })
641
+ ] })
642
+ }
643
+ );
644
+ }
645
+
646
+ // src/components/data-entry/form/form-response/base/FormResponse.styles.ts
647
+ var formResponseSizeStyles = {
648
+ xs: {
649
+ root: "px-2 py-1",
650
+ text: "text-xs"
651
+ },
652
+ sm: {
653
+ root: "px-3 py-2",
654
+ text: "text-sm"
655
+ },
656
+ md: {
657
+ root: "px-4 py-2",
658
+ text: "text-base"
659
+ },
660
+ lg: {
661
+ root: "px-5 py-3",
662
+ text: "text-lg"
663
+ },
664
+ xl: {
665
+ root: "px-6 py-4",
666
+ text: "text-xl"
667
+ }
668
+ };
669
+ function isTextClassName(token) {
670
+ const styleToken = token.split(":").pop() ?? token;
671
+ return styleToken.startsWith("text-");
672
+ }
673
+ function splitClassName(className) {
674
+ const tokens = className.split(/\s+/).filter(Boolean);
675
+ return {
676
+ root: tokens.filter((token) => !isTextClassName(token)).join(" "),
677
+ text: tokens.filter(isTextClassName).join(" ")
678
+ };
679
+ }
680
+ function resolveFormResponseStyles({
681
+ shape,
682
+ size,
683
+ variant
684
+ }) {
685
+ const variantClassNames = splitClassName(variantsLite[variant]);
686
+ const sizeClassNames = formResponseSizeStyles[size];
687
+ return {
688
+ rootClassName: [
689
+ "border",
690
+ variantClassNames.root,
691
+ shapes[shape],
692
+ sizeClassNames.root
693
+ ].filter(Boolean).join(" "),
694
+ textClassName: [
695
+ "font-poppins font-light",
696
+ variantClassNames.text,
697
+ sizeClassNames.text
698
+ ].filter(Boolean).join(" ")
699
+ };
700
+ }
701
+ function FormResponse({
702
+ text,
703
+ variant = "default",
704
+ shape = "roundedSquare",
705
+ size = "md",
706
+ className,
707
+ textClassName
708
+ }) {
709
+ if (!text) {
710
+ return null;
711
+ }
712
+ const styles = resolveFormResponseStyles({ shape, size, variant });
713
+ return /* @__PURE__ */ jsx$1(View, { className: cn(styles.rootClassName, className), children: /* @__PURE__ */ jsx$1(Text, { className: cn(styles.textClassName, textClassName), children: text }) });
714
+ }
715
+
716
+ // src/components/data-entry/input/input-label/base/InputLabel.styles.ts
717
+ var inputLabelStaticClassName = "pointer-events-none select-none px-0 text-[13.5px] leading-none text-[#6B7280]";
718
+ 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";
719
+ var inputLabelErrorClassName = "text-[#6B7280]";
720
+ var inputLabelDisabledClassName = "opacity-60";
721
+ var nativeInputLabelColors = {
722
+ default: "#6B7280",
723
+ disabled: "#9CA3AF"
724
+ };
725
+ var nativeInputLabelStyle = {
726
+ left: 12,
727
+ position: "absolute",
728
+ zIndex: 10
729
+ };
730
+ var nativeInputLabelMetrics = {
731
+ floatingFontSize: 12,
732
+ floatingTop: 6,
733
+ restingFontSize: 16,
734
+ restingTop: 18
735
+ };
736
+ function getLabelColor({ disabled }) {
737
+ if (disabled) {
738
+ return nativeInputLabelColors.disabled;
739
+ }
740
+ return nativeInputLabelColors.default;
741
+ }
742
+ function InputLabel({
743
+ text,
744
+ children,
745
+ className,
746
+ floating,
747
+ errored = false,
748
+ disabled = false,
749
+ animatedValue
750
+ }) {
751
+ const isFloatingLabel = typeof floating === "boolean";
752
+ const progress = animatedValue;
753
+ const animatedStyle = progress ? {
754
+ fontSize: progress.interpolate({
755
+ inputRange: [0, 1],
756
+ outputRange: [
757
+ nativeInputLabelMetrics.restingFontSize,
758
+ nativeInputLabelMetrics.floatingFontSize
759
+ ]
760
+ }),
761
+ lineHeight: progress.interpolate({
762
+ inputRange: [0, 1],
763
+ outputRange: [
764
+ nativeInputLabelMetrics.restingFontSize,
765
+ nativeInputLabelMetrics.floatingFontSize
766
+ ]
767
+ }),
768
+ top: progress.interpolate({
769
+ inputRange: [0, 1],
770
+ outputRange: [
771
+ nativeInputLabelMetrics.restingTop,
772
+ nativeInputLabelMetrics.floatingTop
773
+ ]
774
+ })
775
+ } : {
776
+ fontSize: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
777
+ lineHeight: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
778
+ top: floating === true ? nativeInputLabelMetrics.floatingTop : nativeInputLabelMetrics.restingTop
779
+ };
780
+ return /* @__PURE__ */ jsx$1(
781
+ Animated.Text,
782
+ {
783
+ className: cn(
784
+ isFloatingLabel ? inputLabelBaseClassName : inputLabelStaticClassName,
785
+ isFloatingLabel && "bg-transparent px-0 dark:bg-transparent",
786
+ errored && inputLabelErrorClassName,
787
+ disabled && inputLabelDisabledClassName,
788
+ className
789
+ ),
790
+ style: [
791
+ isFloatingLabel ? nativeInputLabelStyle : null,
792
+ isFloatingLabel ? animatedStyle : null,
793
+ {
794
+ color: getLabelColor({ disabled }),
795
+ includeFontPadding: false
796
+ }
797
+ ],
798
+ children: text || children
799
+ }
800
+ );
801
+ }
802
+
803
+ // src/components/data-entry/input/input-response/base/InputResponse.styles.ts
804
+ var inputResponseBaseClassName = "px-2 pt-1.5 text-sm font-medium";
805
+ var inputResponseVariants = textVariants;
806
+ function InputResponse({
807
+ name,
808
+ visibility = false,
809
+ variant = "default",
810
+ className,
811
+ message
812
+ }) {
813
+ const [mounted, setMounted] = useState(Boolean(visibility));
814
+ const progress = useRef(new Animated.Value(visibility ? 1 : 0)).current;
815
+ useEffect(() => {
816
+ if (visibility) {
817
+ setMounted(true);
818
+ }
819
+ Animated.timing(progress, {
820
+ duration: visibility ? 180 : 120,
821
+ easing: visibility ? Easing.out(Easing.cubic) : Easing.in(Easing.cubic),
822
+ toValue: visibility ? 1 : 0,
823
+ useNativeDriver: true
824
+ }).start(() => {
825
+ if (!visibility) {
826
+ setMounted(false);
827
+ }
828
+ });
829
+ }, [progress, visibility]);
830
+ if (!mounted) {
831
+ return null;
832
+ }
833
+ const animatedStyle = {
834
+ opacity: progress,
835
+ transform: [
836
+ {
837
+ translateY: progress.interpolate({
838
+ inputRange: [0, 1],
839
+ outputRange: [6, 0]
840
+ })
841
+ }
842
+ ]
843
+ };
844
+ const content = message ?? /* @__PURE__ */ jsx$1(ErrorMessage, { name, children: (errorMessage) => String(errorMessage) });
845
+ return /* @__PURE__ */ jsx$1(Animated.View, { className: "w-full", style: animatedStyle, children: /* @__PURE__ */ jsx$1(
846
+ Text,
847
+ {
848
+ className: cn(
849
+ inputResponseBaseClassName,
850
+ inputResponseVariants[variant],
851
+ className
852
+ ),
853
+ style: { includeFontPadding: false },
854
+ children: content
855
+ }
856
+ ) });
857
+ }
858
+ function resolveInputType({
859
+ passwordVisible,
860
+ type
861
+ }) {
862
+ return type === "password" && passwordVisible ? "text" : type;
863
+ }
864
+ function useResolvedInputConfig({
865
+ label,
866
+ placeholder,
867
+ shape,
868
+ type = "text"
869
+ }) {
870
+ const eui = useEUIConfig();
871
+ return {
872
+ shape: shape ?? eui?.config?.global?.shape ?? "square",
873
+ type,
874
+ label: label ?? placeholder
875
+ };
876
+ }
877
+ function useInputFieldState(props) {
878
+ const [field, meta, helpers] = useField(props);
879
+ return {
880
+ field,
881
+ meta,
882
+ helpers
883
+ };
884
+ }
885
+
886
+ // src/components/data-entry/input/input/base/Input.styles.ts
887
+ var inputShapes = shapes;
888
+ var inputRootClassName = "relative w-full";
889
+ var inputFrameClassName = "relative h-14 w-full overflow-hidden border bg-white/95 px-3 dark:bg-eui-dark-800";
890
+ var inputFrameIdleClassName = "border-gray-300 hover:border-gray-400 dark:border-eui-dark-300 dark:hover:border-eui-dark-200";
891
+ var inputFrameActiveClassName = "border-eui-secondary-600";
892
+ var inputFrameErrorClassName = "border-eui-danger-500";
893
+ var inputFrameDisabledClassName = "cursor-not-allowed opacity-60";
894
+ var inputControlClassName = "w-full bg-transparent pt-5 pb-2 text-base font-medium text-gray-950 dark:text-gray-50";
895
+
896
+ // src/components/data-entry/input/input/native/Input.native.styles.ts
897
+ var nativeInputControlClassName = "h-full";
898
+ var nativePasswordInputClassName = "pr-16";
899
+ var nativePasswordToggleClassName = "absolute right-3 top-[18px] h-5 items-center justify-center";
900
+ var nativePasswordToggleTextClassName = "text-xs font-semibold text-eui-dark-200";
901
+ var nativeInputControlStyle = {
902
+ backgroundColor: "transparent",
903
+ borderBottomWidth: 0,
904
+ borderColor: "transparent",
905
+ borderWidth: 0,
906
+ includeFontPadding: false,
907
+ outlineColor: "transparent",
908
+ outlineStyle: "none",
909
+ textAlignVertical: "center"
910
+ };
911
+ function Input(inputProps) {
912
+ const {
913
+ type = "text",
914
+ label,
915
+ placeholder,
916
+ inputClassName,
917
+ labelClassName,
918
+ responseClassName,
919
+ step: _step,
920
+ shape,
921
+ disabled = false,
922
+ className,
923
+ onBlur,
924
+ onFocus,
925
+ onChange: _onChange,
926
+ ..._props
927
+ } = inputProps;
928
+ const { field, helpers, meta } = useInputFieldState(inputProps);
929
+ const [focused, setFocused] = useState(false);
930
+ const [passwordVisible, setPasswordVisible] = useState(false);
931
+ const labelProgress = useRef(
932
+ new Animated.Value(String(field.value ?? "").length > 0 ? 1 : 0)
933
+ ).current;
934
+ const {
935
+ shape: resolvedShape,
936
+ type: resolvedType,
937
+ label: resolvedLabel
938
+ } = useResolvedInputConfig({
939
+ label,
940
+ placeholder,
941
+ shape,
942
+ type
943
+ });
944
+ const inputType = resolveInputType({
945
+ passwordVisible,
946
+ type: resolvedType
947
+ });
948
+ const hasError = Boolean(meta.touched && meta.error);
949
+ const errorText = hasError && typeof meta.error === "string" ? meta.error : null;
950
+ const hasValue = String(field.value ?? "").length > 0;
951
+ const floating = focused || hasValue;
952
+ useEffect(() => {
953
+ Animated.timing(labelProgress, {
954
+ duration: 190,
955
+ easing: Easing.out(Easing.cubic),
956
+ toValue: floating ? 1 : 0,
957
+ useNativeDriver: false
958
+ }).start();
959
+ }, [floating, labelProgress]);
960
+ const handleBlur = (event) => {
961
+ setFocused(false);
962
+ helpers.setTouched(true);
963
+ onBlur?.(event);
964
+ };
965
+ const handleFocus = (event) => {
966
+ setFocused(true);
967
+ onFocus?.(event);
968
+ };
969
+ return /* @__PURE__ */ jsxs(View, { className: inputRootClassName, children: [
970
+ /* @__PURE__ */ jsx$1(
971
+ View,
972
+ {
973
+ className: cn(
974
+ inputFrameClassName,
975
+ hasError ? inputFrameErrorClassName : focused ? inputFrameActiveClassName : inputFrameIdleClassName,
976
+ inputShapes[resolvedShape],
977
+ disabled && inputFrameDisabledClassName,
978
+ className
979
+ ),
980
+ children: /* @__PURE__ */ jsx$1(
981
+ TextInput,
982
+ {
983
+ accessibilityLabel: resolvedLabel,
984
+ className: cn(
985
+ inputControlClassName,
986
+ nativeInputControlClassName,
987
+ type === "password" && nativePasswordInputClassName,
988
+ inputClassName
989
+ ),
990
+ editable: !disabled,
991
+ keyboardType: inputType === "number" ? "numeric" : "default",
992
+ onBlur: handleBlur,
993
+ onChangeText: (value) => helpers.setValue(value),
994
+ onFocus: handleFocus,
995
+ placeholder: "",
996
+ secureTextEntry: type === "password" && !passwordVisible,
997
+ style: nativeInputControlStyle,
998
+ underlineColorAndroid: "transparent",
999
+ value: field.value ?? ""
1000
+ }
1001
+ )
1002
+ }
1003
+ ),
1004
+ /* @__PURE__ */ jsx$1(
1005
+ InputLabel,
1006
+ {
1007
+ animatedValue: labelProgress,
1008
+ disabled,
1009
+ errored: hasError,
1010
+ floating,
1011
+ text: resolvedLabel,
1012
+ className: labelClassName
1013
+ }
1014
+ ),
1015
+ type === "password" ? /* @__PURE__ */ jsx$1(
1016
+ Pressable,
1017
+ {
1018
+ accessibilityRole: "button",
1019
+ accessibilityLabel: passwordVisible ? "Hide password" : "Show password",
1020
+ className: nativePasswordToggleClassName,
1021
+ disabled,
1022
+ onPress: () => setPasswordVisible((current) => !current),
1023
+ children: /* @__PURE__ */ jsx$1(Text, { className: nativePasswordToggleTextClassName, children: passwordVisible ? "Hide" : "Show" })
1024
+ }
1025
+ ) : null,
1026
+ /* @__PURE__ */ jsx$1(
1027
+ InputResponse,
1028
+ {
1029
+ message: errorText,
1030
+ name: field.name,
1031
+ visibility: Boolean(errorText),
1032
+ variant: "danger",
1033
+ className: responseClassName
1034
+ }
1035
+ )
1036
+ ] });
1037
+ }
343
1038
 
344
- export { Button_native_default as Button, EUIProvider, resolveWithGlobal, useEUIConfig };
1039
+ export { Button_native_default as Button, Checkbox, EUIProvider, Form, FormResponse, Input, InputLabel, InputResponse, resolveWithGlobal, useEUIConfig };
345
1040
  //# sourceMappingURL=index.native.mjs.map
346
1041
  //# sourceMappingURL=index.native.mjs.map