@swan-io/lake 1.5.0 → 1.6.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 +1 -1
- package/src/components/AutocompleteSearchInput.d.ts +25 -0
- package/src/components/AutocompleteSearchInput.js +27 -0
- package/src/components/FilterChooser.js +1 -1
- package/src/components/Filters.js +1 -1
- package/src/components/Input.js +1 -1
- package/src/components/LakeButton.js +15 -5
- package/src/components/LakeCombobox.js +1 -1
- package/src/components/LakeModal.js +2 -2
- package/src/components/LakeTextInput.d.ts +2 -0
- package/src/components/LakeTextInput.js +2 -2
- package/src/components/MultiSelect.js +1 -1
- package/src/components/Pressable.d.ts +11 -11
- package/src/components/SidebarNavigationTracker.js +1 -1
- package/src/components/SortBottomPanel.d.ts +21 -0
- package/src/components/SortBottomPanel.js +41 -0
- package/src/components/Stack.d.ts +1 -1
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Future, Result } from "@swan-io/boxed";
|
|
2
|
+
import { MutableRefObject, ReactNode } from "react";
|
|
3
|
+
type Suggestion<T> = {
|
|
4
|
+
id: string;
|
|
5
|
+
title: string;
|
|
6
|
+
subtitle: string;
|
|
7
|
+
value: T;
|
|
8
|
+
};
|
|
9
|
+
type Props<T> = {
|
|
10
|
+
inputRef?: MutableRefObject<unknown>;
|
|
11
|
+
value?: string;
|
|
12
|
+
onValueChange: (value: string) => void;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
id?: string;
|
|
15
|
+
placeholder?: string;
|
|
16
|
+
error?: string;
|
|
17
|
+
emptyResultText: string;
|
|
18
|
+
ListFooterComponent?: ReactNode;
|
|
19
|
+
shouldDisplaySuggestions?: boolean;
|
|
20
|
+
loadSuggestions: (value: string) => Future<Result<Suggestion<T>[], unknown>>;
|
|
21
|
+
onSuggestion: (suggestion: Suggestion<T>) => void;
|
|
22
|
+
onLoadError?: (error: unknown) => void;
|
|
23
|
+
};
|
|
24
|
+
export declare const AutocompleteSearchInput: <T>({ inputRef, value, onValueChange, disabled, id, placeholder, error, emptyResultText, ListFooterComponent, shouldDisplaySuggestions, loadSuggestions, onSuggestion, onLoadError, }: Props<T>) => JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { AsyncData } from "@swan-io/boxed";
|
|
3
|
+
import { useRef, useState } from "react";
|
|
4
|
+
import { colors } from "../constants/design";
|
|
5
|
+
import { LakeCombobox } from "./LakeCombobox";
|
|
6
|
+
import { LakeText } from "./LakeText";
|
|
7
|
+
export const AutocompleteSearchInput = ({ inputRef, value, onValueChange, disabled, id, placeholder, error, emptyResultText, ListFooterComponent, shouldDisplaySuggestions = true, loadSuggestions, onSuggestion, onLoadError, }) => {
|
|
8
|
+
const [state, setState] = useState(AsyncData.NotAsked());
|
|
9
|
+
const lastRequest = useRef();
|
|
10
|
+
return (_jsx(LakeCombobox, { inputRef: inputRef, id: id, placeholder: placeholder, value: value ?? "", items: state, icon: "search-filled", disabled: disabled, error: error, ListFooterComponent: ListFooterComponent, onSelectItem: item => {
|
|
11
|
+
onSuggestion(item);
|
|
12
|
+
}, onValueChange: value => {
|
|
13
|
+
lastRequest.current?.cancel(); // cancel previous request to avoid race condition
|
|
14
|
+
lastRequest.current = undefined; // avoid to cancel twice the same request
|
|
15
|
+
onValueChange(value);
|
|
16
|
+
if (value.length <= 3 || !shouldDisplaySuggestions) {
|
|
17
|
+
return setState(AsyncData.NotAsked());
|
|
18
|
+
}
|
|
19
|
+
setState(AsyncData.Loading());
|
|
20
|
+
const request = loadSuggestions(value);
|
|
21
|
+
lastRequest.current = request;
|
|
22
|
+
if (onLoadError != null) {
|
|
23
|
+
request.tapError(onLoadError);
|
|
24
|
+
}
|
|
25
|
+
request.onResolve(value => setState(AsyncData.Done(value)));
|
|
26
|
+
}, keyExtractor: item => item.id, emptyResultText: emptyResultText, renderItem: item => (_jsxs(_Fragment, { children: [_jsx(LakeText, { numberOfLines: 1, selectable: false, color: colors.gray[900], children: item.title }), _jsx(LakeText, { numberOfLines: 1, selectable: false, variant: "smallRegular", children: item.subtitle })] })) }));
|
|
27
|
+
};
|
package/src/components/Input.js
CHANGED
|
@@ -30,7 +30,7 @@ const styles = StyleSheet.create({
|
|
|
30
30
|
placeholderTextColor: colors.gray[30],
|
|
31
31
|
textOverflow: "ellipsis",
|
|
32
32
|
transitionDuration: "150ms",
|
|
33
|
-
transitionProperty:
|
|
33
|
+
transitionProperty: "border-color, box-shadow",
|
|
34
34
|
whiteSpace: "nowrap",
|
|
35
35
|
wordBreak: "keep-all",
|
|
36
36
|
},
|
|
@@ -20,7 +20,7 @@ const styles = StyleSheet.create({
|
|
|
20
20
|
justifyContent: "center",
|
|
21
21
|
paddingHorizontal: 20,
|
|
22
22
|
transitionDuration: "150ms",
|
|
23
|
-
transitionProperty:
|
|
23
|
+
transitionProperty: "background-color, color",
|
|
24
24
|
},
|
|
25
25
|
grow: {
|
|
26
26
|
flexGrow: 1,
|
|
@@ -76,6 +76,9 @@ const styles = StyleSheet.create({
|
|
|
76
76
|
cursor: "not-allowed",
|
|
77
77
|
opacity: 0.3,
|
|
78
78
|
},
|
|
79
|
+
resetOpacity: {
|
|
80
|
+
opacity: 1,
|
|
81
|
+
},
|
|
79
82
|
loaderContainer: {
|
|
80
83
|
...StyleSheet.absoluteFillObject,
|
|
81
84
|
alignItems: "center",
|
|
@@ -114,6 +117,7 @@ export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLab
|
|
|
114
117
|
hasIconEnd && (isSmall ? styles.withIconEndSmall : styles.withIconEnd),
|
|
115
118
|
hasOnlyIcon && (isSmall ? styles.iconSmallOnly : styles.iconOnly),
|
|
116
119
|
disabled && styles.disabled,
|
|
120
|
+
disabled && forceBackground && styles.resetOpacity,
|
|
117
121
|
grow && styles.grow,
|
|
118
122
|
typeof style == "function" ? style({ hovered, pressed, focused }) : style,
|
|
119
123
|
match(mode)
|
|
@@ -135,7 +139,11 @@ export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLab
|
|
|
135
139
|
? backgroundColor.accented
|
|
136
140
|
: invariantColors.transparent,
|
|
137
141
|
borderWidth: 1,
|
|
138
|
-
borderColor:
|
|
142
|
+
borderColor: disabled && forceBackground
|
|
143
|
+
? colors[color][100]
|
|
144
|
+
: hovered
|
|
145
|
+
? colors[color][600]
|
|
146
|
+
: colors[color][300],
|
|
139
147
|
}))
|
|
140
148
|
.with("tertiary", () => ({
|
|
141
149
|
backgroundColor: pressed
|
|
@@ -147,9 +155,11 @@ export const LakeButton = memo(forwardRef(({ ariaControls, ariaExpanded, ariaLab
|
|
|
147
155
|
.exhaustive(),
|
|
148
156
|
], children: ({ pressed, hovered }) => {
|
|
149
157
|
const textColor = mode === "secondary" || mode === "tertiary"
|
|
150
|
-
?
|
|
151
|
-
? colors[color][
|
|
152
|
-
:
|
|
158
|
+
? disabled && forceBackground
|
|
159
|
+
? colors[color][300]
|
|
160
|
+
: hovered || pressed
|
|
161
|
+
? colors[color][700]
|
|
162
|
+
: colors[color][600]
|
|
153
163
|
: colors[color].contrast;
|
|
154
164
|
return (_jsxs(_Fragment, { children: [hasIconStart && (_jsxs(_Fragment, { children: [_jsx(Icon, { color: textColor, name: icon, size: iconSize }), isNotNullish(children) && _jsx(Space, { width: isSmall ? 8 : 12 })] })), isReactText(children) ? (_jsx(LakeText, { numberOfLines: 1, userSelect: "none", style: [isSmall ? styles.textSmall : styles.text, { color: textColor }], children: children })) : (children), hasIconEnd && (_jsxs(_Fragment, { children: [isNotNullish(children) && _jsx(Space, { width: isSmall ? 8 : 12 }), _jsx(Icon, { color: textColor, name: icon, size: iconSize })] })), loading && (_jsx(View, { role: "none", style: [
|
|
155
165
|
styles.loaderContainer,
|
|
@@ -122,7 +122,7 @@ const LakeComboboxWithRef = ({ inputRef, value, items, ListFooterComponent, onVa
|
|
|
122
122
|
}
|
|
123
123
|
const nextIndex = index + direction;
|
|
124
124
|
event.preventDefault();
|
|
125
|
-
if (nextIndex ===
|
|
125
|
+
if (nextIndex === -1) {
|
|
126
126
|
ref.current?.focus();
|
|
127
127
|
}
|
|
128
128
|
else {
|
|
@@ -112,8 +112,8 @@ const styles = StyleSheet.create({
|
|
|
112
112
|
...StyleSheet.absoluteFillObject,
|
|
113
113
|
},
|
|
114
114
|
closeButton: {
|
|
115
|
-
top: negativeSpacings[
|
|
116
|
-
right: negativeSpacings[
|
|
115
|
+
top: negativeSpacings[16],
|
|
116
|
+
right: negativeSpacings[16],
|
|
117
117
|
},
|
|
118
118
|
});
|
|
119
119
|
export const LakeModal = ({ visible, icon, title, color = "current", children, maxWidth = 570, onPressClose, }) => {
|
|
@@ -22,6 +22,7 @@ export type LakeTextInputProps = Except<TextInputProps, "editable" | "keyboardTy
|
|
|
22
22
|
style?: TextInputProps["style"];
|
|
23
23
|
onChange?: ChangeEventHandler<HTMLInputElement>;
|
|
24
24
|
maxCharCount?: number;
|
|
25
|
+
help?: string;
|
|
25
26
|
};
|
|
26
27
|
export declare const LakeTextInput: import("react").ForwardRefExoticComponent<Except<TextInputProps, "editable" | "keyboardType" | "onChange"> & {
|
|
27
28
|
ariaExpanded?: boolean | undefined;
|
|
@@ -42,4 +43,5 @@ export declare const LakeTextInput: import("react").ForwardRefExoticComponent<Ex
|
|
|
42
43
|
style?: TextInputProps["style"];
|
|
43
44
|
onChange?: ChangeEventHandler<HTMLInputElement> | undefined;
|
|
44
45
|
maxCharCount?: number | undefined;
|
|
46
|
+
help?: string | undefined;
|
|
45
47
|
} & import("react").RefAttributes<TextInput | null>>;
|
|
@@ -124,7 +124,7 @@ const styles = StyleSheet.create({
|
|
|
124
124
|
export const LakeTextInput = forwardRef(({ ariaExpanded, ariaControls, error, disabled = false, validating = false, valid = false, readOnly = false, icon, children, unit, color = "gray", inputMode = "text", hideErrors = false, onChange, pattern, style: stylesFromProps, onFocus: originalOnFocus, onBlur: originalOnBlur, value, defaultValue, multiline = false,
|
|
125
125
|
//maxCharCount is different from maxLength(props inherited of TextInput), maxLength truncates the text in the limitation asked,
|
|
126
126
|
//maxCharCount doesn't have limitation but displays a counter of characters
|
|
127
|
-
maxCharCount, ...props }, forwardRef) => {
|
|
127
|
+
maxCharCount, help, ...props }, forwardRef) => {
|
|
128
128
|
const inputRef = useRef(null);
|
|
129
129
|
const [isHovered, setIsHovered] = useState(false);
|
|
130
130
|
const [isFocused, setIsFocused] = useState(false);
|
|
@@ -159,5 +159,5 @@ maxCharCount, ...props }, forwardRef) => {
|
|
|
159
159
|
isFocused && styles.focused,
|
|
160
160
|
isFocused && { borderColor: colors[color][500] },
|
|
161
161
|
stylesFromProps,
|
|
162
|
-
] }), 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(icon) && (_jsx(Icon, { name: icon, size: 20, color: colors.current.primary, style: styles.icon }))] }), isNotNullish(unit) && (_jsx(LakeText, { color: colors.gray[900], style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], children: unit }))] }), children] }), !hideErrors && (_jsxs(Box, { direction: "row",
|
|
162
|
+
] }), 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(icon) && (_jsx(Icon, { name: icon, size: 20, color: colors.current.primary, style: styles.icon }))] }), isNotNullish(unit) && (_jsx(LakeText, { color: colors.gray[900], style: [styles.unit, (disabled || readOnly) && styles.unitDisabled], children: unit }))] }), children] }), !hideErrors && (_jsxs(Box, { direction: "row", style: styles.errorContainer, children: [isNotNullish(help) ? (_jsx(LakeText, { variant: "smallRegular", color: isNotNullish(error) ? colors.negative[500] : colors.gray[500], children: help })) : (_jsx(LakeText, { variant: "smallRegular", color: colors.negative[500], children: error ?? " " })), 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] })] }))] }))] }));
|
|
163
163
|
});
|
|
@@ -27,7 +27,7 @@ const styles = StyleSheet.create({
|
|
|
27
27
|
cursor: "default",
|
|
28
28
|
overflow: "hidden",
|
|
29
29
|
transitionDuration: "150ms",
|
|
30
|
-
transitionProperty:
|
|
30
|
+
transitionProperty: "border-color, box-shadow",
|
|
31
31
|
},
|
|
32
32
|
errored: {
|
|
33
33
|
borderColor: colors.negative[500],
|
|
@@ -275,6 +275,7 @@ export declare const PressableTextInput: FC<Except<{
|
|
|
275
275
|
"aria-rowspan"?: number | undefined;
|
|
276
276
|
"aria-setsize"?: number | undefined;
|
|
277
277
|
"aria-sort"?: "none" | "ascending" | "descending" | "other" | undefined;
|
|
278
|
+
value?: string | undefined;
|
|
278
279
|
allowFontScaling?: boolean | undefined;
|
|
279
280
|
numberOfLines?: number | undefined;
|
|
280
281
|
onPress?: ((event: import("react-native").GestureResponderEvent) => void) | undefined;
|
|
@@ -286,33 +287,32 @@ export declare const PressableTextInput: FC<Except<{
|
|
|
286
287
|
disabled?: boolean | undefined;
|
|
287
288
|
selectionColor?: import("react-native").ColorValue | undefined;
|
|
288
289
|
textBreakStrategy?: "simple" | "highQuality" | "balanced" | undefined;
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
290
|
+
placeholderTextColor?: import("react-native").ColorValue | undefined;
|
|
291
|
+
readOnly?: boolean | undefined;
|
|
292
|
+
editable?: boolean | undefined;
|
|
293
|
+
keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
|
|
294
|
+
onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
294
295
|
autoCapitalize?: "none" | "sentences" | "words" | "characters" | undefined;
|
|
295
296
|
autoCorrect?: boolean | undefined;
|
|
297
|
+
autoFocus?: boolean | undefined;
|
|
296
298
|
blurOnSubmit?: boolean | undefined;
|
|
297
299
|
caretHidden?: boolean | undefined;
|
|
298
300
|
contextMenuHidden?: boolean | undefined;
|
|
299
301
|
defaultValue?: string | undefined;
|
|
300
|
-
editable?: boolean | undefined;
|
|
301
|
-
keyboardType?: import("react-native").KeyboardTypeOptions | undefined;
|
|
302
302
|
inputMode?: import("react-native").InputModeOptions | undefined;
|
|
303
303
|
maxLength?: number | undefined;
|
|
304
304
|
multiline?: boolean | undefined;
|
|
305
305
|
onBlur?: ((event: NativeSyntheticEvent<React.FocusEvent>) => void) | undefined;
|
|
306
|
-
onChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputChangeEventData>) => void) | undefined;
|
|
307
306
|
onChangeText?: ((text: string) => void) | undefined;
|
|
307
|
+
onContentSizeChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputContentSizeChangeEventData>) => void) | undefined;
|
|
308
308
|
onEndEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputEndEditingEventData>) => void) | undefined;
|
|
309
309
|
onFocus?: ((event: NativeSyntheticEvent<React.FocusEvent>) => void) | undefined;
|
|
310
310
|
onSelectionChange?: ((e: NativeSyntheticEvent<import("react-native").TextInputSelectionChangeEventData>) => void) | undefined;
|
|
311
311
|
onSubmitEditing?: ((e: NativeSyntheticEvent<import("react-native").TextInputSubmitEditingEventData>) => void) | undefined;
|
|
312
312
|
onTextInput?: ((e: NativeSyntheticEvent<import("react-native").TextInputTextInputEventData>) => void) | undefined;
|
|
313
|
+
onScroll?: ((e: NativeSyntheticEvent<import("react-native").TextInputScrollEventData>) => void) | undefined;
|
|
313
314
|
onKeyPress?: ((e: NativeSyntheticEvent<import("react-native").TextInputKeyPressEventData>) => void) | undefined;
|
|
314
315
|
placeholder?: string | undefined;
|
|
315
|
-
placeholderTextColor?: import("react-native").ColorValue | undefined;
|
|
316
316
|
returnKeyType?: import("react-native").ReturnKeyTypeOptions | undefined;
|
|
317
317
|
secureTextEntry?: boolean | undefined;
|
|
318
318
|
selectTextOnFocus?: boolean | undefined;
|
|
@@ -322,10 +322,9 @@ export declare const PressableTextInput: FC<Except<{
|
|
|
322
322
|
} | undefined;
|
|
323
323
|
inputAccessoryViewID?: string | undefined;
|
|
324
324
|
initialValue?: string | undefined;
|
|
325
|
-
autoComplete?: "off" | "name" | "email" | "
|
|
325
|
+
autoComplete?: "off" | "name" | "email" | "tel" | "url" | "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "impp" | "language" | "new-password" | "nickname" | "on" | "one-time-code" | "organization" | "organization-title" | "postal-code" | "sex" | "street-address" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-national" | "transaction-amount" | "transaction-currency" | "username" | undefined;
|
|
326
326
|
enterKeyHint?: "enter" | "search" | "done" | "go" | "next" | "send" | "previous" | undefined;
|
|
327
327
|
rows?: number | undefined;
|
|
328
|
-
readOnly?: boolean | undefined;
|
|
329
328
|
clearButtonMode?: "never" | "while-editing" | "unless-editing" | "always" | undefined;
|
|
330
329
|
clearTextOnFocus?: boolean | undefined;
|
|
331
330
|
dataDetectorTypes?: import("react-native").DataDetectorTypes | import("react-native").DataDetectorTypes[] | undefined;
|
|
@@ -336,6 +335,7 @@ export declare const PressableTextInput: FC<Except<{
|
|
|
336
335
|
selectionState?: import("react-native").DocumentSelectionState | undefined;
|
|
337
336
|
spellCheck?: boolean | undefined;
|
|
338
337
|
textContentType?: "none" | "location" | "name" | "nickname" | "username" | "URL" | "addressCity" | "addressCityAndState" | "addressState" | "countryName" | "creditCardNumber" | "emailAddress" | "familyName" | "fullStreetAddress" | "givenName" | "jobTitle" | "middleName" | "namePrefix" | "nameSuffix" | "organizationName" | "postalCode" | "streetAddressLine1" | "streetAddressLine2" | "sublocality" | "telephoneNumber" | "password" | "newPassword" | "oneTimeCode" | undefined;
|
|
338
|
+
scrollEnabled?: boolean | undefined;
|
|
339
339
|
cursorColor?: import("react-native").ColorValue | null | undefined;
|
|
340
340
|
importantForAutofill?: "auto" | "yes" | "no" | "noExcludeDescendants" | "yesExcludeDescendants" | undefined;
|
|
341
341
|
disableFullscreenUI?: boolean | undefined;
|
|
@@ -24,7 +24,7 @@ const styles = StyleSheet.create({
|
|
|
24
24
|
right: 0,
|
|
25
25
|
transformOrigin: "right top",
|
|
26
26
|
transition: "150ms ease-in-out",
|
|
27
|
-
transitionProperty:
|
|
27
|
+
transitionProperty: "transform, background-color",
|
|
28
28
|
},
|
|
29
29
|
});
|
|
30
30
|
const Context = createContext((_) => { });
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type SortDirection = "Asc" | "Desc";
|
|
3
|
+
export type SortField<T> = {
|
|
4
|
+
name: T;
|
|
5
|
+
ascLabel: string;
|
|
6
|
+
descLabel: string;
|
|
7
|
+
};
|
|
8
|
+
export type SortValue<T extends string> = {
|
|
9
|
+
field: T;
|
|
10
|
+
direction: SortDirection;
|
|
11
|
+
};
|
|
12
|
+
type Props<T extends string> = {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
title: string;
|
|
15
|
+
fields: SortField<T>[];
|
|
16
|
+
value: SortValue<T> | undefined;
|
|
17
|
+
onChange: (value: SortValue<T>) => void;
|
|
18
|
+
onClose: () => void;
|
|
19
|
+
};
|
|
20
|
+
export declare const SortBottomPanel: <T extends string>({ visible, title, value, fields, onChange, onClose, }: Props<T>) => JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import { StyleSheet, View } from "react-native";
|
|
4
|
+
import { commonStyles } from "../constants/commonStyles";
|
|
5
|
+
import { colors, spacings } from "../constants/design";
|
|
6
|
+
import { BottomPanel } from "./BottomPanel";
|
|
7
|
+
import { Icon } from "./Icon";
|
|
8
|
+
import { LakeHeading } from "./LakeHeading";
|
|
9
|
+
import { LakeRadio } from "./LakeRadio";
|
|
10
|
+
import { LakeText } from "./LakeText";
|
|
11
|
+
import { Pressable } from "./Pressable";
|
|
12
|
+
import { Separator } from "./Separator";
|
|
13
|
+
import { Space } from "./Space";
|
|
14
|
+
const styles = StyleSheet.create({
|
|
15
|
+
head: {
|
|
16
|
+
padding: 24,
|
|
17
|
+
paddingBottom: 12,
|
|
18
|
+
},
|
|
19
|
+
option: {
|
|
20
|
+
display: "flex",
|
|
21
|
+
flexDirection: "row",
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
paddingHorizontal: spacings[24],
|
|
24
|
+
paddingVertical: spacings[12],
|
|
25
|
+
},
|
|
26
|
+
arrowDown: {
|
|
27
|
+
transform: "rotate(180deg)",
|
|
28
|
+
},
|
|
29
|
+
text: {
|
|
30
|
+
...commonStyles.fill,
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
export const SortBottomPanel = ({ visible, title, value, fields, onChange, onClose, }) => {
|
|
34
|
+
return (_jsxs(BottomPanel, { visible: visible, onPressClose: onClose, children: [_jsx(View, { style: styles.head, children: _jsx(LakeHeading, { level: 3, variant: "h3", children: title }) }), fields.map((field, index) => (_jsxs(Fragment, { children: [_jsxs(Pressable, { style: styles.option, onPress: () => {
|
|
35
|
+
onChange({ field: field.name, direction: "Asc" });
|
|
36
|
+
onClose();
|
|
37
|
+
}, children: [_jsx(Icon, { name: "arrow-up-filled", size: 12, color: colors.gray[600], style: styles.arrowDown }), _jsx(Space, { width: 12 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[600], style: styles.text, children: field.ascLabel }), _jsx(Space, { width: 16 }), _jsx(LakeRadio, { value: value?.field === field.name && value.direction === "Asc" })] }), _jsxs(Pressable, { style: styles.option, onPress: () => {
|
|
38
|
+
onChange({ field: field.name, direction: "Desc" });
|
|
39
|
+
onClose();
|
|
40
|
+
}, children: [_jsx(Icon, { name: "arrow-up-filled", size: 12, color: colors.gray[600] }), _jsx(Space, { width: 12 }), _jsx(LakeText, { variant: "smallRegular", color: colors.gray[600], style: styles.text, children: field.descLabel }), _jsx(Space, { width: 16 }), _jsx(LakeRadio, { value: value?.field === field.name && value.direction === "Desc" })] }), index < fields.length - 1 && _jsx(Separator, {})] }, field.name))), _jsx(Space, { height: 12 })] }));
|
|
41
|
+
};
|
|
@@ -7,6 +7,6 @@ export declare const Stack: import("react").ForwardRefExoticComponent<import("re
|
|
|
7
7
|
justifyContent?: ("end" | "start" | "normal" | "center" | "spaceBetween" | "spaceAround" | "spaceEvenly") | undefined;
|
|
8
8
|
style?: import("react-native").StyleProp<import("react-native").ViewStyle>;
|
|
9
9
|
} & {
|
|
10
|
-
space?: 4 | 8 | 12 | 16 | 20 |
|
|
10
|
+
space?: 4 | 8 | 12 | 16 | 20 | 32 | 24 | 40 | 48 | 72 | 96 | undefined;
|
|
11
11
|
wrap?: boolean | undefined;
|
|
12
12
|
} & import("react").RefAttributes<View>>;
|