klip-components 0.17.0 → 0.18.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 CHANGED
@@ -16,85 +16,48 @@ export declare interface BorderRadius {
16
16
  /**
17
17
  * A flexible and reusable Button component with multiple variants, sizes, and styling options.
18
18
  * Supports all standard HTML button attributes and provides additional customization through props.
19
- * Uses CSS classes for styling and conditionally applies classes based on props.
20
- *
21
- * @param {ButtonProps} props - The props for the Button component
22
- * @param {('primary'|'secondary'|'success'|'danger')} [props.variant='primary'] - Visual style variant
23
- * @param {('sm'|'md'|'lg')} [props.size='md'] - Button size
24
- * @param {('rectangle'|'square'|'circle')} [props.shape='rectangle'] - Button shape
25
- * @param {boolean} [props.block=false] - Whether button should be full width
26
- * @param {string} [props.className=''] - Additional CSS classes to apply
27
- * @param {React.ReactNode} props.children - Content to render inside the button
28
- * @param {...React.ButtonHTMLAttributes<HTMLButtonElement>} props - All other standard button attributes
29
- * @returns {JSX.Element} The rendered Button component
30
- *
31
- * @example
32
- * // Basic primary button
33
- * <Button>Click me</Button>
34
- *
35
- * @example
36
- * // Secondary button with small size
37
- * <Button variant="secondary" size="sm">Small Button</Button>
38
- *
39
- * @example
40
- * // Full-width danger button with click handler
41
- * <Button
42
- * variant="danger"
43
- * block
44
- * onClick={() => console.log('Clicked!')}
45
- * >
46
- * Delete Item
47
- * </Button>
48
- *
49
- * @example
50
- * // Disabled success button with custom class
51
- * <Button
52
- * variant="success"
53
- * size="lg"
54
- * disabled
55
- * className="my-custom-class"
56
- * >
57
- * Save Changes
58
- * </Button>
59
19
  *
60
20
  * @example
61
- * // Loading button
62
- * <Button loading>
63
- * Processing...
64
- * </Button>
21
+ * // New API - filled primary button
22
+ * <Button variant="filled" color="primary">Click me</Button>
65
23
  *
66
24
  * @example
67
- * // Button with hover disabled (useful for ellipsis buttons)
68
- * <Button hover={false}>
69
- * ...
70
- * </Button>
25
+ * // New API - outline danger button
26
+ * <Button variant="outline" color="danger">Delete</Button>
71
27
  *
72
28
  * @example
73
- * // Square button with icon
74
- * <Button
75
- * variant="primary"
76
- * shape="square"
77
- * startIcon={<Icon />}
78
- * >
79
- * S
80
- * </Button>
29
+ * // New API - ghost button
30
+ * <Button variant="ghost" color="secondary">Cancel</Button>
81
31
  *
82
32
  * @example
83
- * // Circular button
84
- * <Button
85
- * variant="info"
86
- * shape="circle"
87
- * size="lg"
88
- * >
89
- * +
90
- * </Button>
33
+ * // Legacy API (deprecated but still supported)
34
+ * <Button variant="primary">Click me</Button>
35
+ * <Button variant="outline">Outline</Button>
36
+ * <Button variant="danger">Delete</Button>
91
37
  */
92
38
  export declare const Button: default_2.FC<ButtonProps>;
93
39
 
40
+ /** Color type for semantic color options */
41
+ export declare type ButtonColor = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
42
+
43
+ /**
44
+ * Props interface for the Button component.
45
+ * Extends standard HTML button attributes with additional styling options.
46
+ */
94
47
  export declare interface ButtonProps extends default_2.ButtonHTMLAttributes<HTMLButtonElement> {
95
- /** Visual style variant of the button */
96
- variant?: ButtonVariant;
97
- /** Size of the button */
48
+ /**
49
+ * Visual style variant of the button.
50
+ * Use 'filled', 'outline', 'ghost', or 'link' for new API.
51
+ * @default 'filled'
52
+ */
53
+ variant?: ButtonVariantNew | ButtonVariant;
54
+ /**
55
+ * Color scheme for the button.
56
+ * Only applies when using new variant API ('filled', 'outline', 'ghost').
57
+ * @default 'primary'
58
+ */
59
+ color?: ButtonColor;
60
+ /** @deprecated Use the `color` prop instead. */
98
61
  size?: ButtonSize;
99
62
  /** Shape of the button */
100
63
  shape?: ButtonShape;
@@ -129,15 +92,18 @@ export declare interface ButtonSelectProps {
129
92
 
130
93
  export declare type ButtonSelectValue = string | string[];
131
94
 
132
- declare type ButtonShape = 'rectangle' | 'pill' | 'square' | 'circle';
95
+ export declare type ButtonShape = 'rectangle' | 'pill' | 'square' | 'circle';
133
96
 
134
- declare type ButtonSize = 'sm' | 'md' | 'lg';
97
+ export declare type ButtonSize = 'sm' | 'md' | 'lg';
135
98
 
136
99
  /**
137
- * Props interface for the Button component.
138
- * Extends standard HTML button attributes with additional styling options.
100
+ * @deprecated Use ButtonVariantNew instead. This type will be removed in a future version.
101
+ * Old variant type that combined both visual style and color.
139
102
  */
140
- declare type ButtonVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'link' | 'outline' | 'ghost' | 'icon';
103
+ export declare type ButtonVariant = 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info' | 'link' | 'outline' | 'ghost' | 'icon';
104
+
105
+ /** New variant type that represents only the visual style */
106
+ export declare type ButtonVariantNew = 'filled' | 'outline' | 'ghost' | 'link';
141
107
 
142
108
  export declare const ChevronLeft: React.FC<Props>;
143
109
 
@@ -1 +1 @@
1
- "use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,i=(e,t)=>{for(var r in t||(t={}))a.call(t,r)&&l(e,r,t[r]);if(n)for(var r of n(t))s.call(t,r)&&l(e,r,t[r]);return e},o=(e,n)=>t(e,r(n)),c=(e,t)=>{var r={};for(var l in e)a.call(e,l)&&t.indexOf(l)<0&&(r[l]=e[l]);if(null!=e&&n)for(var l of n(e))t.indexOf(l)<0&&s.call(e,l)&&(r[l]=e[l]);return r};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),h=require("react");function u(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=u(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=u(e))&&(n&&(n+=" "),n+=t);return n}function m(...e){const t=e.join(" ").split(" ").filter(Boolean);return[...new Set(t)].join(" ")}function x(...e){return m(p(...e))}const b=({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"})}),f=({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"})}),g=({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:l,className:h="",children:u,loading:p,disabled:m,hover:b=!0}=t,f=c(t,["variant","size","shape","startIcon","endIcon","className","children","loading","disabled","hover"]);return d.jsx("button",o(i({className:x("btn",`btn-${r}`,`btn-${n}`,`btn-${a}`,{"btn-loading":p,"btn-no-hover":!b},h),disabled:m||p},f),{children:p?d.jsx(g,{}):d.jsxs(d.Fragment,{children:[s&&d.jsx("span",{className:"btn-icon-start",children:s}),u,l&&d.jsx("span",{className:"btn-icon-end",children:l})]})}))},j=d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M12 14.975q-.2 0-.375-.062T11.3 14.7l-4.6-4.6q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l3.9 3.9l3.9-3.9q.275-.275.7-.275t.7.275t.275.7t-.275.7l-4.6 4.6q-.15.15-.325.213t-.375.062"})}),y="...",w=({currentPage:e,totalPages:t,siblingCount:r=1})=>h.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,l=a<t-1;if(!s&&!l)return Array.from({length:t},(e,t)=>t+1);if(!s&&l){const e=3+2*r;return[...Array.from({length:e},(e,t)=>t+1),y,t]}if(s&&!l){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]),N=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("thead",o(i({className:x("table-header",r)},a),{children:n}))},C=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("tbody",o(i({className:x("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(i({className:x("table-footer",r)},a),{children:n}))},M=e=>{var t=e,{className:r="",selected:n=!1,children:a}=t,s=c(t,["className","selected","children"]);return d.jsx("tr",o(i({className:x("table-row",{"table-row-selected":n},r)},s),{children:a}))},T=e=>{var t=e,{className:r="",header:n=!1,align:a="left",minWidth:s,maxWidth:l,width:h,children:u,style:p}=t,m=c(t,["className","header","align","minWidth","maxWidth","width","children","style"]);const b=n?"th":"td",f=i(i(i(i({},s&&{minWidth:s}),l&&{maxWidth:l}),h&&{width:h}),p);return d.jsx(b,o(i({className:x("table-cell",`table-cell-${a}`,{"table-cell-header":n},r),style:Object.keys(f).length>0?f:p},m),{children:u}))},P=e=>{var t=e,{className:r="",variant:n="default",dense:a=!1,children:s}=t,l=c(t,["className","variant","dense","children"]);const h=d.jsx("table",o(i({className:x("table",`table-${n}`,{"table-dense":a},r)},l),{children:s}));return d.jsx("div",{className:"table-responsive",children:h})};P.Header=N,P.Body=C,P.Footer=k,P.Row=M,P.Cell=T;const E=h.createContext(void 0),O=()=>{const e=h.useContext(E);if(void 0===e)throw new Error("useMenuContext must be used within a MenuContextProvider");return e},S=({children:e,menuPosition:t="bottom-left"})=>{const[r,n]=h.useState(!1),[a,s]=h.useState({x:0,y:0}),l=h.useRef(null),i=h.useRef(null),o=h.useCallback((e,r)=>{const n=10,a=(null==r?void 0:r.width)||200,s=(null==r?void 0:r.height)||150,l=window.innerWidth,i=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,l-a-n)),c=Math.max(n,Math.min(c,i-s-n)),{x:o,y:c}},[t]),c=h.useCallback(()=>{var e;if(!l.current)return;const t=l.current.getBoundingClientRect(),r=null==(e=i.current)?void 0:e.getBoundingClientRect();s(o(t,r))},[o]),u=()=>n(!1);return h.useEffect(()=>{if(r&&l.current){const e=()=>{var e;const t=l.current.getBoundingClientRect(),r=null==(e=i.current)?void 0:e.getBoundingClientRect();s(o(t,r))};e();const t=setTimeout(e,50);return()=>clearTimeout(t)}},[r,o]),h.useEffect(()=>{const e=e=>{i.current&&i.current.contains(e.target)||l.current&&l.current.contains(e.target)||u()};if(r)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),h.useEffect(()=>{const e=e=>{"Escape"===e.key&&r&&u()};if(r)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]),d.jsx(E.Provider,{value:{isOpen:r,position:a,menuPosition:t,triggerRef:l,contentRef:i,openMenu:()=>{l.current&&n(!0)},closeMenu:u,repositionMenu:c},children:e})},z=({children:e,className:t,style:r={}})=>{const{isOpen:n,position:a,contentRef:s,closeMenu:l}=O(),[o,c]=h.useState(!1),[u,p]=h.useState(!1);h.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 u?d.jsx("article",{ref:s,className:x("menu-content",{"menu-content--open":o},t),style:i({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(),l()}},tabIndex:-1,children:h.Children.map(e,e=>h.isValidElement(e)?h.cloneElement(e,{closeMenu:l}):e)}):null},A=({children:e,onClick:t,closeMenu:r,disabled:n=!1,className:a,style:s={}})=>{const l=()=>{n||(t&&t(),r&&r())};return d.jsx("button",{onClick:l,onKeyDown:e=>{n||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),l())},disabled:n,className:x("menu-item",{"menu-item--disabled":n},a),style:s,role:"menuitem",type:"button",tabIndex:n?-1:0,"aria-disabled":n,children:e})},B=({children:e,className:t,style:r={}})=>{const{triggerRef:n,isOpen:a,openMenu:s,closeMenu:l}=O();return d.jsx("section",{ref:n,onClick:()=>{a?l():s()},className:x("menu-trigger",t),style:r,children:h.cloneElement(e,{isOpen:a})})},q=Object.assign(({children:e,className:t,style:r={},position:n="bottom-left"})=>d.jsx(S,{menuPosition:n,children:d.jsx("div",{className:x("menu-container",t),style:r,children:e})}),{Trigger:B,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:l})=>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:[],l=s.includes(e)?s.filter(t=>t!==e):[...s,e];r(l)})(e),disabled:n,type:"button",children:l},e))})},exports.ChevronLeft=b,exports.ChevronRight=f,exports.DOTS=y,exports.Input=e=>{var t=e,{variant:r="primary",type:n="text",label:a,prefix:s,suffix:l,helperText:o,className:u,labelClass:p,helperTextClass:m,onChange:b,id:f,hasError:v,loading:j=!1,disabled:y}=t,w=c(t,["variant","type","label","prefix","suffix","helperText","className","labelClass","helperTextClass","onChange","id","hasError","loading","disabled"]);const N=h.useId(),C=f||`input-${N}`,k=x("form-field",{"has-prefix":!!s,"has-suffix":!!l},{[`variant-${r}`]:r},{loading:j},u);return d.jsxs("article",{className:"input-container",children:[a&&d.jsx("label",{htmlFor:C,className:x("input-label",p),children:a}),d.jsxs("section",{className:x("input-wrapper",{loading:j}),children:[s&&d.jsx("article",{className:"input-prefix",children:s}),d.jsx("input",i({id:C,type:n,className:k,onChange:e=>null==b?void 0:b(e.target.value),disabled:y||j},w)),j?d.jsx("article",{className:"input-suffix",children:d.jsx(g,{})}):l&&d.jsx("article",{className:"input-suffix",children:l})]}),o&&d.jsx("small",{className:x("input-helper-text",m),style:{color:v?"var(--color-danger)":"inherit"},children:o})]})},exports.Menu=q,exports.MenuContent=z,exports.MenuContextProvider=S,exports.MenuItem=A,exports.MenuTrigger=B,exports.Pagination=({currentPage:e,totalPages:t,onPageChange:r,siblingCount:n=1,hidePrevButton:a=!1,hideNextButton:s=!1,size:l="md",variant:i="secondary",className:o="",disabled:c=!1,mobile:h=!1})=>{const u=w({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)},g=u[u.length-1];return h?d.jsxs("article",{className:x("pagination","pagination--mobile",o),"aria-label":"pagination navigation",children:[!a&&d.jsx(v,{variant:i,size:l,onClick:m,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(b,{})}),d.jsxs("span",{className:"pagination__page-indicator","aria-live":"polite",children:[e," / ",t," pages"]}),!s&&d.jsx(v,{variant:i,size:l,onClick:p,disabled:e===g||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(f,{})})]}):d.jsxs("article",{className:x("pagination",o),"aria-label":"pagination navigation",children:[!a&&d.jsx(v,{variant:i,size:l,onClick:m,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(b,{})}),u.map((n,a)=>n===y?d.jsx(v,{variant:i,size:l,"aria-label":"More pages",shape:"square",disabled:c,hover:!1,children:"…"},a):d.jsx(v,{variant:n===e?"primary":i,size:l,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:i,size:l,onClick:p,disabled:e===g||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(f,{})})]})},exports.Select=e=>{var t=e,{variant:r="primary",label:n,prefix:a,suffix:s,helperText:l,className:u,labelClass:p,helperTextClass:m,onChange:b,id:f,hasError:v,loading:y=!1,disabled:w,options:N=[],placeholder:C,children:k}=t,M=c(t,["variant","label","prefix","suffix","helperText","className","labelClass","helperTextClass","onChange","id","hasError","loading","disabled","options","placeholder","children"]);const T=h.useId(),P=f||`select-${T}`,E=x("form-field",{"has-prefix":!!a,"has-suffix":!!s||!y},{[`variant-${r}`]:r},{loading:y},u);return d.jsxs("article",{className:"select-container",children:[n&&d.jsx("label",{htmlFor:P,className:x("select-label",p),children:n}),d.jsxs("section",{className:x("select-wrapper",{loading:y}),children:[a&&d.jsx("article",{className:"select-prefix",children:a}),d.jsxs("select",o(i({id:P,className:E,onChange:e=>null==b?void 0:b(e.target.value),disabled:w||y},M),{children:[C&&d.jsx("option",{value:"",disabled:!0,hidden:!0,children:C}),N.length>0?N.map(e=>d.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value)):k]})),y?d.jsx("article",{className:"select-suffix",children:d.jsx(g,{})}):d.jsx("article",{className:"select-suffix",children:s||j})]}),l&&d.jsx("small",{className:x("select-helper-text",m),style:{color:v?"var(--color-danger)":"inherit"},children:l})]})},exports.Spinner=g,exports.Table=P,exports.TableBody=C,exports.TableCell=T,exports.TableFooter=k,exports.TableHeader=N,exports.TableRow=M,exports.Toggle=e=>{var t=e,{color:r="var(--color-primary)",size:n="3.75rem",checked:a=!1,onChange:s,label:l,labelPosition:o="right",className:h}=t,u=c(t,["color","size","checked","onChange","label","labelPosition","className"]);return d.jsxs("label",{className:x("switch-container",o,h),children:[d.jsxs("div",{className:"toggle-switch",style:{"--switch-size":n,"--switch-color":r},children:[d.jsx("input",i({type:"checkbox",role:"switch",checked:a,onChange:e=>null==s?void 0:s(e.target.checked)},u)),d.jsx("span",{className:"slider"})]}),l&&d.jsx("span",{className:"switch-label",children:l})]})},exports.clsx=p,exports.cn=x,exports.mergeClasses=m,exports.useMenuContext=O,exports.usePagination=w;
1
+ "use strict";var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,a=Object.prototype.hasOwnProperty,s=Object.prototype.propertyIsEnumerable,l=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,i=(e,t)=>{for(var r in t||(t={}))a.call(t,r)&&l(e,r,t[r]);if(n)for(var r of n(t))s.call(t,r)&&l(e,r,t[r]);return e},o=(e,n)=>t(e,r(n)),c=(e,t)=>{var r={};for(var l in e)a.call(e,l)&&t.indexOf(l)<0&&(r[l]=e[l]);if(null!=e&&n)for(var l of n(e))t.indexOf(l)<0&&s.call(e,l)&&(r[l]=e[l]);return r};Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),h=require("react");function u(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=u(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=u(e))&&(n&&(n+=" "),n+=t);return n}function m(...e){const t=e.join(" ").split(" ").filter(Boolean);return[...new Set(t)].join(" ")}function x(...e){return m(p(...e))}const f=({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"})}),b=({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={primary:{variant:"filled",color:"primary"},secondary:{variant:"filled",color:"secondary"},success:{variant:"filled",color:"success"},danger:{variant:"filled",color:"danger"},warning:{variant:"filled",color:"warning"},info:{variant:"filled",color:"info"},link:{variant:"link",color:"primary"},outline:{variant:"outline",color:"primary"},ghost:{variant:"ghost",color:"primary"}},y=e=>{var t=e,{variant:r="filled",color:n="primary",size:a="md",shape:s="rectangle",startIcon:l,endIcon:h,className:u="",children:p,loading:m,disabled:f,hover:g=!0}=t,y=c(t,["variant","color","size","shape","startIcon","endIcon","className","children","loading","disabled","hover"]);let j=r,w=n;if((e=>Object.keys(v).includes(e))(r)){process.env.NODE_ENV;const e=v[r];j=e.variant,w=e.color}const N="filled"===j?`btn-${w}`:`btn-${j}-${w}`;return d.jsx("button",o(i({className:x("btn",N,`btn-${a}`,`btn-${s}`,{"btn-loading":m,"btn-no-hover":!g},u),disabled:f||m},y),{children:m?d.jsx(b,{}):d.jsxs(d.Fragment,{children:[l&&d.jsx("span",{className:"btn-icon-start",children:l}),p,h&&d.jsx("span",{className:"btn-icon-end",children:h})]})}))},j=d.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 24 24",children:d.jsx("path",{fill:"currentColor",d:"M12 14.975q-.2 0-.375-.062T11.3 14.7l-4.6-4.6q-.275-.275-.275-.7t.275-.7t.7-.275t.7.275l3.9 3.9l3.9-3.9q.275-.275.7-.275t.7.275t.275.7t-.275.7l-4.6 4.6q-.15.15-.325.213t-.375.062"})}),w="...",N=({currentPage:e,totalPages:t,siblingCount:r=1})=>h.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,l=a<t-1;if(!s&&!l)return Array.from({length:t},(e,t)=>t+1);if(!s&&l){const e=3+2*r;return[...Array.from({length:e},(e,t)=>t+1),w,t]}if(s&&!l){const e=3+2*r;return[1,w,...Array.from({length:e},(r,n)=>t-e+n+1)]}return[1,w,...Array.from({length:a-n+1},(e,t)=>n+t),w,t]},[e,t,r]),k=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("thead",o(i({className:x("table-header",r)},a),{children:n}))},C=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("tbody",o(i({className:x("table-body",r)},a),{children:n}))},M=e=>{var t=e,{className:r="",children:n}=t,a=c(t,["className","children"]);return d.jsx("tfoot",o(i({className:x("table-footer",r)},a),{children:n}))},T=e=>{var t=e,{className:r="",selected:n=!1,children:a}=t,s=c(t,["className","selected","children"]);return d.jsx("tr",o(i({className:x("table-row",{"table-row-selected":n},r)},s),{children:a}))},P=e=>{var t=e,{className:r="",header:n=!1,align:a="left",minWidth:s,maxWidth:l,width:h,children:u,style:p}=t,m=c(t,["className","header","align","minWidth","maxWidth","width","children","style"]);const f=n?"th":"td",g=i(i(i(i({},s&&{minWidth:s}),l&&{maxWidth:l}),h&&{width:h}),p);return d.jsx(f,o(i({className:x("table-cell",`table-cell-${a}`,{"table-cell-header":n},r),style:Object.keys(g).length>0?g:p},m),{children:u}))},E=e=>{var t=e,{className:r="",variant:n="default",dense:a=!1,children:s}=t,l=c(t,["className","variant","dense","children"]);const h=d.jsx("table",o(i({className:x("table",`table-${n}`,{"table-dense":a},r)},l),{children:s}));return d.jsx("div",{className:"table-responsive",children:h})};E.Header=k,E.Body=C,E.Footer=M,E.Row=T,E.Cell=P;const O=h.createContext(void 0),S=()=>{const e=h.useContext(O);if(void 0===e)throw new Error("useMenuContext must be used within a MenuContextProvider");return e},z=({children:e,menuPosition:t="bottom-left"})=>{const[r,n]=h.useState(!1),[a,s]=h.useState({x:0,y:0}),l=h.useRef(null),i=h.useRef(null),o=h.useCallback((e,r)=>{const n=10,a=(null==r?void 0:r.width)||200,s=(null==r?void 0:r.height)||150,l=window.innerWidth,i=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,l-a-n)),c=Math.max(n,Math.min(c,i-s-n)),{x:o,y:c}},[t]),c=h.useCallback(()=>{var e;if(!l.current)return;const t=l.current.getBoundingClientRect(),r=null==(e=i.current)?void 0:e.getBoundingClientRect();s(o(t,r))},[o]),u=()=>n(!1);return h.useEffect(()=>{if(r&&l.current){const e=()=>{var e;const t=l.current.getBoundingClientRect(),r=null==(e=i.current)?void 0:e.getBoundingClientRect();s(o(t,r))};e();const t=setTimeout(e,50);return()=>clearTimeout(t)}},[r,o]),h.useEffect(()=>{const e=e=>{i.current&&i.current.contains(e.target)||l.current&&l.current.contains(e.target)||u()};if(r)return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[r]),h.useEffect(()=>{const e=e=>{"Escape"===e.key&&r&&u()};if(r)return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[r]),d.jsx(O.Provider,{value:{isOpen:r,position:a,menuPosition:t,triggerRef:l,contentRef:i,openMenu:()=>{l.current&&n(!0)},closeMenu:u,repositionMenu:c},children:e})},A=({children:e,className:t,style:r={}})=>{const{isOpen:n,position:a,contentRef:s,closeMenu:l}=S(),[o,c]=h.useState(!1),[u,p]=h.useState(!1);h.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 u?d.jsx("article",{ref:s,className:x("menu-content",{"menu-content--open":o},t),style:i({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(),l()}},tabIndex:-1,children:h.Children.map(e,e=>h.isValidElement(e)?h.cloneElement(e,{closeMenu:l}):e)}):null},B=({children:e,onClick:t,closeMenu:r,disabled:n=!1,className:a,style:s={}})=>{const l=()=>{n||(t&&t(),r&&r())};return d.jsx("button",{onClick:l,onKeyDown:e=>{n||"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),l())},disabled:n,className:x("menu-item",{"menu-item--disabled":n},a),style:s,role:"menuitem",type:"button",tabIndex:n?-1:0,"aria-disabled":n,children:e})},$=({children:e,className:t,style:r={}})=>{const{triggerRef:n,isOpen:a,openMenu:s,closeMenu:l}=S();return d.jsx("section",{ref:n,onClick:()=>{a?l():s()},className:x("menu-trigger",t),style:r,children:h.cloneElement(e,{isOpen:a})})},q=Object.assign(({children:e,className:t,style:r={},position:n="bottom-left"})=>d.jsx(z,{menuPosition:n,children:d.jsx("div",{className:x("menu-container",t),style:r,children:e})}),{Trigger:$,Content:A,Item:B});exports.Button=y,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:l})=>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:[],l=s.includes(e)?s.filter(t=>t!==e):[...s,e];r(l)})(e),disabled:n,type:"button",children:l},e))})},exports.ChevronLeft=f,exports.ChevronRight=g,exports.DOTS=w,exports.Input=e=>{var t=e,{variant:r="primary",type:n="text",label:a,prefix:s,suffix:l,helperText:o,className:u,labelClass:p,helperTextClass:m,onChange:f,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=h.useId(),k=g||`input-${N}`,C=x("form-field",{"has-prefix":!!s,"has-suffix":!!l},{[`variant-${r}`]:r},{loading:y},u);return d.jsxs("article",{className:"input-container",children:[a&&d.jsx("label",{htmlFor:k,className:x("input-label",p),children:a}),d.jsxs("section",{className:x("input-wrapper",{loading:y}),children:[s&&d.jsx("article",{className:"input-prefix",children:s}),d.jsx("input",i({id:k,type:n,className:C,onChange:e=>null==f?void 0:f(e.target.value),disabled:j||y},w)),y?d.jsx("article",{className:"input-suffix",children:d.jsx(b,{})}):l&&d.jsx("article",{className:"input-suffix",children:l})]}),o&&d.jsx("small",{className:x("input-helper-text",m),style:{color:v?"var(--color-danger)":"inherit"},children:o})]})},exports.Menu=q,exports.MenuContent=A,exports.MenuContextProvider=z,exports.MenuItem=B,exports.MenuTrigger=$,exports.Pagination=({currentPage:e,totalPages:t,onPageChange:r,siblingCount:n=1,hidePrevButton:a=!1,hideNextButton:s=!1,size:l="md",variant:i="secondary",className:o="",disabled:c=!1,mobile:h=!1})=>{const u=N({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)},b=u[u.length-1];return h?d.jsxs("article",{className:x("pagination","pagination--mobile",o),"aria-label":"pagination navigation",children:[!a&&d.jsx(y,{variant:i,size:l,onClick:m,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(f,{})}),d.jsxs("span",{className:"pagination__page-indicator","aria-live":"polite",children:[e," / ",t," pages"]}),!s&&d.jsx(y,{variant:i,size:l,onClick:p,disabled:e===b||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(g,{})})]}):d.jsxs("article",{className:x("pagination",o),"aria-label":"pagination navigation",children:[!a&&d.jsx(y,{variant:i,size:l,onClick:m,disabled:1===e||c,"aria-label":"Go to previous page",shape:"square",children:d.jsx(f,{})}),u.map((n,a)=>n===w?d.jsx(y,{variant:i,size:l,"aria-label":"More pages",shape:"square",disabled:c,hover:!1,children:"…"},a):d.jsx(y,{variant:n===e?"primary":i,size:l,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(y,{variant:i,size:l,onClick:p,disabled:e===b||c,"aria-label":"Go to next page",shape:"square",children:d.jsx(g,{})})]})},exports.Select=e=>{var t=e,{variant:r="primary",label:n,prefix:a,suffix:s,helperText:l,className:u,labelClass:p,helperTextClass:m,onChange:f,id:g,hasError:v,loading:y=!1,disabled:w,options:N=[],placeholder:k,children:C}=t,M=c(t,["variant","label","prefix","suffix","helperText","className","labelClass","helperTextClass","onChange","id","hasError","loading","disabled","options","placeholder","children"]);const T=h.useId(),P=g||`select-${T}`,E=x("form-field",{"has-prefix":!!a,"has-suffix":!!s||!y},{[`variant-${r}`]:r},{loading:y},u);return d.jsxs("article",{className:"select-container",children:[n&&d.jsx("label",{htmlFor:P,className:x("select-label",p),children:n}),d.jsxs("section",{className:x("select-wrapper",{loading:y}),children:[a&&d.jsx("article",{className:"select-prefix",children:a}),d.jsxs("select",o(i({id:P,className:E,onChange:e=>null==f?void 0:f(e.target.value),disabled:w||y},M),{children:[k&&d.jsx("option",{value:"",disabled:!0,hidden:!0,children:k}),N.length>0?N.map(e=>d.jsx("option",{value:e.value,disabled:e.disabled,children:e.label},e.value)):C]})),y?d.jsx("article",{className:"select-suffix",children:d.jsx(b,{})}):d.jsx("article",{className:"select-suffix",children:s||j})]}),l&&d.jsx("small",{className:x("select-helper-text",m),style:{color:v?"var(--color-danger)":"inherit"},children:l})]})},exports.Spinner=b,exports.Table=E,exports.TableBody=C,exports.TableCell=P,exports.TableFooter=M,exports.TableHeader=k,exports.TableRow=T,exports.Toggle=e=>{var t=e,{color:r="var(--color-primary)",size:n="3.75rem",checked:a=!1,onChange:s,label:l,labelPosition:o="right",className:h}=t,u=c(t,["color","size","checked","onChange","label","labelPosition","className"]);return d.jsxs("label",{className:x("switch-container",o,h),children:[d.jsxs("div",{className:"toggle-switch",style:{"--switch-size":n,"--switch-color":r},children:[d.jsx("input",i({type:"checkbox",role:"switch",checked:a,onChange:e=>null==s?void 0:s(e.target.checked)},u)),d.jsx("span",{className:"slider"})]}),l&&d.jsx("span",{className:"switch-label",children:l})]})},exports.clsx=p,exports.cn=x,exports.mergeClasses=m,exports.useMenuContext=S,exports.usePagination=N;