Skip to content

ThemeComponent - clean leftovers #2719

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/commons/asBaseComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as Modifiers from './modifiers';
import {Scheme, SchemeChangeListener, ThemeManager} from '../style';
import forwardRef from './forwardRef';
import UIComponent from './UIComponent';
import type {ThemeComponent} from '../typings/common';

export interface BaseComponentInjectedProps {
/**
Expand All @@ -23,7 +22,7 @@ const EMPTY_MODIFIERS = {};
const colorScheme = Scheme.getSchemeType();

function asBaseComponent<PROPS, STATICS = {}>(WrappedComponent: React.ComponentType<any>,
options: AsBaseComponentOptions = {}): React.ComponentClass<PROPS & ThemeComponent> & STATICS {
options: AsBaseComponentOptions = {}): React.ComponentClass<PROPS> & STATICS {
class BaseComponent extends UIComponent {
static displayName: string | undefined;
static propTypes: any;
Expand Down
276 changes: 137 additions & 139 deletions src/components/picker/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {ModalTopBarProps} from '../modal/TopBar';
// TODO: Replace with new TextField Props after migration to new TextField has completed
// import {TextFieldProps} from '../../../typings/components/Inputs';
import {TextFieldMethods, TextFieldProps as NewTextFieldProps} from '../../incubator/TextField';
import type {ThemeComponent} from '../../typings/common';

// Note: enum values are uppercase due to legacy
export enum PickerModes {
Expand Down Expand Up @@ -48,144 +47,143 @@ export interface PickerSearchStyle {
selectionColor?: string;
}

export type PickerBaseProps = Omit<NewTextFieldProps, 'value' | 'onChange'> &
ThemeComponent & {
/* ...TextField.propTypes, */
/**
* Temporary prop required for migration to Picker's new API
*/
migrate?: boolean;
/**
* Temporary prop required for inner text field migration
*/
migrateTextField?: boolean;
/**
* Pass for different field type UI (form, filter or settings)
*/
fieldType?: PickerFieldTypes;
/**
* Picker current value in the shape of {value: ..., label: ...}, for custom shape use 'getItemValue' prop
*/
value?: PickerValue;
/**
* Callback for when picker value change
*/
onChange?: (value: PickerValue) => void;
/**
* SINGLE mode or MULTI mode
*/
mode?: PickerModes;
/**
* Limit the number of selected items
*/
selectionLimit?: number;
/**
* Adds blur effect to picker modal (iOS only)
*/
enableModalBlur?: boolean;
/**
* Render custom picker - input will be value (see above)
* Example:
* renderPicker = (selectedItem) => {...}
*/
renderPicker?: RenderPicker;
/**
* Render custom picker item
*/
renderItem?: (
value: PickerValue,
itemProps: PickerItemProps & {isSelected: boolean; isItemDisabled: boolean},
label?: string
) => React.ReactElement;
/**
* Render custom picker modal (e.g ({visible, children, toggleModal}) => {...})
*/
renderCustomModal?: (modalProps: RenderCustomModalProps) => React.ReactElement;
/**
* Custom picker props (when using renderPicker, will apply on the button wrapper)
*/
customPickerProps?: ExpandableOverlayProps;
/**
* Add onPress callback for when pressing the picker
*/
onPress?: () => void;
/**
* @deprecated
* A function that extract the unique value out of the value prop in case value has a custom structure (e.g. {myValue, myLabel})
*/
getItemValue?: (value: PickerValue) => any;
/**
* @deprecated
* A function that extract the label out of the value prop in case value has a custom structure (e.g. {myValue, myLabel})
*/
getItemLabel?: (value: PickerValue) => string;
/**
* A function that returns the label to show for the selected Picker value
*/
getLabel?: (value: PickerValue) => string;
/**
* The picker modal top bar props
*/
topBarProps?: ModalTopBarProps;
/**
* Show search input to filter picker items by label
*/
showSearch?: boolean;
/**
* Style object for the search input (only when passing showSearch)
*/
searchStyle?: PickerSearchStyle;
/**
* Placeholder text for the search input (only when passing showSearch)
*/
searchPlaceholder?: string;
/**
* callback for picker modal search input text change (only when passing showSearch)
*/
onSearchChange?: (searchValue: string) => void;
/**
* Render custom search input (only when passing showSearch)
*/
renderCustomSearch?: (props: PickerItemsListProps) => React.ReactElement;
// /**
// * @deprecated pass useWheelPicker prop instead
// * Allow to use the native picker solution (different style for iOS and Android)
// */
// useNativePicker?: boolean;
/**
* Use wheel picker instead of a list picker
*/
useWheelPicker?: boolean;
/**
* Pass props to the list component that wraps the picker options (allows to control FlatList behavior)
*/
listProps?: Partial<FlatListProps<any>>;
/**
* Pass props to the picker modal
*/
pickerModalProps?: object;
/**
* Custom container style
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Callback for modal onShow event
*/
onShow?: () => void;
/**
* Add safe area in the Picker modal view
*/
useSafeArea?: boolean;
/**
* Data source for Picker
*/
items?: Pick<PickerItemProps, 'label' | 'value' | 'disabled'>[];
/**
* Component test id
*/
testID?: string;
children?: ReactNode | undefined;
};
export type PickerBaseProps = Omit<NewTextFieldProps, 'value' | 'onChange'> & {
/* ...TextField.propTypes, */
/**
* Temporary prop required for migration to Picker's new API
*/
migrate?: boolean;
/**
* Temporary prop required for inner text field migration
*/
migrateTextField?: boolean;
/**
* Pass for different field type UI (form, filter or settings)
*/
fieldType?: PickerFieldTypes;
/**
* Picker current value in the shape of {value: ..., label: ...}, for custom shape use 'getItemValue' prop
*/
value?: PickerValue;
/**
* Callback for when picker value change
*/
onChange?: (value: PickerValue) => void;
/**
* SINGLE mode or MULTI mode
*/
mode?: PickerModes;
/**
* Limit the number of selected items
*/
selectionLimit?: number;
/**
* Adds blur effect to picker modal (iOS only)
*/
enableModalBlur?: boolean;
/**
* Render custom picker - input will be value (see above)
* Example:
* renderPicker = (selectedItem) => {...}
*/
renderPicker?: RenderPicker;
/**
* Render custom picker item
*/
renderItem?: (
value: PickerValue,
itemProps: PickerItemProps & {isSelected: boolean; isItemDisabled: boolean},
label?: string
) => React.ReactElement;
/**
* Render custom picker modal (e.g ({visible, children, toggleModal}) => {...})
*/
renderCustomModal?: (modalProps: RenderCustomModalProps) => React.ReactElement;
/**
* Custom picker props (when using renderPicker, will apply on the button wrapper)
*/
customPickerProps?: ExpandableOverlayProps;
/**
* Add onPress callback for when pressing the picker
*/
onPress?: () => void;
/**
* @deprecated
* A function that extract the unique value out of the value prop in case value has a custom structure (e.g. {myValue, myLabel})
*/
getItemValue?: (value: PickerValue) => any;
/**
* @deprecated
* A function that extract the label out of the value prop in case value has a custom structure (e.g. {myValue, myLabel})
*/
getItemLabel?: (value: PickerValue) => string;
/**
* A function that returns the label to show for the selected Picker value
*/
getLabel?: (value: PickerValue) => string;
/**
* The picker modal top bar props
*/
topBarProps?: ModalTopBarProps;
/**
* Show search input to filter picker items by label
*/
showSearch?: boolean;
/**
* Style object for the search input (only when passing showSearch)
*/
searchStyle?: PickerSearchStyle;
/**
* Placeholder text for the search input (only when passing showSearch)
*/
searchPlaceholder?: string;
/**
* callback for picker modal search input text change (only when passing showSearch)
*/
onSearchChange?: (searchValue: string) => void;
/**
* Render custom search input (only when passing showSearch)
*/
renderCustomSearch?: (props: PickerItemsListProps) => React.ReactElement;
// /**
// * @deprecated pass useWheelPicker prop instead
// * Allow to use the native picker solution (different style for iOS and Android)
// */
// useNativePicker?: boolean;
/**
* Use wheel picker instead of a list picker
*/
useWheelPicker?: boolean;
/**
* Pass props to the list component that wraps the picker options (allows to control FlatList behavior)
*/
listProps?: Partial<FlatListProps<any>>;
/**
* Pass props to the picker modal
*/
pickerModalProps?: object;
/**
* Custom container style
*/
containerStyle?: StyleProp<ViewStyle>;
/**
* Callback for modal onShow event
*/
onShow?: () => void;
/**
* Add safe area in the Picker modal view
*/
useSafeArea?: boolean;
/**
* Data source for Picker
*/
items?: Pick<PickerItemProps, 'label' | 'value' | 'disabled'>[];
/**
* Component test id
*/
testID?: string;
children?: ReactNode | undefined;
};

export type PickerPropsWithSingle = PickerBaseProps & {
mode?: PickerModes.SINGLE;
Expand Down
3 changes: 1 addition & 2 deletions src/components/tabController/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import TabBarItem, {TabControllerItemProps} from './TabBarItem';
import TabPage from './TabPage';
import PageCarousel from './PageCarousel';
import useImperativeTabControllerHandle, {TabControllerImperativeMethods} from './useImperativeTabControllerHandle';
import type {ThemeComponent} from '../../typings/common';

export {TabControllerItemProps, TabControllerImperativeMethods};

Expand All @@ -21,7 +20,7 @@ interface TabControllerStatics {
PageCarousel: typeof PageCarousel;
}

export interface TabControllerProps extends ThemeComponent {
export interface TabControllerProps {
/**
* The list of tab bar items
*/
Expand Down
8 changes: 1 addition & 7 deletions src/components/view/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,14 @@ import React, {useEffect, useMemo, useState} from 'react';
import {View as RNView, SafeAreaView, Animated, ViewProps as RNViewProps, StyleProp, ViewStyle} from 'react-native';
import type {AnimateProps as RNReanimatedProps} from 'react-native-reanimated';
import {Constants, ContainerModifiers} from '../../commons/new';
import type {ThemeComponent} from '../../typings/common';
import type {RecorderProps} from '../../typings/recorderTypes';

/**
* Extra props when using reanimated (only non experimental props)
*/
type ReanimatedProps = Pick<RNReanimatedProps<object>, 'entering' | 'exiting' | 'layout'>;

export interface ViewProps
extends Omit<RNViewProps, 'style'>,
ReanimatedProps,
ThemeComponent,
ContainerModifiers,
RecorderProps {
export interface ViewProps extends Omit<RNViewProps, 'style'>, ReanimatedProps, ContainerModifiers, RecorderProps {
/**
* If true, will render as SafeAreaView
*/
Expand Down
4 changes: 0 additions & 4 deletions src/typings/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,3 @@ export type ExtendTypeWith<T extends Constructor<any>, OtherObject extends objec
ConstructorParameters<T>
>;
export type Dictionary<TYPE> = {[key: string]: TYPE};

export interface ThemeComponent {
useCustomTheme?: boolean;
}