UNPKG

@premieroctet/next-admin

Version:

Next-Admin provides a customizable and turnkey admin dashboard for applications built with Next.js and powered by the Prisma ORM. It aims to simplify the development process by providing a turnkey admin system that can be easily integrated into your proje

148 lines (147 loc) 6.04 kB
"use strict"; var __webpack_require__ = {}; (()=>{ __webpack_require__.n = (module)=>{ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module; __webpack_require__.d(getter, { a: getter }); return getter; }; })(); (()=>{ __webpack_require__.d = (exports1, definition)=>{ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, { enumerable: true, get: definition[key] }); }; })(); (()=>{ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop); })(); (()=>{ __webpack_require__.r = (exports1)=>{ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, { value: 'Module' }); Object.defineProperty(exports1, '__esModule', { value: true }); }; })(); var __webpack_exports__ = {}; __webpack_require__.r(__webpack_exports__); __webpack_require__.d(__webpack_exports__, { getDisplayedValue: ()=>getDisplayedValue, isFileUploadFormat: ()=>isFileUploadFormat, slugify: ()=>slugify, capitalize: ()=>capitalize, extractSerializable: ()=>extractSerializable, formatLabel: ()=>formatLabel, isNativeFunction: ()=>isNativeFunction, isScalar: ()=>isScalar, pipe: ()=>pipe, uncapitalize: ()=>uncapitalize, reorderData: ()=>reorderData, getDeletedFilesFieldName: ()=>getDeletedFilesFieldName, isUploadFile: ()=>isUploadFile }); const external_lodash_sortby_namespaceObject = require("lodash.sortby"); var external_lodash_sortby_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_sortby_namespaceObject); const external_react_namespaceObject = require("react"); var external_react_default = /*#__PURE__*/ __webpack_require__.n(external_react_namespaceObject); const capitalize = (str)=>{ let capitalizedStr = str.charAt(0).toLocaleUpperCase() + str.slice(1); return capitalizedStr; }; const uncapitalize = (str)=>{ let uncapitalizedStr = str.charAt(0).toLocaleLowerCase() + str.slice(1); return uncapitalizedStr; }; const isNativeFunction = (fn)=>/\{\s*\[native code\]\s*\}/.test(fn.toString()); const isScalar = (value)=>"string" == typeof value || "boolean" == typeof value || "number" == typeof value; const pipe = (...fns)=>(x)=>fns.reduce(async (v, f)=>await f(await v), Promise.resolve(x)); const extractSerializable = (obj, isAppDir)=>{ if (Array.isArray(obj)) return obj.map((item)=>extractSerializable(item, isAppDir)); if (obj instanceof Date) return obj.toISOString(); if (null === obj) return obj; if ("object" == typeof obj) { if (isAppDir && external_react_default().isValidElement(obj)) return obj; let newObj = {}; for(const key in obj)if (obj.hasOwnProperty(key)) newObj = { ...newObj, [key]: extractSerializable(obj[key], isAppDir) }; return newObj; } if (isScalar(obj)) return obj; else return null; }; const slugify = (str)=>str.toLowerCase(); const formatLabel = (label)=>{ let spacedLabel = label.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim(); return capitalize(spacedLabel.toLowerCase()); }; const isUploadFile = (obj)=>"object" == typeof obj && "buffer" in obj && "infos" in obj && obj.buffer.length > 0; const getDisplayedValue = (element)=>{ if ("string" == typeof element) return element; if (external_react_default().isValidElement(element)) return Array.prototype.map.call(element.props.children, (child)=>getDisplayedValue(child)).join(""); return ""; }; const getDeletedFilesFieldName = (field)=>`${field}__nextadmin_deleted`; const isFileUploadFormat = (format)=>[ "data-url", "file" ].includes(format); const reorderData = (data, fromId, toId, orderField, idField)=>{ const result = Array.from(data); const from = result.find((item)=>item[idField].value === fromId); const to = result.find((item)=>item[idField].value === toId); if (!from || !to) return result; const fromIndex = result.indexOf(from); const toIndex = result.indexOf(to); result[fromIndex][orderField].value = to[orderField].value; if (fromIndex < toIndex) for(let i = fromIndex + 1; i <= toIndex; i++){ const current = result[i][orderField].value; result[i][orderField].value = current - 1; } else for(let i = toIndex; i < fromIndex; i++){ const current = result[i][orderField].value; result[i][orderField].value = current + 1; } return external_lodash_sortby_default()(result, function(item) { return item[orderField].value; }); }; exports.capitalize = __webpack_exports__.capitalize; exports.extractSerializable = __webpack_exports__.extractSerializable; exports.formatLabel = __webpack_exports__.formatLabel; exports.getDeletedFilesFieldName = __webpack_exports__.getDeletedFilesFieldName; exports.getDisplayedValue = __webpack_exports__.getDisplayedValue; exports.isFileUploadFormat = __webpack_exports__.isFileUploadFormat; exports.isNativeFunction = __webpack_exports__.isNativeFunction; exports.isScalar = __webpack_exports__.isScalar; exports.isUploadFile = __webpack_exports__.isUploadFile; exports.pipe = __webpack_exports__.pipe; exports.reorderData = __webpack_exports__.reorderData; exports.slugify = __webpack_exports__.slugify; exports.uncapitalize = __webpack_exports__.uncapitalize; for(var __webpack_i__ in __webpack_exports__)if (-1 === [ "capitalize", "extractSerializable", "formatLabel", "getDeletedFilesFieldName", "getDisplayedValue", "isFileUploadFormat", "isNativeFunction", "isScalar", "isUploadFile", "pipe", "reorderData", "slugify", "uncapitalize" ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__]; Object.defineProperty(exports, '__esModule', { value: true });