{"code":"import * as tslib_1 from \"tslib\";\r\nimport React, { PureComponent } from 'react';\r\nimport posed from 'react-pose';\r\nimport { invariant } from 'hey-listen';\r\nvar splitStyles = { display: 'inline-block' };\r\nvar SplitText = (function (_super) {\r\n    tslib_1.__extends(SplitText, _super);\r\n    function SplitText(props) {\r\n        var _this = _super.call(this, props) || this;\r\n        var wordPoses = props.wordPoses, charPoses = props.charPoses, children = props.children;\r\n        _this.parseText(children);\r\n        if (wordPoses)\r\n            _this.Word = posed.div(wordPoses);\r\n        if (charPoses)\r\n            _this.Char = posed.div(charPoses);\r\n        return _this;\r\n    }\r\n    SplitText.prototype.parseText = function (text) {\r\n        invariant(typeof text === 'string', 'Child of SplitText must be a string');\r\n        var _a = this.props, children = _a.children, wordPoses = _a.wordPoses, charPoses = _a.charPoses, poseProps = tslib_1.__rest(_a, [\"children\", \"wordPoses\", \"charPoses\"]);\r\n        this.poseProps = poseProps;\r\n        this.numChars = text.length;\r\n        this.text = text.split(' ').map(function (word) { return word.split(''); });\r\n    };\r\n    SplitText.prototype.componentWillReceiveProps = function (_a) {\r\n        var children = _a.children;\r\n        if (this.props.children !== children)\r\n            this.parseText(children);\r\n    };\r\n    SplitText.prototype.renderChars = function (text, wordIndex, numWords, baseCharCount) {\r\n        var _this = this;\r\n        var numCharsInWord = text.length;\r\n        var children = this.props.children;\r\n        return text.map(function (char, i) {\r\n            return _this.Char ? (React.createElement(_this.Char, tslib_1.__assign({ key: children + i, style: splitStyles, wordIndex: wordIndex, numWords: numWords, charIndex: baseCharCount + i, charInWordIndex: i, numChars: _this.numChars, numCharsInWord: numCharsInWord }, _this.poseProps), char)) : (char);\r\n        });\r\n    };\r\n    SplitText.prototype.renderWords = function (text) {\r\n        var _this = this;\r\n        var children = this.props.children;\r\n        var numWords = text.length;\r\n        var charCount = 0;\r\n        return text.map(function (word, i) {\r\n            var chars = _this.renderChars(word, i, numWords, charCount).concat([\r\n                i !== numWords - 1 ? '\\u00A0' : null\r\n            ]);\r\n            charCount += word.length;\r\n            return _this.Word ? (React.createElement(_this.Word, tslib_1.__assign({ key: children + i, style: splitStyles, wordIndex: i, numWords: numWords }, _this.poseProps), chars)) : (React.createElement(\"div\", { style: splitStyles, key: children + i }, chars));\r\n        });\r\n    };\r\n    SplitText.prototype.render = function () {\r\n        return this.renderWords(this.text);\r\n    };\r\n    return SplitText;\r\n}(PureComponent));\r\nexport default SplitText;\r\n//# sourceMappingURL=SplitText.js.map","map":"{\"version\":3,\"file\":\"SplitText.js\",\"sourceRoot\":\"\",\"sources\":[\"src/SplitText.tsx\"],\"names\":[],\"mappings\":\";AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAgB,MAAM,OAAO,CAAC;AAC3D,OAAO,KAAK,MAAM,YAAY,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAYvC,IAAM,WAAW,GAAG,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC;AAEhD;IAAwB,qCAAoB;IAQ1C,mBAAY,KAAY;QAAxB,YACE,kBAAM,KAAK,CAAC,SAQb;QANS,IAAA,2BAAS,EAAE,2BAAS,EAAE,yBAAQ,CAAW;QAEjD,KAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QAEzB,IAAI,SAAS;YAAE,KAAI,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QAChD,IAAI,SAAS;YAAE,KAAI,CAAC,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;;IAClD,CAAC;IAED,6BAAS,GAAT,UAAU,IAAY;QACpB,SAAS,CAAC,OAAO,IAAI,KAAK,QAAQ,EAAE,qCAAqC,CAAC,CAAC;QAE3E,IAAM,eAA6D,EAA3D,sBAAQ,EAAE,wBAAS,EAAE,wBAAS,EAAE,sEAA2B,CAAC;QACpE,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,MA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EAAE,CAAC;YACtB,IAAM,KAAK,GACN,KAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC;gBACjD,CAAC,KAAK,QAAQ,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;cACrC,CAAC;YAEF,SAAS,IAAI,IAAI,CAAC,MAAM,CAAC;YAEzB,OAAO,KAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CACjB,oBAAC,KAAI,CAAC,IAAI,qBACR,GAAG,EAAE,QAAQ,GAAG,CAAC,EACjB,KAAK,EAAE,WAAW,EAClB,SAAS,EAAE,CAAC,EACZ,QAAQ,EAAE,QAAQ,IACd,KAAI,CAAC,SAAS,GAEjB,KAAK,CACI,CACb,CAAC,CAAC,CAAC,CACF,6BAAK,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,QAAQ,GAAG,CAAC,IACvC,KAAK,CACF,CACP,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAED,0BAAM,GAAN;QACE,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;IACH,gBAAC;AAAD,CAAC,AAjGD,CAAwB,aAAa,GAiGpC;AAED,eAAe,SAAS,CAAC\"}","dts":{"name":"/Users/mattperry/Sites/popmotion/packages/react-pose-text/SplitText.d.ts","text":"/// <reference types=\"react\" />\r\nimport { PureComponent, ReactElement } from 'react';\r\nexport declare type PoseProps = {\r\n    [key: string]: any;\r\n};\r\nexport declare type Props = {\r\n    children?: string;\r\n    wordPoses?: PoseProps;\r\n    charPoses?: PoseProps;\r\n    pose?: string | string[];\r\n    initialPose?: string | string[];\r\n};\r\ndeclare class SplitText extends PureComponent<Props> {\r\n    props: Props;\r\n    poseProps: Props;\r\n    text: string[][];\r\n    numChars: number;\r\n    Word: (props: PoseProps) => ReactElement<any>;\r\n    Char: (props: PoseProps) => ReactElement<any>;\r\n    constructor(props: Props);\r\n    parseText(text: string): void;\r\n    componentWillReceiveProps({children}: Props): void;\r\n    renderChars(text: string[], wordIndex: number, numWords: number, baseCharCount: number): (string | JSX.Element)[];\r\n    renderWords(text: string[][]): JSX.Element[];\r\n    render(): JSX.Element[];\r\n}\r\nexport default SplitText;\r\n"}}
