@purpurds/dismissable-chip-group 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.txt +45 -0
- package/dist/dismissable-chip-group-item.d.ts +14 -0
- package/dist/dismissable-chip-group-item.d.ts.map +1 -0
- package/dist/dismissable-chip-group.cjs.js +14 -0
- package/dist/dismissable-chip-group.cjs.js.map +1 -0
- package/dist/dismissable-chip-group.d.ts +20 -0
- package/dist/dismissable-chip-group.d.ts.map +1 -0
- package/dist/dismissable-chip-group.es.js +291 -0
- package/dist/dismissable-chip-group.es.js.map +1 -0
- package/dist/metadata.js +7 -0
- package/dist/styles.css +1 -0
- package/eslint.config.mjs +2 -0
- package/package.json +74 -0
- package/src/dismissable-chip-group-item.tsx +52 -0
- package/src/dismissable-chip-group.module.scss +88 -0
- package/src/dismissable-chip-group.stories.tsx +188 -0
- package/src/dismissable-chip-group.test.tsx +152 -0
- package/src/dismissable-chip-group.tsx +59 -0
- package/src/global.d.ts +4 -0
package/dist/LICENSE.txt
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
Name: @purpurds/heading
|
|
2
|
+
Version: 7.0.0
|
|
3
|
+
License: AGPL-3.0-only
|
|
4
|
+
Private: false
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
Name: classnames
|
|
9
|
+
Version: 2.5.1
|
|
10
|
+
License: MIT
|
|
11
|
+
Private: false
|
|
12
|
+
Description: A simple utility for conditionally joining classNames together
|
|
13
|
+
Repository: git+https://github.com/JedWatson/classnames.git
|
|
14
|
+
Author: Jed Watson
|
|
15
|
+
License Copyright:
|
|
16
|
+
===
|
|
17
|
+
|
|
18
|
+
The MIT License (MIT)
|
|
19
|
+
|
|
20
|
+
Copyright (c) 2018 Jed Watson
|
|
21
|
+
|
|
22
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
23
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
24
|
+
in the Software without restriction, including without limitation the rights
|
|
25
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
26
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
27
|
+
furnished to do so, subject to the following conditions:
|
|
28
|
+
|
|
29
|
+
The above copyright notice and this permission notice shall be included in all
|
|
30
|
+
copies or substantial portions of the Software.
|
|
31
|
+
|
|
32
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
33
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
34
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
35
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
36
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
37
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
38
|
+
SOFTWARE.
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
Name: @purpurds/icon
|
|
43
|
+
Version: 7.0.0
|
|
44
|
+
License: AGPL-3.0-only
|
|
45
|
+
Private: false
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export type DismissableChipGroupItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
4
|
+
["aria-label"]: string;
|
|
5
|
+
["data-testid"]?: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
id?: string;
|
|
8
|
+
onDismiss?: (id?: string) => void;
|
|
9
|
+
};
|
|
10
|
+
export declare const DismissableChipGroupItem: {
|
|
11
|
+
({ children, id, onDismiss, disabled, ...props }: DismissableChipGroupItemProps): React.JSX.Element;
|
|
12
|
+
displayName: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=dismissable-chip-group-item.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismissable-chip-group-item.d.ts","sourceRoot":"","sources":["../src/dismissable-chip-group-item.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAc,SAAS,EAAE,MAAM,OAAO,CAAC;AAOrD,MAAM,MAAM,6BAA6B,GAAG,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAC1F,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IACvB,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAIF,eAAO,MAAM,wBAAwB;sDAMlC,6BAA6B;;CA0B/B,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("react/jsx-runtime"),q=require("react");function I(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var f={exports:{}};/*!
|
|
2
|
+
Copyright (c) 2018 Jed Watson.
|
|
3
|
+
Licensed under the MIT License (MIT), see
|
|
4
|
+
http://jedwatson.github.io/classnames
|
|
5
|
+
*/var g;function T(){return g||(g=1,function(i){(function(){var u={}.hasOwnProperty;function t(){for(var r="",e=0;e<arguments.length;e++){var n=arguments[e];n&&(r=s(r,p(n)))}return r}function p(r){if(typeof r=="string"||typeof r=="number")return r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(null,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var e="";for(var n in r)u.call(r,n)&&r[n]&&(e=s(e,n));return e}function s(r,e){return e?r?r+" "+e:r+e:r}i.exports?(t.default=t,i.exports=t):window.classNames=t})()}(f)),f.exports}var L=T();const P=I(L),o={"purpur-heading":"_purpur-heading_k9fhq_1","purpur-heading--hyphens":"_purpur-heading--hyphens_k9fhq_8","purpur-heading--negative":"_purpur-heading--negative_k9fhq_11","purpur-heading--subsection-100":"_purpur-heading--subsection-100_k9fhq_14","purpur-heading--title-100":"_purpur-heading--title-100_k9fhq_20","purpur-heading--title-200":"_purpur-heading--title-200_k9fhq_26","purpur-heading--title-300":"_purpur-heading--title-300_k9fhq_32","purpur-heading--title-400":"_purpur-heading--title-400_k9fhq_38","purpur-heading--title-500":"_purpur-heading--title-500_k9fhq_44","purpur-heading--title-600":"_purpur-heading--title-600_k9fhq_50","purpur-heading--title-700":"_purpur-heading--title-700_k9fhq_56","purpur-heading--display-25":"_purpur-heading--display-25_k9fhq_62","purpur-heading--display-50":"_purpur-heading--display-50_k9fhq_68","purpur-heading--display-100":"_purpur-heading--display-100_k9fhq_74","purpur-heading--display-200":"_purpur-heading--display-200_k9fhq_80"},A={TITLE100:"title-100"},l="purpur-heading",$=({children:i,className:u="",enableHyphenation:t=!1,negative:p=!1,tag:s,variant:r=A.TITLE100,...e})=>{const n=s,C=P([u,o[l],o[`${l}--${r}`],{[o[`${l}--hyphens`]]:t,[o[`${l}--negative`]]:p}]);return a.jsx(n,{className:C,...e,children:i})};$.displayName="Heading";function M(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var c={exports:{}};/*!
|
|
6
|
+
Copyright (c) 2018 Jed Watson.
|
|
7
|
+
Licensed under the MIT License (MIT), see
|
|
8
|
+
http://jedwatson.github.io/classnames
|
|
9
|
+
*/var m;function E(){return m||(m=1,function(i){(function(){var u={}.hasOwnProperty;function t(){for(var r="",e=0;e<arguments.length;e++){var n=arguments[e];n&&(r=s(r,p.call(this,n)))}return r}function p(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var e="";for(var n in r)u.call(r,n)&&r[n]&&(e=s(e,this&&this[n]||n));return e}function s(r,e){return e?r?r+" "+e:r+e:r}i.exports?(t.default=t,i.exports=t):window.classNames=t})()}(c)),c.exports}var G=E();const j=M(G),N={"purpur-dismissable-chip-group":"_purpur-dismissable-chip-group_15nn8_1","purpur-dismissable-chip-group__container":"_purpur-dismissable-chip-group__container_15nn8_7","purpur-dismissable-chip-group__container--full-width":"_purpur-dismissable-chip-group__container--full-width_15nn8_14","purpur-dismissable-chip-group-item-wrapper":"_purpur-dismissable-chip-group-item-wrapper_15nn8_17","purpur-dismissable-chip-group-item":"_purpur-dismissable-chip-group-item_15nn8_17","purpur-dismissable-chip-group-item--disabled":"_purpur-dismissable-chip-group-item--disabled_15nn8_43"};function B(i){return i&&i.__esModule&&Object.prototype.hasOwnProperty.call(i,"default")?i.default:i}var v={exports:{}};/*!
|
|
10
|
+
Copyright (c) 2018 Jed Watson.
|
|
11
|
+
Licensed under the MIT License (MIT), see
|
|
12
|
+
http://jedwatson.github.io/classnames
|
|
13
|
+
*/var y;function D(){return y||(y=1,function(i){(function(){var u={}.hasOwnProperty;function t(){for(var r="",e=0;e<arguments.length;e++){var n=arguments[e];n&&(r=s(r,p.call(this,n)))}return r}function p(r){if(typeof r=="string"||typeof r=="number")return this&&this[r]||r;if(typeof r!="object")return"";if(Array.isArray(r))return t.apply(this,r);if(r.toString!==Object.prototype.toString&&!r.toString.toString().includes("[native code]"))return r.toString();var e="";for(var n in r)u.call(r,n)&&r[n]&&(e=s(e,this&&this[n]||n));return e}function s(r,e){return e?r?r+" "+e:r+e:r}i.exports?(t.default=t,i.exports=t):window.classNames=t})()}(v)),v.exports}var H=D();const z=B(H),R={"purpur-icon":"_purpur-icon_8u1lq_1","purpur-icon--xxs":"_purpur-icon--xxs_8u1lq_4","purpur-icon--xs":"_purpur-icon--xs_8u1lq_8","purpur-icon--sm":"_purpur-icon--sm_8u1lq_12","purpur-icon--md":"_purpur-icon--md_8u1lq_16","purpur-icon--lg":"_purpur-icon--lg_8u1lq_20","purpur-icon--xl":"_purpur-icon--xl_8u1lq_24"},F=z.bind(R),b="purpur-icon",V="md",Z=i=>i.filter(u=>Object.keys(u).length>=1).map(u=>`${u.name}="${u.value}"`).join(" "),J=({content:i="",title:u}={})=>{const t=[{name:"xmlns",value:"http://www.w3.org/2000/svg"},{name:"fill",value:"currentColor"},{name:"viewBox",value:"0 0 24 24"},u?{name:"role",value:"img"}:{name:"aria-hidden",value:"true"}],p=u?`<title>${u}</title>`:"";return`<svg ${Z(t)}>${p}${i}</svg>`},K=i=>i.replace(/<(\/?)svg([^>]*)>/g,"").trim(),S=({["data-testid"]:i,svg:u,allyTitle:t,className:p,size:s=V,...r})=>{const e=J({content:K(u.svg),title:t}),n=F(p,b,`${b}--${s}`);return a.jsx("span",{className:n,"data-testid":i,dangerouslySetInnerHTML:{__html:e},...r})};S.displayName="Icon";const Q={name:"close",svg:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M4.864 4.864a.9.9 0 0 1 1.273 0L12 10.727l5.864-5.863a.9.9 0 0 1 1.272 1.272L13.273 12l5.863 5.864a.9.9 0 1 1-1.272 1.272L12 13.273l-5.863 5.863a.9.9 0 0 1-1.273-1.272L10.727 12 4.864 6.136a.9.9 0 0 1 0-1.272Z" clip-rule="evenodd"/></svg>',keywords:["close"],category:"utility"},k=i=>a.jsx(S,{...i,svg:Q});k.displayName="IconClose";const x=j.bind(N),d="purpur-dismissable-chip-group-item",O=({children:i,id:u,onDismiss:t,disabled:p,...s})=>{const r=e=>{p?e.preventDefault():t==null||t(u)};return a.jsx("li",{className:x(`${d}-wrapper`),children:q.createElement("button",{...s,className:x(`${d}`,{[`${d}--disabled`]:p}),key:u,disabled:p,"aria-disabled":p,onClick:r},i,a.jsx(k,{size:"sm"}))},u)};O.displayName="DismissableChipGroupItem";const w=j.bind(N),h="purpur-dismissable-chip-group",_=({children:i,className:u,fullWidth:t=!1,title:p,titleTag:s,...r})=>{const e=q.useId(),n=w([u,h]);return a.jsxs("div",{...r,"aria-labelledby":p?`${e}-label`:void 0,className:n,role:"group",children:[p&&a.jsx($,{tag:s??"h2",variant:"subsection-100",children:p}),a.jsx("ul",{"data-testid":"dismissable-chip-group-container",className:w(`${h}__container`,{[`${h}__container--full-width`]:t}),"aria-live":"polite","aria-relevant":"additions removals",children:i})]})};_.Item=O;_.displayName="DismissableChipGroup";exports.DismissableChipGroup=_;
|
|
14
|
+
//# sourceMappingURL=dismissable-chip-group.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismissable-chip-group.cjs.js","sources":["../../heading/dist/heading.es.js","../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../../icon/dist/icon-BqK8slmm.mjs","../../icon/dist/components/close.es.js","../src/dismissable-chip-group-item.tsx","../src/dismissable-chip-group.tsx"],"sourcesContent":["import { jsx as _ } from \"react/jsx-runtime\";\nfunction f(t) {\n return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, \"default\") ? t.default : t;\n}\nvar l = { exports: {} };\n/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\nvar d;\nfunction g() {\n return d || (d = 1, function(t) {\n (function() {\n var s = {}.hasOwnProperty;\n function n() {\n for (var e = \"\", r = 0; r < arguments.length; r++) {\n var i = arguments[r];\n i && (e = p(e, h(i)));\n }\n return e;\n }\n function h(e) {\n if (typeof e == \"string\" || typeof e == \"number\")\n return e;\n if (typeof e != \"object\")\n return \"\";\n if (Array.isArray(e))\n return n.apply(null, e);\n if (e.toString !== Object.prototype.toString && !e.toString.toString().includes(\"[native code]\"))\n return e.toString();\n var r = \"\";\n for (var i in e)\n s.call(e, i) && e[i] && (r = p(r, i));\n return r;\n }\n function p(e, r) {\n return r ? e ? e + \" \" + r : e + r : e;\n }\n t.exports ? (n.default = n, t.exports = n) : window.classNames = n;\n })();\n }(l)), l.exports;\n}\nvar c = g();\nconst y = /* @__PURE__ */ f(c), u = {\n \"purpur-heading\": \"_purpur-heading_k9fhq_1\",\n \"purpur-heading--hyphens\": \"_purpur-heading--hyphens_k9fhq_8\",\n \"purpur-heading--negative\": \"_purpur-heading--negative_k9fhq_11\",\n \"purpur-heading--subsection-100\": \"_purpur-heading--subsection-100_k9fhq_14\",\n \"purpur-heading--title-100\": \"_purpur-heading--title-100_k9fhq_20\",\n \"purpur-heading--title-200\": \"_purpur-heading--title-200_k9fhq_26\",\n \"purpur-heading--title-300\": \"_purpur-heading--title-300_k9fhq_32\",\n \"purpur-heading--title-400\": \"_purpur-heading--title-400_k9fhq_38\",\n \"purpur-heading--title-500\": \"_purpur-heading--title-500_k9fhq_44\",\n \"purpur-heading--title-600\": \"_purpur-heading--title-600_k9fhq_50\",\n \"purpur-heading--title-700\": \"_purpur-heading--title-700_k9fhq_56\",\n \"purpur-heading--display-25\": \"_purpur-heading--display-25_k9fhq_62\",\n \"purpur-heading--display-50\": \"_purpur-heading--display-50_k9fhq_68\",\n \"purpur-heading--display-100\": \"_purpur-heading--display-100_k9fhq_74\",\n \"purpur-heading--display-200\": \"_purpur-heading--display-200_k9fhq_80\"\n}, k = {\n H1: \"h1\",\n H2: \"h2\",\n H3: \"h3\",\n H4: \"h4\",\n H5: \"h5\",\n H6: \"h6\"\n}, T = {\n TITLE100: \"title-100\",\n TITLE200: \"title-200\",\n TITLE300: \"title-300\",\n TITLE400: \"title-400\",\n TITLE500: \"title-500\",\n TITLE600: \"title-600\",\n TITLE700: \"title-700\",\n SUBSECTION100: \"subsection-100\"\n}, I = {\n DISPLAY25: \"display-25\",\n DISPLAY50: \"display-50\",\n DISPLAY100: \"display-100\",\n DISPLAY200: \"display-200\"\n}, a = \"purpur-heading\", q = ({\n children: t,\n className: s = \"\",\n enableHyphenation: n = !1,\n negative: h = !1,\n tag: p,\n variant: e = T.TITLE100,\n ...r\n}) => {\n const i = p, o = y([\n s,\n u[a],\n u[`${a}--${e}`],\n {\n [u[`${a}--hyphens`]]: n,\n [u[`${a}--negative`]]: h\n }\n ]);\n return /* @__PURE__ */ _(i, { className: o, ...r, children: t });\n};\nq.displayName = \"Heading\";\nexport {\n I as DisplayVariant,\n q as Heading,\n k as HeadingTag,\n T as TitleVariant\n};\n//# sourceMappingURL=heading.es.js.map\n","/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import { jsx as a } from \"react/jsx-runtime\";\nfunction f(r) {\n return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, \"default\") ? r.default : r;\n}\nvar c = { exports: {} };\n/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\nvar p;\nfunction m() {\n return p || (p = 1, function(r) {\n (function() {\n var e = {}.hasOwnProperty;\n function o() {\n for (var t = \"\", n = 0; n < arguments.length; n++) {\n var s = arguments[n];\n s && (t = i(t, u.call(this, s)));\n }\n return t;\n }\n function u(t) {\n if (typeof t == \"string\" || typeof t == \"number\")\n return this && this[t] || t;\n if (typeof t != \"object\")\n return \"\";\n if (Array.isArray(t))\n return o.apply(this, t);\n if (t.toString !== Object.prototype.toString && !t.toString.toString().includes(\"[native code]\"))\n return t.toString();\n var n = \"\";\n for (var s in t)\n e.call(t, s) && t[s] && (n = i(n, this && this[s] || s));\n return n;\n }\n function i(t, n) {\n return n ? t ? t + \" \" + n : t + n : t;\n }\n r.exports ? (o.default = o, r.exports = o) : window.classNames = o;\n })();\n }(c)), c.exports;\n}\nvar _ = m();\nconst d = /* @__PURE__ */ f(_), v = {\n \"purpur-icon\": \"_purpur-icon_8u1lq_1\",\n \"purpur-icon--xxs\": \"_purpur-icon--xxs_8u1lq_4\",\n \"purpur-icon--xs\": \"_purpur-icon--xs_8u1lq_8\",\n \"purpur-icon--sm\": \"_purpur-icon--sm_8u1lq_12\",\n \"purpur-icon--md\": \"_purpur-icon--md_8u1lq_16\",\n \"purpur-icon--lg\": \"_purpur-icon--lg_8u1lq_20\",\n \"purpur-icon--xl\": \"_purpur-icon--xl_8u1lq_24\"\n}, g = d.bind(v), l = \"purpur-icon\", x = \"md\", h = (r) => r.filter((e) => Object.keys(e).length >= 1).map((e) => `${e.name}=\"${e.value}\"`).join(\" \"), y = ({ content: r = \"\", title: e } = {}) => {\n const o = [\n { name: \"xmlns\", value: \"http://www.w3.org/2000/svg\" },\n { name: \"fill\", value: \"currentColor\" },\n { name: \"viewBox\", value: \"0 0 24 24\" },\n e ? { name: \"role\", value: \"img\" } : { name: \"aria-hidden\", value: \"true\" }\n ], u = e ? `<title>${e}</title>` : \"\";\n return `<svg ${h(o)}>${u}${r}</svg>`;\n}, S = (r) => r.replace(/<(\\/?)svg([^>]*)>/g, \"\").trim(), b = ({\n [\"data-testid\"]: r,\n svg: e,\n allyTitle: o,\n className: u,\n size: i = x,\n ...t\n}) => {\n const n = y({\n content: S(e.svg),\n title: o\n }), s = g(u, l, `${l}--${i}`);\n return /* @__PURE__ */ a(\n \"span\",\n {\n className: s,\n \"data-testid\": r,\n dangerouslySetInnerHTML: { __html: n },\n ...t\n }\n );\n};\nb.displayName = \"Icon\";\nexport {\n b as I\n};\n//# sourceMappingURL=icon-BqK8slmm.mjs.map\n","import { jsx as l } from \"react/jsx-runtime\";\nimport { I as e } from \"../icon-BqK8slmm.mjs\";\nconst s = {\n name: \"close\",\n svg: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M4.864 4.864a.9.9 0 0 1 1.273 0L12 10.727l5.864-5.863a.9.9 0 0 1 1.272 1.272L13.273 12l5.863 5.864a.9.9 0 1 1-1.272 1.272L12 13.273l-5.863 5.863a.9.9 0 0 1-1.273-1.272L10.727 12 4.864 6.136a.9.9 0 0 1 0-1.272Z\" clip-rule=\"evenodd\"/></svg>',\n keywords: [\"close\"],\n category: \"utility\"\n}, r = (o) => /* @__PURE__ */ l(e, { ...o, svg: s });\nr.displayName = \"IconClose\";\nexport {\n r as IconClose\n};\n//# sourceMappingURL=close.es.js.map\n","import React, { MouseEvent, ReactNode } from \"react\";\nimport { IconClose } from \"@purpurds/icon/close\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./dismissable-chip-group.module.scss\";\nconst cx = c.bind(styles);\n\nexport type DismissableChipGroupItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n [\"aria-label\"]: string;\n [\"data-testid\"]?: string;\n children: ReactNode;\n id?: string;\n onDismiss?: (id?: string) => void;\n};\n\nconst rootClassName = \"purpur-dismissable-chip-group-item\";\n\nexport const DismissableChipGroupItem = ({\n children,\n id,\n onDismiss,\n disabled,\n ...props\n}: DismissableChipGroupItemProps) => {\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n e.preventDefault();\n } else {\n onDismiss?.(id);\n }\n };\n\n return (\n <li key={id} className={cx(`${rootClassName}-wrapper`)}>\n <button\n {...props}\n className={cx(`${rootClassName}`, {\n [`${rootClassName}--disabled`]: disabled,\n })}\n key={id}\n disabled={disabled}\n aria-disabled={disabled}\n onClick={handleClick}\n >\n {children}\n <IconClose size=\"sm\" />\n </button>\n </li>\n );\n};\n\nDismissableChipGroupItem.displayName = \"DismissableChipGroupItem\";\n","import React, { ReactNode, useId } from \"react\";\nimport { Heading, HeadingTagType } from \"@purpurds/heading\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./dismissable-chip-group.module.scss\";\nimport { DismissableChipGroupItem } from \"./dismissable-chip-group-item\";\nconst cx = c.bind(styles);\n\nexport type DismissableChipGroupProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n fullWidth?: boolean;\n title?: string;\n titleTag?: HeadingTagType;\n};\n\nconst rootClassName = \"purpur-dismissable-chip-group\";\n\nexport const DismissableChipGroup = ({\n children,\n className,\n fullWidth = false,\n title,\n titleTag,\n ...props\n}: DismissableChipGroupProps) => {\n const id = useId();\n const classes = cx([className, rootClassName]);\n\n return (\n <div\n {...props}\n aria-labelledby={title ? `${id}-label` : undefined}\n className={classes}\n role=\"group\"\n >\n {title && (\n <Heading tag={titleTag ?? \"h2\"} variant=\"subsection-100\">\n {title}\n </Heading>\n )}\n <ul\n data-testid=\"dismissable-chip-group-container\"\n className={cx(`${rootClassName}__container`, {\n [`${rootClassName}__container--full-width`]: fullWidth,\n })}\n aria-live=\"polite\"\n aria-relevant=\"additions removals\"\n >\n {children}\n </ul>\n </div>\n );\n};\n\nDismissableChipGroup.Item = DismissableChipGroupItem;\n\nDismissableChipGroup.displayName = \"DismissableChipGroup\";\n"],"names":["f","t","l","d","g","s","n","e","r","i","p","h","c","y","u","T","a","q","o","_","hasOwn","classNames","classes","arg","appendClass","parseValue","key","value","newClass","module","m","v","x","S","b","cx","styles","rootClassName","DismissableChipGroupItem","children","id","onDismiss","disabled","props","handleClick","createElement","jsx","IconClose","DismissableChipGroup","className","fullWidth","title","titleTag","useId","jsxs","Heading"],"mappings":"wIACA,SAASA,EAAEC,EAAG,CACZ,OAAOA,GAAKA,EAAE,YAAc,OAAO,UAAU,eAAe,KAAKA,EAAG,SAAS,EAAIA,EAAE,QAAUA,CAC/F,CACA,IAAIC,EAAI,CAAE,QAAS,EAAI,EACvB;AAAA;AAAA;AAAA;AAAA,EAKA,IAAIC,EACJ,SAASC,GAAI,CACX,OAAOD,IAAMA,EAAI,EAAG,SAASF,EAAG,EAC7B,UAAW,CACV,IAAII,EAAI,CAAA,EAAG,eACX,SAASC,GAAI,CACX,QAASC,EAAI,GAAIC,EAAI,EAAGA,EAAI,UAAU,OAAQA,IAAK,CACjD,IAAIC,EAAI,UAAUD,CAAC,EACnBC,IAAMF,EAAIG,EAAEH,EAAGI,EAAEF,CAAC,CAAC,EAC7B,CACQ,OAAOF,CACf,CACM,SAASI,EAAEJ,EAAG,CACZ,GAAI,OAAOA,GAAK,UAAY,OAAOA,GAAK,SACtC,OAAOA,EACT,GAAI,OAAOA,GAAK,SACd,MAAO,GACT,GAAI,MAAM,QAAQA,CAAC,EACjB,OAAOD,EAAE,MAAM,KAA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,EACD,YAAU,SACV,gBAAc,qBAEb,SAAAX,CAAA,CAAA,CACH,CAAA,CACF,CAEJ,EAEAS,EAAqB,KAAOV,EAE5BU,EAAqB,YAAc","x_google_ignoreList":[1]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
|
+
import { HeadingTagType } from '@purpurds/heading';
|
|
3
|
+
|
|
4
|
+
export type DismissableChipGroupProps = {
|
|
5
|
+
["data-testid"]?: string;
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
fullWidth?: boolean;
|
|
9
|
+
title?: string;
|
|
10
|
+
titleTag?: HeadingTagType;
|
|
11
|
+
};
|
|
12
|
+
export declare const DismissableChipGroup: {
|
|
13
|
+
({ children, className, fullWidth, title, titleTag, ...props }: DismissableChipGroupProps): React.JSX.Element;
|
|
14
|
+
Item: {
|
|
15
|
+
({ children, id, onDismiss, disabled, ...props }: import('./dismissable-chip-group-item').DismissableChipGroupItemProps): React.JSX.Element;
|
|
16
|
+
displayName: string;
|
|
17
|
+
};
|
|
18
|
+
displayName: string;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=dismissable-chip-group.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismissable-chip-group.d.ts","sourceRoot":"","sources":["../src/dismissable-chip-group.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,SAAS,EAAS,MAAM,OAAO,CAAC;AAChD,OAAO,EAAW,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAO5D,MAAM,MAAM,yBAAyB,GAAG;IACtC,CAAC,aAAa,CAAC,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B,CAAC;AAIF,eAAO,MAAM,oBAAoB;oEAO9B,yBAAyB;;;;;;CA4B3B,CAAC"}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import { jsx as s, jsxs as C } from "react/jsx-runtime";
|
|
2
|
+
import { createElement as I, useId as L } from "react";
|
|
3
|
+
function T(i) {
|
|
4
|
+
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
5
|
+
}
|
|
6
|
+
var _ = { exports: {} };
|
|
7
|
+
/*!
|
|
8
|
+
Copyright (c) 2018 Jed Watson.
|
|
9
|
+
Licensed under the MIT License (MIT), see
|
|
10
|
+
http://jedwatson.github.io/classnames
|
|
11
|
+
*/
|
|
12
|
+
var f;
|
|
13
|
+
function A() {
|
|
14
|
+
return f || (f = 1, function(i) {
|
|
15
|
+
(function() {
|
|
16
|
+
var u = {}.hasOwnProperty;
|
|
17
|
+
function t() {
|
|
18
|
+
for (var r = "", e = 0; e < arguments.length; e++) {
|
|
19
|
+
var n = arguments[e];
|
|
20
|
+
n && (r = a(r, p(n)));
|
|
21
|
+
}
|
|
22
|
+
return r;
|
|
23
|
+
}
|
|
24
|
+
function p(r) {
|
|
25
|
+
if (typeof r == "string" || typeof r == "number")
|
|
26
|
+
return r;
|
|
27
|
+
if (typeof r != "object")
|
|
28
|
+
return "";
|
|
29
|
+
if (Array.isArray(r))
|
|
30
|
+
return t.apply(null, r);
|
|
31
|
+
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
32
|
+
return r.toString();
|
|
33
|
+
var e = "";
|
|
34
|
+
for (var n in r)
|
|
35
|
+
u.call(r, n) && r[n] && (e = a(e, n));
|
|
36
|
+
return e;
|
|
37
|
+
}
|
|
38
|
+
function a(r, e) {
|
|
39
|
+
return e ? r ? r + " " + e : r + e : r;
|
|
40
|
+
}
|
|
41
|
+
i.exports ? (t.default = t, i.exports = t) : window.classNames = t;
|
|
42
|
+
})();
|
|
43
|
+
}(_)), _.exports;
|
|
44
|
+
}
|
|
45
|
+
var P = A();
|
|
46
|
+
const E = /* @__PURE__ */ T(P), o = {
|
|
47
|
+
"purpur-heading": "_purpur-heading_k9fhq_1",
|
|
48
|
+
"purpur-heading--hyphens": "_purpur-heading--hyphens_k9fhq_8",
|
|
49
|
+
"purpur-heading--negative": "_purpur-heading--negative_k9fhq_11",
|
|
50
|
+
"purpur-heading--subsection-100": "_purpur-heading--subsection-100_k9fhq_14",
|
|
51
|
+
"purpur-heading--title-100": "_purpur-heading--title-100_k9fhq_20",
|
|
52
|
+
"purpur-heading--title-200": "_purpur-heading--title-200_k9fhq_26",
|
|
53
|
+
"purpur-heading--title-300": "_purpur-heading--title-300_k9fhq_32",
|
|
54
|
+
"purpur-heading--title-400": "_purpur-heading--title-400_k9fhq_38",
|
|
55
|
+
"purpur-heading--title-500": "_purpur-heading--title-500_k9fhq_44",
|
|
56
|
+
"purpur-heading--title-600": "_purpur-heading--title-600_k9fhq_50",
|
|
57
|
+
"purpur-heading--title-700": "_purpur-heading--title-700_k9fhq_56",
|
|
58
|
+
"purpur-heading--display-25": "_purpur-heading--display-25_k9fhq_62",
|
|
59
|
+
"purpur-heading--display-50": "_purpur-heading--display-50_k9fhq_68",
|
|
60
|
+
"purpur-heading--display-100": "_purpur-heading--display-100_k9fhq_74",
|
|
61
|
+
"purpur-heading--display-200": "_purpur-heading--display-200_k9fhq_80"
|
|
62
|
+
}, M = {
|
|
63
|
+
TITLE100: "title-100"
|
|
64
|
+
}, l = "purpur-heading", w = ({
|
|
65
|
+
children: i,
|
|
66
|
+
className: u = "",
|
|
67
|
+
enableHyphenation: t = !1,
|
|
68
|
+
negative: p = !1,
|
|
69
|
+
tag: a,
|
|
70
|
+
variant: r = M.TITLE100,
|
|
71
|
+
...e
|
|
72
|
+
}) => {
|
|
73
|
+
const n = a, O = E([
|
|
74
|
+
u,
|
|
75
|
+
o[l],
|
|
76
|
+
o[`${l}--${r}`],
|
|
77
|
+
{
|
|
78
|
+
[o[`${l}--hyphens`]]: t,
|
|
79
|
+
[o[`${l}--negative`]]: p
|
|
80
|
+
}
|
|
81
|
+
]);
|
|
82
|
+
return /* @__PURE__ */ s(n, { className: O, ...e, children: i });
|
|
83
|
+
};
|
|
84
|
+
w.displayName = "Heading";
|
|
85
|
+
function B(i) {
|
|
86
|
+
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
87
|
+
}
|
|
88
|
+
var c = { exports: {} };
|
|
89
|
+
/*!
|
|
90
|
+
Copyright (c) 2018 Jed Watson.
|
|
91
|
+
Licensed under the MIT License (MIT), see
|
|
92
|
+
http://jedwatson.github.io/classnames
|
|
93
|
+
*/
|
|
94
|
+
var g;
|
|
95
|
+
function G() {
|
|
96
|
+
return g || (g = 1, function(i) {
|
|
97
|
+
(function() {
|
|
98
|
+
var u = {}.hasOwnProperty;
|
|
99
|
+
function t() {
|
|
100
|
+
for (var r = "", e = 0; e < arguments.length; e++) {
|
|
101
|
+
var n = arguments[e];
|
|
102
|
+
n && (r = a(r, p.call(this, n)));
|
|
103
|
+
}
|
|
104
|
+
return r;
|
|
105
|
+
}
|
|
106
|
+
function p(r) {
|
|
107
|
+
if (typeof r == "string" || typeof r == "number")
|
|
108
|
+
return this && this[r] || r;
|
|
109
|
+
if (typeof r != "object")
|
|
110
|
+
return "";
|
|
111
|
+
if (Array.isArray(r))
|
|
112
|
+
return t.apply(this, r);
|
|
113
|
+
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
114
|
+
return r.toString();
|
|
115
|
+
var e = "";
|
|
116
|
+
for (var n in r)
|
|
117
|
+
u.call(r, n) && r[n] && (e = a(e, this && this[n] || n));
|
|
118
|
+
return e;
|
|
119
|
+
}
|
|
120
|
+
function a(r, e) {
|
|
121
|
+
return e ? r ? r + " " + e : r + e : r;
|
|
122
|
+
}
|
|
123
|
+
i.exports ? (t.default = t, i.exports = t) : window.classNames = t;
|
|
124
|
+
})();
|
|
125
|
+
}(c)), c.exports;
|
|
126
|
+
}
|
|
127
|
+
var H = G();
|
|
128
|
+
const $ = /* @__PURE__ */ B(H), q = {
|
|
129
|
+
"purpur-dismissable-chip-group": "_purpur-dismissable-chip-group_15nn8_1",
|
|
130
|
+
"purpur-dismissable-chip-group__container": "_purpur-dismissable-chip-group__container_15nn8_7",
|
|
131
|
+
"purpur-dismissable-chip-group__container--full-width": "_purpur-dismissable-chip-group__container--full-width_15nn8_14",
|
|
132
|
+
"purpur-dismissable-chip-group-item-wrapper": "_purpur-dismissable-chip-group-item-wrapper_15nn8_17",
|
|
133
|
+
"purpur-dismissable-chip-group-item": "_purpur-dismissable-chip-group-item_15nn8_17",
|
|
134
|
+
"purpur-dismissable-chip-group-item--disabled": "_purpur-dismissable-chip-group-item--disabled_15nn8_43"
|
|
135
|
+
};
|
|
136
|
+
function z(i) {
|
|
137
|
+
return i && i.__esModule && Object.prototype.hasOwnProperty.call(i, "default") ? i.default : i;
|
|
138
|
+
}
|
|
139
|
+
var m = { exports: {} };
|
|
140
|
+
/*!
|
|
141
|
+
Copyright (c) 2018 Jed Watson.
|
|
142
|
+
Licensed under the MIT License (MIT), see
|
|
143
|
+
http://jedwatson.github.io/classnames
|
|
144
|
+
*/
|
|
145
|
+
var v;
|
|
146
|
+
function D() {
|
|
147
|
+
return v || (v = 1, function(i) {
|
|
148
|
+
(function() {
|
|
149
|
+
var u = {}.hasOwnProperty;
|
|
150
|
+
function t() {
|
|
151
|
+
for (var r = "", e = 0; e < arguments.length; e++) {
|
|
152
|
+
var n = arguments[e];
|
|
153
|
+
n && (r = a(r, p.call(this, n)));
|
|
154
|
+
}
|
|
155
|
+
return r;
|
|
156
|
+
}
|
|
157
|
+
function p(r) {
|
|
158
|
+
if (typeof r == "string" || typeof r == "number")
|
|
159
|
+
return this && this[r] || r;
|
|
160
|
+
if (typeof r != "object")
|
|
161
|
+
return "";
|
|
162
|
+
if (Array.isArray(r))
|
|
163
|
+
return t.apply(this, r);
|
|
164
|
+
if (r.toString !== Object.prototype.toString && !r.toString.toString().includes("[native code]"))
|
|
165
|
+
return r.toString();
|
|
166
|
+
var e = "";
|
|
167
|
+
for (var n in r)
|
|
168
|
+
u.call(r, n) && r[n] && (e = a(e, this && this[n] || n));
|
|
169
|
+
return e;
|
|
170
|
+
}
|
|
171
|
+
function a(r, e) {
|
|
172
|
+
return e ? r ? r + " " + e : r + e : r;
|
|
173
|
+
}
|
|
174
|
+
i.exports ? (t.default = t, i.exports = t) : window.classNames = t;
|
|
175
|
+
})();
|
|
176
|
+
}(m)), m.exports;
|
|
177
|
+
}
|
|
178
|
+
var F = D();
|
|
179
|
+
const R = /* @__PURE__ */ z(F), V = {
|
|
180
|
+
"purpur-icon": "_purpur-icon_8u1lq_1",
|
|
181
|
+
"purpur-icon--xxs": "_purpur-icon--xxs_8u1lq_4",
|
|
182
|
+
"purpur-icon--xs": "_purpur-icon--xs_8u1lq_8",
|
|
183
|
+
"purpur-icon--sm": "_purpur-icon--sm_8u1lq_12",
|
|
184
|
+
"purpur-icon--md": "_purpur-icon--md_8u1lq_16",
|
|
185
|
+
"purpur-icon--lg": "_purpur-icon--lg_8u1lq_20",
|
|
186
|
+
"purpur-icon--xl": "_purpur-icon--xl_8u1lq_24"
|
|
187
|
+
}, Z = R.bind(V), y = "purpur-icon", J = "md", K = (i) => i.filter((u) => Object.keys(u).length >= 1).map((u) => `${u.name}="${u.value}"`).join(" "), Q = ({ content: i = "", title: u } = {}) => {
|
|
188
|
+
const t = [
|
|
189
|
+
{ name: "xmlns", value: "http://www.w3.org/2000/svg" },
|
|
190
|
+
{ name: "fill", value: "currentColor" },
|
|
191
|
+
{ name: "viewBox", value: "0 0 24 24" },
|
|
192
|
+
u ? { name: "role", value: "img" } : { name: "aria-hidden", value: "true" }
|
|
193
|
+
], p = u ? `<title>${u}</title>` : "";
|
|
194
|
+
return `<svg ${K(t)}>${p}${i}</svg>`;
|
|
195
|
+
}, U = (i) => i.replace(/<(\/?)svg([^>]*)>/g, "").trim(), N = ({
|
|
196
|
+
["data-testid"]: i,
|
|
197
|
+
svg: u,
|
|
198
|
+
allyTitle: t,
|
|
199
|
+
className: p,
|
|
200
|
+
size: a = J,
|
|
201
|
+
...r
|
|
202
|
+
}) => {
|
|
203
|
+
const e = Q({
|
|
204
|
+
content: U(u.svg),
|
|
205
|
+
title: t
|
|
206
|
+
}), n = Z(p, y, `${y}--${a}`);
|
|
207
|
+
return /* @__PURE__ */ s(
|
|
208
|
+
"span",
|
|
209
|
+
{
|
|
210
|
+
className: n,
|
|
211
|
+
"data-testid": i,
|
|
212
|
+
dangerouslySetInnerHTML: { __html: e },
|
|
213
|
+
...r
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
};
|
|
217
|
+
N.displayName = "Icon";
|
|
218
|
+
const W = {
|
|
219
|
+
name: "close",
|
|
220
|
+
svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path fill-rule="evenodd" d="M4.864 4.864a.9.9 0 0 1 1.273 0L12 10.727l5.864-5.863a.9.9 0 0 1 1.272 1.272L13.273 12l5.863 5.864a.9.9 0 1 1-1.272 1.272L12 13.273l-5.863 5.863a.9.9 0 0 1-1.273-1.272L10.727 12 4.864 6.136a.9.9 0 0 1 0-1.272Z" clip-rule="evenodd"/></svg>',
|
|
221
|
+
keywords: ["close"],
|
|
222
|
+
category: "utility"
|
|
223
|
+
}, k = (i) => /* @__PURE__ */ s(N, { ...i, svg: W });
|
|
224
|
+
k.displayName = "IconClose";
|
|
225
|
+
const b = $.bind(q), d = "purpur-dismissable-chip-group-item", S = ({
|
|
226
|
+
children: i,
|
|
227
|
+
id: u,
|
|
228
|
+
onDismiss: t,
|
|
229
|
+
disabled: p,
|
|
230
|
+
...a
|
|
231
|
+
}) => {
|
|
232
|
+
const r = (e) => {
|
|
233
|
+
p ? e.preventDefault() : t == null || t(u);
|
|
234
|
+
};
|
|
235
|
+
return /* @__PURE__ */ s("li", { className: b(`${d}-wrapper`), children: /* @__PURE__ */ I(
|
|
236
|
+
"button",
|
|
237
|
+
{
|
|
238
|
+
...a,
|
|
239
|
+
className: b(`${d}`, {
|
|
240
|
+
[`${d}--disabled`]: p
|
|
241
|
+
}),
|
|
242
|
+
key: u,
|
|
243
|
+
disabled: p,
|
|
244
|
+
"aria-disabled": p,
|
|
245
|
+
onClick: r
|
|
246
|
+
},
|
|
247
|
+
i,
|
|
248
|
+
/* @__PURE__ */ s(k, { size: "sm" })
|
|
249
|
+
) }, u);
|
|
250
|
+
};
|
|
251
|
+
S.displayName = "DismissableChipGroupItem";
|
|
252
|
+
const x = $.bind(q), h = "purpur-dismissable-chip-group", j = ({
|
|
253
|
+
children: i,
|
|
254
|
+
className: u,
|
|
255
|
+
fullWidth: t = !1,
|
|
256
|
+
title: p,
|
|
257
|
+
titleTag: a,
|
|
258
|
+
...r
|
|
259
|
+
}) => {
|
|
260
|
+
const e = L(), n = x([u, h]);
|
|
261
|
+
return /* @__PURE__ */ C(
|
|
262
|
+
"div",
|
|
263
|
+
{
|
|
264
|
+
...r,
|
|
265
|
+
"aria-labelledby": p ? `${e}-label` : void 0,
|
|
266
|
+
className: n,
|
|
267
|
+
role: "group",
|
|
268
|
+
children: [
|
|
269
|
+
p && /* @__PURE__ */ s(w, { tag: a ?? "h2", variant: "subsection-100", children: p }),
|
|
270
|
+
/* @__PURE__ */ s(
|
|
271
|
+
"ul",
|
|
272
|
+
{
|
|
273
|
+
"data-testid": "dismissable-chip-group-container",
|
|
274
|
+
className: x(`${h}__container`, {
|
|
275
|
+
[`${h}__container--full-width`]: t
|
|
276
|
+
}),
|
|
277
|
+
"aria-live": "polite",
|
|
278
|
+
"aria-relevant": "additions removals",
|
|
279
|
+
children: i
|
|
280
|
+
}
|
|
281
|
+
)
|
|
282
|
+
]
|
|
283
|
+
}
|
|
284
|
+
);
|
|
285
|
+
};
|
|
286
|
+
j.Item = S;
|
|
287
|
+
j.displayName = "DismissableChipGroup";
|
|
288
|
+
export {
|
|
289
|
+
j as DismissableChipGroup
|
|
290
|
+
};
|
|
291
|
+
//# sourceMappingURL=dismissable-chip-group.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dismissable-chip-group.es.js","sources":["../../heading/dist/heading.es.js","../../../common/temp/node_modules/.pnpm/classnames@2.5.1/node_modules/classnames/bind.js","../../icon/dist/icon-BqK8slmm.mjs","../../icon/dist/components/close.es.js","../src/dismissable-chip-group-item.tsx","../src/dismissable-chip-group.tsx"],"sourcesContent":["import { jsx as _ } from \"react/jsx-runtime\";\nfunction f(t) {\n return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, \"default\") ? t.default : t;\n}\nvar l = { exports: {} };\n/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\nvar d;\nfunction g() {\n return d || (d = 1, function(t) {\n (function() {\n var s = {}.hasOwnProperty;\n function n() {\n for (var e = \"\", r = 0; r < arguments.length; r++) {\n var i = arguments[r];\n i && (e = p(e, h(i)));\n }\n return e;\n }\n function h(e) {\n if (typeof e == \"string\" || typeof e == \"number\")\n return e;\n if (typeof e != \"object\")\n return \"\";\n if (Array.isArray(e))\n return n.apply(null, e);\n if (e.toString !== Object.prototype.toString && !e.toString.toString().includes(\"[native code]\"))\n return e.toString();\n var r = \"\";\n for (var i in e)\n s.call(e, i) && e[i] && (r = p(r, i));\n return r;\n }\n function p(e, r) {\n return r ? e ? e + \" \" + r : e + r : e;\n }\n t.exports ? (n.default = n, t.exports = n) : window.classNames = n;\n })();\n }(l)), l.exports;\n}\nvar c = g();\nconst y = /* @__PURE__ */ f(c), u = {\n \"purpur-heading\": \"_purpur-heading_k9fhq_1\",\n \"purpur-heading--hyphens\": \"_purpur-heading--hyphens_k9fhq_8\",\n \"purpur-heading--negative\": \"_purpur-heading--negative_k9fhq_11\",\n \"purpur-heading--subsection-100\": \"_purpur-heading--subsection-100_k9fhq_14\",\n \"purpur-heading--title-100\": \"_purpur-heading--title-100_k9fhq_20\",\n \"purpur-heading--title-200\": \"_purpur-heading--title-200_k9fhq_26\",\n \"purpur-heading--title-300\": \"_purpur-heading--title-300_k9fhq_32\",\n \"purpur-heading--title-400\": \"_purpur-heading--title-400_k9fhq_38\",\n \"purpur-heading--title-500\": \"_purpur-heading--title-500_k9fhq_44\",\n \"purpur-heading--title-600\": \"_purpur-heading--title-600_k9fhq_50\",\n \"purpur-heading--title-700\": \"_purpur-heading--title-700_k9fhq_56\",\n \"purpur-heading--display-25\": \"_purpur-heading--display-25_k9fhq_62\",\n \"purpur-heading--display-50\": \"_purpur-heading--display-50_k9fhq_68\",\n \"purpur-heading--display-100\": \"_purpur-heading--display-100_k9fhq_74\",\n \"purpur-heading--display-200\": \"_purpur-heading--display-200_k9fhq_80\"\n}, k = {\n H1: \"h1\",\n H2: \"h2\",\n H3: \"h3\",\n H4: \"h4\",\n H5: \"h5\",\n H6: \"h6\"\n}, T = {\n TITLE100: \"title-100\",\n TITLE200: \"title-200\",\n TITLE300: \"title-300\",\n TITLE400: \"title-400\",\n TITLE500: \"title-500\",\n TITLE600: \"title-600\",\n TITLE700: \"title-700\",\n SUBSECTION100: \"subsection-100\"\n}, I = {\n DISPLAY25: \"display-25\",\n DISPLAY50: \"display-50\",\n DISPLAY100: \"display-100\",\n DISPLAY200: \"display-200\"\n}, a = \"purpur-heading\", q = ({\n children: t,\n className: s = \"\",\n enableHyphenation: n = !1,\n negative: h = !1,\n tag: p,\n variant: e = T.TITLE100,\n ...r\n}) => {\n const i = p, o = y([\n s,\n u[a],\n u[`${a}--${e}`],\n {\n [u[`${a}--hyphens`]]: n,\n [u[`${a}--negative`]]: h\n }\n ]);\n return /* @__PURE__ */ _(i, { className: o, ...r, children: t });\n};\nq.displayName = \"Heading\";\nexport {\n I as DisplayVariant,\n q as Heading,\n k as HeadingTag,\n T as TitleVariant\n};\n//# sourceMappingURL=heading.es.js.map\n","/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\n/* global define */\n\n(function () {\n\t'use strict';\n\n\tvar hasOwn = {}.hasOwnProperty;\n\n\tfunction classNames () {\n\t\tvar classes = '';\n\n\t\tfor (var i = 0; i < arguments.length; i++) {\n\t\t\tvar arg = arguments[i];\n\t\t\tif (arg) {\n\t\t\t\tclasses = appendClass(classes, parseValue.call(this, arg));\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction parseValue (arg) {\n\t\tif (typeof arg === 'string' || typeof arg === 'number') {\n\t\t\treturn this && this[arg] || arg;\n\t\t}\n\n\t\tif (typeof arg !== 'object') {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (Array.isArray(arg)) {\n\t\t\treturn classNames.apply(this, arg);\n\t\t}\n\n\t\tif (arg.toString !== Object.prototype.toString && !arg.toString.toString().includes('[native code]')) {\n\t\t\treturn arg.toString();\n\t\t}\n\n\t\tvar classes = '';\n\n\t\tfor (var key in arg) {\n\t\t\tif (hasOwn.call(arg, key) && arg[key]) {\n\t\t\t\tclasses = appendClass(classes, this && this[key] || key);\n\t\t\t}\n\t\t}\n\n\t\treturn classes;\n\t}\n\n\tfunction appendClass (value, newClass) {\n\t\tif (!newClass) {\n\t\t\treturn value;\n\t\t}\n\t\n\t\tif (value) {\n\t\t\treturn value + ' ' + newClass;\n\t\t}\n\t\n\t\treturn value + newClass;\n\t}\n\n\tif (typeof module !== 'undefined' && module.exports) {\n\t\tclassNames.default = classNames;\n\t\tmodule.exports = classNames;\n\t} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {\n\t\t// register as 'classnames', consistent with npm package name\n\t\tdefine('classnames', [], function () {\n\t\t\treturn classNames;\n\t\t});\n\t} else {\n\t\twindow.classNames = classNames;\n\t}\n}());\n","import { jsx as a } from \"react/jsx-runtime\";\nfunction f(r) {\n return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, \"default\") ? r.default : r;\n}\nvar c = { exports: {} };\n/*!\n\tCopyright (c) 2018 Jed Watson.\n\tLicensed under the MIT License (MIT), see\n\thttp://jedwatson.github.io/classnames\n*/\nvar p;\nfunction m() {\n return p || (p = 1, function(r) {\n (function() {\n var e = {}.hasOwnProperty;\n function o() {\n for (var t = \"\", n = 0; n < arguments.length; n++) {\n var s = arguments[n];\n s && (t = i(t, u.call(this, s)));\n }\n return t;\n }\n function u(t) {\n if (typeof t == \"string\" || typeof t == \"number\")\n return this && this[t] || t;\n if (typeof t != \"object\")\n return \"\";\n if (Array.isArray(t))\n return o.apply(this, t);\n if (t.toString !== Object.prototype.toString && !t.toString.toString().includes(\"[native code]\"))\n return t.toString();\n var n = \"\";\n for (var s in t)\n e.call(t, s) && t[s] && (n = i(n, this && this[s] || s));\n return n;\n }\n function i(t, n) {\n return n ? t ? t + \" \" + n : t + n : t;\n }\n r.exports ? (o.default = o, r.exports = o) : window.classNames = o;\n })();\n }(c)), c.exports;\n}\nvar _ = m();\nconst d = /* @__PURE__ */ f(_), v = {\n \"purpur-icon\": \"_purpur-icon_8u1lq_1\",\n \"purpur-icon--xxs\": \"_purpur-icon--xxs_8u1lq_4\",\n \"purpur-icon--xs\": \"_purpur-icon--xs_8u1lq_8\",\n \"purpur-icon--sm\": \"_purpur-icon--sm_8u1lq_12\",\n \"purpur-icon--md\": \"_purpur-icon--md_8u1lq_16\",\n \"purpur-icon--lg\": \"_purpur-icon--lg_8u1lq_20\",\n \"purpur-icon--xl\": \"_purpur-icon--xl_8u1lq_24\"\n}, g = d.bind(v), l = \"purpur-icon\", x = \"md\", h = (r) => r.filter((e) => Object.keys(e).length >= 1).map((e) => `${e.name}=\"${e.value}\"`).join(\" \"), y = ({ content: r = \"\", title: e } = {}) => {\n const o = [\n { name: \"xmlns\", value: \"http://www.w3.org/2000/svg\" },\n { name: \"fill\", value: \"currentColor\" },\n { name: \"viewBox\", value: \"0 0 24 24\" },\n e ? { name: \"role\", value: \"img\" } : { name: \"aria-hidden\", value: \"true\" }\n ], u = e ? `<title>${e}</title>` : \"\";\n return `<svg ${h(o)}>${u}${r}</svg>`;\n}, S = (r) => r.replace(/<(\\/?)svg([^>]*)>/g, \"\").trim(), b = ({\n [\"data-testid\"]: r,\n svg: e,\n allyTitle: o,\n className: u,\n size: i = x,\n ...t\n}) => {\n const n = y({\n content: S(e.svg),\n title: o\n }), s = g(u, l, `${l}--${i}`);\n return /* @__PURE__ */ a(\n \"span\",\n {\n className: s,\n \"data-testid\": r,\n dangerouslySetInnerHTML: { __html: n },\n ...t\n }\n );\n};\nb.displayName = \"Icon\";\nexport {\n b as I\n};\n//# sourceMappingURL=icon-BqK8slmm.mjs.map\n","import { jsx as l } from \"react/jsx-runtime\";\nimport { I as e } from \"../icon-BqK8slmm.mjs\";\nconst s = {\n name: \"close\",\n svg: '<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path fill-rule=\"evenodd\" d=\"M4.864 4.864a.9.9 0 0 1 1.273 0L12 10.727l5.864-5.863a.9.9 0 0 1 1.272 1.272L13.273 12l5.863 5.864a.9.9 0 1 1-1.272 1.272L12 13.273l-5.863 5.863a.9.9 0 0 1-1.273-1.272L10.727 12 4.864 6.136a.9.9 0 0 1 0-1.272Z\" clip-rule=\"evenodd\"/></svg>',\n keywords: [\"close\"],\n category: \"utility\"\n}, r = (o) => /* @__PURE__ */ l(e, { ...o, svg: s });\nr.displayName = \"IconClose\";\nexport {\n r as IconClose\n};\n//# sourceMappingURL=close.es.js.map\n","import React, { MouseEvent, ReactNode } from \"react\";\nimport { IconClose } from \"@purpurds/icon/close\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./dismissable-chip-group.module.scss\";\nconst cx = c.bind(styles);\n\nexport type DismissableChipGroupItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {\n [\"aria-label\"]: string;\n [\"data-testid\"]?: string;\n children: ReactNode;\n id?: string;\n onDismiss?: (id?: string) => void;\n};\n\nconst rootClassName = \"purpur-dismissable-chip-group-item\";\n\nexport const DismissableChipGroupItem = ({\n children,\n id,\n onDismiss,\n disabled,\n ...props\n}: DismissableChipGroupItemProps) => {\n const handleClick = (e: MouseEvent<HTMLButtonElement>) => {\n if (disabled) {\n e.preventDefault();\n } else {\n onDismiss?.(id);\n }\n };\n\n return (\n <li key={id} className={cx(`${rootClassName}-wrapper`)}>\n <button\n {...props}\n className={cx(`${rootClassName}`, {\n [`${rootClassName}--disabled`]: disabled,\n })}\n key={id}\n disabled={disabled}\n aria-disabled={disabled}\n onClick={handleClick}\n >\n {children}\n <IconClose size=\"sm\" />\n </button>\n </li>\n );\n};\n\nDismissableChipGroupItem.displayName = \"DismissableChipGroupItem\";\n","import React, { ReactNode, useId } from \"react\";\nimport { Heading, HeadingTagType } from \"@purpurds/heading\";\nimport c from \"classnames/bind\";\n\nimport styles from \"./dismissable-chip-group.module.scss\";\nimport { DismissableChipGroupItem } from \"./dismissable-chip-group-item\";\nconst cx = c.bind(styles);\n\nexport type DismissableChipGroupProps = {\n [\"data-testid\"]?: string;\n children: ReactNode;\n className?: string;\n fullWidth?: boolean;\n title?: string;\n titleTag?: HeadingTagType;\n};\n\nconst rootClassName = \"purpur-dismissable-chip-group\";\n\nexport const DismissableChipGroup = ({\n children,\n className,\n fullWidth = false,\n title,\n titleTag,\n ...props\n}: DismissableChipGroupProps) => {\n const id = useId();\n const classes = cx([className, rootClassName]);\n\n return (\n <div\n {...props}\n aria-labelledby={title ? `${id}-label` : undefined}\n className={classes}\n role=\"group\"\n >\n {title && (\n <Heading tag={titleTag ?? \"h2\"} variant=\"subsection-100\">\n {title}\n </Heading>\n )}\n <ul\n data-testid=\"dismissable-chip-group-container\"\n className={cx(`${rootClassName}__container`, {\n [`${rootClassName}__container--full-width`]: fullWidth,\n })}\n aria-live=\"polite\"\n aria-relevant=\"additions removals\"\n >\n {children}\n </ul>\n </div>\n );\n};\n\nDismissableChipGroup.Item = DismissableChipGroupItem;\n\nDismissableChipGroup.displayName = \"DismissableChipGroup\";\n"],"names":["f","t","l","d","g","s","n","e","r","i","p","h","c","y","u","T","a","q","o","_","hasOwn","classNames","classes","arg","appendClass","parseValue","key","value","newClass","module","m","v","x","S","b","cx","styles","rootClassName","DismissableChipGroupItem","children","id","onDismiss","disabled","props","handleClick","createElement","jsx","IconClose","DismissableChipGroup","className","fullWidth","title","titleTag","useId","jsxs","Heading"],"mappings":";;AACA,SAASA,EAAEC,GAAG;AACZ,SAAOA,KAAKA,EAAE,cAAc,OAAO,UAAU,eAAe,KAAKA,GAAG,SAAS,IAAIA,EAAE,UAAUA;AAC/F;AACA,IAAIC,IAAI,EAAE,SAAS,GAAI;AACvB;AAAA;AAAA;AAAA;AAAA;AAKA,IAAIC;AACJ,SAASC,IAAI;AACX,SAAOD,MAAMA,IAAI,GAAG,SAASF,GAAG;AAC9B,KAAC,WAAW;AACV,UAAII,IAAI,CAAA,EAAG;AACX,eAASC,IAAI;AACX,iBAASC,IAAI,IAAIC,IAAI,GAAGA,IAAI,UAAU,QAAQA,KAAK;AACjD,cAAIC,IAAI,UAAUD,CAAC;AACnB,UAAAC,MAAMF,IAAIG,EAAEH,GAAGI,EAAEF,CAAC,CAAC;AAAA,QAC7B;AACQ,eAAOF;AAAA,MACf;AACM,eAASI,EAAEJ,GAAG;AACZ,YAAI,OAAOA,KAAK,YAAY,OAAOA,KAAK;AACtC,iBAAOA;AACT,YAAI,OAAOA,KAAK;AACd,iBAAO;AACT,YAAI,MAAM,QAAQA,CAAC;AACjB,iBAAOD,EAAE,MAAM,MAAMC,CAAC;AACxB,YAAIA,EAAE,aAAa,OAAO,UAAU,YAAY,CAACA,EAAE,SAAS,WAAW,SAAS,eAAe;AAC7F,iBAAOA,EAAE,SAAU;AACrB,YAAIC,IAAI;AACR,iBAASC,KAAKF;AACZ,UAAAF,EAAE,KAAKE,GAAGE,CAAC,KAAKF,EAAEE,CAAC,MAAMD,IAAIE,EAAEF,GAAGC,CAAC;AACrC,eAAOD;AAAA,MACf;AACM,eAASE,EAAEH,GAAGC,GAA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AC;AAAA,EACA,UAAAC;AAAA,EACA,GAAGT;AACL,MAAiC;AAC/B,QAAMH,IAAKa,EAAM,GACX/B,IAAUa,EAAG,CAACc,GAAWZ,CAAa,CAAC;AAG3C,SAAA,gBAAAiB;AAAA,IAAC;AAAA,IAAA;AAAA,MACE,GAAGX;AAAA,MACJ,mBAAiBQ,IAAQ,GAAGX,CAAE,WAAW;AAAA,MACzC,WAAWlB;AAAA,MACX,MAAK;AAAA,MAEJ,UAAA;AAAA,QAAA6B,uBACEI,GAAQ,EAAA,KAAKH,KAAY,MAAM,SAAQ,kBACrC,UACHD,EAAA,CAAA;AAAA,QAEF,gBAAAL;AAAA,UAAC;AAAA,UAAA;AAAA,YACC,eAAY;AAAA,YACZ,WAAWX,EAAG,GAAGE,CAAa,eAAe;AAAA,cAC3C,CAAC,GAAGA,CAAa,yBAAyB,GAAGa;AAAA,YAAA,CAC9C;AAAA,YACD,aAAU;AAAA,YACV,iBAAc;AAAA,YAEb,UAAAX;AAAA,UAAA;AAAA,QAAA;AAAA,MACH;AAAA,IAAA;AAAA,EACF;AAEJ;AAEAS,EAAqB,OAAOV;AAE5BU,EAAqB,cAAc;","x_google_ignoreList":[1]}
|
package/dist/metadata.js
ADDED
package/dist/styles.css
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._purpur-dismissable-chip-group_15nn8_1{display:flex;flex-direction:column;gap:var(--purpur-spacing-150);align-items:flex-start}._purpur-dismissable-chip-group__container_15nn8_7{display:flex;flex-wrap:wrap;margin:0;padding:0;gap:var(--purpur-spacing-200)}._purpur-dismissable-chip-group__container--full-width_15nn8_14{width:100%}._purpur-dismissable-chip-group__container--full-width_15nn8_14 ._purpur-dismissable-chip-group-item-wrapper_15nn8_17{flex-grow:1}._purpur-dismissable-chip-group__container--full-width_15nn8_14 ._purpur-dismissable-chip-group-item_15nn8_17{width:100%}._purpur-dismissable-chip-group-item_15nn8_17{position:relative;display:inline-flex;justify-content:center;align-items:center;gap:var(--purpur-spacing-100);padding:calc(var(--purpur-spacing-10) * 10 - var(--purpur-border-width-xs)) calc(var(--purpur-spacing-200) - var(--purpur-border-width-xs));border:var(--purpur-border-width-xs) solid var(--purpur-color-border-interactive-primary);border-radius:var(--purpur-border-radius-md);background:var(--purpur-color-background-interactive-transparent);color:var(--purpur-color-text-interactive-primary);font-family:var(--purpur-typography-family-default);font-size:var(--purpur-typography-scale-100);line-height:var(--purpur-typography-line-height-loose);font-weight:var(--purpur-typography-weight-normal);list-style:none;cursor:pointer;transition:background var(--purpur-motion-duration-100) ease,color var(--purpur-motion-duration-100) ease,border-color var(--purpur-motion-duration-100) ease}._purpur-dismissable-chip-group-item--disabled_15nn8_43{border-color:var(--purpur-color-border-medium);color:var(--purpur-color-text-weak);cursor:not-allowed}._purpur-dismissable-chip-group-item_15nn8_17:hover:not(._purpur-dismissable-chip-group-item--disabled_15nn8_43){padding:calc(var(--purpur-spacing-10) * 10 - var(--purpur-border-width-sm)) calc(var(--purpur-spacing-200) - var(--purpur-border-width-sm));border-width:var(--purpur-border-width-sm);border-color:var(--purpur-color-border-interactive-primary-hover);background:var(--purpur-color-background-interactive-transparent-hover);color:var(--purpur-color-text-interactive-primary-hover)}._purpur-dismissable-chip-group-item_15nn8_17:active:not(._purpur-dismissable-chip-group-item--disabled_15nn8_43){border-color:var(--purpur-color-border-interactive-primary-active);background:var(--purpur-color-background-interactive-transparent-active);color:var(--purpur-color-text-interactive-primary-active)}._purpur-dismissable-chip-group-item_15nn8_17:focus{outline:0}._purpur-dismissable-chip-group-item_15nn8_17:focus:focus-visible:after{content:"";position:absolute;inset:calc(-1 * (var(--purpur-border-width-sm) * 2 + var(--purpur-border-width-xs)));border-radius:var(--purpur-spacing-150);border:var(--purpur-border-width-sm) solid var(--purpur-color-border-interactive-focus)}._purpur-dismissable-chip-group-item-wrapper_15nn8_17{list-style:none}
|
package/package.json
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@purpurds/dismissable-chip-group",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"license": "AGPL-3.0-only",
|
|
5
|
+
"main": "./dist/dismissable-chip-group.cjs.js",
|
|
6
|
+
"types": "./dist/dismissable-chip-group.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"require": "./dist/dismissable-chip-group.cjs.js",
|
|
10
|
+
"types": "./dist/dismissable-chip-group.d.ts",
|
|
11
|
+
"default": "./dist/dismissable-chip-group.es.js"
|
|
12
|
+
},
|
|
13
|
+
"./styles": "./dist/styles.css",
|
|
14
|
+
"./metadata": "./dist/metadata.js"
|
|
15
|
+
},
|
|
16
|
+
"source": "src/dismissable-chip-group.tsx",
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"classnames": "~2.5.0",
|
|
19
|
+
"@purpurds/tokens": "7.0.0",
|
|
20
|
+
"@purpurds/heading": "7.0.0",
|
|
21
|
+
"@purpurds/icon": "7.0.0"
|
|
22
|
+
},
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@rushstack/eslint-patch": "~1.10.0",
|
|
25
|
+
"@storybook/blocks": "^8.6.4",
|
|
26
|
+
"@storybook/react": "^8.6.4",
|
|
27
|
+
"@testing-library/dom": "~10.4.0",
|
|
28
|
+
"@testing-library/jest-dom": "~6.4.0",
|
|
29
|
+
"@testing-library/react": "~16.2.0",
|
|
30
|
+
"@types/node": "20.12.12",
|
|
31
|
+
"@types/react-dom": "^19.0.4",
|
|
32
|
+
"@types/react": "^19.0.10",
|
|
33
|
+
"eslint": "9.24.0",
|
|
34
|
+
"jsdom": "~22.1.0",
|
|
35
|
+
"lint-staged": "15.5.0",
|
|
36
|
+
"prettier": "~2.8.8",
|
|
37
|
+
"react-dom": "^19.0.0",
|
|
38
|
+
"react": "^19.0.0",
|
|
39
|
+
"storybook": "^8.6.4",
|
|
40
|
+
"typescript": "^5.6.3",
|
|
41
|
+
"vite": "^6.2.1",
|
|
42
|
+
"vitest": "^3.1.2",
|
|
43
|
+
"@purpurds/button": "7.0.0",
|
|
44
|
+
"@purpurds/component-rig": "1.0.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@types/react": "^18 || ^19",
|
|
48
|
+
"@types/react-dom": "^18 || ^19",
|
|
49
|
+
"react": "^18 || ^19",
|
|
50
|
+
"react-dom": "^18 || ^19"
|
|
51
|
+
},
|
|
52
|
+
"peerDependenciesMeta": {
|
|
53
|
+
"@types/react": {
|
|
54
|
+
"optional": true
|
|
55
|
+
},
|
|
56
|
+
"@types/react-dom": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build:dev": "vite",
|
|
62
|
+
"build:watch": "vite build --watch",
|
|
63
|
+
"build": "vite build",
|
|
64
|
+
"ci:build": "rushx build",
|
|
65
|
+
"coverage": "vitest run --coverage",
|
|
66
|
+
"lint:fix": "eslint . --fix",
|
|
67
|
+
"lint": "lint-staged --no-stash 2>&1",
|
|
68
|
+
"sbdev": "rush sbdev",
|
|
69
|
+
"test:unit": "vitest run --passWithNoTests",
|
|
70
|
+
"test:watch": "vitest --watch",
|
|
71
|
+
"test": "rushx test:unit",
|
|
72
|
+
"typecheck": "tsc -p ./tsconfig.json"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import React, { MouseEvent, ReactNode } from "react";
|
|
2
|
+
import { IconClose } from "@purpurds/icon/close";
|
|
3
|
+
import c from "classnames/bind";
|
|
4
|
+
|
|
5
|
+
import styles from "./dismissable-chip-group.module.scss";
|
|
6
|
+
const cx = c.bind(styles);
|
|
7
|
+
|
|
8
|
+
export type DismissableChipGroupItemProps = React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
9
|
+
["aria-label"]: string;
|
|
10
|
+
["data-testid"]?: string;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
id?: string;
|
|
13
|
+
onDismiss?: (id?: string) => void;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const rootClassName = "purpur-dismissable-chip-group-item";
|
|
17
|
+
|
|
18
|
+
export const DismissableChipGroupItem = ({
|
|
19
|
+
children,
|
|
20
|
+
id,
|
|
21
|
+
onDismiss,
|
|
22
|
+
disabled,
|
|
23
|
+
...props
|
|
24
|
+
}: DismissableChipGroupItemProps) => {
|
|
25
|
+
const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
|
|
26
|
+
if (disabled) {
|
|
27
|
+
e.preventDefault();
|
|
28
|
+
} else {
|
|
29
|
+
onDismiss?.(id);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<li key={id} className={cx(`${rootClassName}-wrapper`)}>
|
|
35
|
+
<button
|
|
36
|
+
{...props}
|
|
37
|
+
className={cx(`${rootClassName}`, {
|
|
38
|
+
[`${rootClassName}--disabled`]: disabled,
|
|
39
|
+
})}
|
|
40
|
+
key={id}
|
|
41
|
+
disabled={disabled}
|
|
42
|
+
aria-disabled={disabled}
|
|
43
|
+
onClick={handleClick}
|
|
44
|
+
>
|
|
45
|
+
{children}
|
|
46
|
+
<IconClose size="sm" />
|
|
47
|
+
</button>
|
|
48
|
+
</li>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
DismissableChipGroupItem.displayName = "DismissableChipGroupItem";
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
.purpur-dismissable-chip-group {
|
|
2
|
+
$root: &;
|
|
3
|
+
display: flex;
|
|
4
|
+
flex-direction: column;
|
|
5
|
+
gap: var(--purpur-spacing-150);
|
|
6
|
+
align-items: flex-start;
|
|
7
|
+
|
|
8
|
+
&__container {
|
|
9
|
+
display: flex;
|
|
10
|
+
flex-wrap: wrap;
|
|
11
|
+
margin: 0;
|
|
12
|
+
padding: 0;
|
|
13
|
+
gap: var(--purpur-spacing-200);
|
|
14
|
+
|
|
15
|
+
&--full-width {
|
|
16
|
+
width: 100%;
|
|
17
|
+
|
|
18
|
+
#{$root}-item-wrapper {
|
|
19
|
+
flex-grow: 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
#{$root}-item {
|
|
23
|
+
width: 100%;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.purpur-dismissable-chip-group-item {
|
|
30
|
+
$root: &;
|
|
31
|
+
position: relative;
|
|
32
|
+
display: inline-flex;
|
|
33
|
+
justify-content: center;
|
|
34
|
+
align-items: center;
|
|
35
|
+
gap: var(--purpur-spacing-100);
|
|
36
|
+
padding: calc((var(--purpur-spacing-10) * 10) - var(--purpur-border-width-xs))
|
|
37
|
+
calc(var(--purpur-spacing-200) - var(--purpur-border-width-xs));
|
|
38
|
+
border: var(--purpur-border-width-xs) solid var(--purpur-color-border-interactive-primary);
|
|
39
|
+
border-radius: var(--purpur-border-radius-md);
|
|
40
|
+
background: var(--purpur-color-background-interactive-transparent);
|
|
41
|
+
color: var(--purpur-color-text-interactive-primary);
|
|
42
|
+
font-family: var(--purpur-typography-family-default);
|
|
43
|
+
font-size: var(--purpur-typography-scale-100);
|
|
44
|
+
line-height: var(--purpur-typography-line-height-loose);
|
|
45
|
+
font-weight: var(--purpur-typography-weight-normal);
|
|
46
|
+
list-style: none;
|
|
47
|
+
cursor: pointer;
|
|
48
|
+
transition: background var(--purpur-motion-duration-100) ease,
|
|
49
|
+
color var(--purpur-motion-duration-100) ease,
|
|
50
|
+
border-color var(--purpur-motion-duration-100) ease;
|
|
51
|
+
|
|
52
|
+
&--disabled {
|
|
53
|
+
border-color: var(--purpur-color-border-medium);
|
|
54
|
+
color: var(--purpur-color-text-weak);
|
|
55
|
+
cursor: not-allowed;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
&:hover:not(#{$root}--disabled) {
|
|
59
|
+
padding: calc((var(--purpur-spacing-10) * 10) - var(--purpur-border-width-sm))
|
|
60
|
+
calc(var(--purpur-spacing-200) - var(--purpur-border-width-sm));
|
|
61
|
+
border-width: var(--purpur-border-width-sm);
|
|
62
|
+
border-color: var(--purpur-color-border-interactive-primary-hover);
|
|
63
|
+
background: var(--purpur-color-background-interactive-transparent-hover);
|
|
64
|
+
color: var(--purpur-color-text-interactive-primary-hover);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
&:active:not(#{$root}--disabled) {
|
|
68
|
+
border-color: var(--purpur-color-border-interactive-primary-active);
|
|
69
|
+
background: var(--purpur-color-background-interactive-transparent-active);
|
|
70
|
+
color: var(--purpur-color-text-interactive-primary-active);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
&:focus {
|
|
74
|
+
outline: 0;
|
|
75
|
+
|
|
76
|
+
&:focus-visible::after {
|
|
77
|
+
content: "";
|
|
78
|
+
position: absolute;
|
|
79
|
+
inset: calc(-1 * calc((var(--purpur-border-width-sm) * 2) + var(--purpur-border-width-xs)));
|
|
80
|
+
border-radius: var(--purpur-spacing-150);
|
|
81
|
+
border: var(--purpur-border-width-sm) solid var(--purpur-color-border-interactive-focus);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.purpur-dismissable-chip-group-item-wrapper {
|
|
87
|
+
list-style: none;
|
|
88
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Button } from "@purpurds/button";
|
|
3
|
+
import type { Meta, StoryObj } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import "@purpurds/button/styles";
|
|
6
|
+
import "@purpurds/heading/styles";
|
|
7
|
+
import "@purpurds/icon/styles";
|
|
8
|
+
import { DismissableChipGroup } from "./dismissable-chip-group";
|
|
9
|
+
|
|
10
|
+
const meta = {
|
|
11
|
+
title: "Inputs/DismissableChipGroup",
|
|
12
|
+
component: DismissableChipGroup,
|
|
13
|
+
parameters: {
|
|
14
|
+
design: [
|
|
15
|
+
{
|
|
16
|
+
name: "DismissableChipGroup",
|
|
17
|
+
type: "figma",
|
|
18
|
+
url: "https://www.figma.com/design/XEaIIFskrrxIBHMZDkIuIg/Purpur-DS---Component-library---guidelines?node-id=1190-108&p=f&t=CotI9ZkeWvGgJKgd-0",
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
},
|
|
22
|
+
subcomponents: {
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
24
|
+
//@ts-ignore
|
|
25
|
+
"DismissableChipGroup.Item": DismissableChipGroup.Item,
|
|
26
|
+
},
|
|
27
|
+
} satisfies Meta<typeof DismissableChipGroup>;
|
|
28
|
+
|
|
29
|
+
export default meta;
|
|
30
|
+
|
|
31
|
+
export const Showcase: StoryObj<typeof DismissableChipGroup> = {
|
|
32
|
+
args: {
|
|
33
|
+
fullWidth: false,
|
|
34
|
+
title: "Optional DismissableChipGroup title",
|
|
35
|
+
titleTag: "h2",
|
|
36
|
+
"data-testid": "dismissable-chip-group",
|
|
37
|
+
},
|
|
38
|
+
render: (args) => {
|
|
39
|
+
const { ...rest } = args;
|
|
40
|
+
|
|
41
|
+
const items = [
|
|
42
|
+
{
|
|
43
|
+
id: "1",
|
|
44
|
+
label: "Chip 1",
|
|
45
|
+
disabled: false,
|
|
46
|
+
"aria-label": "Press to remove the filter Chip 1",
|
|
47
|
+
"data-testid": "item-1",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
id: "2",
|
|
51
|
+
label: "Chip 2",
|
|
52
|
+
disabled: false,
|
|
53
|
+
"aria-label": "Press to remove the filter Chip 2",
|
|
54
|
+
"data-testid": "item-2",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: "3",
|
|
58
|
+
label: "Chip 3",
|
|
59
|
+
disabled: true,
|
|
60
|
+
"aria-label": "Press to remove the filter Chip 3",
|
|
61
|
+
"data-testid": "item-3",
|
|
62
|
+
},
|
|
63
|
+
];
|
|
64
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
65
|
+
const [chipItems, setChipItems] = useState(items);
|
|
66
|
+
|
|
67
|
+
const onDismiss = (id?: string) => {
|
|
68
|
+
setChipItems((prevItems) => prevItems.filter((item) => item.id !== id));
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<DismissableChipGroup {...rest}>
|
|
73
|
+
{chipItems.map((chipItem) => (
|
|
74
|
+
<DismissableChipGroup.Item
|
|
75
|
+
key={chipItem.id}
|
|
76
|
+
id={chipItem.id}
|
|
77
|
+
disabled={chipItem.disabled}
|
|
78
|
+
aria-label={chipItem["aria-label"]}
|
|
79
|
+
data-testid={chipItem["data-testid"]}
|
|
80
|
+
onDismiss={onDismiss}
|
|
81
|
+
>
|
|
82
|
+
{chipItem.label}
|
|
83
|
+
</DismissableChipGroup.Item>
|
|
84
|
+
))}
|
|
85
|
+
</DismissableChipGroup>
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
tags: ["visual:check"],
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
export const BulkActions: StoryObj<typeof DismissableChipGroup> = {
|
|
92
|
+
args: {
|
|
93
|
+
fullWidth: false,
|
|
94
|
+
},
|
|
95
|
+
render: (args) => {
|
|
96
|
+
const { ...rest } = args;
|
|
97
|
+
|
|
98
|
+
const items = [
|
|
99
|
+
{
|
|
100
|
+
id: "1",
|
|
101
|
+
label: "Chip 1",
|
|
102
|
+
disabled: false,
|
|
103
|
+
"aria-label": "Press to remove the filter Chip 1",
|
|
104
|
+
"data-testid": "item-1",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "2",
|
|
108
|
+
label: "Chip 2",
|
|
109
|
+
disabled: false,
|
|
110
|
+
"aria-label": "Press to remove the filter Chip 2",
|
|
111
|
+
"data-testid": "item-2",
|
|
112
|
+
},
|
|
113
|
+
];
|
|
114
|
+
|
|
115
|
+
// eslint-disable-next-line react-hooks/rules-of-hooks
|
|
116
|
+
const [chipItems, setChipItems] = useState(items);
|
|
117
|
+
|
|
118
|
+
const onDismiss = (id?: string) => {
|
|
119
|
+
setChipItems((prevItems) => prevItems.filter((item) => item.id !== id));
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
return (
|
|
123
|
+
<div>
|
|
124
|
+
<Button
|
|
125
|
+
aria-label="Press to clear all chips"
|
|
126
|
+
variant="text"
|
|
127
|
+
onClick={() => {
|
|
128
|
+
setChipItems([]);
|
|
129
|
+
}}
|
|
130
|
+
>
|
|
131
|
+
Clear All
|
|
132
|
+
</Button>
|
|
133
|
+
<DismissableChipGroup {...rest}>
|
|
134
|
+
{chipItems.map((chipItem) => (
|
|
135
|
+
<DismissableChipGroup.Item
|
|
136
|
+
key={chipItem.id}
|
|
137
|
+
id={chipItem.id}
|
|
138
|
+
disabled={chipItem.disabled}
|
|
139
|
+
aria-label={chipItem["aria-label"]}
|
|
140
|
+
data-testid={chipItem["data-testid"]}
|
|
141
|
+
onDismiss={onDismiss}
|
|
142
|
+
>
|
|
143
|
+
{chipItem.label}
|
|
144
|
+
</DismissableChipGroup.Item>
|
|
145
|
+
))}
|
|
146
|
+
</DismissableChipGroup>
|
|
147
|
+
<Button
|
|
148
|
+
aria-label="Press to reset all chips"
|
|
149
|
+
variant="text"
|
|
150
|
+
onClick={() => {
|
|
151
|
+
setChipItems(items);
|
|
152
|
+
}}
|
|
153
|
+
>
|
|
154
|
+
Reset
|
|
155
|
+
</Button>
|
|
156
|
+
</div>
|
|
157
|
+
);
|
|
158
|
+
},
|
|
159
|
+
tags: ["visual:check"],
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const DismissableChipGroupItem: StoryObj<typeof DismissableChipGroup.Item> = {
|
|
163
|
+
args: {
|
|
164
|
+
["aria-label"]: "Press to remove the filter Chip 1",
|
|
165
|
+
["data-testid"]: "item-1",
|
|
166
|
+
id: "chip-item-1",
|
|
167
|
+
disabled: false,
|
|
168
|
+
onDismiss: (id) => {
|
|
169
|
+
console.log(`Chip "${id}" clicked`);
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
render: (args) => {
|
|
173
|
+
const { id, disabled, onDismiss, ...rest } = args;
|
|
174
|
+
|
|
175
|
+
return (
|
|
176
|
+
<DismissableChipGroup.Item
|
|
177
|
+
{...rest}
|
|
178
|
+
key={id}
|
|
179
|
+
id={id}
|
|
180
|
+
disabled={disabled}
|
|
181
|
+
onDismiss={onDismiss}
|
|
182
|
+
>
|
|
183
|
+
Chip 1
|
|
184
|
+
</DismissableChipGroup.Item>
|
|
185
|
+
);
|
|
186
|
+
},
|
|
187
|
+
tags: ["visual:check"],
|
|
188
|
+
};
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import * as matchers from "@testing-library/jest-dom/matchers";
|
|
3
|
+
import { cleanup, render, screen } from "@testing-library/react";
|
|
4
|
+
import { afterEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
|
|
6
|
+
import { DismissableChipGroup } from "./dismissable-chip-group";
|
|
7
|
+
|
|
8
|
+
expect.extend(matchers);
|
|
9
|
+
|
|
10
|
+
describe("DismissableChipGroup", () => {
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
cleanup();
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it("should render chips with correct text content", () => {
|
|
16
|
+
render(
|
|
17
|
+
<DismissableChipGroup>
|
|
18
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1">
|
|
19
|
+
Chip 1
|
|
20
|
+
</DismissableChipGroup.Item>
|
|
21
|
+
</DismissableChipGroup>
|
|
22
|
+
);
|
|
23
|
+
expect(screen.getByTestId("chip-1")).toHaveTextContent("Chip 1");
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("should render with a title and items", () => {
|
|
27
|
+
render(
|
|
28
|
+
<DismissableChipGroup title="Test Title">
|
|
29
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1">
|
|
30
|
+
Chip 1
|
|
31
|
+
</DismissableChipGroup.Item>
|
|
32
|
+
</DismissableChipGroup>
|
|
33
|
+
);
|
|
34
|
+
expect(screen.getByText("Test Title")).toBeInTheDocument();
|
|
35
|
+
expect(screen.getByTestId("chip-1")).toHaveTextContent("Chip 1");
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("should call onDismiss with the correct id when a chip is dismissed", () => {
|
|
39
|
+
const onDismissMock = vi.fn();
|
|
40
|
+
render(
|
|
41
|
+
<DismissableChipGroup>
|
|
42
|
+
<DismissableChipGroup.Item
|
|
43
|
+
id="chip-1"
|
|
44
|
+
aria-label="Chip 1"
|
|
45
|
+
data-testid="chip-1"
|
|
46
|
+
onDismiss={onDismissMock}
|
|
47
|
+
>
|
|
48
|
+
Chip 1
|
|
49
|
+
</DismissableChipGroup.Item>
|
|
50
|
+
</DismissableChipGroup>
|
|
51
|
+
);
|
|
52
|
+
screen.getByTestId("chip-1").click();
|
|
53
|
+
expect(onDismissMock).toHaveBeenCalledWith("chip-1");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("should apply full-width class when fullWidth is true", () => {
|
|
57
|
+
const { container } = render(
|
|
58
|
+
<DismissableChipGroup fullWidth>
|
|
59
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1">
|
|
60
|
+
Chip 1
|
|
61
|
+
</DismissableChipGroup.Item>
|
|
62
|
+
</DismissableChipGroup>
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
// Find the inner container div
|
|
66
|
+
const innerContainer = container.querySelector(".purpur-dismissable-chip-group__container");
|
|
67
|
+
|
|
68
|
+
// Assert that the full-width class is applied
|
|
69
|
+
expect(innerContainer).toHaveClass("purpur-dismissable-chip-group__container--full-width");
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("should render disabled chips with correct attributes", () => {
|
|
73
|
+
render(
|
|
74
|
+
<DismissableChipGroup>
|
|
75
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1" disabled>
|
|
76
|
+
Chip 1
|
|
77
|
+
</DismissableChipGroup.Item>
|
|
78
|
+
</DismissableChipGroup>
|
|
79
|
+
);
|
|
80
|
+
const chip = screen.getByTestId("chip-1");
|
|
81
|
+
expect(chip).toBeDisabled();
|
|
82
|
+
expect(chip).toHaveAttribute("aria-disabled", "true");
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("should set aria-labelledby correctly when a title is provided", () => {
|
|
86
|
+
render(
|
|
87
|
+
<DismissableChipGroup title="Test Title">
|
|
88
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1">
|
|
89
|
+
Chip 1
|
|
90
|
+
</DismissableChipGroup.Item>
|
|
91
|
+
</DismissableChipGroup>
|
|
92
|
+
);
|
|
93
|
+
const container = screen.getByRole("group");
|
|
94
|
+
expect(container).toHaveAttribute("aria-labelledby");
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
it("should not set aria-labelledby when no title is provided", () => {
|
|
98
|
+
render(
|
|
99
|
+
<DismissableChipGroup>
|
|
100
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1">
|
|
101
|
+
Chip 1
|
|
102
|
+
</DismissableChipGroup.Item>
|
|
103
|
+
</DismissableChipGroup>
|
|
104
|
+
);
|
|
105
|
+
const container = screen.getByRole("group");
|
|
106
|
+
expect(container).not.toHaveAttribute("aria-labelledby");
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
it("should not call onDismiss when a disabled chip is clicked", () => {
|
|
110
|
+
const onDismissMock = vi.fn();
|
|
111
|
+
render(
|
|
112
|
+
<DismissableChipGroup>
|
|
113
|
+
<DismissableChipGroup.Item
|
|
114
|
+
id="chip-1"
|
|
115
|
+
aria-label="Chip 1"
|
|
116
|
+
data-testid="chip-1"
|
|
117
|
+
onDismiss={onDismissMock}
|
|
118
|
+
disabled
|
|
119
|
+
>
|
|
120
|
+
Chip 1
|
|
121
|
+
</DismissableChipGroup.Item>
|
|
122
|
+
</DismissableChipGroup>
|
|
123
|
+
);
|
|
124
|
+
screen.getByTestId("chip-1").click();
|
|
125
|
+
expect(onDismissMock).not.toHaveBeenCalled();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it("should render multiple chips correctly", () => {
|
|
129
|
+
render(
|
|
130
|
+
<>
|
|
131
|
+
<DismissableChipGroup>
|
|
132
|
+
<DismissableChipGroup.Item id="chip-1" aria-label="Chip 1" data-testid="chip-1">
|
|
133
|
+
Chip 1
|
|
134
|
+
</DismissableChipGroup.Item>
|
|
135
|
+
</DismissableChipGroup>
|
|
136
|
+
<DismissableChipGroup>
|
|
137
|
+
<DismissableChipGroup.Item id="chip-2" aria-label="Chip 2" data-testid="chip-2">
|
|
138
|
+
Chip 2
|
|
139
|
+
</DismissableChipGroup.Item>
|
|
140
|
+
</DismissableChipGroup>
|
|
141
|
+
<DismissableChipGroup>
|
|
142
|
+
<DismissableChipGroup.Item id="chip-3" aria-label="Chip 3" data-testid="chip-3">
|
|
143
|
+
Chip 3
|
|
144
|
+
</DismissableChipGroup.Item>
|
|
145
|
+
</DismissableChipGroup>
|
|
146
|
+
</>
|
|
147
|
+
);
|
|
148
|
+
expect(screen.getByTestId("chip-1")).toHaveTextContent("Chip 1");
|
|
149
|
+
expect(screen.getByTestId("chip-2")).toHaveTextContent("Chip 2");
|
|
150
|
+
expect(screen.getByTestId("chip-3")).toHaveTextContent("Chip 3");
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React, { ReactNode, useId } from "react";
|
|
2
|
+
import { Heading, HeadingTagType } from "@purpurds/heading";
|
|
3
|
+
import c from "classnames/bind";
|
|
4
|
+
|
|
5
|
+
import styles from "./dismissable-chip-group.module.scss";
|
|
6
|
+
import { DismissableChipGroupItem } from "./dismissable-chip-group-item";
|
|
7
|
+
const cx = c.bind(styles);
|
|
8
|
+
|
|
9
|
+
export type DismissableChipGroupProps = {
|
|
10
|
+
["data-testid"]?: string;
|
|
11
|
+
children: ReactNode;
|
|
12
|
+
className?: string;
|
|
13
|
+
fullWidth?: boolean;
|
|
14
|
+
title?: string;
|
|
15
|
+
titleTag?: HeadingTagType;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const rootClassName = "purpur-dismissable-chip-group";
|
|
19
|
+
|
|
20
|
+
export const DismissableChipGroup = ({
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
fullWidth = false,
|
|
24
|
+
title,
|
|
25
|
+
titleTag,
|
|
26
|
+
...props
|
|
27
|
+
}: DismissableChipGroupProps) => {
|
|
28
|
+
const id = useId();
|
|
29
|
+
const classes = cx([className, rootClassName]);
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<div
|
|
33
|
+
{...props}
|
|
34
|
+
aria-labelledby={title ? `${id}-label` : undefined}
|
|
35
|
+
className={classes}
|
|
36
|
+
role="group"
|
|
37
|
+
>
|
|
38
|
+
{title && (
|
|
39
|
+
<Heading tag={titleTag ?? "h2"} variant="subsection-100">
|
|
40
|
+
{title}
|
|
41
|
+
</Heading>
|
|
42
|
+
)}
|
|
43
|
+
<ul
|
|
44
|
+
data-testid="dismissable-chip-group-container"
|
|
45
|
+
className={cx(`${rootClassName}__container`, {
|
|
46
|
+
[`${rootClassName}__container--full-width`]: fullWidth,
|
|
47
|
+
})}
|
|
48
|
+
aria-live="polite"
|
|
49
|
+
aria-relevant="additions removals"
|
|
50
|
+
>
|
|
51
|
+
{children}
|
|
52
|
+
</ul>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
DismissableChipGroup.Item = DismissableChipGroupItem;
|
|
58
|
+
|
|
59
|
+
DismissableChipGroup.displayName = "DismissableChipGroup";
|
package/src/global.d.ts
ADDED