index.modern.js 86 KB

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