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 2 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
2 changes: 1 addition & 1 deletion generatedTypes/commons/new.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ export { default as asBaseComponent, BaseComponentInjectedProps } from './asBase
export { default as forwardRef, ForwardRefInjectedProps } from './forwardRef';
export { default as withScrollEnabler, WithScrollEnablerProps } from './withScrollEnabler';
export { default as withScrollReached, WithScrollReachedProps } from './withScrollReached';
export { ContainerModifiers, MarginModifiers, PaddingModifiers, TypographyModifiers, ColorsModifiers, BackgroundColorModifier } from './modifiers';
export { ContainerModifiers, MarginModifiers, PaddingModifiers, TypographyModifiers, ColorsModifiers, BackgroundColorModifier, extractAccessibilityProps, extractComponentProps } from './modifiers';
6 changes: 6 additions & 0 deletions src/commons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,11 @@ module.exports = {
},
get withScrollReached() {
return require('./withScrollReached').default;
},
get extractAccessibilityProps() {
return require('./modifiers').extractAccessibilityProps;
},
get extractComponentProps() {
return require('./modifiers').extractComponentProps;
}
};
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
4 changes: 3 additions & 1 deletion src/commons/new.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ export {
PaddingModifiers,
TypographyModifiers,
ColorsModifiers,
BackgroundColorModifier
BackgroundColorModifier,
extractAccessibilityProps,
extractComponentProps
} from './modifiers';
6 changes: 6 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,12 @@ export default {
get withScrollReached() {
return require('./commons').withScrollReached;
},
get extractAccessibilityProps() {
return require('./commons').extractAccessibilityProps;
},
get extractComponentProps() {
return require('./commons').extractComponentProps;
},

// Helpers
get AvatarHelper() {
Expand Down
4 changes: 3 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ export {
PaddingModifiers,
TypographyModifiers,
ColorsModifiers,
BackgroundColorModifier
BackgroundColorModifier,
extractAccessibilityProps,
extractComponentProps
} from './commons/new';
export * as Incubator from './incubator';
export * as Hooks from './hooks';
Expand Down