@mahatisystems/mahati-ui-components 1.2.0 → 1.3.0

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/index.js CHANGED
@@ -1,244 +1,421 @@
1
- "use strict";var bt=Object.create;var P=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var xt=(t,e)=>{for(var o in e)P(t,o,{get:e[o],enumerable:!0})},N=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ht(e))!wt.call(t,a)&&a!==o&&P(t,a,{get:()=>e[a],enumerable:!(i=mt(e,a))||i.enumerable});return t};var l=(t,e,o)=>(o=t!=null?bt(gt(t)):{},N(e||!t||!t.__esModule?P(o,"default",{value:t,enumerable:!0}):o,t)),yt=t=>N(P({},"__esModule",{value:!0}),t);var le={};xt(le,{MahatiButton:()=>L,MahatiCard:()=>V,MahatiDropdown:()=>U,MahatiFormContainer:()=>j,MahatiInput:()=>H,MahatiKeyValueDisplay:()=>K,MahatiLabel:()=>_,MahatiMain:()=>X,MahatiParagraph:()=>at,MahatiRow:()=>it,MahatiSection:()=>ot,MahatiSpinner:()=>tt,MahatiTabbedInterface:()=>G,MahatiTable:()=>J,MahatiTooltip:()=>D,isValidPassword:()=>pt,isValidUsername:()=>ct,maxLength:()=>lt,minLength:()=>dt,required:()=>st});module.exports=yt(le);var A=require("react");var M=require("react/jsx-runtime"),vt=({text:t,position:e,children:o})=>{let[i,a]=(0,A.useState)(!1);return(0,M.jsxs)("div",{className:"tooltipContainer",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[o,i&&(0,M.jsx)("div",{className:`tooltip ${i?"tooltipVisible":""}`,children:t})]})},D=vt;var b=l(require("styled-components")),F={primary:{color:"#1e73be",textColor:"#ffffff"},success:{color:"#28a97d",textColor:"#ffffff"},danger:{color:"#e53e3e",textColor:"#ffffff"}},kt=b.default.button.attrs(t=>({type:t.type||"button"}))`
2
- padding: ${t=>t.size==="large"?"12px 20px":t.size==="small"?"6px 12px":"10px 16px"};
3
- margin-top: 10px;
4
- color: ${t=>t.textColor||"#ffffff"};
5
- border: none;
6
- border-radius: ${t=>typeof t.radius=="number"?`${t.radius}px`:t.radius||"6px"};
7
- cursor: pointer;
8
-
9
- display: inline-flex;
10
- align-items: center;
11
- justify-content: center;
12
- gap: 8px; /* 👈 space between icon & text */
13
-
14
- font-weight: 600;
15
- font-size: 14px;
16
-
17
- /* --- VARIANT STYLES --- */
18
- ${({variant:t,color:e,danger:o})=>{let i=o?"danger":t;return e?b.css`
19
- background-color: ${e};
20
- `:i&&F[i]?b.css`
21
- background-color: ${F[i].color};
22
- color: ${F[i].textColor};
23
- `:b.css`
24
- background-color: #55b382;
25
- `}}
26
-
27
- &:disabled {
28
- background-color: #ccc;
29
- cursor: not-allowed;
30
- }
31
-
32
- ${({isLoading:t})=>t&&b.css`
33
- pointer-events: none;
34
- opacity: 0.8;
35
- `}
36
- `,L=kt;var k=l(require("styled-components")),g=require("react/jsx-runtime"),Ct=k.default.div`
37
- background: #fff;
38
- border-radius: 8px;
39
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
40
- margin-top: 20px;
41
- display: flex;
42
- flex-direction: column;
43
- `,zt=k.default.div`
44
- padding: 16px 20px;
45
- border-bottom: 1px solid #e2e8f0;
46
- font-size: 1.25rem;
47
- font-weight: 600;
48
- `,St=k.default.div`
49
- padding: 20px;
50
- flex: 1; /* Allows the body to grow */
51
- `,Rt=k.default.div`
52
- padding: 16px 20px;
53
- border-top: 1px solid #e2e8f0;
54
- background: #f7fafc;
55
- `,Tt=({header:t,footer:e,children:o})=>(0,g.jsxs)(Ct,{children:[t&&(0,g.jsx)(zt,{children:t}),(0,g.jsx)(St,{children:o}),e&&(0,g.jsx)(Rt,{children:e})]}),V=Tt;var B=require("react"),C=l(require("styled-components")),w=require("react/jsx-runtime"),Pt=C.default.div`
56
- position: relative;
57
- display: inline-block;
58
- width: 200px;
59
- margin: 10px 0;
60
- `,Mt=C.default.button`
61
- width: 100%;
62
- padding: 10px;
63
- background-color: #007bff;
64
- color: white;
65
- border: none;
66
- border-radius: 4px;
67
- cursor: pointer;
68
- text-align: left;
69
-
70
- &:hover {
71
- background-color: #0056b3;
72
- }
73
- `,Et=C.default.div`
74
- display: ${({open:t})=>t?"block":"none"};
75
- position: absolute;
76
- background-color: white;
77
- min-width: 100%;
78
- box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
79
- z-index: 1;
80
- border-radius: 4px;
81
- `,It=C.default.div`
82
- padding: 10px;
83
- cursor: pointer;
84
- color: #333;
85
-
86
- &:hover {
87
- background-color: #f1f1f1;
88
- }
89
- `,$t=({options:t,onSelect:e})=>{let[o,i]=(0,B.useState)(!1),[a,v]=(0,B.useState)(null),f=u=>{v(u),e(u),i(!1)};return(0,w.jsxs)(Pt,{children:[(0,w.jsx)(Mt,{onClick:()=>i(!o),children:a||"Select an option"}),(0,w.jsx)(Et,{open:o,children:t.map((u,m)=>(0,w.jsx)(It,{onClick:()=>f(u),children:u},m))})]})},U=$t;var O=l(require("styled-components")),Ft=O.default.form`
90
- display: flex;
91
- flex-direction: column;
92
- align-items: center;
93
- justify-content: center;
94
- height: 80vh; /* Take full screen height */
95
- width: 100%; /* Full width of the screen */
96
- max-width: 400px; /* Limit form width */
97
- margin: 0 auto; /* Center horizontally */
98
- padding: 80px;
99
- background-color: white;
100
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); /* Optional: Add a shadow for design */
101
- border-radius: 8px;
102
- `,j=Ft;var E=l(require("styled-components")),z=require("react/jsx-runtime"),Bt=E.default.div`
103
- margin-bottom: 1rem;
104
- `,Nt=E.default.input`
105
- width: 300px; /* Set a fixed width to prevent expansion */
106
- max-width: 100%; /* Optional: Ensure it doesn't exceed the container width */
107
- padding: 0.75rem;
108
- border: 1px solid black;
109
- border-radius: 4px;
110
- background-color: ${t=>t.hasError?"#fff5f5":"#fff"};
111
- font-size: 1rem;
112
- transition: all 0.2s ease-in-out;
113
-
114
- &:focus {
115
- outline: none;
116
- border-color: ${t=>t.hasError?"red":"#0070f3"};
117
- }
118
- `,At=E.default.span`
119
- color: red;
120
- font-size: 0.875rem;
121
- height: 0.8rem; /* Fixed height for error text to avoid layout shift */
122
- display: block;
123
- `,Dt=({type:t="text",name:e,placeholder:o,onChange:i,hasError:a=!1,errorMessage:v="",value:f})=>(0,z.jsxs)(Bt,{children:[(0,z.jsx)(Nt,{type:t,name:e,placeholder:o,value:f,onChange:i,hasError:a}),(0,z.jsx)(At,{children:v})]}),H=Dt;var S=l(require("styled-components")),x=require("react/jsx-runtime"),Lt=S.default.div`
124
- display: flex;
125
- flex-direction: column;
126
- gap: 0.75rem;
127
- padding: 1.5rem;
128
- background-color: #f4f6f8;
129
- margin: 0 auto;
130
- @media (max-width: 600px) {
131
- padding: 0rem;
132
- }
133
- `,Vt=S.default.div`
134
- display: flex;
135
- align-items: center;
136
- justify-content: space-between;
137
- padding: 0.5rem 0;
138
- border-bottom: 1px solid #e0e0e0;
139
- transition: background-color 0.2s;
140
-
141
- &:last-child {
142
- border-bottom: none;
143
- }
144
-
145
- &:hover {
146
- background-color: #55b382;
147
- }
148
- `,Ut=S.default.div`
149
- font-weight: 600;
150
- font-size: 0.95rem;
151
- color: #333;
152
- display: flex;
153
- align-items: center;
154
- width: 45%;
155
- @media (max-width: 600px) {
156
- font-size: 0.85rem;
157
- }
158
- `,Ot=S.default.div`
159
- font-size: 1.2rem;
160
- color: #555;
161
- text-align: left;
162
- word-wrap: break-word;
163
- font-weight: ${t=>t.isBold?"bold":"normal"};
164
- @media (max-width: 600px) {
165
- font-size: 0.85rem;
166
- }
167
- `,jt=({data:t})=>(0,x.jsx)(Lt,{children:Object.entries(t).map(([e,o])=>(0,x.jsxs)(Vt,{children:[(0,x.jsx)(Ut,{children:e}),(0,x.jsx)(Ot,{isBold:e==="SegmentName",children:o||"N/A"})]},e))}),K=jt;var Y=l(require("styled-components")),Ht=Y.default.label`
168
- display: block;
169
- margin-bottom: 5px;
170
- font-weight: bold;
171
- `,_=Ht;var q=l(require("styled-components")),Kt=q.default.main`
172
- display: flex;
173
- flex-direction: column;
174
- align-items: center;
175
- justify-content: center;
176
- min-height: 100vh;
177
- padding: 20px;
178
- background-color: #f9f9f9;
179
- `,X=Kt;var I=l(require("react")),d=l(require("styled-components")),r=require("react/jsx-runtime"),Yt=d.default.div`margin-top: 10px;`,_t=d.default.table`width: 100%; border-collapse: collapse;`,W=d.default.th`padding: 12px; `,qt=d.default.tr`&:nth-child(even) { background-color: #f9f9f9; } &:hover { background-color: #f1f1f1; }`,Z=d.default.td`padding: 10px; border-bottom: 1px solid #ccc;`,Xt=d.default.td`text-align: center; padding: 20px; color: #999;`,Wt=d.default.div`margin-top: 15px; display: flex; flex-direction: column; align-items: center;`,Zt=d.default.div`display: flex; gap: 6px; align-items: center; flex-wrap: wrap;`,R=d.default.button`
180
- padding: 6px 12px;
181
- background: linear-gradient(to right, #1e73be, #28a97d);
182
- color: white;
183
- border: none;
184
- border-radius: 4px;
185
- cursor: pointer;
186
-
187
- &:disabled {
188
- background: #ccc;
189
- cursor: not-allowed;
190
- }
191
- `,Jt=d.default.select`
192
- margin-left: 10px;
193
- padding: 6px;
194
- border-radius: 4px;
195
- border: 1px solid #aaa;
196
- `,Gt=d.default.div`margin-top: 8px; font-size: 13px;`,Qt=({headers:t,data:e,page:o=0,setPage:i,limit:a=0,setLimit:v,totalCount:f=0,highlightRowColor:u,actions:m})=>{let c=Math.ceil(f/a)||0,ft=()=>{let s=[];if(c<=1)return null;s.push((0,r.jsx)(R,{onClick:()=>i?.(1),disabled:o===1,children:"1"},1)),o>3&&s.push((0,r.jsx)("span",{children:"..."},"start-ellipsis"));for(let p=Math.max(2,o-1);p<=Math.min(c-1,o+1);p++)s.push((0,r.jsx)(R,{onClick:()=>i?.(p),disabled:o===p,children:p},p));return o<c-1-1&&s.push((0,r.jsx)("span",{children:"..."},"end-ellipsis")),c>1&&s.push((0,r.jsx)(R,{onClick:()=>i?.(1),disabled:o===1,children:c+1},1)),s};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Yt,{children:(0,r.jsxs)(_t,{children:[(0,r.jsx)("thead",{children:(0,r.jsxs)("tr",{style:{background:"linear-gradient(to right, #1e73be, #28a97d)"},children:[t.map((s,T)=>(0,r.jsx)(W,{children:s.label},T)),m&&(0,r.jsx)(W,{children:"Actions"})]})}),(0,r.jsx)("tbody",{children:e.length>0?e.map((s,T)=>(0,r.jsxs)(qt,{className:u,children:[t.map((p,ut)=>(0,r.jsx)(Z,{children:(()=>{let n=s[p.key];if(I.default.isValidElement(n))return n;if(typeof n=="function")try{let h=n();if(I.default.isValidElement(h))return h}catch(h){console.warn("Error executing function in table cell:",h)}return typeof n=="string"&&n.trim().startsWith("<")&&n.trim().endsWith(">")?(0,r.jsx)("div",{dangerouslySetInnerHTML:{__html:n}}):Array.isArray(n)?n.some(h=>I.default.isValidElement(h))?(0,r.jsx)(r.Fragment,{children:n}):n.join(", "):n instanceof Date?n.toLocaleString():typeof n=="boolean"?n?"Yes":"No":n==null?"-":typeof n=="number"?n.toString():typeof n=="object"?JSON.stringify(n):String(n)})()},ut)),m&&(0,r.jsx)(Z,{children:m(s)})]},T)):(0,r.jsx)("tr",{children:(0,r.jsx)(Xt,{colSpan:t.length+(m?1:0),children:"No data available"})})})]})}),(c>1||f<=a)&&(0,r.jsxs)(Wt,{children:[(0,r.jsxs)(Zt,{children:[(0,r.jsx)(R,{onClick:()=>i?.(o-1),disabled:o===1,children:"Previous"}),ft(),(0,r.jsx)(R,{onClick:()=>i?.(o+1),disabled:o===c,children:"Next"}),(0,r.jsx)(Jt,{value:a,onChange:s=>{i?.(1),v?.(Number(s.target.value))},children:[5,10,15].map(s=>(0,r.jsxs)("option",{value:s,children:[s," per page"]},s))})]}),(0,r.jsxs)(Gt,{children:["Page ",o+1," of ",c+1," (Total: ",f," items)"]})]})]})},J=Qt;var $=l(require("styled-components")),y=require("react/jsx-runtime"),te=$.default.div`
197
- display: flex;
198
- background: #135f9b;
199
- color: #fff;
200
- `,ee=$.default.div`
201
- padding: 12px 20px;
202
- font-size: 16px;
203
- font-weight: 600;
204
- cursor: pointer;
205
- border-bottom: ${({$active:t})=>t?"6px solid red":"none"};
206
- color: ${({$active:t})=>t?"#dcffed":"#fff"};
207
- transition: color 0.3s, border-bottom 0.3s;
208
-
209
- &:hover {
210
- color: #dcffed;
211
- }
212
- `,oe=$.default.div`
213
- padding: 20px;
214
- background: #f9f9f9;
215
- border-radius: 10px;
216
- box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
217
- max-width: 1300px;
218
- `,re=({tabs:t,activeTabId:e,onTabClick:o,content:i})=>(0,y.jsxs)("div",{children:[(0,y.jsx)(te,{children:t.map(a=>(0,y.jsx)(ee,{$active:a.id===e,onClick:()=>o(a.id),children:a.label},a.id))}),(0,y.jsx)(oe,{children:i})]}),G=re;var Q=l(require("styled-components")),ie=Q.default.div`
219
- border: 4px solid rgba(0, 123, 255, 0.2);
220
- border-radius: 10%;
221
- border-top: 4px solid #007bff;
222
- width: 24px;
223
- height: 24px;
224
- animation: spin 1s linear infinite;
225
-
226
- @keyframes spin {
227
- 0% {
228
- transform: rotate(0deg);
229
- }
230
- 100% {
231
- transform: rotate(360deg);
232
- }
233
- }
234
- `,tt=ie;var et=l(require("styled-components")),ne=et.default.section`
235
- text-align: center;
236
- `,ot=ne;var rt=l(require("styled-components")),ae=rt.default.div`
237
- display: flex;
238
- justify-content: space-around;
239
- margin-top: 20px;
240
- `,it=ae;var nt=l(require("styled-components")),se=nt.default.p`
241
- font-size: 20px;
242
- margin: 0;
243
- `,at=se;var st=t=>t?"":"This field is required.",lt=t=>e=>e.length<=t?"":`This field must be at most ${t} characters.`,dt=t=>e=>e.length>=t?"":`This field must be at least ${t} characters.`,ct=t=>/^[a-zA-Z0-9_]+$/.test(t)?"":"Username can only contain alphanumeric characters and underscores.",pt=t=>/^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,20}$/.test(t)?"":"Password must be 6-20 characters long, include uppercase, lowercase, and a number.";0&&(module.exports={MahatiButton,MahatiCard,MahatiDropdown,MahatiFormContainer,MahatiInput,MahatiKeyValueDisplay,MahatiLabel,MahatiMain,MahatiParagraph,MahatiRow,MahatiSection,MahatiSpinner,MahatiTabbedInterface,MahatiTable,MahatiTooltip,isValidPassword,isValidUsername,maxLength,minLength,required});
1
+ "use strict";
2
+ function _define_property(obj, key, value) {
3
+ if (key in obj) {
4
+ Object.defineProperty(obj, key, {
5
+ value: value,
6
+ enumerable: true,
7
+ configurable: true,
8
+ writable: true
9
+ });
10
+ } else {
11
+ obj[key] = value;
12
+ }
13
+ return obj;
14
+ }
15
+ function _object_spread(target) {
16
+ for(var i = 1; i < arguments.length; i++){
17
+ var source = arguments[i] != null ? arguments[i] : {};
18
+ var ownKeys = Object.keys(source);
19
+ if (typeof Object.getOwnPropertySymbols === "function") {
20
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
21
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
22
+ }));
23
+ }
24
+ ownKeys.forEach(function(key) {
25
+ _define_property(target, key, source[key]);
26
+ });
27
+ }
28
+ return target;
29
+ }
30
+ function ownKeys(object, enumerableOnly) {
31
+ var keys = Object.keys(object);
32
+ if (Object.getOwnPropertySymbols) {
33
+ var symbols = Object.getOwnPropertySymbols(object);
34
+ if (enumerableOnly) {
35
+ symbols = symbols.filter(function(sym) {
36
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
37
+ });
38
+ }
39
+ keys.push.apply(keys, symbols);
40
+ }
41
+ return keys;
42
+ }
43
+ function _object_spread_props(target, source) {
44
+ source = source != null ? source : {};
45
+ if (Object.getOwnPropertyDescriptors) {
46
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
47
+ } else {
48
+ ownKeys(Object(source)).forEach(function(key) {
49
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
50
+ });
51
+ }
52
+ return target;
53
+ }
54
+ function _object_without_properties(source, excluded) {
55
+ if (source == null) return {};
56
+ var target = _object_without_properties_loose(source, excluded);
57
+ var key, i;
58
+ if (Object.getOwnPropertySymbols) {
59
+ var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
60
+ for(i = 0; i < sourceSymbolKeys.length; i++){
61
+ key = sourceSymbolKeys[i];
62
+ if (excluded.indexOf(key) >= 0) continue;
63
+ if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
64
+ target[key] = source[key];
65
+ }
66
+ }
67
+ return target;
68
+ }
69
+ function _object_without_properties_loose(source, excluded) {
70
+ if (source == null) return {};
71
+ var target = {};
72
+ var sourceKeys = Object.keys(source);
73
+ var key, i;
74
+ for(i = 0; i < sourceKeys.length; i++){
75
+ key = sourceKeys[i];
76
+ if (excluded.indexOf(key) >= 0) continue;
77
+ target[key] = source[key];
78
+ }
79
+ return target;
80
+ }
81
+ function _tagged_template_literal(strings, raw) {
82
+ if (!raw) {
83
+ raw = strings.slice(0);
84
+ }
85
+ return Object.freeze(Object.defineProperties(strings, {
86
+ raw: {
87
+ value: Object.freeze(raw)
88
+ }
89
+ }));
90
+ }
91
+ function _type_of(obj) {
92
+ "@swc/helpers - typeof";
93
+ return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
94
+ }
95
+ function _templateObject() {
96
+ var data = _tagged_template_literal([
97
+ "\n /* Base Styles */\n display: inline-flex;\n align-items: center;\n justify-content: center;\n white-space: nowrap;\n font-size: 14px;\n font-weight: 500;\n transition: all 200ms ease-in-out;\n cursor: pointer;\n border: none;\n outline: none;\n font-family: inherit;\n position: relative;\n \n /* Focus Styles */\n &:focus-visible {\n outline: 2px solid rgba(59, 130, 246, 0.5);\n outline-offset: 2px;\n }\n \n /* Disabled State */\n &:disabled {\n pointer-events: none;\n opacity: 0.5;\n }\n\n ",
98
+ "\n\n ",
99
+ "\n\n ",
100
+ "\n\n ",
101
+ "\n"
102
+ ]);
103
+ _templateObject = function _templateObject() {
104
+ return data;
105
+ };
106
+ return data;
107
+ }
108
+ function _templateObject1() {
109
+ var data = _tagged_template_literal([
110
+ "\n display: inline-flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n transition: all 200ms ease-in-out;\n \n /* Name-based background for icon buttons */\n ",
111
+ ";\n \n /* Parse border radius from Tailwind classes */\n border-radius: ",
112
+ ";\n \n /* Parse padding from Tailwind classes */\n padding: ",
113
+ ";\n \n /* Parse background color from Tailwind classes (after name) */\n background: ",
114
+ ";\n \n width: 100%;\n height: 100%;\n \n /* Icon sizing */\n svg {\n width: 16px;\n height: 16px;\n flex-shrink: 0;\n }\n \n /* Hover and Active States */\n ",
115
+ "\n"
116
+ ]);
117
+ _templateObject1 = function _templateObject() {
118
+ return data;
119
+ };
120
+ return data;
121
+ }
122
+ function _templateObject2() {
123
+ var data = _tagged_template_literal([
124
+ "\n display: inline-flex;\n flex-direction: ",
125
+ ";\n align-items: ",
126
+ ";\n gap: ",
127
+ ";\n"
128
+ ]);
129
+ _templateObject2 = function _templateObject() {
130
+ return data;
131
+ };
132
+ return data;
133
+ }
134
+ var __create = Object.create;
135
+ var __defProp = Object.defineProperty;
136
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
137
+ var __getOwnPropNames = Object.getOwnPropertyNames;
138
+ var __getProtoOf = Object.getPrototypeOf;
139
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
140
+ var __export = function(target, all) {
141
+ for(var name in all)__defProp(target, name, {
142
+ get: all[name],
143
+ enumerable: true
144
+ });
145
+ };
146
+ var __copyProps = function(to, from, except, desc) {
147
+ if (from && (typeof from === "undefined" ? "undefined" : _type_of(from)) === "object" || typeof from === "function") {
148
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
149
+ try {
150
+ var _loop = function() {
151
+ var key = _step.value;
152
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
153
+ get: function() {
154
+ return from[key];
155
+ },
156
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
157
+ });
158
+ };
159
+ for(var _iterator = __getOwnPropNames(from)[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true)_loop();
160
+ } catch (err) {
161
+ _didIteratorError = true;
162
+ _iteratorError = err;
163
+ } finally{
164
+ try {
165
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
166
+ _iterator.return();
167
+ }
168
+ } finally{
169
+ if (_didIteratorError) {
170
+ throw _iteratorError;
171
+ }
172
+ }
173
+ }
174
+ }
175
+ return to;
176
+ };
177
+ var __toESM = function(mod, isNodeMode, target) {
178
+ return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
179
+ // file that has been converted to a CommonJS file using a Babel-
180
+ // compatible transform (i.e. "__esModule" has not been set), then set
181
+ // "default" to the CommonJS "module.exports" for node compatibility.
182
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
183
+ value: mod,
184
+ enumerable: true
185
+ }) : target, mod);
186
+ };
187
+ var __toCommonJS = function(mod) {
188
+ return __copyProps(__defProp({}, "__esModule", {
189
+ value: true
190
+ }), mod);
191
+ };
192
+ // src/index.ts
193
+ var index_exports = {};
194
+ __export(index_exports, {
195
+ MahatiButton: function() {
196
+ return Button;
197
+ }
198
+ });
199
+ module.exports = __toCommonJS(index_exports);
200
+ // src/components/Button.tsx
201
+ var import_react = __toESM(require("react"));
202
+ var import_styled = __toESM(require("@emotion/styled"));
203
+ var import_jsx_runtime = require("@emotion/react/jsx-runtime");
204
+ var parseHeightWidth = function(className) {
205
+ if (!className) return "36px";
206
+ var match = className.match(/[hw]-(\d+)/);
207
+ if (match) {
208
+ return "".concat(parseInt(match[1]) * 4, "px");
209
+ }
210
+ return "36px";
211
+ };
212
+ var parseGap = function(gapClass) {
213
+ if (!gapClass) return "8px";
214
+ var match = gapClass.match(/gap-(\d+)/);
215
+ if (match) {
216
+ return "".concat(parseInt(match[1]) * 4, "px");
217
+ }
218
+ return "8px";
219
+ };
220
+ var getColorByName = function(name) {
221
+ var colors = {
222
+ blue: "#3b82f6",
223
+ green: "#10b981",
224
+ red: "#ef4444",
225
+ orange: "#f59e0b",
226
+ purple: "#8b5cf6",
227
+ yellow: "#f59e0b",
228
+ pink: "#ec4899",
229
+ teal: "#14b8a6",
230
+ indigo: "#6366f1",
231
+ primary: "linear-gradient(to right, rgba(23, 97, 163, 1), rgba(77, 175, 131, 1))",
232
+ secondary: "#6b7280",
233
+ success: "#10b981",
234
+ danger: "#ef4444",
235
+ warning: "#f59e0b",
236
+ info: "#3b82f6"
237
+ };
238
+ return colors[name === null || name === void 0 ? void 0 : name.toLowerCase()] || colors.primary || "#3b82f6";
239
+ };
240
+ var StyledButton = import_styled.default.button(_templateObject(), function(props) {
241
+ var color = getColorByName(props.$name);
242
+ if (color) {
243
+ if (props.$iconButton) {
244
+ return "\n color: ".concat(color.startsWith("linear") || color.startsWith("rgba") ? "white" : color, ";\n ");
245
+ } else {
246
+ return "\n background: ".concat(color, ";\n color: white;\n border-radius: 6px;\n &:hover { opacity: 0.9; }\n &:active { opacity: 0.95; }\n ");
247
+ }
248
+ }
249
+ return "";
250
+ }, function(props) {
251
+ return props.$iconButton && "\n background: transparent !important;\n padding: 0;\n color: rgba(255, 255, 255, 0.9);\n height: ".concat(props.$height || "36px", ";\n width: ").concat(props.$width || "36px", ";\n min-height: ").concat(props.$height || "36px", ";\n min-width: ").concat(props.$width || "36px", ";\n border-radius: 6px;\n \n &:hover {\n background: transparent !important;\n color: rgba(255, 255, 255, 1);\n }\n \n &:active {\n background: transparent !important;\n }\n \n &:focus-visible {\n outline: 2px solid rgba(255, 255, 255, 0.7);\n outline-offset: 2px;\n }\n ");
252
+ }, function(props) {
253
+ if (props.$iconButton || props.$name) return "";
254
+ switch(props.$variant){
255
+ case "default":
256
+ return "\n background: linear-gradient(to right, rgba(23, 97, 163, 1), rgba(77, 175, 131, 1));\n color: white;\n border-radius: 6px;\n &:hover { opacity: 0.9; }\n &:active { opacity: 0.95; }\n ";
257
+ case "destructive":
258
+ return "\n background: #ef4444;\n color: white;\n border-radius: 6px;\n &:hover { background: #dc2626; }\n &:active { background: #b91c1c; }\n ";
259
+ case "outline":
260
+ return "\n border: 1px solid #e5e7eb;\n background: white;\n color: #374151;\n border-radius: 6px;\n &:hover { \n background: #f9fafb;\n border-color: #d1d5db;\n }\n &:active { background: #f3f4f6; }\n ";
261
+ case "secondary":
262
+ return "\n background: ".concat(getColorByName("blue"), ";\n color: #374151;\n border-radius: 6px;\n &:hover { background: #e5e7eb; }\n &:active { background: #d1d5db; }\n ");
263
+ case "ghost":
264
+ return "\n background: transparent;\n color: #374151;\n border-radius: 6px;\n &:hover { background: #f3f4f6; }\n &:active { background: #e5e7eb; }\n ";
265
+ case "link":
266
+ return "\n background: transparent;\n color: #2563eb;\n text-decoration: underline;\n text-underline-offset: 4px;\n padding: 0;\n height: auto;\n &:hover { \n text-decoration: none;\n color: #1d4ed8;\n }\n &:active { color: #1e40af; }\n ";
267
+ case "danger":
268
+ return "\n background: transparent;\n color: #ef4444;\n border-radius: 6px;\n &:hover {\n background: rgba(239, 68, 68, 0.1);\n }\n &:active {\n background: rgba(239, 68, 68, 0.2);\n }\n ";
269
+ case "dotted":
270
+ return "\n background: linear-gradient(to right, #1e73be, #28a97d);\n color: white;\n border-radius: 8px;\n position: relative;\n overflow: visible;\n \n &::before {\n content: '';\n position: absolute;\n inset: -2px;\n border-radius: 10px;\n padding: 2px;\n background: linear-gradient(to right, #1e73be, #28a97d);\n -webkit-mask: \n linear-gradient(#fff 0 0) content-box, \n linear-gradient(#fff 0 0);\n -webkit-mask-composite: xor;\n mask-composite: exclude;\n border: 2px dashed rgba(255, 255, 255, 0.5);\n }\n \n &:hover { opacity: 0.9; }\n &:active { opacity: 0.95; }\n ";
271
+ case "pill":
272
+ return "\n background: linear-gradient(to right, rgba(23, 97, 163, 1), rgba(77, 175, 131, 1));\n color: white;\n border-radius: 9999px;\n &:hover { opacity: 0.9; }\n &:active { opacity: 0.95; }\n ";
273
+ default:
274
+ return "\n background: linear-gradient(to right, rgba(23, 97, 163, 1), rgba(77, 175, 131, 1));\n color: white;\n border-radius: 6px;\n &:hover { opacity: 0.9; }\n ";
275
+ }
276
+ }, function(props) {
277
+ if (props.$iconButton) return "";
278
+ switch(props.$size){
279
+ case "sm":
280
+ return "height: 36px; padding: 0 12px; font-size: 13px;";
281
+ case "md":
282
+ return "height: 40px; padding: 0 16px; font-size: 14px;";
283
+ case "lg":
284
+ return "height: 44px; padding: 0 24px; font-size: 15px;";
285
+ case "icon":
286
+ return "height: 40px; width: 40px; padding: 0;";
287
+ default:
288
+ return "height: 40px; padding: 0 16px;";
289
+ }
290
+ });
291
+ var IconButtonInner = import_styled.default.span(_templateObject1(), function(props) {
292
+ var color = getColorByName(props.$name);
293
+ if (color) {
294
+ return "\n background: ".concat(color.startsWith("linear") ? color : "rgba(".concat(color.slice(1), ", 0.12)"), ";\n ");
295
+ }
296
+ return "";
297
+ }, function(props) {
298
+ if (!props.$radiusClass) return "6px";
299
+ var match = props.$radiusClass.match(/rounded-\[(\d+)px\]/);
300
+ if (match) return "".concat(match[1], "px");
301
+ if (props.$radiusClass === "rounded-md") return "6px";
302
+ if (props.$radiusClass === "rounded-lg") return "8px";
303
+ if (props.$radiusClass === "rounded-full") return "9999px";
304
+ return "6px";
305
+ }, function(props) {
306
+ if (!props.$paddingClass) return "2px";
307
+ var match = props.$paddingClass.match(/p-\[(\d+)px\]/);
308
+ if (match) return "".concat(match[1], "px");
309
+ return "2px";
310
+ }, function(props) {
311
+ if (props.$name) return "initial";
312
+ if (!props.$bgClass) return "rgba(255, 255, 255, 0.12)";
313
+ var rgbaMatch = props.$bgClass.match(/bg-\[(rgba?\([^)]+\))\]/);
314
+ if (rgbaMatch) return rgbaMatch[1];
315
+ return "rgba(255, 255, 255, 0.12)";
316
+ }, function(props) {
317
+ if (props.$hoverBgClass) {
318
+ var hoverMatch = props.$hoverBgClass.match(/hover:bg-\[(rgba?\([^)]+\))\]/);
319
+ var activeMatch = props.$hoverBgClass.match(/active:bg-\[(rgba?\([^)]+\))\]/);
320
+ var styles = "";
321
+ if (hoverMatch) {
322
+ styles += "button:hover & { background: ".concat(hoverMatch[1], "; }");
323
+ }
324
+ if (activeMatch) {
325
+ styles += "button:active & { background: ".concat(activeMatch[1], "; }");
326
+ }
327
+ return styles;
328
+ }
329
+ if (props.$intensity != null) {
330
+ var v = Math.max(0, Math.min(100, props.$intensity));
331
+ if (v === 0) return "";
332
+ if (v <= 10) return "button:hover & { opacity: 0.95; } button:active & { opacity: 0.90; }";
333
+ if (v <= 25) return "button:hover & { opacity: 0.90; } button:active & { opacity: 0.80; }";
334
+ if (v <= 40) return "button:hover & { opacity: 0.85; } button:active & { opacity: 0.75; }";
335
+ if (v <= 55) return "button:hover & { opacity: 0.80; } button:active & { opacity: 0.70; }";
336
+ if (v <= 70) return "button:hover & { opacity: 0.75; } button:active & { opacity: 0.65; }";
337
+ if (v <= 85) return "button:hover & { opacity: 0.70; } button:active & { opacity: 0.60; }";
338
+ return "button:hover & { opacity: 0.60; } button:active & { opacity: 0.50; }";
339
+ }
340
+ return "\n button:hover & { opacity: 0.85; }\n button:active & { opacity: 0.7; }\n ";
341
+ });
342
+ var IconButtonGroupWrapper = import_styled.default.div(_templateObject2(), function(props) {
343
+ return props.$direction === "col" ? "column" : "row";
344
+ }, function(props) {
345
+ return props.$direction === "col" ? "flex-start" : "center";
346
+ }, function(props) {
347
+ return props.$gap || "8px";
348
+ });
349
+ var IconButtonGroup = import_react.default.forwardRef(function(_param, ref) {
350
+ var className = _param.className, _param_direction = _param.direction, direction = _param_direction === void 0 ? "row" : _param_direction, gapClass = _param.gapClass, props = _object_without_properties(_param, [
351
+ "className",
352
+ "direction",
353
+ "gapClass"
354
+ ]);
355
+ var gap = parseGap(gapClass);
356
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButtonGroupWrapper, _object_spread({
357
+ ref: ref,
358
+ $direction: direction,
359
+ $gap: gap,
360
+ className: className
361
+ }, props));
362
+ });
363
+ IconButtonGroup.displayName = "IconButtonGroup";
364
+ var ButtonBase = import_react.default.forwardRef(function(_param, ref) {
365
+ var className = _param.className, _param_variant = _param.variant, variant = _param_variant === void 0 ? "default" : _param_variant, _param_size = _param.size, size = _param_size === void 0 ? "default" : _param_size, name = _param.name, _param_iconButton = _param.iconButton, iconButton = _param_iconButton === void 0 ? false : _param_iconButton, iconButtonHeightClass = _param.iconButtonHeightClass, iconButtonWidthClass = _param.iconButtonWidthClass, iconButtonBgClass = _param.iconButtonBgClass, iconButtonRadiusClass = _param.iconButtonRadiusClass, iconButtonBgPaddingClass = _param.iconButtonBgPaddingClass, iconButtonHoverBgClass = _param.iconButtonHoverBgClass, iconButtonHoverIntensity = _param.iconButtonHoverIntensity, children = _param.children, props = _object_without_properties(_param, [
366
+ "className",
367
+ "variant",
368
+ "size",
369
+ "name",
370
+ "iconButton",
371
+ "iconButtonHeightClass",
372
+ "iconButtonWidthClass",
373
+ "iconButtonBgClass",
374
+ "iconButtonRadiusClass",
375
+ "iconButtonBgPaddingClass",
376
+ "iconButtonHoverBgClass",
377
+ "iconButtonHoverIntensity",
378
+ "children"
379
+ ]);
380
+ if (iconButton) {
381
+ var height = parseHeightWidth(iconButtonHeightClass);
382
+ var width = parseHeightWidth(iconButtonWidthClass);
383
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledButton, _object_spread_props(_object_spread({
384
+ $variant: variant,
385
+ $size: size,
386
+ $iconButton: true,
387
+ $height: height,
388
+ $width: width,
389
+ $name: name,
390
+ className: className,
391
+ ref: ref
392
+ }, props), {
393
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(IconButtonInner, {
394
+ $bgClass: iconButtonBgClass,
395
+ $radiusClass: iconButtonRadiusClass,
396
+ $paddingClass: iconButtonBgPaddingClass,
397
+ $hoverBgClass: iconButtonHoverBgClass,
398
+ $intensity: iconButtonHoverIntensity,
399
+ $name: name,
400
+ children: children
401
+ })
402
+ }));
403
+ }
404
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(StyledButton, _object_spread_props(_object_spread({
405
+ $variant: variant,
406
+ $size: size,
407
+ $name: name,
408
+ className: className,
409
+ ref: ref
410
+ }, props), {
411
+ children: children
412
+ }));
413
+ });
414
+ ButtonBase.displayName = "Button";
415
+ var Button = ButtonBase;
416
+ Button.IconButtonGroup = IconButtonGroup;
417
+ // Annotate the CommonJS export names for ESM import in node:
418
+ 0 && (module.exports = {
419
+ MahatiButton: MahatiButton
420
+ });
244
421
  //# sourceMappingURL=index.js.map