index.modern.js 84 KB

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