@brightlocal/ui-components 2.9.2 → 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.
- package/README.md +3 -1
- package/component-meta.json +41 -9
- package/dist/badge.cjs +1 -1
- package/dist/badge.d.ts.map +1 -1
- package/dist/badge.js +42 -25
- package/dist/blocks/sidebar.cjs +1 -1
- package/dist/blocks/sidebar.d.ts +1 -3
- package/dist/blocks/sidebar.d.ts.map +1 -1
- package/dist/blocks/sidebar.js +46 -49
- package/dist/browser-entry.d.ts +17 -0
- package/dist/browser-entry.d.ts.map +1 -0
- package/dist/button.cjs +1 -1
- package/dist/button.js +25 -25
- package/dist/card.cjs +1 -1
- package/dist/card.d.ts +10 -1
- package/dist/card.d.ts.map +1 -1
- package/dist/card.js +85 -82
- package/dist/carousel.cjs +1 -1
- package/dist/carousel.d.ts +13 -1
- package/dist/carousel.d.ts.map +1 -1
- package/dist/carousel.js +196 -150
- package/dist/combobox.cjs +3 -3
- package/dist/combobox.d.ts +3 -3
- package/dist/combobox.d.ts.map +1 -1
- package/dist/combobox.js +480 -440
- package/dist/command.cjs +1 -1
- package/dist/command.d.ts +101 -1
- package/dist/command.d.ts.map +1 -1
- package/dist/command.js +383 -119
- package/dist/hooks/use-breakpoint.cjs +1 -1
- package/dist/hooks/use-breakpoint.d.ts.map +1 -1
- package/dist/hooks/use-breakpoint.js +10 -10
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +402 -391
- package/dist/input-chip.cjs +1 -1
- package/dist/input-chip.d.ts +1 -4
- package/dist/input-chip.d.ts.map +1 -1
- package/dist/input-chip.js +163 -170
- package/dist/map.cjs +1 -0
- package/dist/map.d.ts +192 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/map.js +250 -0
- package/dist/sonner.cjs +1 -1
- package/dist/sonner.d.ts.map +1 -1
- package/dist/sonner.js +32 -30
- package/dist/tabs.cjs +1 -1
- package/dist/tabs.d.ts +4 -0
- package/dist/tabs.d.ts.map +1 -1
- package/dist/tabs.js +101 -52
- package/package.json +4 -1
- package/src/blocks/sidebar.tsx +21 -26
- package/src/browser-entry.ts +89 -0
- package/src/browser-tokens.css +1 -0
- package/src/components/badge.tsx +22 -5
- package/src/components/button.tsx +13 -13
- package/src/components/card.tsx +35 -19
- package/src/components/carousel.tsx +101 -9
- package/src/components/combobox.tsx +106 -28
- package/src/components/command.tsx +637 -16
- package/src/components/input-chip.tsx +102 -65
- package/src/components/map.tsx +574 -0
- package/src/components/sonner.tsx +9 -3
- package/src/components/tabs.tsx +118 -22
- package/src/hooks/use-breakpoint.ts +2 -3
- package/src/index.ts +1 -0
package/dist/input-chip.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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;
|
package/dist/input-chip.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
package/dist/input-chip.d.ts.map
CHANGED
|
@@ -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,qBAAqB;IAC7B,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,IAAI,CAAC;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CA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,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"}
|
package/dist/input-chip.js
CHANGED
|
@@ -1,77 +1,89 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import { cva as
|
|
4
|
-
import { cn as
|
|
5
|
-
import { Chip as
|
|
6
|
-
const
|
|
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
|
|
11
|
-
if (!
|
|
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
|
|
23
|
+
return r;
|
|
14
24
|
}
|
|
15
|
-
function
|
|
16
|
-
value:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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 [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
},
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
[
|
|
32
|
-
), y =
|
|
33
|
-
(
|
|
34
|
-
if (
|
|
35
|
-
const
|
|
36
|
-
|
|
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
|
-
[
|
|
39
|
-
),
|
|
40
|
-
(
|
|
41
|
-
|
|
60
|
+
[u, i]
|
|
61
|
+
), D = t.useCallback(
|
|
62
|
+
(x) => {
|
|
63
|
+
R.current || i(b.current.filter((V, S) => S !== x));
|
|
42
64
|
},
|
|
43
|
-
[
|
|
44
|
-
),
|
|
65
|
+
[i]
|
|
66
|
+
), h = t.useMemo(
|
|
45
67
|
() => ({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
inputValue: u,
|
|
49
|
-
setInputValue: m,
|
|
50
|
-
disabled: l,
|
|
68
|
+
onValueChange: i,
|
|
69
|
+
setInputValue: I,
|
|
51
70
|
addItem: y,
|
|
52
|
-
removeItem:
|
|
53
|
-
inputRef:
|
|
54
|
-
|
|
55
|
-
setFocusedChipIndex: v,
|
|
71
|
+
removeItem: D,
|
|
72
|
+
inputRef: n,
|
|
73
|
+
setFocusedChipIndex: w,
|
|
56
74
|
chipRefs: e
|
|
57
75
|
}),
|
|
58
|
-
[
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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__ */
|
|
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
|
|
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
|
-
),
|
|
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
|
-
],
|
|
131
|
+
], W = t.forwardRef(
|
|
120
132
|
({
|
|
121
|
-
className:
|
|
122
|
-
error:
|
|
123
|
-
dataHook:
|
|
124
|
-
trackingEl:
|
|
125
|
-
trackingLabel:
|
|
126
|
-
placeholder:
|
|
127
|
-
inputId:
|
|
128
|
-
"aria-label":
|
|
129
|
-
"aria-labelledby":
|
|
130
|
-
children:
|
|
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
|
-
},
|
|
133
|
-
const {
|
|
134
|
-
value
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
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 (
|
|
151
|
-
|
|
152
|
-
const
|
|
153
|
-
|
|
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__ */
|
|
159
|
+
return /* @__PURE__ */ M(
|
|
157
160
|
"div",
|
|
158
161
|
{
|
|
159
|
-
ref:
|
|
160
|
-
className:
|
|
161
|
-
"data-hook":
|
|
162
|
+
ref: w,
|
|
163
|
+
className: E(H({ error: C }), r),
|
|
164
|
+
"data-hook": p,
|
|
162
165
|
"data-slot": "input-chip",
|
|
163
|
-
"data-tracking-el":
|
|
164
|
-
"data-tracking-label":
|
|
166
|
+
"data-tracking-el": s,
|
|
167
|
+
"data-tracking-label": u,
|
|
165
168
|
...d,
|
|
166
169
|
children: [
|
|
167
|
-
|
|
168
|
-
/* @__PURE__ */
|
|
170
|
+
I,
|
|
171
|
+
/* @__PURE__ */ k(
|
|
169
172
|
"input",
|
|
170
173
|
{
|
|
171
|
-
ref:
|
|
172
|
-
"aria-label":
|
|
173
|
-
"aria-labelledby":
|
|
174
|
-
className:
|
|
174
|
+
ref: o,
|
|
175
|
+
"aria-label": g,
|
|
176
|
+
"aria-labelledby": l,
|
|
177
|
+
className: E(T),
|
|
175
178
|
"data-slot": "input-chip-input",
|
|
176
|
-
disabled:
|
|
177
|
-
id:
|
|
178
|
-
placeholder:
|
|
179
|
+
disabled: R,
|
|
180
|
+
id: c,
|
|
181
|
+
placeholder: f,
|
|
179
182
|
type: "text",
|
|
180
|
-
value:
|
|
181
|
-
onChange:
|
|
182
|
-
onKeyDown:
|
|
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
|
-
|
|
191
|
-
function
|
|
192
|
-
className:
|
|
193
|
-
dataHookPrefix:
|
|
193
|
+
W.displayName = "InputChipInput";
|
|
194
|
+
function O({
|
|
195
|
+
className: r,
|
|
196
|
+
dataHookPrefix: C = "chip"
|
|
194
197
|
}) {
|
|
195
|
-
const {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
|
209
|
-
|
|
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
|
-
|
|
207
|
+
l.current = null;
|
|
212
208
|
}
|
|
213
|
-
}, [
|
|
214
|
-
const
|
|
215
|
-
if (!
|
|
216
|
-
switch (
|
|
209
|
+
}, [c.length, s, f]);
|
|
210
|
+
const I = (n, e) => {
|
|
211
|
+
if (!g)
|
|
212
|
+
switch (n.key) {
|
|
217
213
|
case "ArrowLeft":
|
|
218
|
-
|
|
214
|
+
n.preventDefault(), e > 0 && (u(e - 1), f.current[e - 1]?.focus());
|
|
219
215
|
break;
|
|
220
216
|
case "ArrowRight":
|
|
221
|
-
|
|
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
|
-
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
else if (e >=
|
|
230
|
-
const
|
|
231
|
-
|
|
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
|
-
|
|
229
|
+
u(e), l.current = e, p(e);
|
|
234
230
|
break;
|
|
235
231
|
}
|
|
236
232
|
case "Home":
|
|
237
|
-
|
|
233
|
+
n.preventDefault(), c.length > 0 && (u(0), f.current[0]?.focus());
|
|
238
234
|
break;
|
|
239
235
|
case "End":
|
|
240
|
-
|
|
236
|
+
n.preventDefault(), u(-1), s.current?.focus();
|
|
241
237
|
break;
|
|
242
238
|
}
|
|
243
|
-
}, d = (
|
|
244
|
-
|
|
245
|
-
},
|
|
246
|
-
const e =
|
|
247
|
-
e && (e.closest('[data-slot="chip"]') !== null || e.dataset.slot === "input-chip-input") ||
|
|
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
|
|
250
|
-
|
|
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: (
|
|
253
|
-
|
|
248
|
+
ref: (o) => {
|
|
249
|
+
f.current[e] = o;
|
|
254
250
|
},
|
|
255
|
-
"aria-label": `${
|
|
256
|
-
dataHook: `${
|
|
257
|
-
disabled:
|
|
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:
|
|
256
|
+
onBlur: w,
|
|
261
257
|
onFocus: () => d(e),
|
|
262
|
-
onKeyDown: (
|
|
258
|
+
onKeyDown: (o) => I(o, e),
|
|
263
259
|
onRemove: () => p(e),
|
|
264
|
-
children:
|
|
260
|
+
children: n
|
|
265
261
|
},
|
|
266
|
-
`${
|
|
262
|
+
`${n}-${e}`
|
|
267
263
|
)) });
|
|
268
264
|
}
|
|
269
|
-
const M = A;
|
|
270
265
|
export {
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
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;
|