@swan-io/lake 8.0.0 → 8.1.0
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swan-io/lake",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18.0.0",
|
|
6
6
|
"yarn": "^1.22.0"
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@react-three/drei": "^9.104.1",
|
|
30
30
|
"@react-three/fiber": "^8.16.1",
|
|
31
|
-
"@swan-io/boxed": "^2.
|
|
31
|
+
"@swan-io/boxed": "^2.2.1",
|
|
32
32
|
"@swan-io/chicane": "^2.0.0",
|
|
33
|
-
"@swan-io/graphql-client": "^0.1.
|
|
34
|
-
"@swan-io/use-form": "^2.0.
|
|
33
|
+
"@swan-io/graphql-client": "^0.1.1",
|
|
34
|
+
"@swan-io/use-form": "^2.0.2",
|
|
35
35
|
"dayjs": "^1.11.10",
|
|
36
36
|
"polished": "^4.3.1",
|
|
37
37
|
"prism-react-renderer": "^2.3.1",
|
|
@@ -26,6 +26,7 @@ export type LakeTextInputProps = Except<TextInputProps, "editable" | "keyboardTy
|
|
|
26
26
|
onUnitChange?: (value: string) => void;
|
|
27
27
|
maxCharCount?: number;
|
|
28
28
|
help?: string;
|
|
29
|
+
warning?: boolean;
|
|
29
30
|
renderEnd?: () => ReactNode;
|
|
30
31
|
containerRef?: Ref<View>;
|
|
31
32
|
};
|
|
@@ -242,6 +243,7 @@ export declare const LakeTextInput: import("react").ForwardRefExoticComponent<{
|
|
|
242
243
|
onUnitChange?: ((value: string) => void) | undefined;
|
|
243
244
|
maxCharCount?: number | undefined;
|
|
244
245
|
help?: string | undefined;
|
|
246
|
+
warning?: boolean | undefined;
|
|
245
247
|
renderEnd?: (() => ReactNode) | undefined;
|
|
246
248
|
containerRef?: Ref<View> | undefined;
|
|
247
249
|
} & import("react").RefAttributes<TextInput | null>>;
|
|
@@ -128,7 +128,7 @@ export const LakeTextInput = forwardRef(({ ariaExpanded, ariaControls, error, di
|
|
|
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, renderEnd, ...props }, forwardRef) => {
|
|
131
|
+
maxCharCount, help, warning = false, renderEnd, ...props }, forwardRef) => {
|
|
132
132
|
const inputRef = useRef(null);
|
|
133
133
|
const [isHovered, setIsHovered] = useState(false);
|
|
134
134
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -158,6 +158,7 @@ maxCharCount, help, renderEnd, ...props }, forwardRef) => {
|
|
|
158
158
|
readOnly && styles.readOnly,
|
|
159
159
|
isFocused && styles.focused,
|
|
160
160
|
isNotNullish(unit !== null && unit !== void 0 ? unit : units) && styles.inputWithUnit,
|
|
161
|
+
warning && { borderColor: colors.warning[500] },
|
|
161
162
|
hasError && styles.error,
|
|
162
163
|
valid && styles.valid,
|
|
163
164
|
stylesFromProps,
|
|
@@ -167,5 +168,5 @@ maxCharCount, help, renderEnd, ...props }, forwardRef) => {
|
|
|
167
168
|
readOnly && hasError && styles.readOnlyError,
|
|
168
169
|
disabled && styles.disabled,
|
|
169
170
|
readOnly && styles.readOnly,
|
|
170
|
-
] }), 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 && !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] })] }))] }))] }));
|
|
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] })] }))] }))] }));
|
|
171
172
|
});
|
|
@@ -6,7 +6,7 @@ export const usePersistedState = (key, defaultValue) => {
|
|
|
6
6
|
.toOption()
|
|
7
7
|
.flatMap(Option.fromNullable)
|
|
8
8
|
.map(value => JSON.parse(value))
|
|
9
|
-
.
|
|
9
|
+
.getOr(defaultValue);
|
|
10
10
|
});
|
|
11
11
|
const setPersistedState = useCallback((state) => {
|
|
12
12
|
setState(state);
|