Skip to content

Commit 547f6c3

Browse files
committed
scout: cleanup a few things
1 parent ea9d3fe commit 547f6c3

File tree

4 files changed

+32
-35
lines changed

4 files changed

+32
-35
lines changed

packages/lake/src/components/FilterChooser.tsx

+15-18
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { Pressable, StyleSheet, View } from "react-native";
33
import { colors } from "../constants/design";
44
import { useDisclosure } from "../hooks/useDisclosure";
55
import { isNotNullishOrEmpty } from "../utils/nullish";
6-
import { Box } from "./Box";
76
import { FlatList } from "./FlatList";
87
import { Icon } from "./Icon";
98
import { LakeButton } from "./LakeButton";
@@ -37,7 +36,7 @@ const styles = StyleSheet.create({
3736
},
3837
});
3938

40-
export function FilterChooser<FilterName extends string>({
39+
export const FilterChooser = <FilterName extends string>({
4140
filters,
4241
openFilters,
4342
label,
@@ -53,26 +52,24 @@ export function FilterChooser<FilterName extends string>({
5352
availableFilters: { label: string; name: FilterName }[];
5453
large?: boolean;
5554
onAddFilter: (filterName: FilterName) => void;
56-
}) {
55+
}) => {
5756
const inputRef = useRef<View>(null);
5857
const [visible, { close, toggle }] = useDisclosure(false);
5958

6059
return (
6160
<>
62-
<Box direction="row" justifyContent="start" alignItems="center">
63-
<LakeButton
64-
size="small"
65-
mode="secondary"
66-
color="gray"
67-
onPress={toggle}
68-
ref={inputRef}
69-
icon={large ? "chevron-down-filled" : "filter-filled"}
70-
iconPosition="end"
71-
ariaLabel={label}
72-
>
73-
{large ? label : null}
74-
</LakeButton>
75-
</Box>
61+
<LakeButton
62+
size="small"
63+
mode="secondary"
64+
color="gray"
65+
onPress={toggle}
66+
ref={inputRef}
67+
icon={large ? "chevron-down-filled" : "filter-filled"}
68+
iconPosition="end"
69+
ariaLabel={label}
70+
>
71+
{large ? label : null}
72+
</LakeButton>
7673

7774
<Popover
7875
role="listbox"
@@ -119,4 +116,4 @@ export function FilterChooser<FilterName extends string>({
119116
</Popover>
120117
</>
121118
);
122-
}
119+
};

packages/lake/src/components/WithCurrentColor.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { createContext, MutableRefObject, ReactElement, useLayoutEffect, useRef } from "react";
1+
import { createContext, MutableRefObject, ReactNode, useLayoutEffect, useRef } from "react";
22
import { StyleSheet, View, ViewProps } from "react-native";
33
import { colors, ColorVariants } from "../constants/design";
44
import { isNotNullish } from "../utils/nullish";
55

66
type Props = {
77
variant?: ColorVariants;
88
style?: ViewProps["style"];
9-
children: ReactElement;
9+
children: ReactNode;
1010
};
1111

1212
const styles = StyleSheet.create({

packages/shared-business/src/components/Filters.tsx

+14-15
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,15 @@ type FilterRadioProps<T> = {
133133
onValueChange: (value: T | undefined) => void;
134134
};
135135

136-
function FilterRadio<T>({
136+
const FilterRadio = <T,>({
137137
label,
138138
items,
139139
width,
140140
value,
141141
onValueChange,
142142
onPressRemove,
143143
autoOpen = false,
144-
}: FilterRadioProps<T>) {
144+
}: FilterRadioProps<T>) => {
145145
const inputRef = useRef<View>(null);
146146
const [visible, { close, toggle }] = useDisclosure(autoOpen);
147147
const currentValue = useMemo(() => items.find(i => i.value === value), [items, value]);
@@ -194,7 +194,7 @@ function FilterRadio<T>({
194194
</Popover>
195195
</View>
196196
);
197-
}
197+
};
198198

199199
type FilterCheckboxProps<T> = {
200200
label: string;
@@ -212,7 +212,7 @@ type CheckAllItem = {
212212
checked: boolean | "mixed";
213213
};
214214

215-
function FilterCheckbox<T>({
215+
const FilterCheckbox = <T,>({
216216
label,
217217
items,
218218
width,
@@ -221,7 +221,7 @@ function FilterCheckbox<T>({
221221
onValueChange,
222222
onPressRemove,
223223
autoOpen = false,
224-
}: FilterCheckboxProps<T>) {
224+
}: FilterCheckboxProps<T>) => {
225225
const inputRef = useRef<View>(null);
226226
const [visible, { close, toggle }] = useDisclosure(autoOpen);
227227

@@ -323,7 +323,7 @@ function FilterCheckbox<T>({
323323
</Popover>
324324
</View>
325325
);
326-
}
326+
};
327327

328328
type FilterDateProps = {
329329
label: string;
@@ -339,7 +339,7 @@ type FilterDateProps = {
339339
autoOpen?: boolean;
340340
};
341341

342-
function FilterDate({
342+
const FilterDate = ({
343343
label,
344344
initialValue,
345345
noValueText,
@@ -351,7 +351,7 @@ function FilterDate({
351351
onValueChange,
352352
onPressRemove,
353353
autoOpen = false,
354-
}: FilterDateProps) {
354+
}: FilterDateProps) => {
355355
const inputRef = useRef<View>(null);
356356
const [visible, { close, toggle }] = useDisclosure(autoOpen);
357357

@@ -389,7 +389,7 @@ function FilterDate({
389389
/>
390390
</View>
391391
);
392-
}
392+
};
393393

394394
type FilterInputProps = {
395395
label: string;
@@ -402,7 +402,7 @@ type FilterInputProps = {
402402
autoOpen?: boolean;
403403
};
404404

405-
function FilterInput({
405+
const FilterInput = ({
406406
label,
407407
initialValue = "",
408408
noValueText,
@@ -411,7 +411,7 @@ function FilterInput({
411411
validate,
412412
onValueChange,
413413
onPressRemove,
414-
}: FilterInputProps) {
414+
}: FilterInputProps) => {
415415
const [visible, { close, toggle }] = useDisclosure(autoOpen);
416416
const tagRef = useRef<View>(null);
417417

@@ -480,7 +480,7 @@ function FilterInput({
480480
</Popover>
481481
</View>
482482
);
483-
}
483+
};
484484

485485
export type FilterCheckboxDef<T> = {
486486
type: "checkbox";
@@ -522,9 +522,7 @@ type ExtractFilterValue<T extends Filter<unknown>> = T extends { type: "checkbox
522522
? T["items"][number]["value"][] | undefined
523523
: T extends { type: "radio" }
524524
? T["items"][number]["value"] | undefined
525-
: T extends { type: "boolean" }
526-
? boolean | undefined
527-
: string | undefined;
525+
: string | undefined;
528526

529527
const getFilterValue = <T extends Filter<unknown>["type"]>(
530528
_type: T,
@@ -557,6 +555,7 @@ export const FiltersStack = <T extends FiltersDefinition>({
557555
onChangeFilters,
558556
}: FiltersStackProps<T>) => {
559557
const previousOpened = usePreviousValue(openedFilters);
558+
560559
const lastOpenedFilter =
561560
openedFilters.length > previousOpened.length
562561
? openedFilters[openedFilters.length - 1]

types/react-native/index.d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,7 @@ declare module "react-native" {
447447
backgroundSize?: string;
448448
boxShadow?: string;
449449
display?: DisplayValue;
450+
listStyleType?: string;
450451
maskImage?: string;
451452
position?: PositionValue;
452453
scrollBehavior?: "auto" | "smooth";

0 commit comments

Comments
 (0)