@scripso-homepad/ui 0.3.7 → 0.3.8

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.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { useRef, useState, useLayoutEffect, isValidElement, cloneElement } from 'react';
2
- import { StyleSheet, Platform, TouchableOpacity, Text, View, TextInput, Pressable, ScrollView, Modal, Dimensions } from 'react-native';
2
+ import { StyleSheet, Platform, TouchableOpacity, Text, View, Pressable, TextInput, ScrollView, Modal, Dimensions } from 'react-native';
3
3
  import Svg, { Path } from 'react-native-svg';
4
4
  import { jsx, jsxs } from 'react/jsx-runtime';
5
5
 
@@ -227,14 +227,14 @@ var buttonTypography = {
227
227
  fontFamily: fonts.sans,
228
228
  fontSize: 14,
229
229
  fontWeight: fontWeight.semibold,
230
- lineHeight: 14,
230
+ lineHeight: 18,
231
231
  letterSpacing: 0
232
232
  },
233
233
  sm: {
234
234
  fontFamily: fonts.sans,
235
235
  fontSize: 12,
236
236
  fontWeight: fontWeight.semibold,
237
- lineHeight: 12,
237
+ lineHeight: 16,
238
238
  letterSpacing: 0
239
239
  }
240
240
  };
@@ -359,8 +359,9 @@ function Button({
359
359
  useApplyWebClassName(textRef, textClassName);
360
360
  const label = typeof children !== "undefined" ? children : title;
361
361
  const hasCustomChildren = typeof children !== "undefined";
362
- const hasIcon = showIcon || icon != null;
363
- const iconNode = icon ?? /* @__PURE__ */ jsx(ArrowUpRightIcon, { size: metrics.iconSize, color: preset.iconColor });
362
+ const customIcon = icon != null && typeof icon !== "boolean" ? icon : void 0;
363
+ const hasIcon = showIcon || icon === true || customIcon != null;
364
+ const iconNode = customIcon ?? /* @__PURE__ */ jsx(ArrowUpRightIcon, { size: metrics.iconSize, color: preset.iconColor });
364
365
  const containerStyle = [
365
366
  styles.base,
366
367
  {
@@ -380,6 +381,7 @@ function Button({
380
381
  styles.label,
381
382
  metrics.text,
382
383
  { color: preset.textColor },
384
+ Platform.OS === "android" ? styles.labelAndroid : null,
383
385
  !hasIcon && styles.labelCentered,
384
386
  hasIcon && styles.labelWithIcon,
385
387
  textStyle
@@ -432,6 +434,9 @@ var styles = StyleSheet.create({
432
434
  opacity: 0.6
433
435
  },
434
436
  label: {},
437
+ labelAndroid: {
438
+ includeFontPadding: false
439
+ },
435
440
  labelCentered: {
436
441
  textAlign: "center"
437
442
  },
@@ -446,6 +451,55 @@ var styles = StyleSheet.create({
446
451
  flexShrink: 0
447
452
  }
448
453
  });
454
+
455
+ // src/icons/eyeIconPaths.ts
456
+ var EYE_OPEN_OUTLINE_PATH = "M1.71835 10.2898C1.6489 10.1027 1.6489 9.89691 1.71835 9.70981C2.39476 8.06969 3.54294 6.66735 5.01732 5.68056C6.4917 4.69378 8.22588 4.16699 10 4.16699C11.7741 4.16699 13.5083 4.69378 14.9827 5.68056C16.4571 6.66735 17.6053 8.06969 18.2817 9.70981C18.3511 9.89691 18.3511 10.1027 18.2817 10.2898C17.6053 11.9299 16.4571 13.3323 14.9827 14.3191C13.5083 15.3058 11.7741 15.8326 10 15.8326C8.22588 15.8326 6.4917 15.3058 5.01732 14.3191C3.54294 13.3323 2.39476 11.9299 1.71835 10.2898Z";
457
+ var EYE_OPEN_PUPIL_PATH = "M10 12.4998C11.3807 12.4998 12.5 11.3805 12.5 9.99981C12.5 8.6191 11.3807 7.49981 10 7.49981C8.6193 7.49981 7.50001 8.6191 7.50001 9.99981C7.50001 11.3805 8.6193 12.4998 10 12.4998Z";
458
+ var EYE_OFF_PATH = "M10.733 5.076C13.0624 4.7984 15.4186 5.29082 17.4419 6.47805C19.4651 7.66528 21.0442 9.48208 21.938 11.651C22.0213 11.8755 22.0213 12.1225 21.938 12.347C21.5705 13.238 21.0848 14.0755 20.494 14.837M14.084 14.158C13.5182 14.7045 12.7604 15.0069 11.9738 15C11.1872 14.9932 10.4348 14.6777 9.87854 14.1215C9.32232 13.5652 9.00681 12.8128 8.99998 12.0262C8.99314 11.2396 9.29553 10.4818 9.842 9.916M17.479 17.499C16.1525 18.2848 14.6725 18.776 13.1394 18.9394C11.6063 19.1028 10.056 18.9345 8.59363 18.4459C7.13131 17.9573 5.79119 17.1599 4.66421 16.1077C3.53723 15.0556 2.64975 13.7734 2.062 12.348C1.97866 12.1235 1.97866 11.8765 2.062 11.652C2.94863 9.50186 4.50867 7.69725 6.508 6.509M2 2L22 22";
459
+ function EyeIcon({
460
+ size = 20,
461
+ color = "#c7cdd1",
462
+ strokeWidth = 2
463
+ }) {
464
+ return /* @__PURE__ */ jsxs(Svg, { width: size, height: size, viewBox: "0 0 20 20", fill: "none", children: [
465
+ /* @__PURE__ */ jsx(
466
+ Path,
467
+ {
468
+ d: EYE_OPEN_OUTLINE_PATH,
469
+ stroke: color,
470
+ strokeWidth,
471
+ strokeLinecap: "round",
472
+ strokeLinejoin: "round"
473
+ }
474
+ ),
475
+ /* @__PURE__ */ jsx(
476
+ Path,
477
+ {
478
+ d: EYE_OPEN_PUPIL_PATH,
479
+ stroke: color,
480
+ strokeWidth,
481
+ strokeLinecap: "round",
482
+ strokeLinejoin: "round"
483
+ }
484
+ )
485
+ ] });
486
+ }
487
+ function EyeOffIcon({
488
+ size = 20,
489
+ color = "#c7cdd1",
490
+ strokeWidth = 2
491
+ }) {
492
+ return /* @__PURE__ */ jsx(Svg, { width: size, height: size, viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
493
+ Path,
494
+ {
495
+ d: EYE_OFF_PATH,
496
+ stroke: color,
497
+ strokeWidth,
498
+ strokeLinecap: "round",
499
+ strokeLinejoin: "round"
500
+ }
501
+ ) });
502
+ }
449
503
  var INPUT_HEIGHT = 52;
450
504
  var INPUT_ICON_SIZE = 20;
451
505
  var INPUT_ICON_GAP = 10;
@@ -460,17 +514,30 @@ function resolveInputVisualState({
460
514
  if (focused) return "focused";
461
515
  return "default";
462
516
  }
463
- function getInputFieldStyles(state) {
464
- const outlineBase = {
517
+ function createOutlineStyle(ringColor) {
518
+ return {
465
519
  borderRadius: radii.lg + INPUT_OUTLINE_WIDTH,
466
- padding: INPUT_OUTLINE_WIDTH,
467
- backgroundColor: colors.transparent
520
+ borderWidth: INPUT_OUTLINE_WIDTH,
521
+ borderColor: ringColor,
522
+ padding: 0,
523
+ backgroundColor: colors.transparent,
524
+ width: "100%",
525
+ alignSelf: "stretch",
526
+ ...Platform.OS !== "web" ? { overflow: "hidden" } : null
527
+ };
528
+ }
529
+ var defaultOutline = createOutlineStyle(colors.transparent);
530
+ function getInputFieldStyles(state) {
531
+ const containerBase = {
532
+ borderRadius: radii.lg,
533
+ ...Platform.OS !== "web" ? { overflow: "hidden" } : null
468
534
  };
469
535
  switch (state) {
470
536
  case "disabled":
471
537
  return {
472
- outline: outlineBase,
538
+ outline: defaultOutline,
473
539
  container: {
540
+ ...containerBase,
474
541
  borderWidth: 1,
475
542
  borderColor: colors.stormGray50,
476
543
  backgroundColor: colors.stormGray50
@@ -481,11 +548,9 @@ function getInputFieldStyles(state) {
481
548
  };
482
549
  case "error":
483
550
  return {
484
- outline: {
485
- ...outlineBase,
486
- backgroundColor: colors.inputOutlineError
487
- },
551
+ outline: createOutlineStyle(colors.inputOutlineError),
488
552
  container: {
553
+ ...containerBase,
489
554
  borderWidth: 1,
490
555
  borderColor: colors.inputError,
491
556
  backgroundColor: colors.white
@@ -496,11 +561,9 @@ function getInputFieldStyles(state) {
496
561
  };
497
562
  case "focused":
498
563
  return {
499
- outline: {
500
- ...outlineBase,
501
- backgroundColor: colors.inputOutlineFocus
502
- },
564
+ outline: createOutlineStyle(colors.inputOutlineFocus),
503
565
  container: {
566
+ ...containerBase,
504
567
  borderWidth: 1,
505
568
  borderColor: colors.navy,
506
569
  backgroundColor: colors.white
@@ -511,8 +574,9 @@ function getInputFieldStyles(state) {
511
574
  };
512
575
  default:
513
576
  return {
514
- outline: outlineBase,
577
+ outline: defaultOutline,
515
578
  container: {
579
+ ...containerBase,
516
580
  borderWidth: 1,
517
581
  borderColor: colors.stormGray50,
518
582
  backgroundColor: colors.white
@@ -541,12 +605,13 @@ var inputFieldMetrics = StyleSheet.create({
541
605
  fontFamily: fonts.sans,
542
606
  fontSize: fontSize.md,
543
607
  fontWeight: fontWeight.medium,
544
- lineHeight: fontSize.md,
608
+ lineHeight: Platform.OS === "web" ? fontSize.md : 20,
545
609
  paddingVertical: 0,
546
610
  paddingHorizontal: 0,
547
611
  margin: 0,
548
612
  borderWidth: 0,
549
613
  backgroundColor: colors.transparent,
614
+ ...Platform.OS === "android" ? { includeFontPadding: false } : null,
550
615
  ...Platform.OS === "web" ? {
551
616
  height: "100%",
552
617
  minHeight: 0,
@@ -614,6 +679,8 @@ function Input({
614
679
  errorClassName,
615
680
  hintClassName,
616
681
  editable = true,
682
+ secureTextEntry,
683
+ showPasswordToggle,
617
684
  onFocus,
618
685
  onBlur,
619
686
  ...props
@@ -622,10 +689,13 @@ function Input({
622
689
  const inputRef = useRef(null);
623
690
  const helperRef = useRef(null);
624
691
  const [focused, setFocused] = useState(false);
692
+ const [passwordVisible, setPasswordVisible] = useState(false);
625
693
  useApplyWebClassName(wrapperRef, className);
626
694
  useApplyWebClassName(inputRef, inputClassName);
627
695
  useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
628
696
  const isDisabled = editable === false;
697
+ const passwordToggleEnabled = secureTextEntry === true && showPasswordToggle !== false && rightIcon == null;
698
+ const effectiveSecureTextEntry = passwordToggleEnabled ? !passwordVisible : secureTextEntry;
629
699
  const visualState = resolveInputVisualState({
630
700
  focused,
631
701
  error: Boolean(error),
@@ -642,6 +712,26 @@ function Input({
642
712
  onBlur?.(event);
643
713
  }
644
714
  const helperMessage = error ?? hint;
715
+ function togglePasswordVisibility() {
716
+ if (!isDisabled) {
717
+ setPasswordVisible((visible) => !visible);
718
+ }
719
+ }
720
+ const trailingIcon = passwordToggleEnabled ? /* @__PURE__ */ jsx(
721
+ Pressable,
722
+ {
723
+ onPress: togglePasswordVisibility,
724
+ disabled: isDisabled,
725
+ accessibilityRole: "button",
726
+ accessibilityLabel: passwordVisible ? "Hide password" : "Show password",
727
+ hitSlop: 8,
728
+ style: styles3.iconPressable,
729
+ children: renderInputIcon(
730
+ passwordVisible ? /* @__PURE__ */ jsx(EyeOffIcon, {}) : /* @__PURE__ */ jsx(EyeIcon, {}),
731
+ iconColor
732
+ )
733
+ }
734
+ ) : rightIcon ? renderInputIcon(rightIcon, iconColor) : null;
645
735
  return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.wrapper, containerStyle], children: [
646
736
  label ? /* @__PURE__ */ jsx(Label, { disabled: isDisabled, className: labelClassName, children: label }) : null,
647
737
  /* @__PURE__ */ jsx(View, { style: fieldStyles.outline, children: /* @__PURE__ */ jsxs(View, { style: [inputFieldMetrics.container, fieldStyles.container], children: [
@@ -657,13 +747,14 @@ function Input({
657
747
  ],
658
748
  placeholderTextColor: fieldStyles.placeholder,
659
749
  editable,
750
+ secureTextEntry: effectiveSecureTextEntry,
660
751
  onFocus: handleFocus,
661
752
  onBlur: handleBlur,
662
753
  accessibilityState: { disabled: isDisabled },
663
754
  ...props
664
755
  }
665
756
  ),
666
- rightIcon ? /* @__PURE__ */ jsx(View, { style: styles3.iconSlot, children: renderInputIcon(rightIcon, iconColor) }) : null
757
+ trailingIcon ? /* @__PURE__ */ jsx(View, { style: styles3.iconSlot, children: trailingIcon }) : null
667
758
  ] }) }),
668
759
  helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles3.error : styles3.hint, children: helperMessage }) : null
669
760
  ] });
@@ -680,14 +771,20 @@ var styles3 = StyleSheet.create({
680
771
  justifyContent: "center",
681
772
  flexShrink: 0
682
773
  },
774
+ iconPressable: {
775
+ width: INPUT_ICON_SIZE,
776
+ height: INPUT_ICON_SIZE,
777
+ alignItems: "center",
778
+ justifyContent: "center"
779
+ },
683
780
  error: {
684
781
  fontSize: 12,
685
- lineHeight: 12,
782
+ lineHeight: 16,
686
783
  color: colors.inputError
687
784
  },
688
785
  hint: {
689
786
  fontSize: 12,
690
- lineHeight: 12,
787
+ lineHeight: 16,
691
788
  color: colors.stormGray300
692
789
  }
693
790
  });
@@ -1184,12 +1281,12 @@ var styles5 = StyleSheet.create({
1184
1281
  },
1185
1282
  error: {
1186
1283
  fontSize: 12,
1187
- lineHeight: 12,
1284
+ lineHeight: 16,
1188
1285
  color: colors.inputError
1189
1286
  },
1190
1287
  hint: {
1191
1288
  fontSize: 12,
1192
- lineHeight: 12,
1289
+ lineHeight: 16,
1193
1290
  color: colors.stormGray300
1194
1291
  }
1195
1292
  });