@brightlocal/ui-components 2.10.0 → 2.11.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 (58) hide show
  1. package/README.md +3 -1
  2. package/component-meta.json +41 -9
  3. package/dist/badge.cjs +1 -1
  4. package/dist/badge.d.ts.map +1 -1
  5. package/dist/badge.js +42 -25
  6. package/dist/blocks/sidebar.cjs +1 -1
  7. package/dist/blocks/sidebar.d.ts +1 -3
  8. package/dist/blocks/sidebar.d.ts.map +1 -1
  9. package/dist/blocks/sidebar.js +46 -49
  10. package/dist/button.cjs +1 -1
  11. package/dist/button.js +25 -25
  12. package/dist/card.cjs +1 -1
  13. package/dist/card.d.ts +10 -1
  14. package/dist/card.d.ts.map +1 -1
  15. package/dist/card.js +85 -82
  16. package/dist/carousel.cjs +1 -1
  17. package/dist/carousel.d.ts +13 -1
  18. package/dist/carousel.d.ts.map +1 -1
  19. package/dist/carousel.js +196 -150
  20. package/dist/command.cjs +1 -1
  21. package/dist/command.d.ts +101 -1
  22. package/dist/command.d.ts.map +1 -1
  23. package/dist/command.js +383 -119
  24. package/dist/hooks/use-breakpoint.cjs +1 -1
  25. package/dist/hooks/use-breakpoint.d.ts.map +1 -1
  26. package/dist/hooks/use-breakpoint.js +10 -10
  27. package/dist/index.cjs +1 -1
  28. package/dist/index.d.ts +1 -0
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +402 -391
  31. package/dist/input-chip.cjs +1 -1
  32. package/dist/input-chip.d.ts +1 -4
  33. package/dist/input-chip.d.ts.map +1 -1
  34. package/dist/input-chip.js +163 -170
  35. package/dist/map.cjs +1 -0
  36. package/dist/map.d.ts +192 -0
  37. package/dist/map.d.ts.map +1 -0
  38. package/dist/map.js +250 -0
  39. package/dist/sonner.cjs +1 -1
  40. package/dist/sonner.d.ts.map +1 -1
  41. package/dist/sonner.js +32 -30
  42. package/dist/tabs.cjs +1 -1
  43. package/dist/tabs.d.ts +4 -0
  44. package/dist/tabs.d.ts.map +1 -1
  45. package/dist/tabs.js +101 -52
  46. package/package.json +3 -3
  47. package/src/blocks/sidebar.tsx +21 -26
  48. package/src/components/badge.tsx +22 -5
  49. package/src/components/button.tsx +13 -13
  50. package/src/components/card.tsx +35 -19
  51. package/src/components/carousel.tsx +101 -9
  52. package/src/components/command.tsx +637 -16
  53. package/src/components/input-chip.tsx +102 -65
  54. package/src/components/map.tsx +574 -0
  55. package/src/components/sonner.tsx +9 -3
  56. package/src/components/tabs.tsx +118 -22
  57. package/src/hooks/use-breakpoint.ts +2 -3
  58. package/src/index.ts +1 -0
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const w=require("react/jsx-runtime"),F=require("react"),q=require("class-variance-authority"),D=require("@brightlocal/ui-components/lib/utils"),E=require("@brightlocal/ui-components/chip");function N(s){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const n in s)if(n!=="default"){const a=Object.getOwnPropertyDescriptor(s,n);Object.defineProperty(f,n,a.get?a:{enumerable:!0,get:()=>s[n]})}}return f.default=s,Object.freeze(f)}const u=N(F),S=u.createContext(null);function V(){const s=u.useContext(S);if(!s)throw new Error("InputChip components must be used within an <InputChip>");return s}function O({value:s,defaultValue:f=[],onValueChange:n,disabled:a=!1,allowDuplicates:h=!1,children:d}){const[o,i]=u.useState(f),[l,v]=u.useState(""),[b,I]=u.useState(-1),t=u.useRef(null),e=u.useRef([]),c=s!==void 0,r=c?s:o;u.useEffect(()=>{e.current.length>r.length&&(e.current.length=r.length),b>=r.length&&I(-1)},[r.length,b]);const g=u.useCallback(C=>{c||i(C),n?.(C)},[c,n]),R=u.useCallback(C=>{if(a)return;const m=C.trim();m&&(h||!r.includes(m))&&(g([...r,m]),v(""))},[r,g,h,a]),y=u.useCallback(C=>{a||g(r.filter((m,p)=>p!==C))},[r,g,a]),x=u.useMemo(()=>({value:r,onValueChange:g,inputValue:l,setInputValue:v,disabled:a,addItem:R,removeItem:y,inputRef:t,focusedChipIndex:b,setFocusedChipIndex:I,chipRefs:e}),[r,g,l,v,a,R,y,t,b,I,e]);return w.jsx(S.Provider,{value:x,children:d})}const j=q.cva(["relative flex w-full flex-wrap items-center gap-1","min-h-9 rounded-sm border border-input bg-background","px-3 py-2","has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background","has-[:focus-visible]:shadow-default","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50","transition-[color,box-shadow,border-color]","duration-150","ease-in-out"],{variants:{error:{true:["border-destructive-40","has-[:focus-visible]:border-destructive-40 has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{error:!1}}),$=["flex-1 min-w-20","bg-transparent","border-0 outline-none","text-base font-sans","text-foreground","placeholder:text-muted-foreground","focus:outline-none focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50"],A=u.forwardRef(({className:s,error:f=!1,dataHook:n,trackingEl:a,trackingLabel:h,placeholder:d,inputId:o,"aria-label":i,"aria-labelledby":l,children:v,...b},I)=>{const{value:t,inputValue:e,setInputValue:c,disabled:r,addItem:g,inputRef:R,setFocusedChipIndex:y,chipRefs:x}=V(),C=p=>{c(p.target.value)},m=p=>{if(p.key==="Enter"&&e.trim()&&(p.preventDefault(),g(e)),p.key==="ArrowLeft"&&!e&&t.length>0){p.preventDefault();const k=t.length-1;y(k),x.current[k]?.focus()}if(p.key==="Backspace"&&!e&&t.length>0){p.preventDefault();const k=t.length-1;y(k),x.current[k]?.focus()}};return w.jsxs("div",{ref:I,className:D.cn(j({error:f}),s),"data-hook":n,"data-slot":"input-chip","data-tracking-el":a,"data-tracking-label":h,...b,children:[v,w.jsx("input",{ref:R,"aria-label":i,"aria-labelledby":l,className:D.cn($),"data-slot":"input-chip-input",disabled:r,id:o,placeholder:d,type:"text",value:e,onChange:C,onKeyDown:m})]})});A.displayName="InputChipInput";function B({className:s,dataHookPrefix:f="chip"}){const{value:n,disabled:a,removeItem:h,inputRef:d,setFocusedChipIndex:o,chipRefs:i}=V(),l=u.useRef(null);u.useEffect(()=>{if(l.current!==null){if(l.current==="input")d.current?.focus();else{const t=l.current;t>=0&&t<n.length?i.current[t]?.focus():n.length>0?i.current[n.length-1]?.focus():d.current?.focus()}l.current=null}},[n.length,d,i]);const v=(t,e)=>{if(!a)switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&(o(e-1),i.current[e-1]?.focus());break;case"ArrowRight":t.preventDefault(),e<n.length-1?(o(e+1),i.current[e+1]?.focus()):(o(-1),d.current?.focus());break;case"Backspace":case"Delete":{t.preventDefault();const c=n.length-1;if(c===0)o(-1),l.current="input",h(e);else if(e>=c){const r=c-1;o(r),l.current=r,h(e)}else o(e),l.current=e,h(e);break}case"Home":t.preventDefault(),n.length>0&&(o(0),i.current[0]?.focus());break;case"End":t.preventDefault(),o(-1),d.current?.focus();break}},b=t=>{o(t)},I=t=>{const e=t.relatedTarget;e&&(e.closest('[data-slot="chip"]')!==null||e.dataset.slot==="input-chip-input")||o(-1)};return n.length===0?null:w.jsx("div",{className:D.cn("contents",s),"data-slot":"input-chip-items",children:n.map((t,e)=>w.jsx(E.Chip,{ref:c=>{i.current[e]=c},"aria-label":`${t}, press Delete to remove`,dataHook:`${f}-${e}`,disabled:a,role:"group",tabIndex:-1,onBlur:I,onFocus:()=>b(e),onKeyDown:c=>v(c,e),onRemove:()=>h(e),children:t},`${t}-${e}`))})}const K=j;exports.InputChip=O;exports.InputChipInput=A;exports.InputChipItems=B;exports.inputChipInputVariants=j;exports.inputChipVariants=K;exports.useInputChipContext=V;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const v=require("react/jsx-runtime"),$=require("react"),B=require("class-variance-authority"),j=require("@brightlocal/ui-components/lib/utils"),K=require("@brightlocal/ui-components/chip");function L(n){const f=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const o in n)if(o!=="default"){const u=Object.getOwnPropertyDescriptor(n,o);Object.defineProperty(f,o,u.get?u:{enumerable:!0,get:()=>n[o]})}}return f.default=n,Object.freeze(f)}const t=L($),A=t.createContext(null),F=t.createContext(null),O=t.createContext(null);function E(){const n=t.useContext(A);if(!n)throw new Error("InputChip components must be used within an <InputChip>");return n}function S(){const n=t.useContext(F);if(!n)throw new Error("InputChip components must be used within an <InputChip>");return n}function P(){const n=t.useContext(O);if(!n)throw new Error("InputChip components must be used within an <InputChip>");return n}function T(){const n=E(),{value:f,disabled:o}=S(),{inputValue:u,focusedChipIndex:s}=P();return{...n,value:f,disabled:o,inputValue:u,focusedChipIndex:s}}function _({value:n,defaultValue:f=[],onValueChange:o,disabled:u=!1,allowDuplicates:s=!1,children:h}){const[l,m]=t.useState(f),[i,w]=t.useState(""),[C,x]=t.useState(-1),r=t.useRef(null),e=t.useRef([]),c=n!==void 0,a=c?n:l,b=t.useRef(a),g=t.useRef(o),R=t.useRef(u);t.useLayoutEffect(()=>{b.current=a,g.current=o,R.current=u}),t.useEffect(()=>{e.current.length>a.length&&(e.current.length=a.length),C>=a.length&&x(-1)},[a.length,C]);const p=t.useCallback(y=>{c||m(y),g.current?.(y)},[c]),k=t.useCallback(y=>{if(R.current)return;const V=y.trim();V&&(s||!b.current.includes(V))&&(p([...b.current,V]),w(""))},[s,p]),D=t.useCallback(y=>{R.current||p(b.current.filter((V,N)=>N!==y))},[p]),d=t.useMemo(()=>({onValueChange:p,setInputValue:w,addItem:k,removeItem:D,inputRef:r,setFocusedChipIndex:x,chipRefs:e}),[p,k,D]),I=t.useMemo(()=>({value:a,disabled:u}),[a,u]),M=t.useMemo(()=>({inputValue:i,focusedChipIndex:C}),[i,C]);return v.jsx(A.Provider,{value:d,children:v.jsx(F.Provider,{value:I,children:v.jsx(O.Provider,{value:M,children:h})})})}const H=B.cva(["relative flex w-full flex-wrap items-center gap-1","min-h-9 rounded-sm border border-input bg-background","px-3 py-2","has-[:focus-visible]:border-ring has-[:focus-visible]:bg-background","has-[:focus-visible]:shadow-default","has-[:disabled]:cursor-not-allowed has-[:disabled]:opacity-50","transition-[color,box-shadow,border-color]","duration-150","ease-in-out"],{variants:{error:{true:["border-destructive-40","has-[:focus-visible]:border-destructive-40 has-[:focus-visible]:shadow-destructive"],false:""}},defaultVariants:{error:!1}}),W=["flex-1 min-w-20","bg-transparent","border-0 outline-none","text-base font-sans","text-foreground","placeholder:text-muted-foreground","focus:outline-none focus-visible:outline-none","disabled:cursor-not-allowed disabled:opacity-50"],q=t.forwardRef(({className:n,error:f=!1,dataHook:o,trackingEl:u,trackingLabel:s,placeholder:h,inputId:l,"aria-label":m,"aria-labelledby":i,children:w,...C},x)=>{const{setInputValue:r,addItem:e,inputRef:c,setFocusedChipIndex:a,chipRefs:b}=E(),{value:g,disabled:R}=S(),{inputValue:p}=P(),k=d=>{r(d.target.value)},D=d=>{if(d.key==="Enter"&&p.trim()&&(d.preventDefault(),e(p)),d.key==="ArrowLeft"&&!p&&g.length>0){d.preventDefault();const I=g.length-1;a(I),b.current[I]?.focus()}if(d.key==="Backspace"&&!p&&g.length>0){d.preventDefault();const I=g.length-1;a(I),b.current[I]?.focus()}};return v.jsxs("div",{ref:x,className:j.cn(H({error:f}),n),"data-hook":o,"data-slot":"input-chip","data-tracking-el":u,"data-tracking-label":s,...C,children:[w,v.jsx("input",{ref:c,"aria-label":m,"aria-labelledby":i,className:j.cn(W),"data-slot":"input-chip-input",disabled:R,id:l,placeholder:h,type:"text",value:p,onChange:k,onKeyDown:D})]})});q.displayName="InputChipInput";function z({className:n,dataHookPrefix:f="chip"}){const{removeItem:o,inputRef:u,setFocusedChipIndex:s,chipRefs:h}=E(),{value:l,disabled:m}=S(),i=t.useRef(null);t.useEffect(()=>{if(i.current!==null){if(i.current==="input")u.current?.focus();else{const r=i.current;r>=0&&r<l.length?h.current[r]?.focus():l.length>0?h.current[l.length-1]?.focus():u.current?.focus()}i.current=null}},[l.length,u,h]);const w=(r,e)=>{if(!m)switch(r.key){case"ArrowLeft":r.preventDefault(),e>0&&(s(e-1),h.current[e-1]?.focus());break;case"ArrowRight":r.preventDefault(),e<l.length-1?(s(e+1),h.current[e+1]?.focus()):(s(-1),u.current?.focus());break;case"Backspace":case"Delete":{r.preventDefault();const c=l.length-1;if(c===0)s(-1),i.current="input",o(e);else if(e>=c){const a=c-1;s(a),i.current=a,o(e)}else s(e),i.current=e,o(e);break}case"Home":r.preventDefault(),l.length>0&&(s(0),h.current[0]?.focus());break;case"End":r.preventDefault(),s(-1),u.current?.focus();break}},C=r=>{s(r)},x=r=>{const e=r.relatedTarget;e&&(e.closest('[data-slot="chip"]')!==null||e.dataset.slot==="input-chip-input")||s(-1)};return l.length===0?null:v.jsx("div",{className:j.cn("contents",n),"data-slot":"input-chip-items",children:l.map((r,e)=>v.jsx(K.Chip,{ref:c=>{h.current[e]=c},"aria-label":`${r}, press Delete to remove`,dataHook:`${f}-${e}`,disabled:m,role:"group",tabIndex:-1,onBlur:x,onFocus:()=>C(e),onKeyDown:c=>w(c,e),onRemove:()=>o(e),children:r},`${r}-${e}`))})}exports.InputChip=_;exports.InputChipInput=q;exports.InputChipItems=z;exports.useInputChipContext=T;
@@ -110,8 +110,5 @@ export interface InputChipItemsProps {
110
110
  * Must be used within an InputChip component.
111
111
  */
112
112
  declare function InputChipItems({ className, dataHookPrefix, }: InputChipItemsProps): import("react/jsx-runtime").JSX.Element | null;
113
- declare const inputChipVariants: (props?: ({
114
- error?: boolean | null | undefined;
115
- } & import('class-variance-authority/types').ClassProp) | undefined) => string;
116
- export { InputChip, InputChipInput, InputChipItems, inputChipVariants, inputChipInputVariants, useInputChipContext, };
113
+ export { InputChip, InputChipInput, InputChipItems, useInputChipContext };
117
114
  //# sourceMappingURL=input-chip.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"input-chip.d.ts","sourceRoot":"","sources":["../../src/components/input-chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AASlE,UAAU,qB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QAAgB,EAChB,eAAuB,EACvB,QAAQ,GACT,EAAE,cAAc,2CAsFhB;AAMD,QAAA,MAAM,sBAAsB;;8EA+B3B,CAAC;AAkBF;;GAEG;AACH,MAAM,WAAW,mBACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,EACtD,YAAY,CAAC,OAAO,sBAAsB,CAAC;IAC7C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,QAAA,MAAM,cAAc,4FAmFnB,CAAC;AAOF,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,cAAuB,GACxB,EAAE,mBAAmB,kDAqJrB;AAOD,QAAA,MAAM,iBAAiB;;8EAAyB,CAAC;AAEjD,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,sBAAsB,EACtB,mBAAmB,GACpB,CAAC"}
1
+ {"version":3,"file":"input-chip.d.ts","sourceRoot":"","sources":["../../src/components/input-chip.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B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iB,EACjB,aAAa,EAAE,uBAAuB,EACtC,QAAgB,EAChB,eAAuB,EACvB,QAAQ,GACT,EAAE,cAAc,2CA4FhB;AAMD,QAAA,MAAM,sBAAsB;;8EA+B3B,CAAC;AAkBF;;GAEG;AACH,MAAM,WAAW,mBACf,SACE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,UAAU,CAAC,EACtD,YAAY,CAAC,OAAO,sBAAsB,CAAC;IAC7C;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED;;;GAGG;AACH,QAAA,MAAM,cAAc,4FA6EnB,CAAC;AAOF,MAAM,WAAW,mBAAmB;IAClC,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iCAAiC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,iBAAS,cAAc,CAAC,EACtB,SAAS,EACT,cAAuB,GACxB,EAAE,mBAAmB,kDAgJrB;AAMD,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,cAAc,EAAE,mBAAmB,EAAE,CAAC"}
@@ -1,77 +1,89 @@
1
- import { jsx as D, jsxs as E } from "react/jsx-runtime";
2
- import * as r from "react";
3
- import { cva as $ } from "class-variance-authority";
4
- import { cn as x } from "@brightlocal/ui-components/lib/utils";
5
- import { Chip as B } from "@brightlocal/ui-components/chip";
6
- const V = r.createContext(
7
- null
8
- );
1
+ import { jsx as k, jsxs as M } from "react/jsx-runtime";
2
+ import * as t from "react";
3
+ import { cva as P } from "class-variance-authority";
4
+ import { cn as E } from "@brightlocal/ui-components/lib/utils";
5
+ import { Chip as j } from "@brightlocal/ui-components/chip";
6
+ const $ = t.createContext(null), B = t.createContext(null), K = t.createContext(null);
9
7
  function F() {
10
- const f = r.useContext(V);
11
- if (!f)
8
+ const r = t.useContext($);
9
+ if (!r)
10
+ throw new Error("InputChip components must be used within an <InputChip>");
11
+ return r;
12
+ }
13
+ function A() {
14
+ const r = t.useContext(B);
15
+ if (!r)
16
+ throw new Error("InputChip components must be used within an <InputChip>");
17
+ return r;
18
+ }
19
+ function L() {
20
+ const r = t.useContext(K);
21
+ if (!r)
12
22
  throw new Error("InputChip components must be used within an <InputChip>");
13
- return f;
23
+ return r;
14
24
  }
15
- function T({
16
- value: f,
17
- defaultValue: I = [],
18
- onValueChange: s,
19
- disabled: l = !1,
20
- allowDuplicates: p = !1,
21
- children: h
25
+ function G() {
26
+ const r = F(), { value: C, disabled: p } = A(), { inputValue: s, focusedChipIndex: u } = L();
27
+ return {
28
+ ...r,
29
+ value: C,
30
+ disabled: p,
31
+ inputValue: s,
32
+ focusedChipIndex: u
33
+ };
34
+ }
35
+ function J({
36
+ value: r,
37
+ defaultValue: C = [],
38
+ onValueChange: p,
39
+ disabled: s = !1,
40
+ allowDuplicates: u = !1,
41
+ children: f
22
42
  }) {
23
- const [o, c] = r.useState(I), [u, m] = r.useState(""), [d, v] = r.useState(-1), t = r.useRef(null), e = r.useRef([]), a = f !== void 0, n = a ? f : o;
24
- r.useEffect(() => {
25
- e.current.length > n.length && (e.current.length = n.length), d >= n.length && v(-1);
26
- }, [n.length, d]);
27
- const g = r.useCallback(
28
- (b) => {
29
- a || c(b), s?.(b);
43
+ const [c, g] = t.useState(C), [l, I] = t.useState(""), [d, w] = t.useState(-1), n = t.useRef(null), e = t.useRef([]), o = r !== void 0, a = o ? r : c, b = t.useRef(a), m = t.useRef(p), R = t.useRef(s);
44
+ t.useLayoutEffect(() => {
45
+ b.current = a, m.current = p, R.current = s;
46
+ }), t.useEffect(() => {
47
+ e.current.length > a.length && (e.current.length = a.length), d >= a.length && w(-1);
48
+ }, [a.length, d]);
49
+ const i = t.useCallback(
50
+ (x) => {
51
+ o || g(x), m.current?.(x);
30
52
  },
31
- [a, s]
32
- ), y = r.useCallback(
33
- (b) => {
34
- if (l) return;
35
- const C = b.trim();
36
- C && (p || !n.includes(C)) && (g([...n, C]), m(""));
53
+ [o]
54
+ ), y = t.useCallback(
55
+ (x) => {
56
+ if (R.current) return;
57
+ const V = x.trim();
58
+ V && (u || !b.current.includes(V)) && (i([...b.current, V]), I(""));
37
59
  },
38
- [n, g, p, l]
39
- ), k = r.useCallback(
40
- (b) => {
41
- l || g(n.filter((C, i) => i !== b));
60
+ [u, i]
61
+ ), D = t.useCallback(
62
+ (x) => {
63
+ R.current || i(b.current.filter((V, S) => S !== x));
42
64
  },
43
- [n, g, l]
44
- ), R = r.useMemo(
65
+ [i]
66
+ ), h = t.useMemo(
45
67
  () => ({
46
- value: n,
47
- onValueChange: g,
48
- inputValue: u,
49
- setInputValue: m,
50
- disabled: l,
68
+ onValueChange: i,
69
+ setInputValue: I,
51
70
  addItem: y,
52
- removeItem: k,
53
- inputRef: t,
54
- focusedChipIndex: d,
55
- setFocusedChipIndex: v,
71
+ removeItem: D,
72
+ inputRef: n,
73
+ setFocusedChipIndex: w,
56
74
  chipRefs: e
57
75
  }),
58
- [
59
- n,
60
- g,
61
- u,
62
- m,
63
- l,
64
- y,
65
- k,
66
- t,
67
- d,
68
- v,
69
- e
70
- ]
76
+ [i, y, D]
77
+ ), v = t.useMemo(
78
+ () => ({ value: a, disabled: s }),
79
+ [a, s]
80
+ ), N = t.useMemo(
81
+ () => ({ inputValue: l, focusedChipIndex: d }),
82
+ [l, d]
71
83
  );
72
- return /* @__PURE__ */ D(V.Provider, { value: R, children: h });
84
+ return /* @__PURE__ */ k($.Provider, { value: h, children: /* @__PURE__ */ k(B.Provider, { value: v, children: /* @__PURE__ */ k(K.Provider, { value: N, children: f }) }) });
73
85
  }
74
- const A = $(
86
+ const H = P(
75
87
  [
76
88
  // Layout
77
89
  "relative flex w-full flex-wrap items-center gap-1",
@@ -102,7 +114,7 @@ const A = $(
102
114
  error: !1
103
115
  }
104
116
  }
105
- ), K = [
117
+ ), T = [
106
118
  // Reset and base
107
119
  "flex-1 min-w-20",
108
120
  "bg-transparent",
@@ -116,70 +128,61 @@ const A = $(
116
128
  "focus:outline-none focus-visible:outline-none",
117
129
  // Disabled
118
130
  "disabled:cursor-not-allowed disabled:opacity-50"
119
- ], N = r.forwardRef(
131
+ ], W = t.forwardRef(
120
132
  ({
121
- className: f,
122
- error: I = !1,
123
- dataHook: s,
124
- trackingEl: l,
125
- trackingLabel: p,
126
- placeholder: h,
127
- inputId: o,
128
- "aria-label": c,
129
- "aria-labelledby": u,
130
- children: m,
133
+ className: r,
134
+ error: C = !1,
135
+ dataHook: p,
136
+ trackingEl: s,
137
+ trackingLabel: u,
138
+ placeholder: f,
139
+ inputId: c,
140
+ "aria-label": g,
141
+ "aria-labelledby": l,
142
+ children: I,
131
143
  ...d
132
- }, v) => {
133
- const {
134
- value: t,
135
- inputValue: e,
136
- setInputValue: a,
137
- disabled: n,
138
- addItem: g,
139
- inputRef: y,
140
- setFocusedChipIndex: k,
141
- chipRefs: R
142
- } = F(), b = (i) => {
143
- a(i.target.value);
144
- }, C = (i) => {
145
- if (i.key === "Enter" && e.trim() && (i.preventDefault(), g(e)), i.key === "ArrowLeft" && !e && t.length > 0) {
146
- i.preventDefault();
147
- const w = t.length - 1;
148
- k(w), R.current[w]?.focus();
144
+ }, w) => {
145
+ const { setInputValue: n, addItem: e, inputRef: o, setFocusedChipIndex: a, chipRefs: b } = F(), { value: m, disabled: R } = A(), { inputValue: i } = L(), y = (h) => {
146
+ n(h.target.value);
147
+ }, D = (h) => {
148
+ if (h.key === "Enter" && i.trim() && (h.preventDefault(), e(i)), h.key === "ArrowLeft" && !i && m.length > 0) {
149
+ h.preventDefault();
150
+ const v = m.length - 1;
151
+ a(v), b.current[v]?.focus();
149
152
  }
150
- if (i.key === "Backspace" && !e && t.length > 0) {
151
- i.preventDefault();
152
- const w = t.length - 1;
153
- k(w), R.current[w]?.focus();
153
+ if (h.key === "Backspace" && !i && m.length > 0) {
154
+ h.preventDefault();
155
+ const v = m.length - 1;
156
+ a(v), b.current[v]?.focus();
154
157
  }
155
158
  };
156
- return /* @__PURE__ */ E(
159
+ return /* @__PURE__ */ M(
157
160
  "div",
158
161
  {
159
- ref: v,
160
- className: x(A({ error: I }), f),
161
- "data-hook": s,
162
+ ref: w,
163
+ className: E(H({ error: C }), r),
164
+ "data-hook": p,
162
165
  "data-slot": "input-chip",
163
- "data-tracking-el": l,
164
- "data-tracking-label": p,
166
+ "data-tracking-el": s,
167
+ "data-tracking-label": u,
165
168
  ...d,
166
169
  children: [
167
- m,
168
- /* @__PURE__ */ D(
170
+ I,
171
+ /* @__PURE__ */ k(
169
172
  "input",
170
173
  {
171
- ref: y,
172
- "aria-label": c,
173
- "aria-labelledby": u,
174
- className: x(K),
174
+ ref: o,
175
+ "aria-label": g,
176
+ "aria-labelledby": l,
177
+ className: E(T),
175
178
  "data-slot": "input-chip-input",
176
- disabled: n,
177
- id: o,
178
- placeholder: h,
179
+ disabled: R,
180
+ id: c,
181
+ placeholder: f,
179
182
  type: "text",
180
- value: e,
181
- onChange: b,
182
- onKeyDown: C
183
+ value: i,
184
+ onChange: y,
185
+ onKeyDown: D
183
186
  }
184
187
  )
185
188
  ]
@@ -187,91 +190,81 @@ const A = $(
187
190
  );
188
191
  }
189
192
  );
190
- N.displayName = "InputChipInput";
191
- function W({
192
- className: f,
193
- dataHookPrefix: I = "chip"
193
+ W.displayName = "InputChipInput";
194
+ function O({
195
+ className: r,
196
+ dataHookPrefix: C = "chip"
194
197
  }) {
195
- const {
196
- value: s,
197
- disabled: l,
198
- removeItem: p,
199
- inputRef: h,
200
- setFocusedChipIndex: o,
201
- chipRefs: c
202
- } = F(), u = r.useRef(null);
203
- r.useEffect(() => {
204
- if (u.current !== null) {
205
- if (u.current === "input")
206
- h.current?.focus();
198
+ const { removeItem: p, inputRef: s, setFocusedChipIndex: u, chipRefs: f } = F(), { value: c, disabled: g } = A(), l = t.useRef(null);
199
+ t.useEffect(() => {
200
+ if (l.current !== null) {
201
+ if (l.current === "input")
202
+ s.current?.focus();
207
203
  else {
208
- const t = u.current;
209
- t >= 0 && t < s.length ? c.current[t]?.focus() : s.length > 0 ? c.current[s.length - 1]?.focus() : h.current?.focus();
204
+ const n = l.current;
205
+ n >= 0 && n < c.length ? f.current[n]?.focus() : c.length > 0 ? f.current[c.length - 1]?.focus() : s.current?.focus();
210
206
  }
211
- u.current = null;
207
+ l.current = null;
212
208
  }
213
- }, [s.length, h, c]);
214
- const m = (t, e) => {
215
- if (!l)
216
- switch (t.key) {
209
+ }, [c.length, s, f]);
210
+ const I = (n, e) => {
211
+ if (!g)
212
+ switch (n.key) {
217
213
  case "ArrowLeft":
218
- t.preventDefault(), e > 0 && (o(e - 1), c.current[e - 1]?.focus());
214
+ n.preventDefault(), e > 0 && (u(e - 1), f.current[e - 1]?.focus());
219
215
  break;
220
216
  case "ArrowRight":
221
- t.preventDefault(), e < s.length - 1 ? (o(e + 1), c.current[e + 1]?.focus()) : (o(-1), h.current?.focus());
217
+ n.preventDefault(), e < c.length - 1 ? (u(e + 1), f.current[e + 1]?.focus()) : (u(-1), s.current?.focus());
222
218
  break;
223
219
  case "Backspace":
224
220
  case "Delete": {
225
- t.preventDefault();
226
- const a = s.length - 1;
227
- if (a === 0)
228
- o(-1), u.current = "input", p(e);
229
- else if (e >= a) {
230
- const n = a - 1;
231
- o(n), u.current = n, p(e);
221
+ n.preventDefault();
222
+ const o = c.length - 1;
223
+ if (o === 0)
224
+ u(-1), l.current = "input", p(e);
225
+ else if (e >= o) {
226
+ const a = o - 1;
227
+ u(a), l.current = a, p(e);
232
228
  } else
233
- o(e), u.current = e, p(e);
229
+ u(e), l.current = e, p(e);
234
230
  break;
235
231
  }
236
232
  case "Home":
237
- t.preventDefault(), s.length > 0 && (o(0), c.current[0]?.focus());
233
+ n.preventDefault(), c.length > 0 && (u(0), f.current[0]?.focus());
238
234
  break;
239
235
  case "End":
240
- t.preventDefault(), o(-1), h.current?.focus();
236
+ n.preventDefault(), u(-1), s.current?.focus();
241
237
  break;
242
238
  }
243
- }, d = (t) => {
244
- o(t);
245
- }, v = (t) => {
246
- const e = t.relatedTarget;
247
- e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || o(-1);
239
+ }, d = (n) => {
240
+ u(n);
241
+ }, w = (n) => {
242
+ const e = n.relatedTarget;
243
+ e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") || u(-1);
248
244
  };
249
- return s.length === 0 ? null : /* @__PURE__ */ D("div", { className: x("contents", f), "data-slot": "input-chip-items", children: s.map((t, e) => /* @__PURE__ */ D(
250
- B,
245
+ return c.length === 0 ? null : /* @__PURE__ */ k("div", { className: E("contents", r), "data-slot": "input-chip-items", children: c.map((n, e) => /* @__PURE__ */ k(
246
+ j,
251
247
  {
252
- ref: (a) => {
253
- c.current[e] = a;
248
+ ref: (o) => {
249
+ f.current[e] = o;
254
250
  },
255
- "aria-label": `${t}, press Delete to remove`,
256
- dataHook: `${I}-${e}`,
257
- disabled: l,
251
+ "aria-label": `${n}, press Delete to remove`,
252
+ dataHook: `${C}-${e}`,
253
+ disabled: g,
258
254
  role: "group",
259
255
  tabIndex: -1,
260
- onBlur: v,
256
+ onBlur: w,
261
257
  onFocus: () => d(e),
262
- onKeyDown: (a) => m(a, e),
258
+ onKeyDown: (o) => I(o, e),
263
259
  onRemove: () => p(e),
264
- children: t
260
+ children: n
265
261
  },
266
- `${t}-${e}`
262
+ `${n}-${e}`
267
263
  )) });
268
264
  }
269
- const M = A;
270
265
  export {
271
- T as InputChip,
272
- N as InputChipInput,
273
- W as InputChipItems,
274
- A as inputChipInputVariants,
275
- M as inputChipVariants,
276
- F as useInputChipContext
266
+ J as InputChip,
267
+ W as InputChipInput,
268
+ O as InputChipItems,
269
+ G as useInputChipContext
277
270
  };
package/dist/map.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),N=require("react"),w=require("@brightlocal/icons"),u=require("@brightlocal/ui-components/button"),v=require("@brightlocal/ui-components/card"),p=require("@brightlocal/ui-components/lib/utils"),m=require("@brightlocal/ui-components/popover");function k(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const e in t)if(e!=="default"){const r=Object.getOwnPropertyDescriptor(t,e);Object.defineProperty(a,e,r.get?r:{enumerable:!0,get:()=>t[e]})}}return a.default=t,Object.freeze(a)}const c=k(N),C={primary:"var(--primary)",secondary:"var(--secondary)",destructive:"var(--destructive)",outline:"var(--muted)",warning:"var(--warning-background)"},g=c.forwardRef(({value:t,variant:a="primary",pulse:e=!1,dataHook:r,className:o,trackingEl:n,trackingLabel:i,...l},d)=>s.jsx(u.Button,{ref:d,className:p.cn("size-8 p-0",e&&"animate-grid-pin-pulse transition-none motion-reduce:animate-none",o),dataHook:r,size:"sm",style:e?{"--grid-pin-pulse-color":C[a]}:void 0,trackingEl:n||"map-grid-pin",trackingLabel:i,variant:a,...l,children:String(t)}));g.displayName="MapGridPin";const x=c.forwardRef(({value:t=1,dataHook:a,...e},r)=>s.jsx(g,{ref:r,dataHook:a,value:t,...e}));x.displayName="MapLocationPin";const M=c.forwardRef(({className:t,dataHook:a,trackingEl:e,trackingLabel:r,children:o,...n},i)=>s.jsx(u.Button,{ref:i,className:p.cn("rounded-lg shadow-sm",t),"data-slot":"map-control-button",dataHook:a,trackingEl:e||"map-control-button",trackingLabel:r,variant:"outline",...n,children:o}));M.displayName="MapControlButton";const h=c.forwardRef(({className:t,message:a="Loading map…",dataHook:e,trackingEl:r,trackingLabel:o,...n},i)=>s.jsxs("div",{ref:i,"aria-live":"polite",className:p.cn("text-muted-foreground flex items-center justify-center gap-2 py-6 text-sm",t),"data-hook":e,"data-slot":"map-loading-state","data-tracking-el":r||"map-loading-state","data-tracking-label":o,role:"status",...n,children:[s.jsx("div",{"aria-hidden":"true",className:"size-4 animate-spin rounded-full border-2 border-current border-t-transparent"}),a]}));h.displayName="MapLoadingState";const y=c.forwardRef(({className:t,title:a="Unable to load map",message:e="Something went wrong while loading the map. Please try again.",onRetry:r,dataHook:o,trackingEl:n,trackingLabel:i,...l},d)=>s.jsxs("div",{ref:d,className:p.cn("bg-muted/50 flex flex-col items-center justify-center gap-3 rounded-xl p-8 text-center",t),"data-hook":o,"data-slot":"map-error-state","data-tracking-el":n||"map-error-state","data-tracking-label":i,role:"alert",...l,children:[s.jsx(w.AlertCircle,{"aria-hidden":"true",className:"text-muted-foreground/60",size:40,strokeWidth:1.5}),s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx("h3",{className:"text-foreground text-sm font-semibold","data-slot":"map-error-title",children:a}),e&&s.jsx("p",{className:"text-muted-foreground max-w-xs text-xs","data-slot":"map-error-message",children:e})]}),r&&s.jsx(u.Button,{className:"mt-1",dataHook:`${o}-retry`,size:"sm",variant:"primary",onClick:r,children:"Try again"})]}));y.displayName="MapErrorState";const P=c.forwardRef(({className:t,dataHook:a,trackingEl:e,trackingLabel:r,children:o,...n},i)=>s.jsx(v.Card,{ref:i,className:p.cn("inline-flex w-auto flex-row items-center",t),"data-slot":"map-legend",dataHook:a,density:"condensed",maxWidth:"none",trackingEl:e||"map-legend",trackingLabel:r,variant:"filled",...n,children:s.jsx(v.CardContent,{className:"flex items-center gap-3",children:o})}));P.displayName="MapLegend";function S(t=150){const[a,e]=c.useState(null),[r,o]=c.useState(null),n=c.useRef(null),i=c.useCallback(f=>{n.current&&clearTimeout(n.current),o(f),e(f)},[]),l=c.useCallback(()=>{n.current&&clearTimeout(n.current),n.current=setTimeout(()=>e(null),t)},[t]),d=c.useCallback(()=>{n.current&&clearTimeout(n.current)},[]);return{activeItem:a,anchorItem:r,showItem:i,scheduleClose:l,cancelClose:d}}const R=m.Popover,b=m.PopoverAnchor;b.displayName="MapPopoverAnchor";const j=c.forwardRef(({className:t,side:a="top",sideOffset:e=4,dataHook:r,trackingEl:o,trackingLabel:n,...i},l)=>s.jsx(m.PopoverContent,{ref:l,className:p.cn("w-auto p-3 data-[state=closed]:animate-none data-[state=closed]:opacity-0",t),"data-slot":"map-popover-content","data-tracking-el":o||"map-popover","data-tracking-label":n,dataHook:r,side:a,sideOffset:e,onOpenAutoFocus:d=>d.preventDefault(),...i}));j.displayName="MapPopoverContent";exports.MapControlButton=M;exports.MapErrorState=y;exports.MapGridPin=g;exports.MapLegend=P;exports.MapLoadingState=h;exports.MapLocationPin=x;exports.MapPopover=R;exports.MapPopoverAnchor=b;exports.MapPopoverContent=j;exports.useMapPopoverHover=S;