@scripso-homepad/ui 0.4.18 → 0.4.20

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.d.cts CHANGED
@@ -48,7 +48,7 @@ interface InputProps extends TextInputProps {
48
48
  /** When `secureTextEntry` is set, show a toggleable eye icon. Pass `false` to disable. */
49
49
  showPasswordToggle?: boolean;
50
50
  }
51
- declare function Input({ label, leftIcon, rightIcon, error, invalid, hint, containerStyle, style, className, fieldClassName, fieldStyle, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, secureTextEntry, showPasswordToggle, onFocus, onBlur, multiline, textAlignVertical, ...props }: InputProps): react.JSX.Element;
51
+ declare function Input({ label, leftIcon, rightIcon, error, invalid, hint, containerStyle, style, className, fieldClassName, fieldStyle, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, secureTextEntry, showPasswordToggle, onFocus, onBlur, onChangeText, keyboardType, multiline, textAlign, textAlignVertical, ...props }: InputProps): react.JSX.Element;
52
52
 
53
53
  type SelectOption = {
54
54
  value: string;
@@ -104,7 +104,7 @@ interface PhoneInputProps extends Omit<TextInputProps, "style"> {
104
104
  errorClassName?: string;
105
105
  hintClassName?: string;
106
106
  }
107
- declare function PhoneInput({ label, countryCode, onCountryCodeChange, error, hint, containerStyle, style, className, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, onFocus, onBlur, ...props }: PhoneInputProps): react.JSX.Element;
107
+ declare function PhoneInput({ label, countryCode, onCountryCodeChange, error, hint, containerStyle, style, className, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, onFocus, onBlur, onChangeText, ...props }: PhoneInputProps): react.JSX.Element;
108
108
 
109
109
  type Country = {
110
110
  code: string;
package/dist/index.d.ts CHANGED
@@ -48,7 +48,7 @@ interface InputProps extends TextInputProps {
48
48
  /** When `secureTextEntry` is set, show a toggleable eye icon. Pass `false` to disable. */
49
49
  showPasswordToggle?: boolean;
50
50
  }
51
- declare function Input({ label, leftIcon, rightIcon, error, invalid, hint, containerStyle, style, className, fieldClassName, fieldStyle, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, secureTextEntry, showPasswordToggle, onFocus, onBlur, multiline, textAlignVertical, ...props }: InputProps): react.JSX.Element;
51
+ declare function Input({ label, leftIcon, rightIcon, error, invalid, hint, containerStyle, style, className, fieldClassName, fieldStyle, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, secureTextEntry, showPasswordToggle, onFocus, onBlur, onChangeText, keyboardType, multiline, textAlign, textAlignVertical, ...props }: InputProps): react.JSX.Element;
52
52
 
53
53
  type SelectOption = {
54
54
  value: string;
@@ -104,7 +104,7 @@ interface PhoneInputProps extends Omit<TextInputProps, "style"> {
104
104
  errorClassName?: string;
105
105
  hintClassName?: string;
106
106
  }
107
- declare function PhoneInput({ label, countryCode, onCountryCodeChange, error, hint, containerStyle, style, className, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, onFocus, onBlur, ...props }: PhoneInputProps): react.JSX.Element;
107
+ declare function PhoneInput({ label, countryCode, onCountryCodeChange, error, hint, containerStyle, style, className, labelClassName, labelStyles, inputClassName, errorClassName, hintClassName, editable, onFocus, onBlur, onChangeText, ...props }: PhoneInputProps): react.JSX.Element;
108
108
 
109
109
  type Country = {
110
110
  code: string;
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { spacing, colors, fontWeight, fontSize, fonts, radii, INPUT_ICON_GAP, useApplyWebClassName, resolveInputVisualState, Label, getInputFieldStyles, inputFieldMetrics } from './chunk-U7OSCJKA.js';
2
- export { Button, Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray, typographyScale } from './chunk-U7OSCJKA.js';
1
+ import { spacing, colors, fontWeight, fontSize, fonts, radii, INPUT_ICON_GAP, useApplyWebClassName, resolveInputVisualState, Label, getInputFieldStyles, inputFieldMetrics } from './chunk-F7NV3HPU.js';
2
+ export { Button, Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray, typographyScale } from './chunk-F7NV3HPU.js';
3
3
  import { createContext, useRef, useState, useMemo, useEffect, useLayoutEffect, useContext, isValidElement, cloneElement } from 'react';
4
4
  import { Platform, StyleSheet, Animated, Easing, View, Pressable, Text, Modal, ScrollView, TextInput, Dimensions } from 'react-native';
5
5
  import Svg2, { Path } from 'react-native-svg';
@@ -520,13 +520,6 @@ function Select({
520
520
  inputRange: [0, 1],
521
521
  outputRange: ["0deg", "180deg"]
522
522
  });
523
- const hasError = Boolean(error) || Boolean(invalid);
524
- const visualState = resolveInputVisualState({
525
- focused: open,
526
- error: hasError,
527
- disabled
528
- });
529
- const fieldStyles = getSelectFieldStyles(visualState);
530
523
  const selectedValues = useMemo(
531
524
  () => normalizeSelectedValues(multiple, value),
532
525
  [multiple, value]
@@ -540,6 +533,14 @@ function Select({
540
533
  () => options.filter((option) => !option.disabled),
541
534
  [options]
542
535
  );
536
+ const isEffectivelyDisabled = disabled || selectableOptions.length === 0;
537
+ const hasError = Boolean(error) || Boolean(invalid);
538
+ const visualState = resolveInputVisualState({
539
+ focused: open,
540
+ error: hasError,
541
+ disabled: isEffectivelyDisabled
542
+ });
543
+ const fieldStyles = getSelectFieldStyles(visualState);
543
544
  const selectableIndexByValue = useMemo(
544
545
  () => new Map(
545
546
  selectableOptions.map((option, index) => [option.value, index])
@@ -567,7 +568,7 @@ function Select({
567
568
  setHighlightedIndex(-1);
568
569
  }
569
570
  function openMenu() {
570
- if (disabled || selectableOptions.length === 0) {
571
+ if (isEffectivelyDisabled) {
571
572
  return;
572
573
  }
573
574
  triggerRef.current?.measureInWindow((x, y, width, height) => {
@@ -586,7 +587,6 @@ function Select({
586
587
  return;
587
588
  }
588
589
  if (selectedValues.includes(nextValue)) {
589
- onValueChange?.("");
590
590
  closeMenu();
591
591
  return;
592
592
  }
@@ -616,14 +616,14 @@ function Select({
616
616
  });
617
617
  const dropdownTop = anchor ? resolveSelectDropdownTop(anchor, dropdownHeight) : 0;
618
618
  return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles.wrapper, containerStyle], children: [
619
- label ? /* @__PURE__ */ jsx(Label, { disabled, style: styles.label, className: labelClassName, children: label }) : null,
619
+ label ? /* @__PURE__ */ jsx(Label, { disabled: isEffectivelyDisabled, style: styles.label, className: labelClassName, children: label }) : null,
620
620
  /* @__PURE__ */ jsx(View, { style: fieldStyles.outline, children: /* @__PURE__ */ jsxs(
621
621
  Pressable,
622
622
  {
623
623
  ref: triggerRef,
624
624
  accessibilityRole: "button",
625
- accessibilityState: { disabled, expanded: open },
626
- disabled,
625
+ accessibilityState: { disabled: isEffectivelyDisabled, expanded: open },
626
+ disabled: isEffectivelyDisabled,
627
627
  onPress: open ? closeMenu : openMenu,
628
628
  style: [selectFieldMetrics.container, fieldStyles.container, fieldStyle],
629
629
  children: [
@@ -657,7 +657,7 @@ function Select({
657
657
  ChevronDownIcon,
658
658
  {
659
659
  size: SELECT_CHEVRON_SIZE,
660
- color: disabled ? colors.stormGray200 : SELECT_CHEVRON_COLOR
660
+ color: isEffectivelyDisabled ? colors.stormGray200 : SELECT_CHEVRON_COLOR
661
661
  }
662
662
  )
663
663
  }
@@ -666,35 +666,46 @@ function Select({
666
666
  }
667
667
  ) }),
668
668
  helperMessage ? /* @__PURE__ */ jsx(Text, { ref: helperRef, style: error ? styles.error : styles.hint, children: helperMessage }) : null,
669
- /* @__PURE__ */ jsx(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closeMenu, children: /* @__PURE__ */ jsx(Pressable, { style: styles.overlay, onPress: closeMenu, children: anchor ? /* @__PURE__ */ jsx(
670
- View,
671
- {
672
- ref: menuRef,
673
- style: [
674
- selectDropdownMetrics.menu,
675
- styles.dropdown,
676
- {
677
- top: dropdownTop,
678
- left: anchor.x,
679
- width: anchor.width,
680
- height: dropdownHeight
681
- }
682
- ],
683
- children: needsScroll ? /* @__PURE__ */ jsx(
684
- ScrollView,
685
- {
686
- ref: scrollRef,
687
- style: styles.dropdownScroll,
688
- contentContainerStyle: styles.dropdownContent,
689
- keyboardShouldPersistTaps: "handled",
690
- showsVerticalScrollIndicator: true,
691
- bounces: false,
692
- nestedScrollEnabled: true,
693
- children: optionList
694
- }
695
- ) : /* @__PURE__ */ jsx(View, { style: styles.dropdownContent, children: optionList })
696
- }
697
- ) : null }) })
669
+ /* @__PURE__ */ jsx(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closeMenu, children: /* @__PURE__ */ jsxs(View, { style: styles.overlay, children: [
670
+ /* @__PURE__ */ jsx(
671
+ Pressable,
672
+ {
673
+ style: styles.backdrop,
674
+ onPress: closeMenu,
675
+ accessibilityRole: "button",
676
+ accessibilityLabel: "Close"
677
+ }
678
+ ),
679
+ anchor ? /* @__PURE__ */ jsx(
680
+ View,
681
+ {
682
+ ref: menuRef,
683
+ style: [
684
+ selectDropdownMetrics.menu,
685
+ styles.dropdown,
686
+ {
687
+ top: dropdownTop,
688
+ left: anchor.x,
689
+ width: anchor.width,
690
+ height: dropdownHeight
691
+ }
692
+ ],
693
+ children: needsScroll ? /* @__PURE__ */ jsx(
694
+ ScrollView,
695
+ {
696
+ ref: scrollRef,
697
+ style: styles.dropdownScroll,
698
+ contentContainerStyle: styles.dropdownContent,
699
+ keyboardShouldPersistTaps: "handled",
700
+ showsVerticalScrollIndicator: true,
701
+ bounces: false,
702
+ nestedScrollEnabled: true,
703
+ children: optionList
704
+ }
705
+ ) : /* @__PURE__ */ jsx(View, { style: styles.dropdownContent, children: optionList })
706
+ }
707
+ ) : null
708
+ ] }) })
698
709
  ] });
699
710
  }
700
711
  var styles = StyleSheet.create({
@@ -718,11 +729,15 @@ var styles = StyleSheet.create({
718
729
  justifyContent: "center"
719
730
  },
720
731
  overlay: {
721
- flex: 1,
732
+ flex: 1
733
+ },
734
+ backdrop: {
735
+ ...StyleSheet.absoluteFillObject,
722
736
  backgroundColor: colors.transparent
723
737
  },
724
738
  dropdown: {
725
- position: "absolute"
739
+ position: "absolute",
740
+ zIndex: 1
726
741
  },
727
742
  dropdownScroll: {
728
743
  flex: 1
@@ -1083,6 +1098,9 @@ var styles2 = StyleSheet.create({
1083
1098
  color: colors.slateBlue
1084
1099
  }
1085
1100
  });
1101
+ function sanitizePhoneDigits(value) {
1102
+ return value.replace(/\D/g, "");
1103
+ }
1086
1104
  function PhoneInput({
1087
1105
  label,
1088
1106
  countryCode,
@@ -1100,6 +1118,7 @@ function PhoneInput({
1100
1118
  editable = true,
1101
1119
  onFocus,
1102
1120
  onBlur,
1121
+ onChangeText,
1103
1122
  ...props
1104
1123
  }) {
1105
1124
  const wrapperRef = useRef(null);
@@ -1124,6 +1143,9 @@ function PhoneInput({
1124
1143
  setFocused(false);
1125
1144
  onBlur?.(event);
1126
1145
  }
1146
+ function handleChangeText(value) {
1147
+ onChangeText?.(sanitizePhoneDigits(value));
1148
+ }
1127
1149
  const helperMessage = error ?? hint;
1128
1150
  return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.wrapper, containerStyle], children: [
1129
1151
  label ? /* @__PURE__ */ jsx(
@@ -1168,7 +1190,8 @@ function PhoneInput({
1168
1190
  onFocus: handleFocus,
1169
1191
  onBlur: handleBlur,
1170
1192
  accessibilityState: { disabled: isDisabled },
1171
- ...props
1193
+ ...props,
1194
+ onChangeText: handleChangeText
1172
1195
  }
1173
1196
  )
1174
1197
  }