Skip to content

Commit

Permalink
fixes declaration file
Browse files Browse the repository at this point in the history
  • Loading branch information
atmulyana committed Jun 9, 2023
1 parent 24a1f00 commit 7672ce1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 30 deletions.
49 changes: 27 additions & 22 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,45 @@
* https://github.com/atmulyana/rn-style-props
* @format
*/
//import type {ImageStyle, TextStyle, ViewStyle} from 'react-native/Libraries/StyleSheet/StyleSheetTypes';
type Arr = ReadonlyArray<string>;
type Obj = Readonly<{[prop: string]: any}>;
type StyleProps = null
| undefined
| Obj
| false
| ''
| ReadonlyArray<StyleProps>;
| undefined
| Obj
| false
| ''
| ReadonlyArray<StyleProps>;

declare export const layoutStyleProps: Arr;
declare export const transformStyleProps: Arr;
declare export const shadowStyleProps: Arr;
declare export const viewStyleProps: Arr;
declare export const textStyleProps: Arr;
declare export const imageStyleProps: Arr;
export const layoutStyleProps: Arr;
export const transformStyleProps: Arr;
export const shadowStyleProps: Arr;
export const viewStyleProps: Arr;
export const textStyleProps: Arr;
export const imageStyleProps: Arr;

declare export function isLayoutStyleProp(propName: string): boolean;
declare export function isTransformStyleProp(propName: string): boolean;
declare export function isShadowStyleProp(propName: string): boolean;
declare export function isViewStyleProp(propName: string): boolean;
declare export function isTextStyleProp(propName: string): boolean;
declare export function isImageStyleProp(propName: string): boolean;
export function isLayoutStyleProp(propName: string): boolean;
export function isTransformStyleProp(propName: string): boolean;
export function isShadowStyleProp(propName: string): boolean;
export function isViewStyleProp(propName: string): boolean;
export function isTextStyleProp(propName: string): boolean;
export function isImageStyleProp(propName: string): boolean;

declare export function isViewStyleValidProp(propName: string): boolean;
declare export function isTextStyleValidProp(propName: string): boolean;
declare export function isImageStyleValidProp(propName: string): boolean;
export function isViewStyleValidProp(propName: string): boolean;
export function isTextStyleValidProp(propName: string): boolean;
export function isImageStyleValidProp(propName: string): boolean;

declare export function extractTextStyle(style: StyleProps, paddingForText?: boolean, attrName?: string): {
export function extractTextStyle(style: StyleProps, paddingForText?: boolean, attrName?: string): {
// view: Readonly<ViewStyle>,
// text: Readonly<TextStyle>,
view: Obj,
text: Obj,
unknown: Obj,
};

declare export function extractImageStyle(style: StyleProps, attrName?: string): {
export function extractImageStyle(style: StyleProps, attrName?: string): {
// view: Readonly<ViewStyle>,
// image: Readonly<ImageStyle>,
view: Obj,
image: Obj,
unknown: Obj,
Expand Down
19 changes: 12 additions & 7 deletions index.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@
* @format
* @flow strict
*/
//import type {ImageStyle, TextStyle, ViewStyle} from 'react-native/Libraries/StyleSheet/StyleSheet';
//type Prop<T> = $ReadOnly<Partial<T>>;
type Arr = $ReadOnlyArray<string>;
type Obj = $ReadOnly<{...}>;
type StyleProps =
| null
| void
| Obj
| false
| ''
| $ReadOnlyArray<StyleProps>;

| null
| void
| Obj
| false
| ''
| $ReadOnlyArray<StyleProps>;

declare export const layoutStyleProps: Arr;
declare export const transformStyleProps: Arr;
Expand All @@ -33,12 +34,16 @@ declare export function isTextStyleValidProp(propName: string): boolean;
declare export function isImageStyleValidProp(propName: string): boolean;

declare export function extractTextStyle(style: StyleProps, paddingForText?: boolean, attrName?: string): {
// view: Prop<ViewStyle>,
// text: Prop<TextStyle>,
view: Obj,
text: Obj,
unknown: Obj,
};

declare export function extractImageStyle(style: StyleProps, attrName?: string): {
// view: Prop<ViewStyle>,
// image: Prop<ImageStyle>,
view: Obj,
image: Obj,
unknown: Obj,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rn-style-props",
"version": "0.1.2",
"version": "0.1.3",
"description": "to get react-native style prop types",
"author": "AT Mulyana <atmulyana@yahoo.com>",
"license": "MIT",
Expand Down

0 comments on commit 7672ce1

Please sign in to comment.