@swan-io/lake 13.1.0 → 13.1.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.
package/package.json
CHANGED
|
@@ -27,8 +27,9 @@ export type LakeTextInputProps = Except<TextInputProps, "editable" | "keyboardTy
|
|
|
27
27
|
onUnitChange?: (value: string) => void;
|
|
28
28
|
maxCharCount?: number;
|
|
29
29
|
help?: string;
|
|
30
|
+
info?: ReactNode | null | undefined;
|
|
30
31
|
warning?: boolean;
|
|
31
32
|
renderEnd?: () => ReactNode;
|
|
32
33
|
containerRef?: Ref<View>;
|
|
33
34
|
};
|
|
34
|
-
export declare const LakeTextInput: ({ ref, ariaExpanded, ariaControls, error, disabled, validating, valid, readOnly, icon, children, unit, units, color, inputMode, hideErrors, onChange, onUnitChange, pattern, style: stylesFromProps, containerStyle: containerStylesFromProps, onFocus: originalOnFocus, onBlur: originalOnBlur, value, defaultValue, multiline, containerRef, maxCharCount, help, warning, renderEnd, ...props }: LakeTextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
export declare const LakeTextInput: ({ ref, ariaExpanded, ariaControls, error, disabled, validating, valid, readOnly, icon, children, unit, units, color, inputMode, hideErrors, onChange, onUnitChange, pattern, style: stylesFromProps, containerStyle: containerStylesFromProps, onFocus: originalOnFocus, onBlur: originalOnBlur, value, defaultValue, multiline, containerRef, maxCharCount, help, warning, info, renderEnd, ...props }: LakeTextInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -128,7 +128,7 @@ export const LakeTextInput = ({ ref, ariaExpanded, ariaControls, error, disabled
|
|
|
128
128
|
//maxCharCount is different from maxLength(props inherited of TextInput)
|
|
129
129
|
//maxLength truncates the text in the limitation asked,
|
|
130
130
|
//maxCharCount doesn't have limitation but displays a counter of characters
|
|
131
|
-
maxCharCount, help, warning = false, renderEnd, ...props }) => {
|
|
131
|
+
maxCharCount, help, warning = false, info, renderEnd, ...props }) => {
|
|
132
132
|
const inputRef = useRef(null);
|
|
133
133
|
const [isHovered, setIsHovered] = useState(false);
|
|
134
134
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -148,6 +148,7 @@ maxCharCount, help, warning = false, renderEnd, ...props }) => {
|
|
|
148
148
|
const mergedRef = useMergeRefs(inputRef, ref);
|
|
149
149
|
const isInteractive = !disabled && !readOnly;
|
|
150
150
|
const hasError = isNotNullishOrEmpty(error);
|
|
151
|
+
const hasInfo = isNotNullish(info);
|
|
151
152
|
const charCount = isNullish(value) ? 0 : value.length;
|
|
152
153
|
return (_jsxs(View, { style: commonStyles.fill, children: [_jsxs(View, { style: styles.root, "aria-errormessage": error, children: [_jsxs(View, { style: [styles.container, containerStylesFromProps], children: [_jsxs(View, { style: [
|
|
153
154
|
styles.contents,
|
|
@@ -159,6 +160,7 @@ maxCharCount, help, warning = false, renderEnd, ...props }) => {
|
|
|
159
160
|
isFocused && styles.focused,
|
|
160
161
|
isNotNullish(unit !== null && unit !== void 0 ? unit : units) && styles.inputWithUnit,
|
|
161
162
|
warning && { borderColor: colors.warning[500] },
|
|
163
|
+
hasInfo && { borderColor: colors.shakespear[500] },
|
|
162
164
|
hasError && styles.error,
|
|
163
165
|
valid && styles.valid,
|
|
164
166
|
stylesFromProps,
|
|
@@ -168,5 +170,5 @@ maxCharCount, help, warning = false, renderEnd, ...props }) => {
|
|
|
168
170
|
readOnly && hasError && styles.readOnlyError,
|
|
169
171
|
disabled && styles.disabled,
|
|
170
172
|
readOnly && styles.readOnly,
|
|
171
|
-
] }), isNotNullish(renderEnd) && _jsx(View, { style: styles.endComponents, children: renderEnd() }), validating && (_jsx(ActivityIndicator, { size: "small", style: styles.endIcon, color: colors.current[500] })), !validating && hasError && (_jsx(Icon, { name: "warning-regular", size: 20, color: colors.negative[400], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), !validating && warning && !hasError && (_jsx(Icon, { name: "warning-regular", size: 20, color: colors.warning[500], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), !validating && !hasError && valid && (_jsx(Icon, { name: "checkmark-filled", size: 20, color: colors.positive[400], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] }))] }), isNotNullish(units) && isNotNullish(onUnitChange) ? (_jsx(Box, { children: _jsx(LakeSelect, { value: unit, onValueChange: onUnitChange, items: units.map(value => ({ name: value, value })), disabled: disabled, style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], mode: "borderless", hideErrors: true }) })) : isNotNullish(unit) ? (_jsx(LakeText, { color: colors.gray[900], style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], children: unit })) : null] }), children] }), !hideErrors && (_jsxs(Box, { direction: "row", style: styles.errorContainer, children: [isNotNullish(error) ? (_jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], children: error })) : (_jsx(LakeText, { variant: "smallRegular", color: colors.gray[500], children: help !== null && help !== void 0 ? help : " " })), isNotNullish(maxCharCount) && (_jsxs(_Fragment, { children: [_jsx(Fill, { minWidth: 4 }), _jsxs(LakeText, { variant: "smallRegular", color: charCount > maxCharCount ? colors.negative[500] : colors.gray[400], style: styles.descriptionLimitation, children: [charCount, " / ", maxCharCount] })] }))] }))] }));
|
|
173
|
+
] }), isNotNullish(renderEnd) && _jsx(View, { style: styles.endComponents, children: renderEnd() }), validating && (_jsx(ActivityIndicator, { size: "small", style: styles.endIcon, color: colors.current[500] })), !validating && hasError && (_jsx(Icon, { name: "warning-regular", size: 20, color: colors.negative[400], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), !validating && warning && !hasError && (_jsx(Icon, { name: "warning-regular", size: 20, color: colors.warning[500], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), !validating && info && !hasError && (_jsx(Icon, { name: "info-regular", size: 20, color: colors.shakespear[500], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] })), !validating && !hasError && valid && (_jsx(Icon, { name: "checkmark-filled", size: 20, color: colors.positive[400], style: [styles.endIcon, readOnly && styles.readOnlyEndIcon] }))] }), isNotNullish(units) && isNotNullish(onUnitChange) ? (_jsx(Box, { children: _jsx(LakeSelect, { value: unit, onValueChange: onUnitChange, items: units.map(value => ({ name: value, value })), disabled: disabled, style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], mode: "borderless", hideErrors: true }) })) : isNotNullish(unit) ? (_jsx(LakeText, { color: colors.gray[900], style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], children: unit })) : null] }), children] }), !hideErrors && (_jsxs(Box, { direction: "row", style: styles.errorContainer, children: [isNotNullish(error) ? (_jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], children: error })) : (_jsx(LakeText, { variant: "smallRegular", color: colors.gray[500], children: help !== null && help !== void 0 ? help : " " })), isNotNullish(info) && (_jsx(LakeText, { variant: "smallRegular", color: colors.shakespear[500], children: info })), isNotNullish(maxCharCount) && (_jsxs(_Fragment, { children: [_jsx(Fill, { minWidth: 4 }), _jsxs(LakeText, { variant: "smallRegular", color: charCount > maxCharCount ? colors.negative[500] : colors.gray[400], style: styles.descriptionLimitation, children: [charCount, " / ", maxCharCount] })] }))] }))] }));
|
|
172
174
|
};
|