@adam-milo/ui 1.0.18 → 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 +27 -25
- package/dist/index10.cjs +1 -1
- package/dist/index10.js +1 -1
- package/dist/index11.cjs +1 -1
- package/dist/index11.js +1 -1
- package/dist/index12.cjs +1 -1
- package/dist/index12.js +1 -1
- package/dist/index13.cjs +1 -1
- package/dist/index13.js +1 -1
- package/dist/index14.cjs +1 -1
- package/dist/index14.js +331 -103
- package/dist/index15.cjs +1 -1
- package/dist/index15.js +107 -35
- package/dist/index16.cjs +1 -1
- package/dist/index16.js +41 -9
- 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 +1 -1
- package/dist/index8.cjs +1 -1
- package/dist/index8.js +1 -1
- package/dist/index9.cjs +1 -1
- package/dist/index9.js +1 -1
- 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/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index2.cjs"),i=require("./index3.cjs"),c=require("./index4.cjs"),l=require("./index5.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./index2.cjs"),i=require("./index3.cjs"),c=require("./index4.cjs"),l=require("./index5.cjs"),u=require("./index6.cjs"),p=require("./index7.cjs"),s=require("./index8.cjs"),t=require("./index9.cjs"),g=require("./index10.cjs"),o=require("./index11.cjs"),d=require("./index12.cjs"),C=require("./index13.cjs"),D=require("./index14.cjs"),e=require("./index15.cjs"),m=require("./index16.cjs"),r=require("./index17.cjs"),n=require("@adam-milo/icons");exports.Button=a.Button;exports.EmailInput=i.EmailInput;exports.PasswordInput=c.PasswordInput;exports.NumericInput=l.NumericInput;exports.AlphanumericInput=u.AlphanumericInput;exports.Checkbox=p.Checkbox;exports.Radio=s.Radio;exports.Tabs=t.Tabs;exports.TabsContent=t.TabsContent;exports.TabsList=t.TabsList;exports.TabsTrigger=t.TabsTrigger;exports.Alert=g.Alert;exports.Card=o.Card;exports.CardContent=o.CardContent;exports.CardDescription=o.CardDescription;exports.CardFooter=o.CardFooter;exports.CardHeader=o.CardHeader;exports.CardTitle=o.CardTitle;exports.DataTable=d.DataTable;exports.Chip=C.Chip;exports.ChipGroup=D.ChipGroup;exports.Dialog=e.Dialog;exports.DialogClose=e.DialogClose;exports.DialogContent=e.DialogContent;exports.DialogDescription=e.DialogDescription;exports.DialogFooter=e.DialogFooter;exports.DialogHeader=e.DialogHeader;exports.DialogOverlay=e.DialogOverlay;exports.DialogPortal=e.DialogPortal;exports.DialogTitle=e.DialogTitle;exports.DialogTrigger=e.DialogTrigger;exports.Stack=m.Stack;exports.cn=r.cn;exports.generateId=r.generateId;Object.defineProperty(exports,"Icon",{enumerable:!0,get:()=>n.Icon});Object.defineProperty(exports,"availableIcons",{enumerable:!0,get:()=>n.availableIcons});
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import { Button as e } from "./index2.js";
|
|
2
2
|
import { EmailInput as a } from "./index3.js";
|
|
3
|
-
import { PasswordInput as
|
|
3
|
+
import { PasswordInput as i } from "./index4.js";
|
|
4
4
|
import { NumericInput as m } from "./index5.js";
|
|
5
5
|
import { AlphanumericInput as x } from "./index6.js";
|
|
6
6
|
import { Checkbox as g } from "./index7.js";
|
|
7
|
-
import { Radio as
|
|
8
|
-
import { Tabs as s, TabsContent as c, TabsList as T, TabsTrigger as
|
|
7
|
+
import { Radio as D } from "./index8.js";
|
|
8
|
+
import { Tabs as s, TabsContent as c, TabsList as T, TabsTrigger as u } from "./index9.js";
|
|
9
9
|
import { Alert as I } from "./index10.js";
|
|
10
10
|
import { Card as k, CardContent as v, CardDescription as A, CardFooter as F, CardHeader as H, CardTitle as P } from "./index11.js";
|
|
11
11
|
import { DataTable as y } from "./index12.js";
|
|
12
12
|
import { Chip as E } from "./index13.js";
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
13
|
+
import { ChipGroup as L } from "./index14.js";
|
|
14
|
+
import { Dialog as O, DialogClose as R, DialogContent as S, DialogDescription as j, DialogFooter as q, DialogHeader as z, DialogOverlay as J, DialogPortal as K, DialogTitle as M, DialogTrigger as Q } from "./index15.js";
|
|
15
|
+
import { Stack as V } from "./index16.js";
|
|
16
|
+
import { cn as X, generateId as Y } from "./index17.js";
|
|
17
|
+
import { Icon as _, availableIcons as $ } from "@adam-milo/icons";
|
|
17
18
|
export {
|
|
18
19
|
I as Alert,
|
|
19
20
|
x as AlphanumericInput,
|
|
@@ -26,28 +27,29 @@ export {
|
|
|
26
27
|
P as CardTitle,
|
|
27
28
|
g as Checkbox,
|
|
28
29
|
E as Chip,
|
|
30
|
+
L as ChipGroup,
|
|
29
31
|
y as DataTable,
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
O as Dialog,
|
|
33
|
+
R as DialogClose,
|
|
34
|
+
S as DialogContent,
|
|
35
|
+
j as DialogDescription,
|
|
36
|
+
q as DialogFooter,
|
|
37
|
+
z as DialogHeader,
|
|
38
|
+
J as DialogOverlay,
|
|
39
|
+
K as DialogPortal,
|
|
40
|
+
M as DialogTitle,
|
|
41
|
+
Q as DialogTrigger,
|
|
40
42
|
a as EmailInput,
|
|
41
|
-
|
|
43
|
+
_ as Icon,
|
|
42
44
|
m as NumericInput,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
i as PasswordInput,
|
|
46
|
+
D as Radio,
|
|
47
|
+
V as Stack,
|
|
46
48
|
s as Tabs,
|
|
47
49
|
c as TabsContent,
|
|
48
50
|
T as TabsList,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
u as TabsTrigger,
|
|
52
|
+
$ as availableIcons,
|
|
53
|
+
X as cn,
|
|
54
|
+
Y as generateId
|
|
53
55
|
};
|
package/dist/index10.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("react"),f=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),m=require("react"),f=require("./index17.cjs");;/* empty css */const c=m.forwardRef(({variant:s="info",title:r,icon:d,className:i,children:l,"data-cy":n,"data-testid":o,...u},$)=>{const y={info:"status",success:"status",warning:"alert",error:"alert"},t=n||`alert-${s}`,e=o||`alert-${s}`;return a.jsxs("div",{ref:$,role:y[s],className:f.cn("alert",`alert--${s}`,i),"data-cy":t,"data-testid":e,...u,children:[d&&a.jsx("div",{className:"alert__icon","data-cy":`${t}-icon`,"data-testid":`${e}-icon`,children:d}),a.jsxs("div",{className:"alert__content","data-cy":`${t}-content`,"data-testid":`${e}-content`,children:[r&&a.jsx("div",{className:"alert__title","data-cy":`${t}-title`,"data-testid":`${e}-title`,children:r}),a.jsx("div",{"data-cy":`${t}-message`,"data-testid":`${e}-message`,children:l})]})]})});c.displayName="Alert";exports.Alert=c;
|
package/dist/index10.js
CHANGED
package/dist/index11.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("react"),o=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),i=require("react"),o=require("./index17.cjs");;/* empty css */const l=i.forwardRef(({variant:a="default",className:t,children:d,"data-cy":e,"data-testid":r,...c},s)=>{const p=e||`card-${a}`,N=r||`card-${a}`;return n.jsx("div",{ref:s,className:o.cn("card",`card--${a}`,t),"data-cy":p,"data-testid":N,...c,children:d})});l.displayName="Card";const f=i.forwardRef(({className:a,"data-cy":t,"data-testid":d,...e},r)=>{const c=t||"card-header",s=d||"card-header";return n.jsx("div",{ref:r,className:o.cn("card-header",a),"data-cy":c,"data-testid":s,...e})});f.displayName="CardHeader";const C=i.forwardRef(({className:a,"data-cy":t,"data-testid":d,...e},r)=>{const c=t||"card-title",s=d||"card-title";return n.jsx("h3",{ref:r,className:o.cn("card-title",a),"data-cy":c,"data-testid":s,...e})});C.displayName="CardTitle";const y=i.forwardRef(({className:a,"data-cy":t,"data-testid":d,...e},r)=>{const c=t||"card-description",s=d||"card-description";return n.jsx("p",{ref:r,className:o.cn("card-description",a),"data-cy":c,"data-testid":s,...e})});y.displayName="CardDescription";const u=i.forwardRef(({className:a,"data-cy":t,"data-testid":d,...e},r)=>{const c=t||"card-content",s=d||"card-content";return n.jsx("div",{ref:r,className:o.cn("card-content",a),"data-cy":c,"data-testid":s,...e})});u.displayName="CardContent";const m=i.forwardRef(({className:a,"data-cy":t,"data-testid":d,...e},r)=>{const c=t||"card-footer",s=d||"card-footer";return n.jsx("div",{ref:r,className:o.cn("card-footer",a),"data-cy":c,"data-testid":s,...e})});m.displayName="CardFooter";exports.Card=l;exports.CardContent=u;exports.CardDescription=y;exports.CardFooter=m;exports.CardHeader=f;exports.CardTitle=C;
|
package/dist/index11.js
CHANGED
package/dist/index12.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),j=require("react"),c=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),j=require("react"),c=require("./index17.cjs");;/* empty css */const y=j.forwardRef(({columns:r,data:i,striped:b=!1,hoverable:h=!1,className:$,"data-cy":n,"data-testid":p,...o},_)=>{const e=n||"datatable",t=p||"datatable";return a.jsx("div",{className:"datatable-wrapper","data-cy":`${e}-wrapper`,"data-testid":`${t}-wrapper`,children:a.jsxs("table",{ref:_,className:c.cn("datatable",$),"data-cy":e,"data-testid":t,...o,children:[a.jsx("thead",{className:"datatable__head","data-cy":`${e}-head`,"data-testid":`${t}-head`,children:a.jsx("tr",{children:r.map(d=>a.jsx("th",{className:"datatable__header-cell","data-cy":`${e}-header-${d.key}`,"data-testid":`${t}-header-${d.key}`,children:d.header},d.key))})}),a.jsx("tbody",{"data-cy":`${e}-body`,"data-testid":`${t}-body`,children:i.length===0?a.jsx("tr",{children:a.jsx("td",{colSpan:r.length,className:"datatable__empty","data-cy":`${e}-empty`,"data-testid":`${t}-empty`,children:"No data available"})}):i.map((d,l)=>a.jsx("tr",{className:c.cn("datatable__body-row",h&&"datatable__body-row--hoverable",b&&"datatable__body-row--striped"),"data-cy":`${e}-row-${l}`,"data-testid":`${t}-row-${l}`,children:r.map(s=>a.jsx("td",{className:"datatable__body-cell","data-cy":`${e}-cell-${l}-${s.key}`,"data-testid":`${t}-cell-${l}-${s.key}`,children:String(d[s.key]??"")},s.key))},l))})]})})});y.displayName="DataTable";exports.DataTable=y;
|
package/dist/index12.js
CHANGED
package/dist/index13.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),h=require("react"),u=require("./
|
|
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
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,115 +1,343 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
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";
|
|
5
5
|
/* empty css */
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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;
|
|
16
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]
|
|
17
46
|
);
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
/* @__PURE__ */ n(g, {}),
|
|
24
|
-
/* @__PURE__ */ n(
|
|
25
|
-
a.Content,
|
|
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
|
|
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
52
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
f.
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
|
|
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);
|
|
70
59
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
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(
|
|
88
|
+
({
|
|
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(
|
|
173
|
+
"div",
|
|
79
174
|
{
|
|
80
|
-
ref:
|
|
81
|
-
className:
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
|
|
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
|
+
]
|
|
85
336
|
}
|
|
86
337
|
);
|
|
87
338
|
}
|
|
88
339
|
);
|
|
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;
|
|
340
|
+
ee.displayName = "ChipGroup";
|
|
104
341
|
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
|
|
342
|
+
ee as ChipGroup
|
|
115
343
|
};
|