Skip to content

Modifiers - expose extractAccessibilityProps & extractComponentProps #1043

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 3 commits into from
Dec 6, 2020
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
2 changes: 1 addition & 1 deletion generatedTypes/commons/modifiers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export declare function extractModifierProps(props: Dictionary<any>): _.Dictiona
* @deprecated switch to Modifiers#extractComponentProps
*/
export declare function extractOwnProps(props: Dictionary<any>, ignoreProps: string[]): Pick<Partial<Dictionary<any>>, number>;
export declare function extractComponentProps(component: any, props: Dictionary<any>, ignoreProps: string[]): Pick<Partial<Dictionary<any>>, number>;
export declare function extractComponentProps(component: any, props: Dictionary<any>, ignoreProps?: string[]): Pick<Partial<Dictionary<any>>, number>;
export declare function getThemeProps(props?: any, context?: any): any;
export declare function generateModifiersStyle(options: {
color: boolean;
Expand Down
1 change: 1 addition & 0 deletions generatedTypes/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export * from './style';
export * from './services';
export * as Incubator from './incubator';
export * as Hooks from './hooks';
export * as Modifiers from './commons/modifiers';
export {
asBaseComponent,
withScrollEnabler,
Expand Down
3 changes: 3 additions & 0 deletions src/commons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ module.exports = {
},
get withScrollReached() {
return require('./withScrollReached').default;
},
get modifiers() {
return require('./modifiers');
}
};
2 changes: 1 addition & 1 deletion src/commons/modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export function extractOwnProps(props: Dictionary<any>, ignoreProps: string[]) {
return ownProps;
}

export function extractComponentProps(component: any, props: Dictionary<any>, ignoreProps: string[]) {
export function extractComponentProps(component: any, props: Dictionary<any>, ignoreProps: string[] = []) {
const componentPropTypes = component.propTypes;
const componentProps = _.chain(props)
.pickBy((_value, key) => _.includes(Object.keys(componentPropTypes), key))
Expand Down
3 changes: 3 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ export default {
get withScrollReached() {
return require('./commons').withScrollReached;
},
get Modifiers() {
return require('./commons').modifiers;
},

// Helpers
get AvatarHelper() {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export {
} from './commons/new';
export * as Incubator from './incubator';
export * as Hooks from './hooks';
export * as Modifiers from './commons/modifiers';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is incorrect.
This will export all Modifiers functions separately, while we want to export it as a whole class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can see the usage in the private lib's PR, it is as follows:

import {Modifiers} from 'react-native-ui-lib';
{...Modifiers.extractAccessibilityProps(this.props)}

Is that not what you meant?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.. it's actually correct.
Not sure why it look weird before :/
merging..

export {default as ActionBar, ActionBarProps} from './components/actionBar';
export {default as Avatar, AvatarPropTypes, AvatarProps} from './components/avatar';
export {default as Badge, BadgeProps} from './components/badge';
Expand Down