@adamjanicki/ui 1.5.8 → 1.6.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.
Files changed (38) hide show
  1. package/components/Accordion/Accordion.d.ts +3 -11
  2. package/components/Accordion/Accordion.js +27 -5
  3. package/components/Box/Box.js +3 -38
  4. package/components/Button/Button.d.ts +6 -12
  5. package/components/Button/Button.js +12 -12
  6. package/components/Carousel/Carousel.js +5 -1
  7. package/components/ClickOutside/ClickOutside.d.ts +3 -3
  8. package/components/ClickOutside/ClickOutside.js +1 -1
  9. package/components/Icon/Icon.d.ts +3 -2
  10. package/components/Icon/Icon.js +2 -4
  11. package/components/Icon/icons.d.ts +2 -7
  12. package/components/Icon/icons.js +174 -23
  13. package/components/Input/IconInput.js +1 -1
  14. package/components/Input/Input.js +1 -1
  15. package/components/Input/TextArea.js +1 -1
  16. package/components/Layer/Layer.d.ts +3 -3
  17. package/components/Layer/Layer.js +19 -18
  18. package/components/Link/Link.d.ts +38 -8
  19. package/components/Link/Link.js +14 -8
  20. package/components/Link/index.d.ts +2 -2
  21. package/components/Link/index.js +2 -2
  22. package/components/Select/Select.js +1 -1
  23. package/dist/aui.cjs.js +22 -0
  24. package/dist/aui.es.js +1091 -0
  25. package/dist/aui.umd.js +22 -0
  26. package/functions/assertDefined.d.ts +8 -0
  27. package/functions/assertDefined.js +13 -0
  28. package/functions/classNames.js +4 -1
  29. package/functions/index.d.ts +2 -2
  30. package/functions/index.js +2 -2
  31. package/package.json +14 -4
  32. package/style.css +1 -564
  33. package/utils/transformLayout.d.ts +2 -0
  34. package/utils/transformLayout.js +76 -0
  35. package/utils/types.d.ts +51 -34
  36. package/vite.config.ts +23 -0
  37. package/functions/assert.d.ts +0 -15
  38. package/functions/assert.js +0 -24
@@ -0,0 +1,22 @@
1
+ (function(f,l){typeof exports=="object"&&typeof module<"u"?l(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],l):(f=typeof globalThis<"u"?globalThis:f||self,l(f.Aui={},f.React))})(this,function(f,l){"use strict";var U={exports:{}},M={};/**
2
+ * @license React
3
+ * react-jsx-runtime.production.js
4
+ *
5
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
6
+ *
7
+ * This source code is licensed under the MIT license found in the
8
+ * LICENSE file in the root directory of this source tree.
9
+ */var K;function be(){if(K)return M;K=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(s,o,a){var i=null;if(a!==void 0&&(i=""+a),o.key!==void 0&&(i=""+o.key),"key"in o){a={};for(var d in o)d!=="key"&&(a[d]=o[d])}else a=o;return o=a.ref,{$$typeof:t,type:s,key:i,ref:o!==void 0?o:null,props:a}}return M.Fragment=e,M.jsx=r,M.jsxs=r,M}var P={};/**
10
+ * @license React
11
+ * react-jsx-runtime.development.js
12
+ *
13
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
14
+ *
15
+ * This source code is licensed under the MIT license found in the
16
+ * LICENSE file in the root directory of this source tree.
17
+ */var ee;function ge(){return ee||(ee=1,process.env.NODE_ENV!=="production"&&function(){function t(n){if(n==null)return null;if(typeof n=="function")return n.$$typeof===et?null:n.displayName||n.name||null;if(typeof n=="string")return n;switch(n){case E:return"Fragment";case N:return"Profiler";case T:return"StrictMode";case B:return"Suspense";case _:return"SuspenseList";case Ke:return"Activity"}if(typeof n=="object")switch(typeof n.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),n.$$typeof){case S:return"Portal";case $:return(n.displayName||"Context")+".Provider";case I:return(n._context.displayName||"Context")+".Consumer";case Y:var m=n.render;return n=n.displayName,n||(n=m.displayName||m.name||"",n=n!==""?"ForwardRef("+n+")":"ForwardRef"),n;case R:return m=n.displayName||null,m!==null?m:t(n.type)||"Memo";case ce:m=n._payload,n=n._init;try{return t(n(m))}catch{}}return null}function e(n){return""+n}function r(n){try{e(n);var m=!1}catch{m=!0}if(m){m=console;var b=m.error,y=typeof Symbol=="function"&&Symbol.toStringTag&&n[Symbol.toStringTag]||n.constructor.name||"Object";return b.call(m,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",y),e(n)}}function s(n){if(n===E)return"<>";if(typeof n=="object"&&n!==null&&n.$$typeof===ce)return"<...>";try{var m=t(n);return m?"<"+m+">":"<...>"}catch{return"<...>"}}function o(){var n=X.A;return n===null?null:n.getOwner()}function a(){return Error("react-stack-top-frame")}function i(n){if(ue.call(n,"key")){var m=Object.getOwnPropertyDescriptor(n,"key").get;if(m&&m.isReactWarning)return!1}return n.key!==void 0}function d(n,m){function b(){fe||(fe=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",m))}b.isReactWarning=!0,Object.defineProperty(n,"key",{get:b,configurable:!0})}function h(){var n=t(this.type);return de[n]||(de[n]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),n=this.props.ref,n!==void 0?n:null}function u(n,m,b,y,O,A,G,Q){return b=A.ref,n={$$typeof:k,type:n,key:m,props:A,_owner:O},(b!==void 0?b:null)!==null?Object.defineProperty(n,"ref",{enumerable:!1,get:h}):Object.defineProperty(n,"ref",{enumerable:!1,value:null}),n._store={},Object.defineProperty(n._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(n,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(n,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.defineProperty(n,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:Q}),Object.freeze&&(Object.freeze(n.props),Object.freeze(n)),n}function v(n,m,b,y,O,A,G,Q){var x=m.children;if(x!==void 0)if(y)if(tt(x)){for(y=0;y<x.length;y++)j(x[y]);Object.freeze&&Object.freeze(x)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else j(x);if(ue.call(m,"key")){x=t(n);var L=Object.keys(m).filter(function(rt){return rt!=="key"});y=0<L.length?"{key: someKey, "+L.join(": ..., ")+": ...}":"{key: someKey}",pe[x+y]||(L=0<L.length?"{"+L.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
+ let props = %s;
19
+ <%s {...props} />
20
+ React keys must be passed directly to JSX without using spread:
21
+ let props = %s;
22
+ <%s key={someKey} {...props} />`,y,x,L,x),pe[x+y]=!0)}if(x=null,b!==void 0&&(r(b),x=""+b),i(m)&&(r(m.key),x=""+m.key),"key"in m){b={};for(var Z in m)Z!=="key"&&(b[Z]=m[Z])}else b=m;return x&&d(b,typeof n=="function"?n.displayName||n.name||"Unknown":n),u(n,x,A,O,o(),b,G,Q)}function j(n){typeof n=="object"&&n!==null&&n.$$typeof===k&&n._store&&(n._store.validated=1)}var w=l,k=Symbol.for("react.transitional.element"),S=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),T=Symbol.for("react.strict_mode"),N=Symbol.for("react.profiler"),I=Symbol.for("react.consumer"),$=Symbol.for("react.context"),Y=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),R=Symbol.for("react.memo"),ce=Symbol.for("react.lazy"),Ke=Symbol.for("react.activity"),et=Symbol.for("react.client.reference"),X=w.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue=Object.prototype.hasOwnProperty,tt=Array.isArray,J=console.createTask?console.createTask:function(){return null};w={react_stack_bottom_frame:function(n){return n()}};var fe,de={},me=w.react_stack_bottom_frame.bind(w,a)(),he=J(s(a)),pe={};P.Fragment=E,P.jsx=function(n,m,b,y,O){var A=1e4>X.recentlyCreatedOwnerStacks++;return v(n,m,b,!1,y,O,A?Error("react-stack-top-frame"):me,A?J(s(n)):he)},P.jsxs=function(n,m,b,y,O){var A=1e4>X.recentlyCreatedOwnerStacks++;return v(n,m,b,!0,y,O,A?Error("react-stack-top-frame"):me,A?J(s(n)):he)}}()),P}var te;function we(){return te||(te=1,process.env.NODE_ENV==="production"?U.exports=be():U.exports=ge()),U.exports}var c=we();function p(...t){return t.filter(Boolean).join(" ")}function H(t,e){try{const r=document.getElementById(t);r&&r.scrollIntoView({behavior:e})}catch{return}}function ye(t,e){if(t===void 0)throw new Error(e||"Unexpected undefined value");return t}const g=l.forwardRef(({layout:t,className:e,style:r,...s},o)=>{const a=xe(t);return c.jsx("div",{...s,className:p(a.className,e),style:{...a.style,...r},ref:o})});function xe(t){if(!t)return{className:void 0,style:void 0};const{axis:e,gap:r,align:s,justify:o,padding:a,margin:i,wrap:d}=t,h={};let u=`aui-flex-${e}`;return s&&(u=p(u,`aui-align-${s}`)),o&&(u=p(u,`aui-justify-${o}`)),d&&(u=p(u,"aui-flex-wrap")),r&&(typeof r=="number"?h.gap=r:u=p(u,`aui-gap-${r}`)),a&&(typeof a=="number"?h.padding=a:u=p(u,`aui-pa-${a}`)),i&&(typeof i=="number"?h.margin=i:u=p(u,`aui-ma-${i}`)),{className:u,style:h}}const z="M94.0908,296.3057c-29.82338,0-54-24.17662-54-54s24.17662-54,54-54c.00237,0,.00475,0,.00712,0c.0017,0,141.65138,0,221.99288,0v-222c0-29.82338,24.17662-54,54-54s54,24.17662,54,54c0,.00237,0,.00475,0,.00712s0,273.40726,0,275.97468c0,.00607,0,.01213,0,.0182c0,29.82338-24.17662,54-54,54h-276Z",Ee={down:{contents:[c.jsx("path",{d:z,transform:"matrix(.707107 0.707107-.707107 0.707107 165.642289-79.868246)"})]},up:{contents:[c.jsx("path",{d:z,transform:"matrix(-.707107-.707107 0.707107-.707107 346.357711 591.868246)"})]},left:{contents:[c.jsx("path",{d:z,transform:"matrix(-.707107 0.707107-.707107-.707107 591.868246 165.642289)"})]},right:{contents:[c.jsx("path",{d:z,transform:"matrix(.707107-.707107 0.707107 0.707107-79.868246 346.357711)"})]}},ve="0 0 512 512",D=l.forwardRef(({icon:t,className:e,size:r,style:s,...o},a)=>{const{contents:i,viewBox:d}=Ee[t];return c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:d||ve,className:p("aui-icon",e),style:{width:r,height:r,...s},...o,ref:a,children:i.map((h,u)=>c.jsx(l.Fragment,{children:h},u))})}),W=l.forwardRef(({className:t,...e},r)=>c.jsx("button",{...e,className:p("aui-action aui-button",t),ref:r})),q=l.forwardRef(({variant:t,corners:e,className:r,size:s,...o},a)=>c.jsx(W,{...o,className:p(re({variant:t,corners:e,size:s}),r),ref:a})),re=({variant:t="primary",corners:e="rounded",size:r="regular"})=>`aui-button--${t} aui-button-size--${r} aui-corners--${e}`,ne=l.forwardRef((t,e)=>{const{animated:r,duration:s=.25,keepMounted:o=!1,animateTo:a,animateFrom:i,className:d,style:h,...u}=t,[v,j]=l.useState(r||o),[w,k]=l.useState(!1),S=l.useRef(null),E=l.useRef(null),T=()=>{S.current&&(clearTimeout(S.current),S.current=null),E.current&&(cancelAnimationFrame(E.current),E.current=null)};if(l.useEffect(()=>(r&&v&&(T(),E.current=requestAnimationFrame(()=>k(!0))),T),[r,v]),l.useEffect(()=>(r?j(!0):(T(),k(!1),S.current=window.setTimeout(()=>{o||j(!1)},s*1e3)),T),[r,s,o]),!v)return null;const N=w?a:i;return c.jsx(g,{className:p(d,N?.className),style:{transition:`all ${s}s ease-in-out`,...h,...N?.style},...u,ref:e})}),je=l.forwardRef(({drawers:t,className:e,duration:r,hideDividers:s,...o},a)=>{const[i,d]=l.useState(new Set);return c.jsx(g,{layout:{axis:"y"},...o,className:p("aui-accordion aui-corners--rounded",e),ref:a,children:t.map((h,u)=>c.jsx(Te,{item:h,open:i.has(u),onOpenChange:v=>d(j=>{const w=new Set(j);return v?w.add(u):w.delete(u),w}),duration:r,showDivider:!s&&u<t.length-1},u))})}),Te=({item:t,open:e,onOpenChange:r,duration:s,showDivider:o})=>{const a=l.useRef(null),[i,d]=l.useState(),h=t.content;return l.useEffect(()=>{e&&h&&a.current&&d(a.current.offsetHeight)},[e,h]),c.jsxs(c.Fragment,{children:[c.jsxs(g,{layout:{axis:"y"},children:[c.jsx(W,{onClick:()=>r(!e),children:c.jsxs(g,{layout:{axis:"x",align:"center",gap:"m",padding:"l"},children:[c.jsx(D,{size:12,icon:e?"down":"right",className:"aui-accordion-arrow"}),c.jsx("span",{className:"aui-accordion-label",children:t.label})]})}),c.jsx(ne,{style:{overflow:"hidden"},keepMounted:!0,duration:s,animated:e,animateFrom:{style:{visibility:"hidden",height:0,transform:"translateY(-4px)",opacity:.9}},animateTo:{style:{height:i,transform:"translateY(0)",opacity:1}},children:c.jsx(g,{ref:a,children:h})})]}),o&&c.jsx("hr",{className:"aui-accordion-hr"})]})},Se=l.forwardRef(({type:t,corners:e="rounded",className:r,...s},o)=>c.jsx(g,{...s,className:p(`aui-alert aui-content--${t} aui-corners--${e}`,r),ref:o})),ke=l.forwardRef(({type:t,className:e,corners:r="rounded",...s},o)=>c.jsx(g,{...s,className:p(`aui-badge aui-content--${t} aui-corners--${r}`,e),ref:o})),Ne=l.forwardRef(({type:t,className:e,...r},s)=>c.jsx(g,{...r,className:p(`aui-content--${t} aui-banner`,e),ref:s})),_e=1,Ae=l.forwardRef(({children:t,className:e,hideArrows:r,hideDots:s,dotProps:o,leftArrowProps:a,rightArrowProps:i,autoplayInterval:d,duration:h,...u},v)=>{h=Math.max(h??_e,.1),d=d?Math.max(h,d):void 0;const j=t.length,[w,k]=l.useState({cur:0,delta:0,animating:!1}),S=l.useRef(null),{cur:E,delta:T,animating:N}=w,I=oe(E+T,j),$=l.useCallback(_=>{N||_===0||k(R=>({...R,delta:_,animating:!0}))},[N]),Y=()=>{k(({delta:_,cur:R})=>({delta:_,animating:!1,cur:oe(R+_,j)}))};if(l.useEffect(()=>(d&&(S.current=window.setInterval(()=>{$(1)},d*1e3)),()=>{const _=S.current;S.current=null,_&&clearInterval(_)}),[d,$]),j<=0)return null;const B=N?{transform:`translateX(${-(T/Math.abs(T))*100}%)`,transition:`transform ${h}s ease-in-out`}:void 0;return c.jsxs(g,{...u,className:p("aui-carousel",e),ref:v,children:[c.jsxs(g,{className:"aui-carousel-slider",style:{...B,flexDirection:T>=0?"row":"row-reverse"},onTransitionEnd:Y,children:[c.jsx(g,{className:"aui-carousel-item",children:t[E]}),c.jsx(g,{className:"aui-carousel-item","aria-hidden":!0,children:t[I]})]}),j>1&&c.jsxs(c.Fragment,{children:[!r&&c.jsxs(c.Fragment,{children:[c.jsx(q,{className:p("aui-flex-x aui-align-center aui-justify-center aui-carousel-arrow",a?.className),style:{left:8,...a?.style},corners:"pill","aria-label":"previous",onClick:()=>$(-1),children:a?.children??c.jsx(D,{icon:"left",size:12,style:{marginRight:2}})}),c.jsx(q,{className:p("aui-flex-x aui-align-center aui-justify-center aui-carousel-arrow",i?.className),style:{right:8,...i?.style},corners:"pill","aria-label":"next",onClick:()=>$(1),children:i?.children??c.jsx(D,{icon:"right",size:12,style:{marginLeft:2}})})]}),!s&&c.jsx(g,{layout:{axis:"x",align:"center",gap:"xs"},className:"aui-carousel-dots",children:t.map((_,R)=>c.jsx(q,{className:p("aui-carousel-dot",o?.className),corners:"pill",disabled:E===R||N,onClick:()=>$(R-E),style:o?.style},R))})]})]})});function oe(t,e){return(t%e+e)%e}const $e=({children:t,onClickOutside:e})=>{const r=l.useRef(null),s=l.useRef(!1),o=l.useRef(!1);l.useEffect(()=>{const i=window.setTimeout(()=>{o.current=!0},0);return()=>{clearTimeout(i),o.current=!1}},[]);const a=l.useCallback(i=>{const d=s.current;s.current=!1,!(!o.current||!r.current||d)&&(i.composedPath().includes(r.current)||e(i))},[e]);return l.useEffect(()=>(document.addEventListener("click",a),()=>document.removeEventListener("click",a)),[a]),l.cloneElement(t,{ref:r,onClick:i=>{s.current=!0,t.props?.onClick?.(i)}})},F={right:45,left:-45},se={right:-135,left:-225},C=t=>{const{size:e=36,duration:r=.25,double:s,openStyle:o,open:a,style:i,rounded:d,lineHeight:h,...u}=t,v=h||Math.max(1,Math.round(e/20)),j={width:e,height:e,display:"flex",position:"relative",justifyContent:"center",alignItems:"center",transition:`transform ${r}s ease`},w={height:v,width:e*.7,backgroundColor:"currentColor",position:"absolute",transition:`transform ${r}s ease, opacity ${r}s ease`,borderRadius:d?1e4:0},k=l.useMemo(()=>e/(s?7:4),[e,s]),{outer:S,top:E,middle:T,bottom:N}=o,I=a?S:{},$=a?E:{transform:`translateY(-${k}px)`},Y=a?N:{transform:`translateY(${k}px)`},B=a?T:{};return c.jsxs(W,{style:{...i,...I,...j},...u,"aria-label":u["aria-label"]||"hamburger","aria-expanded":a,children:[c.jsx("span",{style:{...w,...$}}),!s&&c.jsx("span",{style:{...w,...B}}),c.jsx("span",{style:{...w,...Y}})]})},ae=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=F[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},middle:{transform:"scale(0)"},bottom:{transform:i}}},[e]);return c.jsx(C,{...r,openStyle:s})},Re=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=F[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},bottom:{transform:i}}},[e]);return c.jsx(C,{...r,double:!0,openStyle:s})},Oe=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=se[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},bottom:{transform:i}}},[e]);return c.jsx(C,{...r,double:!0,openStyle:s})},Ce=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=F[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},bottom:{transform:i},outer:{transform:"rotate(180deg)"}}},[e]);return c.jsx(C,{...r,double:!0,openStyle:s})},Le=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=F[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},middle:{opacity:0},bottom:{transform:i}}},[e]);return c.jsx(C,{...r,openStyle:s})},Me=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=se[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},middle:{transform:"scale(0)"},bottom:{transform:i}}},[e]);return c.jsx(C,{...r,openStyle:s})},Pe=t=>{const{direction:e="left",...r}=t,s=l.useMemo(()=>{const o=F[e],a=`rotate(${o}deg)`,i=`rotate(${-o}deg)`;return{top:{transform:a},middle:{opacity:0},bottom:{transform:i},outer:{transform:"rotate(180deg)"}}},[e]);return c.jsx(C,{...r,openStyle:s})},De=l.forwardRef(({className:t,corners:e="rounded",...r},s)=>c.jsx("input",{...r,ref:s,className:p(`aui-input-base aui-input aui-corners--${e}`,t)})),Fe=l.forwardRef(({className:t,rows:e=3,corners:r="rounded",...s},o)=>c.jsx("textarea",{...s,ref:o,className:p(`aui-input-base aui-input aui-corners--${r}`,t),rows:e})),Ie=l.forwardRef(({startIcon:t,endIcon:e,className:r,style:s,corners:o="rounded",inputProps:a},i)=>c.jsxs(g,{layout:{axis:"x",align:"center"},className:p(`aui-input aui-icon-input aui-corners--${o}`,r),style:s,ref:i,children:[t,c.jsx("input",{...a,className:p(`aui-input-base aui-corners--${o}`,a?.className)}),e]})),Ye=()=>{const t=window.scrollY,e=document.body.style,r=document.documentElement.style,{overflow:s,position:o,top:a,width:i}=e,{scrollBehavior:d}=r;return r.scrollBehavior="auto",e.overflow="hidden",e.position="fixed",e.top=`-${t}px`,e.width="100%",()=>{e.overflow=s,e.position=o,e.top=a,e.width=i,window.scrollTo(0,t),r.scrollBehavior=d}},ie=(t=!0)=>{l.useEffect(()=>{if(t)return Ye()},[t])},Be=t=>{const{onMatch:e,onUnmatch:r,query:s}=t,[o,a]=l.useState(!1);return l.useEffect(()=>{const i=window.matchMedia(s),d=h=>{h.matches?e?.():r?.(),a(h.matches)};return i.addEventListener("change",d),a(i.matches),()=>i.removeEventListener("change",d)},[e,r,s]),o},Ue=()=>{const[t,e]=l.useState({scrollX:window.scrollX,scrollY:window.scrollY});return l.useEffect(()=>{const r=()=>{e({scrollX:window.scrollX,scrollY:window.scrollY})};return window.addEventListener("scroll",r),()=>window.removeEventListener("scroll",r)},[]),t},ze='a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, [tabindex="0"], [contenteditable]',le=(t=!0)=>{const e=l.useRef(null),r=l.useRef(null),s=l.useCallback(()=>{e.current&&(r.current=e.current.querySelectorAll(ze))},[]);return l.useEffect(()=>{if(!t||!e.current)return;s();const o=i=>{if(i.key!=="Tab")return;if(!r.current||r.current.length===0)return i.preventDefault();const{activeElement:d}=document,h=r.current[0],u=r.current[r.current.length-1];i.shiftKey&&d===h?(u.focus(),i.preventDefault()):!i.shiftKey&&d===u?(h.focus(),i.preventDefault()):e.current?.contains(d)||((i.shiftKey?u:h).focus(),i.preventDefault())},a=new MutationObserver(s);return a.observe(e.current,{childList:!0,subtree:!0}),document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o),a.disconnect()}},[t,s]),e},We=(t={})=>{const{active:e=!0,behavior:r,delay:s}=t;l.useEffect(()=>{const o=window.location.hash;if(!e||o?.length<=1)return;const a=o.substring(1);if(s!==void 0){const i=setTimeout(()=>H(a,r),s);return()=>clearTimeout(i)}H(a,r)},[e,r,s])},qe=t=>{l.useEffect(()=>(window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)),[t])},He=l.forwardRef(({onClose:t,children:e,className:r,disableEscape:s=!1,visible:o,onMouseDown:a,...i},d)=>{const h=le(o);return l.useEffect(()=>{const u=v=>{v.key==="Escape"&&t?.()};return s||document.addEventListener("keydown",u),()=>{s||document.removeEventListener("keydown",u)}},[t,s]),c.jsx(g,{layout:{axis:"y",align:"center",justify:"center"},...i,className:p("aui-layer-backdrop",r),onMouseDown:u=>{a?.(u),t?.()},ref:d,children:l.cloneElement(e,{ref:h,onMouseDown:u=>{u.stopPropagation(),e.props?.onMouseDown?.(u)}})})}),Ve=l.forwardRef(({returnFocusOnEscape:t,disableScrollLock:e,...r},s)=>(ie(!e),l.useEffect(()=>()=>{const o=document.activeElement;t||o?.blur?.()},[t]),c.jsx(He,{...r,visible:!0,ref:s}))),V=l.forwardRef(({LinkElement:t,to:e,className:r,external:s,...o},a)=>{const i={...s?{target:"_blank",rel:"noreferrer noopener"}:{},...o,className:p("aui-action",r)};return t?c.jsx(t,{...i,to:e,ref:a}):c.jsx("a",{...i,href:e,ref:a})}),Xe=l.forwardRef(({className:t,variant:e,corners:r,size:s,...o},a)=>c.jsx(V,{...o,className:p(re({variant:e,corners:r,size:s}),t),ref:a})),Je=l.forwardRef(({className:t,...e},r)=>c.jsx(V,{...e,className:p("aui-link",t),ref:r})),Ge=({className:t,options:e,getOptionLabel:r,corners:s="rounded",style:o,disabled:a,...i},d)=>c.jsxs(g,{className:p("aui-select-container",`aui-corners--${s}`,a?"aui-select-disabled":void 0,t),style:o,children:[c.jsx("select",{...i,ref:d,className:`aui-select aui-corners--${s}`,disabled:a,children:e.map((h,u)=>c.jsx("option",{value:h,children:r?.(h)||h},u))}),c.jsx(D,{icon:"down",className:"aui-select-icon","aria-hidden":!0})]}),Qe=l.forwardRef(Ge),Ze=({className:t,...e})=>c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",className:p("aui-spinner",t),...e,children:c.jsx("path",{fill:"currentColor",d:"M256,0C114.62,0,0,114.62,0,256S114.62,512,256,512c70.64,0,134.59-28.61,180.91-74.88l-31.11-31.11c-38.35,38.3-91.31,61.99-149.8,61.99-117.08,0-212-94.92-212-212S138.92,44,256,44V0Z"})});f.Accordion=je,f.Alert=Se,f.Animated=ne,f.Badge=ke,f.Banner=Ne,f.Box=g,f.Button=q,f.ButtonLink=Xe,f.Carousel=Ae,f.ClickOutside=$e,f.DoubleCross=Re,f.DoubleFlip=Oe,f.DoubleSpin=Ce,f.Hamburger=ae,f.Icon=D,f.IconInput=Ie,f.Input=De,f.Layer=Ve,f.Link=Je,f.Select=Qe,f.Spinner=Ze,f.TextArea=Fe,f.TripleFade=Le,f.TripleFlip=Me,f.TriplePrestige=ae,f.TripleSpin=Pe,f.UnstyledButton=W,f.UnstyledLink=V,f.assertDefined=ye,f.classNames=p,f.scrollToId=H,f.useFocusTrap=le,f.useMediaQuery=Be,f.useScroll=Ue,f.useScrollLock=ie,f.useScrollToHash=We,f.useWindowResize=qe,Object.defineProperty(f,Symbol.toStringTag,{value:"Module"})});
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Assert a value is defined
3
+ *
4
+ * @param value the value to assert presence of
5
+ * @param message optional error message
6
+ * @returns the present value
7
+ */
8
+ export default function assertDefined<T>(value: T | undefined, message?: string): T;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Assert a value is defined
3
+ *
4
+ * @param value the value to assert presence of
5
+ * @param message optional error message
6
+ * @returns the present value
7
+ */
8
+ export default function assertDefined(value, message) {
9
+ if (value === undefined) {
10
+ throw new Error(message || "Unexpected undefined value");
11
+ }
12
+ return value;
13
+ }
@@ -9,5 +9,8 @@ export default function classNames() {
9
9
  for (var _i = 0; _i < arguments.length; _i++) {
10
10
  classNames[_i] = arguments[_i];
11
11
  }
12
- return classNames.filter(Boolean).join(" ");
12
+ return classNames
13
+ .map(function (className) { return className === null || className === void 0 ? void 0 : className.trim(); })
14
+ .filter(Boolean)
15
+ .join(" ");
13
16
  }
@@ -1,4 +1,4 @@
1
1
  import classNames from "./classNames";
2
2
  import scrollToId from "./scrollToId";
3
- import assert, { assertDefined } from "./assert";
4
- export { classNames, scrollToId, assert, assertDefined };
3
+ import assertDefined from "./assertDefined";
4
+ export { classNames, scrollToId, assertDefined };
@@ -1,4 +1,4 @@
1
1
  import classNames from "./classNames";
2
2
  import scrollToId from "./scrollToId";
3
- import assert, { assertDefined } from "./assert";
4
- export { classNames, scrollToId, assert, assertDefined };
3
+ import assertDefined from "./assertDefined";
4
+ export { classNames, scrollToId, assertDefined };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamjanicki/ui",
3
- "version": "1.5.8",
3
+ "version": "1.6.0",
4
4
  "description": "Basic UI components and hooks for React in TypeScript",
5
5
  "type": "module",
6
6
  "main": "./index.js",
@@ -12,9 +12,11 @@
12
12
  "url": "git+https://github.com/adamjanicki2/ui.git"
13
13
  },
14
14
  "scripts": {
15
- "clean": "./clean.sh",
16
- "lint": "eslint src --max-warnings=0",
17
- "build": "npm run clean && npm run lint && tsc; cp src/style.css ./style.css",
15
+ "clean": "python clean.py",
16
+ "lint": "eslint src test --max-warnings=0",
17
+ "test": "jest",
18
+ "scss": "sass --no-source-map --style=compressed src/style.scss style.css",
19
+ "build": "npm run clean && npm run lint && npm test && tsc && npm run scss",
18
20
  "prepare": "npm run build",
19
21
  "dryrun": "npm publish --dry-run"
20
22
  },
@@ -23,8 +25,16 @@
23
25
  "react-dom": ">=18"
24
26
  },
25
27
  "devDependencies": {
28
+ "@testing-library/jest-dom": "^6.7.0",
29
+ "@testing-library/react": "^16.3.0",
30
+ "@testing-library/user-event": "^14.6.1",
31
+ "@types/jest": "^30.0.0",
26
32
  "@types/react": "^19.1.9",
27
33
  "@types/react-dom": "^19.1.7",
34
+ "jest": "^30.0.5",
35
+ "jest-environment-jsdom": "^30.0.5",
36
+ "sass": "^1.90.0",
37
+ "ts-jest": "^29.4.1",
28
38
  "typescript": "^5.9.2"
29
39
  }
30
40
  }