index.js 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637
  1. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  2. var React = require('react');
  3. var React__default = _interopDefault(React);
  4. var core = require('@material-ui/core');
  5. var AddIcon = _interopDefault(require('@material-ui/icons/Add'));
  6. var styles = require('@material-ui/core/styles');
  7. var Autocomplete = require('@material-ui/lab/Autocomplete');
  8. var Autocomplete__default = _interopDefault(Autocomplete);
  9. var Table = _interopDefault(require('@material-ui/core/Table'));
  10. var TableBody = _interopDefault(require('@material-ui/core/TableBody'));
  11. var TableCell = _interopDefault(require('@material-ui/core/TableCell'));
  12. var TableContainer = _interopDefault(require('@material-ui/core/TableContainer'));
  13. var TableHead = _interopDefault(require('@material-ui/core/TableHead'));
  14. var TablePagination = _interopDefault(require('@material-ui/core/TablePagination'));
  15. var TableRow = _interopDefault(require('@material-ui/core/TableRow'));
  16. var TableSortLabel = _interopDefault(require('@material-ui/core/TableSortLabel'));
  17. require('@material-ui/core/Typography');
  18. var EditIcon = _interopDefault(require('@material-ui/icons/Edit'));
  19. var ExpandMore = _interopDefault(require('@material-ui/icons/ExpandMore'));
  20. var CircularProgress = _interopDefault(require('@material-ui/core/CircularProgress'));
  21. function List(_ref) {
  22. var groupName = _ref.groupName,
  23. _ref$members = _ref.members,
  24. members = _ref$members === void 0 ? [] : _ref$members;
  25. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement("h1", null, "1.0.3"), /*#__PURE__*/React__default.createElement("h5", null, "Group: ", /*#__PURE__*/React__default.createElement("em", null, groupName)), /*#__PURE__*/React__default.createElement("ul", null, /*#__PURE__*/React__default.createElement("p", null, "Members"), members.map(function (member) {
  26. return /*#__PURE__*/React__default.createElement("li", {
  27. key: member
  28. }, member);
  29. })));
  30. }
  31. function _extends() {
  32. _extends = Object.assign || function (target) {
  33. for (var i = 1; i < arguments.length; i++) {
  34. var source = arguments[i];
  35. for (var key in source) {
  36. if (Object.prototype.hasOwnProperty.call(source, key)) {
  37. target[key] = source[key];
  38. }
  39. }
  40. }
  41. return target;
  42. };
  43. return _extends.apply(this, arguments);
  44. }
  45. function createCommonjsModule(fn, module) {
  46. return module = { exports: {} }, fn(module, module.exports), module.exports;
  47. }
  48. /** @license React v16.13.1
  49. * react-is.production.min.js
  50. *
  51. * Copyright (c) Facebook, Inc. and its affiliates.
  52. *
  53. * This source code is licensed under the MIT license found in the
  54. * LICENSE file in the root directory of this source tree.
  55. */
  56. var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
  57. Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
  58. function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}var AsyncMode=l;var ConcurrentMode=m;var ContextConsumer=k;var ContextProvider=h;var Element=c;var ForwardRef=n;var Fragment=e;var Lazy=t;var Memo=r;var Portal=d;
  59. var Profiler=g;var StrictMode=f;var Suspense=p;var isAsyncMode=function(a){return A(a)||z(a)===l};var isConcurrentMode=A;var isContextConsumer=function(a){return z(a)===k};var isContextProvider=function(a){return z(a)===h};var isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};var isForwardRef=function(a){return z(a)===n};var isFragment=function(a){return z(a)===e};var isLazy=function(a){return z(a)===t};
  60. var isMemo=function(a){return z(a)===r};var isPortal=function(a){return z(a)===d};var isProfiler=function(a){return z(a)===g};var isStrictMode=function(a){return z(a)===f};var isSuspense=function(a){return z(a)===p};
  61. var isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};var typeOf=z;
  62. var reactIs_production_min = {
  63. AsyncMode: AsyncMode,
  64. ConcurrentMode: ConcurrentMode,
  65. ContextConsumer: ContextConsumer,
  66. ContextProvider: ContextProvider,
  67. Element: Element,
  68. ForwardRef: ForwardRef,
  69. Fragment: Fragment,
  70. Lazy: Lazy,
  71. Memo: Memo,
  72. Portal: Portal,
  73. Profiler: Profiler,
  74. StrictMode: StrictMode,
  75. Suspense: Suspense,
  76. isAsyncMode: isAsyncMode,
  77. isConcurrentMode: isConcurrentMode,
  78. isContextConsumer: isContextConsumer,
  79. isContextProvider: isContextProvider,
  80. isElement: isElement,
  81. isForwardRef: isForwardRef,
  82. isFragment: isFragment,
  83. isLazy: isLazy,
  84. isMemo: isMemo,
  85. isPortal: isPortal,
  86. isProfiler: isProfiler,
  87. isStrictMode: isStrictMode,
  88. isSuspense: isSuspense,
  89. isValidElementType: isValidElementType,
  90. typeOf: typeOf
  91. };
  92. var reactIs_development = createCommonjsModule(function (module, exports) {
  93. if (process.env.NODE_ENV !== "production") {
  94. (function() {
  95. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  96. // nor polyfill, then a plain number is used for performance.
  97. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  98. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  99. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  100. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  101. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  102. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  103. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  104. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  105. // (unstable) APIs that have been removed. Can we remove the symbols?
  106. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  107. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  108. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  109. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  110. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  111. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  112. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  113. var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
  114. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  115. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  116. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  117. function isValidElementType(type) {
  118. return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  119. type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
  120. }
  121. function typeOf(object) {
  122. if (typeof object === 'object' && object !== null) {
  123. var $$typeof = object.$$typeof;
  124. switch ($$typeof) {
  125. case REACT_ELEMENT_TYPE:
  126. var type = object.type;
  127. switch (type) {
  128. case REACT_ASYNC_MODE_TYPE:
  129. case REACT_CONCURRENT_MODE_TYPE:
  130. case REACT_FRAGMENT_TYPE:
  131. case REACT_PROFILER_TYPE:
  132. case REACT_STRICT_MODE_TYPE:
  133. case REACT_SUSPENSE_TYPE:
  134. return type;
  135. default:
  136. var $$typeofType = type && type.$$typeof;
  137. switch ($$typeofType) {
  138. case REACT_CONTEXT_TYPE:
  139. case REACT_FORWARD_REF_TYPE:
  140. case REACT_LAZY_TYPE:
  141. case REACT_MEMO_TYPE:
  142. case REACT_PROVIDER_TYPE:
  143. return $$typeofType;
  144. default:
  145. return $$typeof;
  146. }
  147. }
  148. case REACT_PORTAL_TYPE:
  149. return $$typeof;
  150. }
  151. }
  152. return undefined;
  153. } // AsyncMode is deprecated along with isAsyncMode
  154. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  155. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  156. var ContextConsumer = REACT_CONTEXT_TYPE;
  157. var ContextProvider = REACT_PROVIDER_TYPE;
  158. var Element = REACT_ELEMENT_TYPE;
  159. var ForwardRef = REACT_FORWARD_REF_TYPE;
  160. var Fragment = REACT_FRAGMENT_TYPE;
  161. var Lazy = REACT_LAZY_TYPE;
  162. var Memo = REACT_MEMO_TYPE;
  163. var Portal = REACT_PORTAL_TYPE;
  164. var Profiler = REACT_PROFILER_TYPE;
  165. var StrictMode = REACT_STRICT_MODE_TYPE;
  166. var Suspense = REACT_SUSPENSE_TYPE;
  167. var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
  168. function isAsyncMode(object) {
  169. {
  170. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  171. hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
  172. console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
  173. }
  174. }
  175. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  176. }
  177. function isConcurrentMode(object) {
  178. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  179. }
  180. function isContextConsumer(object) {
  181. return typeOf(object) === REACT_CONTEXT_TYPE;
  182. }
  183. function isContextProvider(object) {
  184. return typeOf(object) === REACT_PROVIDER_TYPE;
  185. }
  186. function isElement(object) {
  187. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  188. }
  189. function isForwardRef(object) {
  190. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  191. }
  192. function isFragment(object) {
  193. return typeOf(object) === REACT_FRAGMENT_TYPE;
  194. }
  195. function isLazy(object) {
  196. return typeOf(object) === REACT_LAZY_TYPE;
  197. }
  198. function isMemo(object) {
  199. return typeOf(object) === REACT_MEMO_TYPE;
  200. }
  201. function isPortal(object) {
  202. return typeOf(object) === REACT_PORTAL_TYPE;
  203. }
  204. function isProfiler(object) {
  205. return typeOf(object) === REACT_PROFILER_TYPE;
  206. }
  207. function isStrictMode(object) {
  208. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  209. }
  210. function isSuspense(object) {
  211. return typeOf(object) === REACT_SUSPENSE_TYPE;
  212. }
  213. exports.AsyncMode = AsyncMode;
  214. exports.ConcurrentMode = ConcurrentMode;
  215. exports.ContextConsumer = ContextConsumer;
  216. exports.ContextProvider = ContextProvider;
  217. exports.Element = Element;
  218. exports.ForwardRef = ForwardRef;
  219. exports.Fragment = Fragment;
  220. exports.Lazy = Lazy;
  221. exports.Memo = Memo;
  222. exports.Portal = Portal;
  223. exports.Profiler = Profiler;
  224. exports.StrictMode = StrictMode;
  225. exports.Suspense = Suspense;
  226. exports.isAsyncMode = isAsyncMode;
  227. exports.isConcurrentMode = isConcurrentMode;
  228. exports.isContextConsumer = isContextConsumer;
  229. exports.isContextProvider = isContextProvider;
  230. exports.isElement = isElement;
  231. exports.isForwardRef = isForwardRef;
  232. exports.isFragment = isFragment;
  233. exports.isLazy = isLazy;
  234. exports.isMemo = isMemo;
  235. exports.isPortal = isPortal;
  236. exports.isProfiler = isProfiler;
  237. exports.isStrictMode = isStrictMode;
  238. exports.isSuspense = isSuspense;
  239. exports.isValidElementType = isValidElementType;
  240. exports.typeOf = typeOf;
  241. })();
  242. }
  243. });
  244. var reactIs = createCommonjsModule(function (module) {
  245. if (process.env.NODE_ENV === 'production') {
  246. module.exports = reactIs_production_min;
  247. } else {
  248. module.exports = reactIs_development;
  249. }
  250. });
  251. /*
  252. object-assign
  253. (c) Sindre Sorhus
  254. @license MIT
  255. */
  256. /* eslint-disable no-unused-vars */
  257. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  258. var hasOwnProperty = Object.prototype.hasOwnProperty;
  259. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  260. function toObject(val) {
  261. if (val === null || val === undefined) {
  262. throw new TypeError('Object.assign cannot be called with null or undefined');
  263. }
  264. return Object(val);
  265. }
  266. function shouldUseNative() {
  267. try {
  268. if (!Object.assign) {
  269. return false;
  270. }
  271. // Detect buggy property enumeration order in older V8 versions.
  272. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  273. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  274. test1[5] = 'de';
  275. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  276. return false;
  277. }
  278. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  279. var test2 = {};
  280. for (var i = 0; i < 10; i++) {
  281. test2['_' + String.fromCharCode(i)] = i;
  282. }
  283. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  284. return test2[n];
  285. });
  286. if (order2.join('') !== '0123456789') {
  287. return false;
  288. }
  289. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  290. var test3 = {};
  291. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  292. test3[letter] = letter;
  293. });
  294. if (Object.keys(Object.assign({}, test3)).join('') !==
  295. 'abcdefghijklmnopqrst') {
  296. return false;
  297. }
  298. return true;
  299. } catch (err) {
  300. // We don't expect any of the above to throw, but better to be safe.
  301. return false;
  302. }
  303. }
  304. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  305. var from;
  306. var to = toObject(target);
  307. var symbols;
  308. for (var s = 1; s < arguments.length; s++) {
  309. from = Object(arguments[s]);
  310. for (var key in from) {
  311. if (hasOwnProperty.call(from, key)) {
  312. to[key] = from[key];
  313. }
  314. }
  315. if (getOwnPropertySymbols) {
  316. symbols = getOwnPropertySymbols(from);
  317. for (var i = 0; i < symbols.length; i++) {
  318. if (propIsEnumerable.call(from, symbols[i])) {
  319. to[symbols[i]] = from[symbols[i]];
  320. }
  321. }
  322. }
  323. }
  324. return to;
  325. };
  326. /**
  327. * Copyright (c) 2013-present, Facebook, Inc.
  328. *
  329. * This source code is licensed under the MIT license found in the
  330. * LICENSE file in the root directory of this source tree.
  331. */
  332. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  333. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  334. var printWarning = function() {};
  335. if (process.env.NODE_ENV !== 'production') {
  336. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  337. var loggedTypeFailures = {};
  338. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  339. printWarning = function(text) {
  340. var message = 'Warning: ' + text;
  341. if (typeof console !== 'undefined') {
  342. console.error(message);
  343. }
  344. try {
  345. // --- Welcome to debugging React ---
  346. // This error was thrown as a convenience so that you can use this stack
  347. // to find the callsite that caused this warning to fire.
  348. throw new Error(message);
  349. } catch (x) {}
  350. };
  351. }
  352. /**
  353. * Assert that the values match with the type specs.
  354. * Error messages are memorized and will only be shown once.
  355. *
  356. * @param {object} typeSpecs Map of name to a ReactPropType
  357. * @param {object} values Runtime values that need to be type-checked
  358. * @param {string} location e.g. "prop", "context", "child context"
  359. * @param {string} componentName Name of the component for error messages.
  360. * @param {?Function} getStack Returns the component stack.
  361. * @private
  362. */
  363. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  364. if (process.env.NODE_ENV !== 'production') {
  365. for (var typeSpecName in typeSpecs) {
  366. if (has(typeSpecs, typeSpecName)) {
  367. var error;
  368. // Prop type validation may throw. In case they do, we don't want to
  369. // fail the render phase where it didn't fail before. So we log it.
  370. // After these have been cleaned up, we'll let them throw.
  371. try {
  372. // This is intentionally an invariant that gets caught. It's the same
  373. // behavior as without this statement except with a better message.
  374. if (typeof typeSpecs[typeSpecName] !== 'function') {
  375. var err = Error(
  376. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  377. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  378. );
  379. err.name = 'Invariant Violation';
  380. throw err;
  381. }
  382. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  383. } catch (ex) {
  384. error = ex;
  385. }
  386. if (error && !(error instanceof Error)) {
  387. printWarning(
  388. (componentName || 'React class') + ': type specification of ' +
  389. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  390. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  391. 'You may have forgotten to pass an argument to the type checker ' +
  392. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  393. 'shape all require an argument).'
  394. );
  395. }
  396. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  397. // Only monitor this failure once because there tends to be a lot of the
  398. // same error.
  399. loggedTypeFailures[error.message] = true;
  400. var stack = getStack ? getStack() : '';
  401. printWarning(
  402. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  403. );
  404. }
  405. }
  406. }
  407. }
  408. }
  409. /**
  410. * Resets warning cache when testing.
  411. *
  412. * @private
  413. */
  414. checkPropTypes.resetWarningCache = function() {
  415. if (process.env.NODE_ENV !== 'production') {
  416. loggedTypeFailures = {};
  417. }
  418. };
  419. var checkPropTypes_1 = checkPropTypes;
  420. var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  421. var printWarning$1 = function() {};
  422. if (process.env.NODE_ENV !== 'production') {
  423. printWarning$1 = function(text) {
  424. var message = 'Warning: ' + text;
  425. if (typeof console !== 'undefined') {
  426. console.error(message);
  427. }
  428. try {
  429. // --- Welcome to debugging React ---
  430. // This error was thrown as a convenience so that you can use this stack
  431. // to find the callsite that caused this warning to fire.
  432. throw new Error(message);
  433. } catch (x) {}
  434. };
  435. }
  436. function emptyFunctionThatReturnsNull() {
  437. return null;
  438. }
  439. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  440. /* global Symbol */
  441. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  442. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  443. /**
  444. * Returns the iterator method function contained on the iterable object.
  445. *
  446. * Be sure to invoke the function with the iterable as context:
  447. *
  448. * var iteratorFn = getIteratorFn(myIterable);
  449. * if (iteratorFn) {
  450. * var iterator = iteratorFn.call(myIterable);
  451. * ...
  452. * }
  453. *
  454. * @param {?object} maybeIterable
  455. * @return {?function}
  456. */
  457. function getIteratorFn(maybeIterable) {
  458. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  459. if (typeof iteratorFn === 'function') {
  460. return iteratorFn;
  461. }
  462. }
  463. /**
  464. * Collection of methods that allow declaration and validation of props that are
  465. * supplied to React components. Example usage:
  466. *
  467. * var Props = require('ReactPropTypes');
  468. * var MyArticle = React.createClass({
  469. * propTypes: {
  470. * // An optional string prop named "description".
  471. * description: Props.string,
  472. *
  473. * // A required enum prop named "category".
  474. * category: Props.oneOf(['News','Photos']).isRequired,
  475. *
  476. * // A prop named "dialog" that requires an instance of Dialog.
  477. * dialog: Props.instanceOf(Dialog).isRequired
  478. * },
  479. * render: function() { ... }
  480. * });
  481. *
  482. * A more formal specification of how these methods are used:
  483. *
  484. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  485. * decl := ReactPropTypes.{type}(.isRequired)?
  486. *
  487. * Each and every declaration produces a function with the same signature. This
  488. * allows the creation of custom validation functions. For example:
  489. *
  490. * var MyLink = React.createClass({
  491. * propTypes: {
  492. * // An optional string or URI prop named "href".
  493. * href: function(props, propName, componentName) {
  494. * var propValue = props[propName];
  495. * if (propValue != null && typeof propValue !== 'string' &&
  496. * !(propValue instanceof URI)) {
  497. * return new Error(
  498. * 'Expected a string or an URI for ' + propName + ' in ' +
  499. * componentName
  500. * );
  501. * }
  502. * }
  503. * },
  504. * render: function() {...}
  505. * });
  506. *
  507. * @internal
  508. */
  509. var ANONYMOUS = '<<anonymous>>';
  510. // Important!
  511. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  512. var ReactPropTypes = {
  513. array: createPrimitiveTypeChecker('array'),
  514. bool: createPrimitiveTypeChecker('boolean'),
  515. func: createPrimitiveTypeChecker('function'),
  516. number: createPrimitiveTypeChecker('number'),
  517. object: createPrimitiveTypeChecker('object'),
  518. string: createPrimitiveTypeChecker('string'),
  519. symbol: createPrimitiveTypeChecker('symbol'),
  520. any: createAnyTypeChecker(),
  521. arrayOf: createArrayOfTypeChecker,
  522. element: createElementTypeChecker(),
  523. elementType: createElementTypeTypeChecker(),
  524. instanceOf: createInstanceTypeChecker,
  525. node: createNodeChecker(),
  526. objectOf: createObjectOfTypeChecker,
  527. oneOf: createEnumTypeChecker,
  528. oneOfType: createUnionTypeChecker,
  529. shape: createShapeTypeChecker,
  530. exact: createStrictShapeTypeChecker,
  531. };
  532. /**
  533. * inlined Object.is polyfill to avoid requiring consumers ship their own
  534. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  535. */
  536. /*eslint-disable no-self-compare*/
  537. function is(x, y) {
  538. // SameValue algorithm
  539. if (x === y) {
  540. // Steps 1-5, 7-10
  541. // Steps 6.b-6.e: +0 != -0
  542. return x !== 0 || 1 / x === 1 / y;
  543. } else {
  544. // Step 6.a: NaN == NaN
  545. return x !== x && y !== y;
  546. }
  547. }
  548. /*eslint-enable no-self-compare*/
  549. /**
  550. * We use an Error-like object for backward compatibility as people may call
  551. * PropTypes directly and inspect their output. However, we don't use real
  552. * Errors anymore. We don't inspect their stack anyway, and creating them
  553. * is prohibitively expensive if they are created too often, such as what
  554. * happens in oneOfType() for any type before the one that matched.
  555. */
  556. function PropTypeError(message) {
  557. this.message = message;
  558. this.stack = '';
  559. }
  560. // Make `instanceof Error` still work for returned errors.
  561. PropTypeError.prototype = Error.prototype;
  562. function createChainableTypeChecker(validate) {
  563. if (process.env.NODE_ENV !== 'production') {
  564. var manualPropTypeCallCache = {};
  565. var manualPropTypeWarningCount = 0;
  566. }
  567. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  568. componentName = componentName || ANONYMOUS;
  569. propFullName = propFullName || propName;
  570. if (secret !== ReactPropTypesSecret_1) {
  571. if (throwOnDirectAccess) {
  572. // New behavior only for users of `prop-types` package
  573. var err = new Error(
  574. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  575. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  576. 'Read more at http://fb.me/use-check-prop-types'
  577. );
  578. err.name = 'Invariant Violation';
  579. throw err;
  580. } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
  581. // Old behavior for people using React.PropTypes
  582. var cacheKey = componentName + ':' + propName;
  583. if (
  584. !manualPropTypeCallCache[cacheKey] &&
  585. // Avoid spamming the console because they are often not actionable except for lib authors
  586. manualPropTypeWarningCount < 3
  587. ) {
  588. printWarning$1(
  589. 'You are manually calling a React.PropTypes validation ' +
  590. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  591. 'and will throw in the standalone `prop-types` package. ' +
  592. 'You may be seeing this warning due to a third-party PropTypes ' +
  593. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  594. );
  595. manualPropTypeCallCache[cacheKey] = true;
  596. manualPropTypeWarningCount++;
  597. }
  598. }
  599. }
  600. if (props[propName] == null) {
  601. if (isRequired) {
  602. if (props[propName] === null) {
  603. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  604. }
  605. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  606. }
  607. return null;
  608. } else {
  609. return validate(props, propName, componentName, location, propFullName);
  610. }
  611. }
  612. var chainedCheckType = checkType.bind(null, false);
  613. chainedCheckType.isRequired = checkType.bind(null, true);
  614. return chainedCheckType;
  615. }
  616. function createPrimitiveTypeChecker(expectedType) {
  617. function validate(props, propName, componentName, location, propFullName, secret) {
  618. var propValue = props[propName];
  619. var propType = getPropType(propValue);
  620. if (propType !== expectedType) {
  621. // `propValue` being instance of, say, date/regexp, pass the 'object'
  622. // check, but we can offer a more precise error message here rather than
  623. // 'of type `object`'.
  624. var preciseType = getPreciseType(propValue);
  625. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  626. }
  627. return null;
  628. }
  629. return createChainableTypeChecker(validate);
  630. }
  631. function createAnyTypeChecker() {
  632. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  633. }
  634. function createArrayOfTypeChecker(typeChecker) {
  635. function validate(props, propName, componentName, location, propFullName) {
  636. if (typeof typeChecker !== 'function') {
  637. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  638. }
  639. var propValue = props[propName];
  640. if (!Array.isArray(propValue)) {
  641. var propType = getPropType(propValue);
  642. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  643. }
  644. for (var i = 0; i < propValue.length; i++) {
  645. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  646. if (error instanceof Error) {
  647. return error;
  648. }
  649. }
  650. return null;
  651. }
  652. return createChainableTypeChecker(validate);
  653. }
  654. function createElementTypeChecker() {
  655. function validate(props, propName, componentName, location, propFullName) {
  656. var propValue = props[propName];
  657. if (!isValidElement(propValue)) {
  658. var propType = getPropType(propValue);
  659. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  660. }
  661. return null;
  662. }
  663. return createChainableTypeChecker(validate);
  664. }
  665. function createElementTypeTypeChecker() {
  666. function validate(props, propName, componentName, location, propFullName) {
  667. var propValue = props[propName];
  668. if (!reactIs.isValidElementType(propValue)) {
  669. var propType = getPropType(propValue);
  670. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  671. }
  672. return null;
  673. }
  674. return createChainableTypeChecker(validate);
  675. }
  676. function createInstanceTypeChecker(expectedClass) {
  677. function validate(props, propName, componentName, location, propFullName) {
  678. if (!(props[propName] instanceof expectedClass)) {
  679. var expectedClassName = expectedClass.name || ANONYMOUS;
  680. var actualClassName = getClassName(props[propName]);
  681. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  682. }
  683. return null;
  684. }
  685. return createChainableTypeChecker(validate);
  686. }
  687. function createEnumTypeChecker(expectedValues) {
  688. if (!Array.isArray(expectedValues)) {
  689. if (process.env.NODE_ENV !== 'production') {
  690. if (arguments.length > 1) {
  691. printWarning$1(
  692. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  693. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  694. );
  695. } else {
  696. printWarning$1('Invalid argument supplied to oneOf, expected an array.');
  697. }
  698. }
  699. return emptyFunctionThatReturnsNull;
  700. }
  701. function validate(props, propName, componentName, location, propFullName) {
  702. var propValue = props[propName];
  703. for (var i = 0; i < expectedValues.length; i++) {
  704. if (is(propValue, expectedValues[i])) {
  705. return null;
  706. }
  707. }
  708. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  709. var type = getPreciseType(value);
  710. if (type === 'symbol') {
  711. return String(value);
  712. }
  713. return value;
  714. });
  715. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  716. }
  717. return createChainableTypeChecker(validate);
  718. }
  719. function createObjectOfTypeChecker(typeChecker) {
  720. function validate(props, propName, componentName, location, propFullName) {
  721. if (typeof typeChecker !== 'function') {
  722. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  723. }
  724. var propValue = props[propName];
  725. var propType = getPropType(propValue);
  726. if (propType !== 'object') {
  727. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  728. }
  729. for (var key in propValue) {
  730. if (has$1(propValue, key)) {
  731. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  732. if (error instanceof Error) {
  733. return error;
  734. }
  735. }
  736. }
  737. return null;
  738. }
  739. return createChainableTypeChecker(validate);
  740. }
  741. function createUnionTypeChecker(arrayOfTypeCheckers) {
  742. if (!Array.isArray(arrayOfTypeCheckers)) {
  743. process.env.NODE_ENV !== 'production' ? printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  744. return emptyFunctionThatReturnsNull;
  745. }
  746. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  747. var checker = arrayOfTypeCheckers[i];
  748. if (typeof checker !== 'function') {
  749. printWarning$1(
  750. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  751. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  752. );
  753. return emptyFunctionThatReturnsNull;
  754. }
  755. }
  756. function validate(props, propName, componentName, location, propFullName) {
  757. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  758. var checker = arrayOfTypeCheckers[i];
  759. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  760. return null;
  761. }
  762. }
  763. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  764. }
  765. return createChainableTypeChecker(validate);
  766. }
  767. function createNodeChecker() {
  768. function validate(props, propName, componentName, location, propFullName) {
  769. if (!isNode(props[propName])) {
  770. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  771. }
  772. return null;
  773. }
  774. return createChainableTypeChecker(validate);
  775. }
  776. function createShapeTypeChecker(shapeTypes) {
  777. function validate(props, propName, componentName, location, propFullName) {
  778. var propValue = props[propName];
  779. var propType = getPropType(propValue);
  780. if (propType !== 'object') {
  781. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  782. }
  783. for (var key in shapeTypes) {
  784. var checker = shapeTypes[key];
  785. if (!checker) {
  786. continue;
  787. }
  788. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  789. if (error) {
  790. return error;
  791. }
  792. }
  793. return null;
  794. }
  795. return createChainableTypeChecker(validate);
  796. }
  797. function createStrictShapeTypeChecker(shapeTypes) {
  798. function validate(props, propName, componentName, location, propFullName) {
  799. var propValue = props[propName];
  800. var propType = getPropType(propValue);
  801. if (propType !== 'object') {
  802. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  803. }
  804. // We need to check all keys in case some are required but missing from
  805. // props.
  806. var allKeys = objectAssign({}, props[propName], shapeTypes);
  807. for (var key in allKeys) {
  808. var checker = shapeTypes[key];
  809. if (!checker) {
  810. return new PropTypeError(
  811. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  812. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  813. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  814. );
  815. }
  816. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  817. if (error) {
  818. return error;
  819. }
  820. }
  821. return null;
  822. }
  823. return createChainableTypeChecker(validate);
  824. }
  825. function isNode(propValue) {
  826. switch (typeof propValue) {
  827. case 'number':
  828. case 'string':
  829. case 'undefined':
  830. return true;
  831. case 'boolean':
  832. return !propValue;
  833. case 'object':
  834. if (Array.isArray(propValue)) {
  835. return propValue.every(isNode);
  836. }
  837. if (propValue === null || isValidElement(propValue)) {
  838. return true;
  839. }
  840. var iteratorFn = getIteratorFn(propValue);
  841. if (iteratorFn) {
  842. var iterator = iteratorFn.call(propValue);
  843. var step;
  844. if (iteratorFn !== propValue.entries) {
  845. while (!(step = iterator.next()).done) {
  846. if (!isNode(step.value)) {
  847. return false;
  848. }
  849. }
  850. } else {
  851. // Iterator will provide entry [k,v] tuples rather than values.
  852. while (!(step = iterator.next()).done) {
  853. var entry = step.value;
  854. if (entry) {
  855. if (!isNode(entry[1])) {
  856. return false;
  857. }
  858. }
  859. }
  860. }
  861. } else {
  862. return false;
  863. }
  864. return true;
  865. default:
  866. return false;
  867. }
  868. }
  869. function isSymbol(propType, propValue) {
  870. // Native Symbol.
  871. if (propType === 'symbol') {
  872. return true;
  873. }
  874. // falsy value can't be a Symbol
  875. if (!propValue) {
  876. return false;
  877. }
  878. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  879. if (propValue['@@toStringTag'] === 'Symbol') {
  880. return true;
  881. }
  882. // Fallback for non-spec compliant Symbols which are polyfilled.
  883. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  884. return true;
  885. }
  886. return false;
  887. }
  888. // Equivalent of `typeof` but with special handling for array and regexp.
  889. function getPropType(propValue) {
  890. var propType = typeof propValue;
  891. if (Array.isArray(propValue)) {
  892. return 'array';
  893. }
  894. if (propValue instanceof RegExp) {
  895. // Old webkits (at least until Android 4.0) return 'function' rather than
  896. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  897. // passes PropTypes.object.
  898. return 'object';
  899. }
  900. if (isSymbol(propType, propValue)) {
  901. return 'symbol';
  902. }
  903. return propType;
  904. }
  905. // This handles more types than `getPropType`. Only used for error messages.
  906. // See `createPrimitiveTypeChecker`.
  907. function getPreciseType(propValue) {
  908. if (typeof propValue === 'undefined' || propValue === null) {
  909. return '' + propValue;
  910. }
  911. var propType = getPropType(propValue);
  912. if (propType === 'object') {
  913. if (propValue instanceof Date) {
  914. return 'date';
  915. } else if (propValue instanceof RegExp) {
  916. return 'regexp';
  917. }
  918. }
  919. return propType;
  920. }
  921. // Returns a string that is postfixed to a warning about an invalid type.
  922. // For example, "undefined" or "of type array"
  923. function getPostfixForTypeWarning(value) {
  924. var type = getPreciseType(value);
  925. switch (type) {
  926. case 'array':
  927. case 'object':
  928. return 'an ' + type;
  929. case 'boolean':
  930. case 'date':
  931. case 'regexp':
  932. return 'a ' + type;
  933. default:
  934. return type;
  935. }
  936. }
  937. // Returns class name of the object, if any.
  938. function getClassName(propValue) {
  939. if (!propValue.constructor || !propValue.constructor.name) {
  940. return ANONYMOUS;
  941. }
  942. return propValue.constructor.name;
  943. }
  944. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  945. ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  946. ReactPropTypes.PropTypes = ReactPropTypes;
  947. return ReactPropTypes;
  948. };
  949. function emptyFunction() {}
  950. function emptyFunctionWithReset() {}
  951. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  952. var factoryWithThrowingShims = function() {
  953. function shim(props, propName, componentName, location, propFullName, secret) {
  954. if (secret === ReactPropTypesSecret_1) {
  955. // It is still safe when called from React.
  956. return;
  957. }
  958. var err = new Error(
  959. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  960. 'Use PropTypes.checkPropTypes() to call them. ' +
  961. 'Read more at http://fb.me/use-check-prop-types'
  962. );
  963. err.name = 'Invariant Violation';
  964. throw err;
  965. } shim.isRequired = shim;
  966. function getShim() {
  967. return shim;
  968. } // Important!
  969. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  970. var ReactPropTypes = {
  971. array: shim,
  972. bool: shim,
  973. func: shim,
  974. number: shim,
  975. object: shim,
  976. string: shim,
  977. symbol: shim,
  978. any: shim,
  979. arrayOf: getShim,
  980. element: shim,
  981. elementType: shim,
  982. instanceOf: getShim,
  983. node: shim,
  984. objectOf: getShim,
  985. oneOf: getShim,
  986. oneOfType: getShim,
  987. shape: getShim,
  988. exact: getShim,
  989. checkPropTypes: emptyFunctionWithReset,
  990. resetWarningCache: emptyFunction
  991. };
  992. ReactPropTypes.PropTypes = ReactPropTypes;
  993. return ReactPropTypes;
  994. };
  995. var propTypes = createCommonjsModule(function (module) {
  996. /**
  997. * Copyright (c) 2013-present, Facebook, Inc.
  998. *
  999. * This source code is licensed under the MIT license found in the
  1000. * LICENSE file in the root directory of this source tree.
  1001. */
  1002. if (process.env.NODE_ENV !== 'production') {
  1003. var ReactIs = reactIs;
  1004. // By explicitly using `prop-types` you are opting into new development behavior.
  1005. // http://fb.me/prop-types-in-prod
  1006. var throwOnDirectAccess = true;
  1007. module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  1008. } else {
  1009. // By explicitly using `prop-types` you are opting into new production behavior.
  1010. // http://fb.me/prop-types-in-prod
  1011. module.exports = factoryWithThrowingShims();
  1012. }
  1013. });
  1014. var filter = Autocomplete.createFilterOptions();
  1015. var BootstrapInput = styles.withStyles(function (theme) {
  1016. return {
  1017. root: {
  1018. 'label + &': {
  1019. marginTop: theme.spacing(3)
  1020. }
  1021. },
  1022. input: {
  1023. borderRadius: 4,
  1024. position: 'relative',
  1025. backgroundColor: 'transparent',
  1026. border: '1px solid #ced4da',
  1027. fontSize: 16,
  1028. padding: '10px 26px 10px 12px',
  1029. transition: theme.transitions.create(['border-color', 'box-shadow']),
  1030. fontFamily: ['-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
  1031. '&:focus': {
  1032. borderRadius: 4,
  1033. borderColor: '#80bdff',
  1034. boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)'
  1035. }
  1036. }
  1037. };
  1038. })(core.InputBase);
  1039. var useStyles = styles.makeStyles(function (theme) {
  1040. return {
  1041. root: {
  1042. width: '100%'
  1043. },
  1044. paper: {
  1045. width: '100%',
  1046. marginBottom: theme.spacing(2)
  1047. },
  1048. table: {
  1049. minWidth: 750
  1050. },
  1051. visuallyHidden: {
  1052. border: 0,
  1053. clip: 'rect(0 0 0 0)',
  1054. height: 1,
  1055. margin: -1,
  1056. overflow: 'hidden',
  1057. padding: 0,
  1058. position: 'absolute',
  1059. top: 20,
  1060. width: 1
  1061. },
  1062. underline: {
  1063. "&&&:before": {
  1064. borderBottom: "none"
  1065. },
  1066. "&&:after": {
  1067. borderBottom: "none"
  1068. }
  1069. }
  1070. };
  1071. });
  1072. function MButton(props) {
  1073. var classes = useStyles();
  1074. var action = props.action,
  1075. onCallback = props.onCallback;
  1076. var handleAction = function handleAction(e) {
  1077. e.preventDefault();
  1078. onCallback(e);
  1079. };
  1080. return /*#__PURE__*/React__default.createElement("div", {
  1081. className: classes.root
  1082. }, /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  1083. variant: "contained",
  1084. style: {
  1085. "float": 'right',
  1086. margin: "5px"
  1087. },
  1088. onClick: function onClick(e) {
  1089. return handleAction(e);
  1090. }
  1091. }, action.icon, action.label)));
  1092. }
  1093. MButton.propTypes = {
  1094. history: propTypes.object,
  1095. action: propTypes.object.isRequired,
  1096. onCallback: propTypes.func.isRequired
  1097. };
  1098. function MkForm(props) {
  1099. var classes = useStyles();
  1100. var _props$fields = props.fields,
  1101. fields = _props$fields === void 0 ? [] : _props$fields,
  1102. _props$data = props.data,
  1103. data = _props$data === void 0 ? {} : _props$data,
  1104. onDropdownCreateNew = props.onDropdownCreateNew,
  1105. _props$actions = props.actions,
  1106. actions = _props$actions === void 0 ? [] : _props$actions,
  1107. partHeaders = props.partHeaders;
  1108. var _React$useState = React__default.useState(data !== undefined ? data : {}),
  1109. _data = _React$useState[0],
  1110. setDataField = _React$useState[1];
  1111. var _React$useState2 = React__default.useState(false),
  1112. open = _React$useState2[0],
  1113. setOpen = _React$useState2[1];
  1114. var _React$useState3 = React__default.useState("#"),
  1115. selectedPhoto = _React$useState3[0],
  1116. setSelectedPhoto = _React$useState3[1];
  1117. var handleTextString = function handleTextString(e, fieldName) {
  1118. var _extends2;
  1119. setDataField(_extends({}, _data, (_extends2 = {}, _extends2[fieldName] = e.target.value, _extends2)));
  1120. };
  1121. var handleTextNumber = function handleTextNumber(e, fieldName) {
  1122. var _extends3;
  1123. setDataField(_extends({}, _data, (_extends3 = {}, _extends3[fieldName] = e.target.value, _extends3)));
  1124. };
  1125. var handleTextMultiline = function handleTextMultiline(e, fieldName) {
  1126. var _extends4;
  1127. setDataField(_extends({}, _data, (_extends4 = {}, _extends4[fieldName] = e.target.value, _extends4)));
  1128. };
  1129. var handleDate = function handleDate(e, fieldName) {
  1130. var _extends5;
  1131. setDataField(_extends({}, _data, (_extends5 = {}, _extends5[fieldName] = e.target.value, _extends5)));
  1132. };
  1133. var handleDropDownChange = function handleDropDownChange(e, fieldName) {
  1134. var _extends6;
  1135. var selectedIndex = e.target.options.selectedIndex;
  1136. var selectedValue = e.target.options[selectedIndex].getAttribute('name');
  1137. var fn = fieldName.split('_');
  1138. var fieldId = fn[0] + '_' + 'id';
  1139. setDataField(_extends({}, _data, (_extends6 = {}, _extends6[fieldName] = selectedValue, _extends6[fieldId] = e.target.value, _extends6)));
  1140. };
  1141. var handleCanCreateNew = function handleCanCreateNew(data) {
  1142. onDropdownCreateNew(data);
  1143. };
  1144. var onChangeValue = function onChangeValue(fieldName, value) {
  1145. var _extends7;
  1146. setDataField(_extends({}, _data, (_extends7 = {}, _extends7[fieldName] = value, _extends7)));
  1147. };
  1148. var onFileChange = function onFileChange(e, f) {};
  1149. var handleSelectItemDialog = function handleSelectItemDialog() {};
  1150. return /*#__PURE__*/React__default.createElement("div", {
  1151. className: classes.root
  1152. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1153. container: true
  1154. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1155. item: true,
  1156. xs: 12
  1157. }, fields.map(function (f, i) {
  1158. if (f.type === 'text_string') {
  1159. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1160. key: f.field_name,
  1161. container: true,
  1162. style: {
  1163. display: 'flex',
  1164. alignItems: 'center',
  1165. marginBottom: '10px'
  1166. }
  1167. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1168. item: true,
  1169. xs: 12,
  1170. sm: 5
  1171. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1172. style: {
  1173. width: '150px'
  1174. }
  1175. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1176. style: {
  1177. paddingRight: '30px',
  1178. color: 'grey'
  1179. }
  1180. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1181. item: true,
  1182. xs: 12,
  1183. sm: 7
  1184. }, /*#__PURE__*/React__default.createElement(core.TextField, {
  1185. id: f.field_name,
  1186. variant: "outlined",
  1187. autoComplete: "off",
  1188. size: "small",
  1189. style: {
  1190. width: '100%'
  1191. },
  1192. InputProps: {
  1193. readOnly: f.readOnly ? f.readOnly : false
  1194. },
  1195. value: _data !== undefined ? _data[f.field_name] : '',
  1196. onChange: function onChange(e) {
  1197. return handleTextString(e, f.field_name);
  1198. }
  1199. })));
  1200. } else if (f.type === 'text_number') {
  1201. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1202. key: f.field_name,
  1203. container: true,
  1204. style: {
  1205. display: 'flex',
  1206. alignItems: 'center',
  1207. marginBottom: '10px'
  1208. }
  1209. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1210. item: true,
  1211. xs: 12,
  1212. sm: 5
  1213. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1214. style: {
  1215. width: '150px'
  1216. }
  1217. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1218. style: {
  1219. paddingRight: '30px',
  1220. color: 'grey'
  1221. }
  1222. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1223. item: true,
  1224. xs: 12,
  1225. sm: 7
  1226. }, /*#__PURE__*/React__default.createElement(core.TextField, {
  1227. id: f.field_name,
  1228. variant: "outlined",
  1229. autoComplete: "off",
  1230. size: "small",
  1231. style: {
  1232. width: '100%'
  1233. },
  1234. type: "number",
  1235. value: _data !== undefined ? _data[f.field_name] : '',
  1236. onChange: function onChange(e) {
  1237. return handleTextNumber(e, f.field_name);
  1238. }
  1239. })));
  1240. } else if (f.type === 'text_multiline') {
  1241. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1242. key: f.field_name,
  1243. container: true,
  1244. style: {
  1245. display: 'flex',
  1246. alignItems: 'center',
  1247. marginBottom: '10px'
  1248. }
  1249. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1250. item: true,
  1251. xs: 12,
  1252. sm: 5
  1253. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1254. style: {
  1255. width: '150px'
  1256. }
  1257. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1258. style: {
  1259. paddingRight: '30px',
  1260. color: 'grey'
  1261. }
  1262. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1263. item: true,
  1264. xs: 12,
  1265. sm: 7
  1266. }, /*#__PURE__*/React__default.createElement(core.TextField, {
  1267. id: f.field_name,
  1268. multiline: true,
  1269. autoComplete: "off",
  1270. rows: 3,
  1271. size: "small",
  1272. style: {
  1273. width: '100%'
  1274. },
  1275. value: _data !== undefined ? _data[f.field_name] : '',
  1276. variant: "outlined",
  1277. onChange: function onChange(e) {
  1278. return handleTextMultiline(e, f.field_name);
  1279. }
  1280. })));
  1281. } else if (f.type === 'date') {
  1282. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1283. key: f.field_name,
  1284. container: true,
  1285. style: {
  1286. display: 'flex',
  1287. alignItems: 'center',
  1288. marginBottom: '10px'
  1289. }
  1290. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1291. item: true,
  1292. xs: 12,
  1293. sm: 5
  1294. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1295. style: {
  1296. width: '150px'
  1297. }
  1298. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1299. style: {
  1300. paddingRight: '30px',
  1301. color: 'grey'
  1302. }
  1303. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1304. item: true,
  1305. xs: 12,
  1306. sm: 7
  1307. }, /*#__PURE__*/React__default.createElement(core.TextField, {
  1308. id: f.field_name,
  1309. variant: "outlined",
  1310. autoComplete: "off",
  1311. size: "small",
  1312. value: _data !== undefined ? _data[f.field_name] : '',
  1313. type: "date",
  1314. style: {
  1315. width: '100%'
  1316. },
  1317. onChange: function onChange(e) {
  1318. return handleDate(e, f.field_name);
  1319. }
  1320. })));
  1321. } else if (f.type === 'dropdown') {
  1322. if (f.options !== undefined && f.option_label_field !== undefined) {
  1323. if (f.field_name === 'priority') {
  1324. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1325. key: f.field_name,
  1326. container: true,
  1327. style: {
  1328. display: 'flex',
  1329. alignItems: 'center',
  1330. marginBottom: '10px'
  1331. }
  1332. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1333. item: true,
  1334. xs: 12,
  1335. sm: 5
  1336. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1337. style: {
  1338. width: '150px'
  1339. }
  1340. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1341. style: {
  1342. paddingRight: '30px',
  1343. color: 'grey'
  1344. }
  1345. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1346. item: true,
  1347. xs: 12,
  1348. sm: 7
  1349. }, /*#__PURE__*/React__default.createElement(core.NativeSelect, {
  1350. value: _data !== undefined ? _data[f.field_name] : '',
  1351. onChange: function onChange(e) {
  1352. return handleDropDownChange(e, f.field_name);
  1353. },
  1354. id: f.field_name,
  1355. input: /*#__PURE__*/React__default.createElement(BootstrapInput, null),
  1356. style: {
  1357. width: '100%'
  1358. }
  1359. }, /*#__PURE__*/React__default.createElement("option", {
  1360. "aria-label": "None",
  1361. value: ""
  1362. }, "Select"), f.options.map(function (d, i) {
  1363. return /*#__PURE__*/React__default.createElement("option", {
  1364. name: d.name,
  1365. value: d.id,
  1366. key: d.id
  1367. }, d.name);
  1368. }))));
  1369. } else {
  1370. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1371. key: f.field_name,
  1372. container: true,
  1373. style: {
  1374. display: 'flex',
  1375. alignItems: 'center',
  1376. marginBottom: '10px'
  1377. }
  1378. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1379. item: true,
  1380. xs: 12,
  1381. sm: 5
  1382. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1383. style: {
  1384. width: '150px'
  1385. }
  1386. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1387. style: {
  1388. paddingRight: '30px',
  1389. color: 'grey'
  1390. }
  1391. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1392. item: true,
  1393. xs: 12,
  1394. sm: 7
  1395. }, /*#__PURE__*/React__default.createElement(Autocomplete__default, {
  1396. id: "combo-box-demo",
  1397. options: f.options,
  1398. getOptionLabel: function getOptionLabel(option) {
  1399. if (typeof option === 'string') {
  1400. return option;
  1401. }
  1402. return option[f.option_label_field];
  1403. },
  1404. style: {
  1405. width: '100%'
  1406. },
  1407. size: "small",
  1408. value: _data !== undefined ? _data[f.field_name] ? _data[f.field_name] : " " : " ",
  1409. filterOptions: function filterOptions(options, params) {
  1410. console.log("Autocomplete", f.can_create);
  1411. if (f.can_create) {
  1412. var newFilter = ['+ Add New'];
  1413. var filtered = filter(options, params);
  1414. return [].concat(newFilter, filtered);
  1415. } else {
  1416. var _filtered = filter(options, params);
  1417. return _filtered;
  1418. }
  1419. },
  1420. onChange: function onChange(event, newValue) {
  1421. if (typeof newValue === 'string') {
  1422. console.log('f.field_name', f.field_name, " f.can_create", f.can_create);
  1423. var d = {
  1424. "canCreate": f.can_create,
  1425. "fields": f.fields,
  1426. "name": f.name,
  1427. "fieldName": f.field_name
  1428. };
  1429. handleCanCreateNew(d);
  1430. } else {
  1431. if (newValue != null && newValue.inputValue !== '' && newValue.product_desc !== "") {
  1432. onChangeValue(f.field_name, newValue[f.option_label_field]);
  1433. }
  1434. }
  1435. },
  1436. renderInput: function renderInput(params) {
  1437. return /*#__PURE__*/React__default.createElement(core.TextField, _extends({}, params, {
  1438. variant: "outlined"
  1439. }));
  1440. }
  1441. })));
  1442. }
  1443. }
  1444. } else if (f.type === 'photo_list') {
  1445. console.log('photo_list:', _data);
  1446. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(core.Grid, {
  1447. key: f.field_name,
  1448. container: true,
  1449. style: {
  1450. display: 'flex',
  1451. alignItems: 'center',
  1452. marginBottom: '10px'
  1453. }
  1454. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1455. item: true,
  1456. xs: 12,
  1457. sm: 5
  1458. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1459. style: {
  1460. width: '150px'
  1461. }
  1462. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1463. style: {
  1464. paddingRight: '30px',
  1465. color: 'grey'
  1466. }
  1467. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1468. item: true,
  1469. xs: 12,
  1470. sm: 7
  1471. }, /*#__PURE__*/React__default.createElement("div", {
  1472. style: {
  1473. display: 'flex',
  1474. alignItems: 'center',
  1475. marginBottom: '10px'
  1476. }
  1477. }, /*#__PURE__*/React__default.createElement("form", null, /*#__PURE__*/React__default.createElement("div", {
  1478. className: "form-group"
  1479. }, /*#__PURE__*/React__default.createElement("input", {
  1480. type: "file",
  1481. name: "imgCollection",
  1482. onChange: function onChange(e) {
  1483. return onFileChange();
  1484. },
  1485. multiple: true
  1486. })))))), _data[f.field_name] !== undefined && _data[f.field_name].length !== 0 ? /*#__PURE__*/React__default.createElement(core.Grid, {
  1487. key: f.field_name,
  1488. container: true,
  1489. style: {
  1490. display: 'flex',
  1491. alignItems: 'center',
  1492. marginBottom: '10px'
  1493. }
  1494. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1495. item: true,
  1496. xs: 12
  1497. }, /*#__PURE__*/React__default.createElement("div", {
  1498. style: {
  1499. display: 'block',
  1500. alignItems: 'center',
  1501. marginBottom: '10px'
  1502. }
  1503. }, /*#__PURE__*/React__default.createElement(core.GridList, {
  1504. className: classes.gridList
  1505. }, _data[f.field_name] === undefined ? /*#__PURE__*/React__default.createElement("span", null) : _data[f.field_name].map(function (tile) {
  1506. return /*#__PURE__*/React__default.createElement(core.GridListTile, {
  1507. key: tile,
  1508. style: {
  1509. width: '100px',
  1510. height: '100px'
  1511. }
  1512. }, /*#__PURE__*/React__default.createElement("img", {
  1513. src: tile,
  1514. alt: tile,
  1515. onClick: function onClick(e) {
  1516. setOpen(true);
  1517. }
  1518. }));
  1519. })))), /*#__PURE__*/React__default.createElement(core.Dialog, {
  1520. maxWidth: "lg",
  1521. "aria-labelledby": "customized-dialog-title",
  1522. open: open
  1523. }, /*#__PURE__*/React__default.createElement(core.DialogTitle, {
  1524. id: "customized-dialog-title",
  1525. onClose: function onClose(e) {
  1526. return setOpen(false);
  1527. }
  1528. }, "Photos"), /*#__PURE__*/React__default.createElement(core.DialogContent, {
  1529. dividers: true
  1530. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1531. item: true,
  1532. xs: 12
  1533. }, /*#__PURE__*/React__default.createElement(core.Grid, null, /*#__PURE__*/React__default.createElement("img", {
  1534. src: selectedPhoto,
  1535. className: "show-img",
  1536. alt: "logo"
  1537. })), /*#__PURE__*/React__default.createElement("br", null), /*#__PURE__*/React__default.createElement(core.Grid, {
  1538. container: true,
  1539. spacing: 3
  1540. }, _data[f.field_name].length > 0 ? _data[f.field_name].map(function (value) {
  1541. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1542. key: value,
  1543. item: true
  1544. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1545. className: "square"
  1546. }, " ", /*#__PURE__*/React__default.createElement("img", {
  1547. src: value,
  1548. className: "thumnail-img",
  1549. alt: "logo",
  1550. onClick: function onClick(e) {
  1551. return setSelectedPhoto(value);
  1552. }
  1553. })));
  1554. }) : /*#__PURE__*/React__default.createElement("span", null)))))) : /*#__PURE__*/React__default.createElement(core.Grid, null));
  1555. } else if (f.type === 'list') {
  1556. console.log('list', _data[f.field_name]);
  1557. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(core.Grid, {
  1558. key: f.field_name,
  1559. container: true,
  1560. style: {
  1561. display: 'flex',
  1562. alignItems: 'center',
  1563. marginBottom: '10px'
  1564. }
  1565. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1566. item: true,
  1567. xs: 12,
  1568. sm: 5
  1569. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1570. style: {
  1571. width: '150px'
  1572. }
  1573. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1574. style: {
  1575. paddingRight: '30px',
  1576. color: 'grey'
  1577. }
  1578. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1579. item: true,
  1580. xs: 12,
  1581. sm: 7
  1582. }, /*#__PURE__*/React__default.createElement("div", {
  1583. style: {
  1584. display: 'block',
  1585. alignItems: 'center',
  1586. marginBottom: '10px'
  1587. }
  1588. }, /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  1589. onClick: handleSelectItemDialog
  1590. }, /*#__PURE__*/React__default.createElement(AddIcon, null)))))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1591. key: f.field_name,
  1592. container: true,
  1593. style: {
  1594. display: 'block',
  1595. alignItems: 'center',
  1596. marginBottom: '10px'
  1597. }
  1598. }, /*#__PURE__*/React__default.createElement("div", {
  1599. style: {
  1600. display: 'block',
  1601. alignItems: 'center',
  1602. marginBottom: '10px'
  1603. }
  1604. }, /*#__PURE__*/React__default.createElement(core.TableContainer, null, /*#__PURE__*/React__default.createElement(core.Table, {
  1605. className: classes.table,
  1606. size: "small",
  1607. "aria-label": "a dense table"
  1608. }, /*#__PURE__*/React__default.createElement(core.TableHead, null, /*#__PURE__*/React__default.createElement(core.TableRow, null, partHeaders.map(function (h, i) {
  1609. return /*#__PURE__*/React__default.createElement(core.TableCell, {
  1610. key: h.id,
  1611. align: "left"
  1612. }, h.label);
  1613. }))), /*#__PURE__*/React__default.createElement(core.TableBody, null, _data[f.field_name].length > 0 ? _data[f.field_name].map(function (row) {
  1614. return /*#__PURE__*/React__default.createElement(core.TableRow, {
  1615. key: row.name
  1616. }, partHeaders.map(function (h, i) {
  1617. return /*#__PURE__*/React__default.createElement(core.TableCell, {
  1618. key: h.id,
  1619. align: h.numeric ? 'right' : 'left'
  1620. }, row[h.id]);
  1621. }));
  1622. }) : /*#__PURE__*/React__default.createElement("span", null)))))));
  1623. } else if (f.type === 'time') {
  1624. return /*#__PURE__*/React__default.createElement(core.Grid, {
  1625. key: f.field_name,
  1626. container: true,
  1627. style: {
  1628. display: 'flex',
  1629. alignItems: 'center',
  1630. marginBottom: '10px'
  1631. }
  1632. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  1633. item: true,
  1634. xs: 12,
  1635. sm: 5
  1636. }, /*#__PURE__*/React__default.createElement(core.Box, {
  1637. style: {
  1638. width: '150px'
  1639. }
  1640. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  1641. style: {
  1642. paddingRight: '30px',
  1643. color: 'grey'
  1644. }
  1645. }, f.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  1646. item: true,
  1647. xs: 12,
  1648. sm: 7
  1649. }, " ", /*#__PURE__*/React__default.createElement(core.TextField, {
  1650. id: "time",
  1651. variant: "outlined",
  1652. size: "small",
  1653. type: "time",
  1654. className: classes.textField,
  1655. InputLabelProps: {
  1656. shrink: true
  1657. },
  1658. inputProps: {
  1659. step: 300
  1660. }
  1661. })));
  1662. }
  1663. })), actions.length > 0 ? /*#__PURE__*/React__default.createElement(core.Grid, {
  1664. item: true,
  1665. xs: 12
  1666. }, actions.map(function (a) {
  1667. if (a.status === _data.status) {
  1668. return /*#__PURE__*/React__default.createElement(MButton, {
  1669. action: a,
  1670. onCallback: function onCallback(event) {
  1671. return a.callback(event, _data);
  1672. }
  1673. });
  1674. }
  1675. })) : /*#__PURE__*/React__default.createElement(core.Grid, null)));
  1676. }
  1677. MkForm.propTypes = {
  1678. history: propTypes.object,
  1679. fields: propTypes.array.isRequired,
  1680. data: propTypes.object,
  1681. isNew: propTypes.bool,
  1682. actions: propTypes.array,
  1683. onDropdownCreateNew: propTypes.func
  1684. };
  1685. function descendingComparator(a, b, _orderBy) {
  1686. if (b[_orderBy] < a[_orderBy]) {
  1687. return -1;
  1688. }
  1689. if (b[_orderBy] > a[_orderBy]) {
  1690. return 1;
  1691. }
  1692. return 0;
  1693. }
  1694. function getComparator(_order, _orderBy) {
  1695. return _order === 'desc' ? function (a, b) {
  1696. return descendingComparator(a, b, _orderBy);
  1697. } : function (a, b) {
  1698. return -descendingComparator(a, b, _orderBy);
  1699. };
  1700. }
  1701. function stableSort(array, comparator) {
  1702. var stabilizedThis = array.map(function (el, index) {
  1703. return [el, index];
  1704. });
  1705. stabilizedThis.sort(function (a, b) {
  1706. var _order = comparator(a[0], b[0]);
  1707. if (_order !== 0) return _order;
  1708. return a[1] - b[1];
  1709. });
  1710. return stabilizedThis.map(function (el) {
  1711. return el[0];
  1712. });
  1713. }
  1714. function EnhancedTableHead(props) {
  1715. var headerStyles = props.headerStyles,
  1716. _order = props._order,
  1717. _orderBy = props._orderBy,
  1718. onRequestSort = props.onRequestSort,
  1719. headCells = props.headCells;
  1720. var createSortHandler = function createSortHandler(property) {
  1721. return function (event) {
  1722. onRequestSort(event, property);
  1723. };
  1724. };
  1725. var sortedStyle = core.createMuiTheme({
  1726. overrides: {
  1727. MuiTableSortLabel: {
  1728. root: {
  1729. "&$active": {
  1730. color: headerStyles.sortedHeader === undefined ? 'grey' : headerStyles.sortedHeader,
  1731. "&& $icon": {
  1732. color: headerStyles.sortedHeader === undefined ? 'grey' : headerStyles.sortedHeader
  1733. }
  1734. }
  1735. }
  1736. }
  1737. }
  1738. });
  1739. return /*#__PURE__*/React__default.createElement(core.ThemeProvider, {
  1740. theme: sortedStyle
  1741. }, /*#__PURE__*/React__default.createElement(TableHead, null, /*#__PURE__*/React__default.createElement(TableRow, null, headCells.map(function (headCell) {
  1742. return /*#__PURE__*/React__default.createElement(TableCell, {
  1743. className: headerStyles.head,
  1744. key: headCell.id,
  1745. align: headCell.numeric ? 'right' : 'left',
  1746. padding: headCell.disablePadding ? 'none' : 'default',
  1747. sortDirection: _orderBy === headCell.id ? _order : false,
  1748. style: {
  1749. width: headCell.id === 'sr' ? '15px' : headCell.width ? headCell.width : ''
  1750. }
  1751. }, headCell.id !== 'sr' ? /*#__PURE__*/React__default.createElement(TableSortLabel, {
  1752. active: _orderBy === headCell.id,
  1753. direction: _orderBy === headCell.id ? _order : 'asc',
  1754. onClick: createSortHandler(headCell.id),
  1755. style: {
  1756. whiteSpace: "nowrap"
  1757. }
  1758. }, headCell.label, _orderBy === headCell.id ? /*#__PURE__*/React__default.createElement("span", {
  1759. className: headerStyles.visuallyHidden
  1760. }, _order === 'desc' ? 'sorted descending' : 'sorted ascending') : null) : /*#__PURE__*/React__default.createElement(TableSortLabel, {
  1761. hideSortIcon: "true",
  1762. align: "right"
  1763. }, headCell.label));
  1764. }), /*#__PURE__*/React__default.createElement(TableCell, {
  1765. className: headerStyles.head,
  1766. style: {
  1767. width: '100px'
  1768. }
  1769. }))));
  1770. }
  1771. EnhancedTableHead.propTypes = {
  1772. headerStyles: propTypes.object.isRequired,
  1773. onRequestSort: propTypes.func.isRequired,
  1774. onSelectAllClick: propTypes.func.isRequired,
  1775. _order: propTypes.oneOf(['asc', 'desc']).isRequired,
  1776. _orderBy: propTypes.string.isRequired,
  1777. rowCount: propTypes.number.isRequired
  1778. };
  1779. var useStyles$1 = styles.makeStyles({
  1780. root: {
  1781. width: '100%'
  1782. },
  1783. table: {
  1784. tableLayout: 'fixed'
  1785. },
  1786. visuallyHidden: {
  1787. b_order: 0,
  1788. clip: 'rect(0 0 0 0)',
  1789. height: 1,
  1790. margin: -1,
  1791. overflow: 'hidden',
  1792. padding: 0,
  1793. position: 'absolute',
  1794. top: 20,
  1795. width: 1
  1796. },
  1797. underline: {
  1798. "&&&:before": {
  1799. b_orderBottom: "none"
  1800. },
  1801. "&&:after": {
  1802. b_orderBottom: "none"
  1803. }
  1804. },
  1805. head: function head(props) {
  1806. return {
  1807. backgroundColor: props.headerBackgroundColor === undefined ? '#0d47a1a8' : props.headerBackgroundColor,
  1808. color: props.headerTextColor === undefined ? 'white' : props.headerTextColor
  1809. };
  1810. },
  1811. sortedHeader: function sortedHeader(props) {
  1812. return {
  1813. color: props.headerTextColor === undefined ? 'grey' : props.headerTextColor
  1814. };
  1815. },
  1816. styledTableRow: function styledTableRow(props) {
  1817. return {
  1818. '&:nth-of-type(even)': {
  1819. backgroundColor: props.primaryColor === undefined ? '#0d47a11c' : props.primaryColor
  1820. }
  1821. };
  1822. }
  1823. });
  1824. function getUpdatedDate(p) {
  1825. var statusDate = p.updated_date;
  1826. var day = '';
  1827. if (statusDate !== undefined) {
  1828. var convertDate = new Date(statusDate.toDate());
  1829. var dd = String(convertDate.getDate()).padStart(2, '0');
  1830. var mm = String(convertDate.getMonth() + 1).padStart(2, '0');
  1831. var yyyy = convertDate.getFullYear();
  1832. day = mm + '/' + dd + '/' + yyyy;
  1833. }
  1834. return day.toString();
  1835. }
  1836. function RowMenu(props) {
  1837. var row = props.row,
  1838. actions = props.actions,
  1839. onSelectedAction = props.onSelectedAction,
  1840. onRowEdit = props.onRowEdit;
  1841. var _React$useState = React__default.useState(null),
  1842. anchorEl = _React$useState[0],
  1843. setAnchorEl = _React$useState[1];
  1844. var handleMenuClick = function handleMenuClick(event) {
  1845. event.stopPropagation();
  1846. setAnchorEl(event.currentTarget);
  1847. };
  1848. var handleSelectMenu = function handleSelectMenu(e, row, action) {
  1849. e.stopPropagation();
  1850. onSelectedAction(row, action.action_name);
  1851. setAnchorEl(null);
  1852. };
  1853. var handleClose = function handleClose(e) {
  1854. setAnchorEl(null);
  1855. e.stopPropagation();
  1856. };
  1857. var handleEdit = function handleEdit(e) {
  1858. onRowEdit(row);
  1859. e.stopPropagation();
  1860. };
  1861. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(core.Menu, {
  1862. id: "actions-" + row.id,
  1863. anchorEl: anchorEl,
  1864. keepMounted: true,
  1865. open: Boolean(anchorEl),
  1866. onClose: handleClose
  1867. }, actions.map(function (action) {
  1868. return /*#__PURE__*/React__default.createElement(core.MenuItem, {
  1869. key: action.display_name,
  1870. onClick: function onClick(e) {
  1871. return handleSelectMenu(e, row, action);
  1872. }
  1873. }, action.display_name);
  1874. })), /*#__PURE__*/React__default.createElement(core.Grid, {
  1875. container: true,
  1876. direction: "row",
  1877. justify: "flex-end",
  1878. alignItems: "center",
  1879. style: {
  1880. display: 'flex'
  1881. }
  1882. }, /*#__PURE__*/React__default.createElement(core.IconButton, {
  1883. id: "edit-" + row.id,
  1884. "aria-label": "more",
  1885. "aria-controls": "long-menu",
  1886. "aria-haspopup": "true",
  1887. onClick: handleEdit,
  1888. size: "small"
  1889. }, /*#__PURE__*/React__default.createElement(EditIcon, null)), /*#__PURE__*/React__default.createElement(core.Box, {
  1890. style: {
  1891. width: '10px'
  1892. }
  1893. }), /*#__PURE__*/React__default.createElement(core.IconButton, {
  1894. id: "dropdown-" + row.id,
  1895. "aria-label": "more",
  1896. "aria-controls": "long-menu",
  1897. "aria-haspopup": "true",
  1898. size: "small",
  1899. onClick: handleMenuClick
  1900. }, /*#__PURE__*/React__default.createElement(ExpandMore, null))));
  1901. }
  1902. RowMenu.propTypes = {
  1903. row: propTypes.object.isRequired,
  1904. actions: propTypes.array.isRequired,
  1905. onSelectedAction: propTypes.func.isRequired,
  1906. onRowEdit: propTypes.func
  1907. };
  1908. function ConfirmDialog(props) {
  1909. var type = props.type,
  1910. itemName = props.itemName,
  1911. openDialog = props.openDialog,
  1912. onCancel = props.onCancel,
  1913. onContinue = props.onContinue;
  1914. var _React$useState2 = React__default.useState(openDialog),
  1915. open = _React$useState2[0],
  1916. setOpen = _React$useState2[1];
  1917. var handleClose = function handleClose() {
  1918. setOpen(false);
  1919. onCancel(false);
  1920. };
  1921. var handleContinue = function handleContinue() {
  1922. onContinue(true);
  1923. };
  1924. return /*#__PURE__*/React__default.createElement("div", null, /*#__PURE__*/React__default.createElement(core.Dialog, {
  1925. open: open,
  1926. onClose: handleClose,
  1927. "aria-labelledby": "alert-dialog-title",
  1928. "aria-describedby": "alert-dialog-description"
  1929. }, /*#__PURE__*/React__default.createElement(core.DialogTitle, {
  1930. id: "alert-dialog-title"
  1931. }, "Delete this " + type + ' "' + itemName + '"?'), /*#__PURE__*/React__default.createElement(core.DialogActions, null, /*#__PURE__*/React__default.createElement(core.Button, {
  1932. onClick: handleClose,
  1933. color: "primary"
  1934. }, "Cancel"), /*#__PURE__*/React__default.createElement(core.Button, {
  1935. onClick: handleContinue,
  1936. color: "primary",
  1937. autoFocus: true
  1938. }, "Delete"))));
  1939. }
  1940. ConfirmDialog.propTypes = {
  1941. history: propTypes.object,
  1942. type: propTypes.string,
  1943. itemName: propTypes.string,
  1944. openDialog: propTypes.bool,
  1945. onCancel: propTypes.func,
  1946. onContinue: propTypes.func
  1947. };
  1948. function MkTable(props) {
  1949. console.log("props.styles:", props.styles);
  1950. var classes = useStyles$1(props.styles);
  1951. var dispatch = props.dispatch,
  1952. _props$data = props.data,
  1953. data = _props$data === void 0 ? [] : _props$data,
  1954. _props$headers = props.headers,
  1955. headers = _props$headers === void 0 ? [] : _props$headers,
  1956. actions = props.actions,
  1957. onActions = props.onActions,
  1958. title = props.title,
  1959. page = props.page,
  1960. rowsPerPage = props.rowsPerPage,
  1961. _props$noMoreToLoad = props.noMoreToLoad,
  1962. noMoreToLoad = _props$noMoreToLoad === void 0 ? false : _props$noMoreToLoad,
  1963. order = props.order,
  1964. orderBy = props.orderBy,
  1965. _props$isLoading = props.isLoading,
  1966. isLoading = _props$isLoading === void 0 ? false : _props$isLoading,
  1967. onChangePaginatePage = props.onChangePaginatePage,
  1968. onGetData = props.onGetData,
  1969. onUpdateDataRow = props.onUpdateDataRow,
  1970. onChangeRowPerPage = props.onChangeRowPerPage,
  1971. _props$dense = props.dense,
  1972. dense = _props$dense === void 0 ? true : _props$dense;
  1973. var _React$useState3 = React__default.useState(rowsPerPage),
  1974. _rowsPerPage = _React$useState3[0],
  1975. setRowsPerPage = _React$useState3[1];
  1976. var _React$useState4 = React__default.useState(page),
  1977. _page = _React$useState4[0],
  1978. setPage = _React$useState4[1];
  1979. var _React$useState5 = React__default.useState(noMoreToLoad),
  1980. _noMoreToLoad = _React$useState5[0],
  1981. setNoMoreToLoad = _React$useState5[1];
  1982. var _React$useState6 = React__default.useState(order),
  1983. _order = _React$useState6[0],
  1984. setOrder = _React$useState6[1];
  1985. var _React$useState7 = React__default.useState(orderBy),
  1986. _orderBy = _React$useState7[0],
  1987. setOrderBy = _React$useState7[1];
  1988. var _React$useState8 = React__default.useState(isLoading),
  1989. _isLoading = _React$useState8[0],
  1990. setIsLoading = _React$useState8[1];
  1991. var _React$useState9 = React__default.useState(false),
  1992. _isConfirm = _React$useState9[0],
  1993. setIsConfirm = _React$useState9[1];
  1994. var _React$useState10 = React__default.useState(''),
  1995. itemName = _React$useState10[0],
  1996. setItemName = _React$useState10[1];
  1997. var _React$useState11 = React__default.useState({}),
  1998. row = _React$useState11[0],
  1999. setRow = _React$useState11[1];
  2000. var _React$useState12 = React__default.useState(''),
  2001. action = _React$useState12[0],
  2002. setAction = _React$useState12[1];
  2003. var _React$useState13 = React__default.useState(dense),
  2004. _dense = _React$useState13[0],
  2005. setDense = _React$useState13[1];
  2006. var handleSelectMenu = function handleSelectMenu(row, action) {
  2007. if (action === 'delete') {
  2008. setItemName(row.name === undefined ? row.product_desc : row.name);
  2009. setIsConfirm(true);
  2010. setRow(row);
  2011. setAction(action);
  2012. } else {
  2013. onActions(row, action);
  2014. }
  2015. };
  2016. var handleDelete = function handleDelete(v) {
  2017. setIsConfirm(false);
  2018. onActions(row, action);
  2019. };
  2020. var handleCancel = function handleCancel(v) {
  2021. setIsConfirm(false);
  2022. };
  2023. var handleRowEdit = function handleRowEdit(row) {
  2024. onUpdateDataRow(row);
  2025. };
  2026. var offset = _page * _rowsPerPage;
  2027. React.useEffect(function () {
  2028. setNoMoreToLoad(noMoreToLoad);
  2029. setPage(page);
  2030. setOrder(order);
  2031. setOrderBy(orderBy);
  2032. setIsLoading(isLoading);
  2033. setRowsPerPage(rowsPerPage);
  2034. setDense(dense);
  2035. }, []);
  2036. var handleRequestSort = function handleRequestSort(event, property) {
  2037. var isAsc = _orderBy === property && _order === 'asc';
  2038. setOrder(isAsc ? 'desc' : 'asc');
  2039. setOrderBy(property);
  2040. };
  2041. var handleChangePage = function handleChangePage(event, newPage) {
  2042. if (!_noMoreToLoad && (newPage + 1) * _rowsPerPage >= data.length) {
  2043. onGetData();
  2044. }
  2045. setPage(newPage);
  2046. onChangePaginatePage(newPage);
  2047. };
  2048. var handleChangeRowsPerPage = function handleChangeRowsPerPage(event) {
  2049. setRowsPerPage(parseInt(event.target.value));
  2050. onChangeRowPerPage(parseInt(event.target.value));
  2051. };
  2052. return /*#__PURE__*/React__default.createElement("div", {
  2053. className: classes.root
  2054. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2055. container: true
  2056. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2057. item: true
  2058. }, /*#__PURE__*/React__default.createElement(TableContainer, null, /*#__PURE__*/React__default.createElement(Table, {
  2059. className: classes.table,
  2060. "aria-labelledby": "tableTitle",
  2061. size: _dense ? 'small' : 'medium',
  2062. "aria-label": "enhanced table"
  2063. }, /*#__PURE__*/React__default.createElement(EnhancedTableHead, {
  2064. headerStyles: classes,
  2065. headCells: headers,
  2066. _order: _order,
  2067. _orderBy: _orderBy,
  2068. onRequestSort: handleRequestSort,
  2069. rowCount: data.length !== undefined ? data.length : 0,
  2070. dispatch: dispatch
  2071. }), /*#__PURE__*/React__default.createElement(TableBody, null, _isLoading ? /*#__PURE__*/React__default.createElement(TableRow, {
  2072. className: classes.styledTableRow
  2073. }, /*#__PURE__*/React__default.createElement(TableCell, {
  2074. colSpan: headers.length,
  2075. align: "center"
  2076. }, " ", /*#__PURE__*/React__default.createElement(CircularProgress, null))) : data.length !== 0 ? stableSort(data, getComparator(_order, _orderBy)).slice(_page * _rowsPerPage, _page * _rowsPerPage + _rowsPerPage).map(function (row, index) {
  2077. return /*#__PURE__*/React__default.createElement(TableRow, {
  2078. hover: true,
  2079. role: "checkbox",
  2080. tabIndex: -1,
  2081. key: row.id,
  2082. id: row.id,
  2083. className: classes.styledTableRow
  2084. }, headers.map(function (h, i) {
  2085. if (h.id === 'sr') {
  2086. return /*#__PURE__*/React__default.createElement(TableCell, {
  2087. key: h.id,
  2088. align: "right",
  2089. style: {
  2090. width: '15px'
  2091. }
  2092. }, ++offset);
  2093. }
  2094. if (h.id === 'status') {
  2095. return /*#__PURE__*/React__default.createElement(TableCell, {
  2096. key: h.id,
  2097. align: h.numeric ? 'right' : 'left'
  2098. }, row[h.id]);
  2099. }
  2100. if (h.id === 'updated_date') {
  2101. return /*#__PURE__*/React__default.createElement(TableCell, {
  2102. key: h.id,
  2103. align: h.numeric ? 'right' : 'left',
  2104. style: {
  2105. width: h.width ? h.width : null
  2106. }
  2107. }, getUpdatedDate(row));
  2108. } else {
  2109. return /*#__PURE__*/React__default.createElement(TableCell, {
  2110. key: h.id,
  2111. align: h.numeric ? 'right' : 'left',
  2112. style: {
  2113. width: h.width ? h.width : null
  2114. }
  2115. }, row[h.id]);
  2116. }
  2117. }), actions ? /*#__PURE__*/React__default.createElement(TableCell, {
  2118. style: {
  2119. width: '150px'
  2120. },
  2121. align: "right"
  2122. }, /*#__PURE__*/React__default.createElement(RowMenu, {
  2123. actions: actions,
  2124. row: row,
  2125. onRowEdit: function onRowEdit(data) {
  2126. return handleRowEdit(data);
  2127. },
  2128. onSelectedAction: function onSelectedAction(data, actionName) {
  2129. return handleSelectMenu(data, actionName);
  2130. }
  2131. })) : /*#__PURE__*/React__default.createElement(TableCell, {
  2132. style: {
  2133. width: '150px'
  2134. },
  2135. align: "right"
  2136. }, /*#__PURE__*/React__default.createElement(core.IconButton, {
  2137. onClick: function onClick(event) {
  2138. return handleRowEdit(row);
  2139. },
  2140. size: dense ? "small" : "medium"
  2141. }, /*#__PURE__*/React__default.createElement(EditIcon, null))));
  2142. }) : /*#__PURE__*/React__default.createElement(TableRow, {
  2143. className: classes.styledTableRow,
  2144. style: {
  2145. width: '100%'
  2146. }
  2147. })))), /*#__PURE__*/React__default.createElement(TablePagination, {
  2148. rowsPerPageOptions: [10, 30, 50],
  2149. labelDisplayedRows: function labelDisplayedRows(_ref) {
  2150. var from = _ref.from,
  2151. to = _ref.to,
  2152. count = _ref.count;
  2153. console.log(from, to, count);
  2154. },
  2155. component: "div",
  2156. count: data.length,
  2157. rowsPerPage: _rowsPerPage,
  2158. page: _page,
  2159. onChangePage: handleChangePage,
  2160. onChangeRowsPerPage: handleChangeRowsPerPage
  2161. }))), _isConfirm ? /*#__PURE__*/React__default.createElement(ConfirmDialog, {
  2162. type: title,
  2163. itemName: itemName,
  2164. openDialog: _isConfirm,
  2165. onCancel: function onCancel(v) {
  2166. return handleCancel();
  2167. },
  2168. onContinue: function onContinue(v) {
  2169. return handleDelete();
  2170. }
  2171. }) : /*#__PURE__*/React__default.createElement("div", null));
  2172. }
  2173. MkTable.propTypes = {
  2174. history: propTypes.object,
  2175. headers: propTypes.array.isRequired,
  2176. data: propTypes.array.isRequired,
  2177. query: propTypes.object,
  2178. onProductBOMClick: propTypes.func,
  2179. onActions: propTypes.func,
  2180. actions: propTypes.array,
  2181. title: propTypes.string,
  2182. order: propTypes.any,
  2183. orderBy: propTypes.any,
  2184. rowsPerPage: propTypes.any,
  2185. noMoreToLoad: propTypes.any,
  2186. isLoading: propTypes.any,
  2187. onChangePaginatePage: propTypes.any,
  2188. onGetData: propTypes.any,
  2189. onChangeRowPerPage: propTypes.any,
  2190. dense: propTypes.any,
  2191. styles: propTypes.any
  2192. };
  2193. var useStyles$2 = styles.makeStyles(function (theme) {
  2194. return {
  2195. root: {
  2196. width: '100%'
  2197. },
  2198. paper: {
  2199. width: '100%',
  2200. marginBottom: theme.spacing(2)
  2201. },
  2202. table: {
  2203. minWidth: 750
  2204. },
  2205. visuallyHidden: {
  2206. border: 0,
  2207. clip: 'rect(0 0 0 0)',
  2208. height: 1,
  2209. margin: -1,
  2210. overflow: 'hidden',
  2211. padding: 0,
  2212. position: 'absolute',
  2213. top: 20,
  2214. width: 1
  2215. },
  2216. underline: {
  2217. "&&&:before": {
  2218. borderBottom: "none"
  2219. },
  2220. "&&:after": {
  2221. borderBottom: "none"
  2222. }
  2223. },
  2224. button: {
  2225. color: 'white',
  2226. width: 150,
  2227. height: 55
  2228. },
  2229. closeButton: {
  2230. position: 'absolute',
  2231. right: theme.spacing(1),
  2232. top: theme.spacing(1),
  2233. color: theme.palette.grey[500]
  2234. },
  2235. headText: {
  2236. fontSize: 14,
  2237. "float": "left",
  2238. color: theme.palette.primary.main,
  2239. fontWeight: "bold"
  2240. }
  2241. };
  2242. });
  2243. function getDataString(data, fieldName) {
  2244. return data[fieldName];
  2245. }
  2246. function MkInfo(props) {
  2247. var classes = useStyles$2();
  2248. var infoData = props.infoData,
  2249. displayFields = props.displayFields,
  2250. _props$isNew = props.isNew,
  2251. isNew = _props$isNew === void 0 ? false : _props$isNew,
  2252. isEditable = props.isEditable,
  2253. currentTabName = props.currentTabName,
  2254. actions = props.actions;
  2255. var _React$useState = React__default.useState(isEditable !== undefined ? isEditable : true),
  2256. editable = _React$useState[0],
  2257. setEditable = _React$useState[1];
  2258. var handleEdit = function handleEdit() {
  2259. setEditable(false);
  2260. };
  2261. return /*#__PURE__*/React__default.createElement("div", {
  2262. className: classes.root
  2263. }, isNew ? /*#__PURE__*/React__default.createElement(core.Grid, {
  2264. container: true,
  2265. style: {
  2266. marginTop: '30px'
  2267. }
  2268. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2269. item: true,
  2270. xs: 12,
  2271. sm: 7
  2272. })) : /*#__PURE__*/React__default.createElement(core.Grid, {
  2273. container: true,
  2274. style: {
  2275. marginTop: '30px'
  2276. }
  2277. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2278. item: true,
  2279. xs: 12,
  2280. sm: 7
  2281. }, !editable ?
  2282. /*#__PURE__*/
  2283. React__default.createElement("div", null) : displayFields.map(function (d, i) {
  2284. return /*#__PURE__*/React__default.createElement(core.Grid, {
  2285. container: true,
  2286. key: i
  2287. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2288. item: true,
  2289. xs: 12,
  2290. style: {
  2291. display: 'flex',
  2292. alignItems: 'center',
  2293. marginBottom: '10px'
  2294. }
  2295. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2296. item: true,
  2297. xs: 12,
  2298. sm: 5
  2299. }, /*#__PURE__*/React__default.createElement(core.Box, {
  2300. style: {
  2301. width: '250px'
  2302. }
  2303. }, /*#__PURE__*/React__default.createElement(core.Typography, {
  2304. style: {
  2305. paddingRight: '30px',
  2306. color: 'grey'
  2307. }
  2308. }, d.label))), /*#__PURE__*/React__default.createElement(core.Grid, {
  2309. item: true,
  2310. xs: 12,
  2311. sm: 7
  2312. }, d.type === 'photo' ? /*#__PURE__*/React__default.createElement("img", null) :
  2313. /*#__PURE__*/
  2314. React__default.createElement(core.Typography, {
  2315. style: {
  2316. paddingRight: '30px'
  2317. }
  2318. }, infoData !== undefined ? getDataString(infoData, d.fieldName) : ''))));
  2319. })), /*#__PURE__*/React__default.createElement(core.Grid, {
  2320. item: true,
  2321. xs: 12,
  2322. sm: 7
  2323. }, /*#__PURE__*/React__default.createElement(core.Grid, {
  2324. container: true,
  2325. direction: "row",
  2326. alignItems: "flex-end"
  2327. }, actions.map(function (a, i) {
  2328. if (currentTabName === 'account') {
  2329. if (infoData.status === 'invited') {
  2330. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2331. style: {
  2332. color: 'white',
  2333. backgroundColor: 'grey',
  2334. "float": 'right',
  2335. marginLeft: '10px'
  2336. }
  2337. }, a.label));
  2338. }
  2339. if (infoData.status === 'joined') {
  2340. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2341. style: {
  2342. color: 'white',
  2343. backgroundColor: 'grey',
  2344. "float": 'right',
  2345. marginLeft: '10px'
  2346. }
  2347. }, a.label));
  2348. }
  2349. if (infoData.status === 'disabled') {
  2350. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2351. style: {
  2352. color: 'white',
  2353. backgroundColor: 'grey',
  2354. "float": 'right',
  2355. marginLeft: '10px'
  2356. }
  2357. }, a.label));
  2358. }
  2359. if (infoData.status === 'requested') {
  2360. if (editable) {
  2361. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2362. style: {
  2363. marginLeft: '10px'
  2364. },
  2365. onClick: handleEdit
  2366. }, a.icon, a.label));
  2367. } else {
  2368. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2369. style: {
  2370. color: 'white',
  2371. backgroundColor: 'grey',
  2372. "float": 'right',
  2373. marginLeft: '10px'
  2374. }
  2375. }, a.label));
  2376. }
  2377. }
  2378. } else {
  2379. if (editable) {
  2380. if (a.action_type === 'edit') {
  2381. console.log('type: ', a.action_type, 'editable: ', editable);
  2382. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2383. style: {
  2384. marginLeft: '10px'
  2385. },
  2386. onClick: handleEdit
  2387. }, a.icon, a.label));
  2388. }
  2389. if (a.action_type === 'delete') {
  2390. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2391. style: {
  2392. "float": 'right',
  2393. marginLeft: '10px'
  2394. }
  2395. }, a.icon, a.label));
  2396. }
  2397. } else {
  2398. if (a.action_type === 'save') {
  2399. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2400. style: {
  2401. marginLeft: '10px'
  2402. }
  2403. }, a.icon, a.label));
  2404. }
  2405. if (a.action_type === 'cancel') {
  2406. return /*#__PURE__*/React__default.createElement(core.Box, null, /*#__PURE__*/React__default.createElement(core.Button, {
  2407. style: {
  2408. "float": 'right',
  2409. marginLeft: '10px'
  2410. }
  2411. }, a.icon, a.label));
  2412. }
  2413. }
  2414. }
  2415. })))));
  2416. }
  2417. MkInfo.propTypes = {
  2418. history: propTypes.object,
  2419. infoData: propTypes.object,
  2420. displayFields: propTypes.array,
  2421. isNew: propTypes.bool,
  2422. isEditable: propTypes.bool,
  2423. actions: propTypes.any
  2424. };
  2425. exports.List = List;
  2426. exports.MkForm = MkForm;
  2427. exports.MkInfo = MkInfo;
  2428. exports.MkTable = MkTable;
  2429. //# sourceMappingURL=index.js.map