@brightlocal/ui-components 2.23.0 → 2.24.1

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 (90) hide show
  1. package/AI_USAGE.md +1 -1
  2. package/README.md +3 -2
  3. package/component-meta.json +116 -25
  4. package/deprecations.json +22 -0
  5. package/dist/alert.cjs +1 -1
  6. package/dist/alert.d.ts.map +1 -1
  7. package/dist/alert.js +6 -9
  8. package/dist/blocks/sidebar.cjs +1 -1
  9. package/dist/blocks/sidebar.d.ts.map +1 -1
  10. package/dist/blocks/sidebar.js +151 -156
  11. package/dist/brand-illustration-motif.cjs +1 -0
  12. package/dist/brand-illustration-motif.d.ts +55 -0
  13. package/dist/brand-illustration-motif.d.ts.map +1 -0
  14. package/dist/brand-illustration-motif.js +67 -0
  15. package/dist/chart.cjs +7 -7
  16. package/dist/chart.d.ts +287 -2
  17. package/dist/chart.d.ts.map +1 -1
  18. package/dist/chart.js +408 -152
  19. package/dist/combobox.cjs +3 -3
  20. package/dist/combobox.d.ts +14 -1
  21. package/dist/combobox.d.ts.map +1 -1
  22. package/dist/combobox.js +387 -376
  23. package/dist/data-table.cjs +1 -0
  24. package/dist/{blocks/data-table.d.ts → data-table.d.ts} +159 -4
  25. package/dist/data-table.d.ts.map +1 -0
  26. package/dist/data-table.js +721 -0
  27. package/dist/field.cjs +1 -1
  28. package/dist/field.d.ts +16 -1
  29. package/dist/field.d.ts.map +1 -1
  30. package/dist/field.js +23 -7
  31. package/dist/global-layout.cjs +1 -1
  32. package/dist/global-layout.d.ts +32 -2
  33. package/dist/global-layout.d.ts.map +1 -1
  34. package/dist/global-layout.js +179 -109
  35. package/dist/index.cjs +1 -1
  36. package/dist/index.d.ts +2 -1
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +526 -511
  39. package/dist/label.cjs +1 -1
  40. package/dist/label.d.ts +9 -0
  41. package/dist/label.d.ts.map +1 -1
  42. package/dist/label.js +26 -22
  43. package/dist/lib/spring-settle.cjs +1 -0
  44. package/dist/lib/spring-settle.d.ts +20 -0
  45. package/dist/lib/spring-settle.d.ts.map +1 -0
  46. package/dist/lib/spring-settle.js +4 -0
  47. package/dist/link.cjs +1 -1
  48. package/dist/link.d.ts +3 -2
  49. package/dist/link.d.ts.map +1 -1
  50. package/dist/link.js +22 -11
  51. package/dist/loading.cjs +1 -1
  52. package/dist/loading.d.ts +2 -1
  53. package/dist/loading.d.ts.map +1 -1
  54. package/dist/loading.js +106 -85
  55. package/dist/select.cjs +2 -2
  56. package/dist/select.d.ts +16 -1
  57. package/dist/select.d.ts.map +1 -1
  58. package/dist/select.js +112 -79
  59. package/dist/table.cjs +1 -1
  60. package/dist/table.d.ts +29 -0
  61. package/dist/table.d.ts.map +1 -1
  62. package/dist/table.js +2 -2
  63. package/dist/text-reveal-motion.cjs +1 -1
  64. package/dist/text-reveal-motion.d.ts.map +1 -1
  65. package/dist/text-reveal-motion.js +236 -219
  66. package/dist/typography.cjs +1 -1
  67. package/dist/typography.d.ts +20 -4
  68. package/dist/typography.d.ts.map +1 -1
  69. package/dist/typography.js +263 -228
  70. package/package.json +2 -14
  71. package/src/blocks/sidebar.tsx +11 -23
  72. package/src/components/alert.tsx +1 -4
  73. package/src/components/brand-illustration-motif.tsx +143 -0
  74. package/src/components/chart.tsx +632 -1
  75. package/src/components/combobox.tsx +47 -0
  76. package/src/{blocks → components}/data-table.tsx +270 -16
  77. package/src/components/field.tsx +31 -0
  78. package/src/components/global-layout.tsx +144 -5
  79. package/src/components/label.tsx +13 -1
  80. package/src/components/link.tsx +13 -1
  81. package/src/components/loading.tsx +71 -38
  82. package/src/components/select.tsx +82 -2
  83. package/src/components/table.tsx +31 -2
  84. package/src/components/text-reveal-motion.tsx +90 -64
  85. package/src/components/typography.tsx +74 -18
  86. package/src/index.ts +2 -1
  87. package/src/lib/spring-settle.ts +19 -0
  88. package/dist/blocks/data-table.cjs +0 -1
  89. package/dist/blocks/data-table.d.ts.map +0 -1
  90. package/dist/blocks/data-table.js +0 -654
package/dist/select.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),q=require("react"),C=require("@radix-ui/react-select"),d=require("@brightlocal/icons"),I=require("class-variance-authority"),a=require("@brightlocal/ui-components/lib/utils"),T=require("./lib/use-dev-warning.cjs"),O=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock");function g(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const _=g(q),o=g(C);function v({children:e,...r}){return t.jsx(o.Root,{"data-slot":"select",...r,children:e})}v.displayName="Select";function x(e){return t.jsx(o.Group,{"data-slot":"select-group",...e})}x.displayName="SelectGroup";function S(e){return t.jsx(o.Value,{"data-slot":"select-value",...e})}S.displayName="SelectValue";const D=I.cva(["relative flex w-full h-9 items-center justify-between gap-2","px-3 py-2","border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color]","bg-neutral-50 border-neutral-300","dark:bg-white/5 dark:border-white/15","text-sm font-normal font-sans text-foreground","[&>span]:block [&>span]:truncate","data-[placeholder]:text-muted-foreground","focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background","focus-visible:shadow-default","data-[state=open]:border-ring","disabled:cursor-not-allowed disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0"]);function h({className:e,children:r,placeholder:n,dataHook:s,error:c,selectLabel:u,...l}){const i=c||l["aria-invalid"]===!0||l["aria-invalid"]==="true",p=l["aria-required"]===!0||l["aria-required"]==="true",m=l["aria-label"]||u||n||"Select an option",k=i?"border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive":"";return t.jsxs(o.Trigger,{...l,"aria-invalid":i?"true":void 0,"aria-label":m,"aria-required":p?"true":void 0,className:a.cn(D(),k,e),"data-hook":s,"data-slot":"select-trigger",children:[r,t.jsx(o.Icon,{asChild:!0,children:t.jsx(d.ChevronDown,{className:"text-muted-foreground"})})]})}h.displayName="SelectTrigger";function y({className:e,children:r,position:n="popper",maxHeight:s,style:c,...u}){O.useOverlayPointerLock();const l=_.useRef(null);T.useDevWarning(()=>l.current?l.current.querySelectorAll('[data-slot="select-item"]').length>=100:!1,`Select contains many items. For large lists (100+), consider using <Combobox> which supports search and filtering.
2
- Import: import { Combobox } from "@brightlocal/ui-components/combobox"`,[r]);const i=a.cn("relative z-50 overflow-hidden","min-w-[8rem]","rounded-md border border-border bg-popover shadow-md","text-popover-foreground","max-h-[var(--radix-select-content-available-height)]","origin-[var(--radix-select-content-transform-origin)]",a.FLOATING_CONTENT_ANIMATION),p=n==="popper"&&a.cn("data-[side=bottom]:translate-y-1","data-[side=left]:-translate-x-1","data-[side=right]:translate-x-1","data-[side=top]:-translate-y-1"),m=s!==void 0?{...c,maxHeight:`min(${s}px, var(--radix-select-content-available-height))`}:c;return t.jsx(o.Portal,{children:t.jsxs(o.Content,{className:a.cn(i,p,e),"data-slot":"select-content",position:n,style:m,...u,children:[t.jsx(b,{}),t.jsx(o.Viewport,{ref:l,className:a.cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:r}),t.jsx(f,{})]})})}y.displayName="SelectContent";function j({className:e,...r}){return t.jsx(o.Label,{className:a.cn("text-muted-foreground px-2 py-1.5 text-xs font-medium",e),"data-slot":"select-label",...r})}j.displayName="SelectLabel";function w({className:e,children:r,...n}){const s=a.cn("relative flex w-full cursor-default select-none items-center gap-2","rounded py-1.5 pl-2 pr-8","text-sm font-normal leading-5 text-popover-foreground","focus:bg-accent focus:text-accent-foreground","hover:bg-accent/50 hover:text-accent-foreground","outline-none focus:outline-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0");return t.jsxs(o.Item,{className:a.cn(s,e),"data-slot":"select-item",...n,children:[t.jsx("span",{className:"absolute right-2 flex size-4 items-center justify-center",children:t.jsx(o.ItemIndicator,{children:t.jsx(d.Check,{})})}),t.jsx(o.ItemText,{children:r})]})}w.displayName="SelectItem";function N({className:e,...r}){return t.jsx(o.Separator,{className:a.cn("bg-border pointer-events-none -mx-1 my-1 h-px",e),"data-slot":"select-separator",...r})}N.displayName="SelectSeparator";function b({className:e,...r}){return t.jsx(o.ScrollUpButton,{className:a.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-up-button",...r,children:t.jsx(d.ChevronUp,{})})}b.displayName="SelectScrollUpButton";function f({className:e,...r}){return t.jsx(o.ScrollDownButton,{className:a.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-down-button",...r,children:t.jsx(d.ChevronDown,{})})}f.displayName="SelectScrollDownButton";exports.Select=v;exports.SelectContent=y;exports.SelectGroup=x;exports.SelectItem=w;exports.SelectLabel=j;exports.SelectScrollDownButton=f;exports.SelectScrollUpButton=b;exports.SelectSeparator=N;exports.SelectTrigger=h;exports.SelectValue=S;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),T=require("react"),R=require("@radix-ui/react-select"),b=require("@brightlocal/icons"),_=require("class-variance-authority"),l=require("@brightlocal/ui-components/lib/utils"),D=require("./lib/use-dev-warning.cjs"),B=require("@brightlocal/ui-components/hooks/use-overlay-pointer-lock");function y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const i=y(T),o=y(R);function j({children:e,onClose:t,onOpenChange:n,open:a,defaultOpen:u,...p}){const[s,f]=i.useState(u??!1),d=a!==void 0,c=d?a:s,m=i.useCallback(h=>{d||f(h),n?.(h)},[d,n]),g=i.useRef(t);i.useEffect(()=>{g.current=t},[t]);const v=i.useRef(c);return i.useEffect(()=>{v.current&&!c&&g.current?.(),v.current=c},[c]),i.useEffect(()=>()=>{v.current&&g.current?.()},[]),r.jsx(o.Root,{"data-slot":"select",defaultOpen:u,open:a,onOpenChange:m,...p,children:e})}j.displayName="Select";function w(e){return r.jsx(o.Group,{"data-slot":"select-group",...e})}w.displayName="SelectGroup";function N(e){return r.jsx(o.Value,{"data-slot":"select-value",...e})}N.displayName="SelectValue";const L=_.cva(["relative flex w-full h-9 items-center justify-between gap-2","px-3 py-2","border border-border rounded-sm outline-none transition-[border-color,box-shadow,background-color]","bg-neutral-50 border-neutral-300","dark:bg-white/5 dark:border-white/15","text-sm font-normal font-sans text-foreground","[&>span]:block [&>span]:truncate","data-[placeholder]:text-muted-foreground","focus-visible:outline-none focus-visible:border-ring dark:focus-visible:border-neutral-500 focus-visible:bg-background","focus-visible:shadow-default","data-[state=open]:border-ring","disabled:cursor-not-allowed disabled:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0"]);function k({className:e,children:t,placeholder:n,dataHook:a,error:u,selectLabel:p,...s}){const f=u||s["aria-invalid"]===!0||s["aria-invalid"]==="true",d=s["aria-required"]===!0||s["aria-required"]==="true",c=s["aria-label"]||p||n||"Select an option",m=f?"border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive":"";return r.jsxs(o.Trigger,{...s,"aria-invalid":f?"true":void 0,"aria-label":c,"aria-required":d?"true":void 0,className:l.cn(L(),m,e),"data-hook":a,"data-slot":"select-trigger",children:[t,r.jsx(o.Icon,{asChild:!0,children:r.jsx(b.ChevronDown,{className:"text-muted-foreground"})})]})}k.displayName="SelectTrigger";function C({className:e,children:t,position:n="popper",maxHeight:a,style:u,...p}){B.useOverlayPointerLock();const s=i.useRef(null);D.useDevWarning(()=>s.current?s.current.querySelectorAll('[data-slot="select-item"]').length>=100:!1,`Select contains many items. For large lists (100+), consider using <Combobox> which supports search and filtering.
2
+ Import: import { Combobox } from "@brightlocal/ui-components/combobox"`,[t]);const f=l.cn("relative z-50 overflow-hidden","min-w-[8rem]","rounded-md border border-border bg-popover shadow-md","text-popover-foreground","max-h-[var(--radix-select-content-available-height)]","origin-[var(--radix-select-content-transform-origin)]",l.FLOATING_CONTENT_ANIMATION),d=n==="popper"&&l.cn("data-[side=bottom]:translate-y-1","data-[side=left]:-translate-x-1","data-[side=right]:translate-x-1","data-[side=top]:-translate-y-1"),c=a!==void 0?{...u,maxHeight:`min(${a}px, var(--radix-select-content-available-height))`}:u;return r.jsx(o.Portal,{children:r.jsxs(o.Content,{className:l.cn(f,d,e),"data-slot":"select-content",position:n,style:c,...p,children:[r.jsx(x,{}),r.jsx(o.Viewport,{ref:s,className:l.cn("p-1",n==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:t}),r.jsx(S,{})]})})}C.displayName="SelectContent";function O({className:e,...t}){return r.jsx(o.Label,{className:l.cn("text-muted-foreground px-2 py-1.5 text-xs font-medium",e),"data-slot":"select-label",...t})}O.displayName="SelectLabel";function q({className:e,children:t,...n}){const a=l.cn("relative flex w-full cursor-default select-none items-center gap-2","rounded py-1.5 pl-2 pr-8","text-sm font-normal leading-5 text-popover-foreground","focus:bg-accent focus:text-accent-foreground","hover:bg-accent/50 hover:text-accent-foreground","outline-none focus:outline-none","data-[disabled]:pointer-events-none data-[disabled]:opacity-50","[&_svg]:pointer-events-none [&_svg]:shrink-0");return r.jsxs(o.Item,{className:l.cn(a,e),"data-slot":"select-item",...n,children:[r.jsx("span",{className:"absolute right-2 flex size-4 items-center justify-center",children:r.jsx(o.ItemIndicator,{children:r.jsx(b.Check,{})})}),r.jsx(o.ItemText,{children:t})]})}q.displayName="SelectItem";function I({className:e,...t}){return r.jsx(o.Separator,{className:l.cn("bg-border pointer-events-none -mx-1 my-1 h-px",e),"data-slot":"select-separator",...t})}I.displayName="SelectSeparator";function x({className:e,...t}){return r.jsx(o.ScrollUpButton,{className:l.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-up-button",...t,children:r.jsx(b.ChevronUp,{})})}x.displayName="SelectScrollUpButton";function S({className:e,...t}){return r.jsx(o.ScrollDownButton,{className:l.cn("flex cursor-default items-center justify-center py-1",e),"data-slot":"select-scroll-down-button",...t,children:r.jsx(b.ChevronDown,{})})}S.displayName="SelectScrollDownButton";exports.Select=j;exports.SelectContent=C;exports.SelectGroup=w;exports.SelectItem=q;exports.SelectLabel=O;exports.SelectScrollDownButton=S;exports.SelectScrollUpButton=x;exports.SelectSeparator=I;exports.SelectTrigger=k;exports.SelectValue=N;
package/dist/select.d.ts CHANGED
@@ -3,6 +3,21 @@ import * as SelectPrimitive from "@radix-ui/react-select";
3
3
  interface SelectProps extends React.ComponentProps<typeof SelectPrimitive.Root> {
4
4
  /** Children to render inside the select */
5
5
  children?: React.ReactNode;
6
+ /**
7
+ * Close-commit callback — fired once each time the dropdown actually
8
+ * closes, and guaranteed to fire **after** any pending `onValueChange` has
9
+ * been delivered. Designed for blur-based form validation — in React Hook
10
+ * Form's onBlur mode, pass `field.onBlur` here so validation runs against
11
+ * the committed value when the dropdown closes, keeping `onOpenChange`
12
+ * free for product logic.
13
+ *
14
+ * Fires only on resolved closes: a controlled consumer that vetoes a close
15
+ * request gets no callback, while a programmatic controlled close does
16
+ * fire it. Unmounting while open counts as a close. Note that Radix Select
17
+ * also closes the dropdown when the window loses focus or resizes — those
18
+ * closes fire this callback too.
19
+ */
20
+ onClose?: () => void;
6
21
  }
7
22
  interface SelectContentProps extends React.ComponentProps<typeof SelectPrimitive.Content> {
8
23
  /**
@@ -32,7 +47,7 @@ interface SelectContentProps extends React.ComponentProps<typeof SelectPrimitive
32
47
  * </Field>
33
48
  * ```
34
49
  */
35
- declare function Select({ children, ...props }: SelectProps): import("react/jsx-runtime").JSX.Element;
50
+ declare function Select({ children, onClose, onOpenChange, open: openProp, defaultOpen, ...props }: SelectProps): import("react/jsx-runtime").JSX.Element;
36
51
  declare namespace Select {
37
52
  var displayName: string;
38
53
  }
@@ -1 +1 @@
1
- {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,eAAe,MAAM,wBAAwB,CAAC;AAe1D,UAAU,WAAY,SAAQ,KAAK,CAAC,cAAc,CAChD,OAAO,eAAe,CAAC,IAAI,CAC5B;IACC,2CAA2C;IAC3C,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED,UAAU,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CACvD,OAAO,eAAe,CAAC,OAAO,CAC/B;IACC;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAMD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,iBAAS,MAAM,CAAC,EAAE,QAAQ,EAAE,GAAG,KAAK,EAAE,EAAE,WAAW,2CAMlD;kBANQ,MAAM;;;AAUf;;GAEG;AACH,iBAAS,WAAW,CAClB,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAG1D;kBAJQ,WAAW;;;AAQpB;;GAEG;AACH,iBAAS,WAAW,CAClB,KAAK,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,KAAK,CAAC,2CAG1D;kBAJQ,WAAW;;;AA6CpB,UAAU,kBAAmB,SAAQ,KAAK,CAAC,cAAc,CACvD,OAAO,eAAe,CAAC,OAAO,CAC/B;IACC,iDAAiD;IACjD,WAAW,CAAC,EAAE,M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ACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,cAAc,CAAC,2CAa7D;kBAhBQ,oBAAoB;;;AAoB7B;;GAEG;AACH,iBAAS,sBAAsB,CAAC,EAC9B,SAAS,EACT,GAAG,KAAK,EACT,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,eAAe,CAAC,gBAAgB,CAAC,2CAa/D;kBAhBQ,sBAAsB;;;AAoB/B,OAAO,EACL,MAAM,EACN,aAAa,EACb,WAAW,EACX,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,aAAa,EACb,WAAW,GACZ,CAAC;AAEF,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/select.js CHANGED
@@ -1,24 +1,57 @@
1
- import { jsx as t, jsxs as p } from "react/jsx-runtime";
2
- import * as h from "react";
1
+ import { jsx as t, jsxs as g } from "react/jsx-runtime";
2
+ import * as c from "react";
3
3
  import * as o from "@radix-ui/react-select";
4
- import { Check as x, ChevronDown as f, ChevronUp as S } from "@brightlocal/icons";
5
- import { cva as y } from "class-variance-authority";
6
- import { cn as a, FLOATING_CONTENT_ANIMATION as N } from "@brightlocal/ui-components/lib/utils";
7
- import { useDevWarning as w } from "./lib/use-dev-warning.js";
8
- import { useOverlayPointerLock as k } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
9
- function I({ children: e, ...r }) {
10
- return /* @__PURE__ */ t(o.Root, { "data-slot": "select", ...r, children: e });
4
+ import { Check as N, ChevronDown as S, ChevronUp as w } from "@brightlocal/icons";
5
+ import { cva as k } from "class-variance-authority";
6
+ import { cn as n, FLOATING_CONTENT_ANIMATION as C } from "@brightlocal/ui-components/lib/utils";
7
+ import { useDevWarning as I } from "./lib/use-dev-warning.js";
8
+ import { useOverlayPointerLock as R } from "@brightlocal/ui-components/hooks/use-overlay-pointer-lock";
9
+ function T({
10
+ children: e,
11
+ onClose: r,
12
+ onOpenChange: l,
13
+ open: s,
14
+ defaultOpen: d,
15
+ ...f
16
+ }) {
17
+ const [a, m] = c.useState(
18
+ d ?? !1
19
+ ), u = s !== void 0, i = u ? s : a, p = c.useCallback(
20
+ (h) => {
21
+ u || m(h), l?.(h);
22
+ },
23
+ [u, l]
24
+ ), b = c.useRef(r);
25
+ c.useEffect(() => {
26
+ b.current = r;
27
+ }, [r]);
28
+ const v = c.useRef(i);
29
+ return c.useEffect(() => {
30
+ v.current && !i && b.current?.(), v.current = i;
31
+ }, [i]), c.useEffect(() => () => {
32
+ v.current && b.current?.();
33
+ }, []), /* @__PURE__ */ t(
34
+ o.Root,
35
+ {
36
+ "data-slot": "select",
37
+ defaultOpen: d,
38
+ open: s,
39
+ onOpenChange: p,
40
+ ...f,
41
+ children: e
42
+ }
43
+ );
11
44
  }
12
- I.displayName = "Select";
13
- function C(e) {
45
+ T.displayName = "Select";
46
+ function O(e) {
14
47
  return /* @__PURE__ */ t(o.Group, { "data-slot": "select-group", ...e });
15
48
  }
16
- C.displayName = "SelectGroup";
17
- function T(e) {
49
+ O.displayName = "SelectGroup";
50
+ function j(e) {
18
51
  return /* @__PURE__ */ t(o.Value, { "data-slot": "select-value", ...e });
19
52
  }
20
- T.displayName = "SelectValue";
21
- const j = y([
53
+ j.displayName = "SelectValue";
54
+ const B = k([
22
55
  // Base layout
23
56
  "relative flex w-full h-9 items-center justify-between gap-2",
24
57
  "px-3 py-2",
@@ -42,51 +75,51 @@ const j = y([
42
75
  // Icon styles (chevron and custom icons)
43
76
  "[&_svg]:pointer-events-none [&_svg]:shrink-0"
44
77
  ]);
45
- function B({
78
+ function L({
46
79
  className: e,
47
80
  children: r,
48
81
  placeholder: l,
49
82
  dataHook: s,
50
- error: i,
51
- selectLabel: d,
52
- ...n
83
+ error: d,
84
+ selectLabel: f,
85
+ ...a
53
86
  }) {
54
- const c = i || n["aria-invalid"] === !0 || n["aria-invalid"] === "true", u = n["aria-required"] === !0 || n["aria-required"] === "true", m = n["aria-label"] || d || l || "Select an option", v = c ? "border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive" : "";
55
- return /* @__PURE__ */ p(
87
+ const m = d || a["aria-invalid"] === !0 || a["aria-invalid"] === "true", u = a["aria-required"] === !0 || a["aria-required"] === "true", i = a["aria-label"] || f || l || "Select an option", p = m ? "border-destructive-40 dark:border-destructive-40 focus-visible:border-destructive-40 dark:focus-visible:border-destructive-40 focus-visible:shadow-destructive data-[state=open]:border-destructive-40 dark:data-[state=open]:border-destructive-40 data-[state=open]:shadow-destructive" : "";
88
+ return /* @__PURE__ */ g(
56
89
  o.Trigger,
57
90
  {
58
- ...n,
59
- "aria-invalid": c ? "true" : void 0,
60
- "aria-label": m,
91
+ ...a,
92
+ "aria-invalid": m ? "true" : void 0,
93
+ "aria-label": i,
61
94
  "aria-required": u ? "true" : void 0,
62
- className: a(j(), v, e),
95
+ className: n(B(), p, e),
63
96
  "data-hook": s,
64
97
  "data-slot": "select-trigger",
65
98
  children: [
66
99
  r,
67
- /* @__PURE__ */ t(o.Icon, { asChild: !0, children: /* @__PURE__ */ t(f, { className: "text-muted-foreground" }) })
100
+ /* @__PURE__ */ t(o.Icon, { asChild: !0, children: /* @__PURE__ */ t(S, { className: "text-muted-foreground" }) })
68
101
  ]
69
102
  }
70
103
  );
71
104
  }
72
- B.displayName = "SelectTrigger";
73
- function L({
105
+ L.displayName = "SelectTrigger";
106
+ function _({
74
107
  className: e,
75
108
  children: r,
76
109
  position: l = "popper",
77
110
  maxHeight: s,
78
- style: i,
79
- ...d
111
+ style: d,
112
+ ...f
80
113
  }) {
81
- k();
82
- const n = h.useRef(null);
83
- w(
84
- () => n.current ? n.current.querySelectorAll('[data-slot="select-item"]').length >= 100 : !1,
114
+ R();
115
+ const a = c.useRef(null);
116
+ I(
117
+ () => a.current ? a.current.querySelectorAll('[data-slot="select-item"]').length >= 100 : !1,
85
118
  `Select contains many items. For large lists (100+), consider using <Combobox> which supports search and filtering.
86
119
  Import: import { Combobox } from "@brightlocal/ui-components/combobox"`,
87
120
  [r]
88
121
  );
89
- const c = a(
122
+ const m = n(
90
123
  // Base appearance
91
124
  "relative z-50 overflow-hidden",
92
125
  "min-w-[8rem]",
@@ -96,51 +129,51 @@ Import: import { Combobox } from "@brightlocal/ui-components/combobox"`,
96
129
  "max-h-[var(--radix-select-content-available-height)]",
97
130
  "origin-[var(--radix-select-content-transform-origin)]",
98
131
  // Animations
99
- N
100
- ), u = l === "popper" && a(
132
+ C
133
+ ), u = l === "popper" && n(
101
134
  "data-[side=bottom]:translate-y-1",
102
135
  "data-[side=left]:-translate-x-1",
103
136
  "data-[side=right]:translate-x-1",
104
137
  "data-[side=top]:-translate-y-1"
105
- ), m = s !== void 0 ? {
106
- ...i,
138
+ ), i = s !== void 0 ? {
139
+ ...d,
107
140
  maxHeight: `min(${s}px, var(--radix-select-content-available-height))`
108
- } : i;
109
- return /* @__PURE__ */ t(o.Portal, { children: /* @__PURE__ */ p(
141
+ } : d;
142
+ return /* @__PURE__ */ t(o.Portal, { children: /* @__PURE__ */ g(
110
143
  o.Content,
111
144
  {
112
- className: a(c, u, e),
145
+ className: n(m, u, e),
113
146
  "data-slot": "select-content",
114
147
  position: l,
115
- style: m,
116
- ...d,
148
+ style: i,
149
+ ...f,
117
150
  children: [
118
- /* @__PURE__ */ t(b, {}),
151
+ /* @__PURE__ */ t(x, {}),
119
152
  /* @__PURE__ */ t(
120
153
  o.Viewport,
121
154
  {
122
- ref: n,
123
- className: a(
155
+ ref: a,
156
+ className: n(
124
157
  "p-1",
125
158
  l === "popper" && "h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"
126
159
  ),
127
160
  children: r
128
161
  }
129
162
  ),
130
- /* @__PURE__ */ t(g, {})
163
+ /* @__PURE__ */ t(y, {})
131
164
  ]
132
165
  }
133
166
  ) });
134
167
  }
135
- L.displayName = "SelectContent";
136
- function _({
168
+ _.displayName = "SelectContent";
169
+ function q({
137
170
  className: e,
138
171
  ...r
139
172
  }) {
140
173
  return /* @__PURE__ */ t(
141
174
  o.Label,
142
175
  {
143
- className: a(
176
+ className: n(
144
177
  "text-muted-foreground px-2 py-1.5 text-xs font-medium",
145
178
  e
146
179
  ),
@@ -149,13 +182,13 @@ function _({
149
182
  }
150
183
  );
151
184
  }
152
- _.displayName = "SelectLabel";
153
- function q({
185
+ q.displayName = "SelectLabel";
186
+ function D({
154
187
  className: e,
155
188
  children: r,
156
189
  ...l
157
190
  }) {
158
- const s = a(
191
+ const s = n(
159
192
  // Base layout
160
193
  "relative flex w-full cursor-default select-none items-center gap-2",
161
194
  "rounded py-1.5 pl-2 pr-8",
@@ -170,79 +203,79 @@ function q({
170
203
  // Icon styles
171
204
  "[&_svg]:pointer-events-none [&_svg]:shrink-0"
172
205
  );
173
- return /* @__PURE__ */ p(
206
+ return /* @__PURE__ */ g(
174
207
  o.Item,
175
208
  {
176
- className: a(s, e),
209
+ className: n(s, e),
177
210
  "data-slot": "select-item",
178
211
  ...l,
179
212
  children: [
180
- /* @__PURE__ */ t("span", { className: "absolute right-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ t(o.ItemIndicator, { children: /* @__PURE__ */ t(x, {}) }) }),
213
+ /* @__PURE__ */ t("span", { className: "absolute right-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ t(o.ItemIndicator, { children: /* @__PURE__ */ t(N, {}) }) }),
181
214
  /* @__PURE__ */ t(o.ItemText, { children: r })
182
215
  ]
183
216
  }
184
217
  );
185
218
  }
186
- q.displayName = "SelectItem";
187
- function D({
219
+ D.displayName = "SelectItem";
220
+ function E({
188
221
  className: e,
189
222
  ...r
190
223
  }) {
191
224
  return /* @__PURE__ */ t(
192
225
  o.Separator,
193
226
  {
194
- className: a("bg-border pointer-events-none -mx-1 my-1 h-px", e),
227
+ className: n("bg-border pointer-events-none -mx-1 my-1 h-px", e),
195
228
  "data-slot": "select-separator",
196
229
  ...r
197
230
  }
198
231
  );
199
232
  }
200
- D.displayName = "SelectSeparator";
201
- function b({
233
+ E.displayName = "SelectSeparator";
234
+ function x({
202
235
  className: e,
203
236
  ...r
204
237
  }) {
205
238
  return /* @__PURE__ */ t(
206
239
  o.ScrollUpButton,
207
240
  {
208
- className: a(
241
+ className: n(
209
242
  "flex cursor-default items-center justify-center py-1",
210
243
  e
211
244
  ),
212
245
  "data-slot": "select-scroll-up-button",
213
246
  ...r,
214
- children: /* @__PURE__ */ t(S, {})
247
+ children: /* @__PURE__ */ t(w, {})
215
248
  }
216
249
  );
217
250
  }
218
- b.displayName = "SelectScrollUpButton";
219
- function g({
251
+ x.displayName = "SelectScrollUpButton";
252
+ function y({
220
253
  className: e,
221
254
  ...r
222
255
  }) {
223
256
  return /* @__PURE__ */ t(
224
257
  o.ScrollDownButton,
225
258
  {
226
- className: a(
259
+ className: n(
227
260
  "flex cursor-default items-center justify-center py-1",
228
261
  e
229
262
  ),
230
263
  "data-slot": "select-scroll-down-button",
231
264
  ...r,
232
- children: /* @__PURE__ */ t(f, {})
265
+ children: /* @__PURE__ */ t(S, {})
233
266
  }
234
267
  );
235
268
  }
236
- g.displayName = "SelectScrollDownButton";
269
+ y.displayName = "SelectScrollDownButton";
237
270
  export {
238
- I as Select,
239
- L as SelectContent,
240
- C as SelectGroup,
241
- q as SelectItem,
242
- _ as SelectLabel,
243
- g as SelectScrollDownButton,
244
- b as SelectScrollUpButton,
245
- D as SelectSeparator,
246
- B as SelectTrigger,
247
- T as SelectValue
271
+ T as Select,
272
+ _ as SelectContent,
273
+ O as SelectGroup,
274
+ D as SelectItem,
275
+ q as SelectLabel,
276
+ y as SelectScrollDownButton,
277
+ x as SelectScrollUpButton,
278
+ E as SelectSeparator,
279
+ L as SelectTrigger,
280
+ j as SelectValue
248
281
  };
package/dist/table.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),N=require("react"),f=require("class-variance-authority"),r=require("@brightlocal/ui-components/lib/utils");function j(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const l=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(t,a,l.get?l:{enumerable:!0,get:()=>e[a]})}}return t.default=e,Object.freeze(t)}const s=j(N),k=f.cva("align-middle bg-transparent text-foreground text-sm font-normal leading-normal break-words",{variants:{size:{default:"h-12 p-2",md:"h-16 p-2",lg:"h-24 p-2"},align:{left:"text-left",right:"text-right",center:"text-center"}},defaultVariants:{size:"default",align:"left"}}),R=f.cva("h-10 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal hover:bg-muted break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",{variants:{align:{left:"text-left",right:"text-right",center:"text-center"}},defaultVariants:{align:"left"}}),u=s.forwardRef(({className:e,dataHook:t,trackingEl:a,trackingLabel:l,layout:d="auto",minWidth:n,scrollRegionLabel:i,style:c,...b},w)=>o.jsx("div",{className:r.cn("relative w-full overflow-x-auto",n&&"focus-visible:shadow-default rounded-md outline-none"),"data-slot":"table-container",...n?{role:"region","aria-label":i??"Scrollable table",tabIndex:0}:void 0,children:o.jsx("table",{ref:w,className:r.cn("w-full caption-bottom text-sm",d==="fixed"&&"table-fixed",e),"data-hook":t,"data-slot":"table","data-tracking-el":a,"data-tracking-label":l,style:{minWidth:n,...c},...b})}));u.displayName="Table";const m=s.forwardRef(({className:e,dataHook:t,...a},l)=>o.jsx("thead",{ref:l,className:r.cn(e),"data-hook":t,"data-slot":"table-header",...a}));m.displayName="TableHeader";const g=s.forwardRef(({className:e,dataHook:t,...a},l)=>o.jsx("tbody",{ref:l,className:r.cn(e),"data-hook":t,"data-slot":"table-body",...a}));g.displayName="TableBody";const p=s.forwardRef(({className:e,dataHook:t,...a},l)=>o.jsx("tfoot",{ref:l,className:r.cn("bg-muted/50",e),"data-hook":t,"data-slot":"table-footer",...a}));p.displayName="TableFooter";const x=s.forwardRef(({className:e,dataHook:t,...a},l)=>o.jsx("tr",{ref:l,className:r.cn("data-[state=selected]:bg-muted transition-colors duration-150 ease-in-out",e),"data-hook":t,"data-slot":"table-row",...a}));x.displayName="TableRow";const T=s.forwardRef(({className:e,dataHook:t,align:a,width:l,minWidth:d,style:n,scope:i="col",...c},b)=>o.jsx("th",{ref:b,className:r.cn(R({align:a}),e),"data-hook":t,"data-slot":"table-head",scope:i,style:{width:l,minWidth:d,...n},...c}));T.displayName="TableHead";const h=s.forwardRef(({className:e,dataHook:t,size:a,align:l,width:d,minWidth:n,style:i,...c},b)=>o.jsx("td",{ref:b,className:r.cn(k({size:a,align:l}),e),"data-hook":t,"data-slot":"table-cell",style:{width:d,minWidth:n,...i},...c}));h.displayName="TableCell";const y=s.forwardRef(({className:e,dataHook:t,...a},l)=>o.jsx("caption",{ref:l,className:r.cn("caption-bottom py-4",e),"data-hook":t,"data-slot":"table-caption",...a}));y.displayName="TableCaption";exports.Table=u;exports.TableBody=g;exports.TableCaption=y;exports.TableCell=h;exports.TableFooter=p;exports.TableHead=T;exports.TableHeader=m;exports.TableRow=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),N=require("react"),f=require("class-variance-authority"),r=require("@brightlocal/ui-components/lib/utils");function j(a){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const e in a)if(e!=="default"){const l=Object.getOwnPropertyDescriptor(a,e);Object.defineProperty(t,e,l.get?l:{enumerable:!0,get:()=>a[e]})}}return t.default=a,Object.freeze(t)}const s=j(N),k=f.cva("align-middle bg-transparent text-foreground text-sm font-normal leading-normal break-words",{variants:{size:{default:"h-12 p-2",md:"h-16 p-2",lg:"h-24 p-2"},align:{left:"text-left",right:"text-right",center:"text-center"}},defaultVariants:{size:"default",align:"left"}}),R=f.cva("h-12 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",{variants:{align:{left:"text-left",right:"text-right",center:"text-center"}},defaultVariants:{align:"left"}}),u=s.forwardRef(({className:a,dataHook:t,trackingEl:e,trackingLabel:l,layout:d="auto",minWidth:n,scrollRegionLabel:i,style:c,...b},w)=>o.jsx("div",{className:r.cn("relative w-full overflow-x-auto",n&&"focus-visible:shadow-default rounded-md outline-none"),"data-slot":"table-container",...n?{role:"region","aria-label":i??"Scrollable table",tabIndex:0}:void 0,children:o.jsx("table",{ref:w,className:r.cn("w-full caption-bottom text-sm",d==="fixed"&&"table-fixed",a),"data-hook":t,"data-slot":"table","data-tracking-el":e,"data-tracking-label":l,style:{minWidth:n,...c},...b})}));u.displayName="Table";const m=s.forwardRef(({className:a,dataHook:t,...e},l)=>o.jsx("thead",{ref:l,className:r.cn("bg-muted",a),"data-hook":t,"data-slot":"table-header",...e}));m.displayName="TableHeader";const g=s.forwardRef(({className:a,dataHook:t,...e},l)=>o.jsx("tbody",{ref:l,className:r.cn(a),"data-hook":t,"data-slot":"table-body",...e}));g.displayName="TableBody";const p=s.forwardRef(({className:a,dataHook:t,...e},l)=>o.jsx("tfoot",{ref:l,className:r.cn("bg-muted/50",a),"data-hook":t,"data-slot":"table-footer",...e}));p.displayName="TableFooter";const x=s.forwardRef(({className:a,dataHook:t,...e},l)=>o.jsx("tr",{ref:l,className:r.cn("data-[state=selected]:bg-muted transition-colors duration-150 ease-in-out",a),"data-hook":t,"data-slot":"table-row",...e}));x.displayName="TableRow";const T=s.forwardRef(({className:a,dataHook:t,align:e,width:l,minWidth:d,style:n,scope:i="col",...c},b)=>o.jsx("th",{ref:b,className:r.cn(R({align:e}),a),"data-hook":t,"data-slot":"table-head",scope:i,style:{width:l,minWidth:d,...n},...c}));T.displayName="TableHead";const h=s.forwardRef(({className:a,dataHook:t,size:e,align:l,width:d,minWidth:n,style:i,...c},b)=>o.jsx("td",{ref:b,className:r.cn(k({size:e,align:l}),a),"data-hook":t,"data-slot":"table-cell",style:{width:d,minWidth:n,...i},...c}));h.displayName="TableCell";const y=s.forwardRef(({className:a,dataHook:t,...e},l)=>o.jsx("caption",{ref:l,className:r.cn("caption-bottom py-4",a),"data-hook":t,"data-slot":"table-caption",...e}));y.displayName="TableCaption";exports.Table=u;exports.TableBody=g;exports.TableCaption=y;exports.TableCell=h;exports.TableFooter=p;exports.TableHead=T;exports.TableHeader=m;exports.TableRow=x;
package/dist/table.d.ts CHANGED
@@ -121,12 +121,41 @@ interface TableCellProps extends Omit<React.ComponentProps<"td">, "align">, Vari
121
121
  align?: "left" | "right" | "center";
122
122
  }
123
123
  declare const TableCell: React.ForwardRefExoticComponent<Omit<TableCellProps, "ref"> & React.RefAttributes<HTMLTableCellElement>>;
124
+ /**
125
+ * Props for the TableCaption component.
126
+ * @deprecated Name the table with a heading and `aria-labelledby` instead. TableCaption will be removed in the next major version.
127
+ */
124
128
  interface TableCaptionProps extends React.ComponentProps<"caption"> {
125
129
  /**
126
130
  * Data hook for automated testing
127
131
  */
128
132
  dataHook?: string;
129
133
  }
134
+ /**
135
+ * @deprecated Name the table with a heading and `aria-labelledby` instead.
136
+ *
137
+ * A `<caption>` is placed solely by the CSS `caption-side` property, never by
138
+ * where it sits among the table's children, so it cannot participate in
139
+ * composition. It also supplies the table's accessible name while contributing
140
+ * nothing to the document outline, and it scrolls horizontally with the table
141
+ * when `minWidth` is set.
142
+ *
143
+ * ```tsx
144
+ * // Before
145
+ * <Table dataHook="transactions">
146
+ * <TableCaption>Recent transactions</TableCaption>
147
+ * ...
148
+ * </Table>
149
+ *
150
+ * // After
151
+ * <TypographyH3 dataHook="transactions-heading" id="transactions-heading">
152
+ * Recent transactions
153
+ * </TypographyH3>
154
+ * <Table aria-labelledby="transactions-heading" dataHook="transactions">
155
+ * ...
156
+ * </Table>
157
+ * ```
158
+ */
130
159
  declare const TableCaption: React.ForwardRefExoticComponent<Omit<TableCaptionProps, "ref"> & React.RefAttributes<HTMLTableCaptionElement>>;
131
160
  export { Table, TableHeader, TableBody, TableFooter, TableHead, TableRow, TableCell, TableCaption, };
132
161
  export type { TableProps, TableHeaderProps, TableBodyProps, TableFooterProps, TableRowProps, TableHeadProps, TableCellProps, TableCaptionProps, };
@@ -1 +1 @@
1
- {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../../src/components/table.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAQlE,QAAA,MAAM,iBAAiB;;;8EAoBtB,CAAC;AAEF,QAAA,MAAM,iBAAiB;;8EActB,CAAC;AAMF,UAAU,UAAW,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;IACxD;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;;OASG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC1B;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,QAAA,MAAM,KAAK,kGA+CV,CAAC;AAQF,UAAU,gBAAiB,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;IAC9D;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,WAAW,+GAUhB,CAAC;AAQF,UAAU,cAAe,SAAQ,KAAK,CAAC,cAAc,CAAC,OAAO,CAAC;IAC5D;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,QAAA,MAAM,SAAS,6GAUd,CAAC;AAQF,UAAU,gBAAiB,SAAQ,KAAK,CAAC,cAAc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SAAQ,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC;IACjE;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,QAAA,MAAM,YAAY,gHAWhB,CAAC;AAQH,OAAO,EACL,KAAK,EACL,WAAW,EACX,SAAS,EACT,WAAW,EACX,SAAS,EACT,QAAQ,EACR,SAAS,EACT,YAAY,GACb,CAAC;AAEF,YAAY,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,cAAc,EACd,iBAAiB,GAClB,CAAC"}
package/dist/table.js CHANGED
@@ -23,7 +23,7 @@ const u = c(
23
23
  }
24
24
  }
25
25
  ), p = c(
26
- "h-10 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal hover:bg-muted break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",
26
+ "h-12 p-2 align-middle text-muted-foreground text-sm font-medium leading-normal break-words outline-none focus-visible:shadow-default transition-[background-color,box-shadow] duration-150 ease-in-out",
27
27
  {
28
28
  variants: {
29
29
  align: {
@@ -86,7 +86,7 @@ const h = r.forwardRef(
86
86
  "thead",
87
87
  {
88
88
  ref: o,
89
- className: d(a),
89
+ className: d("bg-muted", a),
90
90
  "data-hook": t,
91
91
  "data-slot": "table-header",
92
92
  ...e
@@ -1 +1 @@
1
- "use strict";var kt=Object.create;var ht=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var Et=Object.getOwnPropertyNames;var Ft=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var $t=(t,n,e,l)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of Et(n))!Xt.call(t,i)&&i!==e&&ht(t,i,{get:()=>n[i],enumerable:!(l=It(n,i))||l.enumerable});return t};var qt=(t,n,e)=>(e=t!=null?kt(Ft(t)):{},$t(n||!t||!t.__esModule?ht(e,"default",{value:t,enumerable:!0}):e,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react/jsx-runtime"),o=require("react"),W=require("framer-motion"),Ot=require("@brightlocal/ui-components/lib/utils"),Tt=require("./hooks/use-prefers-reduced-motion.cjs");function _t(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const l=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(n,e,l.get?l:{enumerable:!0,get:()=>t[e]})}}return n.default=t,Object.freeze(n)}const gt=_t(o),yt="M250 500C388.071 500 500 388.071 500 250C500 111.929 388.071 0 250 0C111.929 0 0 111.929 0 250C0 388.071 111.929 500 250 500Z",Ct="M492.425 259.355C332.265 293.145 293.145 332.265 259.355 492.425C257.225 502.525 242.775 502.525 240.645 492.425C206.855 332.265 167.735 293.145 7.575 259.355C-2.525 257.225 -2.525 242.775 7.575 240.645C167.735 206.855 206.855 167.735 240.645 7.575C242.775 -2.525 257.225 -2.525 259.355 7.575C293.145 167.735 332.265 206.855 492.425 240.645C502.525 242.775 502.525 257.225 492.425 259.355Z",wt="M258.366 5.58795L296.379 97.3854C298.509 102.526 304.729 104.546 309.47 101.636L394.177 49.7215C401.057 45.5112 409.598 51.7117 407.708 59.5523L384.506 156.16C383.206 161.571 387.046 166.861 392.596 167.301L491.645 175.092C499.685 175.722 502.945 185.763 496.815 191.003L421.259 255.528C417.029 259.138 417.029 265.679 421.259 269.299L496.815 333.824C502.945 339.065 499.685 349.106 491.645 349.736L392.596 357.526C387.046 357.966 383.206 363.257 384.506 368.667L407.708 465.275C409.588 473.116 401.047 479.326 394.177 475.106L309.47 423.192C304.729 420.282 298.509 422.302 296.379 427.442L258.366 519.24C255.275 526.69 244.725 526.69 241.634 519.24L203.621 427.442C201.491 422.302 195.271 420.282 190.53 423.192L105.823 475.106C98.9428 479.316 90.4021 473.116 92.2922 465.275L115.494 368.667C116.794 363.257 112.954 357.966 107.403 357.526L8.35543 349.736C0.314784 349.106 -2.94548 339.065 3.18502 333.824L78.7411 269.299C82.9715 265.689 82.9715 259.148 78.7411 255.528L3.18502 191.003C-2.94548 185.763 0.314784 175.722 8.35543 175.092L107.403 167.301C112.954 166.861 116.794 161.571 115.494 156.16L92.2922 59.5523C90.4121 51.7117 98.9528 45.5012 105.823 49.7215L190.53 101.636C195.271 104.546 201.491 102.526 203.621 97.3854L241.634 5.58795C244.725 -1.86265 255.275 -1.86265 258.366 5.58795Z",D=t=>t<0?0:t>1?1:t,Dt=[yt,Ct,wt,yt,wt,Ct],zt=30,Ht=15,Nt=typeof navigator<"u"&&typeof navigator.hardwareConcurrency=="number"&&navigator.hardwareConcurrency<=4;function Ut(t,n,e){let l=!1,i=null;const h={ballX:0,clipRight:100,rotate:0,pathD:""};function B(){l=!1,t.style.transform=`translateX(${h.ballX}px)`,i&&(i.style.clipPath=`inset(0 ${h.clipRight}% 0 0)`),n.style.transform=`rotate(${h.rotate}deg)`,e.setAttribute("d",h.pathD)}function z(O,Z,G,J){h.ballX=O,h.clipRight=Z,h.rotate=G,h.pathD=J,l||(l=!0,requestAnimationFrame(B))}return z.setItem=O=>{i=O},z}function bt(t,n){return new Promise(e=>{const l=performance.now();function i(){n.cancelled||performance.now()-l>=t?e():requestAnimationFrame(i)}requestAnimationFrame(i)})}const xt=gt.forwardRef(({className:t,dataHook:n,holdTime:e=1300,shimmer:l=!0,gradientFrom:i="var(--loading-gradient-from)",gradientTo:h="var(--loading-gradient-to)",loadingLabel:B,trackingEl:z,trackingLabel:O,children:Z,...G},J)=>{const f=Dt,K=.8,Q=180,V=24,Y=1,H=Tt.usePrefersReducedMotion(),ot=o.useId(),ct=o.useMemo(()=>`text-reveal-gradient-${ot.replace(/:/g,"")}`,[ot]),tt=o.useRef(null),et=o.useRef(null),nt=o.useRef(null),rt=o.useRef(null),lt=o.useRef(null),st=o.useRef(null),at=o.useRef(null),j=o.useRef([]),F=gt.Children.toArray(Z),[Rt,Mt]=o.useState({widths:[],ballSize:0}),{widths:y,ballSize:u}=Rt,vt=o.useCallback(a=>r=>{j.current[a]=r},[]);o.useEffect(()=>{if(j.current.length===0||!j.current[0])return;let a=!1;function r(){if(a)return;const C=[];let M=32;for(let w=0;w<F.length;w++){const v=j.current[w];if(v&&(C[w]=v.scrollWidth,w===0)){const X=v.firstElementChild??v,s=parseFloat(getComputedStyle(X).fontSize)||16;M=Math.round(s*1.5)}}Mt({widths:C,ballSize:M})}return document.fonts.ready.then(()=>{a||requestAnimationFrame(r)}),()=>{a=!0}},[F.length]),o.useEffect(()=>{if(H)return;const a=lt.current;if(!a)return;const r=a;let C,M=null;const w=.12+Math.random()*.06,v=.08+Math.random()*.04,X=Math.random()*Math.PI*2,s=Math.random()*Math.PI*2;let T=-1/0;function N(g){M||(M=g);const d=(g-M)/1e3,m=Math.sin(d*w+X)*Math.PI+Math.sin(d*v+s)*.5;if(Math.abs(m-T)>.01){T=m;const k=Math.cos(m),_=Math.sin(m);r.setAttribute("x1",`${50+45*k}%`),r.setAttribute("y1",`${50+45*_}%`),r.setAttribute("x2",`${50-45*k}%`),r.setAttribute("y2",`${50-45*_}%`)}C=requestAnimationFrame(N)}return C=requestAnimationFrame(N),()=>cancelAnimationFrame(C)},[H]);function Lt(a){a.style.opacity="1",W.animate(0,1,{duration:1.2,ease:[.25,1,.5,1],onUpdate:r=>{a.style.transform=`translateX(${-100+r*200}%)`},onComplete:()=>{a.style.opacity="0"}})}o.useEffect(()=>{if(!nt.current||!rt.current||!tt.current||!et.current||!st.current||!at.current||y.length===0||u===0)return;const a=nt.current,r=rt.current,C=tt.current,M=et.current,w=st.current,v=at.current;function X(g){const d=`${g}px`;w.style.width=d,v.style.width=d}if(H){a.setAttribute("d",f[0]),r.style.opacity="1";const g=j.current[0];g&&(g.style.opacity="1",g.style.clipPath="none"),X(y[0]??0);const d=u*.25,m=(y[0]??0)+d+u/2;C.style.transform=`translateX(${m}px)`;return}const s={cancelled:!1},T=u*.25;async function N(){const{interpolate:g}=await import("flubber");if(s.cancelled)return;const d=Nt?Ht:zt,m=[];for(let L=0;L<f.length;L++){const S=g(f[L],f[(L+1)%f.length]),A=[];for(let P=0;P<=d;P++)A.push(S(P/d));m.push(A)}const k=Ut(C,r,a);r.style.opacity="1";let _=0,b=0,I=0;for(;!s.cancelled;){const L=_%F.length,S=y[L]??0;X(S);const A=-(T+u/2),P=S+T+u/2,ut=P-A,ft=j.current[L];if(!ft)break;k.setItem(ft);for(let c=0;c<F.length;c++){const x=j.current[c];x&&(x.style.opacity=c===L?"1":"0",x.style.clipPath="inset(0 100% 0 0)")}const At=m[b%f.length],U=360,dt=I;if(await new Promise(c=>{if(s.cancelled){c();return}const x=W.animate(A,P,{type:"spring",stiffness:Q*K,damping:V,mass:Y,onUpdate:R=>{if(s.cancelled){x.stop(),c();return}const E=D((R-A)/ut),$=S>0?100-D(R/S)*100:100,q=Math.round(E*d);k(R,$,dt+E*U,At[q])},onComplete:()=>{I=dt+U,b=(b+1)%f.length,c()}})}),s.cancelled)break;if(l&&Lt(M),e>0){const c=performance.now(),x=P;for(;!s.cancelled&&performance.now()-c<e&&(await bt(300,s),!(s.cancelled||performance.now()-c>=e));){const R=(b+1)%f.length,E=m[b%f.length],$=I,q=I+360;await W.animate(0,1,{type:"spring",stiffness:30,damping:9,mass:.5,onUpdate:mt=>{const jt=Math.round(D(mt)*d);k(x,0,$+mt*(q-$),E[jt])}}),I=q,b=R}}if(s.cancelled)break;const Pt=m[b%f.length],pt=I;if(await new Promise(c=>{if(s.cancelled){c();return}const x=W.animate(P,A,{type:"spring",stiffness:Q*K,damping:V,mass:Y,onUpdate:R=>{if(s.cancelled){x.stop(),c();return}const E=D(1-(R-A)/ut),$=S>0?100-D(R/S)*100:100,q=Math.round(E*d);k(R,$,pt-E*U,Pt[q])},onComplete:()=>{I=pt-U,b=(b+1)%f.length,c()}})}),s.cancelled)break;await bt(300,s),_++}}return N(),()=>{s.cancelled=!0}},[y,u,F.length,H,K,e,l,Q,V,Y,f]);const it=o.useMemo(()=>y.length>0?Math.max(...y):0,[y]),St=y.length>0&&u>0;return p.jsx("div",{ref:J,className:Ot.cn("relative inline-flex items-center",t),"data-hook":n,"data-slot":"text-reveal","data-tracking-el":z,"data-tracking-label":O,style:{opacity:St?1:0,transition:"opacity 0.4s ease-out"},...G,children:p.jsxs("div",{ref:st,className:"relative flex items-center",style:{width:it||void 0,transition:"width 0.3s ease-out"},children:[p.jsxs("span",{ref:at,className:"relative inline-block overflow-hidden",style:{width:it||void 0,transition:"width 0.3s ease-out"},children:[F.map((a,r)=>p.jsx("span",{ref:vt(r),style:{display:"block",whiteSpace:"nowrap",opacity:0,clipPath:"inset(0 100% 0 0)",willChange:"clip-path",...r>0?{position:"absolute",top:0,left:0}:{}},children:a},r)),p.jsx("div",{ref:et,className:"pointer-events-none absolute inset-0",style:{opacity:0,transform:"translateX(-100%)",willChange:"transform",background:"linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--background) 40%, transparent) 40%, color-mix(in srgb, var(--background) 70%, transparent) 50%, color-mix(in srgb, var(--background) 40%, transparent) 60%, transparent 100%)"}})]}),p.jsx("div",{ref:tt,className:"absolute",style:{left:-u/2,top:"50%",marginTop:-u/2,width:u,height:u,transform:"translateX(0px)",willChange:"transform"},children:p.jsxs("svg",{"aria-label":B??"Loading","data-slot":"text-reveal-ball",fill:"none",height:u,role:"img",style:{overflow:"visible"},viewBox:"-30 -30 560 560",width:u,xmlns:"http://www.w3.org/2000/svg",children:[p.jsx("defs",{children:p.jsxs("linearGradient",{ref:lt,id:ct,children:[p.jsx("stop",{offset:"-20%",stopColor:i}),p.jsx("stop",{offset:"120%",stopColor:h})]})}),p.jsx("g",{ref:rt,style:{opacity:0,transformOrigin:"250px 250px",willChange:"transform"},children:p.jsx("path",{ref:nt,d:f[0],fill:`url(#${ct})`})})]})})]})})});xt.displayName="TextRevealMotion";exports.TextRevealMotion=xt;
1
+ "use strict";var Tt=Object.create;var yt=Object.defineProperty;var It=Object.getOwnPropertyDescriptor;var $t=Object.getOwnPropertyNames;var qt=Object.getPrototypeOf,Xt=Object.prototype.hasOwnProperty;var Dt=(t,r,n,d)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of $t(r))!Xt.call(t,c)&&c!==n&&yt(t,c,{get:()=>r[c],enumerable:!(d=It(r,c))||d.enumerable});return t};var _t=(t,r,n)=>(n=t!=null?Tt(qt(t)):{},Dt(r||!t||!t.__esModule?yt(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const f=require("react/jsx-runtime"),o=require("react"),B=require("framer-motion"),Ft=require("@brightlocal/ui-components/lib/utils"),zt=require("./hooks/use-prefers-reduced-motion.cjs"),Ct=require("./lib/spring-settle.cjs");function Nt(t){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const d=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,d.get?d:{enumerable:!0,get:()=>t[n]})}}return r.default=t,Object.freeze(r)}const bt=Nt(o),wt="M250 500C388.071 500 500 388.071 500 250C500 111.929 388.071 0 250 0C111.929 0 0 111.929 0 250C0 388.071 111.929 500 250 500Z",Rt="M492.425 259.355C332.265 293.145 293.145 332.265 259.355 492.425C257.225 502.525 242.775 502.525 240.645 492.425C206.855 332.265 167.735 293.145 7.575 259.355C-2.525 257.225 -2.525 242.775 7.575 240.645C167.735 206.855 206.855 167.735 240.645 7.575C242.775 -2.525 257.225 -2.525 259.355 7.575C293.145 167.735 332.265 206.855 492.425 240.645C502.525 242.775 502.525 257.225 492.425 259.355Z",xt="M258.366 5.58795L296.379 97.3854C298.509 102.526 304.729 104.546 309.47 101.636L394.177 49.7215C401.057 45.5112 409.598 51.7117 407.708 59.5523L384.506 156.16C383.206 161.571 387.046 166.861 392.596 167.301L491.645 175.092C499.685 175.722 502.945 185.763 496.815 191.003L421.259 255.528C417.029 259.138 417.029 265.679 421.259 269.299L496.815 333.824C502.945 339.065 499.685 349.106 491.645 349.736L392.596 357.526C387.046 357.966 383.206 363.257 384.506 368.667L407.708 465.275C409.588 473.116 401.047 479.326 394.177 475.106L309.47 423.192C304.729 420.282 298.509 422.302 296.379 427.442L258.366 519.24C255.275 526.69 244.725 526.69 241.634 519.24L203.621 427.442C201.491 422.302 195.271 420.282 190.53 423.192L105.823 475.106C98.9428 479.316 90.4021 473.116 92.2922 465.275L115.494 368.667C116.794 363.257 112.954 357.966 107.403 357.526L8.35543 349.736C0.314784 349.106 -2.94548 339.065 3.18502 333.824L78.7411 269.299C82.9715 265.689 82.9715 259.148 78.7411 255.528L3.18502 191.003C-2.94548 185.763 0.314784 175.722 8.35543 175.092L107.403 167.301C112.954 166.861 116.794 161.571 115.494 156.16L92.2922 59.5523C90.4121 51.7117 98.9528 45.5012 105.823 49.7215L190.53 101.636C195.271 104.546 201.491 102.526 203.621 97.3854L241.634 5.58795C244.725 -1.86265 255.275 -1.86265 258.366 5.58795Z",F=t=>t<0?0:t>1?1:t,Ot=[wt,Rt,xt,wt,xt,Rt];function Ut(t,r,n,d){let c=!1,$=null;const g={ballX:0,clipRight:100,rotate:0,pathD:""};function H(){c=!1,t.style.transform=`translateX(${g.ballX}px)`,$&&($.style.clipPath=`inset(0 ${g.clipRight}% 0 0)`),r.style.transform=`rotate(${g.rotate}deg)`,d?.setAttribute("gradientTransform",`rotate(${-g.rotate} 0.5 0.5)`),n.setAttribute("d",g.pathD)}function z(q,W,Z,p){g.ballX=q,g.clipRight=W,g.rotate=Z,g.pathD=p,c||(c=!0,requestAnimationFrame(H))}return z.setItem=q=>{$=q},z}function Mt(t,r){return new Promise(n=>{const d=performance.now();function c(){r.cancelled||performance.now()-d>=t?n():requestAnimationFrame(c)}requestAnimationFrame(c)})}const St=bt.forwardRef(({className:t,dataHook:r,holdTime:n=1300,shimmer:d=!0,gradientFrom:c="var(--loading-gradient-from)",gradientTo:$="var(--loading-gradient-to)",loadingLabel:g,trackingEl:H,trackingLabel:z,children:q,...W},Z)=>{const p=Ot,G=.8,J=180,K=24,Q=1,N=zt.usePrefersReducedMotion(),lt=o.useId(),ct=o.useMemo(()=>`text-reveal-gradient-${lt.replace(/:/g,"")}`,[lt]),V=o.useRef(null),Y=o.useRef(null),tt=o.useRef(null),et=o.useRef(null),nt=o.useRef(null),rt=o.useRef(null),st=o.useRef(null),E=o.useRef([]),j=bt.Children.toArray(q),[Lt,At]=o.useState({widths:[],ballSize:0}),{widths:b,ballSize:i}=Lt,vt=o.useCallback(a=>s=>{E.current[a]=s},[]);o.useEffect(()=>{if(E.current.length===0||!E.current[0])return;let a=!1;function s(){if(a)return;const w=[];let S=32;for(let R=0;R<j.length;R++){const L=E.current[R];if(L&&(w[R]=L.scrollWidth,R===0)){const k=L.firstElementChild??L,e=parseFloat(getComputedStyle(k).fontSize)||16;S=Math.round(e*1.5)}}At({widths:w,ballSize:S})}return document.fonts.ready.then(()=>{a||requestAnimationFrame(s)}),()=>{a=!0}},[j.length]),o.useEffect(()=>{if(N)return;const a=nt.current;if(!a)return;const s=a;let w,S=null;const R=.12+Math.random()*.06,L=.08+Math.random()*.04,k=Math.random()*Math.PI*2,e=Math.random()*Math.PI*2;let X=-1/0;function O(y){S||(S=y);const m=(y-S)/1e3,u=-Math.PI/4+Math.sin(m*R+k)*.5+Math.sin(m*L+e)*.25;if(Math.abs(u-X)>.01){X=u;const D=Math.cos(u),h=Math.sin(u);s.setAttribute("x1",`${50+45*D}%`),s.setAttribute("y1",`${50+45*h}%`),s.setAttribute("x2",`${50-45*D}%`),s.setAttribute("y2",`${50-45*h}%`)}w=requestAnimationFrame(O)}return w=requestAnimationFrame(O),()=>cancelAnimationFrame(w)},[N]);function Et(a){a.style.opacity="1",B.animate(0,1,{duration:1.2,ease:[.25,1,.5,1],onUpdate:s=>{a.style.transform=`translateX(${-100+s*200}%)`},onComplete:()=>{a.style.opacity="0"}})}o.useEffect(()=>{if(!tt.current||!et.current||!V.current||!Y.current||!rt.current||!st.current||b.length===0||i===0)return;const a=tt.current,s=et.current,w=V.current,S=Y.current,R=rt.current,L=st.current;function k(y){const m=`${y}px`;R.style.width=m,L.style.width=m}if(N){a.setAttribute("d",p[0]),s.style.opacity="1";const y=E.current[0];y&&(y.style.opacity="1",y.style.clipPath="none"),k(b[0]??0);const m=i*.25,u=(b[0]??0)+m+i/2;w.style.transform=`translateX(${u}px)`;return}const e={cancelled:!1},X=i*.25;async function O(){const{interpolate:y}=await import("flubber");if(e.cancelled)return;const m=[];for(let A=0;A<p.length;A++)m.push(y(p[A],p[(A+1)%p.length]));const u=Ut(w,s,a,nt.current);s.style.opacity="1";let D=0,h=0,x=0;for(;!e.cancelled;){const A=D%j.length,P=b[A]??0;k(P);const T=-(X+i/2),_=P+X+i/2,ut=_-T,ft=E.current[A];if(!ft)break;u.setItem(ft);for(let l=0;l<j.length;l++){const C=E.current[l];C&&(C.style.opacity=l===A?"1":"0",C.style.clipPath="inset(0 100% 0 0)")}const dt=m[h],U=360,pt=x;if(await new Promise(l=>{if(e.cancelled){l();return}const C=B.animate(T,_,{type:"spring",stiffness:J*G,damping:K,mass:Q,onUpdate:M=>{if(e.cancelled){C.stop(),l();return}const v=F((M-T)/ut),I=P>0?100-F(M/P)*100:100;u(M,I,pt+v*U,dt(v))},onComplete:()=>{x=pt+U,h=(h+1)%p.length,e.cancelled||u(_,0,x,dt(1)),l()}})}),e.cancelled)break;if(d&&Et(S),n>0){const l=performance.now(),C=_;for(;!e.cancelled&&performance.now()-l<n&&(await Mt(300,e),!(e.cancelled||performance.now()-l>=n));){const M=(h+1)%p.length,v=m[h],I=x,at=x+360;await new Promise(ot=>{if(e.cancelled){ot();return}const kt=B.animate(0,1+Ct.SETTLE_REST_DELTA,{type:"spring",stiffness:30,damping:9,mass:.5,restDelta:Ct.SETTLE_REST_DELTA,onUpdate:Pt=>{if(e.cancelled){kt.stop(),ot();return}const gt=F(Pt);u(C,0,I+gt*(at-I),v(gt))},onComplete:ot})}),e.cancelled||u(C,0,at,v(1)),x=at,h=M}}if(e.cancelled)break;const mt=m[h],ht=x;if(await new Promise(l=>{if(e.cancelled){l();return}const C=B.animate(_,T,{type:"spring",stiffness:J*G,damping:K,mass:Q,onUpdate:M=>{if(e.cancelled){C.stop(),l();return}const v=F(1-(M-T)/ut),I=P>0?100-F(M/P)*100:100;u(M,I,ht-v*U,mt(v))},onComplete:()=>{x=ht-U,h=(h+1)%p.length,e.cancelled||u(T,100,x,mt(1)),l()}})}),e.cancelled)break;await Mt(300,e),D++}}return O(),()=>{e.cancelled=!0}},[b,i,j.length,N,G,n,d,J,K,Q,p]);const it=o.useMemo(()=>b.length>0?Math.max(...b):0,[b]),jt=b.length>0&&i>0;return f.jsx("div",{ref:Z,className:Ft.cn("relative inline-flex items-center",t),"data-hook":r,"data-slot":"text-reveal","data-tracking-el":H,"data-tracking-label":z,style:{opacity:jt?1:0,transition:"opacity 0.4s ease-out"},...W,children:f.jsxs("div",{ref:rt,className:"relative flex items-center",style:{width:it||void 0,transition:"width 0.3s ease-out"},children:[f.jsxs("span",{ref:st,className:"relative inline-block overflow-hidden",style:{width:it||void 0,transition:"width 0.3s ease-out"},children:[j.map((a,s)=>f.jsx("span",{ref:vt(s),style:{display:"block",whiteSpace:"nowrap",opacity:0,clipPath:"inset(0 100% 0 0)",willChange:"clip-path",...s>0?{position:"absolute",top:0,left:0}:{}},children:a},s)),f.jsx("div",{ref:Y,className:"pointer-events-none absolute inset-0",style:{opacity:0,transform:"translateX(-100%)",willChange:"transform",background:"linear-gradient(90deg, transparent 0%, color-mix(in srgb, var(--background) 40%, transparent) 40%, color-mix(in srgb, var(--background) 70%, transparent) 50%, color-mix(in srgb, var(--background) 40%, transparent) 60%, transparent 100%)"}})]}),f.jsx("div",{ref:V,className:"absolute",style:{left:-i/2,top:"50%",marginTop:-i/2,width:i,height:i,transform:"translateX(0px)",willChange:"transform"},children:f.jsxs("svg",{"aria-label":g??"Loading","data-slot":"text-reveal-ball",fill:"none",height:i,role:"img",style:{overflow:"visible"},viewBox:"-30 -30 560 560",width:i,xmlns:"http://www.w3.org/2000/svg",children:[f.jsx("defs",{children:f.jsxs("linearGradient",{ref:nt,id:ct,x1:"81.8%",x2:"18.2%",y1:"18.2%",y2:"81.8%",children:[f.jsx("stop",{offset:"-60%",stopColor:c}),f.jsx("stop",{offset:"120%",stopColor:$})]})}),f.jsx("g",{ref:et,style:{opacity:0,transformOrigin:"250px 250px",willChange:"transform"},children:f.jsx("path",{ref:tt,d:p[0],fill:`url(#${ct})`})})]})})]})})});St.displayName="TextRevealMotion";exports.TextRevealMotion=St;
@@ -1 +1 @@
1
- {"version":3,"file":"text-reveal-motion.d.ts","sourceRoot":"","sources":["../../src/components/text-reveal-motion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAmI/B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EACrC,UAAU,CACX;IACC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAMD;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,8FAsgBrB,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"text-reveal-motion.d.ts","sourceRoot":"","sources":["../../src/components/text-reveal-motion.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA4H/B;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,qBAAsB,SAAQ,IAAI,CACjD,KAAK,CAAC,wBAAwB,CAAC,KAAK,CAAC,EACrC,UAAU,CACX;IACC;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;;;;;;;OAQG;IACH,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAMD;;;;;;GAMG;AACH,QAAA,MAAM,gBAAgB,8FAuiBrB,CAAC;AAIF,OAAO,EAAE,gBAAgB,EAAE,CAAC"}