@corva/ui 3.75.0-22 → 3.75.0-24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),r=require("@babel/runtime/helpers/classCallCheck"),a=require("@babel/runtime/helpers/createClass"),s=require("@babel/runtime/helpers/assertThisInitialized"),n=require("@babel/runtime/helpers/inherits"),i=require("@babel/runtime/helpers/possibleConstructorReturn"),o=require("@babel/runtime/helpers/getPrototypeOf"),u=require("@babel/runtime/helpers/defineProperty"),l=require("@babel/runtime/regenerator"),d=require("react"),c=require("prop-types"),f=require("moment"),h=require("classnames"),p=require("lodash"),y=require("react-infinite-scroller"),m=require("@material-ui/core/colors/grey"),b=require("./styles.css.js"),I=require("../LoadingIndicator/LoadingIndicator.js"),v=require("react/jsx-runtime");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=g(e),L=g(t),T=g(r),D=g(a),C=g(s),w=g(n),P=g(i),x=g(o),A=g(u),R=g(l),k=g(c),N=g(f),j=g(h),B=g(y);function H(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var r,a=x.default(e);if(t){var s=x.default(this).constructor;r=Reflect.construct(a,arguments,s)}else r=a.apply(this,arguments);return P.default(this,r)}}var O=g(m).default[700],S={newerThan12Hours:"Last 12 hours",olderThan12Hours:"Last 24 hours",olderThan1Days:"Earlier this week",olderThan7Days:"Older than 7 days",olderThan14Days:"Older than 14 days",olderThan30Days:"Older than 30 days"},_=function(e){w.default(r,e);var t=H(r);function r(e){var a;return T.default(this,r),a=t.call(this,e),A.default(C.default(a),"loadItems",L.default(R.default.mark((function e(){return R.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!a.state.isLoadingByScroll){e.next=2;break}return e.abrupt("return");case 2:return a.setState({isLoadingByScroll:!0}),e.next=5,a.props.loadItems();case 5:a.setState({isLoadingByScroll:!1});case 6:case"end":return e.stop()}}),e)})))),a.state={isLoadingByScroll:!1,periodDates:a.periodDates},a.updatePeriodsIntervalId=null,a}return D.default(r,[{key:"componentDidMount",value:function(){var e=this;this.updatePeriodsIntervalId=setInterval((function(){return e.setState({periodDates:e.periodDates})}),216e5)}},{key:"componentWillUnmount",value:function(){this.updatePeriodsIntervalId&&clearInterval(this.updatePeriodsIntervalId)}},{key:"periodDates",get:function(){return{hoursAgo12:N.default().subtract(12,"hours"),daysAgo1:N.default().subtract(1,"days"),daysAgo7:N.default().subtract(7,"days"),daysAgo14:N.default().subtract(14,"days"),daysAgo30:N.default().subtract(30,"days")}}},{key:"renderNoItemsLabel",value:function(){return v.jsx("div",{"data-testid":"".concat("generic_infiniteList","_noItems"),className:b.cInfiniteListEmpty,children:this.props.noItemsFoundLabel},"c-infinite-list__empty")}},{key:"renderPeriodSeparator",value:function(e){return v.jsx("div",{"data-testid":"".concat("generic_infiniteList","_periodLabel"),className:b.cInfiniteListPeriod,style:{color:O},children:S[e]},e)}},{key:"renderItems",value:function(){var e=this;if(!this.props.divideByPeriods)return this.props.items.map((function(t){return e.props.renderItem(t)})).unshift(this.props.headerComponent);var t=this.state.periodDates,r=t.hoursAgo12,a=t.daysAgo1,s=t.daysAgo7,n=t.daysAgo14,i=t.daysAgo30,o=this.props.items.reduce((function(t,o,u){var l,d=e.props.renderItem(o,u),c=p.get(o,e.props.pathToCreatedAt),f=N.default(c);return f>=r?l="newerThan12Hours":f<r&&f>=a?l="olderThan12Hours":f<a&&f>=s?l="olderThan1Days":f<s&&f>=n?l="olderThan7Days":f<n&&f>=i?l="olderThan14Days":f<i&&(l="olderThan30Days"),p.set(t,[l,t[l].length],d)}),{newerThan12Hours:[],olderThan12Hours:[],olderThan1Days:[],olderThan7Days:[],olderThan14Days:[],olderThan30Days:[]}),u=Object.keys(o).reduce((function(t,r){return 0===o[r].length?t.concat(o[r]):t.concat([e.renderPeriodSeparator(r)].concat(q.default(o[r])))}),[]);return[this.props.headerComponent].concat(q.default(u))}},{key:"render",value:function(){return v.jsxs("div",{className:j.default(b.cInfiniteList,this.props.infiniteClassName,A.default({},b.cInfiniteListOverflow,!this.props.useWindow)),style:{height:this.props.infiniteContainerHeight},children:[v.jsx(B.default,{loadMore:this.loadItems,hasMore:this.props.moreItemsMayExist&&!this.props.showNoItemsFound,threshold:this.props.threshold,loader:v.jsx(I,{fullscreen:!1},"c-infinite-scroll__loader"),useWindow:this.props.useWindow,initialLoad:this.props.initialLoad,children:this.renderItems()}),this.props.showNoItemsFound&&this.renderNoItemsLabel()]})}}]),r}(d.PureComponent);_.propTypes={infiniteClassName:k.default.string,useWindow:k.default.bool,headerComponent:k.default.node,items:k.default.arrayOf(k.default.shape()).isRequired,showNoItemsFound:k.default.bool.isRequired,noItemsFoundLabel:k.default.string.isRequired,infiniteContainerHeight:k.default.number,moreItemsMayExist:k.default.bool.isRequired,pathToCreatedAt:k.default.arrayOf(k.default.string).isRequired,renderItem:k.default.func.isRequired,loadItems:k.default.func.isRequired,threshold:k.default.number,initialLoad:k.default.bool,divideByPeriods:k.default.bool},_.defaultProps={infiniteClassName:null,useWindow:!1,headerComponent:null,infiniteContainerHeight:null,threshold:3e3,initialLoad:!0,divideByPeriods:!0},module.exports=_;
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),r=require("@babel/runtime/helpers/toConsumableArray"),t=require("@babel/runtime/helpers/asyncToGenerator"),a=require("@babel/runtime/helpers/slicedToArray"),n=require("@babel/runtime/regenerator"),i=require("react"),s=require("prop-types"),o=require("moment"),d=require("classnames"),u=require("lodash"),l=require("react-infinite-scroller"),c=require("@material-ui/core/colors/grey"),f=require("./styles.css.js"),h=require("../LoadingIndicator/LoadingIndicator.js"),y=require("react/jsx-runtime");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=m(e),p=m(r),g=m(t),v=m(a),T=m(n),q=m(s),I=m(o),L=m(d),A=m(l),w=m(c).default[700],x={newerThan12Hours:"Last 12 hours",olderThan12Hours:"Last 24 hours",olderThan1Days:"Earlier this week",olderThan7Days:"Older than 7 days",olderThan14Days:"Older than 14 days",olderThan30Days:"Older than 30 days"},D=function(){return{hoursAgo12:I.default().subtract(12,"hours"),daysAgo1:I.default().subtract(1,"days"),daysAgo7:I.default().subtract(7,"days"),daysAgo14:I.default().subtract(14,"days"),daysAgo30:I.default().subtract(30,"days")}};function j(e){var r=e.infiniteClassName,t=void 0===r?null:r,a=e.useWindow,n=void 0!==a&&a,s=e.headerComponent,o=void 0===s?null:s,d=e.items,l=e.showNoItemsFound,c=e.noItemsFoundLabel,m=e.infiniteContainerHeight,q=void 0===m?null:m,j=e.moreItemsMayExist,C=e.pathToCreatedAt,H=e.renderItem,_=e.loadItems,N=e.threshold,O=void 0===N?3e3:N,R=e.initialLoad,E=void 0===R||R,k=e.divideByPeriods,F=void 0===k||k,M=i.useState(!1),P=v.default(M,2),W=P[0],B=P[1],S=i.useState(D),G=v.default(S,2),z=G[0],J=G[1];i.useEffect((function(){var e=setInterval((function(){return J(D())}),216e5);return function(){return clearInterval(e)}}),[]);var K,Q=(K=g.default(T.default.mark((function e(){return T.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!W){e.next=2;break}return e.abrupt("return");case 2:return B(!0),e.next=5,_();case 5:B(!1);case 6:case"end":return e.stop()}}),e)}))),function(){return K.apply(this,arguments)});return y.jsxs("div",{className:L.default(f.cInfiniteList,t,b.default({},f.cInfiniteListOverflow,!n)),style:{height:q},children:[y.jsx(A.default,{loadMore:Q,hasMore:j&&!l,threshold:O,loader:y.jsx(h,{fullscreen:!1},"c-infinite-scroll__loader"),useWindow:n,initialLoad:E,children:function(){if(!F)return d.map((function(e){return H(e)})).unshift(o);var e=z.hoursAgo12,r=z.daysAgo1,t=z.daysAgo7,a=z.daysAgo14,n=z.daysAgo30,i=d.reduce((function(i,s,o){var d,l=H(s,o),c=u.get(s,C),f=I.default(c);return f>=e?d="newerThan12Hours":f<e&&f>=r?d="olderThan12Hours":f<r&&f>=t?d="olderThan1Days":f<t&&f>=a?d="olderThan7Days":f<a&&f>=n?d="olderThan14Days":f<n&&(d="olderThan30Days"),u.set(i,[d,i[d].length],l)}),{newerThan12Hours:[],olderThan12Hours:[],olderThan1Days:[],olderThan7Days:[],olderThan14Days:[],olderThan30Days:[]}),s=Object.keys(i).reduce((function(e,r){return 0===i[r].length?e.concat(i[r]):e.concat([(t=r,y.jsx("div",{"data-testid":"".concat("generic_infiniteList","_periodLabel"),className:f.cInfiniteListPeriod,style:{color:w},children:x[t]},t))].concat(p.default(i[r])));var t}),[]);return[o].concat(p.default(s))}()}),l&&y.jsx("div",{"data-testid":"".concat("generic_infiniteList","_noItems"),className:f.cInfiniteListEmpty,children:c},"c-infinite-list__empty")]})}j.propTypes={infiniteClassName:q.default.string,useWindow:q.default.bool,headerComponent:q.default.node,items:q.default.arrayOf(q.default.shape()).isRequired,showNoItemsFound:q.default.bool.isRequired,noItemsFoundLabel:q.default.string.isRequired,infiniteContainerHeight:q.default.number,moreItemsMayExist:q.default.bool.isRequired,pathToCreatedAt:q.default.arrayOf(q.default.string).isRequired,renderItem:q.default.func.isRequired,loadItems:q.default.func.isRequired,threshold:q.default.number,initialLoad:q.default.bool,divideByPeriods:q.default.bool};var C=i.memo(j);module.exports=C;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/InfiniteList/index.js"],"sourcesContent":["import { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport moment from 'moment';\nimport classNames from 'classnames';\nimport { get, set } from 'lodash';\nimport InfiniteScroll from 'react-infinite-scroller';\nimport grey from '@material-ui/core/colors/grey';\n\nimport styles from './styles.css';\n\nimport LoadingIndicator from '~components/LoadingIndicator';\n\nconst PAGE_NAME = 'generic_infiniteList';\n\nconst grey700 = grey['700'];\n\nconst INTERVAL_6_HOURS = 6 * 60 * 60 * 1000;\nconst PERIOD_LABELS = {\n newerThan12Hours: 'Last 12 hours',\n olderThan12Hours: 'Last 24 hours',\n olderThan1Days: 'Earlier this week',\n olderThan7Days: 'Older than 7 days',\n olderThan14Days: 'Older than 14 days',\n olderThan30Days: 'Older than 30 days',\n};\n\n/** @extends {PureComponent<any, any, any>} */\nclass InfiniteList extends PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n isLoadingByScroll: false,\n\n periodDates: this.periodDates,\n };\n\n this.updatePeriodsIntervalId = null;\n }\n\n componentDidMount() {\n this.updatePeriodsIntervalId = setInterval(\n () => this.setState({ periodDates: this.periodDates }),\n INTERVAL_6_HOURS\n );\n }\n\n componentWillUnmount() {\n if (this.updatePeriodsIntervalId) {\n clearInterval(this.updatePeriodsIntervalId);\n }\n }\n\n get periodDates() {\n return {\n hoursAgo12: moment().subtract(12, 'hours'),\n daysAgo1: moment().subtract(1, 'days'),\n daysAgo7: moment().subtract(7, 'days'),\n daysAgo14: moment().subtract(14, 'days'),\n daysAgo30: moment().subtract(30, 'days'),\n };\n }\n\n // NOTE: 'react-infinite-scroller' has a bug that when scroll reaches threshold area, it starts\n // to fire loadMore on every scroll event - bottom, up. As a result multiple same request fired.\n //\n // We fix this preventing request that was fired by scroll before previous is finished.\n //\n // Issues:\n // https://github.com/CassetteRocks/react-infinite-scroller/issues/143\n loadItems = async () => {\n if (this.state.isLoadingByScroll) {\n return;\n }\n\n this.setState({ isLoadingByScroll: true });\n\n await this.props.loadItems();\n\n this.setState({ isLoadingByScroll: false });\n };\n\n renderNoItemsLabel() {\n return (\n <div\n data-testid={`${PAGE_NAME}_noItems`}\n key=\"c-infinite-list__empty\"\n className={styles.cInfiniteListEmpty}\n >\n {this.props.noItemsFoundLabel}\n </div>\n );\n }\n\n renderPeriodSeparator(periodKey) {\n return (\n <div\n data-testid={`${PAGE_NAME}_periodLabel`}\n key={periodKey}\n className={styles.cInfiniteListPeriod}\n style={{ color: grey700 }}\n >\n {PERIOD_LABELS[periodKey]}\n </div>\n );\n }\n\n renderItems() {\n if (!this.props.divideByPeriods) {\n return this.props.items\n .map(item => this.props.renderItem(item))\n .unshift(this.props.headerComponent);\n }\n\n const { hoursAgo12, daysAgo1, daysAgo7, daysAgo14, daysAgo30 } = this.state.periodDates;\n\n const itemElsByPeriod = this.props.items.reduce(\n (result, item, index) => {\n let periodKey;\n const itemEl = this.props.renderItem(item, index);\n // NOTE: Backward compatibility for immutable objects in list\n const pathToCreatedAt = get(item, this.props.pathToCreatedAt);\n const itemAt = moment(pathToCreatedAt);\n\n if (itemAt >= hoursAgo12) {\n periodKey = 'newerThan12Hours';\n } else if (itemAt < hoursAgo12 && itemAt >= daysAgo1) {\n periodKey = 'olderThan12Hours';\n } else if (itemAt < daysAgo1 && itemAt >= daysAgo7) {\n periodKey = 'olderThan1Days';\n } else if (itemAt < daysAgo7 && itemAt >= daysAgo14) {\n periodKey = 'olderThan7Days';\n } else if (itemAt < daysAgo14 && itemAt >= daysAgo30) {\n periodKey = 'olderThan14Days';\n } else if (itemAt < daysAgo30) {\n periodKey = 'olderThan30Days';\n }\n\n return set(result, [periodKey, result[periodKey].length], itemEl);\n },\n {\n newerThan12Hours: [],\n olderThan12Hours: [],\n olderThan1Days: [],\n olderThan7Days: [],\n olderThan14Days: [],\n olderThan30Days: [],\n }\n );\n\n const itemElsWithPeriodEls = Object.keys(itemElsByPeriod).reduce((result, periodEls) => {\n if (itemElsByPeriod[periodEls].length === 0) return result.concat(itemElsByPeriod[periodEls]);\n\n return result.concat([this.renderPeriodSeparator(periodEls), ...itemElsByPeriod[periodEls]]);\n }, []);\n\n const itemElsWithPeriodElsWithHeaderEl = [this.props.headerComponent, ...itemElsWithPeriodEls];\n\n return itemElsWithPeriodElsWithHeaderEl;\n }\n\n render() {\n return (\n <div\n className={classNames(styles.cInfiniteList, this.props.infiniteClassName, {\n [styles.cInfiniteListOverflow]: !this.props.useWindow,\n })}\n style={{ height: this.props.infiniteContainerHeight }}\n >\n <InfiniteScroll\n loadMore={this.loadItems}\n hasMore={this.props.moreItemsMayExist && !this.props.showNoItemsFound}\n threshold={this.props.threshold} // NOTE: We should load infinite scroll next page before user get to bottom\n loader={<LoadingIndicator key=\"c-infinite-scroll__loader\" fullscreen={false} />}\n useWindow={this.props.useWindow}\n initialLoad={this.props.initialLoad}\n >\n {this.renderItems()}\n </InfiniteScroll>\n\n {this.props.showNoItemsFound && this.renderNoItemsLabel()}\n </div>\n );\n }\n}\n\nInfiniteList.propTypes = {\n infiniteClassName: PropTypes.string,\n useWindow: PropTypes.bool,\n headerComponent: PropTypes.node,\n // NOTE: Backward compatibility with immutable;\n // Remove when get rid of immutablejs\n items: PropTypes.arrayOf(PropTypes.shape()).isRequired,\n showNoItemsFound: PropTypes.bool.isRequired,\n noItemsFoundLabel: PropTypes.string.isRequired,\n infiniteContainerHeight: PropTypes.number,\n moreItemsMayExist: PropTypes.bool.isRequired,\n pathToCreatedAt: PropTypes.arrayOf(PropTypes.string).isRequired,\n renderItem: PropTypes.func.isRequired,\n loadItems: PropTypes.func.isRequired,\n threshold: PropTypes.number,\n initialLoad: PropTypes.bool,\n divideByPeriods: PropTypes.bool,\n};\n\nInfiniteList.defaultProps = {\n infiniteClassName: null,\n useWindow: false,\n headerComponent: null,\n infiniteContainerHeight: null,\n threshold: 3000,\n initialLoad: true,\n divideByPeriods: true,\n};\n\nexport default InfiniteList;\n"],"names":["grey700","grey","PERIOD_LABELS","newerThan12Hours","olderThan12Hours","olderThan1Days","olderThan7Days","olderThan14Days","olderThan30Days","InfiniteList","_PureComponent","_inherits","_super","_createSuper","props","_this","_classCallCheck","this","call","_defineProperty","_assertThisInitialized","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_context","prev","next","state","isLoadingByScroll","abrupt","setState","loadItems","stop","periodDates","updatePeriodsIntervalId","_createClass","key","value","_this2","setInterval","clearInterval","get","hoursAgo12","moment","subtract","daysAgo1","daysAgo7","daysAgo14","daysAgo30","_jsx","concat","className","styles","cInfiniteListEmpty","children","noItemsFoundLabel","periodKey","cInfiniteListPeriod","style","color","_this3","divideByPeriods","items","map","item","renderItem","unshift","headerComponent","_this$state$periodDat","itemElsByPeriod","reduce","result","index","itemEl","pathToCreatedAt","itemAt","set","length","itemElsWithPeriodEls","Object","keys","periodEls","renderPeriodSeparator","_jsxs","classNames","cInfiniteList","infiniteClassName","cInfiniteListOverflow","useWindow","height","infiniteContainerHeight","InfiniteScroll","loadMore","hasMore","moreItemsMayExist","showNoItemsFound","threshold","loader","LoadingIndicator","fullscreen","initialLoad","renderItems","renderNoItemsLabel","PureComponent","propTypes","PropTypes","string","bool","node","arrayOf","shape","isRequired","number","func","defaultProps"],"mappings":"26CAYA,IAEMA,OAAUC,QAAK,KAGfC,EAAgB,CACpBC,iBAAkB,gBAClBC,iBAAkB,gBAClBC,eAAgB,oBAChBC,eAAgB,oBAChBC,gBAAiB,qBACjBC,gBAAiB,sBAIbC,EAAY,SAAAC,GAAAC,UAAAF,EAAAC,GAAA,IAAAE,EAAAC,EAAAJ,GAChB,SAAAA,EAAYK,GAAO,IAAAC,EASmB,OATnBC,UAAAC,KAAAR,GACjBM,EAAAH,EAAAM,KAAAD,KAAMH,GAAOK,UAyCHC,EAAAA,QAAAL,GAAA,YAAAM,EAAAA,QAAAC,EAAA,QAAAC,MAAA,SAAAC,IAAA,OAAAF,UAAAG,MAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,IACNb,EAAKc,MAAMC,kBAAiB,CAAAJ,EAAAE,KAAA,EAAA,KAAA,CAAA,OAAAF,EAAAK,OAAA,UAAA,KAAA,EAIW,OAA3ChB,EAAKiB,SAAS,CAAEF,mBAAmB,IAAQJ,EAAAE,KAAA,EAErCb,EAAKD,MAAMmB,YAAW,KAAA,EAE5BlB,EAAKiB,SAAS,CAAEF,mBAAmB,IAAS,KA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AA,EAAAA,EAAOmC,uBAAyBxE,KAAKH,MAAM4E,YAE9C9B,MAAO,CAAE+B,OAAQ1E,KAAKH,MAAM8E,yBAA0BpC,SAAA,CAEtDL,MAAC0C,UAAc,CACbC,SAAU7E,KAAKgB,UACf8D,QAAS9E,KAAKH,MAAMkF,oBAAsB/E,KAAKH,MAAMmF,iBACrDC,UAAWjF,KAAKH,MAAMoF,UACtBC,OAAQhD,MAACiD,EAAgB,CAAiCC,YAAY,GAAxC,6BAC9BX,UAAWzE,KAAKH,MAAM4E,UACtBY,YAAarF,KAAKH,MAAMwF,YAAY9C,SAEnCvC,KAAKsF,gBAGPtF,KAAKH,MAAMmF,kBAAoBhF,KAAKuF,uBAG3C,KAAC/F,CAAA,CA5Je,CAASgG,iBA+J3BhG,EAAaiG,UAAY,CACvBlB,kBAAmBmB,EAAS,QAACC,OAC7BlB,UAAWiB,EAAS,QAACE,KACrBxC,gBAAiBsC,EAAS,QAACG,KAG3B9C,MAAO2C,EAAS,QAACI,QAAQJ,EAAS,QAACK,SAASC,WAC5ChB,iBAAkBU,EAAAA,QAAUE,KAAKI,WACjCxD,kBAAmBkD,EAAAA,QAAUC,OAAOK,WACpCrB,wBAAyBe,EAAS,QAACO,OACnClB,kBAAmBW,EAAAA,QAAUE,KAAKI,WAClCrC,gBAAiB+B,EAAAA,QAAUI,QAAQJ,EAAAA,QAAUC,QAAQK,WACrD9C,WAAYwC,EAAAA,QAAUQ,KAAKF,WAC3BhF,UAAW0E,EAAAA,QAAUQ,KAAKF,WAC1Bf,UAAWS,EAAS,QAACO,OACrBZ,YAAaK,EAAS,QAACE,KACvB9C,gBAAiB4C,EAAS,QAACE,MAG7BpG,EAAa2G,aAAe,CAC1B5B,kBAAmB,KACnBE,WAAW,EACXrB,gBAAiB,KACjBuB,wBAAyB,KACzBM,UAAW,IACXI,aAAa,EACbvC,iBAAiB"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/InfiniteList/index.js"],"sourcesContent":["import { memo, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport moment from 'moment';\nimport classNames from 'classnames';\nimport { get, set } from 'lodash';\nimport InfiniteScroll from 'react-infinite-scroller';\nimport grey from '@material-ui/core/colors/grey';\n\nimport styles from './styles.css';\n\nimport LoadingIndicator from '~components/LoadingIndicator';\n\nconst PAGE_NAME = 'generic_infiniteList';\n\nconst grey700 = grey['700'];\n\nconst INTERVAL_6_HOURS = 6 * 60 * 60 * 1000;\nconst PERIOD_LABELS = {\n newerThan12Hours: 'Last 12 hours',\n olderThan12Hours: 'Last 24 hours',\n olderThan1Days: 'Earlier this week',\n olderThan7Days: 'Older than 7 days',\n olderThan14Days: 'Older than 14 days',\n olderThan30Days: 'Older than 30 days',\n};\n\nconst getPeriodDates = () => ({\n hoursAgo12: moment().subtract(12, 'hours'),\n daysAgo1: moment().subtract(1, 'days'),\n daysAgo7: moment().subtract(7, 'days'),\n daysAgo14: moment().subtract(14, 'days'),\n daysAgo30: moment().subtract(30, 'days'),\n});\n\n/** @param {any} props Preserve the legacy component's permissive public prop type. */\nfunction InfiniteList({\n infiniteClassName = null,\n useWindow = false,\n headerComponent = null,\n items,\n showNoItemsFound,\n noItemsFoundLabel,\n infiniteContainerHeight = null,\n moreItemsMayExist,\n pathToCreatedAt,\n renderItem,\n loadItems,\n threshold = 3000,\n initialLoad = true,\n divideByPeriods = true,\n}) {\n const [isLoadingByScroll, setIsLoadingByScroll] = useState(false);\n const [periodDates, setPeriodDates] = useState(getPeriodDates);\n\n useEffect(() => {\n const intervalId = setInterval(() => setPeriodDates(getPeriodDates()), INTERVAL_6_HOURS);\n return () => clearInterval(intervalId);\n }, []);\n\n // NOTE: 'react-infinite-scroller' has a bug that when scroll reaches threshold area, it starts\n // to fire loadMore on every scroll event - bottom, up. As a result multiple same request fired.\n //\n // We fix this preventing request that was fired by scroll before previous is finished.\n //\n // Issues:\n // https://github.com/CassetteRocks/react-infinite-scroller/issues/143\n const loadMore = async () => {\n if (isLoadingByScroll) {\n return;\n }\n\n setIsLoadingByScroll(true);\n\n await loadItems();\n\n setIsLoadingByScroll(false);\n };\n\n const renderNoItemsLabel = () => {\n return (\n <div\n data-testid={`${PAGE_NAME}_noItems`}\n key=\"c-infinite-list__empty\"\n className={styles.cInfiniteListEmpty}\n >\n {noItemsFoundLabel}\n </div>\n );\n };\n\n const renderPeriodSeparator = periodKey => {\n return (\n <div\n data-testid={`${PAGE_NAME}_periodLabel`}\n key={periodKey}\n className={styles.cInfiniteListPeriod}\n style={{ color: grey700 }}\n >\n {PERIOD_LABELS[periodKey]}\n </div>\n );\n };\n\n const renderItems = () => {\n if (!divideByPeriods) {\n return items.map(item => renderItem(item)).unshift(headerComponent);\n }\n\n const { hoursAgo12, daysAgo1, daysAgo7, daysAgo14, daysAgo30 } = periodDates;\n\n const itemElsByPeriod = items.reduce(\n (result, item, index) => {\n let periodKey;\n const itemEl = renderItem(item, index);\n // NOTE: Backward compatibility for immutable objects in list\n const itemCreatedAt = get(item, pathToCreatedAt);\n const itemAt = moment(itemCreatedAt);\n\n if (itemAt >= hoursAgo12) {\n periodKey = 'newerThan12Hours';\n } else if (itemAt < hoursAgo12 && itemAt >= daysAgo1) {\n periodKey = 'olderThan12Hours';\n } else if (itemAt < daysAgo1 && itemAt >= daysAgo7) {\n periodKey = 'olderThan1Days';\n } else if (itemAt < daysAgo7 && itemAt >= daysAgo14) {\n periodKey = 'olderThan7Days';\n } else if (itemAt < daysAgo14 && itemAt >= daysAgo30) {\n periodKey = 'olderThan14Days';\n } else if (itemAt < daysAgo30) {\n periodKey = 'olderThan30Days';\n }\n\n return set(result, [periodKey, result[periodKey].length], itemEl);\n },\n {\n newerThan12Hours: [],\n olderThan12Hours: [],\n olderThan1Days: [],\n olderThan7Days: [],\n olderThan14Days: [],\n olderThan30Days: [],\n }\n );\n\n const itemElsWithPeriodEls = Object.keys(itemElsByPeriod).reduce((result, periodEls) => {\n if (itemElsByPeriod[periodEls].length === 0) return result.concat(itemElsByPeriod[periodEls]);\n\n return result.concat([renderPeriodSeparator(periodEls), ...itemElsByPeriod[periodEls]]);\n }, []);\n\n const itemElsWithPeriodElsWithHeaderEl = [headerComponent, ...itemElsWithPeriodEls];\n\n return itemElsWithPeriodElsWithHeaderEl;\n };\n\n return (\n <div\n className={classNames(styles.cInfiniteList, infiniteClassName, {\n [styles.cInfiniteListOverflow]: !useWindow,\n })}\n style={{ height: infiniteContainerHeight }}\n >\n <InfiniteScroll\n loadMore={loadMore}\n hasMore={moreItemsMayExist && !showNoItemsFound}\n threshold={threshold} // NOTE: We should load infinite scroll next page before user get to bottom\n loader={<LoadingIndicator key=\"c-infinite-scroll__loader\" fullscreen={false} />}\n useWindow={useWindow}\n initialLoad={initialLoad}\n >\n {renderItems()}\n </InfiniteScroll>\n\n {showNoItemsFound && renderNoItemsLabel()}\n </div>\n );\n}\n\nInfiniteList.propTypes = {\n infiniteClassName: PropTypes.string,\n useWindow: PropTypes.bool,\n headerComponent: PropTypes.node,\n // NOTE: Backward compatibility with immutable;\n // Remove when get rid of immutablejs\n items: PropTypes.arrayOf(PropTypes.shape()).isRequired,\n showNoItemsFound: PropTypes.bool.isRequired,\n noItemsFoundLabel: PropTypes.string.isRequired,\n infiniteContainerHeight: PropTypes.number,\n moreItemsMayExist: PropTypes.bool.isRequired,\n pathToCreatedAt: PropTypes.arrayOf(PropTypes.string).isRequired,\n renderItem: PropTypes.func.isRequired,\n loadItems: PropTypes.func.isRequired,\n threshold: PropTypes.number,\n initialLoad: PropTypes.bool,\n divideByPeriods: PropTypes.bool,\n};\n\nexport default memo(InfiniteList);\n"],"names":["grey700","grey","PERIOD_LABELS","newerThan12Hours","olderThan12Hours","olderThan1Days","olderThan7Days","olderThan14Days","olderThan30Days","getPeriodDates","hoursAgo12","moment","subtract","daysAgo1","daysAgo7","daysAgo14","daysAgo30","InfiniteList","_ref","_ref$infiniteClassNam","infiniteClassName","_ref$useWindow","useWindow","_ref$headerComponent","headerComponent","items","showNoItemsFound","noItemsFoundLabel","_ref$infiniteContaine","infiniteContainerHeight","moreItemsMayExist","pathToCreatedAt","renderItem","loadItems","_ref$threshold","threshold","_ref$initialLoad","initialLoad","_ref$divideByPeriods","divideByPeriods","useState","_useState2","_slicedToArray","_useState","isLoadingByScroll","setIsLoadingByScroll","_useState4","_useState3","periodDates","setPeriodDates","useEffect","intervalId","setInterval","clearInterval","_ref2","loadMore","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_context","prev","next","abrupt","stop","apply","this","arguments","_jsxs","className","classNames","styles","cInfiniteList","_defineProperty","cInfiniteListOverflow","style","height","children","_jsx","InfiniteScroll","hasMore","loader","LoadingIndicator","fullscreen","map","item","unshift","itemElsByPeriod","reduce","result","index","periodKey","itemEl","itemCreatedAt","get","itemAt","set","length","itemElsWithPeriodEls","Object","keys","periodEls","concat","cInfiniteListPeriod","color","_toConsumableArray","renderItems","cInfiniteListEmpty","propTypes","PropTypes","string","bool","node","arrayOf","shape","isRequired","number","func","memo"],"mappings":"gsBAcMA,OAAUC,QAAK,KAGfC,EAAgB,CACpBC,iBAAkB,gBAClBC,iBAAkB,gBAClBC,eAAgB,oBAChBC,eAAgB,oBAChBC,gBAAiB,qBACjBC,gBAAiB,sBAGbC,EAAiB,WAAH,MAAU,CAC5BC,WAAYC,EAAAA,UAASC,SAAS,GAAI,SAClCC,SAAUF,EAAAA,UAASC,SAAS,EAAG,QAC/BE,SAAUH,EAAAA,UAASC,SAAS,EAAG,QAC/BG,UAAWJ,EAAAA,UAASC,SAAS,GAAI,QACjCI,UAAWL,EAAAA,UAASC,SAAS,GAAI,QAClC,EAGD,SAASK,EAeNC,GAAA,IAAAC,EAAAD,EAdDE,kBAAAA,aAAoB,KAAID,EAAAE,EAAAH,EACxBI,UAAAA,cAAiBD,EAAAE,EAAAL,EACjBM,gBAAAA,aAAkB,KAAID,EACtBE,IAAAA,MACAC,IAAAA,iBACAC,IAAAA,kBAAiBC,EAAAV,EACjBW,wBAAAA,aAA0B,KAAID,EAC9BE,IAAAA,kB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A,EAAgBc,MAzDjD,IAAAV,CA0D3B,GAAE,IAIH,MAFsC,CAAIpE,GAAe+E,OAAAG,EAAA,QAAKP,IAoBzDQ,KAGFjF,GA7FDqD,EAAAA,IAAA,MAAA,CACE,cAAA,GAAAwB,OArEU,uBAqE0B,YAEpCjC,UAAWE,EAAOoC,mBAAmB9B,SAEpCnD,GAHG,4BA8FZ,CAEAV,EAAa4F,UAAY,CACvBzF,kBAAmB0F,EAAS,QAACC,OAC7BzF,UAAWwF,EAAS,QAACE,KACrBxF,gBAAiBsF,EAAS,QAACG,KAG3BxF,MAAOqF,EAAS,QAACI,QAAQJ,EAAS,QAACK,SAASC,WAC5C1F,iBAAkBoF,EAAAA,QAAUE,KAAKI,WACjCzF,kBAAmBmF,EAAAA,QAAUC,OAAOK,WACpCvF,wBAAyBiF,EAAS,QAACO,OACnCvF,kBAAmBgF,EAAAA,QAAUE,KAAKI,WAClCrF,gBAAiB+E,EAAAA,QAAUI,QAAQJ,EAAAA,QAAUC,QAAQK,WACrDpF,WAAY8E,EAAAA,QAAUQ,KAAKF,WAC3BnF,UAAW6E,EAAAA,QAAUQ,KAAKF,WAC1BjF,UAAW2E,EAAS,QAACO,OACrBhF,YAAayE,EAAS,QAACE,KACvBzE,gBAAiBuE,EAAS,QAACE,MAG7B,IAAeO,EAAAA,EAAAA,KAAKtG"}
@@ -1,2 +1,2 @@
1
- "use strict";var e=require("@babel/runtime/helpers/classCallCheck"),t=require("@babel/runtime/helpers/createClass"),l=require("@babel/runtime/helpers/assertThisInitialized"),i=require("@babel/runtime/helpers/inherits"),a=require("@babel/runtime/helpers/possibleConstructorReturn"),r=require("@babel/runtime/helpers/getPrototypeOf"),s=require("@babel/runtime/helpers/defineProperty"),o=require("react"),n=require("prop-types"),d=require("@material-ui/core/styles"),u=require("@material-ui/core/Paper"),c=require("@material-ui/core/DialogActions"),f=require("@material-ui/core/DialogContent"),p=require("@material-ui/core/DialogTitle"),h=require("@material-ui/core/Button"),m=require("@material-ui/core/Typography"),g=require("@material-ui/core/Input"),x=require("@material-ui/core/RootRef"),j=require("@material-ui/core/colors/grey"),U=require("@material-ui/icons/Delete"),v=require("@material-ui/core"),y=require("../../utils/fileExtension.js"),F=require("./styles.css.js"),N=require("../FileTypeIcon.js"),q=require("../EmojiIconButton.js"),D=require("../FileUploadIconButton.js"),S=require("../FailedFileUploading.js"),b=require("../UserMention/index.js"),C=require("../../utils/mobileDetect.js"),E=require("react/jsx-runtime");function R(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var P=R(e),B=R(t),w=R(l),I=R(i),k=R(a),T=R(r),z=R(s),A=R(n),M=R(u),W=R(c),_=R(f),O=R(p),K=R(h),H=R(m),L=R(g),G=R(x),J=R(j),Q=R(U);function V(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var l,i=T.default(e);if(t){var a=T.default(this).constructor;l=Reflect.construct(i,arguments,a)}else l=i.apply(this,arguments);return k.default(this,l)}}var X="PostPreviewDialog",Y=J.default[200],Z=J.default[400],$=function(e){return E.jsxs(M.default,{className:e.classes.messageWrapper,children:[E.jsx(L.default,{"data-testid":"".concat(X,"_messageInput"),inputRef:e.inputEl,inputComponent:b,inputProps:{withLightTheme:!1,onChange:e.handleMessageChange,companyId:e.companyId,suggestionsPortalHost:e.rootRef.current},placeholder:"Add a message about the file...",fullWidth:!0,disableUnderline:!0,multiline:!0,rows:"3",className:e.classes.textFieldRoot,value:e.comment,onKeyDown:e.handleKeyDown}),E.jsxs("div",{className:F.cPostPreviewDialogMessageAdditionalFieldsWrapper,children:[E.jsx("div",{children:e.additionalFields}),E.jsxs("div",{className:F.cPostPreviewDialogMessageActionFields,children:[!e.fileUrl&&E.jsx(D.default,{htmlColor:J.default[400],openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:e.handleFileUpload,onError:e.handleFileUploadingError,inputId:"preview-dialog-file-upload"}),E.jsx(q,{handleSelectEmoji:e.handleSelectEmoji,emojiIconClassName:e.classes.additionalActionButton,htmlColor:J.default[400],disableRipple:!0})]})]})]})},ee=function(e){return y.getIsImage(e.fileName)?E.jsxs("div",{children:[E.jsxs("div",{className:F.cPostPreviewDialogFileName,children:[E.jsx(H.default,{"data-testid":"".concat(X,"_fileName"),variant:"subtitle2",noWrap:!0,gutterBottom:!0,children:e.fileName}),E.jsx(Q.default,{"data-testid":"".concat(X,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]}),E.jsx("div",{className:F.cPostPreviewDialogFileImageFileWrapper,children:E.jsx("img",{"data-testid":"".concat(X,"_previewImage"),className:F.cPostPreviewDialogFileImage,src:e.fileUrl,alt:"Uploaded file"})})]}):E.jsxs("div",{className:F.cPostPreviewDialogFileDownload,style:{backgroundColor:Y,border:"1px solid ".concat(Z)},children:[E.jsx(N,{fileName:e.fileName}),E.jsxs("div",{className:F.cPostPreviewDialogFileDownloadText,children:[E.jsx(H.default,{"data-testid":"".concat(X,"_fileName"),variant:"subtitle2",noWrap:!0,children:e.fileName}),E.jsx(Q.default,{"data-testid":"".concat(X,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]})]})},te=function(e){I.default(l,e);var t=V(l);function l(e){var i;return P.default(this,l),i=t.call(this,e),z.default(w.default(i),"focusOnInput",(function(){return i.inputEl.current.focus()})),z.default(w.default(i),"handleKeyDown",(function(e){"Enter"===e.key&&i.handleShare()})),z.default(w.default(i),"handleMessageChange",(function(e){return i.setState({comment:e})})),z.default(w.default(i),"handleSelectEmoji",(function(e){return i.setState((function(t){var l=t.comment;return{comment:"".concat(l).concat(e.native)}}))})),z.default(w.default(i),"handleShare",(function(){i.props.handleShare(i.state.comment,i.state.fileUrl,i.state.fileSize,i.state.fileName)})),z.default(w.default(i),"handleFileDelete",(function(){i.setState({fileUrl:"",fileSize:null,fileName:""})})),z.default(w.default(i),"handleFileUpload",(function(e,t,l){i.setState({fileUrl:e,fileName:t,fileSize:l,fileUploadingError:null})})),z.default(w.default(i),"handleFileUploadingError",(function(e){i.setState({fileUrl:null,fileName:null,fileSize:null,fileUploadingError:e})})),i.state={comment:e.message,fileUrl:e.fileUrl,fileSize:e.fileSize,fileName:e.fileName,fileUploadingError:null},i.inputEl=o.createRef(),i.rootRef=o.createRef(),i}return B.default(l,[{key:"componentDidUpdate",value:function(e){!e.open&&this.props.open&&!this.state.comment&&this.props.message&&this.setState({comment:this.props.message}),this.props.fileUrl===e.fileUrl&&this.props.fileSize===e.fileSize&&this.props.fileName===e.fileName||this.setState({fileUrl:this.props.fileUrl,fileSize:this.props.fileSize,fileName:this.props.fileName})}},{key:"render",value:function(){return E.jsx(G.default,{rootRef:this.rootRef,children:E.jsxs(v.Dialog,{fullScreen:C.isNativeDetected,open:this.props.open,onClose:this.props.handleClose,onBackdropClick:this.props.handleClose,onEntered:this.focusOnInput,children:[E.jsx(O.default,{children:this.props.title}),E.jsxs(_.default,{classes:{root:!C.isNativeDetected&&this.props.classes.dialogContentRoot},children:[E.jsx($,{inputEl:this.inputEl,comment:this.state.comment,handleMessageChange:this.handleMessageChange,handleKeyDown:this.handleKeyDown,handleFileUpload:this.handleFileUpload,handleSelectEmoji:this.handleSelectEmoji,handleFileUploadingError:this.handleFileUploadingError,additionalFields:this.props.additionalFields,fileUrl:this.state.fileUrl,classes:this.props.classes,companyId:this.props.companyId,rootRef:this.rootRef}),this.state.fileUploadingError&&E.jsx(S,{errorMessage:this.state.fileUploadingError,className:this.props.classes.fileUploadingError}),this.state.fileUrl&&E.jsx(ee,{fileName:this.state.fileName,fileUrl:this.state.fileUrl,handleFileDelete:this.handleFileDelete,handleFileUploadingError:this.handleFileUploadingError,classes:this.props.classes})]}),E.jsxs(W.default,{className:this.props.classes.dialogActions,children:[E.jsx(K.default,{"data-testid":"".concat(X,"_cancelButton"),color:"primary",onClick:this.props.handleClose,children:this.props.cancelButtonText}),E.jsx(K.default,{"data-testid":"".concat(X,"_okButton"),color:"primary",variant:"contained",disabled:!this.state.fileUrl&&!this.state.comment||!this.props.requiredFields.every(Boolean),onClick:this.handleShare,children:this.props.okButtonText})]})]})})}}]),l}(o.PureComponent);te.propTypes={title:A.default.string,open:A.default.bool.isRequired,fileUrl:A.default.string,fileName:A.default.string,fileSize:A.default.number,handleShare:A.default.func.isRequired,handleClose:A.default.func.isRequired,classes:A.default.shape({}).isRequired,additionalFields:A.default.arrayOf(A.default.node),requiredFields:A.default.arrayOf(A.default.string),message:A.default.string,companyId:A.default.number,okButtonText:A.default.string,cancelButtonText:A.default.string},te.defaultProps={title:"Share a file",fileUrl:"",fileName:"",fileSize:null,additionalFields:[],requiredFields:[],message:"",companyId:null,okButtonText:"Post",cancelButtonText:"Cancel"};var le=d.withStyles((function(e){return{dialogContentRoot:{minWidth:500},textFieldRoot:{marginBottom:20},textInput:{paddingTop:2},messageWrapper:{padding:"18.5px 14px",border:"solid 1px ".concat(e.palette.primary.main),boxShadow:"none"},dialogActions:{padding:"24px 24px",margin:0},deleteButton:{color:"#DADADA",cursor:"pointer"},fileUploadingError:{marginTop:10}}}))(te);module.exports=le;
1
+ "use strict";var e=require("@babel/runtime/helpers/defineProperty"),i=require("@babel/runtime/helpers/slicedToArray"),l=require("react"),t=require("prop-types"),r=require("@material-ui/core/styles"),a=require("@material-ui/core/Paper"),n=require("@material-ui/core/DialogActions"),o=require("@material-ui/core/DialogContent"),s=require("@material-ui/core/DialogTitle"),d=require("@material-ui/core/Button"),c=require("@material-ui/core/Typography"),u=require("@material-ui/core/Input"),f=require("@material-ui/core/RootRef"),m=require("@material-ui/core/colors/grey"),p=require("@material-ui/icons/Delete"),g=require("@material-ui/core"),h=require("../../utils/fileExtension.js"),j=require("./styles.css.js"),v=require("../FileTypeIcon.js"),x=require("../EmojiIconButton.js"),y=require("../FileUploadIconButton.js"),b=require("../FailedFileUploading.js"),N=require("../UserMention/index.js"),U=require("../../utils/mobileDetect.js"),D=require("react/jsx-runtime");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var P=q(e),F=q(i),w=q(t),C=q(a),E=q(n),S=q(o),O=q(s),B=q(d),R=q(c),I=q(u),k=q(f),T=q(m),z=q(p);function A(e,i){var l=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);i&&(t=t.filter((function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable}))),l.push.apply(l,t)}return l}function W(e){for(var i=1;i<arguments.length;i++){var l=null!=arguments[i]?arguments[i]:{};i%2?A(Object(l),!0).forEach((function(i){P.default(e,i,l[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(l)):A(Object(l)).forEach((function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(l,i))}))}return e}var _="PostPreviewDialog",M=T.default[200],K=T.default[400],L=function(e){return D.jsxs(C.default,{className:e.classes.messageWrapper,children:[D.jsx(I.default,{"data-testid":"".concat(_,"_messageInput"),inputRef:e.inputEl,inputComponent:N,inputProps:{withLightTheme:!1,onChange:e.handleMessageChange,companyId:e.companyId,suggestionsPortalHost:e.rootRef.current},placeholder:"Add a message about the file...",fullWidth:!0,disableUnderline:!0,multiline:!0,rows:"3",className:e.classes.textFieldRoot,value:e.comment,onKeyDown:e.handleKeyDown}),D.jsxs("div",{className:j.cPostPreviewDialogMessageAdditionalFieldsWrapper,children:[D.jsx("div",{children:e.additionalFields}),D.jsxs("div",{className:j.cPostPreviewDialogMessageActionFields,children:[!e.fileUrl&&D.jsx(y.default,{htmlColor:T.default[400],openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:e.handleFileUpload,onError:e.handleFileUploadingError,inputId:"preview-dialog-file-upload"}),D.jsx(x,{handleSelectEmoji:e.handleSelectEmoji,emojiIconClassName:e.classes.additionalActionButton,htmlColor:T.default[400],disableRipple:!0})]})]})]})},H=function(e){return h.getIsImage(e.fileName)?D.jsxs("div",{children:[D.jsxs("div",{className:j.cPostPreviewDialogFileName,children:[D.jsx(R.default,{"data-testid":"".concat(_,"_fileName"),variant:"subtitle2",noWrap:!0,gutterBottom:!0,children:e.fileName}),D.jsx(z.default,{"data-testid":"".concat(_,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]}),D.jsx("div",{className:j.cPostPreviewDialogFileImageFileWrapper,children:D.jsx("img",{"data-testid":"".concat(_,"_previewImage"),className:j.cPostPreviewDialogFileImage,src:e.fileUrl,alt:"Uploaded file"})})]}):D.jsxs("div",{className:j.cPostPreviewDialogFileDownload,style:{backgroundColor:M,border:"1px solid ".concat(K)},children:[D.jsx(v,{fileName:e.fileName}),D.jsxs("div",{className:j.cPostPreviewDialogFileDownloadText,children:[D.jsx(R.default,{"data-testid":"".concat(_,"_fileName"),variant:"subtitle2",noWrap:!0,children:e.fileName}),D.jsx(z.default,{"data-testid":"".concat(_,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]})]})},G=[];function J(e){var i=e.title,t=void 0===i?"Share a file":i,r=e.open,a=e.fileUrl,n=void 0===a?"":a,o=e.fileName,s=void 0===o?"":o,d=e.fileSize,c=void 0===d?null:d,u=e.handleShare,f=e.handleClose,m=e.classes,p=e.additionalFields,h=void 0===p?G:p,j=e.requiredFields,v=void 0===j?G:j,x=e.message,y=void 0===x?"":x,N=e.companyId,q=void 0===N?null:N,P=e.okButtonText,w=void 0===P?"Post":P,C=e.cancelButtonText,R=void 0===C?"Cancel":C,I=l.useState((function(){return{comment:y,fileUrl:n,fileSize:c,fileName:s,fileUploadingError:null}})),T=F.default(I,2),z=T[0],A=T[1],M=l.useRef(null),K=l.useRef(null),J=l.useRef({open:r,fileUrl:n,fileSize:c,fileName:s});l.useLayoutEffect((function(){var e=J.current;J.current={open:r,fileUrl:n,fileSize:c,fileName:s};var i=!e.open&&r&&!z.comment&&y,l=n!==e.fileUrl||c!==e.fileSize||s!==e.fileName;(i||l)&&A((function(e){return W(W(W({},e),i?{comment:y}:{}),l?{fileUrl:n,fileSize:c,fileName:s}:{})}))}),[r,n,c,s,y,z.comment]);var Q=function(){return u(z.comment,z.fileUrl,z.fileSize,z.fileName)},V=l.useCallback((function(e){return A((function(i){return W(W({},i),{},{comment:"".concat(i.comment).concat(e.native)})}))}),[]),X=l.useCallback((function(e,i,l){return A((function(t){return W(W({},t),{},{fileUrl:e,fileName:i,fileSize:l,fileUploadingError:null})}))}),[]),Y=l.useCallback((function(e){return A((function(i){return W(W({},i),{},{fileUrl:null,fileName:null,fileSize:null,fileUploadingError:e})}))}),[]);return D.jsx(k.default,{rootRef:K,children:D.jsxs(g.Dialog,{fullScreen:U.isNativeDetected,open:r,onClose:f,onBackdropClick:f,onEntered:function(){return M.current.focus()},children:[D.jsx(O.default,{children:t}),D.jsxs(S.default,{classes:{root:!U.isNativeDetected&&m.dialogContentRoot},children:[D.jsx(L,{inputEl:M,comment:z.comment,handleMessageChange:function(e){return A((function(i){return W(W({},i),{},{comment:e})}))},handleKeyDown:function(e){"Enter"===e.key&&Q()},handleFileUpload:X,handleSelectEmoji:V,handleFileUploadingError:Y,additionalFields:h,fileUrl:z.fileUrl,classes:m,companyId:q,rootRef:K}),z.fileUploadingError&&D.jsx(b,{errorMessage:z.fileUploadingError,className:m.fileUploadingError}),z.fileUrl&&D.jsx(H,{fileName:z.fileName,fileUrl:z.fileUrl,handleFileDelete:function(){return A((function(e){return W(W({},e),{},{fileUrl:"",fileSize:null,fileName:""})}))},handleFileUploadingError:Y,classes:m})]}),D.jsxs(E.default,{className:m.dialogActions,children:[D.jsx(B.default,{"data-testid":"".concat(_,"_cancelButton"),color:"primary",onClick:f,children:R}),D.jsx(B.default,{"data-testid":"".concat(_,"_okButton"),color:"primary",variant:"contained",disabled:!z.fileUrl&&!z.comment||!v.every(Boolean),onClick:Q,children:w})]})]})})}J.propTypes={title:w.default.string,open:w.default.bool.isRequired,fileUrl:w.default.string,fileName:w.default.string,fileSize:w.default.number,handleShare:w.default.func.isRequired,handleClose:w.default.func.isRequired,classes:w.default.shape({}).isRequired,additionalFields:w.default.arrayOf(w.default.node),requiredFields:w.default.arrayOf(w.default.string),message:w.default.string,companyId:w.default.number,okButtonText:w.default.string,cancelButtonText:w.default.string};var Q=r.withStyles((function(e){return{dialogContentRoot:{minWidth:500},textFieldRoot:{marginBottom:20},textInput:{paddingTop:2},messageWrapper:{padding:"18.5px 14px",border:"solid 1px ".concat(e.palette.primary.main),boxShadow:"none"},dialogActions:{padding:"24px 24px",margin:0},deleteButton:{color:"#DADADA",cursor:"pointer"},fileUploadingError:{marginTop:10}}}))(l.memo(J));module.exports=Q;
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/components/PostPreviewDialog/index.js"],"sourcesContent":["import { createRef, PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Paper from '@material-ui/core/Paper';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport Button from '@material-ui/core/Button';\nimport Typography from '@material-ui/core/Typography';\nimport Input from '@material-ui/core/Input';\nimport RootRef from '@material-ui/core/RootRef';\nimport grey from '@material-ui/core/colors/grey';\nimport DeleteIcon from '@material-ui/icons/Delete';\nimport { Dialog } from '@material-ui/core';\n\nimport { getIsImage } from '../../utils/fileExtension';\n\nimport styles from './styles.css';\n\nimport FileTypeIcon from '~/components/FileTypeIcon';\nimport EmojiIconButton from '~/components/EmojiIconButton';\nimport FileUploadIconButton from '~/components/FileUploadIconButton';\nimport FailedFileUploading from '~/components/FailedFileUploading';\nimport UserMention from '~/components/UserMention';\nimport { isNativeDetected } from '~/utils/mobileDetect';\n\nconst PAGE_NAME = 'PostPreviewDialog';\n\nconst grey200 = grey[200];\nconst grey400 = grey[400];\n\nconst muiStyles = theme => ({\n dialogContentRoot: { minWidth: 500 },\n textFieldRoot: { marginBottom: 20 },\n textInput: { paddingTop: 2 },\n messageWrapper: {\n padding: '18.5px 14px',\n border: `solid 1px ${theme.palette.primary.main}`,\n boxShadow: 'none',\n },\n dialogActions: {\n padding: '24px 24px',\n margin: 0,\n },\n deleteButton: {\n color: '#DADADA',\n cursor: 'pointer',\n },\n fileUploadingError: {\n marginTop: 10,\n },\n});\n\n/* eslint-disable react/prop-types */\nconst Message = props => (\n <Paper className={props.classes.messageWrapper}>\n <Input\n data-testid={`${PAGE_NAME}_messageInput`}\n inputRef={props.inputEl}\n inputComponent={UserMention}\n inputProps={{\n withLightTheme: false,\n onChange: props.handleMessageChange,\n companyId: props.companyId,\n suggestionsPortalHost: props.rootRef.current,\n }}\n placeholder=\"Add a message about the file...\"\n fullWidth\n disableUnderline\n multiline\n rows=\"3\"\n className={props.classes.textFieldRoot}\n value={props.comment}\n onKeyDown={props.handleKeyDown}\n />\n <div className={styles.cPostPreviewDialogMessageAdditionalFieldsWrapper}>\n <div>{props.additionalFields}</div>\n <div className={styles.cPostPreviewDialogMessageActionFields}>\n {!props.fileUrl && (\n <FileUploadIconButton\n htmlColor={grey[400]}\n openPreviewDialogOnUpload={false}\n disableRipple\n onFinish={props.handleFileUpload}\n onError={props.handleFileUploadingError}\n inputId=\"preview-dialog-file-upload\"\n />\n )}\n <EmojiIconButton\n handleSelectEmoji={props.handleSelectEmoji}\n emojiIconClassName={props.classes.additionalActionButton}\n htmlColor={grey[400]}\n disableRipple\n />\n </div>\n </div>\n </Paper>\n);\n\nconst File = props => {\n const isImage = getIsImage(props.fileName);\n\n return isImage ? (\n <div>\n <div className={styles.cPostPreviewDialogFileName}>\n <Typography data-testid={`${PAGE_NAME}_fileName`} variant=\"subtitle2\" noWrap gutterBottom>\n {props.fileName}\n </Typography>\n <DeleteIcon\n data-testid={`${PAGE_NAME}_deleteButton`}\n color=\"action\"\n onClick={props.handleFileDelete}\n className={props.classes.deleteButton}\n />\n </div>\n <div className={styles.cPostPreviewDialogFileImageFileWrapper}>\n <img\n data-testid={`${PAGE_NAME}_previewImage`}\n className={styles.cPostPreviewDialogFileImage}\n src={props.fileUrl}\n alt=\"Uploaded file\"\n />\n </div>\n </div>\n ) : (\n <div\n className={styles.cPostPreviewDialogFileDownload}\n style={{\n backgroundColor: grey200,\n border: `1px solid ${grey400}`,\n }}\n >\n <FileTypeIcon fileName={props.fileName} />\n <div className={styles.cPostPreviewDialogFileDownloadText}>\n <Typography data-testid={`${PAGE_NAME}_fileName`} variant=\"subtitle2\" noWrap>\n {props.fileName}\n </Typography>\n <DeleteIcon\n data-testid={`${PAGE_NAME}_deleteButton`}\n color=\"action\"\n onClick={props.handleFileDelete}\n className={props.classes.deleteButton}\n />\n </div>\n </div>\n );\n};\n/* eslint-enable react/prop-types */\n\nclass FileUploadPreviewDialog extends PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n comment: props.message,\n fileUrl: props.fileUrl,\n fileSize: props.fileSize,\n fileName: props.fileName,\n fileUploadingError: null,\n };\n\n this.inputEl = createRef();\n this.rootRef = createRef();\n }\n\n componentDidUpdate(prevProps) {\n if (!prevProps.open && this.props.open && !this.state.comment && this.props.message) {\n this.setState({ comment: this.props.message });\n }\n\n if (\n this.props.fileUrl !== prevProps.fileUrl ||\n this.props.fileSize !== prevProps.fileSize ||\n this.props.fileName !== prevProps.fileName\n ) {\n this.setState({\n fileUrl: this.props.fileUrl,\n fileSize: this.props.fileSize,\n fileName: this.props.fileName,\n });\n }\n }\n\n focusOnInput = () => this.inputEl.current.focus();\n\n handleKeyDown = event => {\n if (event.key === 'Enter') {\n this.handleShare();\n }\n };\n\n handleMessageChange = comment => this.setState({ comment });\n\n handleSelectEmoji = emoji =>\n this.setState(({ comment }) => ({ comment: `${comment}${emoji.native}` }));\n\n handleShare = () => {\n this.props.handleShare(\n this.state.comment,\n this.state.fileUrl,\n this.state.fileSize,\n this.state.fileName\n );\n };\n\n handleFileDelete = () => {\n this.setState({ fileUrl: '', fileSize: null, fileName: '' });\n };\n\n handleFileUpload = (fileUrl, fileName, fileSize) => {\n this.setState({\n fileUrl,\n fileName,\n fileSize,\n fileUploadingError: null,\n });\n };\n\n handleFileUploadingError = fileUploadingError => {\n this.setState({\n fileUrl: null,\n fileName: null,\n fileSize: null,\n fileUploadingError,\n });\n };\n\n render() {\n return (\n <RootRef rootRef={this.rootRef}>\n <Dialog\n fullScreen={isNativeDetected}\n open={this.props.open}\n onClose={this.props.handleClose}\n onBackdropClick={this.props.handleClose}\n onEntered={this.focusOnInput}\n >\n <DialogTitle>{this.props.title}</DialogTitle>\n\n <DialogContent\n classes={{ root: !isNativeDetected && this.props.classes.dialogContentRoot }}\n >\n <Message\n inputEl={this.inputEl}\n comment={this.state.comment}\n handleMessageChange={this.handleMessageChange}\n handleKeyDown={this.handleKeyDown}\n handleFileUpload={this.handleFileUpload}\n handleSelectEmoji={this.handleSelectEmoji}\n handleFileUploadingError={this.handleFileUploadingError}\n additionalFields={this.props.additionalFields}\n fileUrl={this.state.fileUrl}\n classes={this.props.classes}\n companyId={this.props.companyId}\n rootRef={this.rootRef}\n />\n\n {this.state.fileUploadingError && (\n <FailedFileUploading\n errorMessage={this.state.fileUploadingError}\n className={this.props.classes.fileUploadingError}\n />\n )}\n\n {this.state.fileUrl && (\n <File\n fileName={this.state.fileName}\n fileUrl={this.state.fileUrl}\n handleFileDelete={this.handleFileDelete}\n handleFileUploadingError={this.handleFileUploadingError}\n classes={this.props.classes}\n />\n )}\n </DialogContent>\n\n <DialogActions className={this.props.classes.dialogActions}>\n <Button\n data-testid={`${PAGE_NAME}_cancelButton`}\n color=\"primary\"\n onClick={this.props.handleClose}\n >\n {this.props.cancelButtonText}\n </Button>\n\n <Button\n data-testid={`${PAGE_NAME}_okButton`}\n color=\"primary\"\n variant=\"contained\"\n disabled={\n (!this.state.fileUrl && !this.state.comment) ||\n !this.props.requiredFields.every(Boolean)\n }\n onClick={this.handleShare}\n >\n {this.props.okButtonText}\n </Button>\n </DialogActions>\n </Dialog>\n </RootRef>\n );\n }\n}\n\nFileUploadPreviewDialog.propTypes = {\n title: PropTypes.string,\n open: PropTypes.bool.isRequired,\n fileUrl: PropTypes.string,\n fileName: PropTypes.string,\n fileSize: PropTypes.number,\n handleShare: PropTypes.func.isRequired,\n handleClose: PropTypes.func.isRequired,\n\n classes: PropTypes.shape({}).isRequired,\n\n additionalFields: PropTypes.arrayOf(PropTypes.node),\n requiredFields: PropTypes.arrayOf(PropTypes.string),\n message: PropTypes.string,\n companyId: PropTypes.number,\n\n okButtonText: PropTypes.string,\n cancelButtonText: PropTypes.string,\n};\n\nFileUploadPreviewDialog.defaultProps = {\n title: 'Share a file',\n fileUrl: '',\n fileName: '',\n fileSize: null,\n additionalFields: [],\n requiredFields: [],\n message: '',\n companyId: null,\n\n okButtonText: 'Post',\n cancelButtonText: 'Cancel',\n};\n\nexport default withStyles(muiStyles)(FileUploadPreviewDialog);\n"],"names":["PAGE_NAME","grey200","grey","grey400","Message","props","_jsxs","Paper","className","classes","messageWrapper","children","_jsx","Input","concat","inputRef","inputEl","inputComponent","UserMention","inputProps","withLightTheme","onChange","handleMessageChange","companyId","suggestionsPortalHost","rootRef","current","placeholder","fullWidth","disableUnderline","multiline","rows","textFieldRoot","value","comment","onKeyDown","handleKeyDown","jsxs","styles","cPostPreviewDialogMessageAdditionalFieldsWrapper","jsx","additionalFields","cPostPreviewDialogMessageActionFields","fileUrl","FileUploadIconButton","htmlColor","openPreviewDialogOnUpload","disableRipple","onFinish","handleFileUpload","onError","handleFileUploadingError","inputId","EmojiIconButton","handleSelectEmoji","emojiIconClassName","additionalActionButton","File","getIsImage","fileName","cPostPreviewDialogFileName","Typography","variant","noWrap","gutterBottom","DeleteIcon","color","onClick","handleFileDelete","deleteButton","cPostPreviewDialogFileImageFileWrapper","cPostPreviewDialogFileImage","src","alt","cPostPreviewDialogFileDownload","style","backgroundColor","border","FileTypeIcon","cPostPreviewDialogFileDownloadText","FileUploadPreviewDialog","_PureComponent","_inherits","_super","_createSuper","_this","_classCallCheck","this","call","_defineProperty","_assertThisInitialized","focus","event","key","handleShare","setState","emoji","_ref","native","state","fileSize","fileUploadingError","message","createRef","_createClass","prevProps","open","RootRef","Dialog","fullScreen","isNativeDetected","onClose","handleClose","onBackdropClick","onEntered","focusOnInput","DialogTitle","title","DialogContent","root","dialogContentRoot","FailedFileUploading","errorMessage","DialogActions","dialogActions","Button","cancelButtonText","disabled","requiredFields","every","Boolean","okButtonText","PureComponent","propTypes","PropTypes","string","bool","isRequired","number","func","shape","arrayOf","node","defaultProps","PostPreviewDialog","withStyles","theme","minWidth","marginBottom","textInput","paddingTop","padding","palette","primary","main","boxShadow","margin","cursor","marginTop"],"mappings":"s1DA0BA,IAAMA,EAAY,oBAEZC,EAAUC,EAAAA,QAAK,KACfC,EAAUD,EAAAA,QAAK,KAyBfE,EAAU,SAAAC,GAAK,OACnBC,EAAAA,KAACC,EAAAA,QAAK,CAACC,UAAWH,EAAMI,QAAQC,eAAeC,SAAA,CAC7CC,MAACC,UAAK,CACJ,cAAA,GAAAC,OAAgBd,EAAyB,iBACzCe,SAAUV,EAAMW,QAChBC,eAAgBC,EAChBC,WAAY,CACVC,gBAAgB,EAChBC,SAAUhB,EAAMiB,oBAChBC,UAAWlB,EAAMkB,UACjBC,sBAAuBnB,EAAMoB,QAAQC,SAEvCC,YAAY,kCACZC,WAAS,EACTC,kBAAgB,EAChBC,WAAS,EACTC,KAAK,IACLvB,UAAWH,EAAMI,QAAQuB,cACzBC,MAAO5B,EAAM6B,QACbC,UAAW9B,EAAM+B,gBAEnB9B,EAAA+B,KAAA,MAAA,CAAK7B,UAAW8B,EAAOC,iDAAiD5B,SACtE,CAAAC,EAAA4B,IAAA,MAAA,CAAA7B,SAAMN,EAAMoC,mBACZnC,EAAA+B,KAAA,MAAA,CAAK7B,UAAW8B,EAAOI,sCAAsC/B,SAAA,EACzDN,EAAMsC,SACN/B,EAAAA,IAACgC,EAAAA,QAAoB,CACnBC,UAAW3C,EAAI,QAAC,KAChB4C,2BAA2B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ACjB7B,KAAM4B,EAAAA,QAAUE,KAAKC,WACrB9F,QAAS2F,EAAS,QAACC,OACnB5E,SAAU2E,EAAS,QAACC,OACpBnC,SAAUkC,EAAS,QAACI,OACpB5C,YAAawC,EAAAA,QAAUK,KAAKF,WAC5BzB,YAAasB,EAAAA,QAAUK,KAAKF,WAE5BhI,QAAS6H,EAAS,QAACM,MAAM,CAAA,GAAIH,WAE7BhG,iBAAkB6F,EAAS,QAACO,QAAQP,EAAAA,QAAUQ,MAC9Cd,eAAgBM,EAAS,QAACO,QAAQP,EAAAA,QAAUC,QAC5CjC,QAASgC,EAAS,QAACC,OACnBhH,UAAW+G,EAAS,QAACI,OAErBP,aAAcG,EAAS,QAACC,OACxBT,iBAAkBQ,EAAS,QAACC,QAG9BvD,GAAwB+D,aAAe,CACrC1B,MAAO,eACP1E,QAAS,GACTgB,SAAU,GACVyC,SAAU,KACV3D,iBAAkB,GAClBuF,eAAgB,GAChB1B,QAAS,GACT/E,UAAW,KAEX4G,aAAc,OACdL,iBAAkB,UAGpB,IAAAkB,GAAeC,cAlTG,SAAAC,GAAK,MAAK,CAC1B1B,kBAAmB,CAAE2B,SAAU,KAC/BnH,cAAe,CAAEoH,aAAc,IAC/BC,UAAW,CAAEC,WAAY,GACzB5I,eAAgB,CACd6I,QAAS,cACT1E,OAAM,aAAA/D,OAAeoI,EAAMM,QAAQC,QAAQC,MAC3CC,UAAW,QAEb/B,cAAe,CACb2B,QAAS,YACTK,OAAQ,GAEVvF,aAAc,CACZH,MAAO,UACP2F,OAAQ,WAEVxD,mBAAoB,CAClByD,UAAW,IAEd,GA8Rcb,CAAsBjE"}
1
+ {"version":3,"file":"index.js","sources":["../../../../src/components/PostPreviewDialog/index.js"],"sourcesContent":["import { memo, useCallback, useLayoutEffect, useRef, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport { withStyles } from '@material-ui/core/styles';\nimport Paper from '@material-ui/core/Paper';\nimport DialogActions from '@material-ui/core/DialogActions';\nimport DialogContent from '@material-ui/core/DialogContent';\nimport DialogTitle from '@material-ui/core/DialogTitle';\nimport Button from '@material-ui/core/Button';\nimport Typography from '@material-ui/core/Typography';\nimport Input from '@material-ui/core/Input';\nimport RootRef from '@material-ui/core/RootRef';\nimport grey from '@material-ui/core/colors/grey';\nimport DeleteIcon from '@material-ui/icons/Delete';\nimport { Dialog } from '@material-ui/core';\n\nimport { getIsImage } from '../../utils/fileExtension';\n\nimport styles from './styles.css';\n\nimport FileTypeIcon from '~/components/FileTypeIcon';\nimport EmojiIconButton from '~/components/EmojiIconButton';\nimport FileUploadIconButton from '~/components/FileUploadIconButton';\nimport FailedFileUploading from '~/components/FailedFileUploading';\nimport UserMention from '~/components/UserMention';\nimport { isNativeDetected } from '~/utils/mobileDetect';\n\nconst PAGE_NAME = 'PostPreviewDialog';\n\nconst grey200 = grey[200];\nconst grey400 = grey[400];\n\nconst muiStyles = theme => ({\n dialogContentRoot: { minWidth: 500 },\n textFieldRoot: { marginBottom: 20 },\n textInput: { paddingTop: 2 },\n messageWrapper: {\n padding: '18.5px 14px',\n border: `solid 1px ${theme.palette.primary.main}`,\n boxShadow: 'none',\n },\n dialogActions: {\n padding: '24px 24px',\n margin: 0,\n },\n deleteButton: {\n color: '#DADADA',\n cursor: 'pointer',\n },\n fileUploadingError: {\n marginTop: 10,\n },\n});\n\n/* eslint-disable react/prop-types */\nconst Message = props => (\n <Paper className={props.classes.messageWrapper}>\n <Input\n data-testid={`${PAGE_NAME}_messageInput`}\n inputRef={props.inputEl}\n inputComponent={UserMention}\n inputProps={{\n withLightTheme: false,\n onChange: props.handleMessageChange,\n companyId: props.companyId,\n suggestionsPortalHost: props.rootRef.current,\n }}\n placeholder=\"Add a message about the file...\"\n fullWidth\n disableUnderline\n multiline\n rows=\"3\"\n className={props.classes.textFieldRoot}\n value={props.comment}\n onKeyDown={props.handleKeyDown}\n />\n <div className={styles.cPostPreviewDialogMessageAdditionalFieldsWrapper}>\n <div>{props.additionalFields}</div>\n <div className={styles.cPostPreviewDialogMessageActionFields}>\n {!props.fileUrl && (\n <FileUploadIconButton\n htmlColor={grey[400]}\n openPreviewDialogOnUpload={false}\n disableRipple\n onFinish={props.handleFileUpload}\n onError={props.handleFileUploadingError}\n inputId=\"preview-dialog-file-upload\"\n />\n )}\n <EmojiIconButton\n handleSelectEmoji={props.handleSelectEmoji}\n emojiIconClassName={props.classes.additionalActionButton}\n htmlColor={grey[400]}\n disableRipple\n />\n </div>\n </div>\n </Paper>\n);\n\nconst File = props => {\n const isImage = getIsImage(props.fileName);\n\n return isImage ? (\n <div>\n <div className={styles.cPostPreviewDialogFileName}>\n <Typography data-testid={`${PAGE_NAME}_fileName`} variant=\"subtitle2\" noWrap gutterBottom>\n {props.fileName}\n </Typography>\n <DeleteIcon\n data-testid={`${PAGE_NAME}_deleteButton`}\n color=\"action\"\n onClick={props.handleFileDelete}\n className={props.classes.deleteButton}\n />\n </div>\n <div className={styles.cPostPreviewDialogFileImageFileWrapper}>\n <img\n data-testid={`${PAGE_NAME}_previewImage`}\n className={styles.cPostPreviewDialogFileImage}\n src={props.fileUrl}\n alt=\"Uploaded file\"\n />\n </div>\n </div>\n ) : (\n <div\n className={styles.cPostPreviewDialogFileDownload}\n style={{\n backgroundColor: grey200,\n border: `1px solid ${grey400}`,\n }}\n >\n <FileTypeIcon fileName={props.fileName} />\n <div className={styles.cPostPreviewDialogFileDownloadText}>\n <Typography data-testid={`${PAGE_NAME}_fileName`} variant=\"subtitle2\" noWrap>\n {props.fileName}\n </Typography>\n <DeleteIcon\n data-testid={`${PAGE_NAME}_deleteButton`}\n color=\"action\"\n onClick={props.handleFileDelete}\n className={props.classes.deleteButton}\n />\n </div>\n </div>\n );\n};\n/* eslint-enable react/prop-types */\n\nconst emptyFields = [];\n\n/** @param {any} props Preserve the legacy component's public prop type. */\nfunction FileUploadPreviewDialog({\n title = 'Share a file',\n open,\n fileUrl = '',\n fileName = '',\n fileSize = null,\n handleShare: onShare,\n handleClose,\n classes,\n additionalFields = emptyFields,\n requiredFields = emptyFields,\n message = '',\n companyId = null,\n okButtonText = 'Post',\n cancelButtonText = 'Cancel',\n}) {\n const [state, setState] = useState(() => ({\n comment: message,\n fileUrl,\n fileSize,\n fileName,\n fileUploadingError: null,\n }));\n const inputEl = useRef(null);\n const rootRef = useRef(null);\n const previousProps = useRef({ open, fileUrl, fileSize, fileName });\n\n useLayoutEffect(() => {\n const previous = previousProps.current;\n previousProps.current = { open, fileUrl, fileSize, fileName };\n const fillMessage = !previous.open && open && !state.comment && message;\n const fileChanged =\n fileUrl !== previous.fileUrl ||\n fileSize !== previous.fileSize ||\n fileName !== previous.fileName;\n if (fillMessage || fileChanged) {\n setState(current => ({\n ...current,\n ...(fillMessage ? { comment: message } : {}),\n ...(fileChanged ? { fileUrl, fileSize, fileName } : {}),\n }));\n }\n }, [open, fileUrl, fileSize, fileName, message, state.comment]);\n\n const focusOnInput = () => inputEl.current.focus();\n const handleShare = () => onShare(state.comment, state.fileUrl, state.fileSize, state.fileName);\n const handleKeyDown = event => {\n if (event.key === 'Enter') handleShare();\n };\n const handleMessageChange = comment => setState(current => ({ ...current, comment }));\n const handleSelectEmoji = useCallback(\n emoji => setState(current => ({ ...current, comment: `${current.comment}${emoji.native}` })),\n []\n );\n const handleFileDelete = () =>\n setState(current => ({ ...current, fileUrl: '', fileSize: null, fileName: '' }));\n const handleFileUpload = useCallback(\n (uploadedUrl, uploadedName, uploadedSize) =>\n setState(current => ({\n ...current,\n fileUrl: uploadedUrl,\n fileName: uploadedName,\n fileSize: uploadedSize,\n fileUploadingError: null,\n })),\n []\n );\n const handleFileUploadingError = useCallback(\n fileUploadingError =>\n setState(current => ({\n ...current,\n fileUrl: null,\n fileName: null,\n fileSize: null,\n fileUploadingError,\n })),\n []\n );\n\n return (\n <RootRef rootRef={rootRef}>\n <Dialog\n fullScreen={isNativeDetected}\n open={open}\n onClose={handleClose}\n onBackdropClick={handleClose}\n onEntered={focusOnInput}\n >\n <DialogTitle>{title}</DialogTitle>\n\n <DialogContent classes={{ root: !isNativeDetected && classes.dialogContentRoot }}>\n <Message\n inputEl={inputEl}\n comment={state.comment}\n handleMessageChange={handleMessageChange}\n handleKeyDown={handleKeyDown}\n handleFileUpload={handleFileUpload}\n handleSelectEmoji={handleSelectEmoji}\n handleFileUploadingError={handleFileUploadingError}\n additionalFields={additionalFields}\n fileUrl={state.fileUrl}\n classes={classes}\n companyId={companyId}\n rootRef={rootRef}\n />\n\n {state.fileUploadingError && (\n <FailedFileUploading\n errorMessage={state.fileUploadingError}\n className={classes.fileUploadingError}\n />\n )}\n\n {state.fileUrl && (\n <File\n fileName={state.fileName}\n fileUrl={state.fileUrl}\n handleFileDelete={handleFileDelete}\n handleFileUploadingError={handleFileUploadingError}\n classes={classes}\n />\n )}\n </DialogContent>\n\n <DialogActions className={classes.dialogActions}>\n <Button data-testid={`${PAGE_NAME}_cancelButton`} color=\"primary\" onClick={handleClose}>\n {cancelButtonText}\n </Button>\n\n <Button\n data-testid={`${PAGE_NAME}_okButton`}\n color=\"primary\"\n variant=\"contained\"\n disabled={(!state.fileUrl && !state.comment) || !requiredFields.every(Boolean)}\n onClick={handleShare}\n >\n {okButtonText}\n </Button>\n </DialogActions>\n </Dialog>\n </RootRef>\n );\n}\n\nFileUploadPreviewDialog.propTypes = {\n title: PropTypes.string,\n open: PropTypes.bool.isRequired,\n fileUrl: PropTypes.string,\n fileName: PropTypes.string,\n fileSize: PropTypes.number,\n handleShare: PropTypes.func.isRequired,\n handleClose: PropTypes.func.isRequired,\n\n classes: PropTypes.shape({}).isRequired,\n\n additionalFields: PropTypes.arrayOf(PropTypes.node),\n requiredFields: PropTypes.arrayOf(PropTypes.string),\n message: PropTypes.string,\n companyId: PropTypes.number,\n\n okButtonText: PropTypes.string,\n cancelButtonText: PropTypes.string,\n};\n\nexport default withStyles(muiStyles)(memo(FileUploadPreviewDialog));\n"],"names":["PAGE_NAME","grey200","grey","grey400","Message","props","_jsxs","Paper","className","classes","messageWrapper","children","_jsx","Input","concat","inputRef","inputEl","inputComponent","UserMention","inputProps","withLightTheme","onChange","handleMessageChange","companyId","suggestionsPortalHost","rootRef","current","placeholder","fullWidth","disableUnderline","multiline","rows","textFieldRoot","value","comment","onKeyDown","handleKeyDown","jsxs","styles","cPostPreviewDialogMessageAdditionalFieldsWrapper","jsx","additionalFields","cPostPreviewDialogMessageActionFields","fileUrl","FileUploadIconButton","htmlColor","openPreviewDialogOnUpload","disableRipple","onFinish","handleFileUpload","onError","handleFileUploadingError","inputId","EmojiIconButton","handleSelectEmoji","emojiIconClassName","additionalActionButton","File","getIsImage","fileName","cPostPreviewDialogFileName","Typography","variant","noWrap","gutterBottom","DeleteIcon","color","onClick","handleFileDelete","deleteButton","cPostPreviewDialogFileImageFileWrapper","cPostPreviewDialogFileImage","src","alt","cPostPreviewDialogFileDownload","style","backgroundColor","border","FileTypeIcon","cPostPreviewDialogFileDownloadText","emptyFields","FileUploadPreviewDialog","_ref","_ref$title","title","open","_ref$fileUrl","_ref$fileName","_ref$fileSize","fileSize","onShare","handleShare","handleClose","_ref$additionalFields","_ref$requiredFields","requiredFields","_ref$message","message","_ref$companyId","_ref$okButtonText","okButtonText","_ref$cancelButtonText","cancelButtonText","_useState","useState","fileUploadingError","_useState2","_slicedToArray","state","setState","useRef","previousProps","useLayoutEffect","previous","fillMessage","fileChanged","useCallback","emoji","_objectSpread","native","uploadedUrl","uploadedName","uploadedSize","RootRef","Dialog","fullScreen","isNativeDetected","onClose","onBackdropClick","onEntered","focus","DialogTitle","DialogContent","root","dialogContentRoot","event","key","FailedFileUploading","errorMessage","DialogActions","dialogActions","Button","disabled","every","Boolean","propTypes","PropTypes","string","bool","isRequired","number","func","shape","arrayOf","node","withStyles","theme","minWidth","marginBottom","textInput","paddingTop","padding","palette","primary","main","boxShadow","margin","cursor","marginTop","memo"],"mappings":"krDA0BA,IAAMA,EAAY,oBAEZC,EAAUC,EAAAA,QAAK,KACfC,EAAUD,EAAAA,QAAK,KAyBfE,EAAU,SAAAC,GAAK,OAC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AAAA,YA7RG,SAAAC,GAAK,MAAK,CAC1BtB,kBAAmB,CAAEuB,SAAU,KAC/B7H,cAAe,CAAE8H,aAAc,IAC/BC,UAAW,CAAEC,WAAY,GACzBtJ,eAAgB,CACduJ,QAAS,cACTpF,OAAM,aAAA/D,OAAe8I,EAAMM,QAAQC,QAAQC,MAC3CC,UAAW,QAEbzB,cAAe,CACbqB,QAAS,YACTK,OAAQ,GAEVjG,aAAc,CACZH,MAAO,UACPqG,OAAQ,WAEV9D,mBAAoB,CAClB+D,UAAW,IAEd,GAyQcb,CAAsBc,EAAIA,KAACxF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=InfiniteList.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfiniteList.test.d.ts","sourceRoot":"","sources":["../../../../src/components/InfiniteList/__tests__/InfiniteList.test.js"],"names":[],"mappings":""}
@@ -1,61 +1,5 @@
1
- import { PureComponent } from 'react';
2
- import PropTypes from 'prop-types';
3
- import moment from 'moment';
4
- /** @extends {PureComponent<any, any, any>} */
5
- declare class InfiniteList extends PureComponent<any, any, any> {
6
- state: {
7
- isLoadingByScroll: boolean;
8
- periodDates: {
9
- hoursAgo12: moment.Moment;
10
- daysAgo1: moment.Moment;
11
- daysAgo7: moment.Moment;
12
- daysAgo14: moment.Moment;
13
- daysAgo30: moment.Moment;
14
- };
15
- };
16
- updatePeriodsIntervalId: NodeJS.Timer | null;
17
- constructor(props: any);
18
- componentDidMount(): void;
19
- componentWillUnmount(): void;
20
- get periodDates(): {
21
- hoursAgo12: moment.Moment;
22
- daysAgo1: moment.Moment;
23
- daysAgo7: moment.Moment;
24
- daysAgo14: moment.Moment;
25
- daysAgo30: moment.Moment;
26
- };
27
- loadItems: () => Promise<void>;
28
- renderNoItemsLabel(): import("react").JSX.Element;
29
- renderPeriodSeparator(periodKey: any): import("react").JSX.Element;
30
- renderItems(): any;
31
- render(): import("react").JSX.Element;
32
- }
33
- declare namespace InfiniteList {
34
- var propTypes: {
35
- infiniteClassName: PropTypes.Requireable<string>;
36
- useWindow: PropTypes.Requireable<boolean>;
37
- headerComponent: PropTypes.Requireable<PropTypes.ReactNodeLike>;
38
- items: PropTypes.Validator<(PropTypes.InferProps<PropTypes.ValidationMap<any>> | null | undefined)[]>;
39
- showNoItemsFound: PropTypes.Validator<boolean>;
40
- noItemsFoundLabel: PropTypes.Validator<string>;
41
- infiniteContainerHeight: PropTypes.Requireable<number>;
42
- moreItemsMayExist: PropTypes.Validator<boolean>;
43
- pathToCreatedAt: PropTypes.Validator<(string | null | undefined)[]>;
44
- renderItem: PropTypes.Validator<(...args: any[]) => any>;
45
- loadItems: PropTypes.Validator<(...args: any[]) => any>;
46
- threshold: PropTypes.Requireable<number>;
47
- initialLoad: PropTypes.Requireable<boolean>;
48
- divideByPeriods: PropTypes.Requireable<boolean>;
49
- };
50
- var defaultProps: {
51
- infiniteClassName: null;
52
- useWindow: boolean;
53
- headerComponent: null;
54
- infiniteContainerHeight: null;
55
- threshold: number;
56
- initialLoad: boolean;
57
- divideByPeriods: boolean;
58
- };
59
- }
60
- export default InfiniteList;
1
+ /** @param {any} props Preserve the legacy component's permissive public prop type. */
2
+ declare function InfiniteList({ infiniteClassName, useWindow, headerComponent, items, showNoItemsFound, noItemsFoundLabel, infiniteContainerHeight, moreItemsMayExist, pathToCreatedAt, renderItem, loadItems, threshold, initialLoad, divideByPeriods, }: any): import("react").JSX.Element;
3
+ declare const _default: import("react").MemoExoticComponent<typeof InfiniteList>;
4
+ export default _default;
61
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/InfiniteList/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AACtC,OAAO,SAAS,MAAM,YAAY,CAAC;AACnC,OAAO,MAAM,MAAM,QAAQ,CAAC;AAwB5B,8CAA8C;AAC9C,cAAM,YAAa,SAAQ,aAAa,CADZ,GAAG,EAAE,GAAG,EAAE,GAAG,CACD;IAI/B,KAAK;;;;;;;;;;IAML,uBAAuB;IAT9B,YAAY,KAAK,KAAA,EAUhB;IAED,iBAAiB,SAKhB;IAED,oBAAoB,SAInB;IAED,IAAI,WAAW;QAEX,UAAU;QACV,QAAQ;QACR,QAAQ;QACR,SAAS;QACT,SAAS;MAEZ;IASD,SAAS,sBAUP;IAEF,kBAAkB,gCAUjB;IAED,qBAAqB,CAAC,SAAS,KAAA,+BAW9B;IAED,WAAW,QAoDV;IAED,MAAM,gCAsBL;CACF;kBA7JK,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;eA4LH,YAAY"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/InfiniteList/index.js"],"names":[],"mappings":"AAkCA,sFAAsF;AACtF,iBAAS,YAAY,CAAC,EACpB,iBAAwB,EACxB,SAAiB,EACjB,eAAsB,EACtB,KAAK,EACL,gBAAgB,EAChB,iBAAiB,EACjB,uBAA8B,EAC9B,iBAAiB,EACjB,eAAe,EACf,UAAU,EACV,SAAS,EACT,SAAgB,EAChB,WAAkB,EAClB,eAAsB,GACvB,EAhBW,GAgBX,+BA8HA"}
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/toConsumableArray";import r from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/classCallCheck";import o from"@babel/runtime/helpers/createClass";import i from"@babel/runtime/helpers/assertThisInitialized";import n from"@babel/runtime/helpers/inherits";import s from"@babel/runtime/helpers/possibleConstructorReturn";import a from"@babel/runtime/helpers/getPrototypeOf";import l from"@babel/runtime/helpers/defineProperty";import d from"@babel/runtime/regenerator";import{PureComponent as u}from"react";import p from"prop-types";import c from"moment";import h from"classnames";import{get as m,set as f}from"lodash";import y from"react-infinite-scroller";import b from"@material-ui/core/colors/grey";import I from"./styles.css.js";import g from"../LoadingIndicator/LoadingIndicator.js";import{jsx as v,jsxs as L}from"react/jsx-runtime";function T(e){var r=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,o=a(e);if(r){var i=a(this).constructor;t=Reflect.construct(o,arguments,i)}else t=o.apply(this,arguments);return s(this,t)}}var D=b[700],C={newerThan12Hours:"Last 12 hours",olderThan12Hours:"Last 24 hours",olderThan1Days:"Earlier this week",olderThan7Days:"Older than 7 days",olderThan14Days:"Older than 14 days",olderThan30Days:"Older than 30 days"},w=function(s){n(p,u);var a=T(p);function p(e){var o;return t(this,p),o=a.call(this,e),l(i(o),"loadItems",r(d.mark((function e(){return d.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!o.state.isLoadingByScroll){e.next=2;break}return e.abrupt("return");case 2:return o.setState({isLoadingByScroll:!0}),e.next=5,o.props.loadItems();case 5:o.setState({isLoadingByScroll:!1});case 6:case"end":return e.stop()}}),e)})))),o.state={isLoadingByScroll:!1,periodDates:o.periodDates},o.updatePeriodsIntervalId=null,o}return o(p,[{key:"componentDidMount",value:function(){var e=this;this.updatePeriodsIntervalId=setInterval((function(){return e.setState({periodDates:e.periodDates})}),216e5)}},{key:"componentWillUnmount",value:function(){this.updatePeriodsIntervalId&&clearInterval(this.updatePeriodsIntervalId)}},{key:"periodDates",get:function(){return{hoursAgo12:c().subtract(12,"hours"),daysAgo1:c().subtract(1,"days"),daysAgo7:c().subtract(7,"days"),daysAgo14:c().subtract(14,"days"),daysAgo30:c().subtract(30,"days")}}},{key:"renderNoItemsLabel",value:function(){return v("div",{"data-testid":"".concat("generic_infiniteList","_noItems"),className:I.cInfiniteListEmpty,children:this.props.noItemsFoundLabel},"c-infinite-list__empty")}},{key:"renderPeriodSeparator",value:function(e){return v("div",{"data-testid":"".concat("generic_infiniteList","_periodLabel"),className:I.cInfiniteListPeriod,style:{color:D},children:C[e]},e)}},{key:"renderItems",value:function(){var r=this;if(!this.props.divideByPeriods)return this.props.items.map((function(e){return r.props.renderItem(e)})).unshift(this.props.headerComponent);var t=this.state.periodDates,o=t.hoursAgo12,i=t.daysAgo1,n=t.daysAgo7,s=t.daysAgo14,a=t.daysAgo30,l=this.props.items.reduce((function(e,t,l){var d,u=r.props.renderItem(t,l),p=m(t,r.props.pathToCreatedAt),h=c(p);return h>=o?d="newerThan12Hours":h<o&&h>=i?d="olderThan12Hours":h<i&&h>=n?d="olderThan1Days":h<n&&h>=s?d="olderThan7Days":h<s&&h>=a?d="olderThan14Days":h<a&&(d="olderThan30Days"),f(e,[d,e[d].length],u)}),{newerThan12Hours:[],olderThan12Hours:[],olderThan1Days:[],olderThan7Days:[],olderThan14Days:[],olderThan30Days:[]}),d=Object.keys(l).reduce((function(t,o){return 0===l[o].length?t.concat(l[o]):t.concat([r.renderPeriodSeparator(o)].concat(e(l[o])))}),[]);return[this.props.headerComponent].concat(e(d))}},{key:"render",value:function(){return L("div",{className:h(I.cInfiniteList,this.props.infiniteClassName,l({},I.cInfiniteListOverflow,!this.props.useWindow)),style:{height:this.props.infiniteContainerHeight},children:[v(y,{loadMore:this.loadItems,hasMore:this.props.moreItemsMayExist&&!this.props.showNoItemsFound,threshold:this.props.threshold,loader:v(g,{fullscreen:!1},"c-infinite-scroll__loader"),useWindow:this.props.useWindow,initialLoad:this.props.initialLoad,children:this.renderItems()}),this.props.showNoItemsFound&&this.renderNoItemsLabel()]})}}]),p}();w.propTypes={infiniteClassName:p.string,useWindow:p.bool,headerComponent:p.node,items:p.arrayOf(p.shape()).isRequired,showNoItemsFound:p.bool.isRequired,noItemsFoundLabel:p.string.isRequired,infiniteContainerHeight:p.number,moreItemsMayExist:p.bool.isRequired,pathToCreatedAt:p.arrayOf(p.string).isRequired,renderItem:p.func.isRequired,loadItems:p.func.isRequired,threshold:p.number,initialLoad:p.bool,divideByPeriods:p.bool},w.defaultProps={infiniteClassName:null,useWindow:!1,headerComponent:null,infiniteContainerHeight:null,threshold:3e3,initialLoad:!0,divideByPeriods:!0};export{w as default};
1
+ import e from"@babel/runtime/helpers/defineProperty";import r from"@babel/runtime/helpers/toConsumableArray";import o from"@babel/runtime/helpers/asyncToGenerator";import t from"@babel/runtime/helpers/slicedToArray";import n from"@babel/runtime/regenerator";import{memo as i,useState as a,useEffect as s}from"react";import d from"prop-types";import l from"moment";import u from"classnames";import{get as c,set as m}from"lodash";import h from"react-infinite-scroller";import f from"@material-ui/core/colors/grey";import y from"./styles.css.js";import p from"../LoadingIndicator/LoadingIndicator.js";import{jsxs as b,jsx as g}from"react/jsx-runtime";var v=f[700],T={newerThan12Hours:"Last 12 hours",olderThan12Hours:"Last 24 hours",olderThan1Days:"Earlier this week",olderThan7Days:"Older than 7 days",olderThan14Days:"Older than 14 days",olderThan30Days:"Older than 30 days"},I=function(){return{hoursAgo12:l().subtract(12,"hours"),daysAgo1:l().subtract(1,"days"),daysAgo7:l().subtract(7,"days"),daysAgo14:l().subtract(14,"days"),daysAgo30:l().subtract(30,"days")}};function L(i){var d=i.infiniteClassName,f=void 0===d?null:d,L=i.useWindow,A=void 0!==L&&L,w=i.headerComponent,D=void 0===w?null:w,C=i.items,H=i.showNoItemsFound,_=i.noItemsFoundLabel,q=i.infiniteContainerHeight,x=void 0===q?null:q,N=i.moreItemsMayExist,O=i.pathToCreatedAt,R=i.renderItem,j=i.loadItems,k=i.threshold,E=void 0===k?3e3:k,F=i.initialLoad,M=void 0===F||F,P=i.divideByPeriods,W=void 0===P||P,B=a(!1),G=t(B,2),z=G[0],J=G[1],K=a(I),Q=t(K,2),S=Q[0],U=Q[1];s((function(){var e=setInterval((function(){return U(I())}),216e5);return function(){return clearInterval(e)}}),[]);var V,X=(V=o(n.mark((function e(){return n.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!z){e.next=2;break}return e.abrupt("return");case 2:return J(!0),e.next=5,j();case 5:J(!1);case 6:case"end":return e.stop()}}),e)}))),function(){return V.apply(this,arguments)});return b("div",{className:u(y.cInfiniteList,f,e({},y.cInfiniteListOverflow,!A)),style:{height:x},children:[g(h,{loadMore:X,hasMore:N&&!H,threshold:E,loader:g(p,{fullscreen:!1},"c-infinite-scroll__loader"),useWindow:A,initialLoad:M,children:function(){if(!W)return C.map((function(e){return R(e)})).unshift(D);var e=S.hoursAgo12,o=S.daysAgo1,t=S.daysAgo7,n=S.daysAgo14,i=S.daysAgo30,a=C.reduce((function(r,a,s){var d,u=R(a,s),h=c(a,O),f=l(h);return f>=e?d="newerThan12Hours":f<e&&f>=o?d="olderThan12Hours":f<o&&f>=t?d="olderThan1Days":f<t&&f>=n?d="olderThan7Days":f<n&&f>=i?d="olderThan14Days":f<i&&(d="olderThan30Days"),m(r,[d,r[d].length],u)}),{newerThan12Hours:[],olderThan12Hours:[],olderThan1Days:[],olderThan7Days:[],olderThan14Days:[],olderThan30Days:[]}),s=Object.keys(a).reduce((function(e,o){return 0===a[o].length?e.concat(a[o]):e.concat([(t=o,g("div",{"data-testid":"".concat("generic_infiniteList","_periodLabel"),className:y.cInfiniteListPeriod,style:{color:v},children:T[t]},t))].concat(r(a[o])));var t}),[]);return[D].concat(r(s))}()}),H&&g("div",{"data-testid":"".concat("generic_infiniteList","_noItems"),className:y.cInfiniteListEmpty,children:_},"c-infinite-list__empty")]})}L.propTypes={infiniteClassName:d.string,useWindow:d.bool,headerComponent:d.node,items:d.arrayOf(d.shape()).isRequired,showNoItemsFound:d.bool.isRequired,noItemsFoundLabel:d.string.isRequired,infiniteContainerHeight:d.number,moreItemsMayExist:d.bool.isRequired,pathToCreatedAt:d.arrayOf(d.string).isRequired,renderItem:d.func.isRequired,loadItems:d.func.isRequired,threshold:d.number,initialLoad:d.bool,divideByPeriods:d.bool};var A=i(L);export{A as default};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/InfiniteList/index.js"],"sourcesContent":["import { PureComponent } from 'react';\nimport PropTypes from 'prop-types';\nimport moment from 'moment';\nimport classNames from 'classnames';\nimport { get, set } from 'lodash';\nimport InfiniteScroll from 'react-infinite-scroller';\nimport grey from '@material-ui/core/colors/grey';\n\nimport styles from './styles.css';\n\nimport LoadingIndicator from '~components/LoadingIndicator';\n\nconst PAGE_NAME = 'generic_infiniteList';\n\nconst grey700 = grey['700'];\n\nconst INTERVAL_6_HOURS = 6 * 60 * 60 * 1000;\nconst PERIOD_LABELS = {\n newerThan12Hours: 'Last 12 hours',\n olderThan12Hours: 'Last 24 hours',\n olderThan1Days: 'Earlier this week',\n olderThan7Days: 'Older than 7 days',\n olderThan14Days: 'Older than 14 days',\n olderThan30Days: 'Older than 30 days',\n};\n\n/** @extends {PureComponent<any, any, any>} */\nclass InfiniteList extends PureComponent {\n constructor(props) {\n super(props);\n\n this.state = {\n isLoadingByScroll: false,\n\n periodDates: this.periodDates,\n };\n\n this.updatePeriodsIntervalId = null;\n }\n\n componentDidMount() {\n this.updatePeriodsIntervalId = setInterval(\n () => this.setState({ periodDates: this.periodDates }),\n INTERVAL_6_HOURS\n );\n }\n\n componentWillUnmount() {\n if (this.updatePeriodsIntervalId) {\n clearInterval(this.updatePeriodsIntervalId);\n }\n }\n\n get periodDates() {\n return {\n hoursAgo12: moment().subtract(12, 'hours'),\n daysAgo1: moment().subtract(1, 'days'),\n daysAgo7: moment().subtract(7, 'days'),\n daysAgo14: moment().subtract(14, 'days'),\n daysAgo30: moment().subtract(30, 'days'),\n };\n }\n\n // NOTE: 'react-infinite-scroller' has a bug that when scroll reaches threshold area, it starts\n // to fire loadMore on every scroll event - bottom, up. As a result multiple same request fired.\n //\n // We fix this preventing request that was fired by scroll before previous is finished.\n //\n // Issues:\n // https://github.com/CassetteRocks/react-infinite-scroller/issues/143\n loadItems = async () => {\n if (this.state.isLoadingByScroll) {\n return;\n }\n\n this.setState({ isLoadingByScroll: true });\n\n await this.props.loadItems();\n\n this.setState({ isLoadingByScroll: false });\n };\n\n renderNoItemsLabel() {\n return (\n <div\n data-testid={`${PAGE_NAME}_noItems`}\n key=\"c-infinite-list__empty\"\n className={styles.cInfiniteListEmpty}\n >\n {this.props.noItemsFoundLabel}\n </div>\n );\n }\n\n renderPeriodSeparator(periodKey) {\n return (\n <div\n data-testid={`${PAGE_NAME}_periodLabel`}\n key={periodKey}\n className={styles.cInfiniteListPeriod}\n style={{ color: grey700 }}\n >\n {PERIOD_LABELS[periodKey]}\n </div>\n );\n }\n\n renderItems() {\n if (!this.props.divideByPeriods) {\n return this.props.items\n .map(item => this.props.renderItem(item))\n .unshift(this.props.headerComponent);\n }\n\n const { hoursAgo12, daysAgo1, daysAgo7, daysAgo14, daysAgo30 } = this.state.periodDates;\n\n const itemElsByPeriod = this.props.items.reduce(\n (result, item, index) => {\n let periodKey;\n const itemEl = this.props.renderItem(item, index);\n // NOTE: Backward compatibility for immutable objects in list\n const pathToCreatedAt = get(item, this.props.pathToCreatedAt);\n const itemAt = moment(pathToCreatedAt);\n\n if (itemAt >= hoursAgo12) {\n periodKey = 'newerThan12Hours';\n } else if (itemAt < hoursAgo12 && itemAt >= daysAgo1) {\n periodKey = 'olderThan12Hours';\n } else if (itemAt < daysAgo1 && itemAt >= daysAgo7) {\n periodKey = 'olderThan1Days';\n } else if (itemAt < daysAgo7 && itemAt >= daysAgo14) {\n periodKey = 'olderThan7Days';\n } else if (itemAt < daysAgo14 && itemAt >= daysAgo30) {\n periodKey = 'olderThan14Days';\n } else if (itemAt < daysAgo30) {\n periodKey = 'olderThan30Days';\n }\n\n return set(result, [periodKey, result[periodKey].length], itemEl);\n },\n {\n newerThan12Hours: [],\n olderThan12Hours: [],\n olderThan1Days: [],\n olderThan7Days: [],\n olderThan14Days: [],\n olderThan30Days: [],\n }\n );\n\n const itemElsWithPeriodEls = Object.keys(itemElsByPeriod).reduce((result, periodEls) => {\n if (itemElsByPeriod[periodEls].length === 0) return result.concat(itemElsByPeriod[periodEls]);\n\n return result.concat([this.renderPeriodSeparator(periodEls), ...itemElsByPeriod[periodEls]]);\n }, []);\n\n const itemElsWithPeriodElsWithHeaderEl = [this.props.headerComponent, ...itemElsWithPeriodEls];\n\n return itemElsWithPeriodElsWithHeaderEl;\n }\n\n render() {\n return (\n <div\n className={classNames(styles.cInfiniteList, this.props.infiniteClassName, {\n [styles.cInfiniteListOverflow]: !this.props.useWindow,\n })}\n style={{ height: this.props.infiniteContainerHeight }}\n >\n <InfiniteScroll\n loadMore={this.loadItems}\n hasMore={this.props.moreItemsMayExist && !this.props.showNoItemsFound}\n threshold={this.props.threshold} // NOTE: We should load infinite scroll next page before user get to bottom\n loader={<LoadingIndicator key=\"c-infinite-scroll__loader\" fullscreen={false} />}\n useWindow={this.props.useWindow}\n initialLoad={this.props.initialLoad}\n >\n {this.renderItems()}\n </InfiniteScroll>\n\n {this.props.showNoItemsFound && this.renderNoItemsLabel()}\n </div>\n );\n }\n}\n\nInfiniteList.propTypes = {\n infiniteClassName: PropTypes.string,\n useWindow: PropTypes.bool,\n headerComponent: PropTypes.node,\n // NOTE: Backward compatibility with immutable;\n // Remove when get rid of immutablejs\n items: PropTypes.arrayOf(PropTypes.shape()).isRequired,\n showNoItemsFound: PropTypes.bool.isRequired,\n noItemsFoundLabel: PropTypes.string.isRequired,\n infiniteContainerHeight: PropTypes.number,\n moreItemsMayExist: PropTypes.bool.isRequired,\n pathToCreatedAt: PropTypes.arrayOf(PropTypes.string).isRequired,\n renderItem: PropTypes.func.isRequired,\n loadItems: PropTypes.func.isRequired,\n threshold: PropTypes.number,\n initialLoad: PropTypes.bool,\n divideByPeriods: PropTypes.bool,\n};\n\nInfiniteList.defaultProps = {\n infiniteClassName: null,\n useWindow: false,\n headerComponent: null,\n infiniteContainerHeight: null,\n threshold: 3000,\n initialLoad: true,\n divideByPeriods: true,\n};\n\nexport default InfiniteList;\n"],"names":["grey700","grey","PERIOD_LABELS","newerThan12Hours","olderThan12Hours","olderThan1Days","olderThan7Days","olderThan14Days","olderThan30Days","InfiniteList","_PureComponent","_inherits","PureComponent","_super","_createSuper","props","_this","_classCallCheck","this","call","_defineProperty","_assertThisInitialized","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_context","prev","next","state","isLoadingByScroll","abrupt","setState","loadItems","stop","periodDates","updatePeriodsIntervalId","_createClass","key","value","_this2","setInterval","clearInterval","get","hoursAgo12","moment","subtract","daysAgo1","daysAgo7","daysAgo14","daysAgo30","_jsx","concat","className","styles","cInfiniteListEmpty","children","noItemsFoundLabel","periodKey","cInfiniteListPeriod","style","color","_this3","divideByPeriods","items","map","item","renderItem","unshift","headerComponent","_this$state$periodDat","itemElsByPeriod","reduce","result","index","itemEl","pathToCreatedAt","itemAt","set","length","itemElsWithPeriodEls","Object","keys","periodEls","renderPeriodSeparator","_jsxs","classNames","cInfiniteList","infiniteClassName","cInfiniteListOverflow","useWindow","height","infiniteContainerHeight","InfiniteScroll","loadMore","hasMore","moreItemsMayExist","showNoItemsFound","threshold","loader","LoadingIndicator","fullscreen","initialLoad","renderItems","renderNoItemsLabel","propTypes","PropTypes","string","bool","node","arrayOf","shape","isRequired","number","func","defaultProps"],"mappings":"8yCAYA,IAEMA,EAAUC,EAAK,KAGfC,EAAgB,CACpBC,iBAAkB,gBAClBC,iBAAkB,gBAClBC,eAAgB,oBAChBC,eAAgB,oBAChBC,gBAAiB,qBACjBC,gBAAiB,sBAIbC,EAAY,SAAAC,GAAAC,EAAAF,EAASG,GAAT,IAAAC,EAAAC,EAAAL,GAChB,SAAAA,EAAYM,GAAO,IAAAC,EASmB,OATnBC,EAAAC,KAAAT,GACjBO,EAAAH,EAAAM,KAAAD,KAAMH,GAAOK,EAyCHC,EAAAL,GAAA,YAAAM,EAAAC,EAAAC,MAAA,SAAAC,IAAA,OAAAF,EAAAG,MAAA,SAAAC,GAAA,OAAA,OAAAA,EAAAC,KAAAD,EAAAE,MAAA,KAAA,EAAA,IACNb,EAAKc,MAAMC,kBAAiB,CAAAJ,EAAAE,KAAA,EAAA,KAAA,CAAA,OAAAF,EAAAK,OAAA,UAAA,KAAA,EAIW,OAA3ChB,E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H,MAAM0E,kBACpDlC,EAAAA,CAAAA,EAAAA,EAAOmC,uBAAyBxE,KAAKH,MAAM4E,YAE9C9B,MAAO,CAAE+B,OAAQ1E,KAAKH,MAAM8E,yBAA0BpC,SAAA,CAEtDL,EAAC0C,EAAc,CACbC,SAAU7E,KAAKgB,UACf8D,QAAS9E,KAAKH,MAAMkF,oBAAsB/E,KAAKH,MAAMmF,iBACrDC,UAAWjF,KAAKH,MAAMoF,UACtBC,OAAQhD,EAACiD,EAAgB,CAAiCC,YAAY,GAAxC,6BAC9BX,UAAWzE,KAAKH,MAAM4E,UACtBY,YAAarF,KAAKH,MAAMwF,YAAY9C,SAEnCvC,KAAKsF,gBAGPtF,KAAKH,MAAMmF,kBAAoBhF,KAAKuF,uBAG3C,KAAChG,CAAA,CA5Je,GA+JlBA,EAAaiG,UAAY,CACvBjB,kBAAmBkB,EAAUC,OAC7BjB,UAAWgB,EAAUE,KACrBvC,gBAAiBqC,EAAUG,KAG3B7C,MAAO0C,EAAUI,QAAQJ,EAAUK,SAASC,WAC5Cf,iBAAkBS,EAAUE,KAAKI,WACjCvD,kBAAmBiD,EAAUC,OAAOK,WACpCpB,wBAAyBc,EAAUO,OACnCjB,kBAAmBU,EAAUE,KAAKI,WAClCpC,gBAAiB8B,EAAUI,QAAQJ,EAAUC,QAAQK,WACrD7C,WAAYuC,EAAUQ,KAAKF,WAC3B/E,UAAWyE,EAAUQ,KAAKF,WAC1Bd,UAAWQ,EAAUO,OACrBX,YAAaI,EAAUE,KACvB7C,gBAAiB2C,EAAUE,MAG7BpG,EAAa2G,aAAe,CAC1B3B,kBAAmB,KACnBE,WAAW,EACXrB,gBAAiB,KACjBuB,wBAAyB,KACzBM,UAAW,IACXI,aAAa,EACbvC,iBAAiB"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/InfiniteList/index.js"],"sourcesContent":["import { memo, useEffect, useState } from 'react';\nimport PropTypes from 'prop-types';\nimport moment from 'moment';\nimport classNames from 'classnames';\nimport { get, set } from 'lodash';\nimport InfiniteScroll from 'react-infinite-scroller';\nimport grey from '@material-ui/core/colors/grey';\n\nimport styles from './styles.css';\n\nimport LoadingIndicator from '~components/LoadingIndicator';\n\nconst PAGE_NAME = 'generic_infiniteList';\n\nconst grey700 = grey['700'];\n\nconst INTERVAL_6_HOURS = 6 * 60 * 60 * 1000;\nconst PERIOD_LABELS = {\n newerThan12Hours: 'Last 12 hours',\n olderThan12Hours: 'Last 24 hours',\n olderThan1Days: 'Earlier this week',\n olderThan7Days: 'Older than 7 days',\n olderThan14Days: 'Older than 14 days',\n olderThan30Days: 'Older than 30 days',\n};\n\nconst getPeriodDates = () => ({\n hoursAgo12: moment().subtract(12, 'hours'),\n daysAgo1: moment().subtract(1, 'days'),\n daysAgo7: moment().subtract(7, 'days'),\n daysAgo14: moment().subtract(14, 'days'),\n daysAgo30: moment().subtract(30, 'days'),\n});\n\n/** @param {any} props Preserve the legacy component's permissive public prop type. */\nfunction InfiniteList({\n infiniteClassName = null,\n useWindow = false,\n headerComponent = null,\n items,\n showNoItemsFound,\n noItemsFoundLabel,\n infiniteContainerHeight = null,\n moreItemsMayExist,\n pathToCreatedAt,\n renderItem,\n loadItems,\n threshold = 3000,\n initialLoad = true,\n divideByPeriods = true,\n}) {\n const [isLoadingByScroll, setIsLoadingByScroll] = useState(false);\n const [periodDates, setPeriodDates] = useState(getPeriodDates);\n\n useEffect(() => {\n const intervalId = setInterval(() => setPeriodDates(getPeriodDates()), INTERVAL_6_HOURS);\n return () => clearInterval(intervalId);\n }, []);\n\n // NOTE: 'react-infinite-scroller' has a bug that when scroll reaches threshold area, it starts\n // to fire loadMore on every scroll event - bottom, up. As a result multiple same request fired.\n //\n // We fix this preventing request that was fired by scroll before previous is finished.\n //\n // Issues:\n // https://github.com/CassetteRocks/react-infinite-scroller/issues/143\n const loadMore = async () => {\n if (isLoadingByScroll) {\n return;\n }\n\n setIsLoadingByScroll(true);\n\n await loadItems();\n\n setIsLoadingByScroll(false);\n };\n\n const renderNoItemsLabel = () => {\n return (\n <div\n data-testid={`${PAGE_NAME}_noItems`}\n key=\"c-infinite-list__empty\"\n className={styles.cInfiniteListEmpty}\n >\n {noItemsFoundLabel}\n </div>\n );\n };\n\n const renderPeriodSeparator = periodKey => {\n return (\n <div\n data-testid={`${PAGE_NAME}_periodLabel`}\n key={periodKey}\n className={styles.cInfiniteListPeriod}\n style={{ color: grey700 }}\n >\n {PERIOD_LABELS[periodKey]}\n </div>\n );\n };\n\n const renderItems = () => {\n if (!divideByPeriods) {\n return items.map(item => renderItem(item)).unshift(headerComponent);\n }\n\n const { hoursAgo12, daysAgo1, daysAgo7, daysAgo14, daysAgo30 } = periodDates;\n\n const itemElsByPeriod = items.reduce(\n (result, item, index) => {\n let periodKey;\n const itemEl = renderItem(item, index);\n // NOTE: Backward compatibility for immutable objects in list\n const itemCreatedAt = get(item, pathToCreatedAt);\n const itemAt = moment(itemCreatedAt);\n\n if (itemAt >= hoursAgo12) {\n periodKey = 'newerThan12Hours';\n } else if (itemAt < hoursAgo12 && itemAt >= daysAgo1) {\n periodKey = 'olderThan12Hours';\n } else if (itemAt < daysAgo1 && itemAt >= daysAgo7) {\n periodKey = 'olderThan1Days';\n } else if (itemAt < daysAgo7 && itemAt >= daysAgo14) {\n periodKey = 'olderThan7Days';\n } else if (itemAt < daysAgo14 && itemAt >= daysAgo30) {\n periodKey = 'olderThan14Days';\n } else if (itemAt < daysAgo30) {\n periodKey = 'olderThan30Days';\n }\n\n return set(result, [periodKey, result[periodKey].length], itemEl);\n },\n {\n newerThan12Hours: [],\n olderThan12Hours: [],\n olderThan1Days: [],\n olderThan7Days: [],\n olderThan14Days: [],\n olderThan30Days: [],\n }\n );\n\n const itemElsWithPeriodEls = Object.keys(itemElsByPeriod).reduce((result, periodEls) => {\n if (itemElsByPeriod[periodEls].length === 0) return result.concat(itemElsByPeriod[periodEls]);\n\n return result.concat([renderPeriodSeparator(periodEls), ...itemElsByPeriod[periodEls]]);\n }, []);\n\n const itemElsWithPeriodElsWithHeaderEl = [headerComponent, ...itemElsWithPeriodEls];\n\n return itemElsWithPeriodElsWithHeaderEl;\n };\n\n return (\n <div\n className={classNames(styles.cInfiniteList, infiniteClassName, {\n [styles.cInfiniteListOverflow]: !useWindow,\n })}\n style={{ height: infiniteContainerHeight }}\n >\n <InfiniteScroll\n loadMore={loadMore}\n hasMore={moreItemsMayExist && !showNoItemsFound}\n threshold={threshold} // NOTE: We should load infinite scroll next page before user get to bottom\n loader={<LoadingIndicator key=\"c-infinite-scroll__loader\" fullscreen={false} />}\n useWindow={useWindow}\n initialLoad={initialLoad}\n >\n {renderItems()}\n </InfiniteScroll>\n\n {showNoItemsFound && renderNoItemsLabel()}\n </div>\n );\n}\n\nInfiniteList.propTypes = {\n infiniteClassName: PropTypes.string,\n useWindow: PropTypes.bool,\n headerComponent: PropTypes.node,\n // NOTE: Backward compatibility with immutable;\n // Remove when get rid of immutablejs\n items: PropTypes.arrayOf(PropTypes.shape()).isRequired,\n showNoItemsFound: PropTypes.bool.isRequired,\n noItemsFoundLabel: PropTypes.string.isRequired,\n infiniteContainerHeight: PropTypes.number,\n moreItemsMayExist: PropTypes.bool.isRequired,\n pathToCreatedAt: PropTypes.arrayOf(PropTypes.string).isRequired,\n renderItem: PropTypes.func.isRequired,\n loadItems: PropTypes.func.isRequired,\n threshold: PropTypes.number,\n initialLoad: PropTypes.bool,\n divideByPeriods: PropTypes.bool,\n};\n\nexport default memo(InfiniteList);\n"],"names":["grey700","grey","PERIOD_LABELS","newerThan12Hours","olderThan12Hours","olderThan1Days","olderThan7Days","olderThan14Days","olderThan30Days","getPeriodDates","hoursAgo12","moment","subtract","daysAgo1","daysAgo7","daysAgo14","daysAgo30","InfiniteList","_ref","_ref$infiniteClassNam","infiniteClassName","_ref$useWindow","useWindow","_ref$headerComponent","headerComponent","items","showNoItemsFound","noItemsFoundLabel","_ref$infiniteContaine","infiniteContainerHeight","moreItemsMayExist","pathToCreatedAt","renderItem","loadItems","_ref$threshold","threshold","_ref$initialLoad","initialLoad","_ref$divideByPeriods","divideByPeriods","useState","_useState2","_slicedToArray","_useState","isLoadingByScroll","setIsLoadingByScroll","_useState4","_useState3","periodDates","setPeriodDates","useEffect","intervalId","setInterval","clearInterval","_ref2","loadMore","_asyncToGenerator","_regeneratorRuntime","mark","_callee","wrap","_context","prev","next","abrupt","stop","apply","this","arguments","_jsxs","className","classNames","styles","cInfiniteList","_defineProperty","cInfiniteListOverflow","style","height","children","_jsx","InfiniteScroll","hasMore","loader","LoadingIndicator","fullscreen","map","item","unshift","itemElsByPeriod","reduce","result","index","periodKey","itemEl","itemCreatedAt","get","itemAt","set","length","itemElsWithPeriodEls","Object","keys","periodEls","concat","cInfiniteListPeriod","color","_toConsumableArray","renderItems","cInfiniteListEmpty","propTypes","PropTypes","string","bool","node","arrayOf","shape","isRequired","number","func","memo"],"mappings":"woBAYA,IAEMA,EAAUC,EAAK,KAGfC,EAAgB,CACpBC,iBAAkB,gBAClBC,iBAAkB,gBAClBC,eAAgB,oBAChBC,eAAgB,oBAChBC,gBAAiB,qBACjBC,gBAAiB,sBAGbC,EAAiB,WAAH,MAAU,CAC5BC,WAAYC,IAASC,SAAS,GAAI,SAClCC,SAAUF,IAASC,SAAS,EAAG,QAC/BE,SAAUH,IAASC,SAAS,EAAG,QAC/BG,UAAWJ,IAASC,SAAS,GAAI,QACjCI,UAAWL,IAASC,SAAS,GAAI,QAClC,EAGD,SAASK,EAeNC,GAAA,IAAAC,EAAAD,EAdDE,kBAAAA,aAAoB,KAAID,EAAAE,EAAAH,EACxBI,UAAAA,cAAiBD,EAAAE,EAAAL,EACjBM,gBAAAA,aAAkB,KAAID,EACtBE,IAAAA,MACAC,IAAAA,iBACAC,IAAAA,kBAAiBC,EAAAV,EACjBW,wBAAAA,aAA0B,KAAID,EAC9BE,IAAAA,kBACAC,IAAAA,gBACAC,IAAAA,WACAC,IAAAA,UAASC,EAAAhB,EACTiB,UAAAA,aAAY,IAAID,EAAAE,EAAAlB,EAChBmB,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B9B,SAEpCnD,GAHG,4BA8FZ,CAEAV,EAAa4F,UAAY,CACvBzF,kBAAmB0F,EAAUC,OAC7BzF,UAAWwF,EAAUE,KACrBxF,gBAAiBsF,EAAUG,KAG3BxF,MAAOqF,EAAUI,QAAQJ,EAAUK,SAASC,WAC5C1F,iBAAkBoF,EAAUE,KAAKI,WACjCzF,kBAAmBmF,EAAUC,OAAOK,WACpCvF,wBAAyBiF,EAAUO,OACnCvF,kBAAmBgF,EAAUE,KAAKI,WAClCrF,gBAAiB+E,EAAUI,QAAQJ,EAAUC,QAAQK,WACrDpF,WAAY8E,EAAUQ,KAAKF,WAC3BnF,UAAW6E,EAAUQ,KAAKF,WAC1BjF,UAAW2E,EAAUO,OACrBhF,YAAayE,EAAUE,KACvBzE,gBAAiBuE,EAAUE,MAG7B,IAAeO,EAAAA,EAAKtG"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=PostPreviewDialog.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PostPreviewDialog.test.d.ts","sourceRoot":"","sources":["../../../../src/components/PostPreviewDialog/__tests__/PostPreviewDialog.test.js"],"names":[],"mappings":""}
@@ -1,5 +1,5 @@
1
1
  import PropTypes from 'prop-types';
2
- declare const _default: import("react").ComponentType<Pick<Pick<PropTypes.InferProps<{
2
+ declare const _default: import("react").ComponentType<Pick<PropTypes.InferProps<{
3
3
  title: PropTypes.Requireable<string>;
4
4
  open: PropTypes.Validator<boolean>;
5
5
  fileUrl: PropTypes.Requireable<string>;
@@ -14,32 +14,6 @@ declare const _default: import("react").ComponentType<Pick<Pick<PropTypes.InferP
14
14
  companyId: PropTypes.Requireable<number>;
15
15
  okButtonText: PropTypes.Requireable<string>;
16
16
  cancelButtonText: PropTypes.Requireable<string>;
17
- }>, PropTypes.RequiredKeys<{
18
- title: PropTypes.Requireable<string>;
19
- open: PropTypes.Validator<boolean>;
20
- fileUrl: PropTypes.Requireable<string>;
21
- fileName: PropTypes.Requireable<string>;
22
- fileSize: PropTypes.Requireable<number>;
23
- handleShare: PropTypes.Validator<(...args: any[]) => any>;
24
- handleClose: PropTypes.Validator<(...args: any[]) => any>;
25
- classes: PropTypes.Validator<NonNullable<PropTypes.InferProps<{}>>>;
26
- additionalFields: PropTypes.Requireable<PropTypes.ReactNodeLike[]>;
27
- requiredFields: PropTypes.Requireable<(string | null | undefined)[]>;
28
- message: PropTypes.Requireable<string>;
29
- companyId: PropTypes.Requireable<number>;
30
- okButtonText: PropTypes.Requireable<string>;
31
- cancelButtonText: PropTypes.Requireable<string>;
32
- }>> & {
33
- title?: string | null | undefined;
34
- fileUrl?: string | null | undefined;
35
- fileName?: string | null | undefined;
36
- fileSize?: number | null | undefined;
37
- additionalFields?: PropTypes.ReactNodeLike[] | null | undefined;
38
- requiredFields?: (string | null | undefined)[] | null | undefined;
39
- message?: string | null | undefined;
40
- companyId?: number | null | undefined;
41
- okButtonText?: string | null | undefined;
42
- cancelButtonText?: string | null | undefined;
43
- } & {}, "additionalFields" | "cancelButtonText" | "companyId" | "fileName" | "fileSize" | "fileUrl" | "handleClose" | "handleShare" | "message" | "okButtonText" | "open" | "requiredFields" | "title"> & import("@material-ui/styles").StyledComponentProps<"deleteButton" | "dialogActions" | "dialogContentRoot" | "fileUploadingError" | "messageWrapper" | "textFieldRoot" | "textInput">>;
17
+ }>, "additionalFields" | "cancelButtonText" | "companyId" | "fileName" | "fileSize" | "fileUrl" | "handleClose" | "handleShare" | "message" | "okButtonText" | "open" | "requiredFields" | "title"> & import("@material-ui/styles").StyledComponentProps<"deleteButton" | "dialogActions" | "dialogContentRoot" | "fileUploadingError" | "messageWrapper" | "textFieldRoot" | "textInput">>;
44
18
  export default _default;
45
19
  //# sourceMappingURL=index.d.ts.map
@@ -1,2 +1,2 @@
1
- import e from"@babel/runtime/helpers/classCallCheck";import t from"@babel/runtime/helpers/createClass";import i from"@babel/runtime/helpers/assertThisInitialized";import l from"@babel/runtime/helpers/inherits";import o from"@babel/runtime/helpers/possibleConstructorReturn";import r from"@babel/runtime/helpers/getPrototypeOf";import a from"@babel/runtime/helpers/defineProperty";import{createRef as n,PureComponent as s}from"react";import c from"prop-types";import{withStyles as p}from"@material-ui/core/styles";import d from"@material-ui/core/Paper";import m from"@material-ui/core/DialogActions";import f from"@material-ui/core/DialogContent";import h from"@material-ui/core/DialogTitle";import u from"@material-ui/core/Button";import g from"@material-ui/core/Typography";import U from"@material-ui/core/Input";import F from"@material-ui/core/RootRef";import y from"@material-ui/core/colors/grey";import v from"@material-ui/icons/Delete";import{Dialog as N}from"@material-ui/core";import{getIsImage as S}from"../../utils/fileExtension.js";import b from"./styles.css.js";import D from"../FileTypeIcon.js";import C from"../EmojiIconButton.js";import E from"../FileUploadIconButton.js";import P from"../FailedFileUploading.js";import R from"../UserMention/index.js";import{isNativeDetected as B}from"../../utils/mobileDetect.js";import{jsx as x,jsxs as w}from"react/jsx-runtime";function I(e){var t=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var i,l=r(e);if(t){var a=r(this).constructor;i=Reflect.construct(l,arguments,a)}else i=l.apply(this,arguments);return o(this,i)}}var j="PostPreviewDialog",k=y[200],T=y[400],z=function(e){return w(d,{className:e.classes.messageWrapper,children:[x(U,{"data-testid":"".concat(j,"_messageInput"),inputRef:e.inputEl,inputComponent:R,inputProps:{withLightTheme:!1,onChange:e.handleMessageChange,companyId:e.companyId,suggestionsPortalHost:e.rootRef.current},placeholder:"Add a message about the file...",fullWidth:!0,disableUnderline:!0,multiline:!0,rows:"3",className:e.classes.textFieldRoot,value:e.comment,onKeyDown:e.handleKeyDown}),w("div",{className:b.cPostPreviewDialogMessageAdditionalFieldsWrapper,children:[x("div",{children:e.additionalFields}),w("div",{className:b.cPostPreviewDialogMessageActionFields,children:[!e.fileUrl&&x(E,{htmlColor:y[400],openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:e.handleFileUpload,onError:e.handleFileUploadingError,inputId:"preview-dialog-file-upload"}),x(C,{handleSelectEmoji:e.handleSelectEmoji,emojiIconClassName:e.classes.additionalActionButton,htmlColor:y[400],disableRipple:!0})]})]})]})},A=function(e){var t=S(e.fileName);return w("div",t?{children:[w("div",{className:b.cPostPreviewDialogFileName,children:[x(g,{"data-testid":"".concat(j,"_fileName"),variant:"subtitle2",noWrap:!0,gutterBottom:!0,children:e.fileName}),x(v,{"data-testid":"".concat(j,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]}),x("div",{className:b.cPostPreviewDialogFileImageFileWrapper,children:x("img",{"data-testid":"".concat(j,"_previewImage"),className:b.cPostPreviewDialogFileImage,src:e.fileUrl,alt:"Uploaded file"})})]}:{className:b.cPostPreviewDialogFileDownload,style:{backgroundColor:k,border:"1px solid ".concat(T)},children:[x(D,{fileName:e.fileName}),w("div",{className:b.cPostPreviewDialogFileDownloadText,children:[x(g,{"data-testid":"".concat(j,"_fileName"),variant:"subtitle2",noWrap:!0,children:e.fileName}),x(v,{"data-testid":"".concat(j,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]})]})},M=function(o){l(c,s);var r=I(c);function c(t){var l;return e(this,c),l=r.call(this,t),a(i(l),"focusOnInput",(function(){return l.inputEl.current.focus()})),a(i(l),"handleKeyDown",(function(e){"Enter"===e.key&&l.handleShare()})),a(i(l),"handleMessageChange",(function(e){return l.setState({comment:e})})),a(i(l),"handleSelectEmoji",(function(e){return l.setState((function(t){var i=t.comment;return{comment:"".concat(i).concat(e.native)}}))})),a(i(l),"handleShare",(function(){l.props.handleShare(l.state.comment,l.state.fileUrl,l.state.fileSize,l.state.fileName)})),a(i(l),"handleFileDelete",(function(){l.setState({fileUrl:"",fileSize:null,fileName:""})})),a(i(l),"handleFileUpload",(function(e,t,i){l.setState({fileUrl:e,fileName:t,fileSize:i,fileUploadingError:null})})),a(i(l),"handleFileUploadingError",(function(e){l.setState({fileUrl:null,fileName:null,fileSize:null,fileUploadingError:e})})),l.state={comment:t.message,fileUrl:t.fileUrl,fileSize:t.fileSize,fileName:t.fileName,fileUploadingError:null},l.inputEl=n(),l.rootRef=n(),l}return t(c,[{key:"componentDidUpdate",value:function(e){!e.open&&this.props.open&&!this.state.comment&&this.props.message&&this.setState({comment:this.props.message}),this.props.fileUrl===e.fileUrl&&this.props.fileSize===e.fileSize&&this.props.fileName===e.fileName||this.setState({fileUrl:this.props.fileUrl,fileSize:this.props.fileSize,fileName:this.props.fileName})}},{key:"render",value:function(){return x(F,{rootRef:this.rootRef,children:w(N,{fullScreen:B,open:this.props.open,onClose:this.props.handleClose,onBackdropClick:this.props.handleClose,onEntered:this.focusOnInput,children:[x(h,{children:this.props.title}),w(f,{classes:{root:!B&&this.props.classes.dialogContentRoot},children:[x(z,{inputEl:this.inputEl,comment:this.state.comment,handleMessageChange:this.handleMessageChange,handleKeyDown:this.handleKeyDown,handleFileUpload:this.handleFileUpload,handleSelectEmoji:this.handleSelectEmoji,handleFileUploadingError:this.handleFileUploadingError,additionalFields:this.props.additionalFields,fileUrl:this.state.fileUrl,classes:this.props.classes,companyId:this.props.companyId,rootRef:this.rootRef}),this.state.fileUploadingError&&x(P,{errorMessage:this.state.fileUploadingError,className:this.props.classes.fileUploadingError}),this.state.fileUrl&&x(A,{fileName:this.state.fileName,fileUrl:this.state.fileUrl,handleFileDelete:this.handleFileDelete,handleFileUploadingError:this.handleFileUploadingError,classes:this.props.classes})]}),w(m,{className:this.props.classes.dialogActions,children:[x(u,{"data-testid":"".concat(j,"_cancelButton"),color:"primary",onClick:this.props.handleClose,children:this.props.cancelButtonText}),x(u,{"data-testid":"".concat(j,"_okButton"),color:"primary",variant:"contained",disabled:!this.state.fileUrl&&!this.state.comment||!this.props.requiredFields.every(Boolean),onClick:this.handleShare,children:this.props.okButtonText})]})]})})}}]),c}();M.propTypes={title:c.string,open:c.bool.isRequired,fileUrl:c.string,fileName:c.string,fileSize:c.number,handleShare:c.func.isRequired,handleClose:c.func.isRequired,classes:c.shape({}).isRequired,additionalFields:c.arrayOf(c.node),requiredFields:c.arrayOf(c.string),message:c.string,companyId:c.number,okButtonText:c.string,cancelButtonText:c.string},M.defaultProps={title:"Share a file",fileUrl:"",fileName:"",fileSize:null,additionalFields:[],requiredFields:[],message:"",companyId:null,okButtonText:"Post",cancelButtonText:"Cancel"};var W=p((function(e){return{dialogContentRoot:{minWidth:500},textFieldRoot:{marginBottom:20},textInput:{paddingTop:2},messageWrapper:{padding:"18.5px 14px",border:"solid 1px ".concat(e.palette.primary.main),boxShadow:"none"},dialogActions:{padding:"24px 24px",margin:0},deleteButton:{color:"#DADADA",cursor:"pointer"},fileUploadingError:{marginTop:10}}}))(M);export{W as default};
1
+ import e from"@babel/runtime/helpers/defineProperty";import i from"@babel/runtime/helpers/slicedToArray";import{memo as o,useState as r,useRef as l,useLayoutEffect as t,useCallback as n}from"react";import a from"prop-types";import{withStyles as c}from"@material-ui/core/styles";import s from"@material-ui/core/Paper";import d from"@material-ui/core/DialogActions";import m from"@material-ui/core/DialogContent";import f from"@material-ui/core/DialogTitle";import p from"@material-ui/core/Button";import u from"@material-ui/core/Typography";import g from"@material-ui/core/Input";import h from"@material-ui/core/RootRef";import v from"@material-ui/core/colors/grey";import y from"@material-ui/icons/Delete";import{Dialog as U}from"@material-ui/core";import{getIsImage as N}from"../../utils/fileExtension.js";import b from"./styles.css.js";import P from"../FileTypeIcon.js";import D from"../EmojiIconButton.js";import F from"../FileUploadIconButton.js";import j from"../FailedFileUploading.js";import w from"../UserMention/index.js";import{isNativeDetected as E}from"../../utils/mobileDetect.js";import{jsx as S,jsxs as C}from"react/jsx-runtime";function O(e,i){var o=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);i&&(r=r.filter((function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable}))),o.push.apply(o,r)}return o}function x(i){for(var o=1;o<arguments.length;o++){var r=null!=arguments[o]?arguments[o]:{};o%2?O(Object(r),!0).forEach((function(o){e(i,o,r[o])})):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(r)):O(Object(r)).forEach((function(e){Object.defineProperty(i,e,Object.getOwnPropertyDescriptor(r,e))}))}return i}var B="PostPreviewDialog",I=v[200],R=v[400],T=function(e){return C(s,{className:e.classes.messageWrapper,children:[S(g,{"data-testid":"".concat(B,"_messageInput"),inputRef:e.inputEl,inputComponent:w,inputProps:{withLightTheme:!1,onChange:e.handleMessageChange,companyId:e.companyId,suggestionsPortalHost:e.rootRef.current},placeholder:"Add a message about the file...",fullWidth:!0,disableUnderline:!0,multiline:!0,rows:"3",className:e.classes.textFieldRoot,value:e.comment,onKeyDown:e.handleKeyDown}),C("div",{className:b.cPostPreviewDialogMessageAdditionalFieldsWrapper,children:[S("div",{children:e.additionalFields}),C("div",{className:b.cPostPreviewDialogMessageActionFields,children:[!e.fileUrl&&S(F,{htmlColor:v[400],openPreviewDialogOnUpload:!1,disableRipple:!0,onFinish:e.handleFileUpload,onError:e.handleFileUploadingError,inputId:"preview-dialog-file-upload"}),S(D,{handleSelectEmoji:e.handleSelectEmoji,emojiIconClassName:e.classes.additionalActionButton,htmlColor:v[400],disableRipple:!0})]})]})]})},k=function(e){var i=N(e.fileName);return C("div",i?{children:[C("div",{className:b.cPostPreviewDialogFileName,children:[S(u,{"data-testid":"".concat(B,"_fileName"),variant:"subtitle2",noWrap:!0,gutterBottom:!0,children:e.fileName}),S(y,{"data-testid":"".concat(B,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]}),S("div",{className:b.cPostPreviewDialogFileImageFileWrapper,children:S("img",{"data-testid":"".concat(B,"_previewImage"),className:b.cPostPreviewDialogFileImage,src:e.fileUrl,alt:"Uploaded file"})})]}:{className:b.cPostPreviewDialogFileDownload,style:{backgroundColor:I,border:"1px solid ".concat(R)},children:[S(P,{fileName:e.fileName}),C("div",{className:b.cPostPreviewDialogFileDownloadText,children:[S(u,{"data-testid":"".concat(B,"_fileName"),variant:"subtitle2",noWrap:!0,children:e.fileName}),S(y,{"data-testid":"".concat(B,"_deleteButton"),color:"action",onClick:e.handleFileDelete,className:e.classes.deleteButton})]})]})},z=[];function A(e){var o=e.title,a=void 0===o?"Share a file":o,c=e.open,s=e.fileUrl,u=void 0===s?"":s,g=e.fileName,v=void 0===g?"":g,y=e.fileSize,N=void 0===y?null:y,b=e.handleShare,P=e.handleClose,D=e.classes,F=e.additionalFields,w=void 0===F?z:F,O=e.requiredFields,I=void 0===O?z:O,R=e.message,A=void 0===R?"":R,W=e.companyId,_=void 0===W?null:W,q=e.okButtonText,M=void 0===q?"Post":q,K=e.cancelButtonText,H=void 0===K?"Cancel":K,L=r((function(){return{comment:A,fileUrl:u,fileSize:N,fileName:v,fileUploadingError:null}})),G=i(L,2),J=G[0],Q=G[1],V=l(null),X=l(null),Y=l({open:c,fileUrl:u,fileSize:N,fileName:v});t((function(){var e=Y.current;Y.current={open:c,fileUrl:u,fileSize:N,fileName:v};var i=!e.open&&c&&!J.comment&&A,o=u!==e.fileUrl||N!==e.fileSize||v!==e.fileName;(i||o)&&Q((function(e){return x(x(x({},e),i?{comment:A}:{}),o?{fileUrl:u,fileSize:N,fileName:v}:{})}))}),[c,u,N,v,A,J.comment]);var Z=function(){return b(J.comment,J.fileUrl,J.fileSize,J.fileName)},$=n((function(e){return Q((function(i){return x(x({},i),{},{comment:"".concat(i.comment).concat(e.native)})}))}),[]),ee=n((function(e,i,o){return Q((function(r){return x(x({},r),{},{fileUrl:e,fileName:i,fileSize:o,fileUploadingError:null})}))}),[]),ie=n((function(e){return Q((function(i){return x(x({},i),{},{fileUrl:null,fileName:null,fileSize:null,fileUploadingError:e})}))}),[]);return S(h,{rootRef:X,children:C(U,{fullScreen:E,open:c,onClose:P,onBackdropClick:P,onEntered:function(){return V.current.focus()},children:[S(f,{children:a}),C(m,{classes:{root:!E&&D.dialogContentRoot},children:[S(T,{inputEl:V,comment:J.comment,handleMessageChange:function(e){return Q((function(i){return x(x({},i),{},{comment:e})}))},handleKeyDown:function(e){"Enter"===e.key&&Z()},handleFileUpload:ee,handleSelectEmoji:$,handleFileUploadingError:ie,additionalFields:w,fileUrl:J.fileUrl,classes:D,companyId:_,rootRef:X}),J.fileUploadingError&&S(j,{errorMessage:J.fileUploadingError,className:D.fileUploadingError}),J.fileUrl&&S(k,{fileName:J.fileName,fileUrl:J.fileUrl,handleFileDelete:function(){return Q((function(e){return x(x({},e),{},{fileUrl:"",fileSize:null,fileName:""})}))},handleFileUploadingError:ie,classes:D})]}),C(d,{className:D.dialogActions,children:[S(p,{"data-testid":"".concat(B,"_cancelButton"),color:"primary",onClick:P,children:H}),S(p,{"data-testid":"".concat(B,"_okButton"),color:"primary",variant:"contained",disabled:!J.fileUrl&&!J.comment||!I.every(Boolean),onClick:Z,children:M})]})]})})}A.propTypes={title:a.string,open:a.bool.isRequired,fileUrl:a.string,fileName:a.string,fileSize:a.number,handleShare:a.func.isRequired,handleClose:a.func.isRequired,classes:a.shape({}).isRequired,additionalFields:a.arrayOf(a.node),requiredFields:a.arrayOf(a.string),message:a.string,companyId:a.number,okButtonText:a.string,cancelButtonText:a.string};var W=c((function(e){return{dialogContentRoot:{minWidth:500},textFieldRoot:{marginBottom:20},textInput:{paddingTop:2},messageWrapper:{padding:"18.5px 14px",border:"solid 1px ".concat(e.palette.primary.main),boxShadow:"none"},dialogActions:{padding:"24px 24px",margin:0},deleteButton:{color:"#DADADA",cursor:"pointer"},fileUploadingError:{marginTop:10}}}))(o(A));export{W as default};
2
2
  //# sourceMappingURL=index.js.map