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.
@@ -5,6 +5,7 @@ var tailwindMerge = require('tailwind-merge');
5
5
  var react = require('react');
6
6
  var jsxRuntime = require('react/jsx-runtime');
7
7
  var jsxRuntime$1 = require('nativewind/jsx-runtime');
8
+ var formik = require('formik');
8
9
 
9
10
  // src/components/data-entry/button/native/Button.native.tsx
10
11
 
@@ -97,14 +98,14 @@ function useResolvedButtonConfig({
97
98
  // src/data/styles.tsx
98
99
  var variantsSolid = {
99
100
  ["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",
100
- ["primary" /* primary */]: "bg-gradient-to-r from-eui-primary-500 to-eui-primary-600 text-white hover:brightness-110",
101
- ["secondary" /* secondary */]: "bg-gradient-to-r from-eui-secondary-600 to-eui-secondary-500 text-white hover:brightness-110",
102
- ["success" /* success */]: "bg-gradient-to-r from-eui-success-600 to-eui-success-500 text-white hover:brightness-110",
103
- ["danger" /* danger */]: "bg-gradient-to-r from-eui-danger-600 to-eui-danger-500 text-white hover:brightness-110",
104
- ["warning" /* warning */]: "bg-gradient-to-r from-eui-warning-500 to-eui-warning-400 text-black hover:brightness-105",
105
- ["info" /* info */]: "bg-gradient-to-r from-eui-info-600 to-eui-info-500 text-white hover:brightness-110",
106
- ["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",
107
- ["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"
101
+ ["primary" /* primary */]: "bg-eui-primary-500 text-white hover:bg-eui-primary-600",
102
+ ["secondary" /* secondary */]: "bg-eui-secondary-500 text-white hover:bg-eui-secondary-600",
103
+ ["success" /* success */]: "bg-eui-success-500 text-white hover:bg-eui-success-600",
104
+ ["danger" /* danger */]: "bg-eui-danger-500 text-white hover:bg-eui-danger-600",
105
+ ["warning" /* warning */]: "bg-eui-warning-500 text-black hover:bg-eui-warning-400",
106
+ ["info" /* info */]: "bg-eui-info-500 text-white hover:bg-eui-info-600",
107
+ ["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",
108
+ ["dark" /* dark */]: "bg-eui-dark-500 text-white hover:bg-eui-dark-400 dark:bg-eui-dark-400 dark:hover:bg-eui-dark-300"
108
109
  };
109
110
  var variantsLite = {
110
111
  ["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",
@@ -128,6 +129,17 @@ var variantsGhost = {
128
129
  ["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",
129
130
  ["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"
130
131
  };
132
+ var textVariants = {
133
+ ["default" /* default */]: "eui-text-md",
134
+ ["primary" /* primary */]: "text-blue-500",
135
+ ["secondary" /* secondary */]: "text-gray-500",
136
+ ["success" /* success */]: "text-green-500",
137
+ ["danger" /* danger */]: "text-red-500",
138
+ ["warning" /* warning */]: "text-yellow-500",
139
+ ["info" /* info */]: "text-blue-400",
140
+ ["light" /* light */]: "text-gray-300",
141
+ ["dark" /* dark */]: "text-gray-900"
142
+ };
131
143
  var shapes = {
132
144
  ["square" /* square */]: "rounded-none",
133
145
  ["roundedSquare" /* roundedSquare */]: "rounded-md",
@@ -156,7 +168,7 @@ function resolveButtonVariantStyles({
156
168
  ghost: variantsGhost
157
169
  });
158
170
  }
159
- function getButtonTextColorClassName(className) {
171
+ function getButtonLabelColorClassName(className) {
160
172
  return className.split(/\s+/).filter(
161
173
  (token) => token.startsWith("text-") || token.startsWith("dark:text-") || token.startsWith("disabled:text-")
162
174
  ).join(" ");
@@ -203,8 +215,6 @@ function Button({
203
215
  block = false,
204
216
  compact = false,
205
217
  mode,
206
- buttonColor,
207
- textColor,
208
218
  contentClassName,
209
219
  labelClassName,
210
220
  className,
@@ -212,9 +222,6 @@ function Button({
212
222
  appearance,
213
223
  shape,
214
224
  size,
215
- style,
216
- contentStyle,
217
- labelStyle,
218
225
  accessibilityRole = "button",
219
226
  accessibilityState,
220
227
  type: _type,
@@ -242,21 +249,9 @@ function Button({
242
249
  appearance: resolvedAppearance,
243
250
  variant: resolvedVariant
244
251
  });
245
- const textColorClassName = getButtonTextColorClassName(variantStyles);
246
- const rootStyle = {
247
- ...mode === "text" ? {
248
- backgroundColor: "transparent",
249
- borderColor: "transparent"
250
- } : null,
251
- ...buttonColor && mode !== "text" ? {
252
- backgroundColor: buttonColor,
253
- borderColor: buttonColor
254
- } : null,
255
- ...!buttonColor && textColor && resolvedAppearance !== "solid" ? { borderColor: textColor } : null
256
- };
257
- const labelTextStyle = textColor ? { color: textColor } : null;
252
+ const labelColorClassName = getButtonLabelColorClassName(variantStyles);
258
253
  const content = text ?? children;
259
- const resolvedIcon = typeof icon === "function" ? icon({ color: textColor ?? "currentColor", size: iconSize }) : icon;
254
+ const resolvedIcon = typeof icon === "function" ? icon({ color: "currentColor", size: iconSize }) : icon;
260
255
  return /* @__PURE__ */ jsxRuntime$1.jsx(
261
256
  reactNative.Pressable,
262
257
  {
@@ -280,10 +275,8 @@ function Button({
280
275
  disabled: disabled || loading,
281
276
  onPress,
282
277
  style: ({ pressed }) => [
283
- rootStyle,
284
278
  pressed && !disabled && !loading ? { opacity: 0.82 } : null,
285
- disabled || loading ? { opacity: 0.55 } : null,
286
- style
279
+ disabled || loading ? { opacity: 0.55 } : null
287
280
  ],
288
281
  children: /* @__PURE__ */ jsxRuntime$1.jsxs(
289
282
  reactNative.View,
@@ -292,7 +285,6 @@ function Button({
292
285
  "z-10 flex-row items-center justify-center gap-2",
293
286
  contentClassName
294
287
  ),
295
- style: contentStyle,
296
288
  children: [
297
289
  loading ? /* @__PURE__ */ jsxRuntime$1.jsx(
298
290
  reactNative.View,
@@ -301,14 +293,7 @@ function Button({
301
293
  "shrink-0 items-center justify-center",
302
294
  metrics.slotClassName
303
295
  ),
304
- children: /* @__PURE__ */ jsxRuntime$1.jsx(
305
- reactNative.ActivityIndicator,
306
- {
307
- className: textColorClassName,
308
- color: textColor,
309
- size: "small"
310
- }
311
- )
296
+ children: /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.ActivityIndicator, { className: labelColorClassName, size: "small" })
312
297
  }
313
298
  ) : null,
314
299
  !loading && resolvedIcon ? /* @__PURE__ */ jsxRuntime$1.jsx(
@@ -327,11 +312,11 @@ function Button({
327
312
  className: cn(
328
313
  "font-bold",
329
314
  metrics.labelClassName,
330
- textColorClassName,
315
+ labelColorClassName,
331
316
  labelClassName
332
317
  ),
333
318
  numberOfLines: 1,
334
- style: [nativeLabelBaseStyle, labelTextStyle, labelStyle],
319
+ style: nativeLabelBaseStyle,
335
320
  children: content
336
321
  }
337
322
  ) }) : content
@@ -342,9 +327,725 @@ function Button({
342
327
  );
343
328
  }
344
329
  var Button_native_default = Button;
330
+ function isMultiCheckbox(props) {
331
+ return Array.isArray(props.options);
332
+ }
333
+ function useResolvedCheckboxConfig({
334
+ label,
335
+ placeholder,
336
+ variant,
337
+ shape
338
+ }) {
339
+ const eui = useEUIConfig();
340
+ return {
341
+ shape: shape ?? eui?.config?.global?.shape ?? "roundedSquare",
342
+ variant: variant ?? "secondary",
343
+ label: label ?? placeholder
344
+ };
345
+ }
346
+ function useCheckboxFieldState(props) {
347
+ const isMulti = isMultiCheckbox(props);
348
+ const [multiField, multiMeta, multiHelpers] = formik.useField(
349
+ props
350
+ );
351
+ const [singleField, singleMeta, singleHelpers] = formik.useField(
352
+ props
353
+ );
354
+ return {
355
+ isMulti,
356
+ multiField,
357
+ multiMeta,
358
+ multiHelpers,
359
+ singleField,
360
+ singleMeta,
361
+ singleHelpers
362
+ };
363
+ }
364
+
365
+ // src/components/data-entry/checkbox/base/Checkbox.styles.ts
366
+ var checkboxShapes = shapes;
367
+ var checkboxGroupClassName = "flex flex-col gap-2";
368
+ var checkboxOptionRowClassName = "flex flex-row items-start gap-3";
369
+ var checkboxLabelClassName = "cursor-pointer select-none text-sm leading-relaxed text-gray-800 dark:text-gray-200";
370
+ var checkboxIndicatorDisabledClassName = "cursor-not-allowed opacity-50";
371
+
372
+ // src/components/data-entry/checkbox/native/Checkbox.native.styles.ts
373
+ var nativeCheckboxVariants = {
374
+ default: {
375
+ checkedClassName: "border-eui-secondary-600 bg-eui-secondary-600 dark:border-eui-secondary-500 dark:bg-eui-secondary-500",
376
+ iconClassName: "text-white"
377
+ },
378
+ primary: {
379
+ checkedClassName: "border-eui-primary-600 bg-eui-primary-600 dark:border-eui-primary-500 dark:bg-eui-primary-500",
380
+ iconClassName: "text-white"
381
+ },
382
+ secondary: {
383
+ checkedClassName: "border-eui-secondary-600 bg-eui-secondary-600 dark:border-eui-secondary-500 dark:bg-eui-secondary-500",
384
+ iconClassName: "text-white"
385
+ },
386
+ success: {
387
+ checkedClassName: "border-eui-success-600 bg-eui-success-600 dark:border-eui-success-500 dark:bg-eui-success-500",
388
+ iconClassName: "text-white"
389
+ },
390
+ danger: {
391
+ checkedClassName: "border-eui-danger-600 bg-eui-danger-600 dark:border-eui-danger-500 dark:bg-eui-danger-500",
392
+ iconClassName: "text-white"
393
+ },
394
+ warning: {
395
+ checkedClassName: "border-eui-warning-500 bg-eui-warning-500 dark:border-eui-warning-400 dark:bg-eui-warning-400",
396
+ iconClassName: "text-black"
397
+ },
398
+ info: {
399
+ checkedClassName: "border-eui-info-600 bg-eui-info-600 dark:border-eui-info-500 dark:bg-eui-info-500",
400
+ iconClassName: "text-white"
401
+ },
402
+ light: {
403
+ checkedClassName: "border-eui-light-400 bg-eui-light-400 dark:border-gray-200 dark:bg-gray-200",
404
+ iconClassName: "text-gray-900"
405
+ },
406
+ dark: {
407
+ checkedClassName: "border-eui-dark-500 bg-eui-dark-500 dark:border-eui-dark-300 dark:bg-eui-dark-300",
408
+ iconClassName: "text-white"
409
+ }
410
+ };
411
+ function resolveNativeCheckboxVariantStyles(variant) {
412
+ return nativeCheckboxVariants[variant];
413
+ }
414
+ function getIndicatorClassName({
415
+ checked,
416
+ className,
417
+ disabled,
418
+ indicatorClassName,
419
+ checkedIndicatorClassName,
420
+ resolvedShape,
421
+ variantCheckedClassName
422
+ }) {
423
+ return cn(
424
+ "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",
425
+ checkboxShapes[resolvedShape],
426
+ indicatorClassName,
427
+ className,
428
+ checked && variantCheckedClassName,
429
+ checked && checkedIndicatorClassName,
430
+ disabled && checkboxIndicatorDisabledClassName
431
+ );
432
+ }
433
+ function Tick({
434
+ checkedIconClassName,
435
+ iconClassName
436
+ }) {
437
+ return /* @__PURE__ */ jsxRuntime$1.jsx(
438
+ reactNative.Text,
439
+ {
440
+ className: cn(
441
+ "text-sm font-bold leading-none",
442
+ iconClassName,
443
+ checkedIconClassName
444
+ ),
445
+ children: "\u2713"
446
+ }
447
+ );
448
+ }
449
+ function Checkbox(checkboxProps) {
450
+ const {
451
+ label,
452
+ placeholder,
453
+ variant,
454
+ shape,
455
+ disabled = false,
456
+ className,
457
+ groupClassName,
458
+ optionClassName,
459
+ indicatorClassName,
460
+ checkedIndicatorClassName,
461
+ checkedIconClassName,
462
+ labelClassName
463
+ } = checkboxProps;
464
+ const {
465
+ shape: resolvedShape,
466
+ variant: resolvedVariant,
467
+ label: resolvedLabel
468
+ } = useResolvedCheckboxConfig({
469
+ label,
470
+ placeholder,
471
+ variant,
472
+ shape
473
+ });
474
+ const {
475
+ isMulti,
476
+ multiField,
477
+ multiMeta,
478
+ multiHelpers,
479
+ singleField,
480
+ singleMeta,
481
+ singleHelpers
482
+ } = useCheckboxFieldState(checkboxProps);
483
+ const variantStyles = resolveNativeCheckboxVariantStyles(resolvedVariant);
484
+ const activeMeta = isMulti ? multiMeta : singleMeta;
485
+ const multiProps = isMultiCheckbox(checkboxProps) ? checkboxProps : null;
486
+ const singleChecked = singleField.value;
487
+ const errorText = activeMeta.touched && typeof activeMeta.error === "string" ? activeMeta.error : null;
488
+ return /* @__PURE__ */ jsxRuntime$1.jsxs(reactNative.View, { className: cn(checkboxGroupClassName, groupClassName), children: [
489
+ !isMulti && /* @__PURE__ */ jsxRuntime$1.jsxs(
490
+ reactNative.Pressable,
491
+ {
492
+ accessibilityRole: "checkbox",
493
+ accessibilityState: {
494
+ checked: singleChecked,
495
+ disabled
496
+ },
497
+ className: cn(checkboxOptionRowClassName, optionClassName),
498
+ disabled,
499
+ onPress: () => singleHelpers.setValue(!singleChecked),
500
+ children: [
501
+ /* @__PURE__ */ jsxRuntime$1.jsx(
502
+ reactNative.View,
503
+ {
504
+ className: getIndicatorClassName({
505
+ checked: singleChecked,
506
+ className,
507
+ disabled,
508
+ indicatorClassName,
509
+ checkedIndicatorClassName,
510
+ resolvedShape,
511
+ variantCheckedClassName: variantStyles.checkedClassName
512
+ }),
513
+ children: singleChecked ? /* @__PURE__ */ jsxRuntime$1.jsx(
514
+ Tick,
515
+ {
516
+ checkedIconClassName,
517
+ iconClassName: variantStyles.iconClassName
518
+ }
519
+ ) : null
520
+ }
521
+ ),
522
+ resolvedLabel ? /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: cn(checkboxLabelClassName, labelClassName), children: resolvedLabel }) : null
523
+ ]
524
+ }
525
+ ),
526
+ isMulti && multiProps?.options.map((option) => {
527
+ const values = multiField.value ?? [];
528
+ const checked = values.includes(option.value);
529
+ const optionDisabled = disabled || option.disabled === true;
530
+ return /* @__PURE__ */ jsxRuntime$1.jsxs(
531
+ reactNative.Pressable,
532
+ {
533
+ accessibilityRole: "checkbox",
534
+ accessibilityState: {
535
+ checked,
536
+ disabled: optionDisabled
537
+ },
538
+ className: cn(checkboxOptionRowClassName, optionClassName),
539
+ disabled: optionDisabled,
540
+ onPress: () => multiHelpers.setValue(
541
+ checked ? values.filter((value) => value !== option.value) : [...values, option.value]
542
+ ),
543
+ children: [
544
+ /* @__PURE__ */ jsxRuntime$1.jsx(
545
+ reactNative.View,
546
+ {
547
+ className: getIndicatorClassName({
548
+ checked,
549
+ className,
550
+ disabled: optionDisabled,
551
+ indicatorClassName,
552
+ checkedIndicatorClassName,
553
+ resolvedShape,
554
+ variantCheckedClassName: variantStyles.checkedClassName
555
+ }),
556
+ children: checked ? /* @__PURE__ */ jsxRuntime$1.jsx(
557
+ Tick,
558
+ {
559
+ checkedIconClassName,
560
+ iconClassName: variantStyles.iconClassName
561
+ }
562
+ ) : null
563
+ }
564
+ ),
565
+ /* @__PURE__ */ jsxRuntime$1.jsx(
566
+ reactNative.Text,
567
+ {
568
+ className: cn(
569
+ checkboxLabelClassName,
570
+ optionDisabled && "opacity-60",
571
+ labelClassName
572
+ ),
573
+ children: option.label
574
+ }
575
+ )
576
+ ]
577
+ },
578
+ option.value
579
+ );
580
+ }),
581
+ errorText ? /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: "px-2 py-1 text-sm font-medium text-eui-danger-500", children: errorText }) : null
582
+ ] });
583
+ }
584
+ function renderFormChildren(children, formik) {
585
+ return typeof children === "function" ? children(formik) : children;
586
+ }
587
+ function FormObservers({
588
+ formik,
589
+ onChange,
590
+ onDirtyChange
591
+ }) {
592
+ const prevValuesRef = react.useRef(formik.values);
593
+ react.useEffect(() => {
594
+ onDirtyChange?.(formik.dirty);
595
+ }, [formik.dirty, onDirtyChange]);
596
+ react.useEffect(() => {
597
+ if (!onChange) return;
598
+ const currentValues = formik.values;
599
+ const prevValues = prevValuesRef.current;
600
+ const changed = {};
601
+ Object.keys(currentValues).forEach((key) => {
602
+ if (currentValues[key] !== prevValues[key]) {
603
+ changed[key] = currentValues[key];
604
+ }
605
+ });
606
+ if (Object.keys(changed).length > 0) {
607
+ onChange(currentValues, { changed });
608
+ }
609
+ prevValuesRef.current = currentValues;
610
+ }, [formik.values, onChange]);
611
+ return null;
612
+ }
613
+ function Form({
614
+ initialValues = {},
615
+ validationSchema,
616
+ enableReinitialize,
617
+ children,
618
+ className,
619
+ contentClassName,
620
+ onSubmit,
621
+ onChange,
622
+ onDirtyChange
623
+ }) {
624
+ return /* @__PURE__ */ jsxRuntime$1.jsx(
625
+ formik.Formik,
626
+ {
627
+ initialValues,
628
+ validationSchema,
629
+ enableReinitialize,
630
+ onSubmit: async (values, helpers) => {
631
+ await onSubmit(values, helpers);
632
+ },
633
+ children: (formik) => /* @__PURE__ */ jsxRuntime$1.jsxs(reactNative.View, { className: cn(className), children: [
634
+ /* @__PURE__ */ jsxRuntime$1.jsx(
635
+ FormObservers,
636
+ {
637
+ formik,
638
+ onChange,
639
+ onDirtyChange
640
+ }
641
+ ),
642
+ /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.View, { className: cn(contentClassName), children: renderFormChildren(children, formik) })
643
+ ] })
644
+ }
645
+ );
646
+ }
647
+
648
+ // src/components/data-entry/form/form-response/base/FormResponse.styles.ts
649
+ var formResponseSizeStyles = {
650
+ xs: {
651
+ root: "px-2 py-1",
652
+ text: "text-xs"
653
+ },
654
+ sm: {
655
+ root: "px-3 py-2",
656
+ text: "text-sm"
657
+ },
658
+ md: {
659
+ root: "px-4 py-2",
660
+ text: "text-base"
661
+ },
662
+ lg: {
663
+ root: "px-5 py-3",
664
+ text: "text-lg"
665
+ },
666
+ xl: {
667
+ root: "px-6 py-4",
668
+ text: "text-xl"
669
+ }
670
+ };
671
+ function isTextClassName(token) {
672
+ const styleToken = token.split(":").pop() ?? token;
673
+ return styleToken.startsWith("text-");
674
+ }
675
+ function splitClassName(className) {
676
+ const tokens = className.split(/\s+/).filter(Boolean);
677
+ return {
678
+ root: tokens.filter((token) => !isTextClassName(token)).join(" "),
679
+ text: tokens.filter(isTextClassName).join(" ")
680
+ };
681
+ }
682
+ function resolveFormResponseStyles({
683
+ shape,
684
+ size,
685
+ variant
686
+ }) {
687
+ const variantClassNames = splitClassName(variantsLite[variant]);
688
+ const sizeClassNames = formResponseSizeStyles[size];
689
+ return {
690
+ rootClassName: [
691
+ "border",
692
+ variantClassNames.root,
693
+ shapes[shape],
694
+ sizeClassNames.root
695
+ ].filter(Boolean).join(" "),
696
+ textClassName: [
697
+ "font-poppins font-light",
698
+ variantClassNames.text,
699
+ sizeClassNames.text
700
+ ].filter(Boolean).join(" ")
701
+ };
702
+ }
703
+ function FormResponse({
704
+ text,
705
+ variant = "default",
706
+ shape = "roundedSquare",
707
+ size = "md",
708
+ className,
709
+ textClassName
710
+ }) {
711
+ if (!text) {
712
+ return null;
713
+ }
714
+ const styles = resolveFormResponseStyles({ shape, size, variant });
715
+ return /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.View, { className: cn(styles.rootClassName, className), children: /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: cn(styles.textClassName, textClassName), children: text }) });
716
+ }
717
+
718
+ // src/components/data-entry/input/input-label/base/InputLabel.styles.ts
719
+ var inputLabelStaticClassName = "pointer-events-none select-none px-0 text-[13.5px] leading-none text-[#6B7280]";
720
+ 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";
721
+ var inputLabelErrorClassName = "text-[#6B7280]";
722
+ var inputLabelDisabledClassName = "opacity-60";
723
+ var nativeInputLabelColors = {
724
+ default: "#6B7280",
725
+ disabled: "#9CA3AF"
726
+ };
727
+ var nativeInputLabelStyle = {
728
+ left: 12,
729
+ position: "absolute",
730
+ zIndex: 10
731
+ };
732
+ var nativeInputLabelMetrics = {
733
+ floatingFontSize: 12,
734
+ floatingTop: 6,
735
+ restingFontSize: 16,
736
+ restingTop: 18
737
+ };
738
+ function getLabelColor({ disabled }) {
739
+ if (disabled) {
740
+ return nativeInputLabelColors.disabled;
741
+ }
742
+ return nativeInputLabelColors.default;
743
+ }
744
+ function InputLabel({
745
+ text,
746
+ children,
747
+ className,
748
+ floating,
749
+ errored = false,
750
+ disabled = false,
751
+ animatedValue
752
+ }) {
753
+ const isFloatingLabel = typeof floating === "boolean";
754
+ const progress = animatedValue;
755
+ const animatedStyle = progress ? {
756
+ fontSize: progress.interpolate({
757
+ inputRange: [0, 1],
758
+ outputRange: [
759
+ nativeInputLabelMetrics.restingFontSize,
760
+ nativeInputLabelMetrics.floatingFontSize
761
+ ]
762
+ }),
763
+ lineHeight: progress.interpolate({
764
+ inputRange: [0, 1],
765
+ outputRange: [
766
+ nativeInputLabelMetrics.restingFontSize,
767
+ nativeInputLabelMetrics.floatingFontSize
768
+ ]
769
+ }),
770
+ top: progress.interpolate({
771
+ inputRange: [0, 1],
772
+ outputRange: [
773
+ nativeInputLabelMetrics.restingTop,
774
+ nativeInputLabelMetrics.floatingTop
775
+ ]
776
+ })
777
+ } : {
778
+ fontSize: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
779
+ lineHeight: floating === true ? nativeInputLabelMetrics.floatingFontSize : nativeInputLabelMetrics.restingFontSize,
780
+ top: floating === true ? nativeInputLabelMetrics.floatingTop : nativeInputLabelMetrics.restingTop
781
+ };
782
+ return /* @__PURE__ */ jsxRuntime$1.jsx(
783
+ reactNative.Animated.Text,
784
+ {
785
+ className: cn(
786
+ isFloatingLabel ? inputLabelBaseClassName : inputLabelStaticClassName,
787
+ isFloatingLabel && "bg-transparent px-0 dark:bg-transparent",
788
+ errored && inputLabelErrorClassName,
789
+ disabled && inputLabelDisabledClassName,
790
+ className
791
+ ),
792
+ style: [
793
+ isFloatingLabel ? nativeInputLabelStyle : null,
794
+ isFloatingLabel ? animatedStyle : null,
795
+ {
796
+ color: getLabelColor({ disabled }),
797
+ includeFontPadding: false
798
+ }
799
+ ],
800
+ children: text || children
801
+ }
802
+ );
803
+ }
804
+
805
+ // src/components/data-entry/input/input-response/base/InputResponse.styles.ts
806
+ var inputResponseBaseClassName = "px-2 pt-1.5 text-sm font-medium";
807
+ var inputResponseVariants = textVariants;
808
+ function InputResponse({
809
+ name,
810
+ visibility = false,
811
+ variant = "default",
812
+ className,
813
+ message
814
+ }) {
815
+ const [mounted, setMounted] = react.useState(Boolean(visibility));
816
+ const progress = react.useRef(new reactNative.Animated.Value(visibility ? 1 : 0)).current;
817
+ react.useEffect(() => {
818
+ if (visibility) {
819
+ setMounted(true);
820
+ }
821
+ reactNative.Animated.timing(progress, {
822
+ duration: visibility ? 180 : 120,
823
+ easing: visibility ? reactNative.Easing.out(reactNative.Easing.cubic) : reactNative.Easing.in(reactNative.Easing.cubic),
824
+ toValue: visibility ? 1 : 0,
825
+ useNativeDriver: true
826
+ }).start(() => {
827
+ if (!visibility) {
828
+ setMounted(false);
829
+ }
830
+ });
831
+ }, [progress, visibility]);
832
+ if (!mounted) {
833
+ return null;
834
+ }
835
+ const animatedStyle = {
836
+ opacity: progress,
837
+ transform: [
838
+ {
839
+ translateY: progress.interpolate({
840
+ inputRange: [0, 1],
841
+ outputRange: [6, 0]
842
+ })
843
+ }
844
+ ]
845
+ };
846
+ const content = message ?? /* @__PURE__ */ jsxRuntime$1.jsx(formik.ErrorMessage, { name, children: (errorMessage) => String(errorMessage) });
847
+ return /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Animated.View, { className: "w-full", style: animatedStyle, children: /* @__PURE__ */ jsxRuntime$1.jsx(
848
+ reactNative.Text,
849
+ {
850
+ className: cn(
851
+ inputResponseBaseClassName,
852
+ inputResponseVariants[variant],
853
+ className
854
+ ),
855
+ style: { includeFontPadding: false },
856
+ children: content
857
+ }
858
+ ) });
859
+ }
860
+ function resolveInputType({
861
+ passwordVisible,
862
+ type
863
+ }) {
864
+ return type === "password" && passwordVisible ? "text" : type;
865
+ }
866
+ function useResolvedInputConfig({
867
+ label,
868
+ placeholder,
869
+ shape,
870
+ type = "text"
871
+ }) {
872
+ const eui = useEUIConfig();
873
+ return {
874
+ shape: shape ?? eui?.config?.global?.shape ?? "square",
875
+ type,
876
+ label: label ?? placeholder
877
+ };
878
+ }
879
+ function useInputFieldState(props) {
880
+ const [field, meta, helpers] = formik.useField(props);
881
+ return {
882
+ field,
883
+ meta,
884
+ helpers
885
+ };
886
+ }
887
+
888
+ // src/components/data-entry/input/input/base/Input.styles.ts
889
+ var inputShapes = shapes;
890
+ var inputRootClassName = "relative w-full";
891
+ var inputFrameClassName = "relative h-14 w-full overflow-hidden border bg-white/95 px-3 dark:bg-eui-dark-800";
892
+ var inputFrameIdleClassName = "border-gray-300 hover:border-gray-400 dark:border-eui-dark-300 dark:hover:border-eui-dark-200";
893
+ var inputFrameActiveClassName = "border-eui-secondary-600";
894
+ var inputFrameErrorClassName = "border-eui-danger-500";
895
+ var inputFrameDisabledClassName = "cursor-not-allowed opacity-60";
896
+ var inputControlClassName = "w-full bg-transparent pt-5 pb-2 text-base font-medium text-gray-950 dark:text-gray-50";
897
+
898
+ // src/components/data-entry/input/input/native/Input.native.styles.ts
899
+ var nativeInputControlClassName = "h-full";
900
+ var nativePasswordInputClassName = "pr-16";
901
+ var nativePasswordToggleClassName = "absolute right-3 top-[18px] h-5 items-center justify-center";
902
+ var nativePasswordToggleTextClassName = "text-xs font-semibold text-eui-dark-200";
903
+ var nativeInputControlStyle = {
904
+ backgroundColor: "transparent",
905
+ borderBottomWidth: 0,
906
+ borderColor: "transparent",
907
+ borderWidth: 0,
908
+ includeFontPadding: false,
909
+ outlineColor: "transparent",
910
+ outlineStyle: "none",
911
+ textAlignVertical: "center"
912
+ };
913
+ function Input(inputProps) {
914
+ const {
915
+ type = "text",
916
+ label,
917
+ placeholder,
918
+ inputClassName,
919
+ labelClassName,
920
+ responseClassName,
921
+ step: _step,
922
+ shape,
923
+ disabled = false,
924
+ className,
925
+ onBlur,
926
+ onFocus,
927
+ onChange: _onChange,
928
+ ..._props
929
+ } = inputProps;
930
+ const { field, helpers, meta } = useInputFieldState(inputProps);
931
+ const [focused, setFocused] = react.useState(false);
932
+ const [passwordVisible, setPasswordVisible] = react.useState(false);
933
+ const labelProgress = react.useRef(
934
+ new reactNative.Animated.Value(String(field.value ?? "").length > 0 ? 1 : 0)
935
+ ).current;
936
+ const {
937
+ shape: resolvedShape,
938
+ type: resolvedType,
939
+ label: resolvedLabel
940
+ } = useResolvedInputConfig({
941
+ label,
942
+ placeholder,
943
+ shape,
944
+ type
945
+ });
946
+ const inputType = resolveInputType({
947
+ passwordVisible,
948
+ type: resolvedType
949
+ });
950
+ const hasError = Boolean(meta.touched && meta.error);
951
+ const errorText = hasError && typeof meta.error === "string" ? meta.error : null;
952
+ const hasValue = String(field.value ?? "").length > 0;
953
+ const floating = focused || hasValue;
954
+ react.useEffect(() => {
955
+ reactNative.Animated.timing(labelProgress, {
956
+ duration: 190,
957
+ easing: reactNative.Easing.out(reactNative.Easing.cubic),
958
+ toValue: floating ? 1 : 0,
959
+ useNativeDriver: false
960
+ }).start();
961
+ }, [floating, labelProgress]);
962
+ const handleBlur = (event) => {
963
+ setFocused(false);
964
+ helpers.setTouched(true);
965
+ onBlur?.(event);
966
+ };
967
+ const handleFocus = (event) => {
968
+ setFocused(true);
969
+ onFocus?.(event);
970
+ };
971
+ return /* @__PURE__ */ jsxRuntime$1.jsxs(reactNative.View, { className: inputRootClassName, children: [
972
+ /* @__PURE__ */ jsxRuntime$1.jsx(
973
+ reactNative.View,
974
+ {
975
+ className: cn(
976
+ inputFrameClassName,
977
+ hasError ? inputFrameErrorClassName : focused ? inputFrameActiveClassName : inputFrameIdleClassName,
978
+ inputShapes[resolvedShape],
979
+ disabled && inputFrameDisabledClassName,
980
+ className
981
+ ),
982
+ children: /* @__PURE__ */ jsxRuntime$1.jsx(
983
+ reactNative.TextInput,
984
+ {
985
+ accessibilityLabel: resolvedLabel,
986
+ className: cn(
987
+ inputControlClassName,
988
+ nativeInputControlClassName,
989
+ type === "password" && nativePasswordInputClassName,
990
+ inputClassName
991
+ ),
992
+ editable: !disabled,
993
+ keyboardType: inputType === "number" ? "numeric" : "default",
994
+ onBlur: handleBlur,
995
+ onChangeText: (value) => helpers.setValue(value),
996
+ onFocus: handleFocus,
997
+ placeholder: "",
998
+ secureTextEntry: type === "password" && !passwordVisible,
999
+ style: nativeInputControlStyle,
1000
+ underlineColorAndroid: "transparent",
1001
+ value: field.value ?? ""
1002
+ }
1003
+ )
1004
+ }
1005
+ ),
1006
+ /* @__PURE__ */ jsxRuntime$1.jsx(
1007
+ InputLabel,
1008
+ {
1009
+ animatedValue: labelProgress,
1010
+ disabled,
1011
+ errored: hasError,
1012
+ floating,
1013
+ text: resolvedLabel,
1014
+ className: labelClassName
1015
+ }
1016
+ ),
1017
+ type === "password" ? /* @__PURE__ */ jsxRuntime$1.jsx(
1018
+ reactNative.Pressable,
1019
+ {
1020
+ accessibilityRole: "button",
1021
+ accessibilityLabel: passwordVisible ? "Hide password" : "Show password",
1022
+ className: nativePasswordToggleClassName,
1023
+ disabled,
1024
+ onPress: () => setPasswordVisible((current) => !current),
1025
+ children: /* @__PURE__ */ jsxRuntime$1.jsx(reactNative.Text, { className: nativePasswordToggleTextClassName, children: passwordVisible ? "Hide" : "Show" })
1026
+ }
1027
+ ) : null,
1028
+ /* @__PURE__ */ jsxRuntime$1.jsx(
1029
+ InputResponse,
1030
+ {
1031
+ message: errorText,
1032
+ name: field.name,
1033
+ visibility: Boolean(errorText),
1034
+ variant: "danger",
1035
+ className: responseClassName
1036
+ }
1037
+ )
1038
+ ] });
1039
+ }
345
1040
 
346
1041
  exports.Button = Button_native_default;
1042
+ exports.Checkbox = Checkbox;
347
1043
  exports.EUIProvider = EUIProvider;
1044
+ exports.Form = Form;
1045
+ exports.FormResponse = FormResponse;
1046
+ exports.Input = Input;
1047
+ exports.InputLabel = InputLabel;
1048
+ exports.InputResponse = InputResponse;
348
1049
  exports.resolveWithGlobal = resolveWithGlobal;
349
1050
  exports.useEUIConfig = useEUIConfig;
350
1051
  //# sourceMappingURL=index.native.js.map