@scripso-homepad/ui 0.3.7 → 0.3.9
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/README.md +7 -2
- package/dist/index.cjs +152 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +10 -4
- package/dist/index.d.ts +10 -4
- package/dist/index.js +153 -45
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button.tsx +11 -2
- package/src/components/Input.stories.tsx +9 -0
- package/src/components/Input.tsx +60 -5
- package/src/components/PhoneInput.tsx +2 -2
- package/src/icons/EyeIcon.tsx +25 -37
- package/src/icons/EyeIcon.web.tsx +42 -0
- package/src/icons/EyeOffIcon.tsx +29 -0
- package/src/icons/EyeOffIcon.web.tsx +35 -0
- package/src/icons/eyeIconPaths.ts +8 -0
- package/src/theme/input.ts +29 -14
- package/src/theme/tokens.ts +3 -3
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,
|
|
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:
|
|
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:
|
|
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
|
|
363
|
-
const
|
|
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
|
|
464
|
-
|
|
517
|
+
function createOutlineStyle(ringColor) {
|
|
518
|
+
return {
|
|
465
519
|
borderRadius: radii.lg + INPUT_OUTLINE_WIDTH,
|
|
466
|
-
|
|
467
|
-
|
|
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:
|
|
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:
|
|
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,
|
|
@@ -609,23 +674,32 @@ function Input({
|
|
|
609
674
|
containerStyle,
|
|
610
675
|
style,
|
|
611
676
|
className,
|
|
677
|
+
fieldClassName,
|
|
678
|
+
fieldStyle,
|
|
612
679
|
labelClassName,
|
|
613
680
|
inputClassName,
|
|
614
681
|
errorClassName,
|
|
615
682
|
hintClassName,
|
|
616
683
|
editable = true,
|
|
684
|
+
secureTextEntry,
|
|
685
|
+
showPasswordToggle,
|
|
617
686
|
onFocus,
|
|
618
687
|
onBlur,
|
|
619
688
|
...props
|
|
620
689
|
}) {
|
|
621
690
|
const wrapperRef = useRef(null);
|
|
691
|
+
const fieldRef = useRef(null);
|
|
622
692
|
const inputRef = useRef(null);
|
|
623
693
|
const helperRef = useRef(null);
|
|
624
694
|
const [focused, setFocused] = useState(false);
|
|
695
|
+
const [passwordVisible, setPasswordVisible] = useState(false);
|
|
625
696
|
useApplyWebClassName(wrapperRef, className);
|
|
697
|
+
useApplyWebClassName(fieldRef, fieldClassName);
|
|
626
698
|
useApplyWebClassName(inputRef, inputClassName);
|
|
627
699
|
useApplyWebClassName(helperRef, error ? errorClassName : hintClassName);
|
|
628
700
|
const isDisabled = editable === false;
|
|
701
|
+
const passwordToggleEnabled = secureTextEntry === true && showPasswordToggle !== false && rightIcon == null;
|
|
702
|
+
const effectiveSecureTextEntry = passwordToggleEnabled ? !passwordVisible : secureTextEntry;
|
|
629
703
|
const visualState = resolveInputVisualState({
|
|
630
704
|
focused,
|
|
631
705
|
error: Boolean(error),
|
|
@@ -642,29 +716,57 @@ function Input({
|
|
|
642
716
|
onBlur?.(event);
|
|
643
717
|
}
|
|
644
718
|
const helperMessage = error ?? hint;
|
|
719
|
+
function togglePasswordVisibility() {
|
|
720
|
+
if (!isDisabled) {
|
|
721
|
+
setPasswordVisible((visible) => !visible);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
const trailingIcon = passwordToggleEnabled ? /* @__PURE__ */ jsx(
|
|
725
|
+
Pressable,
|
|
726
|
+
{
|
|
727
|
+
onPress: togglePasswordVisibility,
|
|
728
|
+
disabled: isDisabled,
|
|
729
|
+
accessibilityRole: "button",
|
|
730
|
+
accessibilityLabel: passwordVisible ? "Hide password" : "Show password",
|
|
731
|
+
hitSlop: 8,
|
|
732
|
+
style: styles3.iconPressable,
|
|
733
|
+
children: renderInputIcon(
|
|
734
|
+
passwordVisible ? /* @__PURE__ */ jsx(EyeOffIcon, {}) : /* @__PURE__ */ jsx(EyeIcon, {}),
|
|
735
|
+
iconColor
|
|
736
|
+
)
|
|
737
|
+
}
|
|
738
|
+
) : rightIcon ? renderInputIcon(rightIcon, iconColor) : null;
|
|
645
739
|
return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.wrapper, containerStyle], children: [
|
|
646
740
|
label ? /* @__PURE__ */ jsx(Label, { disabled: isDisabled, className: labelClassName, children: label }) : null,
|
|
647
|
-
/* @__PURE__ */ jsx(View, { style: fieldStyles.outline, children: /* @__PURE__ */ jsxs(
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
style:
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
741
|
+
/* @__PURE__ */ jsx(View, { style: fieldStyles.outline, children: /* @__PURE__ */ jsxs(
|
|
742
|
+
View,
|
|
743
|
+
{
|
|
744
|
+
ref: fieldRef,
|
|
745
|
+
style: [inputFieldMetrics.container, fieldStyles.container, fieldStyle],
|
|
746
|
+
children: [
|
|
747
|
+
leftIcon ? /* @__PURE__ */ jsx(View, { style: styles3.iconSlot, children: renderInputIcon(leftIcon, iconColor) }) : null,
|
|
748
|
+
/* @__PURE__ */ jsx(
|
|
749
|
+
TextInput,
|
|
750
|
+
{
|
|
751
|
+
ref: inputRef,
|
|
752
|
+
style: [
|
|
753
|
+
inputFieldMetrics.input,
|
|
754
|
+
fieldStyles.text,
|
|
755
|
+
style
|
|
756
|
+
],
|
|
757
|
+
placeholderTextColor: fieldStyles.placeholder,
|
|
758
|
+
editable,
|
|
759
|
+
secureTextEntry: effectiveSecureTextEntry,
|
|
760
|
+
onFocus: handleFocus,
|
|
761
|
+
onBlur: handleBlur,
|
|
762
|
+
accessibilityState: { disabled: isDisabled },
|
|
763
|
+
...props
|
|
764
|
+
}
|
|
765
|
+
),
|
|
766
|
+
trailingIcon ? /* @__PURE__ */ jsx(View, { style: styles3.iconSlot, children: trailingIcon }) : null
|
|
767
|
+
]
|
|
768
|
+
}
|
|
769
|
+
) }),
|
|
668
770
|
helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles3.error : styles3.hint, children: helperMessage }) : null
|
|
669
771
|
] });
|
|
670
772
|
}
|
|
@@ -680,14 +782,20 @@ var styles3 = StyleSheet.create({
|
|
|
680
782
|
justifyContent: "center",
|
|
681
783
|
flexShrink: 0
|
|
682
784
|
},
|
|
785
|
+
iconPressable: {
|
|
786
|
+
width: INPUT_ICON_SIZE,
|
|
787
|
+
height: INPUT_ICON_SIZE,
|
|
788
|
+
alignItems: "center",
|
|
789
|
+
justifyContent: "center"
|
|
790
|
+
},
|
|
683
791
|
error: {
|
|
684
792
|
fontSize: 12,
|
|
685
|
-
lineHeight:
|
|
793
|
+
lineHeight: 16,
|
|
686
794
|
color: colors.inputError
|
|
687
795
|
},
|
|
688
796
|
hint: {
|
|
689
797
|
fontSize: 12,
|
|
690
|
-
lineHeight:
|
|
798
|
+
lineHeight: 16,
|
|
691
799
|
color: colors.stormGray300
|
|
692
800
|
}
|
|
693
801
|
});
|
|
@@ -1184,12 +1292,12 @@ var styles5 = StyleSheet.create({
|
|
|
1184
1292
|
},
|
|
1185
1293
|
error: {
|
|
1186
1294
|
fontSize: 12,
|
|
1187
|
-
lineHeight:
|
|
1295
|
+
lineHeight: 16,
|
|
1188
1296
|
color: colors.inputError
|
|
1189
1297
|
},
|
|
1190
1298
|
hint: {
|
|
1191
1299
|
fontSize: 12,
|
|
1192
|
-
lineHeight:
|
|
1300
|
+
lineHeight: 16,
|
|
1193
1301
|
color: colors.stormGray300
|
|
1194
1302
|
}
|
|
1195
1303
|
});
|