pillardash-ui-react 0.1.144 → 0.1.146
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/dist/cjs/components/Form/Input/Input.js +1 -1
- package/dist/cjs/components/Form/Input/Input.js.map +1 -1
- package/dist/cjs/components/Loading/Loading.js +1 -1
- package/dist/cjs/components/Loading/Loading.js.map +1 -1
- package/dist/cjs/components/Table/Pagination.js +1 -1
- package/dist/cjs/components/Table/Pagination.js.map +1 -1
- package/dist/cjs/components/Table/Table.js +1 -1
- package/dist/cjs/components/Table/Table.js.map +1 -1
- package/dist/esm/components/Form/Input/Input.mjs +1 -1
- package/dist/esm/components/Form/Input/Input.mjs.map +1 -1
- package/dist/esm/components/Loading/Loading.mjs +1 -1
- package/dist/esm/components/Loading/Loading.mjs.map +1 -1
- package/dist/esm/components/Table/Pagination.mjs +1 -1
- package/dist/esm/components/Table/Pagination.mjs.map +1 -1
- package/dist/esm/components/Table/Table.mjs +1 -1
- package/dist/esm/components/Table/Table.mjs.map +1 -1
- package/dist/styles.css +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime");module.exports=function(a){var t=a.id,s=a.label,l=a.value,i=a.size,o=void 0===i?"md":i,c=a.onChange,n=a.placeholder,d=a.error,x=a.required,m=void 0!==x&&x,p=a.helpText,g=a.type,h=void 0===g?"text":g,b=a.className,
|
|
1
|
+
"use strict";var e=require("../../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime");module.exports=function(a){var t=a.id,s=a.label,l=a.value,i=a.size,o=void 0===i?"md":i,c=a.onChange,n=a.placeholder,d=a.error,x=a.required,m=void 0!==x&&x,p=a.helpText,g=a.type,h=void 0===g?"text":g,b=a.className,y=void 0===b?"":b,u=a.disabled,v=void 0!==u&&u,f=a.icon,N=a.iconPosition,j=void 0===N?"left":N,k=a.rightIcon,_=a.block,q=e.__rest(a,["id","label","value","size","onChange","placeholder","error","required","helpText","type","className","disabled","icon","iconPosition","rightIcon","block"]),w={id:t,value:l,onChange:function(e){c&&c(e)},placeholder:n,disabled:v,className:"w-full rounded-[12px] border ".concat({sm:"text-xs px-3 py-1.5 text-sm min-h-[32px]",md:"text-sm px-4 py-2 text-base min-h-[40px]",lg:"text-base px-4 py-3 text-lg min-h-[48px]"}[o]," ").concat(d?"border-red-500":"border-gray-200 dark:border-gray-600"," ").concat(v?"bg-gray-100 text-gray-500 placeholder-gray-300 dark:bg-gray-800 dark:text-gray-500 dark:placeholder-gray-600":"bg-gray-100 placeholder-gray-400 text-dark dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"," focus:outline-none focus:ring-1 focus:ring-primary ").concat(y," ").concat(f&&"left"===j?"pl-10":""," ").concat(f&&"right"===j?"pr-10":""),"aria-invalid":!!d,"aria-describedby":d?"".concat(t,"-error"):p?"".concat(t,"-help"):void 0};return r.jsxs("div",{className:"mb-4 ".concat(_&&"w-full"),children:[s&&r.jsxs("label",{htmlFor:t,className:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-300",children:[s,m&&r.jsx("span",{className:"ml-1 text-red-500",children:"*"})]}),r.jsxs("div",{className:"relative",children:[f&&"left"===j&&r.jsx("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:f}),"textarea"==h?r.jsx("textarea",e.__assign({},w,{rows:4,className:"".concat(w.className," resize-none")},q)):r.jsx("input",e.__assign({},w,{type:h},q)),f&&"right"===j&&r.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:f}),k&&r.jsx("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 cursor-pointer",children:k})]}),p&&!d&&r.jsx("p",{id:"".concat(t,"-help"),className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:p}),d&&r.jsx("p",{id:"".concat(t,"-error"),className:"mt-1 text-sm text-red-500",children:d})]})};
|
|
2
2
|
//# sourceMappingURL=Input.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Input.js","sources":["../../../../../src/components/Form/Input/Input.tsx"],"sourcesContent":["import React, {
|
|
1
|
+
{"version":3,"file":"Input.js","sources":["../../../../../src/components/Form/Input/Input.tsx"],"sourcesContent":["import React, {\n ChangeEvent,\n InputHTMLAttributes,\n TextareaHTMLAttributes,\n} from \"react\";\nexport type InputElement =\n | HTMLInputElement\n | HTMLTextAreaElement\n | HTMLSelectElement;\nexport interface InputProps extends Omit<\n InputHTMLAttributes<HTMLInputElement> &\n TextareaHTMLAttributes<HTMLTextAreaElement>,\n \"onChange\" | \"size\"\n> {\n id?: string;\n value: string;\n onChange?: (value: React.ChangeEvent<InputElement>) => void;\n placeholder?: string;\n error?: string;\n label?: string;\n required?: boolean;\n helpText?: string;\n icon?: React.ReactNode;\n iconPosition?: \"left\" | \"right\";\n rightIcon?: React.ReactNode;\n className?: string;\n size?: \"sm\" | \"md\" | \"lg\";\n block?: boolean;\n}\n\nconst Input: React.FC<InputProps> = ({\n id,\n label,\n value,\n size = \"md\",\n onChange,\n placeholder,\n error,\n required = false,\n helpText,\n type = \"text\",\n className = \"\",\n disabled = false,\n icon,\n iconPosition = \"left\",\n rightIcon,\n block,\n\n ...restProps\n}) => {\n // Handle input change\n const handleChange = (e: ChangeEvent<InputElement>) => {\n if (onChange) {\n onChange(e);\n }\n };\n\n const sizeClasses = {\n sm: \"text-xs px-3 py-1.5 text-sm min-h-[32px]\",\n md: \"text-sm px-4 py-2 text-base min-h-[40px]\",\n lg: \"text-base px-4 py-3 text-lg min-h-[48px]\",\n };\n\n // const iconSizeClasses = {\n // sm: \"h-4 w-4\",\n // md: \"h-5 w-5\",\n // lg: \"h-6 w-6\",\n // };\n\n const commonProps = {\n id,\n value,\n onChange: handleChange,\n placeholder,\n disabled,\n className: `w-full rounded-[12px] border ${sizeClasses[size]} ${\n error ? \"border-red-500\" : \"border-gray-200 dark:border-gray-600\"\n } ${\n disabled\n ? \"bg-gray-100 text-gray-500 placeholder-gray-300 dark:bg-gray-800 dark:text-gray-500 dark:placeholder-gray-600\"\n : \"bg-gray-100 placeholder-gray-400 text-dark dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500\"\n } focus:outline-none focus:ring-1 focus:ring-primary ${className} ${\n icon && iconPosition === \"left\" ? \"pl-10\" : \"\"\n } ${icon && iconPosition === \"right\" ? \"pr-10\" : \"\"}`,\n \"aria-invalid\": !!error,\n \"aria-describedby\": error\n ? `${id}-error`\n : helpText\n ? `${id}-help`\n : undefined,\n };\n\n return (\n <div className={`mb-4 ${block && \"w-full\"}`}>\n {label && (\n <label\n htmlFor={id}\n className=\"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-300\"\n >\n {label}\n {required && <span className=\"ml-1 text-red-500\">*</span>}\n </label>\n )}\n\n <div className=\"relative\">\n {icon && iconPosition === \"left\" && (\n <div className=\"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3\">\n {icon}\n </div>\n )}\n {type == \"textarea\" ? (\n <textarea\n {...commonProps}\n rows={4}\n className={`${commonProps.className} resize-none`}\n {...(restProps as TextareaHTMLAttributes<HTMLTextAreaElement>)}\n />\n ) : (\n <input\n {...commonProps}\n type={type}\n {...(restProps as InputHTMLAttributes<HTMLInputElement>)}\n />\n )}\n\n {icon && iconPosition === \"right\" && (\n <div className=\"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3\">\n {icon}\n </div>\n )}\n {rightIcon && (\n <div className=\"absolute right-3 top-1/2 -translate-y-1/2 cursor-pointer\">\n {rightIcon}\n </div>\n )}\n </div>\n\n {helpText && !error && (\n <p\n id={`${id}-help`}\n className=\"mt-1 text-sm text-gray-500 dark:text-gray-400\"\n >\n {helpText}\n </p>\n )}\n\n {error && (\n <p id={`${id}-error`} className=\"mt-1 text-sm text-red-500\">\n {error}\n </p>\n )}\n </div>\n );\n};\n\nexport default Input;\n"],"names":["_a","id","label","value","_b","size","onChange","placeholder","error","_c","required","helpText","_d","type","_e","className","_f","disabled","icon","_g","iconPosition","rightIcon","block","restProps","__rest","commonProps","e","concat","sm","md","lg","undefined","_jsxs","children","htmlFor","_jsx","__assign","rows"],"mappings":"qHA8BoC,SAACA,GACnC,IAAAC,EAAED,EAAAC,GACFC,UACAC,EAAKH,EAAAG,MACLC,SAAAC,OAAI,IAAAD,EAAG,OACPE,EAAQN,EAAAM,SACRC,EAAWP,EAAAO,YACXC,EAAKR,EAAAQ,MACLC,EAAAT,EAAAU,SAAAA,OAAQ,IAAAD,GAAQA,EAChBE,EAAQX,EAAAW,SACRC,EAAAZ,EAAAa,KAAAA,OAAI,IAAAD,EAAG,OAAMA,EACbE,EAAAd,EAAAe,UAAAA,OAAS,IAAAD,EAAG,GAAEA,EACdE,aAAAC,OAAQ,IAAAD,KACRE,EAAIlB,EAAAkB,KACJC,iBAAAC,OAAY,IAAAD,EAAG,SACfE,EAASrB,EAAAqB,UACTC,EAAKtB,EAAAsB,MAEFC,EAASC,EAAAA,OAAAxB,EAlBuB,8JAuC7ByB,EAAc,CAClBxB,GAAEA,EACFE,MAAKA,EACLG,SArBmB,SAACoB,GAChBpB,GACFA,EAASoB,EAEb,EAkBEnB,YAAWA,EACXU,SAAQA,EACRF,UAAW,gCAAAY,OAlBO,CAClBC,GAAI,2CACJC,GAAI,2CACJC,GAAI,4CAemDzB,GAAK,KAAAsB,OAC1DnB,EAAQ,iBAAmB,mDAE3BS,EACI,+GACA,2GAA0G,wDAAAU,OACzDZ,cACrDG,GAAyB,SAAjBE,EAA0B,QAAU,GAAE,KAAAO,OAC5CT,GAAyB,UAAjBE,EAA2B,QAAU,IACjD,iBAAkBZ,EAClB,mBAAoBA,EAChB,GAAAmB,OAAG1B,EAAE,UACLU,EACE,GAAAgB,OAAG1B,EAAE,cACL8B,GAGR,OACEC,EAAAA,KAAA,MAAA,CAAKjB,UAAW,QAAAY,OAAQL,GAAS,UAAUW,SAAA,CACxC/B,GACC8B,EAAAA,cACEE,QAASjC,EACTc,UAAU,4EAETb,EACAQ,GAAYyB,EAAAA,YAAMpB,UAAU,oBAAmBkB,SAAA,SAIpDD,EAAAA,YAAKjB,UAAU,WAAUkB,SAAA,CACtBf,GAAyB,SAAjBE,GACPe,EAAAA,IAAA,MAAA,CAAKpB,UAAU,uEAAsEkB,SAClFf,IAGI,YAARL,EACCsB,EAAAA,IAAA,WAAAC,EAAAA,SAAA,CAAA,EACMX,EAAW,CACfY,KAAM,EACNtB,UAAW,GAAAY,OAAGF,EAAYV,UAAS,iBAC9BQ,IAGPY,EAAAA,0BACMV,EAAW,CACfZ,KAAMA,GACDU,IAIRL,GAAyB,UAAjBE,GACPe,EAAAA,IAAA,MAAA,CAAKpB,UAAU,wEAAuEkB,SACnFf,IAGJG,GACCc,EAAAA,IAAA,MAAA,CAAKpB,UAAU,oEACZM,OAKNV,IAAaH,GACZ2B,EAAAA,IAAA,IAAA,CACElC,GAAI,GAAA0B,OAAG1B,EAAE,SACTc,UAAU,gDAA+CkB,SAExDtB,IAIJH,GACC2B,EAAAA,IAAA,IAAA,CAAGlC,GAAI,GAAA0B,OAAG1B,EAAE,UAAUc,UAAU,4BAA2BkB,SACxDzB,MAKX"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),r=function(a){var r=a.size,n=void 0===r?"md":r,t=a.variant,s=void 0===t?"pulse":t,l=a.color,o=void 0===l?"primary":l,i=a.fullScreen,c=void 0!==i&&i,d=a.text,u=a.className,m=void 0===u?"":u,x=a.image,b=a.imageEffect,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),a=require("react"),r=function(a){var r=a.size,n=void 0===r?"md":r,t=a.variant,s=void 0===t?"pulse":t,l=a.color,o=void 0===l?"primary":l,i=a.fullScreen,c=void 0!==i&&i,d=a.text,u=a.className,m=void 0===u?"":u,x=a.image,b=a.imageEffect,g=void 0===b?"pulse":b,h=o.startsWith("#"),p=function(e){return h?"":{text:"text-".concat(o),bg:"bg-".concat(o),border:"border-".concat(o),borderTop:"border-t-".concat(o),borderRight:"border-r-".concat(o)}[e]||""},f={sm:"w-4 h-4",md:"w-8 h-8",lg:"w-12 h-12",xl:"w-16 h-16"},j={sm:"w-8 h-8",md:"w-12 h-12",lg:"w-16 h-16",xl:"w-20 h-20"},v=function(){switch(g){case"bounce":return"animate-bounce";case"spin":return"animate-spin";case"float":return"animate-pulse hover:animate-bounce";case"heartbeat":return"animate-ping";default:return"animate-pulse"}},N=function(){return e.jsxs("div",{className:"relative flex items-center justify-center",children:[e.jsx("img",{src:x,alt:"Loading",className:"".concat(j[n]," object-contain ").concat(v()),style:{filter:"drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1))",animationDuration:"heartbeat"===g?"1.5s":"bounce"===g?"1s":"2s"}}),"float"===g&&e.jsx("div",{className:"absolute inset-0 ".concat(j[n]," rounded-full bg-gradient-to-r from-purple-400 to-blue-400 opacity-20 animate-ping"),style:{animationDuration:"2s"}})]})},y=function(){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"".concat(f[n]," animate-spin rounded-full border-4 border-gray-200 dark:border-gray-700 ").concat(h?"":p("borderTop")),style:h?{borderTopColor:o}:{}}),e.jsx("div",{className:"absolute inset-0 ".concat(f[n]," border-4 border-transparent rounded-full animate-spin ").concat(h?"":p("borderRight")),style:h?{borderRightColor:o,animationDirection:"reverse",animationDuration:"0.75s"}:{animationDirection:"reverse",animationDuration:"0.75s"}})]})},w=function(){return e.jsx("div",{className:"flex space-x-1",children:[0,1,2].map((function(a){return e.jsx("div",{className:"".concat("sm"===n?"w-2 h-2":"md"===n?"w-3 h-3":"lg"===n?"w-4 h-4":"w-5 h-5"," rounded-full animate-bounce ").concat(h?"":p("bg")),style:h?{backgroundColor:o,animationDelay:"".concat(.2*a,"s"),animationDuration:"1.4s"}:{animationDelay:"".concat(.2*a,"s"),animationDuration:"1.4s"}},a)}))})},C=function(){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"".concat(f[n]," rounded-full animate-pulse ").concat(h?"":p("bg")),style:h?{backgroundColor:o}:{}}),e.jsx("div",{className:"absolute inset-0 ".concat(f[n]," rounded-full animate-ping opacity-30 ").concat(h?"":p("bg")),style:h?{backgroundColor:o}:{}})]})},D=function(){return e.jsx("div",{className:"flex space-x-1 items-end",children:[0,1,2,3].map((function(a){return e.jsx("div",{className:"".concat("sm"===n?"w-1":"md"===n?"w-1.5":"lg"===n?"w-2":"w-2.5"," rounded-sm animate-pulse ").concat(h?"":p("bg")),style:h?{backgroundColor:o,height:"".concat(20+10*a,"px"),animationDelay:"".concat(.15*a,"s"),animationDuration:"1.2s"}:{height:"".concat(20+10*a,"px"),animationDelay:"".concat(.15*a,"s"),animationDuration:"1.2s"}},a)}))})},k=function(){return e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"".concat(f[n]," border-4 rounded-full animate-ping ").concat(h?"":p("border")),style:h?{borderColor:o}:{}}),e.jsx("div",{className:"absolute inset-2 border-4 rounded-full animate-ping ".concat(h?"":p("border")),style:h?{borderColor:o,animationDelay:"0.5s"}:{animationDelay:"0.5s"}})]})},S=e.jsxs("div",{className:"flex flex-col items-center justify-center space-y-3 ".concat(m),children:[function(){if("image"===s&&x)return e.jsx(N,{});switch(s){case"dots":return e.jsx(w,{});case"pulse":return e.jsx(C,{});case"bars":return e.jsx(D,{});case"ripple":return e.jsx(k,{});default:return e.jsx(y,{})}}(),d&&e.jsx("p",{className:"".concat({sm:"text-xs",md:"text-sm",lg:"text-base",xl:"text-lg"}[n]," font-medium animate-pulse ").concat(h?"":p("text")),style:h?{color:o}:{},children:d})]});return c?e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-white/80 backdrop-blur-sm dark:bg-gray-950/80",children:S}):S};exports.LoadingDemo=function(){var n=a.useState("blue-500"),t=n[0],s=n[1],l=a.useState("spinner"),o=l[0],i=l[1],c=a.useState("md"),d=c[0],u=c[1],m=a.useState(!1),x=m[0],b=m[1],g=["spinner","dots","pulse","bars","ripple"];return e.jsxs("div",{className:"p-8 max-w-4xl mx-auto",children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-800 mb-8 text-center",children:"Modern Loading Component"}),e.jsxs("div",{className:"bg-white rounded-xl shadow-lg p-6 mb-8",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-4",children:"Customization"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-600 mb-2",children:"Color"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[{name:"Blue",value:"blue-500",hex:"#3B82F6"},{name:"Purple",value:"purple-500",hex:"#8B5CF6"},{name:"Green",value:"green-500",hex:"#10B981"},{name:"Red",value:"red-500",hex:"#EF4444"},{name:"Orange",value:"orange-500",hex:"#F59E0B"},{name:"Pink",value:"pink-500",hex:"#EC4899"},{name:"Indigo",value:"indigo-500",hex:"#6366F1"},{name:"Teal",value:"teal-500",hex:"#14B8A6"}].map((function(a){return e.jsx("button",{onClick:function(){return s(a.value)},className:"w-8 h-8 rounded-full border-2 transition-all ".concat(t===a.value?"border-gray-400 scale-110":"border-gray-200"),style:{backgroundColor:a.hex},title:"".concat(a.name," (").concat(a.value,")")},a.value)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-600 mb-2",children:"Variant"}),e.jsx("select",{value:o,onChange:function(e){return i(e.target.value)},className:"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:g.map((function(a){return e.jsx("option",{value:a,children:a&&(null==a?void 0:a.charAt(0).toUpperCase())+(null==a?void 0:a.slice(1))},a)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-600 mb-2",children:"Size"}),e.jsx("select",{value:d,onChange:function(e){return u(e.target.value)},className:"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:["sm","md","lg","xl"].map((function(a){return e.jsx("option",{value:a,children:null==a?void 0:a.toUpperCase()},a)}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-600 mb-2",children:"Full Screen"}),e.jsx("button",{onClick:function(){return b(!0)},className:"w-full p-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors",children:"Demo Full Screen"})]})]}),e.jsxs("div",{className:"bg-gray-50 rounded-lg p-8 flex flex-col items-center justify-center min-h-32",children:[e.jsx(r,{variant:o,size:d,color:t,text:"Loading..."}),e.jsx("div",{className:"mt-4 p-3 bg-white rounded-md shadow-sm",children:e.jsxs("code",{className:"text-sm text-gray-600",children:['color="',t,'"']})})]})]}),e.jsxs("div",{className:"bg-white rounded-xl shadow-lg p-6",children:[e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-4",children:"All Variants"}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-6",children:g.map((function(a){return e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"bg-gray-50 rounded-lg p-4 flex items-center justify-center h-24 mb-2",children:e.jsx(r,{variant:a,color:t})}),e.jsx("p",{className:"text-sm text-gray-600 capitalize",children:a})]},a)}))}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 rounded-lg",children:[e.jsx("h3",{className:"font-semibold text-blue-800 mb-2",children:"Usage Examples:"}),e.jsxs("div",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"bg-white p-2 rounded border",children:[e.jsx("code",{className:"text-blue-600",children:"// Tailwind CSS class"}),e.jsx("br",{}),e.jsx("code",{children:'<Loading color="primary-500" />'})]}),e.jsxs("div",{className:"bg-white p-2 rounded border",children:[e.jsx("code",{className:"text-blue-600",children:"// Hex color"}),e.jsx("br",{}),e.jsx("code",{children:'<Loading color="#your-brand-color" />'})]}),e.jsxs("div",{className:"bg-white p-2 rounded border",children:[e.jsx("code",{className:"text-blue-600",children:"// Custom Tailwind color"}),e.jsx("br",{}),e.jsx("code",{children:'<Loading color="emerald-400" variant="dots" />'})]})]})]})]}),x&&e.jsx(r,{variant:o,size:d,color:t,text:"Loading in full screen...",fullScreen:!0}),x&&e.jsx("button",{onClick:function(){return b(!1)},className:"fixed top-4 right-4 z-50 bg-red-500 text-white px-4 py-2 rounded-md hover:bg-red-600 transition-colors",children:"Close Full Screen"})]})},exports.default=r;
|
|
2
2
|
//# sourceMappingURL=Loading.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Loading.js","sources":["../../../../src/components/Loading/Loading.tsx"],"sourcesContent":["import React from 'react';\n\nexport interface LoadingProps {\n size?: 'sm' | 'md' | 'lg' | 'xl';\n variant?: 'spinner' | 'dots' | 'pulse' | 'bars' | 'ripple' | 'image';\n color?: string;\n fullScreen?: boolean;\n text?: string;\n className?: string;\n image?: string;\n imageEffect?: 'pulse' | 'bounce' | 'spin' | 'float' | 'heartbeat';\n}\n\nconst Loading: React.FC<LoadingProps> = ({\n size = 'md',\n variant = 'pulse',\n color = 'primary',\n fullScreen = false,\n text,\n className = '',\n image,\n imageEffect = 'pulse',\n }) => {\n // Check if color is a hex value or Tailwind class\n const isHexColor = color.startsWith('#');\n\n // Generate Tailwind classes for non-hex colors\n const getColorClasses = (property: string) => {\n if (isHexColor) return '';\n return {\n text: `text-${color}`,\n bg: `bg-${color}`,\n border: `border-${color}`,\n borderTop: `border-t-${color}`,\n borderRight: `border-r-${color}`,\n }[property] || '';\n };\n\n // Get inline styles for hex colors\n const getColorStyle = (property: string) => {\n if (!isHexColor) return {};\n const styleMap: Record<string, string> = {\n color: 'color',\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor',\n borderTopColor: 'borderTopColor',\n borderRightColor: 'borderRightColor',\n };\n return { [styleMap[property]]: color };\n };\n\n const sizeClasses = {\n sm: 'w-4 h-4',\n md: 'w-8 h-8',\n lg: 'w-12 h-12',\n xl: 'w-16 h-16',\n };\n\n const imageSizeClasses = {\n sm: 'w-8 h-8',\n md: 'w-12 h-12',\n lg: 'w-16 h-16',\n xl: 'w-20 h-20',\n };\n\n const textSizeClasses = {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-base',\n xl: 'text-lg',\n };\n\n const getImageEffectClasses = () => {\n switch (imageEffect) {\n case 'bounce':\n return 'animate-bounce';\n case 'spin':\n return 'animate-spin';\n case 'float':\n return 'animate-pulse hover:animate-bounce';\n case 'heartbeat':\n return 'animate-ping';\n default:\n return 'animate-pulse';\n }\n };\n\n const ImageLoader = () => (\n <div className=\"relative flex items-center justify-center\">\n <img\n src={image}\n alt=\"Loading\"\n className={`${imageSizeClasses[size]} object-contain ${getImageEffectClasses()}`}\n style={{\n filter: 'drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1))',\n animationDuration: imageEffect === 'heartbeat' ? '1.5s' : imageEffect === 'bounce' ? '1s' : '2s',\n }}\n />\n {imageEffect === 'float' && (\n <div\n className={`absolute inset-0 ${imageSizeClasses[size]} rounded-full bg-gradient-to-r from-purple-400 to-blue-400 opacity-20 animate-ping`}\n style={{ animationDuration: '2s' }}\n />\n )}\n </div>\n );\n\n const SpinnerLoader = () => (\n <div className=\"relative\">\n <div\n className={`${sizeClasses[size]} border-4 border-gray-200 rounded-full animate-spin ${\n !isHexColor ? getColorClasses('borderTop') : ''\n }`}\n style={isHexColor ? { borderTopColor: color } : {}}\n />\n <div\n className={`absolute inset-0 ${sizeClasses[size]} border-4 border-transparent rounded-full animate-spin ${\n !isHexColor ? getColorClasses('borderRight') : ''\n }`}\n style={isHexColor ? { borderRightColor: color, animationDirection: 'reverse', animationDuration: '0.75s' } : { animationDirection: 'reverse', animationDuration: '0.75s' }}\n />\n </div>\n );\n\n const DotsLoader = () => (\n <div className=\"flex space-x-1\">\n {[0, 1, 2].map((i) => (\n <div\n key={i}\n className={`${size === 'sm' ? 'w-2 h-2' : size === 'md' ? 'w-3 h-3' : size === 'lg' ? 'w-4 h-4' : 'w-5 h-5'} rounded-full animate-bounce ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? {\n backgroundColor: color,\n animationDelay: `${i * 0.2}s`,\n animationDuration: '1.4s'\n } : {\n animationDelay: `${i * 0.2}s`,\n animationDuration: '1.4s'\n }}\n />\n ))}\n </div>\n );\n\n const PulseLoader = () => (\n <div className=\"relative\">\n <div\n className={`${sizeClasses[size]} rounded-full animate-pulse ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? { backgroundColor: color } : {}}\n />\n <div\n className={`absolute inset-0 ${sizeClasses[size]} rounded-full animate-ping opacity-30 ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? { backgroundColor: color } : {}}\n />\n </div>\n );\n\n const BarsLoader = () => (\n <div className=\"flex space-x-1 items-end\">\n {[0, 1, 2, 3].map((i) => (\n <div\n key={i}\n className={`${size === 'sm' ? 'w-1' : size === 'md' ? 'w-1.5' : size === 'lg' ? 'w-2' : 'w-2.5'} rounded-sm animate-pulse ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? {\n backgroundColor: color,\n height: `${20 + i * 10}px`,\n animationDelay: `${i * 0.15}s`,\n animationDuration: '1.2s'\n } : {\n height: `${20 + i * 10}px`,\n animationDelay: `${i * 0.15}s`,\n animationDuration: '1.2s'\n }}\n />\n ))}\n </div>\n );\n\n const RippleLoader = () => (\n <div className=\"relative\">\n <div\n className={`${sizeClasses[size]} border-4 rounded-full animate-ping ${\n !isHexColor ? getColorClasses('border') : ''\n }`}\n style={isHexColor ? { borderColor: color } : {}}\n />\n <div\n className={`absolute inset-2 border-4 rounded-full animate-ping ${\n !isHexColor ? getColorClasses('border') : ''\n }`}\n style={isHexColor ? {\n borderColor: color,\n animationDelay: '0.5s'\n } : {\n animationDelay: '0.5s'\n }}\n />\n </div>\n );\n\n const getLoader = () => {\n if (variant === 'image' && image) {\n return <ImageLoader />;\n }\n\n switch (variant) {\n case 'dots':\n return <DotsLoader />;\n case 'pulse':\n return <PulseLoader />;\n case 'bars':\n return <BarsLoader />;\n case 'ripple':\n return <RippleLoader />;\n default:\n return <SpinnerLoader />;\n }\n };\n\n const content = (\n <div className={`flex flex-col items-center justify-center space-y-3 ${className}`}>\n {getLoader()}\n {text && (\n <p\n className={`${textSizeClasses[size]} font-medium animate-pulse ${\n !isHexColor ? getColorClasses('text') : ''\n }`}\n style={isHexColor ? { color } : {}}\n >\n {text}\n </p>\n )}\n </div>\n );\n\n if (fullScreen) {\n return (\n <div className=\"fixed inset-0 bg-white/80 backdrop-blur-sm flex items-center justify-center z-50\">\n {content}\n </div>\n );\n }\n\n return content;\n};\n\nexport default Loading;\n// Demo component to showcase different variants\nexport const LoadingDemo: React.FC = () => {\n const [selectedColor, setSelectedColor] = React.useState('blue-500');\n const [selectedVariant, setSelectedVariant] = React.useState<LoadingProps['variant']>('spinner');\n const [selectedSize, setSelectedSize] = React.useState<LoadingProps['size']>('md');\n const [showFullScreen, setShowFullScreen] = React.useState(false);\n\n const colors = [\n { name: 'Blue', value: 'blue-500', hex: '#3B82F6' },\n { name: 'Purple', value: 'purple-500', hex: '#8B5CF6' },\n { name: 'Green', value: 'green-500', hex: '#10B981' },\n { name: 'Red', value: 'red-500', hex: '#EF4444' },\n { name: 'Orange', value: 'orange-500', hex: '#F59E0B' },\n { name: 'Pink', value: 'pink-500', hex: '#EC4899' },\n { name: 'Indigo', value: 'indigo-500', hex: '#6366F1' },\n { name: 'Teal', value: 'teal-500', hex: '#14B8A6' },\n ];\n\n const variants: LoadingProps['variant'][] = ['spinner', 'dots', 'pulse', 'bars', 'ripple'];\n const sizes: LoadingProps['size'][] = ['sm', 'md', 'lg', 'xl'];\n\n return (\n <div className=\"p-8 max-w-4xl mx-auto\">\n <h1 className=\"text-3xl font-bold text-gray-800 mb-8 text-center\">\n Modern Loading Component\n </h1>\n\n <div className=\"bg-white rounded-xl shadow-lg p-6 mb-8\">\n <h2 className=\"text-xl font-semibold text-gray-700 mb-4\">Customization</h2>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6\">\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Color</label>\n <div className=\"flex flex-wrap gap-2\">\n {colors.map((colorOption) => (\n <button\n key={colorOption.value}\n onClick={() => setSelectedColor(colorOption.value)}\n className={`w-8 h-8 rounded-full border-2 transition-all ${\n selectedColor === colorOption.value ? 'border-gray-400 scale-110' : 'border-gray-200'\n }`}\n style={{ backgroundColor: colorOption.hex }}\n title={`${colorOption.name} (${colorOption.value})`}\n />\n ))}\n </div>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Variant</label>\n <select\n value={selectedVariant}\n onChange={(e) => setSelectedVariant(e.target.value as LoadingProps['variant'])}\n className=\"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent\"\n >\n {variants.map((variant) => (\n <option key={variant} value={variant}>\n {variant && (variant?.charAt(0).toUpperCase() + variant?.slice(1))}\n </option>\n ))}\n </select>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Size</label>\n <select\n value={selectedSize}\n onChange={(e) => setSelectedSize(e.target.value as LoadingProps['size'])}\n className=\"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent\"\n >\n {sizes.map((size) => (\n <option key={size} value={size}>\n {size?.toUpperCase()}\n </option>\n ))}\n </select>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Full Screen</label>\n <button\n onClick={() => setShowFullScreen(true)}\n className=\"w-full p-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors\"\n >\n Demo Full Screen\n </button>\n </div>\n </div>\n\n <div className=\"bg-gray-50 rounded-lg p-8 flex flex-col items-center justify-center min-h-32\">\n <Loading\n variant={selectedVariant}\n size={selectedSize}\n color={selectedColor}\n text=\"Loading...\"\n />\n <div className=\"mt-4 p-3 bg-white rounded-md shadow-sm\">\n <code className=\"text-sm text-gray-600\">\n color=\"{selectedColor}\"\n </code>\n </div>\n </div>\n </div>\n\n <div className=\"bg-white rounded-xl shadow-lg p-6\">\n <h2 className=\"text-xl font-semibold text-gray-700 mb-4\">All Variants</h2>\n <div className=\"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-6\">\n {variants.map((variant) => (\n <div key={variant} className=\"text-center\">\n <div className=\"bg-gray-50 rounded-lg p-4 flex items-center justify-center h-24 mb-2\">\n <Loading variant={variant} color={selectedColor} />\n </div>\n <p className=\"text-sm text-gray-600 capitalize\">{variant}</p>\n </div>\n ))}\n </div>\n\n <div className=\"mt-6 p-4 bg-blue-50 rounded-lg\">\n <h3 className=\"font-semibold text-blue-800 mb-2\">Usage Examples:</h3>\n <div className=\"space-y-2 text-sm\">\n <div className=\"bg-white p-2 rounded border\">\n <code className=\"text-blue-600\">{\"// Tailwind CSS class\"}</code><br/>\n <code>{`<Loading color=\"primary-500\" />`}</code>\n </div>\n <div className=\"bg-white p-2 rounded border\">\n <code className=\"text-blue-600\">{\"// Hex color\"}</code><br/>\n <code>{`<Loading color=\"#your-brand-color\" />`}</code>\n </div>\n <div className=\"bg-white p-2 rounded border\">\n <code className=\"text-blue-600\">{\"// Custom Tailwind color\"}</code><br/>\n <code>{`<Loading color=\"emerald-400\" variant=\"dots\" />`}</code>\n </div>\n </div>\n </div>\n </div>\n\n {showFullScreen && (\n <Loading\n variant={selectedVariant}\n size={selectedSize}\n color={selectedColor}\n text=\"Loading in full screen...\"\n fullScreen\n />\n )}\n\n {showFullScreen && (\n <button\n onClick={() => setShowFullScreen(false)}\n className=\"fixed top-4 right-4 z-50 bg-red-500 text-white px-4 py-2 rounded-md hover:bg-red-600 transition-colors\"\n >\n Close Full Screen\n </button>\n )}\n </div>\n );\n};"],"names":["Loading","_a","_b","size","_c","variant","_d","color","_e","fullScreen","text","_f","className","image","_g","imageEffect","isHexColor","startsWith","getColorClasses","property","concat","bg","border","borderTop","borderRight","sizeClasses","sm","md","lg","xl","imageSizeClasses","getImageEffectClasses","ImageLoader","_jsxs","children","_jsx","src","alt","style","filter","animationDuration","SpinnerLoader","borderTopColor","borderRightColor","animationDirection","DotsLoader","map","i","backgroundColor","animationDelay","PulseLoader","BarsLoader","height","RippleLoader","borderColor","content","getLoader","React","useState","selectedColor","setSelectedColor","selectedVariant","setSelectedVariant","selectedSize","setSelectedSize","showFullScreen","setShowFullScreen","variants","name","value","hex","colorOption","onClick","title","onChange","e","target","charAt","toUpperCase","slice"],"mappings":"0HAaMA,EAAkC,SAACC,OACIC,EAAAD,EAAAE,KAAAA,OAAI,IAAAD,EAAG,OACPE,EAAAH,EAAAI,QAAAA,OAAO,IAAAD,EAAG,QAAOA,EACjBE,UAAAC,aAAQ,UAASD,EACjBE,EAAAP,EAAAQ,WAAAA,OAAU,IAAAD,KACVE,SACAC,EAAAV,EAAAW,UAAAA,OAAS,IAAAD,EAAG,GAAEA,EACdE,EAAKZ,EAAAY,MACLC,gBAAAC,OAAW,IAAAD,EAAG,QAAOA,EAGxDE,EAAaT,EAAMU,WAAW,KAG9BC,EAAkB,SAACC,GACrB,OAAIH,EAAmB,GAChB,CACHN,KAAM,QAAAU,OAAQb,GACdc,GAAI,MAAAD,OAAMb,GACVe,OAAQ,UAAAF,OAAUb,GAClBgB,UAAW,YAAAH,OAAYb,GACvBiB,YAAa,YAAAJ,OAAYb,IAC3BY,IAAa,EACnB,EAeMM,EAAc,CAChBC,GAAI,UACJC,GAAI,UACJC,GAAI,YACJC,GAAI,aAGFC,EAAmB,CACrBJ,GAAI,UACJC,GAAI,YACJC,GAAI,YACJC,GAAI,aAUFE,EAAwB,WAC1B,OAAQhB,GACJ,IAAK,SACD,MAAO,iBACX,IAAK,OACD,MAAO,eACX,IAAK,QACD,MAAO,qCACX,IAAK,YACD,MAAO,eACX,QACI,MAAO,gBAEnB,EAEMiB,EAAc,WAAM,OACtBC,EAAAA,KA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loading.js","sources":["../../../../src/components/Loading/Loading.tsx"],"sourcesContent":["import React from 'react';\n\nexport interface LoadingProps {\n size?: 'sm' | 'md' | 'lg' | 'xl';\n variant?: 'spinner' | 'dots' | 'pulse' | 'bars' | 'ripple' | 'image';\n color?: string;\n fullScreen?: boolean;\n text?: string;\n className?: string;\n image?: string;\n imageEffect?: 'pulse' | 'bounce' | 'spin' | 'float' | 'heartbeat';\n}\n\nconst Loading: React.FC<LoadingProps> = ({\n size = 'md',\n variant = 'pulse',\n color = 'primary',\n fullScreen = false,\n text,\n className = '',\n image,\n imageEffect = 'pulse',\n }) => {\n // Check if color is a hex value or Tailwind class\n const isHexColor = color.startsWith('#');\n\n // Generate Tailwind classes for non-hex colors\n const getColorClasses = (property: string) => {\n if (isHexColor) return '';\n return {\n text: `text-${color}`,\n bg: `bg-${color}`,\n border: `border-${color}`,\n borderTop: `border-t-${color}`,\n borderRight: `border-r-${color}`,\n }[property] || '';\n };\n\n // Get inline styles for hex colors\n const getColorStyle = (property: string) => {\n if (!isHexColor) return {};\n const styleMap: Record<string, string> = {\n color: 'color',\n backgroundColor: 'backgroundColor',\n borderColor: 'borderColor',\n borderTopColor: 'borderTopColor',\n borderRightColor: 'borderRightColor',\n };\n return { [styleMap[property]]: color };\n };\n\n const sizeClasses = {\n sm: 'w-4 h-4',\n md: 'w-8 h-8',\n lg: 'w-12 h-12',\n xl: 'w-16 h-16',\n };\n\n const imageSizeClasses = {\n sm: 'w-8 h-8',\n md: 'w-12 h-12',\n lg: 'w-16 h-16',\n xl: 'w-20 h-20',\n };\n\n const textSizeClasses = {\n sm: 'text-xs',\n md: 'text-sm',\n lg: 'text-base',\n xl: 'text-lg',\n };\n\n const getImageEffectClasses = () => {\n switch (imageEffect) {\n case 'bounce':\n return 'animate-bounce';\n case 'spin':\n return 'animate-spin';\n case 'float':\n return 'animate-pulse hover:animate-bounce';\n case 'heartbeat':\n return 'animate-ping';\n default:\n return 'animate-pulse';\n }\n };\n\n const ImageLoader = () => (\n <div className=\"relative flex items-center justify-center\">\n <img\n src={image}\n alt=\"Loading\"\n className={`${imageSizeClasses[size]} object-contain ${getImageEffectClasses()}`}\n style={{\n filter: 'drop-shadow(0 4px 8px rgba(0, 0, 0, 0.1))',\n animationDuration: imageEffect === 'heartbeat' ? '1.5s' : imageEffect === 'bounce' ? '1s' : '2s',\n }}\n />\n {imageEffect === 'float' && (\n <div\n className={`absolute inset-0 ${imageSizeClasses[size]} rounded-full bg-gradient-to-r from-purple-400 to-blue-400 opacity-20 animate-ping`}\n style={{ animationDuration: '2s' }}\n />\n )}\n </div>\n );\n\n const SpinnerLoader = () => (\n <div className=\"relative\">\n <div\n className={`${sizeClasses[size]} animate-spin rounded-full border-4 border-gray-200 dark:border-gray-700 ${\n !isHexColor ? getColorClasses('borderTop') : ''\n }`}\n style={isHexColor ? { borderTopColor: color } : {}}\n />\n <div\n className={`absolute inset-0 ${sizeClasses[size]} border-4 border-transparent rounded-full animate-spin ${\n !isHexColor ? getColorClasses('borderRight') : ''\n }`}\n style={isHexColor ? { borderRightColor: color, animationDirection: 'reverse', animationDuration: '0.75s' } : { animationDirection: 'reverse', animationDuration: '0.75s' }}\n />\n </div>\n );\n\n const DotsLoader = () => (\n <div className=\"flex space-x-1\">\n {[0, 1, 2].map((i) => (\n <div\n key={i}\n className={`${size === 'sm' ? 'w-2 h-2' : size === 'md' ? 'w-3 h-3' : size === 'lg' ? 'w-4 h-4' : 'w-5 h-5'} rounded-full animate-bounce ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? {\n backgroundColor: color,\n animationDelay: `${i * 0.2}s`,\n animationDuration: '1.4s'\n } : {\n animationDelay: `${i * 0.2}s`,\n animationDuration: '1.4s'\n }}\n />\n ))}\n </div>\n );\n\n const PulseLoader = () => (\n <div className=\"relative\">\n <div\n className={`${sizeClasses[size]} rounded-full animate-pulse ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? { backgroundColor: color } : {}}\n />\n <div\n className={`absolute inset-0 ${sizeClasses[size]} rounded-full animate-ping opacity-30 ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? { backgroundColor: color } : {}}\n />\n </div>\n );\n\n const BarsLoader = () => (\n <div className=\"flex space-x-1 items-end\">\n {[0, 1, 2, 3].map((i) => (\n <div\n key={i}\n className={`${size === 'sm' ? 'w-1' : size === 'md' ? 'w-1.5' : size === 'lg' ? 'w-2' : 'w-2.5'} rounded-sm animate-pulse ${\n !isHexColor ? getColorClasses('bg') : ''\n }`}\n style={isHexColor ? {\n backgroundColor: color,\n height: `${20 + i * 10}px`,\n animationDelay: `${i * 0.15}s`,\n animationDuration: '1.2s'\n } : {\n height: `${20 + i * 10}px`,\n animationDelay: `${i * 0.15}s`,\n animationDuration: '1.2s'\n }}\n />\n ))}\n </div>\n );\n\n const RippleLoader = () => (\n <div className=\"relative\">\n <div\n className={`${sizeClasses[size]} border-4 rounded-full animate-ping ${\n !isHexColor ? getColorClasses('border') : ''\n }`}\n style={isHexColor ? { borderColor: color } : {}}\n />\n <div\n className={`absolute inset-2 border-4 rounded-full animate-ping ${\n !isHexColor ? getColorClasses('border') : ''\n }`}\n style={isHexColor ? {\n borderColor: color,\n animationDelay: '0.5s'\n } : {\n animationDelay: '0.5s'\n }}\n />\n </div>\n );\n\n const getLoader = () => {\n if (variant === 'image' && image) {\n return <ImageLoader />;\n }\n\n switch (variant) {\n case 'dots':\n return <DotsLoader />;\n case 'pulse':\n return <PulseLoader />;\n case 'bars':\n return <BarsLoader />;\n case 'ripple':\n return <RippleLoader />;\n default:\n return <SpinnerLoader />;\n }\n };\n\n const content = (\n <div className={`flex flex-col items-center justify-center space-y-3 ${className}`}>\n {getLoader()}\n {text && (\n <p\n className={`${textSizeClasses[size]} font-medium animate-pulse ${\n !isHexColor ? getColorClasses('text') : ''\n }`}\n style={isHexColor ? { color } : {}}\n >\n {text}\n </p>\n )}\n </div>\n );\n\n if (fullScreen) {\n return (\n <div className=\"fixed inset-0 z-50 flex items-center justify-center bg-white/80 backdrop-blur-sm dark:bg-gray-950/80\">\n {content}\n </div>\n );\n }\n\n return content;\n};\n\nexport default Loading;\n// Demo component to showcase different variants\nexport const LoadingDemo: React.FC = () => {\n const [selectedColor, setSelectedColor] = React.useState('blue-500');\n const [selectedVariant, setSelectedVariant] = React.useState<LoadingProps['variant']>('spinner');\n const [selectedSize, setSelectedSize] = React.useState<LoadingProps['size']>('md');\n const [showFullScreen, setShowFullScreen] = React.useState(false);\n\n const colors = [\n { name: 'Blue', value: 'blue-500', hex: '#3B82F6' },\n { name: 'Purple', value: 'purple-500', hex: '#8B5CF6' },\n { name: 'Green', value: 'green-500', hex: '#10B981' },\n { name: 'Red', value: 'red-500', hex: '#EF4444' },\n { name: 'Orange', value: 'orange-500', hex: '#F59E0B' },\n { name: 'Pink', value: 'pink-500', hex: '#EC4899' },\n { name: 'Indigo', value: 'indigo-500', hex: '#6366F1' },\n { name: 'Teal', value: 'teal-500', hex: '#14B8A6' },\n ];\n\n const variants: LoadingProps['variant'][] = ['spinner', 'dots', 'pulse', 'bars', 'ripple'];\n const sizes: LoadingProps['size'][] = ['sm', 'md', 'lg', 'xl'];\n\n return (\n <div className=\"p-8 max-w-4xl mx-auto\">\n <h1 className=\"text-3xl font-bold text-gray-800 mb-8 text-center\">\n Modern Loading Component\n </h1>\n\n <div className=\"bg-white rounded-xl shadow-lg p-6 mb-8\">\n <h2 className=\"text-xl font-semibold text-gray-700 mb-4\">Customization</h2>\n\n <div className=\"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-6\">\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Color</label>\n <div className=\"flex flex-wrap gap-2\">\n {colors.map((colorOption) => (\n <button\n key={colorOption.value}\n onClick={() => setSelectedColor(colorOption.value)}\n className={`w-8 h-8 rounded-full border-2 transition-all ${\n selectedColor === colorOption.value ? 'border-gray-400 scale-110' : 'border-gray-200'\n }`}\n style={{ backgroundColor: colorOption.hex }}\n title={`${colorOption.name} (${colorOption.value})`}\n />\n ))}\n </div>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Variant</label>\n <select\n value={selectedVariant}\n onChange={(e) => setSelectedVariant(e.target.value as LoadingProps['variant'])}\n className=\"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent\"\n >\n {variants.map((variant) => (\n <option key={variant} value={variant}>\n {variant && (variant?.charAt(0).toUpperCase() + variant?.slice(1))}\n </option>\n ))}\n </select>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Size</label>\n <select\n value={selectedSize}\n onChange={(e) => setSelectedSize(e.target.value as LoadingProps['size'])}\n className=\"w-full p-2 border border-gray-300 rounded-md focus:ring-2 focus:ring-blue-500 focus:border-transparent\"\n >\n {sizes.map((size) => (\n <option key={size} value={size}>\n {size?.toUpperCase()}\n </option>\n ))}\n </select>\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-gray-600 mb-2\">Full Screen</label>\n <button\n onClick={() => setShowFullScreen(true)}\n className=\"w-full p-2 bg-gray-600 text-white rounded-md hover:bg-gray-700 transition-colors\"\n >\n Demo Full Screen\n </button>\n </div>\n </div>\n\n <div className=\"bg-gray-50 rounded-lg p-8 flex flex-col items-center justify-center min-h-32\">\n <Loading\n variant={selectedVariant}\n size={selectedSize}\n color={selectedColor}\n text=\"Loading...\"\n />\n <div className=\"mt-4 p-3 bg-white rounded-md shadow-sm\">\n <code className=\"text-sm text-gray-600\">\n color=\"{selectedColor}\"\n </code>\n </div>\n </div>\n </div>\n\n <div className=\"bg-white rounded-xl shadow-lg p-6\">\n <h2 className=\"text-xl font-semibold text-gray-700 mb-4\">All Variants</h2>\n <div className=\"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-5 gap-6\">\n {variants.map((variant) => (\n <div key={variant} className=\"text-center\">\n <div className=\"bg-gray-50 rounded-lg p-4 flex items-center justify-center h-24 mb-2\">\n <Loading variant={variant} color={selectedColor} />\n </div>\n <p className=\"text-sm text-gray-600 capitalize\">{variant}</p>\n </div>\n ))}\n </div>\n\n <div className=\"mt-6 p-4 bg-blue-50 rounded-lg\">\n <h3 className=\"font-semibold text-blue-800 mb-2\">Usage Examples:</h3>\n <div className=\"space-y-2 text-sm\">\n <div className=\"bg-white p-2 rounded border\">\n <code className=\"text-blue-600\">{\"// Tailwind CSS class\"}</code><br/>\n <code>{`<Loading color=\"primary-500\" />`}</code>\n </div>\n <div className=\"bg-white p-2 rounded border\">\n <code className=\"text-blue-600\">{\"// Hex color\"}</code><br/>\n <code>{`<Loading color=\"#your-brand-color\" />`}</code>\n </div>\n <div className=\"bg-white p-2 rounded border\">\n <code className=\"text-blue-600\">{\"// Custom Tailwind color\"}</code><br/>\n <code>{`<Loading color=\"emerald-400\" variant=\"dots\" />`}</code>\n </div>\n </div>\n </div>\n </div>\n\n {showFullScreen && (\n <Loading\n variant={selectedVariant}\n size={selectedSize}\n color={selectedColor}\n text=\"Loading in full screen...\"\n fullScreen\n />\n )}\n\n {showFullScreen && (\n <button\n onClick={() => setShowFullScreen(false)}\n className=\"fixed top-4 right-4 z-50 bg-red-500 text-white px-4 py-2 rounded-md hover:bg-red-600 transition-colors\"\n >\n Close Full Screen\n </button>\n )}\n </div>\n );\n};\n"],"names":["Loading","_a","_b","size","_c","variant","_d","color","_e","fullScreen","text","_f","className","image","_g","imageEffect","isHexColor","startsWith","getColorClasses","property","concat","bg","border","borderTop","borderRight","sizeClasses","sm","md","lg","xl","imageSizeClasses","getImageEffectClasses","ImageLoader","_jsxs","children","_jsx","src","alt","style","filter","animationDuration","SpinnerLoader","borderTopColor","borderRightColor","animationDirection","DotsLoader","map","i","backgroundColor","animationDelay","PulseLoader","BarsLoader","height","RippleLoader","borderColor","content","getLoader","React","useState","selectedColor","setSelectedColor","selectedVariant","setSelectedVariant","selectedSize","setSelectedSize","showFullScreen","setShowFullScreen","variants","name","value","hex","colorOption","onClick","title","onChange","e","target","char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,KAAA,CAAIvB,UAAU,mCAAkCsB,SAAA,oBAChDD,EAAAA,KAAA,MAAA,CAAKrB,UAAU,oBAAmBsB,SAAA,CAC9BD,EAAAA,KAAA,MAAA,CAAKrB,UAAU,8BAA6BsB,SAAA,CACxCC,MAAA,OAAA,CAAMvB,UAAU,gBAAesB,SAAE,0BAA+BC,EAAAA,IAAA,KAAA,CAAA,GAChEA,EAAAA,IAAA,OAAA,CAAAD,SAAO,uCAEXD,OAAA,MAAA,CAAKrB,UAAU,8BAA6BsB,SAAA,CACxCC,EAAAA,IAAA,OAAA,CAAMvB,UAAU,gBAAesB,SAAE,iBAAsBC,EAAAA,IAAA,KAAA,CAAA,GACvDA,EAAAA,IAAA,OAAA,CAAAD,SAAO,6CAEXD,EAAAA,KAAA,MAAA,CAAKrB,UAAU,wCACXuB,EAAAA,IAAA,OAAA,CAAMvB,UAAU,gBAAesB,SAAE,6BAAkCC,EAAAA,IAAA,KAAA,CAAA,GACnEA,EAAAA,IAAA,OAAA,CAAAD,SAAO,+DAMtB+B,GACG9B,EAAAA,IAACnC,EAAO,CACJK,QAASwD,EACT1D,KAAM4D,EACNxD,MAAOoD,EACPjD,KAAK,4BACLD,YAAU,IAIjBwD,GACG9B,EAAAA,IAAA,SAAA,CACIqC,QAAS,WAAM,OAAAN,GAAkB,EAAlB,EACftD,UAAU,yGAAwGsB,SAAA,wBAOtI"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("react/jsx-runtime"),r=require("../Button/Button.js");require("../Button/ExportButton.js"),exports.Pagination=function(a){var t=a.currentPage,n=a.totalPages,i=a.totalItems,s=a.itemsPerPage,d=a.onPageChange,l=a.onViewChange,o=a.loading,c=void 0!==o&&o,g=function(e){e>0&&e<=n&&!c&&d&&d(e)},u=(t-1)*s,x=Math.min(u+s,i);return e.jsxs("div",{className:"flex items-center justify-between border-t border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-900",children:[e.jsx("div",{className:"block flex-1 sm:hidden",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:function(){return g(t-1)},disabled:1===t||c,className:"relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ".concat(1===t||c?"cursor-not-allowed opacity-50":""),children:"Previous"}),e.jsx("button",{onClick:function(){return g(t+1)},disabled:t===n||c,className:"relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ".concat(t===n||c?"cursor-not-allowed opacity-50":""),children:"Next"})]})}),e.jsxs("div",{className:"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:s,onChange:function(e){return l&&l(e.target.value)},disabled:c,className:"appearance-none rounded-md border border-gray-300 bg-white py-2 pl-3 pr-8 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",children:[10,20,30,50,100].map((function(r){return e.jsx("option",{value:r,children:r},r)}))}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300",children:e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:[e.jsxs("span",{children:[i," Entries"]}),e.jsxs("span",{className:"ml-1",children:["(Showing ",u+1,"-",x," of ",i,")"]})]})]}),e.jsx("div",{children:e.jsxs("nav",{className:"relative z-0 inline-flex gap-2 -space-x-px rounded-md shadow-sm","aria-label":"Pagination",children:[e.jsxs("button",{onClick:function(){return g(t-1)},disabled:1===t||c,className:"relative inline-flex items-center rounded-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 ".concat(1===t||c?"cursor-not-allowed opacity-50":""),children:[e.jsx("span",{className:"sr-only",children:"Previous"}),e.jsx("svg",{className:"h-5 w-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})]}),function(){var e=[];if(n<=5)for(var r=1;r<=n;r++)e.push(r);else{var a=Math.max(1,t-2),i=Math.min(n,a+5-1);i-a<4&&(a=Math.max(1,i-5+1));for(r=a;r<=i;r++)e.push(r)}return e}().map((function(r){return e.jsx("button",{onClick:function(){return g(r)},disabled:c,"aria-current":t===r?"page":void 0,className:"relative inline-flex items-center rounded-md border px-4 py-2 text-sm font-semibold ".concat(t===r?"z-10 border-primary-100 bg-primary-50 text-primary":"border-gray-300 bg-white text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"," ").concat(c?"cursor-not-allowed opacity-50":""),children:r},r)})),e.jsxs(r,{onClick:function(){return g(t+1)},disabled:t===n||c,type:"button",variant:"primary",size:"sm",outline:!0,children:["Next Page",e.jsx("svg",{className:"h-5 w-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]})})]})]})};
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),r=require("../Button/Button.js");require("../Button/ExportButton.js"),exports.Pagination=function(a){var t=a.currentPage,n=a.totalPages,i=a.totalItems,s=a.itemsPerPage,d=a.onPageChange,l=a.onViewChange,o=a.loading,c=void 0!==o&&o,g=function(e){e>0&&e<=n&&!c&&d&&d(e)},u=(t-1)*s,x=Math.min(u+s,i);return e.jsxs("div",{className:"flex items-center justify-between border-t rounded-lg border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-900",children:[e.jsx("div",{className:"block flex-1 sm:hidden",children:e.jsxs("div",{className:"flex justify-between",children:[e.jsx("button",{onClick:function(){return g(t-1)},disabled:1===t||c,className:"relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ".concat(1===t||c?"cursor-not-allowed opacity-50":""),children:"Previous"}),e.jsx("button",{onClick:function(){return g(t+1)},disabled:t===n||c,className:"relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ".concat(t===n||c?"cursor-not-allowed opacity-50":""),children:"Next"})]})}),e.jsxs("div",{className:"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex items-center justify-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("select",{value:s,onChange:function(e){return l&&l(e.target.value)},disabled:c,className:"appearance-none rounded-md border border-gray-300 bg-white py-2 pl-3 pr-8 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200",children:[10,20,30,50,100].map((function(r){return e.jsx("option",{value:r,children:r},r)}))}),e.jsx("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300",children:e.jsx("svg",{className:"h-4 w-4",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z",clipRule:"evenodd"})})})]}),e.jsxs("p",{className:"text-sm text-gray-700 dark:text-gray-300",children:[e.jsxs("span",{children:[i," Entries"]}),e.jsxs("span",{className:"ml-1",children:["(Showing ",u+1,"-",x," of ",i,")"]})]})]}),e.jsx("div",{children:e.jsxs("nav",{className:"relative z-0 inline-flex gap-2 -space-x-px rounded-md shadow-sm","aria-label":"Pagination",children:[e.jsxs("button",{onClick:function(){return g(t-1)},disabled:1===t||c,className:"relative inline-flex items-center rounded-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 ".concat(1===t||c?"cursor-not-allowed opacity-50":""),children:[e.jsx("span",{className:"sr-only",children:"Previous"}),e.jsx("svg",{className:"h-5 w-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z",clipRule:"evenodd"})})]}),function(){var e=[];if(n<=5)for(var r=1;r<=n;r++)e.push(r);else{var a=Math.max(1,t-2),i=Math.min(n,a+5-1);i-a<4&&(a=Math.max(1,i-5+1));for(r=a;r<=i;r++)e.push(r)}return e}().map((function(r){return e.jsx("button",{onClick:function(){return g(r)},disabled:c,"aria-current":t===r?"page":void 0,className:"relative inline-flex items-center rounded-md border px-4 py-2 text-sm font-semibold ".concat(t===r?"z-10 border-primary-100 bg-primary-50 text-primary":"border-gray-300 bg-white text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700"," ").concat(c?"cursor-not-allowed opacity-50":""),children:r},r)})),e.jsxs(r,{onClick:function(){return g(t+1)},disabled:t===n||c,type:"button",variant:"primary",size:"sm",outline:!0,children:["Next Page",e.jsx("svg",{className:"h-5 w-5",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor","aria-hidden":"true",children:e.jsx("path",{fillRule:"evenodd",d:"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",clipRule:"evenodd"})})]})]})})]})]})};
|
|
2
2
|
//# sourceMappingURL=Pagination.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Pagination.js","sources":["../../../../src/components/Table/Pagination.tsx"],"sourcesContent":["import { PaginationProps } from \"./types\";\nimport { Button } from \"../Button\";\n\nexport function Pagination({\n currentPage,\n totalPages,\n totalItems,\n itemsPerPage,\n onPageChange,\n onViewChange,\n loading = false,\n}: PaginationProps) {\n const perPageOptions = [10, 20, 30, 50, 100];\n const goToPage = (page: number) => {\n if (page > 0 && page <= totalPages && !loading && onPageChange) {\n onPageChange(page);\n }\n };\n\n const getPageNumbers = () => {\n const pageNumbers = [];\n const maxPagesToShow = 5;\n\n if (totalPages <= maxPagesToShow) {\n for (let i = 1; i <= totalPages; i++) {\n pageNumbers.push(i);\n }\n } else {\n let startPage = Math.max(1, currentPage - 2);\n const endPage = Math.min(totalPages, startPage + maxPagesToShow - 1);\n\n if (endPage - startPage < maxPagesToShow - 1) {\n startPage = Math.max(1, endPage - maxPagesToShow + 1);\n }\n\n for (let i = startPage; i <= endPage; i++) {\n pageNumbers.push(i);\n }\n }\n\n return pageNumbers;\n };\n\n const startIndex = (currentPage - 1) * itemsPerPage;\n const endIndex = Math.min(startIndex + itemsPerPage, totalItems);\n\n return (\n <div className=\"flex items-center justify-between border-t border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-900\">\n <div className=\"block flex-1 sm:hidden\">\n <div className=\"flex justify-between\">\n <button\n onClick={() => goToPage(currentPage - 1)}\n disabled={currentPage === 1 || loading}\n className={`relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ${\n currentPage === 1 || loading\n ? \"cursor-not-allowed opacity-50\"\n : \"\"\n }`}\n >\n Previous\n </button>\n <button\n onClick={() => goToPage(currentPage + 1)}\n disabled={currentPage === totalPages || loading}\n className={`relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ${\n currentPage === totalPages || loading\n ? \"cursor-not-allowed opacity-50\"\n : \"\"\n }`}\n >\n Next\n </button>\n </div>\n </div>\n\n <div className=\"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between\">\n <div className=\"flex items-center justify-center gap-2\">\n {/*{onViewChange && (*/}\n <div className=\"relative\">\n <select\n value={itemsPerPage}\n onChange={(e) => onViewChange && onViewChange(e.target.value)}\n disabled={loading}\n className=\"appearance-none rounded-md border border-gray-300 bg-white py-2 pl-3 pr-8 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200\"\n >\n {perPageOptions.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </select>\n <div className=\"pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300\">\n <svg className=\"h-4 w-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </div>\n </div>\n {/*)}*/}\n <p className=\"text-sm text-gray-700 dark:text-gray-300\">\n <span>{totalItems} Entries</span>\n <span className=\"ml-1\">\n (Showing {startIndex + 1}-{endIndex} of {totalItems})\n </span>\n </p>\n </div>\n <div>\n <nav\n className=\"relative z-0 inline-flex gap-2 -space-x-px rounded-md shadow-sm\"\n aria-label=\"Pagination\"\n >\n <button\n onClick={() => goToPage(currentPage - 1)}\n disabled={currentPage === 1 || loading}\n className={`relative inline-flex items-center rounded-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 ${\n currentPage === 1 || loading\n ? \"cursor-not-allowed opacity-50\"\n : \"\"\n }`}\n >\n <span className=\"sr-only\">Previous</span>\n <svg\n className=\"h-5 w-5\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n {getPageNumbers().map((number) => (\n <button\n key={number}\n onClick={() => goToPage(number)}\n disabled={loading}\n aria-current={currentPage === number ? \"page\" : undefined}\n className={`relative inline-flex items-center rounded-md border px-4 py-2 text-sm font-semibold ${\n currentPage === number\n ? \"z-10 border-primary-100 bg-primary-50 text-primary\"\n : \"border-gray-300 bg-white text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700\"\n } ${loading ? \"cursor-not-allowed opacity-50\" : \"\"}`}\n >\n {number}\n </button>\n ))}\n\n <Button\n onClick={() => goToPage(currentPage + 1)}\n disabled={currentPage === totalPages || loading}\n type=\"button\"\n variant=\"primary\"\n size=\"sm\"\n outline\n >\n Next Page\n <svg\n className=\"h-5 w-5\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </Button>\n </nav>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["_a","currentPage","totalPages","totalItems","itemsPerPage","onPageChange","onViewChange","_b","loading","goToPage","page","startIndex","endIndex","Math","min","_jsxs","className","children","_jsx","onClick","disabled","concat","value","onChange","e","target","map","option","fill","viewBox","fillRule","d","clipRule","xmlns","pageNumbers","i","push","startPage","max","endPage","maxPagesToShow","getPageNumbers","number","undefined","Button","type","variant","size","outline"],"mappings":"yIAGM,SAAqBA,OACzBC,EAAWD,EAAAC,YACXC,EAAUF,EAAAE,WACVC,EAAUH,EAAAG,WACVC,EAAYJ,EAAAI,aACZC,EAAYL,EAAAK,aACZC,EAAYN,EAAAM,aACZC,YAAAC,OAAO,IAAAD,GAAQA,EAGTE,EAAW,SAACC,GACZA,EAAO,GAAKA,GAAQR,IAAeM,GAAWH,GAChDA,EAAaK,EAEjB,EA0BMC,GAAcV,EAAc,GAAKG,EACjCQ,EAAWC,KAAKC,IAAIH,EAAaP,EAAcD,GAErD,OACEY,EAAAA,YAAKC,UAAU,gHAA+GC,SAAA,CAC5HC,EAAAA,IAAA,MAAA,CAAKF,UAAU,kCACbD,EAAAA,KAAA,MAAA,CAAKC,UAAU,uBAAsBC,SAAA,CACnCC,EAAAA,cACEC,QAAS,WAAM,OAAAV,EAASR,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file":"Pagination.js","sources":["../../../../src/components/Table/Pagination.tsx"],"sourcesContent":["import { PaginationProps } from \"./types\";\nimport { Button } from \"../Button\";\n\nexport function Pagination({\n currentPage,\n totalPages,\n totalItems,\n itemsPerPage,\n onPageChange,\n onViewChange,\n loading = false,\n}: PaginationProps) {\n const perPageOptions = [10, 20, 30, 50, 100];\n const goToPage = (page: number) => {\n if (page > 0 && page <= totalPages && !loading && onPageChange) {\n onPageChange(page);\n }\n };\n\n const getPageNumbers = () => {\n const pageNumbers = [];\n const maxPagesToShow = 5;\n\n if (totalPages <= maxPagesToShow) {\n for (let i = 1; i <= totalPages; i++) {\n pageNumbers.push(i);\n }\n } else {\n let startPage = Math.max(1, currentPage - 2);\n const endPage = Math.min(totalPages, startPage + maxPagesToShow - 1);\n\n if (endPage - startPage < maxPagesToShow - 1) {\n startPage = Math.max(1, endPage - maxPagesToShow + 1);\n }\n\n for (let i = startPage; i <= endPage; i++) {\n pageNumbers.push(i);\n }\n }\n\n return pageNumbers;\n };\n\n const startIndex = (currentPage - 1) * itemsPerPage;\n const endIndex = Math.min(startIndex + itemsPerPage, totalItems);\n\n return (\n <div className=\"flex items-center justify-between border-t rounded-lg border-gray-200 bg-white p-3 dark:border-gray-700 dark:bg-gray-900\">\n <div className=\"block flex-1 sm:hidden\">\n <div className=\"flex justify-between\">\n <button\n onClick={() => goToPage(currentPage - 1)}\n disabled={currentPage === 1 || loading}\n className={`relative inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ${\n currentPage === 1 || loading\n ? \"cursor-not-allowed opacity-50\"\n : \"\"\n }`}\n >\n Previous\n </button>\n <button\n onClick={() => goToPage(currentPage + 1)}\n disabled={currentPage === totalPages || loading}\n className={`relative ml-3 inline-flex items-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200 dark:hover:bg-gray-700 ${\n currentPage === totalPages || loading\n ? \"cursor-not-allowed opacity-50\"\n : \"\"\n }`}\n >\n Next\n </button>\n </div>\n </div>\n\n <div className=\"hidden sm:flex sm:flex-1 sm:items-center sm:justify-between\">\n <div className=\"flex items-center justify-center gap-2\">\n {/*{onViewChange && (*/}\n <div className=\"relative\">\n <select\n value={itemsPerPage}\n onChange={(e) => onViewChange && onViewChange(e.target.value)}\n disabled={loading}\n className=\"appearance-none rounded-md border border-gray-300 bg-white py-2 pl-3 pr-8 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-200\"\n >\n {perPageOptions.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </select>\n <div className=\"pointer-events-none absolute inset-y-0 right-0 flex items-center px-2 text-gray-700 dark:text-gray-300\">\n <svg className=\"h-4 w-4\" fill=\"currentColor\" viewBox=\"0 0 20 20\">\n <path\n fillRule=\"evenodd\"\n d=\"M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </div>\n </div>\n {/*)}*/}\n <p className=\"text-sm text-gray-700 dark:text-gray-300\">\n <span>{totalItems} Entries</span>\n <span className=\"ml-1\">\n (Showing {startIndex + 1}-{endIndex} of {totalItems})\n </span>\n </p>\n </div>\n <div>\n <nav\n className=\"relative z-0 inline-flex gap-2 -space-x-px rounded-md shadow-sm\"\n aria-label=\"Pagination\"\n >\n <button\n onClick={() => goToPage(currentPage - 1)}\n disabled={currentPage === 1 || loading}\n className={`relative inline-flex items-center rounded-md border border-gray-300 bg-white px-2 py-2 text-sm font-medium text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700 ${\n currentPage === 1 || loading\n ? \"cursor-not-allowed opacity-50\"\n : \"\"\n }`}\n >\n <span className=\"sr-only\">Previous</span>\n <svg\n className=\"h-5 w-5\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M12.707 5.293a1 1 0 010 1.414L9.414 10l3.293 3.293a1 1 0 01-1.414 1.414l-4-4a1 1 0 010-1.414l4-4a1 1 0 011.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </button>\n\n {getPageNumbers().map((number) => (\n <button\n key={number}\n onClick={() => goToPage(number)}\n disabled={loading}\n aria-current={currentPage === number ? \"page\" : undefined}\n className={`relative inline-flex items-center rounded-md border px-4 py-2 text-sm font-semibold ${\n currentPage === number\n ? \"z-10 border-primary-100 bg-primary-50 text-primary\"\n : \"border-gray-300 bg-white text-gray-500 hover:bg-gray-50 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-300 dark:hover:bg-gray-700\"\n } ${loading ? \"cursor-not-allowed opacity-50\" : \"\"}`}\n >\n {number}\n </button>\n ))}\n\n <Button\n onClick={() => goToPage(currentPage + 1)}\n disabled={currentPage === totalPages || loading}\n type=\"button\"\n variant=\"primary\"\n size=\"sm\"\n outline\n >\n Next Page\n <svg\n className=\"h-5 w-5\"\n xmlns=\"http://www.w3.org/2000/svg\"\n viewBox=\"0 0 20 20\"\n fill=\"currentColor\"\n aria-hidden=\"true\"\n >\n <path\n fillRule=\"evenodd\"\n d=\"M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z\"\n clipRule=\"evenodd\"\n />\n </svg>\n </Button>\n </nav>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["_a","currentPage","totalPages","totalItems","itemsPerPage","onPageChange","onViewChange","_b","loading","goToPage","page","startIndex","endIndex","Math","min","_jsxs","className","children","_jsx","onClick","disabled","concat","value","onChange","e","target","map","option","fill","viewBox","fillRule","d","clipRule","xmlns","pageNumbers","i","push","startPage","max","endPage","maxPagesToShow","getPageNumbers","number","undefined","Button","type","variant","size","outline"],"mappings":"yIAGM,SAAqBA,OACzBC,EAAWD,EAAAC,YACXC,EAAUF,EAAAE,WACVC,EAAUH,EAAAG,WACVC,EAAYJ,EAAAI,aACZC,EAAYL,EAAAK,aACZC,EAAYN,EAAAM,aACZC,YAAAC,OAAO,IAAAD,GAAQA,EAGTE,EAAW,SAACC,GACZA,EAAO,GAAKA,GAAQR,IAAeM,GAAWH,GAChDA,EAAaK,EAEjB,EA0BMC,GAAcV,EAAc,GAAKG,EACjCQ,EAAWC,KAAKC,IAAIH,EAAaP,EAAcD,GAErD,OACEY,EAAAA,YAAKC,UAAU,2HAA0HC,SAAA,CACvIC,EAAAA,IAAA,MAAA,CAAKF,UAAU,kCACbD,EAAAA,KAAA,MAAA,CAAKC,UAAU,uBAAsBC,SAAA,CACnCC,EAAAA,cACEC,QAAS,WAAM,OAAAV,EAASR,EAAc,EAAvB,EACfmB,SAA0B,IAAhBnB,GAAqBO,EAC/BQ,UAAW,oOACO,IAAhBf,GAAqBO,EACjB,gCACA,IACJS,SAAA,aAIJC,EAAAA,IAAA,SAAA,CACEC,QAAS,WAAM,OAAAV,EAASR,EAAc,EAAvB,EACfmB,SAAUnB,IAAgBC,GAAcM,EACxCQ,UAAW,kOAAAK,OACTpB,IAAgBC,GAAcM,EAC1B,gCACA,2BAQZO,OAAA,MAAA,CAAKC,UAAU,wEACbD,EAAAA,KAAA,MAAA,CAAKC,UAAU,yCAAwCC,SAAA,CAErDF,EAAAA,YAAKC,UAAU,WAAUC,SAAA,CACvBC,EAAAA,cACEI,MAAOlB,EACPmB,SAAU,SAACC,GAAM,OAAAlB,GAAgBA,EAAakB,EAAEC,OAAOH,MAAtC,EACjBF,SAAUZ,EACVQ,UAAU,iMAAgMC,SAvE/L,CAAC,GAAI,GAAI,GAAI,GAAI,KAyEZS,KAAI,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A,OAAOD,CACT,CAkGWO,GAAiBf,KAAI,SAACgB,GAAW,OAChCxB,EAAAA,cAEEC,QAAS,WAAM,OAAAV,EAASiC,EAAT,EACftB,SAAUZ,EAAO,eACHP,IAAgByC,EAAS,YAASC,EAChD3B,UAAW,uFAAAK,OACTpB,IAAgByC,EACZ,qDACA,0IAAyI,KAAArB,OAC3Ib,EAAU,gCAAkC,IAAIS,SAEnDyB,GAVIA,EAFyB,IAgBlC3B,EAAAA,KAAC6B,EAAM,CACLzB,QAAS,WAAM,OAAAV,EAASR,EAAc,EAAvB,EACfmB,SAAUnB,IAAgBC,GAAcM,EACxCqC,KAAK,SACLC,QAAQ,UACRC,KAAK,KACLC,SAAO,EAAA/B,SAAA,CAAA,YAGPC,EAAAA,IAAA,MAAA,CACEF,UAAU,UACViB,MAAM,6BACNJ,QAAQ,YACRD,KAAK,eAAc,cACP,gBAEZV,EAAAA,IAAA,OAAA,CACEY,SAAS,UACTC,EAAE,qHACFC,SAAS,2BAS3B"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=require("../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime"),a=require("react"),t=require("lucide-react"),n=require("./Pagination.js"),s=require("./TableSkeleton.js"),l=require("../Cards/EmptyStateCard.js");module.exports=function(i){var d=i.data,o=i.columns,c=i.itemsPerPage,
|
|
1
|
+
"use strict";var e=require("../../node_modules/tslib/tslib.es6.js"),r=require("react/jsx-runtime"),a=require("react"),t=require("lucide-react"),n=require("./Pagination.js"),s=require("./TableSkeleton.js"),l=require("../Cards/EmptyStateCard.js");module.exports=function(i){var d=i.data,o=i.columns,c=i.itemsPerPage,g=void 0===c?20:c,u=i.onViewChange,x=i.totalItems,m=i.currentPage,h=void 0===m?1:m,y=i.onPageChange,v=i.loading,p=void 0!==v&&v,b=i.showPagination,f=void 0===b||b,j=i.onRowClick,w=i.useCardLayout,N=void 0!==w&&w,k=i.emptyState,S=i.expandableRows,C=void 0!==S&&S,P=i.expandedRowRender,R=i.onRowToggle,q=i.defaultExpandedRows,z=void 0===q?new Set:q,_=i.getRowKey,A=void 0===_?function(e,r){return r}:_,K=i.paginationMeta,D=i.defaultSortKey,F=i.defaultSortOrder,M=void 0===F?"asc":F,T=i.onSort,E=a.useState(z),I=E[0],U=E[1],V=a.useState(D||null),H=V[0],L=V[1],O=a.useState(D?M:null),B=O[0],G=O[1],J=(null==K?void 0:K.total)||x||d.length,Q=(null==K?void 0:K.last_page)||Math.ceil(J/g),W=(null==K?void 0:K.current_page)||h,X=(null==K?void 0:K.per_page)||g,Y=a.useMemo((function(){return H&&B?e.__spreadArray([],d,!0).sort((function(e,r){var a,t,n=o.find((function(e){return(e.sortKey||e.value)===H}));return n?("function"==typeof n.value?(a=e[H],t=r[H]):(a=e[n.value],t=r[n.value]),null==a&&null==t?0:null==a?1:null==t?-1:"string"==typeof a&&"string"==typeof t?"asc"===B?a.localeCompare(t):t.localeCompare(a):"number"==typeof a&&"number"==typeof t?"asc"===B?a-t:t-a:"asc"===B?String(a).localeCompare(String(t)):String(t).localeCompare(String(a))):0})):d}),[d,H,B,o]),Z=function(e){if(!e.sortable)return null;var a=String(e.sortKey||e.value);return H!==a?r.jsx(t.ArrowUpDown,{size:14,className:"text-gray-400 dark:text-gray-500"}):"asc"===B?r.jsx(t.ArrowUp,{size:14,className:"text-blue-600"}):r.jsx(t.ArrowDown,{size:14,className:"text-blue-600"})},$=function(e,r){C&&P?ee(e,r):j&&j(e)},ee=function(e,r){var a=A(e,r),t=new Set(I),n=I.has(a);n?t.delete(a):t.add(a),U(t),R&&R(e,!n)},re=function(e,r){var a=A(e,r);return I.has(a)},ae=r.jsx(l,{title:"No Record found"}),te=function(e){switch(e){case"center":return"text-center";case"right":return"text-right";default:return"text-left"}},ne=function(){return r.jsxs("div",{className:"grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3",children:[p&&Array.from({length:X}).map((function(e,a){return r.jsx("div",{className:"rounded-lg border border-gray-200 bg-white p-4 animate-pulse dark:border-gray-700 dark:bg-gray-800",children:r.jsx("div",{className:"space-y-3",children:o.slice(0,3).map((function(e,a){return r.jsxs("div",{className:"flex justify-between items-center",children:[r.jsx("div",{className:"h-4 w-1/3 rounded bg-gray-200 dark:bg-gray-700"}),r.jsx("div",{className:"h-4 w-1/2 rounded bg-gray-200 dark:bg-gray-700"})]},a)}))})},a)})),Y.length>0?Y.map((function(e,a){var n=re(e,a);return r.jsxs("div",{className:"rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800",children:[r.jsx("div",{onClick:function(){return $(e,a)},className:"p-4 transition-all duration-200 hover:border-gray-300 hover:shadow-md dark:hover:border-gray-600 ".concat(j||C?"cursor-pointer":""," ").concat(p?"opacity-50":""," ").concat(C?"border-b border-gray-100 last:border-b-0 dark:border-gray-700":""),children:r.jsxs("div",{className:"space-y-3",children:[C&&r.jsx("div",{className:"flex items-center justify-between mb-2",children:r.jsxs("div",{className:"flex items-center text-sm text-gray-500 dark:text-gray-400",children:[n?r.jsx(t.ChevronDown,{size:16,className:"mr-1"}):r.jsx(t.ChevronRight,{size:16,className:"mr-1"}),r.jsx("span",{children:n?"Hide details":"Show details"})]})}),o.map((function(a,t){return r.jsxs("div",{className:"flex justify-between items-start",children:[r.jsxs("span",{className:"mr-3 flex-shrink-0 text-sm font-medium text-gray-500 dark:text-gray-400",children:[a.title,":"]}),r.jsx("span",{className:"text-right text-sm text-gray-800 dark:text-gray-100",children:"function"==typeof a.value?a.value(e):e[a.value]})]},t)}))]})}),C&&n&&P&&r.jsx("div",{className:"rounded-b-lg border-t border-gray-100 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-900/50",children:P(e)})]},a)})):!p&&r.jsx("div",{className:"col-span-full",children:k||ae})]})};return r.jsxs(r.Fragment,{children:[N?ne():r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"hidden md:block",children:r.jsx("div",{className:"relative overflow-x-auto",children:r.jsxs("table",{className:"w-full",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[C&&r.jsx("th",{className:"w-12 rounded-bl-lg rounded-tl-lg bg-gray-100 px-6 py-3 text-left text-sm font-semibold tracking-wider text-gray-500 dark:bg-gray-800 dark:text-gray-300"}),o.map((function(e,a){return r.jsx("th",{onClick:function(){return function(e){if(e.sortable){var r=String(e.sortKey||e.value),a="asc";H===r&&(a="asc"===B?"desc":"desc"===B?null:"asc"),L(a?r:null),G(a),T&&a&&T(r,a)}}(e)},className:"bg-gray-100 px-6 py-3 text-sm font-semibold tracking-wider text-gray-500 dark:bg-gray-700 dark:text-gray-300 ".concat(e.width||""," ").concat(te(e.align)," ").concat(e.sortable?"cursor-pointer select-none hover:bg-gray-200 dark:hover:bg-gray-700":""," ").concat(C||0!==a?"":"rounded-bl-lg rounded-tl-lg"," ").concat(a===o.length-1?"rounded-br-lg rounded-tr-lg":""," ").concat(e.className||""),style:e.width?{width:e.width}:void 0,children:r.jsxs("div",{className:"flex items-center gap-2 justify-between",children:[r.jsx("span",{children:e.title}),Z(e)]})},a)}))]})}),r.jsxs("tbody",{className:"divide-y divide-gray-200 dark:divide-gray-700 ".concat(p?"opacity-50":""," ").concat(j||C?"cursor-pointer":""),children:[p&&r.jsx(s.TableSkeleton,{columns:o.length+(C?1:0),rows:X}),Y.length>0?Y.map((function(e,n){var s=re(e,n);return r.jsxs(a.Fragment,{children:[r.jsxs("tr",{onClick:function(){return $(e,n)},className:"transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800 ".concat(s?"bg-blue-50 dark:bg-blue-950/40":""),children:[C&&r.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-800 dark:text-gray-100",children:r.jsx("div",{className:"flex items-center justify-center",children:s?r.jsx(t.ChevronDown,{size:16,className:"text-gray-500 dark:text-gray-400"}):r.jsx(t.ChevronRight,{size:16,className:"text-gray-500 dark:text-gray-400"})})}),o.map((function(a,t){return r.jsx("td",{className:"whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-800 dark:text-gray-100 ".concat(te(a.align)," ").concat(a.className||""),style:a.width?{width:a.width}:void 0,children:"function"==typeof a.value?a.value(e):e[a.value]},t)}))]}),C&&s&&P&&r.jsx("tr",{className:"bg-gray-50 dark:bg-gray-900/50",children:r.jsx("td",{colSpan:o.length+1,className:"px-6 py-4",children:r.jsx("div",{className:"animate-fade-in",children:P(e)})})},"".concat(n,"-expanded"))]},n)})):!p&&r.jsx("tr",{children:r.jsx("td",{colSpan:o.length+(C?1:0),className:"px-6 py-12 text-center",children:k||ae})})]})]})})}),r.jsx("div",{className:"block md:hidden",children:ne()})]}),f&&r.jsx(n.Pagination,{currentPage:W,totalPages:Q,totalItems:J,itemsPerPage:X,onPageChange:y,onViewChange:u,loading:p})]})};
|
|
2
2
|
//# sourceMappingURL=Table.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.js","sources":["../../../../src/components/Table/Table.tsx"],"sourcesContent":["import { ReactNode, useMemo, useState } from \"react\";\nimport {\n ArrowDown,\n ArrowUp,\n ArrowUpDown,\n ChevronDown,\n ChevronRight,\n} from \"lucide-react\";\n\nimport { Pagination } from \"./Pagination\";\nimport { ExpandableTableProps, Column } from \"./types\";\nimport { TableSkeleton } from \"./TableSkeleton\";\nimport { EmptyStateCard } from \"../Cards\";\nimport React from \"react\";\n\ntype SortOrder = \"asc\" | \"desc\" | null;\n\nexport default function Table<T>({\n data,\n columns,\n itemsPerPage = 20,\n onViewChange,\n totalItems,\n currentPage = 1,\n onPageChange,\n loading = false,\n showPagination = true,\n onRowClick,\n useCardLayout = false,\n emptyState,\n expandableRows = false,\n expandedRowRender,\n onRowToggle,\n defaultExpandedRows = new Set(),\n getRowKey = (item: T, index: number) => index,\n paginationMeta,\n defaultSortKey,\n defaultSortOrder = \"asc\",\n onSort,\n}: ExpandableTableProps<T>) {\n const [expandedRows, setExpandedRows] =\n useState<Set<string | number>>(defaultExpandedRows);\n const [sortKey, setSortKey] = useState<string | null>(defaultSortKey || null);\n const [sortOrder, setSortOrder] = useState<SortOrder>(\n defaultSortKey ? defaultSortOrder : null,\n );\n\n // Pagination calculations\n const totalItemsCount = paginationMeta?.total || totalItems || data.length;\n const totalPages =\n paginationMeta?.last_page || Math.ceil(totalItemsCount / itemsPerPage);\n const currentPageNumber = paginationMeta?.current_page || currentPage;\n const perPage = paginationMeta?.per_page || itemsPerPage;\n\n // Sorting logic\n const sortedData = useMemo(() => {\n if (!sortKey || !sortOrder) return data;\n\n const sorted = [...data].sort((a, b) => {\n const column = columns.find(\n (col) => (col.sortKey || col.value) === sortKey,\n );\n if (!column) return 0;\n\n let aValue: any;\n let bValue: any;\n\n if (typeof column.value === \"function\") {\n // For function-based columns, use the sortKey to get raw values\n aValue = (a as any)[sortKey];\n bValue = (b as any)[sortKey];\n } else {\n aValue = a[column.value];\n bValue = b[column.value];\n }\n\n // Handle null/undefined\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1;\n if (bValue == null) return -1;\n\n // Handle different types\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n return sortOrder === \"asc\"\n ? aValue.localeCompare(bValue)\n : bValue.localeCompare(aValue);\n }\n\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n return sortOrder === \"asc\" ? aValue - bValue : bValue - aValue;\n }\n\n // Default comparison\n return sortOrder === \"asc\"\n ? String(aValue).localeCompare(String(bValue))\n : String(bValue).localeCompare(String(aValue));\n });\n\n return sorted;\n }, [data, sortKey, sortOrder, columns]);\n\n const currentItems = sortedData;\n\n // Sorting handler\n const handleSort = (column: Column<T>) => {\n if (!column.sortable) return;\n\n const key = String(column.sortKey || column.value);\n let newOrder: SortOrder = \"asc\";\n\n if (sortKey === key) {\n if (sortOrder === \"asc\") newOrder = \"desc\";\n else if (sortOrder === \"desc\") newOrder = null;\n else newOrder = \"asc\";\n }\n\n setSortKey(newOrder ? key : null);\n setSortOrder(newOrder);\n\n if (onSort && newOrder) {\n onSort(key, newOrder);\n }\n };\n\n const getSortIcon = (column: Column<T>) => {\n if (!column.sortable) return null;\n\n const key = String(column.sortKey || column.value);\n if (sortKey !== key) {\n return (\n <ArrowUpDown size={14} className=\"text-gray-400 dark:text-gray-500\" />\n );\n }\n\n return sortOrder === \"asc\" ? (\n <ArrowUp size={14} className=\"text-blue-600\" />\n ) : (\n <ArrowDown size={14} className=\"text-blue-600\" />\n );\n };\n\n // Row expansion logic\n const handleRowClick = (item: T, index: number) => {\n if (expandableRows && expandedRowRender) {\n toggleRow(item, index);\n } else if (onRowClick) {\n onRowClick(item);\n }\n };\n\n const toggleRow = (item: T, index: number) => {\n const rowKey = getRowKey(item, index);\n const newExpandedRows = new Set(expandedRows);\n const isCurrentlyExpanded = expandedRows.has(rowKey);\n\n if (isCurrentlyExpanded) {\n newExpandedRows.delete(rowKey);\n } else {\n newExpandedRows.add(rowKey);\n }\n\n setExpandedRows(newExpandedRows);\n\n if (onRowToggle) {\n onRowToggle(item, !isCurrentlyExpanded);\n }\n };\n\n const isRowExpanded = (item: T, index: number) => {\n const rowKey = getRowKey(item, index);\n return expandedRows.has(rowKey);\n };\n\n const defaultEmptyState = <EmptyStateCard title=\"No Record found\" />;\n\n const getAlignmentClass = (align?: \"left\" | \"center\" | \"right\") => {\n switch (align) {\n case \"center\":\n return \"text-center\";\n case \"right\":\n return \"text-right\";\n default:\n return \"text-left\";\n }\n };\n\n // Card Layout Renderer\n const renderCardLayout = () => (\n <div className=\"grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3\">\n {loading &&\n Array.from({ length: perPage }).map((_, index) => (\n <div\n key={index}\n className=\"rounded-lg border border-gray-200 bg-white p-4 animate-pulse dark:border-gray-700 dark:bg-gray-800\"\n >\n <div className=\"space-y-3\">\n {columns.slice(0, 3).map((_, colIndex) => (\n <div\n key={colIndex}\n className=\"flex justify-between items-center\"\n >\n <div className=\"h-4 w-1/3 rounded bg-gray-200 dark:bg-gray-700\"></div>\n <div className=\"h-4 w-1/2 rounded bg-gray-200 dark:bg-gray-700\"></div>\n </div>\n ))}\n </div>\n </div>\n ))}\n {currentItems.length > 0\n ? currentItems.map((item: T, rowIndex) => {\n const expanded = isRowExpanded(item, rowIndex);\n return (\n <div\n key={rowIndex}\n className=\"rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800\"\n >\n <div\n onClick={() => handleRowClick(item, rowIndex)}\n className={`p-4 transition-all duration-200 hover:border-gray-300 hover:shadow-md dark:hover:border-gray-600 ${\n onRowClick || expandableRows ? \"cursor-pointer\" : \"\"\n } ${loading ? \"opacity-50\" : \"\"} ${\n expandableRows\n ? \"border-b border-gray-100 last:border-b-0 dark:border-gray-700\"\n : \"\"\n }`}\n >\n <div className=\"space-y-3\">\n {expandableRows && (\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"flex items-center text-sm text-gray-500 dark:text-gray-400\">\n {expanded ? (\n <ChevronDown size={16} className=\"mr-1\" />\n ) : (\n <ChevronRight size={16} className=\"mr-1\" />\n )}\n <span>\n {expanded ? \"Hide details\" : \"Show details\"}\n </span>\n </div>\n </div>\n )}\n {columns.map((column, colIndex) => (\n <div\n key={colIndex}\n className=\"flex justify-between items-start\"\n >\n <span className=\"mr-3 flex-shrink-0 text-sm font-medium text-gray-500 dark:text-gray-400\">\n {column.title}:\n </span>\n <span className=\"text-right text-sm text-gray-800 dark:text-gray-100\">\n {typeof column.value === \"function\"\n ? column.value(item)\n : (item[column.value] as ReactNode)}\n </span>\n </div>\n ))}\n </div>\n </div>\n {expandableRows && expanded && expandedRowRender && (\n <div className=\"rounded-b-lg border-t border-gray-100 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-900/50\">\n {expandedRowRender(item)}\n </div>\n )}\n </div>\n );\n })\n : !loading && (\n <div className=\"col-span-full\">\n {emptyState || defaultEmptyState}\n </div>\n )}\n </div>\n );\n\n // Table Layout Renderer\n const renderTableLayout = () => (\n <div className=\"relative overflow-x-auto\">\n <table className=\"w-full\">\n <thead>\n <tr>\n {expandableRows && (\n <th className=\"w-12 rounded-bl-xl rounded-tl-xl bg-gray-100 px-6 py-3 text-left text-sm font-semibold tracking-wider text-gray-500 dark:bg-gray-800 dark:text-gray-300\">\n {/* Toggle column */}\n </th>\n )}\n {columns.map((column, index) => (\n <th\n key={index}\n onClick={() => handleSort(column)}\n className={`bg-gray-100 px-6 py-3 text-sm font-semibold tracking-wider text-gray-500 dark:bg-gray-800 dark:text-gray-300 ${\n column.width || \"\"\n } ${getAlignmentClass(column.align)} ${\n column.sortable\n ? \"cursor-pointer select-none hover:bg-gray-200 dark:hover:bg-gray-700\"\n : \"\"\n } ${!expandableRows && index === 0 ? \"rounded-bl-xl rounded-tl-xl\" : \"\"} ${\n index === columns.length - 1\n ? \"rounded-br-xl rounded-tr-xl\"\n : \"\"\n } ${column.className || \"\"}`}\n style={column.width ? { width: column.width } : undefined}\n >\n <div className=\"flex items-center gap-2 justify-between\">\n <span>{column.title}</span>\n {getSortIcon(column)}\n </div>\n </th>\n ))}\n </tr>\n </thead>\n <tbody\n className={`divide-y divide-gray-200 dark:divide-gray-700 ${loading ? \"opacity-50\" : \"\"} ${\n onRowClick || expandableRows ? \"cursor-pointer\" : \"\"\n }`}\n >\n {loading && (\n <TableSkeleton\n columns={columns.length + (expandableRows ? 1 : 0)}\n rows={perPage}\n />\n )}\n {currentItems.length > 0\n ? currentItems.map((item: T, rowIndex) => {\n const expanded = isRowExpanded(item, rowIndex);\n return (\n <React.Fragment key={rowIndex}>\n <tr\n onClick={() => handleRowClick(item, rowIndex)}\n className={`transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800 ${\n expanded ? \"bg-blue-50 dark:bg-blue-950/40\" : \"\"\n }`}\n >\n {expandableRows && (\n <td className=\"whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-800 dark:text-gray-100\">\n <div className=\"flex items-center justify-center\">\n {expanded ? (\n <ChevronDown\n size={16}\n className=\"text-gray-500 dark:text-gray-400\"\n />\n ) : (\n <ChevronRight\n size={16}\n className=\"text-gray-500 dark:text-gray-400\"\n />\n )}\n </div>\n </td>\n )}\n {columns.map((column, colIndex) => (\n <td\n key={colIndex}\n className={`whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-800 dark:text-gray-100 ${getAlignmentClass(\n column.align,\n )} ${column.className || \"\"}`}\n style={\n column.width ? { width: column.width } : undefined\n }\n >\n {typeof column.value === \"function\"\n ? column.value(item)\n : (item[column.value] as ReactNode)}\n </td>\n ))}\n </tr>\n {expandableRows && expanded && expandedRowRender && (\n <tr\n key={`${rowIndex}-expanded`}\n className=\"bg-gray-50 dark:bg-gray-900/50\"\n >\n <td colSpan={columns.length + 1} className=\"px-6 py-4\">\n <div className=\"animate-fade-in\">\n {expandedRowRender(item)}\n </div>\n </td>\n </tr>\n )}\n </React.Fragment>\n );\n })\n : !loading && (\n <tr>\n <td\n colSpan={columns.length + (expandableRows ? 1 : 0)}\n className=\"px-6 py-12 text-center\"\n >\n {emptyState || defaultEmptyState}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n );\n\n return (\n <>\n {useCardLayout ? (\n renderCardLayout()\n ) : (\n <>\n <div className=\"hidden md:block\">{renderTableLayout()}</div>\n <div className=\"block md:hidden\">{renderCardLayout()}</div>\n </>\n )}\n\n {showPagination && (\n <Pagination\n currentPage={currentPageNumber}\n totalPages={totalPages}\n totalItems={totalItemsCount}\n itemsPerPage={perPage}\n onPageChange={onPageChange}\n onViewChange={onViewChange}\n loading={loading}\n />\n )}\n </>\n );\n}\n"],"names":["_a","data","columns","_b","itemsPerPage","onViewChange","totalItems","_c","currentPage","onPageChange","_d","loading","_e","showPagination","onRowClick","_f","useCardLayout","emptyState","_g","expandableRows","expandedRowRender","onRowToggle","_h","defaultExpandedRows","Set","_j","getRowKey","item","index","paginationMeta","defaultSortKey","_k","defaultSortOrder","onSort","_l","useState","expandedRows","setExpandedRows","_m","sortKey","setSortKey","_o","sortOrder","setSortOrder","totalItemsCount","total","length","totalPages","last_page","Math","ceil","currentPageNumber","current_page","perPage","per_page","currentItems","useMemo","__spreadArray","sort","a","b","aValue","bValue","column","find","col","value","localeCompare","String","getSortIcon","sortable","key","_jsx","ArrowUpDown","size","className","ArrowUp","ArrowDown","handleRowClick","toggleRow","rowKey","newExpandedRows","isCurrentlyExpanded","has","delete","add","isRowExpanded","defaultEmptyState","EmptyStateCard","title","getAlignmentClass","align","renderCardLayout","_jsxs","children","Array","from","map","_","slice","colIndex","rowIndex","expanded","onClick","concat","ChevronDown","ChevronRight","_Fragment","newOrder","handleSort","width","style","undefined","TableSkeleton","rows","React","Fragment","colSpan","Pagination"],"mappings":"oQAiBc,SAAmBA,OAC/BC,EAAID,EAAAC,KACJC,EAAOF,EAAAE,QACPC,EAAAH,EAAAI,aAAAA,OAAY,IAAAD,EAAG,GAAEA,EACjBE,EAAYL,EAAAK,aACZC,EAAUN,EAAAM,WACVC,gBAAAC,OAAW,IAAAD,EAAG,EAACA,EACfE,EAAYT,EAAAS,aACZC,EAAAV,EAAAW,QAAAA,OAAO,IAAAD,GAAQA,EACfE,EAAAZ,EAAAa,eAAAA,OAAc,IAAAD,GAAOA,EACrBE,EAAUd,EAAAc,WACVC,EAAAf,EAAAgB,cAAAA,OAAa,IAAAD,GAAQA,EACrBE,eACAC,EAAAlB,EAAAmB,eAAAA,OAAc,IAAAD,GAAQA,EACtBE,EAAiBpB,EAAAoB,kBACjBC,gBACAC,EAAAtB,EAAAuB,oBAAAA,OAAmB,IAAAD,EAAG,IAAIE,IAAKF,EAC/BG,EAAAzB,EAAA0B,UAAAA,aAAY,SAACC,EAASC,GAAkB,OAAAA,CAAA,EAAKH,EAC7CI,EAAc7B,EAAA6B,eACdC,EAAc9B,EAAA8B,eACdC,EAAA/B,EAAAgC,iBAAAA,aAAmB,MAAKD,EACxBE,EAAMjC,EAAAiC,OAEAC,EACJC,EAAAA,SAA+BZ,GAD1Ba,EAAYF,EAAA,GAAEG,EAAeH,EAAA,GAE9BI,EAAwBH,EAAAA,SAAwBL,GAAkB,MAAjES,EAAOD,EAAA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AA,CAAAsB,SACEtB,EAAAA,UACE6C,QAASnH,EAAQ4C,QAAU3B,EAAiB,EAAI,GAChDwD,UAAU,kCAET1D,GAAcsE,iBAgBzBf,MAAA,MAAA,CAAKG,UAAU,2BAAmBiB,UAIrC/E,GACC2D,MAAC8C,EAAAA,WAAU,CACT9G,YAAa2C,EACbJ,WAAYA,EACZzC,WAAYsC,EACZxC,aAAciD,EACd5C,aAAcA,EACdJ,aAAcA,EACdM,QAASA,MAKnB"}
|
|
1
|
+
{"version":3,"file":"Table.js","sources":["../../../../src/components/Table/Table.tsx"],"sourcesContent":["import { ReactNode, useMemo, useState } from \"react\";\nimport {\n ArrowDown,\n ArrowUp,\n ArrowUpDown,\n ChevronDown,\n ChevronRight,\n} from \"lucide-react\";\n\nimport { Pagination } from \"./Pagination\";\nimport { ExpandableTableProps, Column } from \"./types\";\nimport { TableSkeleton } from \"./TableSkeleton\";\nimport { EmptyStateCard } from \"../Cards\";\nimport React from \"react\";\n\ntype SortOrder = \"asc\" | \"desc\" | null;\n\nexport default function Table<T>({\n data,\n columns,\n itemsPerPage = 20,\n onViewChange,\n totalItems,\n currentPage = 1,\n onPageChange,\n loading = false,\n showPagination = true,\n onRowClick,\n useCardLayout = false,\n emptyState,\n expandableRows = false,\n expandedRowRender,\n onRowToggle,\n defaultExpandedRows = new Set(),\n getRowKey = (item: T, index: number) => index,\n paginationMeta,\n defaultSortKey,\n defaultSortOrder = \"asc\",\n onSort,\n}: ExpandableTableProps<T>) {\n const [expandedRows, setExpandedRows] =\n useState<Set<string | number>>(defaultExpandedRows);\n const [sortKey, setSortKey] = useState<string | null>(defaultSortKey || null);\n const [sortOrder, setSortOrder] = useState<SortOrder>(\n defaultSortKey ? defaultSortOrder : null,\n );\n\n // Pagination calculations\n const totalItemsCount = paginationMeta?.total || totalItems || data.length;\n const totalPages =\n paginationMeta?.last_page || Math.ceil(totalItemsCount / itemsPerPage);\n const currentPageNumber = paginationMeta?.current_page || currentPage;\n const perPage = paginationMeta?.per_page || itemsPerPage;\n\n // Sorting logic\n const sortedData = useMemo(() => {\n if (!sortKey || !sortOrder) return data;\n\n const sorted = [...data].sort((a, b) => {\n const column = columns.find(\n (col) => (col.sortKey || col.value) === sortKey,\n );\n if (!column) return 0;\n\n let aValue: any;\n let bValue: any;\n\n if (typeof column.value === \"function\") {\n // For function-based columns, use the sortKey to get raw values\n aValue = (a as any)[sortKey];\n bValue = (b as any)[sortKey];\n } else {\n aValue = a[column.value];\n bValue = b[column.value];\n }\n\n // Handle null/undefined\n if (aValue == null && bValue == null) return 0;\n if (aValue == null) return 1;\n if (bValue == null) return -1;\n\n // Handle different types\n if (typeof aValue === \"string\" && typeof bValue === \"string\") {\n return sortOrder === \"asc\"\n ? aValue.localeCompare(bValue)\n : bValue.localeCompare(aValue);\n }\n\n if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n return sortOrder === \"asc\" ? aValue - bValue : bValue - aValue;\n }\n\n // Default comparison\n return sortOrder === \"asc\"\n ? String(aValue).localeCompare(String(bValue))\n : String(bValue).localeCompare(String(aValue));\n });\n\n return sorted;\n }, [data, sortKey, sortOrder, columns]);\n\n const currentItems = sortedData;\n\n // Sorting handler\n const handleSort = (column: Column<T>) => {\n if (!column.sortable) return;\n\n const key = String(column.sortKey || column.value);\n let newOrder: SortOrder = \"asc\";\n\n if (sortKey === key) {\n if (sortOrder === \"asc\") newOrder = \"desc\";\n else if (sortOrder === \"desc\") newOrder = null;\n else newOrder = \"asc\";\n }\n\n setSortKey(newOrder ? key : null);\n setSortOrder(newOrder);\n\n if (onSort && newOrder) {\n onSort(key, newOrder);\n }\n };\n\n const getSortIcon = (column: Column<T>) => {\n if (!column.sortable) return null;\n\n const key = String(column.sortKey || column.value);\n if (sortKey !== key) {\n return (\n <ArrowUpDown size={14} className=\"text-gray-400 dark:text-gray-500\" />\n );\n }\n\n return sortOrder === \"asc\" ? (\n <ArrowUp size={14} className=\"text-blue-600\" />\n ) : (\n <ArrowDown size={14} className=\"text-blue-600\" />\n );\n };\n\n // Row expansion logic\n const handleRowClick = (item: T, index: number) => {\n if (expandableRows && expandedRowRender) {\n toggleRow(item, index);\n } else if (onRowClick) {\n onRowClick(item);\n }\n };\n\n const toggleRow = (item: T, index: number) => {\n const rowKey = getRowKey(item, index);\n const newExpandedRows = new Set(expandedRows);\n const isCurrentlyExpanded = expandedRows.has(rowKey);\n\n if (isCurrentlyExpanded) {\n newExpandedRows.delete(rowKey);\n } else {\n newExpandedRows.add(rowKey);\n }\n\n setExpandedRows(newExpandedRows);\n\n if (onRowToggle) {\n onRowToggle(item, !isCurrentlyExpanded);\n }\n };\n\n const isRowExpanded = (item: T, index: number) => {\n const rowKey = getRowKey(item, index);\n return expandedRows.has(rowKey);\n };\n\n const defaultEmptyState = <EmptyStateCard title=\"No Record found\" />;\n\n const getAlignmentClass = (align?: \"left\" | \"center\" | \"right\") => {\n switch (align) {\n case \"center\":\n return \"text-center\";\n case \"right\":\n return \"text-right\";\n default:\n return \"text-left\";\n }\n };\n\n // Card Layout Renderer\n const renderCardLayout = () => (\n <div className=\"grid gap-4 grid-cols-1 sm:grid-cols-2 lg:grid-cols-3\">\n {loading &&\n Array.from({ length: perPage }).map((_, index) => (\n <div\n key={index}\n className=\"rounded-lg border border-gray-200 bg-white p-4 animate-pulse dark:border-gray-700 dark:bg-gray-800\"\n >\n <div className=\"space-y-3\">\n {columns.slice(0, 3).map((_, colIndex) => (\n <div\n key={colIndex}\n className=\"flex justify-between items-center\"\n >\n <div className=\"h-4 w-1/3 rounded bg-gray-200 dark:bg-gray-700\"></div>\n <div className=\"h-4 w-1/2 rounded bg-gray-200 dark:bg-gray-700\"></div>\n </div>\n ))}\n </div>\n </div>\n ))}\n {currentItems.length > 0\n ? currentItems.map((item: T, rowIndex) => {\n const expanded = isRowExpanded(item, rowIndex);\n return (\n <div\n key={rowIndex}\n className=\"rounded-lg border border-gray-200 bg-white dark:border-gray-700 dark:bg-gray-800\"\n >\n <div\n onClick={() => handleRowClick(item, rowIndex)}\n className={`p-4 transition-all duration-200 hover:border-gray-300 hover:shadow-md dark:hover:border-gray-600 ${\n onRowClick || expandableRows ? \"cursor-pointer\" : \"\"\n } ${loading ? \"opacity-50\" : \"\"} ${\n expandableRows\n ? \"border-b border-gray-100 last:border-b-0 dark:border-gray-700\"\n : \"\"\n }`}\n >\n <div className=\"space-y-3\">\n {expandableRows && (\n <div className=\"flex items-center justify-between mb-2\">\n <div className=\"flex items-center text-sm text-gray-500 dark:text-gray-400\">\n {expanded ? (\n <ChevronDown size={16} className=\"mr-1\" />\n ) : (\n <ChevronRight size={16} className=\"mr-1\" />\n )}\n <span>\n {expanded ? \"Hide details\" : \"Show details\"}\n </span>\n </div>\n </div>\n )}\n {columns.map((column, colIndex) => (\n <div\n key={colIndex}\n className=\"flex justify-between items-start\"\n >\n <span className=\"mr-3 flex-shrink-0 text-sm font-medium text-gray-500 dark:text-gray-400\">\n {column.title}:\n </span>\n <span className=\"text-right text-sm text-gray-800 dark:text-gray-100\">\n {typeof column.value === \"function\"\n ? column.value(item)\n : (item[column.value] as ReactNode)}\n </span>\n </div>\n ))}\n </div>\n </div>\n {expandableRows && expanded && expandedRowRender && (\n <div className=\"rounded-b-lg border-t border-gray-100 bg-gray-50 p-4 dark:border-gray-700 dark:bg-gray-900/50\">\n {expandedRowRender(item)}\n </div>\n )}\n </div>\n );\n })\n : !loading && (\n <div className=\"col-span-full\">\n {emptyState || defaultEmptyState}\n </div>\n )}\n </div>\n );\n\n // Table Layout Renderer\n const renderTableLayout = () => (\n <div className=\"relative overflow-x-auto\">\n <table className=\"w-full\">\n <thead>\n <tr>\n {expandableRows && (\n <th className=\"w-12 rounded-bl-lg rounded-tl-lg bg-gray-100 px-6 py-3 text-left text-sm font-semibold tracking-wider text-gray-500 dark:bg-gray-800 dark:text-gray-300\">\n {/* Toggle column */}\n </th>\n )}\n {columns.map((column, index) => (\n <th\n key={index}\n onClick={() => handleSort(column)}\n className={`bg-gray-100 px-6 py-3 text-sm font-semibold tracking-wider text-gray-500 dark:bg-gray-700 dark:text-gray-300 ${\n column.width || \"\"\n } ${getAlignmentClass(column.align)} ${\n column.sortable\n ? \"cursor-pointer select-none hover:bg-gray-200 dark:hover:bg-gray-700\"\n : \"\"\n } ${!expandableRows && index === 0 ? \"rounded-bl-lg rounded-tl-lg\" : \"\"} ${\n index === columns.length - 1\n ? \"rounded-br-lg rounded-tr-lg\"\n : \"\"\n } ${column.className || \"\"}`}\n style={column.width ? { width: column.width } : undefined}\n >\n <div className=\"flex items-center gap-2 justify-between\">\n <span>{column.title}</span>\n {getSortIcon(column)}\n </div>\n </th>\n ))}\n </tr>\n </thead>\n <tbody\n className={`divide-y divide-gray-200 dark:divide-gray-700 ${loading ? \"opacity-50\" : \"\"} ${\n onRowClick || expandableRows ? \"cursor-pointer\" : \"\"\n }`}\n >\n {loading && (\n <TableSkeleton\n columns={columns.length + (expandableRows ? 1 : 0)}\n rows={perPage}\n />\n )}\n {currentItems.length > 0\n ? currentItems.map((item: T, rowIndex) => {\n const expanded = isRowExpanded(item, rowIndex);\n return (\n <React.Fragment key={rowIndex}>\n <tr\n onClick={() => handleRowClick(item, rowIndex)}\n className={`transition-colors duration-150 hover:bg-gray-50 dark:hover:bg-gray-800 ${\n expanded ? \"bg-blue-50 dark:bg-blue-950/40\" : \"\"\n }`}\n >\n {expandableRows && (\n <td className=\"whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-800 dark:text-gray-100\">\n <div className=\"flex items-center justify-center\">\n {expanded ? (\n <ChevronDown\n size={16}\n className=\"text-gray-500 dark:text-gray-400\"\n />\n ) : (\n <ChevronRight\n size={16}\n className=\"text-gray-500 dark:text-gray-400\"\n />\n )}\n </div>\n </td>\n )}\n {columns.map((column, colIndex) => (\n <td\n key={colIndex}\n className={`whitespace-nowrap px-6 py-4 text-sm font-medium text-gray-800 dark:text-gray-100 ${getAlignmentClass(\n column.align,\n )} ${column.className || \"\"}`}\n style={\n column.width ? { width: column.width } : undefined\n }\n >\n {typeof column.value === \"function\"\n ? column.value(item)\n : (item[column.value] as ReactNode)}\n </td>\n ))}\n </tr>\n {expandableRows && expanded && expandedRowRender && (\n <tr\n key={`${rowIndex}-expanded`}\n className=\"bg-gray-50 dark:bg-gray-900/50\"\n >\n <td colSpan={columns.length + 1} className=\"px-6 py-4\">\n <div className=\"animate-fade-in\">\n {expandedRowRender(item)}\n </div>\n </td>\n </tr>\n )}\n </React.Fragment>\n );\n })\n : !loading && (\n <tr>\n <td\n colSpan={columns.length + (expandableRows ? 1 : 0)}\n className=\"px-6 py-12 text-center\"\n >\n {emptyState || defaultEmptyState}\n </td>\n </tr>\n )}\n </tbody>\n </table>\n </div>\n );\n\n return (\n <>\n {useCardLayout ? (\n renderCardLayout()\n ) : (\n <>\n <div className=\"hidden md:block\">{renderTableLayout()}</div>\n <div className=\"block md:hidden\">{renderCardLayout()}</div>\n </>\n )}\n\n {showPagination && (\n <Pagination\n currentPage={currentPageNumber}\n totalPages={totalPages}\n totalItems={totalItemsCount}\n itemsPerPage={perPage}\n onPageChange={onPageChange}\n onViewChange={onViewChange}\n loading={loading}\n />\n )}\n </>\n );\n}\n"],"names":["_a","data","columns","_b","itemsPerPage","onViewChange","totalItems","_c","currentPage","onPageChange","_d","loading","_e","showPagination","onRowClick","_f","useCardLayout","emptyState","_g","expandableRows","expandedRowRender","onRowToggle","_h","defaultExpandedRows","Set","_j","getRowKey","item","index","paginationMeta","defaultSortKey","_k","defaultSortOrder","onSort","_l","useState","expandedRows","setExpandedRows","_m","sortKey","setSortKey","_o","sortOrder","setSortOrder","totalItemsCount","total","length","totalPages","last_page","Math","ceil","currentPageNumber","current_page","perPage","per_page","currentItems","useMemo","__spreadArray","sort","a","b","aValue","bValue","column","find","col","value","localeCompare","String","getSortIcon","sortable","key","_jsx","ArrowUpDown","size","className","ArrowUp","ArrowDown","handleRowClick","toggleRow","rowKey","newExpandedRows","isCurrentlyExpanded","has","delete","add","isRowExpanded","defaultEmptyState","EmptyStateCard","title","getAlignmentClass","align","renderCardLayout","_jsxs","children","Array","from","map","_","slice","colIndex","rowIndex","expanded","onClick","concat","ChevronDown","ChevronRight","_Fragment","newOrder","handleSort","width","style","undefined","TableSkeleton","rows","React","Fragment","colSpan","Pagination"],"mappings":"oQAiBc,SAAmBA,OAC/BC,EAAID,EAAAC,KACJC,EAAOF,EAAAE,QACPC,EAAAH,EAAAI,aAAAA,OAAY,IAAAD,EAAG,GAAEA,EACjBE,EAAYL,EAAAK,aACZC,EAAUN,EAAAM,WACVC,gBAAAC,OAAW,IAAAD,EAAG,EAACA,EACfE,EAAYT,EAAAS,aACZC,EAAAV,EAAAW,QAAAA,OAAO,IAAAD,GAAQA,EACfE,EAAAZ,EAAAa,eAAAA,OAAc,IAAAD,GAAOA,EACrBE,EAAUd,EAAAc,WACVC,EAAAf,EAAAgB,cAAAA,OAAa,IAAAD,GAAQA,EACrBE,eACAC,EAAAlB,EAAAmB,eAAAA,OAAc,IAAAD,GAAQA,EACtBE,EAAiBpB,EAAAoB,kBACjBC,gBACAC,EAAAtB,EAAAuB,oBAAAA,OAAmB,IAAAD,EAAG,IAAIE,IAAKF,EAC/BG,EAAAzB,EAAA0B,UAAAA,aAAY,SAACC,EAASC,GAAkB,OAAAA,CAAA,EAAKH,EAC7CI,EAAc7B,EAAA6B,eACdC,EAAc9B,EAAA8B,eACdC,EAAA/B,EAAAgC,iBAAAA,aAAmB,MAAKD,EACxBE,EAAMjC,EAAAiC,OAEAC,EACJC,EAAAA,SAA+BZ,GAD1Ba,EAAYF,EAAA,GAAEG,EAAeH,EAAA,GAE9BI,EAAwBH,EAAAA,SAAwBL,GAAkB,MAAjES,EAAOD,EAAA,GAAEE,OACVC,EAA4BN,EAAAA,SAChCL,EAAiBE,EAAmB,MAD/BU,OAAWC,OAKZC,GAAkBf,aAAc,EAAdA,EAAgBgB,QAASvC,GAAcL,EAAK6C,OAC9DC,GACJlB,eAAAA,EAAgBmB,YAAaC,KAAKC,KAAKN,EAAkBxC,GACrD+C,GAAoBtB,aAAc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A,EACZzC,WAAYsC,EACZxC,aAAciD,EACd5C,aAAcA,EACdJ,aAAcA,EACdM,QAASA,MAKnB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{__rest as e,__assign as
|
|
1
|
+
import{__rest as e,__assign as r}from"../../../node_modules/tslib/tslib.es6.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";var l=function(l){var o=l.id,i=l.label,c=l.value,n=l.size,d=void 0===n?"md":n,s=l.onChange,m=l.placeholder,p=l.error,x=l.required,g=void 0!==x&&x,h=l.helpText,b=l.type,y=void 0===b?"text":b,u=l.className,v=void 0===u?"":u,f=l.disabled,N=void 0!==f&&f,k=l.icon,w=l.iconPosition,z=void 0===w?"left":w,C=l.rightIcon,j=l.block,q=e(l,["id","label","value","size","onChange","placeholder","error","required","helpText","type","className","disabled","icon","iconPosition","rightIcon","block"]),I={id:o,value:c,onChange:function(e){s&&s(e)},placeholder:m,disabled:N,className:"w-full rounded-[12px] border ".concat({sm:"text-xs px-3 py-1.5 text-sm min-h-[32px]",md:"text-sm px-4 py-2 text-base min-h-[40px]",lg:"text-base px-4 py-3 text-lg min-h-[48px]"}[d]," ").concat(p?"border-red-500":"border-gray-200 dark:border-gray-600"," ").concat(N?"bg-gray-100 text-gray-500 placeholder-gray-300 dark:bg-gray-800 dark:text-gray-500 dark:placeholder-gray-600":"bg-gray-100 placeholder-gray-400 text-dark dark:bg-gray-800 dark:text-gray-100 dark:placeholder-gray-500"," focus:outline-none focus:ring-1 focus:ring-primary ").concat(v," ").concat(k&&"left"===z?"pl-10":""," ").concat(k&&"right"===z?"pr-10":""),"aria-invalid":!!p,"aria-describedby":p?"".concat(o,"-error"):h?"".concat(o,"-help"):void 0};return a("div",{className:"mb-4 ".concat(j&&"w-full"),children:[i&&a("label",{htmlFor:o,className:"mb-1 block text-sm font-medium text-gray-600 dark:text-gray-300",children:[i,g&&t("span",{className:"ml-1 text-red-500",children:"*"})]}),a("div",{className:"relative",children:[k&&"left"===z&&t("div",{className:"pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3",children:k}),"textarea"==y?t("textarea",r({},I,{rows:4,className:"".concat(I.className," resize-none")},q)):t("input",r({},I,{type:y},q)),k&&"right"===z&&t("div",{className:"pointer-events-none absolute inset-y-0 right-0 flex items-center pr-3",children:k}),C&&t("div",{className:"absolute right-3 top-1/2 -translate-y-1/2 cursor-pointer",children:C})]}),h&&!p&&t("p",{id:"".concat(o,"-help"),className:"mt-1 text-sm text-gray-500 dark:text-gray-400",children:h}),p&&t("p",{id:"".concat(o,"-error"),className:"mt-1 text-sm text-red-500",children:p})]})};export{l as default};
|
|
2
2
|
//# sourceMappingURL=Input.mjs.map
|