Skip to content

Commit 2acec53

Browse files
author
27
committed
fix: 修改proptype 失效
1 parent 5d171e5 commit 2acec53

3 files changed

Lines changed: 344 additions & 156 deletions

File tree

demo/packages/withAcss/index.js

Lines changed: 108 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,116 @@ import PropTypes from 'prop-types';
33
import {
44
StyleSheet, View, Text, Image, ImageBackground,
55
} from 'react-native';
6-
import styleMap from "./styleMap"
6+
import styleMap from './styleMap';
77

8-
/**
9-
*
10-
* @type {{pr: ((function(): null)|shim), pt: ((function(): null)|shim), pv: ((function(): null)|shim), b0: shim, brc: ((function(): null)|shim), fw800: shim, fw400: shim, ac: ((function(): null)|shim), bbc: ((function(): null)|shim), brw: ((function(): null)|shim), ai: ((function(): null)|shim), zi: ((function(): null)|shim), as: ((function(): null)|shim), bbw: ((function(): null)|shim), aic: shim, aib: shim, btrr: ((function(): null)|shim), t0: shim, fsi: shim, fsn: shim, bc: ((function(): null)|shim), acfs: shim, l0: shim, ais: shim, jcc: shim, acfe: shim, br: ((function(): null)|shim), btc: ((function(): null)|shim), fw500: shim, bs: ((function(): null)|shim), fdrr: shim, asfs: shim, fw100: shim, bw: ((function(): null)|shim), blc: ((function(): null)|shim), asfe: shim, fw900: shim, b: ((function(): null)|shim), c: ((function(): null)|shim), btw: ((function(): null)|shim), fdc: shim, f: ((function(): null)|shim), h: ((function(): null)|shim), blw: ((function(): null)|shim), l: ((function(): null)|shim), m: ((function(): null)|shim), asa: shim, o: ((function(): null)|shim), asc: shim, p: ((function(): null)|shim), asb: shim, r: ((function(): null)|shim), t: ((function(): null)|shim), fdr: shim, btlr: ((function(): null)|shim), jcsa: shim, w: ((function(): null)|shim), jcsb: shim, jcse: shim, lh: ((function(): null)|shim), acc: shim, ass: shim, fdcr: shim, jcfe: shim, dn: shim, f1: shim, acs: shim, fw600: shim, fw200: shim, mb: ((function(): null)|shim), taa: shim, tac: shim, mh: ((function(): null)|shim), taj: shim, tal: shim, ml: ((function(): null)|shim), tar: shim, mr: ((function(): null)|shim), mt: ((function(): null)|shim), mv: ((function(): null)|shim), bbrr: ((function(): null)|shim), fwb: shim, fwn: shim, ff: shim, aife: shim, fs: ((function(): null)|shim), fw700: shim, fw300: shim, aifs: shim, oh: shim, acsb: shim, acsa: shim, ttc: shim, bblr: ((function(): null)|shim), ttl: shim, ttn: shim, pa: shim, pb: ((function(): null)|shim), ttu: shim, jcfs: shim, ph: ((function(): null)|shim), pl: ((function(): null)|shim), r0: shim}}
11-
*/
128
/* eslint-disable */
13-
const acssPropTypes = {};
14-
for(let i in styleMap){
15-
if(styleMap[i] instanceof Array){
16-
acssPropTypes[i]=PropTypes.bool
17-
}else{
18-
acssPropTypes[i]=PropTypes.oneOfType([PropTypes.number, PropTypes.string])
19-
}
20-
}
9+
const acssPropTypes = {
10+
ac: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
11+
acs: PropTypes.bool,
12+
acc: PropTypes.bool,
13+
acfs: PropTypes.bool,
14+
acfe: PropTypes.bool,
15+
acsb: PropTypes.bool,
16+
acsa: PropTypes.bool,
17+
ai: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
18+
ais: PropTypes.bool,
19+
aib: PropTypes.bool,
20+
aic: PropTypes.bool,
21+
aifs: PropTypes.bool,
22+
aife: PropTypes.bool,
23+
as: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
24+
asa: PropTypes.bool,
25+
ass: PropTypes.bool,
26+
asb: PropTypes.bool,
27+
asc: PropTypes.bool,
28+
asfs: PropTypes.bool,
29+
asfe: PropTypes.bool,
30+
bc: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
31+
br: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
32+
bw: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
33+
bs: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
34+
btw: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
35+
btc: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
36+
brw: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
37+
brc: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
38+
bbw: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
39+
bbc: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
40+
blw: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
41+
blc: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
42+
btrr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
43+
btlr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
44+
bbrr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
45+
bblr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
46+
b: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
47+
b0: PropTypes.bool,
48+
c: PropTypes.oneOfType([PropTypes.string]),
49+
dn: PropTypes.bool,
50+
f: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
51+
f1: PropTypes.bool,
52+
fdr: PropTypes.bool,
53+
fdrr: PropTypes.bool,
54+
fdc: PropTypes.bool,
55+
fdcr: PropTypes.bool,
56+
fwn: PropTypes.bool,
57+
fwb: PropTypes.bool,
58+
fw100: PropTypes.bool,
59+
fw200: PropTypes.bool,
60+
fw300: PropTypes.bool,
61+
fw400: PropTypes.bool,
62+
fw500: PropTypes.bool,
63+
fw600: PropTypes.bool,
64+
fw700: PropTypes.bool,
65+
fw800: PropTypes.bool,
66+
fw900: PropTypes.bool,
67+
fs: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
68+
ff: PropTypes.string,
69+
fsn: PropTypes.bool,
70+
fsi: PropTypes.bool,
71+
h: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
72+
h100p: PropTypes.bool,
73+
jcc: PropTypes.bool,
74+
jcsb: PropTypes.bool,
75+
jcfs: PropTypes.bool,
76+
jcfe: PropTypes.bool,
77+
jcsa: PropTypes.bool,
78+
jcse: PropTypes.bool,
79+
l: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
80+
l0: PropTypes.bool,
81+
lh: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
82+
m: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
83+
mt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
84+
mr: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
85+
mb: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
86+
ml: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
87+
mh: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
88+
mv: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
89+
o: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
90+
oh: PropTypes.bool,
91+
p: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
92+
pa: PropTypes.bool,
93+
pr: PropTypes.oneOfType([PropTypes.bool, PropTypes.number, PropTypes.string]),
94+
pt: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
95+
pb: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
96+
pl: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
97+
ph: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
98+
pv: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
99+
r: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
100+
r0: PropTypes.bool,
101+
t: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
102+
t0: PropTypes.bool,
103+
tac: PropTypes.bool,
104+
tar: PropTypes.bool,
105+
taa: PropTypes.bool,
106+
tal: PropTypes.bool,
107+
taj: PropTypes.bool,
108+
ttu: PropTypes.bool,
109+
ttc: PropTypes.bool,
110+
ttn: PropTypes.bool,
111+
ttl: PropTypes.bool,
112+
w: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
113+
w100p: PropTypes.bool,
114+
zi: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
115+
};
21116
/* eslint-enable */
22117

23118
const getPropsWidthStyle = (props) => {

demo/packages/withAcss/styleMap.js

Lines changed: 128 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,130 @@
1-
const styleMap = {
2-
ac: 'alignContent',
3-
acs: ['alignContent', 'stretch'],
4-
acc: ['alignContent', 'center'],
5-
acfs: ['alignContent', 'flex-start'],
6-
acfe: ['alignContent', 'flex-end'],
7-
acsb: ['alignContent', 'space-between'],
8-
acsa: ['alignContent', 'space-around'],
9-
ai: 'alignItems',
10-
ais: ['alignItems', 'stretch'],
11-
aib: ['alignItems', 'baseline'],
12-
aic: ['alignItems', 'center'],
13-
aifs: ['alignItems', 'flex-start'],
14-
aife: ['alignItems', 'flex-end'],
15-
as: 'alignSelf',
16-
asa: ['alignSelf', 'auto'],
17-
ass: ['alignSelf', 'stretch'],
18-
asb: ['alignSelf', 'baseline'],
19-
asc: ['alignSelf', 'center'],
20-
asfs: ['alignSelf', 'flex-start'],
21-
asfe: ['alignSelf', 'flex-end'],
22-
bc: 'backgroundColor',
23-
br: 'borderRadius',
24-
bw: 'borderWidth',
25-
bs: 'borderStyle',
26-
btw: 'borderTopWidth',
27-
btc: 'borderTopColor',
28-
brw: 'borderRightWidth',
29-
brc: 'borderRightColor',
30-
bbw: 'borderBottomWidth',
31-
bbc: 'borderBottomColor',
32-
blw: 'borderLeftWidth',
33-
blc: 'borderLeftColor',
34-
btrr: 'borderTopRightRadius',
35-
btlr: 'borderTopLeftRadius',
36-
bbrr: 'borderBottomRightRadius',
37-
bblr: 'borderBottomLeftRadius',
38-
b: 'bottom',
39-
b0: ['bottom',0],
40-
c: 'color',
41-
dn: ['display', 'none'],
42-
f: 'flex',
43-
f1: ['flex', 1],
44-
fdr: ['flexDirection', 'row'],
45-
fdrr: ['flexDirection', 'row-reverse'],
46-
fdc: ['flexDirection', 'column'],
47-
fdcr: ['flexDirection', 'column-reverse'],
48-
fwn: ['flexWrap', 'nowrap'],
49-
fwb: ['fontWeight', 'bold'],
50-
fw100: ['fontWeight', "100"],
51-
fw200: ['fontWeight', "200"],
52-
fw300: ['fontWeight', "300"],
53-
fw400: ['fontWeight', "400"],
54-
fw500: ['fontWeight', "500"],
55-
fw600: ['fontWeight', "600"],
56-
fw700: ['fontWeight', "700"],
57-
fw800: ['fontWeight', "800"],
58-
fw900: ['fontWeight', "900"],
59-
fs: 'fontSize',
60-
ff: 'fontFamily',
61-
fsn: ['fontStyle', 'normal'],
62-
fsi: ['fontStyle', 'italic'],
63-
h: 'height',
64-
h100p: ['height', '100%'],
65-
jcc: ['justifyContent', 'center'],
66-
jcsb: ['justifyContent', 'space-between'],
67-
jcfs: ['justifyContent', 'flex-start'],
68-
jcfe: ['justifyContent', 'flex-end'],
69-
jcsa: ['justifyContent', 'space-around'],
70-
jcse: ['justifyContent', 'space-evenly'],
71-
l: 'left',
72-
l0: ['left', 0],
73-
lh: 'lineHeight',
74-
m(value) {
1+
export default {
2+
ac: 'alignContent',
3+
acs: ['alignContent', 'stretch'],
4+
acc: ['alignContent', 'center'],
5+
acfs: ['alignContent', 'flex-start'],
6+
acfe: ['alignContent', 'flex-end'],
7+
acsb: ['alignContent', 'space-between'],
8+
acsa: ['alignContent', 'space-around'],
9+
ai: 'alignItems',
10+
ais: ['alignItems', 'stretch'],
11+
aib: ['alignItems', 'baseline'],
12+
aic: ['alignItems', 'center'],
13+
aifs: ['alignItems', 'flex-start'],
14+
aife: ['alignItems', 'flex-end'],
15+
as: 'alignSelf',
16+
asa: ['alignSelf', 'auto'],
17+
ass: ['alignSelf', 'stretch'],
18+
asb: ['alignSelf', 'baseline'],
19+
asc: ['alignSelf', 'center'],
20+
asfs: ['alignSelf', 'flex-start'],
21+
asfe: ['alignSelf', 'flex-end'],
22+
bc: 'backgroundColor',
23+
br: 'borderRadius',
24+
bw: 'borderWidth',
25+
bs: 'borderStyle',
26+
btw: 'borderTopWidth',
27+
btc: 'borderTopColor',
28+
brw: 'borderRightWidth',
29+
brc: 'borderRightColor',
30+
bbw: 'borderBottomWidth',
31+
bbc: 'borderBottomColor',
32+
blw: 'borderLeftWidth',
33+
blc: 'borderLeftColor',
34+
btrr: 'borderTopRightRadius',
35+
btlr: 'borderTopLeftRadius',
36+
bbrr: 'borderBottomRightRadius',
37+
bblr: 'borderBottomLeftRadius',
38+
b: 'bottom',
39+
b0: ['bottom', 0],
40+
c: 'color',
41+
dn: ['display', 'none'],
42+
f: 'flex',
43+
f1: ['flex', 1],
44+
fdr: ['flexDirection', 'row'],
45+
fdrr: ['flexDirection', 'row-reverse'],
46+
fdc: ['flexDirection', 'column'],
47+
fdcr: ['flexDirection', 'column-reverse'],
48+
fwn: ['flexWrap', 'nowrap'],
49+
fwb: ['fontWeight', 'bold'],
50+
fw100: ['fontWeight', '100'],
51+
fw200: ['fontWeight', '200'],
52+
fw300: ['fontWeight', '300'],
53+
fw400: ['fontWeight', '400'],
54+
fw500: ['fontWeight', '500'],
55+
fw600: ['fontWeight', '600'],
56+
fw700: ['fontWeight', '700'],
57+
fw800: ['fontWeight', '800'],
58+
fw900: ['fontWeight', '900'],
59+
fs: 'fontSize',
60+
ff: 'fontFamily',
61+
fsn: ['fontStyle', 'normal'],
62+
fsi: ['fontStyle', 'italic'],
63+
h: 'height',
64+
h100p: ['height', '100%'],
65+
jcc: ['justifyContent', 'center'],
66+
jcsb: ['justifyContent', 'space-between'],
67+
jcfs: ['justifyContent', 'flex-start'],
68+
jcfe: ['justifyContent', 'flex-end'],
69+
jcsa: ['justifyContent', 'space-around'],
70+
jcse: ['justifyContent', 'space-evenly'],
71+
l: 'left',
72+
l0: ['left', 0],
73+
lh: 'lineHeight',
74+
m(value) {
75+
return {
76+
marginTop: value,
77+
marginBottom: value,
78+
marginRight: value,
79+
marginLeft: value,
80+
};
81+
},
82+
mt: 'marginTop',
83+
mr: 'marginRight',
84+
mb: 'marginBottom',
85+
ml: 'marginLeft',
86+
mh: 'marginHorizontal',
87+
mv: 'marginVertical',
88+
o: 'opacity',
89+
oh: ['overflow', 'hidden'],
90+
p(value) {
91+
return {
92+
paddingTop: value,
93+
paddingBottom: value,
94+
paddingRight: value,
95+
paddingLeft: value,
96+
};
97+
},
98+
pa: ['position', 'absolute'],
99+
pr(value) {
100+
if (value === true) {
75101
return {
76-
marginTop: value,
77-
marginBottom: value,
78-
marginRight: value,
79-
marginLeft: value,
102+
position: 'relative',
80103
};
81-
},
82-
mt: 'marginTop',
83-
mr: 'marginRight',
84-
mb: 'marginBottom',
85-
ml: 'marginLeft',
86-
mh: 'marginHorizontal',
87-
mv: 'marginVertical',
88-
o: 'opacity',
89-
oh: ['overflow', 'hidden'],
90-
p(value) {
91-
return {
92-
paddingTop: value,
93-
paddingBottom: value,
94-
paddingRight: value,
95-
paddingLeft: value,
96-
};
97-
},
98-
pa: ['position', 'absolute'],
99-
pr(value) {
100-
if (value === true) {
101-
return {
102-
position: 'relative',
103-
};
104-
}
105-
return {
106-
paddingRight: value,
107-
};
108-
},
109-
pt: 'paddingTop',
110-
pb: 'paddingBottom',
111-
pl: 'paddingLeft',
112-
ph: 'paddingHorizontal',
113-
pv: 'paddingVertical',
114-
r: 'right',
115-
r0: ['right', 0],
116-
t: 'top',
117-
t0: ['top', 0],
118-
tac: ['textAlign', 'center'],
119-
tar: ['textAlign', 'right'],
120-
taa: ['textAlign', 'auto'],
121-
tal: ['textAlign', 'left'],
122-
taj: ['textAlign', 'justify'],
123-
ttu: ['textTransform', 'uppercase'],
124-
ttc: ['textTransform', 'capitalize'],
125-
ttn: ['textTransform', 'none'],
126-
ttl: ['textTransform', 'lowercase'],
127-
w: 'width',
128-
w100p: ['width', '100%'],
129-
zi: 'zIndex',
130-
};
131-
132-
export default styleMap
104+
}
105+
return {
106+
paddingRight: value,
107+
};
108+
},
109+
pt: 'paddingTop',
110+
pb: 'paddingBottom',
111+
pl: 'paddingLeft',
112+
ph: 'paddingHorizontal',
113+
pv: 'paddingVertical',
114+
r: 'right',
115+
r0: ['right', 0],
116+
t: 'top',
117+
t0: ['top', 0],
118+
tac: ['textAlign', 'center'],
119+
tar: ['textAlign', 'right'],
120+
taa: ['textAlign', 'auto'],
121+
tal: ['textAlign', 'left'],
122+
taj: ['textAlign', 'justify'],
123+
ttu: ['textTransform', 'uppercase'],
124+
ttc: ['textTransform', 'capitalize'],
125+
ttn: ['textTransform', 'none'],
126+
ttl: ['textTransform', 'lowercase'],
127+
w: 'width',
128+
w100p: ['width', '100%'],
129+
zi: 'zIndex',
130+
};

0 commit comments

Comments
 (0)