@bgord/ui 0.6.1 → 0.6.2

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.
@@ -1,3 +1 @@
1
- export * from "./button";
2
1
  export * from "./dialog";
3
- export * from "./revalidate-on-focus";
@@ -4,7 +4,6 @@ export * from "./use-exit-action";
4
4
  export * from "./use-field";
5
5
  export * from "./use-focus-shortcut";
6
6
  export * from "./use-hover";
7
- export * from "./use-language-selector";
8
7
  export * from "./use-meta-enter-submit";
9
8
  export * from "./use-scroll-lock";
10
9
  export * from "./use-shortcuts";
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  type UseExitActionAnimationType = string;
3
3
  type UseExitActionOptionsType = {
4
- actionFn: () => void;
4
+ action: () => void;
5
5
  animation: UseExitActionAnimationType;
6
6
  };
7
7
  type UseExitActionReturnType = {
@@ -5,7 +5,7 @@ export type UseHoverReturnType<T extends HTMLElement> = {
5
5
  attach: {
6
6
  ref: React.RefCallback<T | null>;
7
7
  };
8
- isHovering: boolean;
8
+ hovering: boolean;
9
9
  };
10
- export declare function useHover<T extends HTMLElement = HTMLElement>({ enabled, }?: UseHoverConfigType): UseHoverReturnType<T>;
10
+ export declare function useHover<T extends HTMLElement = HTMLElement>(config?: UseHoverConfigType): UseHoverReturnType<T>;
11
11
  export {};
@@ -1,8 +1,8 @@
1
- interface UseKeyboardShortcutsConfigType {
2
- [keybinding: string]: (event: KeyboardEvent) => void;
3
- }
4
- type UseKeyboardShortcutsOptionsType = {
1
+ type UseShortcutsConfigType = {
2
+ [key: string]: (event: KeyboardEvent) => void;
3
+ };
4
+ type UseShortcutsOptionsType = {
5
5
  enabled?: boolean;
6
6
  };
7
- export declare function useKeyboardShortcuts(config: UseKeyboardShortcutsConfigType, options?: UseKeyboardShortcutsOptionsType): void;
7
+ export declare function useShortcuts(config: UseShortcutsConfigType, options?: UseShortcutsOptionsType): void;
8
8
  export {};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{jsx as U}from"react/jsx-runtime";function he(){return U("button",{type:"button",children:"Click"})}import{useEffect as ie,useRef as me}from"react";import{useEffect as q}from"react";function g(e,t){q(()=>{if(typeof document>"u")return;function r(n){let o=e.current;if(!o)return;if(o.contains(n.target))if(n.target===o){let{left:i,right:m,top:x,bottom:p}=o.getBoundingClientRect(),a=n instanceof MouseEvent?n.clientX:n.touches[0].clientX,y=n instanceof MouseEvent?n.clientY:n.touches[0].clientY;if(a>=i&&a<=m&&y>=x&&y<=p)return}else return;t(n)}return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),()=>{document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r)}},[e,t])}import{useCallback as $,useMemo as h}from"react";class s{static emptyValue=void 0;static isEmpty(e){return e===void 0||e===""||e===null}static compare(e,t){if(s.isEmpty(e)&&s.isEmpty(t))return!0;return e===t}value=s.emptyValue;constructor(e){this.value=s.isEmpty(e)?s.emptyValue:e}get(){return this.value}isEmpty(){return s.isEmpty(this.value)}}import{useEffect as P,useState as M}from"react";import{useSearchParams as W}from"react-router";var l;((r)=>{r.params="params";r.local="local"})(l||={});function L(e){let t=e.strategy??"local",[r,n]=W(),o=new s(r.get(e.name)),i=new s(e.defaultValue),[m,x]=M(o.isEmpty()?i.get():o.get()),p=(c)=>{let k=new s(c);x(k.get())};P(()=>{let c=new s(m);if(t==="params")if(c.isEmpty())r.delete(e.name),n(r);else r.set(e.name,c.get()),n(r)},[m,r,n,e.name,t]);let a=s.isEmpty(m)?"":m,y=(c)=>p(c.currentTarget.value);return{strategy:t,defaultValue:i.get(),currentValue:m,value:a,set:p,handleChange:y,clear:()=>p(i.get()),label:{props:{htmlFor:e.name}},input:{props:{id:e.name,name:e.name,value:a,onChange:y}},changed:!s.compare(m,i.get()),unchanged:s.compare(m,i.get()),empty:s.isEmpty(m)}}class I{static clearAll(e){return()=>e.forEach((t)=>t.clear())}}function A(e){let t=L({...e,strategy:"local"}),r=$((i)=>{if(t.empty)return!0;return s.compare(i,t.currentValue)},[t.empty,t.currentValue]),n=h(()=>e.filterFn??r,[e.filterFn,r]),o=h(()=>Object.entries(e.enum).map(([i,m])=>({name:i,value:m})),[e.enum]);return h(()=>({...t,filterFn:n,options:o,strategy:"local"}),[t,n,o])}import D from"react";function Ue(e){let[t,r]=D.useState("idle"),n=(m)=>{if(m.preventDefault(),t==="idle")r("exiting")},o=(m)=>{if(m.animationName!==e.animation)return;e.actionFn(),r("gone")},i=t==="exiting"?{"data-animation":e.animation,onAnimationEnd:o}:void 0;return{visible:t!=="gone",attach:i,trigger:n}}import{useCallback as B,useMemo as X,useRef as J}from"react";import{useEffect as v,useMemo as K}from"react";import{tinykeys as _}from"tinykeys";function T(e,t){let r=t?.enabled??!0,n=K(()=>e,[JSON.stringify(Object.keys(e))]);v(()=>{if(!r)return;let o=_(window,n);return()=>o()},[n,r])}function De(e){let t=J(null),r=B(()=>{if(t.current)t.current.focus()},[]);return T({[e]:r}),X(()=>({ref:t}),[])}import{useCallback as N,useRef as Q}from"react";import{useState as O}from"react";function C({name:e,defaultValue:t=!1}){let[r,n]=O(t);return{on:r,off:!r,enable:()=>n(!0),disable:()=>n(!1),toggle:()=>n((a)=>!a),props:{controller:{"aria-expanded":r?"true":"false","aria-controls":e,role:"button",tabIndex:0},target:{id:e,role:"region","aria-hidden":r?"false":"true"}}}}function b(e){let{on:t,off:r,enable:n,disable:o,toggle:i,props:m,...x}=e;return{toggle:{on:t,off:r,enable:n,disable:o,toggle:i,props:m},rest:x}}function Je({enabled:e=!0}={}){let{on:t,enable:r,disable:n}=C({name:"is-hovering"}),o=Q(null),i=typeof window<"u"&&"PointerEvent"in window?"pointerenter":"mouseenter",m=typeof window<"u"&&"PointerEvent"in window?"pointerleave":"mouseleave";return{attach:{ref:N((p)=>{let a=o.current;if(a)a.removeEventListener(i,r),a.removeEventListener(m,n);if(o.current=p,p&&e)p.addEventListener(i,r),p.addEventListener(m,n)},[i,m,e,r,n])},isHovering:t&&e}}import Y from"js-cookie";import{useCallback as z,useEffect as V}from"react";import{useRevalidator as ee}from"react-router";import{createContext as Z,use as f,useCallback as j}from"react";import{polishPlurals as G}from"polish-plurals";function F(e){if(e.language==="en"){let t=e.plural??`${e.singular}s`;if(e.value===1)return e.singular;return t}if(e.language==="pl"){let t=e.value??1;if(t===1)return e.singular;return G(e.singular,String(e.plural),String(e.genitive),t)}return console.warn(`[@bgord/frontend] missing pluralization function for language: ${e.language}.`),e.singular}var E=Z({translations:{},language:"en",supportedLanguages:{en:"en"}});function je(){let e=f(E);if(e===void 0)throw Error("useTranslations must be used within the TranslationsContext");return j((r,n)=>{let o=e.translations[r];if(!o)return console.warn(`[@bgord/ui] missing translation for key: ${r}`),r;if(!n)return o;return Object.entries(n).reduce((i,[m,x])=>{let p=new RegExp(`{{${m}}}`,"g");return i.replace(p,String(x))},o)},[e.translations])}function R(){let e=f(E);if(e===void 0)throw Error("useLanguage must be used within the TranslationsContext");return e.language}function Ye(){let e=f(E);if(e===void 0)throw Error("useSupportedLanguages must be used within the TranslationsContext");return e.supportedLanguages}function ze(){let e=R();return(t)=>F({...t,language:e})}function mt(e){let t=R(),r=ee(),n=A({enum:e,defaultValue:t,name:"language"}),o=z(()=>{let i=new s(n.currentValue);if(!i.isEmpty()&&n.changed)Y.set("language",String(i.get())),r.revalidate()},[n.currentValue,n.changed]);return V(()=>{o()},[o]),n}import{useCallback as te,useMemo as re}from"react";function pt(){let e=te((t)=>{if(t.key!=="Enter"||!t.metaKey)return;t.preventDefault(),t.currentTarget.form?.requestSubmit()},[]);return re(()=>({onKeyDown:e}),[e])}import{useEffect as ne}from"react";function H(e=!0){ne(()=>{if(typeof document>"u")return;let t=document.body.style.overflow;if(e)document.body.style.overflow="hidden";return()=>{document.body.style.overflow=t}},[e])}import{jsx as se}from"react/jsx-runtime";function Ct(e){let{toggle:t,rest:r}=b(e),n=me(null);return ie(()=>{if(e.on)n.current?.showModal();else n.current?.close()},[e.on]),T({Escape:t.disable}),H(e.on),g(n,t.disable),se("dialog",{ref:n,tabIndex:0,"aria-modal":"true","data-disp":e.on?"flex":"none","data-dir":"column","data-mx":"auto","data-p":"5","data-position":"fixed","data-z":"2","data-bg":"neutral-900","data-br":"xs","data-backdrop":"stronger","data-animation":"grow-fade-in",...r})}import{useEffect as ue}from"react";import{useRevalidator as pe}from"react-router";function kt(){let e=pe();return ue(()=>{let t=()=>e.revalidate();return window.addEventListener("focus",t),()=>window.removeEventListener("focus",t)},[e]),null}import{redirect as w}from"react-router";class d{static extractFrom(e){return e.headers.get("cookie")??""}}class ae{API_URL;constructor(e){this.API_URL=`${e}/api/auth`}async getServerSession(e){let t=d.extractFrom(e),r=await fetch(`${this.API_URL}/get-session`,{headers:{cookie:t,accept:"application/json"}});if(!r.ok)return null;return await r.json()}async requireSession(e){let t=await this.getServerSession(e);if(t?.user)return t;throw w("/")}async requireNoSession(e,t="/home"){if((await this.getServerSession(e))?.user)throw w(t)}async removeSession(e,t="/login"){let r=d.extractFrom(e),n=await fetch(`${import.meta.env.VITE_API_URL}/api/auth/sign-out`,{method:"POST",headers:{cookie:r}}),o=new Headers;throw n.headers.forEach((i,m)=>{if(m.toLowerCase()==="set-cookie")o.append("set-cookie",i)}),w(t,{headers:o})}}function S(){}var xe=()=>console.warn("Copying to clipboard not supported");async function Bt(e){let t=e.onFailure??xe,r=e.onSuccess??S;if(!navigator.clipboard)t();try{await navigator.clipboard.writeText(e.text),r()}catch(n){t(n)}}var Jt={email:{inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:"false"},password:{new:{autoComplete:"new-password"},current:{autoComplete:"current-password"}}};class ce{static fromRevision(e){return{"if-match":String(e)}}}function Qt(e){return function(){for(let t of e)t()}}class ye{static allUnchanged(e){return e.every((t)=>t.unchanged)}static allEmpty(e){return e.every((t)=>t.empty)}static anyEmpty(e){return e.some((t)=>t.empty)}static anyUnchanged(e){return e.some((t)=>t.unchanged)}static anyChanged(e){return e.some((t)=>t.changed)}}class Te{static inputPattern(e){let t=e.required??!0;if(e.min&&!e.max)return{pattern:`.{${e.min}}`,required:t};if(e.min&&e.max)return{pattern:`.{${e.min},${e.max}}`,required:t};if(!e.min&&e.max)return{pattern:`.{,${e.max}}`,required:t};return{pattern:void 0,required:t}}static textareaPattern(e){let t=e.required??!0;if(e.min&&!e.max)return{minLength:e.min,required:t};if(e.min&&e.max)return{minLength:e.min,maxLength:e.max,required:t};if(!e.min&&e.max)return{maxLength:e.max,required:t};return{required:t}}}function Yt(){if(typeof window>"u")return;return window}function Vt(e=12){return{times(t){let r=e*t,n={height:{height:u(r)},minHeight:{minHeight:u(r)},maxHeight:{maxHeight:u(r)},width:{width:u(r)},minWidth:{minWidth:u(r)},maxWidth:{maxWidth:u(r)},square:{height:u(r),width:u(r)}},o={height:{style:{height:u(r)}},minHeight:{style:{minHeight:u(r)}},maxHeight:{style:{maxHeight:u(r)}},width:{style:{width:u(r)}},minWidth:{style:{minWidth:u(r)}},maxWidth:{style:{maxWidth:u(r)}},square:{style:{height:u(r),width:u(r)}}};return{px:u(r),raw:r,style:o,...n}}}}function u(e){return`${e}px`}class de{static fromRevision(e){return{"if-match":`W/${e}`}}}export{je as useTranslations,C as useToggle,Ye as useSupportedLanguages,H as useScrollLock,ze as usePluralize,pt as useMetaEnterSubmit,mt as useLanguageSelector,R as useLanguage,T as useKeyboardShortcuts,Je as useHover,De as useFocusKeyboardShortcut,l as useFieldStrategyEnum,L as useField,Ue as useExitAction,A as useClientFilter,g as useClickOutside,F as pluralize,S as noop,Yt as getSafeWindow,b as extractUseToggle,Qt as exec,Bt as copyToClipboard,de as WeakETag,E as TranslationsContext,Vt as Rhythm,kt as RevalidateOnFocus,I as LocalFields,Te as Form,ye as Fields,s as Field,ce as ETag,Ct as Dialog,Jt as Credentials,d as Cookies,he as Button,ae as AuthGuard};
1
+ import{useEffect as N,useRef as _}from"react";import{useEffect as v}from"react";function g(e,t){v(()=>{if(typeof document>"u")return;function n(o){let r=e.current;if(!r)return;if(r.contains(o.target))if(o.target===r){let{left:i,right:s,top:p,bottom:u}=r.getBoundingClientRect(),c=o instanceof MouseEvent?o.clientX:o.touches[0].clientX,d=o instanceof MouseEvent?o.clientY:o.touches[0].clientY;if(c>=i&&c<=s&&d>=p&&d<=u)return}else return;t(o)}return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}import{useCallback as F,useMemo as y}from"react";class m{static emptyValue=void 0;static isEmpty(e){return e===void 0||e===""||e===null}static compare(e,t){if(m.isEmpty(e)&&m.isEmpty(t))return!0;return e===t}value=m.emptyValue;constructor(e){this.value=m.isEmpty(e)?m.emptyValue:e}get(){return this.value}isEmpty(){return m.isEmpty(this.value)}}import{useEffect as S,useState as L}from"react";import{useSearchParams as H}from"react-router";var h;((n)=>{n.params="params";n.local="local"})(h||={});function b(e){let t=e.strategy??"local",[n,o]=H(),r=new m(n.get(e.name)),i=new m(e.defaultValue),[s,p]=L(r.isEmpty()?i.get():r.get()),u=(l)=>{let A=new m(l);p(A.get())};S(()=>{let l=new m(s);if(t==="params")if(l.isEmpty())n.delete(e.name),o(n);else n.set(e.name,l.get()),o(n)},[s,n,o,e.name,t]);let c=m.isEmpty(s)?"":s,d=(l)=>u(l.currentTarget.value);return{strategy:t,defaultValue:i.get(),currentValue:s,value:c,set:u,handleChange:d,clear:()=>u(i.get()),label:{props:{htmlFor:e.name}},input:{props:{id:e.name,name:e.name,value:c,onChange:d}},changed:!m.compare(s,i.get()),unchanged:m.compare(s,i.get()),empty:m.isEmpty(s)}}class k{static clearAll(e){return()=>e.forEach((t)=>t.clear())}}function ye(e){let t=b({...e,strategy:"local"}),n=F((i)=>{if(t.empty)return!0;return m.compare(i,t.currentValue)},[t.empty,t.currentValue]),o=y(()=>e.filterFn??n,[e.filterFn,n]),r=y(()=>Object.entries(e.enum).map(([i,s])=>({name:i,value:s})),[e.enum]);return y(()=>({...t,filterFn:o,options:r,strategy:"local"}),[t,o,r])}import M from"react";function ge(e){let[t,n]=M.useState("idle"),o=(s)=>{if(s.preventDefault(),t==="idle")n("exiting")},r=(s)=>{if(s.animationName!==e.animation)return;e.action(),n("gone")},i=t==="exiting"?{"data-animation":e.animation,onAnimationEnd:r}:void 0;return{visible:t!=="gone",attach:i,trigger:o}}import{useCallback as W,useMemo as O,useRef as I}from"react";import{useEffect as X}from"react";import{tinykeys as q}from"tinykeys";function f(e,t){let n=t?.enabled??!0;X(()=>{if(!n)return;let o=q(window,e);return()=>o()},[e,n])}function Ue(e){let t=I(null),n=W(()=>{if(t.current)t.current.focus()},[]);return f({[e]:n}),O(()=>({ref:t}),[])}import{useCallback as D,useRef as J}from"react";import{useState as P}from"react";function E({name:e,defaultValue:t=!1}){let[n,o]=P(t);return{on:n,off:!n,enable:()=>o(!0),disable:()=>o(!1),toggle:()=>o((c)=>!c),props:{controller:{"aria-expanded":n?"true":"false","aria-controls":e,role:"button",tabIndex:0},target:{id:e,role:"region","aria-hidden":n?"false":"true"}}}}function R(e){let{on:t,off:n,enable:o,disable:r,toggle:i,props:s,...p}=e;return{toggle:{on:t,off:n,enable:o,disable:r,toggle:i,props:s},rest:p}}function ke(e){let t=e?.enabled??!0,n=E({name:"_internal"}),o=J(null),r=typeof window<"u"&&"PointerEvent"in window?"pointerenter":"mouseenter",i=typeof window<"u"&&"PointerEvent"in window?"pointerleave":"mouseleave";return{attach:{ref:D((p)=>{let u=o.current;if(u)u.removeEventListener(r,n.enable),u.removeEventListener(i,n.disable);if(o.current=p,p&&t)p.addEventListener(r,n.enable),p.addEventListener(i,n.disable)},[r,i,t,n.enable,n.disable])},hovering:n.on&&t}}import{useCallback as K}from"react";function Xe(){return{onKeyDown:K((t)=>{if(!t.metaKey||t.key!=="Enter")return;t.preventDefault(),t.currentTarget.form?.requestSubmit()},[])}}import{useEffect as $}from"react";function w(e=!0){$(()=>{if(typeof document>"u")return;let t=document.body.style.overflow;if(e)document.body.style.overflow="hidden";return()=>{document.body.style.overflow=t}},[e])}import{jsx as Y}from"react/jsx-runtime";function je(e){let{toggle:t,rest:n}=R(e),o=_(null);return N(()=>{if(e.on)o.current?.showModal();else o.current?.close()},[e.on]),f({Escape:t.disable}),w(e.on),g(o,t.disable),Y("dialog",{ref:o,tabIndex:0,"aria-modal":"true","data-disp":e.on?"flex":"none","data-dir":"column","data-mx":"auto","data-p":"5","data-position":"fixed","data-z":"2","data-bg":"neutral-900","data-br":"xs","data-backdrop":"stronger","data-animation":"grow-fade-in",...n})}var et={email:{inputMode:"email",autoComplete:"email",autoCapitalize:"none",spellCheck:"false"},password:{new:{autoComplete:"new-password"},current:{autoComplete:"current-password"}},off:{autoComplete:"off",spellCheck:!1}};function C(){}class Q{static async copy(e){let t=e.onSuccess??C;if(!navigator.clipboard)return;await navigator.clipboard.writeText(e.text),t()}}import j from"js-cookie";class G{static extractFrom(e){return e.headers.get("cookie")??""}static set(e,t){j.set(e,t)}}class Z{static fromRevision(e){return{"if-match":String(e)}}}function at(e){return function(){for(let t of e)t()}}class z{static allUnchanged(e){return e.every((t)=>t.unchanged)}static allEmpty(e){return e.every((t)=>t.empty)}static anyEmpty(e){return e.some((t)=>t.empty)}static anyUnchanged(e){return e.some((t)=>t.unchanged)}static anyChanged(e){return e.some((t)=>t.changed)}}class V{static input(e){let t=e.required??!0;if(e.min&&!e.max)return{pattern:`.{${e.min}}`,required:t};if(e.min&&e.max)return{pattern:`.{${e.min},${e.max}}`,required:t};if(!e.min&&e.max)return{pattern:`.{,${e.max}}`,required:t};return{pattern:void 0,required:t}}static textarea(e){let t=e.required??!0;if(e.min&&!e.max)return{minLength:e.min,required:t};if(e.min&&e.max)return{minLength:e.min,maxLength:e.max,required:t};if(!e.min&&e.max)return{maxLength:e.max,required:t};return{required:t}}static exact(e){let t=e.required??!0;return{pattern:e.text,required:t}}}function lt(){if(typeof window>"u")return;return window}import{polishPlurals as ee}from"polish-plurals";function U(e){if(e.language==="en"){let t=e.plural??`${e.singular}s`;if(e.value===1)return e.singular;return t}if(e.language==="pl"){let t=e.value??1;if(t===1)return e.singular;return ee(e.singular,String(e.plural),String(e.genitive),t)}return console.warn(`[@bgord/frontend] missing pluralization function for language: ${e.language}.`),e.singular}function xt(e=12){return{times(t){let n=e*t,o={height:{height:a(n)},minHeight:{minHeight:a(n)},maxHeight:{maxHeight:a(n)},width:{width:a(n)},minWidth:{minWidth:a(n)},maxWidth:{maxWidth:a(n)},square:{height:a(n),width:a(n)}},r={height:{style:{height:a(n)}},minHeight:{style:{minHeight:a(n)}},maxHeight:{style:{maxHeight:a(n)}},width:{style:{width:a(n)}},minWidth:{style:{minWidth:a(n)}},maxWidth:{style:{maxWidth:a(n)}},square:{style:{height:a(n),width:a(n)}}};return{px:a(n),raw:n,style:r,...o}}}}function a(e){return`${e}px`}import{createContext as te,use as x,useCallback as ne}from"react";var T=te({translations:{},language:"en",supportedLanguages:{en:"en"}});function bt(){let e=x(T);if(e===void 0)throw Error("useTranslations must be used within the TranslationsContext");return ne((n,o)=>{let r=e.translations[n];if(!r)return console.warn(`[@bgord/ui] missing translation for key: ${n}`),n;if(!o)return r;return Object.entries(o).reduce((i,[s,p])=>{let u=new RegExp(`{{${s}}}`,"g");return i.replace(u,String(p))},r)},[e.translations])}function oe(){let e=x(T);if(e===void 0)throw Error("useLanguage must be used within the TranslationsContext");return e.language}function Et(){let e=x(T);if(e===void 0)throw Error("useSupportedLanguages must be used within the TranslationsContext");return e.supportedLanguages}function Rt(){let e=oe();return(t)=>U({...t,language:e})}class re{static fromRevision(e){return{"if-match":`W/${e}`}}}export{bt as useTranslations,E as useToggle,Et as useSupportedLanguages,f as useShortcuts,w as useScrollLock,Rt as usePluralize,Xe as useMetaEnterSubmit,oe as useLanguage,ke as useHover,Ue as useFocusKeyboardShortcut,h as useFieldStrategyEnum,b as useField,ge as useExitAction,ye as useClientFilter,g as useClickOutside,U as pluralize,C as noop,lt as getSafeWindow,R as extractUseToggle,at as exec,re as WeakETag,T as TranslationsContext,xt as Rhythm,k as LocalFields,V as Form,z as Fields,m as Field,Z as ETag,je as Dialog,G as Cookies,Q as Clipboard,et as Autocomplete};
@@ -1,9 +1,10 @@
1
- type CredentialsType = {
1
+ type AutocompleteType = {
2
2
  email: React.JSX.IntrinsicElements["input"];
3
3
  password: {
4
4
  new: React.JSX.IntrinsicElements["input"];
5
5
  current: React.JSX.IntrinsicElements["input"];
6
6
  };
7
+ off: React.JSX.IntrinsicElements["input"];
7
8
  };
8
- export declare const Credentials: CredentialsType;
9
+ export declare const Autocomplete: AutocompleteType;
9
10
  export {};
@@ -0,0 +1,7 @@
1
+ export type CopyToClipboardOptionsType = {
2
+ text: string;
3
+ onSuccess?: VoidFunction;
4
+ };
5
+ export declare class Clipboard {
6
+ static copy(options: CopyToClipboardOptionsType): Promise<void>;
7
+ }
@@ -1,3 +1,4 @@
1
1
  export declare class Cookies {
2
2
  static extractFrom(request: Request): string;
3
+ static set(name: string, value: string): void;
3
4
  }
@@ -1,45 +1,16 @@
1
- /**
2
- * Utility class for working with multiple fields
3
- * @static
4
- */
5
1
  export declare class Fields {
6
- /**
7
- * Check if all fields are unchanged
8
- * @param {Array<{unchanged: boolean}>} fields - Array of field states
9
- * @returns {boolean} True if all fields match their default values
10
- */
11
2
  static allUnchanged(fields: {
12
3
  unchanged: boolean;
13
4
  }[]): boolean;
14
- /**
15
- * Check if all fields are empty
16
- * @param {Array<{empty: boolean}>} fields - Array of field states
17
- * @returns {boolean} True if all fields are empty
18
- */
19
5
  static allEmpty(fields: {
20
6
  empty: boolean;
21
7
  }[]): boolean;
22
- /**
23
- * Check if any field is empty
24
- * @param {Array<{empty: boolean}>} fields - Array of field states
25
- * @returns {boolean} True if any field is empty
26
- */
27
8
  static anyEmpty(fields: {
28
9
  empty: boolean;
29
10
  }[]): boolean;
30
- /**
31
- * Check if any field is unchanged
32
- * @param {Array<{unchanged: boolean}>} fields - Array of field states
33
- * @returns {boolean} True if any field matches its default value
34
- */
35
11
  static anyUnchanged(fields: {
36
12
  unchanged: boolean;
37
13
  }[]): boolean;
38
- /**
39
- * Check if any field has changed
40
- * @param {Array<{changed: boolean}>} fields - Array of field states
41
- * @returns {boolean} True if any field differs from its default value
42
- */
43
14
  static anyChanged(fields: {
44
15
  changed: boolean;
45
16
  }[]): boolean;
@@ -1,11 +1,16 @@
1
1
  import type React from "react";
2
- type PatternConfigType = {
2
+ type PatternTextConfigType = {
3
3
  min?: number;
4
4
  max?: number;
5
5
  required?: React.JSX.IntrinsicElements["input"]["required"];
6
6
  };
7
+ type PatternExactConfigType = {
8
+ text: string;
9
+ required?: React.JSX.IntrinsicElements["input"]["required"];
10
+ };
7
11
  export declare class Form {
8
- static inputPattern(config: PatternConfigType): React.ComponentPropsWithoutRef<"input">;
9
- static textareaPattern(config: PatternConfigType): React.ComponentPropsWithoutRef<"textarea">;
12
+ static input(config: PatternTextConfigType): React.ComponentPropsWithoutRef<"input">;
13
+ static textarea(config: PatternTextConfigType): React.ComponentPropsWithoutRef<"textarea">;
14
+ static exact(config: PatternExactConfigType): React.ComponentPropsWithoutRef<"input">;
10
15
  }
11
16
  export {};
@@ -1,7 +1,6 @@
1
- export * from "./auth-guard";
1
+ export * from "./autocomplete";
2
+ export * from "./clipboard";
2
3
  export * from "./cookies";
3
- export * from "./copy-to-clipboard";
4
- export * from "./credentials";
5
4
  export * from "./etag";
6
5
  export * from "./exec";
7
6
  export * from "./field";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bgord/ui",
3
- "version": "0.6.1",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -24,7 +24,7 @@
24
24
  "access": "public"
25
25
  },
26
26
  "devDependencies": {
27
- "@biomejs/biome": "2.2.7",
27
+ "@biomejs/biome": "2.3.0",
28
28
  "@commitlint/cli": "20.1.0",
29
29
  "@commitlint/config-conventional": "20.0.0",
30
30
  "@happy-dom/global-registrator": "20.0.8",
@@ -32,7 +32,7 @@
32
32
  "@testing-library/jest-dom": "6.9.1",
33
33
  "@testing-library/react": "16.3.0",
34
34
  "@testing-library/user-event": "14.6.1",
35
- "@types/bun": "1.3.0",
35
+ "@types/bun": "1.3.1",
36
36
  "@types/js-cookie": "3.0.6",
37
37
  "@types/react": "19.2.2",
38
38
  "@types/react-dom": "19.2.2",
package/readme.md CHANGED
@@ -25,9 +25,7 @@ Run the tests
25
25
  ```
26
26
  src/
27
27
  ├── components
28
- │   ├── button.tsx
29
28
  │   ├── dialog.tsx
30
- │   └── revalidate-on-focus.tsx
31
29
  ├── hooks
32
30
  │   ├── use-click-outside.ts
33
31
  │   ├── use-client-filter.ts
@@ -35,16 +33,14 @@ src/
35
33
  │   ├── use-field.ts
36
34
  │   ├── use-focus-shortcut.ts
37
35
  │   ├── use-hover.ts
38
- │   ├── use-language-selector.tsx
39
36
  │   ├── use-meta-enter-submit.tsx
40
37
  │   ├── use-scroll-lock.ts
41
38
  │   ├── use-shortcuts.ts
42
39
  │   └── use-toggle.ts
43
40
  └── services
44
- ├── auth-guard.ts
41
+ ├── autocomplete.ts
42
+ ├── clipboard.ts
45
43
  ├── cookies.ts
46
- ├── copy-to-clipboard.ts
47
- ├── credentials.ts
48
44
  ├── etag.ts
49
45
  ├── exec.ts
50
46
  ├── field.ts
@@ -1 +0,0 @@
1
- export declare function Button(): import("react/jsx-runtime").JSX.Element;
@@ -1 +0,0 @@
1
- export declare function RevalidateOnFocus(): null;
@@ -1,4 +0,0 @@
1
- import { type useClientFilterReturnType } from "./use-client-filter";
2
- type LanguageType = string;
3
- export declare function useLanguageSelector(supportedLanguages: Record<LanguageType, LanguageType>): useClientFilterReturnType<LanguageType>;
4
- export {};
@@ -1,9 +0,0 @@
1
- import type { createAuthClient } from "better-auth/react";
2
- export declare class AuthGuard<T extends ReturnType<typeof createAuthClient>["$Infer"]["Session"]> {
3
- private readonly API_URL;
4
- constructor(BASE_URL: string);
5
- getServerSession(request: Request): Promise<T | null>;
6
- requireSession(request: Request): Promise<T | null>;
7
- requireNoSession(request: Request, target?: string): Promise<void>;
8
- removeSession(request: Request, target?: string): Promise<void>;
9
- }
@@ -1,10 +0,0 @@
1
- type CopyToClipboardTextType = string;
2
- type OnCopyToClipboardFailureType = (error?: unknown) => void;
3
- type OnCopyToClipboardSuccessType = VoidFunction;
4
- export type CopyToClipboardOptionsType = {
5
- text: CopyToClipboardTextType;
6
- onFailure?: OnCopyToClipboardFailureType;
7
- onSuccess?: OnCopyToClipboardSuccessType;
8
- };
9
- export declare function copyToClipboard(options: CopyToClipboardOptionsType): Promise<void>;
10
- export {};