repoweaver
Version:
A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies
1 lines • 11.3 kB
JSON
{"ast":null,"code":"import React, { PureComponent } from 'react';\nimport createIconSet from \"./createIconSet\";\nexport default function createMultiStyleIconSet(styles, optionsInput = {}) {\n const styleNames = Object.keys(styles);\n if (styleNames.length === 0) {\n throw new Error('You need to add at least one style');\n }\n const options = Object.assign({\n defaultStyle: styleNames[0],\n fallbackFamily: _unused => styleNames[0],\n glyphValidator: (_unused, __unused) => true\n }, optionsInput);\n const iconSets = styleNames.reduce((acc, name) => {\n const style = styles[name];\n acc[name] = createIconSet(style.glyphMap || {}, style.fontFamily || '', style.fontFile || '', style.fontStyle || {});\n return acc;\n }, {});\n function styleFromProps(props) {\n return Object.keys(props).reduce((result, propName) => styleNames.indexOf(propName) !== -1 && props[propName] === true ? propName : result, options.defaultStyle);\n }\n function getIconSetForProps(props) {\n const {\n name\n } = props;\n const style = styleFromProps(props);\n if (options.glyphValidator(name, style)) return iconSets[style];\n const family = options.fallbackFamily(name);\n if (styleNames.indexOf(family) === -1) {\n return options.defaultStyle;\n }\n return iconSets[family];\n }\n function selectIconClass(iconSet, iconClass) {\n return iconClass.length > 0 ? iconSet[iconClass] : iconSet;\n }\n function reduceProps(props) {\n return Object.keys(props).reduce((acc, prop) => {\n if (styleNames.indexOf(prop) === -1) {\n acc[prop] = props[prop];\n }\n return acc;\n }, {});\n }\n function getStyledIconSet(style, name = '') {\n if (styleNames.indexOf(style) === -1) {\n return iconSets[options.defaultStyle];\n }\n return !name ? iconSets[styleFromProps({\n [style]: true\n })] : getIconSetForProps({\n name,\n [style]: true\n });\n }\n function getFontFamily(style = options.defaultStyle) {\n return getStyledIconSet(style).getFontFamily();\n }\n function getRawGlyphMap(style = options.defaultStyle) {\n return getStyledIconSet(style).getRawGlyphMap();\n }\n function hasIcon(name, style = options.defaultStyle) {\n return options.glyphValidator(name, style);\n }\n function createStyledIconClass(selectClass = '') {\n class IconClass extends PureComponent {\n static defaultProps = styleNames.reduce((acc, name) => {\n acc[name] = false;\n return acc;\n }, {});\n static font = Object.values(styles).reduce((acc, style) => {\n acc[style.fontFamily] = style.fontFile;\n return acc;\n }, {});\n static StyledIconSet = getStyledIconSet;\n static getFontFamily = getFontFamily;\n static getRawGlyphMap = getRawGlyphMap;\n static hasIcon = hasIcon;\n render() {\n const selectedIconSet = getIconSetForProps(this.props);\n const SelectedIconClass = selectIconClass(selectedIconSet, selectClass);\n const props = reduceProps(this.props);\n return React.createElement(SelectedIconClass, props);\n }\n }\n return IconClass;\n }\n const Icon = createStyledIconClass();\n Icon.Button = createStyledIconClass('Button');\n return Icon;\n}","map":{"version":3,"names":["React","PureComponent","createIconSet","createMultiStyleIconSet","styles","optionsInput","styleNames","Object","keys","length","Error","options","assign","defaultStyle","fallbackFamily","_unused","glyphValidator","__unused","iconSets","reduce","acc","name","style","glyphMap","fontFamily","fontFile","fontStyle","styleFromProps","props","result","propName","indexOf","getIconSetForProps","family","selectIconClass","iconSet","iconClass","reduceProps","prop","getStyledIconSet","getFontFamily","getRawGlyphMap","hasIcon","createStyledIconClass","selectClass","IconClass","defaultProps","font","values","StyledIconSet","render","selectedIconSet","SelectedIconClass","createElement","Icon","Button"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@expo/vector-icons/src/createMultiStyleIconSet.ts"],"sourcesContent":["import React, { PureComponent } from 'react';\n\nimport createIconSet from './createIconSet';\n\ntype FontStyle = {\n fontFamily: string;\n fontFile: any;\n glyphMap: any;\n fontStyle: any;\n};\n\ntype FontStyles = {\n [key: string]: FontStyle;\n};\n\nexport default function createMultiStyleIconSet(styles: FontStyles, optionsInput = {}): any {\n const styleNames = Object.keys(styles);\n\n if (styleNames.length === 0) {\n throw new Error('You need to add at least one style');\n }\n\n const options = {\n defaultStyle: styleNames[0],\n fallbackFamily: (_unused: any) => styleNames[0],\n glyphValidator: (_unused: any, __unused: any) => true,\n ...optionsInput,\n };\n\n const iconSets = styleNames.reduce((acc, name) => {\n const style = styles[name];\n\n acc[name] = createIconSet(\n style.glyphMap || {},\n style.fontFamily || '',\n style.fontFile || '',\n style.fontStyle || {}\n );\n\n return acc;\n }, {});\n\n function styleFromProps(props) {\n return Object.keys(props).reduce(\n (result, propName) =>\n styleNames.indexOf(propName) !== -1 && props[propName] === true ? propName : result,\n options.defaultStyle\n );\n }\n\n function getIconSetForProps(props) {\n const { name } = props;\n const style = styleFromProps(props);\n\n if (options.glyphValidator(name, style)) return iconSets[style];\n\n const family = options.fallbackFamily(name);\n\n if (styleNames.indexOf(family) === -1) {\n return options.defaultStyle;\n }\n\n return iconSets[family];\n }\n\n function selectIconClass(iconSet, iconClass) {\n return iconClass.length > 0 ? iconSet[iconClass] : iconSet;\n }\n\n function reduceProps(props) {\n return Object.keys(props).reduce((acc, prop) => {\n if (styleNames.indexOf(prop) === -1) {\n acc[prop] = props[prop];\n }\n\n return acc;\n }, {});\n }\n\n function getStyledIconSet(style, name = '') {\n if (styleNames.indexOf(style) === -1) {\n return iconSets[options.defaultStyle];\n }\n\n return !name\n ? iconSets[styleFromProps({ [style]: true })]\n : getIconSetForProps({ name, [style]: true });\n }\n\n function getFontFamily(style = options.defaultStyle) {\n return getStyledIconSet(style).getFontFamily();\n }\n\n function getRawGlyphMap(style = options.defaultStyle) {\n return getStyledIconSet(style).getRawGlyphMap();\n }\n\n function hasIcon(name, style = options.defaultStyle) {\n return options.glyphValidator(name, style);\n }\n\n function createStyledIconClass(selectClass = '') {\n class IconClass extends PureComponent {\n static defaultProps = styleNames.reduce((acc, name) => {\n acc[name] = false;\n return acc;\n }, {});\n\n static font = Object.values(styles).reduce((acc, style) => {\n acc[style.fontFamily] = style.fontFile;\n return acc;\n }, {});\n\n static Button: any;\n\n static StyledIconSet = getStyledIconSet;\n static getFontFamily = getFontFamily;\n static getRawGlyphMap = getRawGlyphMap;\n static hasIcon = hasIcon;\n\n render() {\n const selectedIconSet = getIconSetForProps(this.props);\n const SelectedIconClass = selectIconClass(selectedIconSet, selectClass);\n const props = reduceProps(this.props);\n\n return React.createElement(SelectedIconClass, props);\n }\n }\n\n return IconClass;\n }\n\n const Icon = createStyledIconClass();\n Icon.Button = createStyledIconClass('Button');\n return Icon;\n}\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,aAAa,QAAQ,OAAO;AAE5C,OAAOC,aAAa;AAapB,eAAc,SAAUC,uBAAuBA,CAACC,MAAkB,EAAEC,YAAY,GAAG,EAAE;EACnF,MAAMC,UAAU,GAAGC,MAAM,CAACC,IAAI,CAACJ,MAAM,CAAC;EAEtC,IAAIE,UAAU,CAACG,MAAM,KAAK,CAAC,EAAE;IAC3B,MAAM,IAAIC,KAAK,CAAC,oCAAoC,CAAC;EACvD;EAEA,MAAMC,OAAO,GAAAJ,MAAA,CAAAK,MAAA;IACXC,YAAY,EAAEP,UAAU,CAAC,CAAC,CAAC;IAC3BQ,cAAc,EAAGC,OAAY,IAAKT,UAAU,CAAC,CAAC,CAAC;IAC/CU,cAAc,EAAEA,CAACD,OAAY,EAAEE,QAAa,KAAK;EAAI,GAClDZ,YAAY,CAChB;EAED,MAAMa,QAAQ,GAAGZ,UAAU,CAACa,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAI;IAC/C,MAAMC,KAAK,GAAGlB,MAAM,CAACiB,IAAI,CAAC;IAE1BD,GAAG,CAACC,IAAI,CAAC,GAAGnB,aAAa,CACvBoB,KAAK,CAACC,QAAQ,IAAI,EAAE,EACpBD,KAAK,CAACE,UAAU,IAAI,EAAE,EACtBF,KAAK,CAACG,QAAQ,IAAI,EAAE,EACpBH,KAAK,CAACI,SAAS,IAAI,EAAE,CACtB;IAED,OAAON,GAAG;EACZ,CAAC,EAAE,EAAE,CAAC;EAEN,SAASO,cAAcA,CAACC,KAAK;IAC3B,OAAOrB,MAAM,CAACC,IAAI,CAACoB,KAAK,CAAC,CAACT,MAAM,CAC9B,CAACU,MAAM,EAAEC,QAAQ,KACfxB,UAAU,CAACyB,OAAO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