react-admin-crud-manager 1.0.4 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -3
- package/dist/index.cjs.js +37 -40
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1105 -1441
- package/dist/index.es.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/tailwind.css +1938 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -27,8 +27,18 @@ This will output the library files to the `dist/` folder in both CommonJS and ES
|
|
|
27
27
|
|
|
28
28
|
## Usage
|
|
29
29
|
|
|
30
|
+
### 1. Import the built CSS for Tailwind styles
|
|
31
|
+
|
|
32
|
+
In your main entry file (e.g., `src/main.jsx` or `src/index.js`):
|
|
33
|
+
|
|
34
|
+
```js
|
|
35
|
+
import 'react-admin-crud-manager/dist/tailwind.css';
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### 2. Use the component
|
|
39
|
+
|
|
30
40
|
```
|
|
31
|
-
import
|
|
41
|
+
import Crud from 'react-admin-crud-manager';
|
|
32
42
|
|
|
33
43
|
function App() {
|
|
34
44
|
const config = {
|
|
@@ -36,12 +46,12 @@ function App() {
|
|
|
36
46
|
fetchData: async () => { /* fetch logic */ },
|
|
37
47
|
// ...other config options
|
|
38
48
|
};
|
|
39
|
-
return <
|
|
49
|
+
return <Crud config={config} />;
|
|
40
50
|
}
|
|
41
51
|
```
|
|
42
52
|
|
|
43
53
|
## Components
|
|
44
|
-
- `
|
|
54
|
+
- `Crud`: Main CRUD page component
|
|
45
55
|
- `Table`, `Modal`, `Form`, etc.: Available for advanced use
|
|
46
56
|
|
|
47
57
|
## Props
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,62 +1,59 @@
|
|
|
1
|
-
"use strict";const
|
|
1
|
+
"use strict";const h=require("react"),H=require("lucide-react"),Ie=require("react-dom"),we=require("@iconify/react"),Le=require("@tinymce/tinymce-react"),fe=require("notistack"),a=require("prop-types");var ke={exports:{}},be={};/**
|
|
2
2
|
* @license React
|
|
3
|
-
* react-jsx-runtime.production.
|
|
3
|
+
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
5
|
-
* Copyright (c)
|
|
5
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Ne;function Be(){if(Ne)return be;Ne=1;var c=Symbol.for("react.transitional.element"),d=Symbol.for("react.fragment");function s(i,l,r){var n=null;if(r!==void 0&&(n=""+r),l.key!==void 0&&(n=""+l.key),"key"in l){r={};for(var w in l)w!=="key"&&(r[w]=l[w])}else r=l;return l=r.ref,{$$typeof:c,type:i,key:n,ref:l!==void 0?l:null,props:r}}return be.Fragment=d,be.jsx=s,be.jsxs=s,be}var ge={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
13
|
-
* Copyright (c)
|
|
13
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Check the top-level render call using <`+b+">.")}return s}}function qe(r,s){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var b=vr(s);if(We[b])return;We[b]=!0;var S="";r&&r._owner&&r._owner!==De.current&&(S=" It was passed a child from "+O(r._owner.type)+"."),Ne(r),j('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',b,S),Ne(null)}}function Je(r,s){{if(typeof r!="object")return;if(k(r))for(var b=0;b<r.length;b++){var S=r[b];Ie(S)&&qe(S,s)}else if(Ie(r))r._store&&(r._store.validated=!0);else if(r){var I=M(r);if(typeof I=="function"&&I!==r.entries)for(var Y=I.call(r),D;!(D=Y.next()).done;)Ie(D.value)&&qe(D.value,s)}}}function wr(r){{var s=r.type;if(s==null||typeof s=="string")return;var b;if(typeof s=="function")b=s.propTypes;else if(typeof s=="object"&&(s.$$typeof===v||s.$$typeof===u))b=s.propTypes;else return;if(b){var S=O(s);ue(b,r.props,"prop",S,r)}else if(s.PropTypes!==void 0&&!Ae){Ae=!0;var I=O(s);j("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",I||"Unknown")}typeof s.getDefaultProps=="function"&&!s.getDefaultProps.isReactClassApproved&&j("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function jr(r){{for(var s=Object.keys(r.props),b=0;b<s.length;b++){var S=s[b];if(S!=="children"&&S!=="key"){Ne(r),j("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",S),Ne(null);break}}r.ref!==null&&(Ne(r),j("Invalid attribute `ref` supplied to `React.Fragment`."),Ne(null))}}function Ze(r,s,b,S,I,Y){{var D=G(r);if(!D){var P="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(P+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var ae=yr();ae?P+=ae:P+=Ve();var q;r===null?q="null":k(r)?q="array":r!==void 0&&r.$$typeof===c?(q="<"+(O(r.type)||"Unknown")+" />",P=" Did you accidentally export a JSX literal instead of a component?"):q=typeof r,j("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",q,P)}var J=xr(r,s,b,I,Y);if(J==null)return J;if(D){var ne=s.children;if(ne!==void 0)if(S)if(k(ne)){for(var Ce=0;Ce<ne.length;Ce++)Je(ne[Ce],r);Object.freeze&&Object.freeze(ne)}else j("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Je(ne,r)}return r===i?jr(J):wr(J),J}}function kr(r,s,b){return Ze(r,s,b,!0)}function Sr(r,s,b){return Ze(r,s,b,!1)}var Nr=Sr,Cr=kr;_e.Fragment=i,_e.jsx=Nr,_e.jsxs=Cr}()),_e}process.env.NODE_ENV==="production"?$e.exports=Mr():$e.exports=Tr();var e=$e.exports;const nr=(h,c="DD MMM YYYY")=>{if(!h)return"N/A";const o=new Date(h);if(isNaN(o))return"Invalid Date";const i=t=>String(t).padStart(2,"0"),d={YYYY:o.getFullYear(),YY:String(o.getFullYear()).slice(-2),MMMM:o.toLocaleString("en-US",{month:"long"}),MMM:o.toLocaleString("en-US",{month:"short"}),MM:i(o.getMonth()+1),M:o.getMonth()+1,DD:i(o.getDate()),D:o.getDate(),dddd:o.toLocaleString("en-US",{weekday:"long"}),ddd:o.toLocaleString("en-US",{weekday:"short"}),HH:i(o.getHours()),hh:i(o.getHours()%12||12),mm:i(o.getMinutes()),ss:i(o.getSeconds()),A:o.getHours()>=12?"PM":"AM"};return c.replace(/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|HH|hh|mm|ss|A/g,t=>d[t])},_r=(h,c,o=[])=>{if(!(c!=null&&c.trim()))return h;const i=c.toLowerCase(),d=t=>t==null?[]:typeof t=="object"?Object.values(t).flatMap(d):[String(t)];return h.filter(t=>{let n=[];return o.length>0?o.forEach(C=>{t[C]!==void 0&&n.push(...d(t[C]))}):n=d(t),n.some(C=>C.toLowerCase().includes(i))})},Re=g.forwardRef(({className:h="",variant:c="contained",color:o="default",size:i="default",fullWidth:d=!1,children:t,...n},C)=>{var p;const v="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",w={sm:"h-8 px-3 rounded-md text-sm",md:"h-9 px-4 rounded-md text-sm",lg:"h-11 px-6 rounded-md text-base",xl:"h-12 px-8 rounded-lg text-lg",default:"h-9 px-4 rounded-md text-sm"},m={primary:{contained:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500 shadow-sm",outlined:"border border-blue-600 bg-transparent text-blue-600 hover:bg-blue-50 focus:ring-blue-500",text:"bg-transparent text-blue-600 hover:bg-blue-50 focus:ring-blue-500"},success:{contained:"bg-green-600 text-white hover:bg-green-700 focus:ring-green-500 shadow-sm",outlined:"border border-green-600 bg-transparent text-green-600 hover:bg-green-50 focus:ring-green-500",text:"bg-transparent text-green-600 hover:bg-green-50 focus:ring-green-500"},error:{contained:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500 shadow-sm",outlined:"border border-red-600 bg-transparent text-red-600 hover:bg-red-50 focus:ring-red-500",text:"bg-transparent text-red-600 hover:bg-red-50 focus:ring-red-500"},default:{contained:"border bg-gray-200 text-gray-800 hover:bg-gray-300 focus:ring-gray-300 shadow-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 dark:hover:bg-gray-600 dark:focus:ring-gray-600",outlined:"border border-gray-300 bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-300 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700 dark:focus:ring-gray-500",text:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-300 dark:text-gray-200 dark:hover:bg-gray-700 dark:focus:ring-gray-500"}},u=((p=m[o])==null?void 0:p[c])||m.default.contained,f=w[i],R=`
|
|
26
|
-
${v}
|
|
17
|
+
*/var Me;function $e(){return Me||(Me=1,process.env.NODE_ENV!=="production"&&function(){function c(t){if(t==null)return null;if(typeof t=="function")return t.$$typeof===R?null:t.displayName||t.name||null;if(typeof t=="string")return t;switch(t){case k:return"Fragment";case E:return"Profiler";case M:return"StrictMode";case z:return"Suspense";case O:return"SuspenseList";case F:return"Activity"}if(typeof t=="object")switch(typeof t.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),t.$$typeof){case N:return"Portal";case B:return t.displayName||"Context";case P:return(t._context.displayName||"Context")+".Consumer";case Y:var v=t.render;return t=t.displayName,t||(t=v.displayName||v.name||"",t=t!==""?"ForwardRef("+t+")":"ForwardRef"),t;case m:return v=t.displayName||null,v!==null?v:c(t.type)||"Memo";case _:v=t._payload,t=t._init;try{return c(t(v))}catch{}}return null}function d(t){return""+t}function s(t){try{d(t);var v=!1}catch{v=!0}if(v){v=console;var I=v.error,G=typeof Symbol=="function"&&Symbol.toStringTag&&t[Symbol.toStringTag]||t.constructor.name||"Object";return I.call(v,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",G),d(t)}}function i(t){if(t===k)return"<>";if(typeof t=="object"&&t!==null&&t.$$typeof===_)return"<...>";try{var v=c(t);return v?"<"+v+">":"<...>"}catch{return"<...>"}}function l(){var t=y.A;return t===null?null:t.getOwner()}function r(){return Error("react-stack-top-frame")}function n(t){if(A.call(t,"key")){var v=Object.getOwnPropertyDescriptor(t,"key").get;if(v&&v.isReactWarning)return!1}return t.key!==void 0}function w(t,v){function I(){X||(X=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",v))}I.isReactWarning=!0,Object.defineProperty(t,"key",{get:I,configurable:!0})}function C(){var t=c(this.type);return ae[t]||(ae[t]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),t=this.props.ref,t!==void 0?t:null}function x(t,v,I,G,te,ne){var L=I.ref;return t={$$typeof:b,type:t,key:v,props:I,_owner:G},(L!==void 0?L:null)!==null?Object.defineProperty(t,"ref",{enumerable:!1,get:C}):Object.defineProperty(t,"ref",{enumerable:!1,value:null}),t._store={},Object.defineProperty(t._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(t,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(t,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:te}),Object.defineProperty(t,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ne}),Object.freeze&&(Object.freeze(t.props),Object.freeze(t)),t}function f(t,v,I,G,te,ne){var L=v.children;if(L!==void 0)if(G)if(q(L)){for(G=0;G<L.length;G++)u(L[G]);Object.freeze&&Object.freeze(L)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else u(L);if(A.call(v,"key")){L=c(t);var J=Object.keys(v).filter(function(ce){return ce!=="key"});G=0<J.length?"{key: someKey, "+J.join(": ..., ")+": ...}":"{key: someKey}",ie[L+G]||(J=0<J.length?"{"+J.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
|
+
let props = %s;
|
|
19
|
+
<%s {...props} />
|
|
20
|
+
React keys must be passed directly to JSX without using spread:
|
|
21
|
+
let props = %s;
|
|
22
|
+
<%s key={someKey} {...props} />`,G,L,J,L),ie[L+G]=!0)}if(L=null,I!==void 0&&(s(I),L=""+I),n(v)&&(s(v.key),L=""+v.key),"key"in v){I={};for(var le in v)le!=="key"&&(I[le]=v[le])}else I=v;return L&&w(I,typeof t=="function"?t.displayName||t.name||"Unknown":t),x(t,L,I,l(),te,ne)}function u(t){g(t)?t._store&&(t._store.validated=1):typeof t=="object"&&t!==null&&t.$$typeof===_&&(t._payload.status==="fulfilled"?g(t._payload.value)&&t._payload.value._store&&(t._payload.value._store.validated=1):t._store&&(t._store.validated=1))}function g(t){return typeof t=="object"&&t!==null&&t.$$typeof===b}var j=h,b=Symbol.for("react.transitional.element"),N=Symbol.for("react.portal"),k=Symbol.for("react.fragment"),M=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),P=Symbol.for("react.consumer"),B=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),z=Symbol.for("react.suspense"),O=Symbol.for("react.suspense_list"),m=Symbol.for("react.memo"),_=Symbol.for("react.lazy"),F=Symbol.for("react.activity"),R=Symbol.for("react.client.reference"),y=j.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,A=Object.prototype.hasOwnProperty,q=Array.isArray,V=console.createTask?console.createTask:function(){return null};j={react_stack_bottom_frame:function(t){return t()}};var X,ae={},oe=j.react_stack_bottom_frame.bind(j,r)(),re=V(i(r)),ie={};ge.Fragment=k,ge.jsx=function(t,v,I){var G=1e4>y.recentlyCreatedOwnerStacks++;return f(t,v,I,!1,G?Error("react-stack-top-frame"):oe,G?V(i(t)):re)},ge.jsxs=function(t,v,I){var G=1e4>y.recentlyCreatedOwnerStacks++;return f(t,v,I,!0,G?Error("react-stack-top-frame"):oe,G?V(i(t)):re)}}()),ge}process.env.NODE_ENV==="production"?ke.exports=Be():ke.exports=$e();var e=ke.exports;const Te=(c,d="DD MMM YYYY")=>{if(!c)return"N/A";const s=new Date(c);if(isNaN(s))return"Invalid Date";const i=r=>String(r).padStart(2,"0"),l={YYYY:s.getFullYear(),YY:String(s.getFullYear()).slice(-2),MMMM:s.toLocaleString("en-US",{month:"long"}),MMM:s.toLocaleString("en-US",{month:"short"}),MM:i(s.getMonth()+1),M:s.getMonth()+1,DD:i(s.getDate()),D:s.getDate(),dddd:s.toLocaleString("en-US",{weekday:"long"}),ddd:s.toLocaleString("en-US",{weekday:"short"}),HH:i(s.getHours()),hh:i(s.getHours()%12||12),mm:i(s.getMinutes()),ss:i(s.getSeconds()),A:s.getHours()>=12?"PM":"AM"};return d.replace(/YYYY|YY|MMMM|MMM|MM|M|DD|D|dddd|ddd|HH|hh|mm|ss|A/g,r=>l[r])},Ge=(c,d,s=[])=>{if(!(d!=null&&d.trim()))return c;const i=d.toLowerCase(),l=r=>r==null?[]:typeof r=="object"?Object.values(r).flatMap(l):[String(r)];return c.filter(r=>{let n=[];return s.length>0?s.forEach(w=>{r[w]!==void 0&&n.push(...l(r[w]))}):n=l(r),n.some(w=>w.toLowerCase().includes(i))})},ue=h.forwardRef(({className:c="",variant:d="contained",color:s="default",size:i="default",fullWidth:l=!1,children:r,...n},w)=>{var b;const C="inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",x={sm:"h-8 px-3 rounded-md text-sm",md:"h-9 px-4 rounded-md text-sm",lg:"h-11 px-6 rounded-md text-base",xl:"h-12 px-8 rounded-lg text-lg",default:"h-9 px-4 rounded-md text-sm"},f={primary:{contained:"bg-blue-600 text-white hover:bg-blue-700 focus:ring-blue-500 shadow-sm",outlined:"border border-blue-600 bg-transparent text-blue-600 hover:bg-blue-50 focus:ring-blue-500",text:"bg-transparent text-blue-600 hover:bg-blue-50 focus:ring-blue-500"},success:{contained:"bg-green-600 text-white hover:bg-green-700 focus:ring-green-500 shadow-sm",outlined:"border border-green-600 bg-transparent text-green-600 hover:bg-green-50 focus:ring-green-500",text:"bg-transparent text-green-600 hover:bg-green-50 focus:ring-green-500"},error:{contained:"bg-red-600 text-white hover:bg-red-700 focus:ring-red-500 shadow-sm",outlined:"border border-red-600 bg-transparent text-red-600 hover:bg-red-50 focus:ring-red-500",text:"bg-transparent text-red-600 hover:bg-red-50 focus:ring-red-500"},default:{contained:"border bg-gray-200 text-gray-800 hover:bg-gray-300 focus:ring-gray-300 shadow-sm dark:border-gray-600 dark:bg-gray-700 dark:text-gray-100 dark:hover:bg-gray-600 dark:focus:ring-gray-600",outlined:"border border-gray-300 bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-300 dark:border-gray-600 dark:text-gray-200 dark:hover:bg-gray-700 dark:focus:ring-gray-500",text:"bg-transparent text-gray-700 hover:bg-gray-100 focus:ring-gray-300 dark:text-gray-200 dark:hover:bg-gray-700 dark:focus:ring-gray-500"}},u=((b=f[s])==null?void 0:b[d])||f.default.contained,g=x[i],j=`
|
|
23
|
+
${C}
|
|
27
24
|
${u}
|
|
28
|
-
${
|
|
29
|
-
${
|
|
30
|
-
${
|
|
31
|
-
`.trim();return e.jsx("button",{ref:
|
|
32
|
-
${
|
|
33
|
-
${
|
|
34
|
-
${
|
|
35
|
-
${y(N.value)?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":""}`,children:[e.jsx("span",{children:N.label}),u&&y(N.value)&&e.jsx(X.Check,{className:"w-4 h-4"})]},String(N.value))):e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No options found"})})]})]})]},w)},Or=({value:h=!0,onChange:c,text:o,options:i=[],label:d,required:t,name:n="",disabled:C=!1,parentClass:v=""})=>{const w=i.length>0?i:[{label:"Active",value:!0},{label:"Inactive",value:!1}];return e.jsx(e.Fragment,{children:e.jsxs("div",{className:v||"col-span-12",children:[e.jsx(be,{label:d,required:t}),e.jsxs("div",{className:"flex items-center justify-between h-10 gap-4 bg-gray-100 dark:bg-gray-700 px-3 rounded-md border border-gray-100 dark:border-gray-600",children:[o&&e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 flex-shrink overflow-hidden text-ellipsis whitespace-nowrap max-w-[200px]",children:o}),e.jsx("div",{className:"flex items-center gap-6",children:w.map((m,u)=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"switch-field",required:t&&u===0,value:m.value,disabled:C,checked:h===m.value,onChange:()=>c(m.value),className:"w-4 h-4 border-gray-300 cursor-pointer"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-white",children:m.label})]},u))})]})]},n)})},Oe=[{label:"Afghanistan",code:"AF",phone:"93"},{label:"Aland Islands",code:"AX",phone:"358"},{label:"Albania",code:"AL",phone:"355"},{label:"Algeria",code:"DZ",phone:"213"},{label:"American Samoa",code:"AS",phone:"1"},{label:"Andorra",code:"AD",phone:"376"},{label:"Angola",code:"AO",phone:"244"},{label:"Anguilla",code:"AI",phone:"1"},{label:"Antarctica",code:"AQ",phone:"672"},{label:"Antigua and Barbuda",code:"AG",phone:"1"},{label:"Argentina",code:"AR",phone:"54"},{label:"Armenia",code:"AM",phone:"374"},{label:"Aruba",code:"AW",phone:"297"},{label:"Australia",code:"AU",phone:"61"},{label:"Austria",code:"AT",phone:"43"},{label:"Azerbaijan",code:"AZ",phone:"994"},{label:"Bahrain",code:"BH",phone:"973"},{label:"Bangladesh",code:"BD",phone:"880"},{label:"Barbados",code:"BB",phone:"1"},{label:"Belarus",code:"BY",phone:"375"},{label:"Belgium",code:"BE",phone:"32"},{label:"Belize",code:"BZ",phone:"501"},{label:"Benin",code:"BJ",phone:"229"},{label:"Bermuda",code:"BM",phone:"1"},{label:"Bhutan",code:"BT",phone:"975"},{label:"Bolivia",code:"BO",phone:"591"},{label:"Bonaire, Sint Eustatius and Saba",code:"BQ",phone:"599"},{label:"Bosnia and Herzegovina",code:"BA",phone:"387"},{label:"Botswana",code:"BW",phone:"267"},{label:"Bouvet Island",code:"BV",phone:"0055"},{label:"Brazil",code:"BR",phone:"55"},{label:"British Indian Ocean Territory",code:"IO",phone:"246"},{label:"Brunei",code:"BN",phone:"673"},{label:"Bulgaria",code:"BG",phone:"359"},{label:"Burkina Faso",code:"BF",phone:"226"},{label:"Burundi",code:"BI",phone:"257"},{label:"Cambodia",code:"KH",phone:"855"},{label:"Cameroon",code:"CM",phone:"237"},{label:"Canada",code:"CA",phone:"1"},{label:"Cape Verde",code:"CV",phone:"238"},{label:"Cayman Islands",code:"KY",phone:"1"},{label:"Central African Republic",code:"CF",phone:"236"},{label:"Chad",code:"TD",phone:"235"},{label:"Chile",code:"CL",phone:"56"},{label:"China",code:"CN",phone:"86"},{label:"Christmas Island",code:"CX",phone:"61"},{label:"Cocos (Keeling) Islands",code:"CC",phone:"61"},{label:"Colombia",code:"CO",phone:"57"},{label:"Comoros",code:"KM",phone:"269"},{label:"Congo",code:"CG",phone:"242"},{label:"Cook Islands",code:"CK",phone:"682"},{label:"Costa Rica",code:"CR",phone:"506"},{label:"Croatia",code:"HR",phone:"385"},{label:"Cuba",code:"CU",phone:"53"},{label:"Curaçao",code:"CW",phone:"599"},{label:"Cyprus",code:"CY",phone:"357"},{label:"Czech Republic",code:"CZ",phone:"420"},{label:"Democratic Republic of the Congo",code:"CD",phone:"243"},{label:"Denmark",code:"DK",phone:"45"},{label:"Djibouti",code:"DJ",phone:"253"},{label:"Dominica",code:"DM",phone:"1"},{label:"Dominican Republic",code:"DO",phone:"1"},{label:"Ecuador",code:"EC",phone:"593"},{label:"Egypt",code:"EG",phone:"20"},{label:"El Salvador",code:"SV",phone:"503"},{label:"Equatorial Guinea",code:"GQ",phone:"240"},{label:"Eritrea",code:"ER",phone:"291"},{label:"Estonia",code:"EE",phone:"372"},{label:"Eswatini",code:"SZ",phone:"268"},{label:"Ethiopia",code:"ET",phone:"251"},{label:"Falkland Islands",code:"FK",phone:"500"},{label:"Faroe Islands",code:"FO",phone:"298"},{label:"Fiji Islands",code:"FJ",phone:"679"},{label:"Finland",code:"FI",phone:"358"},{label:"France",code:"FR",phone:"33"},{label:"French Guiana",code:"GF",phone:"594"},{label:"French Polynesia",code:"PF",phone:"689"},{label:"French Southern Territories",code:"TF",phone:"262"},{label:"Gabon",code:"GA",phone:"241"},{label:"Georgia",code:"GE",phone:"995"},{label:"Germany",code:"DE",phone:"49"},{label:"Ghana",code:"GH",phone:"233"},{label:"Gibraltar",code:"GI",phone:"350"},{label:"Greece",code:"GR",phone:"30"},{label:"Greenland",code:"GL",phone:"299"},{label:"Grenada",code:"GD",phone:"1"},{label:"Guadeloupe",code:"GP",phone:"590"},{label:"Guam",code:"GU",phone:"1"},{label:"Guatemala",code:"GT",phone:"502"},{label:"Guernsey",code:"GG",phone:"44"},{label:"Guinea",code:"GN",phone:"224"},{label:"Guinea-Bissau",code:"GW",phone:"245"},{label:"Guyana",code:"GY",phone:"592"},{label:"Haiti",code:"HT",phone:"509"},{label:"Heard Island and McDonald Islands",code:"HM",phone:"672"},{label:"Honduras",code:"HN",phone:"504"},{label:"Hong Kong S.A.R.",code:"HK",phone:"852"},{label:"Hungary",code:"HU",phone:"36"},{label:"Iceland",code:"IS",phone:"354"},{label:"India",code:"IN",phone:"91"},{label:"Indonesia",code:"ID",phone:"62"},{label:"Iran",code:"IR",phone:"98"},{label:"Iraq",code:"IQ",phone:"964"},{label:"Ireland",code:"IE",phone:"353"},{label:"Israel",code:"IL",phone:"972"},{label:"Italy",code:"IT",phone:"39"},{label:"Ivory Coast",code:"CI",phone:"225"},{label:"Jamaica",code:"JM",phone:"1"},{label:"Japan",code:"JP",phone:"81"},{label:"Jersey",code:"JE",phone:"44"},{label:"Jordan",code:"JO",phone:"962"},{label:"Kazakhstan",code:"KZ",phone:"7"},{label:"Kenya",code:"KE",phone:"254"},{label:"Kiribati",code:"KI",phone:"686"},{label:"Kosovo",code:"XK",phone:"383"},{label:"Kuwait",code:"KW",phone:"965"},{label:"Kyrgyzstan",code:"KG",phone:"996"},{label:"Laos",code:"LA",phone:"856"},{label:"Latvia",code:"LV",phone:"371"},{label:"Lebanon",code:"LB",phone:"961"},{label:"Lesotho",code:"LS",phone:"266"},{label:"Liberia",code:"LR",phone:"231"},{label:"Libya",code:"LY",phone:"218"},{label:"Liechtenstein",code:"LI",phone:"423"},{label:"Lithuania",code:"LT",phone:"370"},{label:"Luxembourg",code:"LU",phone:"352"},{label:"Macau S.A.R.",code:"MO",phone:"853"},{label:"Madagascar",code:"MG",phone:"261"},{label:"Malawi",code:"MW",phone:"265"},{label:"Malaysia",code:"MY",phone:"60"},{label:"Maldives",code:"MV",phone:"960"},{label:"Mali",code:"ML",phone:"223"},{label:"Malta",code:"MT",phone:"356"},{label:"Man (Isle of)",code:"IM",phone:"44"},{label:"Marshall Islands",code:"MH",phone:"692"},{label:"Martinique",code:"MQ",phone:"596"},{label:"Mauritania",code:"MR",phone:"222"},{label:"Mauritius",code:"MU",phone:"230"},{label:"Mayotte",code:"YT",phone:"262"},{label:"Mexico",code:"MX",phone:"52"},{label:"Micronesia",code:"FM",phone:"691"},{label:"Moldova",code:"MD",phone:"373"},{label:"Monaco",code:"MC",phone:"377"},{label:"Mongolia",code:"MN",phone:"976"},{label:"Montenegro",code:"ME",phone:"382"},{label:"Montserrat",code:"MS",phone:"1"},{label:"Morocco",code:"MA",phone:"212"},{label:"Mozambique",code:"MZ",phone:"258"},{label:"Myanmar",code:"MM",phone:"95"},{label:"Namibia",code:"NA",phone:"264"},{label:"Nauru",code:"NR",phone:"674"},{label:"Nepal",code:"NP",phone:"977"},{label:"Netherlands",code:"NL",phone:"31"},{label:"New Caledonia",code:"NC",phone:"687"},{label:"New Zealand",code:"NZ",phone:"64"},{label:"Nicaragua",code:"NI",phone:"505"},{label:"Niger",code:"NE",phone:"227"},{label:"Nigeria",code:"NG",phone:"234"},{label:"Niue",code:"NU",phone:"683"},{label:"Norfolk Island",code:"NF",phone:"672"},{label:"North Korea",code:"KP",phone:"850"},{label:"North Macedonia",code:"MK",phone:"389"},{label:"Northern Mariana Islands",code:"MP",phone:"1"},{label:"Norway",code:"NO",phone:"47"},{label:"Oman",code:"OM",phone:"968"},{label:"Pakistan",code:"PK",phone:"92"},{label:"Palau",code:"PW",phone:"680"},{label:"Palestinian Territory Occupied",code:"PS",phone:"970"},{label:"Panama",code:"PA",phone:"507"},{label:"Papua New Guinea",code:"PG",phone:"675"},{label:"Paraguay",code:"PY",phone:"595"},{label:"Peru",code:"PE",phone:"51"},{label:"Philippines",code:"PH",phone:"63"},{label:"Pitcairn Island",code:"PN",phone:"870"},{label:"Poland",code:"PL",phone:"48"},{label:"Portugal",code:"PT",phone:"351"},{label:"Puerto Rico",code:"PR",phone:"1"},{label:"Qatar",code:"QA",phone:"974"},{label:"Reunion",code:"RE",phone:"262"},{label:"Romania",code:"RO",phone:"40"},{label:"Russia",code:"RU",phone:"7"},{label:"Rwanda",code:"RW",phone:"250"},{label:"Saint Helena",code:"SH",phone:"290"},{label:"Saint Kitts and Nevis",code:"KN",phone:"1"},{label:"Saint Lucia",code:"LC",phone:"1"},{label:"Saint Pierre and Miquelon",code:"PM",phone:"508"},{label:"Saint Vincent and the Grenadines",code:"VC",phone:"1"},{label:"Saint-Barthelemy",code:"BL",phone:"590"},{label:"Saint-Martin (French part)",code:"MF",phone:"590"},{label:"Samoa",code:"WS",phone:"685"},{label:"San Marino",code:"SM",phone:"378"},{label:"Sao Tome and Principe",code:"ST",phone:"239"},{label:"Saudi Arabia",code:"SA",phone:"966"},{label:"Senegal",code:"SN",phone:"221"},{label:"Serbia",code:"RS",phone:"381"},{label:"Seychelles",code:"SC",phone:"248"},{label:"Sierra Leone",code:"SL",phone:"232"},{label:"Singapore",code:"SG",phone:"65"},{label:"Sint Maarten (Dutch part)",code:"SX",phone:"1721"},{label:"Slovakia",code:"SK",phone:"421"},{label:"Slovenia",code:"SI",phone:"386"},{label:"Solomon Islands",code:"SB",phone:"677"},{label:"Somalia",code:"SO",phone:"252"},{label:"South Africa",code:"ZA",phone:"27"},{label:"South Georgia",code:"GS",phone:"500"},{label:"South Korea",code:"KR",phone:"82"},{label:"South Sudan",code:"SS",phone:"211"},{label:"Spain",code:"ES",phone:"34"},{label:"Sri Lanka",code:"LK",phone:"94"},{label:"Sudan",code:"SD",phone:"249"},{label:"Suriname",code:"SR",phone:"597"},{label:"Svalbard and Jan Mayen Islands",code:"SJ",phone:"47"},{label:"Sweden",code:"SE",phone:"46"},{label:"Switzerland",code:"CH",phone:"41"},{label:"Syria",code:"SY",phone:"963"},{label:"Taiwan",code:"TW",phone:"886"},{label:"Tajikistan",code:"TJ",phone:"992"},{label:"Tanzania",code:"TZ",phone:"255"},{label:"Thailand",code:"TH",phone:"66"},{label:"The Bahamas",code:"BS",phone:"1"},{label:"The Gambia",code:"GM",phone:"220"},{label:"Timor-Leste",code:"TL",phone:"670"},{label:"Togo",code:"TG",phone:"228"},{label:"Tokelau",code:"TK",phone:"690"},{label:"Tonga",code:"TO",phone:"676"},{label:"Trinidad and Tobago",code:"TT",phone:"1"},{label:"Tunisia",code:"TN",phone:"216"},{label:"Turkey",code:"TR",phone:"90"},{label:"Turkmenistan",code:"TM",phone:"993"},{label:"Turks and Caicos Islands",code:"TC",phone:"1"},{label:"Tuvalu",code:"TV",phone:"688"},{label:"Uganda",code:"UG",phone:"256"},{label:"Ukraine",code:"UA",phone:"380"},{label:"United Arab Emirates",code:"AE",phone:"971"},{label:"United Kingdom",code:"GB",phone:"44"},{label:"United States",code:"US",phone:"1"},{label:"United States Minor Outlying Islands",code:"UM",phone:"1"},{label:"Uruguay",code:"UY",phone:"598"},{label:"Uzbekistan",code:"UZ",phone:"998"},{label:"Vanuatu",code:"VU",phone:"678"},{label:"Vatican City State (Holy See)",code:"VA",phone:"379"},{label:"Venezuela",code:"VE",phone:"58"},{label:"Vietnam",code:"VN",phone:"84"},{label:"Virgin Islands (British)",code:"VG",phone:"1"},{label:"Virgin Islands (US)",code:"VI",phone:"1"},{label:"Wallis and Futuna Islands",code:"WF",phone:"681"},{label:"Western Sahara",code:"EH",phone:"212"},{label:"Yemen",code:"YE",phone:"967"},{label:"Zambia",code:"ZM",phone:"260"},{label:"Zimbabwe",code:"ZW",phone:"263"}];function Fr({label:h="",value:c="",name:o="",parentClass:i="",onChange:d,disabled:t=!1,required:n=!1,placeholder:C="Phone number",search:v=!1,countriesList:w=!1,defaultCountry:m=""}){const u=y=>Oe.find(B=>B.code==y),[f,R]=g.useState(u(m)||Oe[0]),[p,T]=g.useState(""),[M,E]=g.useState(!1),[j,L]=g.useState(""),U=g.useRef();g.useEffect(()=>{if(typeof c=="string"&&c.startsWith("+")){const y=Oe.filter(B=>c.startsWith("+"+B.phone)).sort((B,G)=>G.phone.length-B.phone.length)[0];if(y){R(y),T(c.replace("+"+y.phone,""));return}}T(c)},[c]);const V=y=>{const B=y.target.value.replace(/\D/g,"");T(B),f&&d&&d("+"+f.phone+B)},Z=y=>{R(y),d&&d("+"+y.phone+p),E(!1),L("")};g.useEffect(()=>{const y=B=>{U.current&&!U.current.contains(B.target)&&E(!1)};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]);const $=Oe.filter(y=>y.label.toLowerCase().includes(j.toLowerCase())||y.phone.includes(j));if(!w){const y=B=>{const G=B.target.value.replace(/[^+\d]/g,""),_=G.startsWith("+")?"+"+G.replace(/[+]/g,"").slice(0):G;d(_)};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:i||"col-span-12",children:[e.jsx(be,{label:h,required:n}),e.jsx("input",{type:"text",value:c,onChange:y,placeholder:C,disabled:t,required:n,className:`w-full h-10 px-3 text-sm border border-gray-300 dark:border-gray-600 rounded-md \r
|
|
25
|
+
${g}
|
|
26
|
+
${l?"w-full":""}
|
|
27
|
+
${c}
|
|
28
|
+
`.trim();return e.jsx("button",{ref:w,type:n.type||"button",className:j,...n,children:r})});ue.displayName="Button";function ee({label:c,required:d=!1}){return e.jsx(e.Fragment,{children:e.jsxs("label",{className:"block text-sm font-medium text-gray-700 dark:text-gray-300 mb-1",children:[c,d&&e.jsx("span",{className:"ml-1",children:"*"})]})})}const Ye=({options:c=[],value:d,onChange:s,placeholder:i="Select option",className:l="",disabled:r=!1,search:n=!1,label:w="",required:C=!1,name:x="",parentClass:f="",multiple:u=!1,dropdownMaxHeight:g=""})=>{var R;const[j,b]=h.useState(!1),[N,k]=h.useState(""),[M,E]=h.useState(!0),P=h.useRef(null),B=h.useRef(null),Y=y=>String(typeof y=="boolean"?y:y??""),z=u?(d||[]).map(Y):Y(d),O=c.filter(y=>y.label.toLowerCase().includes(N.toLowerCase())),m=y=>{const A=Y(y);return u?z.includes(A):A===z};h.useEffect(()=>{const y=A=>{P.current&&!P.current.contains(A.target)&&(b(!1),k(""))};return document.addEventListener("mousedown",y),()=>document.removeEventListener("mousedown",y)},[]),h.useEffect(()=>{if(j&&P.current){const y=P.current.getBoundingClientRect(),q=window.innerHeight-y.bottom;E(q<200)}},[j]),h.useEffect(()=>{j&&B.current&&B.current.focus()},[j]);const _=y=>{let A=y;if(y==="true"?A=!0:y==="false"&&(A=!1),u){const q=z.includes(Y(y));let V;q?V=d.filter(X=>Y(X)!==Y(y)):V=[...d||[],A],s(V)}else s(A),b(!1);k("")},F=u?c.filter(y=>m(y.value)).map(y=>y.label).join(", "):(R=c.find(y=>m(y.value)))==null?void 0:R.label;return e.jsxs("div",{className:f||"col-span-12",children:[e.jsx(ee,{label:w,required:C}),e.jsxs("div",{className:`relative ${l}`,ref:P,children:[e.jsxs("button",{type:"button",onClick:()=>!r&&b(!j),disabled:r,className:`w-full h-10 px-3 border border-gray-300 dark:border-gray-600 rounded-md text-left text-sm flex items-center justify-between
|
|
29
|
+
${F?"dark:text-white":"text-gray-500 dark:text-gray-400"}
|
|
30
|
+
${r?"opacity-50 cursor-not-allowed":"dark:bg-gray-700"}`,children:[e.jsx("span",{className:"truncate",children:F||i}),e.jsx(H.ChevronDown,{className:`w-4 h-4 transition-transform ${j?"rotate-180":""}`})]}),j&&e.jsxs("div",{className:`absolute z-50 w-full border rounded-md bg-white dark:bg-gray-700 shadow-lg
|
|
31
|
+
${M?"bottom-full mb-1":"top-full mt-1"}`,children:[n&&e.jsx("div",{className:"p-2 border-b border-gray-200 dark:border-gray-600",children:e.jsxs("div",{className:"relative",children:[e.jsx(H.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{ref:B,type:"text",value:N,onChange:y=>k(y.target.value),placeholder:"Search...",className:"w-full pl-9 pr-3 py-2 text-sm border rounded-md bg-white dark:bg-gray-800 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none"})]})}),e.jsx("div",{className:"max-h-40 overflow-y-auto",style:{maxHeight:g||""},children:O.length>0?O.map(y=>e.jsxs("button",{type:"button",onClick:()=>_(String(y.value)),className:`w-full px-3 py-2 text-left text-sm flex items-center justify-between hover:bg-gray-100 dark:hover:bg-gray-600
|
|
32
|
+
${m(y.value)?"bg-blue-50 dark:bg-blue-900/20 text-blue-700 dark:text-blue-300":""}`,children:[e.jsx("span",{children:y.label}),u&&m(y.value)&&e.jsx(H.Check,{className:"w-4 h-4"})]},String(y.value))):e.jsx("div",{className:"px-3 py-2 text-sm text-gray-500 dark:text-gray-400",children:"No options found"})})]})]})]},x)},Ke=({value:c=!0,onChange:d,text:s,options:i=[],label:l,required:r,name:n="",disabled:w=!1,parentClass:C=""})=>{const x=i.length>0?i:[{label:"Active",value:!0},{label:"Inactive",value:!1}];return e.jsx(e.Fragment,{children:e.jsxs("div",{className:C||"col-span-12",children:[e.jsx(ee,{label:l,required:r}),e.jsxs("div",{className:"flex items-center justify-between h-10 gap-4 bg-gray-100 dark:bg-gray-700 px-3 rounded-md border border-gray-100 dark:border-gray-600",children:[s&&e.jsx("p",{className:"text-xs text-gray-600 dark:text-gray-400 flex-shrink overflow-hidden text-ellipsis whitespace-nowrap max-w-[200px]",children:s}),e.jsx("div",{className:"flex items-center gap-6",children:x.map((f,u)=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"radio",name:"switch-field",required:r&&u===0,value:f.value,disabled:w,checked:c===f.value,onChange:()=>d(f.value),className:"w-4 h-4 border-gray-300 cursor-pointer"}),e.jsx("span",{className:"text-sm text-gray-700 dark:text-white",children:f.label})]},u))})]})]},n)})},xe=[{label:"Afghanistan",code:"AF",phone:"93"},{label:"Aland Islands",code:"AX",phone:"358"},{label:"Albania",code:"AL",phone:"355"},{label:"Algeria",code:"DZ",phone:"213"},{label:"American Samoa",code:"AS",phone:"1"},{label:"Andorra",code:"AD",phone:"376"},{label:"Angola",code:"AO",phone:"244"},{label:"Anguilla",code:"AI",phone:"1"},{label:"Antarctica",code:"AQ",phone:"672"},{label:"Antigua and Barbuda",code:"AG",phone:"1"},{label:"Argentina",code:"AR",phone:"54"},{label:"Armenia",code:"AM",phone:"374"},{label:"Aruba",code:"AW",phone:"297"},{label:"Australia",code:"AU",phone:"61"},{label:"Austria",code:"AT",phone:"43"},{label:"Azerbaijan",code:"AZ",phone:"994"},{label:"Bahrain",code:"BH",phone:"973"},{label:"Bangladesh",code:"BD",phone:"880"},{label:"Barbados",code:"BB",phone:"1"},{label:"Belarus",code:"BY",phone:"375"},{label:"Belgium",code:"BE",phone:"32"},{label:"Belize",code:"BZ",phone:"501"},{label:"Benin",code:"BJ",phone:"229"},{label:"Bermuda",code:"BM",phone:"1"},{label:"Bhutan",code:"BT",phone:"975"},{label:"Bolivia",code:"BO",phone:"591"},{label:"Bonaire, Sint Eustatius and Saba",code:"BQ",phone:"599"},{label:"Bosnia and Herzegovina",code:"BA",phone:"387"},{label:"Botswana",code:"BW",phone:"267"},{label:"Bouvet Island",code:"BV",phone:"0055"},{label:"Brazil",code:"BR",phone:"55"},{label:"British Indian Ocean Territory",code:"IO",phone:"246"},{label:"Brunei",code:"BN",phone:"673"},{label:"Bulgaria",code:"BG",phone:"359"},{label:"Burkina Faso",code:"BF",phone:"226"},{label:"Burundi",code:"BI",phone:"257"},{label:"Cambodia",code:"KH",phone:"855"},{label:"Cameroon",code:"CM",phone:"237"},{label:"Canada",code:"CA",phone:"1"},{label:"Cape Verde",code:"CV",phone:"238"},{label:"Cayman Islands",code:"KY",phone:"1"},{label:"Central African Republic",code:"CF",phone:"236"},{label:"Chad",code:"TD",phone:"235"},{label:"Chile",code:"CL",phone:"56"},{label:"China",code:"CN",phone:"86"},{label:"Christmas Island",code:"CX",phone:"61"},{label:"Cocos (Keeling) Islands",code:"CC",phone:"61"},{label:"Colombia",code:"CO",phone:"57"},{label:"Comoros",code:"KM",phone:"269"},{label:"Congo",code:"CG",phone:"242"},{label:"Cook Islands",code:"CK",phone:"682"},{label:"Costa Rica",code:"CR",phone:"506"},{label:"Croatia",code:"HR",phone:"385"},{label:"Cuba",code:"CU",phone:"53"},{label:"Curaçao",code:"CW",phone:"599"},{label:"Cyprus",code:"CY",phone:"357"},{label:"Czech Republic",code:"CZ",phone:"420"},{label:"Democratic Republic of the Congo",code:"CD",phone:"243"},{label:"Denmark",code:"DK",phone:"45"},{label:"Djibouti",code:"DJ",phone:"253"},{label:"Dominica",code:"DM",phone:"1"},{label:"Dominican Republic",code:"DO",phone:"1"},{label:"Ecuador",code:"EC",phone:"593"},{label:"Egypt",code:"EG",phone:"20"},{label:"El Salvador",code:"SV",phone:"503"},{label:"Equatorial Guinea",code:"GQ",phone:"240"},{label:"Eritrea",code:"ER",phone:"291"},{label:"Estonia",code:"EE",phone:"372"},{label:"Eswatini",code:"SZ",phone:"268"},{label:"Ethiopia",code:"ET",phone:"251"},{label:"Falkland Islands",code:"FK",phone:"500"},{label:"Faroe Islands",code:"FO",phone:"298"},{label:"Fiji Islands",code:"FJ",phone:"679"},{label:"Finland",code:"FI",phone:"358"},{label:"France",code:"FR",phone:"33"},{label:"French Guiana",code:"GF",phone:"594"},{label:"French Polynesia",code:"PF",phone:"689"},{label:"French Southern Territories",code:"TF",phone:"262"},{label:"Gabon",code:"GA",phone:"241"},{label:"Georgia",code:"GE",phone:"995"},{label:"Germany",code:"DE",phone:"49"},{label:"Ghana",code:"GH",phone:"233"},{label:"Gibraltar",code:"GI",phone:"350"},{label:"Greece",code:"GR",phone:"30"},{label:"Greenland",code:"GL",phone:"299"},{label:"Grenada",code:"GD",phone:"1"},{label:"Guadeloupe",code:"GP",phone:"590"},{label:"Guam",code:"GU",phone:"1"},{label:"Guatemala",code:"GT",phone:"502"},{label:"Guernsey",code:"GG",phone:"44"},{label:"Guinea",code:"GN",phone:"224"},{label:"Guinea-Bissau",code:"GW",phone:"245"},{label:"Guyana",code:"GY",phone:"592"},{label:"Haiti",code:"HT",phone:"509"},{label:"Heard Island and McDonald Islands",code:"HM",phone:"672"},{label:"Honduras",code:"HN",phone:"504"},{label:"Hong Kong S.A.R.",code:"HK",phone:"852"},{label:"Hungary",code:"HU",phone:"36"},{label:"Iceland",code:"IS",phone:"354"},{label:"India",code:"IN",phone:"91"},{label:"Indonesia",code:"ID",phone:"62"},{label:"Iran",code:"IR",phone:"98"},{label:"Iraq",code:"IQ",phone:"964"},{label:"Ireland",code:"IE",phone:"353"},{label:"Israel",code:"IL",phone:"972"},{label:"Italy",code:"IT",phone:"39"},{label:"Ivory Coast",code:"CI",phone:"225"},{label:"Jamaica",code:"JM",phone:"1"},{label:"Japan",code:"JP",phone:"81"},{label:"Jersey",code:"JE",phone:"44"},{label:"Jordan",code:"JO",phone:"962"},{label:"Kazakhstan",code:"KZ",phone:"7"},{label:"Kenya",code:"KE",phone:"254"},{label:"Kiribati",code:"KI",phone:"686"},{label:"Kosovo",code:"XK",phone:"383"},{label:"Kuwait",code:"KW",phone:"965"},{label:"Kyrgyzstan",code:"KG",phone:"996"},{label:"Laos",code:"LA",phone:"856"},{label:"Latvia",code:"LV",phone:"371"},{label:"Lebanon",code:"LB",phone:"961"},{label:"Lesotho",code:"LS",phone:"266"},{label:"Liberia",code:"LR",phone:"231"},{label:"Libya",code:"LY",phone:"218"},{label:"Liechtenstein",code:"LI",phone:"423"},{label:"Lithuania",code:"LT",phone:"370"},{label:"Luxembourg",code:"LU",phone:"352"},{label:"Macau S.A.R.",code:"MO",phone:"853"},{label:"Madagascar",code:"MG",phone:"261"},{label:"Malawi",code:"MW",phone:"265"},{label:"Malaysia",code:"MY",phone:"60"},{label:"Maldives",code:"MV",phone:"960"},{label:"Mali",code:"ML",phone:"223"},{label:"Malta",code:"MT",phone:"356"},{label:"Man (Isle of)",code:"IM",phone:"44"},{label:"Marshall Islands",code:"MH",phone:"692"},{label:"Martinique",code:"MQ",phone:"596"},{label:"Mauritania",code:"MR",phone:"222"},{label:"Mauritius",code:"MU",phone:"230"},{label:"Mayotte",code:"YT",phone:"262"},{label:"Mexico",code:"MX",phone:"52"},{label:"Micronesia",code:"FM",phone:"691"},{label:"Moldova",code:"MD",phone:"373"},{label:"Monaco",code:"MC",phone:"377"},{label:"Mongolia",code:"MN",phone:"976"},{label:"Montenegro",code:"ME",phone:"382"},{label:"Montserrat",code:"MS",phone:"1"},{label:"Morocco",code:"MA",phone:"212"},{label:"Mozambique",code:"MZ",phone:"258"},{label:"Myanmar",code:"MM",phone:"95"},{label:"Namibia",code:"NA",phone:"264"},{label:"Nauru",code:"NR",phone:"674"},{label:"Nepal",code:"NP",phone:"977"},{label:"Netherlands",code:"NL",phone:"31"},{label:"New Caledonia",code:"NC",phone:"687"},{label:"New Zealand",code:"NZ",phone:"64"},{label:"Nicaragua",code:"NI",phone:"505"},{label:"Niger",code:"NE",phone:"227"},{label:"Nigeria",code:"NG",phone:"234"},{label:"Niue",code:"NU",phone:"683"},{label:"Norfolk Island",code:"NF",phone:"672"},{label:"North Korea",code:"KP",phone:"850"},{label:"North Macedonia",code:"MK",phone:"389"},{label:"Northern Mariana Islands",code:"MP",phone:"1"},{label:"Norway",code:"NO",phone:"47"},{label:"Oman",code:"OM",phone:"968"},{label:"Pakistan",code:"PK",phone:"92"},{label:"Palau",code:"PW",phone:"680"},{label:"Palestinian Territory Occupied",code:"PS",phone:"970"},{label:"Panama",code:"PA",phone:"507"},{label:"Papua New Guinea",code:"PG",phone:"675"},{label:"Paraguay",code:"PY",phone:"595"},{label:"Peru",code:"PE",phone:"51"},{label:"Philippines",code:"PH",phone:"63"},{label:"Pitcairn Island",code:"PN",phone:"870"},{label:"Poland",code:"PL",phone:"48"},{label:"Portugal",code:"PT",phone:"351"},{label:"Puerto Rico",code:"PR",phone:"1"},{label:"Qatar",code:"QA",phone:"974"},{label:"Reunion",code:"RE",phone:"262"},{label:"Romania",code:"RO",phone:"40"},{label:"Russia",code:"RU",phone:"7"},{label:"Rwanda",code:"RW",phone:"250"},{label:"Saint Helena",code:"SH",phone:"290"},{label:"Saint Kitts and Nevis",code:"KN",phone:"1"},{label:"Saint Lucia",code:"LC",phone:"1"},{label:"Saint Pierre and Miquelon",code:"PM",phone:"508"},{label:"Saint Vincent and the Grenadines",code:"VC",phone:"1"},{label:"Saint-Barthelemy",code:"BL",phone:"590"},{label:"Saint-Martin (French part)",code:"MF",phone:"590"},{label:"Samoa",code:"WS",phone:"685"},{label:"San Marino",code:"SM",phone:"378"},{label:"Sao Tome and Principe",code:"ST",phone:"239"},{label:"Saudi Arabia",code:"SA",phone:"966"},{label:"Senegal",code:"SN",phone:"221"},{label:"Serbia",code:"RS",phone:"381"},{label:"Seychelles",code:"SC",phone:"248"},{label:"Sierra Leone",code:"SL",phone:"232"},{label:"Singapore",code:"SG",phone:"65"},{label:"Sint Maarten (Dutch part)",code:"SX",phone:"1721"},{label:"Slovakia",code:"SK",phone:"421"},{label:"Slovenia",code:"SI",phone:"386"},{label:"Solomon Islands",code:"SB",phone:"677"},{label:"Somalia",code:"SO",phone:"252"},{label:"South Africa",code:"ZA",phone:"27"},{label:"South Georgia",code:"GS",phone:"500"},{label:"South Korea",code:"KR",phone:"82"},{label:"South Sudan",code:"SS",phone:"211"},{label:"Spain",code:"ES",phone:"34"},{label:"Sri Lanka",code:"LK",phone:"94"},{label:"Sudan",code:"SD",phone:"249"},{label:"Suriname",code:"SR",phone:"597"},{label:"Svalbard and Jan Mayen Islands",code:"SJ",phone:"47"},{label:"Sweden",code:"SE",phone:"46"},{label:"Switzerland",code:"CH",phone:"41"},{label:"Syria",code:"SY",phone:"963"},{label:"Taiwan",code:"TW",phone:"886"},{label:"Tajikistan",code:"TJ",phone:"992"},{label:"Tanzania",code:"TZ",phone:"255"},{label:"Thailand",code:"TH",phone:"66"},{label:"The Bahamas",code:"BS",phone:"1"},{label:"The Gambia",code:"GM",phone:"220"},{label:"Timor-Leste",code:"TL",phone:"670"},{label:"Togo",code:"TG",phone:"228"},{label:"Tokelau",code:"TK",phone:"690"},{label:"Tonga",code:"TO",phone:"676"},{label:"Trinidad and Tobago",code:"TT",phone:"1"},{label:"Tunisia",code:"TN",phone:"216"},{label:"Turkey",code:"TR",phone:"90"},{label:"Turkmenistan",code:"TM",phone:"993"},{label:"Turks and Caicos Islands",code:"TC",phone:"1"},{label:"Tuvalu",code:"TV",phone:"688"},{label:"Uganda",code:"UG",phone:"256"},{label:"Ukraine",code:"UA",phone:"380"},{label:"United Arab Emirates",code:"AE",phone:"971"},{label:"United Kingdom",code:"GB",phone:"44"},{label:"United States",code:"US",phone:"1"},{label:"United States Minor Outlying Islands",code:"UM",phone:"1"},{label:"Uruguay",code:"UY",phone:"598"},{label:"Uzbekistan",code:"UZ",phone:"998"},{label:"Vanuatu",code:"VU",phone:"678"},{label:"Vatican City State (Holy See)",code:"VA",phone:"379"},{label:"Venezuela",code:"VE",phone:"58"},{label:"Vietnam",code:"VN",phone:"84"},{label:"Virgin Islands (British)",code:"VG",phone:"1"},{label:"Virgin Islands (US)",code:"VI",phone:"1"},{label:"Wallis and Futuna Islands",code:"WF",phone:"681"},{label:"Western Sahara",code:"EH",phone:"212"},{label:"Yemen",code:"YE",phone:"967"},{label:"Zambia",code:"ZM",phone:"260"},{label:"Zimbabwe",code:"ZW",phone:"263"}];function ze({label:c="",value:d="",name:s="",parentClass:i="",onChange:l,disabled:r=!1,required:n=!1,placeholder:w="Phone number",search:C=!1,countriesList:x=!1,defaultCountry:f=""}){const u=m=>xe.find(_=>_.code==m),[g,j]=h.useState(u(f)||xe[0]),[b,N]=h.useState(""),[k,M]=h.useState(!1),[E,P]=h.useState(""),B=h.useRef();h.useEffect(()=>{if(typeof d=="string"&&d.startsWith("+")){const m=xe.filter(_=>d.startsWith("+"+_.phone)).sort((_,F)=>F.phone.length-_.phone.length)[0];if(m){j(m),N(d.replace("+"+m.phone,""));return}}N(d)},[d]);const Y=m=>{const _=m.target.value.replace(/\D/g,"");N(_),g&&l&&l("+"+g.phone+_)},z=m=>{j(m),l&&l("+"+m.phone+b),M(!1),P("")};h.useEffect(()=>{const m=_=>{B.current&&!B.current.contains(_.target)&&M(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[]);const O=xe.filter(m=>m.label.toLowerCase().includes(E.toLowerCase())||m.phone.includes(E));if(!x){const m=_=>{const F=_.target.value.replace(/[^+\d]/g,""),R=F.startsWith("+")?"+"+F.replace(/[+]/g,"").slice(0):F;l(R)};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:i||"col-span-12",children:[e.jsx(ee,{label:c,required:n}),e.jsx("input",{type:"text",value:d,onChange:m,placeholder:w,disabled:r,required:n,className:`w-full h-10 px-3 text-sm border border-gray-300 dark:border-gray-600 rounded-md \r
|
|
36
33
|
bg-white dark:bg-gray-700 text-gray-900 dark:text-gray-100 focus:outline-none \r
|
|
37
|
-
focus:ring-1 focus:ring-blue-300 dark:focus:ring-blue-200`,inputMode:"tel",pattern:"^\\+\\d{1,15}$"})]},
|
|
38
|
-
${
|
|
39
|
-
${
|
|
34
|
+
focus:ring-1 focus:ring-blue-300 dark:focus:ring-blue-200`,inputMode:"tel",pattern:"^\\+\\d{1,15}$"})]},s)})}return e.jsx(e.Fragment,{children:e.jsxs("div",{className:i||"col-span-12",children:[e.jsx(ee,{label:c,required:n}),e.jsxs("div",{className:"relative ",ref:B,children:[e.jsxs("div",{className:`h-[40px] flex items-center border rounded-md px-2 bg-white dark:bg-gray-700 transition-all
|
|
35
|
+
${k?"ring-0.5 ring-blue-100 border-blue-300":"border-gray-300 dark:border-gray-600"}
|
|
36
|
+
${r?"opacity-60 cursor-not-allowed":""}`,children:[e.jsxs("button",{type:"button",disabled:r,onClick:()=>M(!k),className:"flex items-center gap-1 pr-2 border-r border-gray-300 dark:border-gray-700 focus:outline-none",children:[g?e.jsx("img",{src:`https://flagcdn.com/w20/${g.code.toLowerCase()}.png`,alt:g.code,className:"w-5 h-3 object-cover"}):e.jsx("span",{className:"text-gray-400 text-xs",children:"🌐"}),e.jsx(H.ChevronDown,{className:"w-3 h-3 text-gray-500"})]}),g&&e.jsxs("span",{className:"ml-2 text-sm text-gray-700 dark:text-gray-200 whitespace-nowrap",children:["+",g.phone]}),e.jsx("input",{type:"tel",value:b,onChange:Y,required:n,disabled:r||!g,placeholder:g?w:"Select a country",className:"flex-1 ml-2 bg-transparent outline-none text-sm text-gray-800 dark:text-gray-100 placeholder-gray-400"}),e.jsx("input",{type:"tel",required:n,tabIndex:-1,readOnly:!0,value:g&&b?"+"+g.phone+b:"",style:{position:"absolute",opacity:0,pointerEvents:"none",height:0}})]}),k&&e.jsxs("div",{className:"absolute top-full left-0 w-full mt-1 border border-gray-300 dark:border-gray-700 rounded-md bg-white dark:bg-gray-700 shadow-lg z-50 max-h-60 overflow-y-auto",children:[C&&e.jsx("div",{className:"p-2 border-b border-gray-200 dark:border-gray-700",children:e.jsxs("div",{className:"relative",children:[e.jsx(H.Search,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:E,onChange:m=>P(m.target.value),placeholder:"Search country...",className:"w-full pl-9 pr-3 py-2 text-sm border rounded-md bg-white dark:bg-gray-800 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none "})]})}),O.map(m=>e.jsxs("button",{type:"button",onClick:()=>z(m),className:"w-full flex items-center gap-2 px-2 py-1 text-sm hover:bg-blue-50 dark:hover:bg-gray-700 text-gray-800 dark:text-gray-100",children:[e.jsx("img",{src:`https://flagcdn.com/w20/${m.code.toLowerCase()}.png`,alt:m.code,className:"w-5 h-3 object-cover"}),e.jsxs("span",{children:[m.label," (+",m.phone,")"]})]},m.code))]})]})]},s)})}const _e=h.forwardRef(({className:c="",label:d,required:s,...i},l)=>{const r=`
|
|
40
37
|
placeholder-gray-400 dark:placeholder-gray-400
|
|
41
|
-
${
|
|
42
|
-
`.trim();return e.jsx(e.Fragment,{children:e.jsxs("div",{className:i.parentClass||"col-span-12",children:[e.jsx(
|
|
38
|
+
${c}
|
|
39
|
+
`.trim();return e.jsx(e.Fragment,{children:e.jsxs("div",{className:i.parentClass||"col-span-12",children:[e.jsx(ee,{label:d,required:s}),e.jsx("div",{className:"relative",children:e.jsx("textarea",{className:r,ref:l,required:s,...i})})]},i.name)})});_e.displayName="TextArea";const Ue=({label:c="",value:d=null,onChange:s,required:i=!1,accept:l="image/*",id:r,dragDrop:n=!1,name:w="",parentClass:C=""})=>{const[x,f]=h.useState(d),[u,g]=h.useState(!1),j=h.useRef(null);h.useEffect(()=>{f(d)},[d]);const b=E=>{if(!E||E.length===0){f(null),s==null||s(null);return}const P=E[0],B=URL.createObjectURL(P);f({file:P,preview:B}),s==null||s(B)},N=E=>{n&&(E.preventDefault(),g(!0))},k=E=>{n&&(E.preventDefault(),g(!1))},M=E=>{n&&(E.preventDefault(),g(!1),b(E.dataTransfer.files))};return e.jsx(e.Fragment,{children:e.jsxs("div",{className:C||"col-span-12",children:[e.jsx(ee,{label:c,required:i}),e.jsxs("div",{className:`relative rounded-md p-2 transition-all ${u?"border border-dashed border-blue-500 bg-blue-50 dark:bg-blue-900":"border bg-gray-50 dark:bg-gray-700"}`,onDragOver:N,onDragLeave:k,onDrop:M,children:[e.jsxs("div",{className:`flex items-center space-x-3 transition-all ${u?"filter blur-sm":""}`,children:[e.jsx("div",{className:"cursor-pointer",onClick:()=>j.current.click(),children:x?e.jsx("img",{src:x.preview||x,alt:"preview",className:"object-cover w-20 h-20 rounded-full"}):e.jsx(e.Fragment,{children:e.jsx("div",{className:"rounded-full bg-gray-200 dark:bg-gray-800 h-20 w-20 flex items-center justify-center",children:e.jsx(we.Icon,{icon:"ri:image-add-fill",className:"text-gray-400 w-10 h-10"})})})}),e.jsx("input",{ref:j,id:r,type:"file",accept:l,onChange:E=>b(E.target.files),required:i&&!x,className:"inline-flex items-center justify-center p-2 text-gray-400 text-sm file:cursor-pointer"})]}),n&&u&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:e.jsx("span",{className:"text-blue-500 font-semibold text-xl",children:"Drop here"})})]})]},w)})},Ae=h.forwardRef(({label:c,required:d,parentClass:s="",className:i="",type:l="text",onKeyDown:r,...n},w)=>{const[C,x]=h.useState(!1),f=g=>{l==="number"&&["e","E"].includes(g.key)&&g.preventDefault(),r==null||r(g)},u=`
|
|
43
40
|
h-10 placeholder-gray-400 dark:placeholder-gray-400
|
|
44
|
-
${
|
|
41
|
+
${l==="password"?"pr-10":""}
|
|
45
42
|
${i}
|
|
46
|
-
`.trim();return e.jsx(e.Fragment,{children:e.jsxs("div",{className:
|
|
43
|
+
`.trim();return e.jsx(e.Fragment,{children:e.jsxs("div",{className:s||"col-span-12",children:[e.jsx(ee,{label:c,required:d}),e.jsxs("div",{className:"relative",children:[e.jsx("input",{type:l==="password"&&C?"text":l,ref:w,required:d,onKeyDown:f,className:u,...n}),l==="password"&&e.jsx("button",{type:"button",tabIndex:-1,onClick:()=>x(g=>!g),className:"absolute inset-y-0 right-3 flex items-center text-gray-400 hover:text-gray-600 dark:text-gray-400 dark:hover:text-gray-200",children:e.jsx(we.Icon,{icon:C?"mdi:eye-off-outline":"mdi:eye-outline",className:"w-5 h-5"})})]})]},n.name)})});Ae.displayName="Input";const He=({key:c,editorKey:d="",value:s="",onChange:i,label:l="",required:r=!1,placeholder:n="",parentClass:w="col-span-12",height:C=400,inline:x=!1,disabled:f=!1,plugins:u,toolbar:g,menubar:j=!1,fontFamily:b="Inter, sans-serif",initConfig:N={},imageUploadHandler:k})=>{const M=["advlist","autolink","lists","link","image","charmap","preview","anchor","searchreplace","visualblocks","code","fullscreen","insertdatetime","media","table","help","wordcount"],E="undo redo | blocks | bold italic underline forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image media table | removeformat | code fullscreen preview",P=B=>new Promise((Y,z)=>{if(!k){Y(`data:${B.blob().type};base64,${B.base64()}`);return}k(B).then(O=>{O?Y(O):z("Upload failed: No URL returned")}).catch(O=>{z(typeof O=="string"?O:(O==null?void 0:O.message)||"Image upload failed")})});return e.jsxs("div",{className:w,children:[l&&e.jsx(ee,{label:l,required:r}),e.jsx(Le.Editor,{apiKey:d,value:s,disabled:f,init:{height:C,inline:x,menubar:j,branding:!1,statusbar:!0,automatic_uploads:!0,images_upload_handler:P,plugins:u??M,toolbar:g??E,placeholder:n,content_style:`
|
|
47
44
|
body {
|
|
48
|
-
font-family: ${
|
|
45
|
+
font-family: ${b};
|
|
49
46
|
}
|
|
50
|
-
`,...
|
|
47
|
+
`,...N},onEditorChange:B=>{i&&i(B)}})]},c)},qe=({name:c="",label:d="",options:s=[],value:i=null,onChange:l,disabled:r=!1,required:n=!1,parentClass:w="col-span-12",className:C="",multiSelect:x=!1})=>{const f=Array.isArray(s)&&s.length>0,u=b=>f?x?Array.isArray(i)&&i.includes(b):i===b:!!i,g=b=>{l==null||l(b.target.checked,c)},j=(b,N)=>{if(l)if(!x)l(N?b:"",c);else{const k=Array.isArray(i)?[...i]:[];if(N)k.includes(b)||k.push(b);else{const M=k.indexOf(b);M>-1&&k.splice(M,1)}l(k,c)}};return f?e.jsx(e.Fragment,{children:e.jsxs("div",{className:`${w}`,children:[e.jsx(ee,{label:d,required:n}),e.jsx("div",{className:"flex flex-col space-y-2",children:s.map((b,N)=>e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",name:c,value:b.value,checked:u(b.value),disabled:r||b.disabled,required:n&&N===0,onChange:k=>j(b.value,k.target.checked),className:`h-4 w-4 cursor-pointer text-blue-600 border-gray-300 rounded focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 ${C}`},c),b.label&&e.jsx("label",{htmlFor:c,className:"ml-2 text-sm text-gray-700 dark:text-gray-200 select-none",children:b.label})]},b.value||b.label))})]})}):e.jsxs("div",{className:`flex items-center ${w}`,children:[e.jsx("input",{type:"checkbox",name:c,checked:u(),disabled:r,required:n,onChange:g,className:`h-4 w-4 text-blue-600 cursor-pointer border-gray-300 rounded focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400 ${C}`}),d&&e.jsx("label",{htmlFor:c,className:"ml-2 text-sm text-gray-700 dark:text-gray-200 select-none",children:d})]})},Pe=({field:c,formData:d,handleChange:s})=>{const{key:i,label:l,type:r,options:n,placeholder:w,rows:C,inputClass:x,search:f,accept:u,text:g,required:j=!1,minLength:b,dragDrop:N,parentClass:k,countriesList:M,defaultCountry:E,multiple:P,dropdownMaxHeight:B,editorKey:Y,fontFamily:z,disabled:O}=c;let m=d==null?void 0:d[i];m==null&&(m="");const _=w||(r==="select"?`Select ${l}`:`Enter ${l}`),F="w-full px-3 py-2 rounded-md border border-gray-300 dark:border-gray-600 text-sm focus:outline-none focus:ring-1 focus:ring-blue-200 bg-white text-black dark:bg-gray-700 dark:text-white";switch(r){case"select":return e.jsx(Ye,{options:n||[],value:m,onChange:R=>s(i,R),placeholder:_,className:x||"",search:f,required:j,label:l,name:i,disabled:O,parentClass:k,multiple:P,dropdownMaxHeight:B});case"checkbox":return e.jsx(qe,{name:i,label:l,options:n||[],value:m,onChange:R=>s(i,R),required:j,parentClass:k,className:x||"",multiSelect:P,disabled:O});case"switch":return e.jsx(Ke,{value:m,onChange:R=>s(i,R),text:g,options:n||[],label:l,required:j,name:i,disabled:O,parentClass:k});case"phone":return e.jsx(ze,{value:m,onChange:R=>s(i,R),countriesList:M,defaultCountry:E,required:j,placeholder:_,search:f,label:l,name:i,disabled:O,parentClass:k});case"textarea":return e.jsx(_e,{value:m,onChange:R=>s(i,R.target.value),placeholder:_,rows:C||3,className:`${F} ${x||""}`,required:j,name:i,label:l,disabled:O,parentClass:k});case"image":return e.jsx(Ue,{value:m,onChange:R=>s(i,R),required:j,accept:u||"image/*",id:`file-${i}`,dragDrop:N,label:l,name:i,parentClass:k});case"tinyEditor":return e.jsx(He,{value:m,onChange:R=>s(i,R),required:j,placeholder:_,label:l,parentClass:k,fontFamily:z,editorKey:Y,disabled:O},`editor-${i}`);default:return e.jsx(Ae,{type:r||"text",value:m,onChange:R=>s(i,R.target.value),placeholder:_,className:`${F} ${x||""}`,required:j,name:i,minLength:b,label:l,parentClass:k,disabled:O})}},Ve=({isOpen:c,onClose:d,config:s,onApply:i})=>{var x;const[l,r]=h.useState({}),n=(f,u)=>{r(g=>({...g,[f]:u}))},w=()=>{i==null||i(l),d()},C=()=>{r({}),i==null||i({}),d()};return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:`fixed inset-0 bg-black/50 z-40 transition-opacity duration-300 ${c?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none"}`,onClick:d}),e.jsxs("div",{className:`fixed top-0 right-0 h-full w-[28rem] bg-white dark:bg-gray-900 shadow-2xl z-50 flex flex-col border-l border-gray-200 dark:border-gray-700
|
|
51
48
|
transform transition-transform duration-300 ease-in-out
|
|
52
|
-
${
|
|
53
|
-
`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Filters"}),e.jsx("button",{onClick:
|
|
49
|
+
${c?"translate-x-0":"translate-x-full"}
|
|
50
|
+
`,children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-gray-200 dark:border-gray-700",children:[e.jsx("h2",{className:"text-lg font-semibold text-gray-900 dark:text-white",children:"Filters"}),e.jsx("button",{onClick:d,className:"p-2 hover:bg-gray-100 dark:hover:bg-gray-800 rounded-md transition",children:e.jsx(H.X,{className:"w-5 h-5 text-gray-500 dark:text-gray-400"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-4 py-3",children:s!=null&&s.component?e.jsx(s.component,{filters:l,onFilterChange:n}):e.jsx("div",{className:"space-y-4",children:(x=s==null?void 0:s.fields)==null?void 0:x.map(f=>e.jsx(e.Fragment,{children:e.jsx(Pe,{field:f,formData:l,handleChange:n},f.key)}))})}),e.jsxs("div",{className:"flex gap-2 px-4 py-3 border-t border-gray-200 dark:border-gray-700",children:[e.jsx(ue,{onClick:w,variant:"contained",color:"primary",fullWidth:!0,children:"Apply Filters"}),e.jsx(ue,{onClick:C,variant:"contained",className:"min-w-[150px]",children:"Reset"})]})]})]})},Ce={blue:{bg:"bg-blue-100 text-blue-800 dark:bg-blue-900/30 dark:text-blue-300",border:"border border-blue-300 text-blue-700 dark:border-blue-700 dark:text-blue-300"},teal:{bg:"bg-teal-100 text-teal-800 dark:bg-teal-900/30 dark:text-teal-300",border:"border border-teal-300 text-teal-700 dark:border-teal-700 dark:text-teal-300"},purple:{bg:"bg-purple-100 text-purple-800 dark:bg-purple-900/30 dark:text-purple-300",border:"border border-purple-300 text-purple-700 dark:border-purple-700 dark:text-purple-300"},yellow:{bg:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900/30 dark:text-yellow-300",border:"border border-yellow-300 text-yellow-700 dark:border-yellow-700 dark:text-yellow-300"},green:{bg:"bg-green-100 text-green-800 dark:bg-green-900/30 dark:text-green-300",border:"border border-green-300 text-green-700 dark:border-green-700 dark:text-green-300"},red:{bg:"bg-red-100 text-red-800 dark:bg-red-900/30 dark:text-red-300",border:"border border-red-300 text-red-700 dark:border-red-700 dark:text-red-300"},gray:{bg:"bg-gray-100 text-gray-800 dark:bg-gray-900/30 dark:text-gray-300",border:"border border-gray-300 text-gray-700 dark:border-gray-700 dark:text-gray-300"}},Re={contained:"bg",outline:"border !bg-transparent",soft:"bg opacity-90"},Oe=({label:c,variant:d="contained",color:s="green",className:i=""})=>{const l=Ce[s]||Ce.green,r=Re[d]||Re.contained,n=d==="outline"?l.border:l.bg;return e.jsx("span",{className:`inline-flex justify-center items-center rounded-sm text-xs font-semibold px-3 py-1 min-w-[78px]
|
|
54
51
|
${n}
|
|
55
|
-
${
|
|
56
|
-
${i}`,children:
|
|
57
|
-
backdrop-blur-sm animate-in fade-in duration-200`,onClick:
|
|
58
|
-
hover:bg-gray-100 dark:hover:bg-gray-700 rounded-full p-2 shadow-lg transition`,children:e.jsx(X.X,{size:20})}),e.jsx("div",{className:"max-w-5xl w-full px-4 transform transition-all duration-200 scale-95 animate-in zoom-in-95",onClick:t=>t.stopPropagation(),children:e.jsx("img",{src:h,alt:c,className:"w-full max-h-[90vh] object-contain rounded-xl"})})]})})},$r=({config:h})=>{const{data:c=[],table_head:o=[],loading:i=!1,search:d={enabled:!1,placeholder:"Search...",useServerSideSearch:!1},filter:t={enabled:!1,useServerSideFilters:!1},pagination:n={enabled:!1,rows_per_page:10,useServerSidePagination:!1},emptyMessage:C="No data available",onMenuAction:v,setServerSidePaginationData:w=()=>{},onFilterApply:m,filterConfig:u=null}=h,[f,R]=g.useState(""),[p,T]=g.useState(null),[M,E]=g.useState([]),[j,L]=g.useState({}),[U,V]=g.useState(!1),[Z,$]=g.useState(null),[y,B]=g.useState(!1),G=g.useMemo(()=>!d.enabled||!f.trim()||d.useServerSideSearch?c:_r(c,f,d.searchKeys||[]),[c,f,d]),[_,N]=g.useState(1),[O,W]=g.useState((n==null?void 0:n.rows_per_page)||50),[ee,se]=g.useState(G.length||0),ge=n!=null&&n.useServerSidePagination?n.total_pages:Math.ceil(G.length/O),ye=g.useMemo(()=>{if(n.useServerSidePagination)return G;const l=(_-1)*O;return G.slice(l,l+O)},[G,_,O]),pe=g.useRef(null),ve=g.useRef({}),fe=g.useRef(null),oe=l=>{R(l),N(1),d.useServerSideSearch&&(fe.current&&clearTimeout(fe.current),fe.current=setTimeout(async()=>{try{await w(x=>({...x,search:l,current_page:1}))}catch(x){console.error("Search error:",x)}},800))},ke=(l,x,A)=>{A.stopPropagation(),T(null),v==null||v(l.type,x)},Ee=(l,x,A)=>{x.stopPropagation(),E(A);const H=x.currentTarget;ve.current[l]=H;const z=H.getBoundingClientRect(),te=192,Q=A.length*40,ue=window.innerWidth,je=window.innerHeight,F=ue-z.right<te?z.left-te+z.width:z.left,le=je-z.bottom<Q&&z.top>Q?z.top-Q-2:z.bottom+2;L({top:Math.max(8,Math.min(le,je-Q-8)),left:Math.max(8,Math.min(F,ue-te-8))}),T(p===l?null:l)},Me=l=>(_-1)*O+l+1,me=l=>{$(l),B(!0)},ie=(l,x,A,H=null)=>e.jsx(e.Fragment,{children:l?e.jsx("img",{src:l,alt:x||"Avatar",onClick:z=>{z.stopPropagation(),z.preventDefault(),me({src:l,alt:x})},className:`w-10 h-10 cursor-pointer rounded-full object-cover border border-gray-200 dark:border-gray-700 ${A||""}`}):e.jsx(e.Fragment,{children:H||e.jsx("div",{className:`w-10 h-10 flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-700 bg-gray-200 dark:bg-gray-600 ${A||""}`,children:e.jsx(X.User,{className:"w-6 h-6 text-gray-400 dark:text-gray-400"})})})}),de=(l,x)=>e.jsxs("div",{className:`flex items-center space-x-4 ${x.className||""}`,children:[x.imageKey?ie(l[x.imageKey],l[x.titleKey],"group-avatar"):"",e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white group-title",children:l[x.titleKey]||""}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 group-sub-title",children:l[x.subtitleKey]||""})]})]}),xe=(l,x)=>{var te;let A=String(l);const H=x.variant||"contained";let z=x.defaultColor;if(((te=x==null?void 0:x.chipOptions)==null?void 0:te.length)>0){let Q=x==null?void 0:x.chipOptions.find(ue=>ue.value==l);Q&&(A=Q.label,z=Q.color)}return e.jsx(ir,{label:A,variant:H,color:z,className:x.className||""})},ce=(l,x,A)=>{const H=x[l.key];return l.type==="menu_actions"?e.jsx("div",{className:`text-center ${l.className||""}`,children:e.jsx("button",{ref:z=>ve.current[x.id]=z,onClick:z=>Ee(x.id,z,l.menuList),className:"p-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-full transition text-gray-700 dark:text-gray-300",children:e.jsx(X.EllipsisVertical,{className:"h-4 w-4"})})}):l.type==="index"?e.jsx("span",{className:l.className||"",children:Me(A)}):l.type==="group"?de(x,l):l.type==="chip"?e.jsx(e.Fragment,{children:xe(H,l)}):l.type==="date"?e.jsx("span",{className:l.className||"",children:nr(H,l.format||"DD MMM YYYY")}):l.type==="avatar"?e.jsx(e.Fragment,{children:ie(H,l.alt,l.className,l.fallback_icon)}):e.jsx("span",{className:l.className||"",children:H||"N/A"})},Se=(l,x)=>{if(l.onClickDetails)return v==null?void 0:v("view",x);if(typeof l.handleClick=="function")return l.handleClick(x)},we=l=>l.onClickDetails||typeof l.handleClick=="function";return g.useEffect(()=>{const l=()=>{p&&T(null)};return window.addEventListener("scroll",l,!0),()=>{window.removeEventListener("scroll",l,!0)}},[p]),g.useEffect(()=>{const l=x=>{pe.current&&!pe.current.contains(x.target)&&T(null)};return document.addEventListener("click",l),()=>document.removeEventListener("click",l)},[]),g.useEffect(()=>{n!=null&&n.rows_per_page&&(n!=null&&n.useServerSidePagination)&&W((n==null?void 0:n.rows_per_page)||50),n.current_page&&N(n.current_page)},[n.rows_per_page,n==null?void 0:n.useServerSidePagination,n.current_page]),g.useEffect(()=>{se(n!=null&&n.useServerSidePagination?n.total_records:G.length),G.length<=O*(_-1)&&!(n!=null&&n.useServerSidePagination)&&N(l=>l-1||1)},[G.length,n.total_records,n==null?void 0:n.useServerSidePagination]),i?e.jsx(Br,{rows:6,columns:6}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-end items-center mb-6 gap-2",children:[d.enabled&&e.jsx("div",{className:"",children:e.jsxs("div",{className:"relative min-w-[300px]",children:[e.jsx(X.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-300"}),e.jsx("input",{type:"text",placeholder:d.placeholder||"Search...",value:f,onChange:l=>oe(l.target.value),className:"w-full h-[36px] pl-9 pr-4 py-3 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-300 dark:ring-blue-200 disabled:opacity-50"})]})}),u&&t.enabled&&e.jsxs(Re,{onClick:()=>V(!0),variant:"contained",children:[e.jsx(X.Filter,{className:"w-4 h-4 mr-2"}),"Filters"]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700/60",children:e.jsx("tr",{children:o.map(l=>e.jsx("th",{className:"px-6 py-4 text-left text-xs font-medium text-black dark:text-white uppercase tracking-wider min-w-max max-w-[180px] truncate",children:l.title},l.key))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:ye.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:o.length,className:"text-center py-10 text-gray-500 dark:text-gray-400",children:C})}):ye.map((l,x)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-blue-800/10 transition",children:o.map(A=>e.jsx("td",{className:`px-6 py-4 text-sm text-gray-900 dark:text-gray-100 min-w-max max-w-[300px] truncate ${we(A)?"cursor-pointer":""}`,title:String(l[A.key]??""),onClick:()=>Se(A,l),children:A.render?A.render(l,x):ce(A,l,x)},A.key))},l.id||x))})]})}),(n==null?void 0:n.enabled)&&G.length>0&&e.jsxs("div",{className:" bg-gray-50 dark:bg-gray-700/60 px-6 py-3 flex flex-wrap items-center justify-between border-t border-gray-200 dark:border-gray-600 gap-3",children:[e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",(_-1)*O+1," to"," ",Math.min(_*O,ee)," of ",ee," ","results"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Rows per page:"}),e.jsx("select",{value:O,onChange:l=>{const x=Number(l.target.value);W(x),N(1),n.useServerSidePagination&&w(A=>({...A,current_page:1,rows_per_page:x}))},className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm rounded-md px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[2,10,25,50,100].map(l=>e.jsx("option",{value:l,children:l},l))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{if(_>1){const l=_-1;N(l),n.useServerSidePagination&&w(x=>({...x,current_page:l}))}},disabled:_===1,className:"p-2 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition text-gray-500 dark:text-gray-300 disabled:opacity-50",children:e.jsx(X.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:["Page ",_," of ",ge]}),e.jsx("button",{onClick:()=>{if(_<ge){const l=_+1;N(l),n.useServerSidePagination&&w(x=>({...x,current_page:l}))}},disabled:_===ge,className:"p-2 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition text-gray-500 dark:text-gray-300 disabled:opacity-50",children:e.jsx(X.ChevronRight,{className:"h-4 w-4"})})]})]})]})]}),p&&Rr.createPortal(e.jsx("div",{ref:pe,style:{position:"fixed",top:`${j.top}px`,left:`${j.left}px`,zIndex:9999},className:"w-48 bg-white dark:bg-gray-700 rounded-md shadow-lg border border-gray-200 dark:border-gray-600",children:M.map((l,x)=>e.jsxs("button",{onClick:A=>ke(l,c.find(H=>H.id===p),A),className:`w-full flex items-center gap-2 px-4 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-gray-600 ${l.variant==="danger"?"text-red-600 dark:text-red-500":"text-gray-700 dark:text-gray-200"}`,children:[l.icon&&e.jsx("span",{className:"shrink-0",children:l.icon}),l.title]},x))}),document.body),u&&e.jsx(Lr,{isOpen:U,onClose:()=>V(!1),config:u,onApply:m}),y&&e.jsx(dr,{src:Z.src,alt:Z.alt,isOpen:y,setIsOpen:B})]})},Fe=({isOpen:h,onClose:c,icon:o,title:i,children:d,size:t="md",actionButtons:n=[],actions:C,showDefaultClose:v=!0,footerConfig:w=null,hideFooter:m=!1,onFormSubmit:u=()=>{},onCancel:f,loadingBtn:R=!1,executeFunction:p=()=>{},selectedItem:T=null})=>{if(!h)return null;const M={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full"};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-gray-500 opacity-75",onClick:()=>c()}),e.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${M[t]||M.md} max-h-[90vh] flex flex-col dark:bg-gray-800`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[o&&e.jsx("span",{children:o}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:i})]}),e.jsx("button",{onClick:()=>c(),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(X.X,{className:"w-6 h-6"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:d}),n.length>0&&e.jsx("div",{className:"px-4 py-3 flex justify-end gap-3 border-t border-gray-200 dark:border-gray-700 sm:px-6",children:n.map(E=>e.jsx(Re,{onClick:j=>{E.type=="submit"?u(j):p(()=>{var L;return(L=E==null?void 0:E.onClick)==null?void 0:L.call(E,j,T)},L=>c==null?void 0:c(L))},disabled:R||E.disabled,variant:E.variant||"contained",color:E.color||"primary",className:`min-w-[100px] ${E.className}`,type:E.type||"button",children:R?e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white/30 border-t-2 border-t-white mr-2"}),E.label||"Submit","..."]}):E.label||"Submit"}))})]})]})},tr=({config:h,onSubmit:c,initialData:o={}})=>{var w;const{formClass:i="grid grid-cols-12 gap-4",formFields:d=[]}=h||{},[t,n]=g.useState(o);g.useEffect(()=>{n(o)},[]);const C=(m,u)=>{n(f=>({...f,[m]:u}))},v=m=>{m.preventDefault();const u=m.target;if(!u.checkValidity()){u.reportValidity();return}c(t)};return e.jsx("form",{id:(w=h.title)!=null&&w.toLowerCase().includes("edit")?"editForm":"addForm",onSubmit:v,className:i,noValidate:!1,children:d.map(m=>e.jsx(e.Fragment,{children:e.jsx(or,{field:m,formData:t,handleChange:C},m.key)}))})};function Gr({data:h,config:c}){const{fields:o,containerClass:i}=c,[d,t]=g.useState(null),[n,C]=g.useState(!1),v=u=>{t(u),C(!0)},w=({col:u})=>{let f=u==null?void 0:u.icon,R=u.label,p=h[u.key],T=u.type,M=u.variant||"outline",E=u.defaultColor;if(T=="chip"&&u.chipOptions.length>0){let j=u==null?void 0:u.chipOptions.find(L=>L.value==p);j&&(p=j.label,E=j.color)}return e.jsxs("div",{className:`col-span-12 flex items-center space-x-4 p-4 rounded-xl
|
|
59
|
-
bg-gray-100 dark:bg-gray-900 ${u.blockClass}`,children:[
|
|
52
|
+
${r}
|
|
53
|
+
${i}`,children:c})},We=({rows:c=5,columns:d=5})=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-full mb-6 inline-flex justify-end items-center",children:e.jsx("div",{className:"h-8 w-80 bg-gray-300 dark:bg-gray-700 rounded animate-pulse"})}),e.jsx("div",{className:"overflow-hidden rounded-md border border-gray-200 dark:border-gray-800",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{className:"bg-gray-50 dark:bg-gray-900",children:Array.from({length:d}).map((s,i)=>e.jsx("th",{className:"px-4 py-3",children:e.jsx("div",{className:"h-6 w-24 bg-gray-300 dark:bg-gray-700 rounded animate-pulse inline-flex justify-center items-center"})},i))})}),e.jsx("tbody",{children:Array.from({length:c}).map((s,i)=>e.jsx("tr",{className:"border-t border-gray-200 dark:border-gray-800",children:Array.from({length:d}).map((l,r)=>e.jsx("td",{className:"px-4 py-6",children:e.jsx("div",{className:"h-6 w-full bg-gray-300 dark:bg-gray-700 rounded animate-pulse"})},r))},i))})]})})]}),Fe=({src:c,alt:d="preview",isOpen:s,setIsOpen:i})=>{const l=()=>i(!1);return h.useEffect(()=>{const r=n=>{n.key==="Escape"&&l()};return s&&(document.body.style.overflow="hidden",document.addEventListener("keydown",r)),()=>{document.body.style.overflow="",document.removeEventListener("keydown",r)}},[s]),e.jsx(e.Fragment,{children:e.jsxs("div",{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/70 dark:bg-black/80 \r
|
|
54
|
+
backdrop-blur-sm animate-in fade-in duration-200`,onClick:l,children:[e.jsx("button",{onClick:l,className:`absolute top-4 right-4 bg-white dark:bg-gray-800 text-gray-800 dark:text-gray-200\r
|
|
55
|
+
hover:bg-gray-100 dark:hover:bg-gray-700 rounded-full p-2 shadow-lg transition`,children:e.jsx(H.X,{size:20})}),e.jsx("div",{className:"max-w-5xl w-full px-4 transform transition-all duration-200 scale-95 animate-in zoom-in-95",onClick:r=>r.stopPropagation(),children:e.jsx("img",{src:c,alt:d,className:"w-full max-h-[90vh] object-contain rounded-xl"})})]})})},Je=({config:c})=>{const{data:d=[],table_head:s=[],loading:i=!1,search:l={enabled:!1,placeholder:"Search...",useServerSideSearch:!1},filter:r={enabled:!1,useServerSideFilters:!1},pagination:n={enabled:!1,rows_per_page:10,useServerSidePagination:!1},emptyMessage:w="No data available",onMenuAction:C,setServerSidePaginationData:x=()=>{},onFilterApply:f,filterConfig:u=null}=c,[g,j]=h.useState(""),[b,N]=h.useState(null),[k,M]=h.useState([]),[E,P]=h.useState({}),[B,Y]=h.useState(!1),[z,O]=h.useState(null),[m,_]=h.useState(!1),F=h.useMemo(()=>!l.enabled||!g.trim()||l.useServerSideSearch?d:Ge(d,g,l.searchKeys||[]),[d,g,l]),[R,y]=h.useState(1),[A,q]=h.useState((n==null?void 0:n.rows_per_page)||50),[V,X]=h.useState(F.length||0),ae=n!=null&&n.useServerSidePagination?n.total_pages:Math.ceil(F.length/A),oe=h.useMemo(()=>{if(n.useServerSidePagination)return F;const o=(R-1)*A;return F.slice(o,o+A)},[F,R,A]),re=h.useRef(null),ie=h.useRef({}),t=h.useRef(null),v=o=>{j(o),y(1),l.useServerSideSearch&&(t.current&&clearTimeout(t.current),t.current=setTimeout(async()=>{try{await x(p=>({...p,search:o,current_page:1}))}catch(p){console.error("Search error:",p)}},800))},I=(o,p,D)=>{D.stopPropagation(),N(null),C==null||C(o.type,p)},G=(o,p,D)=>{p.stopPropagation(),M(D);const U=p.currentTarget;ie.current[o]=U;const K=U.getBoundingClientRect(),Q=192,Z=D.length*40,de=window.innerWidth,he=window.innerHeight,T=de-K.right<Q?K.left-Q+K.width:K.left,se=he-K.bottom<Z&&K.top>Z?K.top-Z-2:K.bottom+2;P({top:Math.max(8,Math.min(se,he-Z-8)),left:Math.max(8,Math.min(T,de-Q-8))}),N(b===o?null:o)},te=o=>(R-1)*A+o+1,ne=o=>{O(o),_(!0)},L=(o,p,D,U=null)=>e.jsx(e.Fragment,{children:o?e.jsx("img",{src:o,alt:p||"Avatar",onClick:K=>{K.stopPropagation(),K.preventDefault(),ne({src:o,alt:p})},className:`w-10 h-10 cursor-pointer rounded-full object-cover border border-gray-200 dark:border-gray-700 ${D||""}`}):e.jsx(e.Fragment,{children:U||e.jsx("div",{className:`w-10 h-10 flex items-center justify-center rounded-full border border-gray-300 dark:border-gray-700 bg-gray-200 dark:bg-gray-600 ${D||""}`,children:e.jsx(H.User,{className:"w-6 h-6 text-gray-400 dark:text-gray-400"})})})}),J=(o,p)=>e.jsxs("div",{className:`flex items-center space-x-4 ${p.className||""}`,children:[p.imageKey?L(o[p.imageKey],o[p.titleKey],"group-avatar"):"",e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900 dark:text-white group-title",children:o[p.titleKey]||""}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400 group-sub-title",children:o[p.subtitleKey]||""})]})]}),le=(o,p)=>{var Q;let D=String(o);const U=p.variant||"contained";let K=p.defaultColor;if(((Q=p==null?void 0:p.chipOptions)==null?void 0:Q.length)>0){let Z=p==null?void 0:p.chipOptions.find(de=>de.value==o);Z&&(D=Z.label,K=Z.color)}return e.jsx(Oe,{label:D,variant:U,color:K,className:p.className||""})},ce=(o,p,D)=>{const U=p[o.key];return o.type==="menu_actions"?e.jsx("div",{className:`text-center ${o.className||""}`,children:e.jsx("button",{ref:K=>ie.current[p.id]=K,onClick:K=>G(p.id,K,o.menuList),className:"p-2 bg-gray-100 dark:bg-gray-700 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-full transition text-gray-700 dark:text-gray-300",children:e.jsx(H.EllipsisVertical,{className:"h-4 w-4"})})}):o.type==="index"?e.jsx("span",{className:o.className||"",children:te(D)}):o.type==="group"?J(p,o):o.type==="chip"?e.jsx(e.Fragment,{children:le(U,o)}):o.type==="date"?e.jsx("span",{className:o.className||"",children:Te(U,o.format||"DD MMM YYYY")}):o.type==="avatar"?e.jsx(e.Fragment,{children:L(U,o.alt,o.className,o.fallback_icon)}):e.jsx("span",{className:o.className||"",children:U||"N/A"})},pe=(o,p)=>{if(o.onClickDetails)return C==null?void 0:C("view",p);if(typeof o.handleClick=="function")return o.handleClick(p)},me=o=>o.onClickDetails||typeof o.handleClick=="function";return h.useEffect(()=>{const o=()=>{b&&N(null)};return window.addEventListener("scroll",o,!0),()=>{window.removeEventListener("scroll",o,!0)}},[b]),h.useEffect(()=>{const o=p=>{re.current&&!re.current.contains(p.target)&&N(null)};return document.addEventListener("click",o),()=>document.removeEventListener("click",o)},[]),h.useEffect(()=>{n!=null&&n.rows_per_page&&(n!=null&&n.useServerSidePagination)&&q((n==null?void 0:n.rows_per_page)||50),n.current_page&&y(n.current_page)},[n.rows_per_page,n==null?void 0:n.useServerSidePagination,n.current_page]),h.useEffect(()=>{X(n!=null&&n.useServerSidePagination?n.total_records:F.length),F.length<=A*(R-1)&&!(n!=null&&n.useServerSidePagination)&&y(o=>o-1||1)},[F.length,n.total_records,n==null?void 0:n.useServerSidePagination]),i?e.jsx(We,{rows:6,columns:6}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-end items-center mb-6 gap-2",children:[l.enabled&&e.jsx("div",{className:"",children:e.jsxs("div",{className:"relative min-w-[300px]",children:[e.jsx(H.Search,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 dark:text-gray-300"}),e.jsx("input",{type:"text",placeholder:l.placeholder||"Search...",value:g,onChange:o=>v(o.target.value),className:"w-full h-[36px] pl-9 pr-4 py-3 text-sm border border-gray-300 dark:border-gray-600 rounded-md bg-gray-50 dark:bg-gray-700 text-gray-900 dark:text-white placeholder-gray-500 dark:placeholder-gray-400 focus:outline-none focus:ring-1 focus:ring-blue-300 dark:ring-blue-200 disabled:opacity-50"})]})}),u&&r.enabled&&e.jsxs(ue,{onClick:()=>Y(!0),variant:"contained",children:[e.jsx(H.Filter,{className:"w-4 h-4 mr-2"}),"Filters"]})]}),e.jsxs("div",{className:"bg-white dark:bg-gray-800 rounded-lg shadow overflow-hidden border border-gray-200 dark:border-gray-700",children:[e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200 dark:divide-gray-700",children:[e.jsx("thead",{className:"bg-gray-50 dark:bg-gray-700/60",children:e.jsx("tr",{children:s.map(o=>e.jsx("th",{className:"px-6 py-4 text-left text-xs font-medium text-black dark:text-white uppercase tracking-wider min-w-max max-w-[180px] truncate",children:o.title},o.key))})}),e.jsx("tbody",{className:"bg-white dark:bg-gray-800 divide-y divide-gray-200 dark:divide-gray-700",children:oe.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:s.length,className:"text-center py-10 text-gray-500 dark:text-gray-400",children:w})}):oe.map((o,p)=>e.jsx("tr",{className:"hover:bg-gray-50 dark:hover:bg-blue-800/10 transition",children:s.map(D=>e.jsx("td",{className:`px-6 py-4 text-sm text-gray-900 dark:text-gray-100 min-w-max max-w-[300px] truncate ${me(D)?"cursor-pointer":""}`,title:String(o[D.key]??""),onClick:()=>pe(D,o),children:D.render?D.render(o,p):ce(D,o,p)},D.key))},o.id||p))})]})}),(n==null?void 0:n.enabled)&&F.length>0&&e.jsxs("div",{className:" bg-gray-50 dark:bg-gray-700/60 px-6 py-3 flex flex-wrap items-center justify-between border-t border-gray-200 dark:border-gray-600 gap-3",children:[e.jsxs("div",{className:"text-sm text-gray-700 dark:text-gray-300",children:["Showing ",(R-1)*A+1," to"," ",Math.min(R*A,V)," of ",V," ","results"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-sm text-gray-700 dark:text-gray-300",children:"Rows per page:"}),e.jsx("select",{value:A,onChange:o=>{const p=Number(o.target.value);q(p),y(1),n.useServerSidePagination&&x(D=>({...D,current_page:1,rows_per_page:p}))},className:"border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800 text-sm rounded-md px-2 py-1 focus:outline-none focus:ring-1 focus:ring-blue-500",children:[2,10,25,50,100].map(o=>e.jsx("option",{value:o,children:o},o))})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>{if(R>1){const o=R-1;y(o),n.useServerSidePagination&&x(p=>({...p,current_page:o}))}},disabled:R===1,className:"p-2 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition text-gray-500 dark:text-gray-300 disabled:opacity-50",children:e.jsx(H.ChevronLeft,{className:"h-4 w-4"})}),e.jsxs("span",{className:"text-sm text-gray-800 dark:text-gray-200",children:["Page ",R," of ",ae]}),e.jsx("button",{onClick:()=>{if(R<ae){const o=R+1;y(o),n.useServerSidePagination&&x(p=>({...p,current_page:o}))}},disabled:R===ae,className:"p-2 hover:bg-gray-200 dark:hover:bg-gray-600 rounded-md transition text-gray-500 dark:text-gray-300 disabled:opacity-50",children:e.jsx(H.ChevronRight,{className:"h-4 w-4"})})]})]})]})]}),b&&Ie.createPortal(e.jsx("div",{ref:re,style:{position:"fixed",top:`${E.top}px`,left:`${E.left}px`,zIndex:9999},className:"w-48 bg-white dark:bg-gray-700 rounded-md shadow-lg border border-gray-200 dark:border-gray-600",children:k.map((o,p)=>e.jsxs("button",{onClick:D=>I(o,d.find(U=>U.id===b),D),className:`w-full flex items-center gap-2 px-4 py-2 text-sm text-left hover:bg-gray-100 dark:hover:bg-gray-600 ${o.variant==="danger"?"text-red-600 dark:text-red-500":"text-gray-700 dark:text-gray-200"}`,children:[o.icon&&e.jsx("span",{className:"shrink-0",children:o.icon}),o.title]},p))}),document.body),u&&e.jsx(Ve,{isOpen:B,onClose:()=>Y(!1),config:u,onApply:f}),m&&e.jsx(Fe,{src:z.src,alt:z.alt,isOpen:m,setIsOpen:_})]})},ye=({isOpen:c,onClose:d,icon:s,title:i,children:l,size:r="md",actionButtons:n=[],actions:w,showDefaultClose:C=!0,footerConfig:x=null,hideFooter:f=!1,onFormSubmit:u=()=>{},onCancel:g,loadingBtn:j=!1,executeFunction:b=()=>{},selectedItem:N=null})=>{if(!c)return null;const k={sm:"max-w-md",md:"max-w-lg",lg:"max-w-2xl",xl:"max-w-4xl",full:"max-w-full"};return e.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-gray-500 opacity-75",onClick:()=>d()}),e.jsxs("div",{className:`relative bg-white rounded-lg shadow-xl w-full ${k[r]||k.md} max-h-[90vh] flex flex-col dark:bg-gray-800`,children:[e.jsxs("div",{className:"flex items-center justify-between p-4 border-b border-gray-200 dark:border-gray-700 flex-shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[s&&e.jsx("span",{children:s}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white",children:i})]}),e.jsx("button",{onClick:()=>d(),className:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300",children:e.jsx(H.X,{className:"w-6 h-6"})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-4",children:l}),n.length>0&&e.jsx("div",{className:"px-4 py-3 flex justify-end gap-3 border-t border-gray-200 dark:border-gray-700 sm:px-6",children:n.map(M=>e.jsx(ue,{onClick:E=>{M.type=="submit"?u(E):b(()=>{var P;return(P=M==null?void 0:M.onClick)==null?void 0:P.call(M,E,N)},P=>d==null?void 0:d(P))},disabled:j||M.disabled,variant:M.variant||"contained",color:M.color||"primary",className:`min-w-[100px] ${M.className}`,type:M.type||"button",children:j?e.jsxs("div",{className:"flex items-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-2 border-white/30 border-t-2 border-t-white mr-2"}),M.label||"Submit","..."]}):M.label||"Submit"}))})]})]})},Ee=({config:c,onSubmit:d,initialData:s={}})=>{var x;const{formClass:i="grid grid-cols-12 gap-4",formFields:l=[]}=c||{},[r,n]=h.useState(s);h.useEffect(()=>{n(s)},[]);const w=(f,u)=>{n(g=>({...g,[f]:u}))},C=f=>{f.preventDefault();const u=f.target;if(!u.checkValidity()){u.reportValidity();return}d(r)};return e.jsx("form",{id:(x=c.title)!=null&&x.toLowerCase().includes("edit")?"editForm":"addForm",onSubmit:C,className:i,noValidate:!1,children:l.map(f=>e.jsx(e.Fragment,{children:e.jsx(Pe,{field:f,formData:r,handleChange:w},f.key)}))})};function Ze({data:c,config:d}){const{fields:s,containerClass:i}=d,[l,r]=h.useState(null),[n,w]=h.useState(!1),C=u=>{r(u),w(!0)},x=({col:u})=>{let g=u==null?void 0:u.icon,j=u.label,b=c[u.key],N=u.type,k=u.variant||"outline",M=u.defaultColor;if(N=="chip"&&u.chipOptions.length>0){let E=u==null?void 0:u.chipOptions.find(P=>P.value==b);E&&(b=E.label,M=E.color)}return e.jsxs("div",{className:`col-span-12 flex items-center space-x-4 p-4 rounded-xl
|
|
56
|
+
bg-gray-100 dark:bg-gray-900 ${u.blockClass}`,children:[g&&e.jsx("div",{className:"flex-shrink-0",children:g}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-gray-500 dark:text-gray-400",children:j}),N=="chip"?e.jsx(e.Fragment,{children:e.jsx(Oe,{label:b,variant:k,color:M,className:"mt-1"})}):N=="tinyEditor"?e.jsx("p",{className:"mt-1 text-sm text-gray-900 dark:text-white break-words",dangerouslySetInnerHTML:{__html:b}}):e.jsx("p",{className:"mt-1 text-sm text-gray-900 dark:text-white break-words",children:N=="date"?e.jsx("span",{children:Te(b,u.format||"DD MMM YYYY")}):b||"N/A"})]})]})},f=({col:u})=>{let g=c[u.titleKey],j=c[u.subtitleKey],b=c[u.imageKey],N=c[u.fallback_icon];return e.jsxs("div",{className:`col-span-12 flex items-center space-x-4 p-4 rounded-xl
|
|
60
57
|
bg-gray-100 dark:bg-gray-900
|
|
61
|
-
${u.blockClass}`,children:[
|
|
58
|
+
${u.blockClass}`,children:[b?e.jsx("img",{src:b,alt:g,onClick:()=>C({src:b,alt:g}),className:"w-16 h-16 cursor-pointer rounded-full object-cover border-2 border-gray-200 dark:border-gray-700"}):N||e.jsx("div",{className:"w-16 h-16 flex items-center justify-center rounded-full border-2 border-gray-300 dark:border-gray-700 bg-gray-200 dark:bg-gray-600",children:e.jsx(H.User,{className:"w-8 h-8 text-gray-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-semibold text-gray-900 dark:text-white",children:g}),e.jsx("p",{className:"text-sm text-gray-500 dark:text-gray-400",children:j})]})]})};return e.jsxs(e.Fragment,{children:[n&&e.jsx(Fe,{src:l.src,alt:l.alt,isOpen:n,setIsOpen:w}),e.jsx("div",{className:`grid grid-cols-12 gap-4 ${i||""}`,children:s.map(u=>u.type=="group"?e.jsx(f,{col:u}):e.jsx(x,{col:u}))})]})}const De=({config:c})=>{var ne,L,J,le,ce,pe,me,o,p,D,U,K,Q,Z,de,he;const{title:d,fetchData:s=async()=>{},isStaticData:i=!1,tableConfig:l={},modalConfig:r={},filterConfig:n}=c,[w,C]=h.useState(!0),[x,f]=h.useState(!1),[u,g]=h.useState([]),[j,b]=h.useState(null),[N,k]=h.useState({search:"",rows_per_page:50,current_page:1}),[M,E]=h.useState({}),[P,B]=h.useState(!1),[Y,z]=h.useState(!1),[O,m]=h.useState(!1),[_,F]=h.useState(!1),[R,y]=h.useState(!1),[A,q]=h.useState(null),V=(S,T)=>{S==="edit"?(q(T),m(!0)):S==="view"?(q(T),y(!0)):S==="delete"&&(q(T),F(!0))},X=async(S,T,$="",se="")=>{f(!0);try{const W=await(S==null?void 0:S());($||W.message)&&fe.enqueueSnackbar($||W.message,{variant:"success"}),T==null||T(W)}catch(W){(se||W.message)&&fe.enqueueSnackbar(se||W.message,{variant:"error"})}finally{f(!1)}},ae=S=>{let T=S.newObject;i?(g($=>[T,...$]),b($=>({...$,current_page:1}))):(k($=>({...$,current_page:1})),N.current_page==1&&v()),z(!1)},oe=S=>{let T=S.newObject,$=S.targetObject;i?g(se=>se.map(W=>W.id===$.id?{...W,...T}:W)):v(),m(!1)},re=S=>{if(!S){F(!1),q(null);return}i?g(T=>T.filter($=>$.id!==S.targetObject.id)):u.length==1&&N.current_page>1?k(T=>({...T,current_page:T.current_page-1})):v(),F(!1),q(null)},ie=S=>X(()=>{var T,$;return($=(T=r==null?void 0:r.addModal)==null?void 0:T.handleSubmit)==null?void 0:$.call(T,S)},ae),t=S=>X(()=>{var T,$;return($=(T=r==null?void 0:r.editModal)==null?void 0:T.handleSubmit)==null?void 0:$.call(T,S,A)},oe),v=async()=>{C(!0),s==null||s({...N,...M}).then(S=>{g(S.data),b(S.pagination)}).catch(S=>{fe.enqueueSnackbar(S.message,{variant:"error"})}).finally(()=>{C(!1)})},I=S=>{var T;E($=>({...S})),(T=l==null?void 0:l.filter)!=null&&T.useServerSideFilters&&B($=>!$)},G=(S,T)=>S.filter($=>Object.entries(T).every(([se,W])=>$[se]===W)),te=h.useMemo(()=>{var S;return(S=l==null?void 0:l.filter)!=null&&S.useServerSideFilters?data:G(u,M)},[u,M]);return h.useEffect(()=>{v()},[N.search,N.rows_per_page,N.current_page,P]),e.jsx(fe.SnackbarProvider,{maxSnack:3,anchorOrigin:{vertical:"bottom",horizontal:"right"},autoHideDuration:3e3,action:S=>e.jsx("button",{onClick:()=>{window.dispatchEvent(new CustomEvent("closeSnackbar",{detail:S}))},className:"p-1 hover:bg-white/20 rounded-full transition-colors duration-200 text-white flex items-center justify-center",children:e.jsx(H.X,{className:"h-4 w-4"})}),children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900 dark:text-white",children:d}),e.jsx("p",{className:"text-md text-gray-600 dark:text-gray-400 mt-2",children:c==null?void 0:c.description})]}),e.jsx("div",{className:"flex items-center space-x-3",children:e.jsxs(ue,{onClick:()=>z(!0),variant:"contained",color:"primary",children:[e.jsx(H.Plus,{className:"w-4 h-4 mr-2"}),c.buttonText||"Add New"]})})]}),e.jsx(Je,{config:{...l,pagination:{...l.pagination,...j},data:te,setServerSidePaginationData:k,onMenuAction:V,filterConfig:n,onFilterApply:I,loading:w}}),e.jsx(ye,{isOpen:Y,onClose:()=>z(!1),icon:(ne=r.addModal)==null?void 0:ne.icon,title:((L=r.addModal)==null?void 0:L.title)||"Add New",size:((J=r.addModal)==null?void 0:J.size)||"md",onFormSubmit:()=>{var S;return(S=document.querySelector("#addForm"))==null?void 0:S.requestSubmit()},loadingBtn:x,actionButtons:r.addModal.actionButtons,children:e.jsx(Ee,{config:(r==null?void 0:r.addModal)||[],onSubmit:ie,initialData:{},loading:x})}),e.jsx(ye,{isOpen:O,onClose:()=>m(!1),icon:(le=r.editModal)==null?void 0:le.icon,title:((ce=r.editModal)==null?void 0:ce.title)||"Edit",size:((pe=r.editModal)==null?void 0:pe.size)||"md",onFormSubmit:()=>{var S;return(S=document.querySelector("#editForm"))==null?void 0:S.requestSubmit()},actionButtons:r.editModal.actionButtons,loadingBtn:x,children:e.jsx(Ee,{config:r.editModal||[],onSubmit:t,initialData:A,loading:x})}),_&&e.jsx(ye,{isOpen:_,onClose:S=>{re(S)},icon:((me=r.deleteModal)==null?void 0:me.icon)||e.jsx(we.Icon,{icon:"ph:warning-bold",className:"w-6 h-6 text-red-500"}),title:((o=r.deleteModal)==null?void 0:o.title)||"Confirm Delete",size:((p=r.deleteModal)==null?void 0:p.size)||"md",loading:x,actionButtons:r.deleteModal.actionButtons,executeFunction:X,selectedItem:A,children:e.jsx("div",{className:"flex items-center space-x-2 py-3",children:e.jsxs("div",{children:[e.jsx("p",{className:"text-md text-gray-700 dark:text-white",children:((D=r.deleteModal)==null?void 0:D.confirmText)||"Are you sure you want to delete this item?"}),((U=r.deleteModal)==null?void 0:U.referenceKey)&&e.jsx("p",{className:"text-md font-semibold text-gray-700 dark:text-white",children:A[(K=r.deleteModal)==null?void 0:K.referenceKey]})]})})}),r.viewModal&&e.jsx(ye,{isOpen:R,onClose:()=>{y(!1),q(null)},icon:(Q=r.viewModal)==null?void 0:Q.icon,title:((Z=r.viewModal)==null?void 0:Z.title)||"View Details",size:((de=r.viewModal)==null?void 0:de.size)||"lg",footerConfig:r==null?void 0:r.viewModal.footer,children:(he=r.viewModal)!=null&&he.component?e.jsx(r.viewModal.component,{data:A}):e.jsx(Ze,{data:A,config:r.viewModal||{}})})]})})},Se=a.shape({value:a.oneOfType([a.string,a.number,a.bool]).isRequired,label:a.string.isRequired,color:a.string}),ve=a.shape({type:a.string.isRequired,label:a.string.isRequired,color:a.string,variant:a.string,onClick:a.func}),Xe=a.shape({title:a.string.isRequired,type:a.string.isRequired,variant:a.string,icon:a.node}),Qe=a.shape({key:a.string.isRequired,title:a.string,type:a.string,imageKey:a.string,titleKey:a.string,subtitleKey:a.string,onClickDetails:a.bool,variant:a.string,chipOptions:a.arrayOf(Se),defaultColor:a.string,className:a.string,format:a.string,menuList:a.arrayOf(Xe)}),je=a.shape({key:a.string.isRequired,label:a.string,type:a.string.isRequired,required:a.bool,minLength:a.number,parentClass:a.string,search:a.bool,multiple:a.bool,dropdownMaxHeight:a.string,dragDrop:a.bool,countriesList:a.bool,defaultCountry:a.string,placeholder:a.string,rows:a.number,text:a.string,editorKey:a.string,options:a.arrayOf(Se)}),ea=a.shape({key:a.string,label:a.string,type:a.string,imageKey:a.string,titleKey:a.string,subtitleKey:a.string,blockClass:a.string,icon:a.node,variant:a.string,chipOptions:a.arrayOf(Se),defaultColor:a.string,className:a.string,format:a.string});De.propTypes={config:a.shape({title:a.string.isRequired,description:a.string,buttonText:a.string,fetchData:a.func.isRequired,isStaticData:a.bool,tableConfig:a.shape({table_head:a.arrayOf(Qe).isRequired,search:a.shape({enabled:a.bool,useServerSideSearch:a.bool,searchKeys:a.arrayOf(a.string)}),pagination:a.shape({enabled:a.bool,useServerSidePagination:a.bool}),filter:a.shape({enabled:a.bool,useServerSideFilters:a.bool})}).isRequired,modalConfig:a.shape({addModal:a.shape({title:a.string.isRequired,size:a.string,formClass:a.string,formFields:a.arrayOf(je),handleSubmit:a.func.isRequired,actionButtons:a.arrayOf(ve)}),editModal:a.shape({title:a.string.isRequired,size:a.string,formClass:a.string,formFields:a.arrayOf(je),handleSubmit:a.func.isRequired,actionButtons:a.arrayOf(ve)}),deleteModal:a.shape({title:a.string.isRequired,size:a.string,confirmText:a.string,referenceKey:a.string,actionButtons:a.arrayOf(ve)}),viewModal:a.shape({title:a.string.isRequired,size:a.string,component:a.elementType,fields:a.arrayOf(ea),footer:a.shape({cancelButton:a.bool,cancelText:a.string})})}),filterConfig:a.shape({fields:a.arrayOf(je)})}).isRequired};function aa(c){return console.info(c,"props passed"),e.jsx(e.Fragment,{children:e.jsx(De,{config:c.config})})}module.exports=aa;
|
|
62
59
|
//# sourceMappingURL=index.cjs.js.map
|