klip-components 0.12.1 → 0.14.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.d.ts +83 -37
- package/dist/klip-components.cjs.js +1 -1
- package/dist/klip-components.css +1 -1
- package/dist/klip-components.es.js +289 -4
- package/dist/klip-components.umd.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,9 @@ import { ClassValue } from 'clsx';
|
|
|
2
2
|
import { clsx } from 'clsx';
|
|
3
3
|
import { default as default_2 } from 'react';
|
|
4
4
|
import { JSX } from 'react/jsx-runtime';
|
|
5
|
+
import { MenuContentProps } from './MenuContent/MenuContent';
|
|
6
|
+
import { MenuItemProps } from './MenuItem/MenuItem';
|
|
7
|
+
import { MenuTriggerProps } from './MenuTrigger/MenuTrigger';
|
|
5
8
|
|
|
6
9
|
export declare interface BorderRadius {
|
|
7
10
|
sm: string;
|
|
@@ -61,6 +64,12 @@ export declare interface BorderRadius {
|
|
|
61
64
|
* </Button>
|
|
62
65
|
*
|
|
63
66
|
* @example
|
|
67
|
+
* // Button with hover disabled (useful for ellipsis buttons)
|
|
68
|
+
* <Button hover={false}>
|
|
69
|
+
* ...
|
|
70
|
+
* </Button>
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
64
73
|
* // Square button with icon
|
|
65
74
|
* <Button
|
|
66
75
|
* variant="primary"
|
|
@@ -97,6 +106,10 @@ export declare interface ButtonProps extends default_2.ButtonHTMLAttributes<HTML
|
|
|
97
106
|
loading?: boolean;
|
|
98
107
|
/** Content to be rendered inside the button */
|
|
99
108
|
children: default_2.ReactNode;
|
|
109
|
+
/** Whether the menu/dropdown is open (used by Menu.Trigger) */
|
|
110
|
+
isOpen?: boolean;
|
|
111
|
+
/** Whether to enable hover effects (defaults to true) */
|
|
112
|
+
hover?: boolean;
|
|
100
113
|
}
|
|
101
114
|
|
|
102
115
|
export declare const ButtonSelect: default_2.FC<ButtonSelectProps>;
|
|
@@ -121,43 +134,7 @@ declare type ButtonShape = 'rectangle' | 'pill' | 'square' | 'circle';
|
|
|
121
134
|
declare type ButtonSize = 'sm' | 'md' | 'lg';
|
|
122
135
|
|
|
123
136
|
/**
|
|
124
|
-
* Props interface for
|
|
125
|
-
variant = 'primary',
|
|
126
|
-
size = 'md',
|
|
127
|
-
shape = 'rectangle',
|
|
128
|
-
startIcon,
|
|
129
|
-
endIcon,
|
|
130
|
-
loading = false,
|
|
131
|
-
className = '',
|
|
132
|
-
children,
|
|
133
|
-
disabled,
|
|
134
|
-
...props
|
|
135
|
-
}) => {
|
|
136
|
-
return (
|
|
137
|
-
<button
|
|
138
|
-
className={cn(
|
|
139
|
-
'btn',
|
|
140
|
-
`btn-${variant}`,
|
|
141
|
-
`btn-${size}`,
|
|
142
|
-
`btn-${shape}`,
|
|
143
|
-
{ 'btn-loading': loading },
|
|
144
|
-
className
|
|
145
|
-
)}
|
|
146
|
-
disabled={disabled || loading}
|
|
147
|
-
{...props}
|
|
148
|
-
>
|
|
149
|
-
{loading ? (
|
|
150
|
-
<Spinner />
|
|
151
|
-
) : (
|
|
152
|
-
<>
|
|
153
|
-
{startIcon && <span className="btn-icon-start">{startIcon}</span>}
|
|
154
|
-
{children}
|
|
155
|
-
{endIcon && <span className="btn-icon-end">{endIcon}</span>}
|
|
156
|
-
</>
|
|
157
|
-
)}
|
|
158
|
-
</button>
|
|
159
|
-
);
|
|
160
|
-
};
|
|
137
|
+
* Props interface for the Button component.
|
|
161
138
|
* Extends standard HTML button attributes with additional styling options.
|
|
162
139
|
*/
|
|
163
140
|
declare type ButtonVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'link' | 'outline' | 'ghost' | 'icon';
|
|
@@ -314,6 +291,68 @@ export declare interface InputProps extends HtmlInput {
|
|
|
314
291
|
|
|
315
292
|
export declare type InputVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'ghost';
|
|
316
293
|
|
|
294
|
+
export declare const Menu: default_2.FC<MenuProps> & {
|
|
295
|
+
Trigger: default_2.FC<MenuTriggerProps>;
|
|
296
|
+
Content: default_2.FC<MenuContentProps>;
|
|
297
|
+
Item: default_2.FC<MenuItemProps>;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
export declare const MenuContent: default_2.FC<MenuContentProps_2>;
|
|
301
|
+
|
|
302
|
+
declare interface MenuContentProps_2 {
|
|
303
|
+
children: default_2.ReactNode;
|
|
304
|
+
className?: string;
|
|
305
|
+
style?: default_2.CSSProperties;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare interface MenuContextProps {
|
|
309
|
+
children: React.ReactNode;
|
|
310
|
+
menuPosition?: MenuPosition;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
export declare const MenuContextProvider: React.FC<MenuContextProps>;
|
|
314
|
+
|
|
315
|
+
declare interface MenuContextType {
|
|
316
|
+
isOpen: boolean;
|
|
317
|
+
position: Position;
|
|
318
|
+
menuPosition: MenuPosition;
|
|
319
|
+
triggerRef: default_2.RefObject<HTMLDivElement | null>;
|
|
320
|
+
contentRef: default_2.RefObject<HTMLDivElement | null>;
|
|
321
|
+
openMenu: () => void;
|
|
322
|
+
closeMenu: () => void;
|
|
323
|
+
repositionMenu: () => void;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export declare const MenuItem: default_2.FC<MenuItemProps_2>;
|
|
327
|
+
|
|
328
|
+
declare interface MenuItemProps_2 {
|
|
329
|
+
children: default_2.ReactNode;
|
|
330
|
+
onClick?: () => void;
|
|
331
|
+
closeMenu?: () => void;
|
|
332
|
+
disabled?: boolean;
|
|
333
|
+
className?: string;
|
|
334
|
+
style?: default_2.CSSProperties;
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
declare type MenuPosition = 'bottom-left' | 'bottom-right' | 'bottom-center' | 'top-left' | 'top-right' | 'top-center' | 'left-top' | 'left-bottom' | 'left-center' | 'right-top' | 'right-bottom' | 'right-center';
|
|
338
|
+
|
|
339
|
+
declare interface MenuProps {
|
|
340
|
+
children: default_2.ReactNode;
|
|
341
|
+
className?: string;
|
|
342
|
+
style?: default_2.CSSProperties;
|
|
343
|
+
position?: MenuPosition;
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
export declare const MenuTrigger: default_2.FC<MenuTriggerProps_2>;
|
|
347
|
+
|
|
348
|
+
declare interface MenuTriggerProps_2 {
|
|
349
|
+
children: default_2.ReactElement<{
|
|
350
|
+
isOpen?: boolean;
|
|
351
|
+
}>;
|
|
352
|
+
className?: string;
|
|
353
|
+
style?: default_2.CSSProperties;
|
|
354
|
+
}
|
|
355
|
+
|
|
317
356
|
/**
|
|
318
357
|
* Merges multiple CSS class strings and removes duplicates while preserving order.
|
|
319
358
|
* Takes an array of class strings, splits them by spaces, filters out empty values,
|
|
@@ -359,6 +398,11 @@ export declare interface PaginationProps {
|
|
|
359
398
|
mobile?: boolean;
|
|
360
399
|
}
|
|
361
400
|
|
|
401
|
+
declare interface Position {
|
|
402
|
+
x: number;
|
|
403
|
+
y: number;
|
|
404
|
+
}
|
|
405
|
+
|
|
362
406
|
declare interface Props {
|
|
363
407
|
width?: number;
|
|
364
408
|
height?: number;
|
|
@@ -618,6 +662,8 @@ export declare interface Typography {
|
|
|
618
662
|
};
|
|
619
663
|
}
|
|
620
664
|
|
|
665
|
+
export declare const useMenuContext: () => MenuContextType;
|
|
666
|
+
|
|
621
667
|
export declare const usePagination: ({ currentPage, totalPages, siblingCount }: UsePaginationProps) => (string | number)[];
|
|
622
668
|
|
|
623
669
|
declare interface UsePaginationProps {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,a=Object.defineProperties,r=Object.getOwnPropertyDescriptors,s=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable,i=(a,r,s)=>r in a?e(a,r,{enumerable:!0,configurable:!0,writable:!0,value:s}):a[r]=s,l=(e,a)=>{for(var r in a||(a={}))t.call(a,r)&&i(e,r,a[r]);if(s)for(var r of s(a))n.call(a,r)&&i(e,r,a[r]);return e},o=(e,s)=>a(e,r(s)),c=(e,a)=>{var r={};for(var i in e)t.call(e,i)&&a.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&s)for(var i of s(e))a.indexOf(i)<0&&n.call(e,i)&&(r[i]=e[i]);return r};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),h=require("react");function p(e){var a,r,s="";if("string"==typeof e||"number"==typeof e)s+=e;else if("object"==typeof e)if(Array.isArray(e)){var t=e.length;for(a=0;a<t;a++)e[a]&&(r=p(e[a]))&&(s&&(s+=" "),s+=r)}else for(r in e)e[r]&&(s&&(s+=" "),s+=r);return s}function u(){for(var e,a,r=0,s="",t=arguments.length;r<t;r++)(e=arguments[r])&&(a=p(e))&&(s&&(s+=" "),s+=a);return s}function x(...e){const a=e.join(" ").split(" ").filter(Boolean);return[...new Set(a)].join(" ")}function m(...e){return x(u(...e))}const g=({width:e=24,height:a=24})=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:a,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m15 6l-6 6l6 6"})}),b=({width:e=24,height:a=24})=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:a,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 6l6 6l-6 6"})}),f=({color:e="currentColor",size:a=24})=>d.jsxs("svg",{width:a,height:a,stroke:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("style",{children:"\n .spinner_V8m1{transform-origin:center;animation:spinner_zKoa 2s linear infinite}\n .spinner_V8m1 circle{stroke-linecap:round;animation:spinner_YpZS 1.5s ease-in-out infinite}\n @keyframes spinner_zKoa{100%{transform:rotate(360deg)}}\n @keyframes spinner_YpZS{\n 0%{stroke-dasharray:0 150;stroke-dashoffset:0}\n 47.5%{stroke-dasharray:42 150;stroke-dashoffset:-16}\n 95%,100%{stroke-dasharray:42 150;stroke-dashoffset:-59}\n }\n "}),d.jsx("g",{className:"spinner_V8m1",children:d.jsx("circle",{cx:"12",cy:"12",r:"9.5",fill:"none",strokeWidth:"3"})})]}),v=e=>{var a=e,{variant:r="primary",size:s="md",shape:t="rectangle",startIcon:n,endIcon:i,className:h="",children:p,loading:u,disabled:x}=a,g=c(a,["variant","size","shape","startIcon","endIcon","className","children","loading","disabled"]);return d.jsx("button",o(l({className:m("btn",`btn-${r}`,`btn-${s}`,`btn-${t}`,{"btn-loading":u},h),disabled:x||u},g),{children:u?d.jsx(f,{}):d.jsxs(d.Fragment,{children:[n&&d.jsx("span",{className:"btn-icon-start",children:n}),p,i&&d.jsx("span",{className:"btn-icon-end",children:i})]})}))},j="...",y=({currentPage:e,totalPages:a,siblingCount:r=1})=>h.useMemo(()=>{if(a<=7)return Array.from({length:a},(e,a)=>a+1);const s=Math.max(e-r,1),t=Math.min(e+r,a),n=s>2,i=t<a-1;if(!n&&!i)return Array.from({length:a},(e,a)=>a+1);if(!n&&i){const e=3+2*r;return[...Array.from({length:e},(e,a)=>a+1),j,a]}if(n&&!i){const e=3+2*r;return[1,j,...Array.from({length:e},(r,s)=>a-e+s+1)]}return[1,j,...Array.from({length:t-s+1},(e,a)=>s+a),j,a]},[e,a,r]),N=e=>{var a=e,{className:r="",children:s}=a,t=c(a,["className","children"]);return d.jsx("thead",o(l({className:m("table-header",r)},t),{children:s}))},w=e=>{var a=e,{className:r="",children:s}=a,t=c(a,["className","children"]);return d.jsx("tbody",o(l({className:m("table-body",r)},t),{children:s}))},k=e=>{var a=e,{className:r="",children:s}=a,t=c(a,["className","children"]);return d.jsx("tfoot",o(l({className:m("table-footer",r)},t),{children:s}))},C=e=>{var a=e,{className:r="",selected:s=!1,children:t}=a,n=c(a,["className","selected","children"]);return d.jsx("tr",o(l({className:m("table-row",{"table-row-selected":s},r)},n),{children:t}))},P=e=>{var a=e,{className:r="",header:s=!1,align:t="left",minWidth:n,maxWidth:i,width:h,children:p,style:u}=a,x=c(a,["className","header","align","minWidth","maxWidth","width","children","style"]);const g=s?"th":"td",b=l(l(l(l({},n&&{minWidth:n}),i&&{maxWidth:i}),h&&{width:h}),u);return d.jsx(g,o(l({className:m("table-cell",`table-cell-${t}`,{"table-cell-header":s},r),style:Object.keys(b).length>0?b:u},x),{children:p}))},z=e=>{var a=e,{className:r="",variant:s="default",dense:t=!1,children:n}=a,i=c(a,["className","variant","dense","children"]);const h=d.jsx("table",o(l({className:m("table",`table-${s}`,{"table-dense":t},r)},i),{children:n}));return d.jsx("div",{className:"table-responsive",children:h})};z.Header=N,z.Body=w,z.Footer=k,z.Row=C,z.Cell=P,exports.Button=v,exports.ButtonSelect=({options:e,value:a,onChange:r,disabled:s=!1,multiple:t=!1})=>{const n=e=>Array.isArray(a)?a.includes(e):e===a;return d.jsx("div",{className:"button-select "+(s?"disabled":""),children:e.map(({value:e,child:i})=>d.jsx("button",{className:"button-select-option "+(n(e)?"selected":""),onClick:()=>(e=>{if(s)return;if(!t)return void r(e);const n=Array.isArray(a)?a:[],i=n.includes(e)?n.filter(a=>a!==e):[...n,e];r(i)})(e),disabled:s,type:"button",children:i},e))})},exports.ChevronLeft=g,exports.ChevronRight=b,exports.DOTS=j,exports.Input=e=>{var a=e,{variant:r="primary",type:s="text",label:t,prefix:n,suffix:i,helperText:o,className:p,labelClass:u,helperTextClass:x,onChange:g,id:b,hasError:v,loading:j=!1,disabled:y}=a,N=c(a,["variant","type","label","prefix","suffix","helperText","className","labelClass","helperTextClass","onChange","id","hasError","loading","disabled"]);const w=h.useId(),k=b||`input-${w}`,C=m("form-field",{"has-prefix":!!n,"has-suffix":!!i},{[`variant-${r}`]:r},{loading:j},p);return d.jsxs("article",{className:"input-container",children:[t&&d.jsx("label",{htmlFor:k,className:m("input-label",u),children:t}),d.jsxs("section",{className:m("input-wrapper",{loading:j}),children:[n&&d.jsx("article",{className:"input-prefix",children:n}),d.jsx("input",l({id:k,type:s,className:C,onChange:e=>null==g?void 0:g(e.target.value),disabled:y||j},N)),j?d.jsx("article",{className:"input-suffix",children:d.jsx(f,{})}):i&&d.jsx("article",{className:"input-suffix",children:i})]}),o&&d.jsx("small",{className:m("input-helper-text",x),style:{color:v?"var(--color-danger)":"inherit"},children:o})]})},exports.Pagination=({currentPage:e,totalPages:a,onPageChange:r,siblingCount:s=1,hidePrevButton:t=!1,hideNextButton:n=!1,size:i="md",variant:l="secondary",className:o="",disabled:c=!1,mobile:h=!1})=>{const p=y({currentPage:e,totalPages:a,siblingCount:s});if(0===e||0===a)return null;const u=()=>{e<a&&!c&&r(e+1)},x=()=>{e>1&&!c&&r(e-1)},f=p[p.length-1];return h?d.jsxs("article",{className:m("pagination","pagination--mobile",o),"aria-label":"pagination navigation",children:[!t&&d.jsx(v,{variant:l,size:i,onClick:x,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(g,{})}),d.jsxs("span",{className:"pagination__page-indicator","aria-live":"polite",children:[e," / ",a," pages"]}),!n&&d.jsx(v,{variant:l,size:i,onClick:u,disabled:e===f||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(b,{})})]}):d.jsxs("article",{className:m("pagination",o),"aria-label":"pagination navigation",children:[!t&&d.jsx(v,{variant:l,size:i,onClick:x,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(g,{})}),p.map((s,t)=>s===j?d.jsx(v,{variant:l,size:i,"aria-label":"More pages",shape:"square",disabled:c,children:"…"},t):d.jsx(v,{variant:s===e?"primary":l,size:i,onClick:()=>!c&&r(s),disabled:c||1===a,"aria-label":s===e?`Current page, page ${s}`:`Go to page ${s}`,"aria-current":s===e?"page":void 0,shape:"square",children:s},t)),!n&&d.jsx(v,{variant:l,size:i,onClick:u,disabled:e===f||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(b,{})})]})},exports.Spinner=f,exports.Table=z,exports.TableBody=w,exports.TableCell=P,exports.TableFooter=k,exports.TableHeader=N,exports.TableRow=C,exports.Toggle=e=>{var a=e,{color:r="var(--color-primary)",size:s="3.75rem",checked:t=!1,onChange:n,label:i,labelPosition:o="right",className:h}=a,p=c(a,["color","size","checked","onChange","label","labelPosition","className"]);return d.jsxs("label",{className:m("switch-container",o,h),children:[d.jsxs("div",{className:"toggle-switch",style:{"--switch-size":s,"--switch-color":r},children:[d.jsx("input",l({type:"checkbox",role:"switch",checked:t,onChange:e=>null==n?void 0:n(e.target.checked)},p)),d.jsx("span",{className:"slider"})]}),i&&d.jsx("span",{className:"switch-label",children:i})]})},exports.clsx=u,exports.cn=m,exports.mergeClasses=x,exports.usePagination=y;
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,i=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,l=(e,t)=>{for(var r in t||(t={}))a.call(t,r)&&i(e,r,t[r]);if(n)for(var r of n(t))s.call(t,r)&&i(e,r,t[r]);return e},o=(e,n)=>t(e,r(n)),c=(e,t)=>{var r={};for(var i in e)a.call(e,i)&&t.indexOf(i)<0&&(r[i]=e[i]);if(null!=e&&n)for(var i of n(e))t.indexOf(i)<0&&s.call(e,i)&&(r[i]=e[i]);return r};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),u=require("react");function h(e){var t,r,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var a=e.length;for(t=0;t<a;t++)e[t]&&(r=h(e[t]))&&(n&&(n+=" "),n+=r)}else for(r in e)e[r]&&(n&&(n+=" "),n+=r);return n}function p(){for(var e,t,r=0,n="",a=arguments.length;r<a;r++)(e=arguments[r])&&(t=h(e))&&(n&&(n+=" "),n+=t);return n}function m(...e){const t=e.join(" ").split(" ").filter(Boolean);return[...new Set(t)].join(" ")}function b(...e){return m(p(...e))}const x=({width:e=24,height:t=24})=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m15 6l-6 6l6 6"})}),g=({width:e=24,height:t=24})=>d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:e,height:t,viewBox:"0 0 24 24",children:d.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"m9 6l6 6l-6 6"})}),f=({color:e="currentColor",size:t=24})=>d.jsxs("svg",{width:t,height:t,stroke:e,viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:[d.jsx("style",{children:"\n .spinner_V8m1{transform-origin:center;animation:spinner_zKoa 2s linear infinite}\n .spinner_V8m1 circle{stroke-linecap:round;animation:spinner_YpZS 1.5s ease-in-out infinite}\n @keyframes spinner_zKoa{100%{transform:rotate(360deg)}}\n @keyframes spinner_YpZS{\n 0%{stroke-dasharray:0 150;stroke-dashoffset:0}\n 47.5%{stroke-dasharray:42 150;stroke-dashoffset:-16}\n 95%,100%{stroke-dasharray:42 150;stroke-dashoffset:-59}\n }\n "}),d.jsx("g",{className:"spinner_V8m1",children:d.jsx("circle",{cx:"12",cy:"12",r:"9.5",fill:"none",strokeWidth:"3"})})]}),v=e=>{var t=e,{variant:r="primary",size:n="md",shape:a="rectangle",startIcon:s,endIcon:i,className:u="",children:h,loading:p,disabled:m,hover:x=!0}=t,g=c(t,["variant","size","shape","startIcon","endIcon","className","children","loading","disabled","hover"]);return d.jsx("button",o(l({className:b("btn",`btn-${r}`,`btn-${n}`,`btn-${a}`,{"btn-loading":p,"btn-no-hover":!x},u),disabled:m||p},g),{children:p?d.jsx(f,{}):d.jsxs(d.Fragment,{children:[s&&d.jsx("span",{className:"btn-icon-start",children:s}),h,i&&d.jsx("span",{className:"btn-icon-end",children:i})]})}))},y="...",j=({currentPage:e,totalPages:t,siblingCount:r=1})=>u.useMemo(()=>{if(t<=7)return Array.from({length:t},(e,t)=>t+1);const n=Math.max(e-r,1),a=Math.min(e+r,t),s=n>2,i=a<t-1;if(!s&&!i)return Array.from({length:t},(e,t)=>t+1);if(!s&&i){const e=3+2*r;return[...Array.from({length:e},(e,t)=>t+1),y,t]}if(s&&!i){const e=3+2*r;return[1,y,...Array.from({length:e},(r,n)=>t-e+n+1)]}return[1,y,...Array.from({length:a-n+1},(e,t)=>n+t),y,t]},[e,t,r]),w=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("thead",o(l({className:b("table-header",r)},a),{children:n}))},N=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("tbody",o(l({className:b("table-body",r)},a),{children:n}))},k=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("tfoot",o(l({className:b("table-footer",r)},a),{children:n}))},C=e=>{var t=e,{className:r="",selected:n=!1,children:a}=t,s=c(t,["className","selected","children"]);return d.jsx("tr",o(l({className:b("table-row",{"table-row-selected":n},r)},s),{children:a}))},M=e=>{var t=e,{className:r="",header:n=!1,align:a="left",minWidth:s,maxWidth:i,width:u,children:h,style:p}=t,m=c(t,["className","header","align","minWidth","maxWidth","width","children","style"]);const x=n?"th":"td",g=l(l(l(l({},s&&{minWidth:s}),i&&{maxWidth:i}),u&&{width:u}),p);return d.jsx(x,o(l({className:b("table-cell",`table-cell-${a}`,{"table-cell-header":n},r),style:Object.keys(g).length>0?g:p},m),{children:h}))},P=e=>{var t=e,{className:r="",variant:n="default",dense:a=!1,children:s}=t,i=c(t,["className","variant","dense","children"]);const u=d.jsx("table",o(l({className:b("table",`table-${n}`,{"table-dense":a},r)},i),{children:s}));return d.jsx("div",{className:"table-responsive",children:u})};P.Header=w,P.Body=N,P.Footer=k,P.Row=C,P.Cell=M;const T=u.createContext(void 0),E=()=>{const e=u.useContext(T);if(void 0===e)throw new Error("useMenuContext must be used within a MenuContextProvider");return e},O=({children:e,menuPosition:t="bottom-left"})=>{const[r,n]=u.useState(!1),[a,s]=u.useState({x:0,y:0}),i=u.useRef(null),l=u.useRef(null),o=u.useCallback((e,r)=>{const n=10,a=(null==r?void 0:r.width)||200,s=(null==r?void 0:r.height)||150,i=window.innerWidth,l=window.innerHeight;let o=0,c=0;switch(t){case"bottom-left":default:o=e.left,c=e.bottom+n;break;case"bottom-right":o=e.right-a,c=e.bottom+n;break;case"bottom-center":o=e.left+e.width/2-a/2,c=e.bottom+n;break;case"top-left":o=e.left,c=e.top-15-s;break;case"top-right":o=e.right-a,c=e.top-15-s;break;case"top-center":o=e.left+e.width/2-a/2,c=e.top-15-s;break;case"left-top":o=e.left-15-a,c=e.top;break;case"left-bottom":o=e.left-15-a,c=e.bottom-s;break;case"left-center":o=e.left-15-a,c=e.top+e.height/2-s/2;break;case"right-top":o=e.right+n,c=e.top;break;case"right-bottom":o=e.right+n,c=e.bottom-s;break;case"right-center":o=e.right+n,c=e.top+e.height/2-s/2}return o=Math.max(n,Math.min(o,i-a-n)),c=Math.max(n,Math.min(c,l-s-n)),{x:o,y:c}},[t]),c=u.useCallback(()=>{var e;if(!i.current)return;const t=i.current.getBoundingClientRect(),r=null==(e=l.current)?void 0:e.getBoundingClientRect();s(o(t,r))},[o]),h=()=>n(!1);return u.useEffect(()=>{if(r&&i.current){const e=()=>{var e;const t=i.current.getBoundingClientRect(),r=null==(e=l.current)?void 0:e.getBoundingClientRect();s(o(t,r))};e();const t=setTimeout(e,50);return()=>clearTimeout(t)}},[r,o]),u.useEffect(()=>{const e=e=>{l.current&&l.current.contains(e.target)||i.current&&i.current.contains(e.target)||h()};if(r)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),u.useEffect(()=>{const e=e=>{"Escape"===e.key&&r&&h()};if(r)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]),d.jsx(T.Provider,{value:{isOpen:r,position:a,menuPosition:t,triggerRef:i,contentRef:l,openMenu:()=>{i.current&&n(!0)},closeMenu:h,repositionMenu:c},children:e})},z=({children:e,className:t,style:r={}})=>{const{isOpen:n,position:a,contentRef:s,closeMenu:i}=E(),[o,c]=u.useState(!1),[h,p]=u.useState(!1);u.useEffect(()=>{if(n){p(!0);const e=setTimeout(()=>{if(c(!0),s.current){const e=s.current.querySelector('[role="menuitem"]:not([disabled])');e&&e.focus()}},10);return()=>clearTimeout(e)}c(!1);const e=setTimeout(()=>p(!1),150);return()=>clearTimeout(e)},[n,s]);return h?d.jsx("article",{ref:s,className:b("menu-content",{"menu-content--open":o},t),style:l({left:`${a.x}px`,top:`${a.y}px`,opacity:o?1:0,transition:"opacity 0.15s ease-in-out"},r),role:"menu","aria-orientation":"vertical",onKeyDown:e=>{var t,r;if(!s.current)return;const n=Array.from(s.current.querySelectorAll('[role="menuitem"]:not([disabled])')),a=n.findIndex(e=>e===document.activeElement);switch(e.key){case"ArrowDown":e.preventDefault();null==(t=n[a<n.length-1?a+1:0])||t.focus();break;case"ArrowUp":e.preventDefault();null==(r=n[a>0?a-1:n.length-1])||r.focus();break;case"Escape":e.preventDefault(),i()}},tabIndex:-1,children:u.Children.map(e,e=>u.isValidElement(e)?u.cloneElement(e,{closeMenu:i}):e)}):null},A=({children:e,onClick:t,closeMenu:r,disabled:n=!1,className:a,style:s={}})=>{const i=()=>{n||(t&&t(),r&&r())};return d.jsx("button",{onClick:i,onKeyDown:e=>{n||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),i())},disabled:n,className:b("menu-item",{"menu-item--disabled":n},a),style:s,role:"menuitem",type:"button",tabIndex:n?-1:0,"aria-disabled":n,children:e})},S=({children:e,className:t,style:r={}})=>{const{triggerRef:n,isOpen:a,openMenu:s,closeMenu:i}=E();return d.jsx("section",{ref:n,onClick:()=>{a?i():s()},className:b("menu-trigger",t),style:r,children:u.cloneElement(e,{isOpen:a})})},B=Object.assign(({children:e,className:t,style:r={},position:n="bottom-left"})=>d.jsx(O,{menuPosition:n,children:d.jsx("div",{className:b("menu-container",t),style:r,children:e})}),{Trigger:S,Content:z,Item:A});exports.Button=v,exports.ButtonSelect=({options:e,value:t,onChange:r,disabled:n=!1,multiple:a=!1})=>{const s=e=>Array.isArray(t)?t.includes(e):e===t;return d.jsx("div",{className:"button-select "+(n?"disabled":""),children:e.map(({value:e,child:i})=>d.jsx("button",{className:"button-select-option "+(s(e)?"selected":""),onClick:()=>(e=>{if(n)return;if(!a)return void r(e);const s=Array.isArray(t)?t:[],i=s.includes(e)?s.filter(t=>t!==e):[...s,e];r(i)})(e),disabled:n,type:"button",children:i},e))})},exports.ChevronLeft=x,exports.ChevronRight=g,exports.DOTS=y,exports.Input=e=>{var t=e,{variant:r="primary",type:n="text",label:a,prefix:s,suffix:i,helperText:o,className:h,labelClass:p,helperTextClass:m,onChange:x,id:g,hasError:v,loading:y=!1,disabled:j}=t,w=c(t,["variant","type","label","prefix","suffix","helperText","className","labelClass","helperTextClass","onChange","id","hasError","loading","disabled"]);const N=u.useId(),k=g||`input-${N}`,C=b("form-field",{"has-prefix":!!s,"has-suffix":!!i},{[`variant-${r}`]:r},{loading:y},h);return d.jsxs("article",{className:"input-container",children:[a&&d.jsx("label",{htmlFor:k,className:b("input-label",p),children:a}),d.jsxs("section",{className:b("input-wrapper",{loading:y}),children:[s&&d.jsx("article",{className:"input-prefix",children:s}),d.jsx("input",l({id:k,type:n,className:C,onChange:e=>null==x?void 0:x(e.target.value),disabled:j||y},w)),y?d.jsx("article",{className:"input-suffix",children:d.jsx(f,{})}):i&&d.jsx("article",{className:"input-suffix",children:i})]}),o&&d.jsx("small",{className:b("input-helper-text",m),style:{color:v?"var(--color-danger)":"inherit"},children:o})]})},exports.Menu=B,exports.MenuContent=z,exports.MenuContextProvider=O,exports.MenuItem=A,exports.MenuTrigger=S,exports.Pagination=({currentPage:e,totalPages:t,onPageChange:r,siblingCount:n=1,hidePrevButton:a=!1,hideNextButton:s=!1,size:i="md",variant:l="secondary",className:o="",disabled:c=!1,mobile:u=!1})=>{const h=j({currentPage:e,totalPages:t,siblingCount:n});if(0===e||0===t)return null;const p=()=>{e<t&&!c&&r(e+1)},m=()=>{e>1&&!c&&r(e-1)},f=h[h.length-1];return u?d.jsxs("article",{className:b("pagination","pagination--mobile",o),"aria-label":"pagination navigation",children:[!a&&d.jsx(v,{variant:l,size:i,onClick:m,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(x,{})}),d.jsxs("span",{className:"pagination__page-indicator","aria-live":"polite",children:[e," / ",t," pages"]}),!s&&d.jsx(v,{variant:l,size:i,onClick:p,disabled:e===f||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(g,{})})]}):d.jsxs("article",{className:b("pagination",o),"aria-label":"pagination navigation",children:[!a&&d.jsx(v,{variant:l,size:i,onClick:m,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(x,{})}),h.map((n,a)=>n===y?d.jsx(v,{variant:l,size:i,"aria-label":"More pages",shape:"square",disabled:c,hover:!1,children:"…"},a):d.jsx(v,{variant:n===e?"primary":l,size:i,onClick:()=>!c&&r(n),disabled:c||1===t,"aria-label":n===e?`Current page, page ${n}`:`Go to page ${n}`,"aria-current":n===e?"page":void 0,shape:"square",children:n},a)),!s&&d.jsx(v,{variant:l,size:i,onClick:p,disabled:e===f||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(g,{})})]})},exports.Spinner=f,exports.Table=P,exports.TableBody=N,exports.TableCell=M,exports.TableFooter=k,exports.TableHeader=w,exports.TableRow=C,exports.Toggle=e=>{var t=e,{color:r="var(--color-primary)",size:n="3.75rem",checked:a=!1,onChange:s,label:i,labelPosition:o="right",className:u}=t,h=c(t,["color","size","checked","onChange","label","labelPosition","className"]);return d.jsxs("label",{className:b("switch-container",o,u),children:[d.jsxs("div",{className:"toggle-switch",style:{"--switch-size":n,"--switch-color":r},children:[d.jsx("input",l({type:"checkbox",role:"switch",checked:a,onChange:e=>null==s?void 0:s(e.target.checked)},h)),d.jsx("span",{className:"slider"})]}),i&&d.jsx("span",{className:"switch-label",children:i})]})},exports.clsx=p,exports.cn=b,exports.mergeClasses=m,exports.useMenuContext=E,exports.usePagination=j;
|