1 | {"version":3,"file":"Customizer.js","sourceRoot":"../src/","sources":["customizations/Customizer.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAsB,MAAM,qBAAqB,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAG5D;;;;;;;;;;;;;GAaG;AACH;IAAgC,8BAAiC;IAAjE;QAAA,qEA2BC;QADS,4BAAsB,GAAG,cAAM,OAAA,KAAI,CAAC,WAAW,EAAE,EAAlB,CAAkB,CAAC;;IAC5D,CAAC;IA1BQ,sCAAiB,GAAxB;QACE,cAAc,CAAC,OAAO,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACtD,CAAC;IAEM,yCAAoB,GAA3B;QACE,cAAc,CAAC,SAAS,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;IACxD,CAAC;IAEM,2BAAM,GAAb;QAAA,iBAeC;QAdS,IAAA,8CAAgB,CAAgB;QACxC,OAAO,CACL,oBAAC,iBAAiB,CAAC,QAAQ,QACxB,UAAC,aAAiC;YACjC,IAAI,UAAU,GAAG,mBAAmB,CAAC,KAAI,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;YAEhE,IAAI,gBAAgB,EAAE;gBACpB,UAAU,GAAG,gBAAgB,CAAC,UAAU,CAAC,CAAC;aAC3C;YAED,OAAO,oBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,UAAU,IAAG,KAAI,CAAC,KAAK,CAAC,QAAQ,CAA8B,CAAC;QAC3G,CAAC,CAC0B,CAC9B,CAAC;IACJ,CAAC;IAGH,iBAAC;AAAD,CAAC,AA3BD,CAAgC,KAAK,CAAC,SAAS,GA2B9C","sourcesContent":["import * as React from 'react';\nimport { Customizations } from './Customizations';\nimport { CustomizerContext, ICustomizerContext } from './CustomizerContext';\nimport { mergeCustomizations } from './mergeCustomizations';\nimport { ICustomizerProps } from './Customizer.types';\n\n/**\n * The Customizer component allows for default props to be mixed into components which\n * are decorated with the customizable() decorator, or use the styled HOC. This enables\n * injection scenarios like:\n *\n * 1. render svg icons instead of the icon font within all buttons\n * 2. inject a custom theme object into a component\n *\n * Props are provided via the settings prop which should be one of the following:\n * - A json map which contains 1 or more name/value pairs representing injectable props.\n * - A function that receives the current settings and returns the new ones that apply to the scope\n *\n * @public\n */\nexport class Customizer extends React.Component<ICustomizerProps> {\n public componentDidMount(): void {\n Customizations.observe(this._onCustomizationChange);\n }\n\n public componentWillUnmount(): void {\n Customizations.unobserve(this._onCustomizationChange);\n }\n\n public render(): React.ReactElement<{}> {\n const { contextTransform } = this.props;\n return (\n <CustomizerContext.Consumer>\n {(parentContext: ICustomizerContext) => {\n let newContext = mergeCustomizations(this.props, parentContext);\n\n if (contextTransform) {\n newContext = contextTransform(newContext);\n }\n\n return <CustomizerContext.Provider value={newContext}>{this.props.children}</CustomizerContext.Provider>;\n }}\n </CustomizerContext.Consumer>\n );\n }\n\n private _onCustomizationChange = () => this.forceUpdate();\n}\n"]} |