@scripso-homepad/ui 0.4.18 → 0.4.19
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/{chunk-U7OSCJKA.js → chunk-THZ3HYMF.js} +32 -6
- package/dist/chunk-THZ3HYMF.js.map +1 -0
- package/dist/index.cjs +98 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +70 -46
- package/dist/index.js.map +1 -1
- package/dist/web/index.cjs +31 -5
- package/dist/web/index.cjs.map +1 -1
- package/dist/web/index.css +1 -6
- package/dist/web/index.css.map +1 -1
- package/dist/web/index.js +2 -2
- package/dist/web/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/Button.tsx +1 -1
- package/src/components/Input.tsx +40 -0
- package/src/components/PhoneInput.tsx +11 -0
- package/src/components/Select.tsx +26 -15
- package/src/web/components/TableActionsMenu.tsx +1 -1
- package/src/web/components/drawer-scroll.css +1 -7
- package/dist/chunk-U7OSCJKA.js.map +0 -1
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, 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, 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-
|
|
2
|
-
export { Button, Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray, typographyScale } from './chunk-
|
|
1
|
+
import { spacing, colors, fontWeight, fontSize, fonts, radii, INPUT_ICON_GAP, useApplyWebClassName, resolveInputVisualState, Label, getInputFieldStyles, inputFieldMetrics } from './chunk-THZ3HYMF.js';
|
|
2
|
+
export { Button, Input, Label, brand, buttonTypography, colors, emeraldGreen, fontSize, fontWeight, fonts, labelTypography, navy, radii, rubyRed, shadows, spacing, stormGray, typographyScale } from './chunk-THZ3HYMF.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 (
|
|
571
|
+
if (isEffectivelyDisabled) {
|
|
571
572
|
return;
|
|
572
573
|
}
|
|
573
574
|
triggerRef.current?.measureInWindow((x, y, width, height) => {
|
|
@@ -616,14 +617,14 @@ function Select({
|
|
|
616
617
|
});
|
|
617
618
|
const dropdownTop = anchor ? resolveSelectDropdownTop(anchor, dropdownHeight) : 0;
|
|
618
619
|
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,
|
|
620
|
+
label ? /* @__PURE__ */ jsx(Label, { disabled: isEffectivelyDisabled, style: styles.label, className: labelClassName, children: label }) : null,
|
|
620
621
|
/* @__PURE__ */ jsx(View, { style: fieldStyles.outline, children: /* @__PURE__ */ jsxs(
|
|
621
622
|
Pressable,
|
|
622
623
|
{
|
|
623
624
|
ref: triggerRef,
|
|
624
625
|
accessibilityRole: "button",
|
|
625
|
-
accessibilityState: { disabled, expanded: open },
|
|
626
|
-
disabled,
|
|
626
|
+
accessibilityState: { disabled: isEffectivelyDisabled, expanded: open },
|
|
627
|
+
disabled: isEffectivelyDisabled,
|
|
627
628
|
onPress: open ? closeMenu : openMenu,
|
|
628
629
|
style: [selectFieldMetrics.container, fieldStyles.container, fieldStyle],
|
|
629
630
|
children: [
|
|
@@ -657,7 +658,7 @@ function Select({
|
|
|
657
658
|
ChevronDownIcon,
|
|
658
659
|
{
|
|
659
660
|
size: SELECT_CHEVRON_SIZE,
|
|
660
|
-
color:
|
|
661
|
+
color: isEffectivelyDisabled ? colors.stormGray200 : SELECT_CHEVRON_COLOR
|
|
661
662
|
}
|
|
662
663
|
)
|
|
663
664
|
}
|
|
@@ -666,35 +667,46 @@ function Select({
|
|
|
666
667
|
}
|
|
667
668
|
) }),
|
|
668
669
|
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__ */
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
670
|
+
/* @__PURE__ */ jsx(Modal, { visible: open, transparent: true, animationType: "fade", onRequestClose: closeMenu, children: /* @__PURE__ */ jsxs(View, { style: styles.overlay, children: [
|
|
671
|
+
/* @__PURE__ */ jsx(
|
|
672
|
+
Pressable,
|
|
673
|
+
{
|
|
674
|
+
style: styles.backdrop,
|
|
675
|
+
onPress: closeMenu,
|
|
676
|
+
accessibilityRole: "button",
|
|
677
|
+
accessibilityLabel: "Close"
|
|
678
|
+
}
|
|
679
|
+
),
|
|
680
|
+
anchor ? /* @__PURE__ */ jsx(
|
|
681
|
+
View,
|
|
682
|
+
{
|
|
683
|
+
ref: menuRef,
|
|
684
|
+
style: [
|
|
685
|
+
selectDropdownMetrics.menu,
|
|
686
|
+
styles.dropdown,
|
|
687
|
+
{
|
|
688
|
+
top: dropdownTop,
|
|
689
|
+
left: anchor.x,
|
|
690
|
+
width: anchor.width,
|
|
691
|
+
height: dropdownHeight
|
|
692
|
+
}
|
|
693
|
+
],
|
|
694
|
+
children: needsScroll ? /* @__PURE__ */ jsx(
|
|
695
|
+
ScrollView,
|
|
696
|
+
{
|
|
697
|
+
ref: scrollRef,
|
|
698
|
+
style: styles.dropdownScroll,
|
|
699
|
+
contentContainerStyle: styles.dropdownContent,
|
|
700
|
+
keyboardShouldPersistTaps: "handled",
|
|
701
|
+
showsVerticalScrollIndicator: true,
|
|
702
|
+
bounces: false,
|
|
703
|
+
nestedScrollEnabled: true,
|
|
704
|
+
children: optionList
|
|
705
|
+
}
|
|
706
|
+
) : /* @__PURE__ */ jsx(View, { style: styles.dropdownContent, children: optionList })
|
|
707
|
+
}
|
|
708
|
+
) : null
|
|
709
|
+
] }) })
|
|
698
710
|
] });
|
|
699
711
|
}
|
|
700
712
|
var styles = StyleSheet.create({
|
|
@@ -718,11 +730,15 @@ var styles = StyleSheet.create({
|
|
|
718
730
|
justifyContent: "center"
|
|
719
731
|
},
|
|
720
732
|
overlay: {
|
|
721
|
-
flex: 1
|
|
733
|
+
flex: 1
|
|
734
|
+
},
|
|
735
|
+
backdrop: {
|
|
736
|
+
...StyleSheet.absoluteFillObject,
|
|
722
737
|
backgroundColor: colors.transparent
|
|
723
738
|
},
|
|
724
739
|
dropdown: {
|
|
725
|
-
position: "absolute"
|
|
740
|
+
position: "absolute",
|
|
741
|
+
zIndex: 1
|
|
726
742
|
},
|
|
727
743
|
dropdownScroll: {
|
|
728
744
|
flex: 1
|
|
@@ -1083,6 +1099,9 @@ var styles2 = StyleSheet.create({
|
|
|
1083
1099
|
color: colors.slateBlue
|
|
1084
1100
|
}
|
|
1085
1101
|
});
|
|
1102
|
+
function sanitizePhoneDigits(value) {
|
|
1103
|
+
return value.replace(/\D/g, "");
|
|
1104
|
+
}
|
|
1086
1105
|
function PhoneInput({
|
|
1087
1106
|
label,
|
|
1088
1107
|
countryCode,
|
|
@@ -1100,6 +1119,7 @@ function PhoneInput({
|
|
|
1100
1119
|
editable = true,
|
|
1101
1120
|
onFocus,
|
|
1102
1121
|
onBlur,
|
|
1122
|
+
onChangeText,
|
|
1103
1123
|
...props
|
|
1104
1124
|
}) {
|
|
1105
1125
|
const wrapperRef = useRef(null);
|
|
@@ -1124,6 +1144,9 @@ function PhoneInput({
|
|
|
1124
1144
|
setFocused(false);
|
|
1125
1145
|
onBlur?.(event);
|
|
1126
1146
|
}
|
|
1147
|
+
function handleChangeText(value) {
|
|
1148
|
+
onChangeText?.(sanitizePhoneDigits(value));
|
|
1149
|
+
}
|
|
1127
1150
|
const helperMessage = error ?? hint;
|
|
1128
1151
|
return /* @__PURE__ */ jsxs(View, { ref: wrapperRef, style: [styles3.wrapper, containerStyle], children: [
|
|
1129
1152
|
label ? /* @__PURE__ */ jsx(
|
|
@@ -1168,7 +1191,8 @@ function PhoneInput({
|
|
|
1168
1191
|
onFocus: handleFocus,
|
|
1169
1192
|
onBlur: handleBlur,
|
|
1170
1193
|
accessibilityState: { disabled: isDisabled },
|
|
1171
|
-
...props
|
|
1194
|
+
...props,
|
|
1195
|
+
onChangeText: handleChangeText
|
|
1172
1196
|
}
|
|
1173
1197
|
)
|
|
1174
1198
|
}
|