index.js 88 KB

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