@adam-milo/ui 1.0.17 → 1.0.19
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/dist/index.cjs +1 -1
- package/dist/index.js +43 -39
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +59 -109
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +109 -82
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +81 -31
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +33 -106
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +333 -33
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +113 -9
- package/dist/index16.cjs +1 -0
- package/dist/index16.js +43 -0
- package/dist/index17.cjs +1 -0
- package/dist/index17.js +11 -0
- package/dist/index2.cjs +1 -1
- package/dist/index2.js +1 -1
- package/dist/index3.cjs +1 -1
- package/dist/index3.js +1 -1
- package/dist/index4.cjs +1 -1
- package/dist/index4.js +1 -1
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +1 -1
- package/dist/index6.cjs +1 -1
- package/dist/index6.js +1 -1
- package/dist/index7.cjs +1 -1
- package/dist/index7.js +43 -38
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +81 -53
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +52 -60
- package/dist/src/components/data-display/chip-group/ChipGroup.component.d.ts +72 -0
- package/dist/src/components/data-display/chip-group/ChipGroup.component.d.ts.map +1 -0
- package/dist/src/components/forms/checkbox/Checkbox.component.d.ts.map +1 -1
- package/dist/src/components/forms/radio/Radio.component.d.ts +100 -0
- package/dist/src/components/forms/radio/Radio.component.d.ts.map +1 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index13.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 t=require("react/jsx-runtime"),h=require("react"),u=require("./index17.cjs");;/* empty css */const c=h.forwardRef(({variant:e="primary",selected:i=!1,disabled:s=!1,className:r,children:a,"data-testid":d,"data-cy":p,...l},o)=>{const n=u.cn("chip",`chip--${e}`,i&&"chip--selected",s&&"chip--disabled",r);return t.jsx("div",{ref:o,className:n,"data-testid":d||`chip-${e}`,"data-cy":p||`chip-${e}`,"aria-selected":i,"aria-disabled":s,"aria-label":typeof a=="string"?a:void 0,...l,children:t.jsx("span",{className:"chip__label",children:a})})});c.displayName="Chip";exports.Chip=c;
|
package/dist/index13.js
CHANGED
|
@@ -1,115 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import { cn as r } from "./index15.js";
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as m } from "react";
|
|
3
|
+
import { cn as f } from "./index17.js";
|
|
5
4
|
/* empty css */
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
/* @__PURE__ */
|
|
25
|
-
|
|
26
|
-
{
|
|
27
|
-
ref: l,
|
|
28
|
-
className: r("dialog-content", t),
|
|
29
|
-
"data-cy": s,
|
|
30
|
-
"data-testid": y,
|
|
31
|
-
...d,
|
|
32
|
-
children: i
|
|
33
|
-
}
|
|
34
|
-
)
|
|
35
|
-
] });
|
|
36
|
-
});
|
|
37
|
-
D.displayName = a.Content.displayName;
|
|
38
|
-
const f = ({
|
|
39
|
-
className: t,
|
|
40
|
-
"data-cy": i,
|
|
41
|
-
"data-testid": o,
|
|
42
|
-
...e
|
|
43
|
-
}) => {
|
|
44
|
-
const d = i || "dialog-header", l = o || "dialog-header";
|
|
45
|
-
return /* @__PURE__ */ n(
|
|
46
|
-
"div",
|
|
47
|
-
{
|
|
48
|
-
className: r("dialog-header", t),
|
|
49
|
-
"data-cy": d,
|
|
50
|
-
"data-testid": l,
|
|
51
|
-
...e
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
};
|
|
55
|
-
f.displayName = "DialogHeader";
|
|
56
|
-
const N = ({
|
|
57
|
-
className: t,
|
|
58
|
-
"data-cy": i,
|
|
59
|
-
"data-testid": o,
|
|
60
|
-
...e
|
|
61
|
-
}) => {
|
|
62
|
-
const d = i || "dialog-footer", l = o || "dialog-footer";
|
|
63
|
-
return /* @__PURE__ */ n(
|
|
64
|
-
"div",
|
|
65
|
-
{
|
|
66
|
-
className: r("dialog-footer", t),
|
|
67
|
-
"data-cy": d,
|
|
68
|
-
"data-testid": l,
|
|
69
|
-
...e
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
};
|
|
73
|
-
N.displayName = "DialogFooter";
|
|
74
|
-
const C = c(
|
|
75
|
-
({ className: t, "data-cy": i, "data-testid": o, ...e }, d) => {
|
|
76
|
-
const l = i || "dialog-title", s = o || "dialog-title";
|
|
77
|
-
return /* @__PURE__ */ n(
|
|
78
|
-
a.Title,
|
|
5
|
+
const h = m(
|
|
6
|
+
({
|
|
7
|
+
variant: a = "primary",
|
|
8
|
+
selected: s = !1,
|
|
9
|
+
disabled: p = !1,
|
|
10
|
+
className: t,
|
|
11
|
+
children: i,
|
|
12
|
+
"data-testid": c,
|
|
13
|
+
"data-cy": r,
|
|
14
|
+
...o
|
|
15
|
+
}, d) => {
|
|
16
|
+
const l = f(
|
|
17
|
+
"chip",
|
|
18
|
+
`chip--${a}`,
|
|
19
|
+
s && "chip--selected",
|
|
20
|
+
p && "chip--disabled",
|
|
21
|
+
t
|
|
22
|
+
);
|
|
23
|
+
return /* @__PURE__ */ e(
|
|
24
|
+
"div",
|
|
79
25
|
{
|
|
80
26
|
ref: d,
|
|
81
|
-
className:
|
|
82
|
-
"data-
|
|
83
|
-
"data-
|
|
84
|
-
|
|
27
|
+
className: l,
|
|
28
|
+
"data-testid": c || `chip-${a}`,
|
|
29
|
+
"data-cy": r || `chip-${a}`,
|
|
30
|
+
"aria-selected": s,
|
|
31
|
+
"aria-disabled": p,
|
|
32
|
+
"aria-label": typeof i == "string" ? i : void 0,
|
|
33
|
+
...o,
|
|
34
|
+
children: /* @__PURE__ */ e("span", { className: "chip__label", children: i })
|
|
85
35
|
}
|
|
86
36
|
);
|
|
87
37
|
}
|
|
88
38
|
);
|
|
89
|
-
|
|
90
|
-
const T = c(({ className: t, "data-cy": i, "data-testid": o, ...e }, d) => {
|
|
91
|
-
const l = i || "dialog-description", s = o || "dialog-description";
|
|
92
|
-
return /* @__PURE__ */ n(
|
|
93
|
-
a.Description,
|
|
94
|
-
{
|
|
95
|
-
ref: d,
|
|
96
|
-
className: r("dialog-description", t),
|
|
97
|
-
"data-cy": l,
|
|
98
|
-
"data-testid": s,
|
|
99
|
-
...e
|
|
100
|
-
}
|
|
101
|
-
);
|
|
102
|
-
});
|
|
103
|
-
T.displayName = a.Description.displayName;
|
|
39
|
+
h.displayName = "Chip";
|
|
104
40
|
export {
|
|
105
|
-
|
|
106
|
-
P as DialogClose,
|
|
107
|
-
D as DialogContent,
|
|
108
|
-
T as DialogDescription,
|
|
109
|
-
N as DialogFooter,
|
|
110
|
-
f as DialogHeader,
|
|
111
|
-
g as DialogOverlay,
|
|
112
|
-
p as DialogPortal,
|
|
113
|
-
C as DialogTitle,
|
|
114
|
-
O as DialogTrigger
|
|
41
|
+
h as Chip
|
|
115
42
|
};
|
package/dist/index14.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 p=require("react/jsx-runtime"),n=require("react"),P=require("./index17.cjs"),z=require("./index13.cjs");;/* empty css */const K=require("@adam-milo/icons"),V=(t,c,a)=>{if(!t)return .5*c;const u=t.match(/^([\d.]+)(px|rem|em)?/);if(!u)return .5*c;const l=parseFloat(u[1]);switch(u[2]||"px"){case"px":return l;case"rem":return l*c;case"em":return l*a;default:return .5*c}},U=(t,c,a,u,l)=>{let y=0,s=0;for(let d=0;d<t.length;d++){const k=t[d],E=c.get(k.value)||0;if(E===0){s++;break}const I=d>0?u:0,_=y+I+E;if(d<t.length-1){if(_+u+l>a&&s>0)break}else if(_>a&&s>0)break;y=_,s++}return Math.max(1,s)},B=(t,c)=>{const a=n.useRef();return n.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]),n.useCallback((...l)=>{a.current&&clearTimeout(a.current),a.current=setTimeout(()=>t(...l),c)},[t,c])},J=(t,c,a,u,l)=>{const[y,s]=n.useState(t.length),d=n.useCallback(()=>{if(l!==void 0){s(Math.min(l,t.length));return}const g=c.current;if(!g)return;const b=g.clientWidth,h=parseFloat(getComputedStyle(document.documentElement).fontSize)||16,j=window.getComputedStyle(g),x=j.gap,R=parseFloat(j.fontSize)||16,N=V(x,h,R),D=3.75*h;for(let w=0;w<t.length;w++){const m=t[w],$=a.current[w];$&&u.current.set(m.value,$.offsetWidth)}const C=U(t,u.current,b,N,D);s(C)},[t,l,c,a,u]),k=B(d,100);n.useEffect(()=>{a.current.length>t.length&&(a.current=a.current.slice(0,t.length));const g=new Set(t.map(b=>b.value));u.current.forEach((b,h)=>{g.has(h)||u.current.delete(h)}),l===void 0&&(t.some(h=>!u.current.has(h.value))?s(t.length):setTimeout(d,0))},[t,l,d,a,u]),n.useEffect(()=>{const g=c.current;if(!g)return;const b=new ResizeObserver(()=>{k()});return b.observe(g),setTimeout(d,0),()=>{b.disconnect()}},[d,k,c]);const E=t.slice(0,y),I=t.slice(y),_=I.length>0;return{visibleCount:y,visibleItems:E,hiddenItems:I,hasOverflow:_}},A=n.forwardRef(({items:t,selectedValue:c,onSelectionChange:a,removable:u=!1,onRemove:l,variant:y="primary",disabled:s=!1,maxVisible:d,className:k,"data-testid":E,"data-cy":I,..._},g)=>{const h=(t&&Array.isArray(t)?t:[]).filter(e=>e!=null&&typeof e=="object"),j=n.useRef(null),x=n.useRef([]),R=n.useRef(new Map),N=n.useRef(null),[q,D]=n.useState(!1),[C,w]=n.useState(!1),m=n.useRef([]),{visibleItems:$,hiddenItems:f,hasOverflow:F}=J(h,j,x,R,d),O=n.useCallback((e,o,r)=>{s||o||a&&a(c===e?null:e,r)},[s,c,a]),L=n.useCallback((e,o)=>{e.stopPropagation(),!s&&l&&l(o,e)},[s,l]),W=n.useCallback((e,o,r)=>{s||r||(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),O(o,r,e))},[s,O]),G=n.useCallback(e=>{e.stopPropagation(),w(o=>!o),D(!1)},[]),H=n.useCallback((e,o)=>{var r,i,S,v;switch(e.key){case"ArrowDown":e.preventDefault(),o<f.length-1&&((r=m.current[o+1])==null||r.focus());break;case"ArrowUp":e.preventDefault(),o>0&&((i=m.current[o-1])==null||i.focus());break;case"Home":e.preventDefault(),(S=m.current[0])==null||S.focus();break;case"End":e.preventDefault(),(v=m.current[f.length-1])==null||v.focus();break}},[f.length]),T=n.useRef(),M=n.useRef();return n.useEffect(()=>{T.current=e=>{N.current&&!N.current.contains(e.target)&&w(!1)},M.current=e=>{e.key==="Escape"&&w(!1)}}),n.useEffect(()=>{if(!C)return;const e=r=>{var i;return(i=T.current)==null?void 0:i.call(T,r)},o=r=>{var i;return(i=M.current)==null?void 0:i.call(M,r)};return document.addEventListener("mousedown",e),document.addEventListener("keydown",o),()=>{document.removeEventListener("mousedown",e),document.removeEventListener("keydown",o)}},[C]),n.useEffect(()=>{if(process.env.NODE_ENV==="development"&&h.length>0){const e=h.map(r=>r.value),o=new Set(e);e.length!==o.size&&console.warn("[ChipGroup] Duplicate values detected in items array. Each item should have a unique value.")}},[h]),n.useEffect(()=>{m.current.length>f.length&&(m.current=m.current.slice(0,f.length))},[f]),!t||!Array.isArray(t)?null:p.jsxs("div",{ref:g,className:P.cn("chip-group",s&&"chip-group--disabled",k),role:"group","aria-label":"Chip group","data-testid":E||"chip-group","data-cy":I||"chip-group",..._,children:[F&&p.jsxs("div",{className:"sr-only",role:"status","aria-live":"polite","aria-atomic":"true","data-testid":"chip-group-live-region","data-cy":"chip-group-live-region",children:[f.length," additional ",f.length===1?"chip":"chips"," hidden"]}),p.jsxs("div",{ref:j,className:"chip-group__container",children:[$.map(e=>{const o=c===e.value,r=e.variant||y,i=s||e.disabled||!1,S=h.findIndex(v=>v.value===e.value);return p.jsx("div",{ref:v=>{v?x.current[S]=v:x.current[S]=null},className:"chip-group__item-wrapper","data-cy":`chip-group-item-wrapper-${e.value}`,"data-testid":`chip-group-item-wrapper-${e.value}`,children:p.jsxs("div",{className:"chip-group__item",onClick:v=>O(e.value,i,v),onKeyDown:v=>W(v,e.value,i),tabIndex:i?-1:0,role:"button","aria-pressed":o?"true":"false","aria-disabled":i?"true":"false","data-cy":`chip-group-item-${e.value}`,"data-testid":`chip-group-item-${e.value}`,children:[p.jsx(z.Chip,{variant:r,selected:o,disabled:i,"data-cy":`chip-${e.value}`,"data-testid":`chip-${e.value}`,children:e.label}),u&&!s&&!i&&p.jsx("button",{className:"chip-group__remove",onClick:v=>L(v,e.value),"aria-label":`Remove ${e.label}`,"data-cy":`chip-remove-${e.value}`,"data-testid":`chip-remove-${e.value}`,type:"button",children:p.jsx(K.Icon,{name:"Cross2Icon",size:"sm",decorative:!0})})]})},e.value)}),F&&p.jsxs("div",{ref:N,className:"chip-group__overflow",role:"button",tabIndex:0,"aria-expanded":C?"true":"false","aria-haspopup":"menu","aria-label":`Show ${f.length} more ${f.length===1?"chip":"chips"}`,onMouseEnter:()=>!C&&D(!0),onMouseLeave:()=>D(!1),onClick:G,onKeyDown:e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),e.stopPropagation(),w(!C),D(!1))},"data-cy":"chip-group-overflow","data-testid":"chip-group-overflow",children:[p.jsxs(z.Chip,{variant:y,"data-cy":"chip-overflow","data-testid":"chip-overflow",children:["+",f.length]}),q&&!C&&p.jsx("div",{className:"chip-group__tooltip chip-group__tooltip--hover",role:"tooltip","data-cy":"chip-group-tooltip","data-testid":"chip-group-tooltip",children:f.map(e=>p.jsx("div",{className:"chip-group__tooltip-item","data-cy":`chip-group-tooltip-item-${e.value}`,"data-testid":`chip-group-tooltip-item-${e.value}`,children:e.label},e.value))}),C&&p.jsx("div",{className:"chip-group__dropdown",role:"menu","data-cy":"chip-group-dropdown","data-testid":"chip-group-dropdown",children:f.map((e,o)=>p.jsx("div",{ref:r=>{r?m.current[o]=r:m.current[o]=null},className:P.cn("chip-group__dropdown-item",e.disabled&&"chip-group__dropdown-item--disabled"),role:"menuitem",tabIndex:e.disabled?-1:0,"aria-disabled":e.disabled?"true":"false",onClick:r=>{r.stopPropagation(),e.disabled||(O(e.value,!1,r),w(!1))},onKeyDown:r=>{H(r,o),(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),r.stopPropagation(),e.disabled||(O(e.value,!1,r),w(!1)))},"data-cy":`chip-group-dropdown-item-${e.value}`,"data-testid":`chip-group-dropdown-item-${e.value}`,children:e.label},e.value))})]})]})]})});A.displayName="ChipGroup";exports.ChipGroup=A;
|
package/dist/index14.js
CHANGED
|
@@ -1,43 +1,343 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { cn as
|
|
1
|
+
import { jsxs as O, jsx as b } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as B, useRef as _, useState as H, useCallback as I, useEffect as k } from "react";
|
|
3
|
+
import { cn as x } from "./index17.js";
|
|
4
|
+
import { Chip as G } from "./index13.js";
|
|
4
5
|
/* empty css */
|
|
5
|
-
|
|
6
|
+
import { Icon as J } from "@adam-milo/icons";
|
|
7
|
+
const Q = (t, c, n) => {
|
|
8
|
+
if (!t) return 0.5 * c;
|
|
9
|
+
const l = t.match(/^([\d.]+)(px|rem|em)?/);
|
|
10
|
+
if (!l) return 0.5 * c;
|
|
11
|
+
const s = parseFloat(l[1]);
|
|
12
|
+
switch (l[2] || "px") {
|
|
13
|
+
case "px":
|
|
14
|
+
return s;
|
|
15
|
+
case "rem":
|
|
16
|
+
return s * c;
|
|
17
|
+
case "em":
|
|
18
|
+
return s * n;
|
|
19
|
+
default:
|
|
20
|
+
return 0.5 * c;
|
|
21
|
+
}
|
|
22
|
+
}, X = (t, c, n, l, s) => {
|
|
23
|
+
let w = 0, a = 0;
|
|
24
|
+
for (let i = 0; i < t.length; i++) {
|
|
25
|
+
const D = t[i], E = c.get(D.value) || 0;
|
|
26
|
+
if (E === 0) {
|
|
27
|
+
a++;
|
|
28
|
+
break;
|
|
29
|
+
}
|
|
30
|
+
const $ = i > 0 ? l : 0, C = w + $ + E;
|
|
31
|
+
if (i < t.length - 1) {
|
|
32
|
+
if (C + l + s > n && a > 0) break;
|
|
33
|
+
} else if (C > n && a > 0) break;
|
|
34
|
+
w = C, a++;
|
|
35
|
+
}
|
|
36
|
+
return Math.max(1, a);
|
|
37
|
+
}, Y = (t, c) => {
|
|
38
|
+
const n = _();
|
|
39
|
+
return k(() => () => {
|
|
40
|
+
n.current && clearTimeout(n.current);
|
|
41
|
+
}, []), I(
|
|
42
|
+
(...s) => {
|
|
43
|
+
n.current && clearTimeout(n.current), n.current = setTimeout(() => t(...s), c);
|
|
44
|
+
},
|
|
45
|
+
[t, c]
|
|
46
|
+
);
|
|
47
|
+
}, Z = (t, c, n, l, s) => {
|
|
48
|
+
const [w, a] = H(t.length), i = I(() => {
|
|
49
|
+
if (s !== void 0) {
|
|
50
|
+
a(Math.min(s, t.length));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const f = c.current;
|
|
54
|
+
if (!f) return;
|
|
55
|
+
const m = f.clientWidth, p = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16, T = window.getComputedStyle(f), M = T.gap, W = parseFloat(T.fontSize) || 16, S = Q(M, p, W), N = 3.75 * p;
|
|
56
|
+
for (let v = 0; v < t.length; v++) {
|
|
57
|
+
const g = t[v], A = n.current[v];
|
|
58
|
+
A && l.current.set(g.value, A.offsetWidth);
|
|
59
|
+
}
|
|
60
|
+
const y = X(
|
|
61
|
+
t,
|
|
62
|
+
l.current,
|
|
63
|
+
m,
|
|
64
|
+
S,
|
|
65
|
+
N
|
|
66
|
+
);
|
|
67
|
+
a(y);
|
|
68
|
+
}, [t, s, c, n, l]), D = Y(i, 100);
|
|
69
|
+
k(() => {
|
|
70
|
+
n.current.length > t.length && (n.current = n.current.slice(0, t.length));
|
|
71
|
+
const f = new Set(t.map((m) => m.value));
|
|
72
|
+
l.current.forEach((m, p) => {
|
|
73
|
+
f.has(p) || l.current.delete(p);
|
|
74
|
+
}), s === void 0 && (t.some((p) => !l.current.has(p.value)) ? a(t.length) : setTimeout(i, 0));
|
|
75
|
+
}, [t, s, i, n, l]), k(() => {
|
|
76
|
+
const f = c.current;
|
|
77
|
+
if (!f) return;
|
|
78
|
+
const m = new ResizeObserver(() => {
|
|
79
|
+
D();
|
|
80
|
+
});
|
|
81
|
+
return m.observe(f), setTimeout(i, 0), () => {
|
|
82
|
+
m.disconnect();
|
|
83
|
+
};
|
|
84
|
+
}, [i, D, c]);
|
|
85
|
+
const E = t.slice(0, w), $ = t.slice(w), C = $.length > 0;
|
|
86
|
+
return { visibleCount: w, visibleItems: E, hiddenItems: $, hasOverflow: C };
|
|
87
|
+
}, ee = B(
|
|
6
88
|
({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
89
|
+
items: t,
|
|
90
|
+
selectedValue: c,
|
|
91
|
+
onSelectionChange: n,
|
|
92
|
+
removable: l = !1,
|
|
93
|
+
onRemove: s,
|
|
94
|
+
variant: w = "primary",
|
|
95
|
+
disabled: a = !1,
|
|
96
|
+
maxVisible: i,
|
|
97
|
+
className: D,
|
|
98
|
+
"data-testid": E,
|
|
99
|
+
"data-cy": $,
|
|
100
|
+
...C
|
|
101
|
+
}, f) => {
|
|
102
|
+
const p = (t && Array.isArray(t) ? t : []).filter((e) => e != null && typeof e == "object"), T = _(null), M = _([]), W = _(/* @__PURE__ */ new Map()), S = _(null), [K, N] = H(!1), [y, v] = H(!1), g = _([]), { visibleItems: A, hiddenItems: d, hasOverflow: V } = Z(
|
|
103
|
+
p,
|
|
104
|
+
T,
|
|
105
|
+
M,
|
|
106
|
+
W,
|
|
107
|
+
i
|
|
108
|
+
), F = I(
|
|
109
|
+
(e, o, r) => {
|
|
110
|
+
a || o || n && n(c === e ? null : e, r);
|
|
111
|
+
},
|
|
112
|
+
[a, c, n]
|
|
113
|
+
), j = I(
|
|
114
|
+
(e, o) => {
|
|
115
|
+
e.stopPropagation(), !a && s && s(o, e);
|
|
116
|
+
},
|
|
117
|
+
[a, s]
|
|
118
|
+
), U = I(
|
|
119
|
+
(e, o, r) => {
|
|
120
|
+
a || r || (e.key === "Enter" || e.key === " ") && (e.preventDefault(), F(o, r, e));
|
|
121
|
+
},
|
|
122
|
+
[a, F]
|
|
123
|
+
), q = I((e) => {
|
|
124
|
+
e.stopPropagation(), v((o) => !o), N(!1);
|
|
125
|
+
}, []), R = I(
|
|
126
|
+
(e, o) => {
|
|
127
|
+
var r, u, z, h;
|
|
128
|
+
switch (e.key) {
|
|
129
|
+
case "ArrowDown":
|
|
130
|
+
e.preventDefault(), o < d.length - 1 && ((r = g.current[o + 1]) == null || r.focus());
|
|
131
|
+
break;
|
|
132
|
+
case "ArrowUp":
|
|
133
|
+
e.preventDefault(), o > 0 && ((u = g.current[o - 1]) == null || u.focus());
|
|
134
|
+
break;
|
|
135
|
+
case "Home":
|
|
136
|
+
e.preventDefault(), (z = g.current[0]) == null || z.focus();
|
|
137
|
+
break;
|
|
138
|
+
case "End":
|
|
139
|
+
e.preventDefault(), (h = g.current[d.length - 1]) == null || h.focus();
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
[d.length]
|
|
144
|
+
), L = _(), P = _();
|
|
145
|
+
return k(() => {
|
|
146
|
+
L.current = (e) => {
|
|
147
|
+
S.current && !S.current.contains(e.target) && v(!1);
|
|
148
|
+
}, P.current = (e) => {
|
|
149
|
+
e.key === "Escape" && v(!1);
|
|
150
|
+
};
|
|
151
|
+
}), k(() => {
|
|
152
|
+
if (!y) return;
|
|
153
|
+
const e = (r) => {
|
|
154
|
+
var u;
|
|
155
|
+
return (u = L.current) == null ? void 0 : u.call(L, r);
|
|
156
|
+
}, o = (r) => {
|
|
157
|
+
var u;
|
|
158
|
+
return (u = P.current) == null ? void 0 : u.call(P, r);
|
|
159
|
+
};
|
|
160
|
+
return document.addEventListener("mousedown", e), document.addEventListener("keydown", o), () => {
|
|
161
|
+
document.removeEventListener("mousedown", e), document.removeEventListener("keydown", o);
|
|
162
|
+
};
|
|
163
|
+
}, [y]), k(() => {
|
|
164
|
+
if (process.env.NODE_ENV === "development" && p.length > 0) {
|
|
165
|
+
const e = p.map((r) => r.value), o = new Set(e);
|
|
166
|
+
e.length !== o.size && console.warn(
|
|
167
|
+
"[ChipGroup] Duplicate values detected in items array. Each item should have a unique value."
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
}, [p]), k(() => {
|
|
171
|
+
g.current.length > d.length && (g.current = g.current.slice(0, d.length));
|
|
172
|
+
}, [d]), !t || !Array.isArray(t) ? null : /* @__PURE__ */ O(
|
|
20
173
|
"div",
|
|
21
174
|
{
|
|
22
|
-
ref:
|
|
23
|
-
className:
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
175
|
+
ref: f,
|
|
176
|
+
className: x("chip-group", a && "chip-group--disabled", D),
|
|
177
|
+
role: "group",
|
|
178
|
+
"aria-label": "Chip group",
|
|
179
|
+
"data-testid": E || "chip-group",
|
|
180
|
+
"data-cy": $ || "chip-group",
|
|
181
|
+
...C,
|
|
182
|
+
children: [
|
|
183
|
+
V && /* @__PURE__ */ O(
|
|
184
|
+
"div",
|
|
185
|
+
{
|
|
186
|
+
className: "sr-only",
|
|
187
|
+
role: "status",
|
|
188
|
+
"aria-live": "polite",
|
|
189
|
+
"aria-atomic": "true",
|
|
190
|
+
"data-testid": "chip-group-live-region",
|
|
191
|
+
"data-cy": "chip-group-live-region",
|
|
192
|
+
children: [
|
|
193
|
+
d.length,
|
|
194
|
+
" additional ",
|
|
195
|
+
d.length === 1 ? "chip" : "chips",
|
|
196
|
+
" hidden"
|
|
197
|
+
]
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
/* @__PURE__ */ O("div", { ref: T, className: "chip-group__container", children: [
|
|
201
|
+
A.map((e) => {
|
|
202
|
+
const o = c === e.value, r = e.variant || w, u = a || e.disabled || !1, z = p.findIndex((h) => h.value === e.value);
|
|
203
|
+
return /* @__PURE__ */ b(
|
|
204
|
+
"div",
|
|
205
|
+
{
|
|
206
|
+
ref: (h) => {
|
|
207
|
+
h ? M.current[z] = h : M.current[z] = null;
|
|
208
|
+
},
|
|
209
|
+
className: "chip-group__item-wrapper",
|
|
210
|
+
"data-cy": `chip-group-item-wrapper-${e.value}`,
|
|
211
|
+
"data-testid": `chip-group-item-wrapper-${e.value}`,
|
|
212
|
+
children: /* @__PURE__ */ O(
|
|
213
|
+
"div",
|
|
214
|
+
{
|
|
215
|
+
className: "chip-group__item",
|
|
216
|
+
onClick: (h) => F(e.value, u, h),
|
|
217
|
+
onKeyDown: (h) => U(h, e.value, u),
|
|
218
|
+
tabIndex: u ? -1 : 0,
|
|
219
|
+
role: "button",
|
|
220
|
+
"aria-pressed": o ? "true" : "false",
|
|
221
|
+
"aria-disabled": u ? "true" : "false",
|
|
222
|
+
"data-cy": `chip-group-item-${e.value}`,
|
|
223
|
+
"data-testid": `chip-group-item-${e.value}`,
|
|
224
|
+
children: [
|
|
225
|
+
/* @__PURE__ */ b(
|
|
226
|
+
G,
|
|
227
|
+
{
|
|
228
|
+
variant: r,
|
|
229
|
+
selected: o,
|
|
230
|
+
disabled: u,
|
|
231
|
+
"data-cy": `chip-${e.value}`,
|
|
232
|
+
"data-testid": `chip-${e.value}`,
|
|
233
|
+
children: e.label
|
|
234
|
+
}
|
|
235
|
+
),
|
|
236
|
+
l && !a && !u && /* @__PURE__ */ b(
|
|
237
|
+
"button",
|
|
238
|
+
{
|
|
239
|
+
className: "chip-group__remove",
|
|
240
|
+
onClick: (h) => j(h, e.value),
|
|
241
|
+
"aria-label": `Remove ${e.label}`,
|
|
242
|
+
"data-cy": `chip-remove-${e.value}`,
|
|
243
|
+
"data-testid": `chip-remove-${e.value}`,
|
|
244
|
+
type: "button",
|
|
245
|
+
children: /* @__PURE__ */ b(J, { name: "Cross2Icon", size: "sm", decorative: !0 })
|
|
246
|
+
}
|
|
247
|
+
)
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
)
|
|
251
|
+
},
|
|
252
|
+
e.value
|
|
253
|
+
);
|
|
254
|
+
}),
|
|
255
|
+
V && /* @__PURE__ */ O(
|
|
256
|
+
"div",
|
|
257
|
+
{
|
|
258
|
+
ref: S,
|
|
259
|
+
className: "chip-group__overflow",
|
|
260
|
+
role: "button",
|
|
261
|
+
tabIndex: 0,
|
|
262
|
+
"aria-expanded": y ? "true" : "false",
|
|
263
|
+
"aria-haspopup": "menu",
|
|
264
|
+
"aria-label": `Show ${d.length} more ${d.length === 1 ? "chip" : "chips"}`,
|
|
265
|
+
onMouseEnter: () => !y && N(!0),
|
|
266
|
+
onMouseLeave: () => N(!1),
|
|
267
|
+
onClick: q,
|
|
268
|
+
onKeyDown: (e) => {
|
|
269
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), e.stopPropagation(), v(!y), N(!1));
|
|
270
|
+
},
|
|
271
|
+
"data-cy": "chip-group-overflow",
|
|
272
|
+
"data-testid": "chip-group-overflow",
|
|
273
|
+
children: [
|
|
274
|
+
/* @__PURE__ */ O(G, { variant: w, "data-cy": "chip-overflow", "data-testid": "chip-overflow", children: [
|
|
275
|
+
"+",
|
|
276
|
+
d.length
|
|
277
|
+
] }),
|
|
278
|
+
K && !y && /* @__PURE__ */ b(
|
|
279
|
+
"div",
|
|
280
|
+
{
|
|
281
|
+
className: "chip-group__tooltip chip-group__tooltip--hover",
|
|
282
|
+
role: "tooltip",
|
|
283
|
+
"data-cy": "chip-group-tooltip",
|
|
284
|
+
"data-testid": "chip-group-tooltip",
|
|
285
|
+
children: d.map((e) => /* @__PURE__ */ b(
|
|
286
|
+
"div",
|
|
287
|
+
{
|
|
288
|
+
className: "chip-group__tooltip-item",
|
|
289
|
+
"data-cy": `chip-group-tooltip-item-${e.value}`,
|
|
290
|
+
"data-testid": `chip-group-tooltip-item-${e.value}`,
|
|
291
|
+
children: e.label
|
|
292
|
+
},
|
|
293
|
+
e.value
|
|
294
|
+
))
|
|
295
|
+
}
|
|
296
|
+
),
|
|
297
|
+
y && /* @__PURE__ */ b(
|
|
298
|
+
"div",
|
|
299
|
+
{
|
|
300
|
+
className: "chip-group__dropdown",
|
|
301
|
+
role: "menu",
|
|
302
|
+
"data-cy": "chip-group-dropdown",
|
|
303
|
+
"data-testid": "chip-group-dropdown",
|
|
304
|
+
children: d.map((e, o) => /* @__PURE__ */ b(
|
|
305
|
+
"div",
|
|
306
|
+
{
|
|
307
|
+
ref: (r) => {
|
|
308
|
+
r ? g.current[o] = r : g.current[o] = null;
|
|
309
|
+
},
|
|
310
|
+
className: x(
|
|
311
|
+
"chip-group__dropdown-item",
|
|
312
|
+
e.disabled && "chip-group__dropdown-item--disabled"
|
|
313
|
+
),
|
|
314
|
+
role: "menuitem",
|
|
315
|
+
tabIndex: e.disabled ? -1 : 0,
|
|
316
|
+
"aria-disabled": e.disabled ? "true" : "false",
|
|
317
|
+
onClick: (r) => {
|
|
318
|
+
r.stopPropagation(), e.disabled || (F(e.value, !1, r), v(!1));
|
|
319
|
+
},
|
|
320
|
+
onKeyDown: (r) => {
|
|
321
|
+
R(r, o), (r.key === "Enter" || r.key === " ") && (r.preventDefault(), r.stopPropagation(), e.disabled || (F(e.value, !1, r), v(!1)));
|
|
322
|
+
},
|
|
323
|
+
"data-cy": `chip-group-dropdown-item-${e.value}`,
|
|
324
|
+
"data-testid": `chip-group-dropdown-item-${e.value}`,
|
|
325
|
+
children: e.label
|
|
326
|
+
},
|
|
327
|
+
e.value
|
|
328
|
+
))
|
|
329
|
+
}
|
|
330
|
+
)
|
|
331
|
+
]
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
] })
|
|
335
|
+
]
|
|
36
336
|
}
|
|
37
337
|
);
|
|
38
338
|
}
|
|
39
339
|
);
|
|
40
|
-
|
|
340
|
+
ee.displayName = "ChipGroup";
|
|
41
341
|
export {
|
|
42
|
-
|
|
342
|
+
ee as ChipGroup
|
|
43
343
|
};
|
package/dist/index15.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function t(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),c=require("react"),T=require("@radix-ui/react-dialog"),r=require("./index17.cjs");;/* empty css */function j(a){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const t in a)if(t!=="default"){const i=Object.getOwnPropertyDescriptor(a,t);Object.defineProperty(e,t,i.get?i:{enumerable:!0,get:()=>a[t]})}}return e.default=a,Object.freeze(e)}const o=j(T),v=o.Root,C=o.Trigger,y=o.Portal,x=o.Close,g=c.forwardRef(({className:a,"data-cy":e,"data-testid":t,...i},l)=>{const s=e||"dialog-overlay",n=t||"dialog-overlay";return d.jsx(o.Overlay,{ref:l,className:r.cn("dialog-overlay",a),"data-cy":s,"data-testid":n,...i})});g.displayName=o.Overlay.displayName;const D=c.forwardRef(({className:a,children:e,"data-cy":t,"data-testid":i,...l},s)=>{const n=t||"dialog-content",N=i||"dialog-content";return d.jsxs(y,{children:[d.jsx(g,{}),d.jsx(o.Content,{ref:s,className:r.cn("dialog-content",a),"data-cy":n,"data-testid":N,...l,children:e})]})});D.displayName=o.Content.displayName;const f=({className:a,"data-cy":e,"data-testid":t,...i})=>{const l=e||"dialog-header",s=t||"dialog-header";return d.jsx("div",{className:r.cn("dialog-header",a),"data-cy":l,"data-testid":s,...i})};f.displayName="DialogHeader";const u=({className:a,"data-cy":e,"data-testid":t,...i})=>{const l=e||"dialog-footer",s=t||"dialog-footer";return d.jsx("div",{className:r.cn("dialog-footer",a),"data-cy":l,"data-testid":s,...i})};u.displayName="DialogFooter";const m=c.forwardRef(({className:a,"data-cy":e,"data-testid":t,...i},l)=>{const s=e||"dialog-title",n=t||"dialog-title";return d.jsx(o.Title,{ref:l,className:r.cn("dialog-title",a),"data-cy":s,"data-testid":n,...i})});m.displayName=o.Title.displayName;const p=c.forwardRef(({className:a,"data-cy":e,"data-testid":t,...i},l)=>{const s=e||"dialog-description",n=t||"dialog-description";return d.jsx(o.Description,{ref:l,className:r.cn("dialog-description",a),"data-cy":s,"data-testid":n,...i})});p.displayName=o.Description.displayName;exports.Dialog=v;exports.DialogClose=x;exports.DialogContent=D;exports.DialogDescription=p;exports.DialogFooter=u;exports.DialogHeader=f;exports.DialogOverlay=g;exports.DialogPortal=y;exports.DialogTitle=m;exports.DialogTrigger=C;
|