index.modern.js 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055
  1. import React$1 from 'react';
  2. import { InputBase, Grid, Box, Typography, TextField, NativeSelect, Button } from '@material-ui/core';
  3. import { withStyles, makeStyles } from '@material-ui/core/styles';
  4. import '@material-ui/icons/Save';
  5. import '@material-ui/icons/Cancel';
  6. import Table from '@material-ui/core/Table';
  7. import TableBody from '@material-ui/core/TableBody';
  8. import TableCell from '@material-ui/core/TableCell';
  9. import TableContainer from '@material-ui/core/TableContainer';
  10. import TableHead from '@material-ui/core/TableHead';
  11. import TablePagination from '@material-ui/core/TablePagination';
  12. import TableRow from '@material-ui/core/TableRow';
  13. import TableSortLabel from '@material-ui/core/TableSortLabel';
  14. function List({
  15. groupName,
  16. members = []
  17. }) {
  18. return /*#__PURE__*/React$1.createElement("div", null, /*#__PURE__*/React$1.createElement("h1", null, "1.0.3"), /*#__PURE__*/React$1.createElement("h5", null, "Group: ", /*#__PURE__*/React$1.createElement("em", null, groupName)), /*#__PURE__*/React$1.createElement("ul", null, /*#__PURE__*/React$1.createElement("p", null, "Members"), members.map(member => /*#__PURE__*/React$1.createElement("li", {
  19. key: member
  20. }, member))));
  21. }
  22. function createCommonjsModule(fn, module) {
  23. return module = { exports: {} }, fn(module, module.exports), module.exports;
  24. }
  25. /** @license React v16.13.1
  26. * react-is.production.min.js
  27. *
  28. * Copyright (c) Facebook, Inc. and its affiliates.
  29. *
  30. * This source code is licensed under the MIT license found in the
  31. * LICENSE file in the root directory of this source tree.
  32. */
  33. 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?
  34. 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;
  35. 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;
  36. 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};
  37. 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};
  38. 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;
  39. var reactIs_production_min = {
  40. AsyncMode: AsyncMode,
  41. ConcurrentMode: ConcurrentMode,
  42. ContextConsumer: ContextConsumer,
  43. ContextProvider: ContextProvider,
  44. Element: Element,
  45. ForwardRef: ForwardRef,
  46. Fragment: Fragment,
  47. Lazy: Lazy,
  48. Memo: Memo,
  49. Portal: Portal,
  50. Profiler: Profiler,
  51. StrictMode: StrictMode,
  52. Suspense: Suspense,
  53. isAsyncMode: isAsyncMode,
  54. isConcurrentMode: isConcurrentMode,
  55. isContextConsumer: isContextConsumer,
  56. isContextProvider: isContextProvider,
  57. isElement: isElement,
  58. isForwardRef: isForwardRef,
  59. isFragment: isFragment,
  60. isLazy: isLazy,
  61. isMemo: isMemo,
  62. isPortal: isPortal,
  63. isProfiler: isProfiler,
  64. isStrictMode: isStrictMode,
  65. isSuspense: isSuspense,
  66. isValidElementType: isValidElementType,
  67. typeOf: typeOf
  68. };
  69. var reactIs_development = createCommonjsModule(function (module, exports) {
  70. if (process.env.NODE_ENV !== "production") {
  71. (function() {
  72. // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
  73. // nor polyfill, then a plain number is used for performance.
  74. var hasSymbol = typeof Symbol === 'function' && Symbol.for;
  75. var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
  76. var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
  77. var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
  78. var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
  79. var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
  80. var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
  81. var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
  82. // (unstable) APIs that have been removed. Can we remove the symbols?
  83. var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
  84. var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
  85. var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
  86. var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
  87. var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
  88. var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
  89. var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
  90. var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
  91. var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
  92. var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
  93. var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
  94. function isValidElementType(type) {
  95. return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
  96. 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);
  97. }
  98. function typeOf(object) {
  99. if (typeof object === 'object' && object !== null) {
  100. var $$typeof = object.$$typeof;
  101. switch ($$typeof) {
  102. case REACT_ELEMENT_TYPE:
  103. var type = object.type;
  104. switch (type) {
  105. case REACT_ASYNC_MODE_TYPE:
  106. case REACT_CONCURRENT_MODE_TYPE:
  107. case REACT_FRAGMENT_TYPE:
  108. case REACT_PROFILER_TYPE:
  109. case REACT_STRICT_MODE_TYPE:
  110. case REACT_SUSPENSE_TYPE:
  111. return type;
  112. default:
  113. var $$typeofType = type && type.$$typeof;
  114. switch ($$typeofType) {
  115. case REACT_CONTEXT_TYPE:
  116. case REACT_FORWARD_REF_TYPE:
  117. case REACT_LAZY_TYPE:
  118. case REACT_MEMO_TYPE:
  119. case REACT_PROVIDER_TYPE:
  120. return $$typeofType;
  121. default:
  122. return $$typeof;
  123. }
  124. }
  125. case REACT_PORTAL_TYPE:
  126. return $$typeof;
  127. }
  128. }
  129. return undefined;
  130. } // AsyncMode is deprecated along with isAsyncMode
  131. var AsyncMode = REACT_ASYNC_MODE_TYPE;
  132. var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
  133. var ContextConsumer = REACT_CONTEXT_TYPE;
  134. var ContextProvider = REACT_PROVIDER_TYPE;
  135. var Element = REACT_ELEMENT_TYPE;
  136. var ForwardRef = REACT_FORWARD_REF_TYPE;
  137. var Fragment = REACT_FRAGMENT_TYPE;
  138. var Lazy = REACT_LAZY_TYPE;
  139. var Memo = REACT_MEMO_TYPE;
  140. var Portal = REACT_PORTAL_TYPE;
  141. var Profiler = REACT_PROFILER_TYPE;
  142. var StrictMode = REACT_STRICT_MODE_TYPE;
  143. var Suspense = REACT_SUSPENSE_TYPE;
  144. var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
  145. function isAsyncMode(object) {
  146. {
  147. if (!hasWarnedAboutDeprecatedIsAsyncMode) {
  148. hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
  149. 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.');
  150. }
  151. }
  152. return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
  153. }
  154. function isConcurrentMode(object) {
  155. return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
  156. }
  157. function isContextConsumer(object) {
  158. return typeOf(object) === REACT_CONTEXT_TYPE;
  159. }
  160. function isContextProvider(object) {
  161. return typeOf(object) === REACT_PROVIDER_TYPE;
  162. }
  163. function isElement(object) {
  164. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  165. }
  166. function isForwardRef(object) {
  167. return typeOf(object) === REACT_FORWARD_REF_TYPE;
  168. }
  169. function isFragment(object) {
  170. return typeOf(object) === REACT_FRAGMENT_TYPE;
  171. }
  172. function isLazy(object) {
  173. return typeOf(object) === REACT_LAZY_TYPE;
  174. }
  175. function isMemo(object) {
  176. return typeOf(object) === REACT_MEMO_TYPE;
  177. }
  178. function isPortal(object) {
  179. return typeOf(object) === REACT_PORTAL_TYPE;
  180. }
  181. function isProfiler(object) {
  182. return typeOf(object) === REACT_PROFILER_TYPE;
  183. }
  184. function isStrictMode(object) {
  185. return typeOf(object) === REACT_STRICT_MODE_TYPE;
  186. }
  187. function isSuspense(object) {
  188. return typeOf(object) === REACT_SUSPENSE_TYPE;
  189. }
  190. exports.AsyncMode = AsyncMode;
  191. exports.ConcurrentMode = ConcurrentMode;
  192. exports.ContextConsumer = ContextConsumer;
  193. exports.ContextProvider = ContextProvider;
  194. exports.Element = Element;
  195. exports.ForwardRef = ForwardRef;
  196. exports.Fragment = Fragment;
  197. exports.Lazy = Lazy;
  198. exports.Memo = Memo;
  199. exports.Portal = Portal;
  200. exports.Profiler = Profiler;
  201. exports.StrictMode = StrictMode;
  202. exports.Suspense = Suspense;
  203. exports.isAsyncMode = isAsyncMode;
  204. exports.isConcurrentMode = isConcurrentMode;
  205. exports.isContextConsumer = isContextConsumer;
  206. exports.isContextProvider = isContextProvider;
  207. exports.isElement = isElement;
  208. exports.isForwardRef = isForwardRef;
  209. exports.isFragment = isFragment;
  210. exports.isLazy = isLazy;
  211. exports.isMemo = isMemo;
  212. exports.isPortal = isPortal;
  213. exports.isProfiler = isProfiler;
  214. exports.isStrictMode = isStrictMode;
  215. exports.isSuspense = isSuspense;
  216. exports.isValidElementType = isValidElementType;
  217. exports.typeOf = typeOf;
  218. })();
  219. }
  220. });
  221. var reactIs = createCommonjsModule(function (module) {
  222. if (process.env.NODE_ENV === 'production') {
  223. module.exports = reactIs_production_min;
  224. } else {
  225. module.exports = reactIs_development;
  226. }
  227. });
  228. /*
  229. object-assign
  230. (c) Sindre Sorhus
  231. @license MIT
  232. */
  233. /* eslint-disable no-unused-vars */
  234. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  235. var hasOwnProperty = Object.prototype.hasOwnProperty;
  236. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  237. function toObject(val) {
  238. if (val === null || val === undefined) {
  239. throw new TypeError('Object.assign cannot be called with null or undefined');
  240. }
  241. return Object(val);
  242. }
  243. function shouldUseNative() {
  244. try {
  245. if (!Object.assign) {
  246. return false;
  247. }
  248. // Detect buggy property enumeration order in older V8 versions.
  249. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  250. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  251. test1[5] = 'de';
  252. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  253. return false;
  254. }
  255. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  256. var test2 = {};
  257. for (var i = 0; i < 10; i++) {
  258. test2['_' + String.fromCharCode(i)] = i;
  259. }
  260. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  261. return test2[n];
  262. });
  263. if (order2.join('') !== '0123456789') {
  264. return false;
  265. }
  266. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  267. var test3 = {};
  268. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  269. test3[letter] = letter;
  270. });
  271. if (Object.keys(Object.assign({}, test3)).join('') !==
  272. 'abcdefghijklmnopqrst') {
  273. return false;
  274. }
  275. return true;
  276. } catch (err) {
  277. // We don't expect any of the above to throw, but better to be safe.
  278. return false;
  279. }
  280. }
  281. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  282. var from;
  283. var to = toObject(target);
  284. var symbols;
  285. for (var s = 1; s < arguments.length; s++) {
  286. from = Object(arguments[s]);
  287. for (var key in from) {
  288. if (hasOwnProperty.call(from, key)) {
  289. to[key] = from[key];
  290. }
  291. }
  292. if (getOwnPropertySymbols) {
  293. symbols = getOwnPropertySymbols(from);
  294. for (var i = 0; i < symbols.length; i++) {
  295. if (propIsEnumerable.call(from, symbols[i])) {
  296. to[symbols[i]] = from[symbols[i]];
  297. }
  298. }
  299. }
  300. }
  301. return to;
  302. };
  303. /**
  304. * Copyright (c) 2013-present, Facebook, Inc.
  305. *
  306. * This source code is licensed under the MIT license found in the
  307. * LICENSE file in the root directory of this source tree.
  308. */
  309. var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
  310. var ReactPropTypesSecret_1 = ReactPropTypesSecret;
  311. var printWarning = function() {};
  312. if (process.env.NODE_ENV !== 'production') {
  313. var ReactPropTypesSecret$1 = ReactPropTypesSecret_1;
  314. var loggedTypeFailures = {};
  315. var has = Function.call.bind(Object.prototype.hasOwnProperty);
  316. printWarning = function(text) {
  317. var message = 'Warning: ' + text;
  318. if (typeof console !== 'undefined') {
  319. console.error(message);
  320. }
  321. try {
  322. // --- Welcome to debugging React ---
  323. // This error was thrown as a convenience so that you can use this stack
  324. // to find the callsite that caused this warning to fire.
  325. throw new Error(message);
  326. } catch (x) {}
  327. };
  328. }
  329. /**
  330. * Assert that the values match with the type specs.
  331. * Error messages are memorized and will only be shown once.
  332. *
  333. * @param {object} typeSpecs Map of name to a ReactPropType
  334. * @param {object} values Runtime values that need to be type-checked
  335. * @param {string} location e.g. "prop", "context", "child context"
  336. * @param {string} componentName Name of the component for error messages.
  337. * @param {?Function} getStack Returns the component stack.
  338. * @private
  339. */
  340. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  341. if (process.env.NODE_ENV !== 'production') {
  342. for (var typeSpecName in typeSpecs) {
  343. if (has(typeSpecs, typeSpecName)) {
  344. var error;
  345. // Prop type validation may throw. In case they do, we don't want to
  346. // fail the render phase where it didn't fail before. So we log it.
  347. // After these have been cleaned up, we'll let them throw.
  348. try {
  349. // This is intentionally an invariant that gets caught. It's the same
  350. // behavior as without this statement except with a better message.
  351. if (typeof typeSpecs[typeSpecName] !== 'function') {
  352. var err = Error(
  353. (componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
  354. 'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
  355. );
  356. err.name = 'Invariant Violation';
  357. throw err;
  358. }
  359. error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret$1);
  360. } catch (ex) {
  361. error = ex;
  362. }
  363. if (error && !(error instanceof Error)) {
  364. printWarning(
  365. (componentName || 'React class') + ': type specification of ' +
  366. location + ' `' + typeSpecName + '` is invalid; the type checker ' +
  367. 'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
  368. 'You may have forgotten to pass an argument to the type checker ' +
  369. 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
  370. 'shape all require an argument).'
  371. );
  372. }
  373. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  374. // Only monitor this failure once because there tends to be a lot of the
  375. // same error.
  376. loggedTypeFailures[error.message] = true;
  377. var stack = getStack ? getStack() : '';
  378. printWarning(
  379. 'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
  380. );
  381. }
  382. }
  383. }
  384. }
  385. }
  386. /**
  387. * Resets warning cache when testing.
  388. *
  389. * @private
  390. */
  391. checkPropTypes.resetWarningCache = function() {
  392. if (process.env.NODE_ENV !== 'production') {
  393. loggedTypeFailures = {};
  394. }
  395. };
  396. var checkPropTypes_1 = checkPropTypes;
  397. var has$1 = Function.call.bind(Object.prototype.hasOwnProperty);
  398. var printWarning$1 = function() {};
  399. if (process.env.NODE_ENV !== 'production') {
  400. printWarning$1 = function(text) {
  401. var message = 'Warning: ' + text;
  402. if (typeof console !== 'undefined') {
  403. console.error(message);
  404. }
  405. try {
  406. // --- Welcome to debugging React ---
  407. // This error was thrown as a convenience so that you can use this stack
  408. // to find the callsite that caused this warning to fire.
  409. throw new Error(message);
  410. } catch (x) {}
  411. };
  412. }
  413. function emptyFunctionThatReturnsNull() {
  414. return null;
  415. }
  416. var factoryWithTypeCheckers = function(isValidElement, throwOnDirectAccess) {
  417. /* global Symbol */
  418. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  419. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  420. /**
  421. * Returns the iterator method function contained on the iterable object.
  422. *
  423. * Be sure to invoke the function with the iterable as context:
  424. *
  425. * var iteratorFn = getIteratorFn(myIterable);
  426. * if (iteratorFn) {
  427. * var iterator = iteratorFn.call(myIterable);
  428. * ...
  429. * }
  430. *
  431. * @param {?object} maybeIterable
  432. * @return {?function}
  433. */
  434. function getIteratorFn(maybeIterable) {
  435. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  436. if (typeof iteratorFn === 'function') {
  437. return iteratorFn;
  438. }
  439. }
  440. /**
  441. * Collection of methods that allow declaration and validation of props that are
  442. * supplied to React components. Example usage:
  443. *
  444. * var Props = require('ReactPropTypes');
  445. * var MyArticle = React.createClass({
  446. * propTypes: {
  447. * // An optional string prop named "description".
  448. * description: Props.string,
  449. *
  450. * // A required enum prop named "category".
  451. * category: Props.oneOf(['News','Photos']).isRequired,
  452. *
  453. * // A prop named "dialog" that requires an instance of Dialog.
  454. * dialog: Props.instanceOf(Dialog).isRequired
  455. * },
  456. * render: function() { ... }
  457. * });
  458. *
  459. * A more formal specification of how these methods are used:
  460. *
  461. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  462. * decl := ReactPropTypes.{type}(.isRequired)?
  463. *
  464. * Each and every declaration produces a function with the same signature. This
  465. * allows the creation of custom validation functions. For example:
  466. *
  467. * var MyLink = React.createClass({
  468. * propTypes: {
  469. * // An optional string or URI prop named "href".
  470. * href: function(props, propName, componentName) {
  471. * var propValue = props[propName];
  472. * if (propValue != null && typeof propValue !== 'string' &&
  473. * !(propValue instanceof URI)) {
  474. * return new Error(
  475. * 'Expected a string or an URI for ' + propName + ' in ' +
  476. * componentName
  477. * );
  478. * }
  479. * }
  480. * },
  481. * render: function() {...}
  482. * });
  483. *
  484. * @internal
  485. */
  486. var ANONYMOUS = '<<anonymous>>';
  487. // Important!
  488. // Keep this list in sync with production version in `./factoryWithThrowingShims.js`.
  489. var ReactPropTypes = {
  490. array: createPrimitiveTypeChecker('array'),
  491. bool: createPrimitiveTypeChecker('boolean'),
  492. func: createPrimitiveTypeChecker('function'),
  493. number: createPrimitiveTypeChecker('number'),
  494. object: createPrimitiveTypeChecker('object'),
  495. string: createPrimitiveTypeChecker('string'),
  496. symbol: createPrimitiveTypeChecker('symbol'),
  497. any: createAnyTypeChecker(),
  498. arrayOf: createArrayOfTypeChecker,
  499. element: createElementTypeChecker(),
  500. elementType: createElementTypeTypeChecker(),
  501. instanceOf: createInstanceTypeChecker,
  502. node: createNodeChecker(),
  503. objectOf: createObjectOfTypeChecker,
  504. oneOf: createEnumTypeChecker,
  505. oneOfType: createUnionTypeChecker,
  506. shape: createShapeTypeChecker,
  507. exact: createStrictShapeTypeChecker,
  508. };
  509. /**
  510. * inlined Object.is polyfill to avoid requiring consumers ship their own
  511. * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
  512. */
  513. /*eslint-disable no-self-compare*/
  514. function is(x, y) {
  515. // SameValue algorithm
  516. if (x === y) {
  517. // Steps 1-5, 7-10
  518. // Steps 6.b-6.e: +0 != -0
  519. return x !== 0 || 1 / x === 1 / y;
  520. } else {
  521. // Step 6.a: NaN == NaN
  522. return x !== x && y !== y;
  523. }
  524. }
  525. /*eslint-enable no-self-compare*/
  526. /**
  527. * We use an Error-like object for backward compatibility as people may call
  528. * PropTypes directly and inspect their output. However, we don't use real
  529. * Errors anymore. We don't inspect their stack anyway, and creating them
  530. * is prohibitively expensive if they are created too often, such as what
  531. * happens in oneOfType() for any type before the one that matched.
  532. */
  533. function PropTypeError(message) {
  534. this.message = message;
  535. this.stack = '';
  536. }
  537. // Make `instanceof Error` still work for returned errors.
  538. PropTypeError.prototype = Error.prototype;
  539. function createChainableTypeChecker(validate) {
  540. if (process.env.NODE_ENV !== 'production') {
  541. var manualPropTypeCallCache = {};
  542. var manualPropTypeWarningCount = 0;
  543. }
  544. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  545. componentName = componentName || ANONYMOUS;
  546. propFullName = propFullName || propName;
  547. if (secret !== ReactPropTypesSecret_1) {
  548. if (throwOnDirectAccess) {
  549. // New behavior only for users of `prop-types` package
  550. var err = new Error(
  551. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  552. 'Use `PropTypes.checkPropTypes()` to call them. ' +
  553. 'Read more at http://fb.me/use-check-prop-types'
  554. );
  555. err.name = 'Invariant Violation';
  556. throw err;
  557. } else if (process.env.NODE_ENV !== 'production' && typeof console !== 'undefined') {
  558. // Old behavior for people using React.PropTypes
  559. var cacheKey = componentName + ':' + propName;
  560. if (
  561. !manualPropTypeCallCache[cacheKey] &&
  562. // Avoid spamming the console because they are often not actionable except for lib authors
  563. manualPropTypeWarningCount < 3
  564. ) {
  565. printWarning$1(
  566. 'You are manually calling a React.PropTypes validation ' +
  567. 'function for the `' + propFullName + '` prop on `' + componentName + '`. This is deprecated ' +
  568. 'and will throw in the standalone `prop-types` package. ' +
  569. 'You may be seeing this warning due to a third-party PropTypes ' +
  570. 'library. See https://fb.me/react-warning-dont-call-proptypes ' + 'for details.'
  571. );
  572. manualPropTypeCallCache[cacheKey] = true;
  573. manualPropTypeWarningCount++;
  574. }
  575. }
  576. }
  577. if (props[propName] == null) {
  578. if (isRequired) {
  579. if (props[propName] === null) {
  580. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required ' + ('in `' + componentName + '`, but its value is `null`.'));
  581. }
  582. return new PropTypeError('The ' + location + ' `' + propFullName + '` is marked as required in ' + ('`' + componentName + '`, but its value is `undefined`.'));
  583. }
  584. return null;
  585. } else {
  586. return validate(props, propName, componentName, location, propFullName);
  587. }
  588. }
  589. var chainedCheckType = checkType.bind(null, false);
  590. chainedCheckType.isRequired = checkType.bind(null, true);
  591. return chainedCheckType;
  592. }
  593. function createPrimitiveTypeChecker(expectedType) {
  594. function validate(props, propName, componentName, location, propFullName, secret) {
  595. var propValue = props[propName];
  596. var propType = getPropType(propValue);
  597. if (propType !== expectedType) {
  598. // `propValue` being instance of, say, date/regexp, pass the 'object'
  599. // check, but we can offer a more precise error message here rather than
  600. // 'of type `object`'.
  601. var preciseType = getPreciseType(propValue);
  602. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  603. }
  604. return null;
  605. }
  606. return createChainableTypeChecker(validate);
  607. }
  608. function createAnyTypeChecker() {
  609. return createChainableTypeChecker(emptyFunctionThatReturnsNull);
  610. }
  611. function createArrayOfTypeChecker(typeChecker) {
  612. function validate(props, propName, componentName, location, propFullName) {
  613. if (typeof typeChecker !== 'function') {
  614. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside arrayOf.');
  615. }
  616. var propValue = props[propName];
  617. if (!Array.isArray(propValue)) {
  618. var propType = getPropType(propValue);
  619. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  620. }
  621. for (var i = 0; i < propValue.length; i++) {
  622. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']', ReactPropTypesSecret_1);
  623. if (error instanceof Error) {
  624. return error;
  625. }
  626. }
  627. return null;
  628. }
  629. return createChainableTypeChecker(validate);
  630. }
  631. function createElementTypeChecker() {
  632. function validate(props, propName, componentName, location, propFullName) {
  633. var propValue = props[propName];
  634. if (!isValidElement(propValue)) {
  635. var propType = getPropType(propValue);
  636. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement.'));
  637. }
  638. return null;
  639. }
  640. return createChainableTypeChecker(validate);
  641. }
  642. function createElementTypeTypeChecker() {
  643. function validate(props, propName, componentName, location, propFullName) {
  644. var propValue = props[propName];
  645. if (!reactIs.isValidElementType(propValue)) {
  646. var propType = getPropType(propValue);
  647. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected a single ReactElement type.'));
  648. }
  649. return null;
  650. }
  651. return createChainableTypeChecker(validate);
  652. }
  653. function createInstanceTypeChecker(expectedClass) {
  654. function validate(props, propName, componentName, location, propFullName) {
  655. if (!(props[propName] instanceof expectedClass)) {
  656. var expectedClassName = expectedClass.name || ANONYMOUS;
  657. var actualClassName = getClassName(props[propName]);
  658. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  659. }
  660. return null;
  661. }
  662. return createChainableTypeChecker(validate);
  663. }
  664. function createEnumTypeChecker(expectedValues) {
  665. if (!Array.isArray(expectedValues)) {
  666. if (process.env.NODE_ENV !== 'production') {
  667. if (arguments.length > 1) {
  668. printWarning$1(
  669. 'Invalid arguments supplied to oneOf, expected an array, got ' + arguments.length + ' arguments. ' +
  670. 'A common mistake is to write oneOf(x, y, z) instead of oneOf([x, y, z]).'
  671. );
  672. } else {
  673. printWarning$1('Invalid argument supplied to oneOf, expected an array.');
  674. }
  675. }
  676. return emptyFunctionThatReturnsNull;
  677. }
  678. function validate(props, propName, componentName, location, propFullName) {
  679. var propValue = props[propName];
  680. for (var i = 0; i < expectedValues.length; i++) {
  681. if (is(propValue, expectedValues[i])) {
  682. return null;
  683. }
  684. }
  685. var valuesString = JSON.stringify(expectedValues, function replacer(key, value) {
  686. var type = getPreciseType(value);
  687. if (type === 'symbol') {
  688. return String(value);
  689. }
  690. return value;
  691. });
  692. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of value `' + String(propValue) + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  693. }
  694. return createChainableTypeChecker(validate);
  695. }
  696. function createObjectOfTypeChecker(typeChecker) {
  697. function validate(props, propName, componentName, location, propFullName) {
  698. if (typeof typeChecker !== 'function') {
  699. return new PropTypeError('Property `' + propFullName + '` of component `' + componentName + '` has invalid PropType notation inside objectOf.');
  700. }
  701. var propValue = props[propName];
  702. var propType = getPropType(propValue);
  703. if (propType !== 'object') {
  704. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  705. }
  706. for (var key in propValue) {
  707. if (has$1(propValue, key)) {
  708. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  709. if (error instanceof Error) {
  710. return error;
  711. }
  712. }
  713. }
  714. return null;
  715. }
  716. return createChainableTypeChecker(validate);
  717. }
  718. function createUnionTypeChecker(arrayOfTypeCheckers) {
  719. if (!Array.isArray(arrayOfTypeCheckers)) {
  720. process.env.NODE_ENV !== 'production' ? printWarning$1('Invalid argument supplied to oneOfType, expected an instance of array.') : void 0;
  721. return emptyFunctionThatReturnsNull;
  722. }
  723. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  724. var checker = arrayOfTypeCheckers[i];
  725. if (typeof checker !== 'function') {
  726. printWarning$1(
  727. 'Invalid argument supplied to oneOfType. Expected an array of check functions, but ' +
  728. 'received ' + getPostfixForTypeWarning(checker) + ' at index ' + i + '.'
  729. );
  730. return emptyFunctionThatReturnsNull;
  731. }
  732. }
  733. function validate(props, propName, componentName, location, propFullName) {
  734. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  735. var checker = arrayOfTypeCheckers[i];
  736. if (checker(props, propName, componentName, location, propFullName, ReactPropTypesSecret_1) == null) {
  737. return null;
  738. }
  739. }
  740. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  741. }
  742. return createChainableTypeChecker(validate);
  743. }
  744. function createNodeChecker() {
  745. function validate(props, propName, componentName, location, propFullName) {
  746. if (!isNode(props[propName])) {
  747. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  748. }
  749. return null;
  750. }
  751. return createChainableTypeChecker(validate);
  752. }
  753. function createShapeTypeChecker(shapeTypes) {
  754. function validate(props, propName, componentName, location, propFullName) {
  755. var propValue = props[propName];
  756. var propType = getPropType(propValue);
  757. if (propType !== 'object') {
  758. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  759. }
  760. for (var key in shapeTypes) {
  761. var checker = shapeTypes[key];
  762. if (!checker) {
  763. continue;
  764. }
  765. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  766. if (error) {
  767. return error;
  768. }
  769. }
  770. return null;
  771. }
  772. return createChainableTypeChecker(validate);
  773. }
  774. function createStrictShapeTypeChecker(shapeTypes) {
  775. function validate(props, propName, componentName, location, propFullName) {
  776. var propValue = props[propName];
  777. var propType = getPropType(propValue);
  778. if (propType !== 'object') {
  779. return new PropTypeError('Invalid ' + location + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  780. }
  781. // We need to check all keys in case some are required but missing from
  782. // props.
  783. var allKeys = objectAssign({}, props[propName], shapeTypes);
  784. for (var key in allKeys) {
  785. var checker = shapeTypes[key];
  786. if (!checker) {
  787. return new PropTypeError(
  788. 'Invalid ' + location + ' `' + propFullName + '` key `' + key + '` supplied to `' + componentName + '`.' +
  789. '\nBad object: ' + JSON.stringify(props[propName], null, ' ') +
  790. '\nValid keys: ' + JSON.stringify(Object.keys(shapeTypes), null, ' ')
  791. );
  792. }
  793. var error = checker(propValue, key, componentName, location, propFullName + '.' + key, ReactPropTypesSecret_1);
  794. if (error) {
  795. return error;
  796. }
  797. }
  798. return null;
  799. }
  800. return createChainableTypeChecker(validate);
  801. }
  802. function isNode(propValue) {
  803. switch (typeof propValue) {
  804. case 'number':
  805. case 'string':
  806. case 'undefined':
  807. return true;
  808. case 'boolean':
  809. return !propValue;
  810. case 'object':
  811. if (Array.isArray(propValue)) {
  812. return propValue.every(isNode);
  813. }
  814. if (propValue === null || isValidElement(propValue)) {
  815. return true;
  816. }
  817. var iteratorFn = getIteratorFn(propValue);
  818. if (iteratorFn) {
  819. var iterator = iteratorFn.call(propValue);
  820. var step;
  821. if (iteratorFn !== propValue.entries) {
  822. while (!(step = iterator.next()).done) {
  823. if (!isNode(step.value)) {
  824. return false;
  825. }
  826. }
  827. } else {
  828. // Iterator will provide entry [k,v] tuples rather than values.
  829. while (!(step = iterator.next()).done) {
  830. var entry = step.value;
  831. if (entry) {
  832. if (!isNode(entry[1])) {
  833. return false;
  834. }
  835. }
  836. }
  837. }
  838. } else {
  839. return false;
  840. }
  841. return true;
  842. default:
  843. return false;
  844. }
  845. }
  846. function isSymbol(propType, propValue) {
  847. // Native Symbol.
  848. if (propType === 'symbol') {
  849. return true;
  850. }
  851. // falsy value can't be a Symbol
  852. if (!propValue) {
  853. return false;
  854. }
  855. // 19.4.3.5 Symbol.prototype[@@toStringTag] === 'Symbol'
  856. if (propValue['@@toStringTag'] === 'Symbol') {
  857. return true;
  858. }
  859. // Fallback for non-spec compliant Symbols which are polyfilled.
  860. if (typeof Symbol === 'function' && propValue instanceof Symbol) {
  861. return true;
  862. }
  863. return false;
  864. }
  865. // Equivalent of `typeof` but with special handling for array and regexp.
  866. function getPropType(propValue) {
  867. var propType = typeof propValue;
  868. if (Array.isArray(propValue)) {
  869. return 'array';
  870. }
  871. if (propValue instanceof RegExp) {
  872. // Old webkits (at least until Android 4.0) return 'function' rather than
  873. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  874. // passes PropTypes.object.
  875. return 'object';
  876. }
  877. if (isSymbol(propType, propValue)) {
  878. return 'symbol';
  879. }
  880. return propType;
  881. }
  882. // This handles more types than `getPropType`. Only used for error messages.
  883. // See `createPrimitiveTypeChecker`.
  884. function getPreciseType(propValue) {
  885. if (typeof propValue === 'undefined' || propValue === null) {
  886. return '' + propValue;
  887. }
  888. var propType = getPropType(propValue);
  889. if (propType === 'object') {
  890. if (propValue instanceof Date) {
  891. return 'date';
  892. } else if (propValue instanceof RegExp) {
  893. return 'regexp';
  894. }
  895. }
  896. return propType;
  897. }
  898. // Returns a string that is postfixed to a warning about an invalid type.
  899. // For example, "undefined" or "of type array"
  900. function getPostfixForTypeWarning(value) {
  901. var type = getPreciseType(value);
  902. switch (type) {
  903. case 'array':
  904. case 'object':
  905. return 'an ' + type;
  906. case 'boolean':
  907. case 'date':
  908. case 'regexp':
  909. return 'a ' + type;
  910. default:
  911. return type;
  912. }
  913. }
  914. // Returns class name of the object, if any.
  915. function getClassName(propValue) {
  916. if (!propValue.constructor || !propValue.constructor.name) {
  917. return ANONYMOUS;
  918. }
  919. return propValue.constructor.name;
  920. }
  921. ReactPropTypes.checkPropTypes = checkPropTypes_1;
  922. ReactPropTypes.resetWarningCache = checkPropTypes_1.resetWarningCache;
  923. ReactPropTypes.PropTypes = ReactPropTypes;
  924. return ReactPropTypes;
  925. };
  926. function emptyFunction() {}
  927. function emptyFunctionWithReset() {}
  928. emptyFunctionWithReset.resetWarningCache = emptyFunction;
  929. var factoryWithThrowingShims = function() {
  930. function shim(props, propName, componentName, location, propFullName, secret) {
  931. if (secret === ReactPropTypesSecret_1) {
  932. // It is still safe when called from React.
  933. return;
  934. }
  935. var err = new Error(
  936. 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
  937. 'Use PropTypes.checkPropTypes() to call them. ' +
  938. 'Read more at http://fb.me/use-check-prop-types'
  939. );
  940. err.name = 'Invariant Violation';
  941. throw err;
  942. } shim.isRequired = shim;
  943. function getShim() {
  944. return shim;
  945. } // Important!
  946. // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
  947. var ReactPropTypes = {
  948. array: shim,
  949. bool: shim,
  950. func: shim,
  951. number: shim,
  952. object: shim,
  953. string: shim,
  954. symbol: shim,
  955. any: shim,
  956. arrayOf: getShim,
  957. element: shim,
  958. elementType: shim,
  959. instanceOf: getShim,
  960. node: shim,
  961. objectOf: getShim,
  962. oneOf: getShim,
  963. oneOfType: getShim,
  964. shape: getShim,
  965. exact: getShim,
  966. checkPropTypes: emptyFunctionWithReset,
  967. resetWarningCache: emptyFunction
  968. };
  969. ReactPropTypes.PropTypes = ReactPropTypes;
  970. return ReactPropTypes;
  971. };
  972. var propTypes = createCommonjsModule(function (module) {
  973. /**
  974. * Copyright (c) 2013-present, Facebook, Inc.
  975. *
  976. * This source code is licensed under the MIT license found in the
  977. * LICENSE file in the root directory of this source tree.
  978. */
  979. if (process.env.NODE_ENV !== 'production') {
  980. var ReactIs = reactIs;
  981. // By explicitly using `prop-types` you are opting into new development behavior.
  982. // http://fb.me/prop-types-in-prod
  983. var throwOnDirectAccess = true;
  984. module.exports = factoryWithTypeCheckers(ReactIs.isElement, throwOnDirectAccess);
  985. } else {
  986. // By explicitly using `prop-types` you are opting into new production behavior.
  987. // http://fb.me/prop-types-in-prod
  988. module.exports = factoryWithThrowingShims();
  989. }
  990. });
  991. const BootstrapInput = withStyles(theme => ({
  992. root: {
  993. 'label + &': {
  994. marginTop: theme.spacing(3)
  995. }
  996. },
  997. input: {
  998. borderRadius: 4,
  999. position: 'relative',
  1000. backgroundColor: 'transparent',
  1001. border: '1px solid #ced4da',
  1002. fontSize: 16,
  1003. padding: '10px 26px 10px 12px',
  1004. transition: theme.transitions.create(['border-color', 'box-shadow']),
  1005. fontFamily: ['-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"'].join(','),
  1006. '&:focus': {
  1007. borderRadius: 4,
  1008. borderColor: '#80bdff',
  1009. boxShadow: '0 0 0 0.2rem rgba(0,123,255,.25)'
  1010. }
  1011. }
  1012. }))(InputBase);
  1013. const useStyles = makeStyles(theme => ({
  1014. root: {
  1015. width: '100%'
  1016. },
  1017. paper: {
  1018. width: '100%',
  1019. marginBottom: theme.spacing(2)
  1020. },
  1021. table: {
  1022. minWidth: 750
  1023. },
  1024. visuallyHidden: {
  1025. border: 0,
  1026. clip: 'rect(0 0 0 0)',
  1027. height: 1,
  1028. margin: -1,
  1029. overflow: 'hidden',
  1030. padding: 0,
  1031. position: 'absolute',
  1032. top: 20,
  1033. width: 1
  1034. },
  1035. underline: {
  1036. "&&&:before": {
  1037. borderBottom: "none"
  1038. },
  1039. "&&:after": {
  1040. borderBottom: "none"
  1041. }
  1042. }
  1043. }));
  1044. function FieldList(props) {
  1045. const classes = useStyles();
  1046. const {
  1047. fields = [],
  1048. updateData = {},
  1049. onDataCallback
  1050. } = props;
  1051. const [data, setDataField] = React$1.useState(updateData != undefined ? updateData : {});
  1052. const [imgPreview, setImgPreviewPath] = React$1.useState(null);
  1053. const handleTextString = (e, fieldName) => {
  1054. setDataField({ ...data,
  1055. [fieldName]: e.target.value
  1056. });
  1057. };
  1058. const handleTextNumber = (e, fieldName) => {
  1059. setDataField({ ...data,
  1060. [fieldName]: e.target.value
  1061. });
  1062. };
  1063. const handleTextMultiline = (e, fieldName) => {
  1064. setDataField({ ...data,
  1065. [fieldName]: e.target.value
  1066. });
  1067. };
  1068. const handleDate = (e, fieldName) => {
  1069. setDataField({ ...data,
  1070. [fieldName]: e.target.value
  1071. });
  1072. };
  1073. const handleDropDownChange = (e, fieldName) => {
  1074. var selectedIndex = e.target.options.selectedIndex;
  1075. var selectedValue = e.target.options[selectedIndex].getAttribute('name');
  1076. var fn = fieldName.split('_');
  1077. var fieldId = fn[0] + '_' + 'id';
  1078. setDataField({ ...data,
  1079. [fieldName]: selectedValue,
  1080. [fieldId]: e.target.value
  1081. });
  1082. };
  1083. const handleImgUpload = (e, fieldName) => {
  1084. e.preventDefault();
  1085. let reader = new FileReader();
  1086. let file = e.target.files[0];
  1087. reader.onloadend = () => {
  1088. setImgPreviewPath(reader.result);
  1089. };
  1090. reader.readAsDataURL(file);
  1091. setDataField({ ...data,
  1092. [fieldName]: e.target.files[0].name
  1093. });
  1094. };
  1095. const handleDataConfirm = () => {
  1096. onDataCallback(data);
  1097. };
  1098. return /*#__PURE__*/React$1.createElement("div", {
  1099. className: classes.root
  1100. }, /*#__PURE__*/React$1.createElement(Grid, {
  1101. container: true
  1102. }, /*#__PURE__*/React$1.createElement(Grid, {
  1103. item: true,
  1104. xs: 11
  1105. }, fields.map((f, i) => {
  1106. if (f.type == 'text_string') {
  1107. return /*#__PURE__*/React$1.createElement(Grid, {
  1108. key: f.fieldName,
  1109. container: true,
  1110. style: {
  1111. display: 'flex',
  1112. alignItems: 'center',
  1113. marginBottom: '10px'
  1114. }
  1115. }, /*#__PURE__*/React$1.createElement(Grid, {
  1116. item: true,
  1117. xs: 12,
  1118. sm: 5
  1119. }, /*#__PURE__*/React$1.createElement(Box, {
  1120. style: {
  1121. width: '150px'
  1122. }
  1123. }, /*#__PURE__*/React$1.createElement(Typography, {
  1124. style: {
  1125. paddingRight: '30px',
  1126. color: 'grey'
  1127. }
  1128. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1129. item: true,
  1130. xs: 12,
  1131. sm: 7
  1132. }, /*#__PURE__*/React$1.createElement(TextField, {
  1133. id: f.fieldName,
  1134. variant: "outlined",
  1135. autoComplete: "off",
  1136. size: "small",
  1137. style: {
  1138. width: '100%'
  1139. },
  1140. value: data != undefined ? data[f.fieldName] : null,
  1141. onChange: e => handleTextString(e, f.fieldName)
  1142. })));
  1143. } else if (f.type == 'text_number') {
  1144. return /*#__PURE__*/React$1.createElement(Grid, {
  1145. key: f.fieldName,
  1146. container: true,
  1147. style: {
  1148. display: 'flex',
  1149. alignItems: 'center',
  1150. marginBottom: '10px'
  1151. }
  1152. }, /*#__PURE__*/React$1.createElement(Grid, {
  1153. item: true,
  1154. xs: 12,
  1155. sm: 5
  1156. }, /*#__PURE__*/React$1.createElement(Box, {
  1157. style: {
  1158. width: '150px'
  1159. }
  1160. }, /*#__PURE__*/React$1.createElement(Typography, {
  1161. style: {
  1162. paddingRight: '30px',
  1163. color: 'grey'
  1164. }
  1165. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1166. item: true,
  1167. xs: 12,
  1168. sm: 7
  1169. }, /*#__PURE__*/React$1.createElement(TextField, {
  1170. id: f.fieldName,
  1171. variant: "outlined",
  1172. autoComplete: "off",
  1173. size: "small",
  1174. style: {
  1175. width: '100%'
  1176. },
  1177. type: "number",
  1178. value: data != undefined ? data[f.fieldName] : '',
  1179. onChange: e => handleTextNumber(e, f.fieldName)
  1180. })));
  1181. } else if (f.type == 'text_multiline') {
  1182. return /*#__PURE__*/React$1.createElement(Grid, {
  1183. key: f.fieldName,
  1184. container: true,
  1185. style: {
  1186. display: 'flex',
  1187. alignItems: 'center',
  1188. marginBottom: '10px'
  1189. }
  1190. }, /*#__PURE__*/React$1.createElement(Grid, {
  1191. item: true,
  1192. xs: 12,
  1193. sm: 5
  1194. }, /*#__PURE__*/React$1.createElement(Box, {
  1195. style: {
  1196. width: '150px'
  1197. }
  1198. }, /*#__PURE__*/React$1.createElement(Typography, {
  1199. style: {
  1200. paddingRight: '30px',
  1201. color: 'grey'
  1202. }
  1203. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1204. item: true,
  1205. xs: 12,
  1206. sm: 7
  1207. }, /*#__PURE__*/React$1.createElement(TextField, {
  1208. id: f.fieldName,
  1209. multiline: true,
  1210. autoComplete: "off",
  1211. rows: 3,
  1212. size: "small",
  1213. style: {
  1214. width: '100%'
  1215. },
  1216. value: data != undefined ? data[f.fieldName] : '',
  1217. variant: "outlined",
  1218. onChange: e => handleTextMultiline(e, f.fieldName)
  1219. })));
  1220. } else if (f.type == 'date') {
  1221. return /*#__PURE__*/React$1.createElement(Grid, {
  1222. key: f.fieldName,
  1223. container: true,
  1224. style: {
  1225. display: 'flex',
  1226. alignItems: 'center',
  1227. marginBottom: '10px'
  1228. }
  1229. }, /*#__PURE__*/React$1.createElement(Grid, {
  1230. item: true,
  1231. xs: 12,
  1232. sm: 5
  1233. }, /*#__PURE__*/React$1.createElement(Box, {
  1234. style: {
  1235. width: '150px'
  1236. }
  1237. }, /*#__PURE__*/React$1.createElement(Typography, {
  1238. style: {
  1239. paddingRight: '30px',
  1240. color: 'grey'
  1241. }
  1242. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1243. item: true,
  1244. xs: 12,
  1245. sm: 7
  1246. }, /*#__PURE__*/React$1.createElement(TextField, {
  1247. id: f.fieldName,
  1248. variant: "outlined",
  1249. autoComplete: "off",
  1250. size: "small",
  1251. value: data != undefined ? data[f.fieldName] : '',
  1252. type: "date",
  1253. style: {
  1254. width: '100%'
  1255. },
  1256. onChange: e => handleDate(e, f.fieldName)
  1257. })));
  1258. } else if (f.type == 'photo') {
  1259. return /*#__PURE__*/React$1.createElement(Grid, {
  1260. key: f.fieldName,
  1261. container: true,
  1262. style: {
  1263. display: 'flex',
  1264. alignItems: 'center',
  1265. marginBottom: '10px'
  1266. }
  1267. }, /*#__PURE__*/React$1.createElement(Grid, {
  1268. item: true,
  1269. xs: 12,
  1270. sm: 5
  1271. }, /*#__PURE__*/React$1.createElement(Box, {
  1272. style: {
  1273. width: '150px'
  1274. }
  1275. }, /*#__PURE__*/React$1.createElement(Typography, {
  1276. style: {
  1277. paddingRight: '30px',
  1278. color: 'grey'
  1279. }
  1280. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1281. item: true,
  1282. xs: 12,
  1283. sm: 7
  1284. }, /*#__PURE__*/React$1.createElement("img", {
  1285. src: imgPreview == null ? data['photo_url'] : imgPreview,
  1286. style: {
  1287. width: '120px',
  1288. height: '120px',
  1289. border: '1px solid grey'
  1290. }
  1291. }), /*#__PURE__*/React$1.createElement("input", {
  1292. type: "file",
  1293. id: "img-upload",
  1294. onChange: e => handleImgUpload(e, f.fieldName)
  1295. })));
  1296. } else if (f.type == 'dropdown') {
  1297. if (f.fieldName == 'priority') {
  1298. return /*#__PURE__*/React$1.createElement(Grid, {
  1299. key: f.fieldName,
  1300. container: true,
  1301. style: {
  1302. display: 'flex',
  1303. alignItems: 'center',
  1304. marginBottom: '10px'
  1305. }
  1306. }, /*#__PURE__*/React$1.createElement(Grid, {
  1307. item: true,
  1308. xs: 12,
  1309. sm: 5
  1310. }, /*#__PURE__*/React$1.createElement(Box, {
  1311. style: {
  1312. width: '150px'
  1313. }
  1314. }, /*#__PURE__*/React$1.createElement(Typography, {
  1315. style: {
  1316. paddingRight: '30px',
  1317. color: 'grey'
  1318. }
  1319. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1320. item: true,
  1321. xs: 12,
  1322. sm: 7
  1323. }, /*#__PURE__*/React$1.createElement(NativeSelect, {
  1324. id: "demo-customized-select-native",
  1325. value: data != undefined ? data[f.fieldName] : '',
  1326. onChange: e => handleDropDownChange(e, f.fieldName),
  1327. id: f.fieldName,
  1328. input: /*#__PURE__*/React$1.createElement(BootstrapInput, null),
  1329. style: {
  1330. width: '100%'
  1331. }
  1332. }, /*#__PURE__*/React$1.createElement("option", {
  1333. "aria-label": "None",
  1334. value: ""
  1335. }, "Select"), f.options.map((d, i) => {
  1336. return /*#__PURE__*/React$1.createElement("option", {
  1337. name: d.name,
  1338. value: d.id
  1339. }, d.name);
  1340. }))));
  1341. } else {
  1342. var fn = f.fieldName.split('_');
  1343. var fieldId = fn[0] + '_' + 'id';
  1344. return /*#__PURE__*/React$1.createElement(Grid, {
  1345. key: f.fieldName,
  1346. container: true,
  1347. style: {
  1348. display: 'flex',
  1349. alignItems: 'center',
  1350. marginBottom: '10px'
  1351. }
  1352. }, /*#__PURE__*/React$1.createElement(Grid, {
  1353. item: true,
  1354. xs: 12,
  1355. sm: 5
  1356. }, /*#__PURE__*/React$1.createElement(Box, {
  1357. style: {
  1358. width: '150px'
  1359. }
  1360. }, /*#__PURE__*/React$1.createElement(Typography, {
  1361. style: {
  1362. paddingRight: '30px',
  1363. color: 'grey'
  1364. }
  1365. }, f.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1366. item: true,
  1367. xs: 12,
  1368. sm: 7
  1369. }, /*#__PURE__*/React$1.createElement(NativeSelect, {
  1370. id: "demo-customized-select-native",
  1371. value: data != undefined ? data[fieldId] : '',
  1372. onChange: e => handleDropDownChange(e, f.fieldName),
  1373. id: f.fieldName,
  1374. input: /*#__PURE__*/React$1.createElement(BootstrapInput, null),
  1375. style: {
  1376. width: '100%'
  1377. }
  1378. }, /*#__PURE__*/React$1.createElement("option", {
  1379. "aria-label": "None",
  1380. value: ""
  1381. }, "Select"), f.options.map((d, i) => {
  1382. return /*#__PURE__*/React$1.createElement("option", {
  1383. name: d.name,
  1384. value: d.id
  1385. }, d.name);
  1386. }))));
  1387. }
  1388. } else if (f.type == 'checkbox') {
  1389. return /*#__PURE__*/React$1.createElement(Grid, null);
  1390. } else if (f.type == 'radio') {
  1391. return /*#__PURE__*/React$1.createElement(Grid, null);
  1392. }
  1393. })), /*#__PURE__*/React$1.createElement(Grid, {
  1394. item: true,
  1395. xs: 11
  1396. }, /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1397. style: {
  1398. float: 'right'
  1399. },
  1400. onClick: handleDataConfirm
  1401. }, " Confirm")))));
  1402. }
  1403. FieldList.propTypes = {
  1404. history: propTypes.object,
  1405. fields: propTypes.array.isRequired,
  1406. updateData: propTypes.object,
  1407. onDataCallback: propTypes.func
  1408. };
  1409. function descendingComparator(a, b, orderBy) {
  1410. if (b[orderBy] < a[orderBy]) {
  1411. return -1;
  1412. }
  1413. if (b[orderBy] > a[orderBy]) {
  1414. return 1;
  1415. }
  1416. return 0;
  1417. }
  1418. function getComparator(order, orderBy) {
  1419. return order === 'desc' ? (a, b) => descendingComparator(a, b, orderBy) : (a, b) => -descendingComparator(a, b, orderBy);
  1420. }
  1421. function stableSort(array, comparator) {
  1422. const stabilizedThis = array.map((el, index) => [el, index]);
  1423. stabilizedThis.sort((a, b) => {
  1424. const order = comparator(a[0], b[0]);
  1425. if (order !== 0) return order;
  1426. return a[1] - b[1];
  1427. });
  1428. return stabilizedThis.map(el => el[0]);
  1429. }
  1430. function EnhancedTableHead(props) {
  1431. const {
  1432. classes,
  1433. order,
  1434. orderBy,
  1435. onRequestSort,
  1436. onRefreshData,
  1437. headCells
  1438. } = props;
  1439. const createSortHandler = property => event => {
  1440. onRequestSort(event, property);
  1441. onRefreshData();
  1442. };
  1443. return /*#__PURE__*/React$1.createElement(TableHead, null, /*#__PURE__*/React$1.createElement(TableRow, null, headCells.map(headCell => /*#__PURE__*/React$1.createElement(TableCell, {
  1444. key: headCell.id,
  1445. align: headCell.numeric ? 'right' : 'left',
  1446. padding: headCell.disablePadding ? 'none' : 'default',
  1447. sortDirection: orderBy === headCell.id ? order : false
  1448. }, headCell.id != 'id' ? /*#__PURE__*/React$1.createElement(TableSortLabel, {
  1449. active: orderBy === headCell.id,
  1450. direction: orderBy === headCell.id ? order : 'asc',
  1451. onClick: createSortHandler(headCell.id)
  1452. }, headCell.label, orderBy === headCell.id ? /*#__PURE__*/React$1.createElement("span", {
  1453. className: classes.visuallyHidden
  1454. }, order === 'desc' ? 'sorted descending' : 'sorted ascending') : null) : /*#__PURE__*/React$1.createElement(TableSortLabel, {
  1455. hideSortIcon: true
  1456. }, headCell.label)))));
  1457. }
  1458. EnhancedTableHead.propTypes = {
  1459. classes: propTypes.object.isRequired,
  1460. numSelected: propTypes.number.isRequired,
  1461. onRequestSort: propTypes.func.isRequired,
  1462. onRefreshData: propTypes.func.isRequired,
  1463. onSelectAllClick: propTypes.func.isRequired,
  1464. order: propTypes.oneOf(['asc', 'desc']).isRequired,
  1465. orderBy: propTypes.string.isRequired,
  1466. rowCount: propTypes.number.isRequired
  1467. };
  1468. const useStyles$1 = makeStyles(theme => ({
  1469. root: {
  1470. width: '100%'
  1471. },
  1472. paper: {
  1473. width: '100%',
  1474. marginBottom: theme.spacing(2)
  1475. },
  1476. table: {
  1477. minWidth: 750
  1478. },
  1479. visuallyHidden: {
  1480. border: 0,
  1481. clip: 'rect(0 0 0 0)',
  1482. height: 1,
  1483. margin: -1,
  1484. overflow: 'hidden',
  1485. padding: 0,
  1486. position: 'absolute',
  1487. top: 20,
  1488. width: 1
  1489. },
  1490. underline: {
  1491. "&&&:before": {
  1492. borderBottom: "none"
  1493. },
  1494. "&&:after": {
  1495. borderBottom: "none"
  1496. }
  1497. }
  1498. }));
  1499. function TableTemplate(props) {
  1500. const classes = useStyles$1();
  1501. const {
  1502. data = [],
  1503. headers = [],
  1504. onUpdateData,
  1505. onReloadData,
  1506. onChangePage,
  1507. onChangeRowsPerPage,
  1508. rowsPerPage = 10,
  1509. page = 0,
  1510. order = 'asc',
  1511. orderBy
  1512. } = props;
  1513. const [selected, setSelected] = React$1.useState([]);
  1514. const [dense, setDense] = React$1.useState(false);
  1515. const [rowDataPerPage, setRowsPerPage] = React$1.useState(rowsPerPage != undefined ? rowsPerPage : 10);
  1516. const [paginatePage, setPage] = React$1.useState(page != undefined ? page : 0);
  1517. const [paginateOrder, setOrder] = React$1.useState(order != undefined ? order : 'asc');
  1518. const [paginateOrderBy, setOrderBy] = React$1.useState(orderBy != undefined ? orderBy : 'name');
  1519. var offset = paginatePage * rowDataPerPage;
  1520. const handleRequestSort = (event, property) => {
  1521. const isAsc = orderBy === property && order === 'asc';
  1522. setOrder(isAsc ? 'desc' : 'asc');
  1523. setOrderBy(property);
  1524. };
  1525. const handleSelectAllClick = event => {
  1526. if (event.target.checked) {
  1527. const newSelecteds = data.map(n => n.name);
  1528. setSelected(newSelecteds);
  1529. return;
  1530. }
  1531. setSelected([]);
  1532. };
  1533. const handleClick = (event, rowdata) => {
  1534. onUpdateData(true, rowdata);
  1535. };
  1536. const handleChangePage = (event, newPage) => {
  1537. onChangePage(newPage);
  1538. };
  1539. const handleReloadData = () => {
  1540. onReloadData();
  1541. };
  1542. const handleChangeRowsPerPage = event => {
  1543. setRowsPerPage(parseInt(event.target.value, 10));
  1544. onChangeRowsPerPage(parseInt(event.target.value));
  1545. onReloadData();
  1546. };
  1547. const isSelected = name => selected.indexOf(name) !== -1;
  1548. const emptyRows = rowsPerPage - Math.min(rowsPerPage, data.length - page * rowsPerPage);
  1549. return /*#__PURE__*/React$1.createElement("div", {
  1550. className: classes.root
  1551. }, /*#__PURE__*/React$1.createElement(Grid, {
  1552. container: true
  1553. }, /*#__PURE__*/React$1.createElement(Grid, {
  1554. item: true,
  1555. style: {
  1556. marginRight: '10%'
  1557. }
  1558. }, /*#__PURE__*/React$1.createElement(TableContainer, null, /*#__PURE__*/React$1.createElement(Table, {
  1559. className: classes.table,
  1560. "aria-labelledby": "tableTitle",
  1561. size: dense ? 'small' : 'medium',
  1562. "aria-label": "enhanced table"
  1563. }, /*#__PURE__*/React$1.createElement(EnhancedTableHead, {
  1564. classes: classes,
  1565. numSelected: selected.length,
  1566. headCells: headers,
  1567. order: order,
  1568. orderBy: orderBy,
  1569. onSelectAllClick: handleSelectAllClick,
  1570. onRequestSort: handleRequestSort,
  1571. onRefreshData: handleReloadData,
  1572. rowCount: data.length
  1573. }), /*#__PURE__*/React$1.createElement(TableBody, null, data.length != 0 ? stableSort(data, getComparator(order, orderBy)).slice(page * rowsPerPage, page * rowsPerPage + rowsPerPage).map((row, index) => {
  1574. const isItemSelected = isSelected(row.name);
  1575. return /*#__PURE__*/React$1.createElement(TableRow, {
  1576. hover: true,
  1577. onClick: event => handleClick(event, row),
  1578. role: "checkbox",
  1579. "aria-checked": isItemSelected,
  1580. tabIndex: -1,
  1581. key: index,
  1582. selected: isItemSelected
  1583. }, headers.map((h, i) => {
  1584. if (h.id == 'id') {
  1585. return /*#__PURE__*/React$1.createElement(TableCell, {
  1586. key: h.id,
  1587. align: "right"
  1588. }, ++offset);
  1589. } else {
  1590. return /*#__PURE__*/React$1.createElement(TableCell, {
  1591. key: h.id,
  1592. align: "right"
  1593. }, row[h.id]);
  1594. }
  1595. }));
  1596. }) : /*#__PURE__*/React$1.createElement("div", null), emptyRows > 0 && /*#__PURE__*/React$1.createElement(TableRow, {
  1597. style: {
  1598. height: (dense ? 33 : 53) * emptyRows
  1599. }
  1600. }, /*#__PURE__*/React$1.createElement(TableCell, {
  1601. colSpan: 6
  1602. }))))), /*#__PURE__*/React$1.createElement(TablePagination, {
  1603. rowsPerPageOptions: [5, 10, 20, 30],
  1604. labelDisplayedRows: function ({
  1605. from,
  1606. to,
  1607. count
  1608. }) {},
  1609. component: "div",
  1610. count: data.length,
  1611. rowsPerPage: rowsPerPage,
  1612. rowsPerPage: rowsPerPage,
  1613. page: page,
  1614. onChangePage: handleChangePage,
  1615. onChangeRowsPerPage: handleChangeRowsPerPage
  1616. }))));
  1617. }
  1618. TableTemplate.propTypes = {
  1619. history: propTypes.object,
  1620. headers: propTypes.array.isRequired,
  1621. data: propTypes.array.isRequired,
  1622. onUpdateData: propTypes.func,
  1623. onReloadData: propTypes.func,
  1624. onChangePage: propTypes.func,
  1625. onChangeRowsPerPage: propTypes.func,
  1626. query: propTypes.object,
  1627. page: propTypes.any,
  1628. rowsPerPage: propTypes.any,
  1629. order: propTypes.any,
  1630. orderBy: propTypes.any
  1631. };
  1632. const useStyles$2 = makeStyles(theme => ({
  1633. root: {
  1634. width: '100%'
  1635. },
  1636. paper: {
  1637. width: '100%',
  1638. marginBottom: theme.spacing(2)
  1639. },
  1640. table: {
  1641. minWidth: 750
  1642. },
  1643. visuallyHidden: {
  1644. border: 0,
  1645. clip: 'rect(0 0 0 0)',
  1646. height: 1,
  1647. margin: -1,
  1648. overflow: 'hidden',
  1649. padding: 0,
  1650. position: 'absolute',
  1651. top: 20,
  1652. width: 1
  1653. },
  1654. underline: {
  1655. "&&&:before": {
  1656. borderBottom: "none"
  1657. },
  1658. "&&:after": {
  1659. borderBottom: "none"
  1660. }
  1661. },
  1662. button: {
  1663. color: 'white',
  1664. color: theme.palette.primary.main,
  1665. width: 150,
  1666. height: 55
  1667. },
  1668. closeButton: {
  1669. position: 'absolute',
  1670. right: theme.spacing(1),
  1671. top: theme.spacing(1),
  1672. color: theme.palette.grey[500]
  1673. },
  1674. headText: {
  1675. fontSize: 14,
  1676. float: "left",
  1677. color: theme.palette.primary.main,
  1678. fontWeight: "bold"
  1679. },
  1680. paper: {
  1681. padding: theme.spacing(2),
  1682. textAlign: 'center',
  1683. color: theme.palette.text.secondary
  1684. }
  1685. }));
  1686. function getDataString(data, fieldName) {
  1687. return data[fieldName];
  1688. }
  1689. function InfoPage(props) {
  1690. const classes = useStyles$2();
  1691. const {
  1692. infoData,
  1693. displayFields,
  1694. isNew = false,
  1695. isEditable,
  1696. currentTabName,
  1697. actions
  1698. } = props;
  1699. const [editable, setEditable] = React$1.useState(isEditable != undefined ? isEditable : true);
  1700. const [data, setData] = React$1.useState({});
  1701. const handleEdit = () => {
  1702. setEditable(false);
  1703. };
  1704. const handleUpdateData = data => {
  1705. console.log('handle update date:', data);
  1706. setData(data);
  1707. };
  1708. return /*#__PURE__*/React$1.createElement("div", {
  1709. className: classes.root
  1710. }, isNew ? /*#__PURE__*/React$1.createElement(Grid, {
  1711. container: true,
  1712. style: {
  1713. marginTop: '30px'
  1714. }
  1715. }, /*#__PURE__*/React$1.createElement(Grid, {
  1716. item: true,
  1717. xs: 12,
  1718. sm: 7
  1719. }, /*#__PURE__*/React$1.createElement(FieldList, {
  1720. updateData: infoData,
  1721. fields: displayFields,
  1722. isNew: isNew,
  1723. onDataCallback: d => handleUpdateData(d)
  1724. }))) : /*#__PURE__*/React$1.createElement(Grid, {
  1725. container: true,
  1726. style: {
  1727. marginTop: '30px'
  1728. }
  1729. }, /*#__PURE__*/React$1.createElement(Grid, {
  1730. item: true,
  1731. xs: 12,
  1732. sm: 7
  1733. }, !editable ? /*#__PURE__*/React$1.createElement(FieldList, {
  1734. fields: displayFields,
  1735. isNew: isNew,
  1736. updateData: infoData,
  1737. onDataCallback: d => handleUpdateData(d)
  1738. }) : displayFields.map((d, i) => {
  1739. return /*#__PURE__*/React$1.createElement(Grid, {
  1740. container: true
  1741. }, /*#__PURE__*/React$1.createElement(Grid, {
  1742. item: true,
  1743. xs: 12,
  1744. style: {
  1745. display: 'flex',
  1746. alignItems: 'center',
  1747. marginBottom: '10px'
  1748. }
  1749. }, /*#__PURE__*/React$1.createElement(Grid, {
  1750. item: true,
  1751. xs: 12,
  1752. sm: 5
  1753. }, /*#__PURE__*/React$1.createElement(Box, {
  1754. style: {
  1755. width: '250px'
  1756. }
  1757. }, /*#__PURE__*/React$1.createElement(Typography, {
  1758. style: {
  1759. paddingRight: '30px',
  1760. color: 'grey'
  1761. }
  1762. }, d.label))), /*#__PURE__*/React$1.createElement(Grid, {
  1763. item: true,
  1764. xs: 12,
  1765. sm: 7
  1766. }, d.type == 'photo' ? /*#__PURE__*/React$1.createElement("img", {
  1767. src: infoData['photo_url'],
  1768. style: {
  1769. width: '120px',
  1770. height: '120px',
  1771. border: '1px solid grey'
  1772. }
  1773. }) : /*#__PURE__*/React$1.createElement(Typography, {
  1774. style: {
  1775. paddingRight: '30px'
  1776. }
  1777. }, infoData != undefined ? getDataString(infoData, d.fieldName) : ''))));
  1778. })), /*#__PURE__*/React$1.createElement(Grid, {
  1779. item: true,
  1780. xs: 12,
  1781. sm: 7
  1782. }, /*#__PURE__*/React$1.createElement(Grid, {
  1783. container: true,
  1784. direction: "row",
  1785. alignItems: "flex-end"
  1786. }, actions.map((a, i) => {
  1787. if (currentTabName == 'account') {
  1788. if (infoData.status == 'invited') {
  1789. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1790. style: {
  1791. color: 'white',
  1792. backgroundColor: 'grey',
  1793. float: 'right',
  1794. marginLeft: '10px'
  1795. },
  1796. onClick: () => a.callback(data)
  1797. }, a.label));
  1798. }
  1799. if (infoData.status == 'joined') {
  1800. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1801. style: {
  1802. color: 'white',
  1803. backgroundColor: 'grey',
  1804. float: 'right',
  1805. marginLeft: '10px'
  1806. },
  1807. onClick: () => a.callback(data)
  1808. }, a.label));
  1809. }
  1810. if (infoData.status == 'disabled') {
  1811. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1812. style: {
  1813. color: 'white',
  1814. backgroundColor: 'grey',
  1815. float: 'right',
  1816. marginLeft: '10px'
  1817. },
  1818. onClick: () => a.callback(data)
  1819. }, a.label));
  1820. }
  1821. if (infoData.status == 'requested') {
  1822. if (editable) {
  1823. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1824. style: {
  1825. marginLeft: '10px'
  1826. },
  1827. onClick: handleEdit
  1828. }, a.icon, a.label));
  1829. } else {
  1830. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1831. style: {
  1832. color: 'white',
  1833. backgroundColor: 'grey',
  1834. float: 'right',
  1835. marginLeft: '10px'
  1836. },
  1837. onClick: () => a.callback(data)
  1838. }, a.label));
  1839. }
  1840. }
  1841. } else {
  1842. if (editable) {
  1843. if (a.action_type == 'edit') {
  1844. console.log('type: ', a.action_type, 'editable: ', editable);
  1845. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1846. style: {
  1847. marginLeft: '10px'
  1848. },
  1849. onClick: handleEdit
  1850. }, a.icon, a.label));
  1851. }
  1852. if (a.action_type == 'delete') {
  1853. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1854. style: {
  1855. float: 'right',
  1856. marginLeft: '10px'
  1857. },
  1858. onClick: () => a.callback(data)
  1859. }, a.icon, a.label));
  1860. }
  1861. } else {
  1862. if (a.action_type == 'save') {
  1863. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1864. style: {
  1865. marginLeft: '10px'
  1866. },
  1867. onClick: () => a.callback(data)
  1868. }, a.icon, a.label));
  1869. }
  1870. if (a.action_type == 'cancel') {
  1871. return /*#__PURE__*/React$1.createElement(Box, null, /*#__PURE__*/React$1.createElement(Button, {
  1872. style: {
  1873. float: 'right',
  1874. marginLeft: '10px'
  1875. },
  1876. onClick: () => a.callback(data)
  1877. }, a.icon, a.label));
  1878. }
  1879. }
  1880. }
  1881. })))));
  1882. }
  1883. InfoPage.propTypes = {
  1884. history: propTypes.object,
  1885. infoData: propTypes.object,
  1886. displayFields: propTypes.array,
  1887. isNew: propTypes.bool,
  1888. isEditable: propTypes.bool,
  1889. actions: propTypes.any
  1890. };
  1891. function CheckboxList() {
  1892. return /*#__PURE__*/React.createElement("div", null, "checkbox list");
  1893. }
  1894. function RadioList() {
  1895. return /*#__PURE__*/React.createElement("div", null, "radio list");
  1896. }
  1897. export { CheckboxList, FieldList, InfoPage, List, RadioList, TableTemplate };
  1898. //# sourceMappingURL=index.modern.js.map