index.modern.js 85 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630
  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(function (theme) {
  1037. return {
  1038. root: {
  1039. width: '100%'
  1040. },
  1041. paper: {
  1042. width: '100%',
  1043. marginBottom: theme.spacing(2)
  1044. },
  1045. table: {
  1046. minWidth: 750
  1047. },
  1048. visuallyHidden: {
  1049. border: 0,
  1050. clip: 'rect(0 0 0 0)',
  1051. height: 1,
  1052. margin: -1,
  1053. overflow: 'hidden',
  1054. padding: 0,
  1055. position: 'absolute',
  1056. top: 20,
  1057. width: 1
  1058. },
  1059. underline: {
  1060. "&&&:before": {
  1061. borderBottom: "none"
  1062. },
  1063. "&&:after": {
  1064. borderBottom: "none"
  1065. }
  1066. }
  1067. };
  1068. });
  1069. function MButton(props) {
  1070. var classes = useStyles();
  1071. var action = props.action,
  1072. onCallback = props.onCallback;
  1073. var handleAction = function handleAction(e) {
  1074. e.preventDefault();
  1075. onCallback(e);
  1076. };
  1077. return /*#__PURE__*/React.createElement("div", {
  1078. className: classes.root
  1079. }, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  1080. variant: "contained",
  1081. style: {
  1082. "float": 'right',
  1083. margin: "5px"
  1084. },
  1085. onClick: function onClick(e) {
  1086. return handleAction(e);
  1087. }
  1088. }, action.icon, action.label)));
  1089. }
  1090. MButton.propTypes = {
  1091. history: propTypes.object,
  1092. action: propTypes.object.isRequired,
  1093. onCallback: propTypes.func.isRequired
  1094. };
  1095. function MkForm(props) {
  1096. var classes = useStyles();
  1097. var _props$fields = props.fields,
  1098. fields = _props$fields === void 0 ? [] : _props$fields,
  1099. _props$data = props.data,
  1100. data = _props$data === void 0 ? {} : _props$data,
  1101. onDropdownCreateNew = props.onDropdownCreateNew,
  1102. _props$actions = props.actions,
  1103. actions = _props$actions === void 0 ? [] : _props$actions,
  1104. partHeaders = props.partHeaders;
  1105. var _React$useState = React.useState(data !== undefined ? data : {}),
  1106. _data = _React$useState[0],
  1107. setDataField = _React$useState[1];
  1108. var _React$useState2 = React.useState(false),
  1109. open = _React$useState2[0],
  1110. setOpen = _React$useState2[1];
  1111. var _React$useState3 = React.useState("#"),
  1112. selectedPhoto = _React$useState3[0],
  1113. setSelectedPhoto = _React$useState3[1];
  1114. var handleTextString = function handleTextString(e, fieldName) {
  1115. var _extends2;
  1116. setDataField(_extends({}, _data, (_extends2 = {}, _extends2[fieldName] = e.target.value, _extends2)));
  1117. };
  1118. var handleTextNumber = function handleTextNumber(e, fieldName) {
  1119. var _extends3;
  1120. setDataField(_extends({}, _data, (_extends3 = {}, _extends3[fieldName] = e.target.value, _extends3)));
  1121. };
  1122. var handleTextMultiline = function handleTextMultiline(e, fieldName) {
  1123. var _extends4;
  1124. setDataField(_extends({}, _data, (_extends4 = {}, _extends4[fieldName] = e.target.value, _extends4)));
  1125. };
  1126. var handleDate = function handleDate(e, fieldName) {
  1127. var _extends5;
  1128. setDataField(_extends({}, _data, (_extends5 = {}, _extends5[fieldName] = e.target.value, _extends5)));
  1129. };
  1130. var handleDropDownChange = function handleDropDownChange(e, fieldName) {
  1131. var _extends6;
  1132. var selectedIndex = e.target.options.selectedIndex;
  1133. var selectedValue = e.target.options[selectedIndex].getAttribute('name');
  1134. var fn = fieldName.split('_');
  1135. var fieldId = fn[0] + '_' + 'id';
  1136. setDataField(_extends({}, _data, (_extends6 = {}, _extends6[fieldName] = selectedValue, _extends6[fieldId] = e.target.value, _extends6)));
  1137. };
  1138. var handleCanCreateNew = function handleCanCreateNew(data) {
  1139. onDropdownCreateNew(data);
  1140. };
  1141. var onChangeValue = function onChangeValue(fieldName, value) {
  1142. var _extends7;
  1143. setDataField(_extends({}, _data, (_extends7 = {}, _extends7[fieldName] = value, _extends7)));
  1144. };
  1145. var onFileChange = function onFileChange(e, f) {};
  1146. var handleSelectItemDialog = function handleSelectItemDialog() {};
  1147. return /*#__PURE__*/React.createElement("div", {
  1148. className: classes.root
  1149. }, /*#__PURE__*/React.createElement(Grid, {
  1150. container: true
  1151. }, /*#__PURE__*/React.createElement(Grid, {
  1152. item: true,
  1153. xs: 12
  1154. }, fields.map(function (f, i) {
  1155. if (f.type === 'text_string') {
  1156. return /*#__PURE__*/React.createElement(Grid, {
  1157. key: f.field_name,
  1158. container: true,
  1159. style: {
  1160. display: 'flex',
  1161. alignItems: 'center',
  1162. marginBottom: '10px'
  1163. }
  1164. }, /*#__PURE__*/React.createElement(Grid, {
  1165. item: true,
  1166. xs: 12,
  1167. sm: 5
  1168. }, /*#__PURE__*/React.createElement(Box, {
  1169. style: {
  1170. width: '150px'
  1171. }
  1172. }, /*#__PURE__*/React.createElement(Typography, {
  1173. style: {
  1174. paddingRight: '30px',
  1175. color: 'grey'
  1176. }
  1177. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1178. item: true,
  1179. xs: 12,
  1180. sm: 7
  1181. }, /*#__PURE__*/React.createElement(TextField, {
  1182. id: f.field_name,
  1183. variant: "outlined",
  1184. autoComplete: "off",
  1185. size: "small",
  1186. style: {
  1187. width: '100%'
  1188. },
  1189. InputProps: {
  1190. readOnly: f.readOnly ? f.readOnly : false
  1191. },
  1192. value: _data !== undefined ? _data[f.field_name] : '',
  1193. onChange: function onChange(e) {
  1194. return handleTextString(e, f.field_name);
  1195. }
  1196. })));
  1197. } else if (f.type === 'text_number') {
  1198. return /*#__PURE__*/React.createElement(Grid, {
  1199. key: f.field_name,
  1200. container: true,
  1201. style: {
  1202. display: 'flex',
  1203. alignItems: 'center',
  1204. marginBottom: '10px'
  1205. }
  1206. }, /*#__PURE__*/React.createElement(Grid, {
  1207. item: true,
  1208. xs: 12,
  1209. sm: 5
  1210. }, /*#__PURE__*/React.createElement(Box, {
  1211. style: {
  1212. width: '150px'
  1213. }
  1214. }, /*#__PURE__*/React.createElement(Typography, {
  1215. style: {
  1216. paddingRight: '30px',
  1217. color: 'grey'
  1218. }
  1219. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1220. item: true,
  1221. xs: 12,
  1222. sm: 7
  1223. }, /*#__PURE__*/React.createElement(TextField, {
  1224. id: f.field_name,
  1225. variant: "outlined",
  1226. autoComplete: "off",
  1227. size: "small",
  1228. style: {
  1229. width: '100%'
  1230. },
  1231. type: "number",
  1232. value: _data !== undefined ? _data[f.field_name] : '',
  1233. onChange: function onChange(e) {
  1234. return handleTextNumber(e, f.field_name);
  1235. }
  1236. })));
  1237. } else if (f.type === 'text_multiline') {
  1238. return /*#__PURE__*/React.createElement(Grid, {
  1239. key: f.field_name,
  1240. container: true,
  1241. style: {
  1242. display: 'flex',
  1243. alignItems: 'center',
  1244. marginBottom: '10px'
  1245. }
  1246. }, /*#__PURE__*/React.createElement(Grid, {
  1247. item: true,
  1248. xs: 12,
  1249. sm: 5
  1250. }, /*#__PURE__*/React.createElement(Box, {
  1251. style: {
  1252. width: '150px'
  1253. }
  1254. }, /*#__PURE__*/React.createElement(Typography, {
  1255. style: {
  1256. paddingRight: '30px',
  1257. color: 'grey'
  1258. }
  1259. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1260. item: true,
  1261. xs: 12,
  1262. sm: 7
  1263. }, /*#__PURE__*/React.createElement(TextField, {
  1264. id: f.field_name,
  1265. multiline: true,
  1266. autoComplete: "off",
  1267. rows: 3,
  1268. size: "small",
  1269. style: {
  1270. width: '100%'
  1271. },
  1272. value: _data !== undefined ? _data[f.field_name] : '',
  1273. variant: "outlined",
  1274. onChange: function onChange(e) {
  1275. return handleTextMultiline(e, f.field_name);
  1276. }
  1277. })));
  1278. } else if (f.type === 'date') {
  1279. return /*#__PURE__*/React.createElement(Grid, {
  1280. key: f.field_name,
  1281. container: true,
  1282. style: {
  1283. display: 'flex',
  1284. alignItems: 'center',
  1285. marginBottom: '10px'
  1286. }
  1287. }, /*#__PURE__*/React.createElement(Grid, {
  1288. item: true,
  1289. xs: 12,
  1290. sm: 5
  1291. }, /*#__PURE__*/React.createElement(Box, {
  1292. style: {
  1293. width: '150px'
  1294. }
  1295. }, /*#__PURE__*/React.createElement(Typography, {
  1296. style: {
  1297. paddingRight: '30px',
  1298. color: 'grey'
  1299. }
  1300. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1301. item: true,
  1302. xs: 12,
  1303. sm: 7
  1304. }, /*#__PURE__*/React.createElement(TextField, {
  1305. id: f.field_name,
  1306. variant: "outlined",
  1307. autoComplete: "off",
  1308. size: "small",
  1309. value: _data !== undefined ? _data[f.field_name] : '',
  1310. type: "date",
  1311. style: {
  1312. width: '100%'
  1313. },
  1314. onChange: function onChange(e) {
  1315. return handleDate(e, f.field_name);
  1316. }
  1317. })));
  1318. } else if (f.type === 'dropdown') {
  1319. if (f.options !== undefined && f.option_label_field !== undefined) {
  1320. if (f.field_name === 'priority') {
  1321. return /*#__PURE__*/React.createElement(Grid, {
  1322. key: f.field_name,
  1323. container: true,
  1324. style: {
  1325. display: 'flex',
  1326. alignItems: 'center',
  1327. marginBottom: '10px'
  1328. }
  1329. }, /*#__PURE__*/React.createElement(Grid, {
  1330. item: true,
  1331. xs: 12,
  1332. sm: 5
  1333. }, /*#__PURE__*/React.createElement(Box, {
  1334. style: {
  1335. width: '150px'
  1336. }
  1337. }, /*#__PURE__*/React.createElement(Typography, {
  1338. style: {
  1339. paddingRight: '30px',
  1340. color: 'grey'
  1341. }
  1342. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1343. item: true,
  1344. xs: 12,
  1345. sm: 7
  1346. }, /*#__PURE__*/React.createElement(NativeSelect, {
  1347. value: _data !== undefined ? _data[f.field_name] : '',
  1348. onChange: function onChange(e) {
  1349. return handleDropDownChange(e, f.field_name);
  1350. },
  1351. id: f.field_name,
  1352. input: /*#__PURE__*/React.createElement(BootstrapInput, null),
  1353. style: {
  1354. width: '100%'
  1355. }
  1356. }, /*#__PURE__*/React.createElement("option", {
  1357. "aria-label": "None",
  1358. value: ""
  1359. }, "Select"), f.options.map(function (d, i) {
  1360. return /*#__PURE__*/React.createElement("option", {
  1361. name: d.name,
  1362. value: d.id,
  1363. key: d.id
  1364. }, d.name);
  1365. }))));
  1366. } else {
  1367. return /*#__PURE__*/React.createElement(Grid, {
  1368. key: f.field_name,
  1369. container: true,
  1370. style: {
  1371. display: 'flex',
  1372. alignItems: 'center',
  1373. marginBottom: '10px'
  1374. }
  1375. }, /*#__PURE__*/React.createElement(Grid, {
  1376. item: true,
  1377. xs: 12,
  1378. sm: 5
  1379. }, /*#__PURE__*/React.createElement(Box, {
  1380. style: {
  1381. width: '150px'
  1382. }
  1383. }, /*#__PURE__*/React.createElement(Typography, {
  1384. style: {
  1385. paddingRight: '30px',
  1386. color: 'grey'
  1387. }
  1388. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1389. item: true,
  1390. xs: 12,
  1391. sm: 7
  1392. }, /*#__PURE__*/React.createElement(Autocomplete, {
  1393. id: "combo-box-demo",
  1394. options: f.options,
  1395. getOptionLabel: function getOptionLabel(option) {
  1396. if (typeof option === 'string') {
  1397. return option;
  1398. }
  1399. return option[f.option_label_field];
  1400. },
  1401. style: {
  1402. width: '100%'
  1403. },
  1404. size: "small",
  1405. value: _data !== undefined ? _data[f.field_name] ? _data[f.field_name] : " " : " ",
  1406. filterOptions: function filterOptions(options, params) {
  1407. console.log("Autocomplete", f.can_create);
  1408. if (f.can_create) {
  1409. var newFilter = ['+ Add New'];
  1410. var filtered = filter(options, params);
  1411. return [].concat(newFilter, filtered);
  1412. } else {
  1413. var _filtered = filter(options, params);
  1414. return _filtered;
  1415. }
  1416. },
  1417. onChange: function onChange(event, newValue) {
  1418. if (typeof newValue === 'string') {
  1419. console.log('f.field_name', f.field_name, " f.can_create", f.can_create);
  1420. var d = {
  1421. "canCreate": f.can_create,
  1422. "fields": f.fields,
  1423. "name": f.name,
  1424. "fieldName": f.field_name
  1425. };
  1426. handleCanCreateNew(d);
  1427. } else {
  1428. if (newValue != null && newValue.inputValue !== '' && newValue.product_desc !== "") {
  1429. onChangeValue(f.field_name, newValue[f.option_label_field]);
  1430. }
  1431. }
  1432. },
  1433. renderInput: function renderInput(params) {
  1434. return /*#__PURE__*/React.createElement(TextField, _extends({}, params, {
  1435. variant: "outlined"
  1436. }));
  1437. }
  1438. })));
  1439. }
  1440. }
  1441. } else if (f.type === 'photo_list') {
  1442. console.log('photo_list:', _data);
  1443. return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Grid, {
  1444. key: f.field_name,
  1445. container: true,
  1446. style: {
  1447. display: 'flex',
  1448. alignItems: 'center',
  1449. marginBottom: '10px'
  1450. }
  1451. }, /*#__PURE__*/React.createElement(Grid, {
  1452. item: true,
  1453. xs: 12,
  1454. sm: 5
  1455. }, /*#__PURE__*/React.createElement(Box, {
  1456. style: {
  1457. width: '150px'
  1458. }
  1459. }, /*#__PURE__*/React.createElement(Typography, {
  1460. style: {
  1461. paddingRight: '30px',
  1462. color: 'grey'
  1463. }
  1464. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1465. item: true,
  1466. xs: 12,
  1467. sm: 7
  1468. }, /*#__PURE__*/React.createElement("div", {
  1469. style: {
  1470. display: 'flex',
  1471. alignItems: 'center',
  1472. marginBottom: '10px'
  1473. }
  1474. }, /*#__PURE__*/React.createElement("form", null, /*#__PURE__*/React.createElement("div", {
  1475. className: "form-group"
  1476. }, /*#__PURE__*/React.createElement("input", {
  1477. type: "file",
  1478. name: "imgCollection",
  1479. onChange: function onChange(e) {
  1480. return onFileChange();
  1481. },
  1482. multiple: true
  1483. })))))), _data[f.field_name] !== undefined && _data[f.field_name].length !== 0 ? /*#__PURE__*/React.createElement(Grid, {
  1484. key: f.field_name,
  1485. container: true,
  1486. style: {
  1487. display: 'flex',
  1488. alignItems: 'center',
  1489. marginBottom: '10px'
  1490. }
  1491. }, /*#__PURE__*/React.createElement(Grid, {
  1492. item: true,
  1493. xs: 12
  1494. }, /*#__PURE__*/React.createElement("div", {
  1495. style: {
  1496. display: 'block',
  1497. alignItems: 'center',
  1498. marginBottom: '10px'
  1499. }
  1500. }, /*#__PURE__*/React.createElement(GridList, {
  1501. className: classes.gridList
  1502. }, _data[f.field_name] === undefined ? /*#__PURE__*/React.createElement("span", null) : _data[f.field_name].map(function (tile) {
  1503. return /*#__PURE__*/React.createElement(GridListTile, {
  1504. key: tile,
  1505. style: {
  1506. width: '100px',
  1507. height: '100px'
  1508. }
  1509. }, /*#__PURE__*/React.createElement("img", {
  1510. src: tile,
  1511. alt: tile,
  1512. onClick: function onClick(e) {
  1513. setOpen(true);
  1514. }
  1515. }));
  1516. })))), /*#__PURE__*/React.createElement(Dialog, {
  1517. maxWidth: "lg",
  1518. "aria-labelledby": "customized-dialog-title",
  1519. open: open
  1520. }, /*#__PURE__*/React.createElement(DialogTitle, {
  1521. id: "customized-dialog-title",
  1522. onClose: function onClose(e) {
  1523. return setOpen(false);
  1524. }
  1525. }, "Photos"), /*#__PURE__*/React.createElement(DialogContent, {
  1526. dividers: true
  1527. }, /*#__PURE__*/React.createElement(Grid, {
  1528. item: true,
  1529. xs: 12
  1530. }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement("img", {
  1531. src: selectedPhoto,
  1532. className: "show-img",
  1533. alt: "logo"
  1534. })), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement(Grid, {
  1535. container: true,
  1536. spacing: 3
  1537. }, _data[f.field_name].length > 0 ? _data[f.field_name].map(function (value) {
  1538. return /*#__PURE__*/React.createElement(Grid, {
  1539. key: value,
  1540. item: true
  1541. }, /*#__PURE__*/React.createElement(Box, {
  1542. className: "square"
  1543. }, " ", /*#__PURE__*/React.createElement("img", {
  1544. src: value,
  1545. className: "thumnail-img",
  1546. alt: "logo",
  1547. onClick: function onClick(e) {
  1548. return setSelectedPhoto(value);
  1549. }
  1550. })));
  1551. }) : /*#__PURE__*/React.createElement("span", null)))))) : /*#__PURE__*/React.createElement(Grid, null));
  1552. } else if (f.type === 'list') {
  1553. console.log('list', _data[f.field_name]);
  1554. return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Grid, {
  1555. key: f.field_name,
  1556. container: true,
  1557. style: {
  1558. display: 'flex',
  1559. alignItems: 'center',
  1560. marginBottom: '10px'
  1561. }
  1562. }, /*#__PURE__*/React.createElement(Grid, {
  1563. item: true,
  1564. xs: 12,
  1565. sm: 5
  1566. }, /*#__PURE__*/React.createElement(Box, {
  1567. style: {
  1568. width: '150px'
  1569. }
  1570. }, /*#__PURE__*/React.createElement(Typography, {
  1571. style: {
  1572. paddingRight: '30px',
  1573. color: 'grey'
  1574. }
  1575. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1576. item: true,
  1577. xs: 12,
  1578. sm: 7
  1579. }, /*#__PURE__*/React.createElement("div", {
  1580. style: {
  1581. display: 'block',
  1582. alignItems: 'center',
  1583. marginBottom: '10px'
  1584. }
  1585. }, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  1586. onClick: handleSelectItemDialog
  1587. }, /*#__PURE__*/React.createElement(AddIcon, null)))))), /*#__PURE__*/React.createElement(Grid, {
  1588. key: f.field_name,
  1589. container: true,
  1590. style: {
  1591. display: 'block',
  1592. alignItems: 'center',
  1593. marginBottom: '10px'
  1594. }
  1595. }, /*#__PURE__*/React.createElement("div", {
  1596. style: {
  1597. display: 'block',
  1598. alignItems: 'center',
  1599. marginBottom: '10px'
  1600. }
  1601. }, /*#__PURE__*/React.createElement(TableContainer, null, /*#__PURE__*/React.createElement(Table, {
  1602. className: classes.table,
  1603. size: "small",
  1604. "aria-label": "a dense table"
  1605. }, /*#__PURE__*/React.createElement(TableHead, null, /*#__PURE__*/React.createElement(TableRow, null, partHeaders.map(function (h, i) {
  1606. return /*#__PURE__*/React.createElement(TableCell, {
  1607. key: h.id,
  1608. align: "left"
  1609. }, h.label);
  1610. }))), /*#__PURE__*/React.createElement(TableBody, null, _data[f.field_name].length > 0 ? _data[f.field_name].map(function (row) {
  1611. return /*#__PURE__*/React.createElement(TableRow, {
  1612. key: row.name
  1613. }, partHeaders.map(function (h, i) {
  1614. return /*#__PURE__*/React.createElement(TableCell, {
  1615. key: h.id,
  1616. align: h.numeric ? 'right' : 'left'
  1617. }, row[h.id]);
  1618. }));
  1619. }) : /*#__PURE__*/React.createElement("span", null)))))));
  1620. } else if (f.type === 'time') {
  1621. return /*#__PURE__*/React.createElement(Grid, {
  1622. key: f.field_name,
  1623. container: true,
  1624. style: {
  1625. display: 'flex',
  1626. alignItems: 'center',
  1627. marginBottom: '10px'
  1628. }
  1629. }, /*#__PURE__*/React.createElement(Grid, {
  1630. item: true,
  1631. xs: 12,
  1632. sm: 5
  1633. }, /*#__PURE__*/React.createElement(Box, {
  1634. style: {
  1635. width: '150px'
  1636. }
  1637. }, /*#__PURE__*/React.createElement(Typography, {
  1638. style: {
  1639. paddingRight: '30px',
  1640. color: 'grey'
  1641. }
  1642. }, f.label))), /*#__PURE__*/React.createElement(Grid, {
  1643. item: true,
  1644. xs: 12,
  1645. sm: 7
  1646. }, " ", /*#__PURE__*/React.createElement(TextField, {
  1647. id: "time",
  1648. variant: "outlined",
  1649. size: "small",
  1650. type: "time",
  1651. className: classes.textField,
  1652. InputLabelProps: {
  1653. shrink: true
  1654. },
  1655. inputProps: {
  1656. step: 300
  1657. }
  1658. })));
  1659. }
  1660. })), actions.length > 0 ? /*#__PURE__*/React.createElement(Grid, {
  1661. item: true,
  1662. xs: 12
  1663. }, actions.map(function (a) {
  1664. if (a.status === _data.status) {
  1665. return /*#__PURE__*/React.createElement(MButton, {
  1666. action: a,
  1667. onCallback: function onCallback(event) {
  1668. return a.callback(event, _data);
  1669. }
  1670. });
  1671. }
  1672. })) : /*#__PURE__*/React.createElement(Grid, null)));
  1673. }
  1674. MkForm.propTypes = {
  1675. history: propTypes.object,
  1676. fields: propTypes.array.isRequired,
  1677. data: propTypes.object,
  1678. isNew: propTypes.bool,
  1679. actions: propTypes.array,
  1680. onDropdownCreateNew: propTypes.func
  1681. };
  1682. function descendingComparator(a, b, _orderBy) {
  1683. if (b[_orderBy] < a[_orderBy]) {
  1684. return -1;
  1685. }
  1686. if (b[_orderBy] > a[_orderBy]) {
  1687. return 1;
  1688. }
  1689. return 0;
  1690. }
  1691. function getComparator(_order, _orderBy) {
  1692. return _order === 'desc' ? function (a, b) {
  1693. return descendingComparator(a, b, _orderBy);
  1694. } : function (a, b) {
  1695. return -descendingComparator(a, b, _orderBy);
  1696. };
  1697. }
  1698. function stableSort(array, comparator) {
  1699. var stabilizedThis = array.map(function (el, index) {
  1700. return [el, index];
  1701. });
  1702. stabilizedThis.sort(function (a, b) {
  1703. var _order = comparator(a[0], b[0]);
  1704. if (_order !== 0) return _order;
  1705. return a[1] - b[1];
  1706. });
  1707. return stabilizedThis.map(function (el) {
  1708. return el[0];
  1709. });
  1710. }
  1711. function EnhancedTableHead(props) {
  1712. var headerStyles = props.headerStyles,
  1713. _order = props._order,
  1714. _orderBy = props._orderBy,
  1715. onRequestSort = props.onRequestSort,
  1716. headCells = props.headCells;
  1717. var createSortHandler = function createSortHandler(property) {
  1718. return function (event) {
  1719. onRequestSort(event, property);
  1720. };
  1721. };
  1722. var sortedStyle = createMuiTheme({
  1723. overrides: {
  1724. MuiTableSortLabel: {
  1725. root: {
  1726. "&$active": {
  1727. color: headerStyles.sortedHeader === undefined ? 'grey' : headerStyles.sortedHeader,
  1728. "&& $icon": {
  1729. color: headerStyles.sortedHeader === undefined ? 'grey' : headerStyles.sortedHeader
  1730. }
  1731. }
  1732. }
  1733. }
  1734. }
  1735. });
  1736. return /*#__PURE__*/React.createElement(ThemeProvider, {
  1737. theme: sortedStyle
  1738. }, /*#__PURE__*/React.createElement(TableHead$1, null, /*#__PURE__*/React.createElement(TableRow$1, null, headCells.map(function (headCell) {
  1739. return /*#__PURE__*/React.createElement(TableCell$1, {
  1740. className: headerStyles.head,
  1741. key: headCell.id,
  1742. align: headCell.numeric ? 'right' : 'left',
  1743. padding: headCell.disablePadding ? 'none' : 'default',
  1744. sortDirection: _orderBy === headCell.id ? _order : false,
  1745. style: {
  1746. width: headCell.id === 'sr' ? '15px' : headCell.width ? headCell.width : ''
  1747. }
  1748. }, headCell.id !== 'sr' ? /*#__PURE__*/React.createElement(TableSortLabel, {
  1749. active: _orderBy === headCell.id,
  1750. direction: _orderBy === headCell.id ? _order : 'asc',
  1751. onClick: createSortHandler(headCell.id),
  1752. style: {
  1753. whiteSpace: "nowrap"
  1754. }
  1755. }, headCell.label, _orderBy === headCell.id ? /*#__PURE__*/React.createElement("span", {
  1756. className: headerStyles.visuallyHidden
  1757. }, _order === 'desc' ? 'sorted descending' : 'sorted ascending') : null) : /*#__PURE__*/React.createElement(TableSortLabel, {
  1758. hideSortIcon: "true",
  1759. align: "right"
  1760. }, headCell.label));
  1761. }), /*#__PURE__*/React.createElement(TableCell$1, {
  1762. className: headerStyles.head,
  1763. style: {
  1764. width: '100px'
  1765. }
  1766. }))));
  1767. }
  1768. EnhancedTableHead.propTypes = {
  1769. headerStyles: propTypes.object.isRequired,
  1770. onRequestSort: propTypes.func.isRequired,
  1771. onSelectAllClick: propTypes.func.isRequired,
  1772. _order: propTypes.oneOf(['asc', 'desc']).isRequired,
  1773. _orderBy: propTypes.string.isRequired,
  1774. rowCount: propTypes.number.isRequired
  1775. };
  1776. var useStyles$1 = makeStyles({
  1777. root: {
  1778. width: '100%'
  1779. },
  1780. table: {
  1781. tableLayout: 'fixed'
  1782. },
  1783. visuallyHidden: {
  1784. b_order: 0,
  1785. clip: 'rect(0 0 0 0)',
  1786. height: 1,
  1787. margin: -1,
  1788. overflow: 'hidden',
  1789. padding: 0,
  1790. position: 'absolute',
  1791. top: 20,
  1792. width: 1
  1793. },
  1794. underline: {
  1795. "&&&:before": {
  1796. b_orderBottom: "none"
  1797. },
  1798. "&&:after": {
  1799. b_orderBottom: "none"
  1800. }
  1801. },
  1802. head: function head(props) {
  1803. return {
  1804. backgroundColor: props.headerBackgroundColor === undefined ? '#0d47a1a8' : props.headerBackgroundColor,
  1805. color: props.headerTextColor === undefined ? 'white' : props.headerTextColor
  1806. };
  1807. },
  1808. sortedHeader: function sortedHeader(props) {
  1809. return {
  1810. color: props.headerTextColor === undefined ? 'grey' : props.headerTextColor
  1811. };
  1812. },
  1813. styledTableRow: function styledTableRow(props) {
  1814. return {
  1815. '&:nth-of-type(even)': {
  1816. backgroundColor: props.primaryColor === undefined ? '#0d47a11c' : props.primaryColor
  1817. }
  1818. };
  1819. }
  1820. });
  1821. function getUpdatedDate(p) {
  1822. var statusDate = p.updated_date;
  1823. var day = '';
  1824. if (statusDate !== undefined) {
  1825. var convertDate = new Date(statusDate.toDate());
  1826. var dd = String(convertDate.getDate()).padStart(2, '0');
  1827. var mm = String(convertDate.getMonth() + 1).padStart(2, '0');
  1828. var yyyy = convertDate.getFullYear();
  1829. day = mm + '/' + dd + '/' + yyyy;
  1830. }
  1831. return day.toString();
  1832. }
  1833. function RowMenu(props) {
  1834. var row = props.row,
  1835. actions = props.actions,
  1836. onSelectedAction = props.onSelectedAction,
  1837. onRowEdit = props.onRowEdit;
  1838. var _React$useState = React.useState(null),
  1839. anchorEl = _React$useState[0],
  1840. setAnchorEl = _React$useState[1];
  1841. var handleMenuClick = function handleMenuClick(event) {
  1842. event.stopPropagation();
  1843. setAnchorEl(event.currentTarget);
  1844. };
  1845. var handleSelectMenu = function handleSelectMenu(e, row, action) {
  1846. e.stopPropagation();
  1847. onSelectedAction(row, action.action_name);
  1848. setAnchorEl(null);
  1849. };
  1850. var handleClose = function handleClose(e) {
  1851. setAnchorEl(null);
  1852. e.stopPropagation();
  1853. };
  1854. var handleEdit = function handleEdit(e) {
  1855. onRowEdit(row);
  1856. e.stopPropagation();
  1857. };
  1858. return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Menu, {
  1859. id: "actions-" + row.id,
  1860. anchorEl: anchorEl,
  1861. keepMounted: true,
  1862. open: Boolean(anchorEl),
  1863. onClose: handleClose
  1864. }, actions.map(function (action) {
  1865. return /*#__PURE__*/React.createElement(MenuItem, {
  1866. key: action.display_name,
  1867. onClick: function onClick(e) {
  1868. return handleSelectMenu(e, row, action);
  1869. }
  1870. }, action.display_name);
  1871. })), /*#__PURE__*/React.createElement(Grid, {
  1872. container: true,
  1873. direction: "row",
  1874. justify: "flex-end",
  1875. alignItems: "center",
  1876. style: {
  1877. display: 'flex'
  1878. }
  1879. }, /*#__PURE__*/React.createElement(IconButton, {
  1880. id: "edit-" + row.id,
  1881. "aria-label": "more",
  1882. "aria-controls": "long-menu",
  1883. "aria-haspopup": "true",
  1884. onClick: handleEdit,
  1885. size: "small"
  1886. }, /*#__PURE__*/React.createElement(EditIcon, null)), /*#__PURE__*/React.createElement(Box, {
  1887. style: {
  1888. width: '10px'
  1889. }
  1890. }), /*#__PURE__*/React.createElement(IconButton, {
  1891. id: "dropdown-" + row.id,
  1892. "aria-label": "more",
  1893. "aria-controls": "long-menu",
  1894. "aria-haspopup": "true",
  1895. size: "small",
  1896. onClick: handleMenuClick
  1897. }, /*#__PURE__*/React.createElement(ExpandMore, null))));
  1898. }
  1899. RowMenu.propTypes = {
  1900. row: propTypes.object.isRequired,
  1901. actions: propTypes.array.isRequired,
  1902. onSelectedAction: propTypes.func.isRequired,
  1903. onRowEdit: propTypes.func
  1904. };
  1905. function ConfirmDialog(props) {
  1906. var type = props.type,
  1907. itemName = props.itemName,
  1908. openDialog = props.openDialog,
  1909. onCancel = props.onCancel,
  1910. onContinue = props.onContinue;
  1911. var _React$useState2 = React.useState(openDialog),
  1912. open = _React$useState2[0],
  1913. setOpen = _React$useState2[1];
  1914. var handleClose = function handleClose() {
  1915. setOpen(false);
  1916. onCancel(false);
  1917. };
  1918. var handleContinue = function handleContinue() {
  1919. onContinue(true);
  1920. };
  1921. return /*#__PURE__*/React.createElement("div", null, /*#__PURE__*/React.createElement(Dialog, {
  1922. open: open,
  1923. onClose: handleClose,
  1924. "aria-labelledby": "alert-dialog-title",
  1925. "aria-describedby": "alert-dialog-description"
  1926. }, /*#__PURE__*/React.createElement(DialogTitle, {
  1927. id: "alert-dialog-title"
  1928. }, "Delete this " + type + ' "' + itemName + '"?'), /*#__PURE__*/React.createElement(DialogActions, null, /*#__PURE__*/React.createElement(Button, {
  1929. onClick: handleClose,
  1930. color: "primary"
  1931. }, "Cancel"), /*#__PURE__*/React.createElement(Button, {
  1932. onClick: handleContinue,
  1933. color: "primary",
  1934. autoFocus: true
  1935. }, "Delete"))));
  1936. }
  1937. ConfirmDialog.propTypes = {
  1938. history: propTypes.object,
  1939. type: propTypes.string,
  1940. itemName: propTypes.string,
  1941. openDialog: propTypes.bool,
  1942. onCancel: propTypes.func,
  1943. onContinue: propTypes.func
  1944. };
  1945. function MkTable(props) {
  1946. console.log("props.styles:", props.styles);
  1947. var classes = useStyles$1(props.styles);
  1948. var dispatch = props.dispatch,
  1949. _props$data = props.data,
  1950. data = _props$data === void 0 ? [] : _props$data,
  1951. _props$headers = props.headers,
  1952. headers = _props$headers === void 0 ? [] : _props$headers,
  1953. actions = props.actions,
  1954. onActions = props.onActions,
  1955. title = props.title,
  1956. page = props.page,
  1957. rowsPerPage = props.rowsPerPage,
  1958. _props$noMoreToLoad = props.noMoreToLoad,
  1959. noMoreToLoad = _props$noMoreToLoad === void 0 ? false : _props$noMoreToLoad,
  1960. order = props.order,
  1961. orderBy = props.orderBy,
  1962. _props$isLoading = props.isLoading,
  1963. isLoading = _props$isLoading === void 0 ? false : _props$isLoading,
  1964. onChangePaginatePage = props.onChangePaginatePage,
  1965. onGetData = props.onGetData,
  1966. onUpdateDataRow = props.onUpdateDataRow,
  1967. onChangeRowPerPage = props.onChangeRowPerPage,
  1968. _props$dense = props.dense,
  1969. dense = _props$dense === void 0 ? true : _props$dense;
  1970. var _React$useState3 = React.useState(rowsPerPage),
  1971. _rowsPerPage = _React$useState3[0],
  1972. setRowsPerPage = _React$useState3[1];
  1973. var _React$useState4 = React.useState(page),
  1974. _page = _React$useState4[0],
  1975. setPage = _React$useState4[1];
  1976. var _React$useState5 = React.useState(noMoreToLoad),
  1977. _noMoreToLoad = _React$useState5[0],
  1978. setNoMoreToLoad = _React$useState5[1];
  1979. var _React$useState6 = React.useState(order),
  1980. _order = _React$useState6[0],
  1981. setOrder = _React$useState6[1];
  1982. var _React$useState7 = React.useState(orderBy),
  1983. _orderBy = _React$useState7[0],
  1984. setOrderBy = _React$useState7[1];
  1985. var _React$useState8 = React.useState(isLoading),
  1986. _isLoading = _React$useState8[0],
  1987. setIsLoading = _React$useState8[1];
  1988. var _React$useState9 = React.useState(false),
  1989. _isConfirm = _React$useState9[0],
  1990. setIsConfirm = _React$useState9[1];
  1991. var _React$useState10 = React.useState(''),
  1992. itemName = _React$useState10[0],
  1993. setItemName = _React$useState10[1];
  1994. var _React$useState11 = React.useState({}),
  1995. row = _React$useState11[0],
  1996. setRow = _React$useState11[1];
  1997. var _React$useState12 = React.useState(''),
  1998. action = _React$useState12[0],
  1999. setAction = _React$useState12[1];
  2000. var _React$useState13 = React.useState(dense),
  2001. _dense = _React$useState13[0],
  2002. setDense = _React$useState13[1];
  2003. var handleSelectMenu = function handleSelectMenu(row, action) {
  2004. if (action === 'delete') {
  2005. setItemName(row.name === undefined ? row.product_desc : row.name);
  2006. setIsConfirm(true);
  2007. setRow(row);
  2008. setAction(action);
  2009. } else {
  2010. onActions(row, action);
  2011. }
  2012. };
  2013. var handleDelete = function handleDelete(v) {
  2014. setIsConfirm(false);
  2015. onActions(row, action);
  2016. };
  2017. var handleCancel = function handleCancel(v) {
  2018. setIsConfirm(false);
  2019. };
  2020. var handleRowEdit = function handleRowEdit(row) {
  2021. onUpdateDataRow(row);
  2022. };
  2023. var offset = _page * _rowsPerPage;
  2024. useEffect(function () {
  2025. setNoMoreToLoad(noMoreToLoad);
  2026. setPage(page);
  2027. setOrder(order);
  2028. setOrderBy(orderBy);
  2029. setIsLoading(isLoading);
  2030. setRowsPerPage(rowsPerPage);
  2031. setDense(dense);
  2032. }, []);
  2033. var handleRequestSort = function handleRequestSort(event, property) {
  2034. var isAsc = _orderBy === property && _order === 'asc';
  2035. setOrder(isAsc ? 'desc' : 'asc');
  2036. setOrderBy(property);
  2037. };
  2038. var handleChangePage = function handleChangePage(event, newPage) {
  2039. if (!_noMoreToLoad && (newPage + 1) * _rowsPerPage >= data.length) {
  2040. onGetData();
  2041. }
  2042. setPage(newPage);
  2043. onChangePaginatePage(newPage);
  2044. };
  2045. var handleChangeRowsPerPage = function handleChangeRowsPerPage(event) {
  2046. setRowsPerPage(parseInt(event.target.value));
  2047. onChangeRowPerPage(parseInt(event.target.value));
  2048. };
  2049. return /*#__PURE__*/React.createElement("div", {
  2050. className: classes.root
  2051. }, /*#__PURE__*/React.createElement(Grid, {
  2052. container: true
  2053. }, /*#__PURE__*/React.createElement(Grid, {
  2054. item: true
  2055. }, /*#__PURE__*/React.createElement(TableContainer$1, null, /*#__PURE__*/React.createElement(Table$1, {
  2056. className: classes.table,
  2057. "aria-labelledby": "tableTitle",
  2058. size: _dense ? 'small' : 'medium',
  2059. "aria-label": "enhanced table"
  2060. }, /*#__PURE__*/React.createElement(EnhancedTableHead, {
  2061. headerStyles: classes,
  2062. headCells: headers,
  2063. _order: _order,
  2064. _orderBy: _orderBy,
  2065. onRequestSort: handleRequestSort,
  2066. rowCount: data.length !== undefined ? data.length : 0,
  2067. dispatch: dispatch
  2068. }), /*#__PURE__*/React.createElement(TableBody$1, null, _isLoading ? /*#__PURE__*/React.createElement(TableRow$1, {
  2069. className: classes.styledTableRow
  2070. }, /*#__PURE__*/React.createElement(TableCell$1, {
  2071. colSpan: headers.length,
  2072. align: "center"
  2073. }, " ", /*#__PURE__*/React.createElement(CircularProgress, null))) : data.length !== 0 ? stableSort(data, getComparator(_order, _orderBy)).slice(_page * _rowsPerPage, _page * _rowsPerPage + _rowsPerPage).map(function (row, index) {
  2074. return /*#__PURE__*/React.createElement(TableRow$1, {
  2075. hover: true,
  2076. role: "checkbox",
  2077. tabIndex: -1,
  2078. key: row.id,
  2079. id: row.id,
  2080. className: classes.styledTableRow
  2081. }, headers.map(function (h, i) {
  2082. if (h.id === 'sr') {
  2083. return /*#__PURE__*/React.createElement(TableCell$1, {
  2084. key: h.id,
  2085. align: "right",
  2086. style: {
  2087. width: '15px'
  2088. }
  2089. }, ++offset);
  2090. }
  2091. if (h.id === 'status') {
  2092. return /*#__PURE__*/React.createElement(TableCell$1, {
  2093. key: h.id,
  2094. align: h.numeric ? 'right' : 'left'
  2095. }, row[h.id]);
  2096. }
  2097. if (h.id === 'updated_date') {
  2098. return /*#__PURE__*/React.createElement(TableCell$1, {
  2099. key: h.id,
  2100. align: h.numeric ? 'right' : 'left',
  2101. style: {
  2102. width: h.width ? h.width : null
  2103. }
  2104. }, getUpdatedDate(row));
  2105. } else {
  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. }, row[h.id]);
  2113. }
  2114. }), actions ? /*#__PURE__*/React.createElement(TableCell$1, {
  2115. style: {
  2116. width: '150px'
  2117. },
  2118. align: "right"
  2119. }, /*#__PURE__*/React.createElement(RowMenu, {
  2120. actions: actions,
  2121. row: row,
  2122. onRowEdit: function onRowEdit(data) {
  2123. return handleRowEdit(data);
  2124. },
  2125. onSelectedAction: function onSelectedAction(data, actionName) {
  2126. return handleSelectMenu(data, actionName);
  2127. }
  2128. })) : /*#__PURE__*/React.createElement(TableCell$1, {
  2129. style: {
  2130. width: '150px'
  2131. },
  2132. align: "right"
  2133. }, /*#__PURE__*/React.createElement(IconButton, {
  2134. onClick: function onClick(event) {
  2135. return handleRowEdit(row);
  2136. },
  2137. size: dense ? "small" : "medium"
  2138. }, /*#__PURE__*/React.createElement(EditIcon, null))));
  2139. }) : /*#__PURE__*/React.createElement(TableRow$1, {
  2140. className: classes.styledTableRow,
  2141. style: {
  2142. width: '100%'
  2143. }
  2144. })))), /*#__PURE__*/React.createElement(TablePagination, {
  2145. rowsPerPageOptions: [10, 30, 50],
  2146. labelDisplayedRows: function labelDisplayedRows(_ref) {
  2147. var from = _ref.from,
  2148. to = _ref.to,
  2149. count = _ref.count;
  2150. console.log(from, to, count);
  2151. },
  2152. component: "div",
  2153. count: data.length,
  2154. rowsPerPage: _rowsPerPage,
  2155. page: _page,
  2156. onChangePage: handleChangePage,
  2157. onChangeRowsPerPage: handleChangeRowsPerPage
  2158. }))), _isConfirm ? /*#__PURE__*/React.createElement(ConfirmDialog, {
  2159. type: title,
  2160. itemName: itemName,
  2161. openDialog: _isConfirm,
  2162. onCancel: function onCancel(v) {
  2163. return handleCancel();
  2164. },
  2165. onContinue: function onContinue(v) {
  2166. return handleDelete();
  2167. }
  2168. }) : /*#__PURE__*/React.createElement("div", null));
  2169. }
  2170. MkTable.propTypes = {
  2171. history: propTypes.object,
  2172. headers: propTypes.array.isRequired,
  2173. data: propTypes.array.isRequired,
  2174. query: propTypes.object,
  2175. onProductBOMClick: propTypes.func,
  2176. onActions: propTypes.func,
  2177. actions: propTypes.array,
  2178. title: propTypes.string,
  2179. order: propTypes.any,
  2180. orderBy: propTypes.any,
  2181. rowsPerPage: propTypes.any,
  2182. noMoreToLoad: propTypes.any,
  2183. isLoading: propTypes.any,
  2184. onChangePaginatePage: propTypes.any,
  2185. onGetData: propTypes.any,
  2186. onChangeRowPerPage: propTypes.any,
  2187. dense: propTypes.any,
  2188. styles: propTypes.any
  2189. };
  2190. var useStyles$2 = makeStyles(function (theme) {
  2191. return {
  2192. root: {
  2193. width: '100%'
  2194. },
  2195. paper: {
  2196. width: '100%',
  2197. marginBottom: theme.spacing(2)
  2198. },
  2199. table: {
  2200. minWidth: 750
  2201. },
  2202. visuallyHidden: {
  2203. border: 0,
  2204. clip: 'rect(0 0 0 0)',
  2205. height: 1,
  2206. margin: -1,
  2207. overflow: 'hidden',
  2208. padding: 0,
  2209. position: 'absolute',
  2210. top: 20,
  2211. width: 1
  2212. },
  2213. underline: {
  2214. "&&&:before": {
  2215. borderBottom: "none"
  2216. },
  2217. "&&:after": {
  2218. borderBottom: "none"
  2219. }
  2220. },
  2221. button: {
  2222. color: 'white',
  2223. width: 150,
  2224. height: 55
  2225. },
  2226. closeButton: {
  2227. position: 'absolute',
  2228. right: theme.spacing(1),
  2229. top: theme.spacing(1),
  2230. color: theme.palette.grey[500]
  2231. },
  2232. headText: {
  2233. fontSize: 14,
  2234. "float": "left",
  2235. color: theme.palette.primary.main,
  2236. fontWeight: "bold"
  2237. }
  2238. };
  2239. });
  2240. function getDataString(data, fieldName) {
  2241. return data[fieldName];
  2242. }
  2243. function MkInfo(props) {
  2244. var classes = useStyles$2();
  2245. var infoData = props.infoData,
  2246. displayFields = props.displayFields,
  2247. _props$isNew = props.isNew,
  2248. isNew = _props$isNew === void 0 ? false : _props$isNew,
  2249. isEditable = props.isEditable,
  2250. currentTabName = props.currentTabName,
  2251. actions = props.actions;
  2252. var _React$useState = React.useState(isEditable !== undefined ? isEditable : true),
  2253. editable = _React$useState[0],
  2254. setEditable = _React$useState[1];
  2255. var handleEdit = function handleEdit() {
  2256. setEditable(false);
  2257. };
  2258. return /*#__PURE__*/React.createElement("div", {
  2259. className: classes.root
  2260. }, isNew ? /*#__PURE__*/React.createElement(Grid, {
  2261. container: true,
  2262. style: {
  2263. marginTop: '30px'
  2264. }
  2265. }, /*#__PURE__*/React.createElement(Grid, {
  2266. item: true,
  2267. xs: 12,
  2268. sm: 7
  2269. })) : /*#__PURE__*/React.createElement(Grid, {
  2270. container: true,
  2271. style: {
  2272. marginTop: '30px'
  2273. }
  2274. }, /*#__PURE__*/React.createElement(Grid, {
  2275. item: true,
  2276. xs: 12,
  2277. sm: 7
  2278. }, !editable ?
  2279. /*#__PURE__*/
  2280. React.createElement("div", null) : displayFields.map(function (d, i) {
  2281. return /*#__PURE__*/React.createElement(Grid, {
  2282. container: true,
  2283. key: i
  2284. }, /*#__PURE__*/React.createElement(Grid, {
  2285. item: true,
  2286. xs: 12,
  2287. style: {
  2288. display: 'flex',
  2289. alignItems: 'center',
  2290. marginBottom: '10px'
  2291. }
  2292. }, /*#__PURE__*/React.createElement(Grid, {
  2293. item: true,
  2294. xs: 12,
  2295. sm: 5
  2296. }, /*#__PURE__*/React.createElement(Box, {
  2297. style: {
  2298. width: '250px'
  2299. }
  2300. }, /*#__PURE__*/React.createElement(Typography, {
  2301. style: {
  2302. paddingRight: '30px',
  2303. color: 'grey'
  2304. }
  2305. }, d.label))), /*#__PURE__*/React.createElement(Grid, {
  2306. item: true,
  2307. xs: 12,
  2308. sm: 7
  2309. }, d.type === 'photo' ? /*#__PURE__*/React.createElement("img", null) :
  2310. /*#__PURE__*/
  2311. React.createElement(Typography, {
  2312. style: {
  2313. paddingRight: '30px'
  2314. }
  2315. }, infoData !== undefined ? getDataString(infoData, d.fieldName) : ''))));
  2316. })), /*#__PURE__*/React.createElement(Grid, {
  2317. item: true,
  2318. xs: 12,
  2319. sm: 7
  2320. }, /*#__PURE__*/React.createElement(Grid, {
  2321. container: true,
  2322. direction: "row",
  2323. alignItems: "flex-end"
  2324. }, actions.map(function (a, i) {
  2325. if (currentTabName === 'account') {
  2326. if (infoData.status === 'invited') {
  2327. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2328. style: {
  2329. color: 'white',
  2330. backgroundColor: 'grey',
  2331. "float": 'right',
  2332. marginLeft: '10px'
  2333. }
  2334. }, a.label));
  2335. }
  2336. if (infoData.status === 'joined') {
  2337. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2338. style: {
  2339. color: 'white',
  2340. backgroundColor: 'grey',
  2341. "float": 'right',
  2342. marginLeft: '10px'
  2343. }
  2344. }, a.label));
  2345. }
  2346. if (infoData.status === 'disabled') {
  2347. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2348. style: {
  2349. color: 'white',
  2350. backgroundColor: 'grey',
  2351. "float": 'right',
  2352. marginLeft: '10px'
  2353. }
  2354. }, a.label));
  2355. }
  2356. if (infoData.status === 'requested') {
  2357. if (editable) {
  2358. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2359. style: {
  2360. marginLeft: '10px'
  2361. },
  2362. onClick: handleEdit
  2363. }, a.icon, a.label));
  2364. } else {
  2365. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2366. style: {
  2367. color: 'white',
  2368. backgroundColor: 'grey',
  2369. "float": 'right',
  2370. marginLeft: '10px'
  2371. }
  2372. }, a.label));
  2373. }
  2374. }
  2375. } else {
  2376. if (editable) {
  2377. if (a.action_type === 'edit') {
  2378. console.log('type: ', a.action_type, 'editable: ', editable);
  2379. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2380. style: {
  2381. marginLeft: '10px'
  2382. },
  2383. onClick: handleEdit
  2384. }, a.icon, a.label));
  2385. }
  2386. if (a.action_type === 'delete') {
  2387. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2388. style: {
  2389. "float": 'right',
  2390. marginLeft: '10px'
  2391. }
  2392. }, a.icon, a.label));
  2393. }
  2394. } else {
  2395. if (a.action_type === 'save') {
  2396. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2397. style: {
  2398. marginLeft: '10px'
  2399. }
  2400. }, a.icon, a.label));
  2401. }
  2402. if (a.action_type === 'cancel') {
  2403. return /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
  2404. style: {
  2405. "float": 'right',
  2406. marginLeft: '10px'
  2407. }
  2408. }, a.icon, a.label));
  2409. }
  2410. }
  2411. }
  2412. })))));
  2413. }
  2414. MkInfo.propTypes = {
  2415. history: propTypes.object,
  2416. infoData: propTypes.object,
  2417. displayFields: propTypes.array,
  2418. isNew: propTypes.bool,
  2419. isEditable: propTypes.bool,
  2420. actions: propTypes.any
  2421. };
  2422. export { List, MkForm, MkInfo, MkTable };
  2423. //# sourceMappingURL=index.modern.js.map