UNPKG

1.34 kBSource Map (JSON)View Raw
1{"version":3,"file":"components.js","sources":["../src/utils/components.js"],"sourcesContent":["// Forward some props of an instance to a child element.\n//\n// Usage example:\n//\n// <Child {...forwardProps(this, ['name', 'style'])}>\n//\nexport function forwardProps(instance, names) {\n return names.reduce((props, name) => {\n if (instance.props[name]) {\n props[name] = instance.props[name]\n }\n return props\n }, {})\n}\n\n// Forward the props useful to extend the styles of the main child of a\n// component, using either styled() or the style attribute. Additionnal names\n// can be passed as a second parameter.\nexport function stylingProps(instance, names = []) {\n return forwardProps(instance, ['style', 'className', ...names])\n}\n"],"names":["forwardProps","instance","names","reduce","props","name","stylingProps"],"mappings":";;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,YAAT,CAAsBC,QAAtB,EAAgCC,KAAhC,EAAuC;AAC5C,SAAOA,KAAK,CAACC,MAAN,CAAa,UAACC,KAAD,EAAQC,IAAR,EAAiB;AACnC,QAAIJ,QAAQ,CAACG,KAAT,CAAeC,IAAf,CAAJ,EAA0B;AACxBD,MAAAA,KAAK,CAACC,IAAD,CAAL,GAAcJ,QAAQ,CAACG,KAAT,CAAeC,IAAf,CAAd;AACD;;AACD,WAAOD,KAAP;AACD,GALM,EAKJ,EALI,CAAP;AAMD;AAGD;AACA;;AACO,SAASE,YAAT,CAAsBL,QAAtB,EAA4C;AAAA,MAAZC,KAAY,uEAAJ,EAAI;AACjD,SAAOF,YAAY,CAACC,QAAD,GAAY,OAAZ,EAAqB,WAArB,8CAAqCC,KAArC,GAAnB;AACD;;;;;"}
\No newline at end of file