@swan-io/lake 7.0.3 → 7.0.5
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 +1 -1
- package/src/components/LakeCopyButton.js +1 -1
- package/src/components/LakeTagInput.d.ts +4 -1
- package/src/components/LakeTagInput.js +13 -3
- package/src/components/LakeTooltip.js +8 -2
- package/src/utils/object.d.ts +1 -1
- package/src/utils/refs.d.ts +2 -0
- package/src/utils/refs.js +11 -0
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { Pressable } from "./Pressable";
|
|
|
7
7
|
export const copyButtondefaultSize = 21;
|
|
8
8
|
export const LakeCopyButton = ({ valueToCopy, size = copyButtondefaultSize, copyText, copiedText, }) => {
|
|
9
9
|
const [visibleState, setVisibleState] = useState("copy");
|
|
10
|
-
return (_jsx(LakeTooltip, { describedBy: "copy",
|
|
10
|
+
return (_jsx(LakeTooltip, { describedBy: "copy", onHide: () => setVisibleState("copy"), togglableOnFocus: true, content: visibleState === "copy" ? copyText : copiedText, children: _jsx(Pressable, { onPress: event => {
|
|
11
11
|
event.stopPropagation();
|
|
12
12
|
event.preventDefault();
|
|
13
13
|
Clipboard.setString(valueToCopy);
|
|
@@ -14,6 +14,9 @@ export type LakeTagInputProps = Merge<TextInputProps, {
|
|
|
14
14
|
onValuesChanged: (values: string[]) => void;
|
|
15
15
|
placeholder?: string;
|
|
16
16
|
}>;
|
|
17
|
+
export type TagInputRef = TextInput & {
|
|
18
|
+
pushPendingValue: () => void;
|
|
19
|
+
};
|
|
17
20
|
export declare const LakeTagInput: import("react").ForwardRefExoticComponent<{
|
|
18
21
|
allowFontScaling?: boolean | undefined;
|
|
19
22
|
autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
|
|
@@ -216,4 +219,4 @@ export declare const LakeTagInput: import("react").ForwardRefExoticComponent<{
|
|
|
216
219
|
values: string[];
|
|
217
220
|
onValuesChanged: (values: string[]) => void;
|
|
218
221
|
placeholder?: string | undefined;
|
|
219
|
-
} & import("react").RefAttributes<
|
|
222
|
+
} & import("react").RefAttributes<TagInputRef>>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useCallback, useRef, useState } from "react";
|
|
2
|
+
import { forwardRef, useCallback, useImperativeHandle, useRef, useState } from "react";
|
|
3
3
|
import { StyleSheet, TextInput, View, } from "react-native";
|
|
4
4
|
import { P, match } from "ts-pattern";
|
|
5
5
|
import { backgroundColor, colors, radii, shadows, spacings } from "../constants/design";
|
|
@@ -77,11 +77,12 @@ const styles = StyleSheet.create({
|
|
|
77
77
|
},
|
|
78
78
|
});
|
|
79
79
|
const SEPARATORS_REGEX = /,| /;
|
|
80
|
-
export const LakeTagInput = forwardRef(({ validator = () => true, onFocus: originalOnFocus, onBlur: originalOnBlur, validateOnBlur = true, values, onValuesChanged, readOnly = false, disabled = false, valid = false, hideErrors = false, placeholder, help, error, },
|
|
80
|
+
export const LakeTagInput = forwardRef(({ validator = () => true, onFocus: originalOnFocus, onBlur: originalOnBlur, validateOnBlur = true, values, onValuesChanged, readOnly = false, disabled = false, valid = false, hideErrors = false, placeholder, help, error, }, forwardedRef) => {
|
|
81
81
|
const inputRef = useRef(null);
|
|
82
82
|
const containerRef = useRef(null);
|
|
83
83
|
const [isFocused, setIsFocused] = useState(false);
|
|
84
84
|
const [isHovered, setIsHovered] = useState(false);
|
|
85
|
+
const mergedRef = useMergeRefs(inputRef, forwardedRef);
|
|
85
86
|
useHover(containerRef, {
|
|
86
87
|
onHoverStart: () => setIsHovered(true),
|
|
87
88
|
onHoverEnd: () => setIsHovered(false),
|
|
@@ -131,7 +132,16 @@ export const LakeTagInput = forwardRef(({ validator = () => true, onFocus: origi
|
|
|
131
132
|
setIsFocused(false);
|
|
132
133
|
originalOnBlur === null || originalOnBlur === void 0 ? void 0 : originalOnBlur(event);
|
|
133
134
|
}, [pushNewValues, originalOnBlur, validateOnBlur]);
|
|
134
|
-
|
|
135
|
+
useImperativeHandle(forwardedRef, () => ({
|
|
136
|
+
pushPendingValue: () => {
|
|
137
|
+
const input = inputRef.current;
|
|
138
|
+
if (input instanceof HTMLInputElement &&
|
|
139
|
+
isNotNullishOrEmpty(input.value) &&
|
|
140
|
+
validateOnBlur) {
|
|
141
|
+
pushNewValues([input.value]);
|
|
142
|
+
}
|
|
143
|
+
},
|
|
144
|
+
}), [pushNewValues, validateOnBlur]);
|
|
135
145
|
const hasError = isNotNullishOrEmpty(error);
|
|
136
146
|
return (_jsxs(View, { children: [_jsxs(Pressable, { style: [
|
|
137
147
|
styles.root,
|
|
@@ -31,6 +31,12 @@ const styles = StyleSheet.create({
|
|
|
31
31
|
arrowBar: {
|
|
32
32
|
paddingHorizontal: spacings[12],
|
|
33
33
|
},
|
|
34
|
+
arrowBarTop: {
|
|
35
|
+
top: 1,
|
|
36
|
+
},
|
|
37
|
+
arrowBarBottom: {
|
|
38
|
+
bottom: 1,
|
|
39
|
+
},
|
|
34
40
|
info: {
|
|
35
41
|
flexGrow: 0,
|
|
36
42
|
},
|
|
@@ -108,10 +114,10 @@ const Tooltip = memo(forwardRef(({ children, content, describedBy, matchReferenc
|
|
|
108
114
|
.with("left", () => "start")
|
|
109
115
|
.with("center", () => "center")
|
|
110
116
|
.with("right", () => "end")
|
|
111
|
-
.exhaustive(), style: styles.arrowBar, children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 0 16 8 0 8", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null, _jsx(View, { style: [styles.content, { width }], children: typeof content === "string" || typeof content === "number" ? (_jsx(LakeText, { align: "center", color: colors.gray.contrast, children: content })) : (content) }), position.get().verticalPosition === "top" ? (_jsx(Box, { direction: "row", justifyContent: match(position.get().horizontalPosition)
|
|
117
|
+
.exhaustive(), style: [styles.arrowBar, styles.arrowBarTop], children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 0 16 8 0 8", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null, _jsx(View, { style: [styles.content, { width }], children: typeof content === "string" || typeof content === "number" ? (_jsx(LakeText, { align: "center", color: colors.gray.contrast, children: content })) : (content) }), position.get().verticalPosition === "top" ? (_jsx(Box, { direction: "row", justifyContent: match(position.get().horizontalPosition)
|
|
112
118
|
.with("left", () => "start")
|
|
113
119
|
.with("center", () => "center")
|
|
114
120
|
.with("right", () => "end")
|
|
115
|
-
.exhaustive(), style: styles.arrowBar, children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 8 16 0 0 0", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null] }) }) }))] }));
|
|
121
|
+
.exhaustive(), style: [styles.arrowBar, styles.arrowBarBottom], children: _jsx(Svg, { width: 16, height: 8, viewBox: "0 0 16 8", children: _jsx(Polygon, { points: "8 8 16 0 0 0", fill: hideArrow ? "transparent" : colors.gray[900] }) }) })) : null] }) }) }))] }));
|
|
116
122
|
}));
|
|
117
123
|
export const InformationTooltip = forwardRef(({ text }, forwardedRef) => (_jsx(LakeTooltip, { ref: forwardedRef, describedBy: "copy", placement: "right", togglableOnFocus: true, width: 300, content: text, children: _jsx(View, { style: styles.info, children: _jsx(Icon, { name: "info-regular", size: 24, color: colors.gray[900] }) }) })));
|
package/src/utils/object.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const isPlainObject: (value: unknown) => boolean;
|
|
2
|
-
export declare const pick: <T extends Record<K, unknown>, K extends keyof T>(object: T, keys: K[]) => Pick<T, K>;
|
|
2
|
+
export declare const pick: <T extends Record<K, unknown>, const K extends keyof T>(object: T, keys: K[]) => Pick<T, K>;
|